Contact us
Leave a message

Please use:

My public cryptographic key


Member of

Bit Noise

Data transfer C64 <=> PET via datasette

After purchasing a used CBM 3032, the question arose how all those BASIC games I painstakingly typed in during my school days could be resurrected from their hibernation on floppy disk. Fortunately I was able to recover the old Datasette 1530 I initially got with my C64 (back when floppy disk drives cost the equivalent of about 500 € and for a single 5 1/4 inch floppy disk you had to pay some 5 €!). Since this tape memory device should be compatible with both machines, it was self-evident to come up with a workflow as follows:

Disk drive 1541 --> C64 --> Datasette 1530 --> CMB 3032

Not so fast!

When loading a BASIC program into the C64's memory (when omitting the secondary address or setting it to 0), it will be loaded to $0801, which is the start address of the so-called BASIC RAM. This also works with those PET programs, although the PET's BASIC RAM starts at $0401.

What an unpleasant surprise when I learned that the old PETs are incapable of relocating a BASIC program! After loading PET programs into the C64, saving them to tape and subsequently loading them into the PET, they there ended up at $0801, too -- instead of $0401! The PET obviously acts the fool and just uses the two-byte file header as target address, even for BASIC programs loaded as such.

To Rescue...

...came the C64's very flexible memory management functions, which allowed to re-configre it to basically act like a PET. In particular, the BASIC start address can be shifted to $0401, and even the video RAM can be moved from $0400 to a PET-typical $8000.

How it works:

After defining some constants (line 100), the VIC's memory bank #2 (binary: %10) gets selected in line 110. (Note, however, that bits 0 and 1 in the CIA 2's data port A register have inverse meaning, hence OR with %01.). In line 120, the upper nibble of the VIC base address register gets cleared in order to redirect the video RAM directly to the selected memory bank's start (at $8000). Line 130 tells the OS about this change, so that commands like PRINT (or the BSOUT routine, to be precise) still actually write to the screen. In line 140, the NMI vector gets redirected to an RTI opcode in order to suppress RUN-STOP/RESTORE. In the three following lines, start (150) and end (170) of the BASIC RAM area gets moved, taking into account that the BASIC interpreter expects a 0 immediately preceding the BASIC start. From line 200 onward, some PET-like color settings are chosen (pitty, though, that the C64's green is somewhat pale and that its characters are rather ugly). Finally, NEW is called in line 230, having the effect that CLR gets implicitly called and all variable pointers get adjusted to the altered memory layout (which will anyway render the program code inaccessible for the editor after running the program).