;BIOS65 ;6502 portion of BIOS for C64 CP/M ;miscellaneous definitions CR = $0D carriage return LF = $0A line feed ;C64 memory LSTX = $C5 current key pressed QTSW = $D4 quote mode flag 0 = no ;C64 KERNAL entry points KEY = $FF9F scan keyboard SETLFS = $FFBA set LA, FA, SA SETNAM = $FFBD set length & file name address OPEN = $FFC0 open logical file CLOSE = $FFC3 close logical file CHKIN = $FFC6 set channel in CKOUT = $FFC9 set channel out CLRCH = $FFCC restore default channel BASIN = $FFCF input from channel BSOUT = $FFD2 output to channel CLALL = $FFE7 close all files & channels ;Z80 data area translated to C64 address space ;in Z80 memory these are $1000 lower HSTBUF = $800 256 byte disk buffer CMD = $900 command DATA = $901 data register SECTOR = $902 sector register TRACK = $903 track register DISKNO = $904 drive number register KYCHAR = $905 key character IOTYPE = $CFF IO configuration byte MODESW = $DE00 1 = Z80 OFF, 0 = Z80 ON ;start of BIOS65 code * = $A00 LA00 LDA #0 turn Z80 back on STA MODESW NOP delay only JSR LA0C execute Z80 command if any JMP LA00 and loop ;get Z80 command from CMD & see if valid LA0C LDA CMD get saved command CMP #$FF see if Z80 active BNE LA16 if so try to execute JMP ($FFFC) else RESET the C64 LA16 CMP #10 see if 0 to 9 BCC LA1B it is so execute else ignore RTS ;add command again to get 2 x command ;this code assumes vector table never crosses a page boundary LA1B CLD clear decimal flag CLC and then carry ADC CMD A was CMD so A now = 2 x CMD ADC #LB88 JSR SETNAM set length & file name address ;now open JSR OPEN open logical file ;if logical file 2 is open close it LBB1 LDA #2 logical file (LA) = 2 JSR CLOSE close logical file ;now open logical file 2 LDA #2 logical file (LA) 2 LDX #8 drive (FA) 8 LDY #2 secondary address (SA) 2 JSR SETLFS set LA, FA, SA LDA #1 single character LDX #LB6F JSR SETNAM set length & file name address JMP OPEN open logical file ;initialize and then set input to command channel LBCB JSR LB97 initialize diskette ;set input to command channel LBCE LDX #15 logical address = 15 JSR CHKIN set channel in BCS LBCB if error try to initialize JSR BASIN input from channel CMP #"0" test error code "0" RTS ;close and open LA 2 and then LBDB JSR LBB1 set for random access ;set up read from channel 2 LBDE LDX #2 channel 2 JSR CHKIN set channel in BCS LBDB if error try to initialize RTS ;close and open LA 2 and then LBE6 JSR LBB1 set for random access ;set up write to channel 2 LBE9 LDX #2 channel 2 JSR CKOUT set channel out BCS LBE6 if error close and open RTS ;initialize diskette then LBF1 JSR LB97 initialize disk ;set up for write to command channel LBF4 LDX #15 LA 15 for command channel JSR CKOUT set channel out BCS LBF1 if error initialize LDX #0 x = 0 to start transfer after RTS RTS ;Z80 address table in Z80 address space for certain functions. ;In Z80 address space this starts at $FC00 LC00 .wor LC10+$1000 .wor LC20+$1000 .wor LC30+$1000 .wor LC40+$1000 .wor LC50+$1000 .wor LC60+$1000 .wor LC70+$1000 .wor LC80+$1000 LC10 .byt "DIR",CR,0,0,0,0,0,0,0,0,0,0,0,0 LC20 .byt "DIR B:",CR,0,CR,0,0,0,0,0,0,0 LC30 .byt "STAT *.*",CR,0,0,0,0,0,0,0 LC40 .byt "STAT B:*.*",CR,0,0,0,0,0 LC50 .byt "COPY",CR,0,"GTHEWATER",0 LC60 .byt "CONFIG",CR,0,0,0,0,0,0,0,0,0 LC70 .byt "DDT",CR,0,0,0,0,0,0,0,0,0,0,0,0 LC80 .byt "DDT ",0,0,CR,0,0,0,0,0,0,0,0,0 ;note that this area exists in Z80 address space ;starting at $FC90 .byt 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byt 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byt 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byt 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byt 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byt 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byt 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 IOTYPE .byt 1 this is IOTYPE