ROM1 DISK MAGIC V1.2 by Jason Cook
Finally! The ability for a Commodore PET ROM1 computer to be able to use DISK (IEEE-488) devices! This also gives the ability to use SD and wifi based devices (links at bottom).
Update: Version 1.2 compatible with bitfixer's PETdisk MAX v2. The load operation is now closer to the full STATUS implementation provided by ROM 4. This allows for both PETdisk MAX SD and Network LOAD operations.
Download: #^https://www.insanerocketry.com/personal/rom1diskmagic.zipSimply load and run the program from tape cassette and voilà! The ability to load from disk with no decrease in memory footprint. The lack of memory footprint is critical on 8K systems, as many programs and games use every byte of program space.
This is accomplished by utilizing buffer space for tape#2, so it is disabled.
If you need SAVE capability, the patch utilizes 75 bytes at the top of program space.
Video:#^https://www.youtube.com/watch?v=nA95gQia7sM3 minutes 40 secondsBACKGROUND:This code's concept was derived from the original IEEE-488 ROM 1 patch written by André Fachat and ROM 1 disassembly.
I wanted my Commodore PET ROM 1 computer to be able to use new IEEE-488 SD/wifi devices so I started with looking at André Fachat's ROM patch. I was looking for a solution that did not require replacing a ROM, as ideally I want to keep my Commodore PET stock.
TECHNICAL:Like André's code, LOAD and VERIFY mostly returns OK. You must review the ST (status) BASIC variable to get the result or read location $20c. Bit 6 set indicates end of file reached, which is a good indicator. You may also want to check any of the bits 4, 5, 7 set, as any would indicate error.
Quick test BASIC:
IF ((ST) AND 64)>0 THEN REM SUCCESS CODE HERE
Quick test Assembler:
LDA $20C
AND # $40 ;(bit 6) indicates end of file reached, NON ZERO means success.
ASSEMBLY:While BASIC programs should work fine, if you want to use the upgraded SAVE and LOAD from assembly language, first test to see if the patch has been applied by checking $c2+$2=# $03, $c2+$3=# $2c, and tapebuffer2+$a=# $03
1.2 CHANGE - UNFORTUNATELY CHECK tapebuffer2+$8 HAD TO BE CHANGED TO tapebuffer2+$a
TEST FOR PATCH EXAMPLE:
tapebuffer2 = $33a
LDA $C2+$2
CMP # $0c
BNE NOTPATCHED
LDA $C2+$3
CMP # $2c
BNE NOTPATCHED
LDA tapebuffer2+$a
CMP # $03
BNE NOTPATCHED
PATCH IS IDENTIFIED AND ACTIVE
On test success, JMP addresses are as follows:
JSR tapebuffer2+0: LOAD/VERIFY low level address.
Make sure to initialize.
FA(device number)
SA(secondary address)
LFN(logical file number)
FNLEN(file length)
OSPTR(filename)
VERFL(0=LOAD)
1.2 CHANGE FROM tapebuffer2+$3 TO tapebuffer2+$5, and First TEST LOCATION CHANGED TOO
JSR tapebuffer2+$5: (First TEST tapebuffer2+$8 = # $20, SAVE code enabled.)
SAVE low level address.
Make sure to initialize.
FA(device number)
SA(secondary address)
LFN(logical file number)
FNLEN(file length)
OSPTR(filename)
SADDR(start address of save)
EADDR(end address of save)
For reference, native equivalents to above JMP locations:
rom1load = $f362
rom2load = $f322
rom4load = $f356
rom1save = $f6b1
rom2save = $f6a4
rom4save = $f6e3
* rom2 and rom 4 have different locations for
FA, SA, LFN, FNLEN, OSPTR, SADDR, EADDR
rom2 and rom4 share the same locations for those variables.
---
Commodore PET ROM1 Disk ROM Replacement
I decided to also make a ROM 1 Patch as it only requires a single ROM replacement at H4.
Note: Not fully compatible with PETDisk MAX yet.
This is a ROM 1 patch to support disk (IEEE-488) compatibility with only burning and changing the ROM ($F000-$F7FF) H4 in an original ROM 1 Commodore PET.
To use, with computer off and proper grounding, replace ROM in slot H4 with ROM1DiskROM.bin. This product is excellent for doing so:
#^https://www.tindie.com/products/nivagswedna/replacement-pet-rom-6540-pre-programmed/ you must select custom provide the ROM as well as location $F000-F7FF (H4)
This code's concept was derived from the original IEEE-488 ROM 1 patch written by André Fachat and ROM 1 disassembly. Vossi then created a single ROM replacement for $F000-F7FF and this is an enhancement of that concept.
Changes and Improvements: Only 4 error messages shortened rather than 7. Patch code simplified due to larger continuous space availability.
My shortened error messages are:
# = too many files (never called by any ROM code, as far as I can see)
OPEN = file open
NOPN = file not open
DEVNP = device not present
Vossi's original shortened error message reduction were:
TMF = too many files (never called by any ROM, as far as I can see)
OPEN = file open
FNF = file not found
DEVNP = device not present
NIF = not input file
NOF = not output file
T = on tape #
The original patch written by André Fachat is quite impressive as he kept memory matching exact, but used memory areas between $EF00-$EFFF for the patches. Vossi created a nice solution by putting André's patch code between shortened error messages, while keeping the original pointers to the error messages exactly the same.
I was able to reclaim the unused code that André's patch orphaned at iF71C.
Of the four error messages reduced, I can't find where the ROM calls "Too many files", so there are only three shortened error messages that an end user would see.
Like André's code, LOAD and VERIFY mostly returns OK. You must review the ST (status) BASIC variable to get the result or read location $20c. Bit 6 set indicates end of file reached, which is a good indicator. You may also want to any of the bits 4, 5, 7 set, as any would indicate error.
Quick test BASIC:
IF ((ST) AND 64)>0 THEN REM SUCCESS CODE HERE
Quick test Assembler:
LDA $20C
AND # $40 ;(bit 6) indicates end of file reached, NON ZERO means success.
While I have tested, the code could use another pair of eyes to make sure nothing looks or behaves different from André's original patch.
Assembler used: ca65
#^https://cc65.github.io/doc/cl65.html :
cl65 -o THISFILENAME.bin -t none -l THISFILENAME.lst THISFILENAME.s
SD Based Hardware#^https://www.thefuturewas8bit.com/shop/commodore/sd2pet-future.html#^https://bitfixer.com/product/petdisk-max/ (this also gives access to files via wifi)
Tindy - NivagSwedna ROM 6540 Replacement#^https://www.tindie.com/products/nivagswedna/replacement-pet-rom-6540-pre-programmed/Contact me: jason at insanerocketry dot com
Other PET project:
#^https://hub.inktada.com/channel/toweranddragon