diff --git a/.gitignore b/.gitignore index c391a95..7640c55 100644 --- a/.gitignore +++ b/.gitignore @@ -175,3 +175,4 @@ software/asm/ramcbios/ software/asm/wt.asm software/dis/SA-5510/SA-5510.bin software/dis/XPATCH/XPATCH-5510.bin +software.moved.to.RFS/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..06b4c41 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "software/RFS"] + path = software/RFS + url = https://github.com/pdsmart/RFS.git diff --git a/software/RFS b/software/RFS new file mode 160000 index 0000000..899490e --- /dev/null +++ b/software/RFS @@ -0,0 +1 @@ +Subproject commit 899490e46ea0cef35fbc5977f7e616b478801afa diff --git a/software/asm/1z-013a.asm b/software/asm/1z-013a.asm deleted file mode 100644 index a0a99ca..0000000 --- a/software/asm/1z-013a.asm +++ /dev/null @@ -1,3307 +0,0 @@ - ; MONITOR PROGRAM 1Z-013A - ; (MZ700) FOR PAL - ; REV. 83.4.7 - ; Tuesday, 02 of June 1998 at 10:02 PM - ; Tuesday, 09 of June 1998 at 07:17 AM -; Configurable parameters. These are set in the wrapper file, ie monitor_SA1510.asm -; -;COLW: EQU 40 ; Width of the display screen (ie. columns). -;ROW: EQU 25 ; Number of rows on display screen. -;SCRNSZ: EQU COLW * ROW ; Total size, in bytes, of the screen display area. - - ORG 0000h ; 0000h Entrypoint -MONIT: JP START ; MONITOR ON -GETL: JP QGETL ; GET LINE (END "CR") -LETNL: JP QLTNL ; NEW LINE -NL: JP QNL ; -PRNTS: JP QPRTS ; PRINT SPACE -PRNTT: JP QPRTT ; PRINT TAB -PRNT: JP QPRNT ; 1 CHARACTER PRINT -MSG: JP QMSG ; 1 LINE PRINT (END "0DH") -MSGX: JP QMSGX ; RST 18H -GETKY: JP QGET ; GET KEY -BRKEY: JP QBRK ; GET BREAK -WRINF: JP QWRI ; WRITE INFORMATION -WRDAT: JP QWRD ; WRITE DATA -RDINF: JP QRDI ; READ INFORMATION -RDDAT: JP QRDD ; READ DATA -VERFY: JP QVRFY ; VERIFYING CMT -MELDY: JP QMLDY ; RST 30H -TIMST: JP QTMST ; TIME SET - NOP - NOP - JP 1038H ; INTERRUPT ROUTINE (8253) -TIMRD: JP QTMRD ; TIME READ -BELL: JP QBEL ; BELL ON -XTEMP: JP QTEMP ; TEMPO SET (1 - 7) -MSTA: JP MLDST ; MELODY START -MSTP: JP MLDSP ; MELODY STOP - -START: LD SP,SPV ; STACK SET (10F0H) - IM 1 ; IM 1 SET - CALL QMODE ; 8255 MODE SET - CALL QBRK ; CTRL ? - JR NC,ST0 - CP 20H ; KEY IS CTRL KEY - JR NZ,ST0 -CMY0: OUT (0E1H),A ; D000-FFFFH IS DRAM - LD DE,0FFF0H ; TRANS. ADR. - LD HL,DMCP ; MEMORY CHANG PROGRAM - LD BC,05H ; BYTE SIZE - LDIR - JP 0FFF0H ; JUMP $FFF0 - -DMCP: OUT (0E0H),A ; 0000H-0FFFH IS DRAM - JP 0000H - -ST0: LD B,0FFH ; BUFFER CLEAR - LD HL,NAME ; 10F1H-11F0H CLEAR - CALL QCLER - LD A,16H ; LASTER CLR. - CALL PRNT - IF MODE80C = 0 - LD A,017H ; Black background, white characters. Bit 7 is clear as a write to bit 7 @ DFFFH selects 40Char mode. - ELSE - LD A,017H ; Blue background, white characters in colour mode. Bit 7 is set as a write to bit 7 @ DFFFH selects 80Char mode. - ENDIF - ; LD A,71H ; BACK:BLUE CHA.:WRITE - LD HL,0D800H ; COLOR ADDRESS - CALL NCLR8 - LD HL,TIMIN ; INTERRUPT JUMP ROUTINE - LD A,0C3H - LD (1038H),A - LD (1039H),HL - LD A,04H ; NORMAL TEMPO - LD (TEMPW),A - CALL MLDSP ; MELODY STOP - CALL NL - LD DE,MSGQ3 ; ** MONITOR 1Z-013A ** - RST 18H ; CALL MGX - CALL QBEL -SS: LD A,01H - LD (SWRK),A ; KEY IN SILENT - LD HL,0E800H ; USR ROM? - LD (HL),A ; ROM CHECK - JR FD2 - -ST1: CALL NL - LD A,2AH ; "*" PRINT - CALL PRNT - LD DE,BUFER ; GET LINE WORK (11A3H) - CALL GETL -ST2: LD A,(DE) - INC DE - CP 0DH - JR Z,ST1 - CP 'J' ; JUMP - JR Z,GOTO - CP 'L' ; LOAD PROGRAM - JR Z,LOAD - CP 'F' ; FLOPPY ACCESS - JR Z,FD - CP 'B' ; KEY IN BELL - JR Z,SG - CP '#' ; CHANG MEMORY - JR Z,CMY0 - CP 'P' ; PRINTER TEST - JR Z,PTEST - CP 'M' ; MEMORY CORRECTION - JP Z,MCOR - CP 'S' ; SAVE DATA - JP Z,SAVE - CP 'V' ; VERIFYING DATA - JP Z,VRFY - CP 'D' ; DUMP DATA - JP Z,DUMP - NOP - NOP - NOP - NOP - JR ST2 ; NO COMMAND - - ; JUMP COMMAND - -GOTO: CALL HEXIY - JP (HL) - - ; KEY SOUND ON/OFF - -SG: LD A,(SWRK) ; D0=SOUND WORK - RRA - CCF ; CHANGE MODE - RLA - JR SS+2 - - ; FLOPPY - -FD: LD HL,0F000H ; FLOPPY I/O CHECK -FD2: LD A,(HL) - OR A - JR NZ,ST1 -FD1: JP (HL) - - ; ERROR (LOADING) - -QER: CP 02H ; A=02H : BREAK IN - JR Z,ST1 - LD DE,MSGE1 ; CHECK SUM ERROR - RST 18H ; CALL MSGX -L010F: JR ST1 - - ; LOAD COMMAND - -LOAD: CALL QRDI - JR C,QER -LOA0: CALL NL - LD DE,MSGQ2 ; LOADING - RST 18H ; CALL MSGX - LD DE,NAME ; FILE NAME - RST 18H ; CALL MSGX - CALL QRDD - JR C,QER - LD HL,(EXADR) ; EXECUTE ADDRESS - LD A,H - CP 12H ; EXECUTE CHECK - JR C,L010F - JP (HL) - - ; GETLINE AND BREAK IN CHECK - ; - ; EXIT BREAK IN THEN JUMP (ST1) - ; ACC=TOP OF LINE DATA - -BGETL: EX (SP),HL - POP BC ; STACK LOAD - LD DE,BUFER ; MONITOR GETLINE BUFF - CALL GETL - LD A,(DE) - CP 1BH ; BREAK CODE - JR Z,L010F ; JP Z,ST1 - JP (HL) - - ; ASCII TO HEX CONVERT - ; INPUT (DE)=ASCII - ; CY=1 THEN JUMP (ST1) - -HEXIY: EX (SP),IY - POP AF - CALL HLHEX - JR C,L010F ; JP C,ST1 - JP (IY) - -MSGE1: DB "CHECK SUM ER.\r" - - ; PLOTTER PRINTER TEST COMMAND - ; (DPG23) - ; &=CONTROL COMMANDS GROUP - ; C=PEN CHANGE - ; G=GRAPH MODE - ; S=80 CHA. IN 1 LINE - ; L=40 CHA. IN 1 LINE - ; T=PLOTTER TEST - ; IN (DE)=PRINT DATA - -PTEST: LD A,(DE) - CP '&' - JR NZ,PTST1 -PTST0: INC DE - LD A,(DE) - CP 'L' ; 40 IN 1 LINE - JR Z,PLPT - CP 'S' ; 80 IN 1 LINE - JR Z,PPLPT - CP 'C' ; PEN CHANGE - JR Z,PEN - CP 'G' ; GRAPH MODE - JR Z,PLOT - CP 'T' ; TEST - JR Z,PTRN -PTST1: CALL PMSG ; PLOT MESSAGE - JP ST1 - -PLPT: LD DE,LLPT ; 01-09-09-0B-0D - JR PTST1 - -PPLPT: LD DE,SLPT ; 01-09-09-09-0D - JR PTST1 - -PTRN: LD A,04H ; TEST PATTERN - JR PLOT+2 - -PLOT: LD A,02H ; GRAPH CODE - CALL LPRNT - JR PTST0 - -PEN: LD A,1DH ; 1 CHANGE CODE (TEXT MODE) - JR PLOT+2 - - ; 1CHA. PRINT TO $LPT - ; IN: ACC PRINT DATA - -LPRNT: LD C,0 ; RDA TEST (READY? RDA=0) - LD B,A ; PRINT DATA STORE - CALL RDA - LD A,B - OUT (0FFH),A ; DATA OUT - LD A,80H ; RDP HIGH - OUT (0FEH),A - LD C,01H ; RDA TEST - CALL RDA - XOR A ; RDP LOW - OUT (0FEH),A - RET - - ; $LPT MSG - ; IN: DE DATA LOW ADDRESS - ; 0DH MSG END - -PMSG: PUSH DE - PUSH BC - PUSH AF -PMSG1: LD A,(DE) ; ACC=DATA - CALL LPRNT - LD A,(DE) - INC DE - CP 0DH ; END? - JR NZ,PMSG1 - POP AF - POP BC - POP DE - RET - - ; RDA CHECK - ; BRKEY IN TO MONITOR RETURN - ; IN: C RDA CODE - -RDA: IN A,(0FEH) - AND 0DH ; RDA ONLY - CP C - RET Z - CALL BRKEY - JR NZ,RDA - LD SP,SPV - JP ST1 - - ; MELODY - ; DE=DATA LOW ADDRESS - ; EXIT CF=1 BREAK - ; CF=0 OK - -QMLDY: PUSH BC - PUSH DE - PUSH HL - LD A,02H - LD (OCTV),A - LD B,01H -MLD1: LD A,(DE) - CP 0DH ; CR - JR Z,MLD4 - CP 0C8H ; END MARK - JR Z,MLD4 - CP 0CFH ; UNDER OCTAVE - JR Z,MLD2 - CP 2DH ; "-" - JR Z,MLD2 - CP 2BH ; "+" - JR Z,MLD3 - CP 0D7H ; UPPER OCTAVE - JR Z,MLD3 - CP 23H ; "#" HANON - LD HL,MTBL - JR NZ,L01F5 - LD HL,MNTBL - INC DE -L01F5: CALL ONPU ; ONTYO SET - JR C,MLD1 - CALL RYTHM - JR C,MLD5 - CALL MLDST ; MELODY START - LD B,C - JR MLD1 - -MLD2: LD A,3 -L0207: LD (OCTV),A - INC DE - JR MLD1 - -MLD3: LD A,01H - JR L0207 - -MLD4: CALL RYTHM -MLD5: PUSH AF - CALL MLDSP - POP AF - JP RET3 - - ; ONPU TO RATIO CONV - ; EXIT (RATIO)=RATIO VALUE - ; C=ONTYO*TEMPO - -ONPU: PUSH BC - LD B,8 -ONP1: LD A,(DE) -L0220: CP (HL) - JR Z,ONP2 - INC HL - INC HL - INC HL - DJNZ L0220 - SCF - INC DE - POP BC - RET - -ONP2: INC HL - PUSH DE - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL - LD A,H - OR A - JR Z,L023F - LD A,(OCTV) ; 11A0H OCTAVE WORK -L0239: DEC A - JR Z,L023F - ADD HL,HL - JR L0239 - -L023F: LD (RATIO),HL ; 11A1H ONPU RATIO - LD HL,OCTV - LD (HL),02H - DEC HL - POP DE - INC DE - LD A,(DE) - LD B,A - AND 0F0H ; ONTYO ? - CP 30H - JR Z,L0255 - LD A,(HL) ; HL=ONTYO - JR L025A - -L0255: INC DE - LD A,B - AND 0FH - LD (HL),A ; HL=ONTYO -L025A: LD HL,OPTBL - ADD A,L - LD L,A - LD C,(HL) - LD A,(TEMPW) - LD B,A - XOR A -ONP3: ADD A,C - DJNZ ONP3 - POP BC - LD C,A - XOR A - RET - -MTBL: DB "C" - DW 0846H - DB "D" - DW 075FH - DB "E" - DW 0691H - DB "F" - DW 0633H - DB "G" - DW 0586H - DB "A" - DW 04ECH - DB "B" - DW 0464H - DB "R" - DW 0000H -MNTBL: DB "C" ; #C - DW 07CFH - DB "D" ; #D - DW 06F5H - DB "E" ; #E - DW 0633H - DB "F" ; #F - DW 05DAH - DB "G" ; #G - DW 0537H - DB "A" ; #A - DW 04A5H - DB "B" ; #B - DW 0423H - DB "R" ; #R - DW 0000H -OPTBL: DB 01H - DB 02H - DB 03H - DB 04H - DB 06H - DB 08H - DB 0CH - DB 10H - DB 18H - DB 20H - - ; INCREMENT DE REG. - -P4DE: INC DE - INC DE - INC DE - INC DE - RET - - ; MELODY START & STOP - -MLDST: LD HL,(RATIO) - LD A,H - OR A - JR Z,MLDSP - PUSH DE - EX DE,HL - LD HL,CONT0 - LD (HL),E - LD (HL),D - LD A,01H - POP DE - JR MLDS1 - -MLDSP: LD A,36H ; MODE SET (8253 C0) - LD (CONTF),A ; E007H - XOR A -MLDS1: LD (SUNDG),A ; E008H - RET ; TEHRO SET - - ; RHYTHM - ; B=COUNT DATA - ; IN - ; EXIT CF=1 BREAK - ; CF=0 OK - -RYTHM: LD HL,KEYPA ; E000H - LD (HL),0F8H - INC HL - LD A,(HL) - AND 81H ; BREAK IN CHECK - JR NZ,L02D5 - SCF - RET - -L02D5: LD A,(TEMP) ; E008H - RRCA ; TEMPO OUT - JR C,L02D5 -L02DB: LD A,(TEMP) - RRCA - JR NC,L02DB - DJNZ L02D5 - XOR A - RET - - ; TEMPO SET - ; ACC=VALUE (1-7) - -QTEMP: PUSH AF - PUSH BC - AND 0FH - LD B,A - LD A,8 - SUB B - LD (TEMPW),A - POP BC - POP AF - RET - - ; CRT MANAGEMENT - ; EXIT HL:DSPXY H=Y,L=X - ; DE:MANG ADR. (ON DSPXY) - ; A :MANG DATA - ; CY:MANG=1 - -PMANG: LD HL,MANG ; CRT MANG POINTER - LD A,(1172H) ; DSPXY+1 - ADD A,L - LD L,A - LD A,(HL) - INC HL - RL (HL) - OR (HL) - RR (HL) - RRCA - EX DE,HL - LD HL,(DSPXY) - RET - - ; TIME SET - ; ACC=0 : AM - ; =1 : PM - ; DE=SEC: BINARY - -QTMST: DI - PUSH BC - PUSH DE - PUSH HL - LD (AMPM),A ; AMPM DATA - LD A,0F0H - LD (TIMFG),A ; TIME FLAG - LD HL,0A8C0H ; 12 HOURS (43200 SECONDS) - XOR A - SBC HL,DE ; COUNT DATA = 12H-IN DATA - PUSH HL - NOP - EX DE,HL - LD HL,CONTF ; E007H - LD (HL),74H ; C1 - LD (HL),0B0H ; C2 - DEC HL ; CONT2 - LD (HL),E ; E006H - LD (HL),D - DEC HL ; CONT1 - LD (HL),0AH ; E005H STROBE 640,6µSECONDS COUNT2 - LD (HL),0 - INC HL - INC HL ; CONTF - LD (HL),80H ; E007H - DEC HL ; CONT2 -QTMS1: LD C,(HL) ; E006H - LD A,(HL) - CP D - JR NZ,QTMS1 - LD A,C - CP E - JR NZ,QTMS1 - DEC HL ; E005H - NOP - NOP - NOP - LD (HL),0FBH ; 1 SECOND (15611HZ) E005H - LD (HL),3CH - INC HL - POP DE -QTMS2: LD C,(HL) ; E006H - LD A,(HL) - CP D - JR NZ,QTMS2 - LD A,C - CP E - JR NZ,QTMS2 - POP HL - POP DE - POP BC - EI - RET - - ; BELL DATA - ; -QBELD: DB 0D7H - DB "A0" - DB 0DH - NOP - NOP - - ; TIME READ - ; EXIT ACC=0 :AM - ; =1 :PM - ; DE=SEC. BINARY - -QTMRD: PUSH HL - LD HL,CONTF - LD (HL),80H ; E007H C2 - DEC HL ; CONT2 - DI - LD E,(HL) - LD D,(HL) ; e006H C2 MODE0 - EI -L0363: LD A,E - OR D - JR Z,QTMR1 - XOR A - LD HL,0A8C0H ; 12 HOURS - SBC HL,DE - JR C,QTMR2 - EX DE,HL - LD A,(AMPM) - POP HL - RET - -QTMR1: LD DE,0A8C0H -L0378: LD A,(AMPM) - XOR 01H - POP HL - RET - -QTMR2: DI - LD HL,CONT2 - LD A,(HL) - CPL - LD E,A - LD A,(HL) - CPL - LD D,A - EI - INC DE - JR L0378 - - ; TIME INTERRUPT - -TIMIN: PUSH AF - PUSH BC - PUSH DE - PUSH HL - LD HL,AMPM - LD A,(HL) - XOR 01H - LD (HL),A - LD HL,CONTF - LD (HL),80H ; CONT2 - DEC HL - PUSH HL - LD E,(HL) - LD D,(HL) - LD HL,0A8C0H - ADD HL,DE - DEC HL - DEC HL - EX DE,HL - POP HL - LD (HL),E - LD (HL),D - POP HL - POP DE - POP BC - POP AF - EI - RET - - ; SPACE PRINT AND DISP ACC - ; INPUT:HL=DISP. ADR. - -SPHEX: CALL QPRTS ; SPACE PRINT - LD A,(HL) - CALL PRTHX ; DSP OF ACC (ASCII) - LD A,(HL) - RET - - ; (ASCII PRINT) FOR HL - -PRTHL: LD A,H - CALL PRTHX - LD A,L - JR PRTHX - - NOP - NOP - - ; (ASCII PRINT) FOR ACC - -PRTHX: PUSH AF - RRCA - RRCA - RRCA - RRCA - CALL ASC - CALL PRNT - POP AF - CALL ASC - JP PRNT - - ; 80 CHA. 1 LINE CODE (DATA) - -SLPT: DB 01H ; TEXT MODE - DB 09H - DB 09H - DB 09H - DB 0DH - - ; HEXADECIMAL TO ASCII - ; IN : ACC (D3-D0)=HEXADECIMAL - ; EXIT: ACC = ASCII -ASC: AND 0FH - CP 0AH - JR C,NOADD - ADD A,07H -NOADD: ADD A,30H - RET - - ; ASCII TO HEXADECIMAL - ; IN : ACC = ASCII - ; EXIT: ACC = HEXADECIMAL - ; CY = 1 ERROR - -HEXJ: SUB 30H - RET C ; <0 - CP 0AH - CCF - RET NC ; 0-9 - SUB 07H - CP 10H - CCF - RET C - CP 0AH - RET - - NOP - NOP - NOP - NOP - -HEX: JR HEXJ - - ; PRESS PLAY MESSAGE - -MSGN1: DW 207FH -MSGN2: DB "PLAY\r" -MSGN3: DW 207FH - DB "RECORD.\r" ; PRESS RECORD - - NOP - NOP - NOP - NOP - - ; 4 ASCII TO (HL) - ; IN DE=DATA LOW ADDRESS - ; EXIT CF=0 : OK - ; =1 : OUT - -HLHEX: PUSH DE - CALL L2HEX - JR C,L041D - LD H,A - CALL L2HEX - JR C,L041D - LD L,A -L041D: POP DE - RET - - ; 2 ASCII TO (ACC) - ; IN DE=DATA LOW ADRRESS - ; EXIT CF=0 : OK - ; =1 : OUT - -L2HEX: PUSH BC - LD A,(DE) - INC DE - CALL HEX - JR C,L0434 - RRCA - RRCA - RRCA - RRCA - LD C,A - LD A,(DE) - INC DE - CALL HEX - JR C,L0434 - OR C -L0434: POP BC - RET - - ; WRITE INFORMATION - -QWRI: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D7H ; "W" - LD E,0CCH ; "L" - LD HL,IBUFE ; 10F0H - LD BC,80H ; WRITE BYTE SIZE -WRI1: CALL CKSUM ; CHECK SUM - CALL MOTOR ; MOTOR ON - JR C,WRI3 - LD A,E - CP 0CCH ; "L" - JR NZ,WRI2 - CALL NL - PUSH DE - LD DE,MSGN7 ; WRITING - RST 18H ; CALL MSGX - LD DE,NAME ; FILE NAME - RST 18H ; CALL MSGX - POP DE -WRI2: CALL GAP - CALL WTAPE -WRI3: JP RET2 - -MSGN7: DB "WRITING \r" - - ; 40 CHA. IN 1 LINE CODE (DATA) - -LLPT: DB 01H ; TEXT MODE - DB 09H - DB 09H - DB 0BH - DB 0DH - - ; WRITE DATA - ; EXIT CF=0 : OK - ; =1 : BREAK - -QWRD: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D7H ; "W" - LD E,53H ; "S" -L047D: LD BC,(SIZE) ; WRITE DATA BYTE SIZE - LD HL,(DTADR) ; WRITE DATA ADDRESS - LD A,B - OR C - JR Z,RET1 - JR WRI1 - - ; TAPE WRITE - ; BC=BYTE SIZE - ; HL=DATA LOW ADDRESS - ; EXIT CF=0 : OK - ; =1 : BREAK - -WTAPE: PUSH DE - PUSH BC - PUSH HL - LD D,02H - LD A,0F8H ; 88H WOULD BE BETTER!! - LD (KEYPA),A ; E000H -WTAP1: LD A,(HL) - CALL WBYTE ; 1 BYTE WRITE - LD A,(KEYPB) ; E001H - AND 81H ; SHIFT & BREAK - JP NZ,WTAP2 - LD A,02H ; BREAK IN CODE - SCF - JR WTAP3 - -WTAP2: INC HL - DEC BC - LD A,B - OR C - JP NZ,WTAP1 - LD HL,(SUMDT) ; SUM DATA SET - LD A,H - CALL WBYTE - LD A,L - CALL WBYTE - CALL LONG - DEC D - JP NZ,L04C2 - OR A - JP WTAP3 - -L04C2: LD B,0 -L04C4: CALL SHORT - DEC B - JP NZ,L04C4 - POP HL - POP BC - PUSH BC - PUSH HL - JP WTAP1 - -WTAP3: -RET1: POP HL - POP BC - POP DE - RET - - DB 2FH - DB 4EH - - ; READ INFORMATION (FROM $CMT) - ; EXIT ACC=0: OK CF=0 - ; =1: ER CF=1 - ; =2: BREAK CF=1 - -QRDI: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D2H ; "R" - LD E,0CCH ; "L" - LD BC,80H - LD HL,IBUFE -RD1: CALL MOTOR - JP C,RTP6 - CALL TMARK - JP C,RTP6 - CALL RTAPE - JP RTP4 - - ; READ DATA (FROM $CMT) - ; EXIT SAME UP - -QRDD: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D2H ; "R" - LD E,53H ; "S" - LD BC,(SIZE) - LD HL,(DTADR) - LD A,B - OR C - JP Z,RTP4 - JR RD1 - - ; READ TAPE - ; IN BC=SIZE - ; DE=LOAD ADDRESS - ; EXIT ACC=0 : OK CF=0 - ; =1 : ER =1 - ; =2 : BREAK=1 - -RTAPE: PUSH DE - PUSH BC - PUSH HL - LD H,02H ; TWICE WRITE -RTP1: LD BC,KEYPB - LD DE,CSTR -RTP2: CALL EDGE ; 1-->0 EDGE DETECT - JR C,RTP6 - CALL DLY3 ; CALL DLY2*3 - LD A,(DE) ; DATA (1 BIT) READ - AND 20H - JP Z,RTP2 - LD D,H - LD HL,0 - LD (SUMDT),HL - POP HL - POP BC - PUSH BC - PUSH HL -RTP3: CALL RBYTE ; 1 BYTE READ - JR C,RTP6 - LD (HL),A - INC HL - DEC BC - LD A,B - OR C - JR NZ,RTP3 - LD HL,(SUMDT) ; CHECK SUM - CALL RBYTE ; CHECK SUM DATA - JR C,RTP6 - LD E,A - CALL RBYTE ; CHECK SUM DATA - JR C,RTP6 - CP L - JR NZ,RTP5 - LD A,E - CP H - JR NZ,RTP5 -RTP8: XOR A -RTP4: -RET2: POP HL - POP BC - POP DE - CALL MSTOP - PUSH AF - LD A,(TIMFG) ; INT. CHECK - CP 0F0H - JR NZ,L0563 - EI -L0563: POP AF - RET - -RTP5: DEC D - JR Z,RTP7 - LD H,D - CALL GAPCK - JR RTP1 - -RTP7: LD A,01H - JR RTP9 - -RTP6: LD A,02H -RTP9: SCF - JR RTP4 - - ; BELL - -QBEL: PUSH DE - LD DE,QBELD - RST 30H ; CALL MELODY - POP DE - RET - - ; FLASHING AND KEYIN - ; EXIT: ACC INPUT KEY DATA (DSP.CODE) - ; H=F0H THEN NO KEYIN (Z FLAG) - -FLKEY: CALL QFLAS - CALL QKEY - CP 0F0H - RET - - NOP - - ; VERIFY (FROM $CMT) - ; EXIT ACC=0 : OK CF=0 - ; =1 : ER CF=1 - ; =2 : BREAK CF=1 - -QVRFY: DI - PUSH DE - PUSH BC - PUSH HL - LD BC,(SIZE) - LD HL,(DTADR) - LD D,0D2H ; "R" - LD E,53H ; "S" - LD A,B - OR C - JR Z,RTP4 ; END - CALL CKSUM - CALL MOTOR - JR C,RTP6 ; BRK - CALL TMARK ; TAPE MARK DETECT - JR C,RTP6 ; BRK - CALL TVRFY - JR RTP4 - - ; DATA VERIFY - ; BC=SIZE - ; HL=DATA LOW ADDRESS - ; CSMDT=CHECK SUM - ; EXIT ACC=0 : OK CF=0 - ; =1 : ER =1 - ; =2 : BREAK =1 - -TVRFY: PUSH DE - PUSH BC - PUSH HL - LD H,02H ; COMPARE TWICE -TVF1: LD BC,KEYPB - LD DE,CSTR -TVF2: CALL EDGE - JP C,RTP6 ; BRK - CALL DLY3 ; CALL DLY2*3 - LD A,(DE) - AND 20H - JP Z,TVF2 - LD D,H - POP HL - POP BC - PUSH BC - PUSH HL - ; COMPARE TAPE DATA AND STORAGE -TVF3: CALL RBYTE - JR C,RTP6 ; BRK - CP (HL) - JR NZ,RTP7 ; ERROR, NOT EQUAL - INC HL ; STORAGE ADDRESS + 1 - DEC BC ; SIZE - 1 - LD A,B - OR C - JR NZ,TVF3 - ; COMPARE CHECK SUM (1199H/CSMDT) AND TAPE - LD HL,(CSMDT) - CALL RBYTE - CP H - JR NZ,RTP7 ; ERROR, NOT EQUAL - CALL RBYTE - CP L - JR NZ,RTP7 ; ERROR, NOT EQUAL - DEC D ; NUMBER OF COMPARES (2) - 1 - JP Z,RTP8 ; OK, 2 COMPARES - LD H,D ; (-->05C7H), SAVE NUMBER OF COMPARES - JR TVF1 ; NEXT COMPARE - - ; FLASHING DATA LOAD - -QLOAD: PUSH AF - LD A,(FLASH) - CALL QPONT - LD (HL),A - POP AF - RET - - ; NEW LINE AND PRINT HL REG (ASCII) - -NLPHL: CALL NL - CALL PRTHL - RET - - ; EDGE (TAPE DATA EDGE DETECT) - ; BC=KEYPB (E001H) - ; DE=CSTR (E002H) - ; EXIT CF=0 OK CF=1 BREAK - -EDGE: LD A,0F8H ; BREAK KEY IN (88H WOULD BE BETTER!!) - LD (KEYPA),A - NOP -EDG1: LD A,(BC) - AND 81H ; SHIFT & BREAK - JR NZ,L060E - SCF - RET - -L060E: LD A,(DE) - AND 20H - JR NZ,EDG1 ; CSTR D5 = 0 -EDG2: LD A,(BC) ; 8 - AND 81H ; 9 - JR NZ,L061A ; 10/14 - SCF - RET - -L061A: LD A,(DE) ; 8 - AND 20H ; 9 - JR Z,EDG2 ; CSTR D5 = 1 10/14 - RET ; 11 - - NOP - NOP - NOP - NOP - ; 1 BYTE READ - ; EXIT SUMDT=STORE - ; CF=1 : BREAK - ; CF=0 : DATA=ACC - -RBYTE: PUSH BC - PUSH DE - PUSH HL - LD HL,0800H ; 8 BITS - LD BC,KEYPB ; KEY DATA E001H - LD DE,CSTR ; $TAPE DATA E002H -RBY1: CALL EDGE ; 41 OR 101 - JP C,RBY3 ; 13 (SHIFT & BREAK) - CALL DLY3 ; 20+18*63+33 - LD A,(DE) ; DATA READ :8 - AND 20H - JP Z,RBY2 ; 0 - PUSH HL - LD HL,(SUMDT) - INC HL ; CHECK SUM ; COUNT HIGH BITS ON TAPE - LD (SUMDT),HL - POP HL - SCF -RBY2: LD A,L ; BUILD CHAR - RLA - LD L,A - DEC H ; BITCOUNT-1 - JP NZ,RBY1 - CALL EDGE - LD A,L ; CHAR READ -RBY3: POP HL - POP DE - POP BC - RET - - NOP - NOP - NOP - - ; TAPE MARK DETECT - ; E=@L@ : INFORMATION - ; =@S@ : DATA - ; EXIT CF=0 OK - ; =1 BREAK - -TMARK: CALL GAPCK - PUSH BC - PUSH DE - PUSH HL - LD HL,2828H - LD A,E - CP 0CCH ; "L" - JR Z,L066C - LD HL,1414H -L066C: LD (TMCNT),HL - LD BC,KEYPB - LD DE,CSTR -TM1: LD HL,(TMCNT) -TM2: CALL EDGE - JR C,TM4 - CALL DLY3 ; CALL DLY2*3 - LD A,(DE) - AND 20H - JR Z,TM1 - DEC H - JR NZ,TM2 -TM3: CALL EDGE - JR C,TM4 - CALL DLY3 ; CALL DLY2*3 - LD A,(DE) - AND 20H - JR NZ,TM1 - DEC L - JR NZ,TM3 - CALL EDGE -TM4: -RET3: POP HL - POP DE - POP BC - RET - - ; MOTOR ON - ; IN D=@W@ :WRITE - ; =@R@ :READ - ; EXIT CF=0 OK - ; =1 BREAK - ; - ; If the button is pressed, - -MOTOR: PUSH BC - PUSH DE - PUSH HL - LD B,0AH ; Pulse motor upto 10 times if sense is low. Each pulse flips on->off or off->on -MOT1: LD A,(CSTR) ; Check sense, if low then pulse motor to switch it on. - AND 10H - JR Z,MOT4 ; If NZ (bit PC4 is high), then wait a bit and return, motor running. - ; If Z then pulse the motor on circuit. -MOT2: LD B,0FFH ; 2 SEC DELAY -L06AD: CALL DLY12 ; 7 MSEC DELAY - JR L06B4 ; MOTOR ENTRY ADJUST - - JR MOTOR ; ORG 06B2H - -L06B4: DJNZ L06AD - XOR A -MOT7: JR RET3 - -MOT4: LD A,06H ; - LD HL,CSTPT ; 8255 Control register - LD (HL),A ; Set PC3 low - INC A - LD (HL),A ; Set PC3 high - DJNZ MOT1 ; Check to see if sense now active. - CALL NL ; Sense not active so play button hasnt been pressed. - LD A,D ; Determine if we are Loading or Saving, display correct message. - CP 0D7H ; "W" - JR Z,MOT8 - LD DE,MSGN1 ; PLAY MARK - JR MOT9 - -MOT8: LD DE,MSGN3 ; "RECORD." - RST 18H ; CALL MSGX - LD DE,MSGN2 ; "PLAY" -MOT9: RST 18H ; CALL MSGX -MOT5: LD A,(CSTR) ; Check sense input and wait until it is high. - AND 10H - JR NZ,MOT2 - CALL QBRK ; If sense is low, check for User Key Break entry. - JR NZ,MOT5 - SCF - JR MOT7 - - ; INITIAL MESSAGE - -MSGQ3: DB "** MONITOR 1Z-013A **\r" - NOP - - ; MOTOR STOP - -MSTOP: PUSH AF - PUSH BC - PUSH DE - LD B,0AH -MST1: LD A,(CSTR) - AND 10H - JR Z,MST3 - LD A,06H - LD (CSTPT),A - INC A - LD (CSTPT),A - DJNZ MST1 -MST3: JP QRSTR1 - - ; CHECK SUM - ; IN BC=SIZE - ; HL=DATA ADDRESS - ; EXIT SUMDT=STORE - ; CSMDT=STORE - -CKSUM: PUSH BC - PUSH DE -L071C: PUSH HL - LD DE,0 -CKS1: LD A,B - OR C - JR NZ,CKS2 - EX DE,HL -L0725: LD (SUMDT),HL ; NUMBER OF HIGHBITS IN DATA - LD (CSMDT),HL - POP HL - POP DE - POP BC - RET - -CKS2: LD A,(HL) - PUSH BC - LD B,8 -CKS3: RLCA - JR NC,L0737 - INC DE -L0737: DJNZ CKS3 -L0739: POP BC - INC HL - DEC BC - JR CKS1 - - ; MODE SET OF KEYPORT - -QMODE: LD HL,KEYPF - LD (HL),8AH ; 10001010 CTRL WORD MODE0 - LD (HL),07H ; PC3=1 M-ON - LD (HL),05H ; PC2=1 INTMSK - LD (HL),01H ; TZ: Enable VGATE (2xNOP removed below to keep ROM consistency). - RET - - ;NOP - ;NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - - ; 107 MICRO SEC DELAY - -DLY1: LD A,15H ; 18*21+20 -L075B: DEC A - JP NZ,L075B - RET - -DLY2: LD A,13H ; 18*19+20 -L0762: DEC A - JP NZ,L0762 - RET - - ; 1 BYTE WRITE - -WBYTE: PUSH BC - LD B,8 - CALL LONG -WBY1: RLCA - CALL C,LONG - CALL NC,SHORT - DEC B - JP NZ,WBY1 - POP BC - RET - - ; GAP + TAPEMARK - ; E=@L@ LONG GAP - ; =@s@ SHORT GAP - -GAP: PUSH BC - PUSH DE - LD A,E - LD BC,55F0H - LD DE,2828H - CP 0CCH ; "L" - JP Z,GAP1 - LD BC,2AF8H - LD DE,1414H -GAP1: CALL SHORT - DEC BC - LD A,B - OR C - JR NZ,GAP1 -GAP2: CALL LONG - DEC D - JR NZ,GAP2 -GAP3: CALL SHORT - DEC E - JR NZ,GAP3 - CALL LONG - POP DE - POP BC - RET - - ; MEMORY CORRECTION - ; COMMAND "M" - -MCOR: CALL HEXIY ; CORRECTION ADDRESS -MCR1: CALL NLPHL ; CORRECTION ADDRESS PRINT - CALL SPHEX ; ACC-->ASCII DISP. - CALL QPRTS ; SPACE PRINT - CALL BGETL ; GET DATA & CHECK DATA - CALL HLHEX ; HL<--ASCII(DE) - JR C,MCR3 - CALL P4DE ; (INC DE)*4 - INC DE - CALL L2HEX ; DATA CHECK - JR C,MCR1 - CP (HL) - JR NZ,MCR1 - INC DE - LD A,(DE) - CP 0DH ; NOT CORRECTION ? - JR Z,MCR2 - CALL L2HEX ; ACC<--HL(ASCII) - JR C,MCR1 - LD (HL),A ; DATA CORRECT -MCR2: INC HL - JR MCR1 - -MCR3: LD H,B ; MEMORY ADDRESS - LD L,C - JR MCR1 - - DB "(HL)" - DB 0F1H - DB 9EH - DB "SUB (" - - ; GET 1 LINE STATEMENT * - ; DE=DATA STORE LOW ADDRESS - ; (END=CR) - -QGETL: PUSH AF - PUSH BC - PUSH HL - PUSH DE -GETL1: CALL QQKEY ; ENTRY KEY -AUTO3: PUSH AF ; IN KEY DATA SAVE - LD B,A - LD A,(SWRK) ; BELL WORK - RRCA - CALL NC,QBEL ; ENTRY BELL - LD A,B - LD HL,KANAF ; KANA & GRAPH FLAGS - AND 0F0H - CP 0C0H - POP DE ; EREG=FLAGREG - LD A,B - JR NZ,GETL2 ; NOT C0H - CP 0CDH ; CR - JR Z,GETL3 - CP 0CBH ; BREAK - JP Z,GETLC - CP 0CFH ; NIKO MARK WH. - JR Z,GETL2 - CP 0C7H ; CRT EDITION - JR NC,GETL5 ; <=C7H - RR E ; >C7H & CFLAG, CY ? GRAPHIC MODE,CURS.DISPL. - LD A,B - JR NC,GETL5 -GETL2: CALL QDSP ; DISPL. - JR GETL1 - -GETL5: CALL QDPCT ; CRT CONTROL - JR GETL1 - - ; BREAK IN - -GETLC: POP HL - PUSH HL - LD (HL),1BH ; BREAK CODE - INC HL - LD (HL),0DH - JR GETLR - - ; GETLA - -GETLA: RRCA ; CY<--D7 - JR NC,GETL6 - JR GETLB - - ; DELAY 7 MSEC AND SWEP - -DSWEP: CALL DLY12 - CALL QSWEP - RET - - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - -GETL3: CALL PMANG ; CR - LD B,COLW ; 1 LINE - JR NC,GETLA - DEC H ; BEFORE LINE -GETLB: LD B,COLW*2 ; 2 LINE -GETL6: LD L,0 - CALL QPNT1 - POP DE ; STORE TOP ADDRESS - PUSH DE -GETLZ: LD A,(HL) - CALL QDACN - LD (DE),A - INC HL - INC DE - DJNZ GETLZ - EX DE,HL -GETLU: LD (HL),0DH - DEC HL - LD A,(HL) - CP 20H ; SPACE THEN CR - - ; CR AND NEW LINE - - JR Z,GETLU - - ; NEW LINE RETURN - -GETLR: CALL QLTNL - POP DE - POP HL - POP BC - POP AF - RET - - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - - ; MESSAGE PRINT - ; DE PRINT DATA LOW ADDRESS - ; END=CR - -QMSG: PUSH AF - PUSH BC - PUSH DE -MSG1: LD A,(DE) - CP 0DH ; CR - JR Z,MSGX2 - CALL QPRNT - INC DE - JR MSG1 - - ; ALL PRINT MESSAGE - -QMSGX: PUSH AF - PUSH BC - PUSH DE -MSGX1: LD A,(DE) - CP 0DH -MSGX2: JP Z,QRSTR1 - CALL QADCN - CALL PRNT3 - INC DE - JR MSGX1 - - ; TOP OF KEYTBLS - -QKYSM: LD DE,KTBLS ; SHIFT ALSO - JR QKY5 - - ; BREAK CODE IN - -NBRK: LD A,0CBH ; BREAK CODE - OR A - JR QKY1 - - ; GETKEY - ; NO ECHO BACK - ; EXIT ACC=ASCII CODE - -QGET: CALL QKEY ; KEY IN (DISPLAY CODE) - SUB 0F0H ; NOT KEYIN CODE - RET Z - ADD A,0F0H - JP QDACN ; DISPLAY TO ASCII CODE - - NOP - NOP - - ; 1 KEY INPUT - ; IN B=KEY MODE (SHIFT, CTRL, BREAK) - ; C=KEY DATA (COLUMN & ROW) - ; EXIT ACC=DISPLAY CODE - ; IF NO KEY ACC=F0H - ; IF CY=1 THEN ATTRIBUTE ON - ; (SMALL, HIRAKANA) - -QKEY: PUSH BC - PUSH DE - PUSH HL - CALL DSWEP ; DELAY AND KEY SWEP - LD A,B - RLCA - JR C,QKY2 - LD A,0F0H ; SHIFT OR CTRL HERE -QKY1: POP HL - POP DE - POP BC - RET - -QKY2: LD DE,KTBL ; NORMAL KEY TABLE - LD A,B - CP 88H ; BREAK IN (SHIFT & BRK) - JR Z,NBRK - LD H,0 ; HL=ROW & COLUMN - LD L,C - BIT 5,A ; CTRL CHECK - JR NZ,L08F7 ; YES, CTRL - LD A,(KANAF) ; 0=NR., 1=GRAPH - RRCA - JP C,QKYGRP ; GRAPH MODE - LD A,B ; CTRL KEY CHECK - RLA - RLA - JR C,QKYSM - JR QKY5 - -L08F7: LD DE,KTBLC ; CONTROL KEY TABLE -QKY5: ADD HL,DE ; TABLE -QKY55: LD A,(HL) - JR QKY1 - -QKYGRP: BIT 6,B - JR Z,QKYGRS - LD DE,KTBLG - ADD HL,DE - SCF - JR QKY55 - -QKYGRS: LD DE,KTBLGS - JR QKY5 - - ; NEWLINE - -QLTNL: XOR A - LD (DPRNT),A ; ROW POINTER - LD A,0CDH ; CR - JR PRNT5 - - NOP - NOP - -QNL: LD A,(DPRNT) - OR A - RET Z - JR QLTNL - - NOP - - ; PRINT SPACE - -QPRTS: LD A,20H - JR QPRNT - - ; PRINT TAB - -QPRTT: CALL PRNTS - LD A,(DPRNT) - OR A - RET Z -L092C: SUB 10 - JR C,QPRTT - JR NZ,L092C - NOP - NOP - NOP - - ; PRINT - ; IN ACC=PRINT DATA (ASCII) - -QPRNT: CP 0DH ; CR - JR Z,QLTNL - PUSH BC - LD C,A - LD B,A - CALL QPRT - LD A,B - POP BC - RET - -MSGOK: DB "OK!\r" - - ; PRINT ROUTINE - ; 1 CHARACTER - ; INPUT:C=ASCII DATA (QDSP+QDPCT) - -QPRT: LD A,C - CALL QADCN ; ASCII TO DSPLAY - LD C,A - CP 0F0H - RET Z ; ZERO=ILLEGAL DATA - AND 0F0H ; MSD CHECK - CP 0C0H - LD A,C - JR NZ,PRNT3 - CP 0C7H - JR NC,PRNT3 ; CRT EDITOR -PRNT5: CALL QDPCT - CP 0C3H ; "->" - JR Z,PRNT4 - CP 0C5H ; HOME - JR Z,PRNT2 - CP 0C6H ; CLR - RET NZ -PRNT2: XOR A -L0968: LD (DPRNT),A - RET - -PRNT3: CALL QDSP -PRNT4: LD A,(DPRNT) ; TAB POINT+1 - INC A - CP COLW*2 - JR C,L0968 - SUB COLW*2 - JR L0968 - - ; FLASHING BYPASS 1 - -FLAS1: LD A,(FLASH) - JR FLAS2 - - ; BREAK SUBROUTINE BYPASS 1 - ; CTRL OR NOT KEY - -QBRK2: BIT 5,A ; NOT OR CTRL - JR Z,QBRK3 ; CTRL - OR A ; NOTKEY A=7FH - RET - -QBRK3: LD A,20H ; CTRL D5=1 - OR A ; ZERO FLG CLR - SCF - RET - -MSGSV: DB "FILENAME? " - DB 0DH - - ; DLY 7 MSEC -DLY12: PUSH BC - LD B,15H -L0999: CALL DLY3 - DJNZ L0999 - POP BC - RET - - ; LOADING MESSAGE - -MSGQ2: DB "LOADING \r" - - ; DELAY FOR LONG PULSE - -DLY4: LD A,59H ; 18*89+20 -L09AB: DEC A - JP NZ,L09AB - RET - - NOP - NOP - NOP - - ; KEY BOARD SEARCH - ; & DISPLAY CODE CONVERSION - ; EXIT A=DISPLAY CODE - ; CY=GRAPH MODE - ; WITH CURSOR DISPLAY - -QQKEY: PUSH HL - CALL QSAVE -KSL1: CALL FLKEY ; KEY - JR NZ,KSL1 ; KEY IN THEN JUMP -KSL2: CALL FLKEY - JR Z,KSL2 ; NOT KEY IN THEN JUMP - LD H,A - CALL DLY12 ; DELAY CHATTER - CALL QKEY - PUSH AF - CP H ; CHATTER CHECK - POP HL - JR NZ,KSL2 - PUSH HL - POP AF ; IN KEY DATA - CALL QLOAD ; FLASHING DATA LOAD - POP HL - RET - - ; CLEAR 2 - -NCLR08: XOR A ; CY FLAG -NCLR8: LD BC,0800H -CLEAR: PUSH DE ; BC=CLR BYTE SIZE, A=CLR DATA - LD D,A -CLEAR1: LD (HL),D - INC HL - DEC BC - LD A,B - OR C - JR NZ,CLEAR1 - POP DE - RET - - ; FLASHING 2 - -QFLS: PUSH AF - PUSH HL - LD A,(KEYPC) - RLCA - RLCA - JR C,FLAS1 - LD A,(FLSDT) -FLAS2: CALL QPONT ; DISPLAY POSITION - LD (HL),A - POP HL - POP AF - RET - - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - -QFLAS: JR QFLS - - ; SHORT AND LONG PULSE FOR 1 BIT WRITE - -SHORT: PUSH AF ; 12 - LD A,03H ; 9 - LD (CSTPT),A ; E003H PC3=1:16 - CALL DLY1 ; 20+18*21+20 - CALL DLY1 ; 20+18*21+20 - LD A,02H ; 9 - LD (CSTPT),A ; E003H PC3=0:16 - CALL DLY1 ; 20+18*21+20 - CALL DLY1 ; 20+18*21+20 - POP AF ; 11 - RET ; 11 - -LONG: PUSH AF ; 11 - LD A,03H ; 9 - LD (CSTPT),A ; 16 - CALL DLY4 ; 20+18*89+20 - LD A,02H ; 9 - LD (CSTPT),A ; 16 - CALL DLY4 ; 20+18*89+20 - POP AF ; 11 - RET ; 11 - - NOP - NOP - NOP - NOP - NOP - - ; BREAK KEY CHECK - ; AND SHIFT, CTRL KEY CHECK - ; EXIT BREAK ON : ZERO=1 - ; OFF: ZERO=0 - ; NO KEY : CY =0 - ; KEY IN : CY =1 - ; A D6=1 : SHIFT ON - ; =0 : OFF - ; D5=1 : CTRL ON - ; =0 : OFF - ; D4=1 : SHIFT+CNT ON - ; =0 : OFF - -QBRK: LD A,0F8H ; LINE 8SWEEP - LD (KEYPA),A - NOP - LD A,(KEYPB) - OR A - RRA - JP C,QBRK2 ; SHIFT ? - RLA - RLA - JR NC,QBRK1 ; BREAK ? - LD A,40H ; SHIFT D6=1 - SCF - RET - -QBRK1: XOR A ; SHIFT ? - RET - - ; 320 U SEC DELAY - -DLY3: LD A,3FH ; 18*63+33 - JP L0762 ; JP DLY2+2 - - NOP - - ; KEY BOARD SWEEP - ; EXIT B,D7=0 NO DATA - ; =1 DATA - ; D6=0 SHIFT OFF - ; =1 SHIFT ON - ; D5=0 CTRL OFF - ; =1 CTRL ON - ; D4=0 SHIFT+CTRL OFF - ; =1 SHIFT+CTRL ON - ; C = ROW & COLUMN - ; 7 6 5 4 3 2 1 0 - ; * * ^ ^ ^ < < < - -QSWEP: PUSH DE - PUSH HL - XOR A - LD B,0F8H - LD D,A - CALL QBRK - JR NZ,SWEP6 - LD D,88H ; BREAK ON - JR SWEP9 - -SWEP6: JR NC,SWEP0 - LD D,A - JR SWEP0 - -SWEP01: SET 7,D -SWEP0: DEC B - LD A,B - LD (KEYPA),A - CP 0EFH ; MAP SWEEP END ? - JR NZ,SWEP3 - CP 0F8H ; BREAK KEY ROW - JR Z,SWEP0 -SWEP9: LD B,D - POP HL - POP DE - RET - -SWEP3: LD A,(KEYPB) - CPL - OR A - JR Z,SWEP0 - LD E,A -SWEP2: LD H,8 - LD A,B - AND 0FH - RLCA - RLCA - RLCA - LD C,A - LD A,E -L0A89: DEC H - RRCA - JR NC,L0A89 - LD A,H - ADD A,C - LD C,A - JR SWEP01 - ; - ; - ; ASCII TO DISPLAY CODE TABL - ; -ATBL: - ; 00 - 0F - DB 0F0H ; ^ @ - DB 0F0H ; ^ A - DB 0F0H ; ^ B - DB 0F3H ; ^ C - DB 0F0H ; ^ D - DB 0F5H ; ^ E - DB 0F0H ; ^ F - DB 0F0H ; ^ G - DB 0F0H ; ^ H - DB 0F0H ; ^ I - DB 0F0H ; ^ J - DB 0F0H ; ^ K - DB 0F0H ; ^ L - DB 0F0H ; ^ M - DB 0F0H ; ^ N - DB 0F0H ; ^ O - ; 10 - 1F - DB 0F0H ; ^ P - DB 0C1H ; ^ Q CUR. DOWN - DB 0C2H ; ^ R CUR. UP - DB 0C3H ; ^ S CUR. RIGHT - DB 0C4H ; ^ T CUR. LEFT - DB 0C5H ; ^ U HOME - DB 0C6H ; ^ V CLEAR - DB 0F0H ; ^ W - DB 0F0H ; ^ X - DB 0F0H ; ^ Y - DB 0F0H ; ^ Z SEP. - DB 0F0H ; ^ [ - DB 0F0H ; ^ \ - DB 0F0H ; ^ ] - DB 0F0H ; ^ ^ - DB 0F0H ; ^ - - ; 20 - 2F - DB 00H ; SPACE - DB 61H ; ! - DB 62H ; " - DB 63H ; # - DB 64H ; $ - DB 65H ; % - DB 66H ; & - DB 67H ; ' - DB 68H ; ( - DB 69H ; ) - DB 6BH ; * - DB 6AH ; + - DB 2FH ; , - DB 2AH ; - - DB 2EH ; . - DB 2DH ; / - ; 30 - 3F - DB 20H ; 0 - DB 21H ; 1 - DB 22H ; 2 - DB 23H ; 3 - DB 24H ; 4 - DB 25H ; 5 - DB 26H ; 6 - DB 27H ; 7 - DB 28H ; 8 - DB 29H ; 9 - DB 4FH ; : - DB 2CH ; ; - DB 51H ; < - DB 2BH ; = - DB 57H ; > - DB 49H ; ? - ; 40 - 4F - DB 55H ; @ - DB 01H ; A - DB 02H ; B - DB 03H ; C - DB 04H ; D - DB 05H ; E - DB 06H ; F - DB 07H ; G - DB 08H ; H - DB 09H ; I - DB 0AH ; J - DB 0BH ; K - DB 0CH ; L - DB 0DH ; M - DB 0EH ; N - DB 0FH ; O - ; 50 - 5F - DB 10H ; P - DB 11H ; Q - DB 12H ; R - DB 13H ; S - DB 14H ; T - DB 15H ; U - DB 16H ; V - DB 17H ; W - DB 18H ; X - DB 19H ; Y - DB 1AH ; Z - DB 52H ; [ - DB 59H ; \ - DB 54H ; ] - DB 50H ; - DB 45H ; - ; 60 - 6F - DB 0C7H ; UFO - DB 0C8H - DB 0C9H - DB 0CAH - DB 0CBH - DB 0CCH - DB 0CDH - DB 0CEH - DB 0CFH - DB 0DFH - DB 0E7H - DB 0E8H - DB 0E5H - DB 0E9H - DB 0ECH - DB 0EDH - ; 70 - 7F - DB 0D0H - DB 0D1H - DB 0D2H - DB 0D3H - DB 0D4H - DB 0D5H - DB 0D6H - DB 0D7H - DB 0D8H - DB 0D9H - DB 0DAH - DB 0DBH - DB 0DCH - DB 0DDH - DB 0DEH - DB 0C0H - ; 80 - 8F - DB 80H ; } - DB 0BDH - DB 9DH - DB 0B1H - DB 0B5H - DB 0B9H - DB 0B4H - DB 9EH - DB 0B2H - DB 0B6H - DB 0BAH - DB 0BEH - DB 9FH - DB 0B3H - DB 0B7H - DB 0BBH - ; 90 - 9F - DB 0BFH ; _ - DB 0A3H - DB 85H - DB 0A4H ; ` - DB 0A5H ; ~ - DB 0A6H - DB 94H - DB 87H - DB 88H - DB 9CH - DB 82H - DB 98H - DB 84H - DB 92H - DB 90H - DB 83H - ; A0 - AF - DB 91H - DB 81H - DB 9AH - DB 97H - DB 93H - DB 95H - DB 89H - DB 0A1H - DB 0AFH - DB 8BH - DB 86H - DB 96H - DB 0A2H - DB 0ABH - DB 0AAH - DB 8AH - ; B0 - BF - DB 8EH - DB 0B0H - DB 0ADH - DB 8DH - DB 0A7H - DB 0A8H - DB 0A9H - DB 8FH - DB 8CH - DB 0AEH - DB 0ACH - DB 9BH - DB 0A0H - DB 99H - DB 0BCH ; { - DB 0B8H - ; C0 - CF - DB 40H - DB 3BH - DB 3AH - DB 70H - DB 3CH - DB 71H - DB 5AH - DB 3DH - DB 43H - DB 56H - DB 3FH - DB 1EH - DB 4AH - DB 1CH - DB 5DH - DB 3EH - ; D0 - DF - DB 5CH - DB 1FH - DB 5FH - DB 5EH - DB 37H - DB 7BH - DB 7FH - DB 36H - DB 7AH - DB 7EH - DB 33H - DB 4BH - DB 4CH - DB 1DH - DB 6CH - DB 5BH - ; E0 - EF - DB 78H - DB 41H - DB 35H - DB 34H - DB 74H - DB 30H - DB 38H - DB 75H - DB 39H - DB 4DH - DB 6FH - DB 6EH - DB 32H - DB 77H - DB 76H - DB 72H - ; F0 - FF - DB 73H - DB 47H - DB 7CH - DB 53H - DB 31H - DB 4EH - DB 6DH - DB 48H - DB 46H - DB 7DH - DB 44H - DB 1BH - DB 58H - DB 79H - DB 42H - DB 60H - - ; FLASHING DATA SAVE - -QSAVE: LD HL,FLSDT - LD (HL),0EFH ; NORMAL CURSOR - LD A,(KANAF) - RRCA - JR C,L0BA0 ; GRAPH MODE - RRCA - JR NC,SV0 ; NORMAL MODE -L0BA0: LD (HL),0FFH ; GRAPH CURSOR -SV0: LD A,(HL) - PUSH AF - CALL QPONT ; FLASHING POSITION - LD A,(HL) - LD (FLASH),A - POP AF - LD (HL),A - XOR A - LD HL,KEYPA -L0BB1: LD (HL),A - CPL ; OH NO! UNUSED BITS WERE TOUCHED TOO!!! - LD (HL),A - RET - -SV1: LD (HL),43H ; KANA CURSOR - JR SV0 - - ; ASCII TO DISPLAY CODE CONVERT - ; IN ACC:ASCII - ; EXIT ACC:DISPLAY CODE - -QADCN: PUSH BC - PUSH HL - LD HL,ATBL - LD C,A - LD B,0 - ADD HL,BC - LD A,(HL) - JR DACN3 - -VRNS: DB "V1.0A\r" ; VERSION MANAGEMENT - NOP - NOP - NOP - - ; DISPLAY CODE TO ASCII CONVERSION - ; IN ACC=DISPLAY CODE - ; EXIT ACC=ASCII - -QDACN: PUSH BC - PUSH HL - PUSH DE - LD HL,ATBL - LD D,H - LD E,L - LD BC,0100H - CPIR - JR Z,DACN1 - LD A,0F0H -DACN2: POP DE -DACN3: POP HL - POP BC - RET - -DACN1: OR A - DEC HL - SBC HL,DE - LD A,L - JR DACN2 - - ; - ; - ; KEY MATRIX TO DISPLAY CODE TABL - ; -KTBL: - ;S0 00 - 07 - DB 0BFH ; SPARE - DB 0CAH ; GRAPH - DB 58H ; - DB 0C9H ; ALPHA - DB 0F0H ; NO - DB 2CH ; ; - DB 4FH ; : - DB 0CDH ; CR - ;S1 08 - 0F - DB 19H ; Y - DB 1AH ; Z - DB 55H ; @ - DB 52H ; [ - DB 54H ; ] - DB 0F0H ; NULL - DB 0F0H ; NULL - DB 0F0H ; NULL - ;S2 10 - 17 - DB 11H ; Q - DB 12H ; R - DB 13H ; S - DB 14H ; T - DB 15H ; U - DB 16H ; V - DB 17H ; W - DB 18H ; X - ;S3 18 - 1F - DB 09H ; I - DB 0AH ; J - DB 0BH ; K - DB 0CH ; L - DB 0DH ; M - DB 0EH ; N - DB 0FH ; O - DB 10H ; P - ;S4 20 - 27 - DB 01H ; A - DB 02H ; B - DB 03H ; C - DB 04H ; D - DB 05H ; E - DB 06H ; F - DB 07H ; G - DB 08H ; H - ;S5 28 - 2F - DB 21H ; 1 - DB 22H ; 2 - DB 23H ; 3 - DB 24H ; 4 - DB 25H ; 5 - DB 26H ; 6 - DB 27H ; 7 - DB 28H ; 8 - ;S6 30 - 37 - DB 59H ; \ - DB 50H ; - DB 2AH ; - - DB 00H ; SPACE - DB 20H ; 0 - DB 29H ; 9 - DB 2FH ; , - DB 2EH ; . - ;S7 38 - 3F - DB 0C8H ; INST. - DB 0C7H ; DEL. - DB 0C2H ; CURSOR UP - DB 0C1H ; CURSOR DOWN - DB 0C3H ; CURSOR RIGHT - DB 0C4H ; CURSOR LEFT - DB 49H ; ? - DB 2DH ; / - ; - ; - ; KTBL SHIFT ON - ; -KTBLS: - ;S0 00 - 07 - DB 0BFH ; SPARE - DB 0CAH ; GRAPH - DB 1BH ; POND - DB 0C9H ; ALPHA - DB 0F0H ; NO - DB 6AH ; + - DB 6BH ; * - DB 0CDH ; CR - ;S1 08 - 0F - DB 99H ; y - DB 9AH ; z - DB 0A4H ; ` - DB 0BCH ; { - DB 40H ; } - DB 0F0H ; NULL - DB 0F0H ; NULL - DB 0F0H ; NULL - ;S2 10 - 17 - DB 91H ; q - DB 92H ; r - DB 93H ; s - DB 94H ; t - DB 95H ; u - DB 96H ; v - DB 97H ; w - DB 98H ; x - ;S3 18 - 1F - DB 89H ; i - DB 8AH ; j - DB 8BH ; k - DB 8CH ; l - DB 8DH ; m - DB 8EH ; n - DB 8FH ; o - DB 90H ; p - ;S4 20 - 27 - DB 81H ; a - DB 82H ; b - DB 83H ; c - DB 84H ; d - DB 85H ; e - DB 86H ; f - DB 87H ; g - DB 88H ; h - ;S5 28 - 2F - DB 61H ; ! - DB 62H ; " - DB 63H ; # - DB 64H ; $ - DB 65H ; % - DB 66H ; & - DB 67H ; ' - DB 68H ; ( - ;S6 30 - 37 - DB 80H ; \ - DB 0A5H ; POND MARK - DB 2BH ; YEN - DB 00H ; SPACE - DB 60H ; ¶ - DB 69H ; ) - DB 51H ; < - DB 57H ; > - ;S7 38 - 3F - DB 0C6H ; CLR - DB 0C5H ; HOME - DB 0C2H ; CURSOR UP - DB 0C1H ; CURSOR DOWN - DB 0C3H ; CURSOR RIGHT - DB 0C4H ; CURSOR LEFT - DB 5AH ; - DB 45H ; - ; - ; - ; GRAPHIC - ; -KTBLGS: - ;S0 00 - 07 - DB 0BFH ; SPARE - DB 0F0H ; GRAPH BUT NULL - DB 0E5H ; # - DB 0C9H ; ALPHA - DB 0F0H ; NO - DB 42H ; # ; - DB 0B6H ; #: - DB 0CDH ; CR - ;S1 08 - 0F - DB 75H ; #Y - DB 76H ; #Z - DB 0B2H ; #@ - DB 0D8H ; #[ - DB 4EH ; #] - DB 0F0H ; #NULL - DB 0F0H ; #NULL - DB 0F0H ; #NULL - ;S2 10 - 17 - DB 3CH ; #Q - DB 30H ; #R - DB 44H ; #S - DB 71H ; #T - DB 79H ; #U - DB 0DAH ; #V - DB 38H ; #W - DB 6DH ; #X - ;S3 18 - 1F - DB 7DH ; #I - DB 5CH ; #J - DB 5BH ; #K - DB 0B4H ; #L - DB 1CH ; #M - DB 32H ; #N - DB 0B0H ; #O - DB 0D6H ; #P - ;S4 20 - 27 - DB 53H ; #A - DB 6FH ; #B - DB 0DEH ; #C - DB 47H ; #D - DB 34H ; #E - DB 4AH ; #F - DB 4BH ; #G - DB 72H ; #H - ;S5 28 - 2F - DB 37H ; #1 - DB 3EH ; #2 - DB 7FH ; #3 - DB 7BH ; #4 - DB 3AH ; #5 - DB 5EH ; #6 - DB 1FH ; #7 - DB 0BDH ; #8 - ;S6 30 - 37 - DB 0D4H ; #YEN - DB 9EH ; #+ - DB 0D2H ; #- - DB 00H ; SPACE - DB 9CH ; #0 - DB 0A1H ; #9 - DB 0CAH ; #, - DB 0B8H ; #. - ;S7 38 - 3F - DB 0C8H ; INST - DB 0C7H ; DEL. - DB 0C2H ; CURSOR UP - DB 0C1H ; CURSOR DOWN - DB 0C3H ; CURSOR RIGHT - DB 0C4H ; CURSOR LEFT - DB 0BAH ; #? - DB 0DBH ; #/ - ; - ; - ; CONTROL CODE - ; -KTBLC: - ;S0 00 - 07 - DB 0F0H - DB 0F0H - DB 0F0H ; ^ - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - ;S1 08 - 0F - DB 0F0H ; ^Y E3 - DB 5AH ; ^Z E4 (CHECKER) - DB 0F0H ; ^@ - DB 0F0H ; ^[ EB/E5 - DB 0F0H ; ^] EA/E7 - DB 0F0H ; #NULL - DB 0F0H ; #NULL - DB 0F0H ; #NULL - ;S2 10 - 17 - DB 0C1H ; ^Q - DB 0C2H ; ^R - DB 0C3H ; ^S - DB 0C4H ; ^T - DB 0C5H ; ^U - DB 0C6H ; ^V - DB 0F0H ; ^W E1 - DB 0F0H ; ^X E2 - ;S3 18 - 1F - DB 0F0H ; ^I F9 - DB 0F0H ; ^J FA - DB 0F0H ; ^K FB - DB 0F0H ; ^L FC - DB 0F0H ; ^M CD - DB 0F0H ; ^N FE - DB 0F0H ; ^O FF - DB 0F0H ; ^P E0 - ;S4 20 - 27 - DB 0F0H ; ^A F1 - DB 0F0H ; ^B F2 - DB 0F0H ; ^C F3 - DB 0F0H ; ^D F4 - DB 0F0H ; ^E F5 - DB 0F0H ; ^F F6 - DB 0F0H ; ^G F7 - DB 0F0H ; ^H F8 - ;S5 28 - 2F - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - ;S6 30 - 37 (ERROR? 7 VALUES ONLY!!) - DB 0F0H ; ^YEN E6 - DB 0F0H ; ^ EF - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H ; ^, - DB 0F0H - ;S7 38 - 3F - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H ; ^/ EE - ; - ; - ; KANA - ; -KTBLG: - ;S0 00 - 07 - DB 0BFH ; SPARE - DB 0F0H ; GRAPH BUT NULL - DB 0CFH ; NIKO WH. - DB 0C9H ; ALPHA - DB 0F0H ; NO - DB 0B5H ; MO - DB 4DH ; DAKU TEN - DB 0CDH ; CR - ;S1 08 - 0F - DB 35H ; HA - DB 77H ; TA - DB 0D7H ; WA - DB 0B3H ; YO - DB 0B7H ; HANDAKU - DB 0F0H - DB 0F0H - DB 0F0H - ;S2 10 - 17 - DB 7CH ; KA - DB 70H ; KE - DB 41H ; SHI - DB 31H ; KO - DB 39H ; HI - DB 0A6H ; TE - DB 78H ; KI - DB 0DDH ; CHI - ;S3 18 - 1F - DB 3DH ; FU - DB 5DH ; MI - DB 6CH ; MU - DB 56H ; ME - DB 1DH ; RHI - DB 33H ; RA - DB 0D5H ; HE - DB 0B1H ; HO - ;S4 20 - 27 - DB 46H ; SA - DB 6EH ; TO - DB 0D9H ; THU - DB 48H ; SU - DB 74H ; KU - DB 43H ; SE - DB 4CH ; SO - DB 73H ; MA - ;S5 28 - 2F - DB 3FH ; A - DB 36H ; I - DB 7EH ; U - DB 3BH ; E - DB 7AH ; O - DB 1EH ; NA - DB 5FH ; NI - DB 0A2H ; NU - ;S6 30 - 37 - DB 0D3H ; YO - DB 9FH ; YU - DB 0D1H ; YA - DB 00H ; SPACE - DB 9DH ; NO - DB 0A3H ; NE - DB 0D0H ; RU - DB 0B9H ; RE - ;S7 38 - 3F - DB 0C6H ; ?CLR - DB 0C5H ; ?HOME - DB 0C2H ; ?CURSOR UP - DB 0C1H ; ?CURSOR DOWN - DB 0C3H ; ?CURSOR RIGHT - DB 0C4H ; ?CURSOR LEFT - DB 0BBH ; DASH - DB 0BEH ; RO - - ; MEMORY DUMP COMMAND "D" - -DUMP: CALL HEXIY ; START ADDRESS - CALL P4DE - PUSH HL - CALL HLHEX ; END ADDRESS - POP DE - JR C,DUM1 ; DATA ERROR THEN -L0D36: EX DE,HL -DUM3: LD B,08H ; DISPLAY 8 BYTES - LD C,23 ; CHANGE PRINT BIAS - CALL NLPHL ; NEWLINE PRINT -DUM2: CALL SPHEX ; SPACE PRINT + ACC PRINT - INC HL - PUSH AF - LD A,(DSPXY) ; DISPLAY POINT - ADD A,C - LD (DSPXY),A ; X AXIS=X+CREG - POP AF - CP 20H - JR NC,L0D51 - LD A,2EH ; "." -L0D51: CALL QADCN ; ASCII TO DISPLAY CODE - CALL PRNT3 - LD A,(DSPXY) - INC C - SUB C ; ASCII DISPLAY POSITION - LD (DSPXY),A - DEC C - DEC C - DEC C - PUSH HL - SBC HL,DE - POP HL - JR Z,L0D85 - LD A,0F8H - LD (KEYPA),A - NOP - LD A,(KEYPB) - CP 0FEH ; SHIFT KEY ? - JR NZ,L0D78 - CALL QBLNK ; 64MSEC DELAY -L0D78: DJNZ DUM2 -L0D7A: CALL QKEY ; STOP DISPLAY - OR A - JR Z,L0D7A ; SPACE KEY THEN STOP - CALL QBRK ; BREAK IN ? - JR NZ,DUM3 -L0D85: JP ST1 ; COMMAND IN ! - -DUM1: LD HL,160 ; 20*8 BYTES - ADD HL,DE - JR L0D36 - - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - - ; V-BLANK CHECK - -QBLNK: PUSH AF -L0DA7: LD A,(KEYPC) ; V-BLANK - RLCA - JR NC,L0DA7 -L0DAD: LD A,(KEYPC) ; 64 - RLCA ; - JR C,L0DAD ; MSEC - POP AF - RET - ; DISPLAY ON POINTER - ; ACC=DISPLAY CODE - ; EXCEPT F0H - -QDSP: PUSH AF - PUSH BC - PUSH DE - PUSH HL -DSP01: CALL QPONT ; DISPLAY POSITION - LD (HL),A - LD HL,(DSPXY) - LD A,L - CP COLW-1 - JR NZ,DSP04 - CALL PMANG - JR C,DSP04 - EX DE,HL - LD (HL),1 ; LOGICAL 1ST COLUMN - INC HL - LD (HL),0 ; LOGICAL 2ND COLUMN -DSP04: LD A,0C3H ; CURSL - JR L0DE0 - - ; GRAPHIC STATUS CHECK - -GRSTAS: LD A,(KANAF) - CP 01H - LD A,0CAH - RET - - ; DISPLAY CONTROL - ; ACC=CONTROL CODE - -QDPCT: PUSH AF - PUSH BC - PUSH DE - PUSH HL -L0DE0: LD B,A - AND 0F0H - CP 0C0H - JR NZ,CURS5 - XOR B - RLCA - LD C,A - LD B,0 - LD HL,CTBL ; PAGE MODE1 - ADD HL,BC - LD E,(HL) - INC HL - LD D,(HL) - LD HL,(DSPXY) - EX DE,HL - JP (HL) - -CURSD: EX DE,HL ; LD HL,(DSPXY) - LD A,H - CP 24 - JR Z,CURS4 - INC H -CURS1: -CURS3: LD (DSPXY),HL -CURS5: JP QRSTR - -CURSU: EX DE,HL ; LD HL,(DSPXY) - LD A,H - OR A - JR Z,CURS5 - DEC H -CURSU1: JR CURS3 - -CURSR: EX DE,HL ; LD HL,(DSPXY) - LD A,L - CP COLW-1 - JR NC,CURS2 - INC L - JR CURS3 - -CURS2: LD L,0 - INC H - LD A,H - CP 25 - JR C,CURS1 - LD H,24 - LD (DSPXY),HL -CURS4: JR SCROL - -CURSL: EX DE,HL ; LD HL,(DSPXY) - LD A,L - OR A - JR Z,L0E2D - DEC L - JR CURS3 - -L0E2D: LD L,COLW-1 - DEC H - JP P,CURSU1 - LD H,0 - LD (DSPXY),HL - JR CURS5 - -CLRS: LD HL,MANG - LD B,27 - CALL QCLER - LD HL,0D000H ; SCRN TOP - CALL NCLR08 - IF MODE80C = 0 - LD A,017H ; Black background, white characters. Bit 7 is clear as a write to bit 7 @ DFFFH selects 40Char mode. - ELSE - LD A,017H ; Blue background, white characters in colour mode. Bit 7 is set as a write to bit 7 @ DFFFH selects 80Char mode. - ENDIF - ;LD A,71H ; COLOR DATA - CALL NCLR8 ; D800H-DFFFH CLEAR -HOME: LD HL,0 ; DSPXY:0 X=0,Y=0 - JR CURS3 - - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - - ; CR - -CR: CALL PMANG - RRCA - JR NC,CURS2 - LD L,0 - INC H - CP 24 - JR Z,CR1 - INC H - JR CURS1 - -CR1: LD (DSPXY),HL - - ; SCROLL - -SCROL: LD BC,SCRNSZ - COLW - LD DE,SCRN ; TOP OF $CRT ADDRESS - LD HL,SCRN+COLW ; COLUMN - PUSH BC ; 1000 STORE - LDIR - POP BC - PUSH DE - LD DE,SCRN + 800H ; COLOR RAM SCROLL - LD HL,SCRN + 800H + COLW ; SCROLL TOP + 1 LINE - LDIR - LD B,COLW ; ONE LINE - EX DE,HL - IF MODE80C = 0 - LD A,017H ; Black background, white characters. Bit 7 is clear as a write to bit 7 @ DFFFH selects 40Char mode. - ELSE - LD A,017H ; Blue background, white characters in colour mode. Bit 7 is set as a write to bit 7 @ DFFFH selects 80Char mode. - ENDIF - ;LD A,71H ; COLOR RAM INITIAL DATA - CALL QDINT - POP HL - LD B,COLW - CALL QCLER ; LAST LINE CLEAR - LD BC,ROW + 1 ; ROW NUMBER+1 - LD DE,MANG ; LOGICAL MANAGEMENT - LD HL,MANG+1 - LDIR - LD (HL),0 - LD A,(MANG) - OR A - JR Z,QRSTR - LD HL,DSPXY+1 - DEC (HL) - JR SCROL - - ; CONTROL CODE TABLE - -CTBL: DW SCROL ; SCROLLING 10H - DW CURSD ; CURSOR DOWN 11H - DW CURSU ; CURSOR UP 12H - DW CURSR ; CURSOR RIGHT 13H - DW CURSL ; CURSOR LEFT 14H - DW HOME ; 15H - DW CLRS ; 16H - DW DEL ; 17H - DW INST ; 18H - DW ALPHA ; 19H - DW KANA ; GRAPHIC 1AH - DW QRSTR ; 1BH - DW QRSTR ; 1CH - DW CR ; 1DH - DW QRSTR ; 1EH - DW QRSTR ; 1FH - - ; INST BYPASS - -INST2: SET 3,H ; COLOR RAM - LD A,(HL) ; FROM - INC HL - LD (HL),A ; TO - DEC HL ; ADDRESS ADJUST - RES 3,H - LDD ; CHANGE TRNS. - LD A,C - OR B ; BC=0 ? - JR NZ,INST2 - EX DE,HL - LD (HL),0 - SET 3,H ; COLOR RAM - IF MODE80C = 0 - LD (HL),17H ; Black background, white characters. Bit 7 is clear as a write to bit 7 @ DFFFH selects 40Char mode. - ELSE - LD (HL),17H ; Blue background, white characters in colour mode. Bit 7 is set as a write to bit 7 @ DFFFH selects 80Char mode. - ENDIF - ;LD (HL),71H - JR QRSTR - -ALPHA: XOR A -ALPH1: LD (KANAF),A - - ; RESTORE - -QRSTR: POP HL -QRSTR1: POP DE - POP BC - POP AF - RET - - NOP - NOP - NOP - NOP - -KANA: CALL GRSTAS - JP Z,DSP01 ; NOT GRAPH KEY THEN JUMP - LD A,01H - JR ALPH1 - -DEL: EX DE,HL ; LD HL,(DSPXY) - LD A,H ; HOME ? - OR L - JR Z,QRSTR - LD A,L - OR A - JR NZ,DEL1 ; LEFT SIDE ? - CALL PMANG - JR C,DEL1 - CALL QPONT - DEC HL - LD (HL),0 - JR L0F33 ; JUMP CURSL - -DEL1: CALL PMANG - RRCA - LD A,COLW - JR NC,L0F17 - RLCA ; ACC=80 -L0F17: SUB L - LD B,A ; TRNS. BYTE - CALL QPONT -DEL2: LD A,(HL) ; CHANGE FROM ADDRESS - DEC HL - LD (HL),A ; TO - INC HL - SET 3,H ; COLOR RAM - LD A,(HL) - DEC HL - LD (HL),A - RES 3,H ; CHANGE - INC HL - INC HL ; NEXT - DJNZ DEL2 - DEC HL ; ADDRESS ADJUST - LD (HL),0 - SET 3,H - IF MODE80C = 0 - LD HL,017H ; Black background, white characters. Bit 7 is clear as a write to bit 7 @ DFFFH selects 40Char mode. - ELSE - LD HL,017H ; Blue background, white characters in colour mode. Bit 7 is set as a write to bit 7 @ DFFFH selects 80Char mode. - ENDIF - ;LD HL,71H ; BLUE + WHITE -L0F33: LD A,0C4H ; JP CURSL - JP L0DE0 - -INST: CALL PMANG - RRCA - LD L,COLW - 1 - LD A,L - JR NC,L0F42 - INC H -L0F42: CALL QPNT1 - PUSH HL - LD HL,(DSPXY) - JR NC,L0F4D - LD A,(COLW*2) - 1 -L0F4D: SUB L - LD B,0 - LD C,A - POP DE - JR Z,QRSTR - LD A,(DE) - OR A - JR NZ,QRSTR - LD H,D ; HL<-DE - LD L,E - DEC HL - JP INST2 ; JUMP NEXT (BYPASS) - - ; PROGRAM SAVE - ; COMMAND "S" - -SAVE: CALL HEXIY ; START ADDRESS - LD (DTADR),HL ; DATA ADDRESS BUFFER - LD B,H - LD C,L - CALL P4DE - CALL HEXIY ; END ADDRESS - SBC HL,BC ; BYTE SIZE - INC HL - LD (SIZE),HL ; BYTE SIZE BUFFER - CALL P4DE - CALL HEXIY ; EXECUTE ADDRESS - LD (EXADR),HL ; BUFFER - CALL NL - LD DE,MSGSV ; SAVED FILENAME - RST 18H ; CALL MSGX - CALL BGETL ; FILENAME INPUT - CALL P4DE - CALL P4DE - LD HL,NAME ; NAME BUFFER -SAV1: INC DE - LD A,(DE) - LD (HL),A ; FILENAME TRANS. - INC HL - CP 0DH ; END CODE - JR NZ,SAV1 - LD A,01H ; ATTRIBUTE: OBJECT CODE - LD (ATRB),A - CALL QWRI - JP C,QER ; WRITE ERROR - CALL QWRD ; DATA - JP C,QER - CALL NL - LD DE,MSGOK ; OK MESSAGE - RST 18H ; CALL MSGX - JP ST1 - - ; COMPUTE POINT ADDRESS - ; HL=SCREEN COORDINATE - ; EXIT HL=POINT ADDRESS ON SCREEN - -QPONT: LD HL,(DSPXY) -QPNT1: PUSH AF - PUSH BC - PUSH DE - PUSH HL - POP BC - LD DE,COLW ; 40 - LD HL,SCRN-COLW -QPNT2: ADD HL,DE - DEC B - JP P,QPNT2 - LD B,0 - ADD HL,BC - POP DE - POP BC - POP AF - RET - - ; VERIFYING COMMAND "V" - -VRFY: CALL QVRFY - JP C,QER - LD DE,MSGOK - RST 18H - JP ST1 - - ; CLER - ; B=SIZE - ; HL=LOW ADDRESS - -QCLER: XOR A - JR QDINT - -QCLRFF: LD A,0FFH -QDINT: LD (HL),A - INC HL - DJNZ QDINT - RET - - ; GAP CHECK - -GAPCK: PUSH BC - PUSH DE - PUSH HL - LD BC,KEYPB - LD DE,CSTR -GAPCK1: LD H,100 -GAPCK2: CALL EDGE - JR C,GAPCK3 - CALL DLY3 ; CALL DLY2*3 - LD A,(DE) - AND 20H - JR NZ,GAPCK1 - DEC H - JR NZ,GAPCK2 -GAPCK3: JP RET3 - - ; MONITOR WORK AREA - ; (MZ700) - - ORG 10F0H -SPV: -IBUFE: ; TAPE BUFFER (128 BYTES) -ATRB: DS virtual 1 ; ATTRIBUTE -NAME: DS virtual 17 ; FILE NAME -SIZE: DS virtual 2 ; BYTESIZE -DTADR: DS virtual 2 ; DATA ADDRESS -EXADR: DS virtual 2 ; EXECUTION ADDRESS -COMNT: DS virtual 104 ; COMMENT -KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) -DSPXY: DS virtual 2 ; DISPLAY COORDINATES -MANG: DS virtual 27 ; COLUMN MANAGEMENT -FLASH: DS virtual 1 ; FLASHING DATA -FLPST: DS virtual 2 ; FLASHING POSITION -FLSST: DS virtual 1 ; FLASHING STATUS -FLSDT: DS virtual 1 ; CURSOR DATA -STRGF: DS virtual 1 ; STRING FLAG -DPRNT: DS virtual 1 ; TAB COUNTER -TMCNT: DS virtual 2 ; TAPE MARK COUNTER -SUMDT: DS virtual 2 ; CHECK SUM DATA -CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA -AMPM: DS virtual 1 ; AMPM DATA -TIMFG: DS virtual 1 ; TIME FLAG -SWRK: DS virtual 1 ; KEY SOUND FLAG -TEMPW: DS virtual 1 ; TEMPO WORK -ONTYO: DS virtual 1 ; ONTYO WORK -OCTV: DS virtual 1 ; OCTAVE WORK -RATIO: DS virtual 2 ; ONPU RATIO -BUFER: DS virtual 81 ; GET LINE BUFFER - - ; EQU TABLE I/O REPORT - -KEYPA: EQU 0E000H -KEYPB: EQU 0E001H -KEYPC: EQU 0E002H -KEYPF: EQU 0E003H -CSTR: EQU 0E002H -CSTPT: EQU 0E003H -CONT0: EQU 0E004H -CONT1: EQU 0E005H -CONT2: EQU 0E006H -CONTF: EQU 0E007H -SUNDG: EQU 0E008H -TEMP: EQU 0E008H - ; MONITOR WORK AREA - -SCRN: EQU 0D000H -KANST: EQU 0E003H ; KANA STATUS REPORT - - diff --git a/software/asm/cbios.asm b/software/asm/cbios.asm deleted file mode 100644 index 2538d02..0000000 --- a/software/asm/cbios.asm +++ /dev/null @@ -1,2638 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: cbios.asm -;- Created: January 2020 -;- Author(s): Philip Smart -;- Description: Sharp MZ series CPM BIOS System. -;- This is the CPM CBIOS for the Sharp MZ80A hardware plus RFS/80 char upgrades. -;- It makes extensive use of the paged roms to add functionality and conserve -;- RAM for the CPM applications. -;- -;- Credits: Some of the comments and parts of the standard CPM deblocking/blocking algorithm -;- come from the Z80-MBC2 project, (C) SuperFabius. -;- Copyright: (c) 2018-23 Philip Smart -;- -;- History: Jan 2020 - Seperated Bank from RFS for dedicated use with CPM CBIOS. -;- May 2020 - Advent of the new RFS PCB v2.0, quite a few changes to accommodate the -;- additional and different hardware. The SPI is now onboard the PCB and -;- not using the printer interface card. -;- Mar 2021 - Updates for the RFS v2.1 board. -;- Apr 2021 - Removed ROM and RAM Drive functionality as it provided no performance or -;- use benefit over SD which are much larger and RW. -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - ; Bring in definitions and macros. - INCLUDE "cpm_buildversion.asm" - INCLUDE "cpm_definitions.asm" - INCLUDE "macros.asm" - - ORG CBIOSSTART - - ;---------------------------------------------------------------------------------------------------------------------------------------------- - ; CBIOS organisation. - ; - ; Source File Size ROM Type Address Location Description - ; cbios.asm 4K MROM (relocated CBIOS providing the CP/M API, initialisation routines, ROM Disk - ; Monitor ROM from controller routines, Interrupt routines. - ; 0x0000 - 0x0FFF) 0xC000 - 0xCFFF MRON Bank 2 - ; cbios_bank1.asm 2K Paged ROM 0xE800 - 0xEFFF, UROM Bank 8 Basic Sound and Melody, RTC, Keyboard and helper functionality. - ; cbios_bank2.asm 2k Paged ROM 0xE800 - 0xEFFF, UROM Bank 9 Screen I/O and ANSI Terminal Parser. - ; cbios_bank2.asm 2k Paged ROM 0xE800 - 0xEFFF, UROM Bank 10 SD Card Controller functionality. - ; cbios_bank2.asm 2k Paged ROM 0xE800 - 0xEFFF, UROM Bank 11 Floppy Disk Controller functionality. - ;---------------------------------------------------------------------------------------------------------------------------------------------- - - ;------------------------------------------------------------------------------- - ; - ; BIOS jump table - ; - ;------------------------------------------------------------------------------- - JP BOOT_ - JP WBOOT_ - JP CONST_ - JP CONIN_ - JP CONOUT_ - JP LIST_ - JP PUNCH_ - JP READER_ - JP HOME_ - JP SELDSK_ - JP SETTRK_ - JP SETSEC_ - JP SETDMA_ - JP READ_ - JP WRITE_ - JP LISTST_ - JP SECTRN_ - NOP - NOP - RET - JP BANKTOBANK_ - -; Methods to access public functions in paged User Rom. The User Rom bank -; is switched in and a jump made to the public function. The page remains -; selected until the next public access call and the page changed accordingly. - - ; CBIOS Bank 1 - Utilities and Audio. -BANK8: PUSH AF - LD A,ROMBANK8 - LD (BNKSELUSER),A - POP AF - RET - ; CBIOS Bank 2 - Screen / ANSI Terminal -BANK9: PUSH AF - LD A,ROMBANK9 - LD (BNKSELUSER),A - POP AF - RET - ; CBIOS Bank 3 - SD Card. -BANK10: PUSH AF - LD A,ROMBANK10 - LD (BNKSELUSER),A - POP AF - RET - ; CBIOS Bank 4 -BANK11: PUSH AF - LD A,ROMBANK11 - LD (BNKSELUSER),A - POP AF - RET - - ; Method to allow one bank to call a routine in another bank. It is costly in processing time - ; and should only be used infrequently. - ; - ; Input: A [7:4] = Bank to Call - ; [3:0] = Calling Bank. - ; HL = Address to call. - ; AF = Stored on stack to pass to called function. - ; All other registers passed to called function. - ; Stack; +2 = AF - ; Output: All registers and flags returned to caller. - ; -BANKTOBANK_:LD (USRBANKSAV),A ; Save the bank we return to. - SRL A ; Switch to required bank. - SRL A - SRL A - SRL A - LD (BNKSELUSER),A - LD (HLSAVE),HL ; Save HL (exec address) whilst we get AF from stack. - POP HL ; HL = return address in original bank. - POP AF ; AF to pass to called routine. - PUSH HL ; Restore return address onto stack. - LD HL,BKTOBKRET ; Push the address t - PUSH HL ; Called routine must return to this method so we can switch back the banks. - LD HL,(HLSAVE) ; Get address to call. - JP (HL) ; No execute called routine -BKTOBKRET: PUSH AF - LD A,(USRBANKSAV) - AND 00FH ; We just want the bank number we are returning to. - LD (BNKSELUSER),A ; Switch back bank. - POP AF ; Restore A and flags to pass back to caller. - RET - - -; Public methods for User Rom CBIOS Bank 1 - Utility functions. -?REBOOT: LD A,(ROMCTL) ; Make sure Flash RAM I is active. - AND 03FH - LD (ROMCTL),A - LD A,ROMBANK8 ; Method to exit CPM and return to the Sharp MZ80A Monitor. - SCF - CALL SELUSRBNK ; Ensure Rom Control is enabled - JP QREBOOT ; Reboot has to take place from User ROM as the monitor ROM is swapped back to default position. - -?MLDY: CALL BANK8 ; Method to sound a melody given an input array of notes to play. - JP QMELDY - -?BEL: CALL BANK8 ; Method to sound a bell. - JP QBEL - -?TEMP: CALL BANK8 ; Method to set the playback tempo. - JP QTEMP - -?MLDST: CALL BANK8 ; Method to start playing a melody. - JP QMSTA - -?MLDSP: CALL BANK8 ; Method to stop playing a melody. - JP QMSTP - -?MODE: CALL BANK8 ; Method to setup the 8255 PIO. - JP QMODE - -?TIMESET: CALL BANK8 ; Method to setup the RTC. - JP QTIMESET - -?TIMEREAD: CALL BANK8 ; Method to read the RTC. - JP QTIMEREAD - -?CHKKY: CALL BANK8 ; Method to see if a key has been pressed or available in the key buffer. - JP QCHKKY - -?GETKY: CALL BANK8 ; Method to get the next key from the key buffer or wait until one is pressed. - JP QGETKY - - -; Public methods for User Rom CBIOS Bank 2 - Screen / ANSI Terminal functions. - -?PRNT: CALL BANK9 ; Print a character onto the screen at current X/Y location. - JP QPRNT - -?PRTHX: CALL BANK9 ; Print register A onto screen as 2 hex digits. - JP QPRTHX - -?PRTHL: CALL BANK9 ; Print register HL onto screen as 4 hex digits. - JP QPRTHL - -?ANSITERM: CALL BANK9 ; Send character into the ANSI terminal emulator and process. - JP QANSITERM - -?NL: LD A,LF ; Print a newline. - JR ?PRNT - -?PRTS: LD A,SPACE ; Print a space. - JR ?PRNT - -; Public methods for User ROM CBIOS Bank 3 - SD Card functions. - -?SDINIT: CALL BANK10 ; Initialise the SD Card subsystem - JP SD_INIT - -?SDREAD: CALL BANK10 ; Read a full or partial sector (512 bytes). - JP SD_READ - -?SDWRITE: CALL BANK10 ; Write a full or partial sector (512 bytes). - JP SD_WRITE - -?SDGETLBA: CALL BANK10 ; Get the LBA address for the given CPM Track and Sector. - JP SD_GETLBA - -?SDCREAD: CALL BANK10 ; Read a CPM host sector according to stored values (512 bytes). - JP SDC_READ - -?SDCWRITE: CALL BANK10 ; Write a CPM host sector according to stored values (512 bytes). - JP SDC_WRITE - -; Public methods for User ROM CBIOS Bank 4 - Floppy Disk Controller functions. - -?DSKINIT: CALL BANK11 ; Initialise the disk system. - JP QDSKINIT - -?SETDRVCFG: CALL BANK11 ; Set the drive configuration. - JP QSETDRVCFG - -?SETDRVMAP: CALL BANK11 ; Set the drive mapping, ie. CPM Drive C is FDC Drive. - JP QSETDRVMAP - -?SELDRIVE: CALL BANK11 ; Select the requested drive and turn on motor. - JP QSELDRIVE - -?GETMAPDSK: CALL BANK11 ; Map the CPM Disk to an actual controller + disk number. - JP QGETMAPDSK - -?DSKREAD: CALL BANK11 ; Read a sector from the selected disk - JP QDSKREAD - -?DSKWRITE: CALL BANK11 ; Write a sector to the selected disk - JP QDSKWRITE - - - - - ;------------------------------------------------------------------------------- - ; BOOT - ; - ; The BOOT entry point gets control from the cold start loader and is - ; responsible for basic system initialization, including sending a sign-on - ; message, which can be omitted in the first version. - ; If the IOBYTE function is implemented, it must be set at this point. - ; The various system parameters that are set by the WBOOT entry point must be - ; initialized, and control is transferred to the CCP at 3400 + b for further - ; processing. Note that register C must be set to zero to select drive A. - ; - ; NB. This code is executed by the MZF loader. The following code is assembled - ; in the header at $1108 to ensure correct startup. - ; LD A,($E00C) ; - Switch ROM to location $C000 - ; LD A,ROMBANK2 ; - Switch to the CBIOS rom in bank 2 of the monitor rom bank. - ; LD ($EFFD),A ; - Perform the bank switch. - ; JP $C000 ; - Go to BOOT_ - ;------------------------------------------------------------------------------- -BOOT_: DI ; Disable Interrupts and sat mode. NB. Interrupts are physically disabled by 8255 Port C2 set to low. - IM 1 - ; - LD SP,BIOSSTACK ; Setup to use local stack until CPM takes over. - ; - LD HL,CPMBIOS ; Start of CPM disk table and variable area - LD BC,VAREND-CPMBIOS ; Size of CPM disk table and variable area. - XOR A - LD D,A -INIT1: LD (HL),D ; Clear variable memory including stack space. - INC HL - DEC BC - LD A,B - OR C - JR NZ,INIT1 - ; - LD HL,00000H - LD BC,CBASE -INIT2: LD (HL),D ; Clear TPA space. - INC HL - DEC BC - LD A,B - OR C - JR NZ,INIT2 - ; - CALL ?MODE ; Configure 8255 port C, set Motor Off, VGATE to 1 (off) and INTMSK to 0 (interrupts disabled). - LD A,016H - CALL ?PRNT - LD A,017H ; Blue background, white characters in colour mode. Bit 7 is set as a write to bit 7 @ DFFFH selects 80Char mode. - LD HL,ARAM - CALL CLR8 - LD A,004H - LD (TEMPW),A ; Setup the tempo for sound output. - - ; Initialise the Rom Paging Control Registers. - LD B,16 ; If we read the bank control reset register 16 times then this will enable bank control and the 16th read will reset all bank control registers to default. -INIT3: LD A,(BNKCTRLRST) - DJNZ INIT3 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - LD (ROMCTL),A ; Save to memory the value in the bank control register - this register is used for SPI etc so need to remember its setting. - LD A,ROMBANK9 ; Screen Bank. - LD (BNKSELUSER),A - ; - - ; Setup keyboard buffer control. - LD A,0 - LD (KEYCOUNT),A ; Set keyboard buffer to empty. - LD HL,KEYBUF - LD (KEYWRITE),HL ; Set write pointer to beginning of keyboard buffer. - LD (KEYREAD),HL ; Set read pointer to beginning of keyboard buffer. - - ; Setup keyboard rate control and set to CAPSLOCK mode. - ; (0 = Off, 1 = CAPSLOCK, 2 = SHIFTLOCK). - LD A,002H ; Initialise key repeater. - LD (KEYRPT),A - LD A,001H - LD (SFTLK),A ; Setup shift lock, default = off. - - ; Setup the initial cursor, for CAPSLOCK this is a double underscore. - LD A,03EH - LD (FLSDT),A - LD A,080H ; Cursor on (Bit D7=1). - LD (FLASHCTL),A - - ; Change to 80 character mode if enabled. - IF BUILD_80C = 1 - LD HL,DSPCTL ; Setup address of display control register latch. - LD A, 128 ; 80 char mode. - LD E,(HL) ; Dummy operation to enable latch write via multivibrator. - LD (HL), A - ENDIF - - CALL ?MLDSP - CALL ?NL - LD DE,CBIOSSIGNON ; Start of sign on message, as devices are detected they are added to the sign on. - CALL MONPRTSTR - CALL ?BEL ; Beep to indicate startup - for cases where screen is slow to startup. - LD A,0FFH - LD (SWRK),A - - LD HL,NUMBERBUF - LD (NUMBERPOS),HL - ; - XOR A - LD (IOBYT),A - LD (CDISK),A - - ; DRVAVAIL flag definition. Version 1.25 - removed ROM Drives and RAM drives as they provided no speed or use benefit compared with SD drives. - ; - ; 1 = Active. - ; - ; 7 6 5 4 3 2 1 0 - ; ^ ^ ^ ^ ^ ^ ^ ^ - ; | | | | | | | |-- Floppy Drive Present - ; | | | | | | |---- ROM Drive Present - ; | | | | | |------ SD Card Present - ; | | | | |-------- RAM Drive Present - ; | | | |---------- - ; | | |------------ - ; | |-------------- - ; |---------------- Drives present - ; - ; Initialise the SD Card subsystem (if connected). - ; - ; CALL ?SDINIT - LD A,0 ; No drives yet detected so zero available mask. - ; JR NZ,STRT2 - SET 2,A ; Assume the SD Card is present if it initialised. - ; - LD DE,SDAVAIL - CALL PRTSTRTMSG ; Print message and store Drive Availability flag in A - ; -STRT2: LD (DRVAVAIL),A - ; - ; Locate the CPM binary Image in the ROM and store the Bank/Block to speed up warm boot.used for Warm restart CCP/BDOS reload. - LD HL,CPMROMFNAME ; Name of CPM File in rom. - CALL FINDMZF - JP NZ,ROMFINDERR ; Failed to find CPM in the ROM! This shouldnt happen even if we boot from SD card, a copy needs to be in the ROM. - LD (CPMROMLOC),BC - -STRT4: CALL ?DSKINIT ; Initialise the disk subsystem. - JR NZ,STRT5 - LD A,(DRVAVAIL) - SET 0,A ; Indicate Floppy drives are available. - - LD DE,FDCAVAIL - CALL PRTSTRTMSG ; Print message and store Drive Availability flag in A - ; -STRT5: LD DE,CBIOSIGNEND ; Terminate the signon message which now includes list of drives detected. - CALL MONPRTSTR - ;CALL ?NL - ; - ; Allocate DPB according to drives detected in priorty, SD,FDC - ; - LD DE,DPBASE ; Base of parameter block. - LD A,0 ; Using scratch area, setup the disk count, pointer to ALV memory and pointer to CSV memory. - LD (CDIRBUF),A - LD HL,CSVALVMEM - LD (CDIRBUF+1),HL - - ; Drives A,B default to SD card if present. - CALL ADDSDDRIVE - CALL ADDSDDRIVE - - ; Floppy drive controller always has 2 drives so set them up, which will be C,D when SD card present else A,B. - CALL ADDFLPYDRV - CALL ADDFLPYDRV - - ; Add additional SD card drives according to free space. -STRT9: CALL ADDSDDRIVE - ; - ; Now add as many additional SD drives as we have RAM available within the CBIOS. - ; - LD BC,(CDIRBUF+1) - LD HL,CSVALVEND - 257 ; Subtract the size of the ALV (CSV has no size for a fixed SD drive) - OR A - SBC HL,BC - JR C,STRT10 ; If there is no more space, exit. - JR STRT9 ; Add another, keep on adding until there is no more ALV Memory free. - -STRT10: LD A,(CDIRBUF) - LD (NDISKS),A ; Setup max number of system disks found on this boot up. - - ; Setup timer interrupts - LD IX,TIMIN ; Pass the interrupt service handler vector. - LD BC,00000H ; Time starts at 00:00:00 01/01/1980 on initialisation. - LD DE,00000H - LD HL,00000H - CALL ?TIMESET - - ; Signon message after all the hardware has been initialised. - LD DE,CPMCOPYRMSG - CALL MONPRTSTR - - ; CP/M init -CPMINIT: LD A,(DRVAVAIL) - BIT 0,A - JR Z,CPMINIT1 - ; - CALL ?DSKINIT ; Re-initialise the disk subsystem if available. - XOR A ; 0 to accumulator - LD (HSTACT),A ; Host buffer inactive - LD (UNACNT),A ; Clear unalloc count - ; -CPMINIT1: LD A, 0C3H ; C3 IS A JMP INSTRUCTION - LD (00000H), A ; FOR JMP TO WBOOT - LD HL,WBOOTE ; WBOOT ENTRY POINT - LD (00001H), HL ; SET ADDRESS FIELD FOR JMP AT 0 - LD (00005H), A ; FOR JMP TO BDOS - LD HL, CPMBDOS ; BDOS ENTRY POINT - LD (00006H), HL ; ADDRESS FIELD OF JUMP AT 5 TO BDOS - LD HL,TIMIN ; Re-install interrupt vector for RTC incase it was overwritten. - LD (00038H),A - LD (00039H),HL - LD BC,CPMUSERDMA - CALL SETDMA_ - ; - ; check if current disk is valid - LD A,(NDISKS) ; Get the dynamic disk count. - LD L,A - LD A, (CDISK) ; GET CURRENT USER/DISK NUMBER (UUUUDDDD) - AND 00FH ; Isolate the disk number. - CP L ; Drive number ok? - JR C, WBTDSKOK2 ; Yes, jump (Carry set if A < NDISKS) - LD A, (CDISK) ; No, set disk 0 (previous user) - AND 0F0H - LD (CDISK), A ; Save User/Disk -WBTDSKOK2: CALL ?SETDRVMAP ; Refresh the map of physical floppies to CPM drive number. - CALL ?SETDRVCFG - ; LD A,(DISKTYPE) - ; OR A - ; CALL Z,?SELDRIVE ; Select and start disk drive motor if floppy disk. - ; - LD A,05H ; Enable interrupts at hardware level. - LD (KEYPF),A - ; - LD A, (CDISK) - LD C, A ; C = current User/Disk for CCP jump (UUUUDDDD) - ; -GOCPM: EI - JP CCP ; Start the CCP. - - ; Method to add an SD drive into the CPM disk definitions. - ; If the SD controller hasnt been detected the routine exits without configuration. -ADDSDDRIVE: LD A,(DRVAVAIL) - BIT 2,A - RET Z ; No SD interface so skip. - - LD BC,0 ; Setup CSV/ALV parameters for a 16MB SD Card drive. - LD (CDIRBUF+3),BC - LD BC,257 ; 2048/8 + 1 - LD (CDIRBUF+5),BC - LD BC,DPBLOCK4 - LD (CDIRBUF+7),BC ; Address of Disk Parameters - CALL COPYDPB ; Add in an SD drive. - RET - - ; Method to add a Floppy drive into the CPM disk definitions table. - ; If the Floppy controller hasnt been detected then skip without configuration. -ADDFLPYDRV: LD A,(DRVAVAIL) - BIT 0,A - RET Z ; No Floppy drives available then skip. - - LD BC,128/4 ; Setup CSV/ALV parameters for a 1.4MB Floppy drive. - LD (CDIRBUF+3),BC - LD BC,91 ; 720/8 + 1 - LD (CDIRBUF+5),BC - LD BC,DPBLOCK3 - LD (CDIRBUF+7),BC ; Address of Disk Parameters - CALL COPYDPB ; Add in a floppy drive. - RET - - ; Helper method to print a message with a comma if Bit 7 of A is set. -PRTSTRTMSG: PUSH AF - BIT 7,A - JR Z,PRTCOMMA1 - LD A,',' - CALL ?PRNT -PRTCOMMA1: CALL MONPRTSTR - POP AF - SET 7,A - LD (DRVAVAIL),A - RET - - ;------------------------------------------------------------------------------- - ; WBOOT - ; - ; The WBOOT entry point gets control when a warm start occurs. - ; A warm start is performed whenever a user program branches to location - ; 0000H, or when the CPU is reset from the front panel. The CP/M system must - ; be loaded from the first two tracks of drive A up to, but not including, - ; the BIOS, or CBIOS, if the user has completed the patch. System parameters - ; must be initialized as follows: - ; - ; location 0,1,2 - ; Set to JMP WBOOT for warm starts (000H: JMP 4A03H + b) - ; - ; location 3 - ; Set initial value of IOBYTE, if implemented in the CBIOS - ; - ; location 4 - ; High nibble = current user number, low nibble = current drive - ; - ; location 5,6,7 - ; Set to JMP BDOS, which is the primary entry point to CP/M for transient - ; programs. (0005H: JMP 3C06H + b) - ; - ; Refer to Section 6.9 for complete details of page zero use. Upon completion - ; of the initialization, the WBOOT program must branch to the CCP at 3400H+b - ; to restart the system. - ; Upon entry to the CCP, register C is set to the drive to select after system - ; initialization. The WBOOT routine should read location 4 in memory, verify - ; that is a legal drive, and pass it to the CCP in register C. - ;------------------------------------------------------------------------------- -WBOOT_: DI - ; - LD SP,BIOSSTACK - - ; Reload the CCP and BDOS from ROM. - LD DE,CPMBIOS-CBASE ; Only want to load in CCP and BDOS. - LD BC,(CPMROMLOC) ; Load up the Bank and Page where the CPM Image can be found. - CALL UROMLOAD - LD A,ROMBANK9 ; Screen Bank. - LD (BNKSELUSER),A - JP Z,CPMINIT ; Initialise CPM and run. - LD DE,NOBDOS - CALL MONPRTSTR -WBOOT2: JR WBOOT2 ; Nowhere to go! - - - ;------------------------------------------------------------------------------- - ; CONOUT - ; - ; The character is sent from register C to the console output device. - ; The character is in ASCII, with high-order parity bit set to zero. You - ; might want to include a time-out on a line-feed or carriage return, if the - ; console device requires some time interval at the end of the line (such as - ; a TI Silent 700 terminal). You can filter out control characters that cause - ; the console device to react in a strange way (CTRL_Z causes the Lear- - ; Siegler terminal to clear the screen, for example). - ;------------------------------------------------------------------------------- -CONOUT_: LD (SPSAVE),SP ; The original monitor routines and the enhancements can use - LD SP,BIOSSTACK ; more stack space than the 16 words provided by CPM. - LD A,C - CALL ?ANSITERM - LD SP,(SPSAVE) ; Restore the CPM stack. - RET - - ;------------------------------------------------------------------------------- - ; CONIN - ; - ; The next console character is read into register A, and the parity bit is - ; set, high-order bit, to zero. If no console character is ready, wait until - ; a character is typed before returning. - ;------------------------------------------------------------------------------- -CONIN_: LD (SPSAVE),SP ; The original monitor routines and the enhancements can use - LD SP,BIOSSTACK ; more stack space than the 16 words provided by CPM. - CALL ?GETKY - LD SP,(SPSAVE) ; Restore the CPM stack. - RET - - ;------------------------------------------------------------------------------- - ; CONST - ; - ; You should sample the status of the currently assigned console device and - ; return 0FFH in register A if a character is ready to read and 00H in - ; register A if no console characters are ready. - ;------------------------------------------------------------------------------- -CONST_: LD (SPSAVE),SP ; The original monitor routines and the enhancements can use - LD SP,BIOSSTACK ; more stack space than the 16 words provided by CPM. - CALL ?CHKKY - LD SP,(SPSAVE) ; Restore the CPM stack. - RET - - ;------------------------------------------------------------------------------- - ; READER - ; - ; The next character is read from the currently assigned reader device into - ; register A with zero parity (high-order bit must be zero); an end-of-file - ; condition is reported by returning an ASCII CTRL_Z(1AH). - ;------------------------------------------------------------------------------- -READER_: LD A, 01AH ; Reader not implemented. - RET - - ;------------------------------------------------------------------------------- - ; PUNCH - ; - ; The character is sent from register C to the currently assigned punch - ; device. The character is in ASCII with zero parity. - ;------------------------------------------------------------------------------- -PUNCH_: RET ; Punch not implemented - - ;------------------------------------------------------------------------------- - ; LIST - ; - ; The character is sent from register C to the currently assigned listing - ; device. The character is in ASCII with zero parity bit. - ;------------------------------------------------------------------------------- -LIST_: RET - - ;------------------------------------------------------------------------------- - ; LISTST - ; - ; You return the ready status of the list device used by the DESPOOL program - ; to improve console response during its operation. The value 00 is returned - ; in A if the list device is not ready to accept a character and 0FFH if a - ; character can be sent to the printer. A 00 value should be returned if LIST - ; status is not implemented. - ;------------------------------------------------------------------------------- -LISTST_: XOR A ; Not implemented. - RET - - ;------------------------------------------------------------------------------- - ; HOME - ; - ; The disk head of the currently selected disk (initially disk A) is moved to - ; the track 00 position. If the controller allows access to the track 0 flag - ; from the drive, the head is stepped until the track 0 flag is detected. If - ; the controller does not support this feature, the HOME call is translated - ; into a call to SETTRK with a parameter of 0. - ;------------------------------------------------------------------------------- -HOME_: LD BC,00000H - - ;------------------------------------------------------------------------------- - ; SETTRK - ; - ; Register BC contains the track number for subsequent disk accesses on the - ; currently selected drive. The sector number in BC is the same as the number - ; returned from the SECTRN entry point. You can choose to seek the selected - ; track at this time or delay the seek until the next read or write actually - ; occurs. Register BC can take on values in the range 0-76 corresponding to - ; valid track numbers for standard floppy disk drives and 0-65535 for - ; nonstandard disk subsystems. - ;------------------------------------------------------------------------------- -SETTRK_: LD (SEKTRK),BC ; Set track passed from BDOS in register BC. - RET - - ;------------------------------------------------------------------------------- - ; SETSEC - ; - ; Register BC contains the sector number, 1 through 26, for subsequent disk - ; accesses on the currently selected drive. The sector number in BC is the - ; same as the number returned from the SECTRAN entry point. You can choose to - ; send this information to the controller at this point or delay sector - ; selection until a read or write operation occurs. - ;------------------------------------------------------------------------------- -SETSEC_: LD A,C ; Set sector passed from BDOS in register BC. - LD (SEKSEC), A - RET - - ;------------------------------------------------------------------------------- - ; SETDMA - ; - ; Register BC contains the DMA (Disk Memory Access) address for subsequent - ; read or write operations. For example, if B = 00H and C = 80H when SETDMA - ; is called, all subsequent read operations read their data into 80H through - ; 0FFH and all subsequent write operations get their data from 80H through - ; 0FFH, until the next call to SETDMA occurs. The initial DMA address is - ; assumed to be 80H. The controller need not actually support Direct Memory - ; Access. If, for example, all data transfers are through I/O ports, the - ; CBIOS that is constructed uses the 128 byte area starting at the selected - ; DMA address for the memory buffer during the subsequent read or write - ; operations. - ;------------------------------------------------------------------------------- -SETDMA_: LD (DMAADDR),BC - RET - - ;------------------------------------------------------------------------------- - ; SELDSK - ; - ; The disk drive given by register C is selected for further operations, - ; where register C contains 0 for drive A, 1 for drive B, and so on up to 15 - ; for drive P (the standard CP/M distribution version supports four drives). - ; On each disk select, SELDSK must return in HL the base address of a 16-byte - ; area, called the Disk Parameter Header, described in Section 6.10. - ; For standard floppy disk drives, the contents of the header and associated - ; tables do not change; thus, the program segment included in the sample - ; CBIOS performs this operation automatically. - ; - ; If there is an attempt to select a nonexistent drive, SELDSK returns - ; HL = 0000H as an error indicator. Although SELDSK must return the header - ; address on each call, it is advisable to postpone the physical disk select - ; operation until an I/O function (seek, read, or write) is actually - ; performed, because disk selects often occur without ultimately performing - ; any disk I/O, and many controllers unload the head of the current disk - ; before selecting the new drive. This causes an excessive amount of noise - ; and disk wear. The least significant bit of register E is zero if this is - ; the first occurrence of the drive select since the last cold or warm start. - ;------------------------------------------------------------------------------- -SELDSK_: LD (SPSAVE),SP ; The original monitor routines and the enhancements can use - LD SP,BIOSSTACK ; more stack space than the 16 words provided by CPM. - LD HL, 00000H ; HL = error code - LD A,(NDISKS) - LD B,A - LD A,C - CP B - JR NC,SELDSK1 ; Ensure we dont select a non existant disk. - LD (CDISK),A ; Setup drive. -SELDSK0: CALL ?SETDRVCFG - LD A,(DISKTYPE) - CP DSKTYP_SDC - JR Z,SELSDCDSK ; Select SD Card. - ; If it is not an SD drive then it must be a floppy disk. - LD A,C - JR CALCHL -SELDSK1: LD SP,(SPSAVE) ; Restore the CPM stack. - RET - - ; For SD Cards, check that the SD Card is present, otherwise illegal disk. -SELSDCDSK: LD A,(DRVAVAIL) - BIT 2,A - JR Z,SELDSK1 ; No SD Card drives available then skip. - LD A,C - - ; - ; Code for blocking and deblocking algorithm - ; (see CP/M 2.2 Alteration Guide p.34 and APPENDIX G) -CALCHL: LD (SEKDSK),A - RLC A ; *2 - RLC A ; *4 - RLC A ; *8 - RLC A ; *16 - LD HL,DPBASE - LD B,0 - LD C,A - ADD HL,BC - JR SELDSK1 - - - ;------------------------------------------------------------------------------- - ; SECTRAN - ; - ; Logical-to-physical sector translation is performed to improve the overall - ; response of CP/M. Standard CP/M systems are shipped with a skew factor of - ; 6, where six physical sectors are skipped between each logical read - ; operation. This skew factor allows enough time between sectors for most - ; programs to load their buffers without missing the next sector. In - ; particular computer systems that use fast processors, memory, and disk - ; subsystems, the skew factor might be changed to improve overall response. - ; However, the user should maintain a single-density IBM-compatible version - ; of CP/M for information transfer into and out of the computer system, using - ; a skew factor of 6. - ; - ; In general, SECTRAN receives a logical sector number relative to zero in BC - ; and a translate table address in DE. The sector number is used as an index - ; into the translate table, with the resulting physical sector number in HL. - ; For standard systems, the table and indexing code is provided in the CBIOS - ; and need not be changed. - ;------------------------------------------------------------------------------- -SECTRN_: LD H,B - LD L,C - RET - - - ;------------------------------------------------------------------------------- - ; READ - ; - ; Assuming the drive has been selected, the track has been set, and the DMA - ; address has been specified, the READ subroutine attempts to read one sector - ; based upon these parameters and returns the following error codes in - ; register A: - ; - ; 0 - no errors occurred - ; 1 - non recoverable error condition occurred - ; - ; Currently, CP/M responds only to a zero or nonzero value as the return - ; code. That is, if the value in register A is 0, CP/M assumes that the disk - ; operation was completed properly. If an error occurs the CBIOS should - ; attempt at least 10 retries to see if the error is recoverable. When an - ; error is reported the BDOS prints the message BDOS ERR ON x: BAD SECTOR. - ; The operator then has the option of pressing a carriage return to ignore - ; the error, or CTRL_C to abort. - ;------------------------------------------------------------------------------- - ; - ; Code for blocking and deblocking algorithm - ; (see CP/M 2.2 Alteration Guide p.34 and APPENDIX G) - ; -READ_: LD (SPSAVE),SP ; The original monitor routines and the enhancements can use - LD SP,BIOSSTACK ; more stack space than the 16 words provided by CPM. - XOR A - LD (UNACNT), A - LD A, 1 - LD (READOP), A ; read operation - LD (RSFLAG), A ; must read data - LD A, WRUAL - LD (WRTYPE), A ; treat as unalloc - CALL RWOPER ; to perform the read, returns with A=0 no errors or A > 0 errors. - LD SP,(SPSAVE) ; Restore the CPM stack. - RET - - ;------------------------------------------------------------------------------- - ; WRITE - ; - ; Data is written from the currently selected DMA address to the currently - ; selected drive, track, and sector. For floppy disks, the data should be - ; marked as nondeleted data to maintain compatibility with other CP/M - ; systems. The error codes given in the READ command are returned in register - ; A, with error recovery attempts as described above. - ;------------------------------------------------------------------------------- - ; - ; Code for blocking and deblocking algorithm - ; (see CP/M 2.2 Alteration Guide p.34 and APPENDIX G) - ; -WRITE_: LD (SPSAVE),SP ; The original monitor routines and the enhancements can use - LD SP,BIOSSTACK ; more stack space than the 16 words provided by CPM. - XOR A ; 0 to accumulator - LD (READOP), A ; not a read operation - LD A, C ; write type in c - LD (WRTYPE), A - CP WRUAL ; write unallocated? - JR NZ, CHKUNA ; check for unalloc - ; write to unallocated, set parameters - LD A, BLKSIZ/128 ; next unalloc recs - LD (UNACNT), A - LD A, (SEKDSK) ; disk to seek - LD (UNADSK), A ; unadsk = sekdsk - LD HL, (SEKTRK) - LD (UNATRK), HL ; unatrk = sectrk - LD A, (SEKSEC) - LD (UNASEC), A ; unasec = seksec - ; check for write to unallocated sector -CHKUNA: LD A,(UNACNT) ; any unalloc remain? - OR A - JR Z, ALLOC ; skip if not - ; more unallocated records remain - DEC A ; unacnt = unacnt-1 - LD (UNACNT), A - LD A, (SEKDSK) ; same disk? - LD HL, UNADSK - CP (HL) ; sekdsk = unadsk? - JP NZ, ALLOC ; skip if not - ; disks are the same - LD HL, UNATRK - CALL SEKTRKCMP ; sektrk = unatrk? - JP NZ, ALLOC ; skip if not - ; tracks are the same - LD A, (SEKSEC) ; same sector? - LD HL, UNASEC - CP (HL) ; seksec = unasec? - JP NZ, ALLOC ; skip if not - ; match, move to next sector for future ref - INC (HL) ; unasec = unasec+1 - LD A, (HL) ; end of track? - CP CPMSPT ; count CP/M sectors - JR C, NOOVF ; skip if no overflow - ; overflow to next track - LD (HL), 0 ; unasec = 0 - LD HL, (UNATRK) - INC HL - LD (UNATRK), HL ; unatrk = unatrk+1 - ; match found, mark as unnecessary read -NOOVF: XOR A ; 0 to accumulator - LD (RSFLAG), A ; rsflag = 0 - JR ALLOC2 ; to perform the write - ; not an unallocated record, requires pre-read -ALLOC: XOR A ; 0 to accum - LD (UNACNT), A ; unacnt = 0 - INC A ; 1 to accum -ALLOC2: LD (RSFLAG), A ; rsflag = 1 - CALL RWOPER - LD SP,(SPSAVE) ; Restore the CPM stack. - RET - - - ; Function to select a User Bank. If Carry is clear upon entry, on exit the control registers will be disabled. If carry is set then the control registers are left active. - ; During normal operations the control registers are enabled. When access is needed to the full User ROM space, ie for drive read/write then the registers are disabled after - ; setting the correct bank. The upper bits of the User ROM address space (ie. bits 20:19 which select the device) are set to by the ROMCTL variable. - ; -SELUSRBNK: DI - PUSH BC - PUSH AF - ; Use a fixed number of reads to enable the control registers. - LD B,16 -SELUSRBNK0: LD A,(BNKCTRLRST) - DJNZ SELUSRBNK0 - POP AF - POP BC - LD (BNKSELUSER),A ; Select the required bank. - LD A,(ROMCTL) - LD (BNKCTRL),A - JR C,SELUSRBNK3 - LD (BNKCTRLDIS),A ; Disable the control registers, value of A is not important. -SELUSRBNK3: EI - RET - -; EXX -; EX AF,AF' -; LD A,(ROMCTL) ; Get current setting for the coded latch, ie. number of reads needed to enable it. -; LD C,A -; RRA -; RRA -; CPL -; AND 00FH ; Preserve bits 3-1, bit 0 is always 0 on the 74HCT191 latch. -; LD B,A ; Set value to B for loop. -; LD A,(BNKCTRLDIS) ; Do a reset for the case where the above read enabled the latch, possible if external programs are reading/writing the latch area. -; LD A,(BNKCTRL) ; Sample latch at start to detect change. -; LD E,A -;SELUSRBNK1: LD A,(BNKCTRL) ; Read the latch and compare with sample. Either we reach the count limit or the read differs indicating latch control. -; CP E -; JR NZ,SELUSRBNK2 -; DJNZ SELUSRBNK1 -;SELUSRBNK2: LD A,C -; LD (BNKCTRL),A -; EX AF,AF' -; LD (BNKSELUSER),A ; Select the required bank. -; EXX -; JR C,SELUSRBNK3 ; If Carry is set by caller then leave the control registers active. -; LD (BNKCTRLDIS),A ; Disable the control registers, value of A is not important. -;SELUSRBNK3: EI -; RET - - - ; Helper method to set up a Disk Parameter Block. - ; Input: Drive Count = (CDIRBUF) - ; CSV/ALV Memory Pointer (CDIRBUF+1) - ; CSV Size (CDIRBUF+3) - ; ALV Size (CDIRBUF+5) - ; Disk parameters address CDIRBUF+7) - ; Output: Updated CSV/ALV Pointer (CDIRBUF+1) - ; Updated disk count (CDIRBUF) -COPYDPB: LD HL,DPBTMPL ; Base of parameter template for ROM Drive 0 - LD BC,10 - LDIR ; Copy the lower part of the DPB as it is static. - LD HL,CDIRBUF+7 ; Get the address of the disk parameters. - LDI - LDI - LD BC,(CDIRBUF+3) ; Add the CSV size for this entry to the pointer and store. - LD A,B ; Fixed drives dont have a CSV, so if 0, copy 0 and not allocate memory. - OR C - LD HL,CDIRBUF+1 ; Now get the free CSV/ALV pointer. - JR NZ,COPYDPB1 - LD HL,CDIRBUF+3 -COPYDPB1: LDI - LDI - LD HL,(CDIRBUF+1) - LD BC,(CDIRBUF+3) ; Add the CSV size for this entry to the pointer and store. - ADD HL,BC - LD (CDIRBUF+1),HL - LD HL,CDIRBUF+1 - LDI - LDI - LD HL,(CDIRBUF+1) - LD BC,(CDIRBUF+5) ; Now add the size of the ALV for this drive to the pointer for the next drive. - ADD HL,BC - LD (CDIRBUF+1),HL ; Store. - LD A,(CDIRBUF) - INC A - LD (CDIRBUF),A ; Update drive count. - RET - - - ;------------------------------------------------------------------------------- - ; TIMER INTERRUPT - ; - ; This is the RTC interrupt, which interrupts every 100msec. RTC is maintained - ; by keeping an in memory count of seconds past 00:00:00 and an AMPM flag. - ;------------------------------------------------------------------------------- -TIMIN: LD (SPISRSAVE),SP ; CP/M has a small working stack, an interrupt could exhaust it so save interrupts stack and use a local stack. - LD SP,ISRSTACK - ; - PUSH AF ; Save used registers. - PUSH BC - PUSH DE - PUSH HL - ; - ; Reset the interrupt counter. - LD HL,CONTF ; CTC Control register, set to reload the 100ms interrupt time period. - LD (HL),080H ; Select Counter 2, latch counter, read lsb first, mode 0 and binary. - PUSH HL - DEC HL - LD E,(HL) - LD D,(HL) ; Obtain the overrun count if any (due to disabled interrupts). - LD HL, 00001H ; Add full range to count to obtain the period of overrun time. - SBC HL,DE - EX DE,HL - POP HL - LD (HL),0B0H ; Select Counter 2, load lsb first, mode 0 interrupt on terminal count, binary - DEC HL - LD (HL),TMRTICKINTV - LD (HL),000H ; Another 100msec delay till next interrupt. - ; - ; Update the RTC with the time period. - LD HL,(TIMESEC) ; Lower 16bits of counter. - ADD HL,DE - LD (TIMESEC),HL - JR NC,TIMIN1 ; On overflow we increment middle 16bits. - ; - LD HL,(TIMESEC+2) - INC HL - LD (TIMESEC+2),HL - LD A,H - OR L - JR NZ,TIMIN1 ; On overflow we increment upper 16bits. - ; - LD HL,(TIMESEC+4) - INC HL - LD (TIMESEC+4),HL - - ; - ; Flash a cursor at the current XY location. - ; -TIMIN1: LD HL,FLASHCTL - BIT 7,(HL) ; Is cursor enabled? If it isnt, skip further processing. - JR Z,TIMIN2 - ; -FLSHCTL0: LD A,(KEYPC) ; Flashing component, on each timer tick, display the cursor or the original screen character. - LD C,A - XOR (HL) ; Detect a cursor change signal. - RLCA - RLCA - JR NC,TIMIN2 ; No change, skip. - - RES 6,(HL) - LD A,C ; We know there was a change, so decide what to display and write to screen. - RLCA - RLCA - LD A,(FLASH) - JR NC,FLSHCTL1 - SET 6,(HL) ; We are going to display the cursor, so save the underlying character. - LD A,(FLSDT) ; Retrieve the cursor character. -FLSHCTL1: LD HL,(DSPXYADDR) ; Load the desired cursor or character onto the screen. - LD (HL),A - - ; - ; FDC Motor Off Timer - ; -TIMIN2: LD A,(MTROFFTIMER) ; Is the timer non-zero? - OR A - JR Z,TIMIN3 - DEC A ; Decrement. - LD (MTROFFTIMER),A - JR NZ,TIMIN3 ; If zero after decrement, turn off the motor. - OUT (FDC_MOTOR),A ; Turn Motor off - LD (MOTON),A ; Clear Motor on flag - - ; - ; Keyboard processing. - ; -TIMIN3: CALL ?SWEP ; Perform keyboard sweep - LD A,B - RLCA - JR C,ISRKEY2 ; CY=1 then data available. - LD HL,KDATW - LD A,(HL) ; Is a key being held down? - OR A - JR NZ, ISRAUTORPT ; It is so process as an auto repeat key. - XOR A - LD (KEYRPT),A ; No key held then clear the auto repeat initial pause counter. - LD A,NOKEY ; No key code. -ISRKEY1: LD E,A - LD A,(HL) ; Current key scan line position. - INC HL - LD D,(HL) ; Previous key position. - LD (HL),A ; Previous <= current - SUB D ; Are they the same? - JR NC,ISRKEY11 - INC (HL) ; -ISRKEY11: LD A,E -ISRKEY10: CP NOKEY - JR Z,ISREXIT - LD (KEYLAST),A -ISRKEYRPT: LD A,(KEYCOUNT) ; Get current count of bytes in the keyboard buffer. - CP KEYBUFSIZE - 1 - JR NC, ISREXIT ; Keyboard buffer full, so waste character. - INC A - LD (KEYCOUNT),A - LD HL,(KEYWRITE) ; Get the write buffer pointer. - LD (HL), E ; Store the character. - INC L - LD A,L - AND KEYBUFSIZE-1 ; Circular buffer, keep boundaries. - LD L,A - LD (KEYWRITE),HL ; Store updated pointer. -ISREXIT: POP HL - POP DE - POP BC - POP AF - ; - LD SP,(SPISRSAVE) - EI - RET - - ; - ; Helper to determine if a key is being held down and autorepeat should be applied. - ; The criterion is a timer, if this expires then autorepeat is applied. - ; -ISRAUTORPT: LD A,(KEYRPT) ; Increment an initial pause counter. - INC A - CP 10 - JR C,ISRAUTO1 ; Once expired we can auto repeat the last key. - LD A,(KEYLAST) - CP 080H - JR NC,ISREXIT ; Dont auto repeat control keys. - LD E,A - JR ISRKEYRPT -ISRAUTO1: LD (KEYRPT),A - JR ISREXIT - - ; - ; Method to alternate through the 3 shift modes, CAPSLOCK=1, SHIFTLOCK=2, NO LOCK=0 - ; -LOCKTOGGLE: LD HL,FLSDT - LD A,(SFTLK) - INC A - CP 3 - JR C,LOCK0 - XOR A -LOCK0: LD (SFTLK),A - OR A - LD (HL),043H ; Thick block cursor when lower case. - JR Z,LOCK1 - CP 1 - LD (HL),03EH ; Thick underscore when CAPS lock. - JR Z,LOCK1 - LD (HL),0EFH ; Block cursor when SHIFT lock. -LOCK1: JP ISREXIT - - -ISRKEY2: RLCA - RLCA - RLCA - JP C,LOCKTOGGLE ; GRAPH key which acts as the Shift Lock. - RLCA - JP C,ISRBRK ; BREAK key. - LD H,000H - LD L,C - LD A,C - CP 038H ; TEN KEY check. - JR NC,ISRKEY6 ; Jump if TENKEY. - LD A,B - RLCA - LD B,A - LD A,(SFTLK) - OR A - LD A,B - JR Z,ISRKEY14 - RLA - CCF - RRA -ISRKEY14: RLA - RLA - JR NC,ISRKEY3 -ISRKEY15: LD DE,KTBLC -ISRKEY5: ADD HL,DE - LD A,(HL) - JP ISRKEY1 - -ISRKEY3: RRA - JR NC,ISRKEY6 - LD A,(SFTLK) - CP 1 - LD DE,KTBLCL - JR Z,ISRKEY5 - LD DE,KTBLS - JR ISRKEY5 - -ISRKEY6: LD DE,KTBL - JR ISRKEY5 -ISRKEY4: RLCA - RLCA - JR C,ISRKEY15 - LD DE,KTBL - JR ISRKEY5 - - ; Break key pressed, handled in getkey routine. -ISRBRK: LD A,(KEYLAST) - CP BREAKKEY - JP Z,ISREXIT - XOR A ; Reset the keyboard buffer. - LD (KEYCOUNT),A - LD HL,KEYBUF - LD (KEYWRITE),HL - LD (KEYREAD),HL - LD A,BREAKKEY - JP ISRKEY10 - - ; KEYBOARD SWEEP - ; - ; EXIT B,D7=0 NO DATA - ; =1 DATA - ; D6=0 SHIFT OFF - ; =1 SHIFT ON - ; C = ROW & COLUMN - ; -?SWEP: XOR A - LD (KDATW),A ; Reset key counter - LD B,0FAH ; Starting scan line, D3:0 = scan = line 10. D5:4 not used, D7=Cursor flash. - LD D,A - - ; BREAK TEST - ; BREAK ON : ZERO = 1 - ; OFF : ZERO = 0 - ; NO KEY : CY = 0 - ; KEY IN : CY = 1 - ; A D6=1: SHIFT ON - ; =0: SHIFT OFF - ; D5=1: CTRL ON - ; =0: CTRL OFF - ; D4=1: GRAPH ON - ; =0: GRAPH OFF -BREAK: LD A,0F0H - LD (KEYPA),A ; Port A scan line 0 - NOP - LD A,(KEYPB) ; Read back key data. - OR A - RLA - JR NC,BREAK3 ; CTRL/BREAK key pressed? - RRA - RRA ; Check if SHIFT key pressed/ - JR NC,BREAK1 ; SHIFT BREAK not pressed, jump. - RRA - JR NC,BREAK2 ; Check for GRAPH. - CCF - JR SWEP6 ;SWEP1 - -BREAK1: LD A,040H ; A D6=1 SHIFT ON - SCF - JR SWEP6 - -BREAK2: LD A,001H ; No keys found to be pressed on scanline 0. - LD (KDATW),A - LD A,010H ; A D4=1 GRAPH - SCF - JR SWEP6 - -BREAK3: AND 006H ; SHIFT + GRAPH + BREAK? - JR Z,SWEP1A - AND 002H ; SHIFT ? - JR Z,SWEP1 ; Z = 1 = SHIFT BREAK pressed/ - LD A,020H ; A D5=1 CTRL - SCF - JR SWEP6 - -SWEP1: LD D,088H ; Break ON - JR SWEP9 -SWEP1A: JP ?REBOOT ; Shift + Graph + Break ON = RESET. - ; - JR SWEP9 -SWEP6: LD HL,SWPW - PUSH HL - JR NC,SWEP11 - LD D,A - AND 060H ; Shift & Ctrl =no data. - JR NZ,SWEP11 - LD A,D ; Graph Check - XOR (HL) - BIT 4,A - LD (HL),D - JR Z,SWEP0 -SWEP01: SET 7,D ; Data available, set flag. -SWEP0: DEC B - POP HL ; SWEP column work - INC HL - LD A,B - LD (KEYPA),A ; Port A (8255) D3:0 = Scan line output. - CP 0F0H - JR NZ,SWEP3 ; If we are not at scan line 0 then check for key data. - LD A,(HL) ; SWPW - CP 003H ; Have we scanned all lines, if yes then no data? - JR C,SWEP9 - LD (HL),000H ; - RES 7,D ; Reset data in as no data awailable. -SWEP9: LD B,D - RET - -SWEP11: LD (HL),000H - JR SWEP0 -SWEP3: LD A,(KEYPB) ; Port B (8255) D7:0 = Key data in for given scan line. - LD E,A - CPL - AND (HL) - LD (HL),E - PUSH HL - LD HL,KDATW - PUSH BC - LD B,008H -SWEP8: RLC E - JR C,SWEP7 - INC (HL) -SWEP7: DJNZ SWEP8 - POP BC - OR A - JR Z,SWEP0 - LD E,A -SWEP2: LD H,008H - LD A,B - DEC A ; TBL adjust - AND 00FH - RLCA - RLCA - RLCA - LD C,A - LD A,E -SWEP12: DEC H - RRCA - JR NC,SWEP12 - LD A,H - ADD A,C - LD C,A - JP SWEP01 - - ;------------------------------------------------------------------------------- - ; END OF TIMER INTERRUPT - ;------------------------------------------------------------------------------- - - ; Method to clear memory either to 0 or a given pattern. - ; -CLR8Z: XOR A -CLR8: LD BC,00800H -CLRMEM: PUSH DE - LD D,A -L09E8: LD (HL),D - INC HL - DEC BC - LD A,B - OR C - JR NZ,L09E8 - POP DE - RET - -?CLER: XOR A - JR ?DINT -?CLRFF: LD A,0FFH -?DINT: LD (HL),A - INC HL - DJNZ ?DINT - RET - -MULT16x8: LD HL,0 - LD B,8 -MULT16x8_1: ADD HL,HL - RLCA - JR NC,MULT16x8_2 - ADD HL,DE -MULT16x8_2: DJNZ MULT16x8_1 - RET - - - ;------------------------------------------------------------------------------- - ; START OF ROM DRIVE FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; Comparing Strings - ; IN HL Address of string1. - ; DE Address of string2. - ; BC Max bytes to compare, 0x00 or 0x0d will early terminate. - ; OUT zero Set if string1 = string2, reset if string1 != string2. - ; carry Set if string1 > string2, reset if string1 <= string2. -CMPSTRING: PUSH HL - PUSH DE - -CMPSTR1: LD A, (DE) ; Compare bytes. - CP 000h ; Check for end of string. - JR Z, CMPSTR3 - CP 00Dh - JR Z, CMPSTR3 - CPI ; Compare bytes. - JR NZ, CMPSTR2 ; If (HL) != (DE), abort. - INC DE ; Update pointer. - JP PE, CMPSTR1 ; Next byte if BC not zero. - -CMPSTR2: DEC HL - CP (HL) ; Compare again to affect carry. -CMPSTR4: POP DE - POP HL - RET - -CMPSTR3: LD A, (HL) - CP 000h ; Check for end of string. - JR Z, CMPSTR4 - CP 00Dh - JR Z, CMPSTR4 - SCF ; String 1 greater than string 2 - JR CMPSTR4 - - ; HL contains address of block to check. -ISMZF: PUSH BC - PUSH DE - PUSH HL - ; - LD A,(HL) - CP 001h ; Only interested in machine code images. - JR NZ, ISMZFNOT - ; - INC HL - LD DE,NAME ; Checks to confirm this is an MZF header. - LD B,17 ; Maximum of 17 characters, including terminator in filename. -ISMZFNXT: LD A,(HL) - LD (DE),A - CP 00Dh ; If we find a terminator then this indicates potentially a valid name. - JR Z, ISMZFVFY - CP 020h ; >= Space - JR C, ISMZFNOT - CP 05Dh ; =< ] - JR C, ISMZFNXT3 -ISMZFNXT2: CP 091h - JR C, ISMZFNOT ; DEL or > 0x7F, cant be a valid filename so this is not an MZF header. -ISMZFNXT3: INC DE - INC HL - DJNZ ISMZFNXT - JR ISMZFNOT ; No end of string terminator, this cant be a valid filename. -ISMZFVFY: LD A,B - CP 17 - JR Z,ISMZFNOT ; If the filename has no length it cant be valid, so loop. -ISMZFYES: CP A ; Set zero flag to indicate match. -ISMZFNOT: POP HL - POP DE - POP BC - RET - - ; In: - ; HL = filename - ; Out: - ; B = Bank Page file found - ; C = 7:6 = Upper Bank address where file found, 5:0 = Block where found. - ; D = File sequence number. - ; Z set if found. -FINDMZF: LD (TMPADR), HL ; Save name of program to load. - ; - ; Scan MROM Bank - ; B = Bank Page - ; C = Block in page - ; D = File sequence number. - ; -FINDMZF0: LD B,USRROMPAGES ; First 16 pages are reserved in User ROM bank. - ; - LD A,(ROMCTL) - AND 03FH ; Mask out the upper bank address lines so we start with Flash RAM I. - ; -FINDNXTDVC: LD (ROMCTL),A - LD C,0 ; Block in page. - LD D,0 ; File numbering start. -FINDMZF1: LD A,B - OR A ; Select the required user bank and Clear carry so that the control registers are disabled. - CALL SELUSRBNK -FINDMZF2: PUSH BC ; Preserve bank count/block number. - PUSH DE ; Preserve file numbering. - LD HL,0E800h + RFS_ATRB ; Add block offset to get the valid block. - LD A,C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B,A - LD C,0 - ADD HL,BC - - CALL ISMZF ; Check to see if this looks like a header entry. - POP DE - POP BC - JR NZ, FINDMZF4 ; Z set if we found an MZF record. - INC HL ; Save address of filename. -FINDMZF3: PUSH DE - PUSH BC - LD DE,(TMPADR) ; Original DE put onto stack, original filename into DE - LD BC,17 - CALL CMPSTRING - POP BC - POP DE - JR Z, FINDMZFYES - INC D ; Next file sequence number. -FINDMZF4: INC C - LD A,C - CP UROMSIZE/RFSSECTSZ ; Max blocks per page reached? - JR C, FINDMZF5 - LD C,0 - INC B -FINDMZF5: LD A,B - CP 000h ; User ROM has 256 banks of 2K, so stop when we wrap around to zero. - JR NZ, FINDMZF1 - ; - LD A,(ROMCTL) - ADD A, 64 - CP 0C0H ; If both upper address bits are set then we have come to the end. - JR C,FINDNXTDVC - AND 03FH - LD (ROMCTL),A ; Switch back to primary Flash RAM I device. - ; - INC B ; Clear Z flag. - JR FINDMZFNO - ; -FINDMZFYES: LD A,(ROMCTL) - AND 0C0H ; Interested in the top two address bits 20:19 - OR C - LD C,A ; Place the top address bits into the Block as the upper two bits. - LD A,(ROMCTL) - AND 03FH - LD (ROMCTL),A ; Reset upper address bits to the User ROM I device. - XOR A ; Clear Z flag to indicate we found the file and BC points to it. - ; -FINDMZFNO: PUSH AF ; Preserve flags. - LD A,ROMBANK9 - SCF ; Select the required user bank and Set carry so that the control registers remain enabled. - CALL SELUSRBNK - POP AF - RET - - - ; Load Program from ROM - ; IN BC Bank and Block of MZF file. C contains Block in bits 5:0 and upper bank address bits in 7:6. - ; DE 0 - use file size in header, > 0 file size to load. - ; OUT zero Set if file loaded, reset if an error occurred. - ; - ; Load program from RFS Bank 2 (User ROM Bank) - ; -UROMLOAD: PUSH BC - PUSH DE - ; - LD A,C ; Set upper address bits by masking out 7:6 and adding to ROMCTL variable. - AND 0C0H - LD L,A - LD A,(ROMCTL) - AND 03FH - OR L - LD (ROMCTL),A - ; - LD A,C ; Remove upper address bits from starting block. - AND 03FH - LD C,A - ; - LD A,B - OR A ; Select the required user bank and Clear carry so that the control registers are disabled. - CALL SELUSRBNK - ; - LD DE, IBUFE ; Copy the header into the work area. - LD HL, 0E800h ; Add block offset to get the valid block. - LD A,C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B,A - LD C,0 - ADD HL,BC - LD BC, MZFHDRNCSZ -LROMLOAD0: LD A,(BNKCTRLDIS) - LD A,(HL) ; Issues with LDIR and a signal artifact from the mainboard, so manual copy. - INC HL - LD (DE),A - INC DE - DEC BC - LD A,B - OR C - JR NZ,LROMLOAD0 - - LD DE,MZFHDRSZ - MZFHDRNCSZ ; Account for the full MZF header (we only load the initial part to save RAM). - ADD HL,DE - POP DE - LD A,D ; Test DE, if 0 the use the size to load from header. - OR E ; if not 0, use size to load in DE. - JR Z,LROMLOAD1 - LD (SIZE),DE ; Overwrite the header size with the new size to load. - -LROMLOAD1: PUSH HL - LD DE, (DTADR) - LD HL, (SIZE) - LD BC, RFSSECTSZ - MZFHDRSZ - OR A - SBC HL, BC - JR NC, LROMLOAD4 - LD HL, (SIZE) - JR LROMLOAD4 - - ; HL = address in active block to read. - ; B = Bank - ; C = Block -LROMLOAD2: LD A, B - OR A ; Select the required user bank and Clear carry so that the control registers are disabled. - CALL SELUSRBNK - -LROMLOAD3: PUSH BC - LD HL, UROMADDR - LD A, C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B, A - LD C, 0 - ADD HL,BC - PUSH HL - - LD DE, (TMPADR) - LD HL, (TMPSIZE) - LD BC, RFSSECTSZ - CCF - SBC HL, BC - JR NC, LROMLOAD4 - LD BC, (TMPSIZE) - LD HL, 0 -LROMLOAD4: LD (TMPSIZE), HL ; HL contains remaining amount of bytes to load. - POP HL - ; - LD A, B ; Pre check to ensure BC is not zero. - OR C - JR Z, LROMLOAD8 - -LROMLOAD9: LD (BNKCTRLDIS),A ; There exists an issue with using the mainboard decoder signal which I havent quite understood, random activation of the upcounter occurs which appears to be the refresh circuit. - LD A,(HL) ; Issues with LDIR and a signal artifact from the mainboard, so manual copy. - INC HL - LD (DE),A - INC DE - DEC BC - LD A,B - OR C - JR NZ,LROMLOAD9 - - LD BC, (TMPSIZE) - LD A, B ; Post check to ensure we still have bytes - OR C - JR Z, LROMLOAD8 - ; - LD (TMPADR),DE ; Address we are loading into. - POP BC -LROMLOAD6: INC C - LD A, C - CP UROMSIZE/RFSSECTSZ ; Max blocks per page reached? - JR C, LROMLOAD3 - LD C, 0 - INC B - ; -LROMLOAD7: LD A, B - CP 000h - JR NZ, LROMLOAD2 - OR 1 - JR LROMLOAD5 - ; -LROMLOAD8: POP BC -LROMLOAD5: PUSH AF - LD A,(ROMCTL) - AND 03FH - LD (ROMCTL),A ; Switch back to primary Flash RAM I device. - LD A,ROMBANK9 - SCF ; Select the required user bank and Set carry so that the control registers remain enabled. - CALL SELUSRBNK - POP AF - RET - - ; Rom filing system error messages. -ROMFINDERR: LD DE,ROMFDERRMSG - JR MONPRTSTR - - ; Function to print a string with control character interpretation. -MONPRTSTR: LD A,(DE) - OR A - RET Z - INC DE -MONPRTSTR2: CALL ?PRNT - JR MONPRTSTR - ;------------------------------------------------------------------------------- - ; END OF ROM DRIVE FUNCTIONALITY - ;------------------------------------------------------------------------------- - - - ;------------------------------------------------------------------------------- - ; START OF SD CARD DRIVE FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; Method to read a sector from the SD Card. - ; CPM Provides us with a track and sector, take these and calculate the LBA - ; within the SD Card. - ; - ; The SD Card is organised as follows: - ; SECTOR FUNCTION - ; 00000000 --------------------------------------------------------------------------- - ; | ROM FILING SYSTEM IMAGE | - ; | | - ; 00000000 | RFS DIRECTORY ENTRY 000 (32BYTE) | - ; | .. | - ; | .. | - ; 00001FE0 | RFS DIRECTORY ENTRY 255 (32BYTE) | - ; 00002000 --------------------------------------------------------------------------- - ; | | - ; | CP/M DISK IMAGE 1 | - ; | | - ; | | - ; | | - ; | | - ; --------------------------------------------------------------------------- - ; | | - ; | CP/M DISK IMAGE 2 | - ; | | - ; | | - ; | | - ; | | - ; --------------------------------------------------------------------------- - ; | | - ; | CP/M DISK IMAGE 3 | - ; | | - ; | | - ; | | - ; | | - ; --------------------------------------------------------------------------- - ; | | - ; | CP/M DISK IMAGE ... | - ; | | - ; | | - ; | | - ; | | - ; --------------------------------------------------------------------------- - ; - ; The ROM FILING SYSTEM resides at the beginning of the disk so we add this to the start sector for the CPM drive. - ; Then the CPM disk is multiplied by the CPM disk size and this is added to the start sector. - ; The disk is organised as 32 Sectors x 1024 tracks and 1 head. Thus the track is - ; multiplied by 32 as we use LBA addressing (for older cards, the SD utilities will convert to byte - ; address if necessary. This is added to the start sector. We then take the CPM host sector (from the deblocking - ; algorithm) and add to the start sector. We now have the sector CPM is requesting. - ; -SDCREAD: CALL ?SDCREAD - JP READHST3 - -SDCWRITE: CALL ?SDCWRITE - JP WRITEHST3 - - ;------------------------------------------------------------------------------- - ; END OF SD CARD DRIVE FUNCTIONALITY - ;------------------------------------------------------------------------------- - - - - ;------------------------------------------------------------------------------- - ; START OF CPM DEBLOCKING ALGORITHM - ;------------------------------------------------------------------------------- - - ;------------------------------------------------------------------------------- - ; RWOPER - ; - ; The common blocking/deblocking algorithm provided by DR to accommodate devices - ; which have sector sizes bigger than the CPM 128byte standard sector. - ; In this implementation a sector size of 512 has been chosen regardless of - ; what the underlying hardware uses (ie. FDC is 256 byte for a standard MZ800 - ; format disk). - ;------------------------------------------------------------------------------- -RWOPER: XOR A ; zero to accum - LD (ERFLAG), A ; no errors (yet) - LD A, (SEKSEC) ; compute host sector - OR A ; carry = 0 - RRA ; shift right - OR A ; carry = 0 - RRA ; shift right - LD (SEKHST), A ; host sector to seek - ; active host sector? - LD HL, HSTACT ; host active flag - LD A, (HL) - LD (HL), 1 ; always becomes 1 - OR A ; was it already? - JR Z, FILHST ; fill host if not - ; host buffer active, same as seek buffer? - LD A, (SEKDSK) - LD HL, HSTDSK ; same disk? - CP (HL) ; sekdsk = hstdsk? - JR NZ, NOMATCH - ; same disk, same track? - LD HL, HSTTRK - CALL SEKTRKCMP ; sektrk = hsttrk? - JR NZ, NOMATCH - ; same disk, same track, same buffer? - LD A, (SEKHST) - LD HL, HSTSEC ; sekhst = hstsec? - CP (HL) - JR Z, MATCH ; skip if match - ; proper disk, but not correct sector -NOMATCH: LD A, (HSTWRT) ; host written? - OR A - CALL NZ, WRITEHST ; clear host buff - ; may have to fill the host buffer -FILHST: LD A, (SEKDSK) - LD (HSTDSK), A - LD HL, (SEKTRK) - LD (HSTTRK), HL - LD A, (SEKHST) - LD (HSTSEC), A - LD A, (RSFLAG) ; need to read? - OR A - CALL NZ, READHST ; yes, if 1 - OR A - JR NZ,RWEXIT ; If A > 0 then read error occurred. - XOR A ; 0 to accum - LD (HSTWRT), A ; no pending write - ; copy data to or from buffer -MATCH: LD A, (SEKSEC) ; mask buffer number - AND SECMSK ; least signif bits - LD L, A ; ready to shift - LD H, 0 ; double count - ADD HL, HL - ADD HL, HL - ADD HL, HL - ADD HL, HL - ADD HL, HL - ADD HL, HL - ADD HL, HL - ; hl has relative host buffer address - LD DE, HSTBUF - ADD HL, DE ; hl = host address - EX DE, HL ; now in DE - LD HL, (DMAADDR) ; get/put CP/M data - LD C, 128 ; length of move - LD A, (READOP) ; which way? - OR A - JR NZ, RWMOVE ; skip if read - ; write operation, mark and switch direction - LD A, 1 - LD (HSTWRT), A ; hstwrt = 1 - EX DE, HL ; source/dest swap - ; c initially 128, DE is source, HL is dest -RWMOVE: LD A,(INVFDCDATA) ; Check to see if FDC data needs to be inverted. MB8866 controller works on negative logic. - RRCA - JR NC,RWMOVE3 -RWMOVE2: LD A, (DE) ; source character - CPL ; Change to positive values. - INC DE - LD (HL), A ; to dest - INC HL - DEC C ; loop 128 times - JR NZ, RWMOVE2 - JR RWMOVE4 -RWMOVE3: LD A, (DE) ; source character - INC DE - LD (HL), A ; to dest - INC HL - DEC C ; loop 128 times - JR NZ, RWMOVE3 - ; data has been moved to/from host buffer -RWMOVE4: LD A, (WRTYPE) ; write type - CP WRDIR ; to directory? - LD A, (ERFLAG) ; in case of errors - RET NZ ; no further processing - ; clear host buffer for directory write - OR A ; errors? - RET NZ ; skip if so - XOR A ; 0 to accum - LD (HSTWRT), A ; buffer written - CALL WRITEHST -RWEXIT: LD A, (ERFLAG) - RET - - ; utility subroutine for 16-bit compare - ; HL = .unatrk or .hsttrk, compare with sektrk -SEKTRKCMP: EX DE, HL - LD HL, SEKTRK - LD A, (DE) ; low byte compare - CP (HL) ; same? - RET NZ ; return if not - ; low bytes equal, test high 1s - INC DE - INC HL - LD A, (DE) - CP (HL) ; sets flags - RET - - ;------------------------------------------------------------------------------------------------ - ; Read physical sector from host - ; - ; Read data from the floppy disk or RFS. A = 1 if an error occurred. - ;------------------------------------------------------------------------------------------------ -READHST: PUSH BC - PUSH HL - LD A,(DISKTYPE) - CP DSKTYP_SDC ; Is the drive an SD Card? - JP Z,SDCREAD -READHST2: CALL ?DSKREAD ; Floppy card, use the FDC Controller. -READHST3: POP HL - POP BC - RET - - ;------------------------------------------------------------------------------------------------ - ; Write physical sector to host - ; - ; Write data to the floppy disk or RFS. A = 1 if an error occurred. - ;------------------------------------------------------------------------------------------------ -WRITEHST: PUSH BC - PUSH HL - LD A,(DISKTYPE) - CP DSKTYP_SDC ; Is the drive an SD Card? - JP Z,SDCWRITE - CALL ?DSKWRITE -WRITEHST3: POP HL - POP BC - RET -WRITEHST4: LD A,1 ; Error, cannot write. - JR WRITEHST3 - - ;------------------------------------------------------------------------------- - ; END OF CPM DEBLOCKING ALGORITHM - ;------------------------------------------------------------------------------- - - - ;------------------------------------------------------------------------------- - ; START OF DEBUGGING FUNCTIONALITY - ;------------------------------------------------------------------------------- - ; Debug routine to print out all registers and dump a section of memory for analysis. - ; -DEBUG: IF ENADEBUG = 1 - LD (DBGSTACKP),SP - LD SP,DBGSTACK - ; - PUSH AF - PUSH BC - PUSH DE - PUSH HL - ; - PUSH AF - PUSH HL - PUSH DE - PUSH BC - PUSH AF - LD DE, INFOMSG - CALL MONPRTSTR - POP BC - LD A,B - CALL ?PRTHX - LD A,C - CALL ?PRTHX - LD DE, INFOMSG2 - CALL MONPRTSTR - POP BC - LD A,B - CALL ?PRTHX - LD A,C - CALL ?PRTHX - LD DE, INFOMSG3 - CALL MONPRTSTR - POP DE - LD A,D - CALL ?PRTHX - LD A,E - CALL ?PRTHX - LD DE, INFOMSG4 - CALL MONPRTSTR - POP HL - LD A,H - CALL ?PRTHX - LD A,L - CALL ?PRTHX - LD DE, INFOMSG5 - CALL MONPRTSTR - LD HL,(DBGSTACKP) - LD A,H - CALL ?PRTHX - LD A,L - CALL ?PRTHX - CALL ?NL - - LD DE, DRVMSG - CALL MONPRTSTR - LD A, (CDISK) - CALL ?PRTHX - - LD DE, FDCDRVMSG - CALL MONPRTSTR - LD A, (FDCDISK) - CALL ?PRTHX - - LD DE, SEKTRKMSG - CALL MONPRTSTR - LD BC,(SEKTRK) - LD A,B - CALL ?PRTHX - LD A,C - CALL ?PRTHX - CALL ?PRTS - LD A,(SEKSEC) - CALL ?PRTHX - CALL ?PRTS - LD A,(SEKHST) - CALL ?PRTHX - - LD DE, HSTTRKMSG - CALL MONPRTSTR - LD BC,(HSTTRK) - LD A,B - CALL ?PRTHX - LD A,C - CALL ?PRTHX - CALL ?PRTS - LD A,(HSTSEC) - CALL ?PRTHX - - LD DE, UNATRKMSG - CALL MONPRTSTR - LD BC,(UNATRK) - LD A,B - CALL ?PRTHX - LD A,C - CALL ?PRTHX - CALL ?PRTS - LD A,(UNASEC) - CALL ?PRTHX - - LD DE, CTLTRKMSG - CALL MONPRTSTR - LD A,(TRACKNO) ; NB. Track number is 16bit, FDC only uses lower 8bit and assumes little endian read. - CALL ?PRTHX - CALL ?PRTS - LD A,(SECTORNO) - CALL ?PRTHX - - LD DE, DMAMSG - CALL MONPRTSTR - LD BC,(DMAADDR) - LD A,B - CALL ?PRTHX - LD A,C - CALL ?PRTHX - CALL ?NL - - POP AF - JR C, SKIPDUMP - LD HL,DPBASE ; Dump the startup vectors. - LD DE, 1000H - ADD HL, DE - EX DE,HL - LD HL,DPBASE - CALL DUMPX - - LD HL,00000h ; Dump the startup vectors. - LD DE, 00A0H - ADD HL, DE - EX DE,HL - LD HL,00000h - CALL DUMPX - - LD HL,IBUFE ; Dump the data area. - LD DE, 0300H - ADD HL, DE - EX DE,HL - LD HL,IBUFE - CALL DUMPX - - LD HL,CBASE ; Dump the CCP + BDOS area. - LD DE,CBIOSSTART - CBASE - ADD HL, DE - EX DE,HL - LD HL,CBASE - CALL DUMPX - -SKIPDUMP: POP HL - POP DE - POP BC - POP AF - ; - LD SP,(DBGSTACKP) - RET - - ; HL = Start - ; DE = End -DUMPX: LD A,23 -DUM1: LD (TMPCNT),A -DUM3: LD B,010h - LD C,02Fh - CALL NLPHL -DUM2: CALL SPHEX - INC HL - PUSH AF - LD A,(DSPXY) - ADD A,C - LD (DSPXY),A - POP AF - CP 020h - JR NC,L0D51 - LD A,02Eh -L0D51: CALL ?PRNT - LD A,(DSPXY) - INC C - SUB C - LD (DSPXY),A - DEC C - DEC C - DEC C - PUSH HL - SBC HL,DE - POP HL - JR NC,DUM7 -L0D78: DJNZ DUM2 - LD A,(TMPCNT) - DEC A - LD (TMPCNT),A - JR NZ,DUM3 -DUM4: CALL ?CHKKY - CP 0FFH - JR NZ,DUM4 - CALL ?GETKY - CP 'D' - JR NZ,DUM5 - LD A,8 - JR DUM1 -DUM5: CP 'U' - JR NZ,DUM6 - PUSH DE - LD DE,00100H - OR A - SBC HL,DE - POP DE - LD A,8 - JR DUM1 -DUM6: CP 'X' - JR Z,DUM7 - JR DUMPX -DUM7: CALL ?NL - RET - -NLPHL: CALL ?NL - CALL ?PRTHL - RET - - ; SPACE PRINT AND DISP ACC - ; INPUT:HL=DISP. ADR. -SPHEX: CALL ?PRTS ; SPACE PRINT - LD A,(HL) - CALL ?PRTHX ; DSP OF ACC (ASCII) - LD A,(HL) - RET - -DRVMSG: DB "DRV=", 000H -FDCDRVMSG: DB ",FDC=", 000H -SEKTRKMSG: DB ",S=", 000H -HSTTRKMSG: DB ",H=", 000H -UNATRKMSG: DB ",U=", 000H -CTLTRKMSG: DB ",C=", 000H -DMAMSG: DB ",D=", 000H -INFOMSG: DB "AF=", NUL -INFOMSG2: DB ",BC=", 000H -INFOMSG3: DB ",DE=", 000H -INFOMSG4: DB ",HL=", 000H -INFOMSG5: DB ",SP=", 000H - ENDIF - ;------------------------------------------------------------------------------- - ; END OF DEBUGGING FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;------------------------------------------------------------------------------- - ; START OF STATIC LOOKUP TABLES AND CONSTANTS - ;------------------------------------------------------------------------------- - -KTBL: ; Strobe 0 - DB '"' - DB '!' - DB 'W' - DB 'Q' - DB 'A' - DB INSERT - DB NULL - DB 'Z' - ; Strobe 1 - DB '$' - DB '#' - DB 'R' - DB 'E' - DB 'D' - DB 'S' - DB 'X' - DB 'C' - ; Strobe 2 - DB '&' - DB '%' - DB 'Y' - DB 'T' - DB 'G' - DB 'F' - DB 'V' - DB 'B' - ; Strobe 3 - DB '(' - DB '\'' - DB 'I' - DB 'U' - DB 'J' - DB 'H' - DB 'N' - DB SPACE - ; Strobe 4 - DB '_' - DB ')' - DB 'P' - DB 'O' - DB 'L' - DB 'K' - DB '<' - DB 'M' - ; Strobe 5 - DB '~' - DB '=' - DB '{' - DB '`' - DB '*' - DB '+' - DB CURSLEFT - DB '>' - ; Strobe 6 - DB HOMEKEY - DB '|' - DB CURSRIGHT - DB CURSUP - DB CR - DB '}' - DB NULL - DB CURSUP - ; Strobe 7 - DB '8' - DB '7' - DB '5' - DB '4' - DB '2' - DB '1' - DB DBLZERO - DB '0' - ; Strobe 8 - DB '*' - DB '9' - DB '-' - DB '6' - DB NULL - DB '3' - DB NULL - DB ',' - -KTBLS: ; Strobe 0 - DB '2' - DB '1' - DB 'w' - DB 'q' - DB 'a' - DB DELETE - DB NULL - DB 'z' - ; Strobe 1 - DB '4' - DB '3' - DB 'r' - DB 'e' - DB 'd' - DB 's' - DB 'x' - DB 'c' - ; Strobe 2 - DB '6' - DB '5' - DB 'y' - DB 't' - DB 'g' - DB 'f' - DB 'v' - DB 'b' - ; Strobe 3 - DB '8' - DB '7' - DB 'i' - DB 'u' - DB 'j' - DB 'h' - DB 'n' - DB SPACE - ; Strobe 4 - DB '0' - DB '9' - DB 'p' - DB 'o' - DB 'l' - DB 'k' - DB ',' - DB 'm' - ; Strobe 5 - DB '^' - DB '-' - DB '[' - DB '@' - DB ':' - DB ';' - DB '/' - DB '.' - ; Strobe 6 - DB CLRKEY - DB '\\' - DB CURSLEFT - DB CURSDOWN - DB CR - DB ']' - DB NULL - DB '?' - -KTBLCL: ; Strobe 0 - DB '2' - DB '1' - DB 'W' - DB 'Q' - DB 'A' - DB DELETE - DB NULL - DB 'Z' - ; Strobe 1 - DB '4' - DB '3' - DB 'R' - DB 'E' - DB 'D' - DB 'S' - DB 'X' - DB 'C' - ; Strobe 2 - DB '6' - DB '5' - DB 'Y' - DB 'T' - DB 'G' - DB 'F' - DB 'V' - DB 'B' - ; Strobe 3 - DB '8' - DB '7' - DB 'I' - DB 'U' - DB 'J' - DB 'H' - DB 'N' - DB SPACE - ; Strobe 4 - DB '0' - DB '9' - DB 'P' - DB 'O' - DB 'L' - DB 'K' - DB ',' - DB 'M' - ; Strobe 5 - DB '^' - DB '-' - DB '[' - DB '@' - DB ':' - DB ';' - DB '/' - DB '.' - ; Strobe 6 - DB CLRKEY - DB '\\' - DB CURSLEFT - DB CURSDOWN - DB CR - DB ']' - DB NULL - DB '?' - -KTBLC: ; CTRL ON - ; Strobe 0 - DB NOKEY - DB NOKEY - DB CTRL_W - DB CTRL_Q - DB CTRL_A - DB NOKEY - DB 000H - DB CTRL_Z - ; Strobe 1 - DB NOKEY - DB NOKEY - DB CTRL_R - DB CTRL_E - DB CTRL_D - DB CTRL_S - DB CTRL_X - DB CTRL_C - ; Strobe 2 - DB NOKEY - DB NOKEY - DB CTRL_Y - DB CTRL_T - DB CTRL_G - DB CTRL_F - DB CTRL_V - DB CTRL_B - ; Strobe 3 - DB NOKEY - DB NOKEY - DB CTRL_I - DB CTRL_U - DB CTRL_J - DB CTRL_H - DB CTRL_N - DB NOKEY - ; Strobe 4 - DB NOKEY - DB NOKEY - DB CTRL_P - DB CTRL_O - DB CTRL_L - DB CTRL_K - DB NOKEY - DB CTRL_M - ; Strobe 5 - DB CTRL_CAPPA - DB CTRL_UNDSCR - DB ESC - DB CTRL_AT - DB NOKEY - DB NOKEY - DB NOKEY - DB NOKEY - ; Strobe 6 - DB NOKEY - DB CTRL_SLASH - DB NOKEY - DB NOKEY - DB NOKEY - DB CTRL_RB - DB NOKEY - - - -CBIOSSIGNON:IF BUILD_80C = 1 - DB "** CBIOS v1.25, (C) P.D. Smart, 2019-21. Drives:", NUL - ELSE - DB "CBIOS v1.25, (C) P.D. Smart, 2019-21. " - DB "Drives:", NUL - ENDIF -CBIOSIGNEND:IF BUILD_80C = 1 - DB " **", CR, NUL - ELSE - DB CR, NUL - ENDIF -NOBDOS: DB "No BDOS, aborting!", CR, LF, NUL -CPMROMFNAME:DB "CPM223RFS", NUL -ROMFDERRMSG:DB "ROM FIND ERR", CR, NUL -SDAVAIL: DB "SD", NUL -FDCAVAIL: DB "FDC", NUL - ;------------------------------------------------------------------------------- - ; END OF STATIC LOOKUP TABLES AND CONSTANTS - ;------------------------------------------------------------------------------- - -; Disk Parameter Header template. -DPBTMPL: DW 0000H, 0000H, 0000H, 0000H, CDIRBUF - - ; Allocate space for 8 disk parameter block definitions in ROM. - ; - ALIGN_NOPS SCRN - (8 * 16) -;------------------------------------------------------------------------------------------------------------ -; DISK PARAMETER BLOCK -; -; +----+----+------+-----+-----+------+----+----+-----+----+ -; |SPT |BSH |BLM |EXM |DSM |DRM |AL0 |AL1 |CKS |OFF | -; +----+----+------+-----+-----+------+----+----+-----+----+ -; 16B 8B 8B 8B 16B 16B 8B 8B 16B 16B -; -; -SPT is the total number of sectors per track. -; -BSH is the data allocation block shift factor, determined by the data block allocation size. -; -BLM is the data allocation block mask (2[BSH-1]). -; -EXM is the extent mask, determined by the data block allocation size and the number of disk blocks. -; -DSM determines the total storage capacity of the disk drive. -; -DRM determines the total number of directory entries that can be stored on this drive. -; -AL0, AL1 determine reserved directory blocks. -; -CKS is the size of the directory check vector. -; -OFF is the number of reserved tracks at the beginning of the (logical) disk -; -; BLS BSH BLM EXM (DSM < 256) EXM (DSM > 255) -; 1,024 3 7 0 N/A -; 2,048 4 15 1 0 -; 4,096 5 31 3 1 -; 8,192 6 63 7 3 -; 16,384 7 127 15 7 -;------------------------------------------------------------------------------------------------------------ - -; MZ-800 drive but using both heads per track rather than the original -; 1 head for all tracks on side A switching to second head and -; restarting at track 0. -DPB0: DW 64 ; SPT - 128 bytes sectors per track - DB 4 ; BSH - block shift factor - DB 15 ; BLM - block mask - DB 1 ; EXM - Extent mask - DW 155 ; DSM - Storage size (blocks - 1) - DW 63 ; DRM - Number of directory entries - 1 - DB 128 ; AL0 - 1 bit set per directory block - DB 0 ; AL1 - " - DW 16 ; CKS - DIR check vector size (DRM+1)/4 (0=fixed disk) - DW 1 ; OFF - Reserved tracks - DB 6 ; CFG - MZ80A Addition, configuration flag: - ; Bit 1:0 = FDC: Sector Size, 00 = 128, 10 = 256, 11 = 512, 01 = Unused. - ; Bit 2 = Invert, 1 = Invert data, 0 = Use data as read (on MB8866 this is inverted). - ; Bit 4:3 = Disk type, 00 = FDC, 10 = ROM, 11 = SD Card, 01 = Unused - ; Bit 5 = ROMFS Image, 0 = DRV0, 1 = DRV1 - - -; Rom Filing System File Image acting as a drive. -; There are two definitions, 1 for each ROM drive, they can be identical but the CFG bit 5 will differ. -DPB1: DW 128 ; SPT - 128 bytes sectors per track - DB 4 ; 3 ; BSH - block shift factor (Set to 3 for a 240K RomRFS Image). - DB 15 ; 7 ; BLM - block mask (Set to 7 for a 240K RomRFS Image). - DB 0 ; EXM - Extent mask - DW 159 ; 240 ; DSM - Storage size (blocks - 1) (Set to 240 for a 240K RomRFS Image). - DW 63 ; 31 ; DRM - Number of directory entries - 1 - DB 128 ; AL0 - 1 bit set per directory block - DB 0 ; AL1 - " - DW 0 ; 16 ; CKS - DIR check vector size (DRM+1)/4 (0=fixed disk) - DW 0 ; OFF - Reserved tracks - DB 16 ; CFG - MZ80A Addition, configuration flag: - ; Bit 1:0 = FDC: Sector Size, 00 = 128, 10 = 256, 11 = 512, 01 = Unused. - ; Bit 2 = Invert, 1 = Invert data, 0 = Use data as read (on MB8866 this is inverted). - ; Bit 4:3 = Disk type, 00 = FDC, 10 = ROM, 11 = SD Card, 01 = Unused - ; Bit 5 = ROMFS Image, 0 = DRV0, 1 = DRV1 - -; Rom Filing System File Image acting as a drive. -; There are two definitions, 1 for each ROM drive, they can be identical but the CFG bit 5 will differ. -DPB2: DW 128 ; SPT - 128 bytes sectors per track - DB 4 ; 3 ; BSH - block shift factor (Set to 3 for a 240K RomRFS Image). - DB 15 ; 7 ; BLM - block mask (Set to 7 for a 240K RomRFS Image). - DB 0 ; EXM - Extent mask - DW 159 ; 240 ; DSM - Storage size (blocks - 1) (Set to 240 for a 240K RomRFS Image). - DW 63 ; 31 ; DRM - Number of directory entries - 1 - DB 128 ; AL0 - 1 bit set per directory block - DB 0 ; AL1 - " - DW 0 ; 16 ; CKS - DIR check vector size (DRM+1)/4 (0=fixed disk) - DW 0 ; OFF - Reserved tracks - DB 48 ; CFG - MZ80A Addition, configuration flag: - ; Bit 1:0 = FDC: Sector Size, 00 = 128, 10 = 256, 11 = 512, 01 = Unused. - ; Bit 2 = Invert, 1 = Invert data, 0 = Use data as read (on MB8866 this is inverted). - ; Bit 4:3 = Disk type, 00 = FDC, 10 = ROM, 11 = SD Card, 01 = Unused - ; Bit 5 = ROMFS Image, 0 = DRV0, 1 = DRV1 - - -; 1.44MB Floppy -DPB3: DW 144 ; SPT - 128 bytes sectors per track (= 36 sectors of 512 bytes) - DB 4 ; BSH - block shift factor - DB 15 ; BLM - block mask - DB 0 ; EXM - Extent mask - DW 719 ; DSM - Storage size (blocks - 1) - DW 127 ; DRM - Number of directory entries - 1 - DB 192 ; AL0 - 1 bit set per directory block - DB 0 ; AL1 - " - DW 32 ; CKS - DIR check vector size (DRM+1)/4 (0=fixed disk) - DW 0 ; OFF - Reserved tracks - DB 7 ; CFG - MZ80A Addition, configuration flag: - ; Bit 1:0 = FDC: Sector Size, 00 = 128, 10 = 256, 11 = 512, 01 = Unused. - ; Bit 2 = Invert, 1 = Invert data, 0 = Use data as read (on MB8866 this is inverted). - ; Bit 4:3 = Disk type, 00 = FDC, 10 = ROM, 11 = SD Card, 01 = Unused - ; Bit 5 = ROMFS Image, 0 = DRV0, 1 = DRV1 - -; 16Mb SD Hard Disk drives (not hot-swappable). -; This drive has 2048 blocks (small due to size of RAM needed, more blocks more RAM) of 8192 bytes = 16Mb -; There are 1024 directory entries thus AL0/AL1 needs to ave the top four bits set as each block can hold 256 directory entries. -; This implementation limits the sectors per track to 255 (8 bit) even though CPM supports 16bit sectors, so the -; physical drive make up is: 32 Sectors (128 CPM sectors of 128 bytes each) x 1024 tracks, 1 head = 16777216bytes. -; This size has been chosen to maximise the use of the SD Card space and the number of files/programs which can be online -; at the same time. On the MZ80A, memory is more of a premium so keeping the DRM as low as possible saves RAM. -; -DPB4: DW 128 ; SPT - 128 bytes sectors per track (= 36 sectors of 512 bytes) - DB 6 ; BSH - block shift factor - DB 63 ; BLM - block mask - DB 3 ; EXM - Extent mask - DW 2047 ; DSM - Storage size (blocks - 1) - DW 511 ; DRM - Number of directory entries - 1 - DB 192 ; AL0 - 1 bit set per directory block - DB 0 ; AL1 - " - DW 0 ; CKS - DIR check vector size (DRM+1)/4 (0=fixed disk) - DW 0 ; OFF - Reserved tracks - DB 27 ; CFG - MZ80A Addition, configuration flag: - ; Bit 1:0 = FDC: Sector Size, 00 = 128, 10 = 256, 11 = 512, 01 = Unused. - ; Bit 2 = Invert, 1 = Invert data, 0 = Use data as read (on MB8866 this is inverted). - ; Bit 4:3 = Disk type, 00 = FDC, 10 = ROM, 11 = SD Card, 01 = Unused - ; Bit 5 = ROMFS Image, 0 = DRV0, 1 = DRV1 - - -; Rom Filing System RAM Drive. -; If the RFS v2.x board has the optional 512KRAM installed in slot 3 then this definition is used to create a RAM based disk drive within it. -; -DPB5: DW 128 ; SPT - 128 bytes sectors per track - DB 4 ; 3 ; BSH - block shift factor (Set to 3 for a 240K RomRFS Image). - DB 15 ; 7 ; BLM - block mask (Set to 7 for a 240K RomRFS Image). - DB 0 ; EXM - Extent mask - DW 159 ; 240 ; DSM - Storage size (blocks - 1) (Set to 240 for a 240K RomRFS Image). - DW 63 ; 31 ; DRM - Number of directory entries - 1 - DB 128 ; AL0 - 1 bit set per directory block - DB 0 ; AL1 - " - DW 0 ; 16 ; CKS - DIR check vector size (DRM+1)/4 (0=fixed disk) - DW 0 ; OFF - Reserved tracks - DB 8 ; CFG - MZ80A Addition, configuration flag: - ; Bit 1:0 = FDC: Sector Size, 00 = 128, 10 = 256, 11 = 512, 01 = Unused. - ; Bit 2 = Invert, 1 = Invert data, 0 = Use data as read (on MB8866 this is inverted). - ; Bit 4:3 = Disk type, 00 = FDC, 10 = ROM, 11 = SD Card, 01 = RAM - ; Bit 5 = ROMFS Image, 0 = DRV0, 1 = DRV1 - - - ALIGN_NOPS SCRN diff --git a/software/asm/cbios_bank1.asm b/software/asm/cbios_bank1.asm deleted file mode 100644 index 3b0bac8..0000000 --- a/software/asm/cbios_bank1.asm +++ /dev/null @@ -1,456 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: cbios_bank1.asm -;- Created: January 2020 -;- Author(s): Philip Smart -;- Description: Sharp MZ series CPM BIOS System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade for the CPM CBIOS in order to preserve RAM for actual -;- CPM TPA programs. -;- -;- Credits: -;- Copyright: (c) 2018-23 Philip Smart -;- -;- History: Jan 2020 - Seperated Bank from RFS for dedicated use with CPM CBIOS. -;- May 2020 - Advent of the new RFS PCB v2.0, quite a few changes to accommodate the -;- additional and different hardware. The SPI is now onboard the PCB and -;- not using the printer interface card. -;- Mar 2021 - Updates for the RFS v2.1 board. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - ; Bring in definitions and macros. - INCLUDE "cpm_buildversion.asm" - INCLUDE "cpm_definitions.asm" - INCLUDE "macros.asm" - - ;====================================== - ; - ; USER ROM CPM CBIOS BANK 1 - ; - ;====================================== - ORG UROMADDR - - ;----------------------------------------------------------------------------------------- - ; Common code spanning all banks to ensure that a Monitor is selected upon power up/reset. - ;----------------------------------------------------------------------------------------- - NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -CBIOS1_0: LD A,(BNKCTRLRST) - DJNZ CBIOS1_0 ; Apply the default number of coded latch reads to enable the bank control registers. -CBIOS1_1: LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - NOP - NOP - NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select MROM bank 0 - LD (BNKSELMROM),A - NOP - NOP - NOP - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - ; - ; No mans land... this should have switched to Bank 0 and at this point there is a jump to 00000H. - JP 00000H ; This is for safety!! - - - ;------------------------------------------------------------------------------- - ; Jump table for entry into this pages functions. - ;------------------------------------------------------------------------------- - ALIGN_NOPS UROMJMPTBL - JP ?REBOOT ; REBOOT - JP ?MLDY ; QMELDY - JP ?TEMP ; QTEMP - JP MLDST ; QMSTA - JP MLDSP ; QMSTP - JP ?BEL ; QBEL - JP ?MODE ; QMODE - JP ?TIMESET ; QTIMESET - JP ?TIMEREAD ; QTIMEREAD - JP ?CHKKY ; QCHKKY - JP ?GETKY ; QGETKY - - - - ; Method to reboot the machine into startup mode, ie. Monitor at MROM Bank 0, UROM at Bank 0. -?REBOOT: LD A,(MEMSWR) ; Switch memory to power up state, ie. Monitor ROM at 00000H - JP CBIOS1_1 ; Now run the code at the bank start which switches to bank 0, intitialises and then calls 00000H - - ;------------------------------------------------------------------------------- - ; START OF AUDIO CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; Melody function. -?MLDY: PUSH BC - PUSH DE - PUSH HL - LD A,002H - LD (OCTV),A - LD B,001H -MLD1: LD A,(DE) - CP 00DH - JR Z,MLD4 - CP 0C8H - JR Z,MLD4 - CP 0CFH - JR Z,MLD2 - CP 02DH - JR Z,MLD2 - CP 02BH - JR Z,MLD3 - CP 0D7H - JR Z,MLD3 - CP 023H - LD HL,MTBL - JR NZ,MLD1A - LD HL,M?TBL - INC DE -MLD1A: CALL ONPU - JR C,MLD1 - CALL RYTHM - JR C,MLD5 - CALL MLDST - LD B,C - JR MLD1 -MLD2: LD A,003H -MLD2A: LD (OCTV),A - INC DE - JR MLD1 -MLD3: LD A,001H - JR MLD2A -MLD4: CALL RYTHM -MLD5: PUSH AF - CALL MLDSP - POP AF - POP HL - POP DE - POP BC - RET - -ONPU: PUSH BC - LD B,008H - LD A,(DE) -ONP1A: CP (HL) - JR Z,ONP2 - INC HL - INC HL - INC HL - DJNZ ONP1A - SCF - INC DE - POP BC - RET - -ONP2: INC HL - PUSH DE - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL - LD A,H - OR A - JR Z,ONP2B - LD A,(OCTV) -ONP2A: DEC A - JR Z,ONP2B - ADD HL,HL - JR ONP2A -ONP2B: LD (RATIO),HL - LD HL,OCTV - LD (HL),002H - DEC HL - POP DE - INC DE - LD A,(DE) - LD B,A - AND 0F0H - CP 030H - JR Z,ONP2C - LD A,(HL) - JR ONP2D -ONP2C: INC DE - LD A,B - AND 00FH - LD (HL),A -ONP2D: LD HL,OPTBL - ADD A,L - LD L,A - LD C,(HL) - LD A,(TEMPW) - LD B,A - XOR A - JP MLDDLY - -RYTHM: LD HL,KEYPA - LD (HL),0F0H - INC HL - LD A,(HL) - AND 081H - JR NZ,L02D5 - SCF - RET - -L02D5: LD A,(SUNDG) - RRCA - JR C,L02D5 -L02DB: LD A,(SUNDG) - RRCA - JR NC,L02DB - DJNZ L02D5 - XOR A - RET - -MLDST: LD HL,(RATIO) - LD A,H - OR A - JR Z,MLDSP - PUSH DE - EX DE,HL - LD HL,CONT0 - LD (HL),E - LD (HL),D - LD A,001H - POP DE - JR L02C4 -MLDSP: LD A,034H - LD (CONTF),A - XOR A -L02C4: LD (SUNDG),A - RET - -MLDDLY: ADD A,C - DJNZ MLDDLY - POP BC - LD C,A - XOR A - RET - - -?TEMP: PUSH AF - PUSH BC - AND 00FH - LD B,A - LD A,008H - SUB B - LD (TEMPW),A - POP BC - POP AF - RET - - ; - ; Method to sound the bell, basically play a constant tone. - ; -?BEL: PUSH DE - LD DE,00DB1H - CALL ?MLDY - POP DE - RET - - ; - ; Melody (note) lookup table. - ; -MTBL: DB 043H - DB 077H - DB 007H - DB 044H - DB 0A7H - DB 006H - DB 045H - DB 0EDH - DB 005H - DB 046H - DB 098H - DB 005H - DB 047H - DB 0FCH - DB 004H - DB 041H - DB 071H - DB 004H - DB 042H - DB 0F5H - DB 003H - DB 052H - DB 000H - DB 000H -M?TBL: DB 043H - DB 00CH - DB 007H - DB 044H - DB 047H - DB 006H - DB 045H - DB 098H - DB 005H - DB 046H - DB 048H - DB 005H - DB 047H - DB 0B4H - DB 004H - DB 041H - DB 031H - DB 004H - DB 042H - DB 0BBH - DB 003H - DB 052H - DB 000H - DB 000H - -OPTBL: DB 001H - DB 002H - DB 003H - DB 004H - DB 006H - DB 008H - DB 00CH - DB 010H - DB 018H - DB 020H - ;------------------------------------------------------------------------------- - ; END OF AUDIO CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - - ;------------------------------------------------------------------------------- - ; START OF RTC FUNCTIONALITY (INTR HANDLER IN MAIN CBIOS) - ;------------------------------------------------------------------------------- - ; - ; BC:DE:HL contains the time in milliseconds (100msec resolution) since 01/01/1980. In IX is held the interrupt service handler routine address for the RTC. - ; HL contains lower 16 bits, DE contains middle 16 bits, BC contains upper 16bits, allows for a time from 00:00:00 to 23:59:59, for > 500000 days! - ; NB. Caller must disable interrupts before calling this method. -?TIMESET: LD (TIMESEC),HL ; Load lower 16 bits. - EX DE,HL - LD (TIMESEC+2),HL ; Load middle 16 bits. - PUSH BC - POP HL - LD (TIMESEC+4),HL ; Load upper 16 bits. - ; - LD HL,CONTF - LD (HL),074H ; Set Counter 1, read/load lsb first then msb, mode 2 rate generator, binary - LD (HL),0B0H ; Set Counter 2, read/load lsb first then msb, mode 0 interrupt on terminal count, binary - DEC HL - LD DE,TMRTICKINTV ; 100Hz coming into Timer 2 from Timer 1, set divisor to set interrupts per second. - LD (HL),E ; Place current time in Counter 2 - LD (HL),D - DEC HL - LD (HL),03BH ; Place divisor in Counter 1, = 315, thus 31500/315 = 100 - LD (HL),001H - NOP - NOP - NOP - ; - LD A, 0C3H ; Install the interrupt vector for when interrupts are enabled. - LD (00038H),A - LD (00039H),IX - RET - - ; Time Read; - ; Returns BC:DE:HL where HL is lower 16bits, DE is middle 16bits and BC is upper 16bits of milliseconds since 01/01/1980. -?TIMEREAD: LD HL,(TIMESEC+4) - PUSH HL - POP BC - LD HL,(TIMESEC+2) - EX DE,HL - LD HL,(TIMESEC) - RET - ;------------------------------------------------------------------------------- - ; END OF RTC FUNCTIONALITY - ;------------------------------------------------------------------------------- - - - ;------------------------------------------------------------------------------- - ; START OF KEYBOARD FUNCTIONALITY (INTR HANDLER SEPERATE IN CBIOS) - ;------------------------------------------------------------------------------- - -?MODE: LD HL,KEYPF - LD (HL),08AH - LD (HL),007H ; Set Motor to Off. - LD (HL),004H ; Disable interrupts by setting INTMSK to 0. - LD (HL),001H ; Set VGATE to 1. - RET - - ; Method to check if a key has been pressed and stored in buffer.. -?CHKKY: LD A, (KEYCOUNT) - OR A - JR Z,CHKKY2 - LD A,0FFH - RET -CHKKY2: XOR A - RET - -?GETKY: PUSH HL - LD A,(KEYCOUNT) - OR A - JR Z,GETKY2 -GETKY1: DI ; Disable interrupts, we dont want a race state occurring. - LD A,(KEYCOUNT) - DEC A ; Take 1 off the total count as we are reading a character out of the buffer. - LD (KEYCOUNT),A - LD HL,(KEYREAD) ; Get the position in the buffer where the next available character resides. - LD A,(HL) ; Read the character and save. - PUSH AF - INC L ; Update the read pointer and save. - LD A,L - AND KEYBUFSIZE-1 - LD L,A - LD (KEYREAD),HL - POP AF - EI ; Interrupts back on so keys and RTC are actioned. - JR ?PRCKEY ; Process the key, action any non ASCII keys. - ; -GETKY2: LD A,(KEYCOUNT) ; No key available so loop until one is. - OR A - JR Z,GETKY2 - JR GETKY1 - ; -?PRCKEY: CP CR ; CR - JR NZ,?PRCKY3 - JR ?PRCKYE -?PRCKY3: CP HOMEKEY ; HOME - JR NZ,?PRCKY4 - JR GETKY2 -?PRCKY4: CP CLRKEY ; CLR - JR NZ,?PRCKY5 - JR GETKY2 -?PRCKY5: CP INSERT ; INSERT - JR NZ,?PRCKY6 - JR GETKY2 -?PRCKY6: CP DBLZERO ; 00 - JR NZ,?PRCKY7 - LD A,'0' - LD (KEYBUF),A ; Place a character into the keybuffer so we double up on 0 - JR ?PRCKYX -?PRCKY7: CP BREAKKEY ; Break key processing. - JR NZ,?PRCKY8 - JR ?PRCKYE -?PRCKY8: CP DELETE - JR NZ,?PRCKYX - LD A,BACKS ; Map DELETE to BACKSPACE, BACKSPACE is Rubout, DELETE is echo in CPM. -?PRCKYX: -?PRCKYE: - POP HL - RET - - ;------------------------------------------------------------------------------- - ; END OF KEYBOARD FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; Align to end of bank. - ALIGN UROMADDR + 07F8h - ORG UROMADDR + 07F8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh diff --git a/software/asm/cbios_bank2.asm b/software/asm/cbios_bank2.asm deleted file mode 100644 index 62cf113..0000000 --- a/software/asm/cbios_bank2.asm +++ /dev/null @@ -1,1468 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: cbios_bank2.asm -;- Created: January 2020 -;- Author(s): Philip Smart -;- Description: Sharp MZ series CPM BIOS System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade for the CPM CBIOS in order to preserve RAM for actual -;- CPM TPA programs. -;- -;- Credits: ANSITERM utilises a heavily customised version of Ewen McNeill's Amstrad CPC EwenTerm -; Ansi Parser. -; -; (C) Oct 2000 - only the ansiterm.22b module was used with a lot stripped out. -;- Copyright: (c) 2018-23 Philip Smart -;- -;- History: Jan 2020 - Seperated Bank from RFS for dedicated use with CPM CBIOS. -;- May 2020 - Advent of the new RFS PCB v2.0, quite a few changes to accommodate the -;- additional and different hardware. The SPI is now onboard the PCB and -;- not using the printer interface card. -;- Mar 2021 - Updates for the RFS v2.1 board. -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - ; Bring in definitions and macros. - INCLUDE "cpm_buildversion.asm" - INCLUDE "cpm_definitions.asm" - INCLUDE "macros.asm" - - ;====================================== - ; - ; USER ROM CPM CBIOS BANK 2 - ; - ;====================================== - ORG UROMADDR - - ;----------------------------------------------------------------------------------------- - ; Common code spanning all banks to ensure that a Monitor is selected upon power up/reset. - ;----------------------------------------------------------------------------------------- - NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -CBIOS2_0: LD A,(BNKCTRLRST) - DJNZ CBIOS2_0 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - NOP - NOP - NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select MROM bank 0 - LD (BNKSELMROM),A - NOP - NOP - NOP - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - ; - ; No mans land... this should have switched to Bank 0 and at this point there is a jump to 00000H. - JP 00000H ; This is for safety!! - - - ;------------------------------------------------------------------------------- - ; Jump table for entry into this pages functions. - ;------------------------------------------------------------------------------- - ALIGN_NOPS UROMJMPTBL - JP ?PRNT ; QPRNT - JP ?PRTHX ; QPRTHX - JP ?PRTHL ; QPRTHL - JP ?ANSITERM ; QANSITERM - - ;------------------------------------------------------------------------------- - ; START OF SCREEN FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; CR PAGE MODE1 -.CR: CALL .MANG - RRCA - JP NC,CURS2 - LD L,000H - INC H - CP ROW - 1 ; End of line? - JR Z,.CP1 - INC H - JP CURS1 - -.CP1: LD (DSPXY),HL - - ; SCROLLER -.SCROL: LD BC,SCRNSZ - COLW ; Scroll COLW -1 lines - LD DE,SCRN ; Start of the screen. - LD HL,SCRN + COLW ; Start of screen + 1 line. - LDIR - EX DE,HL - LD B,COLW ; Clear last line at bottom of screen. - CALL ?CLER - LD BC,0001AH - LD DE,MANG - LD HL,MANG + 1 - LDIR - LD (HL),000H - LD A,(MANG) - OR A - JP Z,?RSTR - LD HL,DSPXY + 1 - DEC (HL) - JR .SCROL - -?DPCT: PUSH AF ; Display control, character is mapped to a function call. - PUSH BC - PUSH DE - PUSH HL - LD B,A - AND 0F0H - CP 0C0H - JP NZ,?RSTR - XOR B - RLCA - LD C,A - LD B,000H - LD HL,.CTBL -DPCT1: ADD HL,BC - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL - JP (HL) - - -?PRT: LD A,C - CALL ?ADCN - LD C,A - AND 0F0H - CP 0F0H - RET Z - - CP 0C0H - LD A,C - JR NZ,PRNT3 -PRNT5: CALL ?DPCT - CP 0C3H - JR Z,PRNT4 - CP 0C5H - JR Z,PRNT2 - CP 0CDH ; CR - JR Z,PRNT2 - CP 0C6H - RET NZ - -PRNT2: XOR A -PRNT2A: LD (DPRNT),A - RET - -PRNT3: CALL ?DSP -PRNT4: LD A,(DPRNT) - INC A - CP COLW*2 ; 050H - JR C,PRNT4A - SUB COLW*2 ; 050H -PRNT4A: JR PRNT2A - -?NL: LD A,(DPRNT) - OR A - RET Z - -?LTNL: LD A,0CDH - JR PRNT5 -?PRTT: CALL ?PRTS - LD A,(DPRNT) - OR A - RET Z - -L098C: SUB 00AH - JR C,?PRTT - JR NZ,L098C - RET - - ; Delete a character on screen. -?DELCHR: LD A,0C7H - CALL ?DPCT - JR ?PRNT1 - -?NEWLINE: CALL ?NL - JR ?PRNT1 - - ; - ; Function to disable the cursor display. - ; -CURSOROFF: DI - CALL CURSRSTR ; Restore character under the cursor. - LD HL,FLASHCTL ; Indicate cursor is now off. - RES 7,(HL) - EI - RET - - ; - ; Function to enable the cursor display. - ; -CURSORON: DI - CALL DSPXYTOADDR ; Update the screen address for where the cursor should appear. - LD HL,FLASHCTL ; Indicate cursor is now on. - SET 7,(HL) - EI - RET - - ; - ; Function to restore the character beneath the cursor iff the cursor is being dislayed. - ; -CURSRSTR: PUSH HL - PUSH AF - LD HL,FLASHCTL ; Check to see if there is a cursor at the current screen location. - BIT 6,(HL) - JR Z,CURSRSTR1 - RES 6,(HL) - LD HL,(DSPXYADDR) ; There is so we must restore the original character before further processing. - LD A,(FLASH) - LD (HL),A -CURSRSTR1: POP AF - POP HL - RET - - ; - ; Function to convert XY co-ordinates to a physical screen location and save. - ; -DSPXYTOADDR:PUSH HL - PUSH DE - PUSH BC - LD BC,(DSPXY) ; Calculate the new cursor position based on the XY coordinates. - LD DE,COLW - LD HL,SCRN - COLW -DSPXYTOA1: ADD HL,DE - DEC B - JP P,DSPXYTOA1 - LD B,000H - ADD HL,BC - RES 3,H - LD (DSPXYADDR),HL ; Store the new address. - LD A,(HL) ; Store the new character. - LD (FLASH),A -DSPXYTOA2: POP BC - POP DE - POP HL - RET - - ; - ; Function to print a space. - ; -?PRTS: LD A,020H - - ; Function to print a character to the screen. If the character is a control code it is processed as necessary - ; otherwise the character is converted from ASCII display and displayed. - ; -?PRNT: DI - CALL CURSRSTR ; Restore char under cursor. - CP 00DH - JR Z,?NEWLINE - CP 00AH - JR Z,?NEWLINE - CP 07FH - JR Z,?DELCHR - CP BACKS - JR Z,?DELCHR - PUSH BC - LD C,A - LD B,A - CALL ?PRT - LD A,B - POP BC -?PRNT1: CALL DSPXYTOADDR - EI - RET - - ; - ; Function to print out the contents of HL as 4 digit Hexadecimal. - ; -?PRTHL: LD A,H - CALL ?PRTHX - LD A,L - JR ?PRTHX - RET - - ; - ; Function to print out the contents of A as 2 digit Hexadecimal - ; -?PRTHX: PUSH AF - RRCA - RRCA - RRCA - RRCA - CALL ASC - CALL ?PRNT - POP AF - CALL ASC - JP ?PRNT - -ASC: AND 00FH - CP 00AH - JR C,NOADD - ADD A,007H -NOADD: ADD A,030H - RET - -CLR8Z: XOR A - LD BC,00800H - PUSH DE - LD D,A -L09E8: LD (HL),D - INC HL - DEC BC - LD A,B - OR C - JR NZ,L09E8 - POP DE - RET - -REV: LD HL,REVFLG - LD A,(HL) - OR A - CPL - LD (HL),A - JR Z,REV1 - LD A,(INVDSP) - JR REV2 -REV1: LD A,(NRMDSP) -REV2: JP ?RSTR - -.MANG: LD HL,MANG -.MANG2: LD A,(DSPXY + 1) - ADD A,L - LD L,A - LD A,(HL) - INC HL - RL (HL) - OR (HL) - RR (HL) - RRCA - EX DE,HL - LD HL,(DSPXY) - RET - -L09C7: PUSH DE - PUSH HL - LD HL,PBIAS - XOR A - RLD - LD D,A - LD E,(HL) - RRD - XOR A - RR D - RR E - LD HL,SCRN - ADD HL,DE - LD (PAGETP),HL - POP HL - POP DE - RET - -?DSP: PUSH AF - PUSH BC - PUSH DE - PUSH HL - LD B,A - CALL ?PONT - LD (HL),B - LD HL,(DSPXY) - LD A,L -DSP01: CP COLW - 1 ; End of line. - JP NZ,CURSR - CALL .MANG - JR C,CURSR -.DSP03: EX DE,HL - LD (HL),001H - INC HL - LD (HL),000H - JP CURSR - -CURSD: LD HL,(DSPXY) - LD A,H - CP ROW - 1 - JR Z,CURS4 - INC H -CURS1: ;CALL MGP.I -CURS3: LD (DSPXY),HL - JR ?RSTR - -CURSU: LD HL,(DSPXY) - LD A,H - OR A - JR Z,CURS5 - DEC H -CURSU1: JR CURS3 - -CURSR: LD HL,(DSPXY) - LD A,L - CP COLW - 1 ; End of line - JR NC,CURS2 - INC L - JR CURS3 -CURS2: LD L,000H - INC H - LD A,H - CP ROW - JR C,CURS1 - LD H,ROW - 1 - LD (DSPXY),HL -CURS4: JP .SCROL - -CURSL: LD HL,(DSPXY) - LD A,L - OR A - JR Z,CURS5A - DEC L - JR CURS3 -CURS5A: LD L,COLW - 1 ; End of line - DEC H - JP P,CURSU1 - LD H,000H - LD (DSPXY),HL -CURS5: JR ?RSTR - -CLRS: LD HL,MANG - LD B,01BH - CALL ?CLER - LD HL,SCRN - PUSH HL - CALL CLR8Z - POP HL -CLRS1: LD A,(SCLDSP) -HOM0: LD HL,00000H - JP CURS3 - -?RSTR: POP HL -?RSTR1: POP DE - POP BC - POP AF - RET - -DEL: LD HL,(DSPXY) - LD A,H - OR L - JR Z,?RSTR - LD A,L - OR A - JR NZ,DEL1 - CALL .MANG - JR C,DEL1 - CALL ?PONT - DEC HL - LD (HL),000H - JR CURSL -DEL1: CALL .MANG - RRCA - LD A,COLW - JR NC,L0F13 - RLCA -L0F13: SUB L - LD B,A - CALL ?PONT - PUSH HL - POP DE - DEC DE - SET 4,D -DEL2: RES 3,H - RES 3,D - LD A,(HL) - LD (DE),A - INC HL - INC DE - DJNZ DEL2 - DEC HL - LD (HL),000H - JP CURSL - -INST: CALL .MANG - RRCA - LD L,COLW - 1 ; End of line - LD A,L - JR NC,INST1A - INC H -INST1A: CALL ?PNT1 - PUSH HL - LD HL,(DSPXY) - JR NC,INST2 - LD A,(COLW*2)-1 ; 04FH -INST2: SUB L - LD B,A - POP DE - LD A,(DE) - OR A - JR NZ,?RSTR - CALL ?PONT - LD A,(HL) - LD (HL),000H -INST1: INC HL - RES 3,H - LD E,(HL) - LD (HL),A - LD A,E - DJNZ INST1 - JR ?RSTR - -?PONT: LD HL,(DSPXY) -?PNT1: PUSH AF - PUSH BC - PUSH DE - PUSH HL - POP BC - LD DE,COLW - LD HL,SCRN - COLW -?PNT2: ADD HL,DE - DEC B - JP P,?PNT2 - LD B,000H - ADD HL,BC - RES 3,H - POP DE - POP BC - POP AF - RET - -?CLER: XOR A - JR ?DINT -?CLRFF: LD A,0FFH -?DINT: LD (HL),A - INC HL - DJNZ ?DINT - RET - -?ADCN: PUSH BC - PUSH HL - LD HL,ATBL ;00AB5H - LD C,A - LD B,000H - ADD HL,BC - LD A,(HL) - JR DACN3 - -?DACN: PUSH BC - PUSH HL - PUSH DE - LD HL,ATBL - LD D,H - LD E,L - LD BC,00100H - CPIR - JR Z,DACN1 - LD A,0F0H -DACN2: POP DE -DACN3: POP HL - POP BC - RET - -DACN1: OR A - DEC HL - SBC HL,DE - LD A,L - JR DACN2 - - ; CTBL PAGE MODE1 -.CTBL: DW .SCROL - DW CURSD - DW CURSU - DW CURSR - DW CURSL - DW HOM0 - DW CLRS - DW DEL - DW INST - DW ?RSTR - DW ?RSTR - DW ?RSTR - DW REV - DW .CR - DW ?RSTR - DW ?RSTR - -; ASCII TO DISPLAY CODE TABLE -ATBL: DB 0CCH ; NUL '\0' (null character) - DB 0E0H ; SOH (start of heading) - DB 0F2H ; STX (start of text) - DB 0F3H ; ETX (end of text) - DB 0CEH ; EOT (end of transmission) - DB 0CFH ; ENQ (enquiry) - DB 0F6H ; ACK (acknowledge) - DB 0F7H ; BEL '\a' (bell) - DB 0F8H ; BS '\b' (backspace) - DB 0F9H ; HT '\t' (horizontal tab) - DB 0FAH ; LF '\n' (new line) - DB 0FBH ; VT '\v' (vertical tab) - DB 0FCH ; FF '\f' (form feed) - DB 0FDH ; CR '\r' (carriage ret) - DB 0FEH ; SO (shift out) - DB 0FFH ; SI (shift in) - DB 0E1H ; DLE (data link escape) - DB 0C1H ; DC1 (device control 1) - DB 0C2H ; DC2 (device control 2) - DB 0C3H ; DC3 (device control 3) - DB 0C4H ; DC4 (device control 4) - DB 0C5H ; NAK (negative ack.) - DB 0C6H ; SYN (synchronous idle) - DB 0E2H ; ETB (end of trans. blk) - DB 0E3H ; CAN (cancel) - DB 0E4H ; EM (end of medium) - DB 0E5H ; SUB (substitute) - DB 0E6H ; ESC (escape) - DB 0EBH ; FS (file separator) - DB 0EEH ; GS (group separator) - DB 0EFH ; RS (record separator) - DB 0F4H ; US (unit separator) - DB 000H ; SPACE - DB 061H ; ! - DB 062H ; " - DB 063H ; # - DB 064H ; $ - DB 065H ; % - DB 066H ; & - DB 067H ; ' - DB 068H ; ( - DB 069H ; ) - DB 06BH ; * - DB 06AH ; + - DB 02FH ; , - DB 02AH ; - - DB 02EH ; . - DB 02DH ; / - DB 020H ; 0 - DB 021H ; 1 - DB 022H ; 2 - DB 023H ; 3 - DB 024H ; 4 - DB 025H ; 5 - DB 026H ; 6 - DB 027H ; 7 - DB 028H ; 8 - DB 029H ; 9 - DB 04FH ; : - DB 02CH ; ; - DB 051H ; < - DB 02BH ; = - DB 057H ; > - DB 049H ; ? - DB 055H ; @ - DB 001H ; A - DB 002H ; B - DB 003H ; C - DB 004H ; D - DB 005H ; E - DB 006H ; F - DB 007H ; G - DB 008H ; H - DB 009H ; I - DB 00AH ; J - DB 00BH ; K - DB 00CH ; L - DB 00DH ; M - DB 00EH ; N - DB 00FH ; O - DB 010H ; P - DB 011H ; Q - DB 012H ; R - DB 013H ; S - DB 014H ; T - DB 015H ; U - DB 016H ; V - DB 017H ; W - DB 018H ; X - DB 019H ; Y - DB 01AH ; Z - DB 052H ; [ - DB 059H ; \ '\\' - DB 054H ; ] - DB 0BEH ; ^ - DB 03CH ; _ - DB 0C7H ; ` - DB 081H ; a - DB 082H ; b - DB 083H ; c - DB 084H ; d - DB 085H ; e - DB 086H ; f - DB 087H ; g - DB 088H ; h - DB 089H ; i - DB 08AH ; j - DB 08BH ; k - DB 08CH ; l - DB 08DH ; m - DB 08EH ; n - DB 08FH ; o - DB 090H ; p - DB 091H ; q - DB 092H ; r - DB 093H ; s - DB 094H ; t - DB 095H ; u - DB 096H ; v - DB 097H ; w - DB 098H ; x - DB 099H ; y - DB 09AH ; z - DB 0BCH ; { - DB 080H ; | - DB 040H ; } - DB 0A5H ; ~ - DB 0C0H ; DEL - DB 040H - DB 0BDH - DB 09DH - DB 0B1H - DB 0B5H - DB 0B9H - DB 0B4H - DB 09EH - DB 0B2H - DB 0B6H - DB 0BAH - DB 0BEH - DB 09FH - DB 0B3H - DB 0B7H - DB 0BBH - DB 0BFH - DB 0A3H - DB 085H - DB 0A4H - DB 0A5H - DB 0A6H - DB 094H - DB 087H - DB 088H - DB 09CH - DB 082H - DB 098H - DB 084H - DB 092H - DB 090H - DB 083H - DB 091H - DB 081H - DB 09AH - DB 097H - DB 093H - DB 095H - DB 089H - DB 0A1H - DB 0AFH - DB 08BH - DB 086H - DB 096H - DB 0A2H - DB 0ABH - DB 0AAH - DB 08AH - DB 08EH - DB 0B0H - DB 0ADH - DB 08DH - DB 0A7H - DB 0A8H - DB 0A9H - DB 08FH - DB 08CH - DB 0AEH - DB 0ACH - DB 09BH - DB 0A0H - DB 099H - DB 0BCH - DB 0B8H - DB 080H - DB 03BH - DB 03AH - DB 070H - DB 03CH - DB 071H - DB 05AH - DB 03DH - DB 043H - DB 056H - DB 03FH - DB 01EH - DB 04AH - DB 01CH - DB 05DH - DB 03EH - DB 05CH - DB 01FH - DB 05FH - DB 05EH - DB 037H - DB 07BH - DB 07FH - DB 036H - DB 07AH - DB 07EH - DB 033H - DB 04BH - DB 04CH - DB 01DH - DB 06CH - DB 05BH - DB 078H - DB 041H - DB 035H - DB 034H - DB 074H - DB 030H - DB 038H - DB 075H - DB 039H - DB 04DH - DB 06FH - DB 06EH - DB 032H - DB 077H - DB 076H - DB 072H - DB 073H - DB 047H - DB 07CH - DB 053H - DB 031H - DB 04EH - DB 06DH - DB 048H - DB 046H - DB 07DH - DB 044H - DB 01BH - DB 058H - DB 079H - DB 042H - DB 060H - DB 0FDH - DB 0CBH - DB 000H - DB 01EH - ;------------------------------------------------------------------------------- - ; END OF SCREEN FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;---------------------------------------- - ; - ; ANSI EMULATION - ; - ; Emulate the Ansi standard - ; N.B. Turned on when Chr - ; 27 recieved. - ; Entry - A = Char - ; Exit - None - ; Used - None - ; - ;---------------------------------------- -?ANSITERM: PUSH HL - PUSH DE - PUSH BC - PUSH AF - LD C,A ; Move character into C for safe keeping - ; - LD A,(ANSIMODE) - OR A - JR NZ,ANSI2 - LD A,C - CP 27 - JP NZ,NOTANSI ; If it is Chr 27 then we haven't just - ; been turned on, so don't bother with - ; all the checking. - LD A,1 ; Turn on. - LD (ANSIMODE),A - JP AnsiMore - -ANSI2: LD A,(CHARACTERNO) ; CHARACTER number in sequence - OR A ; Is this the first character? - JP Z,AnsiFirst ; Yes, deal with this strange occurance! - - LD A,C ; Put character back in C to check - - CP ";" ; Is it a semi colon? - JP Z,AnsiSemi - - CP "0" ; Is it a number? - JR C,ANSI_NN ; If <0 then no - CP "9"+1 ; If >9 then no - JP C,AnsiNumber - -ANSI_NN: CP "?" ; Simple trap for simple problem! - JP Z,AnsiMore - - CP "@" ; Is it a letter? - JP C,ANSIEXIT ; Abandon if not letter; something wrong - -ANSIFOUND: CALL CURSRSTR ; Restore any character under the cursor. - LD HL,(NUMBERPOS) ; Get value of number buffer - LD A,(HAVELOADED) ; Did we put anything in this byte? - OR A - JR NZ,AF1 - LD (HL),255 ; Mark the fact that nothing was put in -AF1: INC HL - LD A,254 - LD (HL),A ; Mark end of sequence (for unlimited length sequences) - - ;Disable cursor as unwanted side effects such as screen flicker may occur. - LD A,(FLASHCTL) - BIT 7,A - CALL NZ,CURSOROFF - - XOR A - LD (CURSORCOUNT),A ; Restart count - LD A,0C9h - LD (CHGCURSMODE),A ; Disable flashing temp. - - LD HL,NUMBERBUF ; For the routine called. - LD A,C ; Restore number - ; - ; Now work out what happens... - ; - CP "A" ; Check for supported Ansi characters - JP Z,CUU ; Upwards - CP "B" - JP Z,CUD ; Downwards - CP "C" - JP Z,CUF ; Forward - CP "D" - JP Z,CUB ; Backward - CP "H" - JP Z,CUP ; Locate - CP "f" - JP Z,HVP ; Locate - CP "J" - JP Z,ED ; Clear screen - CP "m" - JP Z,SGR ; Set graphics renditon - CP "K" - JP Z,EL ; Clear to end of line - CP "s" - JP Z,SCP ; Save the cursor position - CP "u" - JP Z,RCP ; Restore the cursor position - -ANSIEXIT: CALL CURSORON ; If t - LD HL,NUMBERBUF ; Numbers buffer position - LD (NUMBERPOS),HL - XOR A - LD (CHARACTERNO),A ; Next time it runs, it will be the - ; first character - LD (HAVELOADED),A ; We haven't filled this byte! - LD (CHGCURSMODE),A ; Cursor allowed back again! - XOR A - LD (ANSIMODE),A - JR AnsiMore -NOTANSI: CP 000h ; Filter unprintable characters. - JR Z,AnsiMore - CALL ?PRNT -AnsiMore: POP AF - POP BC - POP DE - POP HL - RET - - ; - ; The various routines needed to handle the filtered characters - ; -AnsiFirst: LD A,255 - LD (CHARACTERNO),A ; Next character is not first! - LD A,C ; Get character back - LD (ANSIFIRST),A ; Save first character to check later - CP "(" ; ( and [ have characters to follow - JP Z,AnsiMore ; and are legal. - CP "[" - JP Z,AnsiMore - CP 09Bh ; CSI - JP Z,AnsiF1 ; Pretend that "[" was first ;-) - JP ANSIEXIT ; = and > don't have anything to follow - ; them but are legal. - ; Others are illegal, so abandon anyway. -AnsiF1: LD A,"[" ; Put a "[" for first character - LD (ANSIFIRST),A - JP ANSIEXIT - -AnsiSemi: LD HL,(NUMBERPOS) ; Move the number pointer to the - LD A,(HAVELOADED) ; Did we put anything in this byte? - OR A - JR NZ,AS1 - LD (HL),255 ; Mark the fact that nothing was put in -AS1: INC HL ; move to next byte - LD (NUMBERPOS),HL - XOR A - LD (HAVELOADED),A ; New byte => not filled! - JP AnsiMore - -AnsiNumber: LD HL,(NUMBERPOS) ; Get address for number - LD A,(HAVELOADED) - OR A ; If value is zero - JR NZ,AN1 - LD A,C ; Get value into A - SUB "0" ; Remove ASCII offset - LD (HL),A ; Save and Exit - LD A,255 - LD (HAVELOADED),A ; Yes, we _have_ put something in! - JP AnsiMore - -AN1: LD A,(HL) ; Stored value in A; TBA in C - ADD A,A ; 2 * - LD D,A ; Save the 2* for later - ADD A,A ; 4 * - ADD A,A ; 8 * - ADD A,D ; 10 * - ADD A,C ; 10 * + new num - SUB "0" ; And remove offset from C value! - LD (HL),A ; Save and Exit. - JP AnsiMore ; Note routine will only work up to 100 - ; which should be okay for this application. - - ;-------------------------------- - ; GET NUMBER - ; - ; Gets the next number from - ; the list - ; - ; Entry - HL = address to get - ; from - ; Exit - HL = next address - ; A = value - ; IF a=255 then default value - ; If a=254 then end of sequence - ; Used - None - ;-------------------------------- -GetNumber: LD A,(HL) ; Get number - CP 254 - RET Z ; Return if end of sequence,ie still point to - ; end - INC HL ; Return pointing to next byte - RET ; Else next address and return - - ;*** ANSI UP - ; -CUU: CALL GetNumber ; Number into A - LD B,A ; Save value into B - CP 255 - JR NZ,CUUlp - LD B,1 ; Default value -CUUlp: LD A,(DSPXY+1) ; A <- Row - CP B ; Is it too far? - JR C,CUU1 - SUB B ; No, then go back that far. - JR CUU2 -CUU1: LD A,0 ; Make the choice, top line. -CUU2: LD (DSPXY+1),A ; Row <- A - JP ANSIEXIT - - ;*** ANSI DOWN - ; -CUD: LD A,(ANSIFIRST) - CP "[" - JP NZ,ANSIEXIT ; Ignore ESC(B - CALL GetNumber - LD B,A ; Save value in b - CP 255 - JR NZ,CUDlp - LD B,1 ; Default -CUDlp: LD A,(DSPXY+1) ; A <- Row - ADD A,B - CP ROW ; Too far? - JP C,CUD1 - LD A,ROW-1 ; Too far then bottom of screen -CUD1: LD (DSPXY+1),A ; Row <- A - JP ANSIEXIT - - ;*** ANSI RIGHT - ; -CUF: CALL GetNumber ; Number into A - LD B,A ; Value saved in B - CP 255 - JR NZ,CUFget - LD B,1 ; Default -CUFget: LD A,(DSPXY) ; A <- Column - ADD A,B ; Add movement. - CP 80 ; Too far? - JR C,CUF2 - LD A,79 ; Yes, right edge -CUF2: LD (DSPXY),A ; Column <- A - JP ANSIEXIT - - ;*** ANSI LEFT - ; -CUB: CALL GetNumber ; Number into A - LD B,A ; Save value in B - CP 255 - JR NZ,CUBget - LD B,1 ; Default -CUBget: LD A,(DSPXY) ; A <- Column - CP B ; Too far? - JR C,CUB1a - SUB B - JR CUB1b -CUB1a: LD A,0 -CUB1b: LD (DSPXY),A ; Column <-A - JP ANSIEXIT - - ;*** ANSI LOCATE - ; -HVP: -CUP: CALL GetNumber - CP 255 - CALL Z,DefaultLine ; Default = 1 - CP 254 ; Sequence End -> 1 - CALL Z,DefaultLine - CP ROW+1 ; Out of range then don't move - JP NC,ANSIEXIT - OR A - CALL Z,DefaultLine ; 0 means default, some strange reason - LD D,A - CALL GetNumber - CP 255 ; Default = 1 - CALL Z,DefaultColumn - CP 254 ; Sequence End -> 1 - CALL Z,DefaultColumn - CP 81 ; Out of range, then don't move - JP NC,ANSIEXIT - OR A - CALL Z,DefaultColumn ; 0 means go with default - LD E,A - EX DE,HL - DEC H ; Translate from Ansi co-ordinates to hardware - DEC L ; co-ordinates - LD (DSPXY),HL ; Set the cursor position. - JP ANSIEXIT - -DefaultColumn: -DefaultLine:LD A,1 - RET - - ;*** ANSI CLEAR SCREEN - ; -ED: CALL GetNumber - OR A - JP Z,ED1 ; Zero means first option - CP 254 ; Also default - JP Z,ED1 - CP 255 - JP Z,ED1 - CP 1 - JP Z,ED2 - CP 2 - JP NZ,ANSIEXIT - - ;*** Option 2 - ; -ED3: LD HL,0 - LD (DSPXY),HL ; Home the cursor - LD A,(JSW_FF) - OR A - JP NZ,ED_Set_LF - CALL CALCSCADDR - CALL CLRSCRN - JP ANSIEXIT - -ED_Set_LF: XOR A ; Note simply so that - LD (JSW_LF),A ; ESC[2J works the same as CTRL-L - JP ANSIEXIT - - ;*** Option 0 - ; -ED1: LD HL,(DSPXY) ; Get and save cursor position - LD A,H - OR L - JP Z,ED3 ; If we are at the top of the - ; screen and clearing to the bottom - ; then we are clearing all the screen! - PUSH HL - LD A,ROW-1 - SUB H ; ROW - Row - LD HL,0 ; Zero start - OR A ; Do we have any lines to add? - JR Z,ED1_2 ; If no bypass that addition! - LD B,A ; Number of lines to count - LD DE,80 -ED1_1: ADD HL,DE - DJNZ ED1_1 -ED1_2: EX DE,HL ; Value into DE - POP HL - LD A,80 - SUB L ; 80 - Columns - LD L,A ; Add to value before - LD H,0 - ADD HL,DE - PUSH HL ; Value saved for later - LD HL,(DSPXY) ; _that_ value again! - POP BC ; Number to blank - CALL CALCSCADDR - CALL CLRSCRN ; Now do it! - JP ANSIEXIT ; Then exit properly - - ;*** Option 1 - clear from cursor to beginning of screen - ; -ED2: LD HL,(DSPXY) ; Get and save cursor position - PUSH HL - LD A,H - LD HL,0 ; Zero start - OR A ; Do we have any lines to add? - JR Z,ED2_2 ; If no bypass that addition! - LD B,A ; Number of lines - LD DE,80 -ED2_1: ADD HL,DE - DJNZ ED2_1 -ED2_2: EX DE,HL ; Value into DE - POP HL - LD H,0 - ADD HL,DE - PUSH HL ; Value saved for later - LD HL,0 ; Find the begining! - POP BC ; Number to blank - CALL CLRSCRN ; Now do it! - JP ANSIEXIT ; Then exit properly - - ; *** ANSI CLEAR LINE - ; -EL: CALL GetNumber ; Get value - CP 0 - JP Z,EL1 ; Zero & Default are the same - CP 255 - JP Z,EL1 - CP 254 - JP Z,EL1 - CP 1 - JP Z,EL2 - CP 2 - JP NZ,ANSIEXIT ; Otherwise don't do a thing - - ;*** Option 2 - clear entire line. - ; - LD HL,(DSPXY) - LD L,0 - LD (DSPXY),HL - CALL CALCSCADDR - LD BC,80 ; 80 bytes to clear (whole line) - CALL CLRSCRN - JP ANSIEXIT - - ;*** Option 0 - Clear from Cursor to end of line. - ; -EL1: LD HL,(DSPXY) - LD A,80 ; Calculate distance to end of line - SUB L - LD C,A - LD B,0 - LD (DSPXY),HL - PUSH HL - POP DE - CALL CALCSCADDR - CALL CLRSCRN - JP ANSIEXIT - - ;*** Option 1 - clear from cursor to beginning of line. - ; -EL2: LD HL,(DSPXY) - LD C,L ; BC = distance from start of line - LD B,0 - LD L,0 - LD (DSPXY),HL - CALL CALCSCADDR - CALL CLRSCRN - JP ANSIEXIT - - ; In HL = XY Pos - ; Out = Screen address. -CALCSCADDR: PUSH AF - PUSH BC - PUSH DE - PUSH HL - LD A,H - LD B,H - LD C,L - LD HL,SCRN - OR A - JR Z,CALC3 - LD DE,80 -CALC2: ADD HL,DE - DJNZ CALC2 -CALC3: POP DE - ADD HL,BC - POP DE - POP BC - POP AF - RET - - ; HL = address - ; BC = length -CLRSCRN: PUSH HL ; 1 for later! - LD D,H - LD E,L - INC DE ; DE <- HL +1 - PUSH BC ; Save the value a little longer! - XOR A - LD (HL), A ; Blank this area! - LDIR ; *** just like magic *** - ; only I forgot it in 22a! - POP BC ; Restore values - POP HL - LD DE,2048 ; Move to attributes block - ADD HL,DE - LD D,H - LD E,L - INC DE ; DE = HL + 1 - LD A,(FONTSET) ; Save in the current values. - LD (HL),A - LDIR - RET - - ;*** ANSI SET GRAPHICS RENDITION - ; -SGR: CALL GetNumber - CP 254 ; 254 signifies end of sequence - JP Z,ANSIEXIT - OR A - CALL Z,AllOff - CP 255 ; Default means all off - CALL Z,AllOff - CP 1 - CALL Z,BoldOn - CP 2 - CALL Z,BoldOff - CP 4 - CALL Z,UnderOn - CP 5 - CALL Z,ItalicOn - CP 6 - CALL Z,ItalicOn - CP 7 - CALL Z,InverseOn - JP SGR ; Code is re-entrant - - ;-------------------------------- - ; - ; RESET GRAPHICS - ; - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -AllOff: PUSH AF ; Save registers - LD A,0C9h ; = off - LD (BOLDMODE),A ; Turn the flags off - LD (ITALICMODE),A - LD (UNDERSCMODE),A - LD (INVMODE),A - LD A,007h ; Black background, white chars. - LD (FONTSET),A ; Reset the bit map store - POP AF ; Restore register - RET - - ;-------------------------------- - ; - ; TURN BOLD ON - ; - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -BoldOn: PUSH AF ; Save register - XOR A ; 0 means on - LD (BOLDMODE),A -BOn1: LD A,(FONTSET) - SET 0,A ; turn ON indicator flag - LD (FONTSET),A - POP AF ; Restore register - RET - - ;-------------------------------- - ; - ; TURN BOLD OFF - ; - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -BoldOff: PUSH AF ; Save register - PUSH BC - LD A,0C9h ; &C9 means off - LD (BOLDMODE),A -BO1: LD A,(FONTSET) - RES 0,A ; turn OFF indicator flag - LD (FONTSET),A - POP BC - POP AF ; Restore register - RET - - ;-------------------------------- - ; - ; TURN ITALICS ON - ; (replaces flashing) - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -ItalicOn: PUSH AF ; Save AF - XOR A - LD (ITALICMODE),A ; 0 means on - LD A,(FONTSET) - SET 1,A ; turn ON indicator flag - LD (FONTSET),A - POP AF ; Restore register - RET - - ;-------------------------------- - ; - ; TURN UNDERLINE ON - ; - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -UnderOn: PUSH AF ; Save register - XOR A ; 0 means on - LD (UNDERSCMODE),A - LD A,(FONTSET) - SET 2,A ; turn ON indicator flag - LD (FONTSET),A - POP AF ; Restore register - RET - - ;-------------------------------- - ; - ; TURN INVERSE ON - ; - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -InverseOn: PUSH AF ; Save register - XOR A ; 0 means on - LD (INVMODE),A - LD A,(FONTSET) - SET 3,A ; turn ON indicator flag - LD (FONTSET),A - POP AF ; Restore AF - RET - - ;*** ANSI SAVE CURSOR POSITION - ; -SCP: LD HL,(DSPXY) ; (backup) <- (current) - LD (CURSORPSAV),HL - JP ANSIEXIT - - ;*** ANSI RESTORE CURSOR POSITION - ; -RCP: LD HL,(CURSORPSAV) ; (current) <- (backup) - LD (DSPXY),HL - JP ANSIEXIT - - ;------------------------------------------------------------------------------- - ; END OF ANSI TERMINAL FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; Align to end of bank. - ALIGN UROMADDR + 07F8h - ORG UROMADDR + 07F8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh diff --git a/software/asm/cbios_bank3.asm b/software/asm/cbios_bank3.asm deleted file mode 100644 index 0874837..0000000 --- a/software/asm/cbios_bank3.asm +++ /dev/null @@ -1,897 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: cbios_bank3.asm -;- Created: January 2020 -;- Author(s): Philip Smart -;- Description: Sharp MZ series CPM BIOS System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade for the CPM CBIOS in order to preserve RAM for actual -;- CPM TPA programs. -;- -;- Credits: -;- Copyright: (c) 2018-23 Philip Smart -;- -;- History: Jan 2020 - Seperated Bank from RFS for dedicated use with CPM CBIOS. -;- May 2020 - Advent of the new RFS PCB v2.0, quite a few changes to accommodate the -;- additional and different hardware. The SPI is now onboard the PCB and -;- not using the printer interface card. -;- Mar 2021 - Updates for the RFS v2.1 board. -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - ; Bring in definitions and macros. - INCLUDE "cpm_buildversion.asm" - INCLUDE "cpm_definitions.asm" - INCLUDE "macros.asm" - - ;============================================================ - ; - ; USER ROM CPM CBIOS BANK 3 - SD Card Controller functions. - ; - ;============================================================ - ORG UROMADDR - - ;----------------------------------------------------------------------------------------- - ; Common code spanning all banks to ensure that a Monitor is selected upon power up/reset. - ;----------------------------------------------------------------------------------------- - NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -CBIOS3_0: LD A,(BNKCTRLRST) - DJNZ CBIOS3_0 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - NOP - NOP - NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select MROM bank 0 - LD (BNKSELMROM),A - NOP - NOP - NOP - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - ; - ; No mans land... this should have switched to Bank 0 and at this point there is a jump to 00000H. - JP 00000H ; This is for safety!! - - - ;------------------------------------------------------------------------------- - ; Jump table for entry into this pages functions. - ;------------------------------------------------------------------------------- - ALIGN_NOPS UROMJMPTBL - JP ?SD_INIT ; SD_INIT - JP ?SD_READ ; SD_READ - JP ?SD_WRITE ; SD_WRITE - JP ?SD_GETLBA ; SD_GETLBA - JP ?SDC_READ ; SDC_READ - JP ?SDC_WRITE ; SDC_WRITE - - - ;------------------------------------------------------------------------------- - ; START OF SD CARD CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;------------------------------------------------------------------------------- - ; Hardware SPI SD Controller (HW_SPI_ENA = 1) - ; This logic uses the RFS PCB v2+ hardware shift registers to communicate with - ; an SD Card. It is the fastest solution available but has a high IC count. - ; - ; Software SPI SD Controller (SW_SPI_ENA = 1) - ; This logic uses the RFS PCB v2+ logic to simulate the SPI interface with - ; bitbanging techniques. It is similar to the Parallel Port SD Controller - ; but uses logic on the RFS board rather than the parallel port interface. - ; - ; Parallel Port SD Controller (PP_SPI_ENA = 1) - ; This logic uses the standard Sharp MZ-80A Parallel Port for simulating the - ; SPI interface with bitbanging techniques. This interface is then used to - ; communicate with an SD Card. - ;------------------------------------------------------------------------------- - - ; Method to initialise the SD card. - ; -?SD_INIT: LD A,0FFH ; CS to high (inactive) - CALL SPICS - ; - CALL SPIINIT ; Train SD with our clock. - ; - LD A,000H ; CS to low (active) - CALL SPICS - - LD BC,SD_RETRIES ; Number of retries before deciding card is not present. -SD_INIT1: LD A,CMD0 ; Command 0 - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - PUSH BC - ; - CALL SDCMD - ; - LD A,(SDBUF+6) ; Get response code. - DEC A ; Set Z flag to test if response is 0x01 - POP BC - JP Z,SD_INIT2 ; Command response 0x01? Exit if match. - - DEC BC - LD A,B - OR C - JR NZ,SD_INIT1 ; Retry for BC times. - LD A,1 - JP SD_EXIT ; Error, card is not responding to CMD0 - -SD_INIT2: ; Now send CMD8 to get card details. This command can only be sent - ; when the card is idle. - LD A,CMD8 ; CMD8 has 0x00001AA as parameter, load up registers and call command routine. - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,0AA01H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - - ; Version 2 card, check its voltage range. IF not in the 2.7-3.6V dont try the ACMD41 to get capabilities. -SD_INIT3: LD A,1 ; Check that we receive 0x0001AA in response. - LD (SDVER),A ; Indicate this is not a version 2 card. - LD A,(SDBUF+9) - CP 1 - JP NZ,SD_INIT8 - LD A,(SDBUF+10) - CP 0AAH - JP NZ,SD_INIT8 - -SD_INIT4: LD A,2 ; This is a version 2 card. -SD_INIT5: LD (SDVER),A ; Indicate this is not a version 2 card. - - CALL SDACMD41 - JR Z,SD_INIT6 - LD A,2 ; Error, card is not responding to ACMD41 - JP SD_EXIT - -SD_INIT6: LD A,CMD58 ; CMD58 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(SDBUF+6) - CP 040H - LD A,CT_SD2 - JR Z,SD_INIT7 - LD A,CT_SD2 | CT_BLOCK -SD_INIT7: LD (SDCAP),A ; Set the capabilities according to the returned flag. - JR SD_INIT14 - - - ; Version 1 card or MMC v3. -SD_INIT8: CALL SDACMD41 - LD A, CT_SD1 - LD E,ACMD41 ; SD1 cards we use the ACMD41 command. - JR Z,SD_INIT9 - LD A,CT_MMC - LD E,CMD1 ; MMC cards we use the CMD1 command. -SD_INIT9: LD (SDCAP),A - LD A,E - CP ACMD41 - JR NZ,SD_INIT10 - CALL SDACMD41 - JR Z,SD_INIT14 - LD A,3 ; Exit code, failed to initialise v1 card. - JR SD_EXIT - -SD_INIT10: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. -SD_INIT11: PUSH BC - LD A,CMD1 ; CMD1 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - OR A - JR Z,SD_INIT13 - LD BC,0FFFFH ; Delay for at least 200mS for the card to recover and be ready. -SD_INIT12: DEC BC ; 6T - LD A,B ; 9T - OR C ; 4T - JR NZ,SD_INIT12 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS - ; - POP BC - DEC BC - LD A,B - OR C - JR NZ,SD_INIT11 - LD A,4 ; Exit code, failed to initialise v1 MMC card. - JR SD_EXIT - -SD_INIT13: POP BC - LD A,CMD16 ; No response from the card for an ACMD41/CMD1 so try CMD16 with parameter 0x00000200 - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00002H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(SDBUF+6) - OR A - JR Z,SD_INIT14 - LD A,0 - LD (SDCAP),A ; No capabilities on this unknown card. -SD_INIT14: XOR A - JR SD_EXIT -SD_EXIT: OR A ; Return value is in A. - RET - - ; - ; A = CMD to send - ; LHED = Argument, ie. CMD = A, L, H, E, D, CRC - ; -SDCMD: LD (SDBUF),A - LD (SDBUF+1),HL - EX DE,HL - LD (SDBUF+3),HL - ; - ; Send command but with parameters preloaded by caller. -SDCMDNP: LD B,5 ; R1 + 32bit argument for CMD8, CMD58 - CP CMD8 - LD C,135 - JP Z,SDCMD0 - LD C,1 ; CMD58 is not CRC checked so just set to 0x01. - CP CMD58 - LD B,5 ; R1 + 32bit argument - JP Z,SDCMD0 - ; - LD B,1 ; Default, expect R1 which is 1 byte. - CP CMD0 ; Work out the CRC based on the command. CRC checking is - LD C,149 ; not implemented but certain commands require a fixed argument and CRC. - JP Z,SDCMD0 - LD C,1 ; Remaining commands are not CRC checked so just set to 0x01. -SDCMD0: PUSH BC ; Save the CRC and the number of bytes to be returned, - LD A,C ; Store the CRC - LD (SDBUF+5),A - LD A,255 ; Preamble byte - CALL SPIOUT - LD HL,SDBUF - LD B,6 -SDCMD1: PUSH BC - LD A,(HL) - INC HL - CALL SPIOUT ; Send the command and parameters. - POP BC - DJNZ SDCMD1 - PUSH HL - LD HL,SD_RETRIES -SDCMD2: PUSH HL - CALL SPIIN - POP HL - CP 0FFH - JR NZ,SDCMD4 - DEC HL - LD A,H - OR L - JR NZ,SDCMD2 - ; - ; Error as we are not receiving data. - ; - POP HL - POP BC - LD A,1 ; Force return code to be error. - LD (SDBUF+6),A - RET - -SDCMD3: PUSH BC - PUSH HL - CALL SPIIN ; -SDCMD4: POP HL - LD (HL),A - INC HL - POP BC ; Get back number of expected bytes. HL = place in buffer to store response. - DJNZ SDCMD3 - IF HW_SPI_ENA = 0 - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH - OUT (SPI_OUT),A - ENDIF - RET - - ; Method to send an Application Command to the SD Card. This involves sending CMD55 followed by the required command. - ; - ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC - ; -SDACMD: PUSH AF - PUSH DE - PUSH HL - LD A,CMD55 ; CMD55 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - POP HL - POP DE - LD A,(SDBUF+6) ; Should be a response of 0 or 1. - CP 2 - JR NC,SDACMDE - POP AF - CALL SDCMD -SDACMD0: LD A,(SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - OR A - RET -SDACMDE: POP AF - JR SDACMD0 - - ; Method to send Application Command 41 to the SD card. This command involves retries and delays - ; hence coded seperately. - ; - ; Returns Z set if successful, else NZ. - ; -SDACMD41: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. -SDACMD1: PUSH BC - LD A,ACMD41 ; ACMD41 has 0x40000000 as parameter, load up registers and call command routine. - LD HL,00040H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDACMD - JR Z,SDACMD3 ; Should be a response of 0 whereby the card has left idle. - LD BC,12903 ; Delay for at least 200mS for the card to recover and be ready. -SDACMD2: DEC BC ; 6T - LD A,B ; 9T - OR C ; 4T - JR NZ,SDACMD2 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS - ; - POP BC - DEC BC - LD A,B - OR C - JR NZ,SDACMD1 - LD A,1 ; Retries exceeded, return error. - OR A - RET -SDACMD3: POP BC ; Success, tidy up stack and exit with Z set. - XOR A - RET - - - - ; Method to initialise communications with the SD card. We basically train it to our clock characteristics. - ; This is important, as is maintaining the same clock for read or write otherwise the card may not respond. -SPIINIT: IF HW_SPI_ENA = 1 - ; Hardware SPI on the RFS v2+ PCB. - LD B,10 - LD A, 0FFH ; We need to send 80 '1's, so preload the data register with all 1's, future transmits dont require this as it self loads with 1's. - LD (HWSPIDATA),A -SPIINIT1: LD (HWSPISTART),A ; Commence transmission of an 8bit byte. Runs 1 8MHz, so 1 byte in 1uS, it takes the Z80 2uS for its quickest instruction at 2MHz clock. - DJNZ SPIINIT1 - RET - - ELSE - - ; Software SPI on the RFS v2+ PCB. - IF SW_SPI_ENA = 1 - - ELSE - - ; Software SPI on the centronics parallel port. - LD B,80 -SPIINIT1: LD A,DOUT_HIGH | CLOCK_HIGH | CS_HIGH ; Output a 1 - OUT (SPI_OUT),A - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Output a 1 - OUT (SPI_OUT),A - DJNZ SPIINIT1 - RET - ENDIF - ENDIF - - ; Method to set the Chip Select level on the SD card. The Chip Select is active LOW. - ; - ; A = 0 - Set CS LOW (active) - ; A = 0xFF - Set CS HIGH (active) -SPICS: IF HW_SPI_ENA = 1 - ; Hardware SPI on the RFS v2+ PCB. - OR A - LD A,(ROMCTL) - SET 1,A ; If we are inactivating CS then set CS high and disable clock by setting BBCLK to low. - RES 0,A - JR NZ, SPICS0 - RES 1,A ; If we are activating CS then set CS low and enable clock by setting BBCLK to high. - SET 0,A -SPICS0: LD (BNKCTRL),A - LD (ROMCTL),A - RET - - ELSE - - ; Software SPI on the RFS v2+ PCB. - IF SW_SPI_ENA = 1 - - ELSE - - ; Software SPI on the centronics parallel port. - OR A - LD A,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Set CS Low if parameter = 0 (ie. enable) - JR Z, SPICS0 - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Set CS High if parameter != 0 (ie. disable) -SPICS0: OUT (SPI_OUT),A - RET - ENDIF - ENDIF - - ; Method to send a byte to the SD card via the SPI protocol. - ; This method uses the hardware shift registers. - ; - ; Input A = Byte to send. - ; -SPIOUT: IF HW_SPI_ENA = 1 - ; Hardware SPI on the RFS v2+ PCB. - LD (HWSPIDATA),A - LD (HWSPISTART),A - RET - - ELSE - - ; Software SPI on the RFS v2+ PCB. - IF SW_SPI_ENA = 1 - - ELSE - - ; Software SPI on the centronics parallel port. - RLCA ; 65432107 - RLCA ; 54321076 - RLCA ; 43210765 - Adjust so that starting bit is same position as Data line. - LD E,A ; E = Character to send. - LD B,8 ; B = Bit count -SPIOUT0: LD A,E - AND DOUT_MASK ; Data bit to data line, clock and cs low. - RLC E -SPIOUT1: OUT (SPI_OUT),A - OR CLOCK_HIGH ; Clock high - OUT (SPI_OUT),A - AND CLOCK_MASK ; Clock low - OUT (SPI_OUT),A - DJNZ SPIOUT0 ; Perform actions for the full 8 bits. - RET - ENDIF - ENDIF - - ; Method to receive a byte from the SD card via the SPI protocol. - ; This method uses the hardware shift registers. - ; NB. Timing must be very similar in SPIOUT and SPIIN. - ; - ; Output: A = received byte. - ; -SPIIN: IF HW_SPI_ENA = 1 - ; Hardware SPI on the RFS v2+ PCB. - LD (HWSPISTART),A ; Commence transmission to receive back data from the SD card, we just send 1's. - LD A,(HWSPIDATA) ; Get the data byte. - RET - - ELSE - - ; Software SPI on the RFS v2+ PCB. - IF SW_SPI_ENA = 1 - - ELSE - - ; Software SPI on the centronics parallel port. - LD BC,00800H | SPI_OUT ; B = Bit count, C = clock port - LD L,0 ; L = Character being read. - LD D,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Output a 0 - OUT (C),D ; To start ensure clock is low and CS is low. - LD E,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Output a 0 -SPIIN1: OUT (C),E ; Clock to high. - IN A,(SPI_IN) ; Input the received bit - OUT (C),D ; Clock to low. - SRL A - RL L - DJNZ SPIIN1 ; Perform actions for the full 8 bits. - LD A,L ; return value - RET - ENDIF - ENDIF - ;------------------------------------------------------------------------------- - ; End of SPI SD Controller - ;------------------------------------------------------------------------------- - - - ; A function from the z88dk stdlib, a delay loop with T state accuracy. - ; - ; enter : hl = tstates >= 141 - ; uses : af, bc, hl -T_DELAY: LD BC,-141 - ADD HL,BC - LD BC,-23 -TDELAYLOOP: ADD HL,BC - JR C, TDELAYLOOP - LD A,L - ADD A,15 - JR NC, TDELAYG0 - CP 8 - JR C, TDELAYG1 - OR 0 -TDELAYG0: INC HL -TDELAYG1: RRA - JR C, TDELAYB0 - NOP -TDELAYB0: RRA - JR NC, TDELAYB1 - OR 0 -TDELAYB1: RRA - RET NC - RET - - ; Method to skip over an SD card input stream to arrive at the required bytes, - ; - ; Input: BC = Number of bytes to skip. - ; -SPISKIP: PUSH BC - CALL SPIIN - POP BC - DEC BC - LD A,B - OR C - JR NZ,SPISKIP - RET - - ; Method to convert an LBA value into a physical byte address. This is achieved by multiplying the block x 512. - ; We take the big endian sector value, shift left 9 times then store the result back onto the stack. - ; This is done as follows: <2> <1> <0> => <2> <1> <0> 0 (ie. 8 bit shift): Shift left <0> with carry, shift left <1> shift left <2>, 0 to - ; - ; Input: HL = Stack offset. - ; -LBATOADDR: LD HL,(SDSTARTSEC+1) - LD A,(HL) ; Start ny retrieving bytes as HED0 - INC HL - LD E,(HL) - INC HL - LD D,(HL) - LD L,A - - SLA D ; Shift the long left by 9 to effect a x512 - RL E - RL H - LD BC,(SDSTARTSEC) - LD A,H ; Now save the results as LHED, big endian format as used by the SD Card argument - LD (BC),A - INC BC - LD A,E - LD (BC),A - INC BC - LD A,D - LD (BC),A - INC BC - LD A,0 - LD (BC),A - RET - - - ; Method to read a sector or partial sector contents to an SD Card. - ; - ; This method was originally a C routine I was using for FatFS but optimised it (still more can be done). The C->ASM is not so optimal. - ; - ; Input: Memory variables: SDSTARTSEC= unsigned long sector. - The sector number or direct byte address for older cards. This is big endian as per card. - ; HL: Address where to store data read from sector. - ; Output: A = 0 - All ok. A > 0 - error occurred. - ; -?SD_READ: DI - PUSH HL ; Store the load address. - LD A,000H - CALL SPICS ; Set CS low (active). - - LD HL,(SDCAP) ; Test to see if CT_BLOCK is available. - LD H,0 - LD A,CT_BLOCK - AND L - JP NZ,SD_READ1 ; If it has CT_BLOCK then use sector numbers otherwise multiply up to bytes. - CALL LBATOADDR ; Multiply the sector by 512 for byte addressing on older cards. - -SD_READ1: ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC - LD A,CMD17 ; Send CMD17 to read a sector. - LD (SDBUF),A - LD HL,(SDSTARTSEC) - LD (SDBUF+1),HL - LD HL,(SDSTARTSEC+2) - LD (SDBUF+3),HL - CALL SDCMDNP ; Execute SD Command, parameters already loaded into command buffer. - LD A,(SDBUF+6) ; Fetch result and store. - AND A - JP NZ,SD_READ6 - - LD HL,1000 ; Sit in a tight loop waiting for the data packet arrival (ie. not 0xFF). -SD_READ2: PUSH HL - LD HL,200 - CALL T_DELAY - CALL SPIIN - POP HL - CP 255 - JP NZ,SD_READ3 - DEC HL - LD A,H - OR L - JR NZ,SD_READ2 - -SD_READ3: CP 254 ; Data? If not exit with error code. - JP NZ,SD_READ6 - - LD BC,SD_SECSIZE ; Size of full sector + 2 bytes CRC. - POP HL ; Get the store address into HL. -SD_READ4: PUSH HL ; Start reading bytes into the buffer. - PUSH BC - CALL SPIIN - POP BC - POP HL - LD (HL),A - INC HL ; Update buffer pointer. - DEC BC - LD A,B - OR C - JP NZ,SD_READ4 ; Not zero, keep reading. - - INC BC ; Were not interested in the CRC so skip it. - INC BC - CALL SPISKIP - - LD A,0 ; And exit with success. -SD_READ5: PUSH AF - LD A,0FFH ; Disable CS therefore deselecting the SD Card. - CALL SPICS - POP AF - EI - RET -SD_READ6: POP HL - LD A,1 - JR SD_READ5 - - - ; Method to write a 512byte sector to an SD Card. - ; - ; Input: Memory variables: SDSTARTSEC= unsigned long sector. - The sector number or direct byte address for older cards. This is big endian as per card. - ; HL: Address of buffer to read data from. - ; Output: A = 0 - All ok. A > 0 - error occurred. -?SD_WRITE: PUSH HL - - LD A,000H ; Activate CS (set low). - CALL SPICS - - ; Open transaction. - LD HL,(SDCAP) ; Check to see if the card has block addressing. - LD H,0 - LD A,CT_BLOCK - AND L - JP NZ,SD_WRITE1 ; If it hasnt then we need to multiply up to the correct byte. - CALL LBATOADDR ; Multiply the sector by 512 for byte addressing. - - ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC -SD_WRITE1: LD A,CMD24 ; Send CMD24 to write a sector. - LD (SDBUF),A - LD HL,(SDSTARTSEC) ; Place long endian sector into command buffer. - LD (SDBUF+1),HL - LD HL,(SDSTARTSEC+2) - LD (SDBUF+3),HL - CALL SDCMDNP ; Send command using No Parameters version as we loaded them into the command buffer already. - LD A,(SDBUF+6) ; Fetch result and store. - AND A - JP NZ,SD_WRITE10 - LD A,255 ; Ok, so command sent successfully, mark the write by sending an 0xFF followed by 0xFE - CALL SPIOUT - LD A,254 - CALL SPIOUT - - ; Write buffer. - LD DE,SD_SECSIZE - POP HL ; Address to read data from. -SD_WRITE2: LD A,D ; So long as we have bytes in the buffer, send to the card for writing. - OR E - JP Z,SD_WRITE3 - - PUSH DE - LD A,(HL) ; Get the byte to transmit. - INC HL ; And update the pointer. - CALL SPIOUT ; Transmit value in A. - POP DE - DEC DE - JR SD_WRITE2 - - ; Close transaction. -SD_WRITE3: INC DE ; Add 2 bytes for CRC - INC DE -SD_WRITE4: LD A,D ; Test to see if we are already at zero, ie. all bytes sent. Exit if so. - OR E - JP Z,SD_WRITE5 - DEC DE - PUSH DE - LD A,0 ; Send 0's as padding bytes and CRC. - CALL SPIOUT - POP DE - JP SD_WRITE4 - -SD_WRITE5: CALL SPIIN ; Check received response, if 0x05 which indicates write under way inside SD Card. - AND 01FH - LD L,A - LD H,0 - CP 5 - JP NZ,SD_WRITE11 - - LD HL,10000 ; Now wait for the write to complete allowing 1000mS before timing out. - PUSH HL - JR SD_WRITE7 -SD_WRITE6: DEC HL - PUSH HL - LD HL,200 ; 200T state delay = 200 x 1/2000000 = 100uS - CALL T_DELAY -SD_WRITE7: CALL SPIIN ; Get a byte, if it is not 0xFF then we have our response so exit. - POP HL - CP 255 - JP Z,SD_WRITE8 - LD A,H - OR L - JR NZ,SD_WRITE6 - -SD_WRITE8: LD A,H ; End of timeout? If so we exit with the preset fail code. - OR L - JP Z,SD_WRITE11 - XOR A ; Success code. - -SD_WRITE9: PUSH AF - LD A,0FFH ; Disable SD Card Chip Select to finish. - CALL SPICS - POP AF - RET -SD_WRITE10: POP HL ; Waste the load address. -SD_WRITE11: LD A,1 ; Error exit. - JR SD_WRITE9 - - - - ; Method to multiply a 16bit number by another 16 bit number to arrive at a 32bit result. - ; Input: DE = Factor 1 - ; BC = Factor 2 - ; Output:DEHL = 32bit Product - ; -MULT16X16: LD HL,0 - LD A,16 -MULT16X1: ADD HL,HL - RL E - RL D - JR NC,$+6 - ADD HL,BC - JR NC,$+3 - INC DE - DEC A - JR NZ,MULT16X1 - RET - - ; Method to add a 16bit number to a 32bit number to obtain a 32bit product. - ; Input: DEHL = 32bit Addend - ; BC = 16bit Addend - ; Output:DEHL = 32bit sum. - ; -ADD3216: ADD HL,BC - EX DE,HL - LD BC,0 - ADC HL,BC - EX DE,HL - RET - - ; Method to add two 32bit numbers whilst calculating the SD Start Sector. - ; Input: DEHL = 32bit Addend - ; (SDSTARTSEC) = 32bit Addend - ; Output: (SDSTARTSEC) = 32bit Sum. - ; Output; DEHL = 32bit Sum. - ; -ADD32: LD BC,(SDSTARTSEC+2) - ADD HL,BC - LD (SDSTARTSEC+2),HL - LD BC,(SDSTARTSEC) - EX DE,HL - ADC HL,BC - LD (SDSTARTSEC),HL - EX DE,HL - RET - - ; Method to get the LBA sector from the current CP/M Track and Sector. - ; This method needs to account for the Rom Filing System image and the other CPM disk images on the SD card. - ; - ; Input: (CDISK) = Disk number - ; (HSTTRK) = Track - ; (HSTSEC) = Sector - ; Output: (SDSTARTSEC) = LBA on SD Card for the desired sector. - ; DEHL = LBA on SD Card for the desired sector. - ; -?SD_GETLBA: PUSH AF ; If needed, pass A and flags via the stack. NB This push is removed by BANKTOBANK so no need to pop after the call. - LD A,ROMBANK11 << 4 | ROMBANK10 ; Calling a function in Bank 11 (CBIOS Bank 4) and returning to current bank 10 (CBIOS Bank 3). - LD HL,QGETMAPDSK ; Calling the map disk function. - CALL BANKTOBANK ; Now make a bank to bank function call. - CP 0FFH - JR Z,SDGETLBAX ; This isnt a physical, ROM disk or SD disk, no need to perform any actions, exit. - CP 040H - JR C,SDGETLBAX ; This isnt a ROM disk or an SD disk, no need to perform any actions, exit. - AND 03FH ; Get the SD disk number. - - LD B,0 - LD C,A - LD DE,CPM_SD_IMGSZ / SD_SECSIZE - CALL MULT16X16 - LD (SDSTARTSEC),DE - LD (SDSTARTSEC+2),HL - - ; DEHL contains the offset for the Disk number, ie. 0 for drive 1, CPM IMAGE SIZE for drive 2, 2x CPM IMAGE SIZE for drive 3 etc. - LD B,0 - LD C, SD_SECPTRK ; Number of sectors per track. - LD DE,(HSTTRK) ; For the SD Card we use the full 16bit track number. - CALL MULT16X16 - - ; Add the two. - CALL ADD32 - - ; Add the number of sectors directly to the current sum. - LD A,(HSTSEC) - LD C,A - LD B,0 - CALL ADD3216 - - ; Now add the offset to account for the RFS image. - IF RFS_END_ADDR/SD_SECSIZE < 010000H - LD BC, RFS_END_ADDR/SD_SECSIZE ; Sector offset for the RFS Image. - CALL ADD3216 - ELSE - LD BC,0 ; Padding is to an even address so lower word will always be zero. - ADD HL,BC - EX DE,HL - LD BC,(RFS_END_ADDR/SD_SECSIZE) / 010000H ; Upper word addition. - ADC HL,BC - EX DE,HL - ENDIF - - ; Store the final sum as the start sector. - PUSH HL - LD HL,SDSTARTSEC - LD (HL),D - INC HL - LD (HL),E - INC HL - POP DE - LD (HL),D - INC HL - LD (HL),E - LD HL,(SDSTARTSEC) - OR 1 ; Indicate we successfully mapped the track/sector to an LBA. -SDGETLBAX: RET - - - ; Method to read a sector for CPM using its track/sector addressing. All reads occur in a 512byte sector. - ; - ; Inputs: (HSTTRK) - 16bit track number. - ; (HSTSEK) - 8bit sector number. - ; (CDISK) - Disk drive number. -?SDC_READ: CALL ?SD_GETLBA ; Get the SD card sector in LBA, - LD A,1 - JP Z,SDC_READ1 ; Error in read, exit with stack tidy. - LD HL,HSTBUF ; Address of the host buffer to hold the sector. - CALL ?SD_READ ; Read in the sector. - OR A - JR NZ,SDC_READ1 ; Check for errors and report. - XOR A ; Indicate success. -SDC_READ1: RET - - ; Method to write a sector for CPM using its track/sector addressing. All writes occur in a 512byte sector. - ; - ; Inputs: (HSTTRK) - 16bit track number. - ; (HSTSEK) - 8bit sector number. - ; (CDISK) - Disk drive number. - ; Outputs: A = 1 - Error. - ; A = 0 - Success. -?SDC_WRITE: CALL ?SD_GETLBA ; Get the SD card sector in LBA, - LD A,1 - JP Z,SDC_WRITE1 ; Error in read, exit with stack tidy. - LD HL,HSTBUF ; Setup the location of the buffer to write. - CALL ?SD_WRITE ; Call write to write the buffer into the given sector. - JR NZ,SDC_WRITE1 - XOR A -SDC_WRITE1: RET - - ;------------------------------------------------------------------------------- - ; END OF SD CARD CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; Align to end of bank. - ALIGN UROMADDR + 07F8h - ORG UROMADDR + 07F8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh - diff --git a/software/asm/cbios_bank4.asm b/software/asm/cbios_bank4.asm deleted file mode 100644 index 9af52f9..0000000 --- a/software/asm/cbios_bank4.asm +++ /dev/null @@ -1,641 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: cbios_bank4.asm -;- Created: January 2020 -;- Author(s): Philip Smart -;- Description: Sharp MZ series CPM BIOS System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade for the CPM CBIOS in order to preserve RAM for actual -;- CPM TPA programs. -;- -;- Credits: -;- Copyright: (c) 2018-23 Philip Smart -;- -;- History: Jan 2020 - Seperated Bank from RFS for dedicated use with CPM CBIOS. -;- May 2020 - Advent of the new RFS PCB v2.0, quite a few changes to accommodate the -;- additional and different hardware. The SPI is now onboard the PCB and -;- not using the printer interface card. -;- Mar 2021 - Updates for the RFS v2.1 board. -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - ; Bring in definitions and macros. - INCLUDE "cpm_buildversion.asm" - INCLUDE "cpm_definitions.asm" - INCLUDE "macros.asm" - - ;============================================================ - ; - ; USER ROM CPM CBIOS BANK 4 - Floppy Disk Controller functions. - ; - ;============================================================ - ORG UROMADDR - - ;----------------------------------------------------------------------------------------- - ; Common code spanning all banks to ensure that a Monitor is selected upon power up/reset. - ;----------------------------------------------------------------------------------------- - NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -CBIOS1_0: LD A,(BNKCTRLRST) - DJNZ CBIOS1_0 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - NOP - NOP - NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select MROM bank 0 - LD (BNKSELMROM),A - NOP - NOP - NOP - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - ; - ; No mans land... this should have switched to Bank 0 and at this point there is a jump to 00000H. - JP 00000H ; This is for safety!! - - - ;------------------------------------------------------------------------------- - ; Jump table for entry into this pages functions. - ;------------------------------------------------------------------------------- - ALIGN_NOPS UROMJMPTBL - JP ?DSKINIT ; DSKINIT - JP ?SETDRVCFG ; SETDRVCFG - JP ?SETDRVMAP ; SETDRVMAP - JP ?SELDRIVE ; SELDRIVE - JP ?GETMAPDSK ; GETMAPDSK - JP ?DSKREAD ; DSKREAD - JP ?DSKWRITE ; DSKWRITE - - - ;------------------------------------------------------------------------------- - ; START OF FDC CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;------------------------------------------------------------------------------------------------ - ; Initialise drive and reset flags, Set motor off - ; - ;------------------------------------------------------------------------------------------------ -?DSKINIT: XOR A - OUT (FDC_MOTOR),A ; Motor off - LD (TRK0FD1),A ; Track 0 flag drive 1 - LD (TRK0FD2),A ; Track 0 flag drive 2 - LD (TRK0FD3),A ; Track 0 flag drive 3 - LD (TRK0FD4),A ; Track 0 flag drive 4 - LD (MOTON),A ; Motor on flag - LD (MTROFFTIMER),A ; Clear the down counter for motor off. - LD A,(FDCROMADDR) ; Check to see if the FDC AFI ROM is installed, use this as - OR A ; an indicator that the FDC is present. - RET - - ; Function to create a mapping table between a CPM disk and a physical disk. -?SETDRVMAP: PUSH HL - PUSH DE - PUSH BC - - ; Zero out the map. - LD B,MAXDISKS - LD HL,DISKMAP - LD A,0FFH -SETDRVMAP1: LD (HL),A - INC HL - DJNZ SETDRVMAP1 - LD HL,DISKMAP ; Place in the Map for next drive. - ; Now go through each disk from the Disk Parameter Base list. - LD B,0 ; Disk number count = CDISK. - LD DE,0 ; Physical disk number, D = FDC, E = SDC. -SETDRVMAP2: LD A,B - CP MAXDISKS - JR Z,SETDRVMAP6 - INC B - PUSH HL - PUSH DE - PUSH BC - ; For the Disk in A, find the parameter table. - RLC A ; *2 - RLC A ; *4 - RLC A ; *8 - RLC A ; *16 - LD HL,DPBASE ; Base of disk description block. - LD B,0 - LD C,A - ADD HL,BC ; HL contains address of actual selected disk block. - LD C,10 - ADD HL,BC ; HL contains address of pointer to disk parameter block. - LD E,(HL) - INC HL - LD D,(HL) ; DE contains address of disk parameter block. - EX DE,HL - LD A,(HL) - LD E,A - LD BC,15 - ADD HL,BC ; Move to configuuration byte which identifies the disk type. - ; - POP BC - POP DE - LD A,(HL) - POP HL - - BIT 4,A ; Disk type = FDC? - JR NZ,SETDRVMAP2A - BIT 3,A - JR Z,SETDRVMAP4 ; Is this an FDC controlled disk, if so store the mapping number in the map unchanged. - ; - LD A,E - OR 020H ; This is a RAM drive, add 020H to the mapping number and store. - INC E - JR SETDRVMAP5 - ; -SETDRVMAP2A:BIT 3,A ; Is this an SD Card disk, if so, add 080H to the mapping number and store. - JR Z,SETDRVMAP3 - LD A,E - OR 080H - INC E - JR SETDRVMAP5 -SETDRVMAP3: LD A,E ; This is a ROM drive, add 040H to the mapping number and store. - OR 040H - INC E - JR SETDRVMAP5 - ; -SETDRVMAP4: LD A,D - INC D -SETDRVMAP5: LD (HL),A - INC HL - JR SETDRVMAP2 - ; -SETDRVMAP6: POP BC - POP DE - POP HL - RET - - ; Function to setup the drive parameters according to the CFG byte in the disk parameter block. -?SETDRVCFG: PUSH HL - PUSH DE - PUSH BC - LD A,(CDISK) - RLC A ; *2 - RLC A ; *4 - RLC A ; *8 - RLC A ; *16 - LD HL,DPBASE ; Base of disk description block. - LD B,0 - LD C,A - ADD HL,BC ; HL contains address of actual selected disk block. - LD C,10 - ADD HL,BC ; HL contains address of pointer to disk parameter block. - LD E,(HL) - INC HL - LD D,(HL) ; DE contains address of disk parameter block. - EX DE,HL - LD A,(HL) - LD E,A - - LD BC,15 - ADD HL,BC ; Move to configuuration byte. - XOR A - BIT 2,(HL) - JR Z,SETDRV0 - INC A -SETDRV0: LD (INVFDCDATA),A ; Data inversion is set according to drive parameter. - LD A,4 - BIT 1,(HL) - JR Z,SETDRV1 - LD A,2 - BIT 0,(HL) - JR Z,SETDRV1 - LD A,1 -SETDRV1: LD (SECTORCNT),A ; Set the disk sector size. - LD D,A - CP 4 - LD A,E - JR Z,SETDRV1A - OR A - RR A - LD E,A - LD A,D - CP 2 - LD A,E - JR Z,SETDRV1A - OR A - RR A ; Convert sectors per track from 128 bytes to 256 byte sectors. -SETDRV1A: INC A ; Add 1 to ease comparisons. - LD (SECPERTRK),A ; Only cater for 8bit, ie. 256 sectors. - DEC A - OR A - RR A - INC A ; Add 1 to ease comparisons. - LD (SECPERHEAD),A ; Convert sectors per track to sectors per head. - ; - XOR A ; Disk type = FDC - BIT 4,(HL) - JR NZ,SETDRV1B ; 4 = 1? - BIT 3,(HL) - JR Z,SETDRV2 ; 3 = 0 - FDC - LD A,DSKTYP_RAM - JR SETDRV2 -SETDRV1B: LD A,DSKTYP_ROM ; Disk type = ROMFS - BIT 3,(HL) ; 3 = 0? Thus 1:0 = ROM - JR Z,SETDRV2 - LD A,DSKTYP_SDC ; Disk type = SD Card, ie. 1:1 -SETDRV2: LD (DISKTYPE),A - POP BC - POP DE - POP HL - RET - - ; Method to get the current disk drive mapped to the correct controller. - ; The CPM CDISK is mapped via MAPDISK[CDISK] and the result: - ; Bit 7 = 1 - SD Card drive. - ; Bit 6 = 1 - ROM Drive. - ; BIT 7:6 = 00 - Floppy drive. -?GETMAPDSK: PUSH HL - PUSH BC - LD A,(CDISK) - LD HL,DISKMAP - LD C,A - LD B,0 - ADD HL,BC - LD A,(HL) ; Get the physical number after mapping from the CDISK. - POP BC - POP HL - RET - - ; Select FDC drive (make active) based on value in DISKMAP[CDISK]. -?SELDRIVE: CALL ?GETMAPDSK - CP 020H ; Anything with bit 7:5 set is not an FDC drive. - RET NC ; This isnt a physical floppy disk, no need to perform any actions, exit. - LD (FDCDISK),A - CALL DSKMTRON ; yes, set motor on and wait - LD A,(FDCDISK) ; select drive no - OR 084H - OUT (FDC_MOTOR),A ; Motor on for drive 0-3 - XOR A - LD (FDCCMD),A ; clr latest FDC command byte - LD HL,00000H -SELDRV2: DEC HL - LD A,H - OR L - JP Z,SELDRVERR ; Reset and print message that this is not a valid disk. - IN A,(FDC_STR) ; Status register. - CPL - RLCA - JR C,SELDRV2 ; Wait on Drive Ready Bit (bit 7) - LD A,(FDCDISK) ; Drive number - LD C,A - LD HL,TRK0FD1 ; 1 track 0 flag for each drive - LD B,000H - ADD HL,BC ; Compute related flag 1002/1003/1004/1005 - BIT 0,(HL) - JR NZ,SELDRV3 ; If the drive hasnt been intialised to track 0, intialise and set flag. - CALL DSKSEEKTK0 ; Seek track 0. - SET 0,(HL) ; Set bit 0 of trk 0 flag -SELDRV3: CALL ?SETDRVCFG - RET - - ; Turn disk motor on if not already running. -DSKMTRON: LD A,255 ; Ensure motor is kept running whilst we read/write. - LD (MTROFFTIMER),A - LD A,(MOTON) ; Test to see if motor is on, if it isnt, switch it on. - RRCA - JR NC, DSKMOTORON - RET -DSKMOTORON: PUSH BC - LD A,080H - OUT (FDC_MOTOR),A ; Motor on - LD B,010H ; -DSKMTR2: CALL MTRDELAY ; - DJNZ DSKMTR2 ; Wait until becomes ready. - LD A,001H ; Set motor on flag. - LD (MOTON),A ; - POP BC - RET - -FDCDLY1: PUSH DE - LD DE,00007H - JP MTRDEL2 - -MTRDELAY: PUSH DE - LD DE,01013H -MTRDEL2: DEC DE - LD A,E - OR D - JR NZ,MTRDEL2 - POP DE - RET - -?DSKWRITE: LD A,MAXWRRETRY - LD (RETRIES),A - LD A,(SECTORCNT) - LD B,A - LD A,(HSTSEC) -DSKWRITE0A: DJNZ DSKWRITE0B - JR DSKWRITE1 -DSKWRITE0B: OR A - RL A - JR DSKWRITE0A -DSKWRITE1: INC A - LD (SECTORNO), A ; Convert from Host 512 byte sector into local sector according to paraameter block. - LD HL,(HSTTRK) - LD (TRACKNO),HL - -DSKWRITE2: CALL SETTRKSEC ; Set current track & sector, get load address to HL -DSKWRITE3: CALL SETHEAD ; Set side reg - CALL SEEK ; Command 1b output (seek) - JP NZ,SEEKRETRY ; - CALL OUTTKSEC ; Set track & sector reg - - LD IX, 0F3FEH ; As below. L03FE - LD IY,WRITEDATA ; Write sector from memory. - DI - ; - LD A,0B4H ; Write Sector multipe with Side Compare for side 1. - CALL DISKCMDWAIT - LD D,2 ; Regardless of 4x128, 2x256 or 1x512, we always read 512bytes by the 2x INI instruction with B=256. -STRTDATWR: LD B,0 ; 256 bytes to load. - JP (IX) - -WRITEDATA: OUTI - JP NZ, 0F3FEH ; This is crucial, as the Z80 is running at 2MHz it is not fast enough so needs - ; hardware acceleration in the form of a banked ROM, if disk not ready jumps to IX, if - ; data ready, jumps to IY. - DEC D - JP NZ,0F3FEH ; If we havent read all sectors to form a 512 byte block, go for next sector. - JR DATASTOP - - ; Read disk starting at the first logical sector in param block 1009/100A - ; Continue reading for the given size 100B/100C and store in the location - ; Pointed to by the address stored in the parameter block. 100D/100E -?DSKREAD: LD A,MAXRDRETRY - LD (RETRIES),A - LD A,(SECTORCNT) - LD B,A - LD A,(HSTSEC) -DSKREAD0A: DJNZ DSKREAD0B - JR DSKREAD1 -DSKREAD0B: OR A - RL A - JR DSKREAD0A -DSKREAD1: INC A - LD (SECTORNO), A ; Convert from Host 512 byte sector into local sector according to paraameter block. - LD HL,(HSTTRK) - LD (TRACKNO),HL -DSKREAD2: CALL SETTRKSEC ; Set current track & sector, get load address to HL -DSKREAD3: CALL SETHEAD ; Set side reg - CALL SEEK ; Command 1b output (seek) - JP NZ,SEEKRETRY ; - CALL OUTTKSEC ; Set track & sector reg - LD IX, 0F3FEH ; As below. L03FE - LD IY,READDATA ; Read sector into memory. - DI - ; - LD A,094H ; Read Sector multiple with Side Compare for side 1. - CALL DISKCMDWAIT - LD D,2 ; Regardless of 4x128, 2x256 or 1x512, we always read 512bytes by the 2x INI instruction with B=256. -STRTDATRD: LD B,0 ; 256 bytes to load. - JP (IX) - - ; Get data from disk sector to staging area. -READDATA: INI - JP NZ,0F3FEH ; This is crucial, as the Z80 is running at 2MHz it is not fast enough so needs - ; hardware acceleration in the form of a banked ROM, if disk not ready jumps to IX, if - ; data ready, jumps to IY. - DEC D - JP NZ,0F3FEH ; If we havent read all sectors to form a 512 byte block, go for next sector. - ; - ; -DATASTOP: LD A,0D8H ; Force interrupt command, Immediate interrupt (I3 bit 3=1) of multiple sector read. - CPL - OUT (FDC_CR),A - CALL WAITRDY ; Wait for controller to become ready, acknowledging interrupt. - IN A,(FDC_STR) ; Check for errors. - CPL - AND 0FFH - JR NZ,SEEKRETRY -UPDSECTOR: PUSH HL - LD A,(SECTORCNT) - LD HL,SECTORNO - ADD A,(HL) ; Update sector to account for sectors read. NB. All reads will start at such a position - LD (HL), A ; that a read will not span a track or head. Ensure that disk formats meet an even 512byte format. - POP HL -MOTOROFF: LD A,MTROFFMSECS ; Schedule motor to be turned off. - LD (MTROFFTIMER),A - XOR A ; Successful read, return 0 - EI - RET - -SEEKRETRY: LD B,A ; Preserve the FDC Error byte. - LD A,(RETRIES) - DEC A - LD (RETRIES),A - LD A,B - JP Z,RETRIESERR - CALL DSKSEEKTK0 - LD A, (READOP) - OR A - LD A,(TRACKNO) ; NB. Track number is 16bit, FDC only uses lower 8bit and assumes little endian read. - JP Z, DSKWRITE2 ; Try write again. - JP DSKREAD2 ; Try the read again. - -DISKCMDWAIT:LD (FDCCMD),A - CPL - OUT (FDC_CR),A - CALL WAITBUSY - RET - - ; Send a command to the disk controller. -DSKCMD: LD (FDCCMD),A ; Store latest FDC command. - CPL ; Compliment it (FDC bit value is reversed). - OUT (FDC_CR),A ; Send command to FDC. - CALL WAITRDY ; Wait to become ready. - IN A,(FDC_STR) ; Get status register. - CPL ; Inverse (FDC is reverse bit logic). - RET - - ; Seek to programmed track. -SEEK: LD A,01BH ; Seek command, load head, verify stepping 6ms. - CALL DSKCMD - AND 099H - RET - - ; Set current track & sector, get load address to HL -SETTRKSEC: CALL ?SELDRIVE - LD A,(TRACKNO) ; NB. Track number is 16bit, FDC only uses lower 8bit and assumes little endian read. - LD HL, HSTBUF - RET - - ; Compute side/head. -SETHEAD: CPL ; - OUT (FDC_DR),A ; Output track no for SEEK command. - PUSH HL - LD HL,SECPERHEAD - LD A,(SECTORNO) ; Check sector, if greater than sector per track, change head. - CP (HL) - POP HL - JR NC,SETHD2 ; Yes, even, set side/head 1 - LD A,001H ; No, odd, set side/head 0 - JR SETHD3 - - ; Set side/head register. -SETHD2: XOR A ; Side 0 -SETHD3: CPL ; Side 1 - OUT (FDC_SIDE),A ; Side/head register. - RET - - ; Set track and sector register. -OUTTKSEC: PUSH HL - LD HL,SECPERHEAD - ; - LD C,FDC_DR ; Port for data retrieval in the INI instruction in main block. - LD A,(TRACKNO) ; Current track number, NB. Track number is 16bit, FDC only uses lower 8bit and assumes little endian read. - CPL - OUT (FDC_TR),A ; Track reg - ; - LD A,(SECTORNO) ; Current sector number - CP (HL) - JR C,OUTTKSEC2 - SUB (HL) - INC A ; Account for the +1 added to ease comparisons. -OUTTKSEC2: CPL - OUT (FDC_SCR),A ; Sector reg - POP HL - RET - - ; Seek to track 0. -DSKSEEKTK0: CALL DSKMTRON ; Make sure disk is spinning. - LD A,00BH ; Restore command, seek track 0. - CALL DSKCMD ; Send command to FDC. - AND 085H ; Process result. - XOR 004H - RET Z - JP DSKSEEKERR - - ; Wait for the drive to become ready. -WAITRDY: PUSH DE - PUSH HL - CALL FDCDLY1 - LD E,007H -WAITRDY2: LD HL,00000H -WAITRDY3: DEC HL - LD A,H - OR L - JR Z,WAITRDY4 - IN A,(FDC_STR) - CPL - RRCA - JR C,WAITRDY3 - POP HL - POP DE - RET - -WAITRDY4: DEC E - JR NZ,WAITRDY2 - POP HL - POP DE - JP WAITRDYERR - -WAITBUSY: PUSH DE - PUSH HL - CALL FDCDLY1 - LD E,007H ; 7 Chances of a 16bit down count delay waiting for DRQ. -WAITBUSY2: LD HL,00000H -WAITBUSY3: DEC HL - LD A,H - OR L - JR Z,WAITBUSY4 ; Down counter expired, decrement retries, error on 0. - IN A,(FDC_STR) ; Get the FDC Status - CPL ; Switch to positive logic. - RRCA ; Shift Busy flag into Carry. - JR NC,WAITBUSY3 ; Busy not set, decrement counter and retry. - POP HL - POP DE - RET - -WAITBUSY4: DEC E - JR NZ,WAITBUSY2 - POP HL - POP DE - JP DSKERR - - - ; Error processing. Consists of printing a message followed by debug data (if enabled) and returning with carry set - ; to indicate error. -DSKERR: LD DE,LOADERR ; Loading error message - JR HDLERROR - -SELDRVERR: LD DE,SELDRVMSG ; Select drive error message. - JR HDLERROR - -WAITRDYERR: LD DE,WAITRDYMSG ; Waiting for ready timeout error message. - JR HDLERROR - -DSKSEEKERR: LD DE,DSKSEEKMSG ; Disk seek to track error message. - JR HDLERROR - -RETRIESERR: BIT 2,A ; Data overrun error if 1. - LD DE,DATAOVRMSG - JR NZ, RETRIESERR2 - BIT 3,A ; CRC error if 1. - LD DE,CRCERRMSG - JR NZ,RETRIESERR2 - LD DE,RETRIESMSG ; Data sector read error message. -RETRIESERR2: - - ; Process error, dump debug data and return fail code. -HDLERROR: LD HL,MSGSTRBUF ; Copy the error messae -HOLERR1: LD A,(DE) - LD (HL),A - CP NUL - JR Z,HOLERR2 - INC DE - INC HL - JR HOLERR1 -HOLERR2: LD DE,MSGSTRBUF -HOLPRTSTR: LD A,(DE) - OR A - JR Z,HOLERR3 - INC DE -HOLPRTSTR2: LD HL,QPRNT - PUSH AF - LD A,ROMBANK9 << 4 | ROMBANK11 ; Call CBIOS Bank 2 from CBIOS Bank 4 - CALL BANKTOBANK - JR HOLPRTSTR -HOLERR3: XOR A - CALL ?DSKINIT - CALL DSKMTRON - LD A,001H ; Indicate error by setting 1 in A register. - EI - RET - - ;------------------------------------------------------------------------------- - ; END OF FDC CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - - ;-------------------------------------- - ; - ; Message table - ; - ;-------------------------------------- -LOADERR: DB "DISK ERROR - LOADING", CR, NUL -SELDRVMSG: DB "DISK ERROR - SELECT", CR, NUL -WAITRDYMSG: DB "DISK ERROR - WAIT", CR, NUL -DSKSEEKMSG: DB "DISK ERROR - SEEK", CR, NUL -RETRIESMSG: DB "DISK ERROR - RETRIES", CR, NUL -DATAOVRMSG: DB "DISK ERROR - DATA OVERRUN", CR, NUL -CRCERRMSG: DB "DISK ERROR - CRC ERROR", CR, NUL - - ; Align to end of bank. - ALIGN UROMADDR + 07F8h - ORG UROMADDR + 07F8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh diff --git a/software/asm/cpm22-bios.asm b/software/asm/cpm22-bios.asm deleted file mode 100644 index ee74e5a..0000000 --- a/software/asm/cpm22-bios.asm +++ /dev/null @@ -1,84 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: cpm22-bios.asm -;- Created: January 2020 -;- Author(s): Philip Smart -;- Description: CPM BIOS for CPM v2.23 on the Sharp MZ80A with the Rom Filing System. -;- Most of the code is stored in the ROM based CBIOS which is part of the -;- Rom Filing System upgrade. Declarations in this file are for tables -;- which need to reside in RAM. -;- -;- Credits: Some of the comments and parts of the deblocking/blocking algorithm come from the -; Z80-MBC2 project, (C) SuperFabius. -;- Copyright: (c) 2020-2023 Philip Smart -;- -;- History: January 2020 - Initial creation. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - ORG CPMBIOS - - ; Boot strap code to setup the machine in order to run CPM and the CBIOS. - ; Previously this used to be in the comment field of the tape header but with the - ; advent of the SDCFS which doesnt store the comment, the bootstrap needs to be relocated. - ; This code will be overwritten with the DP Headers on cold boot. -BOOTLDR: LD B, 0x10 ; Need to read the same location 16 times to enable I/O operations. -BOOTLDR2: LD A, (BNKCTRLRST) - DJNZ BOOTLDR2 - LD A, 0x07 - LD (BNKCTRL), A ; Setup the User ROM Bank default. - LD A, (MEMSW) ; Swap 0000:0FFF to C000:CFFF so lower location uses DRAM. - LD A, 0x02 - LD (BNKSELMROM), A ; Setup the Monitor ROM bank default. - JP CBIOSSTART ; Cold start the CBIOS. - -;------------------------------------------------------------------------------------------------------------ -; DISK PARAMETER HEADER -; -; Disk parameter headers for disk 0 to 3 -; -; +-------+------+------+------+----------+-------+-------+-------+ -; | XLT | 0000 | 0000 | 0000 |DIRBUF | DPB | CSV | ALV | -; +------+------+------+-------+----------+-------+-------+-------+ -; 16B 16B 16B 16B 16B 16B 16B 16B -; -; -XLT Address of the logical-to-physical translation vector, if used for this particular drive, -; or the value 0000H if no sector translation takes place (that is, the physical and -; logical sectornumbers are the same). Disk drives with identical sector skew factors share -; the same translatetables. -; -0000 Scratch pad values for use within the BDOS, initial value is unimportant. -; -DIRBUF Address of a 128-byte scratch pad area for directory operations within BDOS. All DPHs -; address the same scratch pad area. -; -DPB Address of a disk parameter block for this drive. Drives with identical disk characteristics -; address the same disk parameter block. -; -CSV Address of a scratch pad area used for software check for changed disks. This address is -; different for each DPH. -; -ALV Address of a scratch pad area used by the BDOS to keep disk storage allocation information. -; This address is different for each DPH. -;------------------------------------------------------------------------------------------------------------ - ;ALIGN_NOPS DPBASE ; Space for 2xROM, 2xFD, 3xSD or upto 7 drives - ; These entries are created dynamically based on hardware available. - - ; NB. The Disk Parameter Blocks are stored in CBIOS ROM to save RAM space. - -;------------------------------------------------------------------------------------------------------------ -; CPN Disk work areas. -;------------------------------------------------------------------------------------------------------------ - ALIGN_NOPS CDIRBUF ; Memory work areas, just allocate the space. - ALIGN_NOPS CSVALVMEM - ALIGN_NOPS CSVALVEND - ALIGN CBIOSDATA - diff --git a/software/asm/cpm22.asm b/software/asm/cpm22.asm deleted file mode 100644 index 74032ec..0000000 --- a/software/asm/cpm22.asm +++ /dev/null @@ -1,3764 +0,0 @@ -;************************************************************** -;* -;* C P / M version 2 . 2 -;* -;* Reconstructed from memory image on February 27, 1981 -;* -;* by Clark A. Calkins -;* -;************************************************************** - - ; Bring in definitions and macros. - INCLUDE "cpm_buildversion.asm" - INCLUDE "cpm_definitions.asm" - INCLUDE "macros.asm" -; -; Set memory limit here. This is the amount of contigeous -; ram starting from 0000. CP/M will reside at the end of this space. -; - -IOBYTE EQU 3 ;i/o definition byte. -TDRIVE EQU 4 ;current drive name and user number. -ENTRY EQU 5 ;entry point for the cp/m bdos. -TFCB EQU 5CH ;default file control block. -TBUFF EQU 80H ;i/o buffer and command line storage. -TBASE EQU 100H ;transiant program storage area. -; -; Set control character equates. -; -CNTRLC EQU 3 ;control-c -CNTRLE EQU 05H ;control-e -BS EQU 08H ;backspace -;TAB EQU 09H ;tab -;LF EQU 0AH ;line feed -;FF EQU 0CH ;form feed -;CR EQU 0DH ;carriage return -CNTRLP EQU 10H ;control-p -CNTRLR EQU 12H ;control-r -CNTRLS EQU 13H ;control-s -CNTRLU EQU 15H ;control-u -CNTRLX EQU 18H ;control-x -CNTRLZ EQU 1AH ;control-z (end-of-file mark) -DEL EQU 7FH ;rubout - -; CP/M addresses -;CBASE EQU 09C00H -;CCP EQU CBASE ; CP/M System entry -;BDOS EQU CCP + 0806H ; BDOS entry -;BIOS EQU CCP + 01600H ; BIOS entry -CCPLEN EQU CBASE + 7 ; Address of current number of chars into the CCP input buffer -CCPFIRS EQU CBASE + 8 ; Address of the first charater of the CCP input buffer - - - ; - ; Set origin for CP/M - ; - ORG CBASE ; Origin for the Sharp MZ-80A version - ; - JP COMMAND ;execute command processor (ccp). - JP CLEARBUF ;entry to empty input buffer before starting ccp. - -; -; Standard cp/m ccp input buffer. Format is (max length), -; (actual length), (char #1), (char #2), (char #3), etc. -; -INBUFF: DB 127 ;length of input buffer. - DB 0 ;current length of contents. - IF BUILD_80C = 1 - DB "CP/M v2.23 (48K) Copyright(c) 1979 by Digital Research", 00DH, 00AH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; 68 chars - ELSE - DB "CP/M v2.23 (c) 1979 by Digital Research", 00DH, 00AH, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; 68 chars - ENDIF - ;DB "Copyright" - ;DB " 1979 (c) by Digital Research " - DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -INPOINT:DW INBUFF+2 ;input line pointer -NAMEPNT:DW 0 ;input line pointer used for error message. Points to -; ;start of name in error. -; -; Routine to print (A) on the console. All registers used. -; -PRINT: LD E,A ;setup bdos call. - LD C,2 - JP ENTRY -; -; Routine to print (A) on the console and to save (BC). -; -PRINTB: PUSH BC - CALL PRINT - POP BC - RET -; -; Routine to send a carriage return, line feed combination -; to the console. -; -CRLF: LD A,CR - CALL PRINTB - LD A,LF - JP PRINTB -; -; Routine to send one space to the console and save (BC). -; -PRTSPACE: LD A,' ' - JP PRINTB -; -; Routine to print character string pointed to be (BC) on the -; console. It must terminate with a null byte. -; -PLINE: PUSH BC - CALL CRLF - POP HL -PLINE2: LD A,(HL) - OR A - RET Z - INC HL - PUSH HL - CALL PRINT - POP HL - JP PLINE2 -; -; Routine to reset the disk system. -; -RESDSK: LD C,13 - JP ENTRY -; -; Routine to select disk (A). -; -DSKSEL: LD E,A - LD C,14 - JP ENTRY -; -; Routine to call bdos and save the return code. The zero -; flag is set on a return of 0ffh. -; -ENTRY1: CALL ENTRY - LD (RTNCODE),A ;save return code. - INC A ;set zero if 0ffh returned. - RET -; -; Routine to open a file. (DE) must point to the FCB. -; -OPEN: LD C,15 - JP ENTRY1 -; -; Routine to open file at (FCB). -; -OPENFCB:XOR A ;clear the record number byte at fcb+32 - LD (FCB+32),A - LD DE,FCB - JP OPEN -; -; Routine to close a file. (DE) points to FCB. -; -CLOSE: LD C,16 - JP ENTRY1 -; -; Routine to search for the first file with ambigueous name -; (DE). -; -SRCHFST:LD C,17 - JP ENTRY1 -; -; Search for the next ambigeous file name. -; -SRCHNXT:LD C,18 - JP ENTRY1 -; -; Search for file at (FCB). -; -SRCHFCB:LD DE,FCB - JP SRCHFST -; -; Routine to delete a file pointed to by (DE). -; -DELETEFILE: LD C,19 - JP ENTRY -; -; Routine to call the bdos and set the zero flag if a zero -; status is returned. -; -ENTRY2: CALL ENTRY - OR A ;set zero flag if appropriate. - RET -; -; Routine to read the next record from a sequential file. -; (DE) points to the FCB. -; -RDREC: LD C,20 - JP ENTRY2 -; -; Routine to read file at (FCB). -; -READFCB:LD DE,FCB - JP RDREC -; -; Routine to write the next record of a sequential file. -; (DE) points to the FCB. -; -WRTREC: LD C,21 - JP ENTRY2 -; -; Routine to create the file pointed to by (DE). -; -CREATE: LD C,22 - JP ENTRY1 -; -; Routine to rename the file pointed to by (DE). Note that -; the new name starts at (DE+16). -; -RENAM: LD C,23 - JP ENTRY -; -; Get the current user code. -; -GETUSR: LD E,0FFH -; -; Routne to get or set the current user code. -; If (E) is FF then this is a GET, else it is a SET. -; -GETSETUC: LD C,32 - JP ENTRY -; -; Routine to set the current drive byte at (TDRIVE). -; -SETCDRV:CALL GETUSR ;get user number - ADD A,A ;and shift into the upper 4 bits. - ADD A,A - ADD A,A - ADD A,A - LD HL,CDRIVE ;now add in the current drive number. - OR (HL) - LD (TDRIVE),A ;and save. - RET -; -; Move currently active drive down to (TDRIVE). -; -MOVECD: LD A,(CDRIVE) - LD (TDRIVE),A - RET -; -; Routine to convert (A) into upper case ascii. Only letters -; are affected. -; -UPPER: CP 'a' ;check for letters in the range of 'a' to 'z'. - RET C - CP '{' - RET NC - AND 5FH ;convert it if found. - RET -; -; Routine to get a line of input. We must check to see if the -; user is in (BATCH) mode. If so, then read the input from file -; ($$$.SUB). At the end, reset to console input. -; -GETINP: LD A,(BATCH) ;if =0, then use console input. - OR A - JP Z,GETINP1 -; -; Use the submit file ($$$.sub) which is prepared by a -; SUBMIT run. It must be on drive (A) and it will be deleted -; if and error occures (like eof). -; - LD A,(CDRIVE) ;select drive 0 if need be. - OR A - LD A,0 ;always use drive A for submit. - CALL NZ,DSKSEL ;select it if required. - LD DE,BATCHFCB - CALL OPEN ;look for it. - JP Z,GETINP1 ;if not there, use normal input. - LD A,(BATCHFCB+15) ;get last record number+1. - DEC A - LD (BATCHFCB+32),A - LD DE,BATCHFCB - CALL RDREC ;read last record. - JP NZ,GETINP1 ;quit on end of file. -; -; Move this record into input buffer. -; - LD DE,INBUFF+1 - LD HL,TBUFF ;data was read into buffer here. - LD B,128 ;all 128 characters may be used. - CALL HL2DE ;(HL) to (DE), (B) bytes. - LD HL,BATCHFCB+14 - LD (HL),0 ;zero out the 's2' byte. - INC HL ;and decrement the record count. - DEC (HL) - LD DE,BATCHFCB ;close the batch file now. - CALL CLOSE - JP Z,GETINP1 ;quit on an error. - LD A,(CDRIVE) ;re-select previous drive if need be. - OR A - CALL NZ,DSKSEL ;don't do needless selects. -; -; Print line just read on console. -; - LD HL,INBUFF+2 - CALL PLINE2 - CALL CHKCON ;check console, quit on a key. - JP Z,GETINP2 ;jump if no key is pressed. -; -; Terminate the submit job on any keyboard input. Delete this -; file such that it is not re-started and jump to normal keyboard -; input section. -; - CALL DELBATCH ;delete the batch file. - JP CMMND1 ;and restart command input. -; -; Get here for normal keyboard input. Delete the submit file -; incase there was one. -; -GETINP1:CALL DELBATCH ;delete file ($$$.sub). - CALL SETCDRV ;reset active disk. - LD C,10 ;get line from console device. - LD DE,INBUFF - CALL ENTRY - CALL MOVECD ;reset current drive (again). -; -; Convert input line to upper case. -; -GETINP2:LD HL,INBUFF+1 - LD B,(HL) ;(B)=character counter. -GETINP3:INC HL - LD A,B ;end of the line? - OR A - JP Z,GETINP4 - LD A,(HL) ;convert to upper case. - CALL UPPER - LD (HL),A - DEC B ;adjust character count. - JP GETINP3 -GETINP4:LD (HL),A ;add trailing null. - LD HL,INBUFF+2 - LD (INPOINT),HL ;reset input line pointer. - RET -; -; Routine to check the console for a key pressed. The zero -; flag is set is none, else the character is returned in (A). -; -CHKCON: LD C,11 ;check console. - CALL ENTRY - OR A - RET Z ;return if nothing. - LD C,1 ;else get character. - CALL ENTRY - OR A ;clear zero flag and return. - RET -; -; Routine to get the currently active drive number. -; -GETDSK: LD C,25 - JP ENTRY -; -; Set the stabdard dma address. -; -STDDMA: LD DE,TBUFF -; -; Routine to set the dma address to (DE). -; -DMASET: LD C,26 - JP ENTRY -; -; Delete the batch file created by SUBMIT. -; -DELBATCH: LD HL,BATCH ;is batch active? - LD A,(HL) - OR A - RET Z - LD (HL),0 ;yes, de-activate it. - XOR A - CALL DSKSEL ;select drive 0 for sure. - LD DE,BATCHFCB ;and delete this file. - CALL DELETEFILE - LD A,(CDRIVE) ;reset current drive. - JP DSKSEL -; -; Check to two strings at (PATTRN1) and (PATTRN2). They must be -; the same or we halt.... -; -VERIFY: LD DE,PATTRN1 ;these are the serial number bytes. - LD HL,PATTRN2 ;ditto, but how could they be different? - LD B,6 ;6 bytes each. -VERIFY1:LD A,(DE) - CP (HL) - JP NZ,HALTCPM ;jump to halt routine. - INC DE - INC HL - DEC B - JP NZ,VERIFY1 - RET -; -; Print back file name with a '?' to indicate a syntax error. -; -SYNERR: CALL CRLF ;end current line. - LD HL,(NAMEPNT) ;this points to name in error. -SYNERR1:LD A,(HL) ;print it until a space or null is found. - CP ' ' - JP Z,SYNERR2 - OR A - JP Z,SYNERR2 - PUSH HL - CALL PRINT - POP HL - INC HL - JP SYNERR1 -SYNERR2:LD A,'?' ;add trailing '?'. - CALL PRINT - CALL CRLF - CALL DELBATCH ;delete any batch file. - JP CMMND1 ;and restart from console input. -; -; Check character at (DE) for legal command input. Note that the -; zero flag is set if the character is a delimiter. -; -CHECK: LD A,(DE) - OR A - RET Z - CP ' ' ;control characters are not legal here. - JP C,SYNERR - RET Z ;check for valid delimiter. - CP '=' - RET Z - CP '_' - RET Z - CP '.' - RET Z - CP ':' - RET Z - CP 03BH ; ';' - RET Z - CP '<' - RET Z - CP '>' - RET Z - RET -; -; Get the next non-blank character from (DE). -; -NONBLANK: LD A,(DE) - OR A ;string ends with a null. - RET Z - CP ' ' - RET NZ - INC DE - JP NONBLANK -; -; Add (HL)=(HL)+(A) -; -ADDHL: ADD A,L - LD L,A - RET NC ;take care of any carry. - INC H - RET -; -; Convert the first name in (FCB). -; -CONVFST:LD A,0 -; -; Format a file name (convert * to '?', etc.). On return, -; (A)=0 is an unambigeous name was specified. Enter with (A) equal to -; the position within the fcb for the name (either 0 or 16). -; -CONVERT:LD HL,FCB - CALL ADDHL - PUSH HL - PUSH HL - XOR A - LD (CHGDRV),A ;initialize drive change flag. - LD HL,(INPOINT) ;set (HL) as pointer into input line. - EX DE,HL - CALL NONBLANK ;get next non-blank character. - EX DE,HL - LD (NAMEPNT),HL ;save pointer here for any error message. - EX DE,HL - POP HL - LD A,(DE) ;get first character. - OR A - JP Z,CONVRT1 - SBC A,'A'-1 ;might be a drive name, convert to binary. - LD B,A ;and save. - INC DE ;check next character for a ':'. - LD A,(DE) - CP ':' - JP Z,CONVRT2 - DEC DE ;nope, move pointer back to the start of the line. -CONVRT1:LD A,(CDRIVE) - LD (HL),A - JP CONVRT3 -CONVRT2:LD A,B - LD (CHGDRV),A ;set change in drives flag. - LD (HL),B - INC DE -; -; Convert the basic file name. -; -CONVRT3:LD B,08H -CONVRT4:CALL CHECK - JP Z,CONVRT8 - INC HL - CP '*' ;note that an '*' will fill the remaining - JP NZ,CONVRT5 ;field with '?'. - LD (HL),'?' - JP CONVRT6 -CONVRT5:LD (HL),A - INC DE -CONVRT6:DEC B - JP NZ,CONVRT4 -CONVRT7:CALL CHECK ;get next delimiter. - JP Z,GETEXT - INC DE - JP CONVRT7 -CONVRT8:INC HL ;blank fill the file name. - LD (HL),' ' - DEC B - JP NZ,CONVRT8 -; -; Get the extension and convert it. -; -GETEXT: LD B,03H - CP '.' - JP NZ,GETEXT5 - INC DE -GETEXT1:CALL CHECK - JP Z,GETEXT5 - INC HL - CP '*' - JP NZ,GETEXT2 - LD (HL),'?' - JP GETEXT3 -GETEXT2:LD (HL),A - INC DE -GETEXT3:DEC B - JP NZ,GETEXT1 -GETEXT4:CALL CHECK - JP Z,GETEXT6 - INC DE - JP GETEXT4 -GETEXT5:INC HL - LD (HL),' ' - DEC B - JP NZ,GETEXT5 -GETEXT6:LD B,3 -GETEXT7:INC HL - LD (HL),0 - DEC B - JP NZ,GETEXT7 - EX DE,HL - LD (INPOINT),HL ;save input line pointer. - POP HL -; -; Check to see if this is an ambigeous file name specification. -; Set the (A) register to non zero if it is. -; - LD BC,11 ;set name length. -GETEXT8:INC HL - LD A,(HL) - CP '?' ;any question marks? - JP NZ,GETEXT9 - INC B ;count them. -GETEXT9:DEC C - JP NZ,GETEXT8 - LD A,B - OR A - RET -; -; CP/M command table. Note commands can be either 3 or 4 characters long. -; -NUMCMDS EQU 6 ;number of commands -CMDTBL: DB "DIR " - DB "ERA " - DB "TYPE" - DB "SAVE" - DB "REN " - DB "USER" -; -; The following six bytes must agree with those at (PATTRN2) -; or cp/m will HALT. Why? -; -PATTRN1:DB 0,22,0,0,0,0 ;(* serial number bytes *). -; -; Search the command table for a match with what has just -; been entered. If a match is found, then we jump to the -; proper section. Else jump to (UNKNOWN). -; On return, the (C) register is set to the command number -; that matched (or NUMCMDS+1 if no match). -; -SEARCH: LD HL,CMDTBL - LD C,0 -SEARCH1:LD A,C - CP NUMCMDS ;this commands exists. - RET NC - LD DE,FCB+1 ;check this one. - LD B,4 ;max command length. -SEARCH2:LD A,(DE) - CP (HL) - JP NZ,SEARCH3 ;not a match. - INC DE - INC HL - DEC B - JP NZ,SEARCH2 - LD A,(DE) ;allow a 3 character command to match. - CP ' ' - JP NZ,SEARCH4 - LD A,C ;set return register for this command. - RET -SEARCH3:INC HL - DEC B - JP NZ,SEARCH3 -SEARCH4:INC C - JP SEARCH1 -; -; Set the input buffer to empty and then start the command -; processor (ccp). -; -CLEARBUF: XOR A - LD (INBUFF+1),A ;second byte is actual length. -; -;************************************************************** -;* -;* -;* C C P - C o n s o l e C o m m a n d P r o c e s s o r -;* -;************************************************************** -;* -COMMAND:LD SP,CCPSTACK ;setup stack area. - PUSH BC ;note that (C) should be equal to: - LD A,C ;(uuuudddd) where 'uuuu' is the user number - RRA ;and 'dddd' is the drive number. - RRA - RRA - RRA - AND 0FH ;isolate the user number. - LD E,A - CALL GETSETUC ;and set it. - CALL RESDSK ;reset the disk system. - LD (BATCH),A ;clear batch mode flag. - POP BC - LD A,C - AND 0FH ;isolate the drive number. - LD (CDRIVE),A ;and save. - CALL DSKSEL ;...and select. - LD A,(INBUFF+1) - OR A ;anything in input buffer already? - JP NZ,CMMND2 ;yes, we just process it. -; -; Entry point to get a command line from the console. -; -CMMND1: LD SP,CCPSTACK ;set stack straight. - CALL CRLF ;start a new line on the screen. - CALL GETDSK ;get current drive. - ADD A,'A' - CALL PRINT ;print current drive. - LD A,'>' - CALL PRINT ;and add prompt. - CALL GETINP ;get line from user. -; -; Process command line here. -; -CMMND2: LD DE,TBUFF - CALL DMASET ;set standard dma address. - CALL GETDSK - LD (CDRIVE),A ;set current drive. - CALL CONVFST ;convert name typed in. - CALL NZ,SYNERR ;wild cards are not allowed. - LD A,(CHGDRV) ;if a change in drives was indicated, - OR A ;then treat this as an unknown command - JP NZ,UNKNOWN ;which gets executed. - CALL SEARCH ;else search command table for a match. -; -; Note that an unknown command returns -; with (A) pointing to the last address -; in our table which is (UNKNOWN). -; - LD HL,CMDADR ;now, look thru our address table for command (A). - LD E,A ;set (DE) to command number. - LD D,0 - ADD HL,DE - ADD HL,DE ;(HL)=(CMDADR)+2*(command number). - LD A,(HL) ;now pick out this address. - INC HL - LD H,(HL) - LD L,A - JP (HL) ;now execute it. -; -; CP/M command address table. -; -CMDADR: DW DIRECT,ERASE,TYPE,SAVE - DW RENAME,USER,UNKNOWN -; -; Halt the system. Reason for this is unknown at present. -; -HALTCPM: LD HL,76F3H ;'DI HLT' instructions. - LD (CBASE),HL - LD HL,CBASE - JP (HL) -; -; Read error while TYPEing a file. -; -RDERROR:LD BC,RDERR - JP PLINE -RDERR: DB "Read error" - DB 0 -; -; Required file was not located. -; -NONE: LD BC,NOFILE - JP PLINE -NOFILE: DB "No file" - DB 0 -; -; Decode a command of the form 'A>filename number{ filename}. -; Note that a drive specifier is not allowed on the first file -; name. On return, the number is in register (A). Any error -; causes 'filename?' to be printed and the command is aborted. -; -DECODE: CALL CONVFST ;convert filename. - LD A,(CHGDRV) ;do not allow a drive to be specified. - OR A - JP NZ,SYNERR - LD HL,FCB+1 ;convert number now. - LD BC,11 ;(B)=sum register, (C)=max digit count. -DECODE1:LD A,(HL) - CP ' ' ;a space terminates the numeral. - JP Z,DECODE3 - INC HL - SUB '0' ;make binary from ascii. - CP 10 ;legal digit? - JP NC,SYNERR - LD D,A ;yes, save it in (D). - LD A,B ;compute (B)=(B)*10 and check for overflow. - AND 0E0H - JP NZ,SYNERR - LD A,B - RLCA - RLCA - RLCA ;(A)=(B)*8 - ADD A,B ;.......*9 - JP C,SYNERR - ADD A,B ;.......*10 - JP C,SYNERR - ADD A,D ;add in new digit now. -DECODE2:JP C,SYNERR - LD B,A ;and save result. - DEC C ;only look at 11 digits. - JP NZ,DECODE1 - RET -DECODE3:LD A,(HL) ;spaces must follow (why?). - CP ' ' - JP NZ,SYNERR - INC HL -DECODE4:DEC C - JP NZ,DECODE3 - LD A,B ;set (A)=the numeric value entered. - RET -; -; Move 3 bytes from (HL) to (DE). Note that there is only -; one reference to this at (A2D5h). -; -MOVE3: LD B,3 -; -; Move (B) bytes from (HL) to (DE). -; -HL2DE: LD A,(HL) - LD (DE),A - INC HL - INC DE - DEC B - JP NZ,HL2DE - RET -; -; Compute (HL)=(TBUFF)+(A)+(C) and get the byte that's here. -; -EXTRACT:LD HL,TBUFF - ADD A,C - CALL ADDHL - LD A,(HL) - RET -; -; Check drive specified. If it means a change, then the new -; drive will be selected. In any case, the drive byte of the -; fcb will be set to null (means use current drive). -; -DSELECT:XOR A ;null out first byte of fcb. - LD (FCB),A - LD A,(CHGDRV) ;a drive change indicated? - OR A - RET Z - DEC A ;yes, is it the same as the current drive? - LD HL,CDRIVE - CP (HL) - RET Z - JP DSKSEL ;no. Select it then. -; -; Check the drive selection and reset it to the previous -; drive if it was changed for the preceeding command. -; -RESETDR:LD A,(CHGDRV) ;drive change indicated? - OR A - RET Z - DEC A ;yes, was it a different drive? - LD HL,CDRIVE - CP (HL) - RET Z - LD A,(CDRIVE) ;yes, re-select our old drive. - JP DSKSEL -; -;************************************************************** -;* -;* D I R E C T O R Y C O M M A N D -;* -;************************************************************** -; -DIRECT: CALL CONVFST ;convert file name. - CALL DSELECT ;select indicated drive. - LD HL,FCB+1 ;was any file indicated? - LD A,(HL) - CP ' ' - JP NZ,DIRECT2 - LD B,11 ;no. Fill field with '?' - same as *.*. -DIRECT1:LD (HL),'?' - INC HL - DEC B - JP NZ,DIRECT1 -DIRECT2:LD E,0 ;set initial cursor position. - PUSH DE - CALL SRCHFCB ;get first file name. - CALL Z,NONE ;none found at all? -DIRECT3:JP Z,DIRECT9 ;terminate if no more names. - LD A,(RTNCODE) ;get file's position in segment (0-3). - RRCA - RRCA - RRCA - AND 60H ;(A)=position*32 - LD C,A - LD A,10 - CALL EXTRACT ;extract the tenth entry in fcb. - RLA ;check system file status bit. - JP C,DIRECT8 ;we don't list them. - POP DE - LD A,E ;bump name count. - INC E - PUSH DE - IF BUILD_80C = 1 - AND 03H ;at end of line? - ELSE - AND 01H ;at end of line? - ENDIF - PUSH AF - JP NZ,DIRECT4 - CALL CRLF ;yes, end this line and start another. - PUSH BC - CALL GETDSK ;start line with ('A:'). - POP BC - ADD A,'A' - CALL PRINTB - LD A,':' - CALL PRINTB - JP DIRECT5 -DIRECT4:CALL PRTSPACE ;add seperator between file names. - LD A,':' - CALL PRINTB -DIRECT5:CALL PRTSPACE - LD B,1 ;'extract' each file name character at a time. -DIRECT6:LD A,B - CALL EXTRACT - AND 7FH ;strip bit 7 (status bit). - CP ' ' ;are we at the end of the name? - JP NZ,DRECT65 - POP AF ;yes, don't print spaces at the end of a line. - PUSH AF - CP 3 - JP NZ,DRECT63 - LD A,9 ;first check for no extension. - CALL EXTRACT - AND 7FH - CP ' ' - JP Z,DIRECT7 ;don't print spaces. -DRECT63:LD A,' ' ;else print them. -DRECT65:CALL PRINTB - INC B ;bump to next character psoition. - LD A,B - CP 12 ;end of the name? - JP NC,DIRECT7 - CP 9 ;nope, starting extension? - JP NZ,DIRECT6 - CALL PRTSPACE ;yes, add seperating space. - JP DIRECT6 -DIRECT7:POP AF ;get the next file name. -DIRECT8:CALL CHKCON ;first check console, quit on anything. - JP NZ,DIRECT9 - CALL SRCHNXT ;get next name. - JP DIRECT3 ;and continue with our list. -DIRECT9:POP DE ;restore the stack and return to command level. - JP GETBACK -; -;************************************************************** -;* -;* E R A S E C O M M A N D -;* -;************************************************************** -; -ERASE: CALL CONVFST ;convert file name. - CP 11 ;was '*.*' entered? - JP NZ,ERASE1 - LD BC,YESNO ;yes, ask for confirmation. - CALL PLINE - CALL GETINP - LD HL,INBUFF+1 - DEC (HL) ;must be exactly 'y'. - JP NZ,CMMND1 - INC HL - LD A,(HL) - CP 'Y' - JP NZ,CMMND1 - INC HL - LD (INPOINT),HL ;save input line pointer. -ERASE1: CALL DSELECT ;select desired disk. - LD DE,FCB - CALL DELETEFILE ;delete the file. - INC A - CALL Z,NONE ;not there? - JP GETBACK ;return to command level now. -YESNO: DB "All (y/n)?" - DB 0 -; -;************************************************************** -;* -;* T Y P E C O M M A N D -;* -;************************************************************** -; -TYPE: CALL CONVFST ;convert file name. - JP NZ,SYNERR ;wild cards not allowed. - CALL DSELECT ;select indicated drive. - CALL OPENFCB ;open the file. - JP Z,TYPE5 ;not there? - CALL CRLF ;ok, start a new line on the screen. - LD HL,NBYTES ;initialize byte counter. - LD (HL),0FFH ;set to read first sector. -TYPE1: LD HL,NBYTES -TYPE2: LD A,(HL) ;have we written the entire sector? - CP 128 - JP C,TYPE3 - PUSH HL ;yes, read in the next one. - CALL READFCB - POP HL - JP NZ,TYPE4 ;end or error? - XOR A ;ok, clear byte counter. - LD (HL),A -TYPE3: INC (HL) ;count this byte. - LD HL,TBUFF ;and get the (A)th one from the buffer (TBUFF). - CALL ADDHL - LD A,(HL) - CP CNTRLZ ;end of file mark? - JP Z,GETBACK - CALL PRINT ;no, print it. - CALL CHKCON ;check console, quit if anything ready. - JP NZ,GETBACK - JP TYPE1 -; -; Get here on an end of file or read error. -; -TYPE4: DEC A ;read error? - JP Z,GETBACK - CALL RDERROR ;yes, print message. -TYPE5: CALL RESETDR ;and reset proper drive - JP SYNERR ;now print file name with problem. -; -;************************************************************** -;* -;* S A V E C O M M A N D -;* -;************************************************************** -; -SAVE: CALL DECODE ;get numeric number that follows SAVE. - PUSH AF ;save number of pages to write. - CALL CONVFST ;convert file name. - JP NZ,SYNERR ;wild cards not allowed. - CALL DSELECT ;select specified drive. - LD DE,FCB ;now delete this file. - PUSH DE - CALL DELETEFILE - POP DE - CALL CREATE ;and create it again. - JP Z,SAVE3 ;can't create? - XOR A ;clear record number byte. - LD (FCB+32),A - POP AF ;convert pages to sectors. - LD L,A - LD H,0 - ADD HL,HL ;(HL)=number of sectors to write. - LD DE,TBASE ;and we start from here. -SAVE1: LD A,H ;done yet? - OR L - JP Z,SAVE2 - DEC HL ;nope, count this and compute the start - PUSH HL ;of the next 128 byte sector. - LD HL,128 - ADD HL,DE - PUSH HL ;save it and set the transfer address. - CALL DMASET - LD DE,FCB ;write out this sector now. - CALL WRTREC - POP DE ;reset (DE) to the start of the last sector. - POP HL ;restore sector count. - JP NZ,SAVE3 ;write error? - JP SAVE1 -; -; Get here after writing all of the file. -; -SAVE2: LD DE,FCB ;now close the file. - CALL CLOSE - INC A ;did it close ok? - JP NZ,SAVE4 -; -; Print out error message (no space). -; -SAVE3: LD BC,NOSPACE - CALL PLINE -SAVE4: CALL STDDMA ;reset the standard dma address. - JP GETBACK -NOSPACE:DB "No space" - DB 0 -; -;************************************************************** -;* -;* R E N A M E C O M M A N D -;* -;************************************************************** -; -RENAME: CALL CONVFST ;convert first file name. - JP NZ,SYNERR ;wild cards not allowed. - LD A,(CHGDRV) ;remember any change in drives specified. - PUSH AF - CALL DSELECT ;and select this drive. - CALL SRCHFCB ;is this file present? - JP NZ,RENAME6 ;yes, print error message. - LD HL,FCB ;yes, move this name into second slot. - LD DE,FCB+16 - LD B,16 - CALL HL2DE - LD HL,(INPOINT) ;get input pointer. - EX DE,HL - CALL NONBLANK ;get next non blank character. - CP '=' ;only allow an '=' or '_' seperator. - JP Z,RENAME1 - CP '_' - JP NZ,RENAME5 -RENAME1:EX DE,HL - INC HL ;ok, skip seperator. - LD (INPOINT),HL ;save input line pointer. - CALL CONVFST ;convert this second file name now. - JP NZ,RENAME5 ;again, no wild cards. - POP AF ;if a drive was specified, then it - LD B,A ;must be the same as before. - LD HL,CHGDRV - LD A,(HL) - OR A - JP Z,RENAME2 - CP B - LD (HL),B - JP NZ,RENAME5 ;they were different, error. -RENAME2:LD (HL),B ; reset as per the first file specification. - XOR A - LD (FCB),A ;clear the drive byte of the fcb. -RENAME3:CALL SRCHFCB ;and go look for second file. - JP Z,RENAME4 ;doesn't exist? - LD DE,FCB - CALL RENAM ;ok, rename the file. - JP GETBACK -; -; Process rename errors here. -; -RENAME4:CALL NONE ;file not there. - JP GETBACK -RENAME5:CALL RESETDR ;bad command format. - JP SYNERR -RENAME6:LD BC,EXISTS ;destination file already exists. - CALL PLINE - JP GETBACK -EXISTS: DB "File exists" - DB 0 -; -;************************************************************** -;* -;* U S E R C O M M A N D -;* -;************************************************************** -; -USER: CALL DECODE ;get numeric value following command. - CP 16 ;legal user number? - JP NC,SYNERR - LD E,A ;yes but is there anything else? - LD A,(FCB+1) - CP ' ' - JP Z,SYNERR ;yes, that is not allowed. - CALL GETSETUC ;ok, set user code. - JP GETBACK1 -; -;************************************************************** -;* -;* T R A N S I A N T P R O G R A M C O M M A N D -;* -;************************************************************** -; -UNKNOWN:CALL VERIFY ;check for valid system (why?). - LD A,(FCB+1) ;anything to execute? - CP ' ' - JP NZ,UNKWN1 - LD A,(CHGDRV) ;nope, only a drive change? - OR A - JP Z,GETBACK1 ;neither??? - DEC A - LD (CDRIVE),A ;ok, store new drive. - CALL MOVECD ;set (TDRIVE) also. - CALL DSKSEL ;and select this drive. - JP GETBACK1 ;then return. -; -; Here a file name was typed. Prepare to execute it. -; -UNKWN1: LD DE,FCB+9 ;an extension specified? - LD A,(DE) - CP ' ' - JP NZ,SYNERR ;yes, not allowed. -UNKWN2: PUSH DE - CALL DSELECT ;select specified drive. - POP DE - LD HL,COMFILE ;set the extension to 'COM'. - CALL MOVE3 - CALL OPENFCB ;and open this file. - JP Z,UNKWN9 ;not present? -; -; Load in the program. -; - LD HL,TBASE ;store the program starting here. -UNKWN3: PUSH HL - EX DE,HL - CALL DMASET ;set transfer address. - LD DE,FCB ;and read the next record. - CALL RDREC - JP NZ,UNKWN4 ;end of file or read error? - POP HL ;nope, bump pointer for next sector. - LD DE,128 - ADD HL,DE - LD DE,CBASE ;enough room for the whole file? - LD A,L - SUB E - LD A,H - SBC A,D - JP NC,UNKWN0 ;no, it can't fit. - JP UNKWN3 -; -; Get here after finished reading. -; -UNKWN4: POP HL - DEC A ;normal end of file? - JP NZ,UNKWN0 - CALL RESETDR ;yes, reset previous drive. - CALL CONVFST ;convert the first file name that follows - LD HL,CHGDRV ;command name. - PUSH HL - LD A,(HL) ;set drive code in default fcb. - LD (FCB),A - LD A,16 ;put second name 16 bytes later. - CALL CONVERT ;convert second file name. - POP HL - LD A,(HL) ;and set the drive for this second file. - LD (FCB+16),A - XOR A ;clear record byte in fcb. - LD (FCB+32),A - LD DE,TFCB ;move it into place at(005Ch). - LD HL,FCB - LD B,33 - CALL HL2DE - LD HL,INBUFF+2 ;now move the remainder of the input -UNKWN5: LD A,(HL) ;line down to (0080h). Look for a non blank. - OR A ;or a null. - JP Z,UNKWN6 - CP ' ' - JP Z,UNKWN6 - INC HL - JP UNKWN5 -; -; Do the line move now. It ends in a null byte. -; -UNKWN6: LD B,0 ;keep a character count. - LD DE,TBUFF+1 ;data gets put here. -UNKWN7: LD A,(HL) ;move it now. - LD (DE),A - OR A - JP Z,UNKWN8 - INC B - INC HL - INC DE - JP UNKWN7 -UNKWN8: LD A,B ;now store the character count. - LD (TBUFF),A - CALL CRLF ;clean up the screen. - CALL STDDMA ;set standard transfer address. - CALL SETCDRV ;reset current drive. - CALL TBASE ;and execute the program. -; -; Transiant programs return here (or reboot). -; - LD SP,BATCH ;set stack first off. - CALL MOVECD ;move current drive into place (TDRIVE). - CALL DSKSEL ;and reselect it. - JP CMMND1 ;back to comand mode. -; -; Get here if some error occured. -; -UNKWN9: CALL RESETDR ;inproper format. - JP SYNERR -UNKWN0: LD BC,BADLOAD ;read error or won't fit. - CALL PLINE - JP GETBACK -BADLOAD:DB "Bad load" - DB 0 -COMFILE:DB "COM" ;command file extension. -; -; Get here to return to command level. We will reset the -; previous active drive and then either return to command -; level directly or print error message and then return. -; -GETBACK:CALL RESETDR ;reset previous drive. -GETBACK1: CALL CONVFST ;convert first name in (FCB). - LD A,(FCB+1) ;if this was just a drive change request, - SUB ' ' ;make sure it was valid. - LD HL,CHGDRV - OR (HL) - JP NZ,SYNERR - JP CMMND1 ;ok, return to command level. -; -; ccp stack area. -; - DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -CCPSTACK EQU $ ;end of ccp stack area. -; -; Batch (or SUBMIT) processing information storage. -; -BATCH: DB 0 ;batch mode flag (0=not active). -BATCHFCB: DB 0 - DB "$$$ SUB" - DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -; -; File control block setup by the CCP. -; -FCB: DB 0 - DB " " - DB 0,0,0,0,0 - DB " " - DB 0,0,0,0,0 -RTNCODE:DB 0 ;status returned from bdos call. -CDRIVE: DB 0 ;currently active drive. -CHGDRV: DB 0 ;change in drives flag (0=no change). -NBYTES: DW 0 ;byte counter used by TYPE. -; -; Room for expansion? -; - DB 0,0,0,0,0,0,0,0,0,0,0,0,0 -; -; Note that the following six bytes must match those at -; (PATTRN1) or cp/m will HALT. Why? -; -PATTRN2:DB 0,22,0,0,0,0 ;(* serial number bytes *). -; -;************************************************************** -;* -;* B D O S E N T R Y -;* -;************************************************************** -; -FBASE: JP FBASE1 -; -; Bdos error table. -; -BADSCTR:DW ERROR1 ;bad sector on read or write. -BADSLCT:DW ERROR2 ;bad disk select. -RODISK: DW ERROR3 ;disk is read only. -ROFILE: DW ERROR4 ;file is read only. -; -; Entry into bdos. (DE) or (E) are the parameters passed. The -; function number desired is in register (C). -; -FBASE1: - EX DE,HL ;save the (DE) parameters. - LD (PARAMS),HL - EX DE,HL - LD A,E ;and save register (E) in particular. - LD (EPARAM),A - LD HL,0 - LD (STATUS),HL ;clear return status. - ADD HL,SP - LD (USRSTACK),HL ;save users stack pointer. - LD SP,STKAREA ;and set our own. - XOR A ;clear auto select storage space. - LD (AUTOFLAG),A - LD (AUTO),A - LD HL,GOBACK ;set return address. - PUSH HL - LD A,C ;get function number. - CP NFUNCTS ;valid function number? - RET NC - LD C,E ;keep single register function here. - LD HL,FUNCTNS ;now look thru the function table. - LD E,A - LD D,0 ;(DE)=function number. - ADD HL,DE - ADD HL,DE ;(HL)=(start of table)+2*(function number). - LD E,(HL) - INC HL - LD D,(HL) ;now (DE)=address for this function. - LD HL,(PARAMS) ;retrieve parameters. - EX DE,HL ;now (DE) has the original parameters. - JP (HL) ;execute desired function. -; -; BDOS function jump table. -; -NFUNCTS EQU 41 ;number of functions in followin table. -; -FUNCTNS:DW WBOOT,GETCON,OUTCON,GETRDR,PUNCH,LIST,DIRCIO,GETIOB - DW SETIOB,PRTSTR,RDBUFF,GETCSTS,GETVER,RSTDSK,SETDSK,OPENFIL - DW CLOSEFIL,GETFST,GETNXT,DELFILE,READSEQ,WRTSEQ,FCREATE - DW RENFILE,GETLOG,GETCRNT,PUTDMA,GETALOC,WRTPRTD,GETROV,SETATTR - DW GETPARM,GETUSER,RDRANDOM,WTRANDOM,FILESIZE,SETRAN,LOGOFF,RTN - DW RTN,WTSPECL -; -; Bdos error message section. -; -ERROR1: LD HL,BADSEC ;bad sector message. - CALL PRTERR ;print it and get a 1 char responce. - CP CNTRLC ;re-boot request (control-c)? - JP Z,0 ;yes. - RET ;no, return to retry i/o function. -; -ERROR2: LD HL,BADSEL ;bad drive selected. - JP ERROR5 -; -ERROR3: LD HL,DISKRO ;disk is read only. - JP ERROR5 -; -ERROR4: LD HL,FILERO ;file is read only. -; -ERROR5: CALL PRTERR - JP 0 ;always reboot on these errors. -; -BDOSERR:DB "Bdos Err On " -BDOSDRV:DB " : $" -BADSEC: DB "Bad Sector$" -BADSEL: DB "Select$" -FILERO: DB "File " -DISKRO: DB "R/O$" -; -; Print bdos error message. -; -PRTERR: PUSH HL ;save second message pointer. - CALL OUTCRLF ;send (cr)(lf). - LD A,(ACTIVE) ;get active drive. - ADD A,'A' ;make ascii. - LD (BDOSDRV),A ;and put in message. - LD BC,BDOSERR ;and print it. - CALL PRTMESG - POP BC ;print second message line now. - CALL PRTMESG -; -; Get an input character. We will check our 1 character -; buffer first. This may be set by the console status routine. -; -GETCHAR:LD HL,CHARBUF ;check character buffer. - LD A,(HL) ;anything present already? - LD (HL),0 ;...either case clear it. - OR A - RET NZ ;yes, use it. - JP CONIN ;nope, go get a character responce. -; -; Input and echo a character. -; -GETECHO:CALL GETCHAR ;input a character. - CALL CHKCHAR ;carriage control? - RET C ;no, a regular control char so don't echo. - PUSH AF ;ok, save character now. - LD C,A - CALL OUTCON ;and echo it. - POP AF ;get character and return. - RET -; -; Check character in (A). Set the zero flag on a carriage -; control character and the carry flag on any other control -; character. -; -CHKCHAR:CP CR ;check for carriage return, line feed, backspace, - RET Z ;or a tab. - CP LF - RET Z - CP TAB - RET Z - CP BS - RET Z - CP ' ' ;other control char? Set carry flag. - RET -; -; Check the console during output. Halt on a control-s, then -; reboot on a control-c. If anything else is ready, clear the -; zero flag and return (the calling routine may want to do -; something). -; -CKCONSOL: LD A,(CHARBUF) ;check buffer. - OR A ;if anything, just return without checking. - JP NZ,CKCON2 - CALL CONST ;nothing in buffer. Check console. - AND 01H ;look at bit 0. - RET Z ;return if nothing. - CALL CONIN ;ok, get it. - CP CNTRLS ;if not control-s, return with zero cleared. - JP NZ,CKCON1 - CALL CONIN ;halt processing until another char - CP CNTRLC ;is typed. Control-c? - JP Z,0 ;yes, reboot now. - XOR A ;no, just pretend nothing was ever ready. - RET -CKCON1: LD (CHARBUF),A ;save character in buffer for later processing. -CKCON2: LD A,1 ;set (A) to non zero to mean something is ready. - RET -; -; Output (C) to the screen. If the printer flip-flop flag -; is set, we will send character to printer also. The console -; will be checked in the process. -; -OUTCHAR:LD A,(OUTFLAG) ;check output flag. - OR A ;anything and we won't generate output. - JP NZ,OUTCHR1 - PUSH BC - CALL CKCONSOL ;check console (we don't care whats there). - POP BC - PUSH BC - CALL CONOUT ;output (C) to the screen. - POP BC - PUSH BC - LD A,(PRTFLAG) ;check printer flip-flop flag. - OR A - CALL NZ,LIST ;print it also if non-zero. - POP BC -OUTCHR1:LD A,C ;update cursors position. - LD HL,CURPOS - CP DEL ;rubouts don't do anything here. - RET Z - INC (HL) ;bump line pointer. - CP ' ' ;and return if a normal character. - RET NC - DEC (HL) ;restore and check for the start of the line. - LD A,(HL) - OR A - RET Z ;ingnore control characters at the start of the line. - LD A,C - CP BS ;is it a backspace? - JP NZ,OUTCHR2 - DEC (HL) ;yes, backup pointer. - RET -OUTCHR2:CP LF ;is it a line feed? - RET NZ ;ignore anything else. - LD (HL),0 ;reset pointer to start of line. - RET -; -; Output (A) to the screen. If it is a control character -; (other than carriage control), use ^x format. -; -SHOWIT: LD A,C - CALL CHKCHAR ;check character. - JP NC,OUTCON ;not a control, use normal output. - PUSH AF - LD C,'^' ;for a control character, preceed it with '^'. - CALL OUTCHAR - POP AF - OR '@' ;and then use the letter equivelant. - LD C,A -; -; Function to output (C) to the console device and expand tabs -; if necessary. -; -OUTCON: LD A,C - CP TAB ;is it a tab? - JP NZ,OUTCHAR ;use regular output. -OUTCON1:LD C,' ' ;yes it is, use spaces instead. - CALL OUTCHAR - LD A,(CURPOS) ;go until the cursor is at a multiple of 8 - - AND 07H ;position. - JP NZ,OUTCON1 - RET -; -; Echo a backspace character. Erase the prevoius character -; on the screen. -; -BACKUP: CALL BACKUP1 ;backup the screen 1 place. - LD C,' ' ;then blank that character. - CALL CONOUT -BACKUP1:LD C,BS ;then back space once more. - JP CONOUT -; -; Signal a deleted line. Print a '#' at the end and start -; over. -; -NEWLINE:LD C,'#' - CALL OUTCHAR ;print this. - CALL OUTCRLF ;start new line. -NEWLN1: LD A,(CURPOS) ;move the cursor to the starting position. - LD HL,STARTING - CP (HL) - RET NC ;there yet? - LD C,' ' - CALL OUTCHAR ;nope, keep going. - JP NEWLN1 -; -; Output a (cr) (lf) to the console device (screen). -; -OUTCRLF:LD C,CR - CALL OUTCHAR - LD C,LF - JP OUTCHAR -; -; Print message pointed to by (BC). It will end with a '$'. -; -PRTMESG:LD A,(BC) ;check for terminating character. - CP '$' - RET Z - INC BC - PUSH BC ;otherwise, bump pointer and print it. - LD C,A - CALL OUTCON - POP BC - JP PRTMESG -; -; Function to execute a buffered read. -; -RDBUFF: LD A,(CURPOS) ;use present location as starting one. - LD (STARTING),A - LD HL,(PARAMS) ;get the maximum buffer space. - LD C,(HL) - INC HL ;point to first available space. - PUSH HL ;and save. - LD B,0 ;keep a character count. -RDBUF1: PUSH BC - PUSH HL -RDBUF2: CALL GETCHAR ;get the next input character. - AND 7FH ;strip bit 7. - POP HL ;reset registers. - POP BC - CP CR ;en of the line? - JP Z,RDBUF17 - CP LF - JP Z,RDBUF17 - CP BS ;how about a backspace? - JP NZ,RDBUF3 - LD A,B ;yes, but ignore at the beginning of the line. - OR A - JP Z,RDBUF1 - DEC B ;ok, update counter. - LD A,(CURPOS) ;if we backspace to the start of the line, - LD (OUTFLAG),A ;treat as a cancel (control-x). - JP RDBUF10 -RDBUF3: CP DEL ;user typed a rubout? - JP NZ,RDBUF4 - LD A,B ;ignore at the start of the line. - OR A - JP Z,RDBUF1 - LD A,(HL) ;ok, echo the prevoius character. - DEC B ;and reset pointers (counters). - DEC HL - JP RDBUF15 -RDBUF4: CP CNTRLE ;physical end of line? - JP NZ,RDBUF5 - PUSH BC ;yes, do it. - PUSH HL - CALL OUTCRLF - XOR A ;and update starting position. - LD (STARTING),A - JP RDBUF2 -RDBUF5: CP CNTRLP ;control-p? - JP NZ,RDBUF6 - PUSH HL ;yes, flip the print flag filp-flop byte. - LD HL,PRTFLAG - LD A,1 ;PRTFLAG=1-PRTFLAG - SUB (HL) - LD (HL),A - POP HL - JP RDBUF1 -RDBUF6: CP CNTRLX ;control-x (cancel)? - JP NZ,RDBUF8 - POP HL -RDBUF7: LD A,(STARTING) ;yes, backup the cursor to here. - LD HL,CURPOS - CP (HL) - JP NC,RDBUFF ;done yet? - DEC (HL) ;no, decrement pointer and output back up one space. - CALL BACKUP - JP RDBUF7 -RDBUF8: CP CNTRLU ;cntrol-u (cancel line)? - JP NZ,RDBUF9 - CALL NEWLINE ;start a new line. - POP HL - JP RDBUFF -RDBUF9: CP CNTRLR ;control-r? - JP NZ,RDBUF14 -RDBUF10:PUSH BC ;yes, start a new line and retype the old one. - CALL NEWLINE - POP BC - POP HL - PUSH HL - PUSH BC -RDBUF11:LD A,B ;done whole line yet? - OR A - JP Z,RDBUF12 - INC HL ;nope, get next character. - LD C,(HL) - DEC B ;count it. - PUSH BC - PUSH HL - CALL SHOWIT ;and display it. - POP HL - POP BC - JP RDBUF11 -RDBUF12:PUSH HL ;done with line. If we were displaying - LD A,(OUTFLAG) ;then update cursor position. - OR A - JP Z,RDBUF2 - LD HL,CURPOS ;because this line is shorter, we must - SUB (HL) ;back up the cursor (not the screen however) - LD (OUTFLAG),A ;some number of positions. -RDBUF13:CALL BACKUP ;note that as long as (OUTFLAG) is non - LD HL,OUTFLAG ;zero, the screen will not be changed. - DEC (HL) - JP NZ,RDBUF13 - JP RDBUF2 ;now just get the next character. -; -; Just a normal character, put this in our buffer and echo. -; -RDBUF14:INC HL - LD (HL),A ;store character. - INC B ;and count it. -RDBUF15:PUSH BC - PUSH HL - LD C,A ;echo it now. - CALL SHOWIT - POP HL - POP BC - LD A,(HL) ;was it an abort request? - CP CNTRLC ;control-c abort? - LD A,B - JP NZ,RDBUF16 - CP 1 ;only if at start of line. - JP Z,0 -RDBUF16:CP C ;nope, have we filled the buffer? - JP C,RDBUF1 -RDBUF17:POP HL ;yes end the line and return. - LD (HL),B - LD C,CR - JP OUTCHAR ;output (cr) and return. -; -; Function to get a character from the console device. -; -GETCON: CALL GETECHO ;get and echo. - JP SETSTAT ;save status and return. -; -; Function to get a character from the tape reader device. -; -GETRDR: CALL READER ;get a character from reader, set status and return. - JP SETSTAT -; -; Function to perform direct console i/o. If (C) contains (FF) -; then this is an input request. If (C) contains (FE) then -; this is a status request. Otherwise we are to output (C). -; -DIRCIO: LD A,C ;test for (FF). - INC A - JP Z,DIRC1 - INC A ;test for (FE). - JP Z,CONST - JP CONOUT ;just output (C). -DIRC1: CALL CONST ;this is an input request. - OR A - JP Z,GOBACK1 ;not ready? Just return (directly). - CALL CONIN ;yes, get character. - JP SETSTAT ;set status and return. -; -; Function to return the i/o byte. -; -GETIOB: LD A,(IOBYTE) - JP SETSTAT -; -; Function to set the i/o byte. -; -SETIOB: LD HL,IOBYTE - LD (HL),C - RET -; -; Function to print the character string pointed to by (DE) -; on the console device. The string ends with a '$'. -; -PRTSTR: EX DE,HL - LD C,L - LD B,H ;now (BC) points to it. - JP PRTMESG -; -; Function to interigate the console device. -; -GETCSTS:CALL CKCONSOL -; -; Get here to set the status and return to the cleanup -; section. Then back to the user. -; -SETSTAT:LD (STATUS),A -RTN: RET -; -; Set the status to 1 (read or write error code). -; -IOERR1: LD A,1 - JP SETSTAT -; -OUTFLAG:DB 0 ;output flag (non zero means no output). -STARTING: DB 2 ;starting position for cursor. -CURPOS: DB 0 ;cursor position (0=start of line). -PRTFLAG:DB 0 ;printer flag (control-p toggle). List if non zero. -CHARBUF:DB 0 ;single input character buffer. -; -; Stack area for BDOS calls. -; -USRSTACK: DW 0 ;save users stack pointer here. -; - DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -STKAREA EQU $ ;end of stack area. -; -USERNO: DB 0 ;current user number. -ACTIVE: DB 0 ;currently active drive. -PARAMS: DW 0 ;save (DE) parameters here on entry. -STATUS: DW 0 ;status returned from bdos function. -; -; Select error occured, jump to error routine. -; -SLCTERR:LD HL,BADSLCT -; -; Jump to (HL) indirectly. -; -JUMPHL: LD E,(HL) - INC HL - LD D,(HL) ;now (DE) contain the desired address. - EX DE,HL - JP (HL) -; -; Block move. (DE) to (HL), (C) bytes total. -; -DE2HL: INC C ;is count down to zero? -DE2HL1: DEC C - RET Z ;yes, we are done. - LD A,(DE) ;no, move one more byte. - LD (HL),A - INC DE - INC HL - JP DE2HL1 ;and repeat. -; -; Select the desired drive. -; -SELECT: LD A,(ACTIVE) ;get active disk. - LD C,A - CALL SELDSK ;select it. - LD A,H ;valid drive? - OR L ;valid drive? - RET Z ;return if not. -; -; Here, the BIOS returned the address of the parameter block -; in (HL). We will extract the necessary pointers and save them. -; - LD E,(HL) ;yes, get address of translation table into (DE). - INC HL - LD D,(HL) - INC HL - LD (SCRATCH1),HL ;save pointers to scratch areas. - INC HL - INC HL - LD (SCRATCH2),HL ;ditto. - INC HL - INC HL - LD (SCRATCH3),HL ;ditto. - INC HL - INC HL - EX DE,HL ;now save the translation table address. - LD (XLATE),HL - LD HL,DIRBUF ;put the next 8 bytes here. - LD C,8 ;they consist of the directory buffer - CALL DE2HL ;pointer, parameter block pointer, - LD HL,(DISKPB) ;check and allocation vectors. - EX DE,HL - LD HL,SECTORS ;move parameter block into our ram. - LD C,15 ;it is 15 bytes long. - CALL DE2HL - LD HL,(DSKSIZE) ;check disk size. - LD A,H ;more than 256 blocks on this? - LD HL,BIGDISK - LD (HL),0FFH ;set to samll. - OR A - JP Z,SELECT1 - LD (HL),0 ;wrong, set to large. -SELECT1:LD A,0FFH ;clear the zero flag. - OR A - RET -; -; Routine to home the disk track head and clear pointers. -; -HOMEDRV:CALL HOME ;home the head. - XOR A - LD HL,(SCRATCH2) ;set our track pointer also. - LD (HL),A - INC HL - LD (HL),A - LD HL,(SCRATCH3) ;and our sector pointer. - LD (HL),A - INC HL - LD (HL),A - RET -; -; Do the actual disk read and check the error return status. -; -DOREAD: CALL READ - JP IORET -; -; Do the actual disk write and handle any bios error. -; -DOWRITE:CALL WRITE -IORET: OR A - RET Z ;return unless an error occured. - LD HL,BADSCTR ;bad read/write on this sector. - JP JUMPHL -; -; Routine to select the track and sector that the desired -; block number falls in. -; -TRKSEC: LD HL,(FILEPOS) ;get position of last accessed file - LD C,2 ;in directory and compute sector #. - CALL SHIFTR ;sector #=file-position/4. - LD (BLKNMBR),HL ;save this as the block number of interest. - LD (CKSUMTBL),HL ;what's it doing here too? -; -; if the sector number has already been set (BLKNMBR), enter -; at this point. -; -TRKSEC1:LD HL,BLKNMBR - LD C,(HL) ;move sector number into (BC). - INC HL - LD B,(HL) - LD HL,(SCRATCH3) ;get current sector number and - LD E,(HL) ;move this into (DE). - INC HL - LD D,(HL) - LD HL,(SCRATCH2) ;get current track number. - LD A,(HL) ;and this into (HL). - INC HL - LD H,(HL) - LD L,A -TRKSEC2:LD A,C ;is desired sector before current one? - SUB E - LD A,B - SBC A,D - JP NC,TRKSEC3 - PUSH HL ;yes, decrement sectors by one track. - LD HL,(SECTORS) ;get sectors per track. - LD A,E - SUB L - LD E,A - LD A,D - SBC A,H - LD D,A ;now we have backed up one full track. - POP HL - DEC HL ;adjust track counter. - JP TRKSEC2 -TRKSEC3:PUSH HL ;desired sector is after current one. - LD HL,(SECTORS) ;get sectors per track. - ADD HL,DE ;bump sector pointer to next track. - JP C,TRKSEC4 - LD A,C ;is desired sector now before current one? - SUB L - LD A,B - SBC A,H - JP C,TRKSEC4 - EX DE,HL ;not yes, increment track counter - POP HL ;and continue until it is. - INC HL - JP TRKSEC3 -; -; here we have determined the track number that contains the -; desired sector. -; -TRKSEC4:POP HL ;get track number (HL). - PUSH BC - PUSH DE - PUSH HL - EX DE,HL - LD HL,(OFFSET) ;adjust for first track offset. - ADD HL,DE - LD B,H - LD C,L - CALL SETTRK ;select this track. - POP DE ;reset current track pointer. - LD HL,(SCRATCH2) - LD (HL),E - INC HL - LD (HL),D - POP DE - LD HL,(SCRATCH3) ;reset the first sector on this track. - LD (HL),E - INC HL - LD (HL),D - POP BC - LD A,C ;now subtract the desired one. - SUB E ;to make it relative (1-# sectors/track). - LD C,A - LD A,B - SBC A,D - LD B,A - LD HL,(XLATE) ;translate this sector according to this table. - EX DE,HL - CALL SECTRN ;let the bios translate it. - LD C,L - LD B,H - JP SETSEC ;and select it. -; -; Compute block number from record number (SAVNREC) and -; extent number (SAVEXT). -; -GETBLOCK: LD HL,BLKSHFT ;get logical to physical conversion. - LD C,(HL) ;note that this is base 2 log of ratio. - LD A,(SAVNREC) ;get record number. -GETBLK1:OR A ;compute (A)=(A)/2^BLKSHFT. - RRA - DEC C - JP NZ,GETBLK1 - LD B,A ;save result in (B). - LD A,8 - SUB (HL) - LD C,A ;compute (C)=8-BLKSHFT. - LD A,(SAVEXT) -GETBLK2:DEC C ;compute (A)=SAVEXT*2^(8-BLKSHFT). - JP Z,GETBLK3 - OR A - RLA - JP GETBLK2 -GETBLK3:ADD A,B - RET -; -; Routine to extract the (BC) block byte from the fcb pointed -; to by (PARAMS). If this is a big-disk, then these are 16 bit -; block numbers, else they are 8 bit numbers. -; Number is returned in (HL). -; -EXTBLK: LD HL,(PARAMS) ;get fcb address. - LD DE,16 ;block numbers start 16 bytes into fcb. - ADD HL,DE - ADD HL,BC - LD A,(BIGDISK) ;are we using a big-disk? - OR A - JP Z,EXTBLK1 - LD L,(HL) ;no, extract an 8 bit number from the fcb. - LD H,0 - RET -EXTBLK1:ADD HL,BC ;yes, extract a 16 bit number. - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL ;return in (HL). - RET -; -; Compute block number. -; -COMBLK: CALL GETBLOCK - LD C,A - LD B,0 - CALL EXTBLK - LD (BLKNMBR),HL - RET -; -; Check for a zero block number (unused). -; -CHKBLK: LD HL,(BLKNMBR) - LD A,L ;is it zero? - OR H - RET -; -; Adjust physical block (BLKNMBR) and convert to logical -; sector (LOGSECT). This is the starting sector of this block. -; The actual sector of interest is then added to this and the -; resulting sector number is stored back in (BLKNMBR). This -; will still have to be adjusted for the track number. -; -LOGICAL:LD A,(BLKSHFT) ;get log2(physical/logical sectors). - LD HL,(BLKNMBR) ;get physical sector desired. -LOGICL1:ADD HL,HL ;compute logical sector number. - DEC A ;note logical sectors are 128 bytes long. - JP NZ,LOGICL1 - LD (LOGSECT),HL ;save logical sector. - LD A,(BLKMASK) ;get block mask. - LD C,A - LD A,(SAVNREC) ;get next sector to access. - AND C ;extract the relative position within physical block. - OR L ;and add it too logical sector. - LD L,A - LD (BLKNMBR),HL ;and store. - RET -; -; Set (HL) to point to extent byte in fcb. -; -SETEXT: LD HL,(PARAMS) - LD DE,12 ;it is the twelth byte. - ADD HL,DE - RET -; -; Set (HL) to point to record count byte in fcb and (DE) to -; next record number byte. -; -SETHLDE:LD HL,(PARAMS) - LD DE,15 ;record count byte (#15). - ADD HL,DE - EX DE,HL - LD HL,17 ;next record number (#32). - ADD HL,DE - RET -; -; Save current file data from fcb. -; -STRDATA:CALL SETHLDE - LD A,(HL) ;get and store record count byte. - LD (SAVNREC),A - EX DE,HL - LD A,(HL) ;get and store next record number byte. - LD (SAVNXT),A - CALL SETEXT ;point to extent byte. - LD A,(EXTMASK) ;get extent mask. - AND (HL) - LD (SAVEXT),A ;and save extent here. - RET -; -; Set the next record to access. If (MODE) is set to 2, then -; the last record byte (SAVNREC) has the correct number to access. -; For sequential access, (MODE) will be equal to 1. -; -SETNREC:CALL SETHLDE - LD A,(MODE) ;get sequential flag (=1). - CP 2 ;a 2 indicates that no adder is needed. - JP NZ,STNREC1 - XOR A ;clear adder (random access?). -STNREC1:LD C,A - LD A,(SAVNREC) ;get last record number. - ADD A,C ;increment record count. - LD (HL),A ;and set fcb's next record byte. - EX DE,HL - LD A,(SAVNXT) ;get next record byte from storage. - LD (HL),A ;and put this into fcb as number of records used. - RET -; -; Shift (HL) right (C) bits. -; -SHIFTR: INC C -SHIFTR1:DEC C - RET Z - LD A,H - OR A - RRA - LD H,A - LD A,L - RRA - LD L,A - JP SHIFTR1 -; -; Compute the check-sum for the directory buffer. Return -; integer sum in (A). -; -CHECKSUM: LD C,128 ;length of buffer. - LD HL,(DIRBUF) ;get its location. - XOR A ;clear summation byte. -CHKSUM1:ADD A,(HL) ;and compute sum ignoring carries. - INC HL - DEC C - JP NZ,CHKSUM1 - RET -; -; Shift (HL) left (C) bits. -; -SHIFTL: INC C -SHIFTL1:DEC C - RET Z - ADD HL,HL ;shift left 1 bit. - JP SHIFTL1 -; -; Routine to set a bit in a 16 bit value contained in (BC). -; The bit set depends on the current drive selection. -; -SETBIT: PUSH BC ;save 16 bit word. - LD A,(ACTIVE) ;get active drive. - LD C,A - LD HL,1 - CALL SHIFTL ;shift bit 0 into place. - POP BC ;now 'or' this with the original word. - LD A,C - OR L - LD L,A ;low byte done, do high byte. - LD A,B - OR H - LD H,A - RET -; -; Extract the write protect status bit for the current drive. -; The result is returned in (A), bit 0. -; -GETWPRT:LD HL,(WRTPRT) ;get status bytes. - LD A,(ACTIVE) ;which drive is current? - LD C,A - CALL SHIFTR ;shift status such that bit 0 is the - LD A,L ;one of interest for this drive. - AND 01H ;and isolate it. - RET -; -; Function to write protect the current disk. -; -WRTPRTD:LD HL,WRTPRT ;point to status word. - LD C,(HL) ;set (BC) equal to the status. - INC HL - LD B,(HL) - CALL SETBIT ;and set this bit according to current drive. - LD (WRTPRT),HL ;then save. - LD HL,(DIRSIZE) ;now save directory size limit. - INC HL ;remember the last one. - EX DE,HL - LD HL,(SCRATCH1) ;and store it here. - LD (HL),E ;put low byte. - INC HL - LD (HL),D ;then high byte. - RET -; -; Check for a read only file. -; -CHKROFL:CALL FCB2HL ;set (HL) to file entry in directory buffer. -CKROF1: LD DE,9 ;look at bit 7 of the ninth byte. - ADD HL,DE - LD A,(HL) - RLA - RET NC ;return if ok. - LD HL,ROFILE ;else, print error message and terminate. - JP JUMPHL -; -; Check the write protect status of the active disk. -; -CHKWPRT:CALL GETWPRT - RET Z ;return if ok. - LD HL,RODISK ;else print message and terminate. - JP JUMPHL -; -; Routine to set (HL) pointing to the proper entry in the -; directory buffer. -; -FCB2HL: LD HL,(DIRBUF) ;get address of buffer. - LD A,(FCBPOS) ;relative position of file. -; -; Routine to add (A) to (HL). -; -ADDA2HL:ADD A,L - LD L,A - RET NC - INC H ;take care of any carry. - RET -; -; Routine to get the 's2' byte from the fcb supplied in -; the initial parameter specification. -; -GETS2: LD HL,(PARAMS) ;get address of fcb. - LD DE,14 ;relative position of 's2'. - ADD HL,DE - LD A,(HL) ;extract this byte. - RET -; -; Clear the 's2' byte in the fcb. -; -CLEARS2:CALL GETS2 ;this sets (HL) pointing to it. - LD (HL),0 ;now clear it. - RET -; -; Set bit 7 in the 's2' byte of the fcb. -; -SETS2B7:CALL GETS2 ;get the byte. - OR 80H ;and set bit 7. - LD (HL),A ;then store. - RET -; -; Compare (FILEPOS) with (SCRATCH1) and set flags based on -; the difference. This checks to see if there are more file -; names in the directory. We are at (FILEPOS) and there are -; (SCRATCH1) of them to check. -; -MOREFLS:LD HL,(FILEPOS) ;we are here. - EX DE,HL - LD HL,(SCRATCH1) ;and don't go past here. - LD A,E ;compute difference but don't keep. - SUB (HL) - INC HL - LD A,D - SBC A,(HL) ;set carry if no more names. - RET -; -; Call this routine to prevent (SCRATCH1) from being greater -; than (FILEPOS). -; -CHKNMBR:CALL MOREFLS ;SCRATCH1 too big? - RET C - INC DE ;yes, reset it to (FILEPOS). - LD (HL),D - DEC HL - LD (HL),E - RET -; -; Compute (HL)=(DE)-(HL) -; -SUBHL: LD A,E ;compute difference. - SUB L - LD L,A ;store low byte. - LD A,D - SBC A,H - LD H,A ;and then high byte. - RET -; -; Set the directory checksum byte. -; -SETDIR: LD C,0FFH -; -; Routine to set or compare the directory checksum byte. If -; (C)=0ffh, then this will set the checksum byte. Else the byte -; will be checked. If the check fails (the disk has been changed), -; then this disk will be write protected. -; -CHECKDIR: LD HL,(CKSUMTBL) - EX DE,HL - LD HL,(ALLOC1) - CALL SUBHL - RET NC ;ok if (CKSUMTBL) > (ALLOC1), so return. - PUSH BC - CALL CHECKSUM ;else compute checksum. - LD HL,(CHKVECT) ;get address of checksum table. - EX DE,HL - LD HL,(CKSUMTBL) - ADD HL,DE ;set (HL) to point to byte for this drive. - POP BC - INC C ;set or check ? - JP Z,CHKDIR1 - CP (HL) ;check them. - RET Z ;return if they are the same. - CALL MOREFLS ;not the same, do we care? - RET NC - CALL WRTPRTD ;yes, mark this as write protected. - RET -CHKDIR1:LD (HL),A ;just set the byte. - RET -; -; Do a write to the directory of the current disk. -; -DIRWRITE: CALL SETDIR ;set checksum byte. - CALL DIRDMA ;set directory dma address. - LD C,1 ;tell the bios to actually write. - CALL DOWRITE ;then do the write. - JP DEFDMA -; -; Read from the directory. -; -DIRREAD:CALL DIRDMA ;set the directory dma address. - CALL DOREAD ;and read it. -; -; Routine to set the dma address to the users choice. -; -DEFDMA: LD HL,USERDMA ;reset the default dma address and return. - JP DIRDMA1 -; -; Routine to set the dma address for directory work. -; -DIRDMA: LD HL,DIRBUF -; -; Set the dma address. On entry, (HL) points to -; word containing the desired dma address. -; -DIRDMA1:LD C,(HL) - INC HL - LD B,(HL) ;setup (BC) and go to the bios to set it. - JP SETDMA -; -; Move the directory buffer into user's dma space. -; -MOVEDIR:LD HL,(DIRBUF) ;buffer is located here, and - EX DE,HL - LD HL,(USERDMA) ; put it here. - LD C,128 ;this is its length. - JP DE2HL ;move it now and return. -; -; Check (FILEPOS) and set the zero flag if it equals 0ffffh. -; -CKFILPOS: LD HL,FILEPOS - LD A,(HL) - INC HL - CP (HL) ;are both bytes the same? - RET NZ - INC A ;yes, but are they each 0ffh? - RET -; -; Set location (FILEPOS) to 0ffffh. -; -STFILPOS: LD HL,0FFFFH - LD (FILEPOS),HL - RET -; -; Move on to the next file position within the current -; directory buffer. If no more exist, set pointer to 0ffffh -; and the calling routine will check for this. Enter with (C) -; equal to 0ffh to cause the checksum byte to be set, else we -; will check this disk and set write protect if checksums are -; not the same (applies only if another directory sector must -; be read). -; -NXENTRY:LD HL,(DIRSIZE) ;get directory entry size limit. - EX DE,HL - LD HL,(FILEPOS) ;get current count. - INC HL ;go on to the next one. - LD (FILEPOS),HL - CALL SUBHL ;(HL)=(DIRSIZE)-(FILEPOS) - JP NC,NXENT1 ;is there more room left? - JP STFILPOS ;no. Set this flag and return. -NXENT1: LD A,(FILEPOS) ;get file position within directory. - AND 03H ;only look within this sector (only 4 entries fit). - LD B,5 ;convert to relative position (32 bytes each). -NXENT2: ADD A,A ;note that this is not efficient code. - DEC B ;5 'ADD A's would be better. - JP NZ,NXENT2 - LD (FCBPOS),A ;save it as position of fcb. - OR A - RET NZ ;return if we are within buffer. - PUSH BC - CALL TRKSEC ;we need the next directory sector. - CALL DIRREAD - POP BC - JP CHECKDIR -; -; Routine to to get a bit from the disk space allocation -; map. It is returned in (A), bit position 0. On entry to here, -; set (BC) to the block number on the disk to check. -; On return, (D) will contain the original bit position for -; this block number and (HL) will point to the address for it. -; -CKBITMAP: LD A,C ;determine bit number of interest. - AND 07H ;compute (D)=(E)=(C and 7)+1. - INC A - LD E,A ;save particular bit number. - LD D,A -; -; compute (BC)=(BC)/8. -; - LD A,C - RRCA ;now shift right 3 bits. - RRCA - RRCA - AND 1FH ;and clear bits 7,6,5. - LD C,A - LD A,B - ADD A,A ;now shift (B) into bits 7,6,5. - ADD A,A - ADD A,A - ADD A,A - ADD A,A - OR C ;and add in (C). - LD C,A ;ok, (C) ha been completed. - LD A,B ;is there a better way of doing this? - RRCA - RRCA - RRCA - AND 1FH - LD B,A ;and now (B) is completed. -; -; use this as an offset into the disk space allocation -; table. -; - LD HL,(ALOCVECT) - ADD HL,BC - LD A,(HL) ;now get correct byte. -CKBMAP1:RLCA ;get correct bit into position 0. - DEC E - JP NZ,CKBMAP1 - RET -; -; Set or clear the bit map such that block number (BC) will be marked -; as used. On entry, if (E)=0 then this bit will be cleared, if it equals -; 1 then it will be set (don't use anyother values). -; -STBITMAP: PUSH DE - CALL CKBITMAP ;get the byte of interest. - AND 0FEH ;clear the affected bit. - POP BC - OR C ;and now set it acording to (C). -; -; entry to restore the original bit position and then store -; in table. (A) contains the value, (D) contains the bit -; position (1-8), and (HL) points to the address within the -; space allocation table for this byte. -; -STBMAP1:RRCA ;restore original bit position. - DEC D - JP NZ,STBMAP1 - LD (HL),A ;and stor byte in table. - RET -; -; Set/clear space used bits in allocation map for this file. -; On entry, (C)=1 to set the map and (C)=0 to clear it. -; -SETFILE:CALL FCB2HL ;get address of fcb - LD DE,16 - ADD HL,DE ;get to block number bytes. - PUSH BC - LD C,17 ;check all 17 bytes (max) of table. -SETFL1: POP DE - DEC C ;done all bytes yet? - RET Z - PUSH DE - LD A,(BIGDISK) ;check disk size for 16 bit block numbers. - OR A - JP Z,SETFL2 - PUSH BC ;only 8 bit numbers. set (BC) to this one. - PUSH HL - LD C,(HL) ;get low byte from table, always - LD B,0 ;set high byte to zero. - JP SETFL3 -SETFL2: DEC C ;for 16 bit block numbers, adjust counter. - PUSH BC - LD C,(HL) ;now get both the low and high bytes. - INC HL - LD B,(HL) - PUSH HL -SETFL3: LD A,C ;block used? - OR B - JP Z,SETFL4 - LD HL,(DSKSIZE) ;is this block number within the - LD A,L ;space on the disk? - SUB C - LD A,H - SBC A,B - CALL NC,STBITMAP ;yes, set the proper bit. -SETFL4: POP HL ;point to next block number in fcb. - INC HL - POP BC - JP SETFL1 -; -; Construct the space used allocation bit map for the active -; drive. If a file name starts with '$' and it is under the -; current user number, then (STATUS) is set to minus 1. Otherwise -; it is not set at all. -; -BITMAP: LD HL,(DSKSIZE) ;compute size of allocation table. - LD C,3 - CALL SHIFTR ;(HL)=(HL)/8. - INC HL ;at lease 1 byte. - LD B,H - LD C,L ;set (BC) to the allocation table length. -; -; Initialize the bitmap for this drive. Right now, the first -; two bytes are specified by the disk parameter block. However -; a patch could be entered here if it were necessary to setup -; this table in a special mannor. For example, the bios could -; determine locations of 'bad blocks' and set them as already -; 'used' in the map. -; - LD HL,(ALOCVECT) ;now zero out the table now. -BITMAP1:LD (HL),0 - INC HL - DEC BC - LD A,B - OR C - JP NZ,BITMAP1 - LD HL,(ALLOC0) ;get initial space used by directory. - EX DE,HL - LD HL,(ALOCVECT) ;and put this into map. - LD (HL),E - INC HL - LD (HL),D -; -; End of initialization portion. -; - CALL HOMEDRV ;now home the drive. - LD HL,(SCRATCH1) - LD (HL),3 ;force next directory request to read - INC HL ;in a sector. - LD (HL),0 - CALL STFILPOS ;clear initial file position also. -BITMAP2:LD C,0FFH ;read next file name in directory - CALL NXENTRY ;and set checksum byte. - CALL CKFILPOS ;is there another file? - RET Z - CALL FCB2HL ;yes, get its address. - LD A,0E5H - CP (HL) ;empty file entry? - JP Z,BITMAP2 - LD A,(USERNO) ;no, correct user number? - CP (HL) - JP NZ,BITMAP3 - INC HL - LD A,(HL) ;yes, does name start with a '$'? - SUB '$' - JP NZ,BITMAP3 - DEC A ;yes, set atatus to minus one. - LD (STATUS),A -BITMAP3:LD C,1 ;now set this file's space as used in bit map. - CALL SETFILE - CALL CHKNMBR ;keep (SCRATCH1) in bounds. - JP BITMAP2 -; -; Set the status (STATUS) and return. -; -STSTATUS: LD A,(FNDSTAT) - JP SETSTAT -; -; Check extents in (A) and (C). Set the zero flag if they -; are the same. The number of 16k chunks of disk space that -; the directory extent covers is expressad is (EXTMASK+1). -; No registers are modified. -; -SAMEXT: PUSH BC - PUSH AF - LD A,(EXTMASK) ;get extent mask and use it to - CPL ;to compare both extent numbers. - LD B,A ;save resulting mask here. - LD A,C ;mask first extent and save in (C). - AND B - LD C,A - POP AF ;now mask second extent and compare - AND B ;with the first one. - SUB C - AND 1FH ;(* only check buts 0-4 *) - POP BC ;the zero flag is set if they are the same. - RET ;restore (BC) and return. -; -; Search for the first occurence of a file name. On entry, -; register (C) should contain the number of bytes of the fcb -; that must match. -; -FINDFST:LD A,0FFH - LD (FNDSTAT),A - LD HL,COUNTER ;save character count. - LD (HL),C - LD HL,(PARAMS) ;get filename to match. - LD (SAVEFCB),HL ;and save. - CALL STFILPOS ;clear initial file position (set to 0ffffh). - CALL HOMEDRV ;home the drive. -; -; Entry to locate the next occurence of a filename within the -; directory. The disk is not expected to have been changed. If -; it was, then it will be write protected. -; -FINDNXT:LD C,0 ;write protect the disk if changed. - CALL NXENTRY ;get next filename entry in directory. - CALL CKFILPOS ;is file position = 0ffffh? - JP Z,FNDNXT6 ;yes, exit now then. - LD HL,(SAVEFCB) ;set (DE) pointing to filename to match. - EX DE,HL - LD A,(DE) - CP 0E5H ;empty directory entry? - JP Z,FNDNXT1 ;(* are we trying to reserect erased entries? *) - PUSH DE - CALL MOREFLS ;more files in directory? - POP DE - JP NC,FNDNXT6 ;no more. Exit now. -FNDNXT1:CALL FCB2HL ;get address of this fcb in directory. - LD A,(COUNTER) ;get number of bytes (characters) to check. - LD C,A - LD B,0 ;initialize byte position counter. -FNDNXT2:LD A,C ;are we done with the compare? - OR A - JP Z,FNDNXT5 - LD A,(DE) ;no, check next byte. - CP '?' ;don't care about this character? - JP Z,FNDNXT4 - LD A,B ;get bytes position in fcb. - CP 13 ;don't care about the thirteenth byte either. - JP Z,FNDNXT4 - CP 12 ;extent byte? - LD A,(DE) - JP Z,FNDNXT3 - SUB (HL) ;otherwise compare characters. - AND 7FH - JP NZ,FINDNXT ;not the same, check next entry. - JP FNDNXT4 ;so far so good, keep checking. -FNDNXT3:PUSH BC ;check the extent byte here. - LD C,(HL) - CALL SAMEXT - POP BC - JP NZ,FINDNXT ;not the same, look some more. -; -; So far the names compare. Bump pointers to the next byte -; and continue until all (C) characters have been checked. -; -FNDNXT4:INC DE ;bump pointers. - INC HL - INC B - DEC C ;adjust character counter. - JP FNDNXT2 -FNDNXT5:LD A,(FILEPOS) ;return the position of this entry. - AND 03H - LD (STATUS),A - LD HL,FNDSTAT - LD A,(HL) - RLA - RET NC - XOR A - LD (HL),A - RET -; -; Filename was not found. Set appropriate status. -; -FNDNXT6:CALL STFILPOS ;set (FILEPOS) to 0ffffh. - LD A,0FFH ;say not located. - JP SETSTAT -; -; Erase files from the directory. Only the first byte of the -; fcb will be affected. It is set to (E5). -; -ERAFILE:CALL CHKWPRT ;is disk write protected? - LD C,12 ;only compare file names. - CALL FINDFST ;get first file name. -ERAFIL1:CALL CKFILPOS ;any found? - RET Z ;nope, we must be done. - CALL CHKROFL ;is file read only? - CALL FCB2HL ;nope, get address of fcb and - LD (HL),0E5H ;set first byte to 'empty'. - LD C,0 ;clear the space from the bit map. - CALL SETFILE - CALL DIRWRITE ;now write the directory sector back out. - CALL FINDNXT ;find the next file name. - JP ERAFIL1 ;and repeat process. -; -; Look through the space allocation map (bit map) for the -; next available block. Start searching at block number (BC-1). -; The search procedure is to look for an empty block that is -; before the starting block. If not empty, look at a later -; block number. In this way, we return the closest empty block -; on either side of the 'target' block number. This will speed -; access on random devices. For serial devices, this should be -; changed to look in the forward direction first and then start -; at the front and search some more. -; -; On return, (DE)= block number that is empty and (HL) =0 -; if no empry block was found. -; -FNDSPACE: LD D,B ;set (DE) as the block that is checked. - LD E,C -; -; Look before target block. Registers (BC) are used as the lower -; pointer and (DE) as the upper pointer. -; -FNDSPA1:LD A,C ;is block 0 specified? - OR B - JP Z,FNDSPA2 - DEC BC ;nope, check previous block. - PUSH DE - PUSH BC - CALL CKBITMAP - RRA ;is this block empty? - JP NC,FNDSPA3 ;yes. use this. -; -; Note that the above logic gets the first block that it finds -; that is empty. Thus a file could be written 'backward' making -; it very slow to access. This could be changed to look for the -; first empty block and then continue until the start of this -; empty space is located and then used that starting block. -; This should help speed up access to some files especially on -; a well used disk with lots of fairly small 'holes'. -; - POP BC ;nope, check some more. - POP DE -; -; Now look after target block. -; -FNDSPA2:LD HL,(DSKSIZE) ;is block (DE) within disk limits? - LD A,E - SUB L - LD A,D - SBC A,H - JP NC,FNDSPA4 - INC DE ;yes, move on to next one. - PUSH BC - PUSH DE - LD B,D - LD C,E - CALL CKBITMAP ;check it. - RRA ;empty? - JP NC,FNDSPA3 - POP DE ;nope, continue searching. - POP BC - JP FNDSPA1 -; -; Empty block found. Set it as used and return with (HL) -; pointing to it (true?). -; -FNDSPA3:RLA ;reset byte. - INC A ;and set bit 0. - CALL STBMAP1 ;update bit map. - POP HL ;set return registers. - POP DE - RET -; -; Free block was not found. If (BC) is not zero, then we have -; not checked all of the disk space. -; -FNDSPA4:LD A,C - OR B - JP NZ,FNDSPA1 - LD HL,0 ;set 'not found' status. - RET -; -; Move a complete fcb entry into the directory and write it. -; -FCBSET: LD C,0 - LD E,32 ;length of each entry. -; -; Move (E) bytes from the fcb pointed to by (PARAMS) into -; fcb in directory starting at relative byte (C). This updated -; directory buffer is then written to the disk. -; -UPDATE: PUSH DE - LD B,0 ;set (BC) to relative byte position. - LD HL,(PARAMS) ;get address of fcb. - ADD HL,BC ;compute starting byte. - EX DE,HL - CALL FCB2HL ;get address of fcb to update in directory. - POP BC ;set (C) to number of bytes to change. - CALL DE2HL -UPDATE1:CALL TRKSEC ;determine the track and sector affected. - JP DIRWRITE ;then write this sector out. -; -; Routine to change the name of all files on the disk with a -; specified name. The fcb contains the current name as the -; first 12 characters and the new name 16 bytes into the fcb. -; -CHGNAMES: CALL CHKWPRT ;check for a write protected disk. - LD C,12 ;match first 12 bytes of fcb only. - CALL FINDFST ;get first name. - LD HL,(PARAMS) ;get address of fcb. - LD A,(HL) ;get user number. - LD DE,16 ;move over to desired name. - ADD HL,DE - LD (HL),A ;keep same user number. -CHGNAM1:CALL CKFILPOS ;any matching file found? - RET Z ;no, we must be done. - CALL CHKROFL ;check for read only file. - LD C,16 ;start 16 bytes into fcb. - LD E,12 ;and update the first 12 bytes of directory. - CALL UPDATE - CALL FINDNXT ;get te next file name. - JP CHGNAM1 ;and continue. -; -; Update a files attributes. The procedure is to search for -; every file with the same name as shown in fcb (ignoring bit 7) -; and then to update it (which includes bit 7). No other changes -; are made. -; -SAVEATTR: LD C,12 ;match first 12 bytes. - CALL FINDFST ;look for first filename. -SAVATR1:CALL CKFILPOS ;was one found? - RET Z ;nope, we must be done. - LD C,0 ;yes, update the first 12 bytes now. - LD E,12 - CALL UPDATE ;update filename and write directory. - CALL FINDNXT ;and get the next file. - JP SAVATR1 ;then continue until done. -; -; Open a file (name specified in fcb). -; -OPENIT: LD C,15 ;compare the first 15 bytes. - CALL FINDFST ;get the first one in directory. - CALL CKFILPOS ;any at all? - RET Z -OPENIT1:CALL SETEXT ;point to extent byte within users fcb. - LD A,(HL) ;and get it. - PUSH AF ;save it and address. - PUSH HL - CALL FCB2HL ;point to fcb in directory. - EX DE,HL - LD HL,(PARAMS) ;this is the users copy. - LD C,32 ;move it into users space. - PUSH DE - CALL DE2HL - CALL SETS2B7 ;set bit 7 in 's2' byte (unmodified). - POP DE ;now get the extent byte from this fcb. - LD HL,12 - ADD HL,DE - LD C,(HL) ;into (C). - LD HL,15 ;now get the record count byte into (B). - ADD HL,DE - LD B,(HL) - POP HL ;keep the same extent as the user had originally. - POP AF - LD (HL),A - LD A,C ;is it the same as in the directory fcb? - CP (HL) - LD A,B ;if yes, then use the same record count. - JP Z,OPENIT2 - LD A,0 ;if the user specified an extent greater than - JP C,OPENIT2 ;the one in the directory, then set record count to 0. - LD A,128 ;otherwise set to maximum. -OPENIT2:LD HL,(PARAMS) ;set record count in users fcb to (A). - LD DE,15 - ADD HL,DE ;compute relative position. - LD (HL),A ;and set the record count. - RET -; -; Move two bytes from (DE) to (HL) if (and only if) (HL) -; point to a zero value (16 bit). -; Return with zero flag set it (DE) was moved. Registers (DE) -; and (HL) are not changed. However (A) is. -; -MOVEWORD: LD A,(HL) ;check for a zero word. - INC HL - OR (HL) ;both bytes zero? - DEC HL - RET NZ ;nope, just return. - LD A,(DE) ;yes, move two bytes from (DE) into - LD (HL),A ;this zero space. - INC DE - INC HL - LD A,(DE) - LD (HL),A - DEC DE ;don't disturb these registers. - DEC HL - RET -; -; Get here to close a file specified by (fcb). -; -CLOSEIT:XOR A ;clear status and file position bytes. - LD (STATUS),A - LD (FILEPOS),A - LD (FILEPOS+1),A - CALL GETWPRT ;get write protect bit for this drive. - RET NZ ;just return if it is set. - CALL GETS2 ;else get the 's2' byte. - AND 80H ;and look at bit 7 (file unmodified?). - RET NZ ;just return if set. - LD C,15 ;else look up this file in directory. - CALL FINDFST - CALL CKFILPOS ;was it found? - RET Z ;just return if not. - LD BC,16 ;set (HL) pointing to records used section. - CALL FCB2HL - ADD HL,BC - EX DE,HL - LD HL,(PARAMS) ;do the same for users specified fcb. - ADD HL,BC - LD C,16 ;this many bytes are present in this extent. -CLOSEIT1: LD A,(BIGDISK) ;8 or 16 bit record numbers? - OR A - JP Z,CLOSEIT4 - LD A,(HL) ;just 8 bit. Get one from users fcb. - OR A - LD A,(DE) ;now get one from directory fcb. - JP NZ,CLOSEIT2 - LD (HL),A ;users byte was zero. Update from directory. -CLOSEIT2: OR A - JP NZ,CLOSEIT3 - LD A,(HL) ;directories byte was zero, update from users fcb. - LD (DE),A -CLOSEIT3: CP (HL) ;if neither one of these bytes were zero, - JP NZ,CLOSEIT7 ;then close error if they are not the same. - JP CLOSEIT5 ;ok so far, get to next byte in fcbs. -CLOSEIT4: CALL MOVEWORD ;update users fcb if it is zero. - EX DE,HL - CALL MOVEWORD ;update directories fcb if it is zero. - EX DE,HL - LD A,(DE) ;if these two values are no different, - CP (HL) ;then a close error occured. - JP NZ,CLOSEIT7 - INC DE ;check second byte. - INC HL - LD A,(DE) - CP (HL) - JP NZ,CLOSEIT7 - DEC C ;remember 16 bit values. -CLOSEIT5: INC DE ;bump to next item in table. - INC HL - DEC C ;there are 16 entries only. - JP NZ,CLOSEIT1 ;continue if more to do. - LD BC,0FFECH ;backup 20 places (extent byte). - ADD HL,BC - EX DE,HL - ADD HL,BC - LD A,(DE) - CP (HL) ;directory's extent already greater than the - JP C,CLOSEIT6 ;users extent? - LD (HL),A ;no, update directory extent. - LD BC,3 ;and update the record count byte in - ADD HL,BC ;directories fcb. - EX DE,HL - ADD HL,BC - LD A,(HL) ;get from user. - LD (DE),A ;and put in directory. -CLOSEIT6: LD A,0FFH ;set 'was open and is now closed' byte. - LD (CLOSEFLG),A - JP UPDATE1 ;update the directory now. -CLOSEIT7: LD HL,STATUS ;set return status and then return. - DEC (HL) - RET -; -; Routine to get the next empty space in the directory. It -; will then be cleared for use. -; -GETEMPTY: CALL CHKWPRT ;make sure disk is not write protected. - LD HL,(PARAMS) ;save current parameters (fcb). - PUSH HL - LD HL,EMPTYFCB ;use special one for empty space. - LD (PARAMS),HL - LD C,1 ;search for first empty spot in directory. - CALL FINDFST ;(* only check first byte *) - CALL CKFILPOS ;none? - POP HL - LD (PARAMS),HL ;restore original fcb address. - RET Z ;return if no more space. - EX DE,HL - LD HL,15 ;point to number of records for this file. - ADD HL,DE - LD C,17 ;and clear all of this space. - XOR A -GETMT1: LD (HL),A - INC HL - DEC C - JP NZ,GETMT1 - LD HL,13 ;clear the 's1' byte also. - ADD HL,DE - LD (HL),A - CALL CHKNMBR ;keep (SCRATCH1) within bounds. - CALL FCBSET ;write out this fcb entry to directory. - JP SETS2B7 ;set 's2' byte bit 7 (unmodified at present). -; -; Routine to close the current extent and open the next one -; for reading. -; -GETNEXT:XOR A - LD (CLOSEFLG),A ;clear close flag. - CALL CLOSEIT ;close this extent. - CALL CKFILPOS - RET Z ;not there??? - LD HL,(PARAMS) ;get extent byte. - LD BC,12 - ADD HL,BC - LD A,(HL) ;and increment it. - INC A - AND 1FH ;keep within range 0-31. - LD (HL),A - JP Z,GTNEXT1 ;overflow? - LD B,A ;mask extent byte. - LD A,(EXTMASK) - AND B - LD HL,CLOSEFLG ;check close flag (0ffh is ok). - AND (HL) - JP Z,GTNEXT2 ;if zero, we must read in next extent. - JP GTNEXT3 ;else, it is already in memory. -GTNEXT1:LD BC,2 ;Point to the 's2' byte. - ADD HL,BC - INC (HL) ;and bump it. - LD A,(HL) ;too many extents? - AND 0FH - JP Z,GTNEXT5 ;yes, set error code. -; -; Get here to open the next extent. -; -GTNEXT2:LD C,15 ;set to check first 15 bytes of fcb. - CALL FINDFST ;find the first one. - CALL CKFILPOS ;none available? - JP NZ,GTNEXT3 - LD A,(RDWRTFLG) ;no extent present. Can we open an empty one? - INC A ;0ffh means reading (so not possible). - JP Z,GTNEXT5 ;or an error. - CALL GETEMPTY ;we are writing, get an empty entry. - CALL CKFILPOS ;none? - JP Z,GTNEXT5 ;error if true. - JP GTNEXT4 ;else we are almost done. -GTNEXT3:CALL OPENIT1 ;open this extent. -GTNEXT4:CALL STRDATA ;move in updated data (rec #, extent #, etc.) - XOR A ;clear status and return. - JP SETSTAT -; -; Error in extending the file. Too many extents were needed -; or not enough space on the disk. -; -GTNEXT5:CALL IOERR1 ;set error code, clear bit 7 of 's2' - JP SETS2B7 ;so this is not written on a close. -; -; Read a sequential file. -; -RDSEQ: LD A,1 ;set sequential access mode. - LD (MODE),A -RDSEQ1: LD A,0FFH ;don't allow reading unwritten space. - LD (RDWRTFLG),A - CALL STRDATA ;put rec# and ext# into fcb. - LD A,(SAVNREC) ;get next record to read. - LD HL,SAVNXT ;get number of records in extent. - CP (HL) ;within this extent? - JP C,RDSEQ2 - CP 128 ;no. Is this extent fully used? - JP NZ,RDSEQ3 ;no. End-of-file. - CALL GETNEXT ;yes, open the next one. - XOR A ;reset next record to read. - LD (SAVNREC),A - LD A,(STATUS) ;check on open, successful? - OR A - JP NZ,RDSEQ3 ;no, error. -RDSEQ2: CALL COMBLK ;ok. compute block number to read. - CALL CHKBLK ;check it. Within bounds? - JP Z,RDSEQ3 ;no, error. - CALL LOGICAL ;convert (BLKNMBR) to logical sector (128 byte). - CALL TRKSEC1 ;set the track and sector for this block #. - CALL DOREAD ;and read it. - JP SETNREC ;and set the next record to be accessed. -; -; Read error occured. Set status and return. -; -RDSEQ3: JP IOERR1 -; -; Write the next sequential record. -; -WTSEQ: LD A,1 ;set sequential access mode. - LD (MODE),A -WTSEQ1: LD A,0 ;allow an addition empty extent to be opened. - LD (RDWRTFLG),A - CALL CHKWPRT ;check write protect status. - LD HL,(PARAMS) - CALL CKROF1 ;check for read only file, (HL) already set to fcb. - CALL STRDATA ;put updated data into fcb. - LD A,(SAVNREC) ;get record number to write. - CP 128 ;within range? - JP NC,IOERR1 ;no, error(?). - CALL COMBLK ;compute block number. - CALL CHKBLK ;check number. - LD C,0 ;is there one to write to? - JP NZ,WTSEQ6 ;yes, go do it. - CALL GETBLOCK ;get next block number within fcb to use. - LD (RELBLOCK),A ;and save. - LD BC,0 ;start looking for space from the start - OR A ;if none allocated as yet. - JP Z,WTSEQ2 - LD C,A ;extract previous block number from fcb - DEC BC ;so we can be closest to it. - CALL EXTBLK - LD B,H - LD C,L -WTSEQ2: CALL FNDSPACE ;find the next empty block nearest number (BC). - LD A,L ;check for a zero number. - OR H - JP NZ,WTSEQ3 - LD A,2 ;no more space? - JP SETSTAT -WTSEQ3: LD (BLKNMBR),HL ;save block number to access. - EX DE,HL ;put block number into (DE). - LD HL,(PARAMS) ;now we must update the fcb for this - LD BC,16 ;newly allocated block. - ADD HL,BC - LD A,(BIGDISK) ;8 or 16 bit block numbers? - OR A - LD A,(RELBLOCK) ;(* update this entry *) - JP Z,WTSEQ4 ;zero means 16 bit ones. - CALL ADDA2HL ;(HL)=(HL)+(A) - LD (HL),E ;store new block number. - JP WTSEQ5 -WTSEQ4: LD C,A ;compute spot in this 16 bit table. - LD B,0 - ADD HL,BC - ADD HL,BC - LD (HL),E ;stuff block number (DE) there. - INC HL - LD (HL),D -WTSEQ5: LD C,2 ;set (C) to indicate writing to un-used disk space. -WTSEQ6: LD A,(STATUS) ;are we ok so far? - OR A - RET NZ - PUSH BC ;yes, save write flag for bios (register C). - CALL LOGICAL ;convert (BLKNMBR) over to loical sectors. - LD A,(MODE) ;get access mode flag (1=sequential, - DEC A ;0=random, 2=special?). - DEC A - JP NZ,WTSEQ9 -; -; Special random i/o from function #40. Maybe for M/PM, but the -; current block, if it has not been written to, will be zeroed -; out and then written (reason?). -; - POP BC - PUSH BC - LD A,C ;get write status flag (2=writing unused space). - DEC A - DEC A - JP NZ,WTSEQ9 - PUSH HL - LD HL,(DIRBUF) ;zero out the directory buffer. - LD D,A ;note that (A) is zero here. -WTSEQ7: LD (HL),A - INC HL - INC D ;do 128 bytes. - JP P,WTSEQ7 - CALL DIRDMA ;tell the bios the dma address for directory access. - LD HL,(LOGSECT) ;get sector that starts current block. - LD C,2 ;set 'writing to unused space' flag. -WTSEQ8: LD (BLKNMBR),HL ;save sector to write. - PUSH BC - CALL TRKSEC1 ;determine its track and sector numbers. - POP BC - CALL DOWRITE ;now write out 128 bytes of zeros. - LD HL,(BLKNMBR) ;get sector number. - LD C,0 ;set normal write flag. - LD A,(BLKMASK) ;determine if we have written the entire - LD B,A ;physical block. - AND L - CP B - INC HL ;prepare for the next one. - JP NZ,WTSEQ8 ;continue until (BLKMASK+1) sectors written. - POP HL ;reset next sector number. - LD (BLKNMBR),HL - CALL DEFDMA ;and reset dma address. -; -; Normal disk write. Set the desired track and sector then -; do the actual write. -; -WTSEQ9: CALL TRKSEC1 ;determine track and sector for this write. - POP BC ;get write status flag. - PUSH BC - CALL DOWRITE ;and write this out. - POP BC - LD A,(SAVNREC) ;get number of records in file. - LD HL,SAVNXT ;get last record written. - CP (HL) - JP C,WTSEQ10 - LD (HL),A ;we have to update record count. - INC (HL) - LD C,2 -; -;* This area has been patched to correct disk update problem -;* when using blocking and de-blocking in the BIOS. -; -WTSEQ10:NOP ;was 'dcr c' - NOP ;was 'dcr c' - LD HL,0 ;was 'jnz wtseq99' -; -; * End of patch. -; - PUSH AF - CALL GETS2 ;set 'extent written to' flag. - AND 7FH ;(* clear bit 7 *) - LD (HL),A - POP AF ;get record count for this extent. -WTSEQ99:CP 127 ;is it full? - JP NZ,WTSEQ12 - LD A,(MODE) ;yes, are we in sequential mode? - CP 1 - JP NZ,WTSEQ12 - CALL SETNREC ;yes, set next record number. - CALL GETNEXT ;and get next empty space in directory. - LD HL,STATUS ;ok? - LD A,(HL) - OR A - JP NZ,WTSEQ11 - DEC A ;yes, set record count to -1. - LD (SAVNREC),A -WTSEQ11:LD (HL),0 ;clear status. -WTSEQ12:JP SETNREC ;set next record to access. -; -; For random i/o, set the fcb for the desired record number -; based on the 'r0,r1,r2' bytes. These bytes in the fcb are -; used as follows: -; -; fcb+35 fcb+34 fcb+33 -; | 'r-2' | 'r-1' | 'r-0' | -; |7 0 | 7 0 | 7 0| -; |0 0 0 0 0 0 0 0 | 0 0 0 0 0 0 0 0 | 0 0 0 0 0 0 0 0| -; | overflow | | extra | extent | record # | -; | ______________| |_extent|__number___|_____________| -; also 's2' -; -; On entry, register (C) contains 0ffh if this is a read -; and thus we can not access unwritten disk space. Otherwise, -; another extent will be opened (for writing) if required. -; -POSITION: XOR A ;set random i/o flag. - LD (MODE),A -; -; Special entry (function #40). M/PM ? -; -POSITN1:PUSH BC ;save read/write flag. - LD HL,(PARAMS) ;get address of fcb. - EX DE,HL - LD HL,33 ;now get byte 'r0'. - ADD HL,DE - LD A,(HL) - AND 7FH ;keep bits 0-6 for the record number to access. - PUSH AF - LD A,(HL) ;now get bit 7 of 'r0' and bits 0-3 of 'r1'. - RLA - INC HL - LD A,(HL) - RLA - AND 1FH ;and save this in bits 0-4 of (C). - LD C,A ;this is the extent byte. - LD A,(HL) ;now get the extra extent byte. - RRA - RRA - RRA - RRA - AND 0FH - LD B,A ;and save it in (B). - POP AF ;get record number back to (A). - INC HL ;check overflow byte 'r2'. - LD L,(HL) - INC L - DEC L - LD L,6 ;prepare for error. - JP NZ,POSITN5 ;out of disk space error. - LD HL,32 ;store record number into fcb. - ADD HL,DE - LD (HL),A - LD HL,12 ;and now check the extent byte. - ADD HL,DE - LD A,C - SUB (HL) ;same extent as before? - JP NZ,POSITN2 - LD HL,14 ;yes, check extra extent byte 's2' also. - ADD HL,DE - LD A,B - SUB (HL) - AND 7FH - JP Z,POSITN3 ;same, we are almost done then. -; -; Get here when another extent is required. -; -POSITN2:PUSH BC - PUSH DE - CALL CLOSEIT ;close current extent. - POP DE - POP BC - LD L,3 ;prepare for error. - LD A,(STATUS) - INC A - JP Z,POSITN4 ;close error. - LD HL,12 ;put desired extent into fcb now. - ADD HL,DE - LD (HL),C - LD HL,14 ;and store extra extent byte 's2'. - ADD HL,DE - LD (HL),B - CALL OPENIT ;try and get this extent. - LD A,(STATUS) ;was it there? - INC A - JP NZ,POSITN3 - POP BC ;no. can we create a new one (writing?). - PUSH BC - LD L,4 ;prepare for error. - INC C - JP Z,POSITN4 ;nope, reading unwritten space error. - CALL GETEMPTY ;yes we can, try to find space. - LD L,5 ;prepare for error. - LD A,(STATUS) - INC A - JP Z,POSITN4 ;out of space? -; -; Normal return location. Clear error code and return. -; -POSITN3:POP BC ;restore stack. - XOR A ;and clear error code byte. - JP SETSTAT -; -; Error. Set the 's2' byte to indicate this (why?). -; -POSITN4:PUSH HL - CALL GETS2 - LD (HL),0C0H - POP HL -; -; Return with error code (presently in L). -; -POSITN5:POP BC - LD A,L ;get error code. - LD (STATUS),A - JP SETS2B7 -; -; Read a random record. -; -READRAN:LD C,0FFH ;set 'read' status. - CALL POSITION ;position the file to proper record. - CALL Z,RDSEQ1 ;and read it as usual (if no errors). - RET -; -; Write to a random record. -; -WRITERAN: LD C,0 ;set 'writing' flag. - CALL POSITION ;position the file to proper record. - CALL Z,WTSEQ1 ;and write as usual (if no errors). - RET -; -; Compute the random record number. Enter with (HL) pointing -; to a fcb an (DE) contains a relative location of a record -; number. On exit, (C) contains the 'r0' byte, (B) the 'r1' -; byte, and (A) the 'r2' byte. -; -; On return, the zero flag is set if the record is within -; bounds. Otherwise, an overflow occured. -; -COMPRAND: EX DE,HL ;save fcb pointer in (DE). - ADD HL,DE ;compute relative position of record #. - LD C,(HL) ;get record number into (BC). - LD B,0 - LD HL,12 ;now get extent. - ADD HL,DE - LD A,(HL) ;compute (BC)=(record #)+(extent)*128. - RRCA ;move lower bit into bit 7. - AND 80H ;and ignore all other bits. - ADD A,C ;add to our record number. - LD C,A - LD A,0 ;take care of any carry. - ADC A,B - LD B,A - LD A,(HL) ;now get the upper bits of extent into - RRCA ;bit positions 0-3. - AND 0FH ;and ignore all others. - ADD A,B ;add this in to 'r1' byte. - LD B,A - LD HL,14 ;get the 's2' byte (extra extent). - ADD HL,DE - LD A,(HL) - ADD A,A ;and shift it left 4 bits (bits 4-7). - ADD A,A - ADD A,A - ADD A,A - PUSH AF ;save carry flag (bit 0 of flag byte). - ADD A,B ;now add extra extent into 'r1'. - LD B,A - PUSH AF ;and save carry (overflow byte 'r2'). - POP HL ;bit 0 of (L) is the overflow indicator. - LD A,L - POP HL ;and same for first carry flag. - OR L ;either one of these set? - AND 01H ;only check the carry flags. - RET -; -; Routine to setup the fcb (bytes 'r0', 'r1', 'r2') to -; reflect the last record used for a random (or other) file. -; This reads the directory and looks at all extents computing -; the largerst record number for each and keeping the maximum -; value only. Then 'r0', 'r1', and 'r2' will reflect this -; maximum record number. This is used to compute the space used -; by a random file. -; -RANSIZE:LD C,12 ;look thru directory for first entry with - CALL FINDFST ;this name. - LD HL,(PARAMS) ;zero out the 'r0, r1, r2' bytes. - LD DE,33 - ADD HL,DE - PUSH HL - LD (HL),D ;note that (D)=0. - INC HL - LD (HL),D - INC HL - LD (HL),D -RANSIZ1:CALL CKFILPOS ;is there an extent to process? - JP Z,RANSIZ3 ;no, we are done. - CALL FCB2HL ;set (HL) pointing to proper fcb in dir. - LD DE,15 ;point to last record in extent. - CALL COMPRAND ;and compute random parameters. - POP HL - PUSH HL ;now check these values against those - LD E,A ;already in fcb. - LD A,C ;the carry flag will be set if those - SUB (HL) ;in the fcb represent a larger size than - INC HL ;this extent does. - LD A,B - SBC A,(HL) - INC HL - LD A,E - SBC A,(HL) - JP C,RANSIZ2 - LD (HL),E ;we found a larger (in size) extent. - DEC HL ;stuff these values into fcb. - LD (HL),B - DEC HL - LD (HL),C -RANSIZ2:CALL FINDNXT ;now get the next extent. - JP RANSIZ1 ;continue til all done. -RANSIZ3:POP HL ;we are done, restore the stack and - RET ;return. -; -; Function to return the random record position of a given -; file which has been read in sequential mode up to now. -; -SETRAN: LD HL,(PARAMS) ;point to fcb. - LD DE,32 ;and to last used record. - CALL COMPRAND ;compute random position. - LD HL,33 ;now stuff these values into fcb. - ADD HL,DE - LD (HL),C ;move 'r0'. - INC HL - LD (HL),B ;and 'r1'. - INC HL - LD (HL),A ;and lastly 'r2'. - RET -; -; This routine select the drive specified in (ACTIVE) and -; update the login vector and bitmap table if this drive was -; not already active. -; -LOGINDRV: LD HL,(LOGIN) ;get the login vector. - LD A,(ACTIVE) ;get the default drive. - LD C,A - CALL SHIFTR ;position active bit for this drive - PUSH HL ;into bit 0. - EX DE,HL - CALL SELECT ;select this drive. - POP HL - CALL Z,SLCTERR ;valid drive? - LD A,L ;is this a newly activated drive? - RRA - RET C - LD HL,(LOGIN) ;yes, update the login vector. - LD C,L - LD B,H - CALL SETBIT - LD (LOGIN),HL ;and save. - JP BITMAP ;now update the bitmap. -; -; Function to set the active disk number. -; -SETDSK: LD A,(EPARAM) ;get parameter passed and see if this - LD HL,ACTIVE ;represents a change in drives. - CP (HL) - RET Z - LD (HL),A ;yes it does, log it in. - JP LOGINDRV -; -; This is the 'auto disk select' routine. The firsst byte -; of the fcb is examined for a drive specification. If non -; zero then the drive will be selected and loged in. -; -AUTOSEL:LD A,0FFH ;say 'auto-select activated'. - LD (AUTO),A - LD HL,(PARAMS) ;get drive specified. - LD A,(HL) - AND 1FH ;look at lower 5 bits. - DEC A ;adjust for (1=A, 2=B) etc. - LD (EPARAM),A ;and save for the select routine. - CP 1EH ;check for 'no change' condition. - JP NC,AUTOSL1 ;yes, don't change. - LD A,(ACTIVE) ;we must change, save currently active - LD (OLDDRV),A ;drive. - LD A,(HL) ;and save first byte of fcb also. - LD (AUTOFLAG),A ;this must be non-zero. - AND 0E0H ;whats this for (bits 6,7 are used for - LD (HL),A ;something)? - CALL SETDSK ;select and log in this drive. -AUTOSL1:LD A,(USERNO) ;move user number into fcb. - LD HL,(PARAMS) ;(* upper half of first byte *) - OR (HL) - LD (HL),A - RET ;and return (all done). -; -; Function to return the current cp/m version number. -; -GETVER: LD A,022H ;version 2.2 - JP SETSTAT -; -; Function to reset the disk system. -; -RSTDSK: LD HL,0 ;clear write protect status and log - LD (WRTPRT),HL ;in vector. - LD (LOGIN),HL - XOR A ;select drive 'A'. - LD (ACTIVE),A - LD HL,TBUFF ;setup default dma address. - LD (USERDMA),HL - CALL DEFDMA - JP LOGINDRV ;now log in drive 'A'. -; -; Function to open a specified file. -; -OPENFIL:CALL CLEARS2 ;clear 's2' byte. - CALL AUTOSEL ;select proper disk. - JP OPENIT ;and open the file. -; -; Function to close a specified file. -; -CLOSEFIL: CALL AUTOSEL ;select proper disk. - JP CLOSEIT ;and close the file. -; -; Function to return the first occurence of a specified file -; name. If the first byte of the fcb is '?' then the name will -; not be checked (get the first entry no matter what). -; -GETFST: LD C,0 ;prepare for special search. - EX DE,HL - LD A,(HL) ;is first byte a '?'? - CP '?' - JP Z,GETFST1 ;yes, just get very first entry (zero length match). - CALL SETEXT ;get the extension byte from fcb. - LD A,(HL) ;is it '?'? if yes, then we want - CP '?' ;an entry with a specific 's2' byte. - CALL NZ,CLEARS2 ;otherwise, look for a zero 's2' byte. - CALL AUTOSEL ;select proper drive. - LD C,15 ;compare bytes 0-14 in fcb (12&13 excluded). -GETFST1:CALL FINDFST ;find an entry and then move it into - JP MOVEDIR ;the users dma space. -; -; Function to return the next occurence of a file name. -; -GETNXT: LD HL,(SAVEFCB) ;restore pointers. note that no - LD (PARAMS),HL ;other dbos calls are allowed. - CALL AUTOSEL ;no error will be returned, but the - CALL FINDNXT ;results will be wrong. - JP MOVEDIR -; -; Function to delete a file by name. -; -DELFILE:CALL AUTOSEL ;select proper drive. - CALL ERAFILE ;erase the file. - JP STSTATUS ;set status and return. -; -; Function to execute a sequential read of the specified -; record number. -; -READSEQ:CALL AUTOSEL ;select proper drive then read. - JP RDSEQ -; -; Function to write the net sequential record. -; -WRTSEQ: CALL AUTOSEL ;select proper drive then write. - JP WTSEQ -; -; Create a file function. -; -FCREATE:CALL CLEARS2 ;clear the 's2' byte on all creates. - CALL AUTOSEL ;select proper drive and get the next - JP GETEMPTY ;empty directory space. -; -; Function to rename a file. -; -RENFILE:CALL AUTOSEL ;select proper drive and then switch - CALL CHGNAMES ;file names. - JP STSTATUS -; -; Function to return the login vector. -; -GETLOG: LD HL,(LOGIN) - JP GETPRM1 -; -; Function to return the current disk assignment. -; -GETCRNT:LD A,(ACTIVE) - JP SETSTAT -; -; Function to set the dma address. -; -PUTDMA: EX DE,HL - LD (USERDMA),HL ;save in our space and then get to - JP DEFDMA ;the bios with this also. -; -; Function to return the allocation vector. -; -GETALOC:LD HL,(ALOCVECT) - JP GETPRM1 -; -; Function to return the read-only status vector. -; -GETROV: LD HL,(WRTPRT) - JP GETPRM1 -; -; Function to set the file attributes (read-only, system). -; -SETATTR:CALL AUTOSEL ;select proper drive then save attributes. - CALL SAVEATTR - JP STSTATUS -; -; Function to return the address of the disk parameter block -; for the current drive. -; -GETPARM:LD HL,(DISKPB) -GETPRM1:LD (STATUS),HL - RET -; -; Function to get or set the user number. If (E) was (FF) -; then this is a request to return the current user number. -; Else set the user number from (E). -; -GETUSER:LD A,(EPARAM) ;get parameter. - CP 0FFH ;get user number? - JP NZ,SETUSER - LD A,(USERNO) ;yes, just do it. - JP SETSTAT -SETUSER:AND 1FH ;no, we should set it instead. keep low - LD (USERNO),A ;bits (0-4) only. - RET -; -; Function to read a random record from a file. -; -RDRANDOM: CALL AUTOSEL ;select proper drive and read. - JP READRAN -; -; Function to compute the file size for random files. -; -WTRANDOM: CALL AUTOSEL ;select proper drive and write. - JP WRITERAN -; -; Function to compute the size of a random file. -; -FILESIZE: CALL AUTOSEL ;select proper drive and check file length - JP RANSIZE -; -; Function #37. This allows a program to log off any drives. -; On entry, set (DE) to contain a word with bits set for those -; drives that are to be logged off. The log-in vector and the -; write protect vector will be updated. This must be a M/PM -; special function. -; -LOGOFF: LD HL,(PARAMS) ;get drives to log off. - LD A,L ;for each bit that is set, we want - CPL ;to clear that bit in (LOGIN) - LD E,A ;and (WRTPRT). - LD A,H - CPL - LD HL,(LOGIN) ;reset the login vector. - AND H - LD D,A - LD A,L - AND E - LD E,A - LD HL,(WRTPRT) - EX DE,HL - LD (LOGIN),HL ;and save. - LD A,L ;now do the write protect vector. - AND E - LD L,A - LD A,H - AND D - LD H,A - LD (WRTPRT),HL ;and save. all done. - RET -; -; Get here to return to the user. -; -GOBACK: LD A,(AUTO) ;was auto select activated? - OR A - JP Z,GOBACK1 - LD HL,(PARAMS) ;yes, but was a change made? - LD (HL),0 ;(* reset first byte of fcb *) - LD A,(AUTOFLAG) - OR A - JP Z,GOBACK1 - LD (HL),A ;yes, reset first byte properly. - LD A,(OLDDRV) ;and get the old drive and select it. - LD (EPARAM),A - CALL SETDSK -GOBACK1:LD HL,(USRSTACK) ;reset the users stack pointer. - LD SP,HL - LD HL,(STATUS) ;get return status. - LD A,L ;force version 1.4 compatability. - LD B,H - RET ;and go back to user. -; -; Function #40. This is a special entry to do random i/o. -; For the case where we are writing to unused disk space, this -; space will be zeroed out first. This must be a M/PM special -; purpose function, because why would any normal program even -; care about the previous contents of a sector about to be -; written over. -; -WTSPECL:CALL AUTOSEL ;select proper drive. - LD A,2 ;use special write mode. - LD (MODE),A - LD C,0 ;set write indicator. - CALL POSITN1 ;position the file. - CALL Z,WTSEQ1 ;and write (if no errors). - RET -; -;************************************************************** -;* -;* BDOS data storage pool. -;* -;************************************************************** -; -EMPTYFCB: DB 0E5H ;empty directory segment indicator. -WRTPRT: DW 0 ;write protect status for all 16 drives. -LOGIN: DW 0 ;drive active word (1 bit per drive). -USERDMA:DW 080H ;user's dma address (defaults to 80h). -; -; Scratch areas from parameter block. -; -SCRATCH1: DW 0 ;relative position within dir segment for file (0-3). -SCRATCH2: DW 0 ;last selected track number. -SCRATCH3: DW 0 ;last selected sector number. -; -; Disk storage areas from parameter block. -; -DIRBUF: DW 0 ;address of directory buffer to use. -DISKPB: DW 0 ;contains address of disk parameter block. -CHKVECT:DW 0 ;address of check vector. -ALOCVECT: DW 0 ;address of allocation vector (bit map). -; -; Parameter block returned from the bios. -; -SECTORS:DW 0 ;sectors per track from bios. -BLKSHFT:DB 0 ;block shift. -BLKMASK:DB 0 ;block mask. -EXTMASK:DB 0 ;extent mask. -DSKSIZE:DW 0 ;disk size from bios (number of blocks-1). -DIRSIZE:DW 0 ;directory size. -ALLOC0: DW 0 ;storage for first bytes of bit map (dir space used). -ALLOC1: DW 0 -OFFSET: DW 0 ;first usable track number. -XLATE: DW 0 ;sector translation table address. -; -; -CLOSEFLG: DB 0 ;close flag (=0ffh is extent written ok). -RDWRTFLG: DB 0 ;read/write flag (0ffh=read, 0=write). -FNDSTAT:DB 0 ;filename found status (0=found first entry). -MODE: DB 0 ;I/o mode select (0=random, 1=sequential, 2=special random). -EPARAM: DB 0 ;storage for register (E) on entry to bdos. -RELBLOCK: DB 0 ;relative position within fcb of block number written. -COUNTER:DB 0 ;byte counter for directory name searches. -SAVEFCB:DW 0,0 ;save space for address of fcb (for directory searches). -BIGDISK:DB 0 ;if =0 then disk is > 256 blocks long. -AUTO: DB 0 ;if non-zero, then auto select activated. -OLDDRV: DB 0 ;on auto select, storage for previous drive. -AUTOFLAG: DB 0 ;if non-zero, then auto select changed drives. -SAVNXT: DB 0 ;storage for next record number to access. -SAVEXT: DB 0 ;storage for extent number of file. -SAVNREC:DW 0 ;storage for number of records in file. -BLKNMBR:DW 0 ;block number (physical sector) used within a file or logical sect -LOGSECT:DW 0 ;starting logical (128 byte) sector of block (physical sector). -FCBPOS: DB 0 ;relative position within buffer for fcb of file of interest. -FILEPOS:DW 0 ;files position within directory (0 to max entries -1). -; -; Disk directory buffer checksum bytes. One for each of the -; 16 possible drives. -; -CKSUMTBL: DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -; -; Extra space ? -; - DB 0,0,0,0 -; -;************************************************************** -;* -;* B I O S J U M P T A B L E -;* -;************************************************************** -; - ALIGN_NOPS CPMBIOS - -;----------------------------------------------------------------------- -; MZ-80A CPM BIOS STUB - Main Logic in CBIOS.ASM -;----------------------------------------------------------------------- - - ; Bring in the CBIOS stub, has the bootstrap code and DPB place markers. - INCLUDE "cpm22-bios.asm" - - ALIGN_NOPS CBIOSSTART - -;* -;****************** E N D O F C P / M ***************** diff --git a/software/asm/include/MSBASIC_BuildVersion.asm b/software/asm/include/MSBASIC_BuildVersion.asm deleted file mode 100644 index cdc5619..0000000 --- a/software/asm/include/MSBASIC_BuildVersion.asm +++ /dev/null @@ -1 +0,0 @@ -BUILD_VERSION EQU 2 diff --git a/software/asm/include/cpm_buildversion.asm b/software/asm/include/cpm_buildversion.asm deleted file mode 100644 index 05053fe..0000000 --- a/software/asm/include/cpm_buildversion.asm +++ /dev/null @@ -1 +0,0 @@ -BUILD_VERSION EQU 1 diff --git a/software/asm/include/cpm_definitions.asm b/software/asm/include/cpm_definitions.asm deleted file mode 100644 index 5daf9d6..0000000 --- a/software/asm/include/cpm_definitions.asm +++ /dev/null @@ -1,589 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: CPM_Definitions.asm -;- Created: January 2020 -;- Author(s): Philip Smart -;- Description: Sharp MZ series CPM v2.23 -;- Definitions for the Sharp MZ80A CPM v2.23 OS used in the RFS -;- -;- Credits: -;- Copyright: (c) 2019-23 Philip Smart -;- -;- History: Jan 2020 - Initial version. -; May 2020 - Advent of the new RFS PCB v2.0, quite a few changes to accommodate the -; additional and different hardware. The SPI is now onboard the PCB and -; not using the printer interface card. -; Mar 2021 - Changes to work with the RFS v2.1 board. -;- Apr 2021 - Removed ROM and RAM Drive functionality as it provided no performance or -;- use benefit over SD which are much larger and RW. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - -;----------------------------------------------- -; Features. -;----------------------------------------------- -HW_SPI_ENA EQU 1 ; Set to 1 if hardware SPI is present on the RFS PCB v2 board. -SW_SPI_ENA EQU 0 ; Set to 1 if software SPI is present on the RFS PCB v2 board. -PP_SPI_ENA EQU 0 ; Set to 1 if using the SPI interface via the Parallel Port, ie. for RFS PCB v1 which doesnt have SPI onboard. - -; Build time options, only set to '1' to build, '0' to disable, only 1 can be set to '1'. -; IF BUILD_VERSION = 0 -BUILD_80C EQU 1 ; Build for an MZ-80A with a 40/80 column card. -BUILD_40C EQU 0 ; Build for a standard 40 column MZ-80A. -; ENDIF -; IF BUILD_VERSION = 1 -;BUILD_80C EQU 0 ; Build for an MZ-80A with a 40/80 column card. -;BUILD_40C EQU 1 ; Build for a standard 40 column MZ-80A. -; ENDIF - -;----------------------------------------------- -; Configurable settings. -;----------------------------------------------- -MAXRDRETRY EQU 002h -MAXWRRETRY EQU 002h -BLKSIZ EQU 4096 ; CP/M allocation size -HSTSIZ EQU 512 ; host disk sector size -HSTSPT EQU 32 ; host disk sectors/trk -HSTBLK EQU HSTSIZ/128 ; CP/M sects/host buff -CPMSPT EQU HSTBLK * HSTSPT ; CP/M sectors/track -SECMSK EQU HSTBLK-1 ; sector mask -WRALL EQU 0 ; write to allocated -WRDIR EQU 1 ; write to directory -WRUAL EQU 2 ; write to unallocated -TMRTICKINTV EQU 5 ; Number of 0.010mSec ticks per interrupt, ie. resolution of RTC. -MTROFFMSECS EQU 100 ; Time from last access to motor being switched off in seconds in TMRTICKINTV ticks. - IF BUILD_80C = 1 -COLW EQU 80 ; Width of the display screen (ie. columns). - ELSE -COLW EQU 40 ; Width of the display screen (ie. columns). - ENDIF -ROW EQU 25 ; Number of rows on display screen. -SCRNSZ EQU COLW * ROW ; Total size, in bytes, of the screen display area. -SCRLW EQU COLW / 8 ; Number of 8 byte regions in a line for hardware scroll. - -; BIOS equates -MAXDISKS EQU 7 ; Max number of Drives supported -KEYBUFSIZE EQU 16 ; Ensure this is a power of 2, max size 256. - -; Debugging -ENADEBUG EQU 0 ; Enable debugging logic, 1 = enable, 0 = disable - - -;----------------------------------------------- -; Entry/compilation start points. -;----------------------------------------------- -CBIOSSTART EQU 0C000h -CBIOSDATA EQU CBIOSSTART - 0400H -UROMADDR EQU 0E800H ; Start of User ROM Address space. -FDCROMADDR EQU 0F000H -CBASE EQU 0A000H -CPMCCP EQU CBASE ; CP/M System entry -CPMBDOS EQU CPMCCP + 0806H ; BDOS entry -CPMBIOS EQU CPMCCP + 01600H ; Original CPM22 BIOS entry -CPMCOPYRMSG EQU CBASE+8 ; Copyright message stored in CP/M binary. -BOOT EQU CBIOSSTART + 0 -WBOOT EQU CBIOSSTART + 3 -WBOOTE EQU CBIOSSTART + 3 -CONST EQU CBIOSSTART + 6 -CONIN EQU CBIOSSTART + 9 -CONOUT EQU CBIOSSTART + 12 -LIST EQU CBIOSSTART + 15 -PUNCH EQU CBIOSSTART + 18 -READER EQU CBIOSSTART + 21 -HOME EQU CBIOSSTART + 24 -SELDSK EQU CBIOSSTART + 27 -SETTRK EQU CBIOSSTART + 30 -SETSEC EQU CBIOSSTART + 33 -SETDMA EQU CBIOSSTART + 36 -READ EQU CBIOSSTART + 39 -WRITE EQU CBIOSSTART + 42 -FRSTAT EQU CBIOSSTART + 45 -SECTRN EQU CBIOSSTART + 48 -UNUSED EQU CBIOSSTART + 51 -BANKTOBANK EQU CBIOSSTART + 54 -CCP EQU CBASE -CCPCLRBUF EQU CBASE + 3 -DPBASE EQU CPMBIOS -CDIRBUF EQU CPMBIOS + (MAXDISKS * 16) -CSVALVMEM EQU CDIRBUF + 128 -CSVALVEND EQU CBIOSDATA - 1 ;CSVALVMEM + 1253 -IOBYT EQU 00003H ; IOBYTE address -CDISK EQU 00004H ; Address of Current drive name and user number -CPMUSERDMA EQU 00080h ; Default CPM User DMA address. -DPSIZE EQU 16 ; Size of a Disk Parameter Block -DPBLOCK0 EQU SCRN - (8 * DPSIZE) ; Location of the 1st DPB in the CBIOS Rom. -DPBLOCK1 EQU DPBLOCK0 + DPSIZE -DPBLOCK2 EQU DPBLOCK1 + DPSIZE -DPBLOCK3 EQU DPBLOCK2 + DPSIZE -DPBLOCK4 EQU DPBLOCK3 + DPSIZE -DPBLOCK5 EQU DPBLOCK4 + DPSIZE -DPBLOCK6 EQU DPBLOCK5 + DPSIZE -DPBLOCK7 EQU DPBLOCK6 + DPSIZE - -;------------------------------------------------------- -; Function entry points in the CBIOS ROMS -;------------------------------------------------------- -UROMJMPTBL EQU UROMADDR + 00020H ; Position at beginning of each bank of an API jump table of public methods in the bank - -; Public functions in CBIOS User ROM Bank 1 - utility functions, ie. Audio. -QREBOOT EQU 0 + UROMJMPTBL -QMELDY EQU 3 + UROMJMPTBL -QTEMP EQU 6 + UROMJMPTBL -QMSTA EQU 9 + UROMJMPTBL -QMSTP EQU 12 + UROMJMPTBL -QBEL EQU 15 + UROMJMPTBL -QMODE EQU 18 + UROMJMPTBL -QTIMESET EQU 21 + UROMJMPTBL -QTIMEREAD EQU 24 + UROMJMPTBL -QCHKKY EQU 27 + UROMJMPTBL -QGETKY EQU 30 + UROMJMPTBL - -; Public functions in CBIOS User ROM Bank 2 - Screen / ANSI terminal functions. -QPRNT EQU 0 + UROMJMPTBL -QPRTHX EQU 3 + UROMJMPTBL -QPRTHL EQU 6 + UROMJMPTBL -QANSITERM EQU 9 + UROMJMPTBL - -; Public functions in CBIOS User ROM Bank 3 - SD Card functions. -SD_INIT EQU 0 + UROMJMPTBL -SD_READ EQU 3 + UROMJMPTBL -SD_WRITE EQU 6 + UROMJMPTBL -SD_GETLBA EQU 9 + UROMJMPTBL -SDC_READ EQU 12 + UROMJMPTBL -SDC_WRITE EQU 15 + UROMJMPTBL - -; Public functions in CBIOS User ROM Bank 4 - Floppy Disk Controller functions. -QDSKINIT EQU 0 + UROMJMPTBL -QSETDRVCFG EQU 3 + UROMJMPTBL -QSETDRVMAP EQU 6 + UROMJMPTBL -QSELDRIVE EQU 9 + UROMJMPTBL -QGETMAPDSK EQU 12 + UROMJMPTBL -QDSKREAD EQU 15 + UROMJMPTBL -QDSKWRITE EQU 18 + UROMJMPTBL - - -;----------------------------------------------- -; Memory mapped ports in hardware. -;----------------------------------------------- -SCRN: EQU 0D000H -ARAM: EQU 0D800H -DSPCTL: EQU 0DFFFH ; Screen 40/80 select register (bit 7) -KEYPA: EQU 0E000h -KEYPB: EQU 0E001h -KEYPC: EQU 0E002h -KEYPF: EQU 0E003h -CSTR: EQU 0E002h -CSTPT: EQU 0E003h -CONT0: EQU 0E004h -CONT1: EQU 0E005h -CONT2: EQU 0E006h -CONTF: EQU 0E007h -SUNDG: EQU 0E008h -TEMP: EQU 0E008h -MEMSW: EQU 0E00CH -MEMSWR: EQU 0E010H -INVDSP: EQU 0E014H -NRMDSP: EQU 0E015H -SCLDSP: EQU 0E200H -SCLBASE: EQU 0E2H -BNKCTRLRST: EQU 0EFF8H ; Bank control reset, returns all registers to power up default. -BNKCTRLDIS: EQU 0EFF9H ; Disable bank control registers by resetting the coded latch. -HWSPIDATA: EQU 0EFFBH ; Hardware SPI Data register (read/write). -HWSPISTART: EQU 0EFFCH ; Start an SPI transfer. -BNKSELMROM: EQU 0EFFDh ; Select RFS Bank1 (MROM) -BNKSELUSER: EQU 0EFFEh ; Select RFS Bank2 (User ROM) -BNKCTRL: EQU 0EFFFH ; Bank Control register (read/write). - -; -; RFS v2 Control Register constants. -; -BBCLK EQU 1 ; BitBang SPI Clock. -SDCS EQU 2 ; SD Card Chip Select, active low. -BBMOSI EQU 4 ; BitBang MOSI (Master Out Serial In). -CDLTCH1 EQU 8 ; Coded latch up count bit 1 -CDLTCH2 EQU 16 ; Coded latch up count bit 2 -CDLTCH3 EQU 32 ; Coded latch up count bit 3 -BK2A19 EQU 64 ; User ROM Device Select Bit 0 (or Address bit 19). -BK2A20 EQU 128 ; User ROM Device Select Bit 1 (or Address bit 20). - ; BK2A20 : BK2A19 - ; 0 0 = Flash RAM 0 (default). - ; 0 1 = Flash RAM 1. - ; 1 0 = Flasm RAM 2 or Static RAM 0. - ; 1 1 = Reserved. - -BNKCTRLDEF EQU BBMOSI+SDCS+BBCLK ; Default on startup for the Bank Control register. - -;----------------------------------------------- -; IO ports in hardware and values. -;----------------------------------------------- -SPI_OUT EQU 0FFH -SPI_IN EQU 0FEH -; -DOUT_LOW EQU 000H -DOUT_HIGH EQU 004H -DOUT_MASK EQU 004H -DIN_LOW EQU 000H -DIN_HIGH EQU 001H -CLOCK_LOW EQU 000H -CLOCK_HIGH EQU 002H -CLOCK_MASK EQU 0FDH -CS_LOW EQU 000H -CS_HIGH EQU 001H - -;----------------------------------------------- -; Rom File System Header (MZF) -;----------------------------------------------- -RFS_ATRB: EQU 00000h ; Code Type, 01 = Machine Code. -RFS_NAME: EQU 00001h ; Title/Name (17 bytes). -RFS_SIZE: EQU 00012h ; Size of program. -RFS_DTADR: EQU 00014h ; Load address of program. -RFS_EXADR: EQU 00016h ; Exec address of program. -RFS_COMNT: EQU 00018h ; COMMENT -MZFHDRSZ EQU 128 ; Full MZF Header size -MZFHDRNCSZ EQU 24 ; Only the primary MZF data, no comment field. -RFSSECTSZ EQU 256 -MROMSIZE EQU 4096 -UROMSIZE EQU 2048 -BANKSPERTRACK EQU (ROMSECTORSIZE * ROMSECTORS) / UROMSIZE ; (8) We currently only use the UROM for disk images. -SECTORSPERBANK EQU UROMSIZE / ROMSECTORSIZE ; (16) -SECTORSPERBLOCK EQU RFSSECTSZ/ROMSECTORSIZE ; (2) -ROMSECTORSIZE EQU 128 -ROMSECTORS EQU 128 -RAMDRVSECTORSIZE EQU 512 -RAMDRVMAXBANK EQU (RAMDRVSIZE * 1024)/UROMSIZE ; Maximum Bank number for the RAM drive. - -;ROMBK1: EQU 01016H ; CURRENT MROM BANK -;ROMBK2: EQU 01017H ; CURRENT USERROM BANK -;WRKROMBK1: EQU 01018H ; WORKING MROM BANK -;WRKROMBK2: EQU 01019H ; WORKING USERROM BANK - -;----------------------------------------------- -; ROM Banks, 0-7 are reserved for alternative -; Monitor versions, CPM and RFS -; code in MROM bank, -; 0-7 are reserved for RFS code in -; the User ROM bank. -; 8-15 are reserved for CPM code in -; the User ROM bank. -;----------------------------------------------- -MROMPAGES EQU 8 -USRROMPAGES EQU 12 ; Monitor ROM : User ROM -ROMBANK0 EQU 0 ; MROM SA1510 40 Char : RFS Bank 0 - Main RFS Entry point and functions. -ROMBANK1 EQU 1 ; MROM SA1510 80 Char : RFS Bank 1 - Floppy disk controller and utilities. -ROMBANK2 EQU 2 ; CPM 2.2 CBIOS : RFS Bank 2 - SD Card controller and utilities. -ROMBANK3 EQU 3 ; RFS Utilities : RFS Bank 3 - Cmdline tools (Memory, Printer, Help) -ROMBANK4 EQU 4 ; Free : RFS Bank 4 - CMT Utilities. -ROMBANK5 EQU 5 ; Free : RFS Bank 5 -ROMBANK6 EQU 6 ; Free : RFS Bank 6 -ROMBANK7 EQU 7 ; Free : RFS Bank 7 - Memory and timer test utilities. -ROMBANK8 EQU 8 ; : CBIOS Bank 1 - Utilities -ROMBANK9 EQU 9 ; : CBIOS Bank 2 - Screen / ANSI Terminal -ROMBANK10 EQU 10 ; : CBIOS Bank 3 - SD Card -ROMBANK11 EQU 11 ; : CBIOS Bank 4 - Floppy disk controller. - - - -OBJCD EQU 001h - -;----------------------------------------------- -; IO Registers -;----------------------------------------------- -FDC EQU 0D8h ; MB8866 IO Region 0D8h - 0DBh -FDC_CR EQU FDC + 000h ; Command Register -FDC_STR EQU FDC + 000h ; Status Register -FDC_TR EQU FDC + 001h ; Track Register -FDC_SCR EQU FDC + 002h ; Sector Register -FDC_DR EQU FDC + 003h ; Data Register -FDC_MOTOR EQU FDC + 004h ; DS[0-3] and Motor control. 4 drives DS= BIT 0 -> Bit 2 = Drive number, 2=1,1=0,0=0 DS0, 2=1,1=0,0=1 DS1 etc - ; bit 7 = 1 MOTOR ON LOW (Active) -FDC_SIDE EQU FDC + 005h ; Side select, Bit 0 when set = SIDE SELECT LOW - -;----------------------------------------------- -; Common character definitions. -;----------------------------------------------- -SCROLL EQU 001H ;Set scroll direction UP. -BELL EQU 007H -SPACE EQU 020H -TAB EQU 009H ;TAB ACROSS (8 SPACES FOR SD-BOARD) -CR EQU 00DH -LF EQU 00AH -FF EQU 00CH -CS EQU 0CH ; Clear screen -DELETE EQU 07FH -BACKS EQU 008H -SOH EQU 1 ; For XModem etc. -EOT EQU 4 -ACK EQU 6 -NAK EQU 015H -NUL EQU 000H -NULL EQU 000H -CTRL_A EQU 001H -CTRL_B EQU 002H -CTRL_C EQU 003H -CTRL_D EQU 004H -CTRL_E EQU 005H -CTRL_F EQU 006H -CTRL_G EQU 007H -CTRL_H EQU 008H -CTRL_I EQU 009H -CTRL_J EQU 00AH -CTRL_K EQU 00BH -CTRL_L EQU 00CH -CTRL_M EQU 00DH -CTRL_N EQU 00EH -CTRL_O EQU 00FH -CTRL_P EQU 010H -CTRL_Q EQU 011H -CTRL_R EQU 012H -CTRL_S EQU 013H -CTRL_T EQU 014H -CTRL_U EQU 015H -CTRL_V EQU 016H -CTRL_W EQU 017H -CTRL_X EQU 018H -CTRL_Y EQU 019H -CTRL_Z EQU 01AH -ESC EQU 01BH -CTRL_SLASH EQU 01CH -CTRL_LB EQU 01BH -CTRL_RB EQU 01DH -CTRL_CAPPA EQU 01EH -CTRL_UNDSCR EQU 01FH -CTRL_AT EQU 000H -NOKEY EQU 0F0H -CURSRIGHT EQU 0F1H -CURSLEFT EQU 0F2H -CURSUP EQU 0F3H -CURSDOWN EQU 0F4H -DBLZERO EQU 0F5H -INSERT EQU 0F6H -CLRKEY EQU 0F7H -HOMEKEY EQU 0F8H -BREAKKEY EQU 0FBH -GRAPHKEY EQU 0FCH -ALPHAKEY EQU 0FDH - - -; MMC/SD command (SPI mode) -CMD0 EQU 64 + 0 ; GO_IDLE_STATE -CMD1 EQU 64 + 1 ; SEND_OP_COND -ACMD41 EQU 0x40+41 ; SEND_OP_COND (SDC) -CMD8 EQU 64 + 8 ; SEND_IF_COND -CMD9 EQU 64 + 9 ; SEND_CSD -CMD10 EQU 64 + 10 ; SEND_CID -CMD12 EQU 64 + 12 ; STOP_TRANSMISSION -CMD13 EQU 64 + 13 ; SEND_STATUS -ACMD13 EQU 0x40+13 ; SD_STATUS (SDC) -CMD16 EQU 64 + 16 ; SET_BLOCKLEN -CMD17 EQU 64 + 17 ; READ_SINGLE_BLOCK -CMD18 EQU 64 + 18 ; READ_MULTIPLE_BLOCK -CMD23 EQU 64 + 23 ; SET_BLOCK_COUNT -ACMD23 EQU 0x40+23 ; SET_WR_BLK_ERASE_COUNT (SDC) -CMD24 EQU 64 + 24 ; WRITE_BLOCK -CMD25 EQU 64 + 25 ; WRITE_MULTIPLE_BLOCK -CMD32 EQU 64 + 32 ; ERASE_ER_BLK_START -CMD33 EQU 64 + 33 ; ERASE_ER_BLK_END -CMD38 EQU 64 + 38 ; ERASE -CMD55 EQU 64 + 55 ; APP_CMD -CMD58 EQU 64 + 58 ; READ_OCR - -; Card type flags (CardType) -CT_MMC EQU 001H ; MMC ver 3 -CT_SD1 EQU 002H ; SD ver 1 -CT_SD2 EQU 004H ; SD ver 2 -CT_SDC EQU CT_SD1|CT_SD2 ; SD -CT_BLOCK EQU 008H ; Block addressing - -; Disk types. -DSKTYP_FDC EQU 0 ; Type of disk is a Floppy disk and handled by the FDC controller. -DSKTYP_ROM EQU 1 ; Type of disk is a ROM and handled by the ROM methods. -DSKTYP_SDC EQU 2 ; Type of disk is an SD Card and handled by the SD Card methods. -DSKTYP_RAM EQU 3 ; Type of disk is a RAM Drive handled by ROM/RAM methods. - -; -; Rom Filing System constants. -; -RFS_DIRENT EQU 256 ; Directory entries in the RFS directory. -RFS_DIRENTSZ EQU 32 ; Size of a directory entry. -RFS_DIRSIZE EQU RFS_DIRENT * RFS_DIRENTSZ ; Total size of the directory. -RFS_BLOCKSZ EQU 65536 ; Size of a file block per directory entry. -RFS_DRIVES EQU 10 ; Number of RFS Drives (Images). -RFS_IMGSZ EQU RFS_DIRSIZE + (RFS_DIRENT * RFS_BLOCKSZ) ; Total size of the RFS image. -RFS_END_ADDR EQU 010000000H ; End of RFS/Start of CP/M. - -; -; CPM constants -; -CPM_SD_SEC EQU 32 -CPM_SD_TRK EQU 1024 -CPM_SD_IMGSZ EQU CPM_SD_TRK * CPM_SD_SEC * SD_SECSIZE - -; -; SD Card constants. -; -SD_SECSIZE EQU 512 ; Default size of an SD Sector -SD_SECPTRK EQU CPM_SD_SEC ; Sectors of SD_SECSIZE per virtual track. -SD_TRACKS EQU CPM_SD_TRK ; Number of virtual tracks per disk image. -SD_RETRIES EQU 00100H ; Number of retries before giving up. - - -;----------------------------------------------- -; BIOS WORK AREA (MZ80A) -;----------------------------------------------- - ORG CBIOSDATA - - ; Keyboard processing, ensure starts where LSB = 0. -VARSTART EQU $ ; Start of variables. -KEYBUF: DS virtual KEYBUFSIZE ; Interrupt driven keyboard buffer. -KEYCOUNT: DS virtual 1 -KEYWRITE: DS virtual 2 ; Pointer into the buffer where the next character should be placed. -KEYREAD: DS virtual 2 ; Pointer into the buffer where the next character can be read. -KEYLAST: DS virtual 1 ; KEY LAST VALUE -KEYRPT: DS virtual 1 ; KEY REPEAT COUNTER -USRBANKSAV: DS virtual 1 ; Save user bank number when calling another user bank. -HLSAVE: DS virtual 2 ; Space to save HL register when manipulating stack. -ROMCTL DS virtual 1 ; Rom Paging control register contents. -; -SPV: -IBUFE: ; TAPE BUFFER (128 BYTES) -ATRB: DS virtual 1 ; ATTRIBUTE -NAME: DS virtual 17 ; FILE NAME -SIZE: DS virtual 2 ; BYTESIZE -DTADR: DS virtual 2 ; DATA ADDRESS -EXADR: DS virtual 2 ; EXECUTION ADDRESS -COMNT: DS virtual 92 ; Comment / code area of CMT header. -SWPW: DS virtual 10 ; SWEEP WORK -KDATW: DS virtual 2 ; KEY WORK -KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) -DSPXY: DS virtual 2 ; DISPLAY COORDINATES -;DSPXYLST: DS virtual 2 ; Last known cursor position, to compare with DSPXY to detect changes. -MANG: DS virtual 6 ; COLUMN MANAGEMENT -MANGE: DS virtual 1 ; COLUMN MANAGEMENT END -PBIAS: DS virtual 1 ; PAGE BIAS -ROLTOP: DS virtual 1 ; ROLL TOP BIAS -MGPNT: DS virtual 1 ; COLUMN MANAG. POINTER -PAGETP: DS virtual 2 ; PAGE TOP -ROLEND: DS virtual 1 ; ROLL END - DS virtual 14 ; BIAS -FLASH: DS virtual 1 ; FLASHING DATA -SFTLK: DS virtual 1 ; SHIFT LOCK -REVFLG: DS virtual 1 ; REVERSE FLAG -FLSDT: DS virtual 1 ; CURSOR DATA -STRGF: DS virtual 1 ; STRING FLAG -DPRNT: DS virtual 1 ; TAB COUNTER -FLASHCTL: DS virtual 1 ; CURSOR FLASH CONTROL. BIT 0 = Cursor On/Off, BIT 1 = Cursor displayed. -DSPXYADDR: DS virtual 2 ; Address of last known position. -;AMPM: DS virtual 1 ; AMPM DATA -;TIMFG: DS virtual 1 ; TIME FLAG -SWRK: DS virtual 1 ; KEY SOUND FLAG -TEMPW: DS virtual 1 ; TEMPO WORK -ONTYO: DS virtual 1 ; ONTYO WORK -OCTV: DS virtual 1 ; OCTAVE WORK -RATIO: DS virtual 2 ; ONPU RATIO -;BUFER: DS virtual 81 ; GET LINE BUFFER -;KEYBUF: DS virtual 1 ; KEY BUFFER -DRVAVAIL DS virtual 1 ; Flag to indicate which drive controllers are available. Bit 2 = SD, Bit 1 = ROM, Bit 0 = FDC -TIMESEC DS virtual 6 ; RTC 48bit TIME IN MILLISECONDS -FDCCMD DS virtual 1 ; LAST FDC COMMAND SENT TO CONTROLLER. -MOTON DS virtual 1 ; MOTOR ON = 1, OFF = 0 -INVFDCDATA: DS virtual 1 ; INVERT DATA COMING FROM FDC, 1 = INVERT, 0 = AS IS -TRK0FD1 DS virtual 1 ; FD 1 IS AT TRACK 0 = BIT 0 set -TRK0FD2 DS virtual 1 ; FD 2 IS AT TRACK 0 = BIT 0 set -TRK0FD3 DS virtual 1 ; FD 3 IS AT TRACK 0 = BIT 0 set -TRK0FD4 DS virtual 1 ; FD 4 IS AT TRACK 0 = BIT 0 set -RETRIES DS virtual 2 ; DATA READ RETRIES -TMPADR DS virtual 2 ; TEMPORARY ADDRESS STORAGE -TMPSIZE DS virtual 2 ; TEMPORARY SIZE -TMPCNT DS virtual 2 ; TEMPORARY COUNTER -; -CPMROMLOC: DS virtual 2 ; Upper Byte = ROM Bank, Lower Byte = Page of CPM Image. -;CPMROMDRV0: DS virtual 2 ; Upper Byte = ROM Bank, Lower Byte = Page of CPM Rom Drive Image Disk 0. -;CPMROMDRV1: DS virtual 2 ; Upper Byte = ROM Bank, Lower Byte = Page of CPM Rom Drive Image Disk 1. -NDISKS: DS virtual 1 ; Dynamically calculated number of disks on boot. -DISKMAP: DS virtual MAXDISKS ; Disk map of CPM logical to physical controller disk. -FDCDISK: DS virtual 1 ; Physical disk number. -SECPERTRK: DS virtual 1 ; Sectors per track for 1 head. -SECPERHEAD: DS virtual 1 ; Sectors per head. -SECTORCNT: DS virtual 1 ; Sector size as a count of how many sectors make 512 bytes. -DISKTYPE: DS virtual 1 ; Disk type of current selection. -MTROFFTIMER: DS virtual 1 ; Second down counter for FDC motor off. -; -SEKDSK: DS virtual 1 ; Seek disk number -SEKTRK: DS virtual 2 ; Seek disk track -SEKSEC: DS virtual 1 ; Seek sector number -SEKHST: DS virtual 1 ; Seek sector host -; -HSTDSK: DS virtual 1 ; Host disk number -HSTTRK: DS virtual 2 ; Host track number -HSTSEC: DS virtual 1 ; Host sector number -HSTWRT: DS virtual 1 ; Host write flag -HSTACT: DS virtual 1 ; -; -UNACNT: DS virtual 1 ; Unalloc rec cnt -UNADSK: DS virtual 1 ; Last unalloc disk -UNATRK: DS virtual 2 ; Last unalloc track -UNASEC: DS virtual 1 ; Last unalloc sector -; -ERFLAG: DS virtual 1 ; Error number, 0 = no error. -READOP: DS virtual 1 ; If read operation then 1, else 0 for write. -RSFLAG: DS virtual 1 ; Read sector flag. -WRTYPE: DS virtual 1 ; Write operation type. -TRACKNO: DS virtual 2 ; Host controller track number -SECTORNO: DS virtual 1 ; Host controller sector number -DMAADDR: DS virtual 2 ; Last DMA address -HSTBUF: DS virtual 512 ; Host buffer for disk sector storage -HSTBUFE: - -SDVER: DS virtual 1 ; SD Card version. -SDCAP: DS virtual 1 ; SD Card capabilities.. -SDSTARTSEC DS virtual 4 ; Starting sector of data to read/write from/to SD card. -SDBUF: DS virtual 11 ; SD Card command fram buffer for the command and response storage. - -CURSORPSAV DS virtual 2 ; Cursor save position;default 0,0 -HAVELOADED DS virtual 1 ; To show that a value has been put in for Ansi emualtor. -ANSIFIRST DS virtual 1 ; Holds first character of Ansi sequence -NUMBERBUF DS virtual 20 ; Buffer for numbers in Ansi -NUMBERPOS DS virtual 2 ; Address within buffer -CHARACTERNO DS virtual 1 ; Byte within Ansi sequence. 0=first,255=other -CURSORCOUNT DS virtual 1 ; 1/50ths of a second since last change -FONTSET DS virtual 1 ; Ansi font setup. -JSW_FF DS virtual 1 ; Byte value to turn on/off FF routine -JSW_LF DS virtual 1 ; Byte value to turn on/off LF routine -CHARACTER DS virtual 1 ; To buffer character to be printed. -CURSORPOS DS virtual 2 ; Cursor position, default 0,0. -BOLDMODE DS virtual 1 -HIBRITEMODE DS virtual 1 ; 0 means on, &C9 means off -UNDERSCMODE DS virtual 1 -ITALICMODE DS virtual 1 -INVMODE DS virtual 1 -CHGCURSMODE DS virtual 1 -ANSIMODE DS virtual 1 ; 1 = on, 0 = off -COLOUR EQU 0 - -SPSAVE: DS virtual 2 ; CPM Stack save. -SPISRSAVE: DS virtual 2 - ; Stack space for the CBIOS. -MSGSTRBUF: DS virtual 128 ; Lower end of the stack space is for interbank message printing, ie.space for a string to print. -BIOSSTACK EQU $ - ; Stack space for the Interrupt Service Routine. - DS virtual 16 ; Max 8 stack pushes. -ISRSTACK EQU $ - -DBGSTACKP: DS virtual 2 - DS virtual 36 -DBGSTACK: EQU $ - -VAREND EQU $ ; End of variables diff --git a/software/asm/include/macros.asm b/software/asm/include/macros.asm deleted file mode 100644 index 98f06ac..0000000 --- a/software/asm/include/macros.asm +++ /dev/null @@ -1,34 +0,0 @@ -; the following is only to get the original length of 2048 bytes -ALIGN: MACRO ?boundary - DS ?boundary - 1 - ($ + ?boundary - 1) % ?boundary, 0FFh - ENDM - -; the following is only to get the original length of 2048 bytes -ALIGN_NOPS:MACRO ?boundary - DS ?boundary - 1 - ($ + ?boundary - 1) % ?boundary, 000h - ENDM - -; -; Pads up to a certain address. -; Gives an error message if that address is already exceeded. -; -PAD: MACRO ?address - IF $ > ?address - ERROR "Alignment exceeds %s"; % ?address - ENDIF - ds ?address - $ - ENDM - -; -; Pads up to the next multiple of the specified address. -; -;ALIGN: MACRO ?boundary -; ds ?boundary - 1 - ($ + ?boundary - 1) % ?boundary -; ENDM - -; -; Pads to ensure a section of the given size does not cross a 100H boundary. -; -ALIGN_FIT8: MACRO ?size - ds (($ + ?size - 1) >> 8) != ($ >> 8) && (100H - ($ & 0FFH)) || 0 - ENDM diff --git a/software/asm/include/msbasic_buildversion.asm b/software/asm/include/msbasic_buildversion.asm deleted file mode 100644 index cdc5619..0000000 --- a/software/asm/include/msbasic_buildversion.asm +++ /dev/null @@ -1 +0,0 @@ -BUILD_VERSION EQU 2 diff --git a/software/asm/include/msbasic_definitions.asm b/software/asm/include/msbasic_definitions.asm deleted file mode 100644 index c272ddd..0000000 --- a/software/asm/include/msbasic_definitions.asm +++ /dev/null @@ -1,473 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: MSBASIC_Definitions.asm -;- Created: June 2020 -;- Author(s): Philip Smart -;- Description: Sharp MZ series CPM v2.23 -;- Definitions for the Sharp MZ80A CPM v2.23 OS used in the RFS -;- -;- Credits: -;- Copyright: (c) 2019-23 Philip Smart -;- -;- History: Jan 2020 - Initial version. -; May 2020 - Advent of the new RFS PCB v2.0, quite a few changes to accommodate the -; additional and different hardware. The SPI is now onboard the PCB and -; not using the printer interface card. -; Jun 2020 - Copied and strpped from TZFS for BASIC. -; Mar 2021 - Updates to run on v2.1 RFS board and provide SD card CLOAD/CSAVE and DIR -; along with bug fixes. -; -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - -;----------------------------------------------- -; Features. -;----------------------------------------------- - -;----------------------------------------------- - -;----------------------------------------------- -; Configurable settings. -;----------------------------------------------- -; Build options. Set just one to '1' the rest to '0'. -; NB: As there are now 4 versions and 1 or more need to be built, ie. MZ-80A and RFS version for RFS, a flag is set in the file -; BASIC_build.asm which configures the equates below for the correct build. - IF BUILD_VERSION = 0 -BUILD_MZ80A EQU 1 ; Build for the standard Sharp MZ80A, no lower memory. Manually change MAXMEM above. -BUILD_RFS EQU 0 ; Build for standard RFS with SD enhancements. -BUILD_RFSTZ EQU 0 ; Build for RFS where the tranZPUter board is available without the K64F and running under RFS. -BUILD_TZFS EQU 0 ; Build for TZFS where extended memory is available. -BUILD_80C EQU 0 -INCLUDE_ANSITERM EQU 1 ; Include the Ansi terminal emulation processor in the build. - ENDIF - IF BUILD_VERSION = 1 -BUILD_MZ80A EQU 0 -BUILD_RFS EQU 1 -BUILD_RFSTZ EQU 0 -BUILD_TZFS EQU 0 -BUILD_80C EQU 1 -INCLUDE_ANSITERM EQU 1 ; Include the Ansi terminal emulation processor in the build. - ENDIF - IF BUILD_VERSION = 2 -BUILD_MZ80A EQU 0 -BUILD_RFS EQU 1 -BUILD_RFSTZ EQU 0 -BUILD_TZFS EQU 0 -BUILD_80C EQU 0 -INCLUDE_ANSITERM EQU 1 ; Include the Ansi terminal emulation processor in the build. - ENDIF - IF BUILD_VERSION = 3 -BUILD_MZ80A EQU 0 -BUILD_RFS EQU 0 -BUILD_RFSTZ EQU 1 -BUILD_TZFS EQU 0 -BUILD_80C EQU 1 -INCLUDE_ANSITERM EQU 1 ; Include the Ansi terminal emulation processor in the build. - ENDIF - IF BUILD_VERSION = 4 -BUILD_MZ80A EQU 0 -BUILD_RFS EQU 0 -BUILD_RFSTZ EQU 0 -BUILD_TZFS EQU 1 -BUILD_80C EQU 1 -INCLUDE_ANSITERM EQU 1 ; Include the Ansi terminal emulation processor in the build. - ENDIF - IF BUILD_80C = 1 -COLW: EQU 80 ; Width of the display screen (ie. columns). - ELSE -COLW: EQU 40 ; Width of the display screen (ie. columns). - ENDIF -TMRTICKINTV EQU 5 ; Number of 0.010mSec ticks per interrupt, ie. resolution of RTC. -ROW: EQU 25 ; Number of rows on display screen. -SCRNSZ: EQU COLW * ROW ; Total size, in bytes, of the screen display area. -SCRLW: EQU COLW / 8 ; Number of 8 byte regions in a line for hardware scroll. - -; BIOS equates -KEYBUFSIZE EQU 64 ; Ensure this is a power of 2, max size 256. - IF BUILD_MZ80A = 1 -MAXMEM EQU 0CFFFH ; Top of RAM on a standard Sharp MZ80A. - ENDIF - IF BUILD_RFS = 1 -MAXMEM EQU 0CFFFH - TZSVCSECSIZE ; Top of RAM on a standard RFS equipped Sharp MZ80A. Top 512 bytes used by RFS SD sector buffer. - ENDIF - IF BUILD_TZFS+BUILD_RFSTZ > 0 -MAXMEM EQU 10000H - TZSVCSIZE ; Top of RAM on the tranZPUter - ENDIF - -; Tape load/save modes. Used as a flag to enable common code. -TAPELOAD EQU 1 -CTAPELOAD EQU 2 -TAPESAVE EQU 3 -CTAPESAVE EQU 4 - -; Debugging -ENADEBUG EQU 0 ; Enable debugging logic, 1 = enable, 0 = disable - -;----------------------------------------------- -; CMT Object types. -;----------------------------------------------- -ATR_OBJ EQU 1 -ATR_BASIC_PROG EQU 2 -ATR_BASIC_DATA EQU 3 -ATR_SRC_FILE EQU 4 -ATR_RELOC_FILE EQU 5 -ATR_BASIC_MSCAS EQU 07EH -ATR_BASIC_MSTXT EQU 07FH -ATR_PASCAL_PROG EQU 0A0H -ATR_PASCAL_DATA EQU 0A1H -CMTATRB EQU 010F0H -CMTNAME EQU 010F1H - -;------------------------------------------------------- -; Function entry points in the standard SA-1510 Monitor. -;------------------------------------------------------- -QWRI EQU 00021h -QWRD EQU 00024h -QRDI EQU 00027h -QRDD EQU 0002Ah -QVRFY EQU 0002Dh - -;------------------------------------------------------- -; Function entry points in the RFS ROM. -;------------------------------------------------------- -CMT_RDINF EQU 0E886H ; UROMADDR+86H - Tape/SD intercept handler - Read Header -CMT_RDDATA EQU 0E889H ; UROMADDR+89H - Tape/SD intercept handler - Read Data -CMT_WRINF EQU 0E88CH ; UROMADDR+80H - Tape/SD intercept handler - Write Header -CMT_WRDATA EQU 0E88FH ; UROMADDR+8FH - Tape/SD intercept handler - Write Data -CMT_VERIFY EQU 0E892H ; UROMADDR+92H - Tape/SD intercept handler - Verify Data -CMT_DIR EQU 0E895H ; UROMADDR+95H - SD directory command. -CNV_ATOS EQU 0E898H ; UROMADDR+98H - Convert an ASCII string into Sharp ASCII - -;----------------------------------------------- -; BASIC ERROR CODE VALUES -;----------------------------------------------- -NF EQU 00H ; NEXT without FOR -SN EQU 02H ; Syntax error -RG EQU 04H ; RETURN without GOSUB -OD EQU 06H ; Out of DATA -FC EQU 08H ; Function call error -OV EQU 0AH ; Overflow -OM EQU 0CH ; Out of memory -UL EQU 0EH ; Undefined line number -BS EQU 10H ; Bad subscript -DDA EQU 12H ; Re-DIMensioned array -DZ EQU 14H ; Division by zero (/0) -ID EQU 16H ; Illegal direct -TM EQU 18H ; Type miss-match -OS EQU 1AH ; Out of string space -LS EQU 1CH ; String too long -ST EQU 1EH ; String formula too complex -CN EQU 20H ; Can't CONTinue -UF EQU 22H ; UnDEFined FN function -MO EQU 24H ; Missing operand -HX EQU 26H ; HEX error -BN EQU 28H ; BIN error -BV EQU 2AH ; Bad Value error -IO EQU 2CH ; IO error - -;----------------------------------------------- -; Memory mapped ports in hardware. -;----------------------------------------------- -SCRN: EQU 0D000H -ARAM: EQU 0D800H -DSPCTL: EQU 0DFFFH ; Screen 40/80 select register (bit 7) -KEYPA: EQU 0E000h -KEYPB: EQU 0E001h -KEYPC: EQU 0E002h -KEYPF: EQU 0E003h -CSTR: EQU 0E002h -CSTPT: EQU 0E003h -CONT0: EQU 0E004h -CONT1: EQU 0E005h -CONT2: EQU 0E006h -CONTF: EQU 0E007h -SUNDG: EQU 0E008h -TEMP: EQU 0E008h -MEMSW: EQU 0E00CH -MEMSWR: EQU 0E010H -INVDSP: EQU 0E014H -NRMDSP: EQU 0E015H -SCLDSP: EQU 0E200H -SCLBASE: EQU 0E2H -BNKCTRLRST: EQU 0EFF8H ; Bank control reset, returns all registers to power up default. -BNKCTRLDIS: EQU 0EFF9H ; Disable bank control registers by resetting the coded latch. -HWSPIDATA: EQU 0EFFBH ; Hardware SPI Data register (read/write). -HWSPISTART: EQU 0EFFCH ; Start an SPI transfer. -BNKSELMROM: EQU 0EFFDh ; Select RFS Bank1 (MROM) -BNKSELUSER: EQU 0EFFEh ; Select RFS Bank2 (User ROM) -BNKCTRL: EQU 0EFFFH ; Bank Control register (read/write). - -;----------------------------------------------- -; IO Registers -;----------------------------------------------- -FDC EQU 0D8h ; MB8866 IO Region 0D8h - 0DBh -FDC_CR EQU FDC + 000h ; Command Register -FDC_STR EQU FDC + 000h ; Status Register -FDC_TR EQU FDC + 001h ; Track Register -FDC_SCR EQU FDC + 002h ; Sector Register -FDC_DR EQU FDC + 003h ; Data Register -FDC_MOTOR EQU FDC + 004h ; DS[0-3] and Motor control. 4 drives DS= BIT 0 -> Bit 2 = Drive number, 2=1,1=0,0=0 DS0, 2=1,1=0,0=1 DS1 etc - ; bit 7 = 1 MOTOR ON LOW (Active) -FDC_SIDE EQU FDC + 005h ; Side select, Bit 0 when set = SIDE SELECT LOW - -;----------------------------------------------- -; Common character definitions. -;----------------------------------------------- -SCROLL EQU 001H ;Set scroll direction UP. -BELL EQU 007H -SPACE EQU 020H -TAB EQU 009H ;TAB ACROSS (8 SPACES FOR SD-BOARD) -CR EQU 00DH -LF EQU 00AH -FF EQU 00CH -CS EQU 0CH ; Clear screen -DELETE EQU 07FH -BACKS EQU 008H -SOH EQU 1 ; For XModem etc. -EOT EQU 4 -ACK EQU 6 -NAK EQU 015H -NUL EQU 000H -;NULL EQU 000H -CTRL_A EQU 001H -CTRL_B EQU 002H -CTRL_C EQU 003H -CTRL_D EQU 004H -CTRL_E EQU 005H -CTRL_F EQU 006H -CTRL_G EQU 007H -CTRL_H EQU 008H -CTRL_I EQU 009H -CTRL_J EQU 00AH -CTRL_K EQU 00BH -CTRL_L EQU 00CH -CTRL_M EQU 00DH -CTRL_N EQU 00EH -CTRL_O EQU 00FH -CTRL_P EQU 010H -CTRL_Q EQU 011H -CTRL_R EQU 012H -CTRL_S EQU 013H -CTRL_T EQU 014H -CTRL_U EQU 015H -CTRL_V EQU 016H -CTRL_W EQU 017H -CTRL_X EQU 018H -CTRL_Y EQU 019H -CTRL_Z EQU 01AH -ESC EQU 01BH -CTRL_SLASH EQU 01CH -CTRL_LB EQU 01BH -CTRL_RB EQU 01DH -CTRL_CAPPA EQU 01EH -CTRL_UNDSCR EQU 01FH -CTRL_AT EQU 000H -NOKEY EQU 0F0H -CURSRIGHT EQU 0F1H -CURSLEFT EQU 0F2H -CURSUP EQU 0F3H -CURSDOWN EQU 0F4H -DBLZERO EQU 0F5H -INSERT EQU 0F6H -CLRKEY EQU 0F7H -HOMEKEY EQU 0F8H -BREAKKEY EQU 0FBH -GRAPHKEY EQU 0FCH -ALPHAKEY EQU 0FDH - - -;----------------------------------------------- -; Rom File System variable addresses. -;----------------------------------------------- -; Starting 1000H - Generally unused bytes not cleared by the monitor. -ROMBK1: EQU 01016H ; CURRENT MROM BANK -ROMBK2: EQU 01017H ; CURRENT USERROM BANK -WRKROMBK1: EQU 01018H ; WORKING MROM BANK -WRKROMBK2: EQU 01019H ; WORKING USERROM BANK -ROMCTL: EQU 0101AH ; Current Bank control register setting. -SCRNMODE: EQU 0101BH ; Mode of screen, 0 = 40 char, 1 = 80 char. -TMPADR: EQU 0101CH ; TEMPORARY ADDRESS STORAGE -TMPSIZE: EQU 0101EH ; TEMPORARY SIZE -TMPCNT: EQU 01020H ; TEMPORARY COUNTER -TMPLINECNT: EQU 01022H ; Temporary counter for displayed lines. -TMPSTACKP: EQU 01024H ; Temporary stack pointer save. -SDVER: EQU 01026H -SDCAP: EQU 01027H -SDDRIVENO EQU 01028H ; RFS SDCFS Active Drive Number -CMTFILENO EQU 01029H ; Next Sequential file number to read when file request given without name. -TZPU: EQU 0102AH ; Tranzputer present flag (0 = not present, > 0 = present and version number). -; Variables sharing the BUFER buffer, normally the BUFER is only used to get keyboard input and so long as data in BUFER is processed -; before calling the CMT/SD commands and not inbetween there shouldnt be any issue. Also the space used is at the top end of the buffer which is not used so often. -; This frees up memory needed by the CMT and SD card. -SECTORBUF: EQU 0CE00H ; Working buffer to place an SD card sector. -SDSTARTSEC EQU BUFER+50+0 ; Starting sector of data to read/write from/to SD card. -SDLOADADDR EQU BUFER+50+4 ; Address to read/write data from/to SD card. -SDLOADSIZE EQU BUFER+50+6 ; Total remaining byte count data to read/write from/to SD card. -SDAUTOEXEC EQU BUFER+50+8 ; Flag to indicate if a loaded image should be executed (=0xFF) -SDBUF: EQU BUFER+50+9 ; SD Card command fram buffer for the command and response storage. -DIRSECBUF: EQU BUFER+50+20 ; Directory sector in cache. -DUMPADDR: EQU BUFER+50+22 ; Address used by the D(ump) command so that calls without parameters go onto the next block. -CMTLOLOAD: EQU BUFER+50+24 ; Flag to indicate that a tape program is loaded into hi memory then shifted to low memory after ROM pageout. -CMTCOPY: EQU BUFER+50+25 ; Flag to indicate that a CMT copy operation is taking place. -CMTAUTOEXEC: EQU BUFER+50+26 ; Auto execution flag, run CMT program when loaded if flag clear. -DTADRSTORE: EQU BUFER+50+27 ; Backup for load address if actual load shifts to lo memory or to 0x1200 for copy. -SDCOPY: EQU BUFER+50+29 ; Flag to indicate an SD copy is taking place, either CMT->SD or SD->CMT. -RESULT: EQU BUFER+50+30 ; Result variable needed for interbank calls when a result is needed. - -;-------------------------------------------------- -; RFS ROM Banks, 0-7 are reserved for alternative -; Monitor versions, CPM and RFS -; code in MROM bank, -; 0-7 are reserved for RFS code in -; the User ROM bank. -; 8-15 are reserved for CPM code in -; the User ROM bank. -;-------------------------------------------------- -MROMPAGES EQU 8 -USRROMPAGES EQU 12 ; Monitor ROM : User ROM -ROMBANK0 EQU 0 ; MROM SA1510 40 Char : RFS Bank 0 - Main RFS Entry point and functions. -ROMBANK1 EQU 1 ; MROM SA1510 80 Char : RFS Bank 1 - Floppy disk controller and utilities. -ROMBANK2 EQU 2 ; CPM 2.2 CBIOS : RFS Bank 2 - SD Card controller and utilities. -ROMBANK3 EQU 3 ; RFS Utilities : RFS Bank 3 - Cmdline tools (Memory, Printer, Help) -ROMBANK4 EQU 4 ; MZ700 1Z-013A 40C : RFS Bank 4 - CMT Utilities. -ROMBANK5 EQU 5 ; MZ700-1Z-013A 80C : RFS Bank 5 -ROMBANK6 EQU 6 ; MZ-80B IPL : RFS Bank 6 -ROMBANK7 EQU 7 ; Free : RFS Bank 7 - Memory and timer test utilities. -ROMBANK8 EQU 8 ; : CBIOS Bank 1 - Utilities -ROMBANK9 EQU 9 ; : CBIOS Bank 2 - Screen / ANSI Terminal -ROMBANK10 EQU 10 ; : CBIOS Bank 3 - SD Card -ROMBANK11 EQU 11 ; : CBIOS Bank 4 - Floppy disk controller. - -;----------------------------------------------- -; IO ports in hardware and values. -;----------------------------------------------- -MMCFG EQU 060H ; Memory management configuration latch. -SETXMHZ EQU 062H ; Select the alternate clock frequency. -SET2MHZ EQU 064H ; Select the system 2MHz clock frequency. -CLKSELRD EQU 066H ; Read clock selected setting, 0 = 2MHz, 1 = XMHz -SVCREQ EQU 068H ; I/O Processor service request. - -;----------------------------------------------- -; tranZPUter SW Memory Management modes -;----------------------------------------------- -TZMM_ORIG EQU 000H ; Original Sharp MZ80A mode, no tranZPUter features are selected except the I/O control registers (default: 0x60-063). -TZMM_BOOT EQU 001H ; Original mode but E800-EFFF is mapped to tranZPUter RAM so TZFS can be booted. -TZMM_TZFS EQU 002H ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-FFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected. -TZMM_TZFS2 EQU 003H ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 1. -TZMM_TZFS3 EQU 004H ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 2. -TZMM_TZFS4 EQU 005H ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 3. -TZMM_CPM EQU 006H ; CPM main memory configuration, all memory on the tranZPUter board, 64K block 4 selected. Special case for F3C0:F3FF & F7C0:F7FF (floppy disk paging vectors) which resides on the mainboard. -TZMM_CPM2 EQU 007H ; CPM main memory configuration, F000-FFFF are on the tranZPUter board in block 4, 0040-CFFF and E800-EFFF are in block 5, mainboard for D000-DFFF (video), E000-E800 (Memory control) selected. - ; Special case for 0000:003F (interrupt vectors) which resides in block 4, F3C0:F3FF & F7C0:F7FF (floppy disk paging vectors) which resides on the mainboard. -TZMM_COMPAT EQU 008H ; Original mode but with main DRAM in Bank 0 to allow bootstrapping of programs from other machines such as the MZ700. -TZMM_HOSTACCESS EQU 009H ; Mode to allow code running in Bank 0, address E800:FFFF to access host memory. Monitor ROM 0000-0FFF and Main DRAM 0x1000-0xD000, video and memory mapped I/O are on the host machine, User/Floppy ROM E800-FFFF are in tranZPUter memory. -TZMM_MZ700_0 EQU 00AH ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the mainboard. -TZMM_MZ700_1 EQU 00BH ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 0, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the tranZPUter in block 6. -TZMM_MZ700_2 EQU 00CH ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the tranZPUter in block 6. -TZMM_MZ700_3 EQU 00DH ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 0, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is inaccessible. -TZMM_MZ700_4 EQU 00EH ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is inaccessible. -TZMM_MZ800 EQU 00FH ; MZ800 Mode - Tracks original hardware mode offering MZ700/MZ800 configurations. -TZMM_FPGA EQU 015H ; Open up access for the K64F to the FPGA resources such as memory. All other access to RAM or mainboard is blocked. -TZMM_TZPUM EQU 016H ; Everything in on mainboard, no access to tranZPUter memory. -TZMM_TZPU EQU 017H ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 0 is selected. -TZMM_TZPU0 EQU 018H ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 0 is selected. -TZMM_TZPU1 EQU 019H ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 1 is selected. -TZMM_TZPU2 EQU 01AH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 2 is selected. -TZMM_TZPU3 EQU 01BH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 3 is selected. -TZMM_TZPU4 EQU 01CH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 4 is selected. -TZMM_TZPU5 EQU 01DH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 5 is selected. -TZMM_TZPU6 EQU 01EH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 6 is selected. -TZMM_TZPU7 EQU 01FH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 7 is selected. - -;----------------------------------------------- -; TZ File System Header (MZF) -;----------------------------------------------- -TZFS_ATRB: EQU 00000h ; Code Type, 01 = Machine Code. -TZFS_NAME: EQU 00001h ; Title/Name (17 bytes). -TZFS_SIZE: EQU 00012h ; Size of program. -TZFS_DTADR: EQU 00014h ; Load address of program. -TZFS_EXADR: EQU 00016h ; Exec address of program. -TZFS_COMNT: EQU 00018h ; Comment -TZFS_MZFLEN: EQU 128 ; Length of the MZF header. -TZFS_CMTLEN: EQU 104 ; Length of the comment field - -;----------------------------------------------- -; BIOS WORK AREA (MZ80A) -;----------------------------------------------- - ; Variables and control structure used by the I/O processor for service calls and requests. - ORG TZSVCMEM - -TZSVCMEM: EQU 0FD80H ; Start of a memory structure used to communicate with the K64F I/O processor for services such as disk access. -TZSVCSIZE: EQU 00280H ; -TZSVCDIRSZ: EQU 20 ; Size of the directory/file name. -TZSVCFILESZ: EQU 17 ; Size of a Sharp filename. -TZSVCLONGFILESZ: EQU 31 ; Size of a standard filename. -TZSVCLONGFMTSZ: EQU 20 ; Size of a formatted standard filename for use in directory listings. -TZSVCWILDSZ: EQU 20 ; Size of the wildcard. -TZSVCSECSIZE: EQU 512 -TZSVCDIR_ENTSZ: EQU 32 ; Size of a directory entry. -TZSVCWAITIORETRIES: EQU 500 ; Wait retries for IO response. -TZSVCWAITCOUNT: EQU 65535 ; Wait retries for IO request response. -TZSVC_FTYPE_MZF: EQU 0 ; File type being handled is an MZF -TZSVC_FTYPE_CAS: EQU 1 ; File type being handled is an CASsette BASIC script. -TZSVC_FTYPE_BAS: EQU 2 ; File type being handled is an BASic script -TZSVC_FTYPE_ALL: EQU 10 ; Handle any filetype. -TZSVC_FTYPE_ALLFMT: EQU 11 ; Special case for directory listings, all files but truncated and formatted. -TZSVCCMD: DS virtual 1 ; Service command. -TZSVCRESULT: DS virtual 1 ; Service command result. -TZSVCDIRSEC: DS virtual 1 ; Storage for the directory sector number. -TZSVC_FILE_SEC: EQU TZSVCDIRSEC ; Union of the file and directory sector as only one can be used at a time. -TZSVC_TRACK_NO: DS virtual 2 ; Storage for the virtual drive track number. -TZSVC_SECTOR_NO: DS virtual 2 ; Storage for the virtual drive sector number. -TZSVC_FILE_NO: DS virtual 1 ; File number to be opened in a file service command. -TZSVC_FILE_TYPE: DS virtual 1 ; Type of file being accessed to differentiate between Sharp MZF files and other handled files. -TZSVC_LOADADDR: DS virtual 2 ; Dynamic load address for rom/images. -TZSVC_SAVEADDR: EQU TZSVC_LOADADDR ; Union of the load address and the cpu frequency change value, the address of data to be saved. -TZSVC_CPU_FREQ: EQU TZSVC_LOADADDR ; Union of the load address and the save address value, only one can be used at a time. -TZSVC_LOADSIZE: DS virtual 2 ; Size of image to load. -TZSVC_SAVESIZE: EQU TZSVC_LOADSIZE ; Size of image to be saved. -TZSVC_DIRNAME: DS virtual TZSVCDIRSZ ; Service directory/file name. -TZSVC_FILENAME: DS virtual TZSVCFILESZ ; Filename to be opened/created. -TZSVCWILDC: DS virtual TZSVCWILDSZ ; Directory wildcard for file pattern matching. -TZSVCSECTOR: DS virtual TZSVCSECSIZE ; Service command sector - to store directory entries, file sector read or writes. - -TZSVC_CMD_READDIR: EQU 01H ; Service command to open a directory and return the first block of entries. -TZSVC_CMD_NEXTDIR: EQU 02H ; Service command to return the next block of an open directory. -TZSVC_CMD_READFILE: EQU 03H ; Service command to open a file and return the first block. -TZSVC_CMD_NEXTREADFILE: EQU 04H ; Service command to return the next block of an open file. -TZSVC_CMD_WRITEFILE: EQU 05H ; Service command to create a file and save the first block. -TZSVC_CMD_NEXTWRITEFILE:EQU 06H ; Service command to write the next block to the open file. -TZSVC_CMD_CLOSE: EQU 07H ; Service command to close any open file or directory. -TZSVC_CMD_LOADFILE: EQU 08H ; Service command to load a file directly into tranZPUter memory. -TZSVC_CMD_SAVEFILE: EQU 09H ; Service command to save a file directly from tranZPUter memory. -TZSVC_CMD_ERASEFILE: EQU 0aH ; Service command to erase a file on the SD card. -TZSVC_CMD_CHANGEDIR: EQU 0bH ; Service command to change the active directory on the SD card. -TZSVC_CMD_LOAD40BIOS: EQU 20H ; Service command requesting that the 40 column version of the SA1510 BIOS is loaded. -TZSVC_CMD_LOAD80BIOS: EQU 21H ; Service command requesting that the 80 column version of the SA1510 BIOS is loaded. -TZSVC_CMD_LOAD700BIOS40:EQU 22H ; Service command requesting that the MZ700 1Z-013A 40 column BIOS is loaded. -TZSVC_CMD_LOAD700BIOS80:EQU 23H ; Service command requesting that the MZ700 1Z-013A 80 column patched BIOS is loaded. -TZSVC_CMD_LOAD80BIPL: EQU 24H ; Service command requesting the MZ-80B IPL is loaded. -TZSVC_CMD_LOADBDOS: EQU 30H ; Service command to reload CPM BDOS+CCP. -TZSVC_CMD_ADDSDDRIVE: EQU 31H ; Service command to attach a CPM disk to a drive number. -TZSVC_CMD_READSDDRIVE: EQU 32H ; Service command to read an attached SD file as a CPM disk drive. -TZSVC_CMD_WRITESDDRIVE: EQU 33H ; Service command to write to a CPM disk drive which is an attached SD file. -TZSVC_CMD_CPU_BASEFREQ EQU 40H ; Service command to switch to the mainboard frequency. -TZSVC_CMD_CPU_ALTFREQ EQU 41H ; Service command to switch to the alternate frequency provided by the K64F. -TZSVC_CMD_CPU_CHGFREQ EQU 42H ; Service command to set the alternate frequency in hertz. -TZSVC_CMD_CPU_SETZ80 EQU 50H ; Service command to switch to the external Z80 hard cpu. -TZSVC_CMD_CPU_SETT80 EQU 51H ; Service command to switch to the internal T80 soft cpu. -TZSVC_STATUS_OK: EQU 000H ; Flag to indicate the K64F processing completed successfully. -TZSVC_STATUS_REQUEST: EQU 0FEH ; Flag to indicate the Z80 has made a request to the K64F. -TZSVC_STATUS_PROCESSING:EQU 0FFH ; Flag to indicate the K64F is processing a command. diff --git a/software/asm/include/rfs_definitions.asm b/software/asm/include/rfs_definitions.asm deleted file mode 100644 index fcd4b57..0000000 --- a/software/asm/include/rfs_definitions.asm +++ /dev/null @@ -1,563 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: RFS_Definitions.asm -;- Created: September 2019 -;- Author(s): Philip Smart -;- Description: Sharp MZ series Rom Filing System. -;- Definitions for the RFS including SA1510 locations. -;- -;- Credits: -;- Copyright: (c) 2019-23 Philip Smart -;- -;- History: Sep 2019 - Initial version. -;- May 2020 - Advent of the new RFS PCB v2.0, quite a few changes to accommodate the -;- additional and different hardware. The SPI is now onboard the PCB and -;- not using the printer interface card. -;- July 2020 - Updated for the tranZPUter v2.1 hardware. RFS can run with a tranZPUter -;- board with or without the K64 I/O processor. RFS wont use the K64 -;- processor all operations are done by the Z80 under RFS. -;- March 2021- Updates to accommodate the RFS v2.1 board along with back porting TZFS -;- developments. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - -;----------------------------------------------- -; Features. -;----------------------------------------------- -HW_SPI_ENA EQU 1 ; Set to 1 if hardware SPI is present on the RFS PCB v2 board. -SW_SPI_ENA EQU 0 ; Set to 1 if software SPI is present on the RFS PCB v2 board. -PP_SPI_ENA EQU 0 ; Set to 1 if using the SPI interface via the Parallel Port, ie. for RFS PCB v1 which doesnt have SPI onboard. -FUSIONX_ENA EQU 1 ; Set to 1 if using RFS on the tranZPUter FusionX board. - -; Debugging -ENADEBUG EQU 0 ; Enable debugging logic, 1 = enable, 0 = disable - -;----------------------------------------------- -; Entry/compilation start points. -;----------------------------------------------- -UROMADDR EQU 0E800H ; Start of User ROM Address space. -UROMBSTBL EQU UROMADDR + 020H ; Entry point to the bank switching table. -RFSJMPTABLE EQU UROMADDR + 00080H ; Start of jump table. -FDCROMADDR EQU 0F000H - - -;----------------------------------------------- -; Common character definitions. -;----------------------------------------------- -SCROLL EQU 001H ;Set scroll direction UP. -BELL EQU 007H -SPACE EQU 020H -TAB EQU 009H ;TAB ACROSS (8 SPACES FOR SD-BOARD) -CR EQU 00DH -LF EQU 00AH -FF EQU 00CH -CS EQU 0CH ; Clear screen -DELETE EQU 07FH -BACKS EQU 008H -SOH EQU 1 ; For XModem etc. -EOT EQU 4 -ACK EQU 6 -NAK EQU 015H -NUL EQU 000H -NULL EQU 000H -CTRL_A EQU 001H -CTRL_B EQU 002H -CTRL_C EQU 003H -CTRL_D EQU 004H -CTRL_E EQU 005H -CTRL_F EQU 006H -CTRL_G EQU 007H -CTRL_H EQU 008H -CTRL_I EQU 009H -CTRL_J EQU 00AH -CTRL_K EQU 00BH -CTRL_L EQU 00CH -CTRL_M EQU 00DH -CTRL_N EQU 00EH -CTRL_O EQU 00FH -CTRL_P EQU 010H -CTRL_Q EQU 011H -CTRL_R EQU 012H -CTRL_S EQU 013H -CTRL_T EQU 014H -CTRL_U EQU 015H -CTRL_V EQU 016H -CTRL_W EQU 017H -CTRL_X EQU 018H -CTRL_Y EQU 019H -CTRL_Z EQU 01AH -ESC EQU 01BH -CTRL_SLASH EQU 01CH -CTRL_LB EQU 01BH -CTRL_RB EQU 01DH -CTRL_CAPPA EQU 01EH -CTRL_UNDSCR EQU 01FH -CTRL_AT EQU 000H -NOKEY EQU 0F0H -CURSRIGHT EQU 0F1H -CURSLEFT EQU 0F2H -CURSUP EQU 0F3H -CURSDOWN EQU 0F4H -DBLZERO EQU 0F5H -INSERT EQU 0F6H -CLRKEY EQU 0F7H -HOMEKEY EQU 0F8H -BREAKKEY EQU 0FBH -GRAPHKEY EQU 0FCH -ALPHAKEY EQU 0FDH - - -;------------------------------------------------------- -; Function entry points in the standard SA-1510 Monitor. -;------------------------------------------------------- -GETL: EQU 00003h -LETNL: EQU 00006h -NL: EQU 00009h -PRNTS: EQU 0000Ch -PRNT: EQU 00012h -MSG: EQU 00015h -MSGX: EQU 00018h -GETKY EQU 0001Bh -BRKEY EQU 0001Eh -?WRI EQU 00021h -?WRD EQU 00024h -?RDI EQU 00027h -?RDD EQU 0002Ah -?VRFY EQU 0002Dh -MELDY EQU 00030h -?TMST EQU 00033h -MONIT: EQU 00000h -SS: EQU 00089h -ST1: EQU 00095h -HLHEX EQU 00410h -_2HEX EQU 0041Fh -?MODE: EQU 0074DH -?KEY EQU 008CAh -PRNT3 EQU 0096Ch -?ADCN EQU 00BB9h -?DACN EQU 00BCEh -?DSP: EQU 00DB5H -?BLNK EQU 00DA6h -?DPCT EQU 00DDCh -PRTHL: EQU 003BAh -PRTHX: EQU 003C3h -HEX: EQU 003F9h -DPCT: EQU 00DDCh -DLY12: EQU 00DA7h -DLY12A: EQU 00DAAh -?RSTR1: EQU 00EE6h -MOTOR: EQU 006A3H -CKSUM: EQU 0071AH -GAP: EQU 0077AH -WTAPE: EQU 00485H -MSTOP: EQU 00700H - -;----------------------------------------------- -; Memory mapped ports in hardware. -;----------------------------------------------- -SCRN: EQU 0D000H -ARAM: EQU 0D800H -DSPCTL: EQU 0DFFFH ; Screen 40/80 select register (bit 7) -KEYPA: EQU 0E000h -KEYPB: EQU 0E001h -KEYPC: EQU 0E002h -KEYPF: EQU 0E003h -CSTR: EQU 0E002h -CSTPT: EQU 0E003h -CONT0: EQU 0E004h -CONT1: EQU 0E005h -CONT2: EQU 0E006h -CONTF: EQU 0E007h -SUNDG: EQU 0E008h -TEMP: EQU 0E008h -MEMSW: EQU 0E00CH -MEMSWR: EQU 0E010H -INVDSP: EQU 0E014H -NRMDSP: EQU 0E015H -SCLDSP: EQU 0E200H -SCLBASE: EQU 0E2H -BNKCTRLRST: EQU 0EFF8H ; Bank control reset, returns all registers to power up default. -BNKCTRLDIS: EQU 0EFF9H ; Disable bank control registers by resetting the coded latch. -HWSPIDATA: EQU 0EFFBH ; Hardware SPI Data register (read/write). -HWSPISTART: EQU 0EFFCH ; Start an SPI transfer. -BNKSELMROM: EQU 0EFFDh ; Select RFS Bank1 (MROM) -BNKSELUSER: EQU 0EFFEh ; Select RFS Bank2 (User ROM) -BNKCTRL: EQU 0EFFFH ; Bank Control register (read/write). - -; -; RFS v2 Control Register constants. -; -BBCLK EQU 1 ; BitBang SPI Clock. -SDCS EQU 2 ; SD Card Chip Select, active low. -BBMOSI EQU 4 ; BitBang MOSI (Master Out Serial In). -CDLTCH1 EQU 8 ; Coded latch up count bit 1 -CDLTCH2 EQU 16 ; Coded latch up count bit 2 -CDLTCH3 EQU 32 ; Coded latch up count bit 3 -BK2A19 EQU 64 ; User ROM Device Select Bit 0 (or Address bit 19). -BK2A20 EQU 128 ; User ROM Device Select Bit 1 (or Address bit 20). - ; BK2A20 : BK2A19 - ; 0 0 = Flash RAM 0 (default). - ; 0 1 = Flash RAM 1. - ; 1 0 = Flasm RAM 2 or Static RAM 0. - ; 1 1 = Reserved.` - -BNKCTRLDEF EQU BBMOSI+SDCS+BBCLK ; Default on startup for the Bank Control register. - -;----------------------------------------------- -; IO ports in hardware and values. -;----------------------------------------------- -SPI_OUT EQU 0FFH -SPI_IN EQU 0FEH -; -DOUT_LOW EQU 000H -DOUT_HIGH EQU 004H -DOUT_MASK EQU 004H -DIN_LOW EQU 000H -DIN_HIGH EQU 001H -CLOCK_LOW EQU 000H -CLOCK_HIGH EQU 002H -CLOCK_MASK EQU 0FDH -CS_LOW EQU 000H -CS_HIGH EQU 001H -; -MMCFG EQU 060H ; Memory management configuration latch. -SETXMHZ EQU 062H ; Select the alternate clock frequency. -SET2MHZ EQU 064H ; Select the system 2MHz clock frequency. -CLKSELRD EQU 066H ; Read clock selected setting, 0 = 2MHz, 1 = XMHz -SVCREQ EQU 068H ; I/O Processor service request. -CPUCFG EQU 06CH ; Version 2.2 CPU configuration register. -CPUSTATUS EQU 06CH ; Version 2.2 CPU runtime status register. -CPUINFO EQU 06DH ; Version 2.2 CPU information register. -CPLDCFG EQU 06EH ; Version 2.1 CPLD configuration register. -CPLDSTATUS EQU 06EH ; Version 2.1 CPLD status register. -CPLDINFO EQU 06FH ; Version 2.1 CPLD version information register. -MMIO0 EQU 0E0H ; MZ-700/MZ-800 Memory Management Set 0 -MMIO1 EQU 0E1H ; MZ-700/MZ-800 Memory Management Set 1 -MMIO2 EQU 0E2H ; MZ-700/MZ-800 Memory Management Set 2 -MMIO3 EQU 0E3H ; MZ-700/MZ-800 Memory Management Set 3 -MMIO4 EQU 0E4H ; MZ-700/MZ-800 Memory Management Set 4 -MMIO5 EQU 0E5H ; MZ-700/MZ-800 Memory Management Set 5 -MMIO6 EQU 0E6H ; MZ-700/MZ-800 Memory Management Set 6 -MMIO7 EQU 0E7H ; MZ-700/MZ-800 Memory Management Set 7 - -;----------------------------------------------- -; CPLD Configuration constants. -;----------------------------------------------- -MODE_MZ80K EQU 0 ; Set to MZ-80K mode. -MODE_MZ80C EQU 1 ; Set to MZ-80C mode. -MODE_MZ1200 EQU 2 ; Set to MZ-1200 mode. -MODE_MZ80A EQU 3 ; Set to MZ-80A mode (base mode on MZ-80A hardware). -MODE_MZ700 EQU 4 ; Set to MZ-700 mode (base mode on MZ-700 hardware). -MODE_MZ800 EQU 5 ; Set to MZ-800 mode. -MODE_MZ80B EQU 6 ; Set to MZ-80B mode. -MODE_MZ2000 EQU 7 ; Set to MZ-2000 mode. -MODE_VIDEO_FPGA EQU 8 ; Bit flag (bit 3) to switch CPLD into using the new FPGA video hardware. - -;----------------------------------------------- -; tranZPUter SW Memory Management modes -;----------------------------------------------- -TZMM_ENIOWAIT EQU 020H ; Memory management IO Wait State enable - insert a wait state when an IO operation to E0-FF is executed. -TZMM_ORIG EQU 000H ; Original Sharp MZ80A mode, no tranZPUter features are selected except the I/O control registers (default: 0x60-063). -TZMM_BOOT EQU 001H ; Original mode but E800-EFFF is mapped to tranZPUter RAM so TZFS can be booted. -TZMM_TZFS EQU 002H + TZMM_ENIOWAIT ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-FFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected. -TZMM_TZFS2 EQU 003H + TZMM_ENIOWAIT ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 1. -TZMM_TZFS3 EQU 004H + TZMM_ENIOWAIT ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 2. -TZMM_TZFS4 EQU 005H + TZMM_ENIOWAIT ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 3. -TZMM_CPM EQU 006H + TZMM_ENIOWAIT ; CPM main memory configuration, all memory on the tranZPUter board, 64K block 4 selected. Special case for F3C0:F3FF & F7C0:F7FF (floppy disk paging vectors) which resides on the mainboard. -TZMM_CPM2 EQU 007H + TZMM_ENIOWAIT ; CPM main memory configuration, F000-FFFF are on the tranZPUter board in block 4, 0040-CFFF and E800-EFFF are in block 5, mainboard for D000-DFFF (video), E000-E800 (Memory control) selected. - ; Special case for 0000:003F (interrupt vectors) which resides in block 4, F3C0:F3FF & F7C0:F7FF (floppy disk paging vectors) which resides on the mainboard. -TZMM_COMPAT EQU 008H + TZMM_ENIOWAIT ; Original mode but with main DRAM in Bank 0 to allow bootstrapping of programs from other machines such as the MZ700. -TZMM_HOSTACCESS EQU 009H + TZMM_ENIOWAIT ; Mode to allow code running in Bank 0, address E800:FFFF to access host memory. Monitor ROM 0000-0FFF and Main DRAM 0x1000-0xD000, video and memory mapped I/O are on the host machine, User/Floppy ROM E800-FFFF are in tranZPUter memory. -TZMM_MZ700_0 EQU 00AH + TZMM_ENIOWAIT ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the mainboard. -TZMM_MZ700_1 EQU 00BH + TZMM_ENIOWAIT ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 0, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the tranZPUter in block 6. -TZMM_MZ700_2 EQU 00CH + TZMM_ENIOWAIT ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the tranZPUter in block 6. -TZMM_MZ700_3 EQU 00DH + TZMM_ENIOWAIT ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 0, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is inaccessible. -TZMM_MZ700_4 EQU 00EH + TZMM_ENIOWAIT ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is inaccessible. -TZMM_MZ800 EQU 00FH + TZMM_ENIOWAIT ; MZ800 Mode - Tracks original hardware mode offering MZ700/MZ800 configurations. -TZMM_FPGA EQU 015H + TZMM_ENIOWAIT ; Open up access for the K64F to the FPGA resources such as memory. All other access to RAM or mainboard is blocked. -TZMM_TZPUM EQU 016H + TZMM_ENIOWAIT ; Everything in on mainboard, no access to tranZPUter memory. -TZMM_TZPU EQU 017H + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 0 is selected. -TZMM_TZPU0 EQU 018H + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 0 is selected. -TZMM_TZPU1 EQU 019H + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 1 is selected. -TZMM_TZPU2 EQU 01AH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 2 is selected. -TZMM_TZPU3 EQU 01BH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 3 is selected. -TZMM_TZPU4 EQU 01CH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 4 is selected. -TZMM_TZPU5 EQU 01DH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 5 is selected. -TZMM_TZPU6 EQU 01EH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 6 is selected. -TZMM_TZPU7 EQU 01FH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 7 is selected. - -;----------------------------------------------- -; Rom File System Header (MZF) -;----------------------------------------------- -RFS_ATRB: EQU 00000h ; Code Type, 01 = Machine Code. -RFS_NAME: EQU 00001h ; Title/Name (17 bytes). -RFS_SIZE: EQU 00012h ; Size of program. -RFS_DTADR: EQU 00014h ; Load address of program. -RFS_EXADR: EQU 00016h ; Exec address of program. -RFS_COMNT: EQU 00018h ; COMMENT - -;----------------------------------------------- -; Entry/compilation start points. -;----------------------------------------------- -TPSTART: EQU 010F0h -MEMSTART: EQU 01200h -MSTART: EQU 0E900h -MZFHDRSZ EQU 128 -RFSSECTSZ EQU 256 -MROMSIZE EQU 4096 -UROMSIZE EQU 2048 -FNSIZE EQU 17 -; -; Monitor ROM Jump Table definitions. -; -MROMJMPTBL: EQU 00070H -DIRMROM: EQU MROMJMPTBL + 00000H -MFINDMZF: EQU MROMJMPTBL + 00003H -MROMLOAD: EQU MROMJMPTBL + 00006H - -;----------------------------------------------- -; ROM Banks, 0-7 are reserved for alternative -; Monitor versions, CPM and RFS -; code in MROM bank, -; 0-7 are reserved for RFS code in -; the User ROM bank. -; 8-15 are reserved for CPM code in -; the User ROM bank. -;----------------------------------------------- -MROMPAGES EQU 8 -USRROMPAGES EQU 12 ; Monitor ROM : User ROM -ROMBANK0 EQU 0 ; MROM SA1510 40 Char : RFS Bank 0 - Main RFS Entry point and functions. -ROMBANK1 EQU 1 ; MROM SA1510 80 Char : RFS Bank 1 - Floppy disk controller and utilities. -ROMBANK2 EQU 2 ; CPM 2.2 CBIOS : RFS Bank 2 - SD Card controller and utilities. -ROMBANK3 EQU 3 ; RFS Utilities : RFS Bank 3 - Cmdline tools (Memory, Printer, Help) -ROMBANK4 EQU 4 ; MZ700 1Z-013A 40C : RFS Bank 4 - CMT Utilities. -ROMBANK5 EQU 5 ; MZ700-1Z-013A 80C : RFS Bank 5 -ROMBANK6 EQU 6 ; MZ-80B IPL : RFS Bank 6 -ROMBANK7 EQU 7 ; Free : RFS Bank 7 - Memory and timer test utilities. -ROMBANK8 EQU 8 ; : CBIOS Bank 1 - Utilities -ROMBANK9 EQU 9 ; : CBIOS Bank 2 - Screen / ANSI Terminal -ROMBANK10 EQU 10 ; : CBIOS Bank 3 - SD Card -ROMBANK11 EQU 11 ; : CBIOS Bank 4 - Floppy disk controller. - - -; MMC/SD command (SPI mode) -CMD0 EQU 64 + 0 ; GO_IDLE_STATE -CMD1 EQU 64 + 1 ; SEND_OP_COND -ACMD41 EQU 0x40+41 ; SEND_OP_COND (SDC) -CMD8 EQU 64 + 8 ; SEND_IF_COND -CMD9 EQU 64 + 9 ; SEND_CSD -CMD10 EQU 64 + 10 ; SEND_CID -CMD12 EQU 64 + 12 ; STOP_TRANSMISSION -CMD13 EQU 64 + 13 ; SEND_STATUS -ACMD13 EQU 0x40+13 ; SD_STATUS (SDC) -CMD16 EQU 64 + 16 ; SET_BLOCKLEN -CMD17 EQU 64 + 17 ; READ_SINGLE_BLOCK -CMD18 EQU 64 + 18 ; READ_MULTIPLE_BLOCK -CMD23 EQU 64 + 23 ; SET_BLOCK_COUNT -ACMD23 EQU 0x40+23 ; SET_WR_BLK_ERASE_COUNT (SDC) -CMD24 EQU 64 + 24 ; WRITE_BLOCK -CMD25 EQU 64 + 25 ; WRITE_MULTIPLE_BLOCK -CMD32 EQU 64 + 32 ; ERASE_ER_BLK_START -CMD33 EQU 64 + 33 ; ERASE_ER_BLK_END -CMD38 EQU 64 + 38 ; ERASE -CMD55 EQU 64 + 55 ; APP_CMD -CMD58 EQU 64 + 58 ; READ_OCR -SD_SECSIZE EQU 512 ; Default size of an SD Sector -SD_RETRIES EQU 00100H ; Number of retries before giving up. - -; Card type flags (CardType) -CT_MMC EQU 001H ; MMC ver 3 -CT_SD1 EQU 002H ; SD ver 1 -CT_SD2 EQU 004H ; SD ver 2 -CT_SDC EQU CT_SD1|CT_SD2 ; SD -CT_BLOCK EQU 008H ; Block addressing - -; SD Card Directory structure. The directory entries are based on the MZF Header format and constraints. -; -; FLAG1 | FLAG2 | FILE NAME | START SECTOR | SIZE | LOAD ADDR | EXEC ADDR | RESERVED -; 1 Byte | 1 Byte | 17 Bytes | 2 Bytes | 2 Bytes | 2 Bytes | 2 Bytes | 5 Bytes -; -; FLAG1 : BIT 7 = 1, Valid directory entry, 0 = inactive. -; FLAG2 : MZF Execution Code, 0x01 = Binary -; FILENAME : Standard MZF format filename. -; START SECTOR : Sector in the SD card where the program starts. It always starts at position 0 of the sector. -; SIZE : Size in bytes of the program. Each file block occupies 64Kbyte space (as per a tape) and this -; parameter provides the actual space occupied by the program at the current time. -; LOAD ADDR : Start address in memory where data should be loaded. -; EXEC ADDR : If a binary then this parameter specifies the location to auto execute once loaded. -; RESERVED : Not used at the moemnt. -SDDIR_FLAG1 EQU 000H -SDDIR_FLAG2 EQU 001H -SDDIR_FILEN EQU 002H -SDDIR_SSEC EQU 013H -SDDIR_SIZE EQU 015H -SDDIR_LOAD EQU 017H -SDDIR_EXEC EQU 019H -SDDIR_FNSZ EQU FNSIZE -SDDIR_ENTSZ EQU 32 - -; -; Rom Filing System constants for the SD Card. -; -SDDIR_DIRENT EQU 256 ; Directory entries in the RFS directory. -SDDIR_DIRENTSZ EQU 32 ; Size of a directory entry. -SDDIR_DIRSIZE EQU SDDIR_DIRENT * SDDIR_DIRENTSZ ; Total size of the directory. -SDDIR_BLOCKSZ EQU 65536 ; Size of a file block per directory entry. -SDDIR_IMGSZ EQU SDDIR_DIRSIZE + (SDDIR_DIRENT * SDDIR_BLOCKSZ) ; Total size of the RFS image. - -OBJCD EQU 001H ; MZF contains a binary object. -BTX1CD EQU 002H ; MZF contains an MZ-80K/80A BASIC program. -BTX2CD EQU 005H ; MZF contains an MZ-700/800 BASIC program. -BTX3CD EQU 07EH ; MZF contains a NASCOM Cassette BASIC program. -BTX4CD EQU 07FH ; MZF contains a NASCOM ASCII TEXT BASIC program. -TZOBJCD0 EQU 0F8H ; MZF contains a TZFS binary object for page 0. -TZOBJCD1 EQU 0F9H -TZOBJCD2 EQU 0FAH -TZOBJCD3 EQU 0FBH -TZOBJCD4 EQU 0FCH -TZOBJCD5 EQU 0FDH -TZOBJCD6 EQU 0FEH -TZOBJCD7 EQU 0FFH ; MZF contains a TZFS binary object for page 7. - -;----------------------------------------------- -; SA-1510 MONITOR WORK AREA (MZ80A) -;----------------------------------------------- -STACK: EQU 010F0H -; - ORG STACK -; -SPV: -IBUFE: ; TAPE BUFFER (128 BYTES) -ATRB: DS virtual 1 ; ATTRIBUTE -NAME: DS virtual FNSIZE ; FILE NAME -SIZE: DS virtual 2 ; BYTESIZE -DTADR: DS virtual 2 ; DATA ADDRESS -EXADR: DS virtual 2 ; EXECUTION ADDRESS -COMNT: DS virtual 92 ; COMMENT -SWPW: DS virtual 10 ; SWEEP WORK -KDATW: DS virtual 2 ; KEY WORK -KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) -DSPXY: DS virtual 2 ; DISPLAY COORDINATES -MANG: DS virtual 6 ; COLUMN MANAGEMENT -MANGE: DS virtual 1 ; COLUMN MANAGEMENT END -PBIAS: DS virtual 1 ; PAGE BIAS -ROLTOP: DS virtual 1 ; ROLL TOP BIAS -MGPNT: DS virtual 1 ; COLUMN MANAG. POINTER -PAGETP: DS virtual 2 ; PAGE TOP -ROLEND: DS virtual 1 ; ROLL END - DS virtual 14 ; BIAS -FLASH: DS virtual 1 ; FLASHING DATA -SFTLK: DS virtual 1 ; SHIFT LOCK -REVFLG: DS virtual 1 ; REVERSE FLAG -SPAGE: DS virtual 1 ; PAGE CHANGE -FLSDT: DS virtual 1 ; CURSOR DATA -STRGF: DS virtual 1 ; STRING FLAG -DPRNT: DS virtual 1 ; TAB COUNTER -TMCNT: DS virtual 2 ; TAPE MARK COUNTER -SUMDT: DS virtual 2 ; CHECK SUM DATA -CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA -AMPM: DS virtual 1 ; AMPM DATA -TIMFG: DS virtual 1 ; TIME FLAG -SWRK: DS virtual 1 ; KEY SOUND FLAG -TEMPW: DS virtual 1 ; TEMPO WORK -ONTYO: DS virtual 1 ; ONTYO WORK -OCTV: DS virtual 1 ; OCTAVE WORK -RATIO: DS virtual 2 ; ONPU RATIO -BUFER: DS virtual 81 ; GET LINE BUFFER - -; Starting 1000H - Generally unused bytes not cleared by the monitor. -ROMBK1: EQU 01016H ; CURRENT MROM BANK -ROMBK2: EQU 01017H ; CURRENT USERROM BANK -WRKROMBK1: EQU 01018H ; WORKING MROM BANK -WRKROMBK2: EQU 01019H ; WORKING USERROM BANK -ROMCTL: EQU 0101AH ; Current Bank control register setting. -SCRNMODE: EQU 0101BH ; Mode of screen, 0 = 40 char, 1 = 80 char. -TMPADR: EQU 0101CH ; TEMPORARY ADDRESS STORAGE -TMPSIZE: EQU 0101EH ; TEMPORARY SIZE -TMPCNT: EQU 01020H ; TEMPORARY COUNTER -TMPLINECNT: EQU 01022H ; Temporary counter for displayed lines. -TMPSTACKP: EQU 01024H ; Temporary stack pointer save. -SDVER: EQU 01026H -SDCAP: EQU 01027H -SDDRIVENO EQU 01028H ; RFS SDCFS Active Drive Number -CMTFILENO EQU 01029H ; Next Sequential file number to read when file request given without name. -TZPU: EQU 0102AH ; Tranzputer present flag (0 = not present, > 0 = present and version number). -; Variables sharing the BUFER buffer, normally the BUFER is only used to get keyboard input and so long as data in BUFER is processed -; before calling the CMT/SD commands and not inbetween there shouldnt be any issue. Also the space used is at the top end of the buffer which is not used so often. -; This frees up memory needed by the CMT and SD card. -SECTORBUF: EQU 0CE00H ; Working buffer to place an SD card sector. -SDSTARTSEC EQU BUFER+50+0 ; Starting sector of data to read/write from/to SD card. -SDLOADADDR EQU BUFER+50+4 ; Address to read/write data from/to SD card. -SDLOADSIZE EQU BUFER+50+6 ; Total remaining byte count data to read/write from/to SD card. -SDAUTOEXEC EQU BUFER+50+8 ; Flag to indicate if a loaded image should be executed (=0xFF) -SDBUF: EQU BUFER+50+9 ; SD Card command fram buffer for the command and response storage. -DIRSECBUF: EQU BUFER+50+20 ; Directory sector in cache. -DUMPADDR: EQU BUFER+50+22 ; Address used by the D(ump) command so that calls without parameters go onto the next block. -CMTLOLOAD: EQU BUFER+50+24 ; Flag to indicate that a tape program is loaded into hi memory then shifted to low memory after ROM pageout. -CMTCOPY: EQU BUFER+50+25 ; Flag to indicate that a CMT copy operation is taking place. -CMTAUTOEXEC: EQU BUFER+50+26 ; Auto execution flag, run CMT program when loaded if flag clear. -DTADRSTORE: EQU BUFER+50+27 ; Backup for load address if actual load shifts to lo memory or to 0x1200 for copy. -SDCOPY: EQU BUFER+50+29 ; Flag to indicate an SD copy is taking place, either CMT->SD or SD->CMT. -RESULT: EQU BUFER+50+30 ; Result variable needed for interbank calls when a result is needed. - -; Quickdisk work area -;QDPA EQU 01130h ; QD code 1 -;QDPB EQU 01131h ; QD code 2 -;QDPC EQU 01132h ; QD header startaddress -;QDPE EQU 01134h ; QD header length -;QDCPA EQU 0113Bh ; QD error flag -;HDPT EQU 0113Ch ; QD new headpoint possition -;HDPT0 EQU 0113Dh ; QD actual headpoint possition -;FNUPS EQU 0113Eh -;FNUPF EQU 01140h -;FNA EQU 01141h ; File Number A (actual file number) -;FNB EQU 01142h ; File Number B (next file number) -;MTF EQU 01143h ; QD motor flag -;RTYF EQU 01144h -;SYNCF EQU 01146h ; SyncFlags -;RETSP EQU 01147h -;BUFER EQU 011A3h -;QDIRBF EQU 0CD90h - - - -;SPV: -;IBUFE: ; TAPE BUFFER (128 BYTES) -;ATRB: DS virtual 1 ; Code Type, 01 = Machine Code. -;NAME: DS virtual 17 ; Title/Name (17 bytes). -;SIZE: DS virtual 2 ; Size of program. -;DTADR: DS virtual 2 ; Load address of program. -;EXADR: DS virtual 2 ; Exec address of program. -;COMNT: DS virtual 104 ; COMMENT -;KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) -;DSPXY: DS virtual 2 ; DISPLAY COORDINATES -;MANG: DS virtual 27 ; COLUMN MANAGEMENT -;FLASH: DS virtual 1 ; FLASHING DATA -;FLPST: DS virtual 2 ; FLASHING POSITION -;FLSST: DS virtual 1 ; FLASHING STATUS -;FLSDT: DS virtual 1 ; CURSOR DATA -;STRGF: DS virtual 1 ; STRING FLAG -;DPRNT: DS virtual 1 ; TAB COUNTER -;TMCNT: DS virtual 2 ; TAPE MARK COUNTER -;SUMDT: DS virtual 2 ; CHECK SUM DATA -;CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA -;AMPM: DS virtual 1 ; AMPM DATA -;TIMFG: DS virtual 1 ; TIME FLAG -;SWRK: DS virtual 1 ; KEY SOUND FLAG -;TEMPW: DS virtual 1 ; TEMPO WORK -;ONTYO: DS virtual 1 ; ONTYO WORK -;OCTV: DS virtual 1 ; OCTAVE WORK -;RATIO: DS virtual 2 ; ONPU RATIO diff --git a/software/asm/include/rfs_utilities.asm b/software/asm/include/rfs_utilities.asm deleted file mode 100644 index a124819..0000000 --- a/software/asm/include/rfs_utilities.asm +++ /dev/null @@ -1,496 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: RFS_Utilities.asm -;- Created: September 2019 -;- Author(s): Philip Smart -;- Description: Sharp MZ series Rom Filing System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade. -;- -;- Credits: -;- Copyright: (c) 2019-23 Philip Smart -;- -;- History: September 2018 - Merged 2 utilities to create this compilation. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - ; Comparing Strings - ; IN HL Address of string1. - ; DE Address of string2. - ; BC Max bytes to compare, 0x00 or 0x0d will early terminate. - ; OUT zero Set if string1 = string2, reset if string1 != string2. - ; carry Set if string1 > string2, reset if string1 <= string2. -CMPSTRING: IF USE_CMPSTRING = 1 - PUSH HL - PUSH DE - -CMPSTR1: LD A, (DE) ; Compare bytes. - CP 000h ; Check for end of string. - JR Z, CMPSTR3 - CP 00Dh - JR Z, CMPSTR3 - CPI ; Compare bytes. - JR NZ, CMPSTR2 ; If (HL) != (DE), abort. - INC DE ; Update pointer. - JP PE, CMPSTR1 ; Next byte if BC not zero. - -CMPSTR2: DEC HL - CP (HL) ; Compare again to affect carry. -CMPSTR4: POP DE - POP HL - RET - -CMPSTR3: LD A, (HL) - CP 000h ; Check for end of string. - JR Z, CMPSTR4 - CP 00Dh - JR Z, CMPSTR4 - SCF ; String 1 greater than string 2 - JR CMPSTR4 - ENDIF - - - ; IN HL Address of source string, length-prefixed. - ; DE Address of destination string, length-prefixed. - ; B Start index. 1 = first character. - ; C Length of substring to return. - ; - ; OUT carry Set if an error condition happened: - ; If B is zero, then uses index of 1. - ; If index > source length, an empty string is returned. - ; If index + return length > source length, returns all - ; characters from index to end-of-string. - -SUBSTRING: IF USE_SUBSTRING = 1 - PUSH DE ; It would be convenient to keep DE pointing to - ; the start of the destination string - OR A ; Boolean OR resets carry - PUSH AF ; Save carry - LD A, B ; Is index beyond source length? - CP (HL) - DEC A ; Decrement A so NC can be used - JR NC,SUBST3 - - ADD A, C ; If index+len is > 255, error - JR C, SUBST1 - INC A ; Increment A so C can be used - CP (HL) ; If index+len is beyond source length, then error - JR C, SUBST2 - -SUBST1: POP AF ; Set carry flag - SCF - PUSH AF - LD A, (HL) ; Get source length - SUB B ; Subtract start index - INC A ; Compensate - LD C, A ; New size of string - -SUBST2: LD A, C ; Size of sting to get - LD (DE), A ; Save length index - INC DE ; To body of string - LD A, B ; Get index - LD B, 0 ; Zero-extend BC for LDIR - - ADD A, L ; This is a sneaky way to add A to HL - LD L, A ; without using up another 16-bit register - ADC A, H ; - SUB L ; - LD H, A ; - - LDIR ; Copy substring over - POP AF ; Restore flags - POP DE ; Restore destination - RET - -SUBST3: XOR A ; Set a length index of zero - LD (DE), A - POP AF ; Clean off stack and set carry - POP DE - SCF - RET - ENDIF - - ; IN HL Address of string to look in, length prefixed. - ; DE Address of string to find, length prefixed. - ; - ; OUT - ; If found: - ; A Offset into look-up string where the target string was found. - ; The first byte (ignoring length prefix) is offset 1. - ; carry Reset. - ; - ; If not found: - ; A = 0 - ; carry Set. - -INDEX: IF USE_INDEX = 1 - LD A, (DE) ; Abort if string to find is too big - CP (HL) - INC A - JR NC, IDXABORT - - DEC A ; Save length of string to find - LD IXL, A - - LD B, 0 ; Put length of string to search in BC - LD C, (HL) - - INC HL ; Advance pointers - INC DE - PUSH HL ; Save start of search string - -IDXRST: PUSH DE ; Save start of key string - - LD A, IXL ; Initialize matched characters counter - LD IXH, A - - LD A, (DE) ; Get a character to match - CPIR ; Look for it - JR NZ, IDXNF ; Abort if not found - -IDXLOOP: DEC IXH ; Update counter and see if done - JR Z, IDXFOUND - - INC DE ; Get next character in key string - LD A, (DE) - CPI ; See if it matches next char in master - JR Z, IDXLOOP - JP PO, IDXNF ; Abort if we ran out of characters - - POP DE ; If a mismatch, restart from the beginning - JR IDXRST - -IDXNF: POP DE ; Clean stack - POP HL - -IDXABORT: XOR A ; Report failure - SCF - RET - -IDXFOUND: POP DE - POP BC ; BC = address of master - - XOR A ; Put size of key string in DE - LD D, A - LD E, IXL - - SBC HL, DE ; Find index - SBC HL, BC - LD A, L - INC A - RET - ENDIF - - ; IN HL Address of string to be inserted - ; DE Address of string to receive insertion - ; C Index. Start of string is 0 - ; OUT - ; If successful: - ; carry Reset - ; HL Input DE - ; If unsuccessful: - ; carry Set. If new string length is > 255. - ; - ; Notes If index > string length, string is appended. - ; Data after the string is destroyed. - -STRINSERT: IF USE_STRINSERT = 1 - LD A, (DE) - LD B, A - - INC A - CP C - JR NC, STRINSERT1 - LD C, B - -STRINSERT1:DEC A - ADD A, (HL) - RET C - LD (DE), A ; Update length - - PUSH DE ; Make room - PUSH HL - LD A, (HL) - INC C - - LD H, 0 - LD L, C - ADD HL, DE - - LD D, H - LD E, L - PUSH AF - ADD A, E - LD E, A - ADC A, D - SUB E - LD D, A - POP AF - - LD B, 0 - LD C, A - PUSH HL - LDIR - - POP DE ; Copy string over - POP HL - LD C, (HL) - INC HL - LDIR - POP HL - RET - ENDIF - - ; IN HL Address of string. - ; B Index of first character to delete. First character is 0. - ; C Number of characters to kill. - ; OUT - ; If successful: - ; carry Reset - ; If unsuccessful: - ; carry Set - ; - ; Notes If B > string length, then error. - ; If B + C > string length, deletion - ; stops at end of string. - -STRDELETE: IF USE_STRDELETE = 1 - LD A, B ; See if index is too big - CP (HL) - CCF ; Flip for error - RET C - - ADD A, C ; See if too many chars on chopping block - CP (HL) - JR C, STRDELETE1 - - INC B ; Set index as length - LD (HL), B - RET - -STRDELETE1:PUSH HL - LD A, (HL) - SUB C - LD (HL), A - INC HL - - LD E, C - LD C, B - LD B, 0 - ADD HL, BC - - SUB C - LD C, E - LD D, H - LD E, L - ADD HL, BC - LD C, A - LDIR - - POP HL - RET - ENDIF - - ; IN HL Address of first string. - ; DE Address of second string. - ; OUT - ; If successful: - ; carry Reset - ; If unsuccessful: - ; carry Set - ; - ; Notes If new string lenght is > 255, error. - ; HL is saved. - -CONCAT: IF USE_CONCAT = 1 - LD A, (DE) ; Combine lengths - ADD A, (HL) - RET C - LD C, (HL) - LD (HL), A - - LD B, 0 - INC C - PUSH HL - ADD HL, BC - EX DE, HL - LD C, (HL) - INC HL - LDIR - - POP HL - RET - ENDIF - -; Utility: Convert character to upper case -; On entry: A = Character in either case -; On exit: A = Character in upper case -; BC DE HL IX IY I AF' BC' DE' HL' preserved -ConvertCharToUCase: IF USE_CNVUPPER = 1 - CP 'a' ;Character less than 'a'? - RET C ;Yes, so finished - CP 'z'+1 ;Character greater than 'z'? - RET NC ;Yes, so finished - SUB 'a'-'A' ;Convert case - RET - ENDIF -; -; Utility: Convert character to numberic value -; On entry: A = ASCII character (0-9 or A-F) -; On exit: If character is a valid hex digit: -; A = Numberic value (0 to 15) and Z flagged -; If character is not a valid hex digit: -; A = 0xFF and NZ flagged -; BC DE HL IX IY I AF' BC' DE' HL' preserved -; Interrupts not enabled -ConvertCharToNumber: IF USE_CNVCHRTONUM = 1 - CALL ConvertCharToUCase - CP '0' ;Character < '0'? - JR C,@Bad ;Yes, so no hex character - CP '9'+1 ;Character <= '9'? - JR C,@OK ;Yes, got hex character - CP 'A' ;Character < 'A' - JR C,@Bad ;Yes, so not hex character - CP 'F'+1 ;Character <= 'F' - JR C,@OK ;No, not hex -; Character is not a hex digit so return -@Bad: LD A,0FFh ;Return status: not hex character - OR A ; A = 0xFF and NZ flagged - RET -; Character is a hex digit so adjust from ASCII to number -@OK: SUB '0' ;Subtract '0' - CP 00Ah ;Number < 10 ? - JR C,@Finished ;Yes, so finished - SUB 007h ;Adjust for 'A' to 'F' -@Finished: CP A ;Return A = number (0 to 15) and Z flagged to - RET ; indicate character is a valid hex digital - ENDIF - -; Utility: Is character numeric? -; On entry: A = ASCII character -; On exit: Carry flag set if character is numeric (0 to 9) -; A BC DE HL IX IY I AF' BC' DE' HL' preserved -IsCharNumeric: IF USE_ISNUMERIC = 1 - CP '0' ;Less than '0'? - JR C,@Not2 ;Yes, so go return NOT numeric - CP '9'+1 ;Less than or equal to '9'? - RET C ;Yes, so numeric (C flagged) -@Not2: OR A ;No, so NOT numeric (NC flagged) - RET - ENDIF - -; Utility: Convert hexadecimal or decimal text to number -; On entry: DE = Pointer to start of ASCII string -; On exit: If valid number found: -; A = 0 and Z flagged -; HL = Number found -; If valid number not found: -; A != 0 and NZ flagged -; HL = Not specified -; DE = Not specified -; HL = Number -; BC DE IX IY I AF' BC' DE' HL' preserved -; Hexadecmal numbers can be prefixed with either "$" or "0x" -; Decimal numbers must be prefixed with "+" -; A number without a prefix is assumed to be hexadecimal -; Hexadecimal number without a prefix must start with "0" to "9" -; ... this is to stop the assembler getting confused between -; ... register names and constants which could be fixed by -; ... re-ordering the (dis)assebmer's instruction table -; Numbers can be terminated with ")", space, null or control code -; Negative numbers, preceded with "-", are not supported -; Text must be terminated with ')', space or control char. -ConvertStringToNumber: IF USE_CNVSTRTONUM = 1 - PUSH BC - LD HL,0 ;Build result here - LD A,(DE) ;Get character from string - CP '+' ;Does string start with '+' ? - JR Z,@Decimal ;Yes, so its decimal - CP '$' ;Does string start with '$' ? - JR Z,@Hdecimal ;Yes, so its hexadecimal - CP 39 ;Does string start with apostrophe? - JR Z,@Char ;Yes, so its a character - CP '"' ;Does string start with '"' ? - JR Z,@Char ;Yes, so its a character -;; CALL IsCharNumeric ;Is first character '0' to '9' ? -;; JR NC,@Failure ;No, so invalid number -; CALL IsCharHex ;Is first character hexadecimal ? -; JR NC,@Failure ;No, so invalid hex character - CP '0' ;Is first character '0' ? - JR NZ,@HexNext ;No, so default to hexadecimal -; JR NZ,@DecNext ;No, so default to decimal - INC DE ;Point to next character in string - LD A,(DE) ;Get character from string - CALL ConvertCharToUCase - CP 'X' ;Is second character 'x' ? - JR NZ,@HexNext ;No, so must be default format -; JR NZ,@DecNext ;No, so must be default format -; Hexadecimal number... -@Hdecimal: INC DE ;Point to next character in string -@HexNext: LD A,(DE) ;Get character from string - CP ')' ;Terminated with a bracket? - JR Z,@Success ;yes, so success - CP 32+1 ;Space or control character? - JR C,@Success ;Yes, so successld hl - CALL ConvertCharToNumber ;Convert character to number - JR NZ,@Failure ;Return if failure (NZ flagged) - INC DE ;Point to next character in string - ADD HL,HL ;Current result = 16 * current result.. - ADD HL,HL - ADD HL,HL - ADD HL,HL - OR L ;Add new number (0 to 15).. - LD L,A - JR @HexNext -; Decimal number... -@Decimal: INC DE ;Point to next character in string -@DecNext: LD A,(DE) ;Get character from string - CP ')' ;Terminated with a bracket? - JR Z,@Success ;yes, so success - CP 32+1 ;Space or control character? - JR C,@Success ;Yes, so success - CALL IsCharNumeric ;Is first character '0' to '9' ? - JR NC,@Failure ;No, so invalid number - CALL ConvertCharToNumber ;Convert character to number - JR NZ,@Failure ;Return if failure (NZ flagged) - INC DE ;Point to next character in string - PUSH DE - LD B,9 ;Current result = 10 * current result.. - LD D,H - LD E,L -@DecLoop: ADD HL,DE ;Add result to itself 9 times - DJNZ @DecLoop - POP DE - ADD A,L ;Add new number (0 to 15).. - LD L,A - JR NC,@DecNext - INC H - JR @DecNext -; Character... -@Char: INC DE ;Point to next character in string - LD A,(DE) ;Get ASCII character - LD L,A ;Store ASCII value as result - LD H,0 -; JR @Success -; Return result... -@Success: POP BC - XOR A ;Return success with A = 0 and Z flagged - RET -@Failure: POP BC - LD A,0FFh ;Return failure with A != 0 - OR A ; and NZ flagged - RET - ENDIF diff --git a/software/asm/ipl.asm b/software/asm/ipl.asm deleted file mode 100644 index c7d51c6..0000000 --- a/software/asm/ipl.asm +++ /dev/null @@ -1,901 +0,0 @@ - ORG 0000H - ;**************************************************************** - ; - ; Personal Computer - ; MZ-80B - ; - ; Initial Program Loader - ;**************************************************************** - ; - JR START - ; - ; NST RESET - ; -NST: LD A,03H - OUT (PPICTL),A ;Set PC1 NST=1 - ; -START: LD A,82H ;8255 A=OUT B=IN C=OUT - OUT (PPICTL),A - LD A,0FH ;PIO A=OUT - OUT (PIOCTLA),A - LD A,0CFH ;PIO B=IN - OUT (PIOCTLB),A - LD A,0FFH - OUT (PIOCTLB),A - LD A,58H ;BST=1 NST=0 OPEN=1 WRITE=1 - OUT (PPIC),A - LD A,12H - OUT (PPIA),A - XOR A - OUT (GRPHCTL),A ;Set Graphics VRAM to default, input to GRPH I, no output. - LD SP,0FFE0H - LD HL,0D000H - LD A,0B3H - OUT (PIOA),A -CLEAR: LD (HL),00H ;DISPLAY CLEAR - INC HL - LD A,H - OR L - JR NZ,CLEAR - LD A,13H - OUT (PIOA),A - XOR A - LD (DRINO),A - LD (MTFG),A -KEYIN: CALL KEYS1 - BIT 3,A ;C - Cassette. - JR Z,CMT - BIT 0,A ;/ - Boot external rom. - JP Z,EXROMT - JR NKIN ;No selection, so standard startup, try FDC then CMT. - ; -KEYS1: LD B,14H ;Preserve A4-A7, set A4 to prevent all strobes low, the select line 5 (0-4). -KEYS: IN A,(PIOA) - AND 0F0H - OR B - OUT (PIOA),A - IN A,(PIOB) ;Read the strobed key. - RET - ; - ; -NKIN: CALL FDCC - JP Z,FD - JR CMT - ; -FDCC: LD A,0A5H - LD B,A - OUT (0D9H),A - CALL DLY80U - IN A,(0D9H) - CP B - RET - ; - ; ; - ; CMT CONTROL ; - ; ; - ; -CMT: CALL MSTOP - CALL DEL6 - CALL KYEMES - CALL ?RDI - JR C,ST1 - CALL LDMSG - LD HL,NAME - LD E,010H - LD C,010H - CALL DISP2 - LD A,(ATRB) - CP 01H - JR NZ,MISMCH - CALL ?RDD -ST1: PUSH AF - CALL DEL6 - CALL REW - POP AF - JP C,TRYAG - JP NST - ; -MISMCH: LD HL,MES16 - LD E,0AH - LD C,0FH - CALL DISP - CALL MSTOP - SCF - JR ST1 - ; - ;READ INFORMATION - ; CF=1:ERROR -RDINF: -?RDI: DI - LD D,04H - LD BC,0080H - LD HL,IBUFE -RD1: CALL MOTOR - JR C,STPEIR - CALL TMARK - JR C,STPEIR - CALL RTAPE - JR C,STPEIR -RET2S: BIT 3,D - JR Z,EIRTN -STPEIR: CALL MSTOP -EIRTN: EI - RET - ; - ; - ;READ DATA -RDDAT: -?RDD: DI - LD D,08H - LD BC,(SIZE) - LD HL,8000H - JR RD1 - ; - ; - ;READ TAPE - ; BC=SIZE - ; DE=LOAD ADDRSS -RTAPE: PUSH DE - PUSH BC - PUSH HL - LD H,02H -RTP2: CALL SPDIN - JR C,TRTN1 ;BREAK - JR Z,RTP2 - LD D,H - LD HL,0000H - LD (SUMDT),HL - POP HL - POP BC - PUSH BC - PUSH HL -RTP3: CALL RBYTE - JR C,TRTN1 - LD (HL),A - INC HL - DEC BC - LD A,B - OR C - JR NZ,RTP3 - LD HL,(SUMDT) - CALL RBYTE - JR C,TRTN1 - LD E,A - CALL RBYTE - JR C,TRTN1 - CP L - JR NZ,RTP5 - LD A,E - CP H - JR Z,TRTN1 -RTP5: DEC D - JR Z,RTP6 - LD H,D - JR RTP2 -RTP6: CALL BOOTER - SCF -TRTN1: POP HL - POP BC - POP DE - RET - ;EDGE -EDGE: IN A,(PPIB) - CPL - RLCA - RET C ;BREAK - RLCA - JR NC,EDGE ;WAIT ON LOW -EDGE1: IN A,(PPIB) - CPL - RLCA - RET C ;BREAK - RLCA - JR C,EDGE1 ;WAIT ON HIGH - RET - ; 1 BYTE READ - ; DATA=A - ; SUMDT STORE -RBYTE: PUSH HL - LD HL,0800H ; 8 BITS -RBY1: CALL SPDIN - JR C,RBY3 ;BREAK - JR Z,RBY2 ;BIT=0 - PUSH HL - LD HL,(SUMDT) ;CHECKSUM - INC HL - LD (SUMDT),HL - POP HL - SCF -RBY2: RL L - DEC H - JR NZ,RBY1 - CALL EDGE - LD A,L -RBY3: POP HL - RET - ;TAPE MARK DETECT - ; E=L:INFORMATION - ; E=S:DATA -TMARK: PUSH HL - LD HL,1414H - BIT 3,D - JR NZ,TM0 - ADD HL,HL -TM0: LD (TMCNT),HL -TM1: LD HL,(TMCNT) -TM2: CALL SPDIN - JR C,RBY3 - JR Z,TM1 - DEC H - JR NZ,TM2 -TM3: CALL SPDIN - JR C,RBY3 - JR NZ,TM1 - DEC L - JR NZ,TM3 - CALL EDGE - JR RBY3 - ;READ 1 BIT -SPDIN: CALL EDGE ;WAIT ON HIGH - RET C ;BREAK - - CALL DLY2 - IN A,(PPIB) ;READ BIT - AND 40H - RET - ; - ; - ;MOTOR ON -MOTOR: PUSH DE - PUSH BC - PUSH HL - IN A,(PPIB) - AND 20H - JR Z,MOTRD - LD HL,MES6 - LD E,0AH - LD C,0EH - CALL DISP - CALL OPEN -MOT1: IN A,(PIOB) - CPL - RLCA - JR C,MOTR - IN A,(PPIB) - AND 20H - JR NZ,MOT1 - CALL KYEMES - CALL DEL1M -MOTRD: CALL PLAY -MOTR: POP HL - POP BC - POP DE - RET - ; - ; - ;MOTOR STOP -MSTOP: LD A,0DH - OUT (PPICTL),A ;Set PC6 - READ MODE - LD A,1AH - OUT (PPIA),A - CALL DEL6 - JR BLK3 - ;EJECT -OPEN: LD A,08H ;Reset PC4 - EJECT activate - OUT (PPICTL),A - CALL DEL6 - LD A,09H - OUT (PPICTL),A ;Set PC4 - Deactivate EJECT - RET - ; - ; -KYEMES: LD HL,MES3 - LD E,04H - LD C,1CH - CALL DISP - RET - ; - ;PLAY -PLAY: CALL FR - CALL DEL6 - LD A,16H - OUT (PPIA),A - JR BLK3 -BLK1: CALL DEL6 - CALL BLK3 - LD A,13H -BLK2: OUT (PPIA),A -BLK3: LD A,12H - OUT (PPIA),A - RET - ; - ; -FR: LD A,12H -FR1: OUT (PPIA),A - CALL DEL6 - LD A,0BH - OUT (PPICTL),A ;Set PC5 - CALL DEL6 - LD A,0AH - OUT (PPICTL),A ;Reset PC5 - RET - -RRW: LD A,010H - JR FR1 - ;REWIND -REW: CALL RRW - JR BLK1 - ; - ;TIMING DEL -DM1: PUSH AF -L0211: XOR A -L0212: DEC A - JR NZ,L0212 - DEC BC - LD A,B - OR C - JR NZ,L0211 - POP AF - POP BC - RET - -DEL6: PUSH BC - LD BC,00E9H ;233D - JR DM1 -DEL1M: PUSH BC - LD BC,060FH ;1551D - JR DM1 - ; - ;TAPE DELAY TIMING - ; - ; -DLY2: LD A,31H -L022B: DEC A - JP NZ,L022B - RET - ; - ; - ; - ; - ; -LDMSG: LD HL,MES1 - LD E,00H - LD C,0EH - JR DISP - ; -DISP2: LD A,93H - OUT (PIOA),A - JR DISP1 - ; -BOOTER: LD HL,MES8 - LD E,0AH - LD C,0DH - ; -DISP: LD A,93H - OUT (PIOA),A - EXX - LD HL,0D000H -DISP3: LD (HL),00H - INC HL - LD A,H - OR L - JR NZ,DISP3 - EXX -DISP1: XOR A - LD B,A - LD D,0D0H - LDIR - LD A,13H - OUT (PIOA),A - RET - ; - ; -MES1: DB "IPL is loading" -MES3: DB "IPL is looking for a program" -MES6: DB "Make ready CMT" -MES8: DB "Loading error" -MES9: DB "Make ready FD" -MES10: DB "Press F or C" -MES11: DB "F:Floppy diskette" -MES12: DB "C:Cassette tape" -MES13: DB "Drive No? (1-4)" -MES14: DB "This diskette is not master" -MES15: DB "Pressing S key starts the CMT" -MES16: DB "File mode error" - ; -IPLMC: DB 01H - DB "IPLPRO" - ; - ; - ;FD -FD: LD IX,IBADR1 - XOR A - LD (0CF1EH),A - LD (0CF1FH),A - LD IY,0FFE0H - LD HL,0100H - LD (IY+2),L - LD (IY+3),H - CALL BREAD ;INFORMATION INPUT - LD HL,0CF00H ;MASTER CHECK - LD DE,IPLMC - LD B,06H -MCHECK: LD C,(HL) - LD A,(DE) - CP C - JP NZ,NMASTE - INC HL - INC DE - DJNZ MCHECK - CALL LDMSG - LD HL,0CF07H - LD E,010H - LD C,0AH - CALL DISP2 - LD IX,IBADR2 - LD HL,(0CF14H) - LD (IY+2),L - LD (IY+3),H - CALL BREAD - CALL MOFF - JP NST - ; - ; -NODISK: LD HL,MES9 - LD E,0AH - LD C,0DH - CALL DISP - JP ERR1 - ; - ; READY CHECK - ; -READY: LD A,(MTFG) - RRCA - CALL NC,MTON - LD A,(DRINO) ;DRIVE NO GET - OR 84H - OUT (DM),A ;DRIVE SELECT MOTON - XOR A - CALL DLY60M - LD HL,0000H -REDY0: DEC HL - LD A,H - OR L - JR Z,NODISK - IN A,(CR) ;STATUS GET - CPL - RLCA - JR C,REDY0 - LD A,(DRINO) - LD C,A - LD HL,CLBF0 - LD B,00H - ADD HL,BC - BIT 0,(HL) - RET NZ - CALL RCLB - SET 0,(HL) - RET - ; - ; MOTOR ON - ; -MTON: LD A,80H - OUT (DM),A - LD B,0AH ;1SEC DELAY -MTD1: LD HL,3C19H -MTD2: DEC HL - LD A,L - OR H - JR NZ,MTD2 - DJNZ MTD1 - LD A,01H - LD (MTFG),A - RET - ; - ;SEEK TREATMENT - ; -SEEK: LD A,1BH - CPL - OUT (CR),A - CALL BUSY - CALL DLY60M - IN A,(CR) - CPL - AND 99H - RET - ; - ;MOTOR OFF - ; -MOFF: CALL DLY1M - XOR A - OUT (DM),A - LD (CLBF0),A - LD (CLBF1),A - LD (CLBF2),A - LD (CLBF3),A - LD (MTFG),A - RET - ; - ;RECALIBRATION - ; -RCLB: PUSH HL - LD A,0BH - CPL - OUT (CR),A - CALL BUSY - CALL DLY60M - IN A,(CR) - CPL - AND 85H - XOR 04H - POP HL - RET Z - JP ERR - ; - ;BUSY AND WAIT - ; -BUSY: PUSH DE - PUSH HL - CALL DLY80U - LD E,07H -BUSY2: LD HL,0000H -BUSY0: DEC HL - LD A,H - OR L - JR Z,BUSY1 - IN A,(CR) - CPL - RRCA - JR C,BUSY0 - POP HL - POP DE - RET - ; -BUSY1: DEC E - JR NZ,BUSY2 - JP ERR - ; - ;DATA CHECK - ; -CONVRT: LD B,00H - LD DE,0010H - LD HL,(0CF1EH) - XOR A -TRANS: SBC HL,DE - JR C,TRANS1 - INC B - JR TRANS -TRANS1: ADD HL,DE - LD H,B - INC L - LD (IY+4),H - LD (IY+5),L -DCHK: LD A,(DRINO) - CP 04H - JR NC,DTCK1 - LD A,(IY+4) - CP 46H ;70D - JR NC,DTCK1 - LD A,(IY+5) - OR A - JR Z,DTCK1 - CP 11H ;17D - JR NC,DTCK1 - LD A,(IY+2) - OR (IY+3) - RET NZ -DTCK1: JP ERR - ; - ;SEQUENTIAL READ - ; -BREAD: DI - CALL CONVRT - LD A,0AH - LD (RETRY),A -READ1: CALL READY - LD D,(IY+3) - LD A,(IY+2) - OR A - JR Z,RE0 - INC D -RE0: LD A,(IY+5) - LD (IY+1),A - LD A,(IY+4) - LD (IY+0),A - PUSH IX - POP HL -RE8: SRL A - CPL - OUT (DR),A - JR NC,RE1 - LD A,01H - JR RE2 -RE1: LD A,00H -RE2: CPL - OUT (HS),A - CALL SEEK - JR NZ,REE - LD C,0DBH - LD A,(IY+0) - SRL A - CPL - OUT (TR),A - LD A,(IY+1) - CPL - OUT (SCR),A - EXX - LD HL,RE3 - PUSH HL - EXX - LD A,94H - CPL - OUT (CR),A - CALL WAIT -RE6: LD B,00H -RE4: IN A,(CR) - RRCA - RET C - RRCA - JR C,RE4 - INI - JR NZ,RE4 - INC (IY+1) - LD A,(IY+1) - CP 11H ;17D - JR Z,RETS - DEC D - JR NZ,RE6 - JR RE5 -RETS: DEC D -RE5: LD A,0D8H ;FORCE INTERRUPT - CPL - OUT (CR),A - CALL BUSY -RE3: IN A,(CR) - CPL - AND 0FFH - JR NZ,REE - EXX - POP HL - EXX - LD A,(IY+1) - CP 11H ;17D - JR NZ,REX - LD A,01H - LD (IY+1),A - INC (IY+0) -REX: LD A,D - OR A - JR NZ,RE7 - LD A,80H - OUT (DM),A - RET -RE7: LD A,(IY+0) - JR RE8 -REE: LD A,(RETRY) - DEC A - LD (RETRY),A - JR Z,ERR - CALL RCLB - JP READ1 - ; - ; WAIT AND BUSY OFF - ; -WAIT: PUSH DE - PUSH HL - CALL DLY80U - LD E,08H -WAIT2: LD HL,0000H -WAIT0: DEC HL - LD A,H - OR L - JR Z,WAIT1 - IN A,(CR) - CPL - RRCA - JR NC,WAIT0 - POP HL - POP DE - RET -WAIT1: DEC E - JR NZ,WAIT2 - JR ERR - ; -NMASTE: LD HL,MES14 - LD E,07H - LD C,1BH ;27D - CALL DISP - JR ERR1 - ; - ; ; - ; ERRROR OR BREAK ; - ; ; - ; -ERR: CALL BOOTER -ERR1: CALL MOFF -TRYAG2: LD SP,0FFE0H - ; - ;TRYAG - ; -TRYAG: CALL FDCC - JR NZ,TRYAG3 - LD HL,MES10 - LD E,5AH - LD C,0CH ;12D - CALL DISP2 - LD E,0ABH - LD C,11H ;17D - CALL DISP2 - LD E,0D3H - LD C,0FH ;15D - CALL DISP2 -TRYAG1: CALL KEYS1 - BIT 3,A - JP Z,CMT - BIT 6,A - JR Z,DNO - JR TRYAG1 -DNO: LD HL,MES13 ;DRIVE NO SELECT - LD E,0AH - LD C,0FH - CALL DISP -DNO10: LD D,12H - CALL DNO0 - JR NC,DNO3 - LD D,18H - CALL DNO0 - JR NC,DNO3 - JR DNO10 -DNO3: LD A,B - LD (DRINO),A - JP FD - ; -TRYAG3: LD HL,MES15 - LD E,54H - LD C,1DH ;29D - CALL DISP2 -TRYAG4: LD B,06H -TRYAG5: CALL KEYS - BIT 3,A - JP Z,CMT - JR TRYAG5 - ; -DNO0: IN A,(PIOA) - AND 0F0H - OR D - OUT (PIOA),A - IN A,(PIOB) - LD B,00H - LD C,04H - RRCA -DNO1: RRCA - RET NC - INC B - DEC C - JR NZ,DNO1 - RET - ; - ; TIME DELAY (1M &60M &80U ) - ; -DLY80U: PUSH DE - LD DE,000DH ;13D - JP DLYT -DLY1M: PUSH DE - LD DE,0082H ;130D - JP DLYT -DLY60M: PUSH DE - LD DE,1A2CH ;6700D -DLYT: DEC DE - LD A,E - OR D - JR NZ,DLYT - POP DE - RET - ; - ; - ; ; - ; INTRAM EXROM ; - ; ; - ; -EXROMT: LD HL,8000H - LD IX,EROM1 - JR SEROMA -EROM1: IN A,(0F9H) - CP 00H - JP NZ,NKIN - LD IX,EROM2 -ERMT1: JR SEROMA -EROM2: IN A,(0F9H) - LD (HL),A - INC HL - LD A,L - OR H - JR NZ,ERMT1 - OUT (0F8H),A - JP NST - ; -SEROMA: LD A,H - OUT (0F8H),A - LD A,L - OUT (0F9H),A - LD D,04H -SEROMD: DEC D - JR NZ,SEROMD - JP (IX) - - - ; Pad to 4K as this is the standard MROM Bank size. - DS 01000H - $ - -;---------------------------------------------------------- -; Variables/Work area -;---------------------------------------------------------- - -IBUFE: EQU 0CF00H -ATRB: EQU 0CF00H -NAME: EQU 0CF01H -SIZE: EQU 0CF12H -DTADR: EQU 0CF14H -SUMDT: EQU 0FFE0H -TMCNT: EQU 0FFE2H - ; - ; - ;INPUT BUFFER ADDRESS - ; -IBADR1: EQU 0CF00H -IBADR2: EQU 8000H - ; - ; SUBROUTINE WORK - ; -NTRACK: EQU 0FFE0H -NSECT: EQU 0FFE1H -BSIZE: EQU 0FFE2H -STTR: EQU 0FFE4H -STSE: EQU 0FFE5H -MTFG: EQU 0FFE6H -CLBF0: EQU 0FFE7H -CLBF1: EQU 0FFE8H -CLBF2: EQU 0FFE9H -CLBF3: EQU 0FFEAH -RETRY: EQU 0FFEBH -DRINO: EQU 0FFECH - - ; - ; - ; - ; - ; - ; MFM MINIFLOPPY CONTROL - ; - ; - ; - ; CASE OF DISK INITIALIZE - ; DRIVE NO=DRINO (0-3) - ; - ; CASE OF SEQUENTIAL READ - ; DRIVE NO=DRINO (0-3) - ; BYTE SIZE =IY+2,3 - ; ADDRESS =IX+0,1 - ; NEXT TRACK =IY+0 - ; NEXT SECTOR =IY+1 - ; START TRACK =IY+4 - ; START SECTOR =IY+5 - ; - ; - ; I/O PORT ADDRESS - ; -CR: EQU 0D8H ;STATUS/COMMAND PORT -TR: EQU 0D9H ;TRACK REG PORT -SCR: EQU 0DAH ;SECTOR REG PORT -DR: EQU 0DBH ;DATA REG PORT -DM: EQU 0DCH ;MOTOR/DRIVE PORT -HS: EQU 0DDH ;HEAD SIDE SELECT PORT -PPIA: EQU 0E0H -PPIB: EQU 0E1H -PPIC: EQU 0E2H -PPICTL: EQU 0E3H -PIOA: EQU 0E8H -PIOCTLA:EQU 0E9H -PIOB: EQU 0EAH -PIOCTLB:EQU 0EBH -GRPHCTL:EQU 0F4H diff --git a/software/asm/monitor_1z-013a.asm b/software/asm/monitor_1z-013a.asm deleted file mode 100644 index 7b02f6e..0000000 --- a/software/asm/monitor_1z-013a.asm +++ /dev/null @@ -1,7 +0,0 @@ -; Configurable parameters. -COLW: EQU 40 ; Width of the display screen (ie. columns). -ROW: EQU 25 ; Number of rows on display screen. -SCRNSZ: EQU COLW * ROW ; Total size, in bytes, of the screen display area. -MODE80C:EQU 0 - - INCLUDE "1z-013a.asm" diff --git a/software/asm/monitor_80c_1z-013a.asm b/software/asm/monitor_80c_1z-013a.asm deleted file mode 100644 index 4a6b8ae..0000000 --- a/software/asm/monitor_80c_1z-013a.asm +++ /dev/null @@ -1,7 +0,0 @@ -; Configurable parameters. -COLW: EQU 80 ; Width of the display screen (ie. columns). -ROW: EQU 25 ; Number of rows on display screen. -SCRNSZ: EQU COLW * ROW ; Total size, in bytes, of the screen display area. -MODE80C:EQU 1 - - INCLUDE "1z-013a.asm" diff --git a/software/asm/monitor_80c_sa1510.asm b/software/asm/monitor_80c_sa1510.asm deleted file mode 100644 index 526b0ff..0000000 --- a/software/asm/monitor_80c_sa1510.asm +++ /dev/null @@ -1,8 +0,0 @@ -; Configurable parameters. -COLW: EQU 80 ; Width of the display screen (ie. columns). -ROW: EQU 25 ; Number of rows on display screen. -SCRNSZ: EQU COLW * ROW ; Total size, in bytes, of the screen display area. -SCRLW: EQU COLW / 8 ; Number of 8 byte regions in a line for hardware scroll. -MODE80C:EQU 1 - - INCLUDE "sa1510.asm" diff --git a/software/asm/monitor_80c_sa1510_hiload.asm b/software/asm/monitor_80c_sa1510_hiload.asm deleted file mode 100644 index c751b44..0000000 --- a/software/asm/monitor_80c_sa1510_hiload.asm +++ /dev/null @@ -1,8 +0,0 @@ -; Configurable parameters. -COLW: EQU 80 ; Width of the display screen (ie. columns). -ROW: EQU 25 ; Number of rows on display screen. -SCRNSZ: EQU COLW * ROW ; Total size, in bytes, of the screen display area. -SCRLW: EQU COLW / 8 ; Number of 8 byte regions in a line for hardware scroll. -MODE80C:EQU 1 - - INCLUDE "sa1510_hiload.asm" diff --git a/software/asm/monitor_sa1510.asm b/software/asm/monitor_sa1510.asm deleted file mode 100644 index b773df1..0000000 --- a/software/asm/monitor_sa1510.asm +++ /dev/null @@ -1,8 +0,0 @@ -; Configurable parameters. -COLW: EQU 40 ; Width of the display screen (ie. columns). -ROW: EQU 25 ; Number of rows on display screen. -SCRNSZ: EQU COLW * ROW ; Total size, in bytes, of the screen display area. -SCRLW: EQU COLW / 8 ; Number of 8 byte regions in a line for hardware scroll. -MODE80C:EQU 0 - - INCLUDE "sa1510.asm" diff --git a/software/asm/monitor_sa1510_hiload.asm b/software/asm/monitor_sa1510_hiload.asm deleted file mode 100644 index 1c1c61d..0000000 --- a/software/asm/monitor_sa1510_hiload.asm +++ /dev/null @@ -1,8 +0,0 @@ -; Configurable parameters. -COLW: EQU 40 ; Width of the display screen (ie. columns). -ROW: EQU 25 ; Number of rows on display screen. -SCRNSZ: EQU COLW * ROW ; Total size, in bytes, of the screen display area. -SCRLW: EQU COLW / 8 ; Number of 8 byte regions in a line for hardware scroll. -MODE80C:EQU 0 - - INCLUDE "sa1510_hiload.asm" diff --git a/software/asm/msbasic.asm b/software/asm/msbasic.asm deleted file mode 100644 index 5eb7934..0000000 --- a/software/asm/msbasic.asm +++ /dev/null @@ -1,9272 +0,0 @@ -;----------------------------------------------------------------------------------------------- -; NASCOM ROM BASIC Ver 4.7, (C) 1978 Microsoft -; Scanned from source published in 80-BUS NEWS from Vol 2, Issue 3 -; (May-June 1983) to Vol 3, Issue 3 (May-June 1984) -; Adapted for the freeware Zilog Macro Assembler 2.10 to produce -; the original ROM code (checksum A934H). PA -; -; This BASIC has been created from the original NASCOM v4.7b source and also -; may have elements of Grant Searle's changes as both were used in creating this -; version. -; -; It has undergone extensive modification: -; 1. Restore the CLOAD/CSAVE commands. These commands load/save tokenised cassette -; images. The cassette images are from the NASCOM but converted with the -; 'nasconv' C program which removes the tape formatting, updates the token values -; and address pointers. -; 2. Add LOAD/SAVE commands. These commands load/save BASIC in text format. -; 3. Restored the SCREEN command so it works with the Sharp MZ80A 40/80 column screen. -; 4. Increased the command word table to allow additional commands which I expect to add. -; I've added additional comments as things have been figured out to aid future understanding. -; -; Thus (C)opyright notices: -; Original source is: (C) 1978 Microsoft -; Updates (some reversed out): Grant Searle, http://searle.hostei.com/grant/index.html -; eMail: home.micros01@btinternet.com -; All other updates (C) Philip Smart, 2020-23. http://www.eaw.app philip.smart\@net2net.org -;----------------------------------------------------------------------------------------------- - - - ; Bring in additional resources. - INCLUDE "msbasic_buildversion.asm" - INCLUDE "msbasic_definitions.asm" - INCLUDE "macros.asm" - - ; Sharp MZ-80A Tape Format Header - used by all software including RFS/TZFS - ; in processing/loading of this file. - ; - ORG 10F0h - - DB 01h ; Code Type, 01 = Machine Code. -HEADER1: IF BUILD_MZ80A = 1 - DB "MS-BASIC(MZ-80A)", 0DH ; Title/Name (17 bytes). - DW CODEEND - CODESTART ; Size of program. - DW CODESTART ; Load address of program. - DW CODESTART ; Exec address of program. - ENDIF - -HEADER2: IF BUILD_RFS = 1 - IF BUILD_80C = 0 - DB "MS-BASIC(RFS40)", 0DH, 0DH ; Title/Name (17 bytes). - DW CODEEND - CODESTART ; Size of program. - DW CODESTART ; Load address of program. - DW CODESTART ; Exec address of program. - ELSE - DB "MS-BASIC(RFS80)", 0DH, 0DH ; Title/Name (17 bytes). - DW CODEEND - CODESTART ; Size of program. - DW CODESTART ; Load address of program. - DW CODESTART ; Exec address of program. - ENDIF - ENDIF - -HEADER3: IF BUILD_RFSTZ = 1 - DB "MS-BASIC(RFS-TZ)", 0DH ; Title/Name (17 bytes). - DW (CODEEND - CODESTART) + (RELOCEND - RELOC) + (RELOCRFS2END - RELOCRFS2) ; Size of program. - DW 01200H ; Load address of program. - DW RELOCRFS ; Exec address of program. - ENDIF - -HEADER4: IF BUILD_TZFS = 1 - DB "MS-BASIC(TZFS)", 0DH, 0DH, 0DH ; Title/Name (17 bytes). - DW (CODEEND - CODESTART) + (RELOCEND - RELOC) ; Size of program. - DW 01200H ; Load address of program. - DW RELOC ; Exec address of program. - ENDIF - - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h ; Comment (104 bytes). - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - - ; Load address of this program when first loaded. - ; -BUILD1: IF BUILD_MZ80A+BUILD_RFS > 0 - ORG 1200H - ENDIF - -BUILD2: IF BUILD_TZFS+BUILD_RFSTZ > 0 - ORG 0000H - ENDIF - -CODESTART: - -COLD: JP STARTB ; Jump for cold start -WARM: JP WARMST ; Jump for warm start -STARTB: - LD IX,0 ; Flag cold start - JP CSTART ; Jump to initialise - - DW DEINT ; Get integer -32768 to 32767 - DW ABPASS ; Return integer in AB - - -VECTORS: IF BUILD_TZFS+BUILD_RFSTZ > 0 - ALIGN 0038H - ORG 0038H -INTVEC: DS 3 ; Space for the Interrupt vector. - - ALIGN 0066H - ORG 0066H -NMIVEC: DS 3 ; Space for the NMI vector. - ENDIF - -CSTART: DI ; Disable Interrupts and sat mode. NB. Interrupts are physically disabled by 8255 Port C2 set to low. - IM 1 - LD SP,STACK ; Start of workspace RAM - -MEMSW0: IF BUILD_TZFS+BUILD_RFSTZ > 0 - LD A,TZMM_MZ700_0 ; Ensure the top part of RAM is set to use the mainboard as we need to configure hardware. - OUT (MMCFG),A - ENDIF - -INITST: LD A,0 ; Clear break flag - LD (BRKFLG),A - - LD HL,GVARSTART ; Start of global variable area - LD BC,GVAREND-GVARSTART ; Size of global variable area. - XOR A - LD D,A -INIT1: LD (HL),D ; Clear variable memory including stack space. - INC HL - DEC BC - LD A,B - OR C - JR NZ,INIT1 - ; - CALL MODE ; Configure 8255 port C, set Motor Off, VGATE to 1 (off) and INTMSK to 0 (interrupts disabled). - LD A,000H ; Clear the screen buffer. - LD HL,SCRN - CALL CLR8 - LD A,017H ; Blue background, white characters in colour mode. - LD HL,ARAM - CALL CLR8 - LD A,004H - LD (TEMPW),A ; Setup the tempo for sound output. - -INIT3: ; Setup keyboard buffer control. - LD A,0 - LD (KEYCOUNT),A ; Set keyboard buffer to empty. - LD HL,KEYBUF - LD (KEYWRITE),HL ; Set write pointer to beginning of keyboard buffer. - LD (KEYREAD),HL ; Set read pointer to beginning of keyboard buffer. - - ; Setup keyboard rate control and set to CAPSLOCK mode. - ; (0 = Off, 1 = CAPSLOCK, 2 = SHIFTLOCK). - LD A,000H ; Initialise key repeater. - LD (KEYRPT),A - LD A,001H - LD (SFTLK),A ; Setup shift lock, default = off. - - ; Setup the initial cursor, for CAPSLOCK this is a double underscore. - LD A,03EH - LD (FLSDT),A - LD A,080H ; Cursor on (Bit D7=1). - LD (FLASHCTL),A - -INIT80CVC: IF BUILD_RFSTZ+BUILD_TZFS > 0 - ; Change to 80 character mode. - LD HL,DSPCTL ; Setup address of display control register latch. - LD A, 128 ; 80 char mode. - LD E,(HL) ; Dummy operation to enable latch write via multivibrator. - LD (HL), A - ENDIF -INIT80CHAR: IF BUILD_RFS = 1 - - IF BUILD_80C = 1 - LD A, ROMBANK1 ; Switch to 80char monitor SA-1510. - LD (ROMBK1),A - LD (BNKSELMROM),A - LD A, 1 ; As we call RFS for SD services, specifically DIR listing, we have to ensure RFS is configured for 80 column output mode. - LD (SCRNMODE), A - LD A, 0FFH - LD (SPAGE), A - - ; Change to 80 character mode. - LD HL,DSPCTL ; Setup address of display control register latch. - LD A, 128 ; 80 char mode. - LD E,(HL) ; Dummy operation to enable latch write via multivibrator. - LD (HL), A - ELSE - LD A, ROMBANK0 ; Switch to 40char monitor SA-1510. - LD (ROMBK1),A - LD (BNKSELMROM),A - XOR A ; As we call RFS for SD services, specifically DIR listing, we have to ensure RFS is configured for 40 column output mode. - LD (SCRNMODE), A - LD A, 0FFH - LD (SPAGE), A - ENDIF - ENDIF - ; -INIT80END: LD A,000H ; Clear the screen buffer. - LD HL,SCRN - CALL CLR8 - LD A,071H ; Blue background, white characters in colour mode. Bit 7 is set as a write to bit 7 @ DFFFH selects 80Char mode. - LD HL,ARAM - CALL CLR8 - ; - CALL MLDSP - CALL BEL ; Beep to indicate startup - for cases where screen is slow to startup. - LD A,0FFH - LD (SWRK),A - -INITANSI: IF INCLUDE_ANSITERM = 1 ; If the ansi terminal emulator is builtin, enable it as default. - LD (ANSIENABLE),A - ENDIF - - ; Setup timer interrupts - LD IX,TIMIN ; Pass the interrupt service handler vector. - LD BC,00000H ; Time starts at 00:00:00 01/01/1980 on initialisation. - LD DE,00000H - LD HL,00000H - CALL TIMESET - ; - LD A,05H ; Enable interrupts at hardware level, this must be done before switching memory mode. - LD (KEYPF),A - ; -MEMSW1: IF BUILD_TZFS+BUILD_RFSTZ > 0 - LD A,TZMM_MZ700_2 ; Enable the full 64K memory range before starting BASIC initialisation. - OUT (MMCFG),A - ENDIF - - ; Clear memory - LD HL,WRKSPC -MEMSZ1: IF BUILD_MZ80A+BUILD_RFS > 0 - LD BC,MAXMEM - WRKSPC ; Clear to top of physical RAM. - ENDIF -MEMSZ2: IF BUILD_TZFS+BUILD_RFSTZ > 0 - LD BC,10000H - WRKSPC ; Clear to top of physical RAM. - ENDIF - LD E,00H -INIT4: LD (HL),E - INC HL - DEC BC - LD A,B - OR C - JR NZ,INIT4 - ; - EI - ; -INIT: LD DE,INITAB ; Initialise workspace - LD B,INITBE-INITAB+3 ; Bytes to copy - LD HL,WRKSPC ; Into workspace RAM -COPY: LD A,(DE) ; Get source - LD (HL),A ; To destination - INC HL ; Next destination - INC DE ; Next source - DEC B ; Count bytes - JP NZ,COPY ; More to move - ; LD SP,HL ; Temporary stack - CALL CLREG ; Clear registers and stack - CALL PRNTCRLF ; Output CRLF - LD (BUFFER+72+1),A ; Mark end of buffer - LD (PROGST),A ; Initialise program area - - LD HL,MAXMEM - LD DE,0-50 ; 50 Bytes string space - LD (LSTRAM),HL ; Save last available RAM - ADD HL,DE ; Allocate string space - LD (STRSPC),HL ; Save string space - CALL CLRPTR ; Clear program area - LD HL,(STRSPC) ; Get end of memory - LD DE,0-17 ; Offset for free bytes - ADD HL,DE ; Adjust HL - LD DE,PROGST ; Start of program text - LD A,L ; Get LSB - SUB E ; Adjust it - LD L,A ; Re-save - LD A,H ; Get MSB - SBC A,D ; Adjust it - LD H,A ; Re-save - PUSH HL ; Save bytes free - CALL CLS ; Clear screen and initialise the screen variables - LD HL,SIGNON ; Sign-on message - CALL PRS ; Output string - POP HL ; Get bytes free back - CALL PRNTHL ; Output amount of free memory - LD HL,BFREE ; " Bytes free" message - CALL PRS ; Output string - -WARMST: LD SP,STACK ; Temporary stack -BRKRET: CALL CLREG ; Clear registers and stack - JP PRNTOK ; Go to get command line - - ; FUNCTION ADDRESS TABLE - -FNCTAB: DW SGN - DW INT - DW ABS - DW USR - DW FRE - DW INP - DW POS - DW SQR - DW RND - DW LOG - DW EXP - DW COS - DW SIN - DW TAN - DW ATN - DW PEEK - DW DEEK - DW POINT - DW LEN - DW STR - DW VAL - DW ASC - DW CHR - DW HEX - DW BIN - DW LEFT - DW RIGHT - DW MID - - ; RESERVED WORD LIST - -WORDS: DB 'E'+80H,"ND" ; 0x80 - DB 'F'+80H,"OR" ; 0x81 - DB 'N'+80H,"EXT" ; 0x82 - DB 'D'+80H,"ATA" ; 0x83 - DB 'I'+80H,"NPUT" ; 0x84 - DB 'D'+80H,"IM" ; 0x85 - DB 'R'+80H,"EAD" ; 0x86 - DB 'L'+80H,"ET" ; 0x87 - DB 'G'+80H,"OTO" ; 0x88 - DB 'R'+80H,"UN" ; 0x89 - DB 'I'+80H,"F" ; 0x8a - DB 'R'+80H,"ESTORE" ; 0x8b - DB 'G'+80H,"OSUB" ; 0x8c - DB 'R'+80H,"ETURN" ; 0x8d - DB 'R'+80H,"EM" ; 0x8e - DB 'S'+80H,"TOP" ; 0x8f - DB 'O'+80H,"UT" ; 0x90 - DB 'O'+80H,"N" ; 0x91 - DB 'N'+80H,"ULL" ; 0x92 - DB 'W'+80H,"AIT" ; 0x93 - DB 'D'+80H,"EF" ; 0x94 - DB 'P'+80H,"OKE" ; 0x95 - DB 'D'+80H,"OKE" ; 0x96 - DB 'S'+80H,"CREEN" ; 0x97 - DB 'L'+80H,"INES" ; 0x98 - DB 'C'+80H,"LS" ; 0x99 - DB 'W'+80H,"IDTH" ; 0x9a - DB 'M'+80H,"ONITOR" ; 0x9b - DB 'S'+80H,"ET" ; 0x9c - DB 'R'+80H,"ESET" ; 0x9d - DB 'P'+80H,"RINT" ; 0x9e - DB 'C'+80H,"ONT" ; 0x9f - DB 'L'+80H,"IST" ; 0xa0 - DB 'C'+80H,"LEAR" ; 0xa1 - DB 'A'+80H,"NSITERM" ; 0xa2 - - ; Optional commands to be builtin when a tranZPUter board is present. -OPTIONS0: IF BUILD_TZFS = 1 - DB 'C'+80H,"LOAD" ; 0xa3 - DB 'C'+80H,"SAVE" ; 0xa4 - DB 'L'+80H,"OAD" ; 0xa5 - DB 'S'+80H,"AVE" ; 0xa6 - DB 'F'+80H,"REQ" ; 0xa7 - DB 'D'+80H,"IR" ; 0xa8 - DB 'C'+80H,"D" ; 0xa9 - ENDIF -OPTIONS1: IF BUILD_RFSTZ = 1 - DB 'C'+80H,"LOAD" ; 0xa3 - DB 'C'+80H,"SAVE" ; 0xa4 - DB 'R'+80H,"EM" ; 0xa5 - DB 'R'+80H,"EM" ; 0xa6 - DB 'R'+80H,"EM" ; 0xa7 - DB 'R'+80H,"EM" ; 0xa8 - DB 'R'+80H,"EM" ; 0xa9 - ENDIF -OPTIONS2: IF BUILD_RFS = 1 - DB 'C'+80H,"LOAD" ; 0xa3 - DB 'C'+80H,"SAVE" ; 0xa4 - DB 'D'+80H,"IR" ; 0xa5 - DB 'R'+80H,"EM" ; 0xa6 - DB 'R'+80H,"EM" ; 0xa7 - DB 'R'+80H,"EM" ; 0xa8 - DB 'R'+80H,"EM" ; 0xa9 - ENDIF -OPTIONS3: IF BUILD_MZ80A = 1 - DB 'C'+80H,"LOAD" ; 0xa3 - DB 'C'+80H,"SAVE" ; 0xa4 - DB 'R'+80H,"EM" ; 0xa5 - DB 'R'+80H,"EM" ; 0xa6 - DB 'R'+80H,"EM" ; 0xa7 - DB 'R'+80H,"EM" ; 0xa8 - DB 'R'+80H,"EM" ; 0xa9 - ENDIF - DB 'N'+80H,"EW" ; 0xaa <- Command list terminator word, move to lowest command. Update the ZNEW variable below as well. - ; <- Reserved space for new commands. - DB 'R'+80H,"EM" ; 0xab - DB 'R'+80H,"EM" ; 0xac - DB 'R'+80H,"EM" ; 0xad - DB 'R'+80H,"EM" ; 0xae - DB 'R'+80H,"EM" ; 0xaf - DB 'R'+80H,"EM" ; 0xb0 - DB 'R'+80H,"EM" ; 0xb1 - DB 'R'+80H,"EM" ; 0xb2 - DB 'R'+80H,"EM" ; 0xb3 - DB 'R'+80H,"EM" ; 0xb4 - DB 'R'+80H,"EM" ; 0xb5 - DB 'R'+80H,"EM" ; 0xb6 - DB 'R'+80H,"EM" ; 0xb7 - DB 'R'+80H,"EM" ; 0xb8 - DB 'R'+80H,"EM" ; 0xb9 - DB 'R'+80H,"EM" ; 0xba - DB 'R'+80H,"EM" ; 0xbb - DB 'R'+80H,"EM" ; 0xbc - DB 'R'+80H,"EM" ; 0xbd - DB 'R'+80H,"EM" ; 0xbe - DB 'R'+80H,"EM" ; 0xbf - - DB 'T'+80H,"AB(" ; 0xc0 <- 0xa5 - DB 'T'+80H,"O" ; 0xc1 <- 0xa6 - DB 'F'+80H,"N" ; 0xc2 <- 0xa7 - DB 'S'+80H,"PC(" ; 0xc3 <- 0xa8 - DB 'T'+80H,"HEN" ; 0xc4 <- 0xa9 - DB 'N'+80H,"OT" ; 0xc5 <- 0xaa - DB 'S'+80H,"TEP" ; 0xc6 <- 0xab - - DB '+'+80H ; 0xc7 <- 0xac - DB '-'+80H ; 0xc8 <- 0xad - DB '*'+80H ; 0xc9 <- 0xae - DB '/'+80H ; 0xca <- 0xaf - DB '^'+80H ; 0xcb <- 0xb0 - DB 'A'+80H,"ND" ; 0xcc <- 0xb1 - DB 'O'+80H,"R" ; 0xcd <- 0xb2 - DB '>'+80H ; 0xce <- 0xb3 - DB '='+80H ; 0xcf <- 0xb4 - DB '<'+80H ; 0xd0 <- 0xb5 - - DB 'S'+80H,"GN" ; 0xd1 <- 0xb6 - DB 'I'+80H,"NT" ; 0xd2 <- 0xb7 - DB 'A'+80H,"BS" ; 0xd3 <- 0xb8 - DB 'U'+80H,"SR" ; 0xd4 <- 0xb9 - DB 'F'+80H,"RE" ; 0xd5 <- 0xba - DB 'I'+80H,"NP" ; 0xd6 <- 0xbb - DB 'P'+80H,"OS" ; 0xd7 <- 0xbc - DB 'S'+80H,"QR" ; 0xd8 <- 0xbd - DB 'R'+80H,"ND" ; 0xd9 <- 0xbe - DB 'L'+80H,"OG" ; 0xda <- 0xbf - DB 'E'+80H,"XP" ; 0xdb <- 0xc0 - DB 'C'+80H,"OS" ; 0xdc <- 0xc1 - DB 'S'+80H,"IN" ; 0xdd <- 0xc2 - DB 'T'+80H,"AN" ; 0xde <- 0xc3 - DB 'A'+80H,"TN" ; 0xdf <- 0xc4 - DB 'P'+80H,"EEK" ; 0xe0 <- 0xc5 - DB 'D'+80H,"EEK" ; 0xe1 <- 0xc6 - DB 'P'+80H,"OINT" ; 0xe2 <- 0xc7 - DB 'L'+80H,"EN" ; 0xe3 <- 0xc8 - DB 'S'+80H,"TR$" ; 0xe4 <- 0xc9 - DB 'V'+80H,"AL" ; 0xe5 <- 0xca - DB 'A'+80H,"SC" ; 0xe6 <- 0xcb - DB 'C'+80H,"HR$" ; 0xe7 <- 0xcc - DB 'H'+80H,"EX$" ; 0xe8 <- 0xcd - DB 'B'+80H,"IN$" ; 0xe9 <- 0xce - DB 'L'+80H,"EFT$" ; 0xea <- 0xcf - DB 'R'+80H,"IGHT$" ; 0xeb <- 0xd0 - DB 'M'+80H,"ID$" ; 0xec <- 0xd1 - DB 80H ; End of list marker - - ; KEYWORD ADDRESS TABLE - -WORDTB: DW PEND - DW FOR - DW NEXT - DW DATA - DW INPUT - DW DIM - DW READ - DW LET - DW GOTO - DW RUN - DW IF - DW RESTOR - DW GOSUB - DW RETURN - DW REM - DW STOP - DW POUT - DW ON - DW NULL - DW WAIT - DW DEF - DW POKE - DW DOKE - DW SCREEN - DW LINES - DW CLS - DW WIDTH - DW MONITR - DW PSET - DW RESET - DW PRINT - DW CONT - DW LIST - DW CLEAR - DW SETANSITERM ; Enable/disable the ANSI Terminal Emulator. - - ; Optional commands to be builtin when a tranZPUter board is present. -OPTIONS0A: IF BUILD_TZFS = 1 - DW CLOADTZ ; Load tokenised BASIC program. - DW CSAVETZ ; Save tokenised BASIC program. - DW LOAD ; Load ASCII text BASIC program. - DW SAVE ; Save BASIC as ASCII text. - DW SETFREQ ; Set the CPU Frequency. - DW DIRSDCARD ; List out the SD directory. - DW SETDIR ; Change directory for all load and save operations. - ENDIF -OPTIONS1A: IF BUILD_RFSTZ = 1 - DW CLOAD80A ; Load tokenised BASIC program from tape. - DW CSAVE80A ; Save tokenised BASIC program to tape. - DW REM - DW REM - DW REM - DW REM - DW REM - ENDIF -OPTIONS2A: IF BUILD_RFS = 1 - DW CLOAD80A ; Load tokenised BASIC program from tape. - DW CSAVE80A ; Save tokenised BASIC program to tape. - DW SDDIRCMD ; Directory listing of the SD card. - DW REM - DW REM - DW REM - DW REM - ENDIF -OPTIONS3A: IF BUILD_MZ80A = 1 - DW CLOAD80A ; Load tokenised BASIC program from tape. - DW CSAVE80A ; Save tokenised BASIC program to tape. - DW REM - DW REM - DW REM - DW REM - DW REM - ENDIF - DW NEW - - ; RESERVED WORD TOKEN VALUES - -ZEND EQU 080H ; END - ZEND marks the start of the table. -ZFOR EQU 081H ; FOR -ZDATA EQU 083H ; DATA -ZGOTO EQU 088H ; GOTO -ZGOSUB EQU 08CH ; GOSUB -ZREM EQU 08EH ; REM -ZPRINT EQU 09EH ; PRINT -ZNEW EQU 0AAH ; NEW - ZNEW marks the end of the table - ; AA..BF are reserved for future commands. - - ; Space for expansion, a block of tokens for commands has been created from 0xA5 to 0xBF. - -FUNCSTRT EQU 0C0H ; Function start. -ZTAB EQU FUNCSTRT + 00H ; 0A5H ; TAB -ZTO EQU FUNCSTRT + 01H ; 0A6H ; TO -ZFN EQU FUNCSTRT + 02H ; 0A7H ; FN -ZSPC EQU FUNCSTRT + 03H ; 0A8H ; SPC -ZTHEN EQU FUNCSTRT + 04H ; 0A9H ; THEN -ZNOT EQU FUNCSTRT + 05H ; 0AAH ; NOT -ZSTEP EQU FUNCSTRT + 06H ; 0ABH ; STEP - -ZPLUS EQU FUNCSTRT + 07H ; 0ACH ; + -ZMINUS EQU FUNCSTRT + 08H ; 0ADH ; - -ZTIMES EQU FUNCSTRT + 09H ; 0AEH ; * -ZDIV EQU FUNCSTRT + 0AH ; 0AFH ; / - ; 0B0H - ; 0B1H -ZOR EQU FUNCSTRT + 0dH ; 0B2H ; OR -ZGTR EQU FUNCSTRT + 0eH ; 0B3H ; > -ZEQUAL EQU FUNCSTRT + 0fH ; 0B4H ; M -ZLTH EQU FUNCSTRT + 10H ; 0B5H ; < -ZSGN EQU FUNCSTRT + 11H ; 0B6H ; SGN - ; 0B7H - ; 0B8H - ; 0B9H - ; 0BAH - ; 0BBH - ; 0BCH - ; 0BDH - ; 0BEH - ; 0BFH - ; 0C0H - ; 0C1H - ; 0C2H - ; 0C3H - ; 0C4H - ; 0C5H - ; 0C6H -ZPOINT EQU FUNCSTRT + 22H ; 0C7H ; POINT - ; 0C8H - ; 0C9H - ; 0CAH - ; 0CBH - ; 0CCH -ZLEFT EQU FUNCSTRT + 2aH ; 0CFH ; LEFT$ - - ; Space for expansion, reserve a block of tokens for functions. - - - ; ARITHMETIC PRECEDENCE TABLE - -PRITAB: DB 79H ; Precedence value - DW PADD ; FPREG = + FPREG - - DB 79H ; Precedence value - DW PSUB ; FPREG = - FPREG - - DB 7CH ; Precedence value - DW MULT ; PPREG = * FPREG - - DB 7CH ; Precedence value - DW DIV ; FPREG = / FPREG - - DB 7FH ; Precedence value - DW POWER ; FPREG = ^ FPREG - - DB 50H ; Precedence value - DW PAND ; FPREG = AND FPREG - - DB 46H ; Precedence value - DW POR ; FPREG = OR FPREG - - ; BASIC ERROR CODE LIST - -ERRORS: DB "NF" ; NEXT without FOR - DB "SN" ; Syntax error - DB "RG" ; RETURN without GOSUB - DB "OD" ; Out of DATA - DB "FC" ; Illegal function call - DB "OV" ; Overflow error - DB "OM" ; Out of memory - DB "UL" ; Undefined line - DB "BS" ; Bad subscript - DB "DD" ; Re-DIMensioned array - DB "/0" ; Division by zero - DB "ID" ; Illegal direct - DB "TM" ; Type mis-match - DB "OS" ; Out of string space - DB "LS" ; String too long - DB "ST" ; String formula too complex - DB "CN" ; Can't CONTinue - DB "UF" ; Undefined FN function - DB "MO" ; Missing operand - DB "HX" ; HEX error - DB "BN" ; BIN error - DB "BV" ; Bad Value - DB "IO" ; IO error - - ; INITIALISATION TABLE ------------------------------------------------------- - -INITAB: JP WARMST ; Warm start jump - JP FCERR ; "USR (X)" jump (Set to Error) - - OUT (0),A ; "OUT p,n" skeleton - RET - - SUB 0 ; Division support routine - LD L,A - LD A,H - SBC A,0 - LD H,A - LD A,B - SBC A,0 - LD B,A - LD A,0 - RET - - DB 0,0,0 ; Random number seed - ; Table used by RND - DB 035H,04AH,0CAH,099H ;-2.65145E+07 - DB 039H,01CH,076H,098H ; 1.61291E+07 - DB 022H,095H,0B3H,098H ;-1.17691E+07 - DB 00AH,0DDH,047H,098H ; 1.30983E+07 - DB 053H,0D1H,099H,099H ;-2-01612E+07 - DB 00AH,01AH,09FH,098H ;-1.04269E+07 - DB 065H,0BCH,0CDH,098H ;-1.34831E+07 - DB 0D6H,077H,03EH,098H ; 1.24825E+07 - DB 052H,0C7H,04FH,080H ; Last random number - - IN A,(0) ; INP (x) skeleton - RET - - DB 1 ; POS (x) number (1) -INITABW: DB 0FFH ; Terminal width set to initial state of 255 which means unlimited width. Applicable to data output not physical screen. - IF BUILD_80C = 1 - DB 28 ; Width for commas (3 columns) - ELSE - DB 14 ; Width for commas (3 columns) - ENDIF - DB 0 ; No nulls after input bytes - DB 0 ; Output enabled (^O off) - - DW 20 ; Initial lines counter - DW 20 ; Initial lines number - DW 0 ; Array load/save check sum - - DB 0 ; Break not by NMI - DB 0 ; Break flag - - JP TTYLIN ; Input reflection (set to TTY) - JP 0000H ; POINT reflection unused - JP 0000H ; SET reflection - JP 0000H ; RESET reflection - ;JP POINTB ; POINT reflection unused - ;JP SETB ; SET reflection - ;JP RESETB ; RESET reflection - - DW STLOOK ; Temp string space - DW -2 ; Current line number (cold) - DW PROGST+1 ; Start of program text -INITBE: ; END OF INITIALISATION TABLE - - ; END OF INITIALISATION TABLE --------------------------------------------------- - -ERRMSG: DB " Error",0 -INMSG: DB " in ",0 -ZERBYT EQU $-1 ; A zero byte -OKMSG: DB "Ok",CR,LF,0,0 -BRKMSG: DB "Break",0 - -BAKSTK: LD HL,4 ; Look for "FOR" block with - ADD HL,SP ; same index as specified -LOKFOR: LD A,(HL) ; Get block ID - INC HL ; Point to index address - CP ZFOR ; Is it a "FOR" token - RET NZ ; No - exit - LD C,(HL) ; BC = Address of "FOR" index - INC HL - LD B,(HL) - INC HL ; Point to sign of STEP - PUSH HL ; Save pointer to sign - LD L,C ; HL = address of "FOR" index - LD H,B - LD A,D ; See if an index was specified - OR E ; DE = 0 if no index specified - EX DE,HL ; Specified index into HL - JP Z,INDFND ; Skip if no index given - EX DE,HL ; Index back into DE - CALL CPDEHL ; Compare index with one given -INDFND: LD BC,16-3 ; Offset to next block - POP HL ; Restore pointer to sign - RET Z ; Return if block found - ADD HL,BC ; Point to next block - JP LOKFOR ; Keep on looking - -MOVUP: CALL ENFMEM ; See if enough memory -MOVSTR: PUSH BC ; Save end of source - EX (SP),HL ; Swap source and dest" end - POP BC ; Get end of destination -MOVLP: CALL CPDEHL ; See if list moved - LD A,(HL) ; Get byte - LD (BC),A ; Move it - RET Z ; Exit if all done - DEC BC ; Next byte to move to - DEC HL ; Next byte to move - JP MOVLP ; Loop until all bytes moved - -CHKSTK: PUSH HL ; Save code string address - LD HL,(ARREND) ; Lowest free memory - LD B,0 ; BC = Number of levels to test - ADD HL,BC ; 2 Bytes for each level - ADD HL,BC - DB 3EH ; Skip "PUSH HL" -ENFMEM: PUSH HL ; Save code string address - LD A,0D0H ;LOW -48 ; 48 Bytes minimum RAM - SUB L - LD L,A - LD A,0FFH ; HIGH (-48) ; 48 Bytes minimum RAM - SBC A,H - JP C,OMERR ; Not enough - ?OM Error - LD H,A - ADD HL,SP ; Test if stack is overflowed - POP HL ; Restore code string address - RET C ; Return if enough mmory -OMERR: LD E,OM ; ?OM Error - JP BERROR - -DATSNR: LD HL,(DATLIN) ; Get line of current DATA item - LD (LINEAT),HL ; Save as current line -SNERR: LD E,SN ; ?SN Error - DB 01H ; Skip "LD E,DZ" -DZERR: LD E,DZ ; ?/0 Error - DB 01H ; Skip "LD E,NF" -NFERR: LD E,NF ; ?NF Error - DB 01H ; Skip "LD E,DD" -DDERR: LD E,DDA ; ?DD Error - DB 01H ; Skip "LD E,UF" -UFERR: LD E,UF ; ?UF Error - DB 01H ; Skip "LD E,OV -OVERR: LD E,OV ; ?OV Error - DB 01H ; Skip "LD E,TM" -TMERR: LD E,TM ; ?TM Error - -BERROR: CALL CLREG ; Clear registers and stack - LD (CTLOFG),A ; Enable output (A is 0) - CALL STTLIN ; Start new line - LD HL,ERRORS ; Point to error codes - LD D,A ; D = 0 (A is 0) - LD A,'?' - CALL OUTC ; Output '?' - ADD HL,DE ; Offset to correct error code - LD A,(HL) ; First character - CALL OUTC ; Output it - CALL GETCHR ; Get next character - CALL OUTC ; Output it - LD HL,ERRMSG ; "Error" message -ERRIN: CALL PRS ; Output message - LD HL,(LINEAT) ; Get line of error - LD DE,-2 ; Cold start error if -2 - CALL CPDEHL ; See if cold start error - JP Z,CSTART ; Cold start error - Restart - LD A,H ; Was it a direct error? - AND L ; Line = -1 if direct error - INC A - CALL NZ,LINEIN ; No - output line of error - DB 3EH ; Skip "POP BC" -POPNOK: POP BC ; Drop address in input buffer - -PRNTOK: XOR A ; Output "Ok" and get command - LD (CTLOFG),A ; Enable output - CALL STTLIN ; Start new line - LD HL,OKMSG ; "Ok" message - CALL PRS ; Output "Ok" -GETCMD: LD HL,-1 ; Flag direct mode - LD (LINEAT),HL ; Save as current line - CALL GETLIN ; Get an input line - JP C,GETCMD ; Get line again if break - CALL GETCHR ; Get first character - INC A ; Test if end of line - DEC A ; Without affecting Carry - JP Z,GETCMD ; Nothing entered - Get another - PUSH AF ; Save Carry status - CALL ATOH ; Get line number into DE - PUSH DE ; Save line number - CALL CRUNCH ; Tokenise rest of line - LD B,A ; Length of tokenised line -> length is in C, B is zeroed. - POP DE ; Restore line number - POP AF ; Restore Carry - JP NC,EXCUTE ; No line number - Direct mode - PUSH DE ; Save line number - PUSH BC ; Save length of tokenised line - XOR A - LD (LSTBIN),A ; Clear last byte input - CALL GETCHR ; Get next character - OR A ; Set flags - PUSH AF ; And save them - CALL SRCHLN ; Search for line number in DE - JP C,LINFND ; Jump if line found - POP AF ; Get status - PUSH AF ; And re-save - JP Z,ULERR ; Nothing after number - Error - OR A ; Clear Carry -LINFND: PUSH BC ; Save address of line in prog - JP NC,INEWLN ; Line not found - Insert new - EX DE,HL ; Next line address in DE - LD HL,(PROGND) ; End of program -SFTPRG: LD A,(DE) ; Shift rest of program down - LD (BC),A - INC BC ; Next destination - INC DE ; Next source - CALL CPDEHL ; All done? - JP NZ,SFTPRG ; More to do - LD H,B ; HL - New end of program - LD L,C - LD (PROGND),HL ; Update end of program - -INEWLN: POP DE ; Get address of line, - POP AF ; Get status - JP Z,SETPTR ; No text - Set up pointers - LD HL,(PROGND) ; Get end of program - EX (SP),HL ; Get length of input line - POP BC ; End of program to BC - ADD HL,BC ; Find new end - PUSH HL ; Save new end - CALL MOVUP ; Make space for line - POP HL ; Restore new end - LD (PROGND),HL ; Update end of program pointer - EX DE,HL ; Get line to move up in HL - LD (HL),H ; Save MSB - POP DE ; Get new line number - INC HL ; Skip pointer - INC HL - LD (HL),E ; Save LSB of line number - INC HL - LD (HL),D ; Save MSB of line number - INC HL ; To first byte in line - LD DE,BUFFER ; Copy buffer to program -MOVBUF: LD A,(DE) ; Get source - LD (HL),A ; Save destinations - INC HL ; Next source - INC DE ; Next destination - OR A ; Done? - JP NZ,MOVBUF ; No - Repeat -SETPTR: CALL RUNFST ; Set line pointers - INC HL ; To LSB of pointer - EX DE,HL ; Address to DE -PTRLP: LD H,D ; Address to HL - LD L,E - LD A,(HL) ; Get LSB of pointer - INC HL ; To MSB of pointer - OR (HL) ; Compare with MSB pointer - JP Z,GETCMD ; Get command line if end - INC HL ; To LSB of line number - INC HL ; Skip line number - INC HL ; Point to first byte in line - XOR A ; Looking for 00 byte -FNDEND: CP (HL) ; Found end of line? - INC HL ; Move to next byte - JP NZ,FNDEND ; No - Keep looking - EX DE,HL ; Next line address to HL - LD (HL),E ; Save LSB of pointer - INC HL - LD (HL),D ; Save MSB of pointer - JP PTRLP ; Do next line - -SRCHLN: LD HL,(BASTXT) ; Start of program text -SRCHLP: LD B,H ; BC = Address to look at - LD C,L - LD A,(HL) ; Get address of next line - INC HL - OR (HL) ; End of program found? - DEC HL - RET Z ; Yes - Line not found - INC HL - INC HL - LD A,(HL) ; Get LSB of line number - INC HL - LD H,(HL) ; Get MSB of line number - LD L,A - CALL CPDEHL ; Compare with line in DE - LD H,B ; HL = Start of this line - LD L,C - LD A,(HL) ; Get LSB of next line address - INC HL - LD H,(HL) ; Get MSB of next line address - LD L,A ; Next line to HL - CCF - RET Z ; Lines found - Exit - CCF - RET NC ; Line not found,at line after - JP SRCHLP ; Keep looking - -NEW: RET NZ ; Return if any more on line -CLRPTR: LD HL,(BASTXT) ; Point to start of program - XOR A ; Set program area to empty - LD (HL),A ; Save LSB = 00 - INC HL - LD (HL),A ; Save MSB = 00 - INC HL - LD (PROGND),HL ; Set program end - -RUNFST: LD HL,(BASTXT) ; Clear all variables - DEC HL - -INTVAR: LD (BRKLIN),HL ; Initialise RUN variables - LD HL,(LSTRAM) ; Get end of RAM - LD (STRBOT),HL ; Clear string space - XOR A - CALL RESTOR ; Reset DATA pointers - LD HL,(PROGND) ; Get end of program - LD (VAREND),HL ; Clear variables - LD (ARREND),HL ; Clear arrays - -CLREG: POP BC ; Save return address - LD HL,(STRSPC) ; Get end of working RAN - LD SP,HL ; Set stack - LD HL,TMSTPL ; Temporary string pool - LD (TMSTPT),HL ; Reset temporary string ptr - XOR A ; A = 00 - LD L,A ; HL = 0000 - LD H,A - LD (CONTAD),HL ; No CONTinue - LD (FORFLG),A ; Clear FOR flag - LD (FNRGNM),HL ; Clear FN argument - PUSH HL ; HL = 0000 - PUSH BC ; Put back return -DOAGN: LD HL,(BRKLIN) ; Get address of code to RUN - RET ; Return to execution driver - -PROMPT: LD A,'?' ; '?' - CALL OUTC ; Output character - LD A,' ' ; Space - CALL OUTC ; Output character - JP RINPUT ; Get input line - -CRUNCH: XOR A ; Tokenise line @ HL to BUFFER - LD (DATFLG),A ; Reset literal flag - LD C,2+3 ; 2 byte number and 3 nulls - LD DE,BUFFER ; Start of input buffer -CRNCLP: LD A,(HL) ; Get byte - CP ' ' ; Is it a space? - JP Z,MOVDIR ; Yes - Copy direct - LD B,A ; Save character - CP '"' ; Is it a quote? - JP Z,CPYLIT ; Yes - Copy literal string - OR A ; Is it end of buffer? - JP Z,ENDBUF ; Yes - End buffer - LD A,(DATFLG) ; Get data type - OR A ; Literal? - LD A,(HL) ; Get byte to copy - JP NZ,MOVDIR ; Literal - Copy direct - CP '?' ; Is it '?' short for PRINT - LD A,ZPRINT ; "PRINT" token - JP Z,MOVDIR ; Yes - replace it - LD A,(HL) ; Get byte again - CP '0' ; Is it less than '0' - JP C,FNDWRD ; Yes - Look for reserved words - CP 60; ";"+1 ; Is it "0123456789:;" ? - JP C,MOVDIR ; Yes - copy it direct -FNDWRD: PUSH DE ; Look for reserved words - LD DE,WORDS-1 ; Point to table - PUSH BC ; Save count - LD BC,RETNAD ; Where to return to - PUSH BC ; Save return address - LD B,ZEND-1 ; First token value -1 - LD A,(HL) ; Get byte - CP 'a' ; Less than 'a' ? - JP C,SEARCH ; Yes - search for words - CP 'z'+1 ; Greater than 'z' ? - JP NC,SEARCH ; Yes - search for words - AND 01011111B ; Force upper case - LD (HL),A ; Replace byte -SEARCH: LD C,(HL) ; Search for a word - EX DE,HL -GETNXT: INC HL ; Get next reserved word - OR (HL) ; Start of word? - JP P,GETNXT ; No - move on - INC B ; Increment token value - LD A, (HL) ; Get byte from table - AND 01111111B ; Strip bit 7 - RET Z ; Return if end of list - CP C ; Same character as in buffer? - JP NZ,GETNXT ; No - get next word - EX DE,HL - PUSH HL ; Save start of word - -NXTBYT: INC DE ; Look through rest of word - LD A,(DE) ; Get byte from table - OR A ; End of word ? - JP M,MATCH ; Yes - Match found - LD C,A ; Save it - LD A,B ; Get token value - CP ZGOTO ; Is it "GOTO" token ? - JP NZ,NOSPC ; No - Don't allow spaces - CALL GETCHR ; Get next character - DEC HL ; Cancel increment from GETCHR -NOSPC: INC HL ; Next byte - LD A,(HL) ; Get byte - CP 'a' ; Less than 'a' ? - JP C,NOCHNG ; Yes - don't change - AND 01011111B ; Make upper case -NOCHNG: CP C ; Same as in buffer ? - JP Z,NXTBYT ; Yes - keep testing - POP HL ; Get back start of word - JP SEARCH ; Look at next word - -MATCH: LD C,B ; Word found - Save token value - POP AF ; Throw away return - EX DE,HL - RET ; Return to "RETNAD" -RETNAD: EX DE,HL ; Get address in string - LD A,C ; Get token value - POP BC ; Restore buffer length - POP DE ; Get destination address -MOVDIR: INC HL ; Next source in buffer - LD (DE),A ; Put byte in buffer - INC DE ; Move up buffer - INC C ; Increment length of buffer - SUB ':' ; End of statement? - JP Z,SETLIT ; Jump if multi-statement line - CP ZDATA-3AH ; Is it DATA statement ? - JP NZ,TSTREM ; No - see if REM -SETLIT: LD (DATFLG),A ; Set literal flag -TSTREM: SUB ZREM-3AH ; Is it REM? - JP NZ,CRNCLP ; No - Leave flag - LD B,A ; Copy rest of buffer -NXTCHR: LD A,(HL) ; Get byte - OR A ; End of line ? - JP Z,ENDBUF ; Yes - Terminate buffer - CP B ; End of statement ? - JP Z,MOVDIR ; Yes - Get next one -CPYLIT: INC HL ; Move up source string - LD (DE),A ; Save in destination - INC C ; Increment length - INC DE ; Move up destination - JP NXTCHR ; Repeat - -ENDBUF: LD HL,BUFFER-1 ; Point to start of buffer - LD (DE),A ; Mark end of buffer (A = 00) - INC DE - LD (DE),A ; A = 00 - INC DE - LD (DE),A ; A = 00 - RET - -DODEL: LD A,(NULFLG) ; Get null flag status - OR A ; Is it zero? - LD A,0 ; Zero A - Leave flags - LD (NULFLG),A ; Zero null flag - JP NZ,ECHDEL ; Set - Echo it - DEC B ; Decrement length - JP Z,GETLIN ; Get line again if empty - CALL OUTC ; Output null character - DB 3EH ; Skip "DEC B" -ECHDEL: DEC B ; Count bytes in buffer - DEC HL ; Back space buffer - JP Z,OTKLN ; No buffer - Try again - LD A,(HL) ; Get deleted byte - CALL OUTC ; Echo it - JP MORINP ; Get more input - -DELCHR: DEC B ; Count bytes in buffer - DEC HL ; Back space buffer - JR Z,GETLIN ; End of buffer, start again - CALL OUTC ; Output character in A - JP NZ,MORINP ; Not end - Get more -OTKLN: CALL OUTC ; Output character in A -KILIN: CALL PRNTCRLF ; Output CRLF - JP TTYLIN ; Get line again - -GETLIN: -TTYLIN: LD HL,BUFFER ; Get a line by character - LD B,1 ; Set buffer as empty - XOR A - LD (NULFLG),A ; Clear null flag -MORINP: CALL CLOTST ; Get character and test ^O - LD C,A ; Save character in C - CP DELETE ; Delete character? - JP Z,DELCHR ;DODEL ; Yes - Process it - LD A,(NULFLG) ; Get null flag - OR A ; Test null flag status - JP Z,PROCES ; Reset - Process character - LD A,0 ; Set a null - CALL OUTC ; Output null - XOR A ; Clear A - LD (NULFLG),A ; Reset null flag -PROCES: LD A,C ; Get character - CP CTRL_G ; Bell? - JP Z,PUTCTL ; Yes - Save it - CP CTRL_C ; Is it control "C"? - CALL Z,PRNTCRLF ; Yes - Output CRLF - SCF ; Flag break - RET Z ; Return if control "C" - CP CR ; Is it enter? - JP Z,ENDINP ; Yes - Terminate input - CP CTRL_U ; Is it control "U"? - JP Z,KILIN ; Yes - Get another line - CP '@' ; Is it "kill line"? - JP Z,OTKLN ; Yes - Kill line - CP DELETE ; Is it delete? - JP Z,DELCHR ; Yes - Delete character - CP BACKS ; Is it backspace? - JP Z,DELCHR ; Yes - Delete character - CP CTRL_R ; Is it control "R"? - JP NZ,PUTBUF ; No - Put in buffer - PUSH BC ; Save buffer length - PUSH DE ; Save DE - PUSH HL ; Save buffer address - LD (HL),0 ; Mark end of buffer - CALL OUTNCR ; Output and do CRLF - LD HL,BUFFER ; Point to buffer start - CALL PRS ; Output buffer - POP HL ; Restore buffer address - POP DE ; Restore DE - POP BC ; Restore buffer length - JP MORINP ; Get another character - -PUTBUF: CP ' ' ; Is it a control code? - JP C,MORINP ; Yes - Ignore -PUTCTL: LD A,B ; Get number of bytes in buffer - CP 72+1 ; Test for line overflow - LD A,CTRL_G ; Set a bell - JP NC,OUTNBS ; Ring bell if buffer full - LD A,C ; Get character - LD (HL),C ; Save in buffer - LD (LSTBIN),A ; Save last input byte - INC HL ; Move up buffer - INC B ; Increment length -OUTIT: CALL OUTC ; Output the character entered - JP MORINP ; Get another character - -OUTNBS: CALL PRNT ; Strange, get to end of line ring bell then back space???? Disabled, just ring bell. This area of code needs a new handler. - JP MORINP ; Get another character - ;CALL OUTC ; Output bell and back over it - ;LD A,BACKS ; Set back space - ;JP OUTIT ; Output it and get more - -CPDEHL: LD A,H ; Get H - SUB D ; Compare with D - RET NZ ; Different - Exit - LD A,L ; Get L - SUB E ; Compare with E - RET ; Return status - -CHKSYN: LD A,(HL) ; Check syntax of character - EX (SP),HL ; Address of test byte - CP (HL) ; Same as in code string? - INC HL ; Return address - EX (SP),HL ; Put it back - JP Z,GETCHR ; Yes - Get next character - JP SNERR ; Different - ?SN Error - -OUTC: PUSH AF ; Save character - LD A,(CTLOFG) ; Get control "O" flag - OR A ; Is it set? - JP NZ,POPAF ; Yes - don't output - POP AF ; Restore character - PUSH BC ; Save buffer length - PUSH AF ; Save character - CP ' ' ; Is it a control code? - JP C,DINPOS ; Yes - Don't INC POS(X) - LD A,(LWIDTH) ; Get line width - LD B,A ; To B - LD A,(CURPOS) ; Get cursor position - INC B ; Width 255? - JP Z,INCLEN ; Yes - No width limit - DEC B ; Restore width - CP B ; At end of line? - CALL Z,PRNTCRLF ; Yes - output CRLF -INCLEN: INC A ; Move on one character - LD (CURPOS),A ; Save new position -DINPOS: IF INCLUDE_ANSITERM = 1 - LD A,(ANSIENABLE) - OR A - JR Z,NOANSI - POP AF ; Restore character - POP BC ; Restore buffer length - CALL ANSITERM ; Send it via the Ansi processor. - RET - ENDIF -NOANSI: POP AF ; Restore character - POP BC ; Restore buffer length - CALL PRNT ; Send it . - RET - -CLOTST: CALL GETKY ; Get input character - AND 01111111B ; Strip bit 7 - CP CTRL_O ; Is it control "O"? - RET NZ ; No don't flip flag - LD A,(CTLOFG) ; Get flag - CPL ; Flip it - LD (CTLOFG),A ; Put it back - XOR A ; Null character - RET - -LIST: CALL ATOH ; ASCII number to DE - RET NZ ; Return if anything extra - POP BC ; Rubbish - Not needed - CALL SRCHLN ; Search for line number in DE - PUSH BC ; Save address of line - CALL SETLIN ; Set up lines counter -LISTLP: POP HL ; Restore address of line - LD C,(HL) ; Get LSB of next line - INC HL - LD B,(HL) ; Get MSB of next line - INC HL - LD A,B ; BC = 0 (End of program)? - OR C - JP Z,PRNTOK ; Yes - Go to command mode - CALL COUNT ; Count lines - CALL TSTBRK ; Test for break key - PUSH BC ; Save address of next line - CALL PRNTCRLF ; Output CRLF - LD E,(HL) ; Get LSB of line number - INC HL - LD D,(HL) ; Get MSB of line number - INC HL - PUSH HL ; Save address of line start - EX DE,HL ; Line number to HL - CALL PRNTHL ; Output line number in decimal - LD A,' ' ; Space after line number - POP HL ; Restore start of line address -LSTLP2: CALL OUTC ; Output character in A -LSTLP3: LD A,(HL) ; Get next byte in line - OR A ; End of line? - INC HL ; To next byte in line - JP Z,LISTLP ; Yes - get next line - JP P,LSTLP2 ; No token - output it - SUB ZEND-1 ; Find and output word - LD C,A ; Token offset+1 to C - LD DE,WORDS ; Reserved word list -FNDTOK: LD A,(DE) ; Get character in list - INC DE ; Move on to next - OR A ; Is it start of word? - JP P,FNDTOK ; No - Keep looking for word - DEC C ; Count words - JP NZ,FNDTOK ; Not there - keep looking -OUTWRD: AND 01111111B ; Strip bit 7 - CALL OUTC ; Output first character - LD A,(DE) ; Get next character - INC DE ; Move on to next - OR A ; Is it end of word? - JP P,OUTWRD ; No - output the rest - JP LSTLP3 ; Next byte in line - -SETLIN: PUSH HL ; Set up LINES counter - LD HL,(LINESN) ; Get LINES number - LD (LINESC),HL ; Save in LINES counter - POP HL - RET - -COUNT: PUSH HL ; Save code string address - PUSH DE - LD HL,(LINESC) ; Get LINES counter - LD DE,-1 - ADC HL,DE ; Decrement - LD (LINESC),HL ; Put it back - POP DE - POP HL ; Restore code string address - RET P ; Return if more lines to go - PUSH HL ; Save code string address - LD HL,(LINESN) ; Get LINES number - LD (LINESC),HL ; Reset LINES counter - CALL GETKY ; Get input character - CP CTRL_C ; Is it control "C"? - JP Z,RSLNBK ; Yes - Reset LINES and break - POP HL ; Restore code string address - JP COUNT ; Keep on counting - -RSLNBK: LD HL,(LINESN) ; Get LINES number - LD (LINESC),HL ; Reset LINES counter - JP BRKRET ; Go and output "Break" - -FOR: LD A,64H ; Flag "FOR" assignment - LD (FORFLG),A ; Save "FOR" flag - CALL LET ; Set up initial index - POP BC ; Drop RETurn address - PUSH HL ; Save code string address - CALL DATA ; Get next statement address - LD (LOOPST),HL ; Save it for start of loop - LD HL,2 ; Offset for "FOR" block - ADD HL,SP ; Point to it -FORSLP: CALL LOKFOR ; Look for existing "FOR" block - POP DE ; Get code string address - JP NZ,FORFND ; No nesting found - ADD HL,BC ; Move into "FOR" block - PUSH DE ; Save code string address - DEC HL - LD D,(HL) ; Get MSB of loop statement - DEC HL - LD E,(HL) ; Get LSB of loop statement - INC HL - INC HL - PUSH HL ; Save block address - LD HL,(LOOPST) ; Get address of loop statement - CALL CPDEHL ; Compare the FOR loops - POP HL ; Restore block address - JP NZ,FORSLP ; Different FORs - Find another - POP DE ; Restore code string address - LD SP,HL ; Remove all nested loops - -FORFND: EX DE,HL ; Code string address to HL - LD C,8 - CALL CHKSTK ; Check for 8 levels of stack - PUSH HL ; Save code string address - LD HL,(LOOPST) ; Get first statement of loop - EX (SP),HL ; Save and restore code string - PUSH HL ; Re-save code string address - LD HL,(LINEAT) ; Get current line number - EX (SP),HL ; Save and restore code string - CALL TSTNUM ; Make sure it's a number - CALL CHKSYN ; Make sure "TO" is next - DB ZTO ; "TO" token - CALL GETNUM ; Get "TO" expression value - PUSH HL ; Save code string address - CALL BCDEFP ; Move "TO" value to BCDE - POP HL ; Restore code string address - PUSH BC ; Save "TO" value in block - PUSH DE - LD BC,8100H ; BCDE - 1 (default STEP) - LD D,C ; C=0 - LD E,D ; D=0 - LD A,(HL) ; Get next byte in code string - CP ZSTEP ; See if "STEP" is stated - LD A,1 ; Sign of step = 1 - JP NZ,SAVSTP ; No STEP given - Default to 1 - CALL GETCHR ; Jump over "STEP" token - CALL GETNUM ; Get step value - PUSH HL ; Save code string address - CALL BCDEFP ; Move STEP to BCDE - CALL TSTSGN ; Test sign of FPREG - POP HL ; Restore code string address -SAVSTP: PUSH BC ; Save the STEP value in block - PUSH DE - PUSH AF ; Save sign of STEP - INC SP ; Don't save flags - PUSH HL ; Save code string address - LD HL,(BRKLIN) ; Get address of index variable - EX (SP),HL ; Save and restore code string -PUTFID: LD B,ZFOR ; "FOR" block marker - PUSH BC ; Save it - INC SP ; Don't save C - -RUNCNT: CALL TSTBRK ; Execution driver - Test break - LD (BRKLIN),HL ; Save code address for break - LD A,(HL) ; Get next byte in code string - CP ':' ; Multi statement line? - JP Z,EXCUTE ; Yes - Execute it - OR A ; End of line? - JP NZ,SNERR ; No - Syntax error - INC HL ; Point to address of next line - LD A,(HL) ; Get LSB of line pointer - INC HL - OR (HL) ; Is it zero (End of prog)? - JP Z,ENDPRG ; Yes - Terminate execution - INC HL ; Point to line number - LD E,(HL) ; Get LSB of line number - INC HL - LD D,(HL) ; Get MSB of line number - EX DE,HL ; Line number to HL - LD (LINEAT),HL ; Save as current line number - EX DE,HL ; Line number back to DE -EXCUTE: CALL GETCHR ; Get key word - LD DE,RUNCNT ; Where to RETurn to - PUSH DE ; Save for RETurn -IFJMP: RET Z ; Go to RUNCNT if end of STMT -ONJMP: SUB ZEND ; Is it a token? - JP C,LET ; No - try to assign it - CP ZNEW+1-ZEND ; END to NEW ? - JP NC,SNERR ; Not a key word - ?SN Error - RLCA ; Double it - LD C,A ; BC = Offset into table - LD B,0 - EX DE,HL ; Save code string address - LD HL,WORDTB ; Keyword address table - ADD HL,BC ; Point to routine address - LD C,(HL) ; Get LSB of routine address - INC HL - LD B,(HL) ; Get MSB of routine address - PUSH BC ; Save routine address - EX DE,HL ; Restore code string address - -GETCHR: INC HL ; Point to next character - LD A,(HL) ; Get next code string byte - CP ':' ; Z if ':' - RET NC ; NC if > "9" - CP ' ' - JP Z,GETCHR ; Skip over spaces - CP '0' - CCF ; NC if < '0' - INC A ; Test for zero - Leave carry - DEC A ; Z if Null - RET - -RESTOR: EX DE,HL ; Save code string address - LD HL,(BASTXT) ; Point to start of program - JP Z,RESTNL ; Just RESTORE - reset pointer - EX DE,HL ; Restore code string address - CALL ATOH ; Get line number to DE - PUSH HL ; Save code string address - CALL SRCHLN ; Search for line number in DE - LD H,B ; HL = Address of line - LD L,C - POP DE ; Restore code string address - JP NC,ULERR ; ?UL Error if not found -RESTNL: DEC HL ; Byte before DATA statement -UPDATA: LD (NXTDAT),HL ; Update DATA pointer - EX DE,HL ; Restore code string address - RET - -TSTBRK: CALL CHKKY ; Check input status - OR A - RET Z ; No key, go back - CALL GETKY ; Get the key into A - CP ESC ; Escape key? - JR Z,BRK ; Yes, break - CP CTRL_C ; - JR Z,BRK ; Yes, break - CP CTRL_S ; Stop scrolling? - RET NZ ; Other key, ignore - - -STALL: CALL GETKY ; Wait for key - CP CTRL_Q ; Resume scrolling? - RET Z ; Release the chokehold - CP CTRL_C ; Second break? - JR Z,STOP ; Break during hold exits prog - JR STALL ; Loop until or - -BRK LD A,0FFH ; Set BRKFLG - LD (BRKFLG),A ; Store it - - -STOP: RET NZ ; Exit if anything else - DB 0F6H ; Flag "STOP" -PEND: RET NZ ; Exit if anything else - LD (BRKLIN),HL ; Save point of break - DB 21H ; Skip "OR 11111111B" -INPBRK: OR 11111111B ; Flag "Break" wanted - POP BC ; Return not needed and more -ENDPRG: LD HL,(LINEAT) ; Get current line number - PUSH AF ; Save STOP / END status - LD A,L ; Is it direct break? - AND H - INC A ; Line is -1 if direct break - JP Z,NOLIN ; Yes - No line number - LD (ERRLIN),HL ; Save line of break - LD HL,(BRKLIN) ; Get point of break - LD (CONTAD),HL ; Save point to CONTinue -NOLIN: XOR A - LD (CTLOFG),A ; Enable output - CALL STTLIN ; Start a new line - POP AF ; Restore STOP / END status - LD HL,BRKMSG ; "Break" message - JP NZ,ERRIN ; "in line" wanted? - JP PRNTOK ; Go to command mode - -CONT: LD HL,(CONTAD) ; Get CONTinue address - LD A,H ; Is it zero? - OR L - LD E,CN ; ?CN Error - JP Z,BERROR ; Yes - output "?CN Error" - EX DE,HL ; Save code string address - LD HL,(ERRLIN) ; Get line of last break - LD (LINEAT),HL ; Set up current line number - EX DE,HL ; Restore code string address - RET ; CONTinue where left off - -NULL: CALL GETINT ; Get integer 0-255 - RET NZ ; Return if bad value - LD (NULLS),A ; Set nulls number - RET - - -ACCSUM: PUSH HL ; Save address in array - LD HL,(CHKSUM) ; Get check sum - LD B,0 ; BC - Value of byte - LD C,A - ADD HL,BC ; Add byte to check sum - LD (CHKSUM),HL ; Re-save check sum - POP HL ; Restore address in array - RET - -CHKLTR: LD A,(HL) ; Get byte - CP 'A' ; < 'a' ? - RET C ; Carry set if not letter - CP 'Z'+1 ; > 'z' ? - CCF - RET ; Carry set if not letter - -FPSINT: CALL GETCHR ; Get next character -POSINT: CALL GETNUM ; Get integer 0 to 32767 -DEPINT: CALL TSTSGN ; Test sign of FPREG - JP M,FCERR ; Negative - ?FC Error -DEINT: LD A,(FPEXP) ; Get integer value to DE - CP 80H+16 ; Exponent in range (16 bits)? - JP C,FPINT ; Yes - convert it - LD BC,9080H ; BCDE = -32768 - LD DE,0000 - PUSH HL ; Save code string address - CALL CMPNUM ; Compare FPREG with BCDE - POP HL ; Restore code string address - LD D,C ; MSB to D - RET Z ; Return if in range -FCERR: LD E,FC ; ?FC Error - JP BERROR ; Output error- - -ATOH: DEC HL ; ASCII number to DE binary -GETLN: LD DE,0 ; Get number to DE -GTLNLP: CALL GETCHR ; Get next character - RET NC ; Exit if not a digit - PUSH HL ; Save code string address - PUSH AF ; Save digit - LD HL,65529/10 ; Largest number 65529 - CALL CPDEHL ; Number in range? - JP C,SNERR ; No - ?SN Error - LD H,D ; HL = Number - LD L,E - ADD HL,DE ; Times 2 - ADD HL,HL ; Times 4 - ADD HL,DE ; Times 5 - ADD HL,HL ; Times 10 - POP AF ; Restore digit - SUB '0' ; Make it 0 to 9 - LD E,A ; DE = Value of digit - LD D,0 - ADD HL,DE ; Add to number - EX DE,HL ; Number to DE - POP HL ; Restore code string address - JP GTLNLP ; Go to next character - -CLEAR: JP Z,INTVAR ; Just "CLEAR" Keep parameters - CALL POSINT ; Get integer 0 to 32767 to DE - DEC HL ; Cancel increment - CALL GETCHR ; Get next character - PUSH HL ; Save code string address - LD HL,(LSTRAM) ; Get end of RAM - JP Z,STORED ; No value given - Use stored - POP HL ; Restore code string address - CALL CHKSYN ; Check for comma - DB ',' - PUSH DE ; Save number - CALL POSINT ; Get integer 0 to 32767 - DEC HL ; Cancel increment - CALL GETCHR ; Get next character - JP NZ,SNERR ; ?SN Error if more on line - EX (SP),HL ; Save code string address - EX DE,HL ; Number to DE -STORED: LD A,L ; Get LSB of new RAM top - SUB E ; Subtract LSB of string space - LD E,A ; Save LSB - LD A,H ; Get MSB of new RAM top - SBC A,D ; Subtract MSB of string space - LD D,A ; Save MSB - JP C,OMERR ; ?OM Error if not enough mem - PUSH HL ; Save RAM top - LD HL,(PROGND) ; Get program end - LD BC,40 ; 40 Bytes minimum working RAM - ADD HL,BC ; Get lowest address - CALL CPDEHL ; Enough memory? - JP NC,OMERR ; No - ?OM Error - EX DE,HL ; RAM top to HL - LD (STRSPC),HL ; Set new string space - POP HL ; End of memory to use - LD (LSTRAM),HL ; Set new top of RAM - POP HL ; Restore code string address - JP INTVAR ; Initialise variables - -RUN: JP Z,RUNFST ; RUN from start if just RUN - CALL INTVAR ; Initialise variables - LD BC,RUNCNT ; Execution driver loop - JP RUNLIN ; RUN from line number - -GOSUB: LD C,3 ; 3 Levels of stack needed - CALL CHKSTK ; Check for 3 levels of stack - POP BC ; Get return address - PUSH HL ; Save code string for RETURN - PUSH HL ; And for GOSUB routine - LD HL,(LINEAT) ; Get current line - EX (SP),HL ; Into stack - Code string out - LD A,ZGOSUB ; "GOSUB" token - PUSH AF ; Save token - INC SP ; Don't save flags - -RUNLIN: PUSH BC ; Save return address -GOTO: CALL ATOH ; ASCII number to DE binary - CALL REM ; Get end of line - PUSH HL ; Save end of line - LD HL,(LINEAT) ; Get current line - CALL CPDEHL ; Line after current? - POP HL ; Restore end of line - INC HL ; Start of next line - CALL C,SRCHLP ; Line is after current line - CALL NC,SRCHLN ; Line is before current line - LD H,B ; Set up code string address - LD L,C - DEC HL ; Incremented after - RET C ; Line found -ULERR: LD E,UL ; ?UL Error - JP BERROR ; Output error message - -RETURN: RET NZ ; Return if not just RETURN - LD D,-1 ; Flag "GOSUB" search - CALL BAKSTK ; Look "GOSUB" block - LD SP,HL ; Kill all FORs in subroutine - CP ZGOSUB ; Test for "GOSUB" token - LD E,RG ; ?RG Error - JP NZ,BERROR ; Error if no "GOSUB" found - POP HL ; Get RETURN line number - LD (LINEAT),HL ; Save as current - INC HL ; Was it from direct statement? - LD A,H - OR L ; Return to line - JP NZ,RETLIN ; No - Return to line - LD A,(LSTBIN) ; Any INPUT in subroutine? - OR A ; If so buffer is corrupted - JP NZ,POPNOK ; Yes - Go to command mode -RETLIN: LD HL,RUNCNT ; Execution driver loop - EX (SP),HL ; Into stack - Code string out - DB 3EH ; Skip "POP HL" -NXTDTA: POP HL ; Restore code string address - -DATA: DB 01H,3AH ; ':' End of statement -REM: LD C,0 ; 00 End of statement - LD B,0 -NXTSTL: LD A,C ; Statement and byte - LD C,B - LD B,A ; Statement end byte -NXTSTT: LD A,(HL) ; Get byte - OR A ; End of line? - RET Z ; Yes - Exit - CP B ; End of statement? - RET Z ; Yes - Exit - INC HL ; Next byte - CP '"' ; Literal string? - JP Z,NXTSTL ; Yes - Look for another '"' - JP NXTSTT ; Keep looking - -LET: CALL GETVAR ; Get variable name - CALL CHKSYN ; Make sure "=" follows - DB ZEQUAL ; "=" token - PUSH DE ; Save address of variable - LD A,(TYPE) ; Get data type - PUSH AF ; Save type - CALL EVAL ; Evaluate expression - POP AF ; Restore type - EX (SP),HL ; Save code - Get var addr - LD (BRKLIN),HL ; Save address of variable - RRA ; Adjust type - CALL CHKTYP ; Check types are the same - JP Z,LETNUM ; Numeric - Move value -LETSTR: PUSH HL ; Save address of string var - LD HL,(FPREG) ; Pointer to string entry - PUSH HL ; Save it on stack - INC HL ; Skip over length - INC HL - LD E,(HL) ; LSB of string address - INC HL - LD D,(HL) ; MSB of string address - LD HL,(BASTXT) ; Point to start of program - CALL CPDEHL ; Is string before program? - JP NC,CRESTR ; Yes - Create string entry - LD HL,(STRSPC) ; Point to string space - CALL CPDEHL ; Is string literal in program? - POP DE ; Restore address of string - JP NC,MVSTPT ; Yes - Set up pointer - LD HL,TMPSTR ; Temporary string pool - CALL CPDEHL ; Is string in temporary pool? - JP NC,MVSTPT ; No - Set up pointer - DB 3EH ; Skip "POP DE" -CRESTR: POP DE ; Restore address of string - CALL BAKTMP ; Back to last tmp-str entry - EX DE,HL ; Address of string entry - CALL SAVSTR ; Save string in string area -MVSTPT: CALL BAKTMP ; Back to last tmp-str entry - POP HL ; Get string pointer - CALL DETHL4 ; Move string pointer to var - POP HL ; Restore code string address - RET - -LETNUM: PUSH HL ; Save address of variable - CALL FPTHL ; Move value to variable - POP DE ; Restore address of variable - POP HL ; Restore code string address - RET - -ON: CALL GETINT ; Get integer 0-255 - LD A,(HL) ; Get "GOTO" or "GOSUB" token - LD B,A ; Save in B - CP ZGOSUB ; "GOSUB" token? - JP Z,ONGO ; Yes - Find line number - CALL CHKSYN ; Make sure it's "GOTO" - DB ZGOTO ; "GOTO" token - DEC HL ; Cancel increment -ONGO: LD C,E ; Integer of branch value -ONGOLP: DEC C ; Count branches - LD A,B ; Get "GOTO" or "GOSUB" token - JP Z,ONJMP ; Go to that line if right one - CALL GETLN ; Get line number to DE - CP ',' ; Another line number? - RET NZ ; No - Drop through - JP ONGOLP ; Yes - loop - -IF: CALL EVAL ; Evaluate expression - LD A,(HL) ; Get token - CP ZGOTO ; "GOTO" token? - JP Z,IFGO ; Yes - Get line - CALL CHKSYN ; Make sure it's "THEN" - DB ZTHEN ; "THEN" token - DEC HL ; Cancel increment -IFGO: CALL TSTNUM ; Make sure it's numeric - CALL TSTSGN ; Test state of expression - JP Z,REM ; False - Drop through - CALL GETCHR ; Get next character - JP C,GOTO ; Number - GOTO that line - JP IFJMP ; Otherwise do statement - -MRPRNT: DEC HL ; DEC 'cos GETCHR INCs - CALL GETCHR ; Get next character -PRINT: JP Z,PRNTCRLF ; CRLF if just PRINT -PRNTLP: RET Z ; End of list - Exit - CP ZTAB ; "TAB(" token? - JP Z,DOTAB ; Yes - Do TAB routine - CP ZSPC ; "SPC(" token? - JP Z,DOTAB ; Yes - Do SPC routine - PUSH HL ; Save code string address - CP ',' ; Comma? - JP Z,DOCOM ; Yes - Move to next zone - CP 59 ;";" ; Semi-colon? - JP Z,NEXITM ; Do semi-colon routine - POP BC ; Code string address to BC - CALL EVAL ; Evaluate expression - PUSH HL ; Save code string address - LD A,(TYPE) ; Get variable type - OR A ; Is it a string variable? - JP NZ,PRNTST ; Yes - Output string contents - CALL NUMASC ; Convert number to text - CALL CRTST ; Create temporary string - LD (HL),' ' ; Followed by a space - LD HL,(FPREG) ; Get length of output - INC (HL) ; Plus 1 for the space - LD HL,(FPREG) ; < Not needed > - LD A,(LWIDTH) ; Get width of line - LD B,A ; To B - INC B ; Width 255 (No limit)? - JP Z,PRNTNB ; Yes - Output number string - INC B ; Adjust it - LD A,(CURPOS) ; Get cursor position - ADD A,(HL) ; Add length of string - DEC A ; Adjust it - CP B ; Will output fit on this line? - CALL NC,PRNTCRLF ; No - CRLF first -PRNTNB: CALL PRS1 ; Output string at (HL) - XOR A ; Skip CALL by setting 'z' flag -PRNTST: CALL NZ,PRS1 ; Output string at (HL) - POP HL ; Restore code string address - JP MRPRNT ; See if more to PRINT - -STTLIN: LD A,(CURPOS) ; Make sure on new line - OR A ; Already at start? - RET Z ; Yes - Do nothing - JP PRNTCRLF ; Start a new line - -ENDINP: LD (HL),0 ; Mark end of buffer - LD HL,BUFFER-1 ; Point to buffer -PRNTCRLF: LD A,CR ; Load a CR - CALL OUTC ; Output character - ;LD A,LF ; Load a LF - ;CALL OUTC ; Output character -DONULL: XOR A ; Set to position 0 - LD (CURPOS),A ; Store it - LD A,(NULLS) ; Get number of nulls -NULLP: DEC A ; Count them - RET Z ; Return if done - PUSH AF ; Save count - XOR A ; Load a null - CALL OUTC ; Output it - POP AF ; Restore count - JP NULLP ; Keep counting - -DOCOM: LD A,(COMMAN) ; Get comma width - LD B,A ; Save in B - LD A,(CURPOS) ; Get current position - CP B ; Within the limit? - CALL NC,PRNTCRLF ; No - output CRLF - JP NC,NEXITM ; Get next item -ZONELP: SUB 14 ; Next zone of 14 characters - JP NC,ZONELP ; Repeat if more zones - CPL ; Number of spaces to output - JP ASPCS ; Output them - -DOTAB: PUSH AF ; Save token - CALL FNDNUM ; Evaluate expression - CALL CHKSYN ; Make sure ")" follows - DB ")" - DEC HL ; Back space on to ")" - POP AF ; Restore token - SUB ZSPC ; Was it "SPC(" ? - PUSH HL ; Save code string address - JP Z,DOSPC ; Yes - Do 'E' spaces - LD A,(CURPOS) ; Get current position -DOSPC: CPL ; Number of spaces to print to - ADD A,E ; Total number to print - JP NC,NEXITM ; TAB < Current POS(X) -ASPCS: INC A ; Output A spaces - LD B,A ; Save number to print - LD A,' ' ; Space -SPCLP: CALL OUTC ; Output character in A - DEC B ; Count them - JP NZ,SPCLP ; Repeat if more -NEXITM: POP HL ; Restore code string address - CALL GETCHR ; Get next character - JP PRNTLP ; More to print - -REDO: DB "?Redo from start",CR,LF,0 - -BADINP: LD A,(READFG) ; READ or INPUT? - OR A - JP NZ,DATSNR ; READ - ?SN Error - POP BC ; Throw away code string addr - LD HL,REDO ; "Redo from start" message - CALL PRS ; Output string - JP DOAGN ; Do last INPUT again - -INPUT: CALL IDTEST ; Test for illegal direct - LD A,(HL) ; Get character after "INPUT" - CP '"' ; Is there a prompt string? - LD A,0 ; Clear A and leave flags - LD (CTLOFG),A ; Enable output - JP NZ,NOPMPT ; No prompt - get input - CALL QTSTR ; Get string terminated by '"' - CALL CHKSYN ; Check for ';' after prompt - DB ';' - PUSH HL ; Save code string address - CALL PRS1 ; Output prompt string - DB 3EH ; Skip "PUSH HL" -NOPMPT: PUSH HL ; Save code string address - CALL PROMPT ; Get input with "? " prompt - POP BC ; Restore code string address - JP C,INPBRK ; Break pressed - Exit - INC HL ; Next byte - LD A,(HL) ; Get it - OR A ; End of line? - DEC HL ; Back again - PUSH BC ; Re-save code string address - JP Z,NXTDTA ; Yes - Find next DATA stmt - LD (HL),',' ; Store comma as separator - JP NXTITM ; Get next item - -READ: PUSH HL ; Save code string address - LD HL,(NXTDAT) ; Next DATA statement - DB 0F6H ; Flag "READ" -NXTITM: XOR A ; Flag "INPUT" - LD (READFG),A ; Save "READ"/"INPUT" flag - EX (SP),HL ; Get code str' , Save pointer - JP GTVLUS ; Get values - -NEDMOR: CALL CHKSYN ; Check for comma between items - DB ',' -GTVLUS: CALL GETVAR ; Get variable name - EX (SP),HL ; Save code str" , Get pointer - PUSH DE ; Save variable address - LD A,(HL) ; Get next "INPUT"/"DATA" byte - CP ',' ; Comma? - JP Z,ANTVLU ; Yes - Get another value - LD A,(READFG) ; Is it READ? - OR A - JP NZ,FDTLP ; Yes - Find next DATA stmt - LD A,'?' ; More INPUT needed - CALL OUTC ; Output character - CALL PROMPT ; Get INPUT with prompt - POP DE ; Variable address - POP BC ; Code string address - JP C,INPBRK ; Break pressed - INC HL ; Point to next DATA byte - LD A,(HL) ; Get byte - OR A ; Is it zero (No input) ? - DEC HL ; Back space INPUT pointer - PUSH BC ; Save code string address - JP Z,NXTDTA ; Find end of buffer - PUSH DE ; Save variable address -ANTVLU: LD A,(TYPE) ; Check data type - OR A ; Is it numeric? - JP Z,INPBIN ; Yes - Convert to binary - CALL GETCHR ; Get next character - LD D,A ; Save input character - LD B,A ; Again - CP '"' ; Start of literal sting? - JP Z,STRENT ; Yes - Create string entry - LD A,(READFG) ; "READ" or "INPUT" ? - OR A - LD D,A ; Save 00 if "INPUT" - JP Z,ITMSEP ; "INPUT" - End with 00 - LD D,':' ; "DATA" - End with 00 or ':' -ITMSEP: LD B,',' ; Item separator - DEC HL ; Back space for DTSTR -STRENT: CALL DTSTR ; Get string terminated by D - EX DE,HL ; String address to DE - LD HL,LTSTND ; Where to go after LETSTR - EX (SP),HL ; Save HL , get input pointer - PUSH DE ; Save address of string - JP LETSTR ; Assign string to variable - -INPBIN: CALL GETCHR ; Get next character - CALL ASCTFP ; Convert ASCII to FP number - EX (SP),HL ; Save input ptr, Get var addr - CALL FPTHL ; Move FPREG to variable - POP HL ; Restore input pointer -LTSTND: DEC HL ; DEC 'cos GETCHR INCs - CALL GETCHR ; Get next character - JP Z,MORDT ; End of line - More needed? - CP ',' ; Another value? - JP NZ,BADINP ; No - Bad input -MORDT: EX (SP),HL ; Get code string address - DEC HL ; DEC 'cos GETCHR INCs - CALL GETCHR ; Get next character - JP NZ,NEDMOR ; More needed - Get it - POP DE ; Restore DATA pointer - LD A,(READFG) ; "READ" or "INPUT" ? - OR A - EX DE,HL ; DATA pointer to HL - JP NZ,UPDATA ; Update DATA pointer if "READ" - PUSH DE ; Save code string address - OR (HL) ; More input given? - LD HL,EXTIG ; "?Extra ignored" message - CALL NZ,PRS ; Output string if extra given - POP HL ; Restore code string address - RET - -EXTIG: DB "?Extra ignored",CR,LF,0 - -FDTLP: CALL DATA ; Get next statement - OR A ; End of line? - JP NZ,FANDT ; No - See if DATA statement - INC HL - LD A,(HL) ; End of program? - INC HL - OR (HL) ; 00 00 Ends program - LD E,OD ; ?OD Error - JP Z,BERROR ; Yes - Out of DATA - INC HL - LD E,(HL) ; LSB of line number - INC HL - LD D,(HL) ; MSB of line number - EX DE,HL - LD (DATLIN),HL ; Set line of current DATA item - EX DE,HL -FANDT: CALL GETCHR ; Get next character - CP ZDATA ; "DATA" token - JP NZ,FDTLP ; No "DATA" - Keep looking - JP ANTVLU ; Found - Convert input - -NEXT: LD DE,0 ; In case no index given -NEXT1: CALL NZ,GETVAR ; Get index address - LD (BRKLIN),HL ; Save code string address - CALL BAKSTK ; Look for "FOR" block - JP NZ,NFERR ; No "FOR" - ?NF Error - LD SP,HL ; Clear nested loops - PUSH DE ; Save index address - LD A,(HL) ; Get sign of STEP - INC HL - PUSH AF ; Save sign of STEP - PUSH DE ; Save index address - CALL PHLTFP ; Move index value to FPREG - EX (SP),HL ; Save address of TO value - PUSH HL ; Save address of index - CALL ADDPHL ; Add STEP to index value - POP HL ; Restore address of index - CALL FPTHL ; Move value to index variable - POP HL ; Restore address of TO value - CALL LOADFP ; Move TO value to BCDE - PUSH HL ; Save address of line of FOR - CALL CMPNUM ; Compare index with TO value - POP HL ; Restore address of line num - POP BC ; Address of sign of STEP - SUB B ; Compare with expected sign - CALL LOADFP ; BC = Loop stmt,DE = Line num - JP Z,KILFOR ; Loop finished - Terminate it - EX DE,HL ; Loop statement line number - LD (LINEAT),HL ; Set loop line number - LD L,C ; Set code string to loop - LD H,B - JP PUTFID ; Put back "FOR" and continue - -KILFOR: LD SP,HL ; Remove "FOR" block - LD HL,(BRKLIN) ; Code string after "NEXT" - LD A,(HL) ; Get next byte in code string - CP ',' ; More NEXTs ? - JP NZ,RUNCNT ; No - Do next statement - CALL GETCHR ; Position to index name - CALL NEXT1 ; Re-enter NEXT routine - ; < will not RETurn to here , Exit to RUNCNT or Loop > - -GETNUM: CALL EVAL ; Get a numeric expression -TSTNUM: DB 0F6H ; Clear carry (numeric) -TSTSTR: SCF ; Set carry (string) -CHKTYP: LD A,(TYPE) ; Check types match - ADC A,A ; Expected + actual - OR A ; Clear carry , set parity - RET PE ; Even parity - Types match - JP TMERR ; Different types - Error - -OPNPAR: CALL CHKSYN ; Make sure "(" follows - DB "(" -EVAL: DEC HL ; Evaluate expression & save - LD D,0 ; Precedence value -EVAL1: PUSH DE ; Save precedence - LD C,1 - CALL CHKSTK ; Check for 1 level of stack - CALL OPRND ; Get next expression value -EVAL2: LD (NXTOPR),HL ; Save address of next operator -EVAL3: LD HL,(NXTOPR) ; Restore address of next opr - POP BC ; Precedence value and operator - LD A,B ; Get precedence value - CP 78H ; "AND" or "OR" ? - CALL NC,TSTNUM ; No - Make sure it's a number - LD A,(HL) ; Get next operator / function - LD D,0 ; Clear Last relation -RLTLP: SUB ZGTR ; ">" Token - JP C,FOPRND ; + - * / ^ AND OR - Test it - CP ZLTH+1-ZGTR ; < = > - JP NC,FOPRND ; Function - Call it - CP ZEQUAL-ZGTR ; "=" - RLA ; <- Test for legal - XOR D ; <- combinations of < = > - CP D ; <- by combining last token - LD D,A ; <- with current one - JP C,SNERR ; Error if "<<' '==" or ">>" - LD (CUROPR),HL ; Save address of current token - CALL GETCHR ; Get next character - JP RLTLP ; Treat the two as one - -FOPRND: LD A,D ; < = > found ? - OR A - JP NZ,TSTRED ; Yes - Test for reduction - LD A,(HL) ; Get operator token - LD (CUROPR),HL ; Save operator address - SUB ZPLUS ; Operator or function? - RET C ; Neither - Exit - CP ZOR+1-ZPLUS ; Is it + - * / ^ AND OR ? - RET NC ; No - Exit - LD E,A ; Coded operator - LD A,(TYPE) ; Get data type - DEC A ; FF = numeric , 00 = string - OR E ; Combine with coded operator - LD A,E ; Get coded operator - JP Z,CONCAT ; String concatenation - RLCA ; Times 2 - ADD A,E ; Times 3 - LD E,A ; To DE (D is 0) - LD HL,PRITAB ; Precedence table - ADD HL,DE ; To the operator concerned - LD A,B ; Last operator precedence - LD D,(HL) ; Get evaluation precedence - CP D ; Compare with eval precedence - RET NC ; Exit if higher precedence - INC HL ; Point to routine address - CALL TSTNUM ; Make sure it's a number - -STKTHS: PUSH BC ; Save last precedence & token - LD BC,EVAL3 ; Where to go on prec' break - PUSH BC ; Save on stack for return - LD B,E ; Save operator - LD C,D ; Save precedence - CALL STAKFP ; Move value to stack - LD E,B ; Restore operator - LD D,C ; Restore precedence - LD C,(HL) ; Get LSB of routine address - INC HL - LD B,(HL) ; Get MSB of routine address - INC HL - PUSH BC ; Save routine address - LD HL,(CUROPR) ; Address of current operator - JP EVAL1 ; Loop until prec' break - -OPRND: XOR A ; Get operand routine - LD (TYPE),A ; Set numeric expected - CALL GETCHR ; Get next character - LD E,MO ; ?MO Error - JP Z,BERROR ; No operand - Error - JP C,ASCTFP ; Number - Get value - CALL CHKLTR ; See if a letter - JP NC,CONVAR ; Letter - Find variable - CP '&' ; &H = HEX, &B = BINARY [G. Searle] - JR NZ, NOTAMP - CALL GETCHR ; Get next character - CP 'H' ; Hex number indicated? [function added] - JP Z,HEXTFP ; Convert Hex to FPREG - CP 'B' ; Binary number indicated? [function added] - JP Z,BINTFP ; Convert Bin to FPREG - LD E,SN ; If neither then a ?SN Error - JP Z,BERROR ; -NOTAMP: CP ZPLUS ; '+' Token ? - JP Z,OPRND ; Yes - Look for operand - CP '.' ; '.' ? - JP Z,ASCTFP ; Yes - Create FP number - CP ZMINUS ; '-' Token ? - JP Z,MINUS ; Yes - Do minus - CP '"' ; Literal string ? - JP Z,QTSTR ; Get string terminated by '"' - CP ZNOT ; "NOT" Token ? - JP Z,EVNOT ; Yes - Eval NOT expression - CP ZFN ; "FN" Token ? - JP Z,DOFN ; Yes - Do FN routine - SUB ZSGN ; Is it a function? - JP NC,FNOFST ; Yes - Evaluate function -EVLPAR: CALL OPNPAR ; Evaluate expression in "()" - CALL CHKSYN ; Make sure ")" follows - DB ")" - RET - -MINUS: LD D,7DH ; '-' precedence - CALL EVAL1 ; Evaluate until prec' break - LD HL,(NXTOPR) ; Get next operator address - PUSH HL ; Save next operator address - CALL INVSGN ; Negate value -RETNUM: CALL TSTNUM ; Make sure it's a number - POP HL ; Restore next operator address - RET - -CONVAR: CALL GETVAR ; Get variable address to DE -FRMEVL: PUSH HL ; Save code string address - EX DE,HL ; Variable address to HL - LD (FPREG),HL ; Save address of variable - LD A,(TYPE) ; Get type - OR A ; Numeric? - CALL Z,PHLTFP ; Yes - Move contents to FPREG - POP HL ; Restore code string address - RET - -FNOFST: LD B,0 ; Get address of function - RLCA ; Double function offset - LD C,A ; BC = Offset in function table - PUSH BC ; Save adjusted token value - CALL GETCHR ; Get next character - LD A,C ; Get adjusted token value - CP 2*(ZLEFT-ZSGN)-1 ; Adj' LEFT$,RIGHT$ or MID$ ? - JP C,FNVAL ; No - Do function - CALL OPNPAR ; Evaluate expression (X,... - CALL CHKSYN ; Make sure ',' follows - DB ',' - CALL TSTSTR ; Make sure it's a string - EX DE,HL ; Save code string address - LD HL,(FPREG) ; Get address of string - EX (SP),HL ; Save address of string - PUSH HL ; Save adjusted token value - EX DE,HL ; Restore code string address - CALL GETINT ; Get integer 0-255 - EX DE,HL ; Save code string address - EX (SP),HL ; Save integer,HL = adj' token - JP GOFUNC ; Jump to string function - -FNVAL: CALL EVLPAR ; Evaluate expression - EX (SP),HL ; HL = Adjusted token value - LD DE,RETNUM ; Return number from function - PUSH DE ; Save on stack -GOFUNC: LD BC,FNCTAB ; Function routine addresses - ADD HL,BC ; Point to right address - LD C,(HL) ; Get LSB of address - INC HL ; - LD H,(HL) ; Get MSB of address - LD L,C ; Address to HL - JP (HL) ; Jump to function - -SGNEXP: DEC D ; Dee to flag negative exponent - CP ZMINUS ; '-' token ? - RET Z ; Yes - Return - CP '-' ; '-' ASCII ? - RET Z ; Yes - Return - INC D ; Inc to flag positive exponent - CP '+' ; '+' ASCII ? - RET Z ; Yes - Return - CP ZPLUS ; '+' token ? - RET Z ; Yes - Return - DEC HL ; DEC 'cos GETCHR INCs - RET ; Return "NZ" - -POR: DB 0F6H ; Flag "OR" -PAND: XOR A ; Flag "AND" - PUSH AF ; Save "AND" / "OR" flag - CALL TSTNUM ; Make sure it's a number - CALL DEINT ; Get integer -32768 to 32767 - POP AF ; Restore "AND" / "OR" flag - EX DE,HL ; <- Get last - POP BC ; <- value - EX (SP),HL ; <- from - EX DE,HL ; <- stack - CALL FPBCDE ; Move last value to FPREG - PUSH AF ; Save "AND" / "OR" flag - CALL DEINT ; Get integer -32768 to 32767 - POP AF ; Restore "AND" / "OR" flag - POP BC ; Get value - LD A,C ; Get LSB - LD HL,ACPASS ; Address of save AC as current - JP NZ,POR1 ; Jump if OR - AND E ; "AND" LSBs - LD C,A ; Save LSB - LD A,B ; Get MBS - AND D ; "AND" MSBs - JP (HL) ; Save AC as current (ACPASS) - -POR1: OR E ; "OR" LSBs - LD C,A ; Save LSB - LD A,B ; Get MSB - OR D ; "OR" MSBs - JP (HL) ; Save AC as current (ACPASS) - -TSTRED: LD HL,CMPLOG ; Logical compare routine - LD A,(TYPE) ; Get data type - RRA ; Carry set = string - LD A,D ; Get last precedence value - RLA ; Times 2 plus carry - LD E,A ; To E - LD D,64H ; Relational precedence - LD A,B ; Get current precedence - CP D ; Compare with last - RET NC ; Eval if last was rel' or log' - JP STKTHS ; Stack this one and get next - -CMPLOG: DW CMPLG1 ; Compare two values / strings -CMPLG1: LD A,C ; Get data type - OR A - RRA - POP BC ; Get last expression to BCDE - POP DE - PUSH AF ; Save status - CALL CHKTYP ; Check that types match - LD HL,CMPRES ; Result to comparison - PUSH HL ; Save for RETurn - JP Z,CMPNUM ; Compare values if numeric - XOR A ; Compare two strings - LD (TYPE),A ; Set type to numeric - PUSH DE ; Save string name - CALL GSTRCU ; Get current string - LD A,(HL) ; Get length of string - INC HL - INC HL - LD C,(HL) ; Get LSB of address - INC HL - LD B,(HL) ; Get MSB of address - POP DE ; Restore string name - PUSH BC ; Save address of string - PUSH AF ; Save length of string - CALL GSTRDE ; Get second string - CALL LOADFP ; Get address of second string - POP AF ; Restore length of string 1 - LD D,A ; Length to D - POP HL ; Restore address of string 1 -CMPSTR: LD A,E ; Bytes of string 2 to do - OR D ; Bytes of string 1 to do - RET Z ; Exit if all bytes compared - LD A,D ; Get bytes of string 1 to do - SUB 1 - RET C ; Exit if end of string 1 - XOR A - CP E ; Bytes of string 2 to do - INC A - RET NC ; Exit if end of string 2 - DEC D ; Count bytes in string 1 - DEC E ; Count bytes in string 2 - LD A,(BC) ; Byte in string 2 - CP (HL) ; Compare to byte in string 1 - INC HL ; Move up string 1 - INC BC ; Move up string 2 - JP Z,CMPSTR ; Same - Try next bytes - CCF ; Flag difference (">" or "<") - JP FLGDIF ; "<" gives -1 , ">" gives +1 - -CMPRES: INC A ; Increment current value - ADC A,A ; Double plus carry - POP BC ; Get other value - AND B ; Combine them - ADD A,-1 ; Carry set if different - SBC A,A ; 00 - Equal , FF - Different - JP FLGREL ; Set current value & continue - -EVNOT: LD D,5AH ; Precedence value for "NOT" - CALL EVAL1 ; Eval until precedence break - CALL TSTNUM ; Make sure it's a number - CALL DEINT ; Get integer -32768 - 32767 - LD A,E ; Get LSB - CPL ; Invert LSB - LD C,A ; Save "NOT" of LSB - LD A,D ; Get MSB - CPL ; Invert MSB - CALL ACPASS ; Save AC as current - POP BC ; Clean up stack - JP EVAL3 ; Continue evaluation - -DIMRET: DEC HL ; DEC 'cos GETCHR INCs - CALL GETCHR ; Get next character - RET Z ; End of DIM statement - CALL CHKSYN ; Make sure ',' follows - DB ',' -DIM: LD BC,DIMRET ; Return to "DIMRET" - PUSH BC ; Save on stack - DB 0F6H ; Flag "Create" variable -GETVAR: XOR A ; Find variable address,to DE - LD (LCRFLG),A ; Set locate / create flag - LD B,(HL) ; Get First byte of name -GTFNAM: CALL CHKLTR ; See if a letter - JP C,SNERR ; ?SN Error if not a letter - XOR A - LD C,A ; Clear second byte of name - LD (TYPE),A ; Set type to numeric - CALL GETCHR ; Get next character - JP C,SVNAM2 ; Numeric - Save in name - CALL CHKLTR ; See if a letter - JP C,CHARTY ; Not a letter - Check type -SVNAM2: LD C,A ; Save second byte of name -ENDNAM: CALL GETCHR ; Get next character - JP C,ENDNAM ; Numeric - Get another - CALL CHKLTR ; See if a letter - JP NC,ENDNAM ; Letter - Get another -CHARTY: SUB '$' ; String variable? - JP NZ,NOTSTR ; No - Numeric variable - INC A ; A = 1 (string type) - LD (TYPE),A ; Set type to string - RRCA ; A = 80H , Flag for string - ADD A,C ; 2nd byte of name has bit 7 on - LD C,A ; Resave second byte on name - CALL GETCHR ; Get next character -NOTSTR: LD A,(FORFLG) ; Array name needed ? - DEC A - JP Z,ARLDSV ; Yes - Get array name - JP P,NSCFOR ; No array with "FOR" or "FN" - LD A,(HL) ; Get byte again - SUB '(' ; Subscripted variable? - JP Z,SBSCPT ; Yes - Sort out subscript - -NSCFOR: XOR A ; Simple variable - LD (FORFLG),A ; Clear "FOR" flag - PUSH HL ; Save code string address - LD D,B ; DE = Variable name to find - LD E,C - LD HL,(FNRGNM) ; FN argument name - CALL CPDEHL ; Is it the FN argument? - LD DE,FNARG ; Point to argument value - JP Z,POPHRT ; Yes - Return FN argument value - LD HL,(VAREND) ; End of variables - EX DE,HL ; Address of end of search - LD HL,(PROGND) ; Start of variables address -FNDVAR: CALL CPDEHL ; End of variable list table? - JP Z,CFEVAL ; Yes - Called from EVAL? - LD A,C ; Get second byte of name - SUB (HL) ; Compare with name in list - INC HL ; Move on to first byte - JP NZ,FNTHR ; Different - Find another - LD A,B ; Get first byte of name - SUB (HL) ; Compare with name in list -FNTHR: INC HL ; Move on to LSB of value - JP Z,RETADR ; Found - Return address - INC HL ; <- Skip - INC HL ; <- over - INC HL ; <- F.P. - INC HL ; <- value - JP FNDVAR ; Keep looking - -CFEVAL: POP HL ; Restore code string address - EX (SP),HL ; Get return address - PUSH DE ; Save address of variable - LD DE,FRMEVL ; Return address in EVAL - CALL CPDEHL ; Called from EVAL ? - POP DE ; Restore address of variable - JP Z,RETNUL ; Yes - Return null variable - EX (SP),HL ; Put back return - PUSH HL ; Save code string address - PUSH BC ; Save variable name - LD BC,6 ; 2 byte name plus 4 byte data - LD HL,(ARREND) ; End of arrays - PUSH HL ; Save end of arrays - ADD HL,BC ; Move up 6 bytes - POP BC ; Source address in BC - PUSH HL ; Save new end address - CALL MOVUP ; Move arrays up - POP HL ; Restore new end address - LD (ARREND),HL ; Set new end address - LD H,B ; End of variables to HL - LD L,C - LD (VAREND),HL ; Set new end address - -ZEROLP: DEC HL ; Back through to zero variable - LD (HL),0 ; Zero byte in variable - CALL CPDEHL ; Done them all? - JP NZ,ZEROLP ; No - Keep on going - POP DE ; Get variable name - LD (HL),E ; Store second character - INC HL - LD (HL),D ; Store first character - INC HL -RETADR: EX DE,HL ; Address of variable in DE - POP HL ; Restore code string address - RET - -RETNUL: LD (FPEXP),A ; Set result to zero - LD HL,ZERBYT ; Also set a null string - LD (FPREG),HL ; Save for EVAL - POP HL ; Restore code string address - RET - -SBSCPT: PUSH HL ; Save code string address - LD HL,(LCRFLG) ; Locate/Create and Type - EX (SP),HL ; Save and get code string - LD D,A ; Zero number of dimensions -SCPTLP: PUSH DE ; Save number of dimensions - PUSH BC ; Save array name - CALL FPSINT ; Get subscript (0-32767) - POP BC ; Restore array name - POP AF ; Get number of dimensions - EX DE,HL - EX (SP),HL ; Save subscript value - PUSH HL ; Save LCRFLG and TYPE - EX DE,HL - INC A ; Count dimensions - LD D,A ; Save in D - LD A,(HL) ; Get next byte in code string - CP ',' ; Comma (more to come)? - JP Z,SCPTLP ; Yes - More subscripts - CALL CHKSYN ; Make sure ")" follows - DB ")" - LD (NXTOPR),HL ; Save code string address - POP HL ; Get LCRFLG and TYPE - LD (LCRFLG),HL ; Restore Locate/create & type - LD E,0 ; Flag not CSAVE* or CLOAD* - PUSH DE ; Save number of dimensions (D) - DB 11H ; Skip "PUSH HL" and "PUSH AF' - -ARLDSV: PUSH HL ; Save code string address - PUSH AF ; A = 00 , Flags set = Z,N - LD HL,(VAREND) ; Start of arrays - DB 3EH ; Skip "ADD HL,DE" -FNDARY: ADD HL,DE ; Move to next array start - EX DE,HL - LD HL,(ARREND) ; End of arrays - EX DE,HL ; Current array pointer - CALL CPDEHL ; End of arrays found? - JP Z,CREARY ; Yes - Create array - LD A,(HL) ; Get second byte of name - CP C ; Compare with name given - INC HL ; Move on - JP NZ,NXTARY ; Different - Find next array - LD A,(HL) ; Get first byte of name - CP B ; Compare with name given -NXTARY: INC HL ; Move on - LD E,(HL) ; Get LSB of next array address - INC HL - LD D,(HL) ; Get MSB of next array address - INC HL - JP NZ,FNDARY ; Not found - Keep looking - LD A,(LCRFLG) ; Found Locate or Create it? - OR A - JP NZ,DDERR ; Create - ?DD Error - POP AF ; Locate - Get number of dim'ns - LD B,H ; BC Points to array dim'ns - LD C,L - JP Z,POPHRT ; Jump if array load/save - SUB (HL) ; Same number of dimensions? - JP Z,FINDEL ; Yes - Find element -BSERR: LD E,BS ; ?BS Error - JP BERROR ; Output error - -CREARY: LD DE,4 ; 4 Bytes per entry - POP AF ; Array to save or 0 dim'ns? - JP Z,FCERR ; Yes - ?FC Error - LD (HL),C ; Save second byte of name - INC HL - LD (HL),B ; Save first byte of name - INC HL - LD C,A ; Number of dimensions to C - CALL CHKSTK ; Check if enough memory - INC HL ; Point to number of dimensions - INC HL - LD (CUROPR),HL ; Save address of pointer - LD (HL),C ; Set number of dimensions - INC HL - LD A,(LCRFLG) ; Locate of Create? - RLA ; Carry set = Create - LD A,C ; Get number of dimensions -CRARLP: LD BC,10+1 ; Default dimension size 10 - JP NC,DEFSIZ ; Locate - Set default size - POP BC ; Get specified dimension size - INC BC ; Include zero element -DEFSIZ: LD (HL),C ; Save LSB of dimension size - INC HL - LD (HL),B ; Save MSB of dimension size - INC HL - PUSH AF ; Save num' of dim'ns an status - PUSH HL ; Save address of dim'n size - CALL MLDEBC ; Multiply DE by BC to find - EX DE,HL ; amount of mem needed (to DE) - POP HL ; Restore address of dimension - POP AF ; Restore number of dimensions - DEC A ; Count them - JP NZ,CRARLP ; Do next dimension if more - PUSH AF ; Save locate/create flag - LD B,D ; MSB of memory needed - LD C,E ; LSB of memory needed - EX DE,HL - ADD HL,DE ; Add bytes to array start - JP C,OMERR ; Too big - Error - CALL ENFMEM ; See if enough memory - LD (ARREND),HL ; Save new end of array - -ZERARY: DEC HL ; Back through array data - LD (HL),0 ; Set array element to zero - CALL CPDEHL ; All elements zeroed? - JP NZ,ZERARY ; No - Keep on going - INC BC ; Number of bytes + 1 - LD D,A ; A=0 - LD HL,(CUROPR) ; Get address of array - LD E,(HL) ; Number of dimensions - EX DE,HL ; To HL - ADD HL,HL ; Two bytes per dimension size - ADD HL,BC ; Add number of bytes - EX DE,HL ; Bytes needed to DE - DEC HL - DEC HL - LD (HL),E ; Save LSB of bytes needed - INC HL - LD (HL),D ; Save MSB of bytes needed - INC HL - POP AF ; Locate / Create? - JP C,ENDDIM ; A is 0 , End if create -FINDEL: LD B,A ; Find array element - LD C,A - LD A,(HL) ; Number of dimensions - INC HL - DB 16H ; Skip "POP HL" -FNDELP: POP HL ; Address of next dim' size - LD E,(HL) ; Get LSB of dim'n size - INC HL - LD D,(HL) ; Get MSB of dim'n size - INC HL - EX (SP),HL ; Save address - Get index - PUSH AF ; Save number of dim'ns - CALL CPDEHL ; Dimension too large? - JP NC,BSERR ; Yes - ?BS Error - PUSH HL ; Save index - CALL MLDEBC ; Multiply previous by size - POP DE ; Index supplied to DE - ADD HL,DE ; Add index to pointer - POP AF ; Number of dimensions - DEC A ; Count them - LD B,H ; MSB of pointer - LD C,L ; LSB of pointer - JP NZ,FNDELP ; More - Keep going - ADD HL,HL ; 4 Bytes per element - ADD HL,HL - POP BC ; Start of array - ADD HL,BC ; Point to element - EX DE,HL ; Address of element to DE -ENDDIM: LD HL,(NXTOPR) ; Got code string address - RET - -FRE: LD HL,(ARREND) ; Start of free memory - EX DE,HL ; To DE - LD HL,0 ; End of free memory - ADD HL,SP ; Current stack value - LD A,(TYPE) ; Dummy argument type - OR A - JP Z,FRENUM ; Numeric - Free variable space - CALL GSTRCU ; Current string to pool - CALL GARBGE ; Garbage collection - LD HL,(STRSPC) ; Bottom of string space in use - EX DE,HL ; To DE - LD HL,(STRBOT) ; Bottom of string space -FRENUM: LD A,L ; Get LSB of end - SUB E ; Subtract LSB of beginning - LD C,A ; Save difference if C - LD A,H ; Get MSB of end - SBC A,D ; Subtract MSB of beginning -ACPASS: LD B,C ; Return integer AC -ABPASS: LD D,B ; Return integer AB - LD E,0 - LD HL,TYPE ; Point to type - LD (HL),E ; Set type to numeric - LD B,80H+16 ; 16 bit integer - JP RETINT ; Return the integr - -POS: LD A,(CURPOS) ; Get cursor position -PASSA: LD B,A ; Put A into AB - XOR A ; Zero A - JP ABPASS ; Return integer AB - -DEF: CALL CHEKFN ; Get "FN" and name - CALL IDTEST ; Test for illegal direct - LD BC,DATA ; To get next statement - PUSH BC ; Save address for RETurn - PUSH DE ; Save address of function ptr - CALL CHKSYN ; Make sure "(" follows - DB "(" - CALL GETVAR ; Get argument variable name - PUSH HL ; Save code string address - EX DE,HL ; Argument address to HL - DEC HL - LD D,(HL) ; Get first byte of arg name - DEC HL - LD E,(HL) ; Get second byte of arg name - POP HL ; Restore code string address - CALL TSTNUM ; Make sure numeric argument - CALL CHKSYN ; Make sure ")" follows - DB ")" - CALL CHKSYN ; Make sure "=" follows - DB ZEQUAL ; "=" token - LD B,H ; Code string address to BC - LD C,L - EX (SP),HL ; Save code str , Get FN ptr - LD (HL),C ; Save LSB of FN code string - INC HL - LD (HL),B ; Save MSB of FN code string - JP SVSTAD ; Save address and do function - -DOFN: CALL CHEKFN ; Make sure FN follows - PUSH DE ; Save function pointer address - CALL EVLPAR ; Evaluate expression in "()" - CALL TSTNUM ; Make sure numeric result - EX (SP),HL ; Save code str , Get FN ptr - LD E,(HL) ; Get LSB of FN code string - INC HL - LD D,(HL) ; Get MSB of FN code string - INC HL - LD A,D ; And function DEFined? - OR E - JP Z,UFERR ; No - ?UF Error - LD A,(HL) ; Get LSB of argument address - INC HL - LD H,(HL) ; Get MSB of argument address - LD L,A ; HL = Arg variable address - PUSH HL ; Save it - LD HL,(FNRGNM) ; Get old argument name - EX (SP),HL ; ; Save old , Get new - LD (FNRGNM),HL ; Set new argument name - LD HL,(FNARG+2) ; Get LSB,NLSB of old arg value - PUSH HL ; Save it - LD HL,(FNARG) ; Get MSB,EXP of old arg value - PUSH HL ; Save it - LD HL,FNARG ; HL = Value of argument - PUSH DE ; Save FN code string address - CALL FPTHL ; Move FPREG to argument - POP HL ; Get FN code string address - CALL GETNUM ; Get value from function - DEC HL ; DEC 'cos GETCHR INCs - CALL GETCHR ; Get next character - JP NZ,SNERR ; Bad character in FN - Error - POP HL ; Get MSB,EXP of old arg - LD (FNARG),HL ; Restore it - POP HL ; Get LSB,NLSB of old arg - LD (FNARG+2),HL ; Restore it - POP HL ; Get name of old arg - LD (FNRGNM),HL ; Restore it - POP HL ; Restore code string address - RET - -IDTEST: PUSH HL ; Save code string address - LD HL,(LINEAT) ; Get current line number - INC HL ; -1 means direct statement - LD A,H - OR L - POP HL ; Restore code string address - RET NZ ; Return if in program - LD E,ID ; ?ID Error - JP BERROR - -CHEKFN: CALL CHKSYN ; Make sure FN follows - DB ZFN ; "FN" token - LD A,80H - LD (FORFLG),A ; Flag FN name to find - OR (HL) ; FN name has bit 7 set - LD B,A ; in first byte of name - CALL GTFNAM ; Get FN name - JP TSTNUM ; Make sure numeric function - -STR: CALL TSTNUM ; Make sure it's a number - CALL NUMASC ; Turn number into text -STR1: CALL CRTST ; Create string entry for it - CALL GSTRCU ; Current string to pool - LD BC,TOPOOL ; Save in string pool - PUSH BC ; Save address on stack - -SAVSTR: LD A,(HL) ; Get string length - INC HL - INC HL - PUSH HL ; Save pointer to string - CALL TESTR ; See if enough string space - POP HL ; Restore pointer to string - LD C,(HL) ; Get LSB of address - INC HL - LD B,(HL) ; Get MSB of address - CALL CRTMST ; Create string entry - PUSH HL ; Save pointer to MSB of addr - LD L,A ; Length of string - CALL TOSTRA ; Move to string area - POP DE ; Restore pointer to MSB - RET - -MKTMST: CALL TESTR ; See if enough string space -CRTMST: LD HL,TMPSTR ; Temporary string - PUSH HL ; Save it - LD (HL),A ; Save length of string - INC HL -SVSTAD: INC HL - LD (HL),E ; Save LSB of address - INC HL - LD (HL),D ; Save MSB of address - POP HL ; Restore pointer - RET - -CRTST: DEC HL ; DEC - INCed after -QTSTR: LD B,'"' ; Terminating quote - LD D,B ; Quote to D -DTSTR: PUSH HL ; Save start - LD C,-1 ; Set counter to -1 -QTSTLP: INC HL ; Move on - LD A,(HL) ; Get byte - INC C ; Count bytes - OR A ; End of line? - JP Z,CRTSTE ; Yes - Create string entry - CP D ; Terminator D found? - JP Z,CRTSTE ; Yes - Create string entry - CP B ; Terminator B found? - JP NZ,QTSTLP ; No - Keep looking -CRTSTE: CP '"' ; End with '"'? - CALL Z,GETCHR ; Yes - Get next character - EX (SP),HL ; Starting quote - INC HL ; First byte of string - EX DE,HL ; To DE - LD A,C ; Get length - CALL CRTMST ; Create string entry -TSTOPL: LD DE,TMPSTR ; Temporary string - LD HL,(TMSTPT) ; Temporary string pool pointer - LD (FPREG),HL ; Save address of string ptr - LD A,1 - LD (TYPE),A ; Set type to string - CALL DETHL4 ; Move string to pool - CALL CPDEHL ; Out of string pool? - LD (TMSTPT),HL ; Save new pointer - POP HL ; Restore code string address - LD A,(HL) ; Get next code byte - RET NZ ; Return if pool OK - LD E,ST ; ?ST Error - JP BERROR ; String pool overflow - -PRNUMS: INC HL ; Skip leading space -PRS: CALL CRTST ; Create string entry for it -PRS1: CALL GSTRCU ; Current string to pool - CALL LOADFP ; Move string block to BCDE - INC E ; Length + 1 -PRSLP: DEC E ; Count characters - RET Z ; End of string - LD A,(BC) ; Get byte to output - CALL OUTC ; Output character in A - CP CR ; Return? - CALL Z,DONULL ; Yes - Do nulls - INC BC ; Next byte in string - JP PRSLP ; More characters to output - -TESTR: OR A ; Test if enough room - DB 0EH ; No garbage collection done -GRBDON: POP AF ; Garbage collection done - PUSH AF ; Save status - LD HL,(STRSPC) ; Bottom of string space in use - EX DE,HL ; To DE - LD HL,(STRBOT) ; Bottom of string area - CPL ; Negate length (Top down) - LD C,A ; -Length to BC - LD B,-1 ; BC = -ve length of string - ADD HL,BC ; Add to bottom of space in use - INC HL ; Plus one for 2's complement - CALL CPDEHL ; Below string RAM area? - JP C,TESTOS ; Tidy up if not done else err - LD (STRBOT),HL ; Save new bottom of area - INC HL ; Point to first byte of string - EX DE,HL ; Address to DE -POPAF: POP AF ; Throw away status push - RET - -TESTOS: POP AF ; Garbage collect been done? - LD E,OS ; ?OS Error - JP Z,BERROR ; Yes - Not enough string apace - CP A ; Flag garbage collect done - PUSH AF ; Save status - LD BC,GRBDON ; Garbage collection done - PUSH BC ; Save for RETurn -GARBGE: LD HL,(LSTRAM) ; Get end of RAM pointer -GARBLP: LD (STRBOT),HL ; Reset string pointer - LD HL,0 - PUSH HL ; Flag no string found - LD HL,(STRSPC) ; Get bottom of string space - PUSH HL ; Save bottom of string space - LD HL,TMSTPL ; Temporary string pool -GRBLP: EX DE,HL - LD HL,(TMSTPT) ; Temporary string pool pointer - EX DE,HL - CALL CPDEHL ; Temporary string pool done? - LD BC,GRBLP ; Loop until string pool done - JP NZ,STPOOL ; No - See if in string area - LD HL,(PROGND) ; Start of simple variables -SMPVAR: EX DE,HL - LD HL,(VAREND) ; End of simple variables - EX DE,HL - CALL CPDEHL ; All simple strings done? - JP Z,ARRLP ; Yes - Do string arrays - LD A,(HL) ; Get type of variable - INC HL - INC HL - OR A ; "S" flag set if string - CALL STRADD ; See if string in string area - JP SMPVAR ; Loop until simple ones done - -GNXARY: POP BC ; Scrap address of this array -ARRLP: EX DE,HL - LD HL,(ARREND) ; End of string arrays - EX DE,HL - CALL CPDEHL ; All string arrays done? - JP Z,SCNEND ; Yes - Move string if found - CALL LOADFP ; Get array name to BCDE - LD A,E ; Get type of array - PUSH HL ; Save address of num of dim'ns - ADD HL,BC ; Start of next array - OR A ; Test type of array - JP P,GNXARY ; Numeric array - Ignore it - LD (CUROPR),HL ; Save address of next array - POP HL ; Get address of num of dim'ns - LD C,(HL) ; BC = Number of dimensions - LD B,0 - ADD HL,BC ; Two bytes per dimension size - ADD HL,BC - INC HL ; Plus one for number of dim'ns -GRBARY: EX DE,HL - LD HL,(CUROPR) ; Get address of next array - EX DE,HL - CALL CPDEHL ; Is this array finished? - JP Z,ARRLP ; Yes - Get next one - LD BC,GRBARY ; Loop until array all done -STPOOL: PUSH BC ; Save return address - OR 80H ; Flag string type -STRADD: LD A,(HL) ; Get string length - INC HL - INC HL - LD E,(HL) ; Get LSB of string address - INC HL - LD D,(HL) ; Get MSB of string address - INC HL - RET P ; Not a string - Return - OR A ; Set flags on string length - RET Z ; Null string - Return - LD B,H ; Save variable pointer - LD C,L - LD HL,(STRBOT) ; Bottom of new area - CALL CPDEHL ; String been done? - LD H,B ; Restore variable pointer - LD L,C - RET C ; String done - Ignore - POP HL ; Return address - EX (SP),HL ; Lowest available string area - CALL CPDEHL ; String within string area? - EX (SP),HL ; Lowest available string area - PUSH HL ; Re-save return address - LD H,B ; Restore variable pointer - LD L,C - RET NC ; Outside string area - Ignore - POP BC ; Get return , Throw 2 away - POP AF ; - POP AF ; - PUSH HL ; Save variable pointer - PUSH DE ; Save address of current - PUSH BC ; Put back return address - RET ; Go to it - -SCNEND: POP DE ; Addresses of strings - POP HL ; - LD A,L ; HL = 0 if no more to do - OR H - RET Z ; No more to do - Return - DEC HL - LD B,(HL) ; MSB of address of string - DEC HL - LD C,(HL) ; LSB of address of string - PUSH HL ; Save variable address - DEC HL - DEC HL - LD L,(HL) ; HL = Length of string - LD H,0 - ADD HL,BC ; Address of end of string+1 - LD D,B ; String address to DE - LD E,C - DEC HL ; Last byte in string - LD B,H ; Address to BC - LD C,L - LD HL,(STRBOT) ; Current bottom of string area - CALL MOVSTR ; Move string to new address - POP HL ; Restore variable address - LD (HL),C ; Save new LSB of address - INC HL - LD (HL),B ; Save new MSB of address - LD L,C ; Next string area+1 to HL - LD H,B - DEC HL ; Next string area address - JP GARBLP ; Look for more strings - -CONCAT: PUSH BC ; Save prec' opr & code string - PUSH HL ; - LD HL,(FPREG) ; Get first string - EX (SP),HL ; Save first string - CALL OPRND ; Get second string - EX (SP),HL ; Restore first string - CALL TSTSTR ; Make sure it's a string - LD A,(HL) ; Get length of second string - PUSH HL ; Save first string - LD HL,(FPREG) ; Get second string - PUSH HL ; Save second string - ADD A,(HL) ; Add length of second string - LD E,LS ; ?LS Error - JP C,BERROR ; String too long - Error - CALL MKTMST ; Make temporary string - POP DE ; Get second string to DE - CALL GSTRDE ; Move to string pool if needed - EX (SP),HL ; Get first string - CALL GSTRHL ; Move to string pool if needed - PUSH HL ; Save first string - LD HL,(TMPSTR+2) ; Temporary string address - EX DE,HL ; To DE - CALL SSTSA ; First string to string area - CALL SSTSA ; Second string to string area - LD HL,EVAL2 ; Return to evaluation loop - EX (SP),HL ; Save return,get code string - PUSH HL ; Save code string address - JP TSTOPL ; To temporary string to pool - -SSTSA: POP HL ; Return address - EX (SP),HL ; Get string block,save return - LD A,(HL) ; Get length of string - INC HL - INC HL - LD C,(HL) ; Get LSB of string address - INC HL - LD B,(HL) ; Get MSB of string address - LD L,A ; Length to L -TOSTRA: INC L ; INC - DECed after -TSALP: DEC L ; Count bytes moved - RET Z ; End of string - Return - LD A,(BC) ; Get source - LD (DE),A ; Save destination - INC BC ; Next source - INC DE ; Next destination - JP TSALP ; Loop until string moved - -GETSTR: CALL TSTSTR ; Make sure it's a string -GSTRCU: LD HL,(FPREG) ; Get current string -GSTRHL: EX DE,HL ; Save DE -GSTRDE: CALL BAKTMP ; Was it last tmp-str? - EX DE,HL ; Restore DE - RET NZ ; No - Return - PUSH DE ; Save string - LD D,B ; String block address to DE - LD E,C - DEC DE ; Point to length - LD C,(HL) ; Get string length - LD HL,(STRBOT) ; Current bottom of string area - CALL CPDEHL ; Last one in string area? - JP NZ,POPHL ; No - Return - LD B,A ; Clear B (A=0) - ADD HL,BC ; Remove string from str' area - LD (STRBOT),HL ; Save new bottom of str' area -POPHL: POP HL ; Restore string - RET - -BAKTMP: LD HL,(TMSTPT) ; Get temporary string pool top - DEC HL ; Back - LD B,(HL) ; Get MSB of address - DEC HL ; Back - LD C,(HL) ; Get LSB of address - DEC HL ; Back - DEC HL ; Back - CALL CPDEHL ; String last in string pool? - RET NZ ; Yes - Leave it - LD (TMSTPT),HL ; Save new string pool top - RET - -LEN: LD BC,PASSA ; To return integer A - PUSH BC ; Save address -GETLEN: CALL GETSTR ; Get string and its length - XOR A - LD D,A ; Clear D - LD (TYPE),A ; Set type to numeric - LD A,(HL) ; Get length of string - OR A ; Set status flags - RET - -ASC: LD BC,PASSA ; To return integer A - PUSH BC ; Save address -GTFLNM: CALL GETLEN ; Get length of string - JP Z,FCERR ; Null string - Error - INC HL - INC HL - LD E,(HL) ; Get LSB of address - INC HL - LD D,(HL) ; Get MSB of address - LD A,(DE) ; Get first byte of string - RET - -CHR: LD A,1 ; One character string - CALL MKTMST ; Make a temporary string - CALL MAKINT ; Make it integer A - LD HL,(TMPSTR+2) ; Get address of string - LD (HL),E ; Save character -TOPOOL: POP BC ; Clean up stack - JP TSTOPL ; Temporary string to pool - -LEFT: CALL LFRGNM ; Get number and ending ")" - XOR A ; Start at first byte in string -RIGHT1: EX (SP),HL ; Save code string,Get string - LD C,A ; Starting position in string -MID1: PUSH HL ; Save string block address - LD A,(HL) ; Get length of string - CP B ; Compare with number given - JP C,ALLFOL ; All following bytes required - LD A,B ; Get new length - DB 11H ; Skip "LD C,0" -ALLFOL: LD C,0 ; First byte of string - PUSH BC ; Save position in string - CALL TESTR ; See if enough string space - POP BC ; Get position in string - POP HL ; Restore string block address - PUSH HL ; And re-save it - INC HL - INC HL - LD B,(HL) ; Get LSB of address - INC HL - LD H,(HL) ; Get MSB of address - LD L,B ; HL = address of string - LD B,0 ; BC = starting address - ADD HL,BC ; Point to that byte - LD B,H ; BC = source string - LD C,L - CALL CRTMST ; Create a string entry - LD L,A ; Length of new string - CALL TOSTRA ; Move string to string area - POP DE ; Clear stack - CALL GSTRDE ; Move to string pool if needed - JP TSTOPL ; Temporary string to pool - -RIGHT: CALL LFRGNM ; Get number and ending ")" - POP DE ; Get string length - PUSH DE ; And re-save - LD A,(DE) ; Get length - SUB B ; Move back N bytes - JP RIGHT1 ; Go and get sub-string - -MID: EX DE,HL ; Get code string address - LD A,(HL) ; Get next byte ',' or ")" - CALL MIDNUM ; Get number supplied - INC B ; Is it character zero? - DEC B - JP Z,FCERR ; Yes - Error - PUSH BC ; Save starting position - LD E,255 ; All of string - CP ')' ; Any length given? - JP Z,RSTSTR ; No - Rest of string - CALL CHKSYN ; Make sure ',' follows - DB ',' - CALL GETINT ; Get integer 0-255 -RSTSTR: CALL CHKSYN ; Make sure ")" follows - DB ")" - POP AF ; Restore starting position - EX (SP),HL ; Get string,8ave code string - LD BC,MID1 ; Continuation of MID$ routine - PUSH BC ; Save for return - DEC A ; Starting position-1 - CP (HL) ; Compare with length - LD B,0 ; Zero bytes length - RET NC ; Null string if start past end - LD C,A ; Save starting position-1 - LD A,(HL) ; Get length of string - SUB C ; Subtract start - CP E ; Enough string for it? - LD B,A ; Save maximum length available - RET C ; Truncate string if needed - LD B,E ; Set specified length - RET ; Go and create string - -VAL: CALL GETLEN ; Get length of string - JP Z,RESZER ; Result zero - LD E,A ; Save length - INC HL - INC HL - LD A,(HL) ; Get LSB of address - INC HL - LD H,(HL) ; Get MSB of address - LD L,A ; HL = String address - PUSH HL ; Save string address - ADD HL,DE - LD B,(HL) ; Get end of string+1 byte - LD (HL),D ; Zero it to terminate - EX (SP),HL ; Save string end,get start - PUSH BC ; Save end+1 byte - LD A,(HL) ; Get starting byte - CP '$' ; Hex number indicated? [function added G. Searle] - JP NZ,VAL1 - CALL HEXTFP ; Convert Hex to FPREG - JR VAL3 -VAL1: CP '%' ; Binary number indicated? [function added] - JP NZ,VAL2 - CALL BINTFP ; Convert Bin to FPREG - JR VAL3 -VAL2: CALL ASCTFP ; Convert ASCII string to FP -VAL3: POP BC ; Restore end+1 byte - POP HL ; Restore end+1 address - LD (HL),B ; Put back original byte - RET - -LFRGNM: EX DE,HL ; Code string address to HL - CALL CHKSYN ; Make sure ")" follows - DB ")" -MIDNUM: POP BC ; Get return address - POP DE ; Get number supplied - PUSH BC ; Re-save return address - LD B,E ; Number to B - RET - -INP: CALL MAKINT ; Make it integer A - LD (INPORT),A ; Set input port - CALL INPSUB ; Get input from port - JP PASSA ; Return integer A - -POUT: CALL SETIO ; Set up port number - JP OUTSUB ; Output data and return - -WAIT: CALL SETIO ; Set up port number - PUSH AF ; Save AND mask - LD E,0 ; Assume zero if none given - DEC HL ; DEC 'cos GETCHR INCs - CALL GETCHR ; Get next character - JP Z,NOXOR ; No XOR byte given - CALL CHKSYN ; Make sure ',' follows - DB ',' - CALL GETINT ; Get integer 0-255 to XOR with -NOXOR: POP BC ; Restore AND mask -WAITLP: CALL INPSUB ; Get input - XOR E ; Flip selected bits - AND B ; Result non-zero? - JP Z,WAITLP ; No = keep waiting - RET - -SETIO: CALL GETINT ; Get integer 0-255 - LD (INPORT),A ; Set input port - LD (OTPORT),A ; Set output port - CALL CHKSYN ; Make sure ',' follows - DB ',' - JP GETINT ; Get integer 0-255 and return - -FNDNUM: CALL GETCHR ; Get next character -GETINT: CALL GETNUM ; Get a number from 0 to 255 -MAKINT: CALL DEPINT ; Make sure value 0 - 255 - LD A,D ; Get MSB of number - OR A ; Zero? - JP NZ,FCERR ; No - Error - DEC HL ; DEC 'cos GETCHR INCs - CALL GETCHR ; Get next character - LD A,E ; Get number to A - RET - -PEEK: CALL DEINT ; Get memory address - LD A,(DE) ; Get byte in memory - JP PASSA ; Return integer A - -POKE: CALL GETNUM ; Get memory address - CALL DEINT ; Get integer -32768 to 3276 - PUSH DE ; Save memory address - CALL CHKSYN ; Make sure ',' follows - DB ',' - CALL GETINT ; Get integer 0-255 - POP DE ; Restore memory address - LD (DE),A ; Load it into memory - RET - -ROUND: LD HL,HALF ; Add 0.5 to FPREG -ADDPHL: CALL LOADFP ; Load FP at (HL) to BCDE - JP FPADD ; Add BCDE to FPREG - -SUBPHL: CALL LOADFP ; FPREG = -FPREG + number at HL - DB 21H ; Skip "POP BC" and "POP DE" -PSUB: POP BC ; Get FP number from stack - POP DE -SUBCDE: CALL INVSGN ; Negate FPREG -FPADD: LD A,B ; Get FP exponent - OR A ; Is number zero? - RET Z ; Yes - Nothing to add - LD A,(FPEXP) ; Get FPREG exponent - OR A ; Is this number zero? - JP Z,FPBCDE ; Yes - Move BCDE to FPREG - SUB B ; BCDE number larger? - JP NC,NOSWAP ; No - Don't swap them - CPL ; Two's complement - INC A ; FP exponent - EX DE,HL - CALL STAKFP ; Put FPREG on stack - EX DE,HL - CALL FPBCDE ; Move BCDE to FPREG - POP BC ; Restore number from stack - POP DE -NOSWAP: CP 24+1 ; Second number insignificant? - RET NC ; Yes - First number is result - PUSH AF ; Save number of bits to scale - CALL SIGNS ; Set MSBs & sign of result - LD H,A ; Save sign of result - POP AF ; Restore scaling factor - CALL SCALE ; Scale BCDE to same exponent - OR H ; Result to be positive? - LD HL,FPREG ; Point to FPREG - JP P,MINCDE ; No - Subtract FPREG from CDE - CALL PLUCDE ; Add FPREG to CDE - JP NC,RONDUP ; No overflow - Round it up - INC HL ; Point to exponent - INC (HL) ; Increment it - JP Z,OVERR ; Number overflowed - Error - LD L,1 ; 1 bit to shift right - CALL SHRT1 ; Shift result right - JP RONDUP ; Round it up - -MINCDE: XOR A ; Clear A and carry - SUB B ; Negate exponent - LD B,A ; Re-save exponent - LD A,(HL) ; Get LSB of FPREG - SBC A, E ; Subtract LSB of BCDE - LD E,A ; Save LSB of BCDE - INC HL - LD A,(HL) ; Get NMSB of FPREG - SBC A,D ; Subtract NMSB of BCDE - LD D,A ; Save NMSB of BCDE - INC HL - LD A,(HL) ; Get MSB of FPREG - SBC A,C ; Subtract MSB of BCDE - LD C,A ; Save MSB of BCDE -CONPOS: CALL C,COMPL ; Overflow - Make it positive - -BNORM: LD L,B ; L = Exponent - LD H,E ; H = LSB - XOR A -BNRMLP: LD B,A ; Save bit count - LD A,C ; Get MSB - OR A ; Is it zero? - JP NZ,PNORM ; No - Do it bit at a time - LD C,D ; MSB = NMSB - LD D,H ; NMSB= LSB - LD H,L ; LSB = VLSB - LD L,A ; VLSB= 0 - LD A,B ; Get exponent - SUB 8 ; Count 8 bits - CP -24-8 ; Was number zero? - JP NZ,BNRMLP ; No - Keep normalising -RESZER: XOR A ; Result is zero -SAVEXP: LD (FPEXP),A ; Save result as zero - RET - -NORMAL: DEC B ; Count bits - ADD HL,HL ; Shift HL left - LD A,D ; Get NMSB - RLA ; Shift left with last bit - LD D,A ; Save NMSB - LD A,C ; Get MSB - ADC A,A ; Shift left with last bit - LD C,A ; Save MSB -PNORM: JP P,NORMAL ; Not done - Keep going - LD A,B ; Number of bits shifted - LD E,H ; Save HL in EB - LD B,L - OR A ; Any shifting done? - JP Z,RONDUP ; No - Round it up - LD HL,FPEXP ; Point to exponent - ADD A,(HL) ; Add shifted bits - LD (HL),A ; Re-save exponent - JP NC,RESZER ; Underflow - Result is zero - RET Z ; Result is zero -RONDUP: LD A,B ; Get VLSB of number -RONDB: LD HL,FPEXP ; Point to exponent - OR A ; Any rounding? - CALL M,FPROND ; Yes - Round number up - LD B,(HL) ; B = Exponent - INC HL - LD A,(HL) ; Get sign of result - AND 10000000B ; Only bit 7 needed - XOR C ; Set correct sign - LD C,A ; Save correct sign in number - JP FPBCDE ; Move BCDE to FPREG - -FPROND: INC E ; Round LSB - RET NZ ; Return if ok - INC D ; Round NMSB - RET NZ ; Return if ok - INC C ; Round MSB - RET NZ ; Return if ok - LD C,80H ; Set normal value - INC (HL) ; Increment exponent - RET NZ ; Return if ok - JP OVERR ; Overflow error - -PLUCDE: LD A,(HL) ; Get LSB of FPREG - ADD A,E ; Add LSB of BCDE - LD E,A ; Save LSB of BCDE - INC HL - LD A,(HL) ; Get NMSB of FPREG - ADC A,D ; Add NMSB of BCDE - LD D,A ; Save NMSB of BCDE - INC HL - LD A,(HL) ; Get MSB of FPREG - ADC A,C ; Add MSB of BCDE - LD C,A ; Save MSB of BCDE - RET - -COMPL: LD HL,SGNRES ; Sign of result - LD A,(HL) ; Get sign of result - CPL ; Negate it - LD (HL),A ; Put it back - XOR A - LD L,A ; Set L to zero - SUB B ; Negate exponent,set carry - LD B,A ; Re-save exponent - LD A,L ; Load zero - SBC A,E ; Negate LSB - LD E,A ; Re-save LSB - LD A,L ; Load zero - SBC A,D ; Negate NMSB - LD D,A ; Re-save NMSB - LD A,L ; Load zero - SBC A,C ; Negate MSB - LD C,A ; Re-save MSB - RET - -SCALE: LD B,0 ; Clear underflow -SCALLP: SUB 8 ; 8 bits (a whole byte)? - JP C,SHRITE ; No - Shift right A bits - LD B,E ; <- Shift - LD E,D ; <- right - LD D,C ; <- eight - LD C,0 ; <- bits - JP SCALLP ; More bits to shift - -SHRITE: ADD A,8+1 ; Adjust count - LD L,A ; Save bits to shift -SHRLP: XOR A ; Flag for all done - DEC L ; All shifting done? - RET Z ; Yes - Return - LD A,C ; Get MSB -SHRT1: RRA ; Shift it right - LD C,A ; Re-save - LD A,D ; Get NMSB - RRA ; Shift right with last bit - LD D,A ; Re-save it - LD A,E ; Get LSB - RRA ; Shift right with last bit - LD E,A ; Re-save it - LD A,B ; Get underflow - RRA ; Shift right with last bit - LD B,A ; Re-save underflow - JP SHRLP ; More bits to do - -UNITY: DB 000H,000H,000H,081H ; 1.00000 - -LOGTAB: DB 3 ; Table used by LOG - DB 0AAH,056H,019H,080H ; 0.59898 - DB 0F1H,022H,076H,080H ; 0.96147 - DB 045H,0AAH,038H,082H ; 2.88539 - -LOG: CALL TSTSGN ; Test sign of value - OR A - JP PE,FCERR ; ?FC Error if <= zero - LD HL,FPEXP ; Point to exponent - LD A,(HL) ; Get exponent - LD BC,8035H ; BCDE = SQR(1/2) - LD DE,04F3H - SUB B ; Scale value to be < 1 - PUSH AF ; Save scale factor - LD (HL),B ; Save new exponent - PUSH DE ; Save SQR(1/2) - PUSH BC - CALL FPADD ; Add SQR(1/2) to value - POP BC ; Restore SQR(1/2) - POP DE - INC B ; Make it SQR(2) - CALL DVBCDE ; Divide by SQR(2) - LD HL,UNITY ; Point to 1. - CALL SUBPHL ; Subtract FPREG from 1 - LD HL,LOGTAB ; Coefficient table - CALL SUMSER ; Evaluate sum of series - LD BC,8080H ; BCDE = -0.5 - LD DE,0000H - CALL FPADD ; Subtract 0.5 from FPREG - POP AF ; Restore scale factor - CALL RSCALE ; Re-scale number -MULLN2: LD BC,8031H ; BCDE = Ln(2) - LD DE,7218H - DB 21H ; Skip "POP BC" and "POP DE" - -MULT: POP BC ; Get number from stack - POP DE -FPMULT: CALL TSTSGN ; Test sign of FPREG - RET Z ; Return zero if zero - LD L,0 ; Flag add exponents - CALL ADDEXP ; Add exponents - LD A,C ; Get MSB of multiplier - LD (MULVAL),A ; Save MSB of multiplier - EX DE,HL - LD (MULVAL+1),HL ; Save rest of multiplier - LD BC,0 ; Partial product (BCDE) = zero - LD D,B - LD E,B - LD HL,BNORM ; Address of normalise - PUSH HL ; Save for return - LD HL,MULT8 ; Address of 8 bit multiply - PUSH HL ; Save for NMSB,MSB - PUSH HL ; - LD HL,FPREG ; Point to number -MULT8: LD A,(HL) ; Get LSB of number - INC HL ; Point to NMSB - OR A ; Test LSB - JP Z,BYTSFT ; Zero - shift to next byte - PUSH HL ; Save address of number - LD L,8 ; 8 bits to multiply by -MUL8LP: RRA ; Shift LSB right - LD H,A ; Save LSB - LD A,C ; Get MSB - JP NC,NOMADD ; Bit was zero - Don't add - PUSH HL ; Save LSB and count - LD HL,(MULVAL+1) ; Get LSB and NMSB - ADD HL,DE ; Add NMSB and LSB - EX DE,HL ; Leave sum in DE - POP HL ; Restore MSB and count - LD A,(MULVAL) ; Get MSB of multiplier - ADC A,C ; Add MSB -NOMADD: RRA ; Shift MSB right - LD C,A ; Re-save MSB - LD A,D ; Get NMSB - RRA ; Shift NMSB right - LD D,A ; Re-save NMSB - LD A,E ; Get LSB - RRA ; Shift LSB right - LD E,A ; Re-save LSB - LD A,B ; Get VLSB - RRA ; Shift VLSB right - LD B,A ; Re-save VLSB - DEC L ; Count bits multiplied - LD A,H ; Get LSB of multiplier - JP NZ,MUL8LP ; More - Do it -POPHRT: POP HL ; Restore address of number - RET - -BYTSFT: LD B,E ; Shift partial product left - LD E,D - LD D,C - LD C,A - RET - -DIV10: CALL STAKFP ; Save FPREG on stack - LD BC,8420H ; BCDE = 10. - LD DE,0000H - CALL FPBCDE ; Move 10 to FPREG - -DIV: POP BC ; Get number from stack - POP DE -DVBCDE: CALL TSTSGN ; Test sign of FPREG - JP Z,DZERR ; Error if division by zero - LD L,-1 ; Flag subtract exponents - CALL ADDEXP ; Subtract exponents - INC (HL) ; Add 2 to exponent to adjust - INC (HL) - DEC HL ; Point to MSB - LD A,(HL) ; Get MSB of dividend - LD (DIV3),A ; Save for subtraction - DEC HL - LD A,(HL) ; Get NMSB of dividend - LD (DIV2),A ; Save for subtraction - DEC HL - LD A,(HL) ; Get MSB of dividend - LD (DIV1),A ; Save for subtraction - LD B,C ; Get MSB - EX DE,HL ; NMSB,LSB to HL - XOR A - LD C,A ; Clear MSB of quotient - LD D,A ; Clear NMSB of quotient - LD E,A ; Clear LSB of quotient - LD (DIV4),A ; Clear overflow count -DIVLP: PUSH HL ; Save divisor - PUSH BC - LD A,L ; Get LSB of number - CALL DIVSUP ; Subt' divisor from dividend - SBC A,0 ; Count for overflows - CCF - JP NC,RESDIV ; Restore divisor if borrow - LD (DIV4),A ; Re-save overflow count - POP AF ; Scrap divisor - POP AF - SCF ; Set carry to - DB 0D2H ; Skip "POP BC" and "POP HL" - -RESDIV: POP BC ; Restore divisor - POP HL - LD A,C ; Get MSB of quotient - INC A - DEC A - RRA ; Bit 0 to bit 7 - JP M,RONDB ; Done - Normalise result - RLA ; Restore carry - LD A,E ; Get LSB of quotient - RLA ; Double it - LD E,A ; Put it back - LD A,D ; Get NMSB of quotient - RLA ; Double it - LD D,A ; Put it back - LD A,C ; Get MSB of quotient - RLA ; Double it - LD C,A ; Put it back - ADD HL,HL ; Double NMSB,LSB of divisor - LD A,B ; Get MSB of divisor - RLA ; Double it - LD B,A ; Put it back - LD A,(DIV4) ; Get VLSB of quotient - RLA ; Double it - LD (DIV4),A ; Put it back - LD A,C ; Get MSB of quotient - OR D ; Merge NMSB - OR E ; Merge LSB - JP NZ,DIVLP ; Not done - Keep dividing - PUSH HL ; Save divisor - LD HL,FPEXP ; Point to exponent - DEC (HL) ; Divide by 2 - POP HL ; Restore divisor - JP NZ,DIVLP ; Ok - Keep going - JP OVERR ; Overflow error - -ADDEXP: LD A,B ; Get exponent of dividend - OR A ; Test it - JP Z,OVTST3 ; Zero - Result zero - LD A,L ; Get add/subtract flag - LD HL,FPEXP ; Point to exponent - XOR (HL) ; Add or subtract it - ADD A,B ; Add the other exponent - LD B,A ; Save new exponent - RRA ; Test exponent for overflow - XOR B - LD A,B ; Get exponent - JP P,OVTST2 ; Positive - Test for overflow - ADD A,80H ; Add excess 128 - LD (HL),A ; Save new exponent - JP Z,POPHRT ; Zero - Result zero - CALL SIGNS ; Set MSBs and sign of result - LD (HL),A ; Save new exponent - DEC HL ; Point to MSB - RET - -OVTST1: CALL TSTSGN ; Test sign of FPREG - CPL ; Invert sign - POP HL ; Clean up stack -OVTST2: OR A ; Test if new exponent zero -OVTST3: POP HL ; Clear off return address - JP P,RESZER ; Result zero - JP OVERR ; Overflow error - -MLSP10: CALL BCDEFP ; Move FPREG to BCDE - LD A,B ; Get exponent - OR A ; Is it zero? - RET Z ; Yes - Result is zero - ADD A,2 ; Multiply by 4 - JP C,OVERR ; Overflow - ?OV Error - LD B,A ; Re-save exponent - CALL FPADD ; Add BCDE to FPREG (Times 5) - LD HL,FPEXP ; Point to exponent - INC (HL) ; Double number (Times 10) - RET NZ ; Ok - Return - JP OVERR ; Overflow error - -TSTSGN: LD A,(FPEXP) ; Get sign of FPREG - OR A - RET Z ; RETurn if number is zero - LD A,(FPREG+2) ; Get MSB of FPREG - DB 0FEH ; Test sign -RETREL: CPL ; Invert sign - RLA ; Sign bit to carry -FLGDIF: SBC A,A ; Carry to all bits of A - RET NZ ; Return -1 if negative - INC A ; Bump to +1 - RET ; Positive - Return +1 - -SGN: CALL TSTSGN ; Test sign of FPREG -FLGREL: LD B,80H+8 ; 8 bit integer in exponent - LD DE,0 ; Zero NMSB and LSB -RETINT: LD HL,FPEXP ; Point to exponent - LD C,A ; CDE = MSB,NMSB and LSB - LD (HL),B ; Save exponent - LD B,0 ; CDE = integer to normalise - INC HL ; Point to sign of result - LD (HL),80H ; Set sign of result - RLA ; Carry = sign of integer - JP CONPOS ; Set sign of result - -ABS: CALL TSTSGN ; Test sign of FPREG - RET P ; Return if positive -INVSGN: LD HL,FPREG+2 ; Point to MSB - LD A,(HL) ; Get sign of mantissa - XOR 80H ; Invert sign of mantissa - LD (HL),A ; Re-save sign of mantissa - RET - -STAKFP: EX DE,HL ; Save code string address - LD HL,(FPREG) ; LSB,NLSB of FPREG - EX (SP),HL ; Stack them,get return - PUSH HL ; Re-save return - LD HL,(FPREG+2) ; MSB and exponent of FPREG - EX (SP),HL ; Stack them,get return - PUSH HL ; Re-save return - EX DE,HL ; Restore code string address - RET - -PHLTFP: CALL LOADFP ; Number at HL to BCDE -FPBCDE: EX DE,HL ; Save code string address - LD (FPREG),HL ; Save LSB,NLSB of number - LD H,B ; Exponent of number - LD L,C ; MSB of number - LD (FPREG+2),HL ; Save MSB and exponent - EX DE,HL ; Restore code string address - RET - -BCDEFP: LD HL,FPREG ; Point to FPREG -LOADFP: LD E,(HL) ; Get LSB of number - INC HL - LD D,(HL) ; Get NMSB of number - INC HL - LD C,(HL) ; Get MSB of number - INC HL - LD B,(HL) ; Get exponent of number -INCHL: INC HL ; Used for conditional "INC HL" - RET - -FPTHL: LD DE,FPREG ; Point to FPREG -DETHL4: LD B,4 ; 4 bytes to move -DETHLB: LD A,(DE) ; Get source - LD (HL),A ; Save destination - INC DE ; Next source - INC HL ; Next destination - DEC B ; Count bytes - JP NZ,DETHLB ; Loop if more - RET - -SIGNS: LD HL,FPREG+2 ; Point to MSB of FPREG - LD A,(HL) ; Get MSB - RLCA ; Old sign to carry - SCF ; Set MSBit - RRA ; Set MSBit of MSB - LD (HL),A ; Save new MSB - CCF ; Complement sign - RRA ; Old sign to carry - INC HL - INC HL - LD (HL),A ; Set sign of result - LD A,C ; Get MSB - RLCA ; Old sign to carry - SCF ; Set MSBit - RRA ; Set MSBit of MSB - LD C,A ; Save MSB - RRA - XOR (HL) ; New sign of result - RET - -CMPNUM: LD A,B ; Get exponent of number - OR A - JP Z,TSTSGN ; Zero - Test sign of FPREG - LD HL,RETREL ; Return relation routine - PUSH HL ; Save for return - CALL TSTSGN ; Test sign of FPREG - LD A,C ; Get MSB of number - RET Z ; FPREG zero - Number's MSB - LD HL,FPREG+2 ; MSB of FPREG - XOR (HL) ; Combine signs - LD A,C ; Get MSB of number - RET M ; Exit if signs different - CALL CMPFP ; Compare FP numbers - RRA ; Get carry to sign - XOR C ; Combine with MSB of number - RET - -CMPFP: INC HL ; Point to exponent - LD A,B ; Get exponent - CP (HL) ; Compare exponents - RET NZ ; Different - DEC HL ; Point to MBS - LD A,C ; Get MSB - CP (HL) ; Compare MSBs - RET NZ ; Different - DEC HL ; Point to NMSB - LD A,D ; Get NMSB - CP (HL) ; Compare NMSBs - RET NZ ; Different - DEC HL ; Point to LSB - LD A,E ; Get LSB - SUB (HL) ; Compare LSBs - RET NZ ; Different - POP HL ; Drop RETurn - POP HL ; Drop another RETurn - RET - -FPINT: LD B,A ; <- Move - LD C,A ; <- exponent - LD D,A ; <- to all - LD E,A ; <- bits - OR A ; Test exponent - RET Z ; Zero - Return zero - PUSH HL ; Save pointer to number - CALL BCDEFP ; Move FPREG to BCDE - CALL SIGNS ; Set MSBs & sign of result - XOR (HL) ; Combine with sign of FPREG - LD H,A ; Save combined signs - CALL M,DCBCDE ; Negative - Decrement BCDE - LD A,80H+24 ; 24 bits - SUB B ; Bits to shift - CALL SCALE ; Shift BCDE - LD A,H ; Get combined sign - RLA ; Sign to carry - CALL C,FPROND ; Negative - Round number up - LD B,0 ; Zero exponent - CALL C,COMPL ; If negative make positive - POP HL ; Restore pointer to number - RET - -DCBCDE: DEC DE ; Decrement BCDE - LD A,D ; Test LSBs - AND E - INC A - RET NZ ; Exit if LSBs not FFFF - DEC BC ; Decrement MSBs - RET - -INT: LD HL,FPEXP ; Point to exponent - LD A,(HL) ; Get exponent - CP 80H+24 ; Integer accuracy only? - LD A,(FPREG) ; Get LSB - RET NC ; Yes - Already integer - LD A,(HL) ; Get exponent - CALL FPINT ; F.P to integer - LD (HL),80H+24 ; Save 24 bit integer - LD A,E ; Get LSB of number - PUSH AF ; Save LSB - LD A,C ; Get MSB of number - RLA ; Sign to carry - CALL CONPOS ; Set sign of result - POP AF ; Restore LSB of number - RET - -MLDEBC: LD HL,0 ; Clear partial product - LD A,B ; Test multiplier - OR C - RET Z ; Return zero if zero - LD A,16 ; 16 bits -MLDBLP: ADD HL,HL ; Shift P.P left - JP C,BSERR ; ?BS Error if overflow - EX DE,HL - ADD HL,HL ; Shift multiplier left - EX DE,HL - JP NC,NOMLAD ; Bit was zero - No add - ADD HL,BC ; Add multiplicand - JP C,BSERR ; ?BS Error if overflow -NOMLAD: DEC A ; Count bits - JP NZ,MLDBLP ; More - RET - -ASCTFP: CP '-' ; Negative? - PUSH AF ; Save it and flags - JP Z,CNVNUM ; Yes - Convert number - CP '+' ; Positive? - JP Z,CNVNUM ; Yes - Convert number - DEC HL ; DEC 'cos GETCHR INCs -CNVNUM: CALL RESZER ; Set result to zero - LD B,A ; Digits after point counter - LD D,A ; Sign of exponent - LD E,A ; Exponent of ten - CPL - LD C,A ; Before or after point flag -MANLP: CALL GETCHR ; Get next character - JP C,ADDIG ; Digit - Add to number - CP '.' - JP Z,DPOINT ; '.' - Flag point - CP 'E' - JP NZ,CONEXP ; Not 'E' - Scale number - CALL GETCHR ; Get next character - CALL SGNEXP ; Get sign of exponent -EXPLP: CALL GETCHR ; Get next character - JP C,EDIGIT ; Digit - Add to exponent - INC D ; Is sign negative? - JP NZ,CONEXP ; No - Scale number - XOR A - SUB E ; Negate exponent - LD E,A ; And re-save it - INC C ; Flag end of number -DPOINT: INC C ; Flag point passed - JP Z,MANLP ; Zero - Get another digit -CONEXP: PUSH HL ; Save code string address - LD A,E ; Get exponent - SUB B ; Subtract digits after point -SCALMI: CALL P,SCALPL ; Positive - Multiply number - JP P,ENDCON ; Positive - All done - PUSH AF ; Save number of times to /10 - CALL DIV10 ; Divide by 10 - POP AF ; Restore count - INC A ; Count divides - -ENDCON: JP NZ,SCALMI ; More to do - POP DE ; Restore code string address - POP AF ; Restore sign of number - CALL Z,INVSGN ; Negative - Negate number - EX DE,HL ; Code string address to HL - RET - -SCALPL: RET Z ; Exit if no scaling needed -MULTEN: PUSH AF ; Save count - CALL MLSP10 ; Multiply number by 10 - POP AF ; Restore count - DEC A ; Count multiplies - RET - -ADDIG: PUSH DE ; Save sign of exponent - LD D,A ; Save digit - LD A,B ; Get digits after point - ADC A,C ; Add one if after point - LD B,A ; Re-save counter - PUSH BC ; Save point flags - PUSH HL ; Save code string address - PUSH DE ; Save digit - CALL MLSP10 ; Multiply number by 10 - POP AF ; Restore digit - SUB '0' ; Make it absolute - CALL RSCALE ; Re-scale number - POP HL ; Restore code string address - POP BC ; Restore point flags - POP DE ; Restore sign of exponent - JP MANLP ; Get another digit - -RSCALE: CALL STAKFP ; Put number on stack - CALL FLGREL ; Digit to add to FPREG -PADD: POP BC ; Restore number - POP DE - JP FPADD ; Add BCDE to FPREG and return - -EDIGIT: LD A,E ; Get digit - RLCA ; Times 2 - RLCA ; Times 4 - ADD A,E ; Times 5 - RLCA ; Times 10 - ADD A,(HL) ; Add next digit - SUB '0' ; Make it absolute - LD E,A ; Save new digit - JP EXPLP ; Look for another digit - -LINEIN: PUSH HL ; Save code string address - LD HL,INMSG ; Output " in " - CALL PRS ; Output string at HL - POP HL ; Restore code string address -PRNTHL: EX DE,HL ; Code string address to DE - XOR A - LD B,80H+24 ; 24 bits - CALL RETINT ; Return the integer - LD HL,PRNUMS ; Print number string - PUSH HL ; Save for return -NUMASC: LD HL,PBUFF ; Convert number to ASCII - PUSH HL ; Save for return - CALL TSTSGN ; Test sign of FPREG - LD (HL),' ' ; Space at start - JP P,SPCFST ; Positive - Space to start - LD (HL),'-' ; '-' sign at start -SPCFST: INC HL ; First byte of number - LD (HL),'0' ; '0' if zero - JP Z,JSTZER ; Return '0' if zero - PUSH HL ; Save buffer address - CALL M,INVSGN ; Negate FPREG if negative - XOR A ; Zero A - PUSH AF ; Save it - CALL RNGTST ; Test number is in range -SIXDIG: LD BC,9143H ; BCDE - 99999.9 - LD DE,4FF8H - CALL CMPNUM ; Compare numbers - OR A - JP PO,INRNG ; > 99999.9 - Sort it out - POP AF ; Restore count - CALL MULTEN ; Multiply by ten - PUSH AF ; Re-save count - JP SIXDIG ; Test it again - -GTSIXD: CALL DIV10 ; Divide by 10 - POP AF ; Get count - INC A ; Count divides - PUSH AF ; Re-save count - CALL RNGTST ; Test number is in range -INRNG: CALL ROUND ; Add 0.5 to FPREG - INC A - CALL FPINT ; F.P to integer - CALL FPBCDE ; Move BCDE to FPREG - LD BC,0306H ; 1E+06 to 1E-03 range - POP AF ; Restore count - ADD A,C ; 6 digits before point - INC A ; Add one - JP M,MAKNUM ; Do it in 'E' form if < 1E-02 - CP 6+1+1 ; More than 999999 ? - JP NC,MAKNUM ; Yes - Do it in 'E' form - INC A ; Adjust for exponent - LD B,A ; Exponent of number - LD A,2 ; Make it zero after - -MAKNUM: DEC A ; Adjust for digits to do - DEC A - POP HL ; Restore buffer address - PUSH AF ; Save count - LD DE,POWERS ; Powers of ten - DEC B ; Count digits before point - JP NZ,DIGTXT ; Not zero - Do number - LD (HL),'.' ; Save point - INC HL ; Move on - LD (HL),'0' ; Save zero - INC HL ; Move on -DIGTXT: DEC B ; Count digits before point - LD (HL),'.' ; Save point in case - CALL Z,INCHL ; Last digit - move on - PUSH BC ; Save digits before point - PUSH HL ; Save buffer address - PUSH DE ; Save powers of ten - CALL BCDEFP ; Move FPREG to BCDE - POP HL ; Powers of ten table - LD B, '0'-1 ; ASCII '0' - 1 -TRYAGN: INC B ; Count subtractions - LD A,E ; Get LSB - SUB (HL) ; Subtract LSB - LD E,A ; Save LSB - INC HL - LD A,D ; Get NMSB - SBC A,(HL) ; Subtract NMSB - LD D,A ; Save NMSB - INC HL - LD A,C ; Get MSB - SBC A,(HL) ; Subtract MSB - LD C,A ; Save MSB - DEC HL ; Point back to start - DEC HL - JP NC,TRYAGN ; No overflow - Try again - CALL PLUCDE ; Restore number - INC HL ; Start of next number - CALL FPBCDE ; Move BCDE to FPREG - EX DE,HL ; Save point in table - POP HL ; Restore buffer address - LD (HL),B ; Save digit in buffer - INC HL ; And move on - POP BC ; Restore digit count - DEC C ; Count digits - JP NZ,DIGTXT ; More - Do them - DEC B ; Any decimal part? - JP Z,DOEBIT ; No - Do 'E' bit -SUPTLZ: DEC HL ; Move back through buffer - LD A,(HL) ; Get character - CP '0' ; '0' character? - JP Z,SUPTLZ ; Yes - Look back for more - CP '.' ; A decimal point? - CALL NZ,INCHL ; Move back over digit - -DOEBIT: POP AF ; Get 'E' flag - JP Z,NOENED ; No 'E' needed - End buffer - LD (HL),'E' ; Put 'E' in buffer - INC HL ; And move on - LD (HL),'+' ; Put '+' in buffer - JP P,OUTEXP ; Positive - Output exponent - LD (HL),'-' ; Put '-' in buffer - CPL ; Negate exponent - INC A -OUTEXP: LD B,'0'-1 ; ASCII '0' - 1 -EXPTEN: INC B ; Count subtractions - SUB 10 ; Tens digit - JP NC,EXPTEN ; More to do - ADD A,'0'+10 ; Restore and make ASCII - INC HL ; Move on - LD (HL),B ; Save MSB of exponent -JSTZER: INC HL ; - LD (HL),A ; Save LSB of exponent - INC HL -NOENED: LD (HL),C ; Mark end of buffer - POP HL ; Restore code string address - RET - -RNGTST: LD BC,9474H ; BCDE = 999999. - LD DE,23F7H - CALL CMPNUM ; Compare numbers - OR A - POP HL ; Return address to HL - JP PO,GTSIXD ; Too big - Divide by ten - JP (HL) ; Otherwise return to caller - -HALF: DB 00H,00H,00H,80H ; 0.5 - -POWERS: DB 0A0H,086H,001H ; 100000 - DB 010H,027H,000H ; 10000 - DB 0E8H,003H,000H ; 1000 - DB 064H,000H,000H ; 100 - DB 00AH,000H,000H ; 10 - DB 001H,000H,000H ; 1 - -NEGAFT: LD HL,INVSGN ; Negate result - EX (SP),HL ; To be done after caller - JP (HL) ; Return to caller - -SQR: CALL STAKFP ; Put value on stack - LD HL,HALF ; Set power to 1/2 - CALL PHLTFP ; Move 1/2 to FPREG - -POWER: POP BC ; Get base - POP DE - CALL TSTSGN ; Test sign of power - LD A,B ; Get exponent of base - JP Z,EXP ; Make result 1 if zero - JP P,POWER1 ; Positive base - Ok - OR A ; Zero to negative power? - JP Z,DZERR ; Yes - ?/0 Error -POWER1: OR A ; Base zero? - JP Z,SAVEXP ; Yes - Return zero - PUSH DE ; Save base - PUSH BC - LD A,C ; Get MSB of base - OR 01111111B ; Get sign status - CALL BCDEFP ; Move power to BCDE - JP P,POWER2 ; Positive base - Ok - PUSH DE ; Save power - PUSH BC - CALL INT ; Get integer of power - POP BC ; Restore power - POP DE - PUSH AF ; MSB of base - CALL CMPNUM ; Power an integer? - POP HL ; Restore MSB of base - LD A,H ; but don't affect flags - RRA ; Exponent odd or even? -POWER2: POP HL ; Restore MSB and exponent - LD (FPREG+2),HL ; Save base in FPREG - POP HL ; LSBs of base - LD (FPREG),HL ; Save in FPREG - CALL C,NEGAFT ; Odd power - Negate result - CALL Z,INVSGN ; Negative base - Negate it - PUSH DE ; Save power - PUSH BC - CALL LOG ; Get LOG of base - POP BC ; Restore power - POP DE - CALL FPMULT ; Multiply LOG by power - -EXP: CALL STAKFP ; Put value on stack - LD BC,08138H ; BCDE = 1/Ln(2) - LD DE,0AA3BH - CALL FPMULT ; Multiply value by 1/LN(2) - LD A,(FPEXP) ; Get exponent - CP 80H+8 ; Is it in range? - JP NC,OVTST1 ; No - Test for overflow - CALL INT ; Get INT of FPREG - ADD A,80H ; For excess 128 - ADD A,2 ; Exponent > 126? - JP C,OVTST1 ; Yes - Test for overflow - PUSH AF ; Save scaling factor - LD HL,UNITY ; Point to 1. - CALL ADDPHL ; Add 1 to FPREG - CALL MULLN2 ; Multiply by LN(2) - POP AF ; Restore scaling factor - POP BC ; Restore exponent - POP DE - PUSH AF ; Save scaling factor - CALL SUBCDE ; Subtract exponent from FPREG - CALL INVSGN ; Negate result - LD HL,EXPTAB ; Coefficient table - CALL SMSER1 ; Sum the series - LD DE,0 ; Zero LSBs - POP BC ; Scaling factor - LD C,D ; Zero MSB - JP FPMULT ; Scale result to correct value - -EXPTAB: DB 8 ; Table used by EXP - DB 040H,02EH,094H,074H ; -1/7! (-1/5040) - DB 070H,04FH,02EH,077H ; 1/6! ( 1/720) - DB 06EH,002H,088H,07AH ; -1/5! (-1/120) - DB 0E6H,0A0H,02AH,07CH ; 1/4! ( 1/24) - DB 050H,0AAH,0AAH,07EH ; -1/3! (-1/6) - DB 0FFH,0FFH,07FH,07FH ; 1/2! ( 1/2) - DB 000H,000H,080H,081H ; -1/1! (-1/1) - DB 000H,000H,000H,081H ; 1/0! ( 1/1) - -SUMSER: CALL STAKFP ; Put FPREG on stack - LD DE,MULT ; Multiply by "X" - PUSH DE ; To be done after - PUSH HL ; Save address of table - CALL BCDEFP ; Move FPREG to BCDE - CALL FPMULT ; Square the value - POP HL ; Restore address of table -SMSER1: CALL STAKFP ; Put value on stack - LD A,(HL) ; Get number of coefficients - INC HL ; Point to start of table - CALL PHLTFP ; Move coefficient to FPREG - DB 06H ; Skip "POP AF" -SUMLP: POP AF ; Restore count - POP BC ; Restore number - POP DE - DEC A ; Cont coefficients - RET Z ; All done - PUSH DE ; Save number - PUSH BC - PUSH AF ; Save count - PUSH HL ; Save address in table - CALL FPMULT ; Multiply FPREG by BCDE - POP HL ; Restore address in table - CALL LOADFP ; Number at HL to BCDE - PUSH HL ; Save address in table - CALL FPADD ; Add coefficient to FPREG - POP HL ; Restore address in table - JP SUMLP ; More coefficients - -RND: CALL TSTSGN ; Test sign of FPREG - LD HL,SEED+2 ; Random number seed - JP M,RESEED ; Negative - Re-seed - LD HL,LSTRND ; Last random number - CALL PHLTFP ; Move last RND to FPREG - LD HL,SEED+2 ; Random number seed - RET Z ; Return if RND(0) - ADD A,(HL) ; Add (SEED)+2) - AND 00000111B ; 0 to 7 - LD B,0 - LD (HL),A ; Re-save seed - INC HL ; Move to coefficient table - ADD A,A ; 4 bytes - ADD A,A ; per entry - LD C,A ; BC = Offset into table - ADD HL,BC ; Point to coefficient - CALL LOADFP ; Coefficient to BCDE - CALL FPMULT ; ; Multiply FPREG by coefficient - LD A,(SEED+1) ; Get (SEED+1) - INC A ; Add 1 - AND 00000011B ; 0 to 3 - LD B,0 - CP 1 ; Is it zero? - ADC A,B ; Yes - Make it 1 - LD (SEED+1),A ; Re-save seed - LD HL,RNDTAB-4 ; Addition table - ADD A,A ; 4 bytes - ADD A,A ; per entry - LD C,A ; BC = Offset into table - ADD HL,BC ; Point to value - CALL ADDPHL ; Add value to FPREG -RND1: CALL BCDEFP ; Move FPREG to BCDE - LD A,E ; Get LSB - LD E,C ; LSB = MSB - XOR 01001111B ; Fiddle around - LD C,A ; New MSB - LD (HL),80H ; Set exponent - DEC HL ; Point to MSB - LD B,(HL) ; Get MSB - LD (HL),80H ; Make value -0.5 - LD HL,SEED ; Random number seed - INC (HL) ; Count seed - LD A,(HL) ; Get seed - SUB 171 ; Do it modulo 171 - JP NZ,RND2 ; Non-zero - Ok - LD (HL),A ; Zero seed - INC C ; Fillde about - DEC D ; with the - INC E ; number -RND2: CALL BNORM ; Normalise number - LD HL,LSTRND ; Save random number - JP FPTHL ; Move FPREG to last and return - -RESEED: LD (HL),A ; Re-seed random numbers - DEC HL - LD (HL),A - DEC HL - LD (HL),A - JP RND1 ; Return RND seed - -RNDTAB: DB 068H,0B1H,046H,068H ; Table used by RND - DB 099H,0E9H,092H,069H - DB 010H,0D1H,075H,068H - -COS: LD HL,HALFPI ; Point to PI/2 - CALL ADDPHL ; Add it to PPREG -SIN: CALL STAKFP ; Put angle on stack - LD BC,8349H ; BCDE = 2 PI - LD DE,0FDBH - CALL FPBCDE ; Move 2 PI to FPREG - POP BC ; Restore angle - POP DE - CALL DVBCDE ; Divide angle by 2 PI - CALL STAKFP ; Put it on stack - CALL INT ; Get INT of result - POP BC ; Restore number - POP DE - CALL SUBCDE ; Make it 0 <= value < 1 - LD HL,QUARTR ; Point to 0.25 - CALL SUBPHL ; Subtract value from 0.25 - CALL TSTSGN ; Test sign of value - SCF ; Flag positive - JP P,SIN1 ; Positive - Ok - CALL ROUND ; Add 0.5 to value - CALL TSTSGN ; Test sign of value - OR A ; Flag negative -SIN1: PUSH AF ; Save sign - CALL P,INVSGN ; Negate value if positive - LD HL,QUARTR ; Point to 0.25 - CALL ADDPHL ; Add 0.25 to value - POP AF ; Restore sign - CALL NC,INVSGN ; Negative - Make positive - LD HL,SINTAB ; Coefficient table - JP SUMSER ; Evaluate sum of series - -HALFPI: DB 0DBH,00FH,049H,081H ; 1.5708 (PI/2) - -QUARTR: DB 000H,000H,000H,07FH ; 0.25 - -SINTAB: DB 5 ; Table used by SIN - DB 0BAH,0D7H,01EH,086H ; 39.711 - DB 064H,026H,099H,087H ;-76.575 - DB 058H,034H,023H,087H ; 81.602 - DB 0E0H,05DH,0A5H,086H ;-41.342 - DB 0DAH,00FH,049H,083H ; 6.2832 - -TAN: CALL STAKFP ; Put angle on stack - CALL SIN ; Get SIN of angle - POP BC ; Restore angle - POP HL - CALL STAKFP ; Save SIN of angle - EX DE,HL ; BCDE = Angle - CALL FPBCDE ; Angle to FPREG - CALL COS ; Get COS of angle - JP DIV ; TAN = SIN / COS - -ATN: CALL TSTSGN ; Test sign of value - CALL M,NEGAFT ; Negate result after if -ve - CALL M,INVSGN ; Negate value if -ve - LD A,(FPEXP) ; Get exponent - CP 81H ; Number less than 1? - JP C,ATN1 ; Yes - Get arc tangnt - LD BC,8100H ; BCDE = 1 - LD D,C - LD E,C - CALL DVBCDE ; Get reciprocal of number - LD HL,SUBPHL ; Sub angle from PI/2 - PUSH HL ; Save for angle > 1 -ATN1: LD HL,ATNTAB ; Coefficient table - CALL SUMSER ; Evaluate sum of series - LD HL,HALFPI ; PI/2 - angle in case > 1 - RET ; Number > 1 - Sub from PI/2 - -ATNTAB: DB 9 ; Table used by ATN - DB 04AH,0D7H,03BH,078H ; 1/17 - DB 002H,06EH,084H,07BH ;-1/15 - DB 0FEH,0C1H,02FH,07CH ; 1/13 - DB 074H,031H,09AH,07DH ;-1/11 - DB 084H,03DH,05AH,07DH ; 1/9 - DB 0C8H,07FH,091H,07EH ;-1/7 - DB 0E4H,0BBH,04CH,07EH ; 1/5 - DB 06CH,0AAH,0AAH,07FH ;-1/3 - DB 000H,000H,000H,081H ; 1/1 - - -ARET: RET ; A RETurn instruction - -CLS: LD A,016H ; ASCII Clear screen - JP PRNT ; Output character - -WIDTH: CALL GETINT ; Get integer 0-255 - LD A,E ; Width to A - LD (LWIDTH),A ; Set width - RET - -LINES: CALL GETNUM ; Get a number - CALL DEINT ; Get integer -32768 to 32767 - LD (LINESC),DE ; Set lines counter - LD (LINESN),DE ; Set lines number - RET - -DEEK: CALL DEINT ; Get integer -32768 to 32767 - PUSH DE ; Save number - POP HL ; Number to HL - LD B,(HL) ; Get LSB of contents - INC HL - LD A,(HL) ; Get MSB of contents - JP ABPASS ; Return integer AB - -DOKE: CALL GETNUM ; Get a number - CALL DEINT ; Get integer -32768 to 32767 - PUSH DE ; Save address - CALL CHKSYN ; Make sure ',' follows - DB ',' - CALL GETNUM ; Get a number - CALL DEINT ; Get integer -32768 to 32767 - EX (SP),HL ; Save value,get address - LD (HL),E ; Save LSB of value - INC HL - LD (HL),D ; Save MSB of value - POP HL ; Restore code string address - RET - - - ; HEX$(nn) Convert 16 bit number to Hexadecimal string - -HEX: CALL TSTNUM ; Verify it's a number - CALL DEINT ; Get integer -32768 to 32767 - PUSH BC ; Save contents of BC - LD HL,PBUFF - LD A,D ; Get high order into A - CP 000H - JR Z,HEX2 ; Skip output if both high digits are zero - CALL BYT2ASC ; Convert D to ASCII - LD A,B - CP '0' - JR Z,HEX1 ; Don't store high digit if zero - LD (HL),B ; Store it to PBUFF - INC HL ; Next location -HEX1: LD (HL),C ; Store C to PBUFF+1 - INC HL ; Next location -HEX2: LD A,E ; Get lower byte - CALL BYT2ASC ; Convert E to ASCII - LD A,D - CP 000H - JR NZ,HEX3 ; If upper byte was not zero then always print lower byte - LD A,B - CP '0' ; If high digit of lower byte is zero then don't print - JR Z,HEX4 -HEX3: LD (HL),B ; to PBUFF+2 - INC HL ; Next location -HEX4: LD (HL),C ; to PBUFF+3 - INC HL ; PBUFF+4 to zero - XOR A ; Terminating character - LD (HL),A ; Store zero to terminate - INC HL ; Make sure PBUFF is terminated - LD (HL),A ; Store the double zero there - POP BC ; Get BC back - LD HL,PBUFF ; Reset to start of PBUFF - JP STR1 ; Convert the PBUFF to a string and return it - -BYT2ASC LD B,A ; Save original value - AND 00FH ; Strip off upper nybble - CP 00AH ; 0-9? - JR C,ADD30 ; If A-F, add 7 more - ADD A,007H ; Bring value up to ASCII A-F -ADD30 ADD A,030H ; And make ASCII - LD C,A ; Save converted char to C - LD A,B ; Retrieve original value - RRCA ; and Rotate it right - RRCA - RRCA - RRCA - AND 00FH ; Mask off upper nybble - CP 00AH ; 0-9? < A hex? - JR C,ADD301 ; Skip Add 7 - ADD A,007H ; Bring it up to ASCII A-F -ADD301 ADD A,030H ; And make it full ASCII - LD B,A ; Store high order byte - RET - - ; Convert "&Hnnnn" to FPREG - ; Gets a character from (HL) checks for Hexadecimal ASCII numbers "&Hnnnn" - ; Char is in A, NC if char is ;<=>?@ A-z, CY is set if 0-9 -HEXTFP EX DE,HL ; Move code string pointer to DE - LD HL,00000H ; Zero out the value - CALL GETHEX ; Check the number for valid hex - JP C,HXERR ; First value wasn't hex, HX error - JR HEXLP1 ; Convert first character -HEXLP CALL GETHEX ; Get second and addtional characters - JR C,HEXIT ; Exit if not a hex character -HEXLP1 ADD HL,HL ; Rotate 4 bits to the left - ADD HL,HL - ADD HL,HL - ADD HL,HL - OR L ; Add in D0-D3 into L - LD L,A ; Save new value - JR HEXLP ; And continue until all hex characters are in - -GETHEX INC DE ; Next location - LD A,(DE) ; Load character at pointer - CP ' ' - JP Z,GETHEX ; Skip spaces - SUB 030H ; Get absolute value - RET C ; < "0", error - CP 00AH - JR C,NOSUB7 ; Is already in the range 0-9 - SUB 007H ; Reduce to A-F - CP 00AH ; Value should be $0A-$0F at this point - RET C ; CY set if was : ; < = > ? @ -NOSUB7 CP 010H ; > Greater than "F"? - CCF - RET ; CY set if it wasn't valid hex - -HEXIT EX DE,HL ; Value into DE, Code string into HL - LD A,D ; Load DE into AC - LD C,E ; For prep to - PUSH HL - CALL ACPASS ; ACPASS to set AC as integer into FPREG - POP HL - RET - -HXERR: LD E,HX ; ?HEX Error - JP BERROR - - ; BIN$(NN) Convert integer to a 1-16 char binary string -BIN: CALL TSTNUM ; Verify it's a number - CALL DEINT ; Get integer -32768 to 32767 -BIN2: PUSH BC ; Save contents of BC - LD HL,PBUFF - LD B,17 ; One higher than max char count -ZEROSUP: ; Suppress leading zeros - DEC B ; Max 16 chars - LD A,B - CP 001H - JR Z,BITOUT ; Always output at least one character - RL E - RL D - JR NC,ZEROSUP - JR BITOUT2 -BITOUT: - RL E - RL D ; Top bit now in carry -BITOUT2: - LD A,'0' ; Char for '0' - ADC A,0 ; If carry set then '0' --> '1' - LD (HL),A - INC HL - DEC B - JR NZ,BITOUT - XOR A ; Terminating character - LD (HL),A ; Store zero to terminate - INC HL ; Make sure PBUFF is terminated - LD (HL),A ; Store the double zero there - POP BC - LD HL,PBUFF - JP STR1 - - ; Convert "&Bnnnn" to FPREG - ; Gets a character from (HL) checks for Binary ASCII numbers "&Bnnnn" -BINTFP: EX DE,HL ; Move code string pointer to DE - LD HL,00000H ; Zero out the value - CALL CHKBIN ; Check the number for valid bin - JP C,BINERR ; First value wasn't bin, HX error -BINIT: SUB '0' - ADD HL,HL ; Rotate HL left - OR L - LD L,A - CALL CHKBIN ; Get second and addtional characters - JR NC,BINIT ; Process if a bin character - EX DE,HL ; Value into DE, Code string into HL - LD A,D ; Load DE into AC - LD C,E ; For prep to - PUSH HL - CALL ACPASS ; ACPASS to set AC as integer into FPREG - POP HL - RET - - ; Char is in A, NC if char is 0 or 1 -CHKBIN: INC DE - LD A,(DE) - CP ' ' - JP Z,CHKBIN ; Skip spaces - CP '0' ; Set C if < '0' - RET C - CP '2' - CCF ; Set C if > '1' - RET - -BINERR: LD E,BN ; ?BIN Error - JP BERROR - -JJUMP1: LD IX,-1 ; Flag cold start - JP CSTART ; Go and initialise - - ; Restored SCREEN command updated for the MZ80A. - ; The MZ80A uses 0,0 -> COLW-1,ROW-1 addressing as opposed to the NASCOM 1,1 -> 48,16 - ; -SCREEN: CALL GETINT ; Get integer 0 to 255 - PUSH AF ; Save column - CALL CHKSYN ; Make sure "," follows - DB "," - CALL GETINT ; Get integer 0 to 255 - POP BC ; Column to B - PUSH HL ; Save code string address - PUSH BC ; Save column - CALL SCRADR ; Set screen coordinates. - POP HL ; Rstore code string address - RET - -SCRADR: LD B,A ; Line and column to BC once checked. - OR A ; Test it - JP Z,FCERR ; Zero - ?FC Error - CP ROW+1 ; Number of lines - JP P,FCERR ; > Number of lines then ?FC Error - DEC B ; Sharp uses 0,0 addressing so once value verified, decrement. - POP DE ; RETurn address - POP AF ; Get column - PUSH DE ; Re-save RETurn - LD C,A ; Column to DE - OR A ; Test it - JP Z,FCERR ; Zero - ?FC Error - CP COLW+1 ; Number of characters per line - JP P,FCERR ; > number of characters then ?FC Error - DEC C ; Sharp uses 0,0 addressing. - LD (DSPXY),BC ; Save coordinates. - RET - -ARETN: RETN ; Return from NMI - -TSTBIT: PUSH AF ; Save bit mask - AND B ; Get common bits - POP BC ; Restore bit mask - CP B ; Same bit set? - LD A,0 ; Return 0 in A - RET - -OUTNCR: CALL OUTC ; Output character in A - JP PRNTCRLF ; Output CRLF - - ; Command to enable/disable the ANSI Terminal emulator. -SETANSITERM:CALL GETINT - CP 2 ; Can only have 0 or 1. - JR NC,SETANSIERR - LD (ANSIENABLE),A ; Update the flag. - RET -SETANSIERR: LD E,BV ; ?BV Error - JP BERROR ; Yes - output "?BV Error" - - - ;---------------------------------------- - ; TZFS Commands. - ;---------------------------------------- -OPTIONS0C: IF BUILD_TZFS = 1 - - ; Method to load BASIC text program. -LOAD: LD A,TAPELOAD ; Set the type of operation into the flag var. - JR CLOAD0 - - ; Method to load a cassette image (tokenised basic script). - ; -CLOADTZ: LD A,CTAPELOAD ; Set the type of operatiom into the flag var. -CLOAD0: LD (TPFLAG),A - LD A,(HL) ; Get byte after "CLOAD" - ; CP ZTIMES ; "*" token? ("CLOAD*") - ; JP Z,ARRLD1 ; Yes - Array load - SUB ZPRINT ; "?" ("PRINT" token) Verify? - JP Z,FLGVERTZ ; Yes - Flag "verify" - XOR A ; Flag "load" - DB 01H ; Skip "CPL" and "INC HL" -FLGVERTZ: CPL ; Flag "verify" - INC HL ; Skip over "?" - PUSH AF ; Save verify flag - DEC HL ; DEC 'cos GETCHR INCs - CALL GETCHR ; Get next character - LD A,0 ; Any file will do - JP Z,SDNONAM ; No name given - error. - CALL EVAL ; Evaluate expression - CALL GTFLNM ; Get file name - POP AF - OR A - JP NZ,SDVERF - ; - LD HL,TZSVC_FILENAME ; Set the filename to be loaded. - LD A,(TMSTPL) - CP TZSVCFILESZ ; Check size of filename, cant be more than an MZF name of 17 chars. - JP NC,SDFNTG - LD B,A -CLOADTZ1: LD A,(DE) ; Copy filename into service record. - LD (HL),A - INC DE - INC HL - DJNZ CLOADTZ1 - XOR A - LD (HL),A ; Terminate filename. - ; - CALL CLRPTR ; Initialise memory to NEW state ready for program load. - LD A,(TPFLAG) ; What are we processing, cassette image or text? - CP CTAPELOAD - JR Z,CLOADTZ2 ; Is this a cassette image load? - CALL LDTXT ; BASIC text load. - JR SDLOADE -CLOADTZ2: SCF - CALL PRCFIL ; Process file as a load request. - PUSH HL - LD HL,(BASTXT) ; Get start of program memory. - LD BC,(TZSVC_LOADSIZE) ; Get the actual load size. - ADD HL,BC ; Find the end. - XOR A - LD (HL),A ; Last two bytes are xeroed as they are for the next line number. - INC HL - LD (HL),A - INC HL - LD (PROGND),HL ; Set it as the end of program memory. - POP HL - JR SDLOADE ; Exit and tidy up. - -SDVERF: -SDLOADE: LD HL,OKMSG ; "Ok" message - CALL PRS ; Output string - JP SETPTR ; Set up line pointers - - ; Methods to open, read and close an SD file for retrieval of basic program data. Cassette files are read/written - ; directly to memory by the K64F but text files, as they are being expanded/compressed, need to be read/written - ; sector by sector. -LDOPEN: XOR A - LD (TZSVC_FILE_SEC),A ; Starting sector number of file to load. - LD A,TZSVC_FTYPE_BAS ; Type of file is CASsette, the K64F will know how to handle it. - LD (TZSVC_FILE_TYPE),A - LD A,TZSVC_CMD_READFILE - CALL SVC_CMD ; And make communications wit the I/O processor, returning with the required record. - OR A ; Zero means no physical error occurred. - JP NZ, SDOPER ; Open error, K64F didint respond, cannot read! - LD A,(TZSVCRESULT) ; Check the result from the K64F, non zero is an error. - OR A - JP NZ, SDOPER ; Same thing, if K64F processes request and returns an error, open or read problem! - LD HL,TZSVCSECTOR ; Start at beginning of sector. - LD (SECTPOS),HL - RET - -LDCLOSE: LD A,TZSVC_CMD_CLOSE ; Close file. - CALL SVC_CMD ; And make communications wit the I/O processor, returning with the required record. - OR A ; Zero means no physical error occurred. - JP NZ, SDCLER ; Close error, K64F didint respond, cannot close the file. - LD A,(TZSVCRESULT) ; Check the result from the K64F, non zero is an error. - OR A - JP NZ, SDCLER ; Same thing, if K64F closes file and returns an error, closing problem (SD removed!)! - RET - -LDBUF: LD A,(TZSVC_FILE_SEC) ; Update the virtual file sector number so the K64F knows what to read. - INC A - LD (TZSVC_FILE_SEC),A - LD A, TZSVC_CMD_NEXTREADFILE - CALL SVC_CMD ; And make communications with the I/O processor, returning with the required record. - OR A ; Zero means no physical error occurred. - JP NZ, SDRDER ; Write error, K64F didint respond, cannot write so flag as error! - LD A,(TZSVCRESULT) ; Check the result from the K64F, non zero is an error. - OR A - JP NZ, SDRDER ; Same thing, if K64F read from file returns an error, read error (SD removed or disk error!)! - RET - - ; Method to load a BASIC program which is stored as TEXT into memory. This is accomplied sector by sector, line by line, - ; each line needs to be read, tokenised and stored. - ; -LDTXT: CALL LDOPEN ; Open file, read the first sector of data. - LD HL,(PROGND) ; After reset the pointer points to the first line number not the first address - DEC HL ; Update it to keep the later logic more simple. - DEC HL - LD (PROGND),HL - ; -LDTXT0: LD HL,(TZSVC_LOADSIZE) ; Get size of sector loaded. - LD BC,TZSVCSECTOR ; Address of sector - ADD HL,BC ; End of sector address - PUSH HL - POP BC ; BC contains sector end address. - LD HL,(SECTPOS) ; Get position in sector for next line. - LD DE,STACKE ; Copy line into temporary area in case we span sectors. -LDTXT1: PUSH HL - OR A - SBC HL,BC ; So long as the end sector address is greater than the pointer we will have carry. - POP HL - JR C,LDTXT2 ; Check that we havent got to the end of the current sector. - CALL LDBUF ; End of current sector so load new. - LD HL,(TZSVC_LOADSIZE) - LD A,H - OR L - JR Z,LDTXTE ; No bytes in sector means end of file,exit. - LD HL,TZSVCSECTOR ; Start at beginning of sector. -LDTXT2: LD A,(HL) ; Copy the string from the sector to the temporary area. - LD (DE),A - INC HL - CP CR - JR Z,LDTXT3 ; CR means EOS. - CP LF - JR Z,LDTXT3 ; LF means EOS. - INC DE - JR LDTXT1 -LDTXT3: LD A,(HL) ; If CR make sure any LF is wasted. - CP LF - JR NZ,LDTXT4 - INC HL -LDTXT4: LD (SECTPOS),HL - LD HL,STACKE ; Start of line to insert. - XOR A - LD (DE),A ; Terminate string, BASIC uses NULL terminated strings. - CALL ATOH ; Get line number into DE - PUSH DE ; Save line number - CALL CRUNCH ; Convert text to tokens. A returns with size of line in BUFFER. - LD L,C ; Length of string to L. - LD H,0 - LD BC,(PROGND) - PUSH BC - ADD HL,BC ; Find new end - LD (PROGND),HL ; Update end of program pointer - POP DE ; Get back old pointer. - EX DE,HL - LD (HL),E ; Set pointer to end of line. - INC HL - LD (HL),D - INC HL ; Move onto line number. - POP DE ; Get back line number, - LD (HL),E - INC HL - LD (HL),D ; Store line number. - INC HL ; HL now points to first location for tokenised line. - LD DE,BUFFER ; Copy buffer to program -LDMVBUF: LD A,(DE) ; Get source - LD (HL),A ; Save destinations - INC HL ; Next source - INC DE ; Next destination - OR A ; Done? - JP NZ,LDMVBUF ; No - Repeat - ; - JP LDTXT0 ; Get next line. -LDTXTE: CALL LDCLOSE ; Close file for exit. - RET - - ; Method to save BASIC text to file. - ; -SAVE: LD A,TAPESAVE ; Set the type of operation into the flag var. - JR CSAVE0 - - ; Method to save a cassette image (tokenised basic script). - ; -CSAVETZ: LD A,CTAPESAVE ; Set the type of operatiom into the flag var. -CSAVE0: LD (TPFLAG),A - ; - LD B,1 ; Flag "CSAVE" - ; CP ZTIMES ; "*" token? ("CSAVE*") - ; JP Z,ARRSV1 ; Yes - Array save - CALL EVAL ; Evaluate expression - PUSH HL - CALL GTFLNM ; Get file name - ; - LD HL,TZSVC_FILENAME ; Set the filename to be created. - LD A,(TMSTPL) - CP TZSVCFILESZ ; Check size of filename, cant be more than an MZF name of 17 chars. - JP NC,SDFNTG - LD B,A -CSAVE1: LD A,(DE) ; Copy filename into service record. - LD (HL),A - INC DE - INC HL - DJNZ CSAVE1 - XOR A - LD (HL),A ; Terminate filename. - ; - LD A,(TPFLAG) ; What are we processing, cassette image or text? - CP CTAPESAVE - JR Z,CSAVE2 ; Is this a cassette image save? - ; - PUSH DE - CALL SVOPEN ; Open the required file for writing. - CALL SVTXT ; Expand and save text into the file - CALL SVCLOSE ; Finish by closing file so no corruption occurs. - POP DE - JR CSAVEE -CSAVE2: SCF - CCF - CALL PRCFIL ; Process file as a save request. -CSAVEE: POP HL - RET - - - ; Methods to open, write and close an SD file for storage of basic program data. Cassette files are read/written - ; directly to memory by the K64F but text files, as they are being expanded/compressed, need to be read/written - ; sector by sector. - ; -SVOPEN: PUSH HL - XOR A - LD (TZSVC_FILE_SEC),A ; Starting sector number. - LD A,TZSVC_FTYPE_BAS ; Type of file is BASic, the K64F will know how to handle it. - LD (TZSVC_FILE_TYPE),A - LD HL,0 - LD (TZSVC_SAVESIZE),HL ; Initialise the sector size count. - POP HL - LD A,TZSVC_CMD_WRITEFILE - CALL SVC_CMD ; And make communications wit the I/O processor, returning with the required record. - OR A ; Zero means no physical error occurred. - JP NZ, SDCRER ; Create error, K64F didint respond, cannot write! - LD A,(TZSVCRESULT) ; Check the result from the K64F, non zero is an error. - OR A - JP NZ, SDCRER ; Same thing, if K64F processes request and returns an error, creation problem! - RET - -SVCLOSE: CALL SVBUF ; Flush out any unwritten data. - LD A,TZSVC_CMD_CLOSE ; Close file. - CALL SVC_CMD ; And make communications wit the I/O processor, returning with the required record. - OR A ; Zero means no physical error occurred. - JP NZ, SDCLER ; Close error, K64F didint respond, cannot write so flag as error! - LD A,(TZSVCRESULT) ; Check the result from the K64F, non zero is an error. - OR A - JP NZ, SDCLER ; Same thing, if K64F closes file and returns an error, closing problem (SD removed!)! - RET - -SVBUF: LD A, TZSVC_CMD_NEXTWRITEFILE - CALL SVC_CMD ; And make communications with the I/O processor, returning with the required record. - OR A ; Zero means no physical error occurred. - JP NZ, SDWRER ; Write error, K64F didint respond, cannot write so flag as error! - LD A,(TZSVCRESULT) ; Check the result from the K64F, non zero is an error. - OR A - JP NZ, SDWRER ; Same thing, if K64F write to file and returns an error, write error (SD removed or disk full!)! - LD A,(TZSVC_FILE_SEC) ; Update the virtual file sector number - INC A - LD (TZSVC_FILE_SEC),A - LD DE,0 - LD (TZSVC_SAVESIZE),DE ; Initialise to empty sector. - RET - - ; Methods to write into the SD sector a BASIC script as it is expanded into text. - ; -WRLINE: PUSH BC ; Convert line number in DE into text. - XOR A - LD B,80H+24 ; 24 bits - CALL RETINT ; Return the integer - CALL NUMASC ; Output line number in decimal - POP BC - LD HL,PBUFF ; Text version of line number now in PBUFF -WRLINE1: LD A,(HL) ; Loop and write to service command sector, 0 terminates string. - OR A - RET Z - CALL WRBUF - INC HL - JR WRLINE1 - -WRCRLF: LD A,CR ; Carriage return first. - CALL WRBUF - LD A,LF ; Now line feed. -WRBUF: PUSH HL ; Save as were using it. - PUSH DE - LD DE,(TZSVC_SAVESIZE) ; Get current pointer into sector for next char. - LD HL,TZSVCSECTOR ; Add in the absolute address of the service sector. - ADD HL,DE - LD (HL),A ; Save at correct location. - ; CALL PRNT ; Print out what is being saved, debug! - INC DE - LD (TZSVC_SAVESIZE),DE ; Update the sector location for next byte. - LD A,D - CP 2 ; Test to see if buffer full. Hard coded 512 byte msb as Glass isnt resolving shift right correctly. - JR NZ,WRBUF1 - CALL SVBUF ; Save the buffer. - ; Write out buffer. -WRBUF1: POP DE - POP HL ; Restore and get out. - RET - - - ; Method to save the current program in memory to SD card as text. - ; This is the most common way of working with basic scripts, the cassette - ; image type offers speed but in this day and age it is not so much needed. - ; -SVTXT: LD DE,0 - CALL SRCHLN ; Search for line number in DE - PUSH BC ; Save address of line - CALL SETLIN ; Set up lines counter - JR SVTXT1 ; Skip CR on first line. -SVTXT0: CALL WRCRLF ; Write CRLF to buffer. -SVTXT1: POP HL ; Restore address of line - LD C,(HL) ; Get LSB of next line - INC HL - LD B,(HL) ; Get MSB of next line - INC HL - LD A,B ; BC = 0 (End of program)? - OR C - RET Z ; Yes - finish save. - CALL SVCNT ; Count lines - PUSH BC ; Save address of next line - LD E,(HL) ; Get LSB of line number - INC HL - LD D,(HL) ; Get MSB of line number - INC HL - PUSH HL ; Save address of line start - CALL WRLINE ; Write out the line number. - LD A,' ' ; Space after line number - POP HL ; Restore start of line address -SVTXT2: CALL WRBUF ; Output character in A -SVTXT3: LD A,(HL) ; Get next byte in line - OR A ; End of line? - INC HL ; To next byte in line - JP Z,SVTXT0 ; Yes - get next line - JP P,SVTXT2 ; No token - output it - SUB ZEND-1 ; Find and output word - LD C,A ; Token offset+1 to C - LD DE,WORDS ; Reserved word list -SVTXT4: LD A,(DE) ; Get character in list - INC DE ; Move on to next - OR A ; Is it start of word? - JP P,SVTXT4 ; No - Keep looking for word - DEC C ; Count words - JP NZ,SVTXT4 ; Not there - keep looking -SVTXT5: AND 01111111B ; Strip bit 7 - CALL WRBUF ; Output first character - LD A,(DE) ; Get next character - INC DE ; Move on to next - OR A ; Is it end of word? - JP P,SVTXT5 ; No - output the rest - JP SVTXT3 ; Next byte in line - -SVCNT: PUSH HL ; Save code string address - PUSH DE - LD HL,(LINESC) ; Get LINES counter - LD DE,-1 - ADC HL,DE ; Decrement - LD (LINESC),HL ; Put it back - POP DE - POP HL ; Restore code string address - RET P ; Return if more lines to go - PUSH HL ; Save code string address - LD HL,(LINESN) ; Get LINES number - LD (LINESC),HL ; Reset LINES counter - POP HL ; Restore code string address - JP SVCNT ; Keep on counting - - ; Method to process a cassette based file load/save. - ; The file is stored in a tokenised format and maintains a degree - ; of compatibility with NASCOM files. To use NASCOM files please - ; see the 'nasconv' tool which updates the tokens as this version - ; of BASIC adds additional commands which meant adjusting token values. - ; -PRCFIL: JR NC,PRCFIL1 - LD HL,(BASTXT) ; Get start of program memory. - LD (TZSVC_LOADADDR), HL - LD DE,(LSTRAM) - EX DE,HL - SBC HL,DE - LD (TZSVC_LOADSIZE),HL ; Place max size we can load into the service loadsize field. - LD A,TZSVC_CMD_LOADFILE - JR PRCFIL2 -PRCFIL1: LD DE,(BASTXT) ; Get start of program memory. - LD (TZSVC_SAVEADDR), DE - LD HL,(PROGND) ; End of program information - SBC HL,DE ; Get size of program. - LD (TZSVC_SAVESIZE),HL ; Store into service record. - LD A,TZSVC_CMD_SAVEFILE -PRCFIL2: PUSH AF ; Save service command to execute. - ; - ; Setup the service record for the file load/save. - ; - LD A,0FFh ; Tag the filenumber as invalid. - LD (TZSVC_FILE_NO), A - LD A,(TMSTPL) - CP TZSVCFILESZ ; Check size of filename, cant be more than an MZF name of 17 chars. - JP NC,SDFNTG - LD A,TZSVC_FTYPE_CAS ; Type of file is CASsette, the K64F will know how to handle it. - LD (TZSVC_FILE_TYPE),A - POP AF - CALL SVC_CMD ; And make communications wit the I/O processor, returning with the required record. - OR A ; Zero means no physical error occurred. - JR Z, PRCFIL3 - JP SDPHYER -PRCFIL3: LD A,(TZSVCRESULT) ; Check the result from the K64F, non zero is an error. - OR A - RET Z - LD A,(TZSVCCMD) - CP TZSVC_CMD_LOADFILE - JP Z,SDLDER - JP SDSVER - - ; Command to change the Z80 CPU frequency if running with the tranZPUter upgrade. -SETFREQ: CALL POSINT ; Get frequency in KHz - PUSH HL - ; - LD (TZSVC_CPU_FREQ),DE ; Set the required frequency in the service structure. - LD A,D - CP E - JR NZ,SETFREQ1 - LD A, TZSVC_CMD_CPU_BASEFREQ ; Switch to the base frequency. - JR SETFREQ2 -SETFREQ1: LD A, TZSVC_CMD_CPU_ALTFREQ ; Switch to the alternate frequency. -SETFREQ2: CALL SVC_CMD - OR A - JR NZ,SETFREQERR - LD A,D - CP E - JR Z,SETFREQ4 ; If we are disabling the alternate cpu frequency (ie. = 0) indicate success. - LD A, TZSVC_CMD_CPU_CHGFREQ ; Switch to the base frequency. - CALL SVC_CMD - OR A - JR NZ,SETFREQERR - LD HL, (TZSVC_CPU_FREQ) ; Get the actual frequency the K64F could create. - CALL PRNTHL ; Output amount of free memory - LD HL,FREQSET ; Output the actual frequency. -SETFREQ3: CALL PRS ; Output string - POP HL - RET -SETFREQ4: LD HL,FREQDEF ; Set to default. - JR SETFREQ3 - ; -SETFREQERR: LD HL,FREQERR - JP SDERR - - - ; Method to set the file search wildcard prior to requesting a directory listing. The I/O processor applies this filter only returning directories - ; which match the wildcard, ie. A* returns directories starting A... - ; - ; Inputs: - ; HL = Pointer to BASIC input line/ - ; - ; HL and B are not preserved. - -SETWILDCARD:LD DE, TZSVCWILDC ; Location of the wildcard filter in the service record. - LD B, TZSVCWILDSZ-1 - CALL GETSTRING ; Copy the string into the service record. - RET - - ; Command to set the current working directory on the SD card. -SETDIR: LD DE, TZSVC_DIRNAME ; Location of directory name in the service record. - LD B, TZSVCDIRSZ-1 - CALL GETSTRING ; Copy the string into the service record. - RET - - ; Method to print out the filename within an SD Card header. - ; The name may not be terminated as the full 17 chars are used, so this needs - ; to be checked. - ; - ; Input: DE = Address of filename. - ; -PRTFN: PUSH BC - LD B,TZSVCLONGFILESZ ; Maximum size of filename. -PRTMSG: LD A,(DE) - INC DE - CP 000H ; If there is a valid terminator, exit. - JR Z,PRTMSGE - CP 00DH - JR Z,PRTMSGE - CALL OUTC - DJNZ PRTMSG ; Else print until 17 chars have been processed. - CALL PRNTCRLF -PRTMSGE: POP BC - RET - - ; Method to print out an SDC directory entry name. - ; - ; Input: HL = Address of filename. - ; -PRTDIR: PUSH BC - PUSH DE - PUSH HL - ; - LD A,COLW ; At the moment only cater for 40/80 columns. - CP 80 - LD H,47 - JR NZ,PRTDIR0 - LD H,93 -PRTDIR0: LD A,(LINECNT) ; Pause if we fill the screen. - LD E,A - INC E - CP H - JR NZ,PRTNOWAIT - LD E, 0 -PRTDIRWAIT: CALL GETKY - CP ' ' - JR Z,PRTNOWAIT - CP 'X' ; Exit from listing. - LD A,001H - JR Z,PRTDIR4 - JR PRTDIRWAIT -PRTNOWAIT: LD A,E - LD (LINECNT),A - POP DE - PUSH DE ; Get pointer to the file name and print. - CALL PRTFN ; Print out the filename. - LD HL, (DSPXY) - LD A,L - CP 20 - LD A,20 - JR C, PRTDIR2 - LD A,COLW ; 40 Char mode? 2 columns of filenames displayed so NL. - CP 80 - JR NZ,PRTDIR1 - LD A,L ; 80 Char mode we print 4 columns of filenames. - CP 40 - LD A,40 - JR C, PRTDIR2 - LD A,L - CP 60 - LD A,60 - JR C, PRTDIR2 - ; -PRTDIR1: CALL PRNTCRLF - JR PRTDIR3 -PRTDIR2: LD L,A - LD (DSPXY),HL -PRTDIR3: XOR A -PRTDIR4: OR A - POP HL - POP DE - POP BC - RET - - ; Method to request a sector full of directory entries from the I/O processor. - ; - ; Inputs: - ; A = Director Sector number to request (set of directory entries in 512byte blocks). - ; Outputs: - ; A = 0 - success, directory sector filled. - ; A = 255 - I/O Error. - ; A > 1 - Result from I/O processor, which is normally the error code. - ; -SVC_GETDIR: PUSH AF - LD A, TZSVC_FTYPE_ALLFMT ; Setup the filetype so we retrieve all entries in the current directory. - LD (TZSVC_FILE_TYPE),A - POP AF - LD (TZSVCDIRSEC),A ; Save the sector number into the service structure. - OR A ; Sector is 0 then setup for initial read. - LD A, TZSVC_CMD_READDIR ; Readdir command opens the directory. The default directory and wildcard have either been placed in the - JR Z,SVC_GETD1 ; buffer by earlier commands or will be defaulted by the I/O processor. - LD A, TZSVC_CMD_NEXTDIR ; Request the next directory sector. The I/O processor either gets the next block or uses the TZSVCDIRSEC value. -SVC_GETD1: CALL SVC_CMD ; And make communications wit the I/O processor, returning with the required record. - OR A - LD A,255 ; Report I/O error as 255. - RET NZ - LD A,(TZSVCRESULT) - RET ; Return status to caller, 0 = success. - - ; Method to get an SD Directory entry. - ; The I/O processor communications structure uses a 512 byte sector to pass SD data. A sector is cached and each call evaluates if the required request is in cache, if it is not, - ; a new sector is read. - ; - ; Input: D = Directory entry number to retrieve. - ; Output: HL = Address of directory entry. - ; A = 0, no errors, A > 1 error. -GETSDDIRENT:PUSH BC - PUSH DE; - ; - LD A,D - SRL A - SRL A - SRL A - SRL A ; Divide by 16 to get sector number. - LD C,A - LD A,(TZSVCDIRSEC) ; Do we have this sector in the buffer? If we do, use it. - CP C - JR Z,GETDIRSD0 - LD A,C ; Retrieve the directory sector we need. - CALL SVC_GETDIR ; Read a sector full of directory entries.. - OR A - JR NZ,DIRSDERR - ; -GETDIRSD0: POP DE - PUSH DE - LD A,D ; Retrieve the directory entry number required. - AND 00FH - LD HL,TZSVCSECTOR - JR Z,GETDIRSD2 - LD B,A - LD DE,TZSVCDIR_ENTSZ ; Directory entry size -GETDIRSD1: ADD HL,DE ; Directory entry address into HL. - DJNZ GETDIRSD1 -GETDIRSD2: POP DE - POP BC - XOR A - RET - ; -DIRSDERR: POP DE ; Clean up stack. - POP BC - LD E,IO ; ?IO Error - JP BERROR ; Yes - output "?IO Error" - - - ; Method to list the directory of the SD Card. - ; - ; This method obtains a directory listing, either the default or from the search path given and lists it out. - ; No inputs or outputs. - ; -DIRSDCARD: CALL SETWILDCARD ; Setup any wildcard filter prior to processing. - PUSH HL - LD A,1 ; Setup screen for printing, account for the title line. LINECNT is used for page pause. - LD (LINECNT),A - LD A,0FFH - LD (TZSVCDIRSEC),A ; Reset the sector buffer in memory indicator, using 0xFF will force a reread.. - ; -DIRSD0: LD D,0 ; Directory entry number - LD B,0 -DIRSD1: CALL GETSDDIRENT ; Get SD Directory entry details for directory entry number stored in D. - JR NZ,DIRSD4 -DIRSD2: LD A,(HL) - INC HL - OR A - JR Z,DIRSD4 - CALL PRTDIR ; Valid entry so print directory number and name pointed to by HL. - JR NZ,DIRSD4 -DIRSD3: INC D ; Onto next directory entry number. - DJNZ DIRSD1 -DIRSD4: POP HL - RET - - ;-------------------------------------- - ; Error jump table for TZFS. - ;-------------------------------------- -SDNONAM: LD HL,SDBADFN ; Must give a name for SD card load and save. -SDERR: CALL PRS - POP AF ; Waste return address. - JP ERRIN -SDFNTG: LD HL,SDFNTOOG - JR SDERR -SDPHYER: LD HL,SDPHYERR - JR SDERR -SDLDER: LD HL,SDLOADERR - JR SDERR -SDSVER: LD HL,SDSAVEERR - JR SDERR -SDCRER: LD HL,SDCREATER - JR SDERR -SDCLER: LD HL,SDCLOSEER - JR SDERR -SDWRER: LD HL,SDWRITEER - JR SDERR -SDOPER: LD HL,SDOPENER - JR SDERR -SDRDER: LD HL,SDREADER - JR SDERR - - ;-------------------------------------- - ; Test Message table - ;-------------------------------------- -SDBADFN: DB "Filename missing!", CR, NUL -SDFNTOOG: DB "Filename too long!", CR, NUL -SDPHYERR: DB "SD/K64F IO error!", CR, NUL -SDLOADERR: DB "File loading error!", CR, NUL -SDSAVEERR: DB "File save error!", CR, NUL -SDCREATER: DB "File create error!", CR, NUL -SDCLOSEER: DB "File close error!", CR, NUL -SDWRITEER: DB "File write error!", CR, NUL -SDOPENER: DB "File open error!", CR, NUL -SDREADER: DB "File read error!", CR, NUL -FREQERR: DB "Failed to change frequency!", CR, NUL -FREQSET: DB " KHz set.", CR, LF, NUL -FREQDEF: DB "Set to default.", CR, LF, NUL - - ;---------------------------------------- - ; End of Options1 Code - TZFS Build - ;---------------------------------------- - ENDIF ; End of optional commands for use when a tranZPUter board is present. - - ;---------------------------------------- - ; RFS (TranZPUter board) Commands. - ;---------------------------------------- -OPTIONS1C: IF BUILD_RFSTZ = 1 - - - ;-------------------------------------- - ; Error jump table for TZ RFS. - ;-------------------------------------- -RFSNONAM: LD HL,RFSBADFN ; Must give a name for SD card load and save. -RFSERR: CALL PRS - POP AF ; Waste return address. - JP ERRIN -RFSFNTG: LD HL,RFSFNTOOG - JR RFSERR -RFSLDER: LD HL,RFSLOADERR - JR RFSERR -RFSSVER: LD HL,RFSSAVEERR - JR RFSERR - - ;-------------------------------------- - ; Test Message table - ;-------------------------------------- -RFSBADFN: DB "Filename missing!", CR, NUL -RFSFNTOOG: DB "Filename too long!", CR, NUL -RFSLOADERR: DB "File loading error!", CR, NUL -RFSSAVEERR: DB "File save error!", CR, NUL -RFSMSGLOAD: DB "Loading", NUL -RFSMSGOK: DB "Saved", CR, NUL - - ;---------------------------------------- - ; End of Options1 Code - TZ RFS Build - ;---------------------------------------- - ENDIF ; End of optional commands for use when a tranZPUter board is present. - - ;---------------------------------------- - ; RFS Commands. - ;---------------------------------------- -OPTIONS2C: IF BUILD_RFS = 1 - - ; Method to list the RFS Drive directory. - ; - ; Inputs: - ; HL = Pointer to BASIC input line/ - ; - ; HL and B are not preserved. - -SDDIRCMD: LD DE, NAME ; Use the CMT name header for the string. - PUSH DE - LD B, TZSVCFILESZ-1 ; Limit string size. - CALL GETSTRING ; Copy the string into the service record. - POP DE - PUSH HL - CALL CURSOROFF - CALL NL - CALL CMT_DIR - CALL NL - CALL CURSORON - POP HL - RET - - ;---------------------------------------- - ; End of Options2 Code - RFS Build - ;---------------------------------------- - ENDIF ; End of optional commands for standard RFS. - - ;---------------------------------------- - ; MZ80A Commands. - ;---------------------------------------- -OPTIONS3C: IF BUILD_MZ80A+BUILD_RFS+BUILD_RFSTZ > 0 - - ; Method to print out the filename within an SD Card header. - ; The name may not be terminated as the full 17 chars are used, so this needs - ; to be checked. - ; - ; Input: DE = Address of filename. - ; -PRTFN: PUSH BC - LD B,TZSVCLONGFILESZ ; Maximum size of filename. -PRTMSG: LD A,(DE) - INC DE - CP 000H ; If there is a valid terminator, exit. - JR Z,PRTMSGE - CP 00DH - JR Z,PRTMSGE - CALL OUTC - DJNZ PRTMSG ; Else print until 17 chars have been processed. - CALL PRNTCRLF -PRTMSGE: POP BC - RET - - ; Method to load a cassette image (tokenised basic script). - ; -CLOAD80A: LD A,CTAPELOAD ; Set the type of operatiom into the flag var. - LD (TPFLAG),A - LD A,(HL) ; Get byte after "CLOAD" - ; CP ZTIMES ; "*" token? ("CLOAD*") - ; JP Z,ARRLD1 ; Yes - Array load - SUB ZPRINT ; "?" ("PRINT" token) Verify? - JP Z,CMTVERF ; Yes - Flag "verify" - - PUSH HL - PUSH DE - XOR A - LD DE,NAME - LD (DE),A - CALL GETSTRING ; Check for no name, load next file. - POP DE - POP HL - LD A,B - OR A - JR Z,CLOAD80A_2 - - ; CALL GETCHR ; Get next character - ; LD A,0 ; Any file will do - ; JP Z,CMTNONAM ; No name given - error. - CALL EVAL ; Evaluate expression - CALL GTFLNM ; Get file name - ; - LD HL,NAME ; Set the filename to be loaded. - LD A,(TMSTPL) - CP TZSVCFILESZ ; Check size of filename, cant be more than an MZF name of 17 chars. - JP NC,CMTFNTG - LD B,A -CLOAD80A_1: LD A,(DE) ; Copy filename into service record. - LD (HL),A - INC DE - INC HL - DJNZ CLOAD80A_1 - XOR A - LD (HL),A ; Terminate filename. - ; -CLOAD80A_2: CALL CLRPTR ; Initialise memory to NEW state ready for program load. - ; - IF BUILD_RFS+BUILD_RFSTZ > 0 - ; RFS extensions, call the RFS API to execute extended code. - LD DE,NAME - CALL CNV_ATOS ; Convert filename to Sharp ASCII - CALL CMT_RDINF - ENDIF - IF BUILD_MZ80A = 1 - CALL ?RDI - ENDIF - JP C,CMTLDER - LD A,(ATRB) - CP ATR_BASIC_MSCAS ; Verify this is a NASCOM Cassette BASIC image. - JP NZ,CMTATER - ; - LD DE,CMTMSGLOAD ; Show we are loading a program. - CALL MONPRTSTR - LD DE,NAME - CALL PRTFN - LD DE,CMTMSGLOAD2 ; Show we are loading a program. - CALL MONPRTSTR - ; - LD HL,(BASTXT) ; Get start of program memory. - LD (DTADR),HL ; Place the load address into the header to take into account different basic versions with different addresses. - ; - IF BUILD_RFS+BUILD_RFSTZ > 0 - CALL CMT_RDDATA - ENDIF - IF BUILD_MZ80A = 1 - CALL ?RDD - ENDIF - JP C,CMTLDER - ; - LD HL,(BASTXT) ; Get start of program memory. - LD BC,(SIZE) ; Get the actual load size. - ADD HL,BC ; Find the end. - XOR A - LD (HL),A ; Last two bytes are xeroed as they are for the next line number. - INC HL - LD (HL),A - INC HL - LD (PROGND),HL ; Set it as the end of program memory. - ; -CMTVERF: -CMTLOADE: LD HL,OKMSG ; "Ok" message - CALL PRS ; Output string - JP SETPTR ; Set up line pointers - - ; Method to save a cassette image (tokenised basic script). - ; -CSAVE80A: LD A,CTAPESAVE ; Set the type of operatiom into the flag var. - LD (TPFLAG),A - ; - LD B,1 ; Flag "CSAVE" - ; CP ZTIMES ; "*" token? ("CSAVE*") - ; JP Z,ARRSV1 ; Yes - Array save - CALL EVAL ; Evaluate expression - PUSH HL - CALL GTFLNM ; Get file name - ; - LD HL,NAME ; Set the filename to be loaded. - LD A,(TMSTPL) - CP TZSVCFILESZ ; Check size of filename, cant be more than an MZF name of 17 chars. - JP NC,CMTFNTG - LD B,A -CSAVE80A_1: LD A,(DE) ; Copy filename into service record. - LD (HL),A - INC DE - INC HL - DJNZ CSAVE80A_1 - XOR A - LD (HL),A ; Terminate filename. - ; - LD A,ATR_BASIC_MSCAS ; Set attribute: MS BASIC Cassette - LD (ATRB),A - LD HL,(PROGND) ; Get the actual program size. - LD BC,(BASTXT) ; Get start of program memory. - XOR A - SBC HL,BC ; Find the size. - LD (SIZE),HL ; Size of basic program. - LD (DTADR),BC ; Start address of basic program. - LD HL,0 - LD (EXADR),HL ; Exec address is zero for a basic program. - - PUSH DE - IF BUILD_RFS+BUILD_RFSTZ > 0 - LD DE,NAME - CALL CNV_ATOS ; Convert filename from ASCII to Sharp ASCII - CALL CMT_WRINF - ENDIF - IF BUILD_MZ80A = 1 - ; No filename conversion as the RFS may not be available on a standard MZ-80A, user will have to use capitals. - CALL ?WRI ; Commence header write. - ENDIF - JP C,CMTSVER - IF BUILD_RFS+BUILD_RFSTZ > 0 - CALL CMT_WRDATA - ENDIF - IF BUILD_MZ80A = 1 - CALL ?WRD ; data - ENDIF - JR C,CMTSVER - LD HL,CMTMSGOK ; 'OK!' - CALL PRS - POP DE - POP HL - RET - - ; MZ80A specific commands. -OPTIONS3B: IF BUILD_MZ80A = 1 - ENDIF - - ;-------------------------------------- - ; Error jump table for MZ80A. - ;-------------------------------------- -CMTNONAM: LD HL,CMTBADFN ; Must give a name for SD card load and save. -CMTERR: CALL PRS - POP AF ; Waste return address. - JP ERRIN -CMTFNTG: LD HL,CMTFNTOOG - JR CMTERR -CMTLDER: LD HL,CMTLOADERR - JR CMTERR -CMTATER: LD HL,CMTATTRERR - JR CMTERR -CMTSVER: LD HL,CMTSAVEERR - JR CMTERR - - ;-------------------------------------- - ; Test Message table - ;-------------------------------------- -CMTBADFN: DB "Filename missing!", CR, NUL -CMTFNTOOG: DB "Filename too long!", CR, NUL -CMTLOADERR: DB "File loading error!", CR, NUL -CMTSAVEERR: DB "File save error!", CR, NUL -CMTATTRERR: DB "Not an MS-BASIC cassette file error!", CR, NUL -CMTMSGLOAD: DB "Loading \"", NUL -CMTMSGLOAD2:DB "\"", CR, NUL -CMTMSGOK: DB "Saved", CR, NUL - - ;---------------------------------------- - ; End of Options3 Code - MZ80A Build - ;---------------------------------------- - ENDIF - - -MONITR: -MONITR2 IF BUILD_TZFS+BUILD_RFSTZ > 0 - ; Switch memory back to TZFS mode. - LD A, TZMM_TZFS - OUT (MMCFG),A - ENDIF - JP REBOOT ; Restart (Normally Monitor Start) - - ;------------------------------------------------------------------------------- - ; TIMER INTERRUPT - ; - ; This is the RTC interrupt, which interrupts every 100msec. RTC is maintained - ; by keeping an in memory count of seconds past 00:00:00 and an AMPM flag. - ;------------------------------------------------------------------------------- -TIMIN: LD (SPISRSAVE),SP ; Use a seperate stack for the interrupt as the hardware is paged in and RAM paged out. - LD SP,ISRSTACK - ; - PUSH AF ; Save used registers. - PUSH BC - PUSH DE - PUSH HL - ; -MEMSW2: IF BUILD_TZFS+BUILD_RFSTZ > 0 - LD A,TZMM_MZ700_0 ; We meed to be in memory mode 10 to process the interrupts as this allows us access to the hardware. - OUT (MMCFG),A - ENDIF - ; - ; Reset the interrupt counter. - LD HL,CONTF ; CTC Control register, set to reload the 100ms interrupt time period. - LD (HL),080H ; Select Counter 2, latch counter, read lsb first, mode 0 and binary. - PUSH HL - DEC HL - LD E,(HL) - LD D,(HL) ; Obtain the overrun count if any (due to disabled interrupts). - LD HL, 00001H ; Add full range to count to obtain the period of overrun time. - SBC HL,DE - EX DE,HL - POP HL - LD (HL),0B0H ; Select Counter 2, load lsb first, mode 0 interrupt on terminal count, binary - DEC HL - LD (HL),TMRTICKINTV - LD (HL),000H ; Another 100msec delay till next interrupt. - ; - ; Update the RTC with the time period. - LD HL,(TIMESEC) ; Lower 16bits of counter. - ADD HL,DE - LD (TIMESEC),HL - JR NC,TIMIN1 ; On overflow we increment middle 16bits. - ; - LD HL,(TIMESEC+2) - INC HL - LD (TIMESEC+2),HL - LD A,H - OR L - JR NZ,TIMIN1 ; On overflow we increment upper 16bits. - ; - LD HL,(TIMESEC+4) - INC HL - LD (TIMESEC+4),HL - - ; - ; Flash a cursor at the current XY location. - ; -TIMIN1: LD HL,FLASHCTL - BIT 7,(HL) ; Is cursor enabled? If it isnt, skip further processing. - JR Z,TIMIN3 - ; -FLSHCTL0: LD A,(KEYPC) ; Flashing component, on each timer tick, display the cursor or the original screen character. - LD C,A - XOR (HL) ; Detect a cursor change signal. - RLCA - RLCA - JR NC,TIMIN3 ; No change, skip. - - RES 6,(HL) - LD A,C ; We know there was a change, so decide what to display and write to screen. - RLCA - RLCA - LD A,(FLASH) - JR NC,FLSHCTL1 - SET 6,(HL) ; We are going to display the cursor, so save the underlying character. - LD A,(FLSDT) ; Retrieve the cursor character. -FLSHCTL1: LD HL,(DSPXYADDR) ; Load the desired cursor or character onto the screen. - LD (HL),A - - ; - ; Keyboard processing. - ; -TIMIN3: ; Perform keyboard sweep - inline to avoid overhead of a call. - ; KEYBOARD SWEEP - ; - ; EXIT B,D7=0 NO DATA - ; =1 DATA - ; D6=0 SHIFT OFF - ; =1 SHIFT ON - ; C = ROW & COLUMN - ; -SWEP: XOR A - LD (KDATW),A ; Reset key counter - LD B,0FAH ; Starting scan line, D3:0 = scan = line 10. D5:4 not used, D7=Cursor flash. - LD D,A - - ; BREAK TEST - ; BREAK ON : ZERO = 1 - ; OFF : ZERO = 0 - ; NO KEY : CY = 0 - ; KEY IN : CY = 1 - ; A D6=1: SHIFT ON - ; =0: SHIFT OFF - ; D5=1: CTRL ON - ; =0: CTRL OFF - ; D4=1: GRAPH ON - ; =0: GRAPH OFF -BREAK: LD A,0F0H - LD (KEYPA),A ; Port A scan line 0 - NOP - LD A,(KEYPB) ; Read back key data. - OR A - RLA - JR NC,BREAK3 ; CTRL/BREAK key pressed? - RRA - RRA ; Check if SHIFT key pressed/ - JR NC,BREAK1 ; SHIFT BREAK not pressed, jump. - RRA - JR NC,BREAK2 ; Check for GRAPH. - CCF - JR SWEP6 ;SWEP1 - -BREAK1: LD A,040H ; A D6=1 SHIFT ON - SCF - JR SWEP6 - -BREAK2: LD A,001H ; No keys found to be pressed on scanline 0. - LD (KDATW),A - LD A,010H ; A D4=1 GRAPH - SCF - JR SWEP6 - -BREAK3: AND 006H ; SHIFT + GRAPH + BREAK? - JR Z,SWEP1A - AND 002H ; SHIFT ? - JR Z,SWEP1 ; Z = 1 = SHIFT BREAK pressed/ - LD A,020H ; A D5=1 CTRL - SCF - JR SWEP6 - -SWEP1: LD D,088H ; Break ON - JR SWEP9 -SWEP1A: JP REBOOT ; Shift + Graph + Break ON = RESET. - ; -SWEP6: LD HL,SWPW - PUSH HL - JR NC,SWEP11 - LD D,A - AND 060H ; Shift & Ctrl =no data. - JR NZ,SWEP11 - LD A,D ; Graph Check - XOR (HL) - BIT 4,A - LD (HL),D - JR Z,SWEP0 -SWEP01: SET 7,D ; Data available, set flag. -SWEP0: DEC B - POP HL ; SWEP column work - INC HL - LD A,B - LD (KEYPA),A ; Port A (8255) D3:0 = Scan line output. - CP 0F0H - JR NZ,SWEP3 ; If we are not at scan line 0 then check for key data. - LD A,(HL) ; SWPW - CP 003H ; Have we scanned all lines, if yes then no data? - JR C,SWEP9 - LD (HL),000H ; - RES 7,D ; Reset data in as no data awailable. -SWEP9: LD B,D - JR ISRKEY0 - -SWEP11: LD (HL),000H - JR SWEP0 -SWEP3: LD A,(KEYPB) ; Port B (8255) D7:0 = Key data in for given scan line. - LD E,A - CPL - AND (HL) - LD (HL),E - PUSH HL - LD HL,KDATW - PUSH BC - LD B,008H -SWEP8: RLC E - JR C,SWEP7 - INC (HL) -SWEP7: DJNZ SWEP8 - POP BC - OR A - JR Z,SWEP0 - LD E,A -SWEP2: LD H,008H - LD A,B - DEC A ; TBL adjust - AND 00FH - RLCA - RLCA - RLCA - LD C,A - LD A,E -SWEP12: DEC H - RRCA - JR NC,SWEP12 - LD A,H - ADD A,C - LD C,A - JP SWEP01 - -ISRKEY0: LD A,B - RLCA - JP C,ISRKEY2 ; CY=1 then data available. - LD HL,KDATW - LD A,(HL) ; Is a key being held down? - OR A - JR NZ, ISRAUTORPT ; It is so process as an auto repeat key. - XOR A - LD (KEYRPT),A ; No key held then clear the auto repeat initial pause counter. - LD A,NOKEY ; No key code. -ISRKEY1: LD HL,KDATW - LD E,A - LD A,(HL) ; Current key scan line position. - INC HL - LD D,(HL) ; Previous key position. - LD (HL),A ; Previous <= current - SUB D ; Are they the same? - JR NC,ISRKEY11 - INC (HL) ; -ISRKEY11: LD A,E -ISRKEY10: CP NOKEY - JR Z,ISREXIT - LD (KEYLAST),A -ISRKEYRPT: LD A,(KEYCOUNT) ; Get current count of bytes in the keyboard buffer. - CP KEYBUFSIZE - 1 - JR NC, ISREXIT ; Keyboard buffer full, so waste character. - INC A - LD (KEYCOUNT),A - LD HL,(KEYWRITE) ; Get the write buffer pointer. - LD (HL), E ; Store the character. - INC L - LD A,L - AND KEYBUFSIZE-1 ; Circular buffer, keep boundaries. - LD L,A - LD (KEYWRITE),HL ; Store updated pointer. - ; -ISREXIT: -MEMSW3: IF BUILD_TZFS+BUILD_RFSTZ > 0 - LD A,TZMM_MZ700_2 ; Return to the full 64K memory mode. - OUT (MMCFG),A - ENDIF - ; - POP HL - POP DE - POP BC - POP AF - ; - LD SP,(SPISRSAVE) - EI - RET - - ; - ; Helper to determine if a key is being held down and autorepeat should be applied. - ; The criterion is a timer, if this expires then autorepeat is applied. - ; -ISRAUTORPT: LD A,(KEYRPT) ; Increment an initial pause counter. - INC A - CP 10 - JR C,ISRAUTO1 ; Once expired we can auto repeat the last key. - LD A,(KEYLAST) - CP 080H - JR NC,ISREXIT ; Dont auto repeat control keys. - LD E,A - JR ISRKEYRPT -ISRAUTO1: LD (KEYRPT),A - JR ISREXIT - - ; - ; Method to alternate through the 3 shift modes, CAPSLOCK=1, SHIFTLOCK=2, NO LOCK=0 - ; -LOCKTOGGLE: LD HL,FLSDT - LD A,(SFTLK) - INC A - CP 3 - JR C,LOCK0 - XOR A -LOCK0: LD (SFTLK),A - OR A - LD (HL),043H ; Thick block cursor when lower case. - JR Z,LOCK1 - CP 1 - LD (HL),03EH ; Thick underscore when CAPS lock. - JR Z,LOCK1 - LD (HL),0EFH ; Block cursor when SHIFT lock. -LOCK1: JP ISREXIT - - -ISRKEY2: RLCA - RLCA - RLCA - JP C,LOCKTOGGLE ; GRAPH key which acts as the Shift Lock. - RLCA - JP C,ISRBRK ; BREAK key. - LD H,000H - LD L,C - LD A,C - CP 038H ; TEN KEY check. - JR NC,ISRKEY6 ; Jump if TENKEY. - LD A,B - RLCA - LD B,A - LD A,(SFTLK) - OR A - LD A,B - JR Z,ISRKEY14 - RLA - CCF - RRA -ISRKEY14: RLA - RLA - JR NC,ISRKEY3 -ISRKEY15: LD DE,KTBLC -ISRKEY5: ADD HL,DE - LD A,(HL) - JP ISRKEY1 - -ISRKEY3: RRA - JR NC,ISRKEY6 - LD A,(SFTLK) - CP 1 - LD DE,KTBLCL - JR Z,ISRKEY5 - LD DE,KTBLS - JR ISRKEY5 - -ISRKEY6: LD DE,KTBL - JR ISRKEY5 -ISRKEY4: RLCA - RLCA - JR C,ISRKEY15 - LD DE,KTBL - JR ISRKEY5 - - ; Break key pressed, handled in getkey routine. -ISRBRK: LD A,(KEYLAST) - CP BREAKKEY - JP Z,ISREXIT - XOR A ; Reset the keyboard buffer. - LD (KEYCOUNT),A - LD HL,KEYBUF - LD (KEYWRITE),HL - LD (KEYREAD),HL - LD A,BREAKKEY - JP ISRKEY10 - - -KTBL: ; Strobe 0 - DB '"' - DB '!' - DB 'W' - DB 'Q' - DB 'A' - DB INSERT - DB 0 - DB 'Z' - ; Strobe 1 - DB '$' - DB '#' - DB 'R' - DB 'E' - DB 'D' - DB 'S' - DB 'X' - DB 'C' - ; Strobe 2 - DB '&' - DB '%' - DB 'Y' - DB 'T' - DB 'G' - DB 'F' - DB 'V' - DB 'B' - ; Strobe 3 - DB '(' - DB '\'' - DB 'I' - DB 'U' - DB 'J' - DB 'H' - DB 'N' - DB SPACE - ; Strobe 4 - DB '_' - DB ')' - DB 'P' - DB 'O' - DB 'L' - DB 'K' - DB '<' - DB 'M' - ; Strobe 5 - DB '~' - DB '=' - DB '{' - DB '`' - DB '*' - DB '+' - DB CURSLEFT - DB '>' - ; Strobe 6 - DB HOMEKEY - DB '|' - DB CURSRIGHT - DB CURSUP - DB CR - DB '}' - DB 0 - DB CURSUP - ; Strobe 7 - DB '8' - DB '7' - DB '5' - DB '4' - DB '2' - DB '1' - DB DBLZERO - DB '0' - ; Strobe 8 - DB '*' - DB '9' - DB '-' - DB '6' - DB 0 - DB '3' - DB 0 - DB ',' - -KTBLS: ; Strobe 0 - DB '2' - DB '1' - DB 'w' - DB 'q' - DB 'a' - DB DELETE - DB 0 - DB 'z' - ; Strobe 1 - DB '4' - DB '3' - DB 'r' - DB 'e' - DB 'd' - DB 's' - DB 'x' - DB 'c' - ; Strobe 2 - DB '6' - DB '5' - DB 'y' - DB 't' - DB 'g' - DB 'f' - DB 'v' - DB 'b' - ; Strobe 3 - DB '8' - DB '7' - DB 'i' - DB 'u' - DB 'j' - DB 'h' - DB 'n' - DB SPACE - ; Strobe 4 - DB '0' - DB '9' - DB 'p' - DB 'o' - DB 'l' - DB 'k' - DB ',' - DB 'm' - ; Strobe 5 - DB '^' - DB '-' - DB '[' - DB '@' - DB ':' - DB ';' - DB '/' - DB '.' - ; Strobe 6 - DB CLRKEY - DB '\\' - DB CURSLEFT - DB CURSDOWN - DB CR - DB ']' - DB 0 - DB '?' - -KTBLCL: ; Strobe 0 - DB '2' - DB '1' - DB 'W' - DB 'Q' - DB 'A' - DB DELETE - DB 0 - DB 'Z' - ; Strobe 1 - DB '4' - DB '3' - DB 'R' - DB 'E' - DB 'D' - DB 'S' - DB 'X' - DB 'C' - ; Strobe 2 - DB '6' - DB '5' - DB 'Y' - DB 'T' - DB 'G' - DB 'F' - DB 'V' - DB 'B' - ; Strobe 3 - DB '8' - DB '7' - DB 'I' - DB 'U' - DB 'J' - DB 'H' - DB 'N' - DB SPACE - ; Strobe 4 - DB '0' - DB '9' - DB 'P' - DB 'O' - DB 'L' - DB 'K' - DB ',' - DB 'M' - ; Strobe 5 - DB '^' - DB '-' - DB '[' - DB '@' - DB ':' - DB ';' - DB '/' - DB '.' - ; Strobe 6 - DB CLRKEY - DB '\\' - DB CURSLEFT - DB CURSDOWN - DB CR - DB ']' - DB 0 - DB '?' - -KTBLC: ; CTRL ON - ; Strobe 0 - DB NOKEY - DB NOKEY - DB CTRL_W - DB CTRL_Q - DB CTRL_A - DB NOKEY - DB 000H - DB CTRL_Z - ; Strobe 1 - DB NOKEY - DB NOKEY - DB CTRL_R - DB CTRL_E - DB CTRL_D - DB CTRL_S - DB CTRL_X - DB CTRL_C - ; Strobe 2 - DB NOKEY - DB NOKEY - DB CTRL_Y - DB CTRL_T - DB CTRL_G - DB CTRL_F - DB CTRL_V - DB CTRL_B - ; Strobe 3 - DB NOKEY - DB NOKEY - DB CTRL_I - DB CTRL_U - DB CTRL_J - DB CTRL_H - DB CTRL_N - DB NOKEY - ; Strobe 4 - DB NOKEY - DB NOKEY - DB CTRL_P - DB CTRL_O - DB CTRL_L - DB CTRL_K - DB NOKEY - DB CTRL_M - ; Strobe 5 - DB CTRL_CAPPA - DB CTRL_UNDSCR - DB ESC - DB CTRL_AT - DB NOKEY - DB NOKEY - DB NOKEY - DB NOKEY - ; Strobe 6 - DB NOKEY - DB CTRL_SLASH - DB NOKEY - DB NOKEY - DB NOKEY - DB CTRL_RB - DB NOKEY - - ;------------------------------------------------------------------------------- - ; END OF TIMER INTERRUPT - ;------------------------------------------------------------------------------- - - - ;------------------------------------------------------------------------------- - ; SERVICE COMMAND METHODS - ;------------------------------------------------------------------------------- -SVC_CMD: IF BUILD_TZFS = 1 - - ; Method to send a command to the I/O processor and verify it is being acted upon. - ; THe method, after sending the command, polls the service structure result to see if the I/O processor has updated it. If it doesnt update the result - ; then after a period of time the command is resent. After a number of retries the command aborts with error. This is needed in case of the I/O processor crashing - ; we dont want the host to lock up. - ; - ; Inputs: - ; A = Command. - ; Outputs: - ; A = 0 - Success, command being processed. - ; A = 1 - Failure, no contact with I/O processor. - ; A = 2 - Failure, no result from I/O processor, it could have crashed or SD card removed! - PUSH BC - LD (TZSVCCMD), A ; Load up the command into the service record. - LD A,TZSVC_STATUS_REQUEST - LD (TZSVCRESULT),A ; Set the service structure result to REQUEST, if this changes then the K64 is processing. - - LD BC, TZSVCWAITIORETRIES ; Safety in case the IO request wasnt seen by the I/O processor, if we havent seen a response in the service - -SVC_CMD1: PUSH BC - LD A,(TZSVCCMD) - OUT (SVCREQ),A ; Make the service request via the service request port. - - LD BC,0 -SVC_CMD2: LD A,(TZSVCRESULT) - CP TZSVC_STATUS_REQUEST ; I/O processor when it recognises the request sets the status to PROCESSING or gives a result, if this hasnt occurred the the K64F hasnt begun processing. - JR NZ, SVC_CMD3 - DEC BC - LD A,B - OR C - JR NZ, SVC_CMD2 - POP BC - DEC BC - LD A,B - OR C - JR NZ,SVC_CMD1 ; Retry sending the I/O command. - ; - PUSH DE - LD DE,SVCIOERR - CALL MONPRTSTR - POP DE - LD A,1 ; No response, error. - RET -SVC_CMD3: POP BC - ; - LD BC,TZSVCWAITCOUNT ; Number of loops to wait for a response before setting error. -SVC_CMD4: PUSH BC - LD BC,0 -SVC_CMD5: LD A,(TZSVCRESULT) - CP TZSVC_STATUS_PROCESSING ; Wait until the I/O processor sets the result, again timeout in case it locks up. - JR NZ, SVC_CMD6 - DEC BC - LD A,B - OR C - JR NZ,SVC_CMD5 - POP BC - DEC BC - LD A,B - OR C - JR NZ,SVC_CMD4 ; Retry polling for result. - ; - PUSH DE - LD DE,SVCRESPERR - CALL MONPRTSTR - POP DE - LD A,2 - RET -SVC_CMD6: XOR A ; Success. - POP BC - POP BC - RET - - ENDIF - ;------------------------------------------------------------------------------- - ; END OF SERVICE COMMAND METHODS - ;------------------------------------------------------------------------------- - - - - ;------------------------------------------------------------------------------- - ; START OF AUDIO CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; Melody function. -MLDY: PUSH BC - PUSH DE - PUSH HL - LD A,002H - LD (OCTV),A - LD B,001H -MLD1: LD A,(DE) - CP 00DH - JR Z,MLD4 - CP 0C8H - JR Z,MLD4 - CP 0CFH - JR Z,MLD2 - CP 02DH - JR Z,MLD2 - CP 02BH - JR Z,MLD3 - CP 0D7H - JR Z,MLD3 - CP 023H - LD HL,MTBL - JR NZ,MLD1A - LD HL,M?TBL - INC DE -MLD1A: CALL ONPU - JR C,MLD1 - CALL RYTHM - JR C,MLD5 - CALL MLDST - LD B,C - JR MLD1 -MLD2: LD A,003H -MLD2A: LD (OCTV),A - INC DE - JR MLD1 -MLD3: LD A,001H - JR MLD2A -MLD4: CALL RYTHM -MLD5: PUSH AF - CALL MLDSP - POP AF - POP HL - POP DE - POP BC - RET - -ONPU: PUSH BC - LD B,008H - LD A,(DE) -ONP1A: CP (HL) - JR Z,ONP2 - INC HL - INC HL - INC HL - DJNZ ONP1A - SCF - INC DE - POP BC - RET - -ONP2: INC HL - PUSH DE - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL - LD A,H - OR A - JR Z,ONP2B - LD A,(OCTV) -ONP2A: DEC A - JR Z,ONP2B - ADD HL,HL - JR ONP2A -ONP2B: LD (RATIO),HL - LD HL,OCTV - LD (HL),002H - DEC HL - POP DE - INC DE - LD A,(DE) - LD B,A - AND 0F0H - CP 030H - JR Z,ONP2C - LD A,(HL) - JR ONP2D -ONP2C: INC DE - LD A,B - AND 00FH - LD (HL),A -ONP2D: LD HL,OPTBL - ADD A,L - LD L,A - LD C,(HL) - LD A,(TEMPW) - LD B,A - XOR A - JP MLDDLY - -RYTHM: LD HL,KEYPA - LD (HL),0F0H - INC HL - LD A,(HL) - AND 081H - JR NZ,L02D5 - SCF - RET - -L02D5: LD A,(SUNDG) - RRCA - JR C,L02D5 -L02DB: LD A,(SUNDG) - RRCA - JR NC,L02DB - DJNZ L02D5 - XOR A - RET - -MLDST: LD HL,(RATIO) - LD A,H - OR A - JR Z,MLDSP - PUSH DE - EX DE,HL - LD HL,CONT0 - LD (HL),E - LD (HL),D - LD A,001H - POP DE - JR L02C4 -MLDSP: LD A,034H - LD (CONTF),A - XOR A -L02C4: LD (SUNDG),A - RET - -MLDDLY: ADD A,C - DJNZ MLDDLY - POP BC - LD C,A - XOR A - RET - - -TEMPO: PUSH AF - PUSH BC - AND 00FH - LD B,A - LD A,008H - SUB B - LD (TEMPW),A - POP BC - POP AF - RET - - ; - ; Method to sound the bell, basically play a constant tone. - ; -BEL: PUSH DE - LD DE,00DB1H - CALL MLDY - POP DE - RET - - ; - ; Melody (note) lookup table. - ; -MTBL: DB 043H - DB 077H - DB 007H - DB 044H - DB 0A7H - DB 006H - DB 045H - DB 0EDH - DB 005H - DB 046H - DB 098H - DB 005H - DB 047H - DB 0FCH - DB 004H - DB 041H - DB 071H - DB 004H - DB 042H - DB 0F5H - DB 003H - DB 052H - DB 000H - DB 000H -M?TBL: DB 043H - DB 00CH - DB 007H - DB 044H - DB 047H - DB 006H - DB 045H - DB 098H - DB 005H - DB 046H - DB 048H - DB 005H - DB 047H - DB 0B4H - DB 004H - DB 041H - DB 031H - DB 004H - DB 042H - DB 0BBH - DB 003H - DB 052H - DB 000H - DB 000H - -OPTBL: DB 001H - DB 002H - DB 003H - DB 004H - DB 006H - DB 008H - DB 00CH - DB 010H - DB 018H - DB 020H - ;------------------------------------------------------------------------------- - ; END OF AUDIO CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - - ;------------------------------------------------------------------------------- - ; START OF RTC FUNCTIONALITY (INTR HANDLER IN MAIN CBIOS) - ;------------------------------------------------------------------------------- - ; - ; BC:DE:HL contains the time in milliseconds (100msec resolution) since 01/01/1980. In IX is held the interrupt service handler routine address for the RTC. - ; HL contains lower 16 bits, DE contains middle 16 bits, BC contains upper 16bits, allows for a time from 00:00:00 to 23:59:59, for > 500000 days! - ; NB. Caller must disable interrupts before calling this method. -TIMESET: LD (TIMESEC),HL ; Load lower 16 bits. - EX DE,HL - LD (TIMESEC+2),HL ; Load middle 16 bits. - PUSH BC - POP HL - LD (TIMESEC+4),HL ; Load upper 16 bits. - ; - LD HL,CONTF - LD (HL),074H ; Set Counter 1, read/load lsb first then msb, mode 2 rate generator, binary - LD (HL),0B0H ; Set Counter 2, read/load lsb first then msb, mode 0 interrupt on terminal count, binary - DEC HL - LD DE,TMRTICKINTV ; 100Hz coming into Timer 2 from Timer 1, set divisor to set interrupts per second. - LD (HL),E ; Place current time in Counter 2 - LD (HL),D - DEC HL - LD (HL),03BH ; Place divisor in Counter 1, = 315, thus 31500/315 = 100 - LD (HL),001H - NOP - NOP - NOP - ; - LD A, 0C3H ; Install the interrupt vector for when interrupts are enabled. - LD (00038H),A - - ; Interrupt vector stored in RAM for the MZ80A (monitor ROM not writeable!!!). -TIMESET1: IF BUILD_MZ80A+BUILD_RFS > 0 - LD (01039H),IX - ENDIF -TIMESET2: IF BUILD_TZFS+BUILD_RFSTZ > 0 - LD (00039H),IX - ENDIF - RET - - ; Time Read; - ; Returns BC:DE:HL where HL is lower 16bits, DE is middle 16bits and BC is upper 16bits of milliseconds since 01/01/1980. -TIMEREAD: LD HL,(TIMESEC+4) - PUSH HL - POP BC - LD HL,(TIMESEC+2) - EX DE,HL - LD HL,(TIMESEC) - RET - ;------------------------------------------------------------------------------- - ; END OF RTC FUNCTIONALITY - ;------------------------------------------------------------------------------- - - - ;------------------------------------------------------------------------------- - ; UTILITIES - ;------------------------------------------------------------------------------- - - ; Function to print a string with control character interpretation. -MONPRTSTR: LD A,(DE) - OR A - RET Z - INC DE -MONPRTSTR2: CALL PRNT - JR MONPRTSTR - - ; Method to clear memory either to 0 or a given pattern. - ; -CLR8Z: XOR A -CLR8: LD BC,00800H -CLRMEM: PUSH DE - LD D,A -L09E8: LD (HL),D - INC HL - DEC BC - LD A,B - OR C - JR NZ,L09E8 - POP DE - RET - - ; Method to get a string parameter and copy it into the provided buffer. - ; - ; Inputs: - ; HL = Pointer to input line from BASIC. - ; DE = Pointer to Destination buffer. - ; B = Max number of characters to read. - ; Outputs: - ; DE and HL point to end of buffer and input line resepectively. - ; B = Characters copied (ie. B - input B = no characters). - ; -GETSTRING: LD C,B ; Save maximum characters allowed. - LD A,(HL) ; Skip white space before copy. - CP ' ' - JR NC, GETSTR2 - CP 00DH - JR GETSTR4 ; No directory means use the I/O set default. - INC DE - JR GETSTRING -GETSTR1: LD (DE),A ; Copy the name entered by user. Validation is done on the I/O processor, bad directory name will result in error next read/write. - INC HL - INC DE - LD A,(HL) ; Get next char and check it isnt CR, end of input line character. -GETSTR2: CP 00DH - JR Z,GETSTR4 ; Finished if we encounter CR. - CP ZTIMES - JR NZ,GETSTR3 - LD A, '*' ; BASIC has already tokenised the line so revert. -GETSTR3: DJNZ GETSTR1 ; Loop until buffer is full, ignore characters beyond buffer limit. -GETSTR4: LD A,C ; Set B = no characters copied. - SUB B - LD B,A - XOR A ; Place end of buffer terminator as I/O processor uses C strings. - LD (DE),A - RET - - - ; A function from the z88dk stdlib, a delay loop with T state accuracy. - ; - ; enter : hl = tstates >= 141 - ; uses : af, bc, hl -T_DELAY: LD BC,-141 - ADD HL,BC - LD BC,-23 -TDELAYLOOP: ADD HL,BC - JR C, TDELAYLOOP - LD A,L - ADD A,15 - JR NC, TDELAYG0 - CP 8 - JR C, TDELAYG1 - OR 0 -TDELAYG0: INC HL -TDELAYG1: RRA - JR C, TDELAYB0 - NOP -TDELAYB0: RRA - JR NC, TDELAYB1 - OR 0 -TDELAYB1: RRA - RET NC - RET - - ; Method to multiply a 16bit number by another 16 bit number to arrive at a 32bit result. - ; Input: DE = Factor 1 - ; BC = Factor 2 - ; Output:DEHL = 32bit Product - ; -MULT16X16: LD HL,0 - LD A,16 -MULT16X1: ADD HL,HL - RL E - RL D - JR NC,$+6 - ADD HL,BC - JR NC,$+3 - INC DE - DEC A - JR NZ,MULT16X1 - RET - - ; Method to add a 16bit number to a 32bit number to obtain a 32bit product. - ; Input: DEHL = 32bit Addend - ; BC = 16bit Addend - ; Output:DEHL = 32bit sum. - ; -ADD3216: ADD HL,BC - EX DE,HL - LD BC,0 - ADC HL,BC - EX DE,HL - RET - - ;------------------------------------------------------------------------------- - ; END OF UTILITIES - ;------------------------------------------------------------------------------- - - - ;------------------------------------------------------------------------------- - ; START OF KEYBOARD FUNCTIONALITY (INTR HANDLER SEPERATE IN CBIOS) - ;------------------------------------------------------------------------------- - -MODE: LD HL,KEYPF - LD (HL),08AH - LD (HL),007H ; Set Motor to Off. - LD (HL),004H ; Disable interrupts by setting INTMSK to 0. - LD (HL),001H ; Set VGATE to 1. - RET - - ; Method to check if a key has been pressed and stored in buffer.. -CHKKY: CALL CURSORON - LD A, (KEYCOUNT) - OR A - JR Z,CHKKY2 - LD A,0FFH - JR CHKKY3 -CHKKY2: XOR A -CHKKY3: CALL CURSOROFF - OR A - RET - -GETKY: CALL CURSORON - PUSH HL - LD A,(KEYCOUNT) - OR A - JR Z,GETKY2 -GETKY1: DI ; Disable interrupts, we dont want a race state occurring. - LD A,(KEYCOUNT) - DEC A ; Take 1 off the total count as we are reading a character out of the buffer. - LD (KEYCOUNT),A - LD HL,(KEYREAD) ; Get the position in the buffer where the next available character resides. - LD A,(HL) ; Read the character and save. - PUSH AF - INC L ; Update the read pointer and save. - LD A,L - AND KEYBUFSIZE-1 - LD L,A - LD (KEYREAD),HL - POP AF - EI ; Interrupts back on so keys and RTC are actioned. - JR PRCKEY ; Process the key, action any non ASCII keys. - ; -GETKY2: LD A,(KEYCOUNT) ; No key available so loop until one is. - OR A - JR Z,GETKY2 - JR GETKY1 - ; -PRCKEY: CP CR ; CR - JR NZ,PRCKY3 - JR PRCKYE -PRCKY3: CP HOMEKEY ; HOME - JR NZ,PRCKY4 - JR GETKY2 -PRCKY4: CP CLRKEY ; CLR - JR NZ,PRCKY5 - JR GETKY2 -PRCKY5: CP INSERT ; INSERT - JR NZ,PRCKY6 - JR GETKY2 -PRCKY6: CP DBLZERO ; 00 - JR NZ,PRCKY7 - LD A,'0' - LD (KEYBUF),A ; Place a character into the keybuffer so we double up on 0 - JR PRCKYX -PRCKY7: CP BREAKKEY ; Break key processing. - JR NZ,PRCKY8 - -PRCKY8: -PRCKYX: -PRCKYE: - POP HL - CALL CURSOROFF - RET - - ;------------------------------------------------------------------------------- - ; END OF KEYBOARD FUNCTIONALITY - ;------------------------------------------------------------------------------- - - - ;------------------------------------------------------------------------------- - ; START OF SCREEN FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; CR PAGE MODE1 -.CR: CALL .MANG - RRCA - JP NC,CURS2 - LD L,000H - INC H - CP ROW - 1 ; End of line? - JR Z,.CP1 - INC H - JP CURS1 - -.CP1: LD (DSPXY),HL - - ; SCROLLER -.SCROL: LD BC,SCRNSZ - COLW ; Scroll COLW -1 lines - LD DE,SCRN ; Start of the screen. - LD HL,SCRN + COLW ; Start of screen + 1 line. - LDIR - EX DE,HL - LD B,COLW ; Clear last line at bottom of screen. - CALL CLER - LD BC,0001AH - LD DE,MANG - LD HL,MANG + 1 - LDIR - LD (HL),000H - LD A,(MANG) - OR A - JP Z,RSTR - LD HL,DSPXY + 1 - DEC (HL) - JR .SCROL - -DPCT: PUSH AF ; Display control, character is mapped to a function call. - PUSH BC - PUSH DE - PUSH HL - LD B,A - AND 0F0H - CP 0C0H - JP NZ,RSTR - XOR B - RLCA - LD C,A - LD B,000H - LD HL,.CTBL -DPCT1: ADD HL,BC - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL - JP (HL) - - -PRT: LD A,C - CALL ADCN - LD C,A - AND 0F0H - CP 0F0H - RET Z - - CP 0C0H - LD A,C - JR NZ,PRNT3 -PRNT5: CALL DPCT - CP 0C3H - JR Z,PRNT4 - CP 0C5H - JR Z,PRNT2 - CP 0CDH ; CR - JR Z,PRNT2 - CP 0C6H - RET NZ - -PRNT2: XOR A -PRNT2A: LD (DPRNT),A - RET - -PRNT3: CALL DSP -PRNT4: LD A,(DPRNT) - INC A - CP COLW*2 ; 050H - JR C,PRNT4A - SUB COLW*2 ; 050H -PRNT4A: JR PRNT2A - -NL: LD A,(DPRNT) - OR A - RET Z - -LTNL: LD A,0CDH - JR PRNT5 - -PRTT: CALL PRTS - LD A,(DPRNT) - OR A - RET Z - -L098C: SUB 00AH - JR C,PRTT - JR NZ,L098C - RET - - ; Delete a character on screen. -DELETECHR: LD A,0C7H - CALL DPCT - JP PRNT1 - -NEWLINE: CALL NL - JP PRNT1 - - ; - ; Function to disable the cursor display. - ; -CURSOROFF: PUSH HL - DI - LD HL,FLASHCTL ; Indicate cursor is now off. - RES 7,(HL) - CALL CURSRSTR ; Restore character under the cursor. - EI - POP HL - RET - - ; - ; Function to enable the cursor display. - ; -CURSORON: PUSH HL - DI - CALL DSPXYTOADDR ; Update the screen address for where the cursor should appear. - LD HL,FLASHCTL ; Indicate cursor is now on. - SET 7,(HL) - EI - POP HL - RET - - ; - ; Function to restore the character beneath the cursor iff the cursor is being dislayed. - ; -CURSRSTR: PUSH HL - PUSH AF - LD HL,FLASHCTL ; Check to see if there is a cursor at the current screen location. - BIT 6,(HL) - JR Z,CURSRSTR1 - RES 6,(HL) - LD HL,(DSPXYADDR) ; There is so we must restore the original character before further processing. - LD A,(FLASH) - LD (HL),A -CURSRSTR1: POP AF - POP HL - RET - - ; - ; Function to convert XY co-ordinates to a physical screen location and save. - ; -DSPXYTOADDR:PUSH HL - PUSH DE - PUSH BC - LD BC,(DSPXY) ; Calculate the new cursor position based on the XY coordinates. - LD DE,COLW - LD HL,SCRN - COLW -DSPXYTOA1: ADD HL,DE - DEC B - JP P,DSPXYTOA1 - LD B,000H - ADD HL,BC - RES 3,H - LD (DSPXYADDR),HL ; Store the new address. - LD A,(HL) ; Store the new character. - LD (FLASH),A -DSPXYTOA2: POP BC - POP DE - POP HL - RET - - ; - ; Function to print a space. - ; -PRTS: LD A,020H - - ; Function to print a character to the screen. If the character is a control code it is processed as necessary - ; otherwise the character is converted from ASCII display and displayed. - ; -PRNT: CALL CURSOROFF ; Disable the cursor before printing. - DI - ; - LD (SPISRSAVE),SP ; Share the interrupt stack for banked access as the BASIC stack goes out of scope. - LD SP,ISRSTACK ; Interrupts are disabled so we can safely use this stack. - ; -MEMSW4: IF BUILD_TZFS+BUILD_RFSTZ > 0 - PUSH AF - LD A,TZMM_MZ700_0 ; Enable access to the hardware by paging out the upper bank. - OUT (MMCFG),A - POP AF - ENDIF - ; - CP 00DH - JR Z,NEWLINE - CP 00AH - JR Z,NEWLINE - CP 07FH - JP Z,DELETECHR - CP BACKS - JP Z,DELETECHR - PUSH BC - LD C,A - LD B,A - CALL PRT - LD A,B - POP BC -PRNT1: CALL DSPXYTOADDR - ; -MEMSW5: IF BUILD_TZFS+BUILD_RFSTZ > 0 - LD A,TZMM_MZ700_2 ; Enable access to the hardware by paging out the upper bank. - OUT (MMCFG),A - ENDIF - ; - LD SP,(SPISRSAVE) ; Restore the BASIC stack to exit. - EI - RET - - ; A print string method but without memory mode change, for use when the hardware is already switched in and doesnt want to be changed. - ; -PRNTSTR: LD A,(DE) - OR A - JR Z,PRNTSTR6 - INC DE - ; - CALL CURSOROFF ; Turn cursor off for any printing. - CP 00DH - JR NZ,PRNTSTR2 -PRNTSTR1: LD A,(DPRNT) - OR A - JR Z,PRNTSTR5 - LD A,0CDH - CALL DPCT - JR PRNTSTR5 -PRNTSTR2: CP 00AH - JR Z,PRNTSTR1 - CP 07FH - JR NZ,PRNTSTR4 -PRNTSTR3: LD A,0C7H - CALL DPCT - JR PRNTSTR5 -PRNTSTR4: CP BACKS - JR Z,PRNTSTR3 - PUSH BC - LD C,A - LD B,A - CALL PRT - LD A,B - POP BC -PRNTSTR5: CALL DSPXYTOADDR - JR PRNTSTR -PRNTSTR6: RET - - ; - ; Function to print out the contents of HL as 4 digit Hexadecimal. - ; -PRTHL: LD A,H - CALL PRTHX - LD A,L - JR PRTHX - RET - - ; - ; Function to print out the contents of A as 2 digit Hexadecimal - ; -PRTHX: PUSH AF - RRCA - RRCA - RRCA - RRCA - CALL ASCII - CALL PRNT - POP AF - CALL ASCII - JP PRNT - -ASCII: AND 00FH - CP 00AH - JR C,NOADD - ADD A,007H -NOADD: ADD A,030H - RET - -;CLR8Z: XOR A -; LD BC,00800H -; PUSH DE -; LD D,A -;L09E8: LD (HL),D -; INC HL -; DEC BC -; LD A,B -; OR C -; JR NZ,L09E8 -; POP DE -; RET - -REV: LD HL,REVFLG - LD A,(HL) - OR A - CPL - LD (HL),A - JR Z,REV1 - LD A,(INVDSP) - JR REV2 -REV1: LD A,(NRMDSP) -REV2: JP RSTR - -.MANG: LD HL,MANG -.MANG2: LD A,(DSPXY + 1) - ADD A,L - LD L,A - LD A,(HL) - INC HL - RL (HL) - OR (HL) - RR (HL) - RRCA - EX DE,HL - LD HL,(DSPXY) - RET - -L09C7: PUSH DE - PUSH HL - LD HL,PBIAS - XOR A - RLD - LD D,A - LD E,(HL) - RRD - XOR A - RR D - RR E - LD HL,SCRN - ADD HL,DE - LD (PAGETP),HL - POP HL - POP DE - RET - -DSP: PUSH AF - PUSH BC - PUSH DE - PUSH HL - LD B,A - CALL PONT - LD (HL),B - LD HL,(DSPXY) - LD A,L -DSP01: CP COLW - 1 ; End of line. - JP NZ,CURSR - CALL .MANG - JR C,CURSR -.DSP03: EX DE,HL - LD (HL),001H - INC HL - LD (HL),000H - JP CURSR - -CURSD: LD HL,(DSPXY) - LD A,H - CP ROW - 1 - JR Z,CURS4 - INC H -CURS1: ;CALL MGP.I -CURS3: LD (DSPXY),HL - JR RSTR - -CURSU: LD HL,(DSPXY) - LD A,H - OR A - JR Z,CURS5 - DEC H -CURSU1: JR CURS3 - -CURSR: LD HL,(DSPXY) - LD A,L - CP COLW - 1 ; End of line - JR NC,CURS2 - INC L - JR CURS3 -CURS2: LD L,000H - INC H - LD A,H - CP ROW - JR C,CURS1 - LD H,ROW - 1 - LD (DSPXY),HL -CURS4: JP .SCROL - -CURSL: LD HL,(DSPXY) - LD A,L - OR A - JR Z,CURS5A - DEC L - JR CURS3 -CURS5A: LD L,COLW - 1 ; End of line - DEC H - JP P,CURSU1 - LD H,000H - LD (DSPXY),HL -CURS5: JR RSTR - -CLRS: LD HL,MANG - LD B,01BH - CALL CLER - LD HL,SCRN - ;PUSH HL - CALL CLR8Z - ;POP HL - IF BUILD_80C = 0 - LD A,071H ; Black background, white characters. Bit 7 is clear as a write to bit 7 @ DFFFH selects 40Char mode. - ELSE - LD A,071H ; Blue background, white characters in colour mode. Bit 7 is set as a write to bit 7 @ DFFFH selects 80Char mode. - ENDIF - CALL CLR8 ; D800H-DFFFH CLEAR -CLRS1: LD A,(SCLDSP) -HOM0: LD HL,00000H - JP CURS3 - -RSTR: POP HL -RSTR1: POP DE - POP BC - POP AF - RET - -DEL: LD HL,(DSPXY) - LD A,H - OR L - JR Z,RSTR - LD A,L - OR A - JR NZ,DEL1 - CALL .MANG - JR C,DEL1 - CALL PONT - DEC HL - LD (HL),000H - JR CURSL -DEL1: CALL .MANG - RRCA - LD A,COLW - JR NC,L0F13 - RLCA -L0F13: SUB L - LD B,A - CALL PONT - PUSH HL - POP DE - DEC DE - SET 4,D -DEL2: RES 3,H - RES 3,D - LD A,(HL) - LD (DE),A - INC HL - INC DE - DJNZ DEL2 - DEC HL - LD (HL),000H - JP CURSL - -INST: CALL .MANG - RRCA - LD L,COLW - 1 ; End of line - LD A,L - JR NC,INST1A - INC H -INST1A: CALL PNT1 - PUSH HL - LD HL,(DSPXY) - JR NC,INST2 - LD A,(COLW*2)-1 ; 04FH -INST2: SUB L - LD B,A - POP DE - LD A,(DE) - OR A - JR NZ,RSTR - CALL PONT - LD A,(HL) - LD (HL),000H -INST1: INC HL - RES 3,H - LD E,(HL) - LD (HL),A - LD A,E - DJNZ INST1 - JR RSTR - -PONT: LD HL,(DSPXY) -PNT1: PUSH AF - PUSH BC - PUSH DE - PUSH HL - POP BC - LD DE,COLW - LD HL,SCRN - COLW -PNT2: ADD HL,DE - DEC B - JP P,PNT2 - LD B,000H - ADD HL,BC - RES 3,H - POP DE - POP BC - POP AF - RET - -CLER: XOR A - JR DINT -CLRFF: LD A,0FFH -DINT: LD (HL),A - INC HL - DJNZ DINT - RET - -ADCN: PUSH BC - PUSH HL - LD HL,ATBL ;00AB5H - LD C,A - LD B,000H - ADD HL,BC - LD A,(HL) - JR DACN3 - -DACN: PUSH BC - PUSH HL - PUSH DE - LD HL,ATBL - LD D,H - LD E,L - LD BC,00100H - CPIR - JR Z,DACN1 - LD A,0F0H -DACN2: POP DE -DACN3: POP HL - POP BC - RET - -DACN1: OR A - DEC HL - SBC HL,DE - LD A,L - JR DACN2 - - ; CTBL PAGE MODE1 -.CTBL: DW .SCROL - DW CURSD - DW CURSU - DW CURSR - DW CURSL - DW HOM0 - DW CLRS - DW DEL - DW INST - DW RSTR - DW RSTR - DW RSTR - DW REV - DW .CR - DW RSTR - DW RSTR - -; ASCII TO DISPLAY CODE TABLE -ATBL: DB 0CCH ; NUL '\0' (null character) - DB 0E0H ; SOH (start of heading) - DB 0F2H ; STX (start of text) - DB 0F3H ; ETX (end of text) - DB 0CEH ; EOT (end of transmission) - DB 0CFH ; ENQ (enquiry) - DB 0F6H ; ACK (acknowledge) - DB 0F7H ; BEL '\a' (bell) - DB 0F8H ; BS '\b' (backspace) - DB 0F9H ; HT '\t' (horizontal tab) - DB 0FAH ; LF '\n' (new line) - DB 0FBH ; VT '\v' (vertical tab) - DB 0FCH ; FF '\f' (form feed) - DB 0FDH ; CR '\r' (carriage ret) - DB 0FEH ; SO (shift out) - DB 0FFH ; SI (shift in) - DB 0E1H ; DLE (data link escape) - DB 0C1H ; DC1 (device control 1) - DB 0C2H ; DC2 (device control 2) - DB 0C3H ; DC3 (device control 3) - DB 0C4H ; DC4 (device control 4) - DB 0C5H ; NAK (negative ack.) - DB 0C6H ; SYN (synchronous idle) - DB 0E2H ; ETB (end of trans. blk) - DB 0E3H ; CAN (cancel) - DB 0E4H ; EM (end of medium) - DB 0E5H ; SUB (substitute) - DB 0E6H ; ESC (escape) - DB 0EBH ; FS (file separator) - DB 0EEH ; GS (group separator) - DB 0EFH ; RS (record separator) - DB 0F4H ; US (unit separator) - DB 000H ; SPACE - DB 061H ; ! - DB 062H ; " - DB 063H ; # - DB 064H ; $ - DB 065H ; % - DB 066H ; & - DB 067H ; ' - DB 068H ; ( - DB 069H ; ) - DB 06BH ; * - DB 06AH ; + - DB 02FH ; , - DB 02AH ; - - DB 02EH ; . - DB 02DH ; / - DB 020H ; 0 - DB 021H ; 1 - DB 022H ; 2 - DB 023H ; 3 - DB 024H ; 4 - DB 025H ; 5 - DB 026H ; 6 - DB 027H ; 7 - DB 028H ; 8 - DB 029H ; 9 - DB 04FH ; : - DB 02CH ; ; - DB 051H ; < - DB 02BH ; = - DB 057H ; > - DB 049H ; ? - DB 055H ; @ - DB 001H ; A - DB 002H ; B - DB 003H ; C - DB 004H ; D - DB 005H ; E - DB 006H ; F - DB 007H ; G - DB 008H ; H - DB 009H ; I - DB 00AH ; J - DB 00BH ; K - DB 00CH ; L - DB 00DH ; M - DB 00EH ; N - DB 00FH ; O - DB 010H ; P - DB 011H ; Q - DB 012H ; R - DB 013H ; S - DB 014H ; T - DB 015H ; U - DB 016H ; V - DB 017H ; W - DB 018H ; X - DB 019H ; Y - DB 01AH ; Z - DB 052H ; [ - DB 059H ; \ '\\' - DB 054H ; ] - DB 0BEH ; ^ - DB 03CH ; _ - DB 0C7H ; ` - DB 081H ; a - DB 082H ; b - DB 083H ; c - DB 084H ; d - DB 085H ; e - DB 086H ; f - DB 087H ; g - DB 088H ; h - DB 089H ; i - DB 08AH ; j - DB 08BH ; k - DB 08CH ; l - DB 08DH ; m - DB 08EH ; n - DB 08FH ; o - DB 090H ; p - DB 091H ; q - DB 092H ; r - DB 093H ; s - DB 094H ; t - DB 095H ; u - DB 096H ; v - DB 097H ; w - DB 098H ; x - DB 099H ; y - DB 09AH ; z - DB 0BCH ; { - DB 080H ; | - DB 040H ; } - DB 0A5H ; ~ - DB 0C0H ; DEL - DB 040H - DB 0BDH - DB 09DH - DB 0B1H - DB 0B5H - DB 0B9H - DB 0B4H - DB 09EH - DB 0B2H - DB 0B6H - DB 0BAH - DB 0BEH - DB 09FH - DB 0B3H - DB 0B7H - DB 0BBH - DB 0BFH - DB 0A3H - DB 085H - DB 0A4H - DB 0A5H - DB 0A6H - DB 094H - DB 087H - DB 088H - DB 09CH - DB 082H - DB 098H - DB 084H - DB 092H - DB 090H - DB 083H - DB 091H - DB 081H - DB 09AH - DB 097H - DB 093H - DB 095H - DB 089H - DB 0A1H - DB 0AFH - DB 08BH - DB 086H - DB 096H - DB 0A2H - DB 0ABH - DB 0AAH - DB 08AH - DB 08EH - DB 0B0H - DB 0ADH - DB 08DH - DB 0A7H - DB 0A8H - DB 0A9H - DB 08FH - DB 08CH - DB 0AEH - DB 0ACH - DB 09BH - DB 0A0H - DB 099H - DB 0BCH - DB 0B8H - DB 080H - DB 03BH - DB 03AH - DB 070H - DB 03CH - DB 071H - DB 05AH - DB 03DH - DB 043H - DB 056H - DB 03FH - DB 01EH - DB 04AH - DB 01CH - DB 05DH - DB 03EH - DB 05CH - DB 01FH - DB 05FH - DB 05EH - DB 037H - DB 07BH - DB 07FH - DB 036H - DB 07AH - DB 07EH - DB 033H - DB 04BH - DB 04CH - DB 01DH - DB 06CH - DB 05BH - DB 078H - DB 041H - DB 035H - DB 034H - DB 074H - DB 030H - DB 038H - DB 075H - DB 039H - DB 04DH - DB 06FH - DB 06EH - DB 032H - DB 077H - DB 076H - DB 072H - DB 073H - DB 047H - DB 07CH - DB 053H - DB 031H - DB 04EH - DB 06DH - DB 048H - DB 046H - DB 07DH - DB 044H - DB 01BH - DB 058H - DB 079H - DB 042H - DB 060H - DB 0FDH - DB 0CBH - DB 000H - DB 01EH - ;------------------------------------------------------------------------------- - ; END OF SCREEN FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;------------------------------------------------------------------------------- - ; CMT UTILITIES - ;------------------------------------------------------------------------------- -?WRI: PUSH DE - PUSH BC - PUSH HL - LD D,0D7H - LD E,0CCH - LD HL,IBUFE - LD BC,00080H -WRI1: CALL CKSUM - CALL MOTOR - JR C,CMIWRI2 - LD A,E - CP 0CCH - JR NZ,CMIWRI1 - CALL NL - PUSH DE - LD DE,MSGWRITING ; Writing Message - CALL MONPRTSTR - LD DE,NAME - CALL MONPRTSTR - LD DE,MSGWRITING2 - CALL MONPRTSTR - POP DE -CMIWRI1: DI - CALL GAP - CALL WTAPE -CMIWRI2: JP RET2 - - -?WRD: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D7H - LD E,053H - LD BC,(SIZE) - LD HL,(DTADR) - LD A,B - OR C - JR Z,WTAP3 - JR WRI1 - -WTAPE: PUSH DE - PUSH BC - PUSH HL - LD D,002H - LD A,0F0H - LD (KEYPA),A -WTAP1: LD A,(HL) - CALL WBYTE - LD A,(KEYPB) - AND 081H - JP NZ,WTAP2 - SCF - JR WTAP3 -WTAP2: INC HL - DEC BC - LD A,B - OR C - JP NZ,WTAP1 - LD HL,(SUMDT) - LD A,H - CALL WBYTE - LD A,L - CALL WBYTE - CALL LONG - DEC D - JP NZ,WTAP4 - OR A - JP WTAP3 - -WTAP4: LD B,000H -WTAP5: CALL SHORT - DEC B - JP NZ,WTAP5 - POP HL - POP BC - PUSH BC - PUSH HL - JP WTAP1 -WTAP3: POP HL - POP BC - POP DE - RET - -?RDI: PUSH DE - PUSH BC - PUSH HL - LD D,0D2H - LD E,0CCH - LD BC,00080H - LD HL,IBUFE -RD1: DI -MEMSWRT0: IF BUILD_TZFS+BUILD_RFSTZ > 0 - LD (SPISRSAVE),SP ; Share the interrupt stack whilst accessing hardware as the BASIC stack goes out of scope. - LD SP,ISRSTACK ; Interrupts are disabled so we can safely use this stack. - LD A,TZMM_MZ700_0 ; We meed to be in memory mode 10 to access the tape hardware. - OUT (MMCFG),A - ENDIF - ; - CALL MOTOR - JP C,RTP6 - DI - CALL TMARK - JP C,RTP6 - CALL RTAPE - JP RET2 - -?RDD: PUSH DE - PUSH BC - PUSH HL - LD D,0D2H - LD E,053H - LD BC,(SIZE) - LD HL,(DTADR) - LD A,B - OR C - JP Z,RET2 - JR RD1 - -RTAPE: PUSH DE - PUSH BC - PUSH HL - LD H,002H -RTP1: LD BC,KEYPB - LD DE,KEYPC -RTP2: CALL EDGE - JP C,RTP6 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,RTP2 - LD D,H - LD HL,00000H - LD (SUMDT),HL - POP HL - POP BC - PUSH BC - PUSH HL -RTP3: CALL RBYTE - JP C,RTP6 - ; For TZFS/RFS page in top bank of memory for potential data store. -MEMSWRT1: IF BUILD_TZFS+BUILD_RFSTZ > 0 - EX AF,AF' - LD A,TZMM_MZ700_2 - OUT (MMCFG),A - EX AF,AF' - LD (HL),A ; Save the byte just read once memory has been paged in. - LD A,TZMM_MZ700_0 - OUT (MMCFG),A - ELSE - LD (HL),A ; Save the byte just read. - ENDIF - - INC HL - DEC BC - LD A,B - OR C - JP NZ,RTP3 - LD HL,(SUMDT) - CALL RBYTE - JP C,RTP6 - LD E,A - CALL RBYTE - JP C,RTP6 - CP L - JP NZ,RTP5 - LD A,E - CP H - JP NZ,RTP5 -RTP8: XOR A -RET2: CALL MSTOP -MEMSWRT4: IF BUILD_TZFS+BUILD_RFSTZ > 0 - EX AF,AF' - LD A,TZMM_MZ700_2 ; Return to the full 64K memory mode. - OUT (MMCFG),A - EX AF,AF' - LD SP,(SPISRSAVE) ; Restore the BASIC stack to exit. - ENDIF - ; - POP HL - POP BC - POP DE - PUSH AF - EI - POP AF - RET - -RTP5: DEC D - JR Z,RTP7 - LD H,D - CALL GAPCK - JR RTP1 -RTP7: LD A,001H - JR RTP9 -RTP6: LD A,002H -RTP9: SCF - JR RET2 - - -?VRFY: DI - PUSH DE - PUSH BC - PUSH HL - LD BC,(SIZE) - LD HL,(DTADR) - LD D,0D2H - LD E,053H - LD A,B - OR C - JR Z,RET2 - CALL CKSUM - CALL MOTOR - JR C,RTP6 - CALL TMARK - JP C,RTP6 - CALL TVRFY - JR RET2 - -TVRFY: PUSH DE - PUSH BC - PUSH HL - LD H,002H -TVF1: LD BC,KEYPB - LD DE,KEYPC -TVF2: CALL EDGE - JP C,RTP6 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,TVF2 - LD D,H - POP HL - POP BC - PUSH BC - PUSH HL -TVF3: CALL RBYTE - JP C,RTP6 - CP (HL) - JP NZ,RTP7 - INC HL - DEC BC - LD A,B - OR C - JP NZ,TVF3 - LD HL,(CSMDT) - CALL RBYTE - CP H - JR NZ,RTP7 - CALL RBYTE - CP L - JR NZ,RTP7 - DEC D - JP Z,RTP8 - LD H,D - JR TVF1 - -EDGE: LD A,0F0H - LD (KEYPA),A - NOP -EDG1: LD A,(BC) - AND 081H - JP NZ,EDG1A - SCF - RET -EDG1A: LD A,(DE) - AND 020H - JP NZ,EDG1 -EDG2: LD A,(BC) - AND 081H - JP NZ,EDG3 - SCF - RET -EDG3: LD A,(DE) - AND 020H - JP Z,EDG2 - RET - -RBYTE: PUSH BC - PUSH DE - PUSH HL - LD HL,00800H - LD BC,KEYPB - LD DE,KEYPC -RBY1: CALL EDGE - JP C,RBY3 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,RBY2 - PUSH HL - LD HL,(SUMDT) - INC HL - LD (SUMDT),HL - POP HL - SCF -RBY2: LD A,L - RLA - LD L,A - DEC H - JP NZ,RBY1 - CALL EDGE - LD A,L -RBY3: POP HL - POP DE - POP BC - RET - -TMARK: CALL GAPCK - PUSH BC - PUSH DE - PUSH HL - LD HL,02828H ; 40 short and 40 long gap pulses - LD A,E - CP 0CCH - JP Z,TM0 - LD HL,01414H ; 20 short and 20 long tape mark pulses -TM0: LD (TMCNT),HL - LD BC,KEYPB - LD DE,KEYPC -TM1: LD HL,(TMCNT) -TM2: CALL EDGE - JP C,RET3 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,TM1 - DEC H - JP NZ,TM2 -TM3: CALL EDGE - JP C,RET3 - CALL DLY3 - LD A,(DE) - AND 020H - JP NZ,TM1 - DEC L - JP NZ,TM3 - CALL EDGE -RET3: -TM4: POP HL - POP DE - POP BC - RET - -MOTOR: PUSH BC - PUSH DE - PUSH HL - LD B,00AH -MOT1: LD A,(KEYPC) - AND 010H - JR Z,MOT4 -MOT2: LD B,0A6H -MOT3: CALL DLY12 - DJNZ MOT3 - XOR A -MOT7: JR RET3 -MOT4: LD A,006H - LD HL,KEYPF - LD (HL),A - INC A - LD (HL),A - DJNZ MOT1 - LD A,D - CP 0D7H - JR Z,MOT8 - LD DE,MSGPLAY - JR MOT9 -MOT8: LD DE,MSGRECORD ; RECORD message. -MOT9: CALL PRNTSTR -MOT5: LD A,(KEYPC) - AND 010H - JR NZ,MOT2 - ; CALL ?BRK - ; JR NZ,MOT5 - ; BREAK KEY CHECK HERE - JR MOT5 - -MSTOP: PUSH AF - PUSH BC - PUSH DE - LD B,00AH -MST1: LD A,(KEYPC) - AND 010H - JR Z,MST3 -MST2: LD A,006H - LD (KEYPF),A - INC A - LD (KEYPF),A - DJNZ MST1 -MST3: JP RSTR1 - -CKSUM: PUSH BC - PUSH DE - PUSH HL - LD DE,00000H -CKS1: LD A,B - OR C - JR NZ,CKS2 - EX DE,HL - LD (SUMDT),HL - LD (CSMDT),HL - POP HL - POP DE - POP BC - RET - -CKS2: LD A,(HL) - PUSH BC - LD B,008H -CKS3: RLCA - JR NC,CKS4 - INC DE -CKS4: DJNZ CKS3 - POP BC - INC HL - DEC BC - JR CKS1 - -DLY1: LD A,00EH -DLY1A: DEC A - JP NZ,DLY1A - RET - -DLY2: LD A,00DH -DLY2A: DEC A - JP NZ,DLY2A - RET - -DLY3: NEG - NEG - LD A,02AH - JP DLY2A - -WBYTE: PUSH BC - LD B,008H - CALL LONG -WBY1: RLCA - CALL C,LONG - CALL NC,SHORT - DEC B - JP NZ,WBY1 - POP BC - RET - -GAP: PUSH BC - PUSH DE - LD A,E - LD BC,055F0H - LD DE,02828H - CP 0CCH - JP Z,GAP1 - LD BC,02AF8H - LD DE,01414H -GAP1: CALL SHORT - DEC BC - LD A,B - OR C - JR NZ,GAP1 -GAP2: CALL LONG - DEC D - JR NZ,GAP2 -GAP3: CALL SHORT - DEC E - JR NZ,GAP3 - CALL LONG - POP DE - POP BC - RET - -SHORT: PUSH AF - LD A,003H - LD (KEYPF),A - CALL DLY1 - CALL DLY1 - LD A,002H - LD (KEYPF),A - CALL DLY1 - CALL DLY1 - POP AF - RET - -LONG: PUSH AF - LD A,003H - LD (KEYPF),A - CALL DLY1 - CALL DLY1 - CALL DLY1 - CALL DLY1 - LD A,002H - LD (KEYPF),A - CALL DLY1 - CALL DLY1 - CALL DLY1 - CALL DLY2 - POP AF - RET - -L09AB: ADD A,C - DJNZ L09AB - POP BC - LD C,A - XOR A - RET - -DLY12: PUSH BC - LD B,023H -DLY12A: CALL DLY3 - DJNZ DLY12A - POP BC - RET - -GAPCK: PUSH BC - PUSH DE - PUSH HL - LD BC,KEYPB - LD DE,KEYPC -GAPCK1: LD H,064H -GAPCK2: CALL EDGE - JR C,GAPCK3 - CALL DLY3 - LD A,(DE) - AND 020H - JR NZ,GAPCK1 - DEC H - JR NZ,GAPCK2 -GAPCK3: JP RET3 - ;------------------------------------------------------------------------------- - ; END OF CMT UTILITIES - ;------------------------------------------------------------------------------- - - - ;------------------------------------------------------------------------------- - ; ANSI TERMINAL FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;---------------------------------------- - ; - ; ANSI EMULATION - ; - ; Emulate the Ansi standard - ; N.B. Turned on when Chr - ; 27 recieved. - ; Entry - A = Char - ; Exit - None - ; Used - None - ; - ;---------------------------------------- -ANSITERM: IF INCLUDE_ANSITERM = 1 - PUSH HL - PUSH DE - PUSH BC - PUSH AF - LD C,A ; Move character into C for safe keeping - ; - LD A,(ANSIMODE) - OR A - JR NZ,ANSI2 - LD A,C - CP 27 - JP NZ,NOTANSI ; If it is Chr 27 then we haven't just - ; been turned on, so don't bother with - ; all the checking. - LD A,1 ; Turn on. - LD (ANSIMODE),A - JP AnsiMore - -ANSI2: LD A,(CHARACTERNO) ; CHARACTER number in sequence - OR A ; Is this the first character? - JP Z,AnsiFirst ; Yes, deal with this strange occurance! - - LD A,C ; Put character back in C to check - - CP ";" ; Is it a semi colon? - JP Z,AnsiSemi - - CP "0" ; Is it a number? - JR C,ANSI_NN ; If <0 then no - CP "9"+1 ; If >9 then no - JP C,AnsiNumber - -ANSI_NN: CP "?" ; Simple trap for simple problem! - JP Z,AnsiMore - - CP "@" ; Is it a letter? - JP C,ANSIEXIT ; Abandon if not letter; something wrong - -ANSIFOUND: CALL CURSOROFF ; Turn cursor off and restore any character under the cursor. - LD HL,(NUMBERPOS) ; Get value of number buffer - LD A,(HAVELOADED) ; Did we put anything in this byte? - OR A - JR NZ,AF1 - LD (HL),255 ; Mark the fact that nothing was put in -AF1: INC HL - LD A,254 - LD (HL),A ; Mark end of sequence (for unlimited length sequences) - - XOR A - LD (CURSORCOUNT),A ; Restart count - LD A,0C9h - LD (CHGCURSMODE),A ; Disable flashing temp. - - LD HL,NUMBERBUF ; For the routine called. - LD A,C ; Restore number - ; - ; Now work out what happens... - ; - CP "A" ; Check for supported Ansi characters - JP Z,CUU ; Upwards - CP "B" - JP Z,CUD ; Downwards - CP "C" - JP Z,CUF ; Forward - CP "D" - JP Z,CUB ; Backward - CP "H" - JP Z,CUP ; Locate - CP "f" - JP Z,HVP ; Locate - CP "J" - JP Z,ED ; Clear screen - CP "m" - JP Z,SGR ; Set graphics renditon - CP "K" - JP Z,EL ; Clear to end of line - CP "s" - JP Z,SCP ; Save the cursor position - CP "u" - JP Z,RCP ; Restore the cursor position - -ANSIEXIT: ;CALL CURSORON ; If t - LD HL,NUMBERBUF ; Numbers buffer position - LD (NUMBERPOS),HL - XOR A - LD (CHARACTERNO),A ; Next time it runs, it will be the - ; first character - LD (HAVELOADED),A ; We haven't filled this byte! - LD (CHGCURSMODE),A ; Cursor allowed back again! - XOR A - LD (ANSIMODE),A - JR AnsiMore -NOTANSI: CP 000h ; Filter unprintable characters. - JR Z,AnsiMore - CALL PRNT -AnsiMore: POP AF - POP BC - POP DE - POP HL - RET - ; - ; The various routines needed to handle the filtered characters - ; -AnsiFirst: LD A,255 - LD (CHARACTERNO),A ; Next character is not first! - LD A,C ; Get character back - LD (ANSIFIRST),A ; Save first character to check later - CP "(" ; ( and [ have characters to follow - JP Z,AnsiMore ; and are legal. - CP "[" - JP Z,AnsiMore - CP 09Bh ; CSI - JP Z,AnsiF1 ; Pretend that "[" was first ;-) - JP ANSIEXIT ; = and > don't have anything to follow - ; them but are legal. - ; Others are illegal, so abandon anyway. -AnsiF1: LD A,"[" ; Put a "[" for first character - LD (ANSIFIRST),A - JP ANSIEXIT - -AnsiSemi: LD HL,(NUMBERPOS) ; Move the number pointer to the - LD A,(HAVELOADED) ; Did we put anything in this byte? - OR A - JR NZ,AS1 - LD (HL),255 ; Mark the fact that nothing was put in -AS1: INC HL ; move to next byte - LD (NUMBERPOS),HL - XOR A - LD (HAVELOADED),A ; New byte => not filled! - JP AnsiMore - -AnsiNumber: LD HL,(NUMBERPOS) ; Get address for number - LD A,(HAVELOADED) - OR A ; If value is zero - JR NZ,AN1 - LD A,C ; Get value into A - SUB "0" ; Remove ASCII offset - LD (HL),A ; Save and Exit - LD A,255 - LD (HAVELOADED),A ; Yes, we _have_ put something in! - JP AnsiMore - -AN1: LD A,(HL) ; Stored value in A; TBA in C - ADD A,A ; 2 * - LD D,A ; Save the 2* for later - ADD A,A ; 4 * - ADD A,A ; 8 * - ADD A,D ; 10 * - ADD A,C ; 10 * + new num - SUB "0" ; And remove offset from C value! - LD (HL),A ; Save and Exit. - JP AnsiMore ; Note routine will only work up to 100 - ; which should be okay for this application. - - ;-------------------------------- - ; GET NUMBER - ; - ; Gets the next number from - ; the list - ; - ; Entry - HL = address to get - ; from - ; Exit - HL = next address - ; A = value - ; IF a=255 then default value - ; If a=254 then end of sequence - ; Used - None - ;-------------------------------- -GetNumber: LD A,(HL) ; Get number - CP 254 - RET Z ; Return if end of sequence,ie still point to - ; end - INC HL ; Return pointing to next byte - RET ; Else next address and return - - ;*** ANSI UP - ; -CUU: CALL GetNumber ; Number into A - LD B,A ; Save value into B - CP 255 - JR NZ,CUUlp - LD B,1 ; Default value -CUUlp: LD A,(DSPXY+1) ; A <- Row - CP B ; Is it too far? - JR C,CUU1 - SUB B ; No, then go back that far. - JR CUU2 -CUU1: LD A,0 ; Make the choice, top line. -CUU2: LD (DSPXY+1),A ; Row <- A - JP ANSIEXIT - - ;*** ANSI DOWN - ; -CUD: LD A,(ANSIFIRST) - CP "[" - JP NZ,ANSIEXIT ; Ignore ESC(B - CALL GetNumber - LD B,A ; Save value in b - CP 255 - JR NZ,CUDlp - LD B,1 ; Default -CUDlp: LD A,(DSPXY+1) ; A <- Row - ADD A,B - CP ROW ; Too far? - JP C,CUD1 - LD A,ROW-1 ; Too far then bottom of screen -CUD1: LD (DSPXY+1),A ; Row <- A - JP ANSIEXIT - - ;*** ANSI RIGHT - ; -CUF: CALL GetNumber ; Number into A - LD B,A ; Value saved in B - CP 255 - JR NZ,CUFget - LD B,1 ; Default -CUFget: LD A,(DSPXY) ; A <- Column - ADD A,B ; Add movement. - CP 80 ; Too far? - JR C,CUF2 - LD A,79 ; Yes, right edge -CUF2: LD (DSPXY),A ; Column <- A - JP ANSIEXIT - - ;*** ANSI LEFT - ; -CUB: CALL GetNumber ; Number into A - LD B,A ; Save value in B - CP 255 - JR NZ,CUBget - LD B,1 ; Default -CUBget: LD A,(DSPXY) ; A <- Column - CP B ; Too far? - JR C,CUB1a - SUB B - JR CUB1b -CUB1a: LD A,0 -CUB1b: LD (DSPXY),A ; Column <-A - JP ANSIEXIT - - ;*** ANSI LOCATE - ; -HVP: -CUP: CALL GetNumber - CP 255 - CALL Z,DefaultLine ; Default = 1 - CP 254 ; Sequence End -> 1 - CALL Z,DefaultLine - CP ROW+1 ; Out of range then don't move - JP NC,ANSIEXIT - OR A - CALL Z,DefaultLine ; 0 means default, some strange reason - LD D,A - CALL GetNumber - CP 255 ; Default = 1 - CALL Z,DefaultColumn - CP 254 ; Sequence End -> 1 - CALL Z,DefaultColumn - CP 81 ; Out of range, then don't move - JP NC,ANSIEXIT - OR A - CALL Z,DefaultColumn ; 0 means go with default - LD E,A - EX DE,HL - DEC H ; Translate from Ansi co-ordinates to hardware - DEC L ; co-ordinates - LD (DSPXY),HL ; Set the cursor position. - JP ANSIEXIT - -DefaultColumn: -DefaultLine:LD A,1 - RET - - ;*** ANSI CLEAR SCREEN - ; -ED: CALL GetNumber - OR A - JP Z,ED1 ; Zero means first option - CP 254 ; Also default - JP Z,ED1 - CP 255 - JP Z,ED1 - CP 1 - JP Z,ED2 - CP 2 - JP NZ,ANSIEXIT - - ;*** Option 2 - ; -ED3: LD HL,0 - LD (DSPXY),HL ; Home the cursor - LD A,(JSW_FF) - OR A - JP NZ,ED_Set_LF - CALL CALCSCADDR - CALL CLRSCRN - JP ANSIEXIT - -ED_Set_LF: XOR A ; Note simply so that - LD (JSW_LF),A ; ESC[2J works the same as CTRL-L - JP ANSIEXIT - - ;*** Option 0 - ; -ED1: LD HL,(DSPXY) ; Get and save cursor position - LD A,H - OR L - JP Z,ED3 ; If we are at the top of the - ; screen and clearing to the bottom - ; then we are clearing all the screen! - PUSH HL - LD A,ROW-1 - SUB H ; ROW - Row - LD HL,0 ; Zero start - OR A ; Do we have any lines to add? - JR Z,ED1_2 ; If no bypass that addition! - LD B,A ; Number of lines to count - LD DE,80 -ED1_1: ADD HL,DE - DJNZ ED1_1 -ED1_2: EX DE,HL ; Value into DE - POP HL - LD A,80 - SUB L ; 80 - Columns - LD L,A ; Add to value before - LD H,0 - ADD HL,DE - PUSH HL ; Value saved for later - LD HL,(DSPXY) ; _that_ value again! - POP BC ; Number to blank - CALL CALCSCADDR - CALL CLRSCRN ; Now do it! - JP ANSIEXIT ; Then exit properly - - ;*** Option 1 - clear from cursor to beginning of screen - ; -ED2: LD HL,(DSPXY) ; Get and save cursor position - PUSH HL - LD A,H - LD HL,0 ; Zero start - OR A ; Do we have any lines to add? - JR Z,ED2_2 ; If no bypass that addition! - LD B,A ; Number of lines - LD DE,80 -ED2_1: ADD HL,DE - DJNZ ED2_1 -ED2_2: EX DE,HL ; Value into DE - POP HL - LD H,0 - ADD HL,DE - PUSH HL ; Value saved for later - LD HL,0 ; Find the begining! - POP BC ; Number to blank - CALL CLRSCRN ; Now do it! - JP ANSIEXIT ; Then exit properly - - ; *** ANSI CLEAR LINE - ; -EL: CALL GetNumber ; Get value - CP 0 - JP Z,EL1 ; Zero & Default are the same - CP 255 - JP Z,EL1 - CP 254 - JP Z,EL1 - CP 1 - JP Z,EL2 - CP 2 - JP NZ,ANSIEXIT ; Otherwise don't do a thing - - ;*** Option 2 - clear entire line. - ; - LD HL,(DSPXY) - LD L,0 - LD (DSPXY),HL - CALL CALCSCADDR - LD BC,80 ; 80 bytes to clear (whole line) - CALL CLRSCRN - JP ANSIEXIT - - ;*** Option 0 - Clear from Cursor to end of line. - ; -EL1: LD HL,(DSPXY) - LD A,80 ; Calculate distance to end of line - SUB L - LD C,A - LD B,0 - LD (DSPXY),HL - PUSH HL - POP DE - CALL CALCSCADDR - CALL CLRSCRN - JP ANSIEXIT - - ;*** Option 1 - clear from cursor to beginning of line. - ; -EL2: LD HL,(DSPXY) - LD C,L ; BC = distance from start of line - LD B,0 - LD L,0 - LD (DSPXY),HL - CALL CALCSCADDR - CALL CLRSCRN - JP ANSIEXIT - - ; In HL = XY Pos - ; Out = Screen address. -CALCSCADDR: PUSH AF - PUSH BC - PUSH DE - PUSH HL - LD A,H - LD B,H - LD C,L - LD HL,SCRN - OR A - JR Z,CALC3 - LD DE,80 -CALC2: ADD HL,DE - DJNZ CALC2 -CALC3: POP DE - ADD HL,BC - POP DE - POP BC - POP AF - RET - - ; HL = address - ; BC = length -CLRSCRN: DI - ; -MEMSW6: IF BUILD_TZFS+BUILD_RFSTZ > 0 - LD A,TZMM_MZ700_0 ; Enable access to the hardware by paging out the upper bank. - OUT (MMCFG),A - ENDIF - - LD (HLSAVE),HL ; 1 for later! - LD D,H - LD E,L - INC DE ; DE <- HL +1 - LD (BCSAVE),BC ; Save the value a little longer! - XOR A - LD (HL), A ; Blank this area! - LDIR ; *** just like magic *** - ; only I forgot it in 22a! - LD BC,(BCSAVE) ; Restore values - LD HL,(HLSAVE) - LD DE,2048 ; Move to attributes block - ADD HL,DE - LD D,H - LD E,L - INC DE ; DE = HL + 1 - LD A,(FONTSET) ; Save in the current values. - LD (HL),A - LDIR - -MEMSW7: IF BUILD_TZFS+BUILD_RFSTZ > 0 - LD A,TZMM_MZ700_2 ; Enable access to the hardware by paging out the upper bank. - OUT (MMCFG),A - ENDIF - ; - EI - RET - - ;*** ANSI SET GRAPHICS RENDITION - ; -SGR: CALL GetNumber - CP 254 ; 254 signifies end of sequence - JP Z,ANSIEXIT - OR A - CALL Z,AllOff - CP 255 ; Default means all off - CALL Z,AllOff - CP 1 - CALL Z,BoldOn - CP 2 - CALL Z,BoldOff - CP 4 - CALL Z,UnderOn - CP 5 - CALL Z,ItalicOn - CP 6 - CALL Z,ItalicOn - CP 7 - CALL Z,InverseOn - JP SGR ; Code is re-entrant - - ;-------------------------------- - ; - ; RESET GRAPHICS - ; - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -AllOff: PUSH AF ; Save registers - LD A,0C9h ; = off - LD (BOLDMODE),A ; Turn the flags off - LD (ITALICMODE),A - LD (UNDERSCMODE),A - LD (INVMODE),A - LD A,007h ; Black background, white chars. - LD (FONTSET),A ; Reset the bit map store - POP AF ; Restore register - RET - - ;-------------------------------- - ; - ; TURN BOLD ON - ; - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -BoldOn: PUSH AF ; Save register - XOR A ; 0 means on - LD (BOLDMODE),A -BOn1: LD A,(FONTSET) - SET 0,A ; turn ON indicator flag - LD (FONTSET),A - POP AF ; Restore register - RET - - ;-------------------------------- - ; - ; TURN BOLD OFF - ; - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -BoldOff: PUSH AF ; Save register - PUSH BC - LD A,0C9h ; &C9 means off - LD (BOLDMODE),A -BO1: LD A,(FONTSET) - RES 0,A ; turn OFF indicator flag - LD (FONTSET),A - POP BC - POP AF ; Restore register - RET - - ;-------------------------------- - ; - ; TURN ITALICS ON - ; (replaces flashing) - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -ItalicOn: PUSH AF ; Save AF - XOR A - LD (ITALICMODE),A ; 0 means on - LD A,(FONTSET) - SET 1,A ; turn ON indicator flag - LD (FONTSET),A - POP AF ; Restore register - RET - - ;-------------------------------- - ; - ; TURN UNDERLINE ON - ; - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -UnderOn: PUSH AF ; Save register - XOR A ; 0 means on - LD (UNDERSCMODE),A - LD A,(FONTSET) - SET 2,A ; turn ON indicator flag - LD (FONTSET),A - POP AF ; Restore register - RET - - ;-------------------------------- - ; - ; TURN INVERSE ON - ; - ; Entry - None - ; Exit - None - ; Used - None - ;-------------------------------- -InverseOn: PUSH AF ; Save register - XOR A ; 0 means on - LD (INVMODE),A - LD A,(FONTSET) - SET 3,A ; turn ON indicator flag - LD (FONTSET),A - POP AF ; Restore AF - RET - - ;*** ANSI SAVE CURSOR POSITION - ; -SCP: LD HL,(DSPXY) ; (backup) <- (current) - LD (CURSORPSAV),HL - JP ANSIEXIT - - ;*** ANSI RESTORE CURSOR POSITION - ; -RCP: LD HL,(CURSORPSAV) ; (current) <- (backup) - LD (DSPXY),HL - JP ANSIEXIT - - - ; Control variables for the Ansi Emulator. Inline with the code as this module - ; is a build time include and the target for execution is RAM. - ; -CURSORPSAV DS 2, 0 ; Cursor save position;default 0,0 -HAVELOADED DS 1, 0 ; To show that a value has been put in for Ansi emualtor. -ANSIFIRST DS 1, 0 ; Holds first character of Ansi sequence -NUMBERBUF DS 20, 0 ; Buffer for numbers in Ansi -NUMBERPOS DW 1, NUMBERBUF ; Address within buffer -CHARACTERNO DS 1, 0 ; Byte within Ansi sequence. 0=first,255=other -CURSORCOUNT DS 1, 0 ; 1/50ths of a second since last change -FONTSET DS 1, 071H ; Ansi font setup - Blue background White Foreground as default. -JSW_FF DS 1, 0 ; Byte value to turn on/off FF routine -JSW_LF DS 1, 0 ; Byte value to turn on/off LF routine -CHARACTER DS 1, 0 ; To buffer character to be printed. -CURSORPOS DS 2, 0 ; Cursor position, default 0,0. -BOLDMODE DS 1, 0 -HIBRITEMODE DS 1, 0 ; 0 means on, &C9 means off -UNDERSCMODE DS 1, 0 -ITALICMODE DS 1, 0 -INVMODE DS 1, 0 -CHGCURSMODE DS 1, 0 -ANSIMODE DS 1, 0 ; 1 = on, 0 = off -BCSAVE DW 1, 0 ; Register save for when stack is not paged in. -DESAVE DW 1, 0 -HLSAVE DW 1, 0 -COLOUR EQU 0 - - ENDIF - ;------------------------------------------------------------------------------- - ; END OF ANSI TERMINAL FUNCTIONALITY - ;------------------------------------------------------------------------------- - - -REBOOT: DI -REBOOTTZ: IF BUILD_TZFS +BUILD_RFSTZ > 0 - LD A,TZMM_TZFS - OUT (MMCFG),A - ENDIF - -REBOOT80A: IF BUILD_MZ80A = 1 - ENDIF - - ; For RFS we need to switch back to the 40 char monitor. -REBOOTRFS: IF BUILD_RFS+BUILD_80C = 2 - LD A, ROMBANK0 ; Switch to 40Char monitor. - LD (ROMBK1),A - LD (BNKSELMROM),A - ENDIF - JP 0000H ; Now restart in the SA1510 monitor. - - ;------------------------------------------------------------------------------- - ; START OF STATIC LOOKUP TABLES AND CONSTANTS - ;------------------------------------------------------------------------------- - - ;-------------------------------------- - ; Test Message table - ;-------------------------------------- - -BFREE: DB " Bytes free",CR,LF,0,0 -SIGNON: IF BUILD_TZFS = 1 - DB "Microsoft Basic (TZFS) Ver 4.7b",CR,LF - DB "Copyright ",40,"C",41 - DB " 1978 by Microsoft",CR,LF,0,0 - ENDIF - IF BUILD_RFSTZ = 1 - DB "Microsoft Basic (RFS TZ) Ver 4.7b",CR,LF - DB "Copyright ",40,"C",41 - DB " 1978 by Microsoft",CR,LF,0,0 - ENDIF - IF BUILD_RFS = 1 - DB "Microsoft Basic (RFS) Ver 4.7b",CR,LF - DB "Copyright ",40,"C",41 - DB " 1978 by Microsoft",CR,LF,0,0 - ENDIF - IF BUILD_MZ80A = 1 - DB "Microsoft Basic (MZ-80A) Ver 4.7b",CR,LF - DB "Copyright ",40,"C",41 - DB " 1978 by Microsoft",CR,LF,0,0 - ENDIF -SVCRESPERR: DB "I/O Response Error, time out!", CR, NUL -SVCIOERR: DB "I/O Error, time out!", CR, NUL -MSGRECORD: DB CR, "Press RECORD+PLAY", CR, NUL -MSGPLAY: DB CR, "Press PLAY", CR, NUL -MSGWRITING: DB "Writing \"", NUL -MSGWRITING2:DB "\"", CR, NUL -ANSIERR: DB "Bad value!", CR, NUL - - ;------------------------------------------------------------------------------- - ; END OF STATIC LOOKUP TABLES AND CONSTANTS - ;------------------------------------------------------------------------------- - - ;------------------------------------------------------------------------------- - ; START OF DEBUGGING FUNCTIONALITY - ;------------------------------------------------------------------------------- - ; Debug routine to print out all registers and dump a section of memory for analysis. - ; -DEBUG: IF ENADEBUG = 1 - LD (DBGSTACKP),SP - LD SP,DBGSTACK - ; - PUSH AF - PUSH BC - PUSH DE - PUSH HL - ; - PUSH AF - PUSH HL - PUSH DE - PUSH BC - PUSH AF - LD DE, INFOMSG - CALL MONPRTSTR - POP BC - LD A,B - CALL PRTHX - LD A,C - CALL PRTHX - LD DE, INFOMSG2 - CALL MONPRTSTR - POP BC - LD A,B - CALL PRTHX - LD A,C - CALL PRTHX - LD DE, INFOMSG3 - CALL MONPRTSTR - POP DE - LD A,D - CALL PRTHX - LD A,E - CALL PRTHX - LD DE, INFOMSG4 - CALL MONPRTSTR - POP HL - LD A,H - CALL PRTHX - LD A,L - CALL PRTHX - LD DE, INFOMSG5 - CALL MONPRTSTR - LD HL,(DBGSTACKP) - LD A,H - CALL PRTHX - LD A,L - CALL PRTHX - CALL NL - - POP AF - JR C, SKIPDUMP - ; - LD HL,04000H ; WRKSPC ; Dump the startup vectors. - LD DE, 1000H - ADD HL, DE - EX DE,HL - LD HL,WRKSPC - CALL DUMPX - - LD HL,00000h ; Dump the startup vectors. - LD DE, 00A0H - ADD HL, DE - EX DE,HL - LD HL,00000h - CALL DUMPX - - LD HL,IBUFE ; Dump the data area. - LD DE, 0300H - ADD HL, DE - EX DE,HL - LD HL,IBUFE - CALL DUMPX - -SKIPDUMP: ;JR SKIPDUMP - POP HL - POP DE - POP BC - POP AF - ; - LD SP,(DBGSTACKP) - RET - - ; HL = Start - ; DE = End -DUMPX: LD A,10 -DUM1: LD (TMPCNT),A -DUM3: LD B,010h - LD C,02Fh - CALL NLPHL -DUM2: CALL SPHEX - INC HL - PUSH AF - LD A,(DSPXY) - ADD A,C - LD (DSPXY),A - POP AF - CP 020h - JR NC,L0D51 - LD A,02Eh -L0D51: CALL PRNT - LD A,(DSPXY) - INC C - SUB C - LD (DSPXY),A - DEC C - DEC C - DEC C - PUSH HL - SBC HL,DE - POP HL - JR NC,DUM7 -L0D78: DJNZ DUM2 - LD A,(TMPCNT) - DEC A - LD (TMPCNT),A - JR NZ,DUM3 -DUM4: CALL CHKKY - CP 0FFH - JR NZ,DUM4 - CALL GETKY - CP 'D' - JR NZ,DUM5 - LD A,8 - JR DUM1 -DUM5: CP 'U' - JR NZ,DUM6 - PUSH DE - LD DE,00100H - OR A - SBC HL,DE - POP DE - LD A,8 - JR DUM1 -DUM6: CP 'X' - JR Z,DUM7 - JR DUMPX -DUM7: CALL NL - RET - -NLPHL: CALL NL - CALL PRTHL - RET - - ; SPACE PRINT AND DISP ACC - ; INPUT:HL=DISP. ADR. -SPHEX: CALL PRTS ; SPACE PRINT - LD A,(HL) - CALL PRTHX ; DSP OF ACC (ASCII) - LD A,(HL) - RET - - ; Debugger messages, bit cryptic but this is due to limited space on the screen. - ; -INFOMSG: DB "AF=", NUL -INFOMSG2: DB ",BC=", 000H -INFOMSG3: DB ",DE=", 000H -INFOMSG4: DB ",HL=", 000H -INFOMSG5: DB ",SP=", 000H - - ; Seperate stack for the debugger so as not to affect anything it is reporting on. - ; -TMPCNT DS virtual 2 ; TEMPORARY COUNTER -DBGSTACKP: DS 2 - DS 128, 000H -DBGSTACK: EQU $ - - ENDIF - ;------------------------------------------------------------------------------- - ; END OF DEBUGGING FUNCTIONALITY - ;------------------------------------------------------------------------------- -CODEEND: - - ;------------------------------------------------------------------------------- - ; BASIC RELOCATION - ;------------------------------------------------------------------------------- - - - ; For TZFS builds the image needs to be relocated from 0x1200 to 0x0000 on startup after switching the memory mode. -RELOCSTART: IF BUILD_TZFS+BUILD_RFSTZ > 0 - ORG $ + 1200H - - ; Switch memory. -RELOC: LD A, TZMM_MZ700_0 ; Switch to the MZ700 memory map where the lower 4K 0000:0FFF is in block 6, we therefore preserve the Monitor for exit. - OUT (MMCFG),A - - ; Move the image down and start. - LD DE, 0000H - LD HL, 01200H - LD BC, CODEEND - CODESTART - LDIR - JP 0000H - ENDIF - - ; For RFS builds a two stage relocation is needed, a) relocate to tranzputer RAM, b) run the TZFS relocation code. -RELOC_RFS: IF BUILD_RFSTZ = 1 - - ; Switch memory. -RELOCRFS: LD A, TZMM_BOOT ; Go to boot mode, copy the relocation code to EC80H and execute. - OUT (MMCFG),A - - ; Move the relocation code to EC80H. - LD DE, 0EC80H - LD HL, RELOCRFS2 - LD BC, RELOCRFS2END - RELOCRFS2 - LDIR - JP 0EC80H ; Run the relocation code. - ENDIF -RELOCEND: - -RELOCRFS2: IF BUILD_TZFS+BUILD_RFSTZ > 0 - ; Move the image down into tranZPUter memory and then start the real relocation. - LD HL, 01200H - LD BC, (CODEEND - CODESTART) + (RELOCEND - RELOC) ; Size of program. - - ; Fetch a byte from main DRAM and write it into Bank 0 same location. -RELOCRFS2_1: LD A,TZMM_BOOT - OUT (MMCFG),A - LD A,(HL) - ; - EX AF,AF' - LD A,TZMM_TZFS - OUT (MMCFG),A - EX AF,AF' - ; - LD (HL),A - INC HL - DEC BC - LD A,B - OR C - JR NZ, RELOCRFS2_1 - ; - LD DE, 00000H ; Copy the reboot handler into Bank 0 at 00000H. - LD HL, 0EC80H + (REBOOTTZRFS - RELOCRFS2) - LD BC, RELOCRFS2END - REBOOTTZRFS - LDIR - ; - JP RELOC ; Jump into the original TZFS relocation code. - - ; Reboot handler for TZ/RFS mode. This code is transferred into RAM bank 0 at 0000H as this is not used for BASIC - ; and executed when a return to the Monitor ROM is needed. Location 004AH in the Monitor ROM is the startup vector. -REBOOTTZRFS: ALIGN_NOPS $ + 04AH - 4 -REBOOTTZRFS1: LD A,TZMM_ORIG - OUT (MMCFG),A - JP 00000H -RELOCRFS2END:ENDIF - - - ; Variables start at the end of the code in the running image (not relocatable image). - ORG CODEEND -GVARSTART EQU $ ; Start of variables. - - ; Pad out so that the keyboard buffer is aligned on a 256 byte block boundary. - ALIGN ($ + 0100H) & 0FF00H - -KEYBUF: DS virtual KEYBUFSIZE ; Interrupt driven keyboard buffer. -KEYCOUNT: DS virtual 1 -KEYWRITE: DS virtual 2 ; Pointer into the buffer where the next character should be placed. -KEYREAD: DS virtual 2 ; Pointer into the buffer where the next character can be read. -KEYLAST: DS virtual 1 ; Last key value -KEYRPT: DS virtual 1 ; Key repeat counter - -MONVARSTRT: EQU $ - - ; For MZ80A or MZ80A with RFS we share the original monitor variable space. - IF BUILD_MZ80A+BUILD_RFS > 0 - ORG 010F0H - ENDIF -SPV: -IBUFE: ; TAPE BUFFER (128 BYTES) -ATRB: DS virtual 1 ; ATTRIBUTE -NAME: DS virtual 17 ; FILE NAME -SIZE: DS virtual 2 ; BYTESIZE -DTADR: DS virtual 2 ; DATA ADDRESS -EXADR: DS virtual 2 ; EXECUTION ADDRESS -COMNT: DS virtual 92 ; Comment / code area of CMT header. -SWPW: DS virtual 10 ; SWEEP WORK -KDATW: DS virtual 2 ; KEY WORK -KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) -DSPXY: DS virtual 2 ; DISPLAY COORDINATES -MANG: DS virtual 6 ; COLUMN MANAGEMENT -MANGE: DS virtual 1 ; COLUMN MANAGEMENT END -PBIAS: DS virtual 1 ; PAGE BIAS -ROLTOP: DS virtual 1 ; ROLL TOP BIAS -MGPNT: DS virtual 1 ; COLUMN MANAG. POINTER -PAGETP: DS virtual 2 ; PAGE TOP -ROLEND: DS virtual 1 ; ROLL END - DS virtual 14 ; BIAS -FLASH: DS virtual 1 ; FLASHING DATA -SFTLK: DS virtual 1 ; SHIFT LOCK -REVFLG: DS virtual 1 ; REVERSE FLAG -SPAGE: DS virtual 1 ; PAGE CHANGE -FLSDT: DS virtual 1 ; CURSOR DATA -STRGF: DS virtual 1 ; STRING FLAG -DPRNT: DS virtual 1 ; TAB COUNTER -TMCNT: DS virtual 2 ; TAPE MARK COUNTER -SUMDT: DS virtual 2 ; CHECK SUM DATA -CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA -AMPM: DS virtual 1 ; AMPM DATA -TIMFG: DS virtual 1 ; TIME FLAG -SWRK: DS virtual 1 ; KEY SOUND FLAG -TEMPW: DS virtual 1 ; TEMPO WORK -ONTYO: DS virtual 1 ; ONTYO WORK -OCTV: DS virtual 1 ; OCTAVE WORK -RATIO: DS virtual 2 ; ONPU RATIO - - ; Remaining variables inside MS-BASIC variable space. - IF BUILD_MZ80A+BUILD_RFS > 0 - ORG MONVARSTRT - ENDIF - -DSPXYADDR: DS virtual 2 ; Address of last known position. - -FLASHCTL: DS virtual 1 ; CURSOR FLASH CONTROL. BIT 0 = Cursor On/Off, BIT 1 = Cursor displayed. -TIMESEC: DS virtual 6 ; RTC 48bit TIME IN MILLISECONDS -LINECNT: DS virtual 2 ; Counter for displayed lines. - -ANSIENABLE: DS virtual 1 ; Ansi Terminal flag. -; -TPFLAG DS virtual 1 -SECTPOS DS virtual 2 - -SPISRSAVE: DS virtual 2 - ; Stack space for the Interrupt Service Routine. - DS virtual 32 ; Max 8 stack pushes. -ISRSTACK EQU $ -STACKE: EQU $ - DS virtual 128 -STACK: EQU $ - - -WRKSPC DS virtual 3 ; 0 BASIC Work space -USR DS virtual 3 ; 3H "USR (x)" jump -OUTSUB DS virtual 1 ; 6H "OUT p,n" -OTPORT DS virtual 2 ; 7H Port (p) -DIVSUP DS virtual 1 ; 9H Division support routine -DIV1 DS virtual 4 ; 0AH <- Values -DIV2 DS virtual 4 ; 0EH <- to -DIV3 DS virtual 3 ; 12H <- be -DIV4 DS virtual 2 ; 15H <-inserted -SEED DS virtual 35 ; 17H Random number seed -LSTRND DS virtual 4 ; 3AH Last random number -INPSUB DS virtual 1 ; 3EH #INP (x)" Routine -INPORT DS virtual 2 ; 3FH PORT (x) -NULLS DS virtual 1 ; 41H Number of nulls -LWIDTH DS virtual 1 ; 42H Terminal width -COMMAN DS virtual 1 ; 43H Width for commas -NULFLG DS virtual 1 ; 44H Null after input byte flag -CTLOFG DS virtual 1 ; 45H Control "O" flag -LINESC DS virtual 2 ; 46H Lines counter -LINESN DS virtual 2 ; 48H Lines number -CHKSUM DS virtual 2 ; 4AH Array load/save check sum -NMIFLG DS virtual 1 ; 4CH Flag for NMI break routine -BRKFLG DS virtual 1 ; 4DH Break flag -RINPUT DS virtual 3 ; 4EH Input reflection -POINT DS virtual 3 ; 51H "POINT" reflection (unused) -PSET DS virtual 3 ; 54H "SET" reflection -RESET DS virtual 3 ; 57H "RESET" reflection -STRSPC DS virtual 2 ; 5AH Bottom of string space -LINEAT DS virtual 2 ; 5CH Current line number -BASTXT DS virtual 3 ; 5EH Pointer to start of program -BUFFER DS virtual 5 ; 61H Input buffer -STACKI DS virtual 69 ; 66H Initial stack -CURPOS DS virtual 1 ; 0ABH Character position on line -LCRFLG DS virtual 1 ; 0ACH Locate/Create flag -TYPE DS virtual 1 ; 0ADH Data type flag -DATFLG DS virtual 1 ; 0AEH Literal statement flag -LSTRAM DS virtual 2 ; 0AFH Last available RAM -TMSTPT DS virtual 2 ; 0B1H Temporary string pointer -TMSTPL DS virtual 12 ; 0B3H Temporary string pool -TMPSTR DS virtual 4 ; 0BFH Temporary string -STRBOT DS virtual 2 ; 0C3H Bottom of string space -CUROPR DS virtual 2 ; 0C5H Current operator in EVAL -LOOPST DS virtual 2 ; 0C7H First statement of loop -DATLIN DS virtual 2 ; 0C9H Line of current DATA item -FORFLG DS virtual 1 ; 0CBH "FOR" loop flag -LSTBIN DS virtual 1 ; 0CCH Last byte entered -READFG DS virtual 1 ; 0CDH Read/Input flag -BRKLIN DS virtual 2 ; 0CEH Line of break -NXTOPR DS virtual 2 ; 0D0H Next operator in EVAL -ERRLIN DS virtual 2 ; 0D2H Line of error -CONTAD DS virtual 2 ; 0D4H Where to CONTinue -PROGND DS virtual 2 ; 0D6H End of program -VAREND DS virtual 2 ; 0D8H End of variables -ARREND DS virtual 2 ; 0DAH End of arrays -NXTDAT DS virtual 2 ; 0DCH Next data item -FNRGNM DS virtual 2 ; 0DEH Name of FN argument -FNARG DS virtual 4 ; 0E0H FN argument value -FPREG DS virtual 3 ; 0E4H Floating point register -FPEXP DS virtual 1 ; FPREG+3 Floating point exponent -SGNRES DS virtual 1 ; 0E8H Sign of result -PBUFF DS virtual 13 ; 0E9H Number print buffer -MULVAL DS virtual 3 ; 0F6H Multiplier -PROGST DS virtual 100 ; 0F9H Start of program text area -STLOOK DS virtual 1 ; 15DH Start of memory test - -GVAREND EQU $ ; End of variables diff --git a/software/asm/mz80afi.asm b/software/asm/mz80afi.asm deleted file mode 100644 index e42477a..0000000 --- a/software/asm/mz80afi.asm +++ /dev/null @@ -1,371 +0,0 @@ -; Disassembly of the file "D:\MZ80AFI.BIN" -; -; CPU Type: Z80 -; -; Using the opcode map file "D:\DZ80-INI.MAP" -; ; Created with dZ80 2.0 -; -; on Thursday, 06 of February 2020 at 01:38 PM -; -i ; Bring in additional resources. - INCLUDE "rfs_definitions.asm" - INCLUDE "macros.asm" - - - ;====================================== - ; - ; Floppy Disk Interface - ; - ;====================================== - ORG 0E800H - -FLOPPY: NOP - LD DE,01008H - LD HL,PRMBLK - LD BC,0000BH - LDIR - CALL L0151 -L000F: CALL NL - LD DE,BOOTDRV - CALL MSG - LD DE,011A3H - CALL GETL - LD A,(DE) - CP 01BH - JP Z,SS - LD HL,0000CH - ADD HL,DE - LD A,(HL) - CP 00DH - JR Z,L003A ; (+00dh) - CALL 03F9H - JR C,L000F ; (-023h) - DEC A - CP 004H - JR NC,L000F ; (-028h) - LD (01008H),A -L003A: LD IX,01008H - CALL L01BA - LD HL,0CE00H - LD DE,DSKID - LD B,007H -L0049: LD C,(HL) - LD A,(DE) - CP C - JP NZ,L008C - INC HL - INC DE - DJNZ L0049 ; (-00ah) - CALL NL - LD DE,IPLLOAD - CALL MSG - LD DE,0CE07H - CALL MSG - LD HL,(0CE16H) - LD (IX+005H),L - LD (IX+006H),H - LD HL,(0CE14H) - LD (IX+003H),L - LD (IX+004H),H - LD HL,(0CE1EH) - LD (IX+001H),L - LD (IX+002H),H - CALL L01BA - CALL L0151 - LD HL,(0CE18H) - JP (HL) - -L0087: LD DE,LOADERR - JR L008F ; (+003h) - -L008C: LD DE,DSKNOTMST -L008F: CALL NL - CALL MSG - CALL NL - LD DE,DSKDAT - CALL MELDY - JP SS - -BOOTDRV: DB "BOOY DRIVE ?", 00DH -LOADERR: DB "LOADING ERROR", 00DH -IPLLOAD: DB "IPL IS LOADING ", 00DH -DSKID: DB 002H, "IPLPRO" -DSKDAT: DB "A0", 0D7H, "ARA", 0D7H, "AR", 00DH -PRMBLK: DB 000H, 000H, 000H, 000H, 001H, 000H, 0CEH, 000H, 000H, 000H, 000H -DSKNOTMST: DB "THIS DISKETTE IS NOT MASTER", 00Dh - -L0104: LD A,(01001H) - RRCA - CALL NC,L0138 - LD A,(IX+000H) - OR 084H - OUT (0DCH),A - XOR A - LD (01000H),A - LD HL,00000H -L0119: DEC HL - LD A,H - OR L - JP Z,L029D - IN A,(0D8H) - CPL - RLCA - JR C,L0119 ; (-00ch) - LD C,(IX+000H) - LD HL,01002H - LD B,000H - ADD HL,BC - BIT 0,(HL) - JR NZ,L0137 ; (+005h) - CALL L0164 - SET 0,(HL) -L0137: RET - -L0138: LD A,080H - OUT (0DCH),A - LD B,010H -L013E: CALL L02C7 - DJNZ L013E ; (-005h) - LD A,001H - LD (01001H),A - RET - -L0149: LD A,01BH - CALL L0171 - AND 099H - RET - -L0151: XOR A - OUT (0DCH),A - LD (01002H),A - LD (01003H),A - LD (01004H),A - LD (01005H),A - LD (01001H),A - RET - -L0164: LD A,00BH - CALL L0171 - AND 085H - XOR 004H - RET Z - JP L029D - -L0171: LD (01000H),A - CPL - OUT (0D8H),A - CALL L017E - IN A,(0D8H) - CPL - RET - -L017E: PUSH DE - PUSH HL - CALL L02C0 - LD E,007H -L0185: LD HL,00000H -L0188: DEC HL - LD A,H - OR L - JR Z,L0196 ; (+009h) - IN A,(0D8H) - CPL - RRCA - JR C,L0188 ; (-00bh) - POP HL - POP DE - RET - -L0196: DEC E - JR NZ,L0185 ; (-014h) - JP L029D - -L019C: PUSH DE - PUSH HL - CALL L02C0 - LD E,007H -L01A3: LD HL,00000H -L01A6: DEC HL - LD A,H - OR L - JR Z,L01B4 ; (+009h) - IN A,(0D8H) - CPL - RRCA - JR NC,L01A6 ; (-00bh) - POP HL - POP DE - RET - -L01B4: DEC E - JR NZ,L01A3 ; (-014h) - JP L029D - -L01BA: CALL L0220 -L01BD: CALL L0229 -L01C0: CALL L0249 - CALL L0149 - JR NZ,L0216 ; (+04eh) - CALL L0259 - PUSH IX - LD IX,L03FE - LD IY,L01DF - DI - LD A,094H - CALL L028A -L01DB: LD B,000H - JP (IX) - -L01DF: INI - JP NZ,L03FE - POP IX - INC (IX+008H) - LD A,(IX+008H) - PUSH IX - LD IX,L03FE - CP 011H - JR Z,L01FB ; (+005h) - DEC D - JR NZ,L01DB ; (-01eh) - JR L01FC ; (+001h) -L01FB: DEC D -L01FC: CALL L0294 - CALL L02D2 - POP IX - IN A,(0D8H) - CPL - AND 0FFH - JR NZ,L0216 ; (+00bh) - CALL L0278 - JP Z,L021B - LD A,(IX+007H) - JR L01C0 ; (-056h) -L0216: CALL L026A - JR L01BD ; (-05eh) - -L021B: LD A,080H - OUT (0DCH),A - RET - -L0220: CALL L02A3 - LD A,00AH - LD (01006H),A - RET - -L0229: CALL L0104 - LD D,(IX+004H) - LD A,(IX+003H) - OR A - JR Z,L0236 ; (+001h) - INC D -L0236: LD A,(IX+00AH) - LD (IX+008H),A - LD A,(IX+009H) - LD (IX+007H),A - LD L,(IX+005H) - LD H,(IX+006H) - RET - -L0249: SRL A - CPL - OUT (0DBH),A - JR NC,L0254 ; (+004h) - LD A,001H - JR L0255 ; (+001h) -L0254: XOR A -L0255: CPL - OUT (0DDH),A - RET - -L0259: LD C,0DBH - LD A,(IX+007H) - SRL A - CPL - OUT (0D9H),A - LD A,(IX+008H) - CPL - OUT (0DAH),A - RET - -L026A: LD A,(01006H) - DEC A - LD (01006H),A - JP Z,L029D - CALL L0164 - RET - -L0278: LD A,(IX+008H) - CP 011H - JR NZ,L0287 ; (+008h) - LD A,001H - LD (IX+008H),A - INC (IX+007H) -L0287: LD A,D - OR A - RET - -L028A: LD (01000H),A - CPL - OUT (0D8H),A - CALL L019C - RET - -L0294: LD A,0D8H - CPL - OUT (0D8H),A - CALL L017E - RET - -L029D: CALL L0151 - JP L0087 - -L02A3: LD B,000H - LD DE,00010H - LD L,(IX+001H) - LD H,(IX+002H) - XOR A -L02AF: SBC HL,DE - JR C,L02B6 ; (+003h) - INC B - JR L02AF ; (-007h) -L02B6: ADD HL,DE - LD H,B - INC L - LD (IX+009H),H - LD (IX+00AH),L - RET - -L02C0: PUSH DE - LD DE,00007H - JP L02CB - -L02C7: PUSH DE - LD DE,01013H -L02CB: DEC DE - LD A,E - OR D - JR NZ,L02CB ; (-005h) - POP DE - RET - -L02D2: PUSH AF - LD A,(0119CH) - CP 0F0H - JR NZ,L02DB ; (+001h) - EI -L02DB: POP AF - RET - - ALIGN 0EBFDh - DB 0FFh - -L03FE: JP (IY) -;DB 0DDH -; DB 0E9H - - ; Ensure we fill the entire 1K by padding with FF's. - ALIGN 0EFFDh - DB 0FFh - -LF7FE: DB 0fDH - DB 0E9H diff --git a/software/asm/ramcheck.asm b/software/asm/ramcheck.asm deleted file mode 100644 index dce76f5..0000000 --- a/software/asm/ramcheck.asm +++ /dev/null @@ -1,155 +0,0 @@ - -LETNL: EQU 0006h -PRNTS: EQU 000Ch -PRNT: EQU 0012h -MSG: EQU 0015h -MONIT: EQU 0086h -PRTHL: EQU 03BAh -PRTHX: EQU 03C3h -DPCT: EQU 0DDCh -MSTART: EQU 1200h - - ORG 10F0h - - DB 01h ; Code Type, 01 = Machine Code. - DB "RAM TEST V1.0", 0Dh, 00h, 00h ; Title/Name (17 bytes). - DW MSTART - START ; Size of program. - DW START ; Load address of program. - DW START ; Exec address of program. - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h ; Comment (104 bytes). - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h - - ORG 01200h - -START: LD DE,TITLE - CALL MSG - CALL LETNL - LD B, 20 ; Number of loops -LOOP: LD HL,MSTART ; Start of checked memory, - LD D,0CEh ; End memory check CE00 -LOOP1: LD A,000h - CP L - JR NZ,LOOP1b - CALL PRTHL ; Print HL as 4digit hex. - LD A,0C4h ; Move cursor left. - LD E,004h ; 4 times. -LOOP1a: CALL DPCT - DEC E - JR NZ,LOOP1a -LOOP1b: INC HL - LD A,H - CP D ; Have we reached end of memory. - JR Z,LOOP3 ; Yes, exit. - LD A,(HL) ; Read memory location under test, ie. 0. - CPL ; Subtract, ie. FF - A, ie FF - 0 = FF. - LD (HL),A ; Write it back, ie. FF. - SUB (HL) ; Subtract written memory value from A, ie. should be 0. - JR NZ,LOOP2 ; Not zero, we have an error. - LD A,(HL) ; Reread memory location, ie. FF - CPL ; Subtract FF - FF - LD (HL),A ; Write 0 - SUB (HL) ; Subtract 0 - JR Z,LOOP1 ; Loop if the same, ie. 0 -LOOP2: LD A,16h - CALL PRNT ; Print A - CALL PRTHX ; Print HL as 4 digit hex. - CALL PRNTS ; Print space. - XOR A - LD (HL),A - LD A,(HL) ; Get into A the failing bits. - CALL PRTHX ; Print A as 2 digit hex. - CALL PRNTS ; Print space. - LD A,0FFh ; Repeat but first load FF into memory - LD (HL),A - LD A,(HL) - CALL PRTHX ; Print A as 2 digit hex. - NOP - JR LOOP4 - -LOOP3: LD DE,OKCHECK - CALL MSG ; Print check message in DE - LD A,B ; Print loop count. - CALL PRTHX - LD DE,OKMSG - CALL MSG ; Print ok message in DE - DEC B - JR NZ,LOOP - LD DE,DONEMSG - CALL MSG ; Print check message in DE - JP MONIT - -OKCHECK: DB 11h - DB "CHECK: ", 0Dh -OKMSG: DB "OK.", 0Dh -DONEMSG: DB 11h - DB "RAM TEST COMPLETE.", 0Dh - -LOOP4: LD B,09h - CALL PRNTS ; Print space. - XOR A ; Zero A - SCF ; Set Carry -LOOP5: PUSH AF ; Store A and Flags - LD (HL),A ; Store 0 to bad location. - LD A,(HL) ; Read back - CALL PRTHX ; Print A as 2 digit hex. - CALL PRNTS ; Print space - POP AF ; Get back A (ie. 0 + C) - RLA ; Rotate left A. Bit LSB becomes Carry (ie. 1 first instance), Carry becomes MSB - DJNZ LOOP5 ; Loop if not zero, ie. print out all bit locations written and read to memory to locate bad bit. - XOR A ; Zero A, clears flags. - LD A,80h - LD B,08h -LOOP6: PUSH AF ; Repeat above but AND memory location with original A (ie. 80) - LD C,A ; Basically walk through all the bits to find which one is stuck. - LD (HL),A - LD A,(HL) - AND C - NOP - JR Z,LOOP8 ; If zero then print out the bit number - NOP - NOP - LD A,C - CPL - LD (HL),A - LD A,(HL) - AND C - JR NZ,LOOP8 ; As above, if the compliment doesnt yield zero, print out the bit number. -LOOP7: POP AF - RRCA - NOP - DJNZ LOOP6 - JP MONIT - -LOOP8: CALL LETNL ; New line. - LD DE,BITMSG ; BIT message - CALL MSG ; Print message in DE - LD A,B - DEC A - CALL PRTHX ; Print A as 2 digit hex, ie. BIT number. - CALL LETNL ; New line - LD DE,BANKMSG ; BANK message - CALL MSG ; Print message in DE - LD A,H - CP 50h ; 'P' - JR NC,LOOP9 ; Work out bank number, 1, 2 or 3. - LD A,01h - JR LOOP11 - -LOOP9: CP 90h - JR NC,LOOP10 - LD A,02h - JR LOOP11 - -LOOP10: LD A,03h -LOOP11: CALL PRTHX ; Print A as 2 digit hex, ie. BANK number. - JR LOOP7 - -BITMSG: DB " BIT: ", 0Dh -BANKMSG: DB " BANK: ", 0Dh - -TITLE: DB "SHARPMZ RAM TEST (C) P. SMART 2018", 0Dh, 00h diff --git a/software/asm/rfs.asm b/software/asm/rfs.asm deleted file mode 100644 index 9ddcbd8..0000000 --- a/software/asm/rfs.asm +++ /dev/null @@ -1,1347 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: rfs.asm -;- Created: July 2019 -;- Author(s): Philip Smart -;- Description: Sharp MZ series Rom Filing System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade. -;- -;- Credits: -;- Copyright: (c) 2018-2023 Philip Smart -;- -;- History: July 2019 - Merged 2 utilities to create this compilation. -; May 2020 - Bank switch changes with release of v2 pcb with coded latch. The coded -; latch adds additional instruction overhead as the control latches share -; the same address space as the Flash RAMS thus the extra hardware to -; only enable the control registers if a fixed number of reads is made -; into the upper 8 bytes which normally wouldnt occur. Caveat - ensure -; that no loop instruction is ever placed into EFF8H - EFFFH. -; July 2020 - Updated for the v2.1 hardware. RFS can run with a tranZPUter board with -; or without the K64 I/O processor. RFS wont use the K64 processor all -; operations are done by the Z80 under RFS. -;- April 2021- Updates for the v2.1 RFS board. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - ; Bring in additional resources. - INCLUDE "rfs_definitions.asm" - - - ;============================================================ - ; - ; USER ROM BANK 0 - Main RFS Entry point and functions. - ; - ;============================================================ - ORG UROMADDR - - - ;-------------------------------- - ; Common code spanning all banks. - ;-------------------------------- -ROMFS: NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -ROMFS_0: LD A,(BNKCTRLRST) - DJNZ ROMFS_0 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - LD (ROMCTL),A ; Save to memory the value in the bank control register - this register is used for SPI etc so need to remember its setting. - XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 - LD (BNKSELMROM),A - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - JP ROMFS_1 ; Skip the reset vector. - JP 00000H ; Other banks will switch at this point thus forcing a full reset. - - ALIGN_NOPS UROMBSTBL - - ;------------------------------------------------------------------------------------------ - ; Bank switching code, allows a call to code in another bank. - ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. - ;------------------------------------------------------------------------------------------ - ; -BKSW0to0: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK0 ; Required bank to call. - JR BKSW0_0 -BKSW0to1: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK1 ; Required bank to call. - JR BKSW0_0 -BKSW0to2: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK2 ; Required bank to call. - JR BKSW0_0 -BKSW0to3: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK3 ; Required bank to call. - JR BKSW0_0 -BKSW0to4: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK4 ; Required bank to call. - JR BKSW0_0 -BKSW0to5: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK5 ; Required bank to call. - JR BKSW0_0 -BKSW0to6: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK6 ; Required bank to call. - JR BKSW0_0 -BKSW0to7: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK7 ; Required bank to call. - ; -BKSW0_0: PUSH HL ; Place function to call on stack - LD HL, BKSWRET0 ; Place bank switchers return address on stack. - EX (SP),HL - LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. - LD (BNKSELUSER), A ; Repeat the bank switch B times to enable the bank control register and set its value. - JP (HL) ; Jump to required function. -BKSWRET0: POP AF ; Get bank which called us. - LD (BNKSELUSER), A ; Return to that bank. - POP AF - RET ; Return to caller. - - ALIGN RFSJMPTABLE - ORG RFSJMPTABLE - - ;------------------------------------------------------------------------------------------ - ; Enhanced function Jump table. - ; This table is generally used by the monitor ROM to call functions within the User ROM. - ;------------------------------------------------------------------------------------------ -PRTMZF: JP _PRTMZF ; UROMADDR+80H - Print out an MZF header stored in the IBUFE location. -PRTDBG: JP _PRTDBG ; UROMADDR+83H - Print out debug information, if enabled. -CMT_RDINF: JP _CMT_RDINF ; UROMADDR+86H - Tape/SD intercept handler - Read Header -CMT_RDDATA: JP _CMT_RDDATA ; UROMADDR+89H - Tape/SD intercept handler - Read Data -CMT_WRINF: JP _CMT_WRINF ; UROMADDR+80H - Tape/SD intercept handler - Write Header -CMT_WRDATA: JP _CMT_WRDATA ; UROMADDR+8FH - Tape/SD intercept handler - Write Data -CMT_VERIFY: JP _CMT_VERIFY ; UROMADDR+92H - Tape/SD intercept handler - Verify Data -CMT_DIR: JP _CMT_DIR ; UROMADDR+95H - SD card directory listing command. -CNV_ATOS: JP _CNV_ATOS ; UROMADDR+98H - Convert string from Ascii to Sharp Ascii - ;----------------------------------------- - - - ;----------------------------------------- - ; Initialisation and startup. - ;----------------------------------------- - ; - ; NB. Bank control registers are left selected. Any software needing access to the top 8 bytes of a - ; ROM/RAM page need to disable them, perform their actions then re-emable. - ; - JP ROMFS_1 ; Skip the reset vector. - ; -ROMFS_1: - LD A, (ROMBK1) ; Ensure all banks are at default - CP 8 ; If the ROMBK1 value is 255, an illegal value, then the machine has just started so initialise memory. - JR C, ROMFS_3 - XOR A ; Clear the lower stack space as we use it for variables. - LD B, 7*8 - LD HL, 01000H -ROMFS_2: LD (HL),A - INC HL - DJNZ ROMFS_2 - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (ROMCTL),A ; Save to memory the value in the bank control register - this register is used for SPI etc so need to remember its setting. - LD A,(ROMBK1) -ROMFS_3: LD (BNKSELMROM),A ; start up. - LD A, (ROMBK2) - LD (BNKSELUSER),A - - ;------------------------------------------------------------------------------- - ; START OF RFS INITIALISATION AND COMMAND ENTRY PROCESSOR FUNCTIONALITY. - ;------------------------------------------------------------------------------- - ; - ; Replacement command processor in place of the SA1510 command processor. - ; -MONITOR: IF FUSIONX_ENA = 0 - IN A,(CPLDINFO) ; See if a tranZPUter board is present. - AND 0E7H ; Mask out the CPLD Version and host HW. - LD C,A - CP 020H ; Upper bits specify the version, should be at least 1. - JR C,CHKTZ1 - AND 007H ; Get Hardware, should be an MZ-80A for RFS. - CP MODE_MZ80A - LD A,C - JR Z,CHKTZ1 - XOR A -CHKTZ1: AND 0E0H - ELSE - XOR A - ENDIF - LD (TZPU), A ; Flag = 0 if no tranZPUter present otherwise contains version (1 - 15). - LD HL,DSPCTL ; Setup address of display control register latch. - ; - XOR A ; Set the initial SDCFS active drive number. - LD (SDDRIVENO),A - ; - LD A, (ROMBK1) - CP 1 - JR Z, SET80CHAR - CP 0 - JR NZ, SIGNON - ; -SET40CHAR: LD A, 0 ; Using MROM in Bank 0 = 40 char mode. - LD E,(HL) ; Dummy operation to enable latch write via multivibrator. - LD (HL), A - LD (SCRNMODE), A - LD (SPAGE), A ; Allow MZ80A scrolling - JR SIGNON -SET80CHAR: LD A, 128 ; Using MROM in Bank 1 = 80 char mode. - LD E,(HL) ; Dummy operation to enable latch write via multivibrator. - LD (HL), A - LD A, 1 - LD (SCRNMODE), A - LD A, 0FFH - LD (SPAGE), A ; MZ80K Scrolling in 80 column mode for time being. - ; -SIGNON: LD A,0C4h ; Move cursor left to overwrite part of SA-1510 monitor banner. - LD E,004h ; 2 times. -SIGNON1: CALL DPCT - DEC E - JR NZ,SIGNON1 - ; - LD A,(TZPU) - OR A - JR Z,SIGNON2 - LD DE,MSGSONTZ - JR SIGNON3 - ; -SIGNON2: LD DE,MSGSON ; Sign on message, -SIGNON3: LD HL,PRINTMSG - CALL BKSW0to6 - ; JR ST1X - - ; Initialise SD card, report any errors. - LD HL, SDINIT ; SD Card Initialisation - CALL BKSW0to2 ; Call the initialisation routine. - LD A,L - OR A ; 0 = No error. - JR Z,ST1X - - ; Place error code in C to print as a number and report with the error message. - ADD A,'0' - LD C,A - LD DE,MSGSDINITER - LD HL,PRINTMSG - CALL BKSW0to6 - - ; Command processor, table based. - ; A line is inpt then a comparison made with entries in the table. If a match is found then the bank and function - ; address are extracted and a call to the function @ given bank made. The commands can be of variable length - ; but important to not that longer commands using the same letters as shorter commands must appear first in the table. - ; -ST1X: CALL NL ; Command line monitor extension. - LD A,'*' - CALL PRNT - LD DE,BUFER - CALL GETL - ; - LD A,(BUFER+1) ; Drive change number 0..9. Each number represents an RFS SDCFS Drive number. - CP '0' - JR C,CMDCMP - CP ':' - JR NC,CMDCMP - SUB '0' - LD D,A - LD A,(BUFER+2) - CP CR ; If a CR is present then we match, a drive selection number was entered. - LD A,D - JR NZ,CMDCMP - ; Simple command, just update the active drive number. - LD (SDDRIVENO),A - JR ST1X - ; -CMDCMP: XOR A ; Clear the result variable used by interbank calls. Some functions set this variable and we act on it. - LD (RESULT),A - LD HL,CMDTABLE -CMDCMP0: LD DE,BUFER+1 ; First command byte after the * prompt. - LD A,(HL) - CP 000H - JR Z,ST1X ; Skip processing on lines where just CR pressed. - BIT 7,A ; Bit 7 set on command properties indicates table end, exit if needed. - JR NZ,CMDNOCMP - - LD C,A ; Command properties into C - SET 6,C ; Assume command match. - AND 007H ; Mask out bytes in command mask. - LD B,A ; Number of bytes in command. - INC HL -CMDCMP1: LD A,(DE) ; Compare all bytes and reset match bit if we find a difference. - - CP (HL) - JR Z, CMDCMP2 - RES 6,C ; No command match. -CMDCMP2: INC DE - INC HL - DJNZ CMDCMP1 - BIT 6,C ; Bit 7 is still set then we have a command match. - JR NZ,CMDCMP3 - INC HL - INC HL ; Skip over function address - JR CMDCMP0 ; Try match next command. -CMDCMP3: LD A,(HL) ; Command function address into HL - INC HL - LD H,(HL) - LD L,A - PUSH HL - LD (TMPADR),DE ; Store the key buffer location where arguments start. - LD A,C - SRL A - SRL A - SRL A - AND 007H ; Mask out just the bank number of the command. - CP 000H - JR Z,CMDCMP6 ; No point using the bank switching logic for the current bank 0. - LD B,A - LD HL,BKSW0to0 ; Base address of bank switching functions. - LD DE,BKSW0to1 - BKSW0to0 ; DE is the number of bytes between bank switch calls. - OR A - JR Z,CMDCMP5 -CMDCMP4: ADD HL,DE - DJNZ CMDCMP4 -CMDCMP5: EX DE,HL ; Address of bank switch function into DE. - POP HL ; Get address of command into HL. - LD BC,CMDCMPEND - PUSH BC ; Address to return to after command is executed. - PUSH DE ; Now jump to DE which will switch to the correct bank and execute function at HL. - LD DE,(TMPADR) - RET -CMDCMP6: LD DE,CMDCMPEND ; Put return address onto stack. - PUSH DE - LD DE,(TMPADR) ; For the current bank, just jump to the function. - JP (HL) - -CMDNOCMP: LD DE,MSGBADCMD - LD HL,PRINTMSG - CALL BKSW0to6 -CMDCMPEND: LD A,(RESULT) - CP 0FEH ; A Result code of 0FEH means execute loaded code, address is in the CMT Header EXADR location. - JP NZ,ST1X - LD HL,(EXADR) - JP (HL) - - ; Monitor command table. This table contains the list of recognised commands along with the - ; handler function and bank in which it is located. - ; - ; 7 6 5:3 2:0 - ; END MATCH BANK SIZE -CMDTABLE: DB 000H | 000H | 000H | 002H ; Bit 2:0 = Command Size, 5:3 = Bank, 6 = Command match, 7 = Command table end. - DB "40" ; 40 Char screen mode. - DW SETMODE40 - DB 000H | 000H | 000H | 002H - DB "80" ; 80 Char screen mode. - DW SETMODE80 - ;DB 000H | 000H | 000H | 004H - ;DB "7008" ; Switch to 80 column MZ700 mode. - ;DW SETMODE7008 - ;DB 000H | 000H | 000H | 003H - ;DB "700" ; Switch to 40 column MZ700 mode. - ;DW SETMODE700 - DB 000H | 000H | 000H | 005H - DB "BASIC" ; Load and run BASIC SA-5510. - DW LOADBASIC - DB 000H | 000H | 020H | 001H - DB 'B' ; Bell. - DW SGX - DB 000H | 000H | 000H | 003H - DB "CPM" ; Load and run CPM. - DW LOADCPM - DB 000H | 000H | 018H | 002H - DB "CP" ; Copy Memory. - DW MCOPY - DB 000H | 000H | 018H | 001H - DB 'C' ; Clear Memory. - DW INITMEMX - DB 000H | 000H | 018H | 001H - DB 'D' ; Dump Memory. - DW DUMPX - DB 000H | 000H | 010H | 002H - DB "EC" ; Erase file. - DW ERASESD - DB 000H | 000H | 008H | 001H - DB 'F' ; RFS Floppy boot code. - DW FLOPPY - DB 000H | 000H | 008H | 001H - DB 0AAH ; Original Floppy boot code. - DW FDCK - DB 000H | 000H | 030H | 001H - DB 'H' ; Help screen. - DW HELP - DB 000H | 000H | 000H | 002H - DB "IR" ; List ROM directory. - DW DIRROM - DB 000H | 000H | 010H | 002H - DB "IC" ; List SD Card directory. - DW DIRSDCARD - DB 000H | 000H | 000H | 001H - DB 'J' ; Jump to address. - DW GOTOX - DB 000H | 000H | 020H | 004H - DB "LTNX" ; Load from CMT without auto execution. - DW LOADTAPENX - DB 000H | 000H | 020H | 002H - DB "LT" ; Load from CMT - DW LOADTAPE - DB 000H | 000H | 000H | 004H - DB "LRNX" ; Load from ROM without auto execution. - DW LOADROMNX - DB 000H | 000H | 000H | 002H - DB "LR" ; Load from ROM - DW LOADROM - DB 000H | 000H | 010H | 004H - DB "LCNX" ; Load from SDCARD without auto execution. - DW LOADSDCARDX - DB 000H | 000H | 010H | 002H - DB "LC" ; Load from SD CARD - DW LOADSDCARD - DB 000H | 000H | 020H | 001H - DB "L" ; Original Load from CMT - DW LOADTAPE - DB 000H | 000H | 018H | 001H - DB 'M' ; Edit Memory. - DW MCORX - DB 000H | 000H | 018H | 001H - DB 'P' ; Printer test. - DW PTESTX - DB 000H | 000H | 038H | 001H - DB 'R' ; Memory test. - DW MEMTEST - DB 000H | 000H | 018H | 004H - DB "SD2T" ; Copy SD Card to Tape. - DW SD2TAPE - DB 000H | 000H | 010H | 002H - DB "SC" ; Save to SD CARD - DW SAVESDCARD - DB 000H | 000H | 020H | 002H - DB "ST" ; Save to CMT - DW SAVEX - DB 000H | 000H | 020H | 001H - DB 'S' ; Save to CMT - DW SAVEX - DB 000H | 000H | 000H | 004H - DB "TEST" ; A test function used in debugging. - DW LOCALTEST - DB 000H | 000H | 018H | 004H - DB "T2SD" ; Copy Tape to SD Card. - DW TAPE2SD - DB 000H | 000H | 038H | 001H - DB 'T' ; Timer test. - DW TIMERTST - DB 000H | 000H | 000H | 001H - DB 'V' ; Verify CMT Save. - DW VRFYX - DB 000H | 000H | 000H | 001H - DB 'X' ; Exchange to hi load rom so DRAM = 0000:0CFFF - DW HIROM - DB 080H | 000H | 000H | 001H - - ;------------------------------------------------------------------------------- - ; END OF RFS INITIALISATION AND COMMAND ENTRY PROCESSOR FUNCTIONALITY. - ;------------------------------------------------------------------------------- - - ; A method used when testing hardware, scope and code will change but one of its purposes is to generate a scope signal pattern. - ; -LOCALTEST: LD A,64 - LD (0EFFBH),A - JP LOCALTEST - - - ;------------------------------------------------------------------------------- - ; START OF RFS COMMAND FUNCTIONS. - ;------------------------------------------------------------------------------- - - ; Method to branch execution to a user given address. - ; -GOTOX: CALL HEXIYX - JP (HL) - -HEXIYX: EX (SP),IY - POP AF - CALL HLHEX - JR C,HEXIYX2 - JP (IY) -HEXIYX2: POP AF ; Waste the intermediate caller address - RET - - - ;==================================== - ; - ; Screen Width Commands - ; - ;==================================== - -HIROM: LD A, (MEMSW) ; Swap ROM into high range slot. - LD A, ROMBANK2 - LD (ROMBK1),A ; Save bank being enabled. - LD (BNKSELMROM),A ; Switch to the hiload rom in bank 2. - JP 0C000H - -SETMODE40: LD A, ROMBANK0 ; Switch to 40Char monitor. - LD (ROMBK1),A - LD (BNKSELMROM),A - LD HL,DSPCTL ; Setup address of display control register latch. - LD A, 0 - LD E,(HL) ; Dummy operation to enable latch write via multivibrator. - LD (HL), A - JP MONIT - -SETMODE80: LD A, ROMBANK1 ; Switch to 80char monitor. - LD (ROMBK1),A - LD (BNKSELMROM),A - LD HL,DSPCTL ; Setup address of display control register latch. - LD A, 128 - LD E,(HL) ; Dummy operation to enable latch write via multivibrator. - LD (HL), A - JP MONIT - -NOTZPU: LD DE,MSGNOTZINST ; No tranZPUter installed. - LD HL,PRINTMSG - CALL BKSW0to6 - RET - - ; The RFS depends on variables stored in unused parts of the Monitor scratch area. - ; When switching into a compatibility mode the memory is switched and these variables go - ; out of scope. This routine clears the memory and sets any crucial variables after - ; memory switch so that a restart functions as expected. - ; -SETMODECLR: POP HL ; Get return address, will go OOS after memory mode change. - LD A,TZMM_COMPAT - OUT (MMCFG),A ; Set memory mode to compatibility. - XOR A ; Clear out the RFS variable area in the tranZPUter memory. - LD DE, 01000H - LD B, 030H -SETCLR_1: LD (DE),A - INC DE - DJNZ SETCLR_1 - JP (HL) ; Return to caller. - - ; Command to switch to the MZ700 compatibility mode with 80 column display. - ; -;SETMODE7008:LD A,(TZPU) ; Check there is a tranZPUter card installed. -; OR A -; JR Z,NOTZPU -; LD HL,DSPCTL ; Setup address of display control register latch. -; LD A, 128 ; Setup for 80char display. -; LD E,(HL) ; Dummy operation to enable latch write via multivibrator. -; LD (HL), A -; CALL SETMODECLR ; Set memory mode and clear variable area. -; LD A,ROMBANK5 ; Select the 80 column version of the 1Z-013A ROM. -;SETMODE_2: LD (ROMBK1),A -; LD (BNKSELMROM),A -; LD A,MODE_MZ700 ; Set the CPLD compatibility mode. -;SETMODE_3: OUT (CPLDCFG),A -; JP MONIT ; Cold start the monitor. - - ; Command to switch to the MZ700 compatibility mode with original 40 column display. - ; -;SETMODE700: LD A,(TZPU) ; Check there is a tranZPUter card installed. -; OR A -; JR Z,NOTZPU -; LD HL,DSPCTL ; Setup address of display control register latch. -; LD A, 0 ; Setup for 40char display. -; LD E,(HL) ; Dummy operation to enable latch write via multivibrator. -; LD (HL), A -; CALL SETMODECLR ; Set memory mode and clear variable area. -; LD A,ROMBANK4 ; Select the 40 column version of the 1Z-013A ROM. -; JR SETMODE_2 - - ;==================================== - ; - ; ROM File System Commands - ; - ;==================================== - - ; HL contains address of block to check. -ISMZF: PUSH BC - PUSH DE - PUSH HL - ; - LD A,(HL) - CP OBJCD ; Only interested in machine code images. - JR NZ, ISMZFNOT - ; - INC HL - LD DE,NAME ; Checks to confirm this is an MZF header. - LD B,FNSIZE ; Maximum of 17 characters, including terminator in filename. -ISMZFNXT: LD A,(HL) - LD (DE),A - CP 00DH ; If we find a terminator then this indicates potentially a valid name. - JR Z, ISMZFNXT3 - CP 000H ; Same applies for NULL terminator. - JR Z, ISMZFNXT3 - CP 020H ; >= Space - JR C, ISMZFNOT - CP 05DH ; =< ] - JR C, ISMZFNXT3 -ISMZFNXT2: CP 091H - JR C, ISMZFNOT ; DEL or > 0x7F, cant be a valid filename so this is not an MZF header. -ISMZFNXT3: INC DE - INC HL - DJNZ ISMZFNXT -ISMZFYES: CP A ; Set zero flag to indicate match. - -ISMZFNOT: POP HL - POP DE - POP BC - RET - - -_PRTDBG: IF ENADEBUG = 1 - PUSH HL - PUSH DE - PUSH BC - PUSH AF - LD A,(ROMBK1) - LD (BNKSELMROM),A ; Set the MROM bank back to original. - CALL PRTHL ; HL - LD A, ' ' - CALL PRNT - LD H,B - LD L,C - CALL PRTHL ; BC - LD A, ' ' - CALL PRNT - LD H,D - LD L,E - CALL PRTHL ; DE - LD A, ' ' - CALL PRNT - POP HL ; Get AF into HL. - PUSH HL - CALL PRTHL ; AF - LD A, ' ' - CALL PRNT - LD A, ':' - CALL PRNT - LD A, ' ' - CALL PRNT - ; CALL NL - ; CALL GETKY - LD A,(WRKROMBK1) - LD (BNKSELMROM),A ; Set the MROM bank back to scanned bank. - POP AF - POP BC - POP DE - POP HL - RET - ENDIF - -_PRTMZF: PUSH BC - PUSH DE - PUSH HL - ; - LD A,(ROMBK1) ; Ensure main MROM is switched in. - LD (BNKSELMROM),A - ; - LD A,(SCRNMODE) - CP 0 - LD H,47 - JR Z,PRTMZF0 - LD H,93 -PRTMZF0: LD A,(TMPLINECNT) ; Pause if we fill the screen. - LD E,A - INC E - CP H - JR NZ,PRTNOPAUSE - LD E, 0 -PRTPAUSE: CALL GETKY - CP ' ' - JR Z,PRTNOPAUSE - CP 'X' ; Exit from listing. - LD A,001H - JR Z,PRTMZF4 - JR PRTPAUSE -PRTNOPAUSE: LD A,E - LD (TMPLINECNT),A - ; - LD A, D ; Print out file number and increment. - CALL PRTHX - LD A, '.' ; File type is MACHINE CODE program. - CALL PRNT - LD DE,NAME ; Print out filename. - LD B,FNSIZE ; Maximum size of filename. -_PRTMSG: LD A,(DE) - INC DE - CP 000H - JR Z,_PRTMSGE - CP 00DH - JR Z,_PRTMSGE - CALL PRNT - DJNZ _PRTMSG - ; -_PRTMSGE: LD HL, (DSPXY) - ; - LD A,L - CP 20 - LD A,20 - JR C, PRTMZF2 - ; - LD A,(SCRNMODE) ; 40 Char mode? 2 columns of filenames displayed so NL. - CP 0 - JR Z,PRTMZF1 - ; - LD A,L ; 80 Char mode we print 4 columns of filenames. - CP 40 - LD A,40 - JR C, PRTMZF2 - ; - LD A,L - CP 60 - LD A,60 - JR C, PRTMZF2 - ; -PRTMZF1: CALL NL - JR PRTMZF3 -PRTMZF2: LD L,A - LD (DSPXY),HL -PRTMZF3: XOR A -PRTMZF4: OR A - PUSH AF - LD A, (WRKROMBK1) - LD (BNKSELMROM),A - POP AF - POP HL - POP DE - POP BC - RET - - - ; Method to list the directory of the ROM devices. - ; -DIRROM: ;DI ; Disable interrupts as we are switching out the main rom. - ; - LD A,1 ; Account for the title. - LD (TMPLINECNT),A - ; - LD DE,MSGRDIRLST ; Print out header. - LD HL,PRINTMSG - CALL BKSW0to6 - - ; D = File sequence number. - LD D,0 ; File numbering start. - - ; - ; Get directory of User ROM. - ; - LD A,ROMBANK3 - LD (WRKROMBK1),A - LD (BNKSELMROM),A - CALL DIRMROM - ; - ; Scan MROM Bank - ; B = Bank Page - ; C = Block in page - ; - LD B,MROMPAGES ; First 8 pages are reserved in MROM bank. - LD C,0 ; Block in page. - ; -DIRNXTPG: LD A,B - LD (WRKROMBK1), A - LD (BNKSELMROM),A ; Select bank. - - PUSH BC ; Preserve bank count/block number. - PUSH DE ; Preserve file numbering. - LD A,C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B,A - LD C,0 - LD HL,RFS_ATRB ; Add block offset to get the valid block address. - ADD HL,BC - CALL ISMZF - POP DE - POP BC - JR NZ, DIRNOTMZF - ; - CALL PRTMZF - JR NZ,DIRNXTPGX - INC D ; Next file sequence number. - ; -DIRNOTMZF: INC C ; Next block. - LD A,C - CP MROMSIZE/RFSSECTSZ ; Max blocks per page reached? - JR C, DIRNXTPG2 - LD C,0 - INC B -DIRNXTPG2: LD A,B - CP 080h ; MROM has 128 banks of 4K, so stop when we reach 128. - JR NZ, DIRNXTPG - -DIRNXTPGX: LD A,(ROMBK1) - LD (BNKSELMROM),A ; Set the MROM bank back to original. - ;EI ; No need to block interrupts now as MROM bank restored. - RET ; End of scan, return to monitor - - - ; In: - ; HL = filename - ; D = File sequence number. - ; Out: - ; B = Bank Page file found - ; C = Block where found. - ; D = File sequence number. - ; Z set if found. -FINDMZF: PUSH DE - LD (TMPADR), HL ; Save name of program to load. - EX DE, HL ; String needed in DE for conversion. - LD HL,0FFFFh ; Tag the filenumber as invalid. - LD (TMPCNT), HL - CALL ConvertStringToNumber ; See if a file number was given instead of a filename. - JR NZ, FINDMZF0 ; - LD (TMPCNT), HL ; Store filenumber making load by filenumber valid. - ; - ; Scan MROM Bank - ; B = Bank Page - ; C = Block in page - ; -FINDMZF0: POP DE ; Get file sequence number in D. - LD B,MROMPAGES ; First 4 pages are reserved in User ROM bank. - LD C,0 ; Block in page. -FINDMZF1: LD A,B - LD (WRKROMBK1), A - LD (BNKSELMROM),A ; Select bank. -FINDMZF2: PUSH BC ; Preserve bank count/block number. - PUSH DE ; Preserve file numbering. - LD HL,RFS_ATRB ; Add block offset to get the valid block. - LD A,C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B,A - LD C,0 - ADD HL,BC - - CALL ISMZF - POP DE - POP BC - LD A,(ROMBK1) - LD (BNKSELMROM),A ; Set the MROM bank back to original. - JR NZ, FINDMZF4 ; Z set if we found an MZF record. - INC HL ; Save address of filename. - PUSH HL - ; CALL PRTMZF ; Print out for confirmation. - LD HL,(TMPCNT) - LD A,H - CP 0FFh ; If TMPCNT tagged as 0xFF then we dont have a filenumber so must match filename. - JR Z, FINDMZF3 - LD A,L ; Check file number, load if match - CP D - JR NZ, FINDMZF3 ; Check name just in case. - POP HL - JR FINDMZFYES ; Else the filenumber matches so load the file. - -FINDMZF3: POP HL - PUSH DE - PUSH BC - LD DE,(TMPADR) ; Original DE put onto stack, original filename into HL - LD BC,FNSIZE - LD A,(WRKROMBK1) - LD (BNKSELMROM),A ; Select correct bank for comparison. - CALL CMPSTRING - POP BC - POP DE - JR Z, FINDMZFYES - INC D ; Next file sequence number. -FINDMZF4: INC C - LD A,C - CP MROMSIZE/RFSSECTSZ ; Max blocks per page reached? - JR C, FINDMZF5 - LD C,0 - INC B -FINDMZF5: LD A,B - CP 080h ; MROM has 128 banks of 4K, so stop when we get to 128. - JR NZ, FINDMZF1 - INC B - JR FINDMZFNO - -FINDMZFYES: ; Flag set by previous test. -FINDMZFNO: PUSH AF - LD A,(ROMBK1) - LD (BNKSELMROM),A ; Set the MROM bank back to original. - POP AF - RET - - - ; Load Program from ROM - ; IN DE Name of program to load. - ; OUT zero Set if string1 = string2, reset if string1 != string2. - ; carry Set if string1 > string2, reset if string1 <= string2. -LOADROMNX: LD L,0FFH - JR LOADROM1 -LOADROM: LD L,000H -LOADROM1: ;DI - PUSH HL ; Preserve execute flag. - EX DE,HL ; User ROM expects HL to have the filename pointer. - - PUSH HL ; Save pointer to filename for FINDMZF in Monitor ROM. - - ; D = File sequence number. - LD D,0 ; File numbering start. - ; - LD A,ROMBANK3 ; Activate the RFS Utilities MROM bank. - LD (WRKROMBK1), A - LD (BNKSELMROM),A - CALL MFINDMZF ; Try and find the file in User ROM via MROM utility. - POP HL - JR Z,MROMLOAD0 - ; - CALL FINDMZF ; Find the bank and block where the file resides. HL = filename. - JR Z, LROMLOAD - ; - JR LROMNTFND ; Requested file not found. - ; -MROMLOAD0: PUSH BC ; Preserve bank and block where MZF file found. - PUSH AF - LD A,(ROMBK1) ; Page in monitor so we can print a message. - LD (BNKSELMROM),A - LD DE,MSGLOAD+1 ; Skip initial CR. - LD BC,NAME - LD HL,PRINTMSG - CALL BKSW0to6 - LD A,(WRKROMBK1) ; Revert to MROM bank to load the application. - LD (BNKSELMROM),A - POP AF - POP BC - ; - CALL MROMLOAD ; Load the file from User ROM via MROM utility. - JP Z, LROMLOAD5 - -LROMNTFND: POP HL ; Dont need execute flag anymore so waste it. - LD A,(ROMBK1) - LD (BNKSELMROM),A - LD HL,PRINTMSG - LD DE,MSGNOTFND ; Not found - CALL BKSW0to6 -LOADROMEND:;EI - RET - - ; - ; Load program from RFS Bank 1 (MROM Bank) - ; -LROMLOAD: PUSH BC - ; - PUSH BC - LD DE,MSGLOAD+1 - LD BC,NAME - LD HL,PRINTMSG - CALL BKSW0to6 - POP BC - ; - LD A,B - LD (WRKROMBK1),A - LD (BNKSELMROM),A - ; - LD DE, IBUFE ; Copy the header into the work area. - LD HL, 00000h ; Add block offset to get the valid block. - LD A,C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B,A - LD C,0 - ADD HL,BC - LD BC, MZFHDRSZ - LDIR - - PUSH HL - LD DE, (DTADR) - LD HL, (SIZE) - LD BC, RFSSECTSZ - MZFHDRSZ - SBC HL, BC - JR NC, LROMLOAD4 - LD HL, (SIZE) - JR LROMLOAD4 - - ; HL = address in active block to read. - ; B = Bank - ; C = Block -LROMLOAD2: LD A, B - LD (WRKROMBK1), A - LD (BNKSELMROM),A - -LROMLOAD3: PUSH BC - LD HL, 00000h - LD A, C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B, A - LD C, 0 - ADD HL,BC - PUSH HL - - LD DE, (TMPADR) - LD HL, (TMPSIZE) - LD BC, RFSSECTSZ - SBC HL, BC - JR NC, LROMLOAD4 - LD BC, (TMPSIZE) - LD HL, 0 -LROMLOAD4: LD (TMPSIZE), HL ; HL contains remaining amount of bytes to load. - POP HL - ; - LD A, B ; Pre check to ensure BC is not zero. - OR C - JR Z, LROMLOAD8 - LDIR - LD BC, (TMPSIZE) - LD A, B ; Post check to ensure we still have bytes - OR C - JR Z, LROMLOAD8 - ; - LD (TMPADR),DE ; Address we are loading into. - POP BC -LROMLOAD6: INC C - LD A, C - CP MROMSIZE/RFSSECTSZ ; Max blocks per page reached? - JR C, LROMLOAD7 - LD C, 0 - INC B - ; -LROMLOAD7: LD A, B - CP 080h - JR Z, LROMLOAD5 - JR LROMLOAD2 - ; -LROMLOAD8: POP BC -LROMLOAD5: POP HL ; Retrieve execute flag. - LD A,(ROMBK1) - LD (BNKSELMROM),A ; Set the MROM bank back to original. - LD A,L ; Autoexecute turned off? - CP 0FFh - JP Z,LROMLOAD9 ; Go back to monitor if it has been, else execute. - LD HL,(EXADR) - ;EI ; No need to block interrupts now as MROM bank restored. - JP (HL) ; Execution address. -LROMLOAD9: RET - - - ; Quick method to load CPM. So long as the filename doesnt change this method will load and boot CPM. -LOADCPM: LD DE,CPMFN48 ; Load up the 48K version of CPM -LOADPRGNM: PUSH HL - LD HL,BUFER -LOADPRGNM1: LD A,(DE) - LD (HL),A - CP CR - JR Z,LOADPRGNM2 - INC DE - INC HL - JR LOADPRGNM1 -LOADPRGNM2: POP HL - LD DE,BUFER - JP LOADROM - - ; Quick method to load the basic interpreter. So long as the filename doesnt change this method will load and boot Basic. -LOADBASIC: LD DE,BASICFILENM - JR LOADPRGNM - -LOADPROG: LD HL,LOADSDCARD - CALL BKSW0to2 - RET - - ;------------------------------------------------------------------------------- - ; END OF RFS COMMAND FUNCTIONS. - ;------------------------------------------------------------------------------- - - ;------------------------------------------------------------------------------- - ; DEVICE DRIVERS - Intercept handlers to provide enhanced services to - ; existing MA-80A BIOS API functions. - ;------------------------------------------------------------------------------- - - ; Method to set the RFS Drive number from the Load/Save string provided. -SETDRIVE: LD A,(DE) ; If a drive is given it will be in format : - OR A ; Exit if null or CR found, no drive specifier present. - JR Z,SETDRV3 - CP 00DH - JR Z,SETDRV3 - CP '"' ; String quotes, skip over. - JR NZ,SETDRV1 - INC DE - JR SETDRIVE - ; -SETDRV1: LD A,(DE) ; Check for :, if no colon exit. - LD C,A - INC DE - LD A,(DE) - DEC DE - CP ':' - JR NZ, SETDRV3 - ; - LD A,C - CP 'C' ; CMT unit specified by C: - JR Z,SETDRV2 - SUB '0' ; Check the drive number, should be in range 0..9 - JP C,SD_INVDRV - CP 10 - JP NC,SD_INVDRV -SETDRV2: INC DE - LD (SDDRIVENO),A ; Store drive number for later use. - XOR A - LD (CMTFILENO),A ; Setup the starting file number for sequential file reads (ie. when no filename given). - ; - PUSH DE ; Need to remove the drive qualifier once processed. - PUSH DE - INC DE - INC DE ; Move onto filename. - EX DE,HL - POP DE - LD BC,SDDIR_FNSZ - LDIR - POP DE - ; -SETDRV3: XOR A - RET - - ; Method to check if the active drive is the CMT. -CHECKCMT: LD A,(SDDRIVENO) - CP 'C' - RET - - ; Convert the lower 4 bits of A into a Hex character. -TOHEXDIGIT: AND 00FH ; Simple logic, add 30H to get 0..9, add additional 7 if value >= 10 to get digits A..F. - CP 00AH - JR C,NOADD - ADD A,007H -NOADD: ADD A,030H - RET - - ; Convert a number into Hex string and store in buffer pointed to by DE. - ; -TOHEX: PUSH DE - PUSH AF ; Save AF to retrieve lower 4 bits. - RRCA ; Shift upper 4 bits to lower to convert to hex. - RRCA - RRCA - RRCA - CALL TOHEXDIGIT - LD (DE),A ; Store and convert lower 4 bits. - INC DE - POP AF - CALL TOHEXDIGIT - LD (DE),A - INC DE - LD A,CR ; Terminate with a CR. - LD (DE),A - POP DE ; DE back to start of string. - RET - - ; Handler to intercept the CMT Read Header Information call and insert selectable - ; SD Card RFS Drive functionality. - ; DE contains a pointer to memory containing the file to load. If (DE) = NULL then - ; load the next sequential file from the SD card directory. - ; DE = Filename. Can contain a drive specifier in format : - ; - ; No registers or flags should be affected as we dont know the caller state. -_CMT_RDINF: CALL SETDRIVE ; Set drive if specified. - RET NZ - CALL CHECKCMT ; If drive is set to the CMT Unit exit with Z set so that the original CMT handlers are called. - JP Z,?RDI - LD A,(DE) ; Check to see if empty string given, if so expand the default Next file number into the buffer. - CP CR - JR NZ,_CMT_RDINF1 - LD A,(CMTFILENO) ; Get next sequential number and convert to hex. - PUSH AF - CALL TOHEX - POP AF - INC A ; Increment number so next call retrieves the next sequential file. - LD (CMTFILENO),A - ; -_CMT_RDINF1:PUSH DE - LD HL,LOADSDINF ; DE already points to the filename, call LOADSDINF to locate it on the SD card and setup the header. - CALL BKSW0to2 - ; Copy the filename into the Buffer provided allowing for file number to name expansion. - POP DE - LD HL,NAME - LD BC,SDDIR_FNSZ - LDIR - ; - LD A,(RESULT) - OR A - RET Z ; 0 = success, return with carry clear. - SCF ; > 0 = fail, return with carry set. - RET - - ; Handler to intercept the CMT Read Data call and insert selectable SD Card RFS - ; Drive functionality. - ; - ; No registers or flags should be affected as we dont know the caller state. -_CMT_RDDATA:LD HL,LOADSDDATA - CALL BKSW0to2 - LD A,(RESULT) - OR A - JR NZ,_CMT_RDERR - RET -_CMT_RDERR: SCF - RET - - ; Handler to intercept the CMT Write Header Information call and insert selectable - ; SD Card RFS Drive functionality. - ; - ; No registers or flags should be affected as we dont know the caller state. - ; - ; At the moment, the WRINF call only creates a filename if non specified. The actual write to file occurs in WRDATA. Once I have more understanding of - ; how the sequential data mode works I can adapt it to be compatible. -_CMT_WRINF: LD DE,NAME ; Caller has already setup the CMT header so we use this for processing. - ; - CALL SETDRIVE ; Set drive if specified. - RET NZ - CALL CHECKCMT - JP Z,?WRI - ; - LD A,(DE) ; Check to see if empty string given, if so create a default name. - CP CR - JR NZ,_CMT_WRINF1 - ; - LD HL,DEFAULTFN - LD BC,DEFAULTFNE - DEFAULTFN - LDIR - LD A,(CMTFILENO) ; Get next sequential number and convert to hex. - PUSH AF - CALL TOHEX - POP AF - INC A ; Increment number so next call retrieves the next sequential file. - LD (CMTFILENO),A - ; -_CMT_WRINF1:LD A,0 ; Always success as nothing is written. - OR A - RET - - ; Handler to intercept the CMT Write Data call and insert selectable SD Card RFS - ; Drive functionality. - ; - ; No registers or flags should be affected as we dont know the caller state. -_CMT_WRDATA: LD HL,SAVESDDATA - CALL BKSW0to2 - LD A,(RESULT) - OR A - JR NZ,_CMT_RDERR - RET - - ; Handler to intercept the CMT Verify Data call and insert selectable SD Card - ; RFS Drive functionality. - ; - ; No registers or flags should be affected as we dont know the caller state. -_CMT_VERIFY:CALL SETDRIVE ; Set drive if specified. - RET NZ - CALL CHECKCMT - JR Z,_VERIFY - LD DE,MSGNOVERIFY - JR SD_ERRMSG - -_VERIFY: JP ?VRFY - -SD_INVDRV: LD DE,MSGINVDRV ; Invalid drive specified. - JR SD_ERRMSG -SD_NOTFND: LD DE,MSGNOTFND -SD_ERRMSG: LD HL,PRINTMSG - CALL BKSW0to6 ; Print message that file wasnt found. - LD A,1 - OR A - RET - - ; Method to list the contents of the active RFS drive number. -_CMT_DIR: CALL SETDRIVE ; Change to the given drive. - RET NZ - CALL CHECKCMT ; Cannot DIR tape drive so give error. - JP Z,_CMT_NODIR - LD HL,DIRSDCARD - CALL BKSW0to2 ; Call the standard RFS directory command. - RET -_CMT_NODIR: LD DE,MSGNOCMTDIR - JR SD_ERRMSG - - ; Stub to call the ASCII to Sharp ASCII conversion routine stored in Bank 5. - ; Inputs: DE = String to convert, NULL or CR terminated. - ; B = Maximum number of characters to convert. - ; All registers except AF preserved. - ; -_CNV_ATOS: PUSH HL - LD HL,CNVSTR_AS - CALL BKSW0to5 - POP HL - RET - - ;------------------------------------------------------------------------------- - ; END OF DEVICE DRIVERS - ;------------------------------------------------------------------------------- - - ;-------------------------------------- - ; - ; Message table - Refer to bank 6 for - ; all messages. - ; - ;-------------------------------------- - - ; Quick load program names. -CPMFN48: DB "CPM223RFS", 00DH -BASICFILENM:DB "BASIC SA-5510RFS", 00DH -DEFAULTFN: DB "DEFAULT" -DEFAULTFNE: EQU $ - - ; Bring in additional resources. - USE_CMPSTRING: EQU 1 - USE_SUBSTRING: EQU 0 - USE_INDEX: EQU 0 - USE_STRINSERT: EQU 0 - USE_STRDELETE: EQU 0 - USE_CONCAT: EQU 0 - USE_CNVUPPER: EQU 1 - USE_CNVCHRTONUM: EQU 1 - USE_ISNUMERIC: EQU 1 - USE_CNVSTRTONUM: EQU 1 - ; - INCLUDE "macros.asm" - INCLUDE "rfs_utilities.asm" - ; - ; Ensure we fill the entire 2K by padding with FF's. - ; - ALIGN 0EFF8h - ORG 0EFF8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh - -MEND: - - ; - ; Include all other banks which make up the RFS User cited ROM. - ; - INCLUDE "rfs_bank1.asm" - INCLUDE "rfs_bank2.asm" - INCLUDE "rfs_bank3.asm" - INCLUDE "rfs_bank4.asm" - INCLUDE "rfs_bank5.asm" - INCLUDE "rfs_bank6.asm" - INCLUDE "rfs_bank7.asm" diff --git a/software/asm/rfs_bank1.asm b/software/asm/rfs_bank1.asm deleted file mode 100644 index 6250a89..0000000 --- a/software/asm/rfs_bank1.asm +++ /dev/null @@ -1,536 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: rfs_bank1.asm -;- Created: July 2019 -;- Author(s): Philip Smart -;- Description: Sharp MZ series Rom Filing System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade. -;- -;- Credits: -;- Copyright: (c) 2018-2023 Philip Smart -;- -;- History: July 2019 - Merged 2 utilities to create this compilation. -; May 2020 - Bank switch changes with release of v2 pcb with coded latch. The coded -; latch adds additional instruction overhead as the control latches share -; the same address space as the Flash RAMS thus the extra hardware to -; only enable the control registers if a fixed number of reads is made -; into the upper 8 bytes which normally wouldnt occur. Caveat - ensure -; that no loop instruction is ever placed into EFF8H - EFFFH. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - ;============================================================ - ; - ; USER ROM BANK 1 - Floppy Disk Controller functions. - ; - ;============================================================ - ORG UROMADDR - - ;-------------------------------- - ; Common code spanning all banks. - ;-------------------------------- - NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -ROMFS1_0: LD A,(BNKCTRLRST) - DJNZ ROMFS1_0 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - NOP - NOP - NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 - LD (BNKSELMROM),A - NOP - NOP - NOP - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - ; - ; No mans land... this should have switched to Bank 0 and at this point there is a jump to 00000H. - JP 00000H ; This is for safety!! - - ;------------------------------------------------------------------------------------------ - ; Bank switching code, allows a call to code in another bank. - ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. - ;------------------------------------------------------------------------------------------ - ALIGN_NOPS UROMBSTBL - ; -BKSW1to0: PUSH AF - LD A, ROMBANK1 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK0 ; Required bank to call. - JR BKSW1_0 -BKSW1to1: PUSH AF - LD A, ROMBANK1 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK1 ; Required bank to call. - JR BKSW1_0 -BKSW1to2: PUSH AF - LD A, ROMBANK1 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK2 ; Required bank to call. - JR BKSW1_0 -BKSW1to3: PUSH AF - LD A, ROMBANK1 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK3 ; Required bank to call. - JR BKSW1_0 -BKSW1to4: PUSH AF - LD A, ROMBANK1 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK4 ; Required bank to call. - JR BKSW1_0 -BKSW1to5: PUSH AF - LD A, ROMBANK1 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK5 ; Required bank to call. - JR BKSW1_0 -BKSW1to6: PUSH AF - LD A, ROMBANK1 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK6 ; Required bank to call. - JR BKSW1_0 -BKSW1to7: PUSH AF - LD A, ROMBANK1 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK7 ; Required bank to call. - ; -BKSW1_0: PUSH HL ; Place function to call on stack - LD HL, BKSWRET1 ; Place bank switchers return address on stack. - EX (SP),HL - LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. - LD (BNKSELUSER), A ; Repeat the bank switch B times to enable the bank control register and set its value. - JP (HL) ; Jump to required function. -BKSWRET1: POP AF ; Get bank which called us. - LD (BNKSELUSER), A ; Return to that bank. - POP AF - RET - -FDCCMD EQU 01000H -MOTON EQU 01001H -TRK0FD1 EQU 01002H -TRK0FD2 EQU 01003H -TRK0FD3 EQU 01004H -TRK0FD4 EQU 01005H -RETRIES EQU 01006H -BPARA EQU 01008H - - ;------------------------------------------------------------------------------- - ; START OF FLOPPY DISK CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; Method to check if the floppy interface ROM is present and if it is, jump to its entry point. - ; -FDCK: CALL FDCKROM ; Check to see if the Floppy ROM is present, exit if it isnt. - CALL Z,0F000h - RET ; JP CMDCMPEND -FDCKROM: LD A,(0F000h) - OR A - RET - -FLOPPY: PUSH DE ; Preserve pointer to input buffer. - LD DE,BPARA ; Copy disk parameter block into RAM work area. (From) - LD HL,PRMBLK ; (To) - LD BC,0000BH ; 11 bytes of config data. - LDIR ; BC=0, HL=F0E8, DE=1013 - POP DE ; init 1001-1005, port $DC mit $00 - LD A,(DE) ; If not at the end of the line, then process as the boot disk number. - CP 00Dh ; - JR NZ,GETBOOTDSK ; - CALL DSKINIT ; Initialise disk and flags. -L000F: LD DE,MSGBOOTDRV ; - LD HL,PRINTMSG - CALL BKSW1to6 - LD DE,011A3H ; - CALL GETL ; - LD A,(DE) ; - CP 01BH ; Check input value is in range 1-4. - JP Z,SS ; - LD HL,0000CH ; - ADD HL,DE ; - LD A,(HL) ; - CP 00DH ; - JR Z,L003A ; -GETBOOTDSK:CALL HEX ; Convert number to binary - JR C,L000F ; If illegal, loop back and re-prompt. - DEC A ; - CP 004H ; Check in range, if not loop back. - JR NC,L000F ; - LD (BPARA),A ; Store in parameter block. -L003A: LD IX,BPARA ; Point to drive number., - CALL DSKREAD ; Read sector 1 of trk 0 - LD HL,0CE00H ; Now compare the first 7 bytes of what was read to see if this is a bootable disk. - LD DE,DSKID ; - LD B,007H ; -L0049: LD C,(HL) ; - LD A,(DE) ; - CP C ; - JP NZ,L008C ; If NZ then this is not a master disk, ie not bootable, so error exit with message. - INC HL ; - INC DE ; - DJNZ L0049 ; - LD DE,MSGIPLLOAD ; - LD HL,PRINTMSG - CALL BKSW1to6 - LD DE,0CE07H ; Program name stored at 8th byte in boot sector. - LD HL,PRTFN - CALL BKSW1to6 - LD HL,(0CE16H) ; Get the load address - LD (IX+005H),L ; And store in parameter block at 100D/100E - LD (IX+006H),H ; - INC HL - DEC HL - JR NZ, NOTCPM ; If load address is 0 then where loading CPM. - ; LD A,(MEMSW) ; Page out ROM. -NOTCPM: LD HL,(0CE14H) ; Get the size - LD (IX+003H),L ; And store in parameter block at 100B/100C - LD (IX+004H),H ; - LD HL,(0CE1EH) ; Get logical sector number - LD (IX+001H),L ; And store in parameter block at 1009/100A - LD (IX+002H),H ; - CALL DSKREAD ; Read the required data and store in memory. - CALL DSKINIT ; Reset the disk ready for next operation. - LD HL,(0CE18H) ; Get the execution address - JP (HL) ; And execute. - -DSKLOADERR:LD DE,MSGLOADERR ; Loading error message - JR L008F ; (+003h) - -L008C: LD DE,MSGDSKNOTMST ; This is not a boot/master disk message. -L008F: LD HL,PRINTMSG - CALL BKSW1to6 - LD DE,ERRTONE ; Play error tone. - CALL MELDY - ; - LD SP,(TMPSTACKP) ; Recover the correct stack pointer before exit. - RET ; JP SS - -L0104: LD A,(MOTON) ; motor on flag - RRCA ; motor off? - CALL NC,DSKMOTORON ; yes, set motor on and wait - LD A,(IX+000H) ;drive no - OR 084H ; - OUT (0DCH),A ; Motor on for drive 0-3 - XOR A ; - LD (FDCCMD),A ; clr latest FDC command byte - LD HL,00000H ; -L0119: DEC HL ; - LD A,H ; - OR L ; - JP Z,DSKERR ; Reset and print message that this is not a bootable disk. - IN A,(0D8H) ; Status register. - CPL ; - RLCA ; - JR C,L0119 ; Wait on motor off (bit 7) - LD C,(IX+000H) ; Drive number - LD HL,TRK0FD1 ; 1 track 0 flag for each drive - LD B,000H ; - ADD HL,BC ; Compute related flag 1002/1003/1004/1005 - BIT 0,(HL) ; - JR NZ,L0137 ; - CALL DSKSEEKTK0 ; Seek track 0. - SET 0,(HL) ; Set bit 0 of trk 0 flag -L0137: RET - - ; Turn disk motor on. -DSKMOTORON:LD A,080H - OUT (0DCH),A ; Motor on - LD B,010H ; -L013E: CALL L02C7 ; - DJNZ L013E ; Wait until becomes ready. - LD A,001H ; Set motor on flag. - LD (MOTON),A ; - RET - -L0149: LD A,01BH - CALL DSKCMD - AND 099H - RET - - ; Initialise drive and reset flags, Set motor off -DSKINIT: XOR A - OUT (0DCH),A ; Motor on/off - LD (TRK0FD1),A ; Track 0 flag drive 1 - LD (TRK0FD2),A ; Track 0 flag drive 2 - LD (TRK0FD3),A ; Track 0 flag drive 3 - LD (TRK0FD4),A ; Track 0 flag drive 4 - LD (MOTON),A ; Motor on flag - RET - -DSKSEEKTK0:LD A,00BH ; Restore command, seek track 0. - CALL DSKCMD ; Send command to FDC. - AND 085H ; Process result. - XOR 004H - RET Z - JP DSKERR - -DSKCMD: LD (FDCCMD),A ; Store latest FDC command. - CPL ; Compliment it (FDC bit value is reversed). - OUT (0D8H),A ; Send command to FDC. - CALL L017E ; Wait to become ready. - IN A,(0D8H) ; Get status register. - CPL ; Inverse (FDC is reverse bit logic). - RET - -L017E: PUSH DE - PUSH HL - CALL L02C0 - LD E,007H -L0185: LD HL,00000H -L0188: DEC HL - LD A,H - OR L - JR Z,L0196 ; (+009h) - IN A,(0D8H) - CPL - RRCA - JR C,L0188 ; (-00bh) - POP HL - POP DE - RET - -L0196: DEC E - JR NZ,L0185 ; (-014h) - JP DSKERR - -L019C: PUSH DE - PUSH HL - CALL L02C0 - LD E,007H -L01A3: LD HL,00000H -L01A6: DEC HL - LD A,H - OR L - JR Z,L01B4 ; (+009h) - IN A,(0D8H) - CPL - RRCA - JR NC,L01A6 ; (-00bh) - POP HL - POP DE - RET - -L01B4: DEC E - JR NZ,L01A3 ; (-014h) - JP DSKERR - - ; Read disk starting at the first logical sector in param block 1009/100A - ; Continue reading for the given size 100B/100C and store in the location - ; Pointed to by the address stored in the parameter block. 100D/100E -DSKREAD: CALL L0220 ; Compute logical sector-no to track-no & sector-no, retries=10 -L01BD: CALL L0229 ; Set current track & sector, get load address to HL -L01C0: CALL L0249 ; Set side reg - CALL L0149 ; Command 1b output (seek) - JR NZ,L0216 ; - CALL L0259 ; Set track & sector reg - PUSH IX ; Save 1008H - LD IX, 0F3FEH ; As below. L03FE - LD IY,L01DF ; Read sector into memory. - ;DI - LD A,094H ; Latest FDC command byte - CALL L028A -L01DB: LD B,000H - JP (IX) - - ; Get data from disk sector to staging area (CE00). -L01DF: INI - LD A,(DE) ; If not at the end of the line, then process as the boot disk number. - JP NZ, 0F3FEH ; This is crucial, as the Z80 is running at 2MHz it is not fast enough so needs - ; hardware acceleration in the form of a banked ROM, if disk not ready jumps to IX, if - ; data ready, jumps to IY. L03FE - POP IX - INC (IX+008H) ; Increment current sector number - LD A,(IX+008H) ; Load current sector number - PUSH IX ; Save 1008H - LD IX, 0F3FEH ; As above. L03FE - CP 011H ; Sector 17? Need to loop to next track. - JR Z,L01FB - DEC D - JR NZ,L01DB - JR L01FC ; (+001h) - -L01FB: DEC D -L01FC: CALL L0294 - CALL L02D2 - POP IX - IN A,(0D8H) - CPL - AND 0FFH - JR NZ,L0216 ; (+00bh) - CALL L0278 - JP Z,L021B - LD A,(IX+007H) - JR L01C0 ; (-056h) - -L0216: CALL L026A - JR L01BD ; (-05eh) - -L021B: LD A,080H - OUT (0DCH),A ; Motor on - RET - -L0220: CALL L02A3 ; compute logical sector no to track no & sector no - LD A,00AH ; 10 retries - LD (RETRIES),A - RET - - ; Set current track & sector, get load address to HL -L0229: CALL L0104 - LD D,(IX+004H) ; Number of sectors to read - LD A,(IX+003H) ; Bytes to read - OR A ; 0? - JR Z,L0236 ; Yes - INC D ; Number of sectors to read + 1 -L0236: LD A,(IX+00AH) ; Start sector number - LD (IX+008H),A ; To current sector number - LD A,(IX+009H) ; Start track number - LD (IX+007H),A ; To current track number - LD L,(IX+005H) ; Load address low byte - LD H,(IX+006H) ; Load address high byte - RET - - ; Compute side/head. -L0249: SRL A ; Track number even? - CPL ; - OUT (0DBH),A ; Output track no. - JR NC,L0254 ; Yes, even, set side/head 1 - LD A,001H ; No, odd, set side/head 0 - JR L0255 - - ; Set side/head register. -L0254: XOR A ; Side 0 -L0255: CPL ; Side 1 - OUT (0DDH),A ; Side/head register. - RET - - ; Set track and sector register. -L0259: LD C,0DBH - LD A,(IX+007H) ; Current track number - SRL A - CPL - OUT (0D9H),A ; Track reg - LD A,(IX+008H) ; Current sector number - CPL - OUT (0DAH),A ; Sector reg - RET - -L026A: LD A,(RETRIES) - DEC A - LD (RETRIES),A - JP Z,DSKERR - CALL DSKSEEKTK0 - RET - -L0278: LD A,(IX+008H) - CP 011H - JR NZ,L0287 ; (+008h) - LD A,001H - LD (IX+008H),A - INC (IX+007H) -L0287: LD A,D - OR A - RET - -L028A: LD (FDCCMD),A - CPL - OUT (0D8H),A - CALL L019C - RET - -L0294: LD A,0D8H - CPL - OUT (0D8H),A - CALL L017E - RET - -DSKERR: CALL DSKINIT - JP DSKLOADERR - - ; Logical sector number to physical track and sector. -L02A3: LD B,000H - LD DE,00010H ; No of sectors per trk (16) - LD L,(IX+001H) ; Logical sector number - LD H,(IX+002H) ; 2 bytes in length - XOR A -L02AF: SBC HL,DE ; Subtract 16 sectors/trk - JR C,L02B6 ; Yes, negative value - INC B ; Count track - JR L02AF ; Loop -L02B6: ADD HL,DE ; Reset HL to the previous - LD H,B ; Track - INC L ; Correction +1 - LD (IX+009H),H ; Start track no - LD (IX+00AH),L ; Start sector no - RET - -L02C0: PUSH DE - LD DE,00007H - JP L02CB - -L02C7: PUSH DE - LD DE,01013H -L02CB: DEC DE - LD A,E - OR D - JR NZ,L02CB ; (-005h) - POP DE - RET - -L02D2: PUSH AF - LD A,(0119CH) - CP 0F0H - JR NZ,L02DB ; (+001h) - ;EI -L02DB: POP AF - RET - -;wait on bit 0 and bit 1 = 0 of state reg -L0300: IN A,(0D8H) ; State reg - RRCA - JR C,L0300 ; Wait on not busy - RRCA - JR C,L0300 ; Wait on data reg ready - JP (IY) ; to f1df - - ;------------------------------------------------------------------------------- - ; END OF FLOPPY DISK CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;-------------------------------------- - ; - ; Message table - Refer to bank 6 for - ; all messages. - ; - ;-------------------------------------- - - ; Error tone. -ERRTONE: DB "A0", 0D7H, "ARA", 0D7H, "AR", 00DH - - ; Identifier to indicate this is a valid boot disk -DSKID: DB 002H, "IPLPRO" - - ; Parameter block to indicate configuration and load area. -PRMBLK: DB 000H, 000H, 000H, 000H, 001H, 000H, 0CEH, 000H, 000H, 000H, 000H - - ; Ensure we fill the entire 2K by padding with FF's. - ALIGN 0EBFDh - DB 0FFh - -L03FE: JP (IY) - - ALIGN 0EFF8h - ORG 0EFF8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh diff --git a/software/asm/rfs_bank2.asm b/software/asm/rfs_bank2.asm deleted file mode 100644 index 69baa0b..0000000 --- a/software/asm/rfs_bank2.asm +++ /dev/null @@ -1,1605 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: rfs_bank2.asm -;- Created: July 2019 -;- Author(s): Philip Smart -;- Description: Sharp MZ series Rom Filing System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade. -;- -;- Credits: -;- Copyright: (c) 2018-2023 Philip Smart -;- -;- History: July 2019 - Merged 2 utilities to create this compilation. -; May 2020 - Bank switch changes with release of v2 pcb with coded latch. The coded -; latch adds additional instruction overhead as the control latches share -; the same address space as the Flash RAMS thus the extra hardware to -; only enable the control registers if a fixed number of reads is made -; into the upper 8 bytes which normally wouldnt occur. Caveat - ensure -; that no loop instruction is ever placed into EFF8H - EFFFH. -; July 2020 - Bug fixes and additions. -; July 2020 - Updated for the v2.1 hardware. RFS can run with a tranZPUter board with -; or without the K64 I/O processor. RFS wont use the K64 processor all -; operations are done by the Z80 under RFS. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - ;=========================================================== - ; - ; USER ROM BANK 2 - SD Card Controller functions. - ; - ;=========================================================== - ORG UROMADDR - - ;-------------------------------- - ; Common code spanning all banks. - ;-------------------------------- - NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -ROMFS2_0: LD A,(BNKCTRLRST) - DJNZ ROMFS2_0 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - NOP - NOP - NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 - LD (BNKSELMROM),A - NOP - NOP - NOP - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - ; - ; No mans land... this should have switched to Bank 0 and at this point there is a jump to 00000H. - JP 00000H ; This is for safety!! - - - ;------------------------------------------------------------------------------------------ - ; Bank switching code, allows a call to code in another bank. - ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. - ;------------------------------------------------------------------------------------------ - ALIGN_NOPS UROMBSTBL - ; -BKSW2to0: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK0 ; Required bank to call. - JR BKSW2_0 -BKSW2to1: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK1 ; Required bank to call. - JR BKSW2_0 -BKSW2to2: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK2 ; Required bank to call. - JR BKSW2_0 -BKSW2to3: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK3 ; Required bank to call. - JR BKSW2_0 -BKSW2to4: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK4 ; Required bank to call. - JR BKSW2_0 -BKSW2to5: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK5 ; Required bank to call. - JR BKSW2_0 -BKSW2to6: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK6 ; Required bank to call. - JR BKSW2_0 -BKSW2to7: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK7 ; Required bank to call. - ; -BKSW2_0: PUSH HL ; Place function to call on stack - LD HL, BKSWRET2 ; Place bank switchers return address on stack. - EX (SP),HL - LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. - LD (BNKSELUSER), A ; Repeat the bank switch B times to enable the bank control register and set its value. - JP (HL) ; Jump to required function. -BKSWRET2: POP AF ; Get bank which called us. - LD (BNKSELUSER), A ; Return to that bank. - POP AF - RET - - ;------------------------------------------------------------------------------- - ; GENERAL PURPOSE FUNCTIONS. - ;------------------------------------------------------------------------------- - - ; Method to multiply a 16bit number by another 16 bit number to arrive at a 32bit result. - ; Input: DE = Factor 1 - ; BC = Factor 2 - ; Output:DEHL = 32bit Product - ; -MULT16X16: LD HL,0 - LD A,16 -MULT16X1: ADD HL,HL - RL E - RL D - JR NC,$+6 - ADD HL,BC - JR NC,$+3 - INC DE - DEC A - JR NZ,MULT16X1 - RET - - ; Method to add a 16bit number to a 32bit number to obtain a 32bit product. - ; Input: DEHL = 32bit Addend - ; BC = 16bit Addend - ; Output:DEHL = 32bit sum. - ; -ADD3216: ADD HL,BC - EX DE,HL - LD BC,0 - ADC HL,BC - EX DE,HL - RET - - ; Method to add two 32bit numbers whilst calculating the SD Start Sector. - ; Input: DEHL = 32bit Addend - ; (SDSTARTSEC) = 32bit Addend - ; Output: (SDSTARTSEC) = 32bit Sum. - ; Output; DEHL = 32bit Sum. - ; -ADD32: LD BC,(SDSTARTSEC+2) - ADD HL,BC - LD (SDSTARTSEC+2),HL - LD BC,(SDSTARTSEC) - EX DE,HL - ADC HL,BC - LD (SDSTARTSEC),HL - EX DE,HL - RET - - ; A function from the z88dk stdlib, a delay loop with T state accuracy. - ; - ; enter : hl = tstates >= 141 - ; uses : af, bc, hl -T_DELAY: LD BC,-141 - ADD HL,BC - LD BC,-23 -TDELAYLOOP: ADD HL,BC - JR C, TDELAYLOOP - LD A,L - ADD A,15 - JR NC, TDELAYG0 - CP 8 - JR C, TDELAYG1 - OR 0 -TDELAYG0: INC HL -TDELAYG1: RRA - JR C, TDELAYB0 - NOP -TDELAYB0: RRA - JR NC, TDELAYB1 - OR 0 -TDELAYB1: RRA - RET NC - RET - - - ;------------------------------------------------------------------------------- - ; START OF SD CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;------------------------------------------------------------------------------- - ; Hardware SPI SD Controller (HW_SPI_ENA = 1) - ; This logic uses the RFS PCB v2+ hardware shift registers to communicate with - ; an SD Card. It is the fastest solution available but has a high IC count. - ; - ; Software SPI SD Controller (SW_SPI_ENA = 1) - ; This logic uses the RFS PCB v2+ logic to simulate the SPI interface with - ; bitbanging techniques. It is similar to the Parallel Port SD Controller - ; but uses logic on the RFS board rather than the parallel port interface. - ; - ; Parallel Port SD Controller (PP_SPI_ENA = 1) - ; This logic uses the standard Sharp MZ-80A Parallel Port for simulating the - ; SPI interface with bitbanging techniques. This interface is then used to - ; communicate with an SD Card. - ;------------------------------------------------------------------------------- - - ; Method to initialise the SD card. Assume that the RFS control registers are enabled, the default state within the RFS environment. - ; -SDINIT: LD A,0FFH ; CS to inactive (high) - CALL SPICS - ; - CALL SPIINIT ; Train SD with our clock. - ; - LD A,0 ; CS to active (low) - CALL SPICS - ; - LD BC,SD_RETRIES ; Number of retries before giving up, card not responding. -SDINIT1: LD A,CMD0 ; Command 0 - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - PUSH BC - ; - CALL SDCMD - ; - LD A,(SDBUF+6) ; Get response code. - DEC A ; Set Z flag to test if response is 0x01 - POP BC - JP Z,SDINIT2 ; Command response 0x01? Exit if match. - - DEC BC - LD A,B - OR C - JR NZ,SDINIT1 ; Retry for BC times. - LD A,1 - JP SD_EXIT ; Error, card is not responding to CMD0 - -SDINIT2: ; Now send CMD8 to get card details. This command can only be sent - ; when the card is idle. - LD A,CMD8 ; CMD8 has 0x00001AA as parameter, load up registers and call command routine. - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,0AA01H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - - ; Version 2 card, check its voltage range. IF not in the 2.7-3.6V dont try the ACMD41 to get capabilities. -SDINIT3: LD A,1 ; Check that we receive 0x0001AA in response. - LD (SDVER),A ; Indicate this is not a version 2 card. - LD A,(SDBUF+9) - CP 1 - JP NZ,SDINIT8 - LD A,(SDBUF+10) - CP 0AAH - JP NZ,SDINIT8 - -SDINIT4: LD A,2 ; This is a version 2 card. -SDINIT5: LD (SDVER),A ; Indicate this is not a version 2 card. - - CALL SDACMD41 - JR Z,SDINIT6 - LD A,2 ; Error, card is not responding to ACMD41 - JP SD_EXIT - -SDINIT6: LD A,CMD58 ; CMD58 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(SDBUF+6) - CP 040H - LD A,CT_SD2 - JR Z,SDINIT7 - LD A,CT_SD2 | CT_BLOCK -SDINIT7: LD (SDCAP),A ; Set the capabilities according to the returned flag. - JR SDINIT14 - - - ; Version 1 card or MMC v3. -SDINIT8: CALL SDACMD41 - LD A, CT_SD1 - LD E,ACMD41 ; SD1 cards we use the ACMD41 command. - JR Z,SDINIT9 - LD A,CT_MMC - LD E,CMD1 ; MMC cards we use the CMD1 command. -SDINIT9: LD (SDCAP),A - LD A,E - CP ACMD41 - JR NZ,SDINIT10 - CALL SDACMD41 - JR Z,SDINIT14 - LD A,3 ; Exit code, failed to initialise v1 card. - JP SD_EXIT - -SDINIT10: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. -SDINIT11: PUSH BC - LD A,CMD1 ; CMD1 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - OR A - JR Z,SDINIT13 - LD BC,0FFFFH ; Delay for at least 200mS for the card to recover and be ready. -SDINIT12: DEC BC ; 6T - LD A,B ; 9T - OR C ; 4T - JR NZ,SDINIT12 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS - ; - POP BC - DEC BC - LD A,B - OR C - JR NZ,SDINIT11 - LD A,4 ; Exit code, failed to initialise v1 MMC card. - JP SD_EXIT - -SDINIT13: POP BC - LD A,CMD16 ; No response from the card for an ACMD41/CMD1 so try CMD16 with parameter 0x00000200 - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00002H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(SDBUF+6) - OR A - JR Z,SDINIT14 - LD A,0 - LD (SDCAP),A ; No capabilities on this unknown card. -SDINIT14: XOR A - JR SD_EXIT -SD_EXIT: LD L,A ; Return value goes into HL. - LD H,0 - RET - - ; Method to send a command to the card and receive back a response. - ; - ; A = CMD to send - ; LHED = Argument, ie. CMD = A, L, H, E, D, CRC - ; -SDCMD: LD (SDBUF),A - LD (SDBUF+1),HL - EX DE,HL - LD (SDBUF+3),HL - ; - ; Send command but with parameters preloaded by caller. -SDCMDNP: LD B,5 ; R1 + 32bit argument for CMD8, CMD58 - CP CMD8 - LD C,135 - JP Z,SDCMD0 - LD C,1 ; CMD58 is not CRC checked so just set to 0x01. - CP CMD58 - LD B,5 ; R1 + 32bit argument - JP Z,SDCMD0 - ; - LD B,1 ; Default, expect R1 which is 1 byte. - CP CMD0 ; Work out the CRC based on the command. CRC checking is - LD C,149 ; not implemented but certain commands require a fixed argument and CRC. - JP Z,SDCMD0 - LD C,1 ; Remaining commands are not CRC checked so just set to 0x01. -SDCMD0: PUSH BC ; Save the CRC and the number of bytes to be returned, - LD A,C ; Store the CRC - LD (SDBUF+5),A - LD A,255 ; Preamble byte - CALL SPIOUT - LD HL,SDBUF - LD B,6 -SDCMD1: PUSH BC - LD A,(HL) - INC HL - CALL SPIOUT ; Send the command and parameters. - POP BC - DJNZ SDCMD1 - PUSH HL - LD HL,SD_RETRIES -SDCMD2: PUSH HL - CALL SPIIN - POP HL - CP 0FFH - JR NZ,SDCMD4 ; If != 0xFF then byte received is response R1. - DEC HL - LD A,H - OR L - JR NZ,SDCMD2 - ; - ; Error as we are not receiving data. - ; - POP HL - POP BC - LD A,1 ; Force return code to be error. - LD (SDBUF+6),A - RET - -SDCMD3: PUSH BC - PUSH HL - CALL SPIIN ; -SDCMD4: POP HL - LD (HL),A - INC HL - POP BC ; Get back number of expected bytes. HL = place in buffer to store response. - DJNZ SDCMD3 - IF HW_SPI_ENA = 0 - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH - OUT (SPI_OUT),A - ENDIF - RET - - ; Method to send an Application Command to the SD Card. This involves sending CMD55 followed by the required command. - ; - ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC - ; -SDACMD: PUSH AF - PUSH DE - PUSH HL - LD A,CMD55 ; CMD55 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - POP HL - POP DE - LD A,(SDBUF+6) ; Should be a response of 0 or 1. - CP 2 - JR NC,SDACMDE - POP AF - CALL SDCMD -SDACMD0: LD A,(SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - OR A - RET -SDACMDE: POP AF - JR SDACMD0 - - ; Method to send Application Command 41 to the SD card. This command involves retries and delays - ; hence coded seperately. - ; - ; Returns Z set if successful, else NZ. - ; -SDACMD41: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. -SDACMD1: PUSH BC - LD A,ACMD41 ; ACMD41 has 0x40000000 as parameter, load up registers and call command routine. - LD HL,00040H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDACMD - JR Z,SDACMD3 - LD BC,12903 ; Delay for at least 200mS for the card to recover and be ready. -SDACMD2: DEC BC ; 6T - LD A,B ; 9T - OR C ; 4T - JR NZ,SDACMD2 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS - ; - POP BC - DEC BC - LD A,B - OR C - JR NZ,SDACMD1 - LD A,1 - OR A ; Retries exceeded, return error. - RET -SDACMD3: POP BC ; Success, tidy up stack and exit with Z set. - XOR A - RET - - ; Method to initialise communications with the SD card. We basically train it to our clock characteristics. - ; This is important, as is maintaining the same clock for read or write otherwise the card may not respond. -SPIINIT: IF HW_SPI_ENA = 1 - ; Hardware SPI on the RFS v2+ PCB. - LD B,10 - LD A, 0FFH ; We need to send 80 '1's, so preload the data register with all 1's, future transmits dont require this as it self loads with 1's. - LD (HWSPIDATA),A -SPIINIT1: LD (HWSPISTART),A ; Commence transmission of an 8bit byte. Runs 1 8MHz, so 1 byte in 1uS, it takes the Z80 2uS for its quickest instruction at 2MHz clock. - DJNZ SPIINIT1 - RET - - ELSE - - ; Software SPI on the RFS v2+ PCB. - IF SW_SPI_ENA = 1 - - ELSE - - ; Software SPI on the centronics parallel port. - LD B,80 -SPIINIT1: LD A,DOUT_HIGH | CLOCK_HIGH | CS_HIGH ; Output a 1 - OUT (SPI_OUT),A - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Output a 1 - OUT (SPI_OUT),A - DJNZ SPIINIT1 - RET - ENDIF - ENDIF - - ; Method to set the Chip Select level on the SD card. The Chip Select is active LOW. - ; - ; A = 0 - Set CS LOW (active) - ; A = 0xFF - Set CS HIGH (active) -SPICS: IF HW_SPI_ENA = 1 - ; Hardware SPI on the RFS v2+ PCB. - OR A - LD A,(ROMCTL) - SET 1,A ; If we are inactivating CS then set CS high and disable clock by setting BBCLK to low. - RES 0,A - JR NZ, SPICS0 - RES 1,A ; If we are activating CS then set CS low and enable clock by setting BBCLK to high. - SET 0,A -SPICS0: LD (BNKCTRL),A - LD (ROMCTL),A - RET - - ELSE - - ; Software SPI on the RFS v2+ PCB. - IF SW_SPI_ENA = 1 - - ELSE - - ; Software SPI on the centronics parallel port. - OR A - LD A,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Set CS Low if parameter = 0 (ie. enable) - JR Z, SPICS0 - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Set CS High if parameter != 0 (ie. disable) -SPICS0: OUT (SPI_OUT),A - RET - ENDIF - ENDIF - - ; Method to send a byte to the SD card via the SPI protocol. - ; This method uses the hardware shift registers. - ; - ; Input A = Byte to send. - ; -SPIOUT: IF HW_SPI_ENA = 1 - ; Hardware SPI on the RFS v2+ PCB. - LD (HWSPIDATA),A - LD (HWSPISTART),A - RET - - ELSE - - ; Software SPI on the RFS v2+ PCB. - IF SW_SPI_ENA = 1 - - ELSE - - ; Software SPI on the centronics parallel port. - RLCA ; 65432107 - RLCA ; 54321076 - RLCA ; 43210765 - Adjust so that starting bit is same position as Data line. - LD E,A ; E = Character to send. - LD B,8 ; B = Bit count -SPIOUT0: LD A,E - AND DOUT_MASK ; Data bit to data line, clock and cs low. - RLC E -SPIOUT1: OUT (SPI_OUT),A - OR CLOCK_HIGH ; Clock high - OUT (SPI_OUT),A - AND CLOCK_MASK ; Clock low - OUT (SPI_OUT),A - DJNZ SPIOUT0 ; Perform actions for the full 8 bits. - RET - ENDIF - ENDIF - - ; Method to receive a byte from the SD card via the SPI protocol. - ; This method uses the hardware shift registers. - ; NB. Timing must be very similar in SPIOUT and SPIIN. - ; - ; Output: A = received byte. - ; -SPIIN: IF HW_SPI_ENA = 1 - ; Hardware SPI on the RFS v2+ PCB. - LD (HWSPISTART),A ; Commence transmission to receive back data from the SD card, we just send 1's. - LD A,(HWSPIDATA) ; Get the data byte. - RET - - ELSE - - ; Software SPI on the RFS v2+ PCB. - IF SW_SPI_ENA = 1 - - ELSE - - ; Software SPI on the centronics parallel port. - LD BC,00800H | SPI_OUT ; B = Bit count, C = clock port - LD L,0 ; L = Character being read. - LD D,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Output a 0 - OUT (C),D ; To start ensure clock is low and CS is low. - LD E,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Output a 0 -SPIIN1: OUT (C),E ; Clock to high. - IN A,(SPI_IN) ; Input the received bit - OUT (C),D ; Clock to low. - SRL A - RL L - DJNZ SPIIN1 ; Perform actions for the full 8 bits. - LD A,L ; return value - RET - ENDIF - ENDIF - ;------------------------------------------------------------------------------- - ; End of SPI SD Controller - ;------------------------------------------------------------------------------- - - - - ; Method to skip over an SD card input stream to arrive at the required bytes, - ; - ; Input: BC = Number of bytes to skip. - ; -SPISKIP: PUSH BC - CALL SPIIN - POP BC - DEC BC - LD A,B - OR C - JR NZ,SPISKIP - RET - - ; Method to convert an LBA value into a physical byte address. This is achieved by multiplying the block x 512. - ; We take the big endian sector value, shift left 9 times then store the result back onto the stack. - ; This is done as follows: <2> <1> <0> => <2> <1> <0> 0 (ie. 8 bit shift): Shift left <0> with carry, shift left <1> shift left <2>, 0 to - ; - ; Input: HL = Stack offset. - ; -LBATOADDR: LD HL,(SDSTARTSEC+1) - LD A,(HL) ; Start ny retrieving bytes as HED0 - INC HL - LD E,(HL) - INC HL - LD D,(HL) - LD L,A - - SLA D ; Shift the long left by 9 to effect a x512 - RL E - RL H - LD BC,(SDSTARTSEC) - LD A,H ; Now save the results as LHED, big endian format as used by the SD Card argument - LD (BC),A - INC BC - LD A,E - LD (BC),A - INC BC - LD A,D - LD (BC),A - INC BC - XOR A - LD (BC),A - RET - - - ; - ; This method was originally a C routine I was using for FatFS but optimised it (still more can be done). The C->ASM is not so optimal. - ; - ; Input: Memory variables: SDSTARTSEC= unsigned long sector. - The sector number or direct byte address for older cards. This is big endian as per card. - ; HL: Address where to store data read from sector. - ; BC: Size of data to read, upto a sector size. - ; Output: A: 0 - All ok. A > 0 - error occurred. - ; HL: End address of data loaded, - ; -SD_READ: PUSH HL ; Store the load address. - PUSH BC ; Store the read size. - XOR A - CALL SPICS ; Set CS low (active). - - LD HL,(SDCAP) ; Test to see if CT_BLOCK is available. - LD H,0 - LD A,CT_BLOCK - AND L - JP NZ,SD_READ1 ; If it has CT_BLOCK then use sector numbers otherwise multiply up to bytes. - CALL LBATOADDR ; Multiply the sector by 512 for byte addressing on older cards. - -SD_READ1: ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC - LD A,CMD17 ; Send CMD17 to read a sector. - LD (SDBUF),A - LD HL,(SDSTARTSEC) - LD (SDBUF+1),HL - LD HL,(SDSTARTSEC+2) - LD (SDBUF+3),HL - CALL SDCMDNP ; Execute SD Command, parameters already loaded into command buffer. - LD A,(SDBUF+6) ; Fetch result and store. - AND A - JP NZ,SD_READ6 ; If R1 is positive then an error occurred, get out. - - LD HL,1000 ; Sit in a tight loop waiting for the data packet arrival (ie. not 0xFF). -SD_READ2: PUSH HL - LD HL,200 - CALL T_DELAY - CALL SPIIN - POP HL - CP 255 - JP NZ,SD_READ3 - DEC HL - LD A,H - OR L - JR NZ,SD_READ2 - -SD_READ3: CP 254 ; Data? If not exit with error code. - JP NZ,SD_READ6 - - LD HL,SD_SECSIZE ; Size of full sector + 2 bytes CRC. - POP BC - OR A - SBC HL,BC ; Calculate the bytes to skip once we have read the required bytes. - EX DE,HL - POP HL ; Get the store address into HL. -SD_READ4: PUSH HL ; Start reading bytes into the buffer. - PUSH DE - PUSH BC - CALL SPIIN - POP BC - POP DE - POP HL - LD (HL),A - INC HL ; Update buffer pointer. - DEC BC - LD A,B - OR C - JP NZ,SD_READ4 ; Not zero, keep reading. - PUSH HL - PUSH DE - POP BC - INC BC ; Were not interested in the CRC so skip it. - INC BC - CALL SPISKIP ; Skip unread bytes + CRC. - POP HL - XOR A ; And exit with success. -SD_READ5: PUSH AF - LD A,0FFH ; De-activate CS. - CALL SPICS - POP AF - RET -SD_READ6: POP BC - POP HL - LD A,1 - JR SD_READ5 - - ; Method to write a 512byte sector to an SD Card. - ; - ; Input: Memory variables: SDSTARTSEC= unsigned long sector. - The sector number or direct byte address for older cards. This is big endian as per card. - ; HL: Address of buffer to read data from. - ; BC: Size of data to write, upto a sector size. - ; Output: A: 0 - All ok. A > 0 - error occurred. - ; HL: Address of end of buffer. -SD_WRITE: PUSH HL - PUSH BC - - XOR A ; Activate CS (set low). - CALL SPICS - - ; Open transaction. - LD HL,(SDCAP) ; Check to see if the card has block addressing. - LD H,0 - LD A,CT_BLOCK - AND L - JP NZ,SD_WRITE1 ; If it hasnt then we need to multiply up to the correct byte. - CALL LBATOADDR ; Multiply the sector by 512 for byte addressing. - - ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC -SD_WRITE1: LD A,CMD24 ; Send CMD24 to write a sector. - LD (SDBUF),A - LD HL,(SDSTARTSEC) ; Place long endian sector into command buffer. - LD (SDBUF+1),HL - LD HL,(SDSTARTSEC+2) - LD (SDBUF+3),HL - CALL SDCMDNP ; Send command using No Parameters version as we loaded them into the command buffer already. - LD A,(SDBUF+6) ; Fetch result and store. - AND A - JP NZ,SD_WRITE10 - LD A,255 ; Ok, so command sent successfully, mark the write by sending an 0xFF followed by 0xFE - CALL SPIOUT - LD A,254 - CALL SPIOUT - - ; Write buffer. - POP BC - LD HL,SD_SECSIZE - OR A - SBC HL,BC ; Calculate number of bytes to pad with 0. - EX DE,HL - POP HL ; Address to read data from. - ; -SD_WRITE2: LD A,B ; So long as we have bytes in the buffer, send to the card for writing. - OR C - JP Z,SD_WRITE3 - - PUSH DE - PUSH BC - LD A,(HL) ; Get the byte to transmit. - INC HL ; And update the pointer. - CALL SPIOUT ; Transmit value in A. - POP BC - POP DE - DEC BC - JR SD_WRITE2 - - ; Close transaction. -SD_WRITE3: PUSH HL ; Save the end of buffer address for return to caller. - PUSH DE ; DE contains number of padding bytes to send - POP BC - INC BC ; Add 2 bytes for CRC - INC BC -SD_WRITE4: LD A,B ; Test to see if we are already at zero, ie. all bytes sent. Exit if so. - OR C - JP Z,SD_WRITE5 - DEC BC - PUSH BC - XOR A ; Send 0's as padding bytes and CRC. - CALL SPIOUT - POP BC - JP SD_WRITE4 - -SD_WRITE5: CALL SPIIN ; Check received response, if 0x05 which indicates write under way inside SD Card. - AND 01FH - CP 5 - JP NZ,SD_WRITE11 - - LD HL,10000 ; Now wait for the write to complete allowing 1000mS before timing out. - PUSH HL - JR SD_WRITE7 -SD_WRITE6: DEC HL - PUSH HL - LD HL,200 ; 200T state delay = 200 x 1/2000000 = 100uS - CALL T_DELAY -SD_WRITE7: CALL SPIIN ; Get a byte, if it is not 0xFF then we have our response so exit. - POP HL - CP 255 - JP Z,SD_WRITE8 - LD A,H - OR L - JR NZ,SD_WRITE6 - -SD_WRITE8: LD A,H ; End of timeout? If so we exit with the preset fail code. - OR L - JP Z,SD_WRITE11 - XOR A ; Success code. - POP HL ; Get the updated return address to pass back to caller. -SD_WRITE9: PUSH AF - LD A,0FFH ; Disable SD Card Chip Select to finish. - CALL SPICS - POP AF - RET -SD_WRITE10: POP HL ; Waste the byte count and .. -SD_WRITE11: POP HL ; ..load address. - LD A,1 ; Error exit. - JR SD_WRITE9 - - - ; Method to print out an SDC directory entry name along with an incremental file number. The file number can be - ; used as a quick reference to a file rather than the filename. - ; - ; Input: HL = Address of filename. - ; D = File number. - ; A = File type. - ; -PRTDIR: PUSH BC - PUSH DE - PUSH HL - LD C,A ; Preseve file type. - ; - LD A,(SCRNMODE) - CP 0 - LD H,47 - JR Z,PRTDIR0 - LD H,93 -PRTDIR0: LD A,(TMPLINECNT) ; Pause if we fill the screen. - LD E,A - INC E - CP H - JR NZ,PRTNOWAIT - LD E, 0 -PRTDIRWAIT: CALL GETKY - CP ' ' - JR Z,PRTNOWAIT - CP 'X' ; Exit from listing. - LD A,001H - JR Z,PRTDIR4 - JR PRTDIRWAIT -PRTNOWAIT: LD A,E - LD (TMPLINECNT),A - ; - LD A, D ; Print out file number and increment. - CALL PRTHX - LD A,C - LD C,02AH - - CP BTX1CD ; '*' File type is 80K/80A BASIC. - JR Z,PRTDIR0A - INC C - CP BTX2CD ; '+' File type is 700/800 BASIC. - JR Z,PRTDIR0A - INC C - CP BTX3CD ; ',' File type is a NASCOM Cassette BASIC program. - JR Z,PRTDIR0A - INC C - CP BTX4CD ; '-' File type is a NASCOM ASCII TEXT BASIC program. - JR Z,PRTDIR0A - INC C - CP OBJCD ; '.' File type is MACHINE CODE program. - JR Z,PRTDIR0A - INC C -PRTDIR0A: LD A,C - CALL PRNT - POP DE - PUSH DE ; Get pointer to the file name and print. - - LD HL,PRTFN - CALL BKSW2to6 ; Print out the filename. - ; - LD HL, (DSPXY) - ; - LD A,L - CP 20 - LD A,20 - JR C, PRTDIR2 - ; - LD A,(SCRNMODE) ; 40 Char mode? 2 columns of filenames displayed so NL. - CP 0 - JR Z,PRTDIR1 - ; - LD A,L ; 80 Char mode we print 4 columns of filenames. - CP 40 - LD A,40 - JR C, PRTDIR2 - ; - LD A,L - CP 60 - LD A,60 - JR C, PRTDIR2 - ; -PRTDIR1: CALL NL - JR PRTDIR3 -PRTDIR2: LD L,A - LD (DSPXY),HL -PRTDIR3: XOR A -PRTDIR4: OR A - POP HL - POP DE - POP BC - RET - - - ; Method to get the LBA sector for an RFS SDCFS image location according to drive. - ; Inputs: - ; A = Starting sector in a single image. - ; or - ; DEHL = starting sector. - ; Outputs: - ; DEHL = Sector number. -RFSGETSECT: LD DE,0 ; Load DEHL with a 32bit start sector. DE=0 as SDCFS starts from sector 0. - LD H,0 ; Set HL to sector number. - LD L,A -RFSGETSECTR:LD A,(SDDRIVENO) ; Entry point when DEHL is defined. -GETDIRDRV: OR A ; Multiply up according to drive number. - RET Z - CP 'C' ; If SDDRIVENO is set to 'C" - CMT, then default to SD Drive 0. CMT is valid in certain applications but not for SD access. - JR NZ,GETDIRDRV1 - LD A,1 -GETDIRDRV1: DEC A - LD BC,08010H ; Number of sectors in an SDCFS image, 2000H directory + (64 * 65536) file blocks. - CALL ADD3216 ; Add drive sector multiple to move to next drive. - JR GETDIRDRV - - ; Method to set the SD Card 32bit LBA sector address. - ; Inputs: - ; DEHL = 32bit sector number. -SETLBAADDR: PUSH HL - POP BC - LD HL,SDSTARTSEC ; Store the starting sector in the SD card buffer ready for retrieval. - LD (HL), D - INC HL - LD (HL), E - INC HL - LD (HL), B - INC HL - LD (HL), C - INC HL - RET - - ; Method to get an SD Directory entry. - ; The SD Card works in 512byte sectors so a sector is cached and each call evaluates if the required request is in cache, if it is not, a new sector - ; is read. - ; - ; Input: E = Directory entry number to retrieve. - ; Output: HL = Address of directory entry. - ; A = 0, no errors, A > 1 error. -GETSDDIRENT:PUSH BC - PUSH DE; - ; - LD A,E - SRL A - SRL A - SRL A - SRL A ; Divide by 16 to get sector number. - LD C,A - LD A,(DIRSECBUF) ; Do we have this sector in the buffer? If we do, use it. - CP C - JR Z,GETDIRSD0 - LD A,C - LD (DIRSECBUF),A ; Save the sector number we will load into the buffer. - ; - LD HL,SECTORBUF - LD (SDLOADADDR),HL - ; - CALL RFSGETSECT ; Get the directory sector, offset by drive number. DEHL is returned as the full 32bit LBA sector address. - CALL SETLBAADDR ; Store the sector address into the SD command buffer. - ; - LD BC,SD_SECSIZE ; Set retrieval size to 1 sector. - LD (SDLOADSIZE),BC - LD HL,(SDLOADADDR) - ; - ;DI - CALL SD_READ ; Read the sector. - ;EI - ; - OR A - JR NZ,DIRSDERR - LD (SDLOADADDR),HL ; Save the updated address. -GETDIRSD0: POP DE - PUSH DE - LD A,E ; Retrieve the directory entry number required. - AND 00FH - LD HL,SECTORBUF - JR Z,GETDIRSD2 - LD B,A - LD DE,SDDIR_ENTSZ ; Directory entry size -GETDIRSD1: ADD HL,DE ; Directory entry address into HL. - DJNZ GETDIRSD1 -GETDIRSD2: POP DE - POP BC - XOR A -GETDIRSD3: OR A - RET - ; -DIRSDERR: EX DE,HL ; Print error message, show HL as it contains sector number where error occurred. - PUSH HL - POP BC ; HL to BC as the call requires the value to be displayed in BC. - LD DE,MSGSDRERR - CALL SDPRINT ; Print out the filename. - POP DE - POP BC - LD A,1 - JR GETDIRSD3 - - ; Method to find a free slot in the directory. - ; - ; Input: None. - ; Output: E = Free directory entry. - ; HL = Address of directory entry. - ; C = 1 if no free directory slot available. - ; Unless other directory entry functions called, DIRSECBUF = directory sector in cache which contains the free entry found. -GETDIRFREE: LD A,0FFH - LD (DIRSECBUF),A ; Reset the sector buffer in memory indicator. - ; - LD E,0 ; Directory entry number - LD B,0 ; Scanning 256 directory entries for a free slot. -GETDIRFREE1:CALL GETSDDIRENT ; Get SD Directory entry details for directory entry number stored in D. - RET NZ ; Error reading sector so abort. - LD A,(HL) - BIT 7,A ; Look for an inactive directory entry slot, Bit 7 of lower flag = 0? - JR NZ,GETDIRFREE2 - OR A - RET ; Found an entry that is free. -GETDIRFREE2:INC E ; Onto next directory entry number. - DJNZ GETDIRFREE1 - SCF - RET - - - ; Method to write the cached SD Directory entry sector back to SD card. - ; Normal use would be to call GERSDDIRENT to locate a required entry or slot, update it then call - ; this method to flush it back to SD disk. -WRSDDIRENT: LD A,(DIRSECBUF) ; Get the directory sector number of the cached directory sector. - ; - CALL RFSGETSECT ; Get the directory sector, offset by drive number. DEHL is returned as the full 32bit LBA sector address. - CALL SETLBAADDR ; Store the sector address into the SD command buffer. - ; - LD HL,SECTORBUF ; Address of the sector. - LD BC,SD_SECSIZE ; Set the size as one full sector. - ; - ;DI - CALL SD_WRITE - ;EI - ; - OR A - JR NZ,DIRSDWERR - XOR A -WRSDDIRENT1:OR A - RET -DIRSDWERR: LD DE,MSGSDWERR - PUSH HL - POP BC ; HL to BC as the call requires the value to be displayed in BC. - CALL SDPRINT ; Print out the filename. - LD A,1 - JR WRSDDIRENT1 - - - - ; Method to list the directory of the SD Card. - ; - ; This method creates a unique sequenced number starting at 0 and attaches to each successive valid directory entry - ; The file number and file name are then printed out in tabular format. The file number can be used in Load/Save commands - ; instead of the filename. - ; - ; No inputs or outputs. - ; -DIRSDCARD: LD A,1 ; Setup screen for printing, account for the title line. TMPLINECNT is used for page pause. - LD (TMPLINECNT),A - LD A,0FFH - LD (DIRSECBUF),A ; Reset the sector buffer in memory indicator. - ; - LD A,(SDDRIVENO) - CP 'C' - JR Z,DIRSDP - ADD A,'0' -DIRSDP: LD C,A ; C is printed as a character embedded in the message. - LD DE,MSGCDIRLST ; Print out header. - CALL SDPRINT ; Print out the header. - ; -DIRSD0: LD E,0 ; Directory entry number - LD D,0 ; Directory file number (incr when a valid dirent is found). - LD B,0 -DIRSD1: CALL GETSDDIRENT ; Get SD Directory entry details for directory entry number stored in D. - RET NZ -DIRSD2: LD A,(HL) - BIT 7,A ; Is this entry active, ie. Bit 7 of lower flag = 1? - JR Z,DIRSD3 - INC HL - LD A,(HL) ; Get file attribute for print identification. - INC HL ; Hop over flags. - CALL PRTDIR ; Valid entry so print directory number and name pointed to by HL. - JR NZ,DIRSD4 - INC D -DIRSD3: INC E ; Onto next directory entry number. - DJNZ DIRSD1 -DIRSD4: RET - ; - - - ; Method to locate an entry in the SD directory based on a filenumber or a filename. - ; This method is called with the raw parameter string in DE which is then parsed to determine if a filenumber - ; or filename has been given. - ; Input: DE = String containing a filenumber of filename. - ; Output: (TMPCNT) = 0xFFFF - DE contains a filename. - ; (TMPCNT) != 0xFFFF - DE contains a filenumber and (TMPCNT) is set to that number. -FINDSDX: PUSH DE - LD HL,0FFFFh ; Tag the filenumber as invalid. - LD (TMPCNT), HL - CALL _2HEX - JR C, FINDSDX1 ; - LD L,A - LD H,0 - LD A,(DE) ; Before comitting the file number verify it is actually a 2 digit hex string. - CP 00DH - JR Z,FINDSDX0 - OR A - JR NZ,FINDSDX1 -FINDSDX0: LD (TMPCNT), HL ; Store filenumber making load by filenumber valid. -FINDSDX1: POP DE - - ; Method to locate an entry in the SD directory based on a filenumber or a filename. - ; Input: DE = String containing a filenumber or filename. - ; (TMPCNT) = 0xFFFF - DE contains a filename. - ; (TMPCNT) != 0xFFFF - Filenumber. -FINDSD: PUSH DE - LD A,0FFH - LD (DIRSECBUF),A ; Reset the sector buffer in memory indicator. - LD E,0 ; Directory entry number start - LD D,0 ; Directory file number (incr when a valid dirent is found). - LD B,0 -FINDSD1: CALL GETSDDIRENT ; Get SD Directory entry details for directory entry number stored in D. -FINDSD2: BIT 7,(HL) ; Is this entry active, ie. Bit 7 of lower flag = 1? - JR Z,FINDSD3 - PUSH HL - LD HL,(TMPCNT) - ;LD H,(HL) - LD A,H - CP 0FFH - LD A,L - POP HL - JR Z,FINDSD4 ; A filenumber wasnt given so will need to name match. - CP D ; Match on filenumber, does the given number match with the current? - JR Z,FINDSD9 - INC D -FINDSD3: INC E - DJNZ FINDSD1 - POP DE ; No match, waste pointer to input string and exit with 1. - LD A,1 - JP FINDSD10 ; We didnt find a match so exit with code 1. - ; -FINDSD4: LD (TMPADR), DE ; Save current directory position and file number. - POP DE ; Get back pointer to given filename. HL contains directory filename. - PUSH DE ; Save DE as the pointer will be needed on next loop. - PUSH BC ; Save directory count. - ; - LD B,SDDIR_FNSZ - INC HL - INC HL ; Hop over flags. -FINDSD5: LD A,(DE) - OR A - JR Z, FINDSD9A - CP 00Dh ; If we find a terminator then this is a valid name. - JR Z, FINDSD9A - CP (HL) - JR NZ,FINDSD8 ; Mot a match. -FINDSD6: INC DE - INC HL - DJNZ FINDSD5 ; Loop for all the filename characters until terminator or difference found. - JR FINDSD9 ; If we matched all FNSIZE characters then this is a valid name. - - ; No match. -FINDSD8: POP BC ; Retrieve the directory count for next entry, - LD DE,(TMPADR) ; Retrieve the directory position and file number. - JR FINDSD3 - - ; Match -FINDSD9A: POP BC ; Waste the directory count. - LD DE,(TMPADR) ; Retrieve the directory position and file number. -FINDSD9: POP BC ; Waste the pointer to the input string. - XOR A ; D contains the filenumber. -FINDSD10: OR A - RET - - - ; Method to erase a filCOSMIC_CRUISER1MC.256.bine in the SD RFS. This is a simple matter of resetting the valid entry flag (bit 7 of FLAG1) in the directory entry for - ; the required file. - ; Input: DE = String containing filenumber or filename to erase. - ; Output: A = 0 Success, 1 = Fail. -ERASESD: CALL FINDSDX - JR NZ,LOADSD3 ; Not found? Print message and exit. - ; Directory entry in cache, HL points to FLAG1 of entry. - LD A,(HL) ; Clear the valid entry flag, bit 7 of FLAG1 - AND 07FH - LD (HL),A - PUSH DE - CALL WRSDDIRENT ; Flush the directory entry to disk to effect the delete. - OR A - JR NZ,ERASESD1 ; Failure, the report and exit. - POP BC ; Get the directory entry number. - LD B,0 - LD DE,MSGERASEDIR - XOR A ; Success. - JR SDPRINTRES -ERASESD1: LD A,1 - LD DE,MSGERAFAIL ; Fail, print out message. -SDPRINTRES: LD (RESULT),A -SDPRINT: LD HL,PRINTMSG - CALL BKSW2to6 ; Print out the filename. - RET - - ; Entry point when copying the SD file. Setup flags to indicate copying to effect any special processing. - ; The idea is to load the file into memory, dont execute and pass back the parameters within the CMT header. - ; -LOADSDCP: LD A,0FFH - LD (SDAUTOEXEC),A - JR LOADSD2 - - ; Load a program from the SD Card into RAM and/or execute it. - ; - ; DE points to a number or filename to load. -LOADSDCARDX:LD A,0FFH - JR LOADSD1 - -LOADSDCARD: XOR A -LOADSD1: LD (SDAUTOEXEC),A - XOR A ; Clear copying flag. -LOADSD2: LD (SDCOPY),A - LD A,0FFH ; For interbank calls, save result in a memory variable. - LD (RESULT),A - CALL FINDSDX - JP Z,LOADSD10 -LOADSD3: LD DE,MSGNOTFND - JR SDPRINT - - ; Helper method for the CMT replacement functions3. This method is inter bank called to locate a file pointed to by DE and set the header information. -LOADSDINF: CALL FINDSDX - JR Z,LOADSD9 ; Same as section above difference is we want to return after the header information has been extracted. - JP LOADSDXERR - - ; Helper method for CMT replacement functions. This method is called to load data with details already set in the CMT header and SD command buffer. -LOADSDDATA: LD DE,(DTADR) ; Update the load address in case caller changed it after reading the header. - LD (SDLOADADDR),DE - CALL LOADSD11 - LD A,0 - JR C,LOADSDDAT1 - JR Z,LOADSDDAT1 - INC A -LOADSDDAT1: LD (RESULT),A - RET - - ; We have found the directory entry, so use it to load the program into memory. - ; HL points to end of filename so requires an update to point to start of the directory entry. - ; Copy all relevant information into the CMT header (for reference) and working variables. - ; -LOADSD9: LD A,L - AND 0E0H - INC A - LD L,A - LD A,(HL) - LD (ATRB),A ; Type of file, store in the tape header memory. - INC HL - LD DE,NAME - LD B,SDDIR_FNSZ -LOADSD90: LD A,(HL) - OR A - JR NZ,LOADSD91 - LD A,CR ; Map NULL's to CR - applications use CR. -LOADSD91: LD (DE),A ; Copy the filename into the CMT area. - INC HL - INC DE - DJNZ LOADSD90 - ; - LD D,(HL) - INC HL - LD E,(HL) ; Start sector upper 16 bits, big endian. SDCFS under RFS this should always be zero. - INC HL - PUSH DE - - LD D,(HL) - INC HL - LD E,(HL) ; Start sector lower 16 bits, big endian. - INC HL - ; - EX (SP),HL - EX DE,HL - CALL RFSGETSECTR ; Get the directory sector, offset by drive number. DEHL is returned as the full 32bit LBA sector address. - CALL SETLBAADDR ; Store the sector address into the SD command buffer. - POP HL - ; - LD E,(HL) - INC HL - LD D,(HL) ; Size of file. - INC HL - LD (SIZE),DE - LD (SDLOADSIZE),DE - LD E,(HL) - INC HL - LD D,(HL) ; Load address. - INC HL - LD A,D - LD (DTADRSTORE),DE ; Save the original load address, use this to fill DTADR when complete if it has changed.. - CP 001H - JR NC,LOADSD9A - LD DE,01200H ; If the file specifies a load address below 1000H then shift to 1200H as it is not valid. -LOADSD9A: LD (DTADR),DE - LD (SDLOADADDR),DE - LD E,(HL) - INC HL - LD D,(HL) ; Execution address, store in tape header memory. - LD (EXADR),DE - JR LOADSDX ; Exit with ok. - ; -LOADSD10 CALL LOADSD9 ; Modularised file find as the CMT replacement functions need it. - LD DE,MSGLOAD+1 ; Skip initial CR. - LD BC,NAME - CALL SDPRINT ; Print out the filename. - CALL LOADSD11 - JR C,LOADSD14 - JR NZ,LOADSDERR - JR LOADSD14 - ; -LOADSD11: LD A,(SDLOADSIZE+1) - CP 002H - LD BC,SD_SECSIZE ; A full sector read if remaining bytes >=512 - JR NC,LOADSD12 - LD BC,(SDLOADSIZE) ; Get remaining bytes size. -LOADSD12: LD HL,(SDLOADADDR) - ;DI - CALL SD_READ ; Read the sector. - ;EI - OR A - RET NZ ; Failure to read a sector, abandon with error message. - LD (SDLOADADDR),HL ; Save the updated address. - ; - LD HL,SDSTARTSEC+3 - INC (HL) - JR NZ,LOADSD12A - DEC HL - INC (HL) -LOADSD12A: LD HL,(SDLOADSIZE) - LD DE,SD_SECSIZE - OR A - SBC HL,DE - RET C - RET Z - LD (SDLOADSIZE),HL - JR LOADSD11 - - ; - ; Execute code loaded. -LOADSD14: LD A,(SDAUTOEXEC) ; Autoexecute turned off? - CP 0FFh - JP Z,LOADSD15 ; Go back to monitor if it has been, else execute. - LD A,(ATRB) - CP OBJCD - JR NZ,LOADSD17 - LD A,0FEH ; Indicate that the program needs executing, must occur from ROM Bank 0. - JR LOADSDEXIT - ; - ; Load only. -LOADSD15: LD DE,MSGCMTDATA ; Indicate where the program was loaded and the execution address. - LD HL,(DTADR) - PUSH HL - LD HL,(EXADR) - PUSH HL - LD BC,(SIZE) -LOADSD16: LD HL,PRINTMSG - CALL BKSW2to6 ; Print out the filename with stack parameters. - POP BC - POP BC ; Remove parameters off stack. -LOADSDX: XOR A ; Non error exit. -LOADSDEXIT: LD (RESULT),A ; 0 = No error, 2 = Error, 0xFE = Execute code, address at EXADR - RET - - ; Not a binary file so cannot execute. -LOADSD17: LD DE,MSGNOTBIN - JR LOADSDERR2 - -LOADSDERR: LD DE,MSGSDRERR ; Print out the filename. - LD BC,(TMPCNT) -LOADSDERR2: CALL SDPRINT -LOADSDXERR: LD A,2 - JR LOADSDEXIT - - ; Setup for saving an application to SD Card but using the CMT header. Also set the copy flag because the values in the header - ; may not reflect where the image is stored (ie. CTM LOAD=0x0000 -> data is at 0x1200). - ; -SAVESDCARDX:LD A,0FFH - JR SAVESD1 - - ; Method to save a block of memory to the SD card as a program. - ; The parameters which should be given are: - ; XXXXYYYYZZZZ - where XXXX = Start Address, YYYY = End Address, ZZZZ = Execution Address. - ; Prompt for a filename which will be written into the CMT header. - ; All the values are stored in the CMT header and copied as needed into the SD directory. - ; -SAVESDCARD: LD HL,GETCMTPARM ; Get the CMT parameters. - CALL BKSW2to3 - LD A,C - OR A - RET NZ ; Exit if an error occurred. - ; - LD A,OBJCD ; Set attribute: OBJ - LD (ATRB),A - ; -SAVESDDATA: XOR A ; Disable the copy flag. -SAVESD1: LD (SDCOPY),A - LD A,0FFH ; Interbank calls, pass result via a memory variable. Assume failure unless updated. - LD (RESULT),A - - ; Find free slot. - CALL GETDIRFREE - JR NC,SAVESD4 - LD DE,MSGDIRFULL ; Directory is full so abort command. - LD A,1 ; Directory full code. - JP SDPRINTRES - ; -SAVESD4: PUSH DE ; Save the directory entry number. - PUSH HL - LD B,0 - LD C,E - LD DE,MSGSVDIRENT - CALL SDPRINT ; Print out the filename. - POP HL ; HL points to the directory entry buffer. - LD A,080H - LD (HL),A ; Set directory entry flag indicating that the entry is in use. - INC HL - LD A,(ATRB) - LD (HL),A ; Copy attribute. - INC HL - LD BC,SDDIR_FNSZ - LD DE,NAME - EX DE,HL - LDIR ; Copy filename across to directory. - EX DE,HL - POP DE ; Get directory entry number in E. - ; - PUSH HL - LD D,0 - LD BC,SDDIR_BLOCKSZ / SD_SECSIZE ; Put the blocksize as sectors into BC and multiply with E to get the block address. - CALL MULT16X16 ; DEHL to contain LBA address for given block. - LD BC,SDDIR_DIRSIZE / SD_SECSIZE - CALL ADD3216 ; Add in size of directory to arrive at correct LBA sector. - PUSH HL - POP BC ; 32bit LBA now in DEBC - POP HL - ; Store the Big Endian LBA Sector into the directory entry. - LD (HL),D ; Now save the 32bit LBA sector number into the directory entry. - INC HL - LD (HL),E - INC HL - LD A,B - LD (HL),A - INC HL - LD A,C - LD (HL),A - INC HL - ; - PUSH BC ; Save BC and swap for HL so sector now in DEHL. - EX (SP),HL - CALL RFSGETSECTR ; Get the directory sector, offset by drive number. DEHL is returned as the full 32bit LBA sector address. - CALL SETLBAADDR ; Store the sector address into the SD command buffer. - POP HL - ; - LD DE,(SIZE) ; Add in the size of the program. - LD (SDLOADSIZE),DE - LD (HL),E - INC HL - LD (HL),D - INC HL - ; - LD DE,(DTADR) ; Add in the load address of the program. - LD (HL),E - INC HL - LD (HL),D - INC HL - ; - LD A,(SDCOPY) - OR A - JR Z,SAVEDS4A - LD DE,01200H ; Copy mode -> data is always at 0x1200. -SAVEDS4A: LD (SDLOADADDR),DE - ; - LD DE,(EXADR) ; Add in the execution address of the program. - LD (HL),E - INC HL - LD (HL),D - INC HL - ; - ; Header has been written into the cached directory sector, write out data and if successful, write out - ; the directory entry to complete. - ; -SAVESD5: LD A,(SDLOADSIZE+1) - CP 002H - LD BC,SD_SECSIZE ; A full sector read if remaining bytes >=512 - JR NC,SAVESD6 - LD BC,(SDLOADSIZE) ; Get remaining bytes size. -SAVESD6: LD HL,(SDLOADADDR) - ;DI - CALL SD_WRITE ; Write the sector. - ;EI - OR A - JR NZ,SAVESD9 ; Failure to read a sector, abandon with error message. - LD (SDLOADADDR),HL ; Save the updated address. - ; - LD HL,SDSTARTSEC+3 - INC (HL) - JR NZ,SAVESD7 - DEC HL - INC (HL) -SAVESD7: LD A,(SDLOADSIZE+1) - CP 002H - JR C,SAVESD8 ; If carry then the last read obtained the remaining bytes. - LD HL,(SDLOADSIZE) - LD DE,SD_SECSIZE - OR A - SBC HL,DE - LD (SDLOADSIZE),HL - JR SAVESD5 -SAVESD8: ; Data written, now write out the directory entry. - CALL WRSDDIRENT ; Flush the directory entry to disk. - ;PUSH HL - ;PUSH DE - ;PUSH BC - ;LD BC,01000H - ;LD DE,0D000H - ;LD HL,DUMPBC - ;CALL BKSW2to3 - ;POP BC - ;POP DE - ;POP HL - OR A - JR NZ,SAVESD9 - LD A,0 ; Success. - LD (RESULT),A - RET -SAVESD9: LD DE,MSGSVFAIL ; Fail, print out message. - LD A,1 ; Write failed code. - JP SDPRINTRES ; Print out the filename. - - ;------------------------------------------------------------------------------- - ; END OF SD CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - - ;-------------------------------------- - ; - ; Message table - Refer to Bank 6 for - ; all printable messages. - ; - ;-------------------------------------- - - ALIGN 0EFF8h - ORG 0EFF8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh diff --git a/software/asm/rfs_bank3.asm b/software/asm/rfs_bank3.asm deleted file mode 100644 index 79d1cd3..0000000 --- a/software/asm/rfs_bank3.asm +++ /dev/null @@ -1,548 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: rfs_bank3.asm -;- Created: July 2019 -;- Author(s): Philip Smart -;- Description: Sharp MZ series Rom Filing System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade. -;- -;- Credits: -;- Copyright: (c) 2018-2023 Philip Smart -;- -;- History: July 2019 - Merged 2 utilities to create this compilation. -; May 2020 - Bank switch changes with release of v2 pcb with coded latch. The coded -; latch adds additional instruction overhead as the control latches share -; the same address space as the Flash RAMS thus the extra hardware to -; only enable the control registers if a fixed number of reads is made -; into the upper 8 bytes which normally wouldnt occur. Caveat - ensure -; that no loop instruction is ever placed into EFF8H - EFFFH. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - -ROW EQU 25 -COLW EQU 40 -SCRNSZ EQU COLW * ROW -MODE80C EQU 0 - - ;=========================================================== - ; - ; USER ROM BANK 3 - Monitor memory utilities. - ; - ;=========================================================== - ORG UROMADDR - - ;-------------------------------- - ; Common code spanning all banks. - ;-------------------------------- - NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -ROMFS3_0: LD A,(BNKCTRLRST) - DJNZ ROMFS3_0 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - NOP - NOP - NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 - LD (BNKSELMROM),A - NOP - NOP - NOP - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - ; - ; No mans land... this should have switched to Bank 0 and at this point there is a jump to 00000H. - JP 00000H ; This is for safety!! - - - ;------------------------------------------------------------------------------------------ - ; Bank switching code, allows a call to code in another bank. - ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. - ;------------------------------------------------------------------------------------------ - ALIGN_NOPS UROMBSTBL - ; -BKSW3to0: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK0 ; Required bank to call. - JR BKSW3_0 -BKSW3to1: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK1 ; Required bank to call. - JR BKSW3_0 -BKSW3to2: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK2 ; Required bank to call. - JR BKSW3_0 -BKSW3to3: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK3 ; Required bank to call. - JR BKSW3_0 -BKSW3to4: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK4 ; Required bank to call. - JR BKSW3_0 -BKSW3to5: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK5 ; Required bank to call. - JR BKSW3_0 -BKSW3to6: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK6 ; Required bank to call. - JR BKSW3_0 -BKSW3to7: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK7 ; Required bank to call. - ; -BKSW3_0: PUSH HL ; Place function to call on stack - LD HL, BKSWRET3 ; Place bank switchers return address on stack. - EX (SP),HL - LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. - LD (BNKSELUSER), A ; Repeat the bank switch B times to enable the bank control register and set its value. - JP (HL) ; Jump to required function. -BKSWRET3: POP AF ; Get bank which called us. - LD (BNKSELUSER), A ; Return to that bank. - POP AF - RET - - ;------------------------------------------------------------------------------- - ; START OF TAPE/SD CMDLINE TOOLS FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; Method to copy an application on a tape to an SD stored application. The tape drive is read and the first - ; encountered program is loaded into memory at 0x1200. The CMT header is populated with the correct details (even if - ; the load address isnt 0x1200, the CMT Header contains the correct value). - ; A call is then made to write the application to the SD card. - ; -TAPE2SD: ; Load from tape into memory, filling the tape CMT header and loading data into location 0x1200. - LD HL,LOADTAPECP ; Call the Loadtape command, non execute version to get the tape contents into memory. - CALL BKSW3to4 - LD A,(RESULT) - OR A - JR NZ,TAPE2SDERR - ; Save to SD Card. - LD HL,SAVESDCARDX - CALL BKSW3to2 - LD A,(RESULT) - OR A - JR NZ,TAPE2SDERR - LD DE,MSGT2SDOK - JR TAPE2SDERR2 -TAPE2SDERR: LD DE,MSGT2SDERR -TAPE2SDERR2:LD HL,PRINTMSG - CALL BKSW3to6 - RET - - ; Method to copy an SD stored application to a Cassette tape in the CMT. - ; The directory entry number or filename is passed to the command and the entry is located within the SD - ; directory structure. The file is then loaded into memory and the CMT header populated. A call is then made - ; to write out the data to tap. - ; -SD2TAPE: ; Load from SD, fill the CMT header then call CMT save. - LD HL,LOADSDCP - CALL BKSW3to2 - LD A,(RESULT) - OR A - JR NZ,SD2TAPEERR - LD HL,SAVECMT - CALL BKSW3to4 - LD A,(RESULT) - OR A - JR NZ,SD2TAPEERR - RET -SD2TAPEERR: LD DE,MSGSD2TERR - JR TAPE2SDERR2 - RET - ;------------------------------------------------------------------------------- - ; END OF TAPE/SD CMDLINE TOOLS FUNCTIONALITY - ;------------------------------------------------------------------------------- - - - ;------------------------------------------------------------------------------- - ; START OF MEMORY CMDLINE TOOLS FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; - ; Memory correction - ; command 'M' - ; -MCORX: CALL READ4HEX ; correction address - RET C -MCORX1: CALL NLPHL ; corr. adr. print - CALL SPHEX ; ACC ASCII display - CALL PRNTS ; space print - LD DE,BUFER ; Input the data. - CALL GETL - LD A,(DE) - CP 01Bh ; If . pressed, exit. - RET Z - PUSH HL - POP BC - CALL HLHEX ; If the existing address is no longer hex, reset. HLASCII(DE). If it is hex, take as the address to store data into. - JR C,MCRX3 ; Line is corrupted as the address is no longer in Hex, reset. - INC DE - INC DE - INC DE - INC DE - INC DE ; - CALL _2HEX ; Get value entered. - JR C,MCORX1 ; Not hex, reset. - CP (HL) ; Not same as memory, reset. - JR NZ,MCORX1 - INC DE ; - LD A,(DE) ; Check if no data just CR, if so, move onto next address. - CP 00Dh ; not correction - JR Z,MCRX2 - CALL _2HEX ; Get the new entered data. ACCHL(ASCII) - JR C,MCORX1 ; New data not hex, reset. - LD (HL),A ; data correct so store. -MCRX2: INC HL - JR MCORX1 -MCRX3: LD H,B ; memory address - LD L,C - JR MCORX1 - - ; Memory copy command 'CPY' - ; Parameters: XXXYYYZZZ - XXXX = Source, YYYY = Destination, ZZZZ = Size -MCOPY: CALL READ4HEX ; Source - JR C,MCOPYER1 - PUSH HL - CALL READ4HEX ; Destination - JR C,MCOPYER2 - PUSH HL - CALL READ4HEX ; Size - JR C,MCOPYER3 - PUSH HL - POP BC ; Size - POP DE ; Destination - POP HL ; Source - LDIR - RET - ; -MCOPYER3: POP HL -MCOPYER2: POP HL -MCOPYER1: RET - - - ; Dump method when called interbank as HL cannot be passed. - ; - ; BC = Start - ; DE = End -DUMPBC: PUSH BC - POP HL - JR DUMP - - ; Command line utility to dump memory. - ; Get start and optional end addresses from the command line, ie. XXXX[XXXX] - ; Paging is implemented, 23 lines at a time, pressing U goes back 100H, pressing D scrolls down 100H - ; -DUMPX: CALL HLHEX ; Get start address if present into HL - JR NC,DUMPX1 - LD DE,(DUMPADDR) ; Setup default start and end. - JR DUMPX2 -DUMPX1: INC DE - INC DE - INC DE - INC DE - PUSH HL - CALL HLHEX ; Get end address if present into HL - POP DE ; DE = Start address - JR NC,DUMPX4 ; Both present? Then display. -DUMPX2: LD A,(SCRNMODE) - OR A - LD HL,000A0h ; Make up an end address based on 160 bytes from start for 40 column mode. - JR Z,DUMPX3 - LD HL,00140h ; Make up an end address based on 320 bytes from start for 80 column mode. -DUMPX3: ADD HL,DE -DUMPX4: EX DE,HL - ; - ; HL = Start - ; DE = End -DUMP: LD A,23 -DUMP0: LD (TMPCNT),A - LD A,(SCRNMODE) ; Configure output according to screen mode, 40/80 chars. - OR A - JR NZ,DUMP1 - LD B,008H ; 40 Char, output 23 lines of 40 char. - LD C,017H - JR DUMP2 -DUMP1: LD B,010h ; 80 Char, output 23 lines of 80 char. - LD C,02Fh -DUMP2: CALL NLPHL -DUMP3: CALL SPHEX - INC HL - PUSH AF - LD A,(DSPXY) - ADD A,C - LD (DSPXY),A - POP AF - CP 020h - JR NC,DUMP4 - LD A,02Eh -DUMP4: CALL ?ADCN - CALL PRNT3 - LD A,(DSPXY) - INC C - SUB C - LD (DSPXY),A - DEC C - DEC C - DEC C - PUSH HL - SBC HL,DE - POP HL - JR NC,DUMP9 -DUMP5: DJNZ DUMP3 - LD A,(TMPCNT) - DEC A - JR NZ,DUMP0 -DUMP6: CALL GETKY ; Pause, X to quit, D to go down a block, U to go up a block. - OR A - JR Z,DUMP6 - CP 'D' - JR NZ,DUMP7 - LD A,8 - JR DUMP0 -DUMP7: CP 'U' - JR NZ,DUMP8 - PUSH DE - LD DE,00100H - OR A - SBC HL,DE - POP DE - LD A,8 - JR DUMP0 -DUMP8: CP 'X' - JR Z,DUMP9 - JR DUMP -DUMP9: LD (DUMPADDR),HL ; Store last address so we can just press D for next page, - CALL NL - RET - - - ; Cmd tool to clear memory. - ; Read cmd line for an init byte, if one not present, use 00H - ; -INITMEMX: CALL _2HEX - JR NC,INITMEMX1 - LD A,000H -INITMEMX1: PUSH AF - LD DE,MSGINITM - LD HL,PRINTMSG - CALL BKSW1to6 - LD HL,1200h - LD BC,0D000h - 1200h - POP DE -CLEAR1: LD A,D - LD (HL),A - INC HL - DEC BC - LD A,B - OR C - JP NZ,CLEAR1 - RET - - - ; Method to get the CMT parameters from the command line. - ; The parameters which should be given are: - ; XXXXYYYYZZZZ - where XXXX = Start Address, YYYY = End Address, ZZZZ = Execution Address. - ; If the start, end and execution address parameters are correct, prompt for a filename which will be written into the CMT header. - ; Output: Reg C = 0 - Success - ; = 1 - Error. -GETCMTPARM: CALL READ4HEX ; Start address - JR C,GETCMT1 - LD (DTADR),HL ; data adress buffer - LD B,H - LD C,L - CALL READ4HEX ; End address - JR C,GETCMT1 - SBC HL,BC - INC HL - LD (SIZE),HL ; byte size buffer - CALL READ4HEX ; Execution address - JR C,GETCMT1 - LD (EXADR),HL ; buffer - CALL NL - LD DE,MSGSAVE ; 'FILENAME? ' - LD HL,PRINTMSG - CALL BKSW2to6 ; Print out the filename. - LD DE,BUFER - CALL GETL - LD HL,BUFER+10 - LD DE,NAME ; name buffer - LD BC,FNSIZE - LDIR ; C = 0 means success. - RET -GETCMT1: LD C,1 ; C = 1 means an error occured. - RET - - - ; Method to read 4 bytes from a buffer pointed to by DE and attempt to convert to a 16bit number. If it fails, print out an error - ; message and return with C set. - ; - ; Input: DE = Address of digits to conver. - ; Output: HL = 16 bit number. - -READ4HEX: CALL HLHEX - JR C,READ4HEXERR - INC DE - INC DE - INC DE - INC DE - OR A ; Clear carry flag. - RET -READ4HEXERR:LD DE,MSGREAD4HEX ; Load up error message, print and exit. -READ4HEXPRE:LD HL,PRINTMSG - CALL BKSW1to6 - SCF - RET - - ; SPACE PRINT AND DISP ACC - ; INPUT:HL=DISP. ADR. -SPHEX: CALL PRNTS ; SPACE PRINT - LD A,(HL) - CALL PRTHX ; DSP OF ACC (ASCII) - LD A,(HL) - RET - - ; NEW LINE AND PRINT HL REG (ASCII) -NLPHL: CALL NL - CALL PRTHL - RET - ;------------------------------------------------------------------------------- - ; END OF MEMORY CMDLINE TOOLS FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;------------------------------------------------------------------------------- - ; START OF PRINTER CMDLINE TOOLS FUNCTIONALITY - ;------------------------------------------------------------------------------- -PTESTX: LD A,(DE) - CP '&' ; plotter test - JR NZ,PTST1X -PTST0X: INC DE - LD A,(DE) - CP 'L' ; 40 in 1 line - JR Z,.LPTX - CP 'S' ; 80 in 1 line - JR Z,..LPTX - CP 'C' ; Pen change - JR Z,PENX - CP 'G' ; Graph mode - JR Z,PLOTX - CP 'T' ; Test - JR Z,PTRNX -; -PTST1X: CALL PMSGX -ST1X2: RET -.LPTX: LD DE,LLPT ; 01-09-09-0B-0D - JR PTST1X -..LPTX: LD DE,SLPT ; 01-09-09-09-0D - JR PTST1X -PTRNX: LD A,004h ; Test pattern - JR LE999 -PLOTX: LD A,002h ; Graph mode -LE999: CALL LPRNTX - JR PTST0X -PENX: LD A,01Dh ; 1 change code (text mode) - JR LE999 -; -; -; 1 char print to $LPT -; -; in: ACC print data -; -; -LPRNTX: LD C,000h ; RDAX test - LD B,A ; print data store - CALL RDAX - LD A,B - OUT (0FFh),A ; data out - LD A,080h ; RDP high - OUT (0FEh),A - LD C,001h ; RDA test - CALL RDAX - XOR A ; RDP low - OUT (0FEh),A - RET -; -; $LPT msg. -; in: DE data low address -; 0D msg. end -; -PMSGX: PUSH DE - PUSH BC - PUSH AF -PMSGX1: LD A,(DE) ; ACC = data - CALL LPRNTX - LD A,(DE) - INC DE - CP 00Dh ; end ? - JR NZ,PMSGX1 - POP AF - POP BC - POP DE - RET - -; -; RDA check -; -; BRKEY in to monitor return -; in: C RDA code -; -RDAX: IN A,(0FEh) - AND 00Dh - CP C - RET Z - CALL BRKEY - JR NZ,RDAX - LD SP,ATRB - JR ST1X2 - - ; 40 CHA. IN 1 LINE CODE (DATA) -LLPT: DB 01H ; TEXT MODE - DB 09H - DB 09H - DB 0BH - DB 0DH - - ; 80 CHA. 1 LINE CODE (DATA) -SLPT: DB 01H ; TEXT MODE - DB 09H - DB 09H - DB 09H - DB 0DH - - ;------------------------------------------------------------------------------- - ; END OF PRINTER CMDLINE TOOLS FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;-------------------------------------- - ; - ; Message table - Refer to bank 6 for - ; all messages. - ; - ;-------------------------------------- - - ALIGN 0EFF8h - ORG 0EFF8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh diff --git a/software/asm/rfs_bank4.asm b/software/asm/rfs_bank4.asm deleted file mode 100644 index 31377ad..0000000 --- a/software/asm/rfs_bank4.asm +++ /dev/null @@ -1,335 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: rfs_bank4.asm -;- Created: July 2019 -;- Author(s): Philip Smart -;- Description: Sharp MZ series Rom Filing System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade. -;- -;- Credits: -;- Copyright: (c) 2018-2023 Philip Smart -;- -;- History: July 2019 - Merged 2 utilities to create this compilation. -; May 2020 - Bank switch changes with release of v2 pcb with coded latch. The coded -; latch adds additional instruction overhead as the control latches share -; the same address space as the Flash RAMS thus the extra hardware to -; only enable the control registers if a fixed number of reads is made -; into the upper 8 bytes which normally wouldnt occur. Caveat - ensure -; that no loop instruction is ever placed into EFF8H - EFFFH. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - - ;=========================================================== - ; - ; USER ROM BANK 4 - CMT Controller utilities. - ; - ;=========================================================== - ORG UROMADDR - - ;-------------------------------- - ; Common code spanning all banks. - ;-------------------------------- - NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -ROMFS4_0: LD A,(BNKCTRLRST) - DJNZ ROMFS4_0 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - NOP - NOP - NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 - LD (BNKSELMROM),A - NOP - NOP - NOP - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - ; - ; No mans land... this should have switched to Bank 0 and at this point there is a jump to 00000H. - JP 00000H ; This is for safety!! - - - ;------------------------------------------------------------------------------------------ - ; Bank switching code, allows a call to code in another bank. - ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. - ;------------------------------------------------------------------------------------------ - ALIGN_NOPS UROMBSTBL - ; -BKSW4to0: PUSH AF - LD A, ROMBANK4 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK0 ; Required bank to call. - JR BKSW4_0 -BKSW4to1: PUSH AF - LD A, ROMBANK4 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK1 ; Required bank to call. - JR BKSW4_0 -BKSW4to2: PUSH AF - LD A, ROMBANK4 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK2 ; Required bank to call. - JR BKSW4_0 -BKSW4to3: PUSH AF - LD A, ROMBANK4 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK3 ; Required bank to call. - JR BKSW4_0 -BKSW4to4: PUSH AF - LD A, ROMBANK4 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK4 ; Required bank to call. - JR BKSW4_0 -BKSW4to5: PUSH AF - LD A, ROMBANK4 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK5 ; Required bank to call. - JR BKSW4_0 -BKSW4to6: PUSH AF - LD A, ROMBANK4 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK6 ; Required bank to call. - JR BKSW4_0 -BKSW4to7: PUSH AF - LD A, ROMBANK4 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK7 ; Required bank to call. - ; -BKSW4_0: PUSH HL ; Place function to call on stack - LD HL, BKSWRET4 ; Place bank switchers return address on stack. - EX (SP),HL - LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. - LD (BNKSELUSER), A ; Repeat the bank switch B times to enable the bank control register and set its value. - JP (HL) ; Jump to required function. -BKSWRET4: POP AF ; Get bank which called us. - LD (BNKSELUSER), A ; Return to that bank. - POP AF - RET - - ;------------------------------------------------------------------------------- - ; START OF CMT CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; CMT Utility to Load a program from tape. - ; - ; Three entry points: - ; LOADTAPE = Load the first program shifting to lo memory if required and execute. - ; LOADTAPENX = Load the first program and return without executing. - ; LOADTAPECP = Load the first program to address 0x1200 and return. - ; -LOADTAPECP: LD A,0FFH - LD (CMTAUTOEXEC),A - JR LOADTAPE2 -LOADTAPENX: LD A,0FFH - JR LOADTAPE1 -LOADTAPE: LD A,000H -LOADTAPE1: LD (CMTAUTOEXEC),A - XOR A -LOADTAPE2: LD (CMTCOPY),A ; Set cmt copy mode, 0xFF if we are copying. - LD A,0FFH ; If called interbank, set a result code in memory to detect success. - LD (RESULT),A - CALL ?RDI - JP C,?ERX2 - LD DE,MSGLOAD ; 'LOADING ' - LD BC,NAME - LD HL,PRINTMSG - CALL BKSW4to6 - XOR A - LD (CMTLOLOAD),A - - LD HL,(DTADR) ; Common code, store load address in case we shift or manipulate loading. - LD (DTADRSTORE),HL - - LD A,(CMTCOPY) ; If were copying we always load at 0x1200. - OR A - JR Z,LOADTAPE3 - LD HL,01200H - LD (DTADR),HL - -LOADTAPE3: LD HL,(DTADR) ; If were loading and the load address is below 0x1200, shift it to 0x1200 to load then move into correct location. - LD A,H - OR L - JR NZ,LOADTAPE4 - LD A,0FFh - LD (CMTLOLOAD),A - LD HL,01200h - LD (DTADR),HL -LOADTAPE4: CALL ?RDD - JP C,?ERX2 - LD HL,(DTADRSTORE) ; Restore the original load address into the CMT header. - LD (DTADR),HL - LD A,(CMTCOPY) - OR A - JR NZ,LOADTAPE6 -LOADTAPE5: LD A,(CMTAUTOEXEC) ; Get back the auto execute flag. - OR A - JR NZ,LOADTAPE6 ; Dont execute.. - LD A,(CMTLOLOAD) - CP 0FFh - JR Z,LOADTAPELM ; Execute at low memory? - LD BC,00100h - LD HL,(EXADR) - JP (HL) -LOADTAPELM: LD A,(MEMSW) ; Perform memory switch, mapping out ROM from $0000 to $C000 - LD HL,01200h ; Shift the program down to RAM at $0000 - LD DE,00000h - LD BC,(SIZE) - LDIR - LD BC,00100h - LD HL,(EXADR) ; Fetch exec address and run. - JP (HL) -LOADTAPE6: LD DE,MSGCMTDATA - PUSH HL ; Load address as parameter 2. - LD HL,(EXADR) - PUSH HL ; Execution address as parameter 1. - LD BC,(SIZE) ; Size as BC parameter. - LD HL,PRINTMSG - CALL BKSW4to6 - POP BC - POP BC ; Waste parameters. - XOR A ; Success. - LD (RESULT),A - RET - - - ; SA1510 Routine to write a tape header. Copied into the RFS and modified to merge better - ; with the RFS interface. - ; -CMTWRI: ;DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D7H - LD E,0CCH - LD HL,IBUFE - LD BC,00080H - CALL CKSUM - CALL MOTOR - JR C,CMTWRI2 - LD A,E - CP 0CCH - JR NZ,CMTWRI1 - PUSH HL - PUSH DE - PUSH BC - LD DE,MSGCMTWRITE - LD BC,NAME - LD HL,PRINTMSG - CALL BKSW4to6 - POP BC - POP DE - POP HL -CMTWRI1: CALL GAP - CALL WTAPE -CMTWRI2: POP HL - POP BC - POP DE - CALL MSTOP - PUSH AF - LD A,(TIMFG) - CP 0F0H - JR NZ,CMTWRI3 - ;EI -CMTWRI3: POP AF - RET - - - ; Method to save an application stored in memory to a cassette in the CMT. The start, size and execution address are either given in BUFER via the - ; command line and the a filename is prompted for and read, or alternatively all the data is passed into the function already set in the CMT header. - ; The tape is then opened and the header + data are written out. - ; -SAVECMT: LD A,0FFH ; Set SDCOPY to indicate this is a copy command and not a command line save. - JR SAVEX1 - ; - ; Normal entry point, the cmdline contains XXXXYYYYZZZZ where XXXX=start, YYYY=size, ZZZZ=exec addr. A filenname is prompted for and read. - ; The data is stored in the CMT header prior to writing out the header and data.. - ; -SAVEX: LD HL,GETCMTPARM ; Get the CMT parameters. - CALL BKSW4to3 - LD A,C - OR A - RET NZ ; Exit if an error occurred. - - XOR A -SAVEX1: LD (SDCOPY),A - LD A,0FFH - LD (RESULT),A ; For interbank calls, pass result via a memory variable. Assume failure unless updated. - LD A,OBJCD ; Set attribute: OBJ - LD (ATRB),A - CALL CMTWRI ; Commence header write. Header doesnt need updating for header write. -?ERX1: JP C,?ERX2 - - LD A,(SDCOPY) - OR A - JR Z,SAVEX2 - LD DE,(DTADR) - LD A,D ; If copying and address is below 1000H, then data is held at 1200H so update header for write. - CP 001H - JR NC,SAVEX2 - LD DE,01200H - LD (DTADR),DE -SAVEX2: CALL ?WRD ; data - JR C,?ERX1 - LD DE,MSGSAVEOK ; 'OK!' - LD HL,PRINTMSG - CALL BKSW4to6 - LD A,0 ; Success. - LD (RESULT),A - RET -?ERX2: CP 002h - JR NZ,?ERX3 - LD (RESULT),A ; Set break key pressed code. - RET Z -?ERX3: LD DE,MSGE1 ; 'CHECK SUM ER.' - LD HL,PRINTMSG - CALL BKSW4to6 - RET - - - ; Method to verify that a tape write occurred free of error. After a write, the tape is read and compared with the memory that created it. - ; -VRFYX: CALL ?VRFY - JP C,?ERX2 - LD DE,MSGOK ; 'OK!' - LD HL,PRINTMSG - CALL BKSW4to6 - RET - - ; Method to toggle the audible key press sound, ie a beep when a key is pressed. - ; -SGX: LD A,(SWRK) - RRA - CCF - RLA - LD (SWRK),A - RET - - ;------------------------------------------------------------------------------- - ; END OF CMT CONTROLLER FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;-------------------------------------- - ; - ; Message table - Refer to bank 6 for - ; all messages. - ; - ;-------------------------------------- - - ALIGN 0EFF8h - ORG 0EFF8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh diff --git a/software/asm/rfs_bank5.asm b/software/asm/rfs_bank5.asm deleted file mode 100644 index 5bda0db..0000000 --- a/software/asm/rfs_bank5.asm +++ /dev/null @@ -1,210 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: rfs_bank5.asm -;- Created: July 2019 -;- Author(s): Philip Smart -;- Description: Sharp MZ series Rom Filing System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade. -;- -;- Credits: -;- Copyright: (c) 2018-2023 Philip Smart -;- -;- History: July 2019 - Merged 2 utilities to create this compilation. -; May 2020 - Bank switch changes with release of v2 pcb with coded latch. The coded -; latch adds additional instruction overhead as the control latches share -; the same address space as the Flash RAMS thus the extra hardware to -; only enable the control registers if a fixed number of reads is made -; into the upper 8 bytes which normally wouldnt occur. Caveat - ensure -; that no loop instruction is ever placed into EFF8H - EFFFH. -; Mar 2021 - Add mapping utilities for Sharp<->ASCII conversion. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - - ;====================================== - ; - ; USER ROM BANK 5 - Utilities - ; - ;====================================== - ORG UROMADDR - - ;-------------------------------- - ; Common code spanning all banks. - ;-------------------------------- - NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -ROMFS5_0: LD A,(BNKCTRLRST) - DJNZ ROMFS5_0 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - NOP - NOP - NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 - LD (BNKSELMROM),A - NOP - NOP - NOP - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - ; - ; No mans land... this should have switched to Bank 0 and at this point there is a jump to 00000H. - JP 00000H ; This is for safety!! - - - ;------------------------------------------------------------------------------------------ - ; Bank switching code, allows a call to code in another bank. - ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. - ;------------------------------------------------------------------------------------------ - ALIGN_NOPS UROMBSTBL - ; -BKSW5to0: PUSH AF - LD A, ROMBANK5 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK0 ; Required bank to call. - JR BKSW5_0 -BKSW5to1: PUSH AF - LD A, ROMBANK5 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK1 ; Required bank to call. - JR BKSW5_0 -BKSW5to2: PUSH AF - LD A, ROMBANK5 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK2 ; Required bank to call. - JR BKSW5_0 -BKSW5to3: PUSH AF - LD A, ROMBANK5 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK3 ; Required bank to call. - JR BKSW5_0 -BKSW5to4: PUSH AF - LD A, ROMBANK5 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK4 ; Required bank to call. - JR BKSW5_0 -BKSW5to5: PUSH AF - LD A, ROMBANK5 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK5 ; Required bank to call. - JR BKSW5_0 -BKSW5to6: PUSH AF - LD A, ROMBANK5 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK6 ; Required bank to call. - JR BKSW5_0 -BKSW5to7: PUSH AF - LD A, ROMBANK5 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK7 ; Required bank to call. - ; -BKSW5_0: PUSH HL ; Place function to call on stack - LD HL, BKSWRET5 ; Place bank switchers return address on stack. - EX (SP),HL - LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. - LD (BNKSELUSER), A ; Repeat the bank switch B times to enable the bank control register and set its value. - JP (HL) ; Jump to required function. -BKSWRET5: POP AF ; Get bank which called us. - LD (BNKSELUSER), A ; Return to that bank. - POP AF - RET - - - ; Method to convert a string with Sharp ASCII codes into standard ASCII codes via map lookup. - ; Inputs: DE = pointer to string for conversion. - ; B = Maximum number of characters to convert if string not terminated. - ; -CNVSTR_SA: PUSH HL - PUSH DE - PUSH BC -CNVSTRSA1: LD A,(DE) ; Get character for conversion. - OR A ; Exit at End of String (NULL, CR) - JR Z,CNVSTRSAEX - CP 00DH - JR Z,CNVSTRSAEX - CP 020H ; No point mapping control characters. - JR C,CNVSTRSA2 - ; - LD HL,SHARPTOASC ; Start of mapping table. - PUSH BC - LD C,A - LD B,0 - ADD HL,BC ; Add in character offset. - POP BC - LD A,(HL) - LD (DE),A ; Map character. -CNVSTRSA2: INC DE - DJNZ CNVSTRSA1 -CNVSTRSAEX: POP BC ; Restore all registers used except AF. - POP DE - POP HL - RET - - ; Method to convert a string with standard ASCII into Sharp ASCII codes via scan lookup in the mapping table. - ; Inputs: DE = pointer to string for conversion. - ; B = Maximum number of characters to convert if string not terminated. -CNVSTR_AS: PUSH HL - PUSH DE - PUSH BC -CNVSTRAS1: LD A,(DE) ; Get character for conversion. - OR A ; Exit at End of String (NULL, CR) - JR Z,CNVSTRSAEX - CP 00DH - JR Z,CNVSTRSAEX - CP 020H ; No point mapping control characters. - JR C,CNVSTRAS5 - - LD HL,SHARPTOASC + 020H - PUSH BC - LD B, 0100H - 020H -CNVSTRAS2: CP (HL) ; Go through table looking for a match. - JR Z,CNVSTRAS3 - INC HL - DJNZ CNVSTRAS2 - JR CNVSTRAS4 ; No match then dont convert. -CNVSTRAS3: LD BC,SHARPTOASC ; On match or expiration of BC subtract table starting point to arrive at index. - OR A - SBC HL,BC - LD A,L ; Index is used as the converted character. -CNVSTRAS4: LD (DE),A - POP BC -CNVSTRAS5: INC DE - DJNZ CNVSTRAS1 - JR CNVSTRSAEX - - ; Mapping table to convert between Sharp ASCII and standard ASCII. - ; Sharp -> ASCII : Index with Sharp value into table to obtain conversion. - ; ASCII -> Sharp : Scan into table looking for value, on match the idx is the conversion. NB 0x20 = 0x20. -SHARPTOASC: DB 000H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 000H, 020H, 020H ; 0x0F - DB 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H ; 0x1F - DB 020H, 021H, 022H, 023H, 024H, 025H, 026H, 027H, 028H, 029H, 02AH, 02BH, 02CH, 02DH, 02EH, 02FH ; 0x2F - DB 030H, 031H, 032H, 033H, 034H, 035H, 036H, 037H, 038H, 039H, 03AH, 03BH, 03CH, 03DH, 03EH, 03FH ; 0x3F - DB 040H, 041H, 042H, 043H, 044H, 045H, 046H, 047H, 048H, 049H, 04AH, 04BH, 04CH, 04DH, 04EH, 04FH ; 0x4F - DB 050H, 051H, 052H, 053H, 054H, 055H, 056H, 057H, 058H, 059H, 05AH, 05BH, 05CH, 05DH, 05EH, 05FH ; 0x5F - DB 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H ; 0x6F - DB 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H ; 0x7F - DB 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H ; 0x8F - DB 020H, 020H, 065H, 020H, 020H, 020H, 074H, 067H, 068H, 020H, 062H, 078H, 064H, 072H, 070H, 063H ; 0x9F - DB 071H, 061H, 07AH, 077H, 073H, 075H, 069H, 020H, 04FH, 06BH, 066H, 076H, 020H, 075H, 042H, 06AH ; 0xAF - DB 06EH, 020H, 055H, 06DH, 020H, 020H, 020H, 06FH, 06CH, 041H, 06FH, 061H, 020H, 079H, 020H, 020H ; 0xBF - DB 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H ; 0xCF - DB 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H ; 0xDF - DB 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H ; 0xEF - DB 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H, 020H ; 0xFF - - ALIGN 0EFF8h - ORG 0EFF8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh diff --git a/software/asm/rfs_bank6.asm b/software/asm/rfs_bank6.asm deleted file mode 100644 index 6a36a8b..0000000 --- a/software/asm/rfs_bank6.asm +++ /dev/null @@ -1,497 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: rfs_bank6.asm -;- Created: July 2019 -;- Author(s): Philip Smart -;- Description: Sharp MZ series Rom Filing System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade. -;- -;- Credits: -;- Copyright: (c) 2018-2023 Philip Smart -;- -;- History: July 2019 - Merged 2 utilities to create this compilation. -; May 2020 - Bank switch changes with release of v2 pcb with coded latch. The coded -; latch adds additional instruction overhead as the control latches share -; the same address space as the Flash RAMS thus the extra hardware to -; only enable the control registers if a fixed number of reads is made -; into the upper 8 bytes which normally wouldnt occur. Caveat - ensure -; that no loop instruction is ever placed into EFF8H - EFFFH. -; July 2020 - Updated for the v2.1 hardware. RFS can run with a tranZPUter board with -; or without the K64 I/O processor. RFS wont use the K64 processor all -; operations are done by the Z80 under RFS. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - - ;====================================== - ; - ; USER ROM BANK 6 - ; - ;====================================== - ORG UROMADDR - - ;-------------------------------- - ; Common code spanning all banks. - ;-------------------------------- - NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -ROMFS6_0: LD A,(BNKCTRLRST) - DJNZ ROMFS6_0 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - NOP - NOP - NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 - LD (BNKSELMROM),A - NOP - NOP - NOP - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - ; - ; No mans land... this should have switched to Bank 0 and at this point there is a jump to 00000H. - JP 00000H ; This is for safety!! - - - ;------------------------------------------------------------------------------------------ - ; Bank switching code, allows a call to code in another bank. - ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. - ;------------------------------------------------------------------------------------------ - ALIGN_NOPS UROMBSTBL - ; -BKSW6to0: PUSH AF - LD A, ROMBANK6 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK0 ; Required bank to call. - JR BKSW6_0 -BKSW6to1: PUSH AF - LD A, ROMBANK6 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK1 ; Required bank to call. - JR BKSW6_0 -BKSW6to2: PUSH AF - LD A, ROMBANK6 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK2 ; Required bank to call. - JR BKSW6_0 -BKSW6to3: PUSH AF - LD A, ROMBANK6 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK3 ; Required bank to call. - JR BKSW6_0 -BKSW6to4: PUSH AF - LD A, ROMBANK6 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK4 ; Required bank to call. - JR BKSW6_0 -BKSW6to5: PUSH AF - LD A, ROMBANK6 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK5 ; Required bank to call. - JR BKSW6_0 -BKSW6to6: PUSH AF - LD A, ROMBANK6 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK6 ; Required bank to call. - JR BKSW6_0 -BKSW6to7: PUSH AF - LD A, ROMBANK6 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK7 ; Required bank to call. - ; -BKSW6_0: PUSH HL ; Place function to call on stack - LD HL, BKSWRET6 ; Place bank switchers return address on stack. - EX (SP),HL - LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. - LD (BNKSELUSER), A ; Repeat the bank switch B times to enable the bank control register and set its value. - JP (HL) ; Jump to required function. -BKSWRET6: POP AF ; Get bank which called us. - LD (BNKSELUSER), A ; Return to that bank. - POP AF - RET - - ;------------------------------------------------------------------------------- - ; START OF PRINT ROUTINE METHODS - ;------------------------------------------------------------------------------- - - ; Method to print out a true ASCII character, not the Sharp values. This is done using the mapping table ATBL for the - ; range 0..127, 128.. call the original Sharp routine. - ; Input: A = Ascii character. -PRINTASCII: PUSH HL - PUSH BC - CP 080H ; Anything above 080H isnt ascii so call original routine. - JR NC,PRINTASCII1 - CP 00DH ; Carriage Return? Dont map just execute via original Sharp call. - JR Z,PRINTASCII1 - LD HL,ATBL - LD C,A - LD B,0 - ADD HL,BC - LD A,(HL) - CALL ?DSP -PRINTASCII0:POP BC - POP HL - RET -PRINTASCII1:CALL PRNT - JR PRINTASCII0 - - ; Method to print out a string residing in this bank. - ; - ; As string messages take up space and banks are limited, it makes sense to locate all strings in one - ; bank and print them out from here, hence this method. - ; - ; Also, as strings often require embedded values to be printed (aka printf), a basic mechanism for printing out stack - ; parameters is provided. A PUSH before calling this method followed by an embedded marker (ie. 0xFF) will see the stack - ; value printed in hex at the point in the string where the marker appears. - ; - ; Input: DE = Address, in this bank or any other location EXCEPT another bank. - ; BC = Value to print with marker 0xFB if needed. - ; Upto 4 stack values accessed by markers 0xFF, 0xFE, 0xFD, 0xFC -PRINTMSG: LD A,(DE) - CP 000H ; End of string? - RET Z - CP 0FFH ; Marker to print out first stack parameter. - JR Z,PRINTMSG3 - CP 0FEH ; Marker to print out second stack parameter. - JR Z,PRINTMSG6 - CP 0FDH ; Marker to print out third stack parameter. - JR Z,PRINTMSG7 - CP 0FCH ; Marker to print out fourth stack parameter. - JR Z,PRINTMSG8 - CP 0FBH ; Marker to print out BC. - JR Z,PRINTMSG9 - CP 0FAH ; Marker to print out a filename with filename address stored in BC. - JR Z,PRINTMSG10 - CP 0F9H ; Marker to print out C as a character. - JR NZ,PRINTMSG1 - LD A,C -PRINTMSG1: CALL PRINTASCII -PRINTMSG2: INC DE - JR PRINTMSG -PRINTMSG3: LD HL,8+0 ; Get first stack parameter, there are 2 pushes on the stack plus return address before the parameters. -PRINTMSG4: ADD HL,SP - LD A,(HL) - INC HL - LD H,(HL) - LD L,A -PRINTMSG5: CALL PRTHL - JR PRINTMSG2 -PRINTMSG6: LD HL,8+2 - JR PRINTMSG4 -PRINTMSG7: LD HL,8+4 - JR PRINTMSG4 -PRINTMSG8: LD HL,8+6 - JR PRINTMSG4 -PRINTMSG9: PUSH BC ; Print out contents of BC as 4 digit hex. - POP HL - JR PRINTMSG5 -PRINTMSG10: PUSH DE ; Print out a filename with pointer stored in BC. - PUSH BC - POP DE - CALL PRTFN - POP DE - JR PRINTMSG2 - - - ; Method to print out the filename within an MZF header or SD Card header. - ; The name may not be terminated as the full 17 chars are used, so this needs - ; to be checked. Also, the filename uses Sharp Ascii so call the original Sharp - ; print routine. - ; - ; Input: DE = Address of filename. - ; -PRTFN: PUSH BC - LD B,FNSIZE ; Maximum size of filename. -PRTMSG: LD A,(DE) - INC DE - CP 000H ; If there is a valid terminator, exit. - JR Z,PRTMSGE - CP 00DH - JR Z,PRTMSGE - CALL PRNT - DJNZ PRTMSG ; Else print until 17 chars have been processed. - CALL NL -PRTMSGE: POP BC - RET - ;------------------------------------------------------------------------------- - ; END OF PRINT ROUTINE METHODS - ;------------------------------------------------------------------------------- - - - - ;------------------------------------------------------------------------------- - ; START OF HELP SCREEN FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; Simple help screen to display commands. -HELP: CALL NL - LD DE, HELPSCR - CALL PRTSTR - RET - - ; A modified print string routine with full screen pause to print out the help screen text. The routine prints out true ascii - ; as opposed to Sharp modified ascii. - ; A string is NULL terminated. -PRTSTR: PUSH AF - PUSH BC - PUSH DE - LD A,0 - LD (TMPLINECNT),A -PRTSTR1: LD A,(DE) - CP 000H ; NULL terminates the string. - JR Z,PRTSTRE - CP 00DH ; As does CR. - JR Z,PRTSTR3 -PRTSTR2: CALL PRINTASCII - INC DE - JR PRTSTR1 -PRTSTR3: PUSH AF - LD A,(TMPLINECNT) - CP 24 - JR Z,PRTSTR5 - INC A -PRTSTR4: LD (TMPLINECNT),A - POP AF - JR PRTSTR2 -PRTSTR5: CALL GETKY - CP ' ' - JR NZ,PRTSTR5 - XOR A - JR PRTSTR4 -PRTSTRE: POP DE - POP BC - POP AF - RET - - ; Help text. Use of lower case, due to Sharp's non standard character set, is not easy, you have to manually code each byte - ; hence using upper case. - ; 1 40 -HELPSCR: DB "0..9 - select RFS Drive.", 00DH - DB "40 - 40 col mode.", 00DH - DB "80 - 80 col mode.", 00DH - ;DB "700 - Select MZ-700 Mode.", 00DH - ;DB "7008 - Select MZ-700 80 col Mode.", 00DH - DB "B - toggle keyboard bell.", 00DH - DB "BASIC - Load BASIC SA-5510.", 00DH - DB "C - clear memory $1200-$D000.", 00DH - DB "CPXXXXYYYYZZZZ - copy memory", 00DH - DB " XXXX=src,YYYY=dst,ZZZZ=size", 00DH - DB "CPM - Load CPM.", 00DH - DB "DXXXX[YYYY] - dump mem XXXX to YYYY.", 00DH - DB "EC[FN]- erase file, FN=No, or Filename", 00DH - DB "F[X] - boot fd drive X.", 00DH - DB "f - boot fd original rom.", 00DH - DB "H - this help screen.", 00DH - DB "IR/IC - rfs dir listing rom/sd card.", 00DH - DB "JXXXX - jump to location XXXX.", 00DH - DB "LT[FN]- load tape, FN=Filename", 00DH - DB "LR[FN]- load rom, FN=No. or Filename", 00DH - DB "LC[FN]- load sdcard, FN=No. or Filename", 00DH - DB " - add NX for no exec, ie.LRNX.", 00DH - DB "MXXXX - edit memory starting at XXXX.", 00DH - DB "P - test printer.", 00DH - DB "R - test dram memory.", 00DH - DB "SD2T - copy sd card to tape.", 00DH - DB "ST[XXXXYYYYZZZZ] - save mem to tape.", 00DH - DB "SC[XXXXYYYYZZZZ] - save mem to card.", 00DH - DB " XXXX=start,YYYY=end,ZZZZ=exec", 00DH - DB "T - test timer.", 00DH - DB "T2SD - copy tape to sd card.", 00DH - DB "V - verify tape save.", 00DH - DB 000H - - ;------------------------------------------------------------------------------- - ; END OF HELP SCREEN FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; TRUE ASCII TO DISPLAY CODE TABLE - ; -ATBL: DB 0CCH ; NUL '\0' (null character) - DB 0E0H ; SOH (start of heading) - DB 0F2H ; STX (start of text) - DB 0F3H ; ETX (end of text) - DB 0CEH ; EOT (end of transmission) - DB 0CFH ; ENQ (enquiry) - DB 0F6H ; ACK (acknowledge) - DB 0F7H ; BEL '\a' (bell) - DB 0F8H ; BS '\b' (backspace) - DB 0F9H ; HT '\t' (horizontal tab) - DB 0FAH ; LF '\n' (new line) - DB 0FBH ; VT '\v' (vertical tab) - DB 0FCH ; FF '\f' (form feed) - DB 0FDH ; CR '\r' (carriage ret) - DB 0FEH ; SO (shift out) - DB 0FFH ; SI (shift in) - DB 0E1H ; DLE (data link escape) - DB 0C1H ; DC1 (device control 1) - DB 0C2H ; DC2 (device control 2) - DB 0C3H ; DC3 (device control 3) - DB 0C4H ; DC4 (device control 4) - DB 0C5H ; NAK (negative ack.) - DB 0C6H ; SYN (synchronous idle) - DB 0E2H ; ETB (end of trans. blk) - DB 0E3H ; CAN (cancel) - DB 0E4H ; EM (end of medium) - DB 0E5H ; SUB (substitute) - DB 0E6H ; ESC (escape) - DB 0EBH ; FS (file separator) - DB 0EEH ; GS (group separator) - DB 0EFH ; RS (record separator) - DB 0F4H ; US (unit separator) - DB 000H ; SPACE - DB 061H ; ! - DB 062H ; " - DB 063H ; # - DB 064H ; $ - DB 065H ; % - DB 066H ; & - DB 067H ; ' - DB 068H ; ( - DB 069H ; ) - DB 06BH ; * - DB 06AH ; + - DB 02FH ; , - DB 02AH ; - - DB 02EH ; . - DB 02DH ; / - DB 020H ; 0 - DB 021H ; 1 - DB 022H ; 2 - DB 023H ; 3 - DB 024H ; 4 - DB 025H ; 5 - DB 026H ; 6 - DB 027H ; 7 - DB 028H ; 8 - DB 029H ; 9 - DB 04FH ; : - DB 02CH ; ; - DB 051H ; < - DB 02BH ; = - DB 057H ; > - DB 049H ; ? - DB 055H ; @ - DB 001H ; A - DB 002H ; B - DB 003H ; C - DB 004H ; D - DB 005H ; E - DB 006H ; F - DB 007H ; G - DB 008H ; H - DB 009H ; I - DB 00AH ; J - DB 00BH ; K - DB 00CH ; L - DB 00DH ; M - DB 00EH ; N - DB 00FH ; O - DB 010H ; P - DB 011H ; Q - DB 012H ; R - DB 013H ; S - DB 014H ; T - DB 015H ; U - DB 016H ; V - DB 017H ; W - DB 018H ; X - DB 019H ; Y - DB 01AH ; Z - DB 052H ; [ - DB 059H ; \ '\\' - DB 054H ; ] - DB 0BEH ; ^ - DB 03CH ; _ - DB 0C7H ; ` - DB 081H ; a - DB 082H ; b - DB 083H ; c - DB 084H ; d - DB 085H ; e - DB 086H ; f - DB 087H ; g - DB 088H ; h - DB 089H ; i - DB 08AH ; j - DB 08BH ; k - DB 08CH ; l - DB 08DH ; m - DB 08EH ; n - DB 08FH ; o - DB 090H ; p - DB 091H ; q - DB 092H ; r - DB 093H ; s - DB 094H ; t - DB 095H ; u - DB 096H ; v - DB 097H ; w - DB 098H ; x - DB 099H ; y - DB 09AH ; z - DB 0BCH ; { - DB 080H ; | - DB 040H ; } - DB 0A5H ; ~ - DB 0C0H ; DEL - - ;-------------------------------------- - ; - ; Message table - ; - ;-------------------------------------- -MSGSONTZ: DB "+ TZ" ; Version 2.x with version 2.1+ of tranZPUter board installed. -MSGSON: DB "+ RFS ", 0ABh, "2.1a **", 00DH, 000H ; Version 2.x-> as we are now using the v2.x PCB with 4 devices on-board -MSGNOTFND: DB "Not Found", 00DH, 000H -MSGRDIRLST: DB "ROM Directory:", 00DH, 000H -MSGTRM: DB 00DH, 000H -MSGBADCMD: DB "???", 00DH, 000H -MSGSDINITER:DB "SD Card Error ", 0F9H, 00DH, 000H -MSGCDIRLST: DB "SD Card Directory ",0F9H,":", 00DH, 000H -MSGSDRERR: DB "Read error, Sec:",0FBH, 000H -MSGSDWERR: DB "Write error, Sec:",0FBH, 000H -MSGSVFAIL: DB "Error, save failed.", 00DH, 000H -MSGERAFAIL: DB "Dir update failed.", 00DH, 000H -MSGSVDIRENT:DB "Saving into dir entry:",0FBH, 00DH, 000H -MSGERASEDIR:DB "Deleted dir entry:",0FBH, 000H -MSGCMTDATA: DB "Load:",0FEH,",Exec:",0FFH, ",Size:",0FBH, 00DH, 000H -MSGNOTBIN: DB "Not binary", 00DH, 000H -MSGLOAD: DB 00DH, "Loading ",'"',0FAH,'"', 00DH, 000H -MSGSAVE: DB 00DH, "Filename: ", 000H -MSGDIRFULL: DB "Directory full", 00DH, 000H -MSGE1: DB 00DH, "Check sum error!", 00DH, 000H ; Check sum error. -MSGCMTWRITE:DB 00DH, "Writing ", '"',0FAH,'"', 00DH, 000H -MSGOK: DB 00DH, "OK!", 00DH, 000H -MSGSAVEOK: DB "Tape image saved.", 00DH, 000H -MSGBOOTDRV: DB 00DH, "Floppy boot drive ?", 000H -MSGLOADERR: DB 00DH, "Disk loading error", 00DH, 000H -MSGIPLLOAD: DB 00DH, "Disk loading ", 000H -MSGDSKNOTMST:DB 00DH, "Not a boot disk", 00Dh, 000H -MSGINITM: DB "Init memory", 00DH, 000H -MSGREAD4HEX:DB "Bad hex number", 00DH, 000H -MSGT2SDERR: DB "Copy from Tape to SD Failed", 00DH, 000H -MSGSD2TERR: DB "Copy from SD to Tape Failed", 00DH, 000H -MSGT2SDOK: DB "Success, Tape to SD done.", 00DH, 000H -MSGSD2TOK: DB "Success, SD to Tape done.", 00DH, 000H -MSGNOTZINST:DB "No tranZPUter >=v2 card installed.", 00DH, 000H -MSGNOCMTDIR:DB "CMT has no directory.", 00DH, 000H -MSGINVDRV: DB "Invalid drive, SD=0..9 or C=CMT", 00DH, 000H -MSGNOVERIFY:DB "No Verify for SD!", 00DH, 000H - - ALIGN 0EFF8h - ORG 0EFF8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh diff --git a/software/asm/rfs_bank7.asm b/software/asm/rfs_bank7.asm deleted file mode 100644 index 5f66f24..0000000 --- a/software/asm/rfs_bank7.asm +++ /dev/null @@ -1,496 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: rfs_bank4.asm -;- Created: July 2019 -;- Author(s): Philip Smart -;- Description: Sharp MZ series Rom Filing System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade. -;- -;- Credits: -;- Copyright: (c) 2018-2023 Philip Smart -;- -;- History: July 2019 - Merged 2 utilities to create this compilation. -; May 2020 - Bank switch changes with release of v2 pcb with coded latch. The coded -; latch adds additional instruction overhead as the control latches share -; the same address space as the Flash RAMS thus the extra hardware to -; only enable the control registers if a fixed number of reads is made -; into the upper 8 bytes which normally wouldnt occur. Caveat - ensure -; that no loop instruction is ever placed into EFF8H - EFFFH. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - - ;=========================================================== - ; - ; USER ROM BANK 7 - Memory and timer test utilities. - ; - ;=========================================================== - ORG UROMADDR - - ;-------------------------------- - ; Common code spanning all banks. - ;-------------------------------- - NOP - LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -ROMFS7_0: LD A,(BNKCTRLRST) - DJNZ ROMFS7_0 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - NOP - NOP - NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 - LD (BNKSELMROM),A - NOP - NOP - NOP - LD (BNKSELUSER),A ; and start up - ie. SA1510 Monitor - this occurs as User Bank 0 is enabled and the jmp to 0 is coded in it. - ; - ; No mans land... this should have switched to Bank 0 and at this point there is a jump to 00000H. - JP 00000H ; This is for safety!! - - - ;------------------------------------------------------------------------------------------ - ; Bank switching code, allows a call to code in another bank. - ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. - ;------------------------------------------------------------------------------------------ - ALIGN_NOPS UROMBSTBL - ; -BKSW7to0: PUSH AF - LD A, ROMBANK7 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK0 ; Required bank to call. - JR BKSW7_0 -BKSW7to1: PUSH AF - LD A, ROMBANK7 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK1 ; Required bank to call. - JR BKSW7_0 -BKSW7to2: PUSH AF - LD A, ROMBANK7 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK2 ; Required bank to call. - JR BKSW7_0 -BKSW7to3: PUSH AF - LD A, ROMBANK7 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK3 ; Required bank to call. - JR BKSW7_0 -BKSW7to4: PUSH AF - LD A, ROMBANK7 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK4 ; Required bank to call. - JR BKSW7_0 -BKSW7to5: PUSH AF - LD A, ROMBANK7 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK5 ; Required bank to call. - JR BKSW7_0 -BKSW7to6: PUSH AF - LD A, ROMBANK7 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK6 ; Required bank to call. - JR BKSW7_0 -BKSW7to7: PUSH AF - LD A, ROMBANK7 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK7 ; Required bank to call. - ; -BKSW7_0: PUSH HL ; Place function to call on stack - LD HL, BKSWRET7 ; Place bank switchers return address on stack. - EX (SP),HL - LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. - LD (BNKSELUSER), A ; Repeat the bank switch B times to enable the bank control register and set its value. - JP (HL) ; Jump to required function. -BKSWRET7: POP AF ; Get bank which called us. - LD (BNKSELUSER), A ; Return to that bank. - POP AF - RET - - ;------------------------------------------------------------------------------- - ; START OF MEMORY TEST FUNCTIONALITY - ;------------------------------------------------------------------------------- - -MEMTEST: LD B,240 ; Number of loops -LOOP: LD HL,MEMSTART ; Start of checked memory, - LD D,0CFh ; End memory check CF00 -LOOP1: LD A,000h - CP L - JR NZ,LOOP1b - CALL PRTHL ; Print HL as 4digit hex. - LD A,0C4h ; Move cursor left. - LD E,004h ; 4 times. -LOOP1a: CALL DPCT - DEC E - JR NZ,LOOP1a -LOOP1b: INC HL - LD A,H - CP D ; Have we reached end of memory. - JR Z,LOOP3 ; Yes, exit. - LD A,(HL) ; Read memory location under test, ie. 0. - CPL ; Subtract, ie. FF - A, ie FF - 0 = FF. - LD (HL),A ; Write it back, ie. FF. - SUB (HL) ; Subtract written memory value from A, ie. should be 0. - JR NZ,LOOP2 ; Not zero, we have an error. - LD A,(HL) ; Reread memory location, ie. FF - CPL ; Subtract FF - FF - LD (HL),A ; Write 0 - SUB (HL) ; Subtract 0 - JR Z,LOOP1 ; Loop if the same, ie. 0 -LOOP2: LD A,16h - CALL PRNT ; Print A - CALL PRTHX ; Print HL as 4 digit hex. - CALL PRNTS ; Print space. - XOR A - LD (HL),A - LD A,(HL) ; Get into A the failing bits. - CALL PRTHX ; Print A as 2 digit hex. - CALL PRNTS ; Print space. - LD A,0FFh ; Repeat but first load FF into memory - LD (HL),A - LD A,(HL) - CALL PRTHX ; Print A as 2 digit hex. - NOP - JR LOOP4 - -LOOP3: CALL PRTHL - LD DE,OKCHECK - CALL MSG ; Print check message in DE - LD A,B ; Print loop count. - CALL PRTHX - LD DE,OKMSG - CALL MSG ; Print ok message in DE - CALL NL - DEC B - JR NZ,LOOP - LD DE,DONEMSG - CALL MSG ; Print check message in DE - JP ST1X - -LOOP4: LD B,09h - CALL PRNTS ; Print space. - XOR A ; Zero A - SCF ; Set Carry -LOOP5: PUSH AF ; Store A and Flags - LD (HL),A ; Store 0 to bad location. - LD A,(HL) ; Read back - CALL PRTHX ; Print A as 2 digit hex. - CALL PRNTS ; Print space - POP AF ; Get back A (ie. 0 + C) - RLA ; Rotate left A. Bit LSB becomes Carry (ie. 1 first instance), Carry becomes MSB - DJNZ LOOP5 ; Loop if not zero, ie. print out all bit locations written and read to memory to locate bad bit. - XOR A ; Zero A, clears flags. - LD A,80h - LD B,08h -LOOP6: PUSH AF ; Repeat above but AND memory location with original A (ie. 80) - LD C,A ; Basically walk through all the bits to find which one is stuck. - LD (HL),A - LD A,(HL) - AND C - NOP - JR Z,LOOP8 ; If zero then print out the bit number - NOP - NOP - LD A,C - CPL - LD (HL),A - LD A,(HL) - AND C - JR NZ,LOOP8 ; As above, if the compliment doesnt yield zero, print out the bit number. -LOOP7: POP AF - RRCA - NOP - DJNZ LOOP6 - JP ST1X - -LOOP8: CALL LETNL ; New line. - LD DE,BITMSG ; BIT message - CALL MSG ; Print message in DE - LD A,B - DEC A - CALL PRTHX ; Print A as 2 digit hex, ie. BIT number. - CALL LETNL ; New line - LD DE,BANKMSG ; BANK message - CALL MSG ; Print message in DE - LD A,H - CP 50h ; 'P' - JR NC,LOOP9 ; Work out bank number, 1, 2 or 3. - LD A,01h - JR LOOP11 - -LOOP9: CP 90h - JR NC,LOOP10 - LD A,02h - JR LOOP11 - -LOOP10: LD A,03h -LOOP11: CALL PRTHX ; Print A as 2 digit hex, ie. BANK number. - JR LOOP7 - -DLY1S: PUSH AF - PUSH BC - LD C,10 -L0324: CALL DLY12 - DEC C - JR NZ,L0324 - POP BC - POP AF - RET - - ;------------------------------------------------------------------------------- - ; END OF MEMORY TEST FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;------------------------------------------------------------------------------- - ; START OF TIMER TEST FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ; Test the 8253 Timer, configure it as per the monitor and display the read back values. -TIMERTST: CALL NL - LD DE,MSG_TIMERTST - CALL MSG - CALL NL - LD DE,MSG_TIMERVAL - CALL MSG - LD A,01h - LD DE,8000h - CALL TIMERTST1 -NDE: JP NDE - JP ST1X -TIMERTST1: ;DI - PUSH BC - PUSH DE - PUSH HL - LD (AMPM),A - LD A,0F0H - LD (TIMFG),A -ABCD: LD HL,0A8C0H - XOR A - SBC HL,DE - PUSH HL - INC HL - EX DE,HL - - LD HL,CONTF ; Control Register - LD (HL),0B0H ; 10110000 Control Counter 2 10, Write 2 bytes 11, 000 Interrupt on Terminal Count, 0 16 bit binary - LD (HL),074H ; 01110100 Control Counter 1 01, Write 2 bytes 11, 010 Rate Generator, 0 16 bit binary - LD (HL),030H ; 00110100 Control Counter 1 01, Write 2 bytes 11, 010 interrupt on Terminal Count, 0 16 bit binary - - LD HL,CONT2 ; Counter 2 - LD (HL),E - LD (HL),D - - LD HL,CONT1 ; Counter 1 - LD (HL),00AH - LD (HL),000H - - LD HL,CONT0 ; Counter 0 - LD (HL),00CH - LD (HL),0C0H - -; LD HL,CONT2 ; Counter 2 -; LD C,(HL) -; LD A,(HL) -; CP D -; JP NZ,L0323H -; LD A,C -; CP E -; JP Z,CDEF - ; - -L0323H: PUSH AF - PUSH BC - PUSH DE - PUSH HL - ; - LD HL,CONTF ; Control Register - LD (HL),080H - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - ;CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),040H - LD HL,CONT1 ; Counter 1 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - ;CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),000H - LD HL,CONT0 ; Counter 0 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - ;CALL DLY1S - ; - LD A,0C4h ; Move cursor left. - LD E,0Eh ; 4 times. -L0330: CALL DPCT - DEC E - JR NZ,L0330 - ; -; LD C,20 -;L0324: CALL DLY12 -; DEC C -; JR NZ,L0324 - ; - POP HL - POP DE - POP BC - POP AF - ; - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CP D - JP NZ,L0323H - LD A,C - CP E - JP NZ,L0323H - ; - ; - PUSH AF - PUSH BC - PUSH DE - PUSH HL - CALL NL - CALL NL - CALL NL - LD DE,MSG_TIMERVAL2 - CALL MSG - POP HL - POP DE - POP BC - POP AF - - ; -CDEF: POP DE - LD HL,CONT1 - LD (HL),00CH - LD (HL),07BH - INC HL - -L0336H: PUSH AF - PUSH BC - PUSH DE - PUSH HL - ; - LD HL,CONTF ; Control Register - LD (HL),080H - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),040H - LD HL,CONT1 ; Counter 1 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),000H - LD HL,CONT0 ; Counter 0 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL DLY1S - ; - LD A,0C4h ; Move cursor left. - LD E,0Eh ; 4 times. -L0340: CALL DPCT - DEC E - JR NZ,L0340 - ; - POP HL - POP DE - POP BC - POP AF - - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CP D - JR NZ,L0336H - LD A,C - CP E - JR NZ,L0336H - CALL NL - LD DE,MSG_TIMERVAL3 - CALL MSG - POP HL - POP DE - POP BC - ;EI - RET - ;------------------------------------------------------------------------------- - ; END OF TIMER TEST FUNCTIONALITY - ;------------------------------------------------------------------------------- - - ;-------------------------------------- - ; - ; Message table - ; - ;-------------------------------------- -OKCHECK: DB ", CHECK: ", 0Dh -OKMSG: DB " OK.", 0Dh -DONEMSG: DB 11h - DB "RAM TEST COMPLETE.", 0Dh - -BITMSG: DB " BIT: ", 0Dh -BANKMSG: DB " BANK: ", 0Dh -MSG_TIMERTST: - DB "8253 TIMER TEST", 0Dh, 00h -MSG_TIMERVAL: - DB "READ VALUE 1: ", 0Dh, 00h -MSG_TIMERVAL2: - DB "READ VALUE 2: ", 0Dh, 00h -MSG_TIMERVAL3: - DB "READ DONE.", 0Dh, 00h - - ALIGN 0EFF8h - ORG 0EFF8h - DB 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh diff --git a/software/asm/rfs_mrom.asm b/software/asm/rfs_mrom.asm deleted file mode 100644 index c234b2a..0000000 --- a/software/asm/rfs_mrom.asm +++ /dev/null @@ -1,744 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: rfs_mrom.asm -;- Created: September 2019 -;- Author(s): Philip Smart -;- Description: Sharp MZ series Rom Filing System. -;- This assembly language program is written to utilise the banked flashroms added with -;- the MZ-80A RFS hardware upgrade. -;- The purpose of this program is to provide helper utilities to the RFS in order that -;- the RFS can read the User Banks and extract required programs. -;- -;- Credits: -;- Copyright: (c) 2018-2023 Philip Smart -;- -;- History: Sep 2019 - Initial version. -; May 2020 - Bank switch changes with release of v2 pcb with coded latch. The coded -; latch adds additional instruction overhead as the control latches share -; the same address space as the Flash RAMS thus the extra hardware to -; only enable the control registers if a fixed number of reads is made -; into the upper 8 bytes which normally wouldnt occur. Caveat - ensure -; that no loop instruction is ever placed into EFF8H - EFFFH. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - - ; MONITOR WORK AREA - ; (MZ-80A) - -STACK: EQU 010F0H - - ORG STACK -SPV: -IBUFE: ; TAPE BUFFER (128 BYTES) -ATRB: DS virtual 1 ; ATTRIBUTE -NAME: DS virtual FNSIZE ; FILE NAME -SIZE: DS virtual 2 ; BYTESIZE -DTADR: DS virtual 2 ; DATA ADDRESS -EXADR: DS virtual 2 ; EXECUTION ADDRESS -COMNT: DS virtual 92 ; COMMENT -SWPW: DS virtual 10 ; SWEEP WORK -KDATW: DS virtual 2 ; KEY WORK -KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) -DSPXY: DS virtual 2 ; DISPLAY COORDINATES -MANG: DS virtual 6 ; COLUMN MANAGEMENT -MANGE: DS virtual 1 ; COLUMN MANAGEMENT END -PBIAS: DS virtual 1 ; PAGE BIAS -ROLTOP: DS virtual 1 ; ROLL TOP BIAS -MGPNT: DS virtual 1 ; COLUMN MANAG. POINTER -PAGETP: DS virtual 2 ; PAGE TOP -ROLEND: DS virtual 1 ; ROLL END - DS virtual 14 ; BIAS -FLASH: DS virtual 1 ; FLASHING DATA -SFTLK: DS virtual 1 ; SHIFT LOCK -REVFLG: DS virtual 1 ; REVERSE FLAG -SPAGE: DS virtual 1 ; PAGE CHANGE -FLSDT: DS virtual 1 ; CURSOR DATA -STRGF: DS virtual 1 ; STRING FLAG -DPRNT: DS virtual 1 ; TAB COUNTER -TMCNT: DS virtual 2 ; TAPE MARK COUNTER -SUMDT: DS virtual 2 ; CHECK SUM DATA -CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA -AMPM: DS virtual 1 ; AMPM DATA -TIMFG: DS virtual 1 ; TIME FLAG -SWRK: DS virtual 1 ; KEY SOUND FLAG -TEMPW: DS virtual 1 ; TEMPO WORK -ONTYO: DS virtual 1 ; ONTYO WORK -OCTV: DS virtual 1 ; OCTAVE WORK -RATIO: DS virtual 2 ; ONPU RATIO -BUFER: DS virtual 81 ; GET LINE BUFFER - -; Starting 1000H - Generally unused bytes not cleared by the monitor. -ROMBK1: EQU 01016H ; CURRENT MROM BANK -ROMBK2: EQU 01017H ; CURRENT USERROM BANK -WRKROMBK1: EQU 01018H ; WORKING MROM BANK -WRKROMBK2: EQU 01019H ; WORKING USERROM BANK -ROMCTL: EQU 0101AH ; Current Bank control register setting. -SCRNMODE: EQU 0101BH ; Mode of screen, 0 = 40 char, 1 = 80 char. -TMPADR: EQU 0101CH ; TEMPORARY ADDRESS STORAGE -TMPSIZE: EQU 0101EH ; TEMPORARY SIZE -TMPCNT: EQU 01020H ; TEMPORARY COUNTER -TMPLINECNT: EQU 01022H ; Temporary counter for displayed lines. -TMPSTACKP: EQU 01024H ; Temporary stack pointer save. - - ; EQU TABLE I/O REPORT - -;----------------------------------------------- -; Memory mapped ports in hardware. -;----------------------------------------------- -SCRN: EQU 0D000H -ARAM: EQU 0D800H -KEYPA: EQU 0E000h -KEYPB: EQU 0E001h -KEYPC: EQU 0E002h -KEYPF: EQU 0E003h -CSTR: EQU 0E002h -CSTPT: EQU 0E003h -CONT0: EQU 0E004h -CONT1: EQU 0E005h -CONT2: EQU 0E006h -CONTF: EQU 0E007h -SUNDG: EQU 0E008h -TEMP: EQU 0E008h -MEMSW: EQU 0E00CH -MEMSWR: EQU 0E010H -INVDSP: EQU 0E014H -NRMDSP: EQU 0E015H -SCLDSP: EQU 0E200H -BNKCTRLRST: EQU 0EFF8H ; Bank control reset, returns all registers to power up default. -BNKCTRLDIS: EQU 0EFF9H ; Disable bank control registers by resetting the coded latch. -HWSPIDATA: EQU 0EFFBH ; Hardware SPI Data register (read/write). -HWSPISTART: EQU 0EFFCH ; Start an SPI transfer. -BNKSELMROM: EQU 0EFFDh ; Select RFS Bank1 (MROM) -BNKSELUSER: EQU 0EFFEh ; Select RFS Bank2 (User ROM) -BNKCTRL: EQU 0EFFFH ; Bank Control register (read/write). - -; -; RFS v2 Control Register constants. -; -BBCLK EQU 1 ; BitBang SPI Clock. -SDCS EQU 2 ; SD Card Chip Select, active low. -BBMOSI EQU 4 ; BitBang MOSI (Master Out Serial In). -CDLTCH1 EQU 8 ; Coded latch up count bit 1 -CDLTCH2 EQU 16 ; Coded latch up count bit 2 -CDLTCH3 EQU 32 ; Coded latch up count bit 3 -BK2A19 EQU 64 ; User ROM Device Select Bit 0 (or Address bit 19). -BK2A20 EQU 128 ; User ROM Device Select Bit 1 (or Address bit 20). - ; BK2A20 : BK2A19 - ; 0 0 = Flash RAM 0 (default). - ; 0 1 = Flash RAM 1. - ; 1 0 = Flasm RAM 2 or Static RAM 0. - ; 1 1 = Reserved.` - -BNKCTRLDEF EQU BBMOSI+SDCS+BBCLK ; Default on startup for the Bank Control register. - -;----------------------------------------------- -; Rom File System Header (MZF) -;----------------------------------------------- -RFS_ATRB: EQU 00000h ; Code Type, 01 = Machine Code. -RFS_NAME: EQU 00001h ; Title/Name (17 bytes). -RFS_SIZE: EQU 00012h ; Size of program. -RFS_DTADR: EQU 00014h ; Load address of program. -RFS_EXADR: EQU 00016h ; Exec address of program. -RFS_COMNT: EQU 00018h ; COMMENT - -;----------------------------------------------- -; ROM Banks, 0-7 are reserved for alternative -; Monitor versions, CPM and RFS -; code in MROM bank, -; 0-7 are reserved for RFS code in -; the User ROM bank. -; 8-15 are reserved for CPM code in -; the User ROM bank. -;----------------------------------------------- -MROMPAGES EQU 8 -USRROMPAGES EQU 12 ; Monitor ROM : User ROM -ROMBANK0 EQU 0 ; MROM SA1510 40 Char : RFS Bank 0 - Main RFS Entry point and functions. -ROMBANK1 EQU 1 ; MROM SA1510 80 Char : RFS Bank 1 - Floppy disk controller and utilities. -ROMBANK2 EQU 2 ; CPM 2.2 CBIOS : RFS Bank 2 - SD Card controller and utilities. -ROMBANK3 EQU 3 ; RFS Utilities : RFS Bank 3 - Cmdline tools (Memory, Printer, Help) -ROMBANK4 EQU 4 ; Free : RFS Bank 4 - CMT Utilities. -ROMBANK5 EQU 5 ; Free : RFS Bank 5 -ROMBANK6 EQU 6 ; Free : RFS Bank 6 -ROMBANK7 EQU 7 ; Free : RFS Bank 7 - Memory and timer test utilities. -ROMBANK8 EQU 8 ; : CBIOS Bank 1 - Utilities -ROMBANK9 EQU 9 ; : CBIOS Bank 2 - Screen / ANSI Terminal -ROMBANK10 EQU 10 ; : CBIOS Bank 3 - SD Card -ROMBANK11 EQU 11 ; : CBIOS Bank 4 - Floppy disk controller. - -; File types. -OBJCD EQU 001H ; MZF contains a binary object. -BTX1CD EQU 002H ; MZF contains a BASIC program. -BTX2CD EQU 005H ; MZF contains a BASIC program. -TZOBJCD0 EQU 0F8H ; MZF contains a TZFS binary object for page 0. -TZOBJCD1 EQU 0F8H -TZOBJCD2 EQU 0F8H -TZOBJCD3 EQU 0F8H -TZOBJCD4 EQU 0F8H -TZOBJCD5 EQU 0F8H -TZOBJCD6 EQU 0F8H -TZOBJCD7 EQU 0F8H ; MZF contains a TZFS binary object for page 7. - -; Address definitions. -; -UROMADDR EQU 0E800H ; Start of User ROM Address space. -MROMJMPTBL EQU 00070H ; Fixed location of the Monitor ROM Jump Table. -; -; User ROM Jump Table definitions. -; -RFSJMPTABLE EQU UROMADDR + 00080H ; Entry point to the bank switching table. -PRTMZF EQU RFSJMPTABLE + 00000H ; Entry point into User ROM for the PRTMZF function. -PRTDBG EQU RFSJMPTABLE + 00003H ; Entry point into User ROM for the PRTDBG function. -; -MZFHDRSZ EQU 128 -RFSSECTSZ EQU 256 -MROMSIZE EQU 4096 -UROMSIZE EQU 2048 -FNSIZE EQU 17 ; Size of tape filename. - -;ROW EQU 25 -;COLW40 EQU 80 -;SCRNSZ40 EQU COLW40 * ROW -;COLW80 EQU 80 -;SCRNSZ80 EQU COLW80 * ROW -;MODE80C EQU 0 - - ;====================================== - ; - ; MONITOR ROM BANK 3 - RFS Utilities - ; - ;====================================== - ORG 00000h - -MONIT: -MROMBK3: JP START ; The lower part of the rom mimics the SA1510 MROM such that if a reset occurs when - ; this bank is paged in, it starts up and reverts to the SA1510 MROM. - - ALIGN_NOPS 0038H - ORG 0038H ; NMI Vector - JP 1038H ; Interrupt routine - - ALIGN_NOPS 004AH - ORG 004Ah - - ; As this is not the monitor ROM, if we arrive at START it means a reset without the monitor rom bank being selected - ; so we switch it in and do a jump to 0 for reset. -START: LD SP, STACK - IM 1 - CALL ?MODE - LD B,0FFH - LD HL,NAME - CALL ?CLER - ; - CALL INITBNKCTL - NOP - NOP - NOP - ; - LD A,(ROMBK2) ; User ROM to default. - LD (BNKSELUSER), A - LD A, (ROMBK1) ; Monitor ROM to default. - LD (BNKSELMROM), A - - ; Location for STRT1 in monitor ROM (just after Colour RAM clear call). After the bank switch we should - ; resume at this point in original monitor - ie. line commencing LD HL,TIMIN @ 006CH. - ORG 0006Ch - JR START - - ALIGN_NOPS MROMJMPTBL - ORG MROMJMPTBL - - ;----------------------------------------- - ; Enhanced function Jump table. - ;----------------------------------------- -DIRMROM: JP _DIRMROM -MFINDMZF: JP _MFINDMZF -MROMLOAD: JP _MROMLOAD - ;----------------------------------------- - - ;==================================== - ; - ; ROM File System Commands - ; - ;==================================== - - ; Method to initialise the bank control registers to a default state. - ; -INITBNKCTL:LD B,16 ; If we read the bank control reset register 15 times then this will enable bank control and then the 16th read will reset all bank control registers to default. -INITBNK_1: LD A,(BNKCTRLRST) - DJNZ INITBNK_1 ; Apply the default number of coded latch reads to enable the bank control registers. - LD A,BNKCTRLDEF ; Set coded latch, SDCS high, BBMOSI to high and BBCLK to high which enables SDCLK. - LD (BNKCTRL),A - LD (ROMCTL),A ; Save to memory the value in the bank control register - this register is used for SPI etc so need to remember its setting. - RET - - - ; Function to select a User Bank. If Carry is clear upon entry, on exit the control registers will be disabled. If carry is set then the control registers are left active. - ; - -SELUSRBNK: PUSH BC - PUSH AF - LD A,(ROMCTL) ; Get current setting for the coded latch, ie. number of reads needed to enable it. - LD C,A - RRA - RRA - CPL - AND 00FH ; Preserve bits 3-1, bit 0 is always 0 on the 74HCT191 latch. - LD B,A ; Set value to B for loop. - LD A,(BNKCTRLDIS) -SELUSRBNK1:LD A,(BNKSELUSER) - DJNZ SELUSRBNK1 - POP AF - LD (BNKSELUSER),A ; Select the required bank. - LD A,C - POP BC - JR NC,SELUSRBNK2 ; If Carry is set by caller then leave the control registers active. - AND 03FH ; When we leave the registers active, set upper bank bits to 0 to select Flash RAM I, the default. - LD (BNKCTRL),A - RET -SELUSRBNK2:LD (BNKCTRL),A ; Update the upper address lines according to in-memory value. - LD (BNKCTRLDIS),A ; Disable the control registers, value of A is not important. - RET - - ; Function to select a User Bank. If Carry is clear upon entry, on exit the control registers will be disabled. If carry is set then the control registers are left active. - ; During normal operations the control registers are enabled. When access is needed to the full User ROM space, ie for drive read/write then the registers are disabled after - ; setting the correct bank. The upper bits of the User ROM address space (ie. bits 20:19 which select the device) are set to by the ROMCTL variable. - ; -;SELUSRBNK: PUSH BC -; PUSH AF -; ; Reset to a known state to allow for spurious read/writes to control area clocking the up counter. -; LD B,15 -;SEL1: LD A,(BNKCTRLDIS) -; DJNZ SEL1 -; ; Now loop for the correct up counter required to enable the latches. -; LD B,15 ; Set value to B for loop. -;SELUSRBNK1:LD A,(BNKCTRL) ; Read the latch and compare with sample. Either we reach the count limit or the read differs indicating latch control. -; DJNZ SELUSRBNK1 -; POP AF -; POP BC -; LD (BNKSELUSER),A ; Select the required bank. -; LD A,(ROMCTL) -; JR NC,SELUSRBNK2 -; AND 03FH ; When we leave the registers active, set upper bank bits to 0 to select Flash RAM I, the default. -; LD (BNKCTRL),A -; RET -;SELUSRBNK2:LD (BNKCTRL),A -; LD (BNKCTRLDIS),A ; Disable the control registers, value of A is not important. -; RET - - - ; HL contains address of block to check. -ISMZF: PUSH BC - PUSH DE - PUSH HL - ; - LD A,(HL) - CP 001h ; Only interested in machine code images. - JR NZ, ISMZFNOT - ; - INC HL - LD DE,NAME ; Checks to confirm this is an MZF header. - LD B,FNSIZE ; Maximum of 17 characters, including terminator in filename. -ISMZFNXT: LD A,(HL) - LD (DE),A - CP 00DH ; If we find a terminator then this indicates potentially a valid name. - JR Z, ISMZFNXT3 - CP 000H ; Same applies for NULL terminator. - JR Z, ISMZFNXT3 - CP 020h ; >= Space - JR C, ISMZFNOT - CP 05Dh ; =< ] - JR C, ISMZFNXT3 -ISMZFNXT2: CP 091h - JR C, ISMZFNOT ; DEL or > 0x7F, cant be a valid filename so this is not an MZF header. -ISMZFNXT3: INC DE - INC HL - DJNZ ISMZFNXT -ISMZFYES: CP A ; Set zero flag to indicate match. -ISMZFNOT: POP HL - POP DE - POP BC - RET - - ; B contains Bank to select. - ; D = File sequence number. - ; HL contains the Block page address. -_DIRMROM: PUSH BC - ; - ; Scan MROM Bank - ; B = Bank Page - ; C = Block in page - ; - LD B,USRROMPAGES ; First 16x2K pages are reserved in User bank. - LD A,(ROMCTL) - AND 03FH ; Mask out the upper bank address lines so we start with Flash RAM I. - ; -DIRNXTDVC: LD (ROMCTL),A - LD C,0 ; Block in page. -DIRNXTPG: LD A,B - LD (WRKROMBK2), A - OR A ; Select the required user bank and Clear carry so that the control registers are disabled. - CALL SELUSRBNK - PUSH BC ; Preserve bank count/block number. - PUSH DE ; Preserve file numbering. - LD A,C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B,A - LD C,0 - LD HL,0E800h + RFS_ATRB ; Add block offset to get the valid block address. - ADD HL,BC - CALL ISMZF - POP DE - POP BC - JR NZ, DIRNOTMZF - ; - CALL _PRTMZF - INC D ; Next file sequence number. -DIRNOTMZF: INC C - LD A,C - CP UROMSIZE/RFSSECTSZ ; Max blocks per page reached? - JR C, DIRNXTPG2 - LD C,0 - INC B -DIRNXTPG2: LD A,B - CP 000h ; User rom has 256 banks of 2K, so stop when we wrap round to 0. - JR NZ, DIRNXTPG - LD A,(ROMCTL) - ADD A, 64 - CP 0C0H ; If both upper address bits are set then we have come to the end. - JR C,DIRNXTDVC - AND 03FH - LD (ROMCTL),A ; Switch back to primary Flash RAM I device. - LD A,(ROMBK2) - SCF ; Select the required user bank and Set carry so that the control registers remain enabled. - CALL SELUSRBNK - POP BC - RET - - - ; Wrapper to call the User ROM function to display the MZF filename. - ; This function needs to manipulate the banks such that the calling bank is accessible. -_PRTMZF: LD A,(ROMBK2) - SCF ; Select the required user bank and Set carry so that the control registers remain enabled. - CALL SELUSRBNK - CALL PRTMZF - ;CALL PRTDBG - LD A,(WRKROMBK2) - OR A ; Select the required user bank and Clear carry so that the control registers are disabled. - CALL SELUSRBNK - RET - - - ; In: - ; HL = filename - ; D = File sequence number. - ; Out: - ; B = Bank Page file found - ; C = Block where found. - ; D = File sequence number. - ; Z set if found. -_MFINDMZF: PUSH DE - LD (TMPADR), HL ; Save name of program to load. - EX DE, HL ; String needed in DE for conversion. - LD HL,0FFFFh ; Tag the filenumber as invalid. - LD (TMPCNT), HL - CALL ConvertStringToNumber ; See if a file number was given instead of a filename. - JR NZ, FINDMZF0 ; - LD (TMPCNT), HL ; Store filenumber making load by filenumber valid. - - ; - ; Scan MROM Bank - ; B = Bank Page - ; C = Block in page - ; D = File sequence number. - ; - ; Output: B = Bank where file found - ; C = Block within bank where page found. - ; A[7:6] = Upper bits of bank where page found. - ; -FINDMZF0: POP DE ; Get file sequence number in D. - LD B,USRROMPAGES ; First 8 pages are reserved in User ROM bank. - ;LD D,0 ; File numbering start. - LD A,(ROMCTL) - AND 03FH ; Mask out the upper bank address lines so we start with Flash RAM I. - ; -FINDNXTDVC:LD (ROMCTL),A - LD C,0 ; Block in page. - ; -FINDMZF1: LD A,B - LD (WRKROMBK2), A - OR A ; Select the required user bank and Clear carry so that the control registers are disabled. - CALL SELUSRBNK -FINDMZF2: PUSH BC ; Preserve bank count/block number. - PUSH DE ; Preserve file numbering. - LD HL,0E800h + RFS_ATRB ; Add block offset to get the valid block. - LD A,C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B,A - LD C,0 - ADD HL,BC - - CALL ISMZF - POP DE - POP BC - JR NZ, FINDMZF4 ; Z set if we found an MZF record. - INC HL ; Save address of filename. - PUSH HL - LD HL,(TMPCNT) - LD A,H - CP 0FFh ; If TMPCNT tagged as 0xFF then we dont have a filenumber so must match filename. - JR Z, FINDMZF3 - LD A,L ; Check file number, load if match - CP D - JR NZ, FINDMZF3 ; Check name just in case. - POP HL - JR FINDMZFYES ; Else the filenumber matches so load the file. - -FINDMZF3: POP HL - PUSH DE - PUSH BC - LD DE,(TMPADR) ; Original DE put onto stack, original filename into DE - LD BC,FNSIZE - CALL CMPSTRING - POP BC - POP DE - JR Z, FINDMZFYES - INC D ; Next file sequence number. -FINDMZF4: INC C - LD A,C - CP UROMSIZE/RFSSECTSZ ; Max blocks per page reached? - JR C, FINDMZF5 - LD C,0 - INC B -FINDMZF5: LD A,B - CP 000h ; User ROM has 256 banks of 2K, so stop when we wrap around to zero. - JR NZ, FINDMZF1 - ; - LD A,(ROMCTL) - ADD A, 64 - CP 0C0H ; If both upper address bits are set then we have come to the end. - JR C,FINDNXTDVC - AND 03FH - LD (ROMCTL),A ; Switch back to primary Flash RAM I device. - ; - INC B - JR FINDMZFNO -FINDMZFYES: ; Flag set by previous test. -FINDMZFNO: PUSH AF - LD A,(ROMBK2) - SCF ; Select the required user bank and Set carry so that the control registers remain enabled. - CALL SELUSRBNK - POP AF - RET - - LD A,(ROMCTL) - AND 03FH - LD (ROMCTL),A ; Switch back to primary Flash RAM I device. - - ; Load Program from ROM - ; Input: B = Bank of MZF File to load - ; C = Block within bank of start of MZF file. - ; A[7:6] = Upper bits of bank containing MZF File to load. - ; Output:Zero = Set if file loaded, reset if an error occurred. - ; - ; Load program from User ROM Banks I, II or III - ; -_MROMLOAD: PUSH BC - ; - AND 0C0H ; Ensure only top two bits are used. - LD D,A - LD A,(ROMCTL) - AND 03FH ; Mask out the upper bank address lines so we can OR in the value given. - OR D - LD (ROMCTL),A - ; - LD A,B - LD (WRKROMBK2),A - OR A ; Select the required user bank and Clear carry so that the control registers are disabled. - CALL SELUSRBNK - ; - LD DE, IBUFE ; Copy the header into the work area. - LD HL, 0E800h ; Add block offset to get the valid block. - LD A,C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B,A - LD C,0 - ADD HL,BC - LD BC, MZFHDRSZ - -LROMLOAD1: LD A,(HL) ; Issues with LDIR and a signal artifact from the mainboard, so manual copy. - INC HL - LD (DE),A - INC DE - DEC BC - LD A,B - OR C - JR NZ,LROMLOAD1 - - PUSH HL - LD DE, (DTADR) - LD HL, (SIZE) - LD BC, RFSSECTSZ - MZFHDRSZ - OR A - SBC HL, BC - JR NC, LROMLOAD4 - LD HL, (SIZE) - JR LROMLOAD4 - - ; HL = address in active block to read. - ; B = Bank - ; C = Block -LROMLOAD2: LD A, B - LD (WRKROMBK2), A - OR A ; Select the required user bank and Clear carry so that the control registers are disabled. - CALL SELUSRBNK - -LROMLOAD3: PUSH BC - LD HL, 0E800h - LD A, C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B, A - LD C, 0 - ADD HL,BC - PUSH HL - - LD DE, (TMPADR) - LD HL, (TMPSIZE) - LD BC, RFSSECTSZ - OR A - SBC HL, BC - JR NC, LROMLOAD4 - LD BC, (TMPSIZE) - LD HL, 0 -LROMLOAD4: LD (TMPSIZE), HL ; HL contains remaining amount of bytes to load. - POP HL - ; - LD A, B ; Pre check to ensure BC is not zero. - OR C - JR Z, LROMLOAD8 - -LROMLOAD9: LD (BNKCTRLDIS),A ; There exists an issue with using the mainboard decoder signal which I havent quite understood, random activation of the upcounter occurs which appears to be the refresh circuit. - LD A,(HL) ; Issues with LDIR and a signal artifact from the mainboard, so manual copy. - INC HL - LD (DE),A - INC DE - DEC BC - LD A,B - OR C - JR NZ,LROMLOAD9 - - LD BC, (TMPSIZE) - LD A, B ; Post check to ensure we still have bytes - OR C - JR Z, LROMLOAD8 - ; - LD (TMPADR),DE ; Address we are loading into. - POP BC -LROMLOAD6: INC C - LD A, C - CP UROMSIZE/RFSSECTSZ ; Max blocks per page reached? - JR C, LROMLOAD2 ;LROMLOAD3 ;LROMLOAD7 - LD C, 0 - INC B - ; -LROMLOAD7: LD A, B - CP 000h - JR NZ, LROMLOAD2 - OR 1 - JR LROMLOAD5 - ; -LROMLOAD8: POP BC -LROMLOAD5: PUSH AF - LD A,(ROMCTL) - AND 03FH - LD (ROMCTL),A ; Switch back to primary Flash RAM I device. - LD A,(ROMBK2) - SCF ; Select the required user bank and Set carry so that the control registers remain enabled. - CALL SELUSRBNK - POP AF - RET - - - - ;====================================== - ; - ; SA1510 mirrored functions. - ; - ;====================================== - -?MODE: LD HL,KEYPF - LD (HL),08AH - LD (HL),007H - LD (HL),005H - LD (HL),001H - RET - -?CLER: XOR A - JR ?DINT -?CLRFF: LD A,0FFH -?DINT: LD (HL),A - INC HL - DJNZ ?DINT - RET - - - ;====================================== - ; - ; Message table - ; - ;====================================== - - - - - ; Bring in additional resources. - USE_CMPSTRING: EQU 1 - USE_SUBSTRING: EQU 0 - USE_INDEX: EQU 0 - USE_STRINSERT: EQU 0 - USE_STRDELETE: EQU 0 - USE_CONCAT: EQU 0 - USE_CNVUPPER: EQU 1 - USE_CNVCHRTONUM: EQU 1 - USE_ISNUMERIC: EQU 1 - USE_CNVSTRTONUM: EQU 1 - ; - INCLUDE "macros.asm" - ;INCLUDE "rfs_definitions.asm" - INCLUDE "rfs_utilities.asm" - - ; Ensure we fill the entire 4K by padding with FF's. - ALIGN 1000H - diff --git a/software/asm/sa-5510_rfs.asm b/software/asm/sa-5510_rfs.asm deleted file mode 100644 index 342859d..0000000 --- a/software/asm/sa-5510_rfs.asm +++ /dev/null @@ -1,7508 +0,0 @@ -; Disassembly of the file "SA-5510.bin" -; -; CPU Type: Z80 -; -; Created with dZ80 2.1 -; -; on Wednesday, 31 of March 2021 at 11:11 PM -; - -BUILD_ORIG EQU 0 ; Build BASIC SA-5510 with original configuration, identical to version loaded from tape. -BUILD_RFS EQU 1 ; Build BASIC SA-5510 for use under RFS with SD Card access. - -PRTC EQU 0FEH -PRTD EQU 0FFH -GETL EQU 00003H -LETNL EQU 00006H -NL EQU 00009H -PRNTS EQU 0000CH -PRNTT EQU 0000FH -PRNT EQU 00012H -MSG EQU 00015H -MSGX EQU 00018H -GETKY EQU 0001BH -BRKEY EQU 0001EH -?WRI EQU 00021H -?WRD EQU 00024H -?RDI EQU 00027H -?RDD EQU 0002AH -?VRFY EQU 0002DH -MELDY EQU 00030H -?TMST EQU 00033H -TIMRD EQU 0003BH -BELL EQU 0003EH -XTEMP EQU 00041H -MSTA EQU 00044H -MSTP EQU 00047H -MONIT EQU 00000H -SS EQU 00089H -ST1 EQU 00095H -HLHEX EQU 00410H -_2HEX EQU 0041FH -?MODE EQU 0074DH -?KEY EQU 008CAH -PRNT3 EQU 0096CH -?ADCN EQU 00BB9H -?DACN EQU 00BCEH -?DSP EQU 00DB5H -?BLNK EQU 00DA6H -?DPCT EQU 00DDCH -PRTHL EQU 003BAH -PRTHX EQU 003C3H -ASC EQU 003DAH -HEX EQU 003F9H -DPCT EQU 00DDCH -DLY12 EQU 00DA7H -DLY12A EQU 00DAAH -?RSTR1 EQU 00EE6H -MOTOR EQU 006A3H -CKSUM EQU 0071AH -GAP EQU 0077AH -WTAPE EQU 00485H -MSTOP EQU 00700H -LINEBUFR EQU 0490DH -ATRB EQU 010F0H -NAME EQU 010F1H -SIZE EQU 01102H -DTADR EQU 01104H -EXADR EQU 01106H -COMNT EQU 01108H -SWPW EQU 01164H -KDATW EQU 0116EH -KANAF EQU 01170H -DSPXY EQU 01171H -MANG EQU 01173H -MANGE EQU 01179H -PBIAS EQU 0117AH -ROLTOP EQU 0117BH -MGPNT EQU 0117CH -PAGETP EQU 0117DH -ROLEND EQU 0117FH -FLASH EQU 0118EH -SFTLK EQU 0118FH -REVFLG EQU 01190H -SPAGE EQU 01191H -FLSDT EQU 01192H -STRGF EQU 01193H -DPRNT EQU 01194H -TMCNT EQU 01195H -SUMDT EQU 01197H -CSMDT EQU 01199H -AMPM EQU 0119BH -TIMFG EQU 0119CH -SWRK EQU 0119DH -TEMPW EQU 0119EH -ONTYO EQU 0119FH -OCTV EQU 011A0H -RATIO EQU 011A1H -BUFER EQU 011A3H -CMT_RDINF EQU 0E886H ; UROMADDR+86H - Tape/SD intercept handler - Read Header -CMT_RDDATA EQU 0E889H ; UROMADDR+89H - Tape/SD intercept handler - Read Data -CMT_WRINF EQU 0E88CH ; UROMADDR+80H - Tape/SD intercept handler - Write Header -CMT_WRDATA EQU 0E88FH ; UROMADDR+8FH - Tape/SD intercept handler - Write Data -CMT_VERIFY EQU 0E892H ; UROMADDR+92H - Tape/SD intercept handler - Verify Data -CMT_DIR EQU 0E895H ; UROMADDR+95H - SD directory command. -PRGSTART EQU 011FDH ; Build includes the tape copy code under original build. - - ; Original build set the tape handlers to original. - IF BUILD_ORIG = 1 -QRDI EQU ?RDI -QRDD EQU ?RDD -QWRI EQU ?WRI -QWRD EQU ?WRD - ENDIF - IF BUILD_RFS = 1 -QRDI EQU RFSRDI -QRDD EQU CMT_RDDATA -QWRI EQU CMT_WRINF -QWRD EQU CMT_WRDATA - ENDIF - - ; Create an MZF Tape header. - ORG ATRB - - ; Declare the MZF header to bootstrap BASIC from tape/SD. -BOOTATRB: DB 01h ; Code Type, 01 = Machine Code. -BOOTNAME: IF BUILD_ORIG = 1 - DB "BASIC SA-5510 ", 0Dh ; Title/Name (17 bytes). - ENDIF - IF BUILD_RFS = 1 - DB "BASIC SA-5510RFS", 0Dh ; Title/Name (17 bytes). - ENDIF -BOOTSIZE: DW BASICEND - TAPECOPY ; Size of program. -BOOTDTADR: DW TAPECOPY ; Load address of program. -BOOTEXADR: DW COLDSTRT ; Exec address of program. -BOOTCOMNT: DS 104 ; COMMENT - - ORG PRGSTART - -TAPECOPY: IF BUILD_ORIG = 1 - JP TAPECOPYPRG - ENDIF - IF BUILD_RFS = 1 ; Under RFS build the tape copy code isnt needed so place NOP's where the call resides. - NOP - NOP - NOP - ENDIF - -COLDSTRT: LD HL,048FFH ; Scan for memory top. - IF BUILD_ORIG = 1 - LD D,0D0H ; Full memory for original build - ENDIF - IF BUILD_RFS = 1 - LD D,0CEH ; RFS uses the top 512byte sector for SD card operations so need to limit memory. - ENDIF -L1205: INC HL - LD A,H - CP D - JR Z,L1214 ; (+00aH) - LD A,0FFH ; Set location to 255, reread and subtract, should be 0 if real memory. - LD (HL),A - SUB (HL) - JR NZ,L1214 ; (+004H) - LD (HL),A - CP (HL) - JR Z,L1205 ; (-00fH) -L1214: LD (04908H),HL - LD (0490AH),HL - LD SP,HL - CALL BELL - XOR A - LD D,A - LD E,A - CALL ?TMST - CALL L132C - CALL L1313 - LD DE,TITLEMSG - CALL L1329 - LD DE,COPYRMSG - CALL L1329 - CALL L131E - CALL L1944 - LD BC,0000AH - CALL L184D - CALL L1841 - CALL MSGNL - LD DE,BYTESMSG - CALL MSGX - ; - ; Warm start, entry point after command error or completion. - ; -WARMSTRT: NOP - NOP -WARMSTRTMON:NOP ; Sharp defined BASIC restart location from Monitor. - NOP - NOP - NOP - NOP - NOP - NOP - NOP - LD SP,(0490AH) - LD DE,READYMSG - CALL MSGNL -L1262: LD HL,L12B8 - PUSH HL -L1266: LD HL,0504DH - CALL L19BA - CALL L19BA - CALL NL - LD DE,LINEBUFR - LD A,(L2A83) - OR A - JR Z,L1299 ; (+01eH) - LD HL,(L2A84) - PUSH HL - LD BC,(02A86H) - ADD HL,BC - JR C,L12A6 ; (+020H) - LD (L2A84),HL - POP HL - PUSH DE - CALL STRTONUM - EX DE,HL - LD (HL),020H - INC HL - LD (HL),00DH - EX DE,HL - POP DE - CALL MSGX -L1299: CALL L1338 - LD A,(DE) - CP 01BH - RET NZ - XOR A - LD (L2A83),A - JR L1299 ; (-00dH) - -L12A6: XOR A - LD (L2A83),A - JP SYNTAXERR - - CALL L1266 - LD A,(DE) - CP 00DH - RET Z - LD HL,(0490AH) - LD SP,HL -L12B8: CALL L146A - CALL L14F8 - LD HL,(04A10H) - LD A,L - OR H - JR NZ,L12D4 ; (+00fH) - LD HL,04A12H - LD (05051H),HL - CALL EXECNOTCHR - DB 00DH - DW L1B5F - JP L1262 - -L12D4: CALL L12DA - JP L1262 - -L12DA: CALL L145E - CALL L1459 - CALL L18B0 - RET PE - LD (DE),A - CALL Z,L1302 - LD A,(04A12H) - CP 00DH - RET Z - CALL L18B3 - DI - LD (DE),A - LD (04A0EH),HL - EX DE,HL - LD HL,04A0EH - CALL L18F2 - CALL L18A2 - JR L130C ; (+00aH) - -L1302: CALL L18F2 - EX DE,HL - CALL L1873 - CALL L1762 -L130C: CALL L19C3 - EX DE,HL - JP L18EA - -L1313: LD B,021H -L1315: LD A,0CFH - CALL PRNT - DJNZ L1315 ; (-007H) - JR L132C ; (+00eH) - -L131E: LD B,021H -L1320: LD A,0D7H - CALL PRNT - DJNZ L1320 ; (-007H) - JR L132C ; (+003H) - -L1329: CALL MSGX -L132C: CALL LETNL - JP LETNL - -MSGNL: CALL NL - JP MSGX - -L1338: CALL GETL - LD A,0C9H - CALL ?DPCT - LD A,000H - LD HL,SFTLK - LD (HL),A - RET - -TITLEMSG: DB " BASIC ",0A6H,0B0H,096H,092H,09DH,09EH,09DH,092H,096H,092H,09DH," SA-5510" - DB 00DH -COPYRMSG: DB " C",0B7H,09EH,0BDH,09DH,0A6H,097H,098H,096H," 1981 ",09AH,0BDH," SHARP C",0B7H,09DH,09EH,"." - DB 00DH -READYMSG: DB "R",092H,0A1H,09CH,0BDH - DB 00DH -ERRORMSG: DB "*E",09DH,09DH,0B7H,09DH - DB 00DH -INMSG: DB " ",0A6H,0B0H - DB 00DH -BREAKMSG: DB "*B",09DH,092H,0A1H,0A9H - DB 00DH -BYTESMSG: DB " B",0BDH,096H,092H,0A4H - DB 00DH -ERRCODE: DB 012H ; Storage of error code - DB 000H -L13A5: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - - ; Error table. A is loaded with code and the 01 is LD BC, so a 3E 01 would be LD A,01 and the next entry would be skipped as it would see 01 3E 02 or LB BC,023E. - ; Designed to save code, the error code is loaded into A then it falls all the way to the bottom of this table before returning. -SYNTAXERR: LD A,1 ; Syntax error - DB 001H -OVFLERR: LD A,2 ; Operation result overflow - DB 001H -ILDATERR: LD A,3 ; Illegal data - DB 001H -DATMISERR: LD A,4 ; Data type mismatch - DB 001H -STRLENERR: LD A,5 ; String length exceeded 255 characters - DB 001H -MEMERR: LD A,6 ; Insufficient memory capacity. - DB 001H - LD A,7 ; Size of array larger than previous definition. - DB 001H -LINELENERR: LD A,8 ; Length of text line too long. - DB 001H -GOSUBERR: LD A,10 ; GOSUB nest exceeds 16 deep. - DB 001H -FORNEXTERR: LD A,11 ; FOR-NEXT nest exceeds 16 deep. - DB 001H -FUNCERR: LD A,12 ; FUNC levels exceed depth of 6. - DB 001H -NEXTFORERR: LD A,13 ; NEXT without FOR - DB 001H -RETGOSBERR: LD A,14 ; RETURN without GOSUB - DB 001H -UNDEFFNERR: LD A,15 ; Undefined function - DB 001H -LINEERR: LD A,16 ; Unused reference line number - DB 001H -CONTERR: LD A,17 ; CONT cannot be executed - DB 001H -BADWRERR: LD A,18 ; Write statement to BASIC error - DB 001H -CMDSTMTERR: LD A,19 ; Direct mode and statements are mixed - DB 001H -READDATAERR:LD A,24 ; READ without DATA - DB 001H -OPENERR: LD A,43 ; OPEN issued on already open file. - DB 001H -UNKNWNERR: LD A,60 ; - DB 001H -OUTFILEERR: LD A,63 ; Out of file - DB 001H -PRTNRDYERR: LD A,65 ; Printer not ready - DB 001H -PRTHWERR: LD A,66 ; Printer hardware error - DB 001H -PRTPAPERERR:LD A,67 ; Out of paper - DB 001H -CHKSUMERR: LD A,70 ; Check sum error - JR L1403 ; (+009H) - -L13FA: LD IY,L1400 - RET - - NOP -L1400: LD A,(013FFH) -L1403: LD (ERRCODE),A - CALL L1ABF - CALL L1AB8 - JR Z,L142A ; (+01cH) - LD HL,05056H - LD A,(HL) - CP 001H - JR NZ,L1421 ; (+00bH) - INC (HL) - LD HL,(0490AH) - LD SP,HL - LD HL,(05057H) - JP L1EAA - -L1421: CALL L1991 - CALL L1978 - CALL L199E -L142A: LD DE,ERRORMSG - CALL MSGNL - LD HL,(ERRCODE) - CALL L1453 - JR L143E ; (+006H) - -L1438: LD DE,BREAKMSG - CALL MSGNL -L143E: LD BC,WARMSTRT - PUSH BC - XOR A - LD (L2A83),A - CALL BELL - CALL L1AB8 - RET Z - LD DE,INMSG - CALL MSGX -L1453: CALL L1841 - JP MSGX - -L1459: XOR A - LD (L1463),A - RET - -L145E: XOR A - LD (05059H),A - RET - -L1463: NOP -L1464: SBC A,C - LD H,D - RET Z - RRCA - SUB B - LD H,D -L146A: LD HL,LINEBUFR - CALL L17F6 - LD (04A10H),DE - LD DE,04A12H - LD C,000H -L1479: CALL L1561 - RET Z - OR A - JP M,SYNTAXERR - DEC DE - PUSH HL - LD HL,L1479 - EX (SP),HL - CP 03FH - LD B,088H - JR Z,L1498 ; (+00bH) - DEC HL - PUSH DE - LD DE,CMDWORDTBL - CALL L14C7 - JR NZ,L14A8 ; (+011H) - POP DE -L1498: LD A,080H - CALL L14B3 - CP 084H - RET NC -L14A0: CALL L1595 - CP ':' - RET Z - POP AF - RET - -L14A8: LD DE,UNUSEDTBL1 - CALL L14C7 - JR NZ,L14B9 ; (+009H) - POP DE - LD A,081H -L14B3: LD (DE),A - INC DE -L14B5: LD A,B - LD (DE),A - INC DE - RET - -L14B9: LD DE,OPERATORTBL - LD B,083H - CALL L14C9 - POP DE - JR Z,L14B5 ; (-00fH) - INC HL - INC DE - RET - -L14C7: LD B,080H -L14C9: PUSH HL -L14CA: CALL SKIPSPACE - OR A - JP M,L14F1 - EX DE,HL - CALL SKIPSPACE - EX DE,HL - SUB (HL) - INC HL - INC DE - JR Z,L14CA ; (-011H) - ADD A,080H - JR NZ,L14E2 ; (+003H) - INC SP - INC SP - RET - -L14E2: POP HL - DEC DE -L14E4: LD A,(DE) - INC DE - OR A - JR Z,L14EF ; (+006H) - JP P,L14E4 - INC B - JR L14C9 ; (-026H) - -L14EF: DEC A - RET - -L14F1: POP HL - CALL SKIPSPACE - DEC A - LD A,(HL) - RET - -L14F8: LD HL,(04A10H) - LD DE,LINEBUFR - LD C,0B2H - CALL L17FE - LD A,020H - LD (DE),A - INC DE - LD HL,04A12H -L150A: CALL L1561 - RET Z - SUB 080H - JR C,L150A ; (-008H) - DEC DE - DEC C - CP 003H - JR C,L1525 ; (+00dH) - SUB 002H - LD B,A - PUSH HL - LD HL,OPERATORTBL -L151F: CALL L1554 - POP HL - JR L150A ; (-01bH) - -L1525: EX AF,AF' - LD A,(HL) - INC HL - SUB 07FH - LD B,A - PUSH HL - EX AF,AF' - OR A - JR Z,L153D ; (+00dH) - LD HL,L151F - PUSH HL - LD HL,UNUSEDTBL1 - DEC A - RET Z - LD HL,UNUSEDTBL2 - RET - -L153D: PUSH BC - LD HL,CMDWORDTBL - CALL L1554 - POP AF - LD HL,L150A - EX (SP),HL - CP 004H - RET NC - JP L14A0 - -L154F: BIT 7,(HL) - INC HL - JR Z,L154F ; (-005H) -L1554: DJNZ L154F ; (-007H) -L1556: CALL L158A - ADD A,080H - JR NC,L1556 ; (-007H) - DEC DE - LD (DE),A - INC DE - RET - -L1561: CALL L158A - RET Z - CALL L1575 - JR Z,L1561 ; (-009H) - CP 022H - RET NZ - CALL L1581 - CP 00DH - JR NZ,L1561 ; (-013H) - RET - -L1575: CP 020H - RET Z - CP PRTD - RET Z - CP 028H - RET Z - CP 029H - RET - -L1581: CALL L158A - RET Z - CP 022H - JR NZ,L1581 ; (-008H) - RET - -L158A: LD A,(HL) - LD (DE),A - INC HL - INC DE - INC C - JP Z,LINELENERR - CP 00DH - RET - -L1595: CALL L158A - RET Z - CP ':' - RET Z - CP 022H - JR NZ,L1595 ; (-00bH) - CALL L1581 - CP 00DH - JR NZ,L1595 ; (-012H) - RET - - ; Reserved word table. -CMDWORDTBL: DB "RE", "M" | 080H - DB "DAT", "A" | 080H - DB 0FFH | 080H - DB 0FFH | 080H - DB "REA", "D" | 080H - DB "LIS", "T" | 080H - DB "RU", "N" | 080H - DB "NE", "W" | 080H - DB "PRIN", "T" | 080H - DB "LE", "T" | 080H - DB "FO", "R" | 080H - DB "I", "F" | 080H - DB "THE", "N" | 080H - DB "GOT", "O" | 080H - DB "GOSU", "B" | 080H - DB "RETUR", "N" | 080H - DB "NEX", "T" | 080H - DB "STO", "P" | 080H - DB "EN", "D" | 080H - DB 0FFH | 080H - DB "O", "N" | 080H - DB "LOA", "D" | 080H - DB "SAV", "E" | 080H - DB "VERIF", "Y" | 080H - DB "POK", "E" | 080H - DB "DI", "M" | 080H - DB "DEF F", "N" | 080H - DB "INPU", "T" | 080H - DB "RESTOR", "E" | 080H - DB "CL", "R" | 080H - DB "MUSI", "C" | 080H - DB "TEMP", "O" | 080H - DB "USR", "(" | 080H - DB "WOPE", "N" | 080H - DB "ROPE", "N" | 080H - DB "CLOS", "E" | 080H - DB "MO", "N" | 080H - DB "LIMI", "T" | 080H - DB "CON", "T" | 080H - DB "GE", "T" | 080H - DB "INP", "@" | 080H - DB "OUT", "@" | 080H - DB "CURSO", "R" | 080H - DB "SE", "T" | 080H - DB "RESE", "T" | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB "AUT", "O" | 080H - DB 0FFH | 080H - DB 0FFH | 080H - DB "COPY/", "P" | 080H - DB "PAGE/", "P" | 080H - IF BUILD_ORIG = 1 - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - ENDIF - IF BUILD_RFS = 1 - DB "DI", "R" | 080H ; New DIR command to list the SD card directory. - ENDIF - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 000H -UNUSEDTBL1: DB 07FH | 080H - DB 000H -UNUSEDTBL2: DB 07FH | 080H - DB 000H -OPERATORTBL:DB ">", "<" | 080H - DB "<", ">" | 080H - DB "=", "<" | 080H - DB "<", "=" | 080H - DB "=", ">" | 080H - DB ">", "=" | 080H - DB 07FH | 080H - DB ">" | 080H - DB "<" | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB "T", "O" | 080H - DB "STE", "P" | 080H - DB "LEFT$", "(" | 080H - DB "RIGHT$", "(" | 080H - DB "MID$", "(" | 080H - DB "LEN", "(" | 080H - DB "CHR$", "(" | 080H - DB "STR$", "(" | 080H - DB "ASC", "(" | 080H - DB "VAL", "(" | 080H - DB "PEEK", "(" | 080H - DB "TAB", "(" | 080H - DB "SPACE$", "(" | 080H - DB "SIZ", "E" | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB "STRING$", "(" | 080H - DB 07FH | 080H - DB "CHARACTER$", "(" | 080H - DB "CS", "R" | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB 07FH | 080H - DB "RND", "(" | 080H - DB "SIN", "(" | 080H - DB "COS", "(" | 080H - DB "TAN", "(" | 080H - DB "ATN", "(" | 080H - DB "EXP", "(" | 080H - DB "INT", "(" | 080H - DB "LOG", "(" | 080H - DB "LN", "(" | 080H - DB "ABS", "(" | 080H - DB "SGN", "(" | 080H - DB "SQR", "(" | 080H - DB 07FH | 080H - DB 000H -L173A: LD HL,(05051H) - DEC HL -INCSKIPSPCE:INC HL -SKIPSPACE: LD A,(HL) - CP 020H - RET NZ - JR INCSKIPSPCE ; (-007H) - -L1745: PUSH AF - LD A,00DH -L1748: CP (HL) - INC HL - JR NZ,L1748 ; (-004H) - POP AF - RET - -L174E: INC HL -L174F: CALL L193B - RET Z - CP 022H - JR NZ,L174E ; (-009H) -L1757: INC HL - LD A,(HL) - CP 00DH - RET Z - CP 022H - JR NZ,L1757 ; (-009H) - JR L174E ; (-014H) - -L1762: LD A,C - CPL - LD C,A - LD A,B - CPL - LD B,A - INC BC - RET - -L176A: CALL SKIPSPACE - SUB 030H - CP 00AH - LD A,(HL) - RET - -L1773: LD A,H - SUB D - RET NZ - LD A,L - SUB E - RET - -L1779: POP HL ; Get address after call and jump to it via a RET command. -L177A: EX (SP),HL -EXECHL: PUSH AF - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - POP AF - EX (SP),HL - RET - -L1783: POP HL -L1784: EX (SP),HL - INC HL - INC HL - EX (SP),HL - RET - -L1789: LD HL,(04E94H) - INC HL - INC HL - INC HL - INC HL - INC HL - RET - -L1792: LD HL,(05051H) -EXECNOTCHR: CALL SKIPSPACE ; Scan for character after command - EX (SP),HL - CP (HL) - INC HL - JR NZ,EXECHL ; (-022H) - INC HL - JR L17AB ; Move the return address pointer over the test character and function address. - -L17A0: LD HL,(05051H) -MATCHCHR: CALL SKIPSPACE - EX (SP),HL - CP (HL) - JP NZ,SYNTAXERR -L17AB: INC HL - EX (SP),HL - JR INCSKIPSPCE ; (-071H) - -L17AF: XOR A - CP H - JR Z,L17B7 ; (+004H) - EX DE,HL - CP H - JR NZ,L177A ; (-03dH) -L17B7: LD A,L - LD L,H -L17B9: OR A - JR Z,L17CC ; (+010H) - RRA - JR NC,L17C2 ; (+003H) - ADD HL,DE - JR C,L177A ; (-048H) -L17C2: OR A - JR Z,L17CC ; (+007H) - EX DE,HL - ADD HL,HL - EX DE,HL - JR NC,L17B9 ; (-011H) - JR L177A ; (-052H) - -L17CC: EX DE,HL - JR L1784 ; (-04bH) - -L17CF: CALL L17AF - OR C - INC DE - RET - -L17D5: LD DE,MONIT - LD B,D -L17D9: CALL L176A - JR NC,L1784 ; (-05aH) - AND 00FH - LD C,A - XOR A - PUSH HL - LD L,E - LD H,D - ADD HL,HL - RRA - ADD HL,HL - RRA - ADD HL,DE - RRA - ADD HL,HL - RRA - ADD HL,BC - EX DE,HL - POP HL - INC HL - ADC A,A - JR NC,L17D9 ; (-01bH) - JR L177A ; (-07cH) - -L17F6: CALL L17D5 - XOR E - INC DE - RET - - ; Method to convert a number in HL to a string. -STRTONUM: LD C,000H -L17FE: LD A,020H - LD (DE),A - INC DE - PUSH DE - LD B,000H - LD DE,L2710 - CALL L1827 - LD DE,003E8H - CALL L1827 - LD DE,00064H - CALL L1827 - LD DE,0000AH - CALL L1827 - LD A,L - POP HL - OR 030H - LD (HL),A - INC HL - LD (HL),00DH - EX DE,HL - RET - -L1827: LD A,0FFH -L1829: INC A - OR A - SBC HL,DE - JR NC,L1829 ; (-006H) - ADD HL,DE - OR A - JR NZ,L1836 ; (+003H) - OR B - RET Z - XOR A -L1836: INC B - OR 030H - POP DE - EX (SP),HL - LD (HL),A - INC HL - EX (SP),HL - PUSH DE - INC C - RET - - ; Convert a string into a numeric and store. -L1841: LD DE,04AB3H ; Conversion to be stored in location. - PUSH DE - CALL STRTONUM - POP DE - RET - -L184A: LD BC,MONIT -L184D: LD HL,(04E94H) - ADD HL,BC - JR C,L185C ; (+009H) - EX DE,HL - LD HL,0FF9CH - ADD HL,SP - XOR A - SBC HL,DE - RET NC -L185C: JP MEMERR - -L185F: PUSH HL - PUSH DE - CALL L184D - POP DE - POP HL - RET - -L1867: LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - EX DE,HL - LD A,L - OR H - RET - -L1873: PUSH BC - PUSH HL - PUSH DE - EX DE,HL - ADD HL,BC - EX DE,HL - CALL L1789 - LD A,L - SUB E - LD C,A - LD A,H - SBC A,D - LD B,A - INC BC - POP HL - PUSH HL - EX DE,HL - JR L18A8 ; (+020H) - -L1888: CALL L185F - PUSH BC - PUSH HL - PUSH DE - CALL L1789 - PUSH HL - ADD HL,BC - EX (SP),HL - LD A,L - SUB E - LD C,A - LD A,H - SBC A,D - LD B,A - INC BC - POP DE - LDDR -L189E: POP DE - POP HL - POP BC - RET - -L18A2: CALL L1888 -L18A5: PUSH BC - PUSH HL - PUSH DE -L18A8: LD A,C - OR B - JR Z,L189E ; (-00eH) - LDIR - JR L189E ; (-012H) - -L18B0: LD (L18BF),HL -L18B3: LD HL,0505CH -L18B6: PUSH HL - CALL L1867 - JP Z,L1779 - PUSH HL - DB 021H -L18BF: DB 0AAH - DB 00FH - CALL L1773 - POP HL - JP Z,L1783 - JP C,L1783 - POP AF - JR L18B6 ; (-018H) - -L18CE: PUSH HL - LD E,(HL) - INC HL - LD D,(HL) - LD A,E - OR D - JP Z,L1779 - DB 021H -L18D8: DB 042H - DB 04CH - CALL L1773 - POP HL - INC HL - INC HL - JP L1784 - -L18E3: ADD HL,BC - EX DE,HL - POP HL - LD (HL),E - INC HL - LD (HL),D - EX DE,HL -L18EA: PUSH HL - CALL L1867 - JR NZ,L18E3 ; (-00dH) - POP HL - RET - -L18F2: PUSH HL - LD BC,00004H - ADD HL,BC - CALL L1900 - INC BC - POP HL - RET - -L18FD: LD BC,MONIT -L1900: PUSH HL - LD A,00DH -L1903: CP (HL) - INC HL - INC BC - JR NZ,L1903 ; (-005H) - DEC BC - POP HL - RET - -L190B: CALL L1921 -L190E: LD A,E - EX DE,HL - LD BC,MONIT - LD HL,(04E92H) - DEC HL -L1917: INC HL - ADD HL,BC - CP (HL) - INC HL - LD C,(HL) - INC HL - JR NZ,L1917 ; (-008H) - EX DE,HL - RET - -L1921: LD A,D - OR A - RET NZ - JR L1929 ; (+003H) - -L1926: LD A,D - OR A - RET Z -L1929: JP DATMISERR - -L192C: LD HL,(04E94H) - EX DE,HL -L1930: LD BC,00005H - LDIR - RET - -L1936: LD HL,(04E94H) - JR L1930 ; (-00bH) - -L193B: CALL SKIPSPACE - CP 00DH - RET Z - CP ':' - RET - -L1944: LD HL,MONIT - LD (04E4CH),HL - CALL L1957 - CALL L199E - CALL L1978 - CALL L1459 - RET - -L1957: LD HL,0505CH - CALL L19BA - LD DE,04E4EH -L1960: PUSH HL - LD HL,04E96H - XOR A - SBC HL,DE - LD B,L - SRL B - POP HL - EX DE,HL -L196C: XOR A - LD (HL),E - INC HL - LD (HL),D - INC HL - LD (DE),A - INC DE - LD (DE),A - INC DE - DJNZ L196C ; (-00bH) - RET - -L1978: LD HL,05040H - LD (04E9AH),HL - LD HL,04FD7H - LD (04E98H),HL - LD HL,04EBAH - LD (04E96H),HL - LD HL,05053H - CALL L19BA - LD (HL),A -L1991: XOR A - LD (05056H),A - RET - -L1996: LD HL,(04E84H) - LD DE,04E84H - JR L1960 ; (-03eH) - -L199E: LD HL,04DF2H - LD B,05AH -L19A3: LD (HL),000H - INC HL - DJNZ L19A3 ; (-005H) - LD B,01AH - LD HL,04E50H -L19AD: LD E,(HL) - INC HL - LD D,(HL) - INC HL - PUSH HL - EX DE,HL - CALL L2E09 - POP HL - DJNZ L19AD ; (-00cH) - RET - -L19BA: XOR A -L19BB: LD (HL),A - INC HL - LD (HL),A - INC HL - RET - -L19C0: CALL L1888 -L19C3: PUSH HL - LD A,E - EX AF,AF' - LD A,D - LD HL,04E94H -L19CA: LD E,(HL) - INC HL - LD D,(HL) - CP D - JR C,L19D7 ; (+007H) - JR NZ,L19E2 ; (+010H) - EX AF,AF' - CP E - JR NC,L19E1 ; (+00bH) - EX AF,AF' -L19D7: EX DE,HL - ADD HL,BC - EX DE,HL - LD (HL),D - DEC HL - LD (HL),E - DEC HL - DEC HL - JR L19CA ; (-017H) - -L19E1: EX AF,AF' -L19E2: LD D,A - EX AF,AF' - LD E,A - POP HL - RET - -L19E7: CALL L1873 - PUSH BC - CALL L1762 - CALL L19C3 - POP BC - RET - -L19F3: CALL SKIPSPACE - LD DE,00D2CH - LD BC,MONIT - CP 022H - JR NZ,L1A02 ; (+002H) - LD E,A - INC HL -L1A02: PUSH HL -L1A03: LD A,(HL) - CP D - JR Z,L1A0F ; (+008H) - CP E - INC HL - JR Z,L1A0F ; (+004H) - INC BC - JR L1A03 ; (-00bH) - -L1A0E: PUSH HL -L1A0F: EX (SP),HL - PUSH HL - CALL L1A1E - EX DE,HL - EX (SP),HL - CALL L18A5 - POP DE - POP HL - JP SKIPSPACE - -L1A1E: PUSH BC - XOR A - LD E,A - LD HL,(04E92H) - JR L1A2B ; (+005H) - -L1A26: INC HL - LD C,(HL) - INC HL - INC HL - ADD HL,BC -L1A2B: INC E - CP (HL) - JR NZ,L1A26 ; (-009H) - POP BC - PUSH BC - INC BC - INC BC - INC BC - EX DE,HL - CALL L1888 - EX DE,HL - PUSH HL - ADD HL,BC - DEC HL - LD (HL),00DH - LD HL,(04E94H) - ADD HL,BC - LD (04E94H),HL - POP HL - POP BC - LD (HL),E - INC HL - LD (HL),C - INC HL - LD D,001H - RET - -L1A4E: PUSH HL - LD HL,(04E94H) - LD DE,MONIT - LD A,(HL) - OR A - JP P,L1779 - CP 0C1H - JR C,L1A72 ; (+014H) - SUB 0D1H - JP NC,L1779 - LD E,003H - ADD HL,DE - LD E,(HL) - INC HL - LD D,(HL) - JR L1A6F ; (+004H) - -L1A6B: SRL D - RR E -L1A6F: INC A - JR NZ,L1A6B ; (-007H) -L1A72: JP L1783 - -L1A75: CALL EXECNOTCHR - DB 00DH - DW L1A7E - JP L177A - -L1A7E: PUSH HL - DEC HL -L1A80: CALL L1A91 - JR Z,L1A80 ; (-005H) - CP 00DH - JP NZ,L1779 - POP HL - CALL L2333 - JP L1784 - -L1A91: CALL INCSKIPSPCE - CP 045H - RET Z -L1A97: CALL L176A - JR NC,L1A9E ; (+002H) - CP (HL) - RET - -L1A9E: CP 02EH - RET Z - CP '+' - RET Z - CP '-' - RET - -L1AA7: PUSH HL - CALL L1AB8 - POP HL - RET Z - JR L1AB5 ; Command statement error. - -L1AAF: PUSH HL - CALL L1AB8 - POP HL - RET NZ -L1AB5: JP CMDSTMTERR - -L1AB8: LD HL,(0504FH) - LD A,H - OR L - RET - -L1ABE: NOP -L1ABF: LD HL,L1ABE - XOR A - CP (HL) - LD (HL),A - JR NZ,L1AEE ; (+027H) -L1AC7: LD HL,0505CH -L1ACA: LD E,(HL) - INC HL - LD D,(HL) - DEC HL - LD A,E - OR D - RET Z - CALL L1773 - RET C - EX DE,HL - ADD HL,DE - EX DE,HL - LD (HL),E - INC HL - LD (HL),D - EX DE,HL - JR L1ACA ; (-014H) - -L1ADE: LD HL,(04E4EH) - LD DE,0505CH - DEC HL - DEC HL - XOR A - SBC HL,DE - LD B,H - LD C,L - JP L19E7 - -L1AEE: CALL L1ADE -L1AF1: CALL L1996 - CALL L199E - CALL L1978 - RET - - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - PUSH BC - CALL L1AEE - POP BC - LD A,B - OR A - JR NZ,L1B10 ; (+004H) - LD A,C - CP 003H - RET C -L1B10: PUSH BC - DEC BC - DEC BC - LD DE,0505CH - CALL L19C0 - POP BC - RET - -L1B1B: LD HL,0505CH -L1B1E: LD E,(HL) - INC HL - LD D,(HL) - DEC HL - LD A,D - OR E - RET Z - CALL L1773 - RET NC - PUSH DE - EX DE,HL - XOR A - SBC HL,DE - EX DE,HL - LD (HL),E - INC HL - LD (HL),D - POP HL - JR L1B1E ; (-017H) - -L1B35: LD HL,(05051H) -L1B38: CALL SKIPSPACE -L1B3B: CP 00DH - JR Z,L1B45 ; (+006H) - CALL MATCHCHR - DB ':' - JR L1B5C ; (+017H) - -L1B45: LD HL,(0504DH) - LD A,H - OR L - JP Z,WARMSTRT -L1B4D: LD A,(HL) - INC HL - OR (HL) - DEC HL - JP Z,L1D17 - LD DE,0504DH - LD BC,00004H - LDIR -L1B5C: LD (05051H),HL -L1B5F: LD A,(05056H) - DEC A - CALL Z,L1B9F - CALL BRKEY - JR NZ,L1B73 ; (+008H) - LD A,002H - CALL L29EB - JP L1438 - -L1B73: LD HL,(04E92H) - CALL L19BA - LD (04E94H),HL - CALL L173A -L1B7F: SUB 080H - JP C,CMDLET - INC HL - LD C,(HL) - INC HL - PUSH HL - LD HL,CMDJMPTBL - JP NZ,SYNTAXERR - LD A,C - ADD A,080H - JP NC,SYNTAXERR - LD C,A -L1B95: LD B,000H - ADD HL,BC - ADD HL,BC - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - EX (SP),HL - RET - -L1B9F: CALL L1AB8 - RET Z - LD DE,L13A5 - LD HL,0504DH - JR NZ,L1BAC ; (+001H) - EX DE,HL -L1BAC: LD BC,LETNL - LDIR - RET - -CMDJMPTBL: DW CMDREMDATA - DW CMDREMDATA - DW SYNTAXERR - DW SYNTAXERR - DW CMDREAD - DW CMDLIST - DW CMDRUN - DW CMDNEW - DW CMDPRINT - DW CMDLET - DW CMDFOR - DW CMDIF - DW SYNTAXERR - DW CMDGOTO - DW CMDGOSUB - DW CMDRETURN - DW CMDNEXT - DW CMDSTOP - DW CMDEND - DW SYNTAXERR - DW CMDON - DW CMDLOAD - DW CMDSAVE - DW CMDVERIFY - DW CMDPOKE - DW CMDDIM - DW CMDDEFFN - DW CMDINPUT - DW CMDRESTORE - DW CMDCLS - DW CMDMUSIC - DW CMDTEMPO - DW CMDUSRN - DW CMDWOPEN - DW CMDROPEN - DW CMDCLOSE - DW CMDMON - DW CMDLIMIT - DW CMDCONT - DW CMDGET - DW CMDINP - DW CMDOUT - DW CMDCURSOR - DW CMDSET - DW CMDRESET - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW CMDAUTO - DW SYNTAXERR - DW SYNTAXERR - DW CMDCOPY - DW CMDPAGE - IF BUILD_ORIG = 1 - DW SYNTAXERR - ENDIF - IF BUILD_RFS = 1 - DW CMDDIR - ENDIF - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR -L1C32: CALL L193B - JP NZ,SYNTAXERR - LD (05051H),HL - RET - -CMDREMDATA: CALL L174F - JP L1B38 - -CMDNEW: XOR A - LD (L1463),A - CALL L1944 -L1C49: JP WARMSTRT - -L1C4C: DB 006H -CMDLIST: XOR A - LD (L1CAB),A - CALL EXECNOTCHR - DB '/' - DW L1C60 - CALL MATCHCHR - DB 050H - LD A,001H - LD (L1CAB),A -L1C60: CALL L1AA7 - DB 03EH - LD A,(BC) - LD (L1C4C),A - PUSH HL - LD HL,04AB3H - CALL L19BA - DEC A - CALL L19BB - POP HL - CALL L193B - CALL NZ,L1CF3 - LD (05051H),HL - LD HL,0505CH -L1C80: PUSH HL - CALL L1867 - POP HL -L1C85: JR Z,L1C49 ; (-03eH) - CALL L18F2 - LD DE,04A0EH - LDIR - LD HL,(04AB3H) - EX DE,HL - LD HL,(04A10H) - CALL L1773 - JR C,L1CDF ; (+044H) - EX DE,HL - LD HL,(04AB5H) - CALL L1773 - JR C,L1CDF ; (+03bH) - CALL L14F8 - LD DE,LINEBUFR - DB 03EH -L1CAB: DB 000H - OR A - JR Z,L1CBA ; (+00bH) - CALL L31A2 - CALL L3246 - CALL L31A7 - JR L1CC7 ; (+00dH) - -L1CBA: CALL MSGNL - LD A,(L1C4C) - DEC A - LD (L1C4C),A - CALL Z,L1CE4 -L1CC7: CALL BRKEY - JR Z,L1C85 ; (-047H) -L1CCC: CALL GETKY - CP 020H - JR Z,L1CCC ; (-007H) - CP 03FH - JR NZ,L1CDF ; (+008H) - LD BC,L2000 -L1CDA: DEC BC - LD A,B - OR C - JR NZ,L1CDA ; (-005H) -L1CDF: LD HL,(04A0EH) - JR L1C80 ; (-064H) - -L1CE4: INC A - LD (L1C4C),A - PUSH BC - LD BC,00001H -L1CEC: DEC BC - LD A,B - OR C - JR NZ,L1CEC ; (-005H) - POP BC - RET - -L1CF3: CALL L17F6 - LD (04AB3H),DE - CALL L193B - JR Z,L1D0A ; (+00bH) - CALL MATCHCHR - DB '-' - CALL L193B - RET Z - CALL L17F6 -L1D0A: LD (04AB5H),DE - CALL L193B - RET Z - JP SYNTAXERR - -CMDEND: DB 0AFH - DB 001H -L1D17: LD A,001H - EX AF,AF' - CALL L1AAF - EX AF,AF' - OR A - CALL Z,L1D24 - JR L1D41 ; (+01dH) - -L1D24: CALL L1C32 - LD A,001H - JP L29EB - -CMDSTOP: CALL L1AAF - CALL L1D24 - LD HL,(0504FH) - LD DE,L1D44 - CALL MSGX - CALL L1841 - CALL MSGX -L1D41: JP WARMSTRT - -L1D44: DB "*S",096H,0B7H,09EH," ",0A6H,0B0H,00DH -CMDRESTORE: CALL L17F6 - CALL L1C32 - LD BC,L1B35 - PUSH BC - LD A,D - OR E - JP Z,L145E - LD BC,L2D46 - PUSH BC -L1D60: EX DE,HL -L1D61: CALL L18B0 - PUSH DE - INC DE - RET Z - JP LINEERR - -CMDLET: PUSH HL -L1D6B: CALL L193B - JP Z,SYNTAXERR - CP 03DH - INC HL - JR NZ,L1D6B ; (-00bH) - CALL L2293 - LD (05051H),HL - CALL L1D95 - POP HL - CALL L267F - CALL L24B2 - CALL MATCHCHR - DB 03DH - CALL L1D9A - CALL L1DA5 - DW DATMISERR - JP L1B35 - -L1D95: LD HL,04900H - JR L1D9D ; (+003H) - -L1D9A: LD HL,04904H -L1D9D: LD (HL),C - INC HL - LD (HL),B - INC HL - LD (HL),E - INC HL - LD (HL),D - RET - -L1DA5: LD HL,04903H - LD B,(HL) - INC HL - LD C,(HL) - INC HL - LD A,(HL) - LD DE,(04906H) - OR A - JR NZ,L1DBD ; (+009H) - OR B - JP NZ,L177A - CALL L1936 - JR L1DF2 ; (+035H) - -L1DBD: XOR A - OR B - JP Z,L177A - LD HL,L1DF5 - XOR A - LD B,A - SBC HL,DE - JR Z,L1DFE ; (+033H) - LD HL,(04900H) - XOR A - SBC HL,BC - LD B,H - LD C,L - JR C,L1DDA ; (+005H) - CALL L1888 - JR L1DE2 ; (+008H) - -L1DDA: PUSH BC - CALL L1762 - CALL L1873 - POP BC -L1DE2: CALL L19C3 - LD HL,(04902H) - EX DE,HL - CALL L190E - EX DE,HL - DEC DE - DEC HL - INC BC - LDIR -L1DF2: JP L1784 - -L1DF5: JR NC,L1E27 ; (+030H) - DEC C - JR NC,L1E2A ; (+030H) - DEC C - JR NC,L1E2D ; (+030H) - DEC C -L1DFE: LD HL,(04902H) - EX DE,HL - CALL L190B - EX DE,HL - LD DE,L1DF5 - PUSH DE - LD B,003H -L1E0C: LD C,002H -L1E0E: CALL L176A - JR NC,L1E5D ; (+04aH) - LD (DE),A - INC DE - INC HL - DEC C - JR NZ,L1E0E ; (-00bH) - LD A,00DH - LD (DE),A - INC DE - DEC B - JR NZ,L1E0C ; (-014H) - CALL EXECNOTCHR - DB 00DH - DW ILDATERR - POP HL -L1E27: CALL L1E69 -L1E2A: LD B,000H - LD A,E -L1E2D: CP 018H - JR NC,L1E5D ; (+02cH) - SUB 00CH - JR C,L1E37 ; (+002H) - LD E,A - INC B -L1E37: LD A,B - PUSH AF - PUSH HL - LD HL,00E10H - CALL L17CF - POP HL - PUSH DE - INC HL - CALL L1E69 - LD A,E - CP 03CH - JR NC,L1E5D ; (+012H) - PUSH HL - LD HL,0003CH - CALL L17CF - POP HL - EX (SP),HL - ADD HL,DE - EX (SP),HL - INC HL - CALL L1E69 - LD A,E - CP 03CH -L1E5D: JR NC,L1E8E ; (+02fH) - POP HL - ADD HL,DE - EX DE,HL - POP AF - CALL ?TMST - JP L1784 - -L1E69: EXX - LD BC,00005H - CALL L1E7F - CALL L2333 - CALL L1926 - CALL L1A4E - OR C - INC DE - EXX - LD BC,0FFFBH -L1E7F: LD HL,(04E94H) - ADD HL,BC - LD (04E94H),HL - EXX - RET - -GETNUM: CALL L1E69 - LD A,D - OR A - RET Z -L1E8E: JP ILDATERR - -CMDRUN: XOR A - LD (L2A83),A - LD (L30E2),A - CALL L2E94 - CALL L145E - CALL L1459 - CALL L176A - JR NC,L1EAF ; (+009H) -CMDGOTO: CALL L17F6 -L1EA9: EX DE,HL -L1EAA: CALL L1D61 - JR L1EC4 ; (+015H) - -L1EAF: CALL L193B - JP NZ,SYNTAXERR - CALL L1991 - CALL L1978 - CALL L1996 - CALL L199E - LD HL,0505CH -L1EC4: JP L1B4D - -CMDGOSUB: CALL L1AAF - CALL L17F6 -L1ECD: CALL L1C32 - CALL L1D60 - EXX - LD HL,05055H - LD A,(HL) - CP 00FH - JP Z,GOSUBERR - INC (HL) - DEC HL - DEC HL - LD DE,(04E9AH) - DEC DE - LD BC,00007H - LDDR - INC DE - LD (04E9AH),DE - LD C,007H - ADD HL,BC - LD (HL),000H - EXX - JP L1B4D - -CMDRETURN: CALL L1AAF - LD HL,05055H - XOR A - CP (HL) - JP Z,RETGOSBERR - DEC (HL) -L1F04: LD HL,05053H - LD A,(HL) - OR A - JR Z,L1F1A ; (+00fH) - DEC (HL) - INC HL - DEC (HL) - LD HL,(04E98H) - LD BC,00013H - ADD HL,BC - LD (04E98H),HL - JR L1F04 ; (-016H) - -L1F1A: LD HL,(04E9AH) - LD DE,0504DH - LD BC,00007H - LDIR - LD (04E9AH),HL - JP L1B35 - -CMDFOR: CALL L267F - CALL MATCHCHR - DB 03DH ; = - PUSH DE - CALL L1FB7 - POP HL - LD (05040H),HL - EX DE,HL - CALL L24BD - CALL L1936 - CALL L17A0 - SBC A,(HL) - CALL L1FB7 - LD DE,05048H - CALL L1936 - CALL L1792 - SBC A,A - LD E,H - RRA - CALL L1FB7 - LD HL,(04E94H) - JR L1F5F ; (+003H) - - LD HL,L2A88 -L1F5F: LD DE,05042H - LD A,(HL) - LD (05047H),A - LD BC,00005H - LDIR - LD HL,(04E98H) - LD DE,(05040H) - LD A,(05053H) - INC A -L1F76: DEC A - JR Z,L1F98 ; (+01fH) - EX AF,AF' - LD A,(HL) - SUB E - LD B,A - INC HL - LD A,(HL) - SUB D - OR B - LD BC,PRNT - ADD HL,BC - JR Z,L1F8A ; (+003H) - EX AF,AF' - JR L1F76 ; (-014H) - -L1F8A: LD (04E98H),HL - EX AF,AF' - DEC A - LD HL,05053H - LD B,(HL) - LD (HL),A - SUB B - INC HL - ADD A,(HL) - LD (HL),A -L1F98: LD HL,05054H - LD A,(HL) - CP 00FH - JP Z,FORNEXTERR - INC (HL) - DEC HL - INC (HL) - DEC HL - LD DE,(04E98H) - LD BC,00013H - DEC DE - LDDR - INC DE - EX DE,HL - LD (04E98H),HL - JP L1B35 - -L1FB7: CALL L2333 - LD (05051H),HL - JP L1926 - -CMDNEXT: LD A,(05053H) - OR A -L1FC4: JP Z,NEXTFORERR - CALL L2640 - LD (05051H),HL - LD HL,(04E98H) - CALL NC,L2039 -L1FD3: LD A,E - SUB (HL) - INC HL - LD B,A - LD A,D - SUB (HL) - OR B - JR Z,L1FF1 ; (+015H) - EXX - LD HL,05053H - LD A,(HL) - DEC A - JR Z,L1FC4 ; (-020H) - LD (HL),A - INC HL - DEC (HL) - EXX - LD BC,PRNT - ADD HL,BC - LD (04E98H),HL - JR L1FD3 ; (-01eH) - -L1FF1: INC HL - CALL L24BD - PUSH DE - PUSH HL - CALL L3405 - POP HL - POP DE - LD BC,00005H - ADD HL,BC -L2000: LD A,(HL) - INC HL - PUSH HL - OR A - JP P,L201B - EX DE,HL - CALL L3A66 - POP HL - LD BC,00005H - JR C,L2025 ; (+014H) -L2011: ADD HL,BC - LD DE,0504DH - INC C - LDIR - JP L1B35 - -L201B: CALL L3A66 - POP HL - LD BC,00005H - CCF - JR C,L2011 ; (-014H) -L2025: LD C,00BH - ADD HL,BC - LD (04E98H),HL - LD HL,05053H - DEC (HL) - INC HL - DEC (HL) - CALL L1792 - INC L - DEC (HL) - DEC DE - JR CMDNEXT ; (-079H) - -L2039: LD E,(HL) - INC HL - LD D,(HL) - DEC HL - RET - -CMDON: CALL L1AAF - CALL L2333 - CALL L1926 - CALL L1A4E - DB 04CH - DB 020H - CALL MATCHCHR - DB 080H - SUB 08DH - CP 002H - JP NC,SYNTAXERR - EX AF,AF' - INC HL - LD A,E - OR A - JR Z,L2061 ; (+004H) - LD A,D - OR A - JR Z,L206F ; (+00eH) -L2061: JP CMDREMDATA - -L2064: CALL L193B - JP Z,L1B3B - CP ',' - INC HL - JR NZ,L2064 ; (-00bH) -L206F: DEC E - JR NZ,L2064 ; (-00eH) - CALL L17F6 - CALL L174F - EX AF,AF' - OR A - JP NZ,L1ECD - JP L1EA9 - -CMDDIM: CALL L267F - LD BC,MONIT - CP 024H - JR NZ,L208C ; (+002H) - INC HL - INC B -L208C: CALL MATCHCHR - DB 028H - CALL L2107 - JR NZ,L20E5 ; (+050H) - PUSH HL - LD HL,(L2105) - LD E,H - LD D,A - LD H,A - INC HL - INC DE - CALL L17AF - CP D - INC DE - LD A,(L2104) - OR A - POP HL - PUSH DE - PUSH HL - LD HL,00002H - JR NZ,L20B1 ; (+002H) - LD L,005H -L20B1: CALL L17AF - CP D - INC DE - LD HL,00004H - ADD HL,DE - JP C,MEMERR - LD B,H - LD C,L - POP DE - CALL L19C0 - LD HL,(L18D8) - EX DE,HL - LD (HL),E - INC HL - LD (HL),D - INC HL - LD DE,(02105H) - LD (HL),E - INC HL - LD (HL),D - INC HL - POP BC - LD A,(L2104) - OR A - JR Z,L20F0 ; (+016H) -L20DA: LD (HL),000H - INC HL - LD (HL),00DH - INC HL - DEC BC - LD A,B - OR C - JR NZ,L20DA ; (-00bH) -L20E5: LD HL,(L2102) - CALL EXECNOTCHR - DB ',' - DW L1B38 - JR CMDDIM ; (-070H) - -L20F0: EX DE,HL -L20F1: PUSH BC - LD HL,L2A8D - LD BC,00005H - LDIR - POP BC - DEC BC - LD A,B - OR C - JR NZ,L20F1 ; (-00fH) - JR L20E5 ; (-01dH) - -L2102: XOR (HL) - LD H,C -L2104: DB 001H -L2105: DB 00BH - DB 001H -L2107: PUSH DE - PUSH BC - CALL GETNUM - POP BC - LD A,(HL) - CP ',' - CALL Z,L2185 - CALL MATCHCHR - DB 029H - LD (L2102),HL - POP HL - LD (L18D8),HL - EX DE,HL - LD (L2105),HL - LD A,B - LD (L2104),A - LD HL,04E86H - LD DE,LETNL - OR A - JR Z,L2130 ; (+001H) - ADD HL,DE -L2130: LD A,C - LD E,002H - OR A - JR NZ,L2137 ; (+001H) - ADD HL,DE -L2137: LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL -L213B: CALL L18CE - LD L,(HL) - LD HL,L2E28 - LD E,(HL) - INC HL - PUSH HL - LD L,(HL) - LD D,000H - LD H,D - INC HL - INC DE - CALL L17CF - LD A,(L2104) - OR A - JR NZ,L215F ; (+00bH) - LD HL,00005H - CALL L17CF - POP HL - ADD HL,DE - INC HL - JR L213B ; (-024H) - -L215F: POP HL - INC HL - LD B,000H -L2163: LD C,(HL) - INC HL - INC HL - ADD HL,BC - DEC DE - LD A,D - OR E - JR NZ,L2163 ; (-009H) - JR L213B ; (-033H) - - XOR A - RET - - LD C,(HL) - INC HL - LD B,(HL) - INC HL - LD DE,(02105H) - LD A,B - CP D - JR C,L217E ; (+002H) - LD A,C - CP E -L217E: JP C,ILDATERR - LD A,001H - OR A - RET - -L2185: INC C - PUSH BC - PUSH DE - INC HL - CALL GETNUM - LD A,E - POP DE - LD D,A - POP BC - RET - -CMDPOKE: CALL L299F - CALL L2E94 - PUSH DE - CALL L299F - LD A,D - OR A - JP NZ,ILDATERR - EX (SP),HL - LD (HL),E - POP HL -L21A3: JP L1B38 - -CMDCLS: PUSH HL - CALL L1AF1 - POP HL - JR L21A3 ; (-00aH) - -CMDIF: CALL L1AAF - CALL EXECNOTCHR - DB 0AEH - DW L21D3 - CALL L2DBA - JP Z,SYNTAXERR - LD B,A - CALL L2712 - PUSH HL - LD A,B - CALL L2DC1 - RST 038H - RST 038H - LD BC,00008H - ADD HL,BC - LD A,(HL) - POP HL - OR A - JR NZ,L21E3 ; (+013H) -L21D0: JP L1B45 - -L21D3: CALL L2293 - CALL L1926 - LD IX,(04E94H) - BIT 7,(IX+004H) - JR Z,L21D0 ; (-013H) -L21E3: CALL MATCHCHR - ADD A,B - SUB 08CH - INC HL - CP 002H - JP Z,CMDGOSUB -L21EF: JP NC,SYNTAXERR - OR A - CALL Z,L21F9 - JP CMDGOTO - -L21F9: CALL L176A - RET C - POP BC - JP L1B7F - -CMDDEFFN: CALL SKIPSPACE - SUB 041H - CP 01AH - JR NC,L21EF ; (-01bH) - LD E,(HL) - INC HL - CALL MATCHCHR - DB 028H - SUB 041H - CP 01AH - JR NC,L21EF ; (-027H) - LD D,(HL) - INC HL - CALL MATCHCHR - DB 029H - CALL MATCHCHR - DB 03DH - PUSH HL - CALL L174F - POP BC - PUSH HL - XOR A - SBC HL,BC - PUSH BC - PUSH HL - LD HL,(04E84H) -L222E: LD A,(HL) - CP E - JR Z,L224D ; (+01bH) - OR A - JR Z,L223C ; (+007H) - INC HL - INC HL - CALL L1745 - JR L222E ; (-00eH) - -L223C: EX DE,HL - LD BC,GETL - CALL L19C0 - EX DE,HL - LD (HL),E - INC HL - LD (HL),D - INC HL - LD (HL),00DH - EX DE,HL - JR L225D ; (+010H) - -L224D: INC HL - LD (HL),D - INC HL - PUSH HL - CALL L174F - POP DE - XOR A - SBC HL,DE - LD B,H - LD C,L - CALL L19E7 -L225D: POP BC - POP HL - CALL L18A2 - CALL L19C3 - POP HL -L2266: JP L1B38 - -CMDMUSIC: CALL L193B - JR Z,L2266 ; (-008H) - CALL L2333 - CALL L193B - JR Z,L2277 ; (+001H) - INC HL -L2277: CALL L190B - CALL MELDY - JP C,L1438 - JR CMDMUSIC ; (-019H) - -CMDTEMPO: CALL GETNUM - LD A,E - DEC A - CP 007H - JP NC,ILDATERR - INC A - CALL XTEMP - JR L2266 ; (-02cH) - -L2292: INC HL -L2293: CALL L2333 -L2296: CP 03DH - JR NZ,L229C ; (+002H) - LD A,089H -L229C: CP 083H - RET C - CP 090H - RET NC - SUB 083H - EX AF,AF' - LD A,D - OR A - JR NZ,L22B4 ; (+00bH) - EX AF,AF' - EXX - LD BC,L2296 - LD DE,L2332 - JP L23BB - -L22B4: EX AF,AF' - PUSH DE - PUSH AF - CALL L2332 - POP AF - EX AF,AF' - EX (SP),HL - CALL L190B - LD A,C - PUSH AF - EX DE,HL - CALL L190B - POP AF - LD B,A - CALL L2305 - LD HL,L22F3 - PUSH HL - LD HL,L22E1 - EX AF,AF' - LD C,A - LD B,000H - ADD HL,BC - ADD HL,BC - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - EX AF,AF' - OR A - LD A,001H - JP (HL) - -L22E1: DW L231B - DW L231B - DW L231E - DW L231E - DW L2322 - DW L2322 - DW L2325 - DW L2328 - DW L232F -L22F3: LD DE,L2A92 - OR A - JR NZ,L22FC ; (+003H) - LD DE,L2A8D -L22FC: CALL L192C - POP HL - CALL L23FA - JR L2296 ; (-06fH) - -L2305: LD A,B - OR C - RET Z - LD A,C - CP B - JR NZ,L2315 ; (+009H) -L230C: LD A,(DE) - SUB (HL) - JR NZ,L2315 ; (+005H) - INC HL - INC DE - DJNZ L230C ; (-008H) - RET - -L2315: LD A,001H - DB 0D0H - LD A,080H - RET - -L231B: RET NZ - XOR A - RET - -L231E: RET Z - RET M - XOR A - RET - -L2322: RET P - XOR A - RET - -L2325: RET Z - XOR A - RET - -L2328: LD A,000H - RET Z - RET M - LD A,001H - RET - -L232F: RET M - XOR A - RET - -L2332: INC HL -L2333: LD A,(HL) - CP 020H - JR Z,L2332 ; (-006H) - CP '+' - JR Z,L2348 ; (+00cH) - CP '-' - JR NZ,L2349 ; (+009H) - CALL L2392 - CALL L2410 - JR L234C ; (+004H) - -L2348: INC HL -L2349: CALL L2393 -L234C: CP '+' - JR Z,L2356 ; (+006H) - CP '-' - RET NZ - LD A,00DH - DB 001H ; Create a dummy LD BC, to preserve A -L2356: LD A,00CH - EX AF,AF' - LD A,D - OR A - JR NZ,L2367 ; (+00aH) - EX AF,AF' - EXX - LD BC,L234C - LD DE,L2392 - JR L23BB ; (+054H) - -L2367: EX AF,AF' - CP 00CH - JP NZ,SYNTAXERR - PUSH DE - CALL L2392 - EX (SP),HL - PUSH DE - CALL L190B - LD A,C - PUSH AF - EX DE,HL - CALL L190B - POP AF - ADD A,C - JP C,STRLENERR - PUSH AF - EX DE,HL - CALL L18A2 - CALL L19C3 - POP AF - LD C,A - DEC DE - LD (DE),A - POP DE - POP HL - LD A,(HL) - JR L234C ; (-046H) - -L2392: INC HL -L2393: CALL L23AC -L2396: CP '/' - JR Z,L23A0 ; (+006H) - CP 02AH - RET NZ - LD A,00EH - DB 001H -L23A0: LD A,00FH - EXX - LD BC,L2396 - LD DE,L23AB - JR L23BB ; (+010H) - -L23AB: INC HL -L23AC: CALL L2402 -L23AF: CP 05EH - RET NZ - LD A,010H - EXX - LD BC,L23AF - LD DE,L2401 -L23BB: PUSH BC - LD HL,(04E94H) - LD BC,00005H - ADD HL,BC - LD (04E94H),HL - LD HL,L2691 - LD C,A - ADD HL,BC - ADD HL,BC - LD C,(HL) - INC HL - LD B,(HL) - PUSH BC - LD HL,L23DC - PUSH HL - PUSH DE - EXX - LD A,D - OR A - RET Z -L23D9: JP DATMISERR - -L23DC: LD A,D - OR A - JR NZ,L23D9 ; (-007H) - POP IY - PUSH HL - LD HL,(04E94H) - LD BC,0FFFBH - LD E,L - LD D,H - ADD HL,BC - LD (04E94H),HL - EX DE,HL - LD BC,L23F9 - PUSH BC - JP (IY) - -L23F6: CALL L192C -L23F9: POP HL -L23FA: LD BC,00005H - LD D,B - LD E,B - LD A,(HL) - RET - -L2401: INC HL -L2402: CALL SKIPSPACE - CP '+' - JR Z,L2425 ; (+01cH) - CP '-' - JR NZ,L2426 ; (+019H) - CALL L2425 -L2410: EXX - LD HL,(04E94H) - PUSH HL - LD BC,00004H - ADD HL,BC - LD A,(HL) - POP HL - OR A - JR Z,L2422 ; (+004H) - LD A,(HL) - ADD A,080H - LD (HL),A -L2422: EXX - LD A,(HL) - RET - -L2425: INC HL -L2426: CALL L2640 - JR NC,L2447 ; (+01cH) - LD A,046H - CP E - JR NZ,L2436 ; (+006H) - LD A,04EH - CP D - JP Z,L24F0 -L2436: CALL L24B2 - PUSH HL - LD A,B - OR A - JR Z,L23F6 ; (-048H) - EX DE,HL - LD B,000H - CALL L1A0E - POP HL - LD A,(HL) - RET - -L2447: CP 080H - JR C,L2481 ; (+036H) - CP 0FFH - JR Z,L24A8 ; (+059H) - CP 0C0H - JR C,L2472 ; (+01fH) - SUB 0C0H - PUSH AF - CALL L2332 - CALL L1926 - CALL MATCHCHR - DB 029H - POP AF - PUSH HL - LD HL,L23F9 - PUSH HL - LD HL,(04E94H) - EX DE,HL - LD HL,L26DB - PUSH HL - LD C,A - JP L1B95 - -L2472: SUB 0A0H - JR C,L248F ; (+019H) - LD C,A - CALL INCSKIPSPCE - PUSH HL - LD HL,L26B3 - JP L1B95 - -L2481: CP 028H - JR Z,L2492 ; (+00dH) - CP 022H - JP Z,L19F3 - CALL L1A97 - JR Z,L249E ; (+00fH) -L248F: JP SYNTAXERR - -L2492: LD BC,MONIT - CALL L185F - CALL L2292 - JP L2712 - -L249E: LD DE,(04E94H) - CALL L3670 - JP L23FA - -L24A8: CALL INCSKIPSPCE - PUSH HL - LD DE,L2A97 - JP L23F6 - -L24B2: LD A,(HL) - CP 024H - JP Z,L256F - CP 028H - JP Z,L25FE -L24BD: PUSH HL - LD HL,(04E8AH) - LD BC,00005H -L24C4: LD A,(HL) - CP E - INC HL - JR NZ,L24CD ; (+004H) - LD A,(HL) - CP D - JR Z,L24EB ; (+01eH) -L24CD: OR A - JR Z,L24D4 ; (+004H) - INC HL - ADD HL,BC - JR L24C4 ; (-010H) - -L24D4: LD C,007H - DEC HL - PUSH DE - EX DE,HL - LD HL,L2A8D - DEC HL - DEC HL - CALL L18A2 - CALL L19C3 - EX DE,HL - POP DE - LD (HL),E - INC HL - LD (HL),D - LD C,005H -L24EB: INC HL - EX DE,HL - POP HL - LD A,(HL) - RET - -L24F0: LD A,(HL) - SUB 041H - CP 01AH - JP NC,SYNTAXERR - LD E,(HL) - INC HL - CALL MATCHCHR - DB 028H - PUSH DE - CALL L2333 - CALL L1926 - CALL L2712 - POP DE - PUSH HL - LD HL,(04E84H) -L250D: LD A,(HL) - OR A - JP Z,UNDEFFNERR - CP E - JR Z,L251C ; (+007H) - INC HL - INC HL - CALL L1745 - JR L250D ; (-00fH) - -L251C: INC HL - LD E,(HL) - INC HL - PUSH HL - PUSH DE - LD D,020H - CALL L24BD - POP HL - PUSH DE - PUSH HL - LD HL,(04E96H) - LD DE,04E9CH - CALL L1773 - JP Z,FUNCERR - LD BC,0FFFAH - ADD HL,BC - LD (04E96H),HL - POP DE - LD (HL),E - INC HL - POP DE - LD BC,00005H - EX DE,HL - CALL L18A5 - EX DE,HL - LD HL,(04E94H) - CALL L18A5 - POP HL - CALL L2333 - CALL L1926 - CALL L193B - JP NZ,SYNTAXERR - LD HL,(04E96H) - LD E,(HL) - INC HL - LD D,020H - CALL L24BD - CALL L18A5 - ADD HL,BC - LD (04E96H),HL - JP L23F9 - -L256F: CALL INCSKIPSPCE - CP 028H - JP Z,L25F9 - PUSH HL - LD HL,04954H - XOR A - SBC HL,DE - JR Z,L25B2 ; (+032H) - EX DE,HL - LD (L18D8),HL - LD HL,(04E90H) -L2587: CALL L18CE - SUB (HL) - DEC H - JR Z,L25AA ; (+01cH) - LD B,000H - LD C,(HL) - ADD HL,BC - INC HL - INC HL - JR L2587 ; (-00fH) - - LD BC,00004H - EX DE,HL - LD HL,L18D8 - CALL L18A2 - CALL L19C3 - EX DE,HL - ADD HL,BC - DEC HL - LD (HL),00DH - DEC HL - LD (HL),B -L25AA: LD C,(HL) - INC HL - LD B,001H - EX DE,HL - POP HL - LD A,(HL) - RET - -L25B2: CALL TIMRD - EX DE,HL - OR A - JR Z,L25BB ; (+002H) - LD A,00CH -L25BB: EXX - LD HL,L1DF5 - PUSH HL - EXX - LD DE,0F1F0H - CALL L25D9 - LD DE,0FFC4H - CALL L25D8 - LD A,L - CALL L25E2 - POP DE - LD BC,00106H - POP HL - LD A,(HL) - RET - -L25D8: XOR A -L25D9: ADD HL,DE - JR NC,L25DF ; (+003H) - INC A - JR L25D9 ; (-006H) - -L25DF: OR A - SBC HL,DE -L25E2: LD BC,L30F6 -L25E5: ADD A,C - JR NC,L25EB ; (+003H) - INC B - JR L25E5 ; (-006H) - -L25EB: ADD A,03AH - EX AF,AF' - LD A,B - EXX - LD (HL),A - INC HL - EX AF,AF' - LD (HL),A - INC HL - LD (HL),00DH - EXX - RET - -L25F9: LD BC,00100H - JR L2601 ; (+003H) - -L25FE: LD BC,MONIT -L2601: INC HL - CALL L2107 - JP Z,ILDATERR - PUSH HL - LD L,C - LD H,000H - LD C,E - LD E,D - LD B,H - LD D,H - PUSH BC - INC HL - CALL L17CF - POP HL - ADD HL,DE - EX DE,HL - LD A,(L2104) - OR A - JR NZ,L262B ; (+00dH) - LD HL,00005H - CALL L17CF - POP HL - ADD HL,DE - LD BC,00005H - JR L263A ; (+00fH) - -L262B: POP HL - LD B,000H -L262E: LD C,(HL) - INC HL - LD A,D - OR E - JR Z,L2639 ; (+005H) - ADD HL,BC - INC HL - DEC DE - JR L262E ; (-00bH) - -L2639: INC B -L263A: EX DE,HL - LD HL,(L2102) - LD A,(HL) - RET - -L2640: CALL SKIPSPACE - LD BC,L411A - SUB B - CP C - LD A,(HL) - RET NC - LD E,A - LD D,020H -L264D: INC HL - LD A,(HL) - CP D - JR Z,L264D ; (-005H) - SUB B - CP C - JR C,L265A ; (+004H) - SUB 0EFH - CP 00AH -L265A: LD A,(HL) - CCF - RET C - LD D,A - CP 04EH - JR NZ,L2667 ; (+005H) - LD A,046H - CP E - JR Z,L267A ; (+013H) -L2667: INC HL - LD A,(HL) - CP 020H - JR Z,L2667 ; (-006H) - SUB B - CP C - JR C,L2667 ; (-00aH) - SUB 0EFH - CP 00AH - JR C,L2667 ; (-010H) -L2677: LD A,(HL) - SCF - RET - -L267A: CALL INCSKIPSPCE - SCF - RET - -L267F: CALL L2640 - JR NC,L268E ; (+00aH) - LD A,046H - CP E - JR NZ,L268C ; (+003H) - LD A,04EH - CP D -L268C: JR NZ,L2677 ; (-017H) -L268E: JP SYNTAXERR - -L2691: DW L3B62 - DW L3B62 - DW L3B87 - DW L3B87 - DW L3B8B - DW L3B8B - DW L3B7F - DW L3B73 - DW L3B77 - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW L3405 - DW L3403 - DW L3500 - DW L35D0 - DW L4159 -L26B3: DW L26F3 - DW L270F - DW L273E - DW L2765 - DW L2772 - DW L277F - DW L27B4 - DW L279A - DW L27F9 - DW L2801 - DW L2804 - DW L2895 - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW L2824 - DW SYNTAXERR - DW L2841 - DW L287C - DW SYNTAXERR -L26DB: DW L3B98 - DW L3C16 - DW L3D05 - DW L3D14 - DW L4076 - DW L3E03 - DW L3A86 - DW L4064 - DW L3F35 - DW L289D - DW L28A2 - DW L3D3F -L26F3: DB 0CDH - DB 033H - DB 023H - DB 0CDH - DB 094H - DB 02EH -L26F9: PUSH DE - CALL GETNUM - CALL L2712 - EX (SP),HL - PUSH HL - EX DE,HL - CALL L190B - LD A,C - SUB L - JR C,L273A ; (+030H) - PUSH HL - LD C,A - ADD HL,DE - JR L2732 ; (+023H) - -L270F: DB 0CDH -L2710: DB 017H - DB 027H -L2712: CALL MATCHCHR - DB 029H - RET - - CALL L2333 - CALL L2E94 - PUSH DE - CALL GETNUM - JR L2724 ; (+001H) - -L2723: PUSH BC -L2724: EX (SP),HL - PUSH HL - EX DE,HL - CALL L190B - LD A,C - SUB L - JR C,L273A ; (+00cH) - PUSH HL - LD C,A - LD L,E - LD H,D -L2732: EX DE,HL - CALL L19E7 - POP BC - DEC HL - LD (HL),C - INC HL -L273A: POP DE - POP HL - LD A,(HL) - RET - -L273E: CALL L2333 - CALL L2E94 - PUSH DE - PUSH BC - CALL GETNUM - POP BC - LD A,E - OR A - JP Z,ILDATERR - LD A,C - SUB E - JR NC,L2755 ; (+002H) - LD A,PRTD -L2755: INC A - LD E,A - POP BC - CALL L2723 - CALL L2E94 - CP '-' - JR NZ,L26F9 ; (-069H) - INC HL - JR L2712 ; (-053H) - -L2765: CALL L2333 - CALL L190B - CALL L2712 - PUSH HL - LD A,C - JR L27C4 ; (+052H) - -L2772: CALL L299F - CALL L2712 - LD A,E - LD BC,00001H - JP L280F - -L277F: CALL L2333 - CALL L1926 - CALL L2712 - PUSH HL - LD HL,(04E94H) - LD DE,04AB3H - PUSH DE - CALL L38BB - POP HL - CALL L19F3 - POP HL - LD A,(HL) - RET - -L279A: CALL L2333 - CALL L190B - CALL L2712 - PUSH HL - EX DE,HL - JR L27AA ; (+003H) - - LD HL,L27B2 -L27AA: CALL L1A75 - AND A - DAA - POP HL - LD A,(HL) - RET - -L27B2: DB 030H - DB 00DH -L27B4: CALL L2333 - CALL L190B - CALL L2712 - LD A,C - OR A - JP Z,ILDATERR -L27C2: LD A,(DE) - PUSH HL -L27C4: LD E,A - LD D,000H -L27C7: CALL L27CD - POP HL - LD A,(HL) - RET - -L27CD: LD B,080H - LD A,D - OR E - JR Z,L27E7 ; (+014H) - LD B,0D0H - LD A,D - OR A - JR NZ,L27DE ; (+005H) - LD B,0C8H - LD D,E - LD E,000H -L27DE: EX DE,HL -L27DF: BIT 7,H - JR NZ,L27E6 ; (+003H) - ADD HL,HL - DJNZ L27DF ; (-007H) -L27E6: EX DE,HL -L27E7: LD HL,(04E94H) - LD (HL),B - INC HL - CALL L19BA - LD (HL),E - INC HL - LD (HL),D - LD BC,00005H - LD DE,MONIT - RET - -L27F9: CALL L299F - CALL L2712 - JR L27C2 ; (-03fH) - -L2801: JP SYNTAXERR - -L2804: CALL GETNUM - CALL L2712 - LD A,020H - LD C,E - LD B,000H -L280F: PUSH HL - PUSH AF - CALL L1A1E - POP AF - PUSH DE - PUSH BC - LD B,C - INC B - JR L281D ; (+002H) - -L281B: LD (HL),A - INC HL -L281D: DJNZ L281B ; (-004H) - POP BC - POP DE - POP HL - LD A,(HL) - RET - -L2824: CALL L2333 - CALL L2E94 - PUSH DE - CALL GETNUM - CALL L2712 - EX (SP),HL - PUSH DE - EX DE,HL - CALL L190B - LD A,C - OR A - JP Z,ILDATERR - LD A,(DE) - POP BC - POP HL - JR L280F ; (-032H) - -L2841: CALL L1E69 - LD A,E - CP 028H -L2847: JP NC,ILDATERR - PUSH AF - CALL MATCHCHR - DB ',' - CALL GETNUM - CALL MATCHCHR - DB 029H - LD A,E - CP 019H - JR NC,L2847 ; (-014H) - POP AF - LD C,A - LD B,E - INC B - PUSH HL - LD HL,(PAGETP) - LD D,000H - LD E,028H - XOR A - SBC HL,DE -L286A: ADD HL,DE - DJNZ L286A ; (-003H) - ADD HL,BC - CALL L2878 - POP HL - LD BC,00001H - JP L280F - -L2878: LD A,(HL) - JP ?DACN - -L287C: CALL EXECNOTCHR - DB 056H - DW L288C - LD A,(01172H) -L2885: LD D,000H - LD E,A - PUSH HL - JP L27C7 - -L288C: CALL MATCHCHR - DB 048H - LD A,(DSPXY) - JR L2885 ; (-010H) - -L2895: PUSH HL - CALL L184A - EX DE,HL - JP L27C7 - -L289D: LD A,(DE) - OR 080H - LD (DE),A - RET - -L28A2: LD A,(DE) - LD DE,L192C - PUSH DE - LD DE,L2A92 - OR A - RET P - LD DE,L2A88 - CP 080H - RET NZ - LD DE,L2A8D - RET - -CMDMON: JP MONIT - -CMDCURSOR: CALL GETNUM - LD A,E - CP 028H -L28BF: JP NC,ILDATERR - PUSH AF - CALL MATCHCHR - DB ',' - CALL GETNUM - LD A,E - CP 019H - JR NC,L28BF ; (-010H) - PUSH HL - LD HL,(DSPXY) - LD A,E - SUB H - LD H,A - LD A,(MGPNT) - JP M,L28F8 - ADD A,H - SUB 032H - JR NC,L28E3 ; (+002H) - ADD A,032H -L28E3: LD (MGPNT),A - EX DE,HL - LD H,L - POP DE - POP AF - LD L,A - LD (DSPXY),HL - NOP - NOP - NOP - LD (DPRNT),A - EX DE,HL - JP L1B38 - -L28F8: ADD A,H - JP P,L28E3 - ADD A,032H - JR L28E3 ; (-01dH) - - NOP - NOP -CMDGET: CALL L267F - CALL L24B2 - LD (05051H),HL - CALL L1D9A - CALL GETKY - PUSH AF - LD A,(04905H) - OR A - JR Z,L292D ; (+015H) - POP AF - LD BC,MONIT - OR A - JR Z,L2920 ; (+001H) - INC BC -L2920: CALL L280F -L2923: CALL L1D95 - CALL L1DA5 - DW DATMISERR - JR L2998 ; (+06bH) - -L292D: POP AF - LD DE,MONIT - CALL L2939 -L2934: CALL L27CD - JR L2923 ; (-016H) - -L2939: OR A - RET Z - SUB 030H - CP 00AH - RET NC - LD E,A - RET - -CMDUSRN: CALL L299F - PUSH DE - CALL EXECNOTCHR - DB ',' - DW L2959 - CALL L267F - CALL L24B2 - LD A,B - OR A - JP Z,DATMISERR - LD B,000H -L2959: CALL L2712 - LD (05051H),HL - CALL L13FA - LD HL,L1B35 - EX (SP),HL - JP (HL) - -CMDLIMIT: LD DE,L299B - CALL L14C7 - JR NZ,L2977 ; (+008H) - LD (05051H),HL - LD HL,(04908H) - JR L2994 ; (+01dH) - -L2977: CALL L299F - LD (05051H),HL - LD HL,(04908H) - CALL L1773 - JP C,ILDATERR - LD HL,(04E94H) - LD BC,000C8H - ADD HL,BC - CALL L1773 - JP NC,BADWRERR - EX DE,HL -L2994: LD (0490AH),HL - LD SP,HL -L2998: JP L1B35 - -L299B: LD C,L - LD B,C - RET C - NOP -L299F: CALL EXECNOTCHR - DB 024H - DW L29CB - LD DE,MONIT -L29A8: CALL L176A - JR NC,L29C2 ; (+015H) -L29AD: AND 00FH - LD C,A - LD B,000H - LD A,D - AND 0F0H - JP NZ,ILDATERR - EX DE,HL - ADD HL,HL - ADD HL,HL - ADD HL,HL - ADD HL,HL - ADD HL,BC - EX DE,HL - INC HL - JR L29A8 ; (-01aH) - -L29C2: SUB 041H - CP 006H - RET NC - ADD A,00AH - JR L29AD ; (-01eH) - -L29CB: JP L1E69 - -CMDCONT: CALL L1AA7 - LD A,(L1463) - OR A - JP Z,CONTERR - PUSH AF - XOR A - CALL L29EB - POP AF - LD HL,(05051H) - OR A - JP M,L2C56 - DEC A - JR Z,L2998 ; (-050H) - JP L1B5F - -L29EB: LD (L1463),A - LD DE,L1464 - LD BC,LETNL - LD HL,0504DH - OR A - JR NZ,L29FB ; (+001H) - EX DE,HL -L29FB: LDIR - RET - -CMDINP: CALL GETNUM - CALL L2E94 - LD A,E - LD (L2A15),A - CALL L267F - CALL L24B2 - LD (05051H),HL - CALL L1D9A - DB 0DBH -L2A15: DB 0FFH - LD E,A - LD D,000H - JP L2934 - -CMDOUT: CALL GETNUM - CALL L2E94 - LD A,E - LD (L2A2B),A - CALL GETNUM - LD A,E - DB 0D3H -L2A2B: DB 0FFH -L2A2C: JP L1B38 - -CMDAUTO: CALL L1AA7 - CALL L193B - JR Z,L2A5F ; (+028H) - CALL EXECNOTCHR - DB ',' - DW L2A3F - JR L2A71 ; (+032H) - -L2A3F: CALL L2A7A - LD (02A84H),DE - CALL L193B - JR Z,L2A6C ; (+021H) - CALL EXECNOTCHR - DB ',' - DW SYNTAXERR -L2A51: CALL L2A7A - LD (02A86H),DE -L2A58: LD A,001H - LD (L2A83),A - JR L2A2C ; (-033H) - -L2A5F: LD DE,0000AH - LD (02A84H),DE -L2A66: LD (02A86H),DE - JR L2A58 ; (-014H) - -L2A6C: LD DE,0000AH - JR L2A66 ; (-00bH) - -L2A71: LD DE,0000AH - LD (02A84H),DE - JR L2A51 ; (-029H) - -L2A7A: CALL L1E69 - LD A,D - OR E - RET NZ - JP SYNTAXERR - -L2A83: DB 000H -L2A84: DB 00AH - DB 000H - DB 00AH - DB 000H -L2A88: DB 0C1H - DB 000H - DB 000H - DB 000H - DB 080H -L2A8D: DB 080H - DB 000H - DB 000H - DB 000H - DB 000H -L2A92: DB 041H - DB 000H - DB 000H - DB 000H - DB 080H -L2A97: DB 0C2H - DB 0A1H - DB 0DAH - DB 00FH - DB 0C9H - AND 00FH - ADD A,030H - CP ':' - RET C - ADD A,007H - RET - -CMDSET: LD A,001H - JR L2AAB ; (+001H) - -CMDRESET: XOR A -L2AAB: PUSH AF - CALL GETNUM - PUSH DE - CALL MATCHCHR - DB ',' - CALL GETNUM - LD (05051H),HL - LD A,E -L2ABB: SUB 032H - JR NC,L2ABB ; (-004H) - ADD A,032H - LD E,A - POP BC - LD A,C -L2AC4: SUB 050H - JR NC,L2AC4 ; (-004H) - ADD A,050H - LD C,A - XOR A - SRL C - JR NC,L2ADE ; (+00eH) - SRL E - JR NC,L2AD8 ; (+004H) - ADD A,004H -L2AD6: ADD A,002H -L2AD8: ADD A,001H -L2ADA: ADD A,001H - JR L2AE4 ; (+006H) - -L2ADE: SRL E - JR NC,L2ADA ; (-008H) - JR L2AD6 ; (-00eH) - -L2AE4: PUSH AF - LD HL,(PAGETP) - LD A,028H -L2AEA: ADD HL,DE - DEC A - JR NZ,L2AEA ; (-004H) - ADD HL,BC - RES 3,H - LD A,(HL) - CP 0F0H - JR NC,L2AF8 ; (+002H) - LD A,0F0H -L2AF8: POP BC - LD C,A - POP AF - OR A - LD A,B - JR Z,L2B02 ; (+003H) - OR C - JR L2B04 ; (+002H) - -L2B02: CPL - AND C -L2B04: CP 0F0H - JR NZ,L2B09 ; (+001H) - XOR A -L2B09: LD (HL),A - JP L1B35 - -CMDPRINT: CALL EXECNOTCHR ; Check to see if a stream, ie. /T = Tape is given. The 02FH below is / and the function after is called if it doesnt match /. - DB '/' ; Execute below function IFF first non-space character after PRINT command is not a / - DW L2B18 - CALL L2E9B - JR L2B1E ; (+006H) - -L2B18: CALL L2DBA - CALL L2E94 -L2B1E: CALL L193B - JR NZ,L2B2F ; (+00cH) - LD (05051H),HL -L2B26: LD HL,L2BEF - CALL L2BE3 - JP L1B35 - -L2B2F: CALL EXECNOTCHR - DB 03BH - DW L2B35 -L2B35: LD BC,L2B4D - PUSH BC - CP ',' - RET NZ - INC HL - LD A,(04DD4H) - OR A - RET P - AND 07FH - JP Z,PRNTT - CP 002H - RET NZ - JP L326E - -L2B4D: CALL L193B - LD (05051H),HL - JP NZ,L2B60 - LD A,(04DD4H) - OR A - JP M,L1B35 - JP L2B26 - -L2B60: CP 03BH - JR Z,L2B66 ; (+002H) - CP ',' -L2B66: JP Z,L2B2F - CALL EXECNOTCHR - DB 0A9H - DW L2B9A - CALL GETNUM - CALL MATCHCHR - DB 029H - LD D,013H - LD A,(DPRNT) - LD B,A - LD A,(04DD4H) - CP 080H - JR Z,L2B8D ; (+00aH) - LD D,020H - CP 082H - JR NZ,L2BBD ; (+034H) - LD A,(L32D3) - LD B,A -L2B8D: LD A,E - SUB B - JR C,L2B2F ; (-062H) - LD C,A - LD B,000H - LD A,D - CALL L280F - JR L2B9D ; (+003H) - -L2B9A: CALL L2293 -L2B9D: PUSH HL - LD HL,LINEBUFR - LD A,D - OR A - CALL Z,L2BC0 - CALL NZ,L2BD0 - LD HL,L2BF7 - CALL L2BE3 - LD HL,L2B1E - EX (SP),HL - CALL L193B - RET Z - CP 03BH - RET Z - CP ',' - RET Z -L2BBD: JP SYNTAXERR - -L2BC0: PUSH AF - PUSH HL - EX DE,HL - LD HL,(04E94H) - CALL L38BB - POP HL - CALL L18FD - JP L2BD9 - -L2BD0: PUSH AF - CALL L190B - EX DE,HL - CALL L18A5 - EX DE,HL -L2BD9: DEC HL - LD (HL),C - INC HL - PUSH HL - ADD HL,BC - LD (HL),00DH - POP DE - POP AF -L2BE2: RET - -L2BE3: LD A,(04DD4H) - ADD A,080H - CALL L13FA - CALL L2E12 - JP (HL) - -L2BEF: LD B,000H - XOR E - INC DE - AND A - LD SP,L2BE2 -L2BF7: DEC D - NOP - XOR E - INC DE - OR H - LD SP,L3064 -CMDINPUT: CALL L1AAF - CALL EXECNOTCHR - DB '/' - DW L2C0E - CALL L2E9B - JP L2C62 - -L2C0E: CALL L2DBA - CALL SKIPSPACE - CP 022H - LD DE,L2C5F - JR NZ,L2C25 ; (+00aH) - CALL L2333 - CALL MATCHCHR - DB 03BH - CALL L190B -L2C25: LD (05051H),HL -L2C28: CALL MSG - LD A,(DPRNT) - LD B,A - LD L,A - LD H,000H - LD DE,LINEBUFR - ADD HL,DE - LD (L2C8C),HL - CALL GETL - EX DE,HL - LD A,(HL) - CP 01BH - JR NZ,L2C4A ; (+008H) - LD A,080H - CALL L29EB - JP L1438 - -L2C4A: INC B - LD A,00DH -L2C4D: CP (HL) - JR Z,L2C56 ; (+006H) - INC HL - DJNZ L2C4D ; (-006H) - JP L2C8E - -L2C56: CALL NL - LD DE,L2C5F - JP L2C28 - -L2C5F: CCF - JR NZ,L2C6F ; (+00dH) -L2C62: CALL L2E94 - LD (05051H),HL -L2C68: LD DE,LINEBUFR - PUSH DE - LD HL,L2C84 -L2C6F: CALL L2BE3 - POP HL - DEC HL - LD (HL),C - INC HL - LD A,B - OR A - JP NZ,STRLENERR - CALL L1A0E - LD HL,L2C68 - JP L2CC8 - -L2C84: XOR E - INC DE - XOR E - INC DE - XOR E - INC DE - ADC A,A - DB 030H -L2C8C: DB 00FH - DB 049H -L2C8E: LD A,(04DD4H) - CP 081H - JP Z,L2D1D - LD HL,(L2C8C) - CALL L18FD - LD DE,LINEBUFR - PUSH DE - INC BC - LDIR - POP HL - LD (L2C8C),HL - CALL SKIPSPACE - CP 00DH - JP Z,L2C56 - CALL EXECNOTCHR - DB ',' - DW L2CBF - PUSH HL - LD DE,L2D11 - CALL L19F3 - POP HL - JR L2CC2 ; (+003H) - -L2CBF: CALL L19F3 -L2CC2: LD (L2C8C),HL - LD HL,L2C8E -L2CC8: PUSH HL - CALL L1D95 - LD HL,(05051H) - CALL L267F - CALL L24B2 - LD (05051H),HL - CALL L1D9A -L2CDB: CALL L1DA5 - DW L2CF4 - LD HL,(05051H) - CALL L193B - JR NZ,L2CEC ; (+004H) - POP AF - JP L1B35 - -L2CEC: CALL MATCHCHR - DB ',' - LD (05051H),HL - RET - -L2CF4: LD DE,(04902H) - CALL L190B - EX DE,HL - CALL EXECNOTCHR - DB 00DH - DW L2D05 - LD HL,L2D10 -L2D05: CALL L1A75 - OR H - INC DE - CALL L1D95 - JP L2CDB - -L2D10: DB 030H -L2D11: DB 00DH -CMDREAD: LD (05051H),HL - LD A,081H - LD (04DD4H),A - CALL L1AAF -L2D1D: LD A,(05059H) - OR A - CALL Z,L2D43 - LD HL,(0505AH) - CALL L193B - JR NZ,L2D32 ; (+006H) - CALL L2D6B - JP L2D1D - -L2D32: CALL L19F3 - CALL L2E94 - LD (0505AH),HL - LD HL,LINEBUFR - LD (HL),00DH - JP L2CC2 - -L2D43: LD HL,0505CH -L2D46: XOR A - LD (05059H),A -L2D4A: LD A,(HL) - INC HL - OR (HL) - INC HL - JP Z,READDATAERR - INC HL - INC HL -L2D53: CALL EXECNOTCHR - DB 080H - DW L2D68 - CALL EXECNOTCHR - DB 081H - DW L2D68 - LD (0505AH),HL - LD A,001H - LD (05059H),A - RET - -L2D68: CALL L174F -L2D6B: INC HL - CP ':' - JP Z,L2D53 - JP L2D4A - -L2D74: DB 001H -CMDLOAD: CALL EXECNOTCHR - DB '/' - DW L2EDA - CALL MATCHCHR - DB 'T' - JP L2EDA - -CMDSAVE: CALL L1AA7 - CALL EXECNOTCHR - DB '/' - DW L2FE0 - CALL MATCHCHR - DB 'T' - JP L2FE0 - -CMDROPEN: CALL EXECNOTCHR - DB '/' - DW L311E - CALL MATCHCHR - DB 'T' - JP L311E - -CMDWOPEN: CALL EXECNOTCHR - DB '/' - DW L30E5 - CALL MATCHCHR - DB 'T' - JP L30E5 - - NOP -CMDCLOSE: CALL EXECNOTCHR - DB '/' - DW L3171 - CALL MATCHCHR - DB 'T' - JP L3171 - -L2DBA: LD A,080H - LD (04DD4H),A - OR A - RET - -L2DC1: LD HL,04DF2H - LD DE,NL - LD B,00AH -L2DC9: CP (HL) - JR Z,L2DD2 ; (+006H) - ADD HL,DE - DJNZ L2DC9 ; (-006H) - JP L177A - -L2DD2: LD A,00AH - SUB B - JP L1784 - -L2DD8: LD A,B - OR C - JR Z,L2DDE ; (+002H) - INC BC - INC BC -L2DDE: LD E,(HL) - INC HL - LD D,(HL) - DEC HL - PUSH HL - LD H,B - LD L,C - CALL L1773 - POP HL - JR Z,L2DF7 ; (+00cH) - EX DE,HL - PUSH BC - LD C,L - LD B,H - CALL L19E7 - POP BC - CALL L19C0 - EX DE,HL -L2DF7: LD D,H - LD E,L - LD A,C - OR B - RET Z - LD (HL),C - INC HL - LD (HL),B - DEC HL - DEC BC - DEC BC - RET - - CALL L2DD8 - INC HL - INC HL - RET - -L2E09: PUSH BC - LD BC,MONIT - CALL L2DD8 - POP BC - RET - -L2E12: ADD A,A - ADD A,L - LD L,A - JR NC,L2E18 ; (+001H) - INC H -L2E18: LD A,(HL) - INC HL - LD H,(HL) - LD L,A - RET - -L2E1D: LD DE,CMTFNAME ; Compare loaded filename against name given by user. - PUSH HL - INC HL - LD B,010H -L2E24: LD A,(DE) - CP (HL) - JR NZ,L2E31 ; (+009H) -L2E28: INC HL - INC DE - CP 00DH - JR Z,L2E31 ; (+003H) - DEC B - JR NZ,L2E24 ; (-00dH) -L2E31: POP HL - RET - -CMTBUF: DB 002H -CMTFNAME: DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - PUSH HL - LD HL,GETL - LD (04DD6H),HL - LD HL,04DD8H - LD B,005H -L2E5F: LD (HL),000H - INC HL - DJNZ L2E5F ; (-005H) - LD HL,CMTFNAME - LD B,011H -L2E69: LD (HL),00DH - INC HL - DJNZ L2E69 ; (-005H) - LD B,00EH -L2E70: LD (HL),000H - INC HL - DJNZ L2E70 ; (-005H) - POP HL - CALL L2E94 - CALL L2333 - LD A,D - OR A - JP Z,UNKNWNERR - LD A,C - DEC A - CP 010H - JP NC,UNKNWNERR - PUSH HL - CALL L190B - LD HL,CMTFNAME - EX DE,HL - LDIR - POP HL - RET - -L2E94: CALL EXECNOTCHR - DB ',' - DW L2E9A -L2E9A: RET - -L2E9B: LD B,000H - LD DE,L2EB0 - CALL L14C9 - JP NZ,SYNTAXERR - CALL L2E94 - LD A,B - ADD A,082H - LD (04DD4H),A - RET - -L2EB0: DB 0D0H - DB 0D4H - DB 000H -CMDVERIFY: CALL L1AA7 - XOR A - JR L2EDC ; (+023H) - -L2EB9: LD A,(ATRB) - CP 002H - JR NZ,L2EE6 ; (+026H) - CALL L2F62 - CALL L1B1B - CALL ?VRFY - PUSH AF - CALL L1AC7 - POP AF - JP C,L30B3 - LD DE,L2FDD - CALL MSGNL - JP L1B35 - -L2EDA: LD A,001H -L2EDC: LD (L2D74),A - LD BC,L2EE6 - PUSH BC - JP L2FE4 - -L2EE6: CALL QRDI ; Original ?RDI call - JP C,L30B3 - CALL L2F67 - LD HL,ATRB - LD A,(HL) - OR A - JR Z,L2EE6 ; (-010H) - CP 004H - JR NC,L2EE6 ; (-014H) - LD DE,CMTFNAME - LD A,(DE) - CP 00DH - JR Z,L2F07 ; (+005H) - CALL L2E1D - JR NZ,L2EE6 ; (-021H) -L2F07: LD A,(L2D74) - OR A - JR Z,L2EB9 ; (-054H) - LD A,(ATRB) - CP 001H - JP Z,L2F8E - CP 002H - JR NZ,L2EE6 ; (-033H) - CALL L1944 - LD HL,(SIZE) - DEC HL - DEC HL - LD C,L - LD B,H - LD DE,0505CH - CALL L1888 - CALL L19C3 - LD (DTADR),DE - CALL L2F6C - CALL QRDD ; Original ?RDD call - JR C,L2F3E ; (+006H) - CALL L1ABF - JP L1B35 - -L2F3E: PUSH AF - CALL L2F4B - POP AF - PUSH AF - CALL L1944 - POP AF - JP L30B3 - -L2F4B: LD DE,0505EH - LD HL,04E4EH - XOR A - SBC HL,DE - RET Z - LD C,L - LD B,H - DEC DE - DEC DE - CALL L1873 - CALL L1762 - JP L19C3 - -L2F62: LD DE,L2FD2 - JR L2F6F ; (+008H) - -L2F67: LD DE,L2FC2 - JR L2F6F ; (+003H) - -L2F6C: LD DE,L2FC9 -L2F6F: CALL MSGNL - LD DE,NAME - LD A,(DE) - CP 00DH - RET Z - PUSH DE - CALL L2F86 - POP DE - LD A,00DH - LD (01101H),A - CALL MSGX -L2F86: LD DE,L2F8C - JP MSGX - -L2F8C: DB 022H - DB 00DH -L2F8E: LD HL,(DTADR) - EX DE,HL - LD HL,(0490AH) - DEC HL - CALL L1773 - JR NC,L2FB6 ; (+01bH) - LD HL,(SIZE) - ADD HL,DE - JR C,L2FBC ; (+01bH) - EX DE,HL - LD HL,(04908H) - CALL L1773 - JR C,L2FBC ; (+012H) - CALL L2F6C - CALL QRDD ; Original ?RDD call - JP C,L30B3 - JP L1B35 - -L2FB6: CALL MSTOP - JP BADWRERR - -L2FBC: CALL MSTOP - JP MEMERR - -L2FC2: DB "F",0B7H,0A5H,0B0H,09CH," " - DB 00DH -L2FC9: DB "L",0B7H,0A1H,09CH,0A6H,0B0H,097H," " - DB 00DH -L2FD2: DB "V",092H,09DH,0A6H,0AAH,0BDH,0A6H,0B0H,097H," " - DB 00DH -L2FDD: DB "OK" - DB 00DH -L2FE0: LD BC,L3038 - PUSH BC -L2FE4: CALL EXECNOTCHR - DB ',' - DW L2FEA -L2FEA: PUSH HL - LD HL,CMTBUF - LD (HL),002H -L2FF0: LD B,011H -L2FF2: INC HL - LD (HL),00DH - DJNZ L2FF2 ; (-005H) - CALL L1459 - POP HL - CALL L193B ; Skip space to CR, ':' or char. - LD (05051H),HL - RET Z ; CR or ':' return. - CALL L2333 - CALL L193B ; Skip space to CR, ':' or char. - JP NZ,SYNTAXERR - LD (05051H),HL - LD A,D - OR A - JP Z,UNKNWNERR - CALL L190B - LD A,C - OR A - RET Z - CP 011H - JP NC,UNKNWNERR - EX DE,HL - LD DE,CMTFNAME - LDIR - RET - -L3025: LD DE,ATRB - LD HL,CMTBUF - LD BC,PRNT - LDIR - LD B,06EH -L3032: XOR A - LD (DE),A - INC DE - DJNZ L3032 ; (-005H) - RET - -L3038: CALL L3025 - LD HL,0505CH - LD (DTADR),HL - LD DE,0505CH - LD HL,(04E4EH) - XOR A - SBC HL,DE - LD (SIZE),HL - CALL QWRI ; Original ?WRI call - JP C,L30B8 - CALL L1B1B - CALL QWRD ; Original ?WRD call - PUSH AF - CALL L1ABF - POP AF - JP C,L30B8 - JP WARMSTRT - -L3064: CALL L1459 - LD A,(L30E2) - CP 001H - JR NZ,L309A ; (+02cH) - LD HL,(L30E3) -L3071: PUSH DE - LD DE,04DD3H - CALL L1773 - JR C,L3082 ; (+008H) - CALL QWRD ; Original ?WRD call - JR C,L30B8 ; (+039H) - LD HL,04CD3H -L3082: POP DE - LD A,(DE) - LD (HL),A - INC HL - INC DE - CP 00DH - JR NZ,L3071 ; (-01aH) - LD (L30E3),HL - RET - - CALL L1459 - LD A,(L30E2) - PUSH DE - LD C,000H - CP 002H -L309A: JP NZ,OUTFILEERR - LD (L2D74),A - LD HL,(L30E3) -L30A3: PUSH DE - LD DE,04DD3H - CALL L1773 - JR C,L30BE ; (+012H) - PUSH BC - CALL QRDD ; Original ?RDD call - POP BC - JR NC,L30BB ; (+008H) -L30B3: CP 002H - JP NZ,CHKSUMERR -L30B8: JP L1438 - -L30BB: LD HL,04CD3H -L30BE: LD A,(HL) - LD B,A - CP 0FFH - JR NZ,L30CC ; (+008H) - LD A,(L2D74) - CP 002H - JP Z,OUTFILEERR -L30CC: XOR A - LD (L2D74),A - LD A,B - POP DE - LD (DE),A - INC HL - INC DE - INC C - CP 00DH - JR NZ,L30A3 ; (-037H) - DEC C - POP DE - LD (L30E3),HL - LD B,000H - RET - -L30E2: NOP -L30E3: NOP - NOP -L30E5: CALL L1AAF - LD A,(L30E2) - OR A - JP NZ,OPENERR - LD BC,L30FC - PUSH BC - PUSH HL - DB 021H - DB 033H -L30F6: DB 02EH - LD (HL),003H - JP L2FF0 - -L30FC: CALL L3025 - LD HL,00100H - LD (SIZE),HL - LD HL,04CD3H - LD (L30E3),HL - LD (DTADR),HL - CALL QWRI ; Original ?WRI call -L3111: JR C,L30B8 ; (-05bH) - CALL MSTOP - LD A,001H - LD (L30E2),A -L311B: JP L1B35 - -L311E: CALL L1AAF - LD A,(L30E2) - OR A - JP NZ,OPENERR - LD BC,L313A - PUSH BC - LD A,002H - LD (L2D74),A - PUSH HL - LD HL,CMTBUF - LD (HL),004H - JP L2FF0 - -L313A: CALL QRDI ; Original ?RDI call. - JP C,L30B3 - LD HL,ATRB - LD A,(HL) - CP 003H - JR NZ,L313A ; (-00eH) - LD DE,CMTFNAME - LD A,(DE) - CP 00DH - JR Z,L3155 ; (+005H) - CALL L2E1D ; Compare filename. - JR NZ,L313A ; NZ - filename doesnt match, read next header. -L3155: LD A,002H - LD (L30E2),A - CALL MSTOP - LD HL,04CD3H - LD (DTADR),HL - LD HL,00100H - LD (SIZE),HL - LD HL,04DD3H - LD (L30E3),HL - JR L311B ; (-056H) - -L3171: CALL L1459 - LD A,(L30E2) - OR A - JR Z,L3195 ; (+01bH) - PUSH HL - DEC A - JR NZ,L3190 ; (+012H) - LD HL,(L30E3) - LD DE,04DD3H - CALL L1773 - JR NC,L3198 ; (+00fH) -L3189: LD (HL),0FFH - CALL QWRD ; Original ?WRD call -L318E: JR C,L3111 ; (-07fH) -L3190: XOR A - LD (L30E2),A - POP HL -L3195: JP CMDREMDATA - -L3198: CALL QWRD ; Original ?WRD call - JR C,L318E ; (-00fH) - LD HL,04CD3H - JR L3189 ; (-019H) - -L31A2: LD A,(L32D3) - OR A - RET Z -L31A7: CALL L32C2 - LD A,00DH - CALL L3291 - XOR A - LD (L32D3),A - RET - - PUSH BC - PUSH DE - LD A,(L32D3) - LD B,A -L31BA: LD A,(DE) - CP 00DH - JP Z,L3258 - CP 020H - CALL C,L31CC - CALL L3291 - INC B - INC DE - JR L31BA ; (-012H) - -L31CC: CP 005H - JR Z,L31F0 ; (+020H) - CP 006H - JR Z,L3200 ; (+02cH) - CP 010H - JR Z,L3221 ; (+049H) - CP 011H - JR Z,L31F9 ; (+01dH) - CP 012H - JR Z,L31F5 ; (+015H) - CP 013H - JR Z,L3226 ; (+042H) - CP 014H - JR Z,L322A ; (+042H) - CP 015H - JR Z,L3238 ; (+04cH) - POP AF - INC DE - JR L31BA ; (-036H) - -L31F0: LD A,00FH -L31F2: LD B,PRTD - RET - -L31F5: LD A,00BH - JR L31F2 ; (-007H) - -L31F9: LD A,009H - LD (L326D),A - JR L31F2 ; (-00eH) - -L3200: LD A,00CH - CALL L3291 - LD A,009H - CALL L3291 - LD A,009H - CALL L3291 - LD A,00BH - CALL L3291 - LD A,00AH - CALL L3291 - CALL L3267 - CALL L3291 - JR L31F0 ; (-031H) - -L3221: CALL L3267 - JR L31F2 ; (-034H) - -L3226: LD A,00CH - JR L31F2 ; (-038H) - -L322A: LD A,009H - CALL L3291 - LD A,009H - CALL L3291 - LD A,009H - JR L31F2 ; (-046H) - -L3238: LD A,009H - CALL L3291 - LD A,009H - CALL L3291 - LD A,00BH - JR L31F2 ; (-054H) - -L3246: PUSH BC - PUSH DE - LD A,(L32D3) - LD B,A -L324C: LD A,(DE) - CP 00DH - JR Z,L3258 ; (+007H) - CALL L3291 - INC DE - INC B - JR L324C ; (-00cH) - -L3258: LD A,B - CP 0A0H - JR C,L325F ; (+002H) - SUB 0A0H -L325F: LD (L32D3),A - POP DE - POP BC - JP L32C2 - -L3267: LD A,00AH - LD (L326D),A - RET - -L326D: LD A,(BC) -L326E: PUSH BC - PUSH DE - LD A,(L32D3) - LD B,A -L3274: LD A,020H - CALL L3291 - INC B - LD A,B -L327B: SUB 00AH - JR C,L3274 ; (-00bH) - JR NZ,L327B ; (-006H) - JP L3258 - -L3284: CALL L3291 - CALL L32A5 - IN A,(PRTC) - RRCA - RRCA - RET - -L328F: LD A,01BH -L3291: PUSH AF - CALL L32A5 - POP AF - OUT (PRTD),A - LD A,080H - OUT (PRTC),A - LD A,001H - CALL L32A6 - XOR A - OUT (PRTC),A - RET - -L32A5: XOR A -L32A6: PUSH BC - PUSH DE - LD C,A - LD B,00FH - LD DE,MONIT -L32AE: IN A,(PRTC) - AND 00DH - CP C - JR Z,L32BF ; (+00aH) - DEC DE - LD A,D - OR E - JR NZ,L32AE ; (-00cH) - DJNZ L32AE ; (-00eH) - JP PRTNRDYERR - -L32BF: POP DE - POP BC - RET - -L32C2: LD A,007H - CALL L3284 - JP NC,PRTPAPERERR - LD A,008H - CALL L3284 - RET C - JP PRTHWERR - -L32D3: NOP -CMDPAGE: CALL GETNUM - LD A,E - OR A - JP Z,ILDATERR - LD A,009H - CALL L3291 - LD A,009H - CALL L3291 - LD A,E - PUSH AF - RRCA - RRCA - RRCA - RRCA - CALL ASC - CALL L3291 - POP AF - CALL ASC - CALL L3291 - JP L1B38 - -L32FC: CALL L31A7 - JP L1B35 - - CALL L193B - LD (05051H),HL - JR Z,L32FC ; (-00eH) - PUSH HL - CALL L338A - LD BC,00500H - CALL L2DD8 - POP HL -L3315: CALL L193B - LD (05051H),HL - JR Z,L3373 ; (+056H) - CALL L2E94 - CALL EXECNOTCHR - DB 03BH - DW L3326 -L3326: CALL L2293 - PUSH HL - LD HL,(04E80H) - PUSH BC - LD BC,003F0H - ADD HL,BC - POP BC - LD A,D - OR A - CALL Z,L2BC0 - CALL NZ,L2BD0 - LD A,B - OR C - JR Z,L3362 ; (+023H) - PUSH DE - LD HL,(04E80H) - INC HL - INC HL - LD E,(HL) - INC HL - LD D,(HL) - DEC HL - PUSH DE - PUSH HL - EX DE,HL - ADD HL,BC - XOR A - EX DE,HL - LD HL,003E8H - SBC HL,DE - JP C,ILDATERR - POP HL - LD (HL),E - INC HL - LD (HL),D - INC HL - POP DE - ADD HL,DE - POP DE - EX DE,HL - LDIR -L3362: LD HL,L3315 - EX (SP),HL - CALL L193B - RET Z - CP 03BH - RET Z - CP ',' - RET Z - JP SYNTAXERR - -L3373: LD HL,(04E80H) - INC HL - INC HL - LD E,(HL) - INC HL - LD D,(HL) - LD A,D - OR E - JR Z,L3387 ; (+008H) - INC HL - EX DE,HL - CALL L3390 - CALL L338A -L3387: JP L1B35 - -L338A: LD HL,(04E80H) - JP L2E09 - -L3390: CALL L328F - LD A,018H - CALL L3291 - LD A,L - CALL L3291 - LD A,H - CALL L3291 -L33A0: LD A,(DE) - CALL L3291 - INC DE - DEC HL - LD A,H - OR L - JR NZ,L33A0 ; (-00aH) - RET - -CMDCOPY: CALL L193B - JP Z,SYNTAXERR - INC HL - LD (05051H),HL - SUB 034H - JP Z,SYNTAXERR - INC A - JP Z,SYNTAXERR - INC A - JP Z,SYNTAXERR - INC A - JP NZ,SYNTAXERR - LD HL,(PAGETP) - LD C,019H -L33CB: CALL L31A7 - LD A,028H - LD B,A -L33D1: CALL L2878 - OR A - JR Z,L33DB ; (+004H) - CP 00DH - JR NZ,L33DD ; (+002H) -L33DB: LD A,020H -L33DD: CALL L3291 - CALL BRKEY - JR Z,L33FD ; (+018H) - INC HL - DJNZ L33D1 ; (-017H) - DEC C - JR NZ,L33CB ; (-020H) - CALL L31A7 - JP L1B35 - -L33F1: CALL L328F - LD A,(L326D) - JP L3291 - - CALL L33F1 -L33FD: JP L1438 - -L3400: DB 000H -L3401: DB 080H -L3402: DB 086H -L3403: XOR A - DB 001H -L3405: LD A,080H - PUSH DE - XOR (HL) - CPL - LD C,A - LD A,(DE) - AND 080H - LD B,A - XOR C - CPL - AND 080H - LD C,A -L3414: PUSH BC - LD B,(HL) - RES 7,B - LD A,(DE) - AND 07FH - CP B - JR NC,L3428 ; (+00aH) - POP BC - EX DE,HL - LD A,B - XOR C - CPL - AND 080H - LD B,A - JR L3414 ; (-014H) - -L3428: LD C,A - ADD A,040H - LD (L3402),A - LD A,C - SUB B - POP BC - LD (03400H),BC - PUSH DE - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD C,(HL) - INC HL - LD B,(HL) - POP HL - INC HL - JR Z,L345C ; (+01aH) -L3442: CP 008H - JR NC,L3453 ; (+00dH) -L3446: SRL B - RR C - RR D - RR E - DEC A - JR NZ,L3446 ; (-00bH) - JR L345C ; (+009H) - -L3453: LD E,D - LD D,C - LD C,B - LD B,000H - SUB 008H - JR NZ,L3442 ; (-01aH) -L345C: LD A,(L3400) - OR A - JR Z,L349C ; (+03aH) - LD A,(HL) - INC HL - ADD A,E - LD E,A - LD A,(HL) - INC HL - ADC A,D - LD D,A - LD A,(HL) - INC HL - ADC A,C - LD C,A - LD A,(HL) - ADC A,B - LD B,A - JR NC,L347F ; (+00cH) - RR B - RR C - RR D - RR E - LD HL,L3402 - INC (HL) -L347F: LD HL,L3402 - LD A,(HL) - SUB 040H - JR C,L348E ; (+007H) - JP M,OVFLERR - DEC HL - OR (HL) - JR L3491 ; (+003H) - -L348E: CALL L3CDE -L3491: POP HL -L3492: LD (HL),A - INC HL - LD (HL),E - INC HL - LD (HL),D - INC HL - LD (HL),C - INC HL - LD (HL),B - RET - -L349C: LD A,(HL) - INC HL - SUB E - LD E,A - LD A,(HL) - INC HL - SBC A,D - LD D,A - LD A,(HL) - INC HL - SBC A,C - LD C,A - LD A,(HL) - SBC A,B - LD B,A - CALL C,L34E4 - OR C - OR D - JR NZ,L34B7 ; (+005H) - LD A,E - CP 03FH - JR C,L348E ; (-029H) -L34B7: LD HL,L3402 -L34BA: LD A,B - OR A - JP M,L347F - JR NZ,L34D4 ; (+013H) - LD A,(HL) - SUB 008H - JR C,L348E ; (-038H) - LD (HL),A - LD A,C - OR D - OR E - JR Z,L348E ; (-03eH) - LD B,C - LD C,D - LD D,E - LD E,000H - JP L34BA - -L34D4: DEC (HL) - JR C,L348E ; (-049H) - SLA E - RL D - RL C - RL B - JP P,L34D4 - JR L347F ; (-065H) - -L34E4: LD HL,L3401 - LD A,(HL) - ADD A,080H - LD (HL),A - LD A,E - CPL - ADD A,001H - LD E,A - LD A,D - CPL - ADC A,000H - LD D,A - LD A,C - CPL - ADC A,000H - LD C,A - LD A,B - CPL - ADC A,000H - LD B,A - RET - -L3500: PUSH DE - LD A,(DE) - XOR (HL) - CPL - AND 080H - LD (L3401),A - LD B,(HL) - RES 7,B - LD A,(DE) - AND 07FH - ADD A,B - JP Z,L348E - DEC A -L3514: CP 030H - JP C,L348E - CP 0E0H - JP NC,OVFLERR - LD (L3402),A - XOR A - LD (L3400),A - LD BC,00004H - ADD HL,BC - LD A,(HL) - OR A - JP P,L348E - PUSH HL - POP IY - LD C,B - EX DE,HL - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - PUSH HL - LD H,B - LD L,B - EXX - POP HL - LD E,(HL) - INC HL - LD D,(HL) - LD HL,MONIT - LD A,D - OR A - JP P,L348E - LD C,004H -L354A: LD A,(IY+000H) - LD B,008H - OR A - JR Z,L35C5 ; (+073H) -L3552: RLA - JR NC,L3569 ; (+014H) - EX AF,AF' - EXX - LD A,B - ADD A,C - LD C,A - ADC HL,DE - EXX - ADC HL,DE - JR NC,L3568 ; (+007H) - LD A,(L3400) - INC A - LD (L3400),A -L3568: EX AF,AF' -L3569: SRL D - RR E - EXX - RR D - RR E - RR B - EXX - DJNZ L3552 ; (-025H) -L3577: DEC IY - DEC C - JR NZ,L354A ; (-032H) - LD A,(L3400) - OR A - JR Z,L3599 ; (+017H) - LD B,A - LD A,(L3402) - ADD A,B - LD (L3402),A -L358A: SCF - RR H - RR L - EXX - RR H - RR L - RR C - EXX - DJNZ L358A ; (-00fH) -L3599: EXX - LD A,C - OR A - JP P,L35BD - LD DE,00001H - ADD HL,DE - EXX - LD DE,MONIT - ADC HL,DE - JR NC,L35BC ; (+011H) - RR H - RR L - EXX - RR H - RR L - EXX - LD A,(L3402) - INC A - LD (L3402),A -L35BC: EXX -L35BD: PUSH HL - EXX - LD B,H - LD C,L - POP DE - JP L34B7 - -L35C5: LD A,E - LD E,D - LD D,000H - EXX - LD B,E - LD E,D - LD D,A - EXX - JR L3577 ; (-059H) - -L35D0: PUSH DE - LD A,(DE) - XOR (HL) - CPL - AND 080H - LD (L3401),A - LD B,(HL) - RES 7,B - LD A,(DE) - AND 07FH - SUB B - ADD A,081H -L35E2: CP 030H - JP C,L348E - CP 0E0H - JP NC,OVFLERR - LD (L3402),A - INC HL - INC DE - EX DE,HL - LD C,(HL) - INC HL - LD B,(HL) - INC HL - PUSH HL - EX DE,HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD A,L - EX AF,AF' - LD A,H - LD H,B - LD L,C - EXX - POP HL - LD C,(HL) - INC HL - LD B,(HL) - LD H,A - EX AF,AF' - LD L,A - LD E,(HL) - INC HL - LD D,(HL) - LD H,B - LD L,C - LD A,D - OR A - JP P,OVFLERR - LD C,004H -L3615: LD B,008H -L3617: BIT 7,H - JR NZ,L3633 ; (+018H) - OR A -L361C: RLA - EXX - ADD HL,HL - EXX - ADC HL,HL - DJNZ L3617 ; (-00dH) - PUSH AF - DEC C - JR NZ,L3615 ; (-013H) -L3628: POP AF - LD E,A - POP AF - LD D,A - POP AF - LD C,A - POP AF - LD B,A - JP L34B7 - -L3633: EXX - OR A - SBC HL,DE - EXX - SBC HL,DE - CCF - JR C,L361C ; (-021H) - EXX - ADD HL,DE - EXX - ADC HL,DE - OR A - RLA - EXX - ADD HL,HL - EXX - ADC HL,HL - DEC B - JR NZ,L3652 ; (+006H) - PUSH AF - LD B,008H - DEC C - JR Z,L3628 ; (-02aH) -L3652: EXX - OR A - SBC HL,DE - EXX - SBC HL,DE - SCF - RLA - DEC B - JR NZ,L3664 ; (+006H) - PUSH AF - LD B,008H - DEC C - JR Z,L3628 ; (-03cH) -L3664: EXX - ADD HL,HL - EXX - ADC HL,HL - JR NC,L3617 ; (-054H) - JR L3652 ; (-01bH) - -L366D: DEC E -L366E: XOR C - LD D,B -L3670: LD A,(HL) - PUSH HL - POP IX - EX DE,HL - LD (L366E),HL - EX AF,AF' - XOR A - LD (L366D),A - LD H,A - LD L,A - EXX - LD H,A - LD L,A - LD B,A - LD C,A - EX AF,AF' - CP 02EH - JR Z,L369D ; (+014H) - SUB 030H -L368B: CALL L3772 - CALL L3768 - SUB 030H - CP 00AH - JR C,L368B ; (-00cH) - ADD A,030H - CP 02EH - JR NZ,L36AD ; (+010H) -L369D: CALL L3768 - SUB 030H - CP 00AH - JR NC,L36AB ; (+005H) - CALL L3780 - JR L369D ; (-00eH) - -L36AB: ADD A,030H -L36AD: CP 045H - JR NZ,L36F5 ; (+044H) - EXX - CALL L3768 - LD B,001H - CP '+' - JR Z,L36C1 ; (+006H) - CP '-' - JP NZ,SYNTAXERR - DEC B -L36C1: LD A,B - OR A - EX AF,AF' - CALL L3768 - SUB 030H - NOP - NOP - CP 00AH - JR NC,L36EB ; (+01cH) - LD B,A - CALL L3768 - SUB 030H - CP 00AH - JR NC,L36EB ; (+012H) - LD C,A - CALL L3768 - SUB 030H - CP 00AH - JP C,OVFLERR - LD A,B - ADD A,A - ADD A,A - ADD A,B - ADD A,A - ADD A,C - LD B,A -L36EB: EX AF,AF' - LD A,B - JR NZ,L36F1 ; (+002H) - CPL - INC A -L36F1: LD (L366D),A - EXX -L36F5: PUSH IX - LD A,(L366D) - ADD A,01DH - ADD A,C - LD (L366D),A - CP 030H - JR C,L370B ; (+007H) - CP 080H - JP C,OVFLERR - JR L375D ; (+052H) - -L370B: LD A,080H - LD (L3401),A - LD A,0A0H - LD (L3402),A - PUSH HL - EXX - POP BC - LD D,H - LD E,L - LD HL,L3725 - PUSH HL - LD HL,(L366E) - PUSH HL - JP L34B7 - -L3725: LD A,(L366D) - LD L,A - LD C,A - LD H,000H - LD B,H - ADD HL,HL - ADD HL,HL - ADD HL,BC - LD BC,L37AE - ADD HL,BC - LD DE,(0366EH) - LD A,080H - LD (L3401),A - LD A,020H - ADD A,(HL) - LD B,A - LD A,(DE) - AND 07FH - ADD A,B - JP C,OVFLERR - SUB 021H - JR NC,L374D ; (+001H) - XOR A -L374D: LD BC,L3755 - PUSH BC - PUSH DE - JP L3514 - -L3755: POP HL - LD BC,00005H - LD D,B - LD E,B - LD A,(HL) - RET - -L375D: LD HL,L3755 - PUSH HL - LD HL,(L366E) - PUSH HL - JP L348E - -L3768: INC IX - LD A,(IX+000H) - CP 020H - RET NZ - JR L3768 ; (-00aH) - -L3772: OR A - JR NZ,L3778 ; (+003H) - OR B - RET Z - XOR A -L3778: EX AF,AF' - LD A,B - CP 009H - JR NZ,L378E ; (+010H) - INC C - RET - -L3780: OR A - JR NZ,L3788 ; (+005H) - DEC C - OR B - RET Z - INC C - XOR A -L3788: EX AF,AF' - LD A,B - CP 009H - RET Z - DEC C -L378E: INC B - LD D,H - LD E,L - EXX - LD D,H - LD E,L - XOR A - ADD HL,HL - RLA - ADD HL,HL - RLA - ADD HL,DE - LD D,000H - ADC A,D - ADD HL,HL - RLA - EX AF,AF' - LD E,A - EX AF,AF' - ADD HL,DE - ADC A,D - EXX - ADD HL,HL - ADD HL,HL - ADD HL,DE - ADD HL,HL - LD D,000H - LD E,A - ADD HL,DE - RET - -L37AE: DB 0E0H - DB 0F5H - DB 0F7H - DB 0D2H - DB 0CAH - DB 0E3H - DB 0F3H - DB 0B5H - DB 087H - DB 0FDH - DB 0E7H - DB 0B8H - DB 0D1H - DB 074H - DB 09EH - DB 0EAH - DB 025H - DB 006H - DB 012H - DB 0C6H - DB 0EDH - DB 0AFH - DB 087H - DB 096H - DB 0F7H - DB 0F1H - DB 0CDH - DB 014H - DB 0BEH - DB 09AH - DB 0F4H - DB 001H - DB 09AH - DB 06DH - DB 0C1H - DB 0F7H - DB 081H - DB 000H - DB 0C9H - DB 0F1H - DB 0FBH - DB 050H - DB 0A0H - DB 01DH - DB 097H -L37DB: DB 0FEH - DB 065H - DB 008H - DB 0E5H - DB 0BCH - DB 001H - DB 07EH - DB 04AH - DB 01EH - DB 0ECH - DB 005H - DB 08FH - DB 0EEH - DB 092H - DB 093H - DB 008H - DB 032H - DB 0AAH - DB 077H - DB 0B8H - DB 00BH - DB 0BFH - DB 094H - DB 095H - DB 0E6H - DB 00FH - DB 0F7H - DB 07CH - DB 01DH - DB 090H - DB 012H - DB 035H - DB 0DCH - DB 024H - DB 0B4H - DB 015H - DB 042H - DB 013H - DB 02EH - DB 0E1H - DB 019H - DB 009H - DB 0CCH - DB 0BCH - DB 08CH - DB 01CH - DB 00CH - DB 0FFH - DB 0EBH - DB 0AFH - DB 01FH - DB 0CFH - DB 0FEH - DB 0E6H - DB 0DBH - DB 023H - DB 041H - DB 05FH - DB 070H - DB 089H - DB 026H - DB 012H - DB 077H - DB 0CCH - DB 0ABH - DB 029H - DB 0D6H - DB 094H - DB 0BFH - DB 0D6H - DB 02DH - DB 006H - DB 0BDH - DB 037H - DB 086H - DB 030H - DB 047H - DB 0ACH - DB 0C5H - DB 0A7H - DB 033H - DB 059H - DB 017H - DB 0B7H - DB 0D1H - DB 037H - DB 098H - DB 06EH - DB 012H - DB 083H - DB 03AH - DB 03DH - DB 00AH - DB 0D7H - DB 0A3H - DB 03DH - DB 0CDH - DB 0CCH - DB 0CCH - DB 0CCH - DB 041H - DB 000H - DB 000H - DB 000H - DB 080H - DB 044H - DB 000H - DB 000H - DB 000H - DB 0A0H - DB 047H - DB 000H - DB 000H - DB 000H - DB 0C8H - DB 04AH - DB 000H - DB 000H - DB 000H - DB 0FAH - DB 04EH - DB 000H - DB 000H - DB 040H - DB 09CH - DB 051H - DB 000H - DB 000H - DB 050H - DB 0C3H - DB 054H - DB 000H - DB 000H - DB 024H - DB 0F4H - DB 058H - DB 000H - DB 080H - DB 096H - DB 098H - DB 05BH - DB 000H - DB 020H - DB 0BCH - DB 0BEH - DB 05EH - DB 000H - DB 028H - DB 06BH - DB 0EEH - DB 062H - DB 000H - DB 0F9H - DB 002H - DB 095H - DB 065H - DB 040H - DB 0B7H - DB 043H - DB 0BAH - DB 068H - DB 010H - DB 0A5H - DB 0D4H - DB 0E8H - DB 06CH - DB 02AH - DB 0E7H - DB 084H - DB 091H - DB 06FH - DB 0F5H - DB 020H - DB 0E6H - DB 0B5H - DB 072H - DB 032H - DB 0A9H - DB 05FH - DB 0E3H - DB 076H - DB 0BFH - DB 0C9H - DB 01BH - DB 08EH - DB 079H - DB 02FH - DB 0BCH - DB 0A2H - DB 0B1H - DB 07CH - DB 03AH - DB 06BH - DB 00BH - DB 0DEH - DB 080H - DB 005H - DB 023H - DB 0C7H - DB 08AH -L38A3: DB 08DH - DB 06CH -L38A5: DB 001H -L38A6: DB 020H -L38A7: DB 031H -L38A8: DB 02EH - DB 035H - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH -L38AF: DB 00DH -L38B0: DB 00DH -L38B1: DB 000H -L38B2: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L38BB: PUSH DE - CALL L3997 - LD A,(L38A5) - OR A - JP Z,L3960 - JP M,L38CF - CP 009H - JR C,L392B ; (+05eH) - JR L38D4 ; (+005H) - -L38CF: CP PRTD - JP NC,L395B -L38D4: LD A,02EH - LD (L38A7),A - LD HL,L38B0 - XOR A -L38DD: DEC HL - CP (HL) - JR Z,L38DD ; (-004H) - LD A,(HL) - CP 02EH - JP Z,L398A - INC HL - LD (HL),045H - INC HL - LD A,(L38A5) - LD B,'+' - OR A - JP P,L38FD - CP 0EDH - JP C,L398A - LD B,'-' - CPL - INC A -L38FD: LD (HL),B - INC HL - LD BC,0FF0AH -L3902: INC B - SUB C - JR NC,L3902 ; (-004H) - ADD A,C - LD (HL),B - INC HL - LD (HL),A - INC HL - LD (HL),00DH -L390D: LD HL,L38A6 -L3910: INC HL - LD A,(HL) - CP 00DH - JR Z,L391D ; (+007H) - JR NC,L3910 ; (-008H) - OR 030H - LD (HL),A - JR L3910 ; (-00dH) - -L391D: LD DE,L38A6 - XOR A - SBC HL,DE - LD B,H - LD C,L - POP HL - EX DE,HL - INC BC - LDIR - RET - -L392B: LD HL,L38A8 - LD DE,L38A7 - LD B,A - INC B -L3933: DEC B - JR Z,L393C ; (+006H) - LD A,(HL) - LD (DE),A - INC HL - INC DE - JR L3933 ; (-009H) - -L393C: LD A,02EH - LD (DE),A - LD HL,L38B0 -L3942: LD (HL),00DH - DEC HL - LD A,(HL) - OR A - JR Z,L3942 ; (-007H) - CP 02EH - JR NZ,L394F ; (+002H) - LD (HL),00DH -L394F: LD HL,L38A7 - LD A,(HL) - CP 00DH - JR NZ,L390D ; (-04aH) - LD (HL),000H - JR L390D ; (-04eH) - -L395B: LD DE,L38B2 - JR L3963 ; (+003H) - -L3960: LD DE,L38B1 -L3963: LD HL,L38AF - LD A,00DH - LD (DE),A - PUSH DE - DEC DE - LD BC,00008H - LDDR - EX DE,HL - LD A,(L38A5) - OR A - JR Z,L397A ; (+003H) - LD (HL),000H - DEC HL -L397A: LD (HL),02EH - DEC HL - LD (HL),000H - POP HL -L3980: DEC HL - LD A,(HL) - CP 000H - JR NZ,L390D ; (-079H) - LD (HL),00DH - JR L3980 ; (-00aH) - -L398A: LD HL,L3994 - LD BC,GETL - POP DE - LDIR - RET - -L3994: JR NZ,L39C6 ; (+030H) - DEC C -L3997: LD (L38A3),HL - LD A,(HL) - LD B,020H - OR A - JP M,L39A3 - LD B,'-' -L39A3: AND 07FH - LD (HL),A - LD A,B - LD (L38A6),A - EX DE,HL - LD HL,L37DB - LD A,0ECH - EX AF,AF' -L39B1: EX AF,AF' - INC A - EX AF,AF' - LD BC,00005H - ADD HL,BC - PUSH HL - PUSH DE - LD A,(DE) - CALL L3A73 - POP DE - POP HL - JR NC,L39B1 ; (-011H) - EX AF,AF' - LD (L38A5),A -L39C6: PUSH DE - LD BC,L39D8 - PUSH BC - PUSH DE - LD A,080H - LD (L3401),A - LD A,(DE) - SUB (HL) - ADD A,081H - JP L35E2 - -L39D8: LD HL,L38A7 - LD (HL),000H - INC HL - EX (SP),HL - LD A,(HL) - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - PUSH HL - EX DE,HL - EXX - POP HL - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL - SUB 0C0H - JR NC,L39FE ; (+00dH) -L39F1: SRL H - RR L - EXX - RR H - RR L - EXX - INC A - JR NZ,L39F1 ; (-00dH) -L39FE: POP BC - LD A,009H -L3A01: EX AF,AF' - XOR A - LD D,H - LD E,L - EXX - LD D,H - LD E,L - ADD HL,HL - EXX - ADC HL,HL - RLA - EXX - ADD HL,HL - EXX - ADC HL,HL - RLA - EXX - ADD HL,DE - EXX - ADC HL,DE - LD D,000H - ADC A,D - EXX - ADD HL,HL - EXX - ADC HL,HL - RLA - LD (BC),A - INC BC - EX AF,AF' - DEC A - JR NZ,L3A01 ; (-026H) -L3A27: LD HL,L38B0 - LD A,(HL) - LD (HL),000H - CP 005H - LD C,000H - JR C,L3A34 ; (+001H) - INC C -L3A34: LD B,00AH -L3A36: DEC B - JR Z,L3A47 ; (+00eH) - DEC HL - LD A,(HL) - ADD A,C - LD (HL),A - SUB 00AH - LD C,000H - JR C,L3A36 ; (-00dH) - INC C - LD (HL),A - JR L3A36 ; (-011H) - -L3A47: LD A,(L38A7) - OR A - RET Z - LD HL,L38AF - LD DE,L38B0 - LD BC,NL - LDDR - EX DE,HL - LD (HL),000H - LD A,(L38A5) - INC A - LD (L38A5),A - JR L3A27 ; (-03cH) - -L3A63: LD BC,00005H -L3A66: LD A,(DE) - OR A - JP M,L3A73 - BIT 7,(HL) - JR Z,L3A71 ; (+002H) - SCF - RET - -L3A71: EX DE,HL - LD A,(DE) -L3A73: CP (HL) - RET NZ - DEC C - ADD HL,BC - EX DE,HL - ADD HL,BC - EX DE,HL - LD B,003H -L3A7C: LD A,(DE) - CP (HL) - RET NZ - DEC HL - DEC DE - DJNZ L3A7C ; (-007H) - LD A,(DE) - CP (HL) - RET - -L3A86: EX DE,HL - CALL L3997 - LD A,(L38A6) - LD B,080H - CP 020H - JR Z,L3A95 ; (+002H) - LD B,000H -L3A95: LD A,B - LD (L3401),A - OR A - JR Z,L3B1A ; (+07eH) - LD A,(L38A5) - DEC A - JP M,L3B50 - LD HL,L38B0 - LD B,00DH - LD (HL),B - SUB 008H - JR NC,L3AB3 ; (+006H) -L3AAD: LD (HL),B - DEC HL - INC A - JR NZ,L3AAD ; (-005H) - DEC A -L3AB3: INC A - LD (L366D),A - LD IX,L38A7 - XOR A - LD H,A - LD L,A - EXX - LD B,A - LD C,A - LD H,A - LD L,A -L3AC3: LD A,(IX+000H) - CP 00DH - JR Z,L3AD1 ; (+007H) - CALL L3772 - INC IX - JR L3AC3 ; (-00eH) - -L3AD1: LD A,(L366D) - ADD A,01DH - ADD A,C - LD (L366D),A - LD A,0A0H - LD (L3402),A - PUSH HL - EXX - POP BC - LD D,H - LD E,L - LD HL,L3AEF - PUSH HL - LD HL,(L38A3) - PUSH HL - JP L34B7 - -L3AEF: LD A,(L366D) - LD C,A - LD L,A - LD H,000H - LD B,H - ADD HL,HL - ADD HL,HL - ADD HL,BC - LD BC,L37AE - ADD HL,BC - LD DE,(038A3H) - XOR A - LD (L3400),A - LD A,020H - ADD A,(HL) - LD B,A - LD A,(DE) - AND 07FH - ADD A,B - JP C,OVFLERR - SUB 021H - JR NC,L3B16 ; (+001H) - XOR A -L3B16: PUSH DE - JP L3514 - -L3B1A: LD A,(L38A5) - DEC A - JP M,L3B55 - LD HL,L38B0 - LD BC,00D00H - LD (HL),B - SUB 008H - JR NC,L3B3B ; (+00fH) - JR L3B36 ; (+008H) - -L3B2E: EX AF,AF' - LD A,(HL) - OR A - JR Z,L3B34 ; (+001H) - INC C -L3B34: LD (HL),B - EX AF,AF' -L3B36: DEC HL - INC A - JR NZ,L3B2E ; (-00cH) - DEC A -L3B3B: EX AF,AF' - LD A,C - OR A - JR Z,L3B4C ; (+00cH) -L3B40: LD A,(HL) - INC A - LD (HL),A - CP 00AH - JR NZ,L3B4C ; (+005H) - LD (HL),000H - DEC HL - JR L3B40 ; (-00cH) - -L3B4C: EX AF,AF' - JP L3AB3 - -L3B50: LD DE,L2A8D - JR L3B58 ; (+003H) - -L3B55: LD DE,L2A92 -L3B58: LD HL,(L38A3) - EX DE,HL -L3B5C: LD BC,00005H - LDIR - RET - -L3B62: PUSH DE - CALL L3A63 - JR Z,L3B6D ; (+005H) -L3B68: LD HL,L2A92 - JR L3B70 ; (+003H) - -L3B6D: LD HL,L2A8D -L3B70: POP DE - JR L3B5C ; (-017H) - -L3B73: PUSH DE - EX DE,HL - JR L3B78 ; (+001H) - -L3B77: PUSH DE -L3B78: CALL L3A63 - JR C,L3B68 ; (-015H) - JR L3B6D ; (-012H) - -L3B7F: PUSH DE - CALL L3A63 - JR Z,L3B68 ; (-01dH) - JR L3B6D ; (-01aH) - -L3B87: PUSH DE - EX DE,HL - JR L3B8C ; (+001H) - -L3B8B: PUSH DE -L3B8C: CALL L3A63 - JR C,L3B6D ; (-024H) - JR L3B68 ; (-02bH) - -L3B93: CP (HL) - DEC (HL) - JR Z,L3B73 ; (-024H) - RST 008H -L3B98: PUSH DE - EX DE,HL - LD A,(HL) - LD BC,00004H - ADD HL,BC - XOR (HL) - JP M,L3BC4 - LD DE,L3B93 - PUSH DE - LD HL,L3BE9 - CALL L3500 - POP HL - PUSH HL - LD A,(HL) - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD C,(HL) - INC HL - LD B,(HL) - CP 0C1H - CALL NC,L3BD2 - POP HL - PUSH HL - CALL L3492 - JR L3BCE ; (+00aH) - -L3BC4: LD DE,L3B93 - LD HL,L3BE4 - PUSH DE - CALL L3B5C -L3BCE: POP HL - POP DE - JR L3B5C ; (-076H) - -L3BD2: SUB 0C0H -L3BD4: SLA E - RL D - RL C - RL B - DEC A - JR NZ,L3BD4 ; (-00bH) - LD A,0C0H - JP L3CC5 - -L3BE4: CP (HL) - DEC (HL) - JR Z,L3BC4 ; (-024H) - RST 008H -L3BE9: DB 0C5H - DB 000H - DB 000H - DB 000H - DB 0B8H -L3BEE: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L3BF3: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L3BF8: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L3BFD: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L3C02: LD DE,L3BEE - JP L3405 - -L3C08: CALL L3C02 -L3C0B: LD HL,L3BF3 -L3C0E: LD DE,L3BEE - JP L3500 - -L3C14: NOP -L3C15: NOP -L3C16: PUSH DE - LD HL,L3CE7 - CALL L35D0 - POP HL - PUSH HL - LD A,(HL) - LD (L3C15),A - OR 080H - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD C,(HL) - INC HL - LD B,(HL) - CP 0C3H - JR C,L3C43 ; (+012H) - SUB 0C2H -L3C33: SLA E - RL D - RL C - RL B - DEC A - JR NZ,L3C33 ; (-00bH) - LD A,0C2H - CALL L3CC5 -L3C43: LD HL,08000H - CP 0C2H - JR C,L3C50 ; (+006H) - LD H,L - RES 7,B - CALL L3CC5 -L3C50: CP 0C1H - JR C,L3C5A ; (+006H) - INC L - RES 7,B - CALL L3CC5 -L3C5A: EX AF,AF' - LD A,(L3C15) - XOR H - CPL - AND 080H - LD H,A - LD (L3C14),HL - EX AF,AF' - POP HL - PUSH HL - CALL L3492 - LD A,(L3C14) - OR A - JR Z,L3C7A ; (+008H) - POP DE - PUSH DE - LD HL,L2A88 - CALL L3403 -L3C7A: POP HL - PUSH HL - LD A,(HL) - AND 07FH - LD B,A - LD A,(L3C15) - OR B - LD (HL),A - LD DE,L3BEE - CALL L3B5C - LD DE,L3BF3 - LD HL,L3BEE - CALL L3B5C - CALL L3C0B - LD DE,L3BF3 - LD HL,L3BEE - CALL L3B5C - LD HL,L3CEC - CALL L3C0E - LD HL,L3CF1 - CALL L3C08 - LD HL,L3CF6 - CALL L3C08 - LD HL,L3CFB - CALL L3C08 - LD HL,L3D00 - CALL L3C02 - POP DE - LD HL,L3BEE - JP L3500 - -L3CC5: BIT 7,B - RET NZ - EX AF,AF' - LD A,B - OR C - OR E - OR D - JR Z,L3CDE ; (+00fH) - EX AF,AF' -L3CD0: BIT 7,B - RET NZ - SLA E - RL D - RL C - RL B - DEC A - JR NZ,L3CD0 ; (-00eH) -L3CDE: LD BC,MONIT - LD DE,MONIT - LD A,080H - RET - -L3CE7: DB 0C1H - DB 0A1H - DB 0DAH - DB 00FH - DB 0C9H -L3CEC: DB 0B4H - DB 0DCH - DB 00FH - DB 00AH - DB 09FH -L3CF1: DB 039H - DB 061H - DB 08FH - DB 029H - DB 099H -L3CF6: DB 0BDH - DB 0C8H - DB 077H - DB 034H - DB 0A3H -L3CFB: DB 040H - DB 085H - DB 0E1H - DB 05DH - DB 0A5H -L3D00: DB 0C1H - DB 094H - DB 0DAH - DB 00FH - DB 0C9H -L3D05: PUSH DE - LD HL,L3CE7 - CALL L3403 - POP HL - CALL L4193 - EX DE,HL - JP L3C16 - -L3D14: PUSH DE - EX DE,HL - LD DE,L3BFD - CALL L3B5C - POP DE - PUSH DE - CALL L3D05 - POP HL - PUSH HL - LD DE,L3BF8 - CALL L3B5C - POP DE - PUSH DE - LD HL,L3BFD - CALL L3B5C - POP DE - PUSH DE - CALL L3C16 - POP DE - LD HL,L3BF8 - JP L35D0 - -L3D3D: NOP -L3D3E: NOP -L3D3F: LD A,003H - LD (L3D3D),A - PUSH DE - EX DE,HL - LD A,(HL) - ADD A,080H - JP NC,ILDATERR - JR NZ,L3D5B ; (+00dH) - EX AF,AF' - LD BC,00004H - ADD HL,BC - LD A,(HL) - SBC HL,BC - OR A - JP P,L3DBA - EX AF,AF' -L3D5B: BIT 0,A - JR NZ,L3DD5 ; (+076H) - LD (L3D3E),A - LD (HL),0C0H - LD DE,L3BEE - CALL L3B5C - LD HL,L3DED - CALL L3C0E - LD HL,L3DF2 -L3D73: CALL L3C02 -L3D76: LD DE,L3BF3 - POP HL - PUSH HL - CALL L3B5C - LD DE,L3BF3 - LD HL,L3BEE - CALL L35D0 - LD HL,L3BF3 - CALL L3C02 - LD HL,L3BEE - LD A,(HL) - AND 07FH - DEC A - JR C,L3DBA ; (+024H) - OR 080H - LD (HL),A - LD A,(L3D3D) - DEC A - LD (L3D3D),A - JR NZ,L3D76 ; (-02cH) - LD A,(L3D3E) - CP 040H - CALL NZ,L3DC1 - LD B,(HL) - RES 7,B - ADD A,B - SUB 040H - JR C,L3DBA ; (+008H) - JP M,OVFLERR - OR 080H - LD (HL),A - JR L3DBD ; (+003H) - -L3DBA: LD HL,L2A8D -L3DBD: POP DE - JP L3B5C - -L3DC1: JR C,L3DCA ; (+007H) - SUB 040H - SRL A - ADD A,040H - RET - -L3DCA: LD B,A - LD A,040H - SUB B - SRL A - LD B,A - LD A,040H - SUB B - RET - -L3DD5: INC A - LD (L3D3E),A - LD (HL),0BFH - LD DE,L3BEE - CALL L3B5C - LD HL,L3DF7 - CALL L3C0E - LD HL,L3DFC - JP L3D73 - -L3DED: DB 0C0H - DB 000H - DB 000H - DB 000H - DB 090H -L3DF2: DB 0BFH - DB 000H - DB 000H - DB 000H - DB 0E0H -L3DF7: DB 0C0H - DB 000H - DB 000H - DB 000H - DB 0E0H -L3DFC: DB 0BFH - DB 000H - DB 000H - DB 000H - DB 090H -L3E01: NOP -L3E02: NOP -L3E03: PUSH DE - LD A,(DE) - AND 080H - LD (L3E01),A - LD A,(DE) - OR 080H - LD (DE),A - LD HL,L3F2D - CALL L35D0 - POP HL - PUSH HL - LD A,040H - LD (L3E02),A - LD A,(HL) - SUB 0C1H - CALL NC,L3EBB - POP DE - PUSH DE - LD HL,L3F28 - CALL L3403 - POP HL - PUSH HL - LD DE,L3BEE - CALL L3B5C - LD HL,L3F05 - CALL L3C0E - LD HL,L3F0A - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD HL,L3F0F - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD HL,L3F14 - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD HL,L3F19 - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD HL,L3F1E - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD HL,L3F23 - CALL L3C02 - LD HL,L3BEE - LD B,(HL) - RES 7,B - LD A,(L3E02) - ADD A,B - JP C,L3EFC - SUB 03FH - JR C,L3EEC ; (+067H) - JP M,L3EFC - OR 080H - LD (HL),A - LD A,(L3E01) - OR A - JR Z,L3E98 ; (+007H) - LD HL,L3BEE - POP DE - JP L3B5C - -L3E98: POP DE - PUSH DE - LD HL,L2A88 - CALL L3B5C - POP DE - PUSH DE - LD A,(DE) - CP 0FCH - PUSH AF - JR C,L3EAA ; (+002H) - DEC A - LD (DE),A -L3EAA: LD HL,L3BEE - CALL L35D0 - POP AF - POP HL - RET C - LD A,(HL) - DEC A - LD (HL),A - RET M - PUSH HL - JP L348E - -L3EBB: INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD C,(HL) - INC HL - LD B,(HL) - PUSH HL - INC A - LD H,A - XOR A -L3EC7: SLA E - RL D - RL C - RL B - RLA - JR C,L3EFA ; (+028H) - DEC H - JR NZ,L3EC7 ; (-00eH) - ADD A,040H - JR C,L3EFA ; (+021H) - LD (L3E02),A - LD A,0C0H - CALL L3CC5 - POP HL - LD (HL),B - DEC HL - LD (HL),C - DEC HL - LD (HL),D - DEC HL - LD (HL),E - DEC HL - LD (HL),A - RET - -L3EEC: LD A,(L3E01) - OR A - JP Z,OVFLERR -L3EF3: LD HL,L2A8D - POP DE - JP L3B5C - -L3EFA: POP AF - POP AF -L3EFC: LD A,(L3E01) - OR A - JP NZ,OVFLERR - JR L3EF3 ; (-012H) - -L3F05: DB 0B3H - DB 07CH - DB 08CH - DB 090H - DB 0E3H -L3F0A: DB 0B6H - DB 01FH - DB 0DFH - DB 062H - DB 0F8H -L3F0F: DB 0B9H - DB 0E2H - DB 06DH - DB 0DDH - DB 0DEH -L3F14: DB 0BCH - DB 08BH - DB 033H - DB 0C1H - DB 0A0H -L3F19: DB 0BEH - DB 089H - DB 04AH - DB 0F1H - DB 0ADH -L3F1E: DB 0BFH - DB 034H - DB 033H - DB 0F2H - DB 0FAH -L3F23: DB 0C0H - DB 036H - DB 0F3H - DB 004H - DB 0B5H -L3F28: DB 0C0H - DB 000H - DB 000H - DB 000H - DB 080H -L3F2D: DB 0C0H - DB 0F8H - DB 017H - DB 072H - DB 0B1H -L3F32: DB 000H -L3F33: DB 000H -L3F34: DB 000H -L3F35: PUSH DE - LD A,080H - LD (L3F33),A - LD (L3F32),A - EX DE,HL - LD A,(HL) - OR A - JP P,OVFLERR - CP 08AH - JR NC,L3F53 ; (+00bH) - XOR A - LD (L3F32),A - EX DE,HL - CALL L3D3F - POP HL - PUSH HL - LD A,(HL) -L3F53: CP 0C1H - CALL C,L4011 - LD B,000H - CP 0C1H - JR Z,L3F64 ; (+006H) - SUB 0C1H - LD B,A - LD A,0C1H - LD (HL),A -L3F64: LD A,B - LD (L3F34),A - LD DE,L3BEE - CALL L3B5C - POP DE - PUSH DE - LD HL,L4055 - CALL L3403 - LD HL,L4055 - CALL L3C02 - POP DE - PUSH DE - LD HL,L3BEE - CALL L35D0 - POP DE - PUSH DE - LD HL,L405A - CALL L3500 - POP HL - PUSH HL - LD DE,L3BF3 - CALL L3B5C - POP HL - PUSH HL - LD DE,L3BF3 - CALL L3500 - LD DE,L3BEE - LD HL,L3BF3 - CALL L3B5C - LD HL,L4041 - CALL L3C0E - LD HL,L4046 - CALL L3C08 - LD HL,L404B - CALL L3C08 - LD HL,L4050 - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD DE,L3BF3 - LD HL,L3BEE - CALL L3B5C - LD A,(L3F34) - ADD A,A - INC A - LD B,A - LD A,008H -L3FD3: BIT 7,B - JR NZ,L3FDC ; (+005H) - SLA B - DEC A - JR NZ,L3FD3 ; (-009H) -L3FDC: ADD A,0C0H - LD HL,L3BEE - LD (HL),A - INC HL - XOR A - LD (HL),A - INC HL - LD (HL),A - INC HL - LD (HL),A - INC HL - LD (HL),B - LD HL,L405F - CALL L3C0E - LD HL,L3BF3 - CALL L3C02 - LD HL,L3BEE - LD A,(L3F33) - CALL L4191 - POP DE - PUSH DE - CALL L3B5C - POP DE - LD A,(L3F32) - OR A - RET NZ - LD HL,L3BEE - JP L3405 - -L4011: PUSH HL - LD DE,L3BEE - CALL L3B5C - POP DE - PUSH DE - LD HL,L2A88 - CALL L3B5C - POP DE - PUSH DE - LD HL,L3BEE - CALL L35D0 - POP HL - LD A,(HL) - CP 0C1H - JR NC,L4039 ; (+00bH) - PUSH HL - EX DE,HL - LD HL,L2A88 - CALL L3B5C - POP HL - LD A,0C1H -L4039: EX AF,AF' - LD A,000H - LD (L3F33),A - EX AF,AF' - RET - -L4041: DB 0ADH - DB 0A4H - DB 062H - DB 0CCH - DB 0AFH -L4046: DB 0B2H - DB 09FH - DB 0E9H - DB 047H - DB 0F9H -L404B: DB 0B8H - DB 0A4H - DB 082H - DB 0AAH - DB 0DCH -L4050: DB 0BFH - DB 0BFH - DB 0CCH - DB 0B0H - DB 0AFH -L4055: DB 0C1H - DB 033H - DB 0F3H - DB 004H - DB 0B5H -L405A: DB 0C3H - DB 099H - DB 079H - DB 082H - DB 0BAH -L405F: DB 0BFH - DB 0F8H - DB 017H - DB 072H - DB 0B1H -L4064: PUSH DE - CALL L3F35 - POP DE - LD HL,L406F - JP L3500 - -L406F: DB 0BFH - DB 0A9H - DB 0D8H - DB 05BH - DB 0DEH -L4074: DB 000H -L4075: DB 000H -L4076: PUSH DE - EX DE,HL - LD A,(HL) - AND 080H - LD (L4074),A - SET 7,(HL) - LD DE,L2A88 - CALL L3A63 - LD A,080H - JR NC,L40A3 ; (+019H) - LD DE,L3BEE - POP HL - PUSH HL - CALL L3B5C - POP DE - PUSH DE - LD HL,L2A88 - CALL L3B5C - POP DE - PUSH DE - LD HL,L3BEE - CALL L35D0 - XOR A -L40A3: LD (L4075),A - POP HL - PUSH HL - LD DE,L3BEE - CALL L3B5C - POP HL - PUSH HL - CALL L3C0E - LD HL,L3BEE - LD DE,L3BF3 - CALL L3B5C - LD HL,L4121 - CALL L3C0E - LD HL,L4126 - CALL L3C08 - LD HL,L412B - CALL L3C08 - LD HL,L4130 - CALL L3C08 - LD HL,L4135 - CALL L3C08 - LD HL,L413A - CALL L3C08 - LD HL,L413F - CALL L3C08 - LD HL,L4144 - CALL L3C08 - LD HL,L4149 - CALL L3C08 - LD HL,L2A88 - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - POP DE - PUSH DE - LD HL,L3BEE - CALL L3B5C - LD A,(L4075) - OR A - JR NZ,L411B ; (+010H) - POP DE - PUSH DE - LD HL,L3CE7 - CALL L3B5C - POP DE - PUSH DE - LD HL,L3BEE - DB 0CDH - DB 003H -L411A: DB 034H -L411B: POP HL - LD A,(L4074) - JR L4191 ; (+070H) - -L4121: DB 037H - DB 0CAH - DB 09AH - DB 056H - DB 0DFH -L4126: DB 0BAH - DB 012H - DB 077H - DB 0CCH - DB 0ABH -L412B: DB 03BH - DB 023H - DB 0B2H - DB 05EH - DB 0F8H -L4130: DB 0BCH - DB 020H - DB 063H - DB 090H - DB 0E9H -L4135: DB 03DH - DB 0EEH - DB 03DH - DB 0E0H - DB 0AAH -L413A: DB 0BDH - DB 04FH - DB 01AH - DB 0D5H - DB 0DFH -L413F: DB 03EH - DB 0E3H - DB 0AFH - DB 003H - DB 092H -L4144: DB 0BEH - DB 02AH - DB 07BH - DB 0C7H - DB 0CCH -L4149: DB 03FH - DB 017H - DB 096H - DB 0AAH - DB 0AAH -L414E: DB 000H - DB 000H - DB 000H - DB 000H -L4152: DB 000H -L4153: DB 000H -L4154: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L4159: PUSH DE - LD DE,L4154 - CALL L3B5C - POP HL - PUSH HL - LD BC,00004H - ADD HL,BC - LD A,(HL) - OR A - POP HL - PUSH HL - JP P,L348E - LD A,(HL) - AND 080H - LD (L4153),A - SET 7,(HL) - EX DE,HL - CALL L3F35 - LD A,(L4153) - OR A - CALL Z,L41A4 - POP DE - PUSH DE - LD HL,L4154 - CALL L3500 - POP DE - PUSH DE - CALL L3E03 - POP HL - LD A,(L4153) -L4191: OR A - RET NZ -L4193: LD BC,00004H - ADD HL,BC - BIT 7,(HL) - PUSH AF - XOR A - SBC HL,BC - POP AF - RET Z - LD A,(HL) - ADD A,080H - LD (HL),A - RET - -L41A4: LD HL,L4154 - LD DE,L414E - CALL L3B5C - LD DE,L4154 - CALL L3A86 - LD DE,L414E - LD HL,L4154 - CALL L3403 - LD HL,L4152 - LD A,(HL) - OR A - JP M,ILDATERR - LD HL,L4154 - LD A,(HL) - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD C,(HL) - INC HL - LD B,(HL) - AND 07FH - SUB 041H - JR C,L41E6 ; (+010H) - JR Z,L41E3 ; (+00bH) -L41D8: SLA E - RL D - RL C - RL B - DEC A - JR NZ,L41D8 ; (-00bH) -L41E3: RL B - RET C -L41E6: LD A,080H - LD (L4153),A - RET - -TAPECOPYPRG:IF BUILD_ORIG = 1 - ; Self duplicate code. This method is used to duplicate BASIC SA-5510 onto a new cassette. - NOP - LD DE,ATRB - LD HL,L4223 - LD BC,PRNT - LDIR - LD HL,TAPECOPY - LD (DTADR),HL - LD DE,TAPECOPYPRG - EX DE,HL - XOR A - SBC HL,DE - INC HL - LD (SIZE),HL - LD HL,COLDSTRT - LD (EXADR),HL - CALL ?WRI - RET C - LD HL,TAPECOPYPRG - LD A,0C9H - LD (HL),A - CALL ?WRD - PUSH AF - LD A,000H - LD (HL),A - POP AF - RET C - RET - -L4223: DB 001H,"BASIC SA-5510",00DH - ENDIF - - ; Define extensions under RFS. Each is in a seperate block due to Glass Z80 way of not evaluating labels inside IF statements when false. - ; -RFSRDI: IF BUILD_RFS = 1 - ; RFS extensions, call the RFS API to execute extended code. - LD DE,CMTFNAME - JP CMT_RDINF - ENDIF -CMDDIR: IF BUILD_RFS = 1 - CALL L193B ; Skip space to CR, ':' or char. - LD (05051H),HL - JR Z,CMDDIRNOSTR ; CR or ':' return. -CMDDIRNOSTR: EX DE,HL ; CMT_DIR expects DE to point to argument string. - CALL CMT_DIR - JP WARMSTRT - ENDIF - -BASICEND: diff --git a/software/asm/sa1510.asm b/software/asm/sa1510.asm deleted file mode 100644 index 0648efd..0000000 --- a/software/asm/sa1510.asm +++ /dev/null @@ -1,2833 +0,0 @@ -; Disassembly of the file "sa1510.rom" -; - -; Configurable parameters. These are set in the wrapper file, ie monitor_SA1510.asm -; -;COLW: EQU 40 ; Width of the display screen (ie. columns). -;ROW: EQU 25 ; Number of rows on display screen. -;SCRNSZ: EQU COLW * ROW ; Total size, in bytes, of the screen display area. - - ORG 00000H -MONIT: JP START -GETL: JP ?GETL -LETNL: JP ?LTNL -NL: JP ?NL -PRNTS: JP ?PRTS -PRNTT: JP ?PRTT -PRNT: JP ?PRNT -MSG: JP ?MSG -MSGX: JP ?MSGX ; RST 3 -GETKY: JP ?GET -BRKEY: JP ?BRK -WRINF: JP ?WRI -WRDAT: JP ?WRD -RDINF: JP ?RDI -RDDAT: JP ?RDD -VERFY: JP ?VRFY -MELDY: JP ?MLDY -TIMST: JP ?TMST - NOP - NOP - JP 1038H ; Interrupt routine -TIMRD: JP ?TMRD -BELL: JP ?BEL -XTEMP: JP ?TEMP -MSTA: JP MLDST -MSTP: JP MLDSP -START: LD SP,STACK - IM 1 - CALL ?MODE - LD B,0FFH - LD HL,NAME - CALL ?CLER ; Clear 256 bytes from NAME 10F1h to 11F0h - LD A,016H - CALL PRNT - IF MODE80C = 0 - LD A,007H ; Black background, white characters. Bit 7 is clear as a write to bit 7 @ DFFFH selects 40Char mode. - ELSE - LD A,017H ; Blue background, white characters in colour mode. Bit 7 is set as a write to bit 7 @ DFFFH selects 80Char mode. - ENDIF - LD HL,ARAM - JR STRT1 - JP 1035H ; NMI routine. -STRT1: CALL CLR8 - LD HL,TIMIN - LD A,0C3H - LD (1038H),A - LD (01039H),HL - LD A,004H - LD (TEMPW),A - CALL MLDSP - CALL NL - LD DE,00100H - RST 018H - IF MODE80C = 0 ; For 80 char mode we need a hook to setup SPAGE mode. - CALL ?BEL - ELSE - CALL HOOK ; Call new routine to setup SPAGE. - ENDIF -SS: LD A,0FFH -SS1: LD (SWRK),A - LD HL,USRROM - LD (HL),055H - JR FD2 - -ST1: CALL NL - LD A,'*' - CALL PRNT - LD DE,BUFER - CALL GETL -ST2: LD A,(DE) - INC DE - CP 00DH - JR Z,ST1 - CP 'J' ; JUMP? - JR Z,GOTO - CP 'L' ; LOAD? - JR Z,LOAD - CP 'F' ; FLOPPY? - JR Z,FD - CP 'B' ; BELL? - JR Z,SG - JR ST2 - - ; JUMP COMMAND -GOTO: CALL HLHEX - JR C,ST1 - JP (HL) - - ; KEY SOUND ON OFF -SG: LD A,(SWRK) - CPL - JR SS1 - - ; FLOPPY ROM CHECK AND RUN -FD: LD HL,FLPROM -FD2: LD A,(HL) - OR A - JR NZ,ST1 - JP (HL) - -?ER: CP 002H - JR Z,ST1 - LD DE,MSGE1 - RST 018H - JR ST1 - - ; LOAD COMMAND -LOAD: CALL ?RDI - JR C,?ER - CALL NL - LD DE,MSG?2 - RST 018H - LD DE,NAME - RST 018H - CALL ?RDD - JR C,?ER - LD HL,(EXADR) - LD A,H - CP 012H - JR C,ST1 - JP (HL) - - ; LOADING -MSG?2: DB 04CH, 0B7H, 0A1H, 09CH - DB 0A6H, 0B0H, 097H, 020H - DB 00DH - - ; SIGN ON BANNER -MSG?3: DB "** MONITOR SA-1510 **", 0DH - - ; For 80 Character mode we need some space, so shorten the Check Sum Error message. - ; - ; CHECK SUM ERROR -MSGE1: IF MODE80C = 0 - DB 043H, 098H, 092H, 09FH, 0A9H, 020H, 0A4H, 0A5H - DB 0B3H, 020H, 092H, 09DH, 09DH, 0B7H, 09DH, 00DH - ELSE - DB "CK SUM?", 0DH - ENDIF - - ; Hook = 7 bytes. -HOOK: IF MODE80C = 1 - LD A,0FFH - LD (SPAGE),A - JP ?BEL ; Original called routine - ENDIF - - ; CR PAGE MODE1 -.CR: CALL .MANG - RRCA - JP NC,CURS2 - LD L,000H - INC H - CP ROW - 1 ; End of line? - JR Z,.CP1 - INC H - JP CURS1 - -.CP1: LD (DSPXY),HL - - ; SCROLLER -.SCROL: LD BC,SCRNSZ - COLW ; Scroll COLW -1 lines - LD DE,SCRN ; Start of the screen. - LD HL,SCRN + COLW ; Start of screen + 1 line. - LDIR - EX DE,HL - LD B,COLW ; Clear last line at bottom of screen. - CALL ?CLER - LD BC,0001AH - LD DE,MANG - LD HL,MANG + 1 - LDIR - LD (HL),000H - LD A,(MANG) - OR A - JP Z,?RSTR - LD HL,DSPXY + 1 - DEC (HL) - JR .SCROL - - - ; CTBL PAGE MODE1 -.CTBL: DW .SCROL - DW CURSD - DW CURSU - DW CURSR - DW CURSL - DW HOM0 - DW CLRS - DW DEL - DW INST - DW ALPHA - DW KANA - DW ?RSTR - DW REV - DW .CR - DW ?RSTR - DW ?RSTR - -?MLDY: PUSH BC - PUSH DE - PUSH HL - LD A,002H - LD (OCTV),A - LD B,001H -MLD1: LD A,(DE) - CP 00DH - JR Z,MLD4 - CP 0C8H - JR Z,MLD4 - CP 0CFH - JR Z,MLD2 - CP 02DH - JR Z,MLD2 - CP 02BH - JR Z,MLD3 - CP 0D7H - JR Z,MLD3 - CP 023H - LD HL,MTBL - JR NZ,MLD1A - LD HL,M?TBL - INC DE -MLD1A: CALL ONPU - JR C,MLD1 - CALL RYTHM - JR C,MLD5 - CALL MLDST - LD B,C - JR MLD1 -MLD2: LD A,003H -MLD2A: LD (OCTV),A - INC DE - JR MLD1 -MLD3: LD A,001H - JR MLD2A -MLD4: CALL RYTHM -MLD5: PUSH AF - CALL MLDSP - POP AF - JP RET3 - -ONPU: PUSH BC - LD B,008H - LD A,(DE) -ONP1A: CP (HL) - JR Z,ONP2 - INC HL - INC HL - INC HL - DJNZ ONP1A - SCF - INC DE - POP BC - RET - -ONP2: INC HL - PUSH DE - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL - LD A,H - OR A - JR Z,ONP2B - LD A,(OCTV) -ONP2A: DEC A - JR Z,ONP2B - ADD HL,HL - JR ONP2A -ONP2B: LD (RATIO),HL - LD HL,OCTV - LD (HL),002H - DEC HL - POP DE - INC DE - LD A,(DE) - LD B,A - AND 0F0H - CP 030H - JR Z,ONP2C - LD A,(HL) - JR ONP2D -ONP2C: INC DE - LD A,B - AND 00FH - LD (HL),A -ONP2D: LD HL,OPTBL - ADD A,L - LD L,A - LD C,(HL) - LD A,(TEMPW) - LD B,A - XOR A - JP L09AB - -MTBL: DB 043H - DB 077H - DB 007H - DB 044H - DB 0A7H - DB 006H - DB 045H - DB 0EDH - DB 005H - DB 046H - DB 098H - DB 005H - DB 047H - DB 0FCH - DB 004H - DB 041H - DB 071H - DB 004H - DB 042H - DB 0F5H - DB 003H - DB 052H - DB 000H - DB 000H -M?TBL: DB 043H - DB 00CH - DB 007H - DB 044H - DB 047H - DB 006H - DB 045H - DB 098H - DB 005H - DB 046H - DB 048H - DB 005H - DB 047H - DB 0B4H - DB 004H - DB 041H - DB 031H - DB 004H - DB 042H - DB 0BBH - DB 003H - DB 052H - DB 000H - DB 000H - -OPTBL: DB 001H - DB 002H - DB 003H - DB 004H - DB 006H - DB 008H - DB 00CH - DB 010H - DB 018H - DB 020H - -?SAVE: LD HL,FLSDT - LD (HL),0EFH - LD A,(KANAF) - OR A - JR Z,L0270 - LD (HL),0FFH -L0270: LD A,(HL) - PUSH AF - CALL ?PONT - LD A,(HL) - LD (FLASH),A - POP AF - LD (HL),A - XOR A - LD HL,KEYPA - LD (HL),A - CPL - LD (HL),A - RET - -MGP.I: PUSH AF - PUSH HL - LD HL,MGPNT - LD A,(HL) - INC A - CP 033H - JR NZ,L028F - XOR A -L028F: PUSH HL - LD L,A - LD A,(SPAGE) - OR A - LD A,L - POP HL - JR NZ,L029A - LD (HL),A -L029A: POP HL - POP AF - RET - -MGP.D: PUSH AF - PUSH HL - LD HL,MGPNT - LD A,(HL) - DEC A - JP P,L028F - LD A,032H - JR L028F -MLDST: LD HL,(RATIO) - LD A,H - OR A - JR Z,MLDSP - PUSH DE - EX DE,HL - LD HL,CONT0 - LD (HL),E - LD (HL),D - LD A,001H - POP DE - JR L02C4 -MLDSP: LD A,034H - LD (CONTF),A - XOR A -L02C4: LD (SUNDG),A - RET - -RYTHM: LD HL,KEYPA - LD (HL),0F0H - INC HL - LD A,(HL) - AND 081H - JR NZ,L02D5 - SCF - RET - -L02D5: LD A,(SUNDG) - RRCA - JR C,L02D5 -L02DB: LD A,(SUNDG) - RRCA - JR NC,L02DB - DJNZ L02D5 - XOR A - RET - -?BEL: PUSH DE - LD DE,00DB1H - RST 030H - POP DE - RET - -?TEMP: PUSH AF - PUSH BC - AND 00FH - LD B,A - LD A,008H - SUB B - LD (TEMPW),A - POP BC - POP AF - RET - -?TMST: DI - PUSH BC - PUSH DE - PUSH HL - LD (AMPM),A - LD A,0F0H - LD (TIMFG),A - LD HL,0A8C0H - XOR A - SBC HL,DE - PUSH HL - INC HL - EX DE,HL - LD HL,CONTF - LD (HL),074H - LD (HL),0B0H - DEC HL - LD (HL),E - LD (HL),D - DEC HL - LD (HL),00AH - LD (HL),000H - INC HL - INC HL - LD (HL),080H - DEC HL -L0323: LD C,(HL) - LD A,(HL) - CP D - JR NZ,L0323 - LD A,C - CP E - JR NZ,L0323 - DEC HL - NOP - NOP - NOP - LD (HL),00CH - LD (HL),07BH - INC HL - POP DE -L0336: LD C,(HL) - LD A,(HL) - CP D - JR NZ,L0336 - LD A,C - CP E - JR NZ,L0336 - POP HL - POP DE - POP BC - EI - RET - -?TMRD: PUSH HL - LD HL,CONTF - LD (HL),080H - DEC HL - DI - LD E,(HL) - LD D,(HL) - EI - LD A,E - OR D - JR Z,?TMR1 - XOR A - LD HL,0A8C0H - SBC HL,DE - JR C,?TMR2 - EX DE,HL - LD A,(AMPM) - POP HL - RET - -?TMR1: LD DE,0A8C0H -?TMR1A: LD A,(AMPM) - XOR 001H - POP HL - RET - -?TMR2: DI - LD HL,CONT2 - LD A,(HL) - CPL - LD E,A - LD A,(HL) - CPL - LD D,A - EI - INC DE - JR ?TMR1A - -TIMIN: PUSH AF - PUSH BC - PUSH DE - PUSH HL - LD HL,AMPM - LD A,(HL) - XOR 001H - LD (HL),A - LD HL,CONTF - LD (HL),080H - DEC HL - PUSH HL - LD E,(HL) - LD D,(HL) - LD HL,0A8C0H - ADD HL,DE - DEC HL - DEC HL - EX DE,HL - POP HL - LD (HL),E - LD (HL),D - POP HL - POP DE - POP BC - POP AF - EI - RET - -.DSP03: EX DE,HL - LD (HL),001H - INC HL - LD (HL),000H - JP CURSR -.MANG2: LD A,(DSPXY + 1) - ADD A,L - LD L,A - LD A,(HL) - INC HL - RL (HL) - OR (HL) - RR (HL) - RRCA - EX DE,HL - LD HL,(DSPXY) - RET - - LD C,H - POP AF -PRTHL: LD A,H - CALL PRTHX - LD A,L - JR PRTHX - LD B,E - LD B,E -PRTHX: PUSH AF - RRCA - RRCA - RRCA - RRCA - CALL ASC - CALL PRNT - POP AF - CALL ASC - JP PRNT -L03D5: POP DE - POP HL - POP BC - POP AF - RET - -ASC: AND 00FH - CP 00AH - JR C,NOADD - ADD A,007H -NOADD: ADD A,030H - RET - -HEXJ: CP 030H - RET C - CP 03AH - JR C,HEX1 - SUB 007H - CP 040H - JR NC,HEX2 -HEX1: AND 00FH - RET -HEX2: SCF - RET - - ; Unused memory. - LD C,B - LD C,H - -HEX: JR HEXJ - -HOME: LD HL,(DSPXY) - LD A,(MGPNT) - SUB H - JR NC,HOM1 - ADD A,032H -HOM1: LD (MGPNT),A -HOM0: LD HL,00000H - JP CURS3 - - ; Unused memory. - INC L - -HLHEX: PUSH DE - CALL L041F - JR C,L041D - LD H,A - CALL L041F - JR C,L041D - LD L,A -L041D: POP DE - RET - -L041F: PUSH BC - LD A,(DE) - INC DE - CALL HEX - JR C,L0434 - RRCA - RRCA - RRCA - RRCA - LD C,A - LD A,(DE) - INC DE - CALL HEX - JR C,L0434 - OR C -L0434: POP BC - RET - -?WRI: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D7H - LD E,0CCH - LD HL,STACK - LD BC,00080H -L0444: CALL L071A - CALL MOTOR - JR C,L0464 - LD A,E - CP 0CCH - JR NZ,L045E - CALL NL - PUSH DE - LD DE,MSG?7 ; Writing Message - RST 018H - LD DE,NAME - RST 018H - POP DE -L045E: CALL L077A - CALL L0485 -L0464: JP L0552 - - ; Writing -MSG?7: DB 057H, 09DH, 0A6H, 096H, 0A6H - DB 0B0H, 097H, 020H, 00DH - -?WRD: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D7H - LD E,053H - LD BC,(SIZE) - LD HL,(DTADR) - LD A,B - OR C - JR Z,L04CB - JR L0444 -L0485: PUSH DE - PUSH BC - PUSH HL - LD D,002H - LD A,0F0H - LD (KEYPA),A -L048F: LD A,(HL) - CALL L0767 - LD A,(KEYPB) - AND 081H - JP NZ,L049E - SCF - JR L04CB -L049E: INC HL - DEC BC - LD A,B - OR C - JP NZ,L048F - LD HL,(SUMDT) - LD A,H - CALL L0767 - LD A,L - CALL L0767 - CALL L0D57 - DEC D - JP NZ,L04BB - OR A - JP L04CB -L04BB: LD B,000H -L04BD: CALL L0D3E - DEC B - JP NZ,L04BD - POP HL - POP BC - PUSH BC - PUSH HL - JP L048F -L04CB: POP HL - POP BC - POP DE - RET - -?RDI: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D2H - LD E,0CCH - LD BC,00080H - LD HL,STACK -L04DD: CALL MOTOR - JP C,L0570 - CALL TMARK - JP C,L0570 - CALL L0505 - JP L0552 - -?RDD: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D2H - LD E,053H - LD BC,(SIZE) - LD HL,(DTADR) - LD A,B - OR C - JP Z,L0552 - JR L04DD -L0505: PUSH DE - PUSH BC - PUSH HL - LD H,002H -L050A: LD BC,KEYPB - LD DE,KEYPC -L0510: CALL EDGE - JP C,L0570 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,L0510 - LD D,H - LD HL,00000H - LD (SUMDT),HL - POP HL - POP BC - PUSH BC - PUSH HL -L052A: CALL RBYTE - JP C,L0570 - LD (HL),A - INC HL - DEC BC - LD A,B - OR C - JP NZ,L052A - LD HL,(SUMDT) - CALL RBYTE - JP C,L0570 - LD E,A - CALL RBYTE - JP C,L0570 - CP L - JP NZ,L0563 - LD A,E - CP H - JP NZ,L0563 -L0551: XOR A -L0552: POP HL - POP BC - POP DE - CALL MSTOP - PUSH AF - LD A,(TIMFG) - CP 0F0H - JR NZ,L0561 - EI -L0561: POP AF - RET - -L0563: DEC D - JR Z,L056C - LD H,D - CALL GAPCK - JR L050A -L056C: LD A,001H - JR L0572 -L0570: LD A,002H -L0572: SCF - JR L0552 - - -?VRFY: DI - PUSH DE - PUSH BC - PUSH HL - LD BC,(SIZE) - LD HL,(DTADR) - LD D,0D2H - LD E,053H - LD A,B - OR C - JR Z,L0552 - CALL L071A - CALL MOTOR - JR C,L0570 - CALL TMARK - JP C,L0570 - CALL TVRFY - JR L0552 - -TVRFY: PUSH DE - PUSH BC - PUSH HL - LD H,002H -TVF1: LD BC,KEYPB - LD DE,KEYPC -TVF2: CALL EDGE - JP C,L0570 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,TVF2 - LD D,H - POP HL - POP BC - PUSH BC - PUSH HL -TVF3: CALL RBYTE - JP C,L0570 - CP (HL) - JP NZ,L056C - INC HL - DEC BC - LD A,B - OR C - JP NZ,TVF3 - LD HL,(CSMDT) - CALL RBYTE - CP H - JR NZ,L056C - CALL RBYTE - CP L - JR NZ,L056C - DEC D - JP Z,L0551 - LD H,D - JR TVF1 - - ; PRINT '00' -GETLD: LD DE,DBLZERO - RST 018H - JP AUTO2 - - ; ROLL UP -ROLUP: LD HL,PBIAS - LD A,(ROLEND) - CP (HL) - JP Z,?RSTR - JP ROLU1 - -?LOAD: PUSH AF - LD A,(FLASH) - CALL ?PONT - LD (HL),A - POP AF - RET - - ; Unused memory - XOR E - LD C,A - -EDGE: LD A,0F0H - LD (KEYPA),A - NOP -EDG1: LD A,(BC) - AND 081H - JP NZ,EDG1A - SCF - RET -EDG1A: LD A,(DE) - AND 020H - JP NZ,EDG1 -EDG2: LD A,(BC) - AND 081H - JP NZ,EDG3 - SCF - RET -EDG3: LD A,(DE) - AND 020H - JP Z,EDG2 - RET - -RBYTE: PUSH BC - PUSH DE - PUSH HL - LD HL,00800H - LD BC,KEYPB - LD DE,KEYPC -RBY1: CALL EDGE - JP C,RBY3 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,RBY2 - PUSH HL - LD HL,(SUMDT) - INC HL - LD (SUMDT),HL - POP HL - SCF -RBY2: LD A,L - RLA - LD L,A - DEC H - JP NZ,RBY1 - CALL EDGE - LD A,L -RBY3: POP HL - POP DE - POP BC - RET - -TMARK: CALL GAPCK - PUSH BC - PUSH DE - PUSH HL - LD HL,02828H ; 40 short and 40 long gap pulses - LD A,E - CP 0CCH - JP Z,TM0 - LD HL,01414H ; 20 short and 20 long tape mark pulses -TM0: LD (TMCNT),HL - LD BC,KEYPB - LD DE,KEYPC -TM1: LD HL,(TMCNT) -TM2: CALL EDGE - JP C,RET3 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,TM1 - DEC H - JP NZ,TM2 -TM3: CALL EDGE - JP C,RET3 - CALL DLY3 - LD A,(DE) - AND 020H - JP NZ,TM1 - DEC L - JP NZ,TM3 - CALL EDGE -RET3: -TM4: POP HL - POP DE - POP BC - RET - -MOTOR: PUSH BC - PUSH DE - PUSH HL - LD B,00AH -MOT1: LD A,(KEYPC) - AND 010H - JR Z,MOT4 -MOT2: LD B,0A6H -L06B1: CALL DLY12 - DJNZ L06B1 - XOR A -MOT7: JR RET3 -MOT4: LD A,006H - LD HL,KEYPF - LD (HL),A - INC A - LD (HL),A - DJNZ MOT1 - CALL NL - LD A,D - CP 0D7H - JR Z,MOT8 - LD DE,00D9EH - JR MOT9 -MOT8: LD DE,MSG_3 ; RECORD message. - RST 018H - LD DE,00DA0H -MOT9: RST 018H -MOT5: LD A,(KEYPC) - AND 010H - JR NZ,MOT2 - CALL ?BRK - JR NZ,MOT5 - SCF - JR MOT7 - -L06E7: LD B,0C9H - LD A,(KANAF) - OR A - JR NZ,L06F0 - INC B -L06F0: LD A,B - JP ?KY1 - - ; PRESS RECORD message. -MSG_3: DB 07FH, 020H - DB 052H, 045H, 043H, 04FH, 052H - DB 044H, 02EH, 00DH - - ; Padding not used - DB 034H - DB 044H - -MSTOP: PUSH AF - PUSH BC - PUSH DE - LD B,00AH -L0705: LD A,(KEYPC) - AND 010H - JR Z,L0717 - LD A,006H - LD (KEYPF),A - INC A - LD (KEYPF),A - DJNZ L0705 -L0717: JP ?RSTR1 -L071A: PUSH BC - PUSH DE - PUSH HL - LD DE,00000H -L0720: LD A,B - OR C - JR NZ,L072F - EX DE,HL - LD (SUMDT),HL - LD (CSMDT),HL - POP HL - POP DE - POP BC - RET - -L072F: LD A,(HL) - PUSH BC - LD B,008H -L0733: RLCA - JR NC,L0737 - INC DE -L0737: DJNZ L0733 - POP BC - INC HL - DEC BC - JR L0720 -L073E: RLCA - RLCA - RLCA - LD C,A - LD A,E -L0743: DEC H - RRCA - JR NC,L0743 - LD A,H - ADD A,C - LD C,A - JP SWEP01 -?MODE: LD HL,KEYPF - LD (HL),08AH - LD (HL),007H - LD (HL),005H - LD (HL),001H - RET - -L0759: LD A,00EH -L075B: DEC A - JP NZ,L075B - RET - -L0760: LD A,00DH -L0762: DEC A - JP NZ,L0762 - RET - -L0767: PUSH BC - LD B,008H - CALL L0D57 -L076D: RLCA - CALL C,L0D57 - CALL NC,L0D3E - DEC B - JP NZ,L076D - POP BC - RET - -L077A: PUSH BC - PUSH DE - LD A,E - LD BC,055F0H - LD DE,02828H - CP 0CCH - JP Z,L078E - LD BC,02AF8H - LD DE,01414H -L078E: CALL L0D3E - DEC BC - LD A,B - OR C - JR NZ,L078E -L0796: CALL L0D57 - DEC D - JR NZ,L0796 -L079C: CALL L0D3E - DEC E - JR NZ,L079C - CALL L0D57 - POP DE - POP BC - RET - -?GETL: PUSH AF - PUSH BC - PUSH HL - PUSH DE -GETL0: CALL ?SAVE -GETL0A: CALL ?KEY - CP 0CBH - JR Z,GETL0A -GETL0B: CALL ?KEY - CALL ?FLAS - JR Z,GETL0B -GETL0C: PUSH AF - XOR A - LD (STRGF),A - POP AF -AUTO3: LD B,A -GETL0D: CALL ?LOAD - LD A,(SWRK) - OR A - CALL Z,?BEL - LD A,B - CP 0E7H - JP Z,GETLD - CP 0E6H - JR Z,CHGPK - CP 0EEH - JR Z,CHGPA - CP 0E5H - JR Z,DMT - CP 0E0H - JP Z,LOCK - JR NC,GETL0B - AND 0F0H - CP 0C0H - JR NZ,GETL2 - LD A,B - CP 0CDH - JR Z,GETL3 - CP 0CBH - JP Z,GETLC - CP 0C7H - JR NC,GETL5 - LD A,(KANAF) - OR A - LD A,B - JR Z,GETL5 -GETL2: LD A,B - CALL ?DSP -AUTO2: CALL ?SAVE - LD A,(STRGF) - OR A - JR NZ,AUTO5 -AUTOL: LD E,014H -AUTOL1: CALL ?KEY - JR NZ,AUTO3 - CALL AUTCK -GETL1: JR C,GETL0B - DEC E - JR NZ,AUTOL1 - LD A,001H - LD (STRGF),A -AUTO5: CALL DLY12 - CALL DLY12 - CALL ?KEY - CALL ?FLAS - JR NZ,GETL0C - CALL AUTCK - JR C,GETL1 - JR GETL0D -GETL5: CALL ?DPCT - JR AUTO2 - -CHGPA: XOR A - IF MODE80C = 1 - JR CHGPK - ELSE - JR CHGPK1 - ENDIF -CHGPK: LD A,0FFH -CHGPK1: LD (SPAGE),A - LD A,0C6H - CALL ?DPCT -CHGP1: JP GETL0 - -GETLC: POP HL - PUSH HL - LD (HL),01BH - INC HL - LD (HL),00DH - JR GETLR - -DMT: LD B,05AH - JR GETL2 - -GETL3: CALL .MANG - LD B,COLW ; PDS was 028H - JR NC,GETLA - DEC H -GETLB: LD B,COLW*2 ; 050H -GETL6: LD L,000H - CALL ?PNT1 - POP DE - PUSH DE -GETL6A: LD A,(HL) - CALL ?DACN - LD (DE),A - INC HL - RES 3,H - INC DE - DJNZ GETL6A - EX DE,HL -GETL6B: LD (HL),00DH - DEC HL - LD A,(HL) - CP 020H - JR Z,GETL6B -GETLR: CALL ?LTNL - JP L03D5 - -GETLA: RRCA - JR NC,GETL6 - JR GETLB - -LOCK: LD HL,SFTLK - LD A,(HL) - CPL - LD (HL),A - JR CHGP1 - -?MSG: PUSH AF - PUSH BC - PUSH DE -MSG1: LD A,(DE) - CP 00DH - JR Z,MSGX2 - CALL ?PRNT - INC DE - JR MSG1 - -?MSGX: PUSH AF - PUSH BC - PUSH DE -MSGX1: LD A,(DE) - CP 00DH -MSGX2: JP Z,?RSTR1 - CALL ?ADCN - CALL PRNT3 - INC DE - JR MSGX1 - -?GET: PUSH BC - PUSH HL - LD B,009H - LD HL,SWPW + 1 - CALL ?CLRFF - POP HL - POP BC - CALL ?KEY - SUB 0F0H - RET Z - ADD A,0F0H - JP ?DACN - -?KEY: PUSH BC - PUSH DE - PUSH HL - CALL ?SWEP - LD A,B - RLCA - JR C,?KY2 - LD A,0F0H -?KY1: LD E,A - CALL AUTCK - LD A,(KDATW) - OR A - JR Z,?KY11 - CALL DLY12 - CALL ?SWEP - LD A,B - RLCA - JR C,?KY2 -?KY11: LD A,E - CP 0F0H - JR NZ,?KY9 -?KY10: JP RET3 -?KY2: RLCA - RLCA - RLCA - JP C,L06E7 - RLCA - JP C,_BRK - LD H,000H - LD L,C - LD A,C - CP 038H - JR NC,?KY6 - LD A,(KANAF) - OR A - LD A,B - RLCA - JR NZ,?KY4 - LD B,A - LD A,(SFTLK) - OR A - LD A,B - JR Z,L0917 - RLA - CCF - RRA -L0917: RLA - RLA - JR NC,?KY3 -L091B: LD DE,KTBLC -?KY5: ADD HL,DE - LD A,(HL) - JR ?KY1 -?KY3: RRA - JR NC,?KY6 - LD DE,KTBLS - JR ?KY5 -?KY6: LD DE,KTBL ; 00BEAH - JR ?KY5 -?KY4: RLCA - JR C,?KY7 - RLCA - JR C,L091B - LD DE,KTBLG - JR ?KY5 -?KY7: LD DE,KTBLGS - JR ?KY5 -?KY9: CALL AUTCK - INC A - LD A,E - JR ?KY10 - -?PRT: LD A,C - CALL ?ADCN - LD C,A - AND 0F0H - CP 0F0H - RET Z - - CP 0C0H - LD A,C - JR NZ,PRNT3 -PRNT5: CALL ?DPCT - CP 0C3H - JR Z,PRNT4 - CP 0C5H - JR Z,PRNT2 - CP 0CDH ; CR - JR Z,PRNT2 - CP 0C6H - RET NZ - -PRNT2: XOR A -PRNT2A: LD (DPRNT),A - RET - -PRNT3: CALL ?DSP -PRNT4: LD A,(DPRNT) - INC A - CP COLW*2 ; 050H - JR C,PRNT4A - SUB COLW*2 ; 050H -PRNT4A: JR PRNT2A - -?NL: LD A,(DPRNT) - OR A - RET Z - -?LTNL: LD A,0CDH - JR PRNT5 -?PRTT: CALL PRNTS - LD A,(DPRNT) - OR A - RET Z - -L098C: SUB 00AH - JR C,?PRTT - JR NZ,L098C - RET - -?PRTS: LD A,020H -?PRNT: CP 00DH - JR Z,?LTNL - PUSH BC - LD C,A - LD B,A - CALL ?PRT - LD A,B - POP BC - RET - -DLY3: NEG - NEG - LD A,02AH - JP L0762 -L09AB: ADD A,C - DJNZ L09AB - POP BC - LD C,A - XOR A - RET - - DB 010H -??KEY: PUSH BC - PUSH DE - PUSH HL - CALL ?SAVE -L09B9: CALL ?KEY - CALL ?FLAS - JR Z,L09B9 - CALL ?LOAD - JP RET3 -L09C7: PUSH DE - PUSH HL - LD HL,PBIAS - XOR A - RLD - LD D,A - LD E,(HL) - RRD - XOR A - RR D - RR E - LD HL,SCRN - ADD HL,DE - LD (PAGETP),HL - POP HL - POP DE - RET - -L09E2: XOR A -CLR8: LD BC,00800H - PUSH DE - LD D,A -L09E8: LD (HL),D - INC HL - DEC BC - LD A,B - OR C - JR NZ,L09E8 - POP DE - RET - -AUTCK: LD HL,KDATW - LD A,(HL) - INC HL - LD D,(HL) - LD (HL),A - SUB D - RET NC - INC (HL) - RET - -DBLZERO:DB 030H - DB 030H - DB 00DH - -?FLAS: PUSH AF - PUSH HL - LD A,(KEYPC) - RLCA - RLCA - JR C,FLAS1 - LD A,(FLSDT) -FLAS2: CALL ?PONT - LD (HL),A -FLAS3: POP HL - POP AF - RET - -FLAS1: LD A,(FLASH) - JR FLAS2 - -REV: LD HL,REVFLG - LD A,(HL) - OR A - CPL - LD (HL),A - JR Z,REV1 - LD A,(INVDSP) - JR REV2 -REV1: LD A,(NRMDSP) -REV2: JP ?RSTR - -.MANG: LD HL,MANG - LD A,(SPAGE) - OR A - JP NZ,.MANG2 - LD A,(MGPNT) -.MANG3: SUB 008H - INC HL - JR NC,.MANG3 - ADD A,008H - LD C,(HL) - DEC HL - LD B,A - INC B - PUSH BC - LD A,(HL) -.MANG4: RR C - RRA - DJNZ .MANG4 - POP BC - EX DE,HL -.MANG1: LD HL,(DSPXY) - RET - -?SWEP: PUSH DE - PUSH HL - XOR A - LD (KDATW),A - LD B,0FAH - LD D,A - CALL ?BRK - JR NZ,SWEP6 - LD D,088H - JR SWEP9 -SWEP6: LD HL,SWPW - PUSH HL - JR NC,SWEP11 - LD D,A - AND 060H - JR NZ,SWEP11 - LD A,D - XOR (HL) - BIT 4,A - LD (HL),D - JR Z,SWEP0 -SWEP01: SET 7,D -SWEP0: DEC B - POP HL - INC HL - LD A,B - LD (KEYPA),A - CP 0F0H - JR NZ,SWEP3 - LD A,(HL) - CP 003H - JR C,SWEP9 - LD (HL),000H - RES 7,D -SWEP9: LD B,D - POP HL - POP DE - RET - -SWEP11: LD (HL),000H - JR SWEP0 -SWEP3: LD A,(KEYPB) - LD E,A - CPL - AND (HL) - LD (HL),E - PUSH HL - LD HL,KDATW - PUSH BC - LD B,008H -SWEP8: RLC E - JR C,SWEP7 - INC (HL) -SWEP7: DJNZ SWEP8 - POP BC - OR A - JR Z,SWEP0 - LD E,A -SWEP2: LD H,008H - LD A,B - DEC A - AND 00FH - JP L073E - -; ASCII TO DISPLAY CODE TABLE -ATBL: DB 0CCH - DB 0E0H - DB 0F2H - DB 0F3H - DB 0CEH - DB 0CFH - DB 0F6H - DB 0F7H - DB 0F8H - DB 0F9H - DB 0FAH - DB 0FBH - DB 0FCH - DB 0FDH - DB 0FEH - DB 0FFH - DB 0E1H - DB 0C1H - DB 0C2H - DB 0C3H - DB 0C4H - DB 0C5H - DB 0C6H - DB 0E2H - DB 0E3H - DB 0E4H - DB 0E5H - DB 0E6H - DB 0EBH - DB 0EEH - DB 0EFH - DB 0F4H - DB 000H ; 32 space - DB 061H ; 33 a - DB 062H - DB 063H - DB 064H - DB 065H - DB 066H - DB 067H - DB 068H - DB 069H - DB 06BH - DB 06AH - DB 02FH - DB 02AH - DB 02EH - DB 02DH - DB 020H - DB 021H - DB 022H - DB 023H - DB 024H - DB 025H - DB 026H - DB 027H - DB 028H - DB 029H - DB 04FH - DB 02CH - DB 051H - DB 02BH - DB 057H - DB 049H - DB 055H - DB 001H - DB 002H - DB 003H - DB 004H - DB 005H - DB 006H - DB 007H - DB 008H - DB 009H - DB 00AH - DB 00BH - DB 00CH - DB 00DH - DB 00EH - DB 00FH - DB 010H - DB 011H - DB 012H - DB 013H - DB 014H - DB 015H - DB 016H - DB 017H - DB 018H - DB 019H - DB 01AH - DB 052H - DB 059H - DB 054H - DB 050H - DB 045H - DB 0C7H - DB 0C8H - DB 0C9H - DB 0CAH - DB 0CBH - DB 0CCH - DB 0CDH - DB 0CEH - DB 0CFH - DB 0DFH - DB 0E7H - DB 0E8H - DB 0E9H - DB 0EAH - DB 0ECH - DB 0EDH - DB 0D0H - DB 0D1H - DB 0D2H - DB 0D3H - DB 0D4H - DB 0D5H - DB 0D6H - DB 0D7H - DB 0D8H - DB 0D9H - DB 0DAH - DB 0DBH - DB 0DCH - DB 0DDH - DB 0DEH - DB 0C0H - DB 040H - DB 0BDH - DB 09DH - DB 0B1H - DB 0B5H - DB 0B9H - DB 0B4H - DB 09EH - DB 0B2H - DB 0B6H - DB 0BAH - DB 0BEH - DB 09FH - DB 0B3H - DB 0B7H - DB 0BBH - DB 0BFH - DB 0A3H - DB 085H - DB 0A4H - DB 0A5H - DB 0A6H - DB 094H - DB 087H - DB 088H - DB 09CH - DB 082H - DB 098H - DB 084H - DB 092H - DB 090H - DB 083H - DB 091H - DB 081H - DB 09AH - DB 097H - DB 093H - DB 095H - DB 089H - DB 0A1H - DB 0AFH - DB 08BH - DB 086H - DB 096H - DB 0A2H - DB 0ABH - DB 0AAH - DB 08AH - DB 08EH - DB 0B0H - DB 0ADH - DB 08DH - DB 0A7H - DB 0A8H - DB 0A9H - DB 08FH - DB 08CH - DB 0AEH - DB 0ACH - DB 09BH - DB 0A0H - DB 099H - DB 0BCH - DB 0B8H - DB 080H - DB 03BH - DB 03AH - DB 070H - DB 03CH - DB 071H - DB 05AH - DB 03DH - DB 043H - DB 056H - DB 03FH - DB 01EH - DB 04AH - DB 01CH - DB 05DH - DB 03EH - DB 05CH - DB 01FH - DB 05FH - DB 05EH - DB 037H - DB 07BH - DB 07FH - DB 036H - DB 07AH - DB 07EH - DB 033H - DB 04BH - DB 04CH - DB 01DH - DB 06CH - DB 05BH - DB 078H - DB 041H - DB 035H - DB 034H - DB 074H - DB 030H - DB 038H - DB 075H - DB 039H - DB 04DH - DB 06FH - DB 06EH - DB 032H - DB 077H - DB 076H - DB 072H - DB 073H - DB 047H - DB 07CH - DB 053H - DB 031H - DB 04EH - DB 06DH - DB 048H - DB 046H - DB 07DH - DB 044H - DB 01BH - DB 058H - DB 079H - DB 042H - DB 060H - DB 0FDH - DB 0CBH - DB 000H - DB 01EH - -?ADCN: PUSH BC - PUSH HL - LD HL,ATBL ;00AB5H - LD C,A - LD B,000H - ADD HL,BC - LD A,(HL) - JR DACN3 - -_BRK: LD A,0CBH - OR A - JP ?KY10 - - ; Unused memory. - DB 029H - DB 0F4H - DB 0DDH - -?DACN: PUSH BC - PUSH HL - PUSH DE - LD HL,ATBL - LD D,H - LD E,L - LD BC,00100H - CPIR - JR Z,DACN1 - LD A,0F0H -DACN2: POP DE -DACN3: POP HL - POP BC - RET - -DACN1: OR A - DEC HL - SBC HL,DE - LD A,L - JR DACN2 - -KTBL: ;S0 00 - 07 ; - DB 022H ; 2 - DB 021H ; 1 - DB 017H ; W - DB 011H ; Q - DB 001H ; A - DB 0C7H ; DEL - DB 000H ; NULL - DB 01AH ; Z - ;S1 08 - 0F ; - DB 024H ; 4 - DB 023H ; 3 - DB 012H ; R - DB 005H ; E - DB 004H ; D - DB 013H ; S - DB 018H ; X - DB 003H ; C - ;S2 10 - 17 ; - DB 026H ; 6 - DB 025H ; 5 - DB 019H ; Y - DB 014H ; T - DB 007H ; G - DB 006H ; F - DB 016H ; V - DB 002H ; B - ;S3 18 - 1F ; - DB 028H ; 8 - DB 027H ; 7 - DB 009H ; I - DB 015H ; U - DB 00AH ; J - DB 008H ; H - DB 00EH ; N - DB 000H ; SPACE - ;S4 20 - 27 ; - DB 020H ; 0 - DB 029H ; 9 - DB 010H ; P - DB 00FH ; O - DB 00CH ; L - DB 00BH ; K - DB 02FH ; , - DB 00DH ; M - ;S5 28 - 2F ; - DB 0BEH ; ^ - DB 02AH ; - - DB 052H ; [ - DB 055H ; @ - DB 04FH ; : - DB 02CH ; ; - DB 02DH ; / - DB 02EH ; . - ;S6 30 - 37 ; - DB 0C5H ; HOME - DB 059H ; \ - DB 0C3H ; CURSOR RIGHT - DB 0C2H ; CURSOR UP - DB 0CDH ; CR - DB 054H ; ] - DB 000H ; NULL - DB 049H ; ? - ;S7 38 - 3F ; - DB 028H ; 8 - DB 027H ; 7 - DB 025H ; 5 - DB 024H ; 4 - DB 022H ; 2 - DB 021H ; 1 - DB 0E7H ; 00 - DB 020H ; 0 - ; S8 ; - DB 06AH ; * - DB 029H ; 9 - DB 02AH ; - - DB 026H ; 6 - DB 000H ; NULL - DB 023H ; 3 - DB 000H ; NULL - DB 02EH ; , - -KTBLS: ;S0 00 - 07 ; - DB 062H ; " - DB 061H ; ! - DB 097H ; w - DB 091H ; q - DB 081H ; a - DB 0C8H ; INSERT - DB 000H ; NULL - DB 09AH ; z - ;S1 08 - 0F ; - DB 064H ; $ - DB 063H ; # - DB 092H ; r - DB 085H ; e - DB 084H ; d - DB 093H ; s - DB 098H ; x - DB 083H ; c - ;S2 10 - 17 ; - DB 066H ; & - DB 065H ; % - DB 099H ; y - DB 094H ; t - DB 087H ; g - DB 086H ; f - DB 096H ; v - DB 082H ; b - ;S3 18 - 1F ; - DB 068H ; ( - DB 067H ; ' - DB 089H ; i - DB 095H ; u - DB 08AH ; j - DB 088H ; h - DB 08EH ; n - DB 000H ; SPACE - ;S4 20 - 27 ; - DB 0BFH ; _ - DB 069H ; ) - DB 090H ; p - DB 08FH ; o - DB 08CH ; l - DB 08BH ; k - DB 051H ; < - DB 08DH ; m - ;S5 28 - 2F ; - DB 0A5H ; ~ - DB 02BH ; = - DB 0BCH ; ( - DB 0A4H ; ' - DB 06BH ; # - DB 06AH ; + - DB 045H ; <- - DB 057H ; > - ;S6 30 - 37 ; - DB 0C6H ; CLR - DB 080H ; | - DB 0C4H ; CURSOR LEFT - DB 0C1H ; CURSOR DOWN - DB 0CDH ; CR - DB 040H ; ) - DB 000H ; NULL - DB 050H ; UP^ - ; -KTBLG: ;S0 00 - 07 ; - DB 03EH ; #2 - DB 037H ; #1 - DB 038H ; #W - DB 03CH ; #Q - DB 053H ; #A - DB 0C7H ; #DEL - DB 000H ; #NULL - DB 076H ; #Z - ;S1 08 - 0F ; - DB 07BH ; #4 - DB 07FH ; #3 - DB 030H ; #R - DB 034H ; #E - DB 047H ; #D - DB 044H ; #S - DB 06DH ; #X - DB 0DEH ; #C - ;S2 10 - 17 ; - DB 05EH ; #6 - DB 03AH ; #5 - DB 075H ; #Y - DB 071H ; #T - DB 04BH ; #G - DB 04AH ; #F - DB 0DAH ; #V - DB 06FH ; #B - ;S3 18 - 1F ; - DB 0BDH ; #8 - DB 01FH ; #7 - DB 07DH ; #I - DB 079H ; #U - DB 05CH ; #J - DB 072H ; #H - DB 032H ; #N - DB 000H ; SPACE - ;S4 20 - 27 ; - DB 09CH ; #0 - DB 0A1H ; #9 - DB 0D6H ; #P - DB 0B0H ; #O - DB 0B4H ; #L - DB 05BH ; #K - DB 060H ; #, - DB 01CH ; #M - ;S5 28 - 2F ; - DB 09EH ; #^ - DB 0D2H ; #- - DB 0D8H ; #[ - DB 0B2H ; #@ - DB 0B6H ; ##: - DB 042H ; #; - DB 0DBH ; #/ - DB 0B8H ; #. - ;S6 30 - 37 ; - DB 0C5H ; HOME - DB 0D4H ; #\ - DB 0C3H ; CURSOR RIGHT - DB 0C2H ; CURSOR UP - DB 0CDH ; CR - DB 04EH ; #J - DB 000H ; NULL - DB 0BAH ; #? - ; -KTBLGS: ;S0 00 - 07 ; - DB 036H ; ?2 - DB 03FH ; ?1 - DB 078H ; ?W - DB 07CH ; ?Q - DB 046H ; ?A - DB 0C8H ; INST - DB 000H ; NULL - DB 077H ; ?Z - ;S1 08 - 0F ; - DB 03BH ; ?4 - DB 07EH ; ?3 - DB 070H ; ?R - DB 074H ; ?E - DB 048H ; ?D - DB 041H ; ?S - DB 0DDH ; ?X - DB 0D9H ; C - ;S2 10 - 17 ; - DB 01EH ; ?6 - DB 07AH ; ?5 - DB 035H ; ?Y - DB 031H ; ?T - DB 04CH ; ?G - DB 043H ; ?F - DB 0A6H ; ?V - DB 06EH ; ?B - ;S3 18 - 1F ; - DB 0A2H ; ?8 - DB 05FH ; ?7 - DB 03DH ; ?I - DB 039H ; ?U - DB 05DH ; ?J - DB 073H ; ?H - DB 033H ; ?N - DB 000H ; SPACE - ;S4 20 - 27 ; - DB 09DH ; ?0 - DB 0A3H ; ?9 - DB 0B1H ; ?P - DB 0D5H ; ?O - DB 056H ; ?L - DB 06CH ; ?K - DB 0D0H ; ?, - DB 01DH ; ?M - ;S5 28 - 2F ; - DB 09FH ; ?^ - DB 0D1H ; ?- - DB 0B3H ; ?[ - DB 0D7H ; ?@ - DB 04DH ; ?: - DB 0B5H ; ?; - DB 01BH ; ?/ - DB 0B9H ; ?. - ;S6 30 - 37 ; - DB 0C6H ; CLR - DB 0D3H ; ?\ - DB 0C4H ; CURSOR RIGHT - DB 0C1H ; CURSOR UP - DB 0CDH ; CR - DB 0B7H ; ?J - DB 000H ; NULL - DB 0BBH ; ?? - ; -KTBLC: ;S0 00 - 07 ; - DB 0F0H ; CODE 80H=NOT KEY - DB 0F0H ; - DB 0E2H ; CTRL + W - DB 0C1H ; CTRL + Q - DB 0E0H ; CTRL + A SHIFT LOCK - DB 0F0H ; - DB 000H ; - DB 0E5H ; CTRL + Z - ;S1 08 - 0F ; - DB 0F0H ; - DB 0F0H ; - DB 0C2H ; CTRL + R - DB 0CFH ; CTRL + E ROLL DOWN - DB 0CEH ; CTRL + D ROLL UP - DB 0C3H ; CTRL + S - DB 0E3H ; CTRL + X - DB 0F3H ; CTRL + C - ;S2 10 - 17 ; - DB 0F0H ; - DB 0F0H ; - DB 0E4H ; CTRL + Y - DB 0C4H ; CTRL + T - DB 0F7H ; CTRL + G - DB 0F6H ; CTRL + F - DB 0C6H ; CTRL + V CLR - DB 0F2H ; CTRL + B - ;S3 18 - 1F ; - DB 0F0H ; - DB 0F0H ; - DB 0F9H ; CTRL + I - DB 0C5H ; CTRL + U HOME - DB 0FAH ; CTRL + J - DB 0F8H ; CTRL + H - DB 0FEH ; CTRL + N - DB 0F0H ; - ;S4 20 - 27 ; - DB 0F0H ; - DB 0F0H ; - DB 0E1H ; CTRL + P - DB 0FFH ; CTRL + O - DB 0FCH ; CTRL + L - DB 0FBH ; CTRL + K - DB 0F0H ; - DB 0FDH ; CTRL + M - ;S5 28 - 2F ; - DB 0EFH ; CTRL + ^ - DB 0F4H ; CTRL + - - DB 0E6H ; CTRL + [ - DB 0CCH ; CTRL + @ REVERSE - DB 0F0H ; - DB 0F0H ; - DB 0F0H ; - DB 0F0H ; - ;S6 30 - 37 ; - DB 0F0H ; - DB 0EBH ; CTRL + \ - DB 0F0H ; - DB 0F0H ; - DB 0F0H ; - DB 0EEH ; CTRL + ] - DB 0F0H ; - -?BRK: LD A,0F0H - LD (KEYPA),A - NOP - LD A,(KEYPB) - OR A - RLA - JR NC,L0D37 - RRA - RRA - JR NC,L0D27 - RRA - JR NC,L0D2B - CCF - RET - -L0D27: LD A,040H - SCF - RET - -L0D2B: LD A,(KDATW) - LD A,001H - LD (KDATW),A - LD A,010H - SCF - RET - -L0D37: AND 002H - RET Z - - LD A,020H - SCF - RET - -L0D3E: PUSH AF - LD A,003H - LD (KEYPF),A - CALL L0759 - CALL L0759 - LD A,002H - LD (KEYPF),A - CALL L0759 - CALL L0759 - POP AF - RET - -L0D57: PUSH AF - LD A,003H - LD (KEYPF),A - CALL L0759 - CALL L0759 - CALL L0759 - CALL L0759 - LD A,002H - LD (KEYPF),A - CALL L0759 - CALL L0759 - CALL L0759 - CALL L0760 - POP AF - RET - -?DSPA: CP 008H - JR Z,L0D90 -L0D80: RRC (HL) - DJNZ L0D80 - SET 0,(HL) - RES 1,(HL) - LD B,A -L0D89: RLC (HL) - DJNZ L0D89 -DSP04: JP CURSR -L0D90: INC HL - SET 0,(HL) - RES 1,(HL) - JR DSP04 -DSP02: SET 7,(HL) - INC HL - RES 0,(HL) - JR DSP04 - - -MSG_1: DB 07FH, 020H -MSG_2: DB 050H, 04CH, 041H, 059H, 00DH, 0F3H - -?BLNK: RET - -DLY12: PUSH BC - LD B,023H -DLY12A: CALL DLY3 - DJNZ DLY12A - POP BC - RET - - ; BELL DATA -?BELD: DB 0D7H, 041H, 030H, 00DH - -?DSP: PUSH AF - PUSH BC - PUSH DE - PUSH HL - LD B,A - CALL ?PONT - LD (HL),B - LD HL,(DSPXY) - LD A,L -DSP01: CP COLW - 1 ; End of line. - JR NZ,DSP04 - CALL .MANG - JR C,DSP04 - LD A,(SPAGE) - OR A - JP NZ,.DSP03 - EX DE,HL - LD A,B - CP 007H - JR Z,DSP02 - JR ?DSPA - - ; Unused memory. - INC H - DI - -?DPCT: PUSH AF ; Display control, character is mapped to a function call. - PUSH BC - PUSH DE - PUSH HL - LD B,A - AND 0F0H - CP 0C0H - JP NZ,?RSTR - XOR B - RLCA - LD C,A - LD B,000H - LD HL,CTBL - LD A,(SPAGE) - OR A - JR Z,DPCT1 - LD HL,.CTBL -DPCT1: ADD HL,BC - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL - JP (HL) - - -CTBL: DW SCROL - DW CURSD - DW CURSU - DW CURSR - DW CURSL - DW HOME - DW CLRS - DW DEL - DW INST - DW ALPHA - DW KANA - DW ?RSTR - DW REV - DW CR - DW ROLUP - DW ROLD - -;.CTBL: DW .SCROL -; DW CURSD -; DW CURSU -; DW CURSR -; DW CURSL -; DW HOM0 -; DW CLRS -; DW DEL -; DW INST -; DW ALPHA -; DW KANA -; DW ?RSTR -; DW REV -; DW .CR -; DW ?RSTR -; DW ?RSTR - -SCROL: LD HL,PBIAS - LD C,SCRLW ; Number of 8byte blocks in a line to scroll. - LD A,(ROLEND) - ADD A,C - LD (ROLEND),A - LD A,(ROLTOP) - ADD A,C - LD (ROLTOP),A -SCROL1: LD A,C - ADD A,(HL) - LD (HL),A - CALL L09C7 - LD HL,(PAGETP) - LD DE,SCRNSZ - ADD HL,DE ; HL=PAGETOP + 1000/2000 - LD B,COLW - XOR A -SCROL2: RES 3,H - LD (HL),A - INC HL - DJNZ SCROL2 - LD A,(PBIAS) ; PBIAS is the offest for hardware scroll. - LD L,A - LD H,SCLBASE ; Hardware scroll region, E2 - LD A,(HL) - LD HL,MANGE - OR A - LD B,007H -SCROL3: RR (HL) - DEC HL - DJNZ SCROL3 - JP ?RSTR - -CURSD: LD HL,(DSPXY) - LD A,H - CP ROW - 1 - JR Z,CURS4 - INC H -CURS1: CALL MGP.I -CURS3: LD (DSPXY),HL - JR ?RSTR - -CURSU: LD HL,(DSPXY) - LD A,H - OR A - JR Z,CURS5 - DEC H -CURSU1: CALL MGP.D - JR CURS3 - -CURSR: LD HL,(DSPXY) - LD A,L - CP COLW - 1 ; End of line - JR NC,CURS2 - INC L - JR CURS3 -CURS2: LD L,000H - INC H - LD A,H - CP ROW - JR C,CURS1 - LD H,ROW - 1 - LD (DSPXY),HL -CURS4: JR CURS6 - -CURSL: LD HL,(DSPXY) - LD A,L - OR A - JR Z,CURS5A - DEC L - JR CURS3 -CURS5A: LD L,COLW - 1 ; End of line - DEC H - JP P,CURSU1 - LD H,000H - LD (DSPXY),HL -CURS5: LD A,(SPAGE) - OR A - JR NZ,?RSTR - JP ROLD - -CLRS: LD HL,MANG - LD B,01BH - CALL ?CLER - LD HL,SCRN - PUSH HL - CALL L09E2 - POP HL - LD A,(SPAGE) - OR A - JR NZ,CLRS1 - LD (PAGETP),HL - LD A,07DH - LD (ROLEND),A -CLRS1: LD A,(SCLDSP) -HOM00: JP HOM0 - -CURS6: LD A,(SPAGE) - OR A - JP NZ,.SCROL - JP ROLU - -ALPHA: XOR A -ALPHI: LD (KANAF),A -?RSTR: POP HL -?RSTR1: POP DE - POP BC - POP AF - RET - - ; Unused memory - DEC C - DEC C - DEC C - DEC C - -KANA: LD A,001H - JR ALPHI - -DEL: LD HL,(DSPXY) - LD A,H - OR L - JR Z,?RSTR - LD A,L - OR A - JR NZ,DEL1 - CALL .MANG - JR C,DEL1 - CALL ?PONT - DEC HL - LD (HL),000H - JR CURSL -DEL1: CALL .MANG - RRCA - LD A,COLW - JR NC,L0F13 - RLCA -L0F13: SUB L - LD B,A - CALL ?PONT - PUSH HL - POP DE - DEC DE - SET 4,D -DEL2: RES 3,H - RES 3,D - LD A,(HL) - LD (DE),A - INC HL - INC DE - DJNZ DEL2 - DEC HL - LD (HL),000H - JP CURSL - -INST: CALL .MANG - RRCA - LD L,COLW - 1 ; End of line - LD A,L - JR NC,INST1A - INC H -INST1A: CALL ?PNT1 - PUSH HL - LD HL,(DSPXY) - JR NC,INST2 - LD A,(COLW*2)-1 ; 04FH -INST2: SUB L - LD B,A - POP DE - LD A,(DE) - OR A - JR NZ,?RSTR - CALL ?PONT - LD A,(HL) - LD (HL),000H -INST1: INC HL - RES 3,H - LD E,(HL) - LD (HL),A - LD A,E - DJNZ INST1 - JR ?RSTR - -ROLD: LD HL,PBIAS - LD A,(ROLTOP) - CP (HL) - JR Z,?RSTR - CALL MGP.D - LD A,(HL) - SUB SCRLW ; Number of 8byte blocks in a line to scroll. -ROL2: LD (HL),A - LD L,A - LD H,SCLBASE - LD A,(HL) - CALL L09C7 - JP ?RSTR - -CR: CALL .MANG - RRCA - JP NC,CURS2 - LD L,000H - INC H - LD A,H - CP ROW - 1 ; End of line? - JR Z,CR3 - JR NC,CR2 - CALL MGP.I - INC H - JP CURS1 -CR2: DEC H - LD (DSPXY),HL - LD HL,ROLU - PUSH HL - PUSH AF - PUSH BC - PUSH DE - CALL ROLU -CR3: LD (DSPXY),HL - CALL MGP.I - -ROLU: LD HL,PBIAS - LD A,(ROLEND) - CP (HL) - JP Z,SCROL -ROLU1: CALL MGP.I - LD A,(HL) - ADD A,SCRLW ; Number of 8byte blocks in a line to scroll. - JR ROL2 - -?PONT: LD HL,(DSPXY) -?PNT1: PUSH AF - PUSH BC - PUSH DE - PUSH HL - POP BC - LD DE,COLW - LD HL,SCRN - COLW - LD A,(SPAGE) - OR A - JR NZ,?PNT2 - LD HL,(PAGETP) - SBC HL,DE -?PNT2: ADD HL,DE - DEC B - JP P,?PNT2 - LD B,000H - ADD HL,BC - RES 3,H - POP DE - POP BC - POP AF - RET - -?CLER: XOR A - JR ?DINT -?CLRFF: LD A,0FFH -?DINT: LD (HL),A - INC HL - DJNZ ?DINT - RET - -GAPCK: PUSH BC - PUSH DE - PUSH HL - LD BC,KEYPB - LD DE,KEYPC -GAPCK1: LD H,064H -GAPCK2: CALL EDGE - JR C,GAPCK3 - CALL DLY3 - LD A,(DE) - AND 020H - JR NZ,GAPCK1 - DEC H - JR NZ,GAPCK2 -GAPCK3: JP RET3 - - ; MONITOR WORK AREA - ; (MZ700) - -STACK: EQU 010F0H - - ORG STACK -SPV: -IBUFE: ; TAPE BUFFER (128 BYTES) -ATRB: DS virtual 1 ; ATTRIBUTE -NAME: DS virtual 17 ; FILE NAME -SIZE: DS virtual 2 ; BYTESIZE -DTADR: DS virtual 2 ; DATA ADDRESS -EXADR: DS virtual 2 ; EXECUTION ADDRESS -COMNT: DS virtual 92 ; COMMENT -SWPW: DS virtual 10 ; SWEEP WORK -KDATW: DS virtual 2 ; KEY WORK -KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) -DSPXY: DS virtual 2 ; DISPLAY COORDINATES -MANG: DS virtual 6 ; COLUMN MANAGEMENT -MANGE: DS virtual 1 ; COLUMN MANAGEMENT END -PBIAS: DS virtual 1 ; PAGE BIAS -ROLTOP: DS virtual 1 ; ROLL TOP BIAS -MGPNT: DS virtual 1 ; COLUMN MANAG. POINTER -PAGETP: DS virtual 2 ; PAGE TOP -ROLEND: DS virtual 1 ; ROLL END - DS virtual 14 ; BIAS -FLASH: DS virtual 1 ; FLASHING DATA -SFTLK: DS virtual 1 ; SHIFT LOCK -REVFLG: DS virtual 1 ; REVERSE FLAG -SPAGE: DS virtual 1 ; PAGE CHANGE -FLSDT: DS virtual 1 ; CURSOR DATA -STRGF: DS virtual 1 ; STRING FLAG -DPRNT: DS virtual 1 ; TAB COUNTER -TMCNT: DS virtual 2 ; TAPE MARK COUNTER -SUMDT: DS virtual 2 ; CHECK SUM DATA -CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA -AMPM: DS virtual 1 ; AMPM DATA -TIMFG: DS virtual 1 ; TIME FLAG -SWRK: DS virtual 1 ; KEY SOUND FLAG -TEMPW: DS virtual 1 ; TEMPO WORK -ONTYO: DS virtual 1 ; ONTYO WORK -OCTV: DS virtual 1 ; OCTAVE WORK -RATIO: DS virtual 2 ; ONPU RATIO -BUFER: DS virtual 81 ; GET LINE BUFFER - -USRROM: EQU 0E800H ; Address of 2K User Rom. -FLPROM: EQU 0F000H ; Address of 4K Floppy control Rom. - - ; EQU TABLE I/O REPORT - -SCRN: EQU 0D000H -ARAM: EQU 0D800H -KEYPA: EQU 0E000H -KEYPB: EQU 0E001H -KEYPC: EQU 0E002H -KEYPF: EQU 0E003H -CSTR: EQU 0E002H -CSTPT: EQU 0E003H -CONT0: EQU 0E004H -CONT1: EQU 0E005H -CONT2: EQU 0E006H -CONTF: EQU 0E007H -SUNDG: EQU 0E008H -TEMP: EQU 0E008H -MEMSW: EQU 0E00CH -MEMSWR: EQU 0E010H -INVDSP: EQU 0E014H -NRMDSP: EQU 0E015H -SCLDSP: EQU 0E200H -SCLBASE:EQU 0E2H diff --git a/software/asm/sa1510_hiload.asm b/software/asm/sa1510_hiload.asm deleted file mode 100644 index 0aa861a..0000000 --- a/software/asm/sa1510_hiload.asm +++ /dev/null @@ -1,2804 +0,0 @@ -; Disassembly of the file "sa1510.rom" -; - -; Configurable parameters. These are set in the wrapper file, ie monitor_SA1510.asm -; -;COLW: EQU 40 ; Width of the display screen (ie. columns). -;ROW: EQU 25 ; Number of rows on display screen. -;SCRNSZ: EQU COLW * ROW ; Total size, in bytes, of the screen display area. - - ORG HL_MONIT - -MONIT: JP START ; 00 -GETL: JP ?GETL ; 03 -LETNL: JP ?LTNL ; 06 -NL: JP ?NL ; 09 -PRNTS: JP ?PRTS ; 0C -PRNTT: JP ?PRTT ; 0F -PRNT: JP ?PRNT ; 12 -MSG: JP ?MSG ; 15 -MSGX: JP ?MSGX ; 18 -GETKY: JP ?GET ; 1B -BRKEY: JP ?BRK ; 1E -WRINF: JP ?WRI ; 21 -WRDAT: JP ?WRD ; 24 -RDINF: JP ?RDI ; 27 -RDDAT: JP ?RDD ; 2A -VERFY: JP ?VRFY ; 2D -MELDY: JP ?MLDY ; 30 -TIMST: JP ?TMST ; 33 -TIMRD: JP ?TMRD ; 36 -BELL: JP ?BEL ; 39 -XTEMP: JP ?TEMP ; 3C -MSTA: JP MLDST ; 3F -MSTP: JP MLDSP ; 42 -DACN: JP ?DACN ; 45 -ADCN: JP ?ADCN ; 48 -WTKEY: JP ??KEY ; 4B -PRTAHEX:JP PRTHX ; 4E - -START: LD SP,STACK - IM 1 - CALL ?MODE - LD B,0FFH - LD HL,NAME - CALL ?CLER ; Clear 256 bytes from NAME 10F1h to 11F0h - LD A,016H - CALL PRNT - IF MODE80C = 0 - LD A,007H ; Black background, white characters. Bit 7 is clear as a write to bit 7 @ DFFFH selects 40Char mode. - ELSE - LD A,017H ; Blue background, white characters in colour mode. Bit 7 is set as a write to bit 7 @ DFFFH selects 80Char mode. - ENDIF - LD HL,ARAM -STRT1: CALL CLR8 - LD HL,TIMIN - LD A,0C3H - LD (1038H),A - LD (01039H),HL - LD A,004H - LD (TEMPW),A - - ; Setup display to 40/80 characters depending upon config. - IF MODE80C = 0 - LD HL,DSPCTL ; Setup address of display control register latch. - LD A, 0 ; Using MROM in Bank 0 = 40 char mode. - LD E,(HL) ; Dummy operation to enable latch write via multivibrator. - LD (HL), A - LD (SPAGE), A ; Allow MZ80A scrolling - ELSE - LD HL,DSPCTL ; Setup address of display control register latch. - LD A, 128 ; Using MROM in Bank 1 = 80 char mode. - LD E,(HL) ; Dummy operation to enable latch write via multivibrator. - LD (HL), A - LD (SPAGE), A ; MZ80K Scrolling in 80 column mode for time being. - ENDIF - CALL MLDSP - CALL NL - LD DE,SIGNON ; 00100H - CALL ?MSGX - CALL ?BEL -SS: LD A,0FFH -SS1: LD (SWRK),A - -ST1: CALL NL - LD A,023H ; # Prompt - CALL PRNT - LD DE,BUFER - CALL GETL -ST2: LD A,(DE) - INC DE - CP 00DH - JR Z,ST1 - CP 'J' ; JUMP? - JR Z,GOTO - CP 'L' ; LOAD? - JR Z,LOAD - CP 'C' - JP Z,0B200H -; CP 'F' ; FLOPPY? -; JR Z,FD -; CP 'B' ; BELL? -; JR Z,SG - JR ST2 - - ; JUMP COMMAND -GOTO: CALL HLHEX - JR C,ST1 - JP (HL) - - ; KEY SOUND ON OFF -;G: LD A,(SWRK) -; CPL -; JR SS1 - - ; FLOPPY ROM CHECK AND RUN -;FD: LD HL,FLPROM -;FD2: LD A,(HL) -; OR A -; JR NZ,ST1 -; JP (HL) - -?ER: CP 002H - JR Z,ST1 - LD DE,MSGE1 - CALL ?MSGX - JR ST1 - - ; LOAD COMMAND -LOAD: CALL ?RDI - JR C,?ER - CALL NL - LD DE,MSG?2 - CALL ?MSGX - LD DE,NAME - CALL ?MSGX - CALL ?RDD - JR C,?ER - LD HL,(EXADR) - LD A,H - CP 012H - JR C,ST1 - JP (HL) - - ; LOADING -MSG?2: DB 04CH, 0B7H, 0A1H, 09CH - DB 0A6H, 0B0H, 097H, 020H - DB 00DH - - ; SIGN ON BANNER -SIGNON: DB "** MONITOR SA-1510h **", 0DH - - ; For 80 Character mode we need some space, so shorten the Check Sum Error message. - ; - ; CHECK SUM ERROR -MSGE1: DB "CK SUM?", 0DH - - ; CR PAGE MODE1 -.CR: CALL .MANG - RRCA - JP NC,CURS2 - LD L,000H - INC H - CP ROW - 1 ; End of line? - JR Z,.CP1 - INC H - JP CURS1 - -.CP1: LD (DSPXY),HL - - ; SCROLLER -.SCROL: LD BC,SCRNSZ - COLW ; Scroll COLW -1 lines - LD DE,SCRN ; Start of the screen. - LD HL,SCRN + COLW ; Start of screen + 1 line. - LDIR - EX DE,HL - LD B,COLW ; Clear last line at bottom of screen. - CALL ?CLER - LD BC,0001AH - LD DE,MANG - LD HL,MANG + 1 - LDIR - LD (HL),000H - LD A,(MANG) - OR A - JP Z,?RSTR - LD HL,DSPXY + 1 - DEC (HL) - JR .SCROL - - - ; CTBL PAGE MODE1 -.CTBL: DW .SCROL - DW CURSD - DW CURSU - DW CURSR - DW CURSL - DW HOM0 - DW CLRS - DW DEL - DW INST - DW ALPHA - DW KANA - DW ?RSTR - DW REV - DW .CR - DW ?RSTR - DW ?RSTR - -?MLDY: PUSH BC - PUSH DE - PUSH HL - LD A,002H - LD (OCTV),A - LD B,001H -MLD1: LD A,(DE) - CP 00DH - JR Z,MLD4 - CP 0C8H - JR Z,MLD4 - CP 0CFH - JR Z,MLD2 - CP 02DH - JR Z,MLD2 - CP 02BH - JR Z,MLD3 - CP 0D7H - JR Z,MLD3 - CP 023H - LD HL,MTBL - JR NZ,MLD1A - LD HL,M?TBL - INC DE -MLD1A: CALL ONPU - JR C,MLD1 - CALL RYTHM - JR C,MLD5 - CALL MLDST - LD B,C - JR MLD1 -MLD2: LD A,003H -MLD2A: LD (OCTV),A - INC DE - JR MLD1 -MLD3: LD A,001H - JR MLD2A -MLD4: CALL RYTHM -MLD5: PUSH AF - CALL MLDSP - POP AF - JP RET3 - -ONPU: PUSH BC - LD B,008H - LD A,(DE) -ONP1A: CP (HL) - JR Z,ONP2 - INC HL - INC HL - INC HL - DJNZ ONP1A - SCF - INC DE - POP BC - RET - -ONP2: INC HL - PUSH DE - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL - LD A,H - OR A - JR Z,ONP2B - LD A,(OCTV) -ONP2A: DEC A - JR Z,ONP2B - ADD HL,HL - JR ONP2A -ONP2B: LD (RATIO),HL - LD HL,OCTV - LD (HL),002H - DEC HL - POP DE - INC DE - LD A,(DE) - LD B,A - AND 0F0H - CP 030H - JR Z,ONP2C - LD A,(HL) - JR ONP2D -ONP2C: INC DE - LD A,B - AND 00FH - LD (HL),A -ONP2D: LD HL,OPTBL - ADD A,L - LD L,A - LD C,(HL) - LD A,(TEMPW) - LD B,A - XOR A - JP L09AB - -MTBL: DB 043H - DB 077H - DB 007H - DB 044H - DB 0A7H - DB 006H - DB 045H - DB 0EDH - DB 005H - DB 046H - DB 098H - DB 005H - DB 047H - DB 0FCH - DB 004H - DB 041H - DB 071H - DB 004H - DB 042H - DB 0F5H - DB 003H - DB 052H - DB 000H - DB 000H -M?TBL: DB 043H - DB 00CH - DB 007H - DB 044H - DB 047H - DB 006H - DB 045H - DB 098H - DB 005H - DB 046H - DB 048H - DB 005H - DB 047H - DB 0B4H - DB 004H - DB 041H - DB 031H - DB 004H - DB 042H - DB 0BBH - DB 003H - DB 052H - DB 000H - DB 000H - -OPTBL: DB 001H - DB 002H - DB 003H - DB 004H - DB 006H - DB 008H - DB 00CH - DB 010H - DB 018H - DB 020H - -?SAVE: LD HL,FLSDT - LD (HL),0EFH - LD A,(KANAF) - OR A - JR Z,L0270 - LD (HL),0FFH -L0270: LD A,(HL) - PUSH AF - CALL ?PONT - LD A,(HL) - LD (FLASH),A - POP AF - LD (HL),A - XOR A - LD HL,KEYPA - LD (HL),A - CPL - LD (HL),A - RET - -MGP.I: PUSH AF - PUSH HL - LD HL,MGPNT - LD A,(HL) - INC A - CP 033H - JR NZ,L028F - XOR A -L028F: PUSH HL - LD L,A - LD A,(SPAGE) - OR A - LD A,L - POP HL - JR NZ,L029A - LD (HL),A -L029A: POP HL - POP AF - RET - -MGP.D: PUSH AF - PUSH HL - LD HL,MGPNT - LD A,(HL) - DEC A - JP P,L028F - LD A,032H - JR L028F -MLDST: LD HL,(RATIO) - LD A,H - OR A - JR Z,MLDSP - PUSH DE - EX DE,HL - LD HL,CONT0 - LD (HL),E - LD (HL),D - LD A,001H - POP DE - JR L02C4 -MLDSP: LD A,034H - LD (CONTF),A - XOR A -L02C4: LD (SUNDG),A - RET - -RYTHM: LD HL,KEYPA - LD (HL),0F0H - INC HL - LD A,(HL) - AND 081H - JR NZ,L02D5 - SCF - RET - -L02D5: LD A,(SUNDG) - RRCA - JR C,L02D5 -L02DB: LD A,(SUNDG) - RRCA - JR NC,L02DB - DJNZ L02D5 - XOR A - RET - -?BEL: PUSH DE - LD DE,00DB1H - CALL ?MLDY - POP DE - RET - -?TEMP: PUSH AF - PUSH BC - AND 00FH - LD B,A - LD A,008H - SUB B - LD (TEMPW),A - POP BC - POP AF - RET - -?TMST: DI - PUSH BC - PUSH DE - PUSH HL - LD (AMPM),A - LD A,0F0H - LD (TIMFG),A - LD HL,0A8C0H - XOR A - SBC HL,DE - PUSH HL - INC HL - EX DE,HL - LD HL,CONTF - LD (HL),074H - LD (HL),0B0H - DEC HL - LD (HL),E - LD (HL),D - DEC HL - LD (HL),00AH - LD (HL),000H - INC HL - INC HL - LD (HL),080H - DEC HL -L0323: LD C,(HL) - LD A,(HL) - CP D - JR NZ,L0323 - LD A,C - CP E - JR NZ,L0323 - DEC HL - NOP - NOP - NOP - LD (HL),00CH - LD (HL),07BH - INC HL - POP DE -L0336: LD C,(HL) - LD A,(HL) - CP D - JR NZ,L0336 - LD A,C - CP E - JR NZ,L0336 - POP HL - POP DE - POP BC - EI - RET - -?TMRD: PUSH HL - LD HL,CONTF - LD (HL),080H - DEC HL - DI - LD E,(HL) - LD D,(HL) - EI - LD A,E - OR D - JR Z,?TMR1 - XOR A - LD HL,0A8C0H - SBC HL,DE - JR C,?TMR2 - EX DE,HL - LD A,(AMPM) - POP HL - RET - -?TMR1: LD DE,0A8C0H -?TMR1A: LD A,(AMPM) - XOR 001H - POP HL - RET - -?TMR2: DI - LD HL,CONT2 - LD A,(HL) - CPL - LD E,A - LD A,(HL) - CPL - LD D,A - EI - INC DE - JR ?TMR1A - -TIMIN: PUSH AF - PUSH BC - PUSH DE - PUSH HL - LD HL,AMPM - LD A,(HL) - XOR 001H - LD (HL),A - LD HL,CONTF - LD (HL),080H - DEC HL - PUSH HL - LD E,(HL) - LD D,(HL) - LD HL,0A8C0H - ADD HL,DE - DEC HL - DEC HL - EX DE,HL - POP HL - LD (HL),E - LD (HL),D - POP HL - POP DE - POP BC - POP AF - EI - RET - -.DSP03: EX DE,HL - LD (HL),001H - INC HL - LD (HL),000H - JP CURSR -.MANG2: LD A,(DSPXY + 1) - ADD A,L - LD L,A - LD A,(HL) - INC HL - RL (HL) - OR (HL) - RR (HL) - RRCA - EX DE,HL - LD HL,(DSPXY) - RET - - LD C,H - POP AF -PRTHL: LD A,H - CALL PRTHX - LD A,L - JR PRTHX - LD B,E - LD B,E -PRTHX: PUSH AF - RRCA - RRCA - RRCA - RRCA - CALL ASC - CALL PRNT - POP AF - CALL ASC - JP PRNT -L03D5: POP DE - POP HL - POP BC - POP AF - RET - -ASC: AND 00FH - CP 00AH - JR C,NOADD - ADD A,007H -NOADD: ADD A,030H - RET - -HEXJ: CP 030H - RET C - CP 03AH - JR C,HEX1 - SUB 007H - CP 040H - JR NC,HEX2 -HEX1: AND 00FH - RET -HEX2: SCF - RET - - ; Unused memory. - LD C,B - LD C,H - -HEX: JR HEXJ - -HOME: LD HL,(DSPXY) - LD A,(MGPNT) - SUB H - JR NC,HOM1 - ADD A,032H -HOM1: LD (MGPNT),A -HOM0: LD HL,00000H - JP CURS3 - - ; Unused memory. - INC L - -HLHEX: PUSH DE - CALL L041F - JR C,L041D - LD H,A - CALL L041F - JR C,L041D - LD L,A -L041D: POP DE - RET - -L041F: PUSH BC - LD A,(DE) - INC DE - CALL HEX - JR C,L0434 - RRCA - RRCA - RRCA - RRCA - LD C,A - LD A,(DE) - INC DE - CALL HEX - JR C,L0434 - OR C -L0434: POP BC - RET - -?WRI: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D7H - LD E,0CCH - LD HL,STACK - LD BC,00080H -L0444: CALL L071A - CALL MOTOR - JR C,L0464 - LD A,E - CP 0CCH - JR NZ,L045E - CALL NL - PUSH DE - LD DE,MSG?7 ; Writing Message - CALL ?MSGX - LD DE,NAME - CALL ?MSGX - POP DE -L045E: CALL L077A - CALL L0485 -L0464: JP L0552 - - ; Writing -MSG?7: DB 057H, 09DH, 0A6H, 096H, 0A6H - DB 0B0H, 097H, 020H, 00DH - -?WRD: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D7H - LD E,053H - LD BC,(SIZE) - LD HL,(DTADR) - LD A,B - OR C - JR Z,L04CB - JR L0444 -L0485: PUSH DE - PUSH BC - PUSH HL - LD D,002H - LD A,0F0H - LD (KEYPA),A -L048F: LD A,(HL) - CALL L0767 - LD A,(KEYPB) - AND 081H - JP NZ,L049E - SCF - JR L04CB -L049E: INC HL - DEC BC - LD A,B - OR C - JP NZ,L048F - LD HL,(SUMDT) - LD A,H - CALL L0767 - LD A,L - CALL L0767 - CALL L0D57 - DEC D - JP NZ,L04BB - OR A - JP L04CB -L04BB: LD B,000H -L04BD: CALL L0D3E - DEC B - JP NZ,L04BD - POP HL - POP BC - PUSH BC - PUSH HL - JP L048F -L04CB: POP HL - POP BC - POP DE - RET - -?RDI: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D2H - LD E,0CCH - LD BC,00080H - LD HL,STACK -L04DD: CALL MOTOR - JP C,L0570 - CALL TMARK - JP C,L0570 - CALL L0505 - JP L0552 - -?RDD: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D2H - LD E,053H - LD BC,(SIZE) - LD HL,(DTADR) - LD A,B - OR C - JP Z,L0552 - JR L04DD -L0505: PUSH DE - PUSH BC - PUSH HL - LD H,002H -L050A: LD BC,KEYPB - LD DE,KEYPC -L0510: CALL EDGE - JP C,L0570 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,L0510 - LD D,H - LD HL,00000H - LD (SUMDT),HL - POP HL - POP BC - PUSH BC - PUSH HL -L052A: CALL RBYTE - JP C,L0570 - LD (HL),A - INC HL - DEC BC - LD A,B - OR C - JP NZ,L052A - LD HL,(SUMDT) - CALL RBYTE - JP C,L0570 - LD E,A - CALL RBYTE - JP C,L0570 - CP L - JP NZ,L0563 - LD A,E - CP H - JP NZ,L0563 -L0551: XOR A -L0552: POP HL - POP BC - POP DE - CALL MSTOP - PUSH AF - LD A,(TIMFG) - CP 0F0H - JR NZ,L0561 - EI -L0561: POP AF - RET - -L0563: DEC D - JR Z,L056C - LD H,D - CALL GAPCK - JR L050A -L056C: LD A,001H - JR L0572 -L0570: LD A,002H -L0572: SCF - JR L0552 - - -?VRFY: DI - PUSH DE - PUSH BC - PUSH HL - LD BC,(SIZE) - LD HL,(DTADR) - LD D,0D2H - LD E,053H - LD A,B - OR C - JR Z,L0552 - CALL L071A - CALL MOTOR - JR C,L0570 - CALL TMARK - JP C,L0570 - CALL TVRFY - JR L0552 - -TVRFY: PUSH DE - PUSH BC - PUSH HL - LD H,002H -TVF1: LD BC,KEYPB - LD DE,KEYPC -TVF2: CALL EDGE - JP C,L0570 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,TVF2 - LD D,H - POP HL - POP BC - PUSH BC - PUSH HL -TVF3: CALL RBYTE - JP C,L0570 - CP (HL) - JP NZ,L056C - INC HL - DEC BC - LD A,B - OR C - JP NZ,TVF3 - LD HL,(CSMDT) - CALL RBYTE - CP H - JR NZ,L056C - CALL RBYTE - CP L - JR NZ,L056C - DEC D - JP Z,L0551 - LD H,D - JR TVF1 - - ; PRINT '00' -GETLD: LD DE,DBLZERO - CALL ?MSGX - JP AUTO2 - - ; ROLL UP -ROLUP: LD HL,PBIAS - LD A,(ROLEND) - CP (HL) - JP Z,?RSTR - JP ROLU1 - -?LOAD: PUSH AF - LD A,(FLASH) - CALL ?PONT - LD (HL),A - POP AF - RET - - ; Unused memory - XOR E - LD C,A - -EDGE: LD A,0F0H - LD (KEYPA),A - NOP -EDG1: LD A,(BC) - AND 081H - JP NZ,EDG1A - SCF - RET -EDG1A: LD A,(DE) - AND 020H - JP NZ,EDG1 -EDG2: LD A,(BC) - AND 081H - JP NZ,EDG3 - SCF - RET -EDG3: LD A,(DE) - AND 020H - JP Z,EDG2 - RET - -RBYTE: PUSH BC - PUSH DE - PUSH HL - LD HL,00800H - LD BC,KEYPB - LD DE,KEYPC -RBY1: CALL EDGE - JP C,RBY3 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,RBY2 - PUSH HL - LD HL,(SUMDT) - INC HL - LD (SUMDT),HL - POP HL - SCF -RBY2: LD A,L - RLA - LD L,A - DEC H - JP NZ,RBY1 - CALL EDGE - LD A,L -RBY3: POP HL - POP DE - POP BC - RET - -TMARK: CALL GAPCK - PUSH BC - PUSH DE - PUSH HL - LD HL,02828H ; 40 short and 40 long gap pulses - LD A,E - CP 0CCH - JP Z,TM0 - LD HL,01414H ; 20 short and 20 long tape mark pulses -TM0: LD (TMCNT),HL - LD BC,KEYPB - LD DE,KEYPC -TM1: LD HL,(TMCNT) -TM2: CALL EDGE - JP C,RET3 - CALL DLY3 - LD A,(DE) - AND 020H - JP Z,TM1 - DEC H - JP NZ,TM2 -TM3: CALL EDGE - JP C,RET3 - CALL DLY3 - LD A,(DE) - AND 020H - JP NZ,TM1 - DEC L - JP NZ,TM3 - CALL EDGE -RET3: -TM4: POP HL - POP DE - POP BC - RET - -MOTOR: PUSH BC - PUSH DE - PUSH HL - LD B,00AH -MOT1: LD A,(KEYPC) - AND 010H - JR Z,MOT4 -MOT2: LD B,0A6H -L06B1: CALL DLY12 - DJNZ L06B1 - XOR A -MOT7: JR RET3 -MOT4: LD A,006H - LD HL,KEYPF - LD (HL),A - INC A - LD (HL),A - DJNZ MOT1 - CALL NL - LD A,D - CP 0D7H - JR Z,MOT8 - LD DE,00D9EH - JR MOT9 -MOT8: LD DE,MSG_3 ; RECORD message. - CALL ?MSGX - LD DE,00DA0H -MOT9: CALL ?MSGX -MOT5: LD A,(KEYPC) - AND 010H - JR NZ,MOT2 - CALL ?BRK - JR NZ,MOT5 - SCF - JR MOT7 - -L06E7: LD B,0C9H - LD A,(KANAF) - OR A - JR NZ,L06F0 - INC B -L06F0: LD A,B - JP ?KY1 - - ; PRESS RECORD message. -MSG_3: DB 07FH, 020H - DB 052H, 045H, 043H, 04FH, 052H - DB 044H, 02EH, 00DH - - ; Padding not used - DB 034H - DB 044H - -MSTOP: PUSH AF - PUSH BC - PUSH DE - LD B,00AH -L0705: LD A,(KEYPC) - AND 010H - JR Z,L0717 - LD A,006H - LD (KEYPF),A - INC A - LD (KEYPF),A - DJNZ L0705 -L0717: JP ?RSTR1 -L071A: PUSH BC - PUSH DE - PUSH HL - LD DE,00000H -L0720: LD A,B - OR C - JR NZ,L072F - EX DE,HL - LD (SUMDT),HL - LD (CSMDT),HL - POP HL - POP DE - POP BC - RET - -L072F: LD A,(HL) - PUSH BC - LD B,008H -L0733: RLCA - JR NC,L0737 - INC DE -L0737: DJNZ L0733 - POP BC - INC HL - DEC BC - JR L0720 -L073E: RLCA - RLCA - RLCA - LD C,A - LD A,E -L0743: DEC H - RRCA - JR NC,L0743 - LD A,H - ADD A,C - LD C,A - JP SWEP01 -?MODE: LD HL,KEYPF - LD (HL),08AH - LD (HL),007H - LD (HL),005H - LD (HL),001H - RET - -L0759: LD A,00EH -L075B: DEC A - JP NZ,L075B - RET - -L0760: LD A,00DH -L0762: DEC A - JP NZ,L0762 - RET - -L0767: PUSH BC - LD B,008H - CALL L0D57 -L076D: RLCA - CALL C,L0D57 - CALL NC,L0D3E - DEC B - JP NZ,L076D - POP BC - RET - -L077A: PUSH BC - PUSH DE - LD A,E - LD BC,055F0H - LD DE,02828H - CP 0CCH - JP Z,L078E - LD BC,02AF8H - LD DE,01414H -L078E: CALL L0D3E - DEC BC - LD A,B - OR C - JR NZ,L078E -L0796: CALL L0D57 - DEC D - JR NZ,L0796 -L079C: CALL L0D3E - DEC E - JR NZ,L079C - CALL L0D57 - POP DE - POP BC - RET - -?GETL: PUSH AF - PUSH BC - PUSH HL - PUSH DE -GETL0: CALL ?SAVE -GETL0A: CALL ?KEY - CP 0CBH - JR Z,GETL0A -GETL0B: CALL ?KEY - CALL ?FLAS - JR Z,GETL0B -GETL0C: PUSH AF - XOR A - LD (STRGF),A - POP AF -AUTO3: LD B,A -GETL0D: CALL ?LOAD - LD A,(SWRK) - OR A - CALL Z,?BEL - LD A,B - CP 0E7H - JP Z,GETLD - CP 0E6H - JR Z,CHGPK - CP 0EEH - JR Z,CHGPA - CP 0E5H - JR Z,DMT - CP 0E0H - JP Z,LOCK - JR NC,GETL0B - AND 0F0H - CP 0C0H - JR NZ,GETL2 - LD A,B - CP 0CDH - JR Z,GETL3 - CP 0CBH - JP Z,GETLC - CP 0C7H - JR NC,GETL5 - LD A,(KANAF) - OR A - LD A,B - JR Z,GETL5 -GETL2: LD A,B - CALL ?DSP -AUTO2: CALL ?SAVE - LD A,(STRGF) - OR A - JR NZ,AUTO5 -AUTOL: LD E,014H -AUTOL1: CALL ?KEY - JR NZ,AUTO3 - CALL AUTCK -GETL1: JR C,GETL0B - DEC E - JR NZ,AUTOL1 - LD A,001H - LD (STRGF),A -AUTO5: CALL DLY12 - CALL DLY12 - CALL ?KEY - CALL ?FLAS - JR NZ,GETL0C - CALL AUTCK - JR C,GETL1 - JR GETL0D -GETL5: CALL ?DPCT - JR AUTO2 - -CHGPA: XOR A - IF MODE80C = 1 - JR CHGPK - ELSE - JR CHGPK1 - ENDIF -CHGPK: LD A,0FFH -CHGPK1: LD (SPAGE),A - LD A,0C6H - CALL ?DPCT -CHGP1: JP GETL0 - -GETLC: POP HL - PUSH HL - LD (HL),01BH - INC HL - LD (HL),00DH - JR GETLR - -DMT: LD B,05AH - JR GETL2 - -GETL3: CALL .MANG - LD B,COLW ; PDS was 028H - JR NC,GETLA - DEC H -GETLB: LD B,COLW*2 ; 050H -GETL6: LD L,000H - CALL ?PNT1 - POP DE - PUSH DE -GETL6A: LD A,(HL) - CALL ?DACN - LD (DE),A - INC HL - RES 3,H - INC DE - DJNZ GETL6A - EX DE,HL -GETL6B: LD (HL),00DH - DEC HL - LD A,(HL) - CP 020H - JR Z,GETL6B -GETLR: CALL ?LTNL - JP L03D5 - -GETLA: RRCA - JR NC,GETL6 - JR GETLB - -LOCK: LD HL,SFTLK - LD A,(HL) - CPL - LD (HL),A - JR CHGP1 - -?MSG: PUSH AF - PUSH BC - PUSH DE -MSG1: LD A,(DE) - CP 00DH - JR Z,MSGX2 - CALL ?PRNT - INC DE - JR MSG1 - -?MSGX: PUSH AF - PUSH BC - PUSH DE -MSGX1: LD A,(DE) - CP 00DH -MSGX2: JP Z,?RSTR1 - CALL ?ADCN - CALL PRNT3 - INC DE - JR MSGX1 - -?GET: PUSH BC - PUSH HL - LD B,009H - LD HL,SWPW+1 - CALL ?CLRFF - POP HL - POP BC - CALL ?KEY - SUB 0F0H - RET Z - ADD A,0F0H - JP ?DACN - -?KEY: PUSH BC - PUSH DE - PUSH HL - CALL ?SWEP - LD A,B - RLCA - JR C,?KY2 - LD A,0F0H -?KY1: LD E,A - CALL AUTCK - LD A,(KDATW) - OR A - JR Z,?KY11 - CALL DLY12 - CALL ?SWEP - LD A,B - RLCA - JR C,?KY2 -?KY11: LD A,E - CP 0F0H - JR NZ,?KY9 -?KY10: JP RET3 -?KY2: RLCA - RLCA - RLCA - JP C,L06E7 - RLCA - JP C,_BRK - LD H,000H - LD L,C - LD A,C - CP 038H - JR NC,?KY6 - LD A,(KANAF) - OR A - LD A,B - RLCA - JR NZ,?KY4 - LD B,A - LD A,(SFTLK) - OR A - LD A,B - JR Z,L0917 - RLA - CCF - RRA -L0917: RLA - RLA - JR NC,?KY3 -L091B: LD DE,KTBLC -?KY5: ADD HL,DE - LD A,(HL) - JR ?KY1 -?KY3: RRA - JR NC,?KY6 - LD DE,KTBLS - JR ?KY5 -?KY6: LD DE,KTBL ; 00BEAH - JR ?KY5 -?KY4: RLCA - JR C,?KY7 - RLCA - JR C,L091B - LD DE,KTBLG - JR ?KY5 -?KY7: LD DE,KTBLGS - JR ?KY5 -?KY9: CALL AUTCK - INC A - LD A,E - JR ?KY10 - -?PRT: LD A,C - CALL ?ADCN - LD C,A - AND 0F0H - CP 0F0H - RET Z - - CP 0C0H - LD A,C - JR NZ,PRNT3 -PRNT5: CALL ?DPCT - CP 0C3H - JR Z,PRNT4 - CP 0C5H - JR Z,PRNT2 - CP 0CDH ; CR - JR Z,PRNT2 - CP 0C6H - RET NZ - -PRNT2: XOR A -PRNT2A: LD (DPRNT),A - RET - -PRNT3: CALL ?DSP -PRNT4: LD A,(DPRNT) - INC A - CP COLW*2 ; 050H - JR C,PRNT4A - SUB COLW*2 ; 050H -PRNT4A: JR PRNT2A - -?NL: LD A,(DPRNT) - OR A - RET Z - -?LTNL: LD A,0CDH - JR PRNT5 -?PRTT: CALL PRNTS - LD A,(DPRNT) - OR A - RET Z - -L098C: SUB 00AH - JR C,?PRTT - JR NZ,L098C - RET - -?PRTS: LD A,020H -?PRNT: CP 00DH - JR Z,?LTNL - PUSH BC - LD C,A - LD B,A - CALL ?PRT - LD A,B - POP BC - RET - -DLY3: NEG - NEG - LD A,02AH - JP L0762 -L09AB: ADD A,C - DJNZ L09AB - POP BC - LD C,A - XOR A - RET - - DB 0010H -??KEY: PUSH BC - PUSH DE - PUSH HL - CALL ?SAVE -L09B9: CALL ?KEY - CALL ?FLAS - JR Z,L09B9 - CALL ?LOAD - JP RET3 - -L09C7: PUSH DE - PUSH HL - LD HL,PBIAS - XOR A - RLD - LD D,A - LD E,(HL) - RRD - XOR A - RR D - RR E - LD HL,SCRN - ADD HL,DE - LD (PAGETP),HL - POP HL - POP DE - RET - -L09E2: XOR A -CLR8: LD BC,00800H - PUSH DE - LD D,A -L09E8: LD (HL),D - INC HL - DEC BC - LD A,B - OR C - JR NZ,L09E8 - POP DE - RET - -AUTCK: LD HL,KDATW - LD A,(HL) - INC HL - LD D,(HL) - LD (HL),A - SUB D - RET NC - INC (HL) - RET - -DBLZERO:DB 030H - DB 030H - DB 00DH - -?FLAS: PUSH AF - PUSH HL - LD A,(KEYPC) - RLCA - RLCA - JR C,FLAS1 - LD A,(FLSDT) -FLAS2: CALL ?PONT - LD (HL),A -FLAS3: POP HL - POP AF - RET - -FLAS1: LD A,(FLASH) - JR FLAS2 - -REV: LD HL,REVFLG - LD A,(HL) - OR A - CPL - LD (HL),A - JR Z,REV1 - LD A,(INVDSP) - JR REV2 -REV1: LD A,(NRMDSP) -REV2: JP ?RSTR - -.MANG: LD HL,MANG - LD A,(SPAGE) - OR A - JP NZ,.MANG2 - LD A,(MGPNT) -.MANG3: SUB 008H - INC HL - JR NC,.MANG3 - ADD A,008H - LD C,(HL) - DEC HL - LD B,A - INC B - PUSH BC - LD A,(HL) -.MANG4: RR C - RRA - DJNZ .MANG4 - POP BC - EX DE,HL -.MANG1: LD HL,(DSPXY) - RET - -?SWEP: PUSH DE - PUSH HL - XOR A - LD (KDATW),A - LD B,0FAH - LD D,A - CALL ?BRK - JR NZ,SWEP6 - LD D,088H - JR SWEP9 -SWEP6: LD HL,SWPW - PUSH HL - JR NC,SWEP11 - LD D,A - AND 060H - JR NZ,SWEP11 - LD A,D - XOR (HL) - BIT 4,A - LD (HL),D - JR Z,SWEP0 -SWEP01: SET 7,D -SWEP0: DEC B - POP HL - INC HL - LD A,B - LD (KEYPA),A - CP 0F0H - JR NZ,SWEP3 - LD A,(HL) - CP 003H - JR C,SWEP9 - LD (HL),000H - RES 7,D -SWEP9: LD B,D - POP HL - POP DE - RET - -SWEP11: LD (HL),000H - JR SWEP0 -SWEP3: LD A,(KEYPB) - LD E,A - CPL - AND (HL) - LD (HL),E - PUSH HL - LD HL,KDATW - PUSH BC - LD B,008H -SWEP8: RLC E - JR C,SWEP7 - INC (HL) -SWEP7: DJNZ SWEP8 - POP BC - OR A - JR Z,SWEP0 - LD E,A -SWEP2: LD H,008H - LD A,B - DEC A - AND 00FH - JP L073E - -; ASCII TO DISPLAY CODE TABLE -ATBL: DB 0CCH ; NUL '\0' (null character) - DB 0E0H ; SOH (start of heading) - DB 0F2H ; STX (start of text) - DB 0F3H ; ETX (end of text) - DB 0CEH ; EOT (end of transmission) - DB 0CFH ; ENQ (enquiry) - DB 0F6H ; ACK (acknowledge) - DB 0F7H ; BEL '\a' (bell) - DB 0F8H ; BS '\b' (backspace) - DB 0F9H ; HT '\t' (horizontal tab) - DB 0FAH ; LF '\n' (new line) - DB 0FBH ; VT '\v' (vertical tab) - DB 0FCH ; FF '\f' (form feed) - DB 0FDH ; CR '\r' (carriage ret) - DB 0FEH ; SO (shift out) - DB 0FFH ; SI (shift in) - DB 0E1H ; DLE (data link escape) - DB 0C1H ; DC1 (device control 1) - DB 0C2H ; DC2 (device control 2) - DB 0C3H ; DC3 (device control 3) - DB 0C4H ; DC4 (device control 4) - DB 0C5H ; NAK (negative ack.) - DB 0C6H ; SYN (synchronous idle) - DB 0E2H ; ETB (end of trans. blk) - DB 0E3H ; CAN (cancel) - DB 0E4H ; EM (end of medium) - DB 0E5H ; SUB (substitute) - DB 0E6H ; ESC (escape) - DB 0EBH ; FS (file separator) - DB 0EEH ; GS (group separator) - DB 0EFH ; RS (record separator) - DB 0F4H ; US (unit separator) - DB 000H ; SPACE - DB 061H ; ! - DB 062H ; " - DB 063H ; # - DB 064H ; $ - DB 065H ; % - DB 066H ; & - DB 067H ; ' - DB 068H ; ( - DB 069H ; ) - DB 06BH ; * - DB 06AH ; + - DB 02FH ; , - DB 02AH ; - - DB 02EH ; . - DB 02DH ; / - DB 020H ; 0 - DB 021H ; 1 - DB 022H ; 2 - DB 023H ; 3 - DB 024H ; 4 - DB 025H ; 5 - DB 026H ; 6 - DB 027H ; 7 - DB 028H ; 8 - DB 029H ; 9 - DB 04FH ; : - DB 02CH ; ; - DB 051H ; < - DB 02BH ; = - DB 057H ; > - DB 049H ; ? - DB 055H ; @ - DB 001H ; A - DB 002H ; B - DB 003H ; C - DB 004H ; D - DB 005H ; E - DB 006H ; F - DB 007H ; G - DB 008H ; H - DB 009H ; I - DB 00AH ; J - DB 00BH ; K - DB 00CH ; L - DB 00DH ; M - DB 00EH ; N - DB 00FH ; O - DB 010H ; P - DB 011H ; Q - DB 012H ; R - DB 013H ; S - DB 014H ; T - DB 015H ; U - DB 016H ; V - DB 017H ; W - DB 018H ; X - DB 019H ; Y - DB 01AH ; Z - DB 052H ; [ - DB 059H ; \ '\\' - DB 054H ; ] - DB 0BEH ; ^ - DB 03CH ; _ - DB 0C7H ; ` - DB 081H ; a - DB 082H ; b - DB 083H ; c - DB 084H ; d - DB 085H ; e - DB 086H ; f - DB 087H ; g - DB 088H ; h - DB 089H ; i - DB 08AH ; j - DB 08BH ; k - DB 08CH ; l - DB 08DH ; m - DB 08EH ; n - DB 08FH ; o - DB 090H ; p - DB 091H ; q - DB 092H ; r - DB 093H ; s - DB 094H ; t - DB 095H ; u - DB 096H ; v - DB 097H ; w - DB 098H ; x - DB 099H ; y - DB 09AH ; z - DB 0BCH ; { - DB 080H ; | - DB 040H ; } - DB 0A5H ; ~ - DB 0C0H ; DEL - DB 040H - DB 0BDH - DB 09DH - DB 0B1H - DB 0B5H - DB 0B9H - DB 0B4H - DB 09EH - DB 0B2H - DB 0B6H - DB 0BAH - DB 0BEH - DB 09FH - DB 0B3H - DB 0B7H - DB 0BBH - DB 0BFH - DB 0A3H - DB 085H - DB 0A4H - DB 0A5H - DB 0A6H - DB 094H - DB 087H - DB 088H - DB 09CH - DB 082H - DB 098H - DB 084H - DB 092H - DB 090H - DB 083H - DB 091H - DB 081H - DB 09AH - DB 097H - DB 093H - DB 095H - DB 089H - DB 0A1H - DB 0AFH - DB 08BH - DB 086H - DB 096H - DB 0A2H - DB 0ABH - DB 0AAH - DB 08AH - DB 08EH - DB 0B0H - DB 0ADH - DB 08DH - DB 0A7H - DB 0A8H - DB 0A9H - DB 08FH - DB 08CH - DB 0AEH - DB 0ACH - DB 09BH - DB 0A0H - DB 099H - DB 0BCH - DB 0B8H - DB 080H - DB 03BH - DB 03AH - DB 070H - DB 03CH - DB 071H - DB 05AH - DB 03DH - DB 043H - DB 056H - DB 03FH - DB 01EH - DB 04AH - DB 01CH - DB 05DH - DB 03EH - DB 05CH - DB 01FH - DB 05FH - DB 05EH - DB 037H - DB 07BH - DB 07FH - DB 036H - DB 07AH - DB 07EH - DB 033H - DB 04BH - DB 04CH - DB 01DH - DB 06CH - DB 05BH - DB 078H - DB 041H - DB 035H - DB 034H - DB 074H - DB 030H - DB 038H - DB 075H - DB 039H - DB 04DH - DB 06FH - DB 06EH - DB 032H - DB 077H - DB 076H - DB 072H - DB 073H - DB 047H - DB 07CH - DB 053H - DB 031H - DB 04EH - DB 06DH - DB 048H - DB 046H - DB 07DH - DB 044H - DB 01BH - DB 058H - DB 079H - DB 042H - DB 060H - DB 0FDH - DB 0CBH - DB 000H - DB 01EH - -?ADCN: PUSH BC - PUSH HL - LD HL,ATBL ;00AB5H - LD C,A - LD B,000H - ADD HL,BC - LD A,(HL) - JR DACN3 - -_BRK: LD A,0CBH - OR A - JP ?KY10 - - ; Unused memory. - DB 029H - DB 0F4H - DB 0DDH - -?DACN: PUSH BC - PUSH HL - PUSH DE - LD HL,ATBL - LD D,H - LD E,L - LD BC,00100H - CPIR - JR Z,DACN1 - LD A,0F0H -DACN2: POP DE -DACN3: POP HL - POP BC - RET - -DACN1: OR A - DEC HL - SBC HL,DE - LD A,L - JR DACN2 - -KTBL: DB 022H - DB 021H - DB 017H - DB 011H - DB 001H - DB 0C7H - DB 000H - DB 01AH - DB 024H - DB 023H - DB 012H - DB 005H - DB 004H - DB 013H - DB 018H - DB 003H - DB 026H - DB 025H - DB 019H - DB 014H - DB 007H - DB 006H - DB 016H - DB 002H - DB 028H - DB 027H - DB 009H - DB 015H - DB 00AH - DB 008H - DB 00EH - DB 000H - DB 020H - DB 029H - DB 010H - DB 00FH - DB 00CH - DB 00BH - DB 02FH - DB 00DH - DB 0BEH - DB 02AH - DB 052H - DB 055H - DB 04FH - DB 02CH - DB 02DH - DB 02EH - DB 0C5H - DB 059H - DB 0C3H - DB 0C2H - DB 0CDH - DB 054H - DB 000H - DB 049H - DB 028H - DB 027H - DB 025H - DB 024H - DB 022H - DB 021H - DB 0E7H - DB 020H - DB 06AH - DB 029H - DB 02AH - DB 026H - DB 000H - DB 023H - DB 000H - DB 02EH - -KTBLS: DB 062H - DB 061H - DB 097H - DB 091H - DB 081H - DB 0C8H - DB 000H - DB 09AH - DB 064H - DB 063H - DB 092H - DB 085H - DB 084H - DB 093H - DB 098H - DB 083H - DB 066H - DB 065H - DB 099H - DB 094H - DB 087H - DB 086H - DB 096H - DB 082H - DB 068H - DB 067H - DB 089H - DB 095H - DB 08AH - DB 088H - DB 08EH - DB 000H - DB 0BFH - DB 069H - DB 090H - DB 08FH - DB 08CH - DB 08BH - DB 051H - DB 08DH - DB 0A5H - DB 02BH - DB 0BCH - DB 0A4H - DB 06BH - DB 06AH - DB 045H - DB 057H - DB 0C6H - DB 080H - DB 0C4H - DB 0C1H - DB 0CDH - DB 040H - DB 000H - DB 050H - -KTBLG: DB 03EH - DB 037H - DB 038H - DB 03CH - DB 053H - DB 0C7H - DB 000H - DB 076H - DB 07BH - DB 07FH - DB 030H - DB 034H - DB 047H - DB 044H - DB 06DH - DB 0DEH - DB 05EH - DB 03AH - DB 075H - DB 071H - DB 04BH - DB 04AH - DB 0DAH - DB 06FH - DB 0BDH - DB 01FH - DB 07DH - DB 079H - DB 05CH - DB 072H - DB 032H - DB 000H - DB 09CH - DB 0A1H - DB 0D6H - DB 0B0H - DB 0B4H - DB 05BH - DB 060H - DB 01CH - DB 09EH - DB 0D2H - DB 0D8H - DB 0B2H - DB 0B6H - DB 042H - DB 0DBH - DB 0B8H - DB 0C5H - DB 0D4H - DB 0C3H - DB 0C2H - DB 0CDH - DB 04EH - DB 000H - DB 0BAH - -KTBLGS: DB 036H - DB 03FH - DB 078H - DB 07CH - DB 046H - DB 0C8H - DB 000H - DB 077H - DB 03BH - DB 07EH - DB 070H - DB 074H - DB 048H - DB 041H - DB 0DDH - DB 0D9H - DB 01EH - DB 07AH - DB 035H - DB 031H - DB 04CH - DB 043H - DB 0A6H - DB 06EH - DB 0A2H - DB 05FH - DB 03DH - DB 039H - DB 05DH - DB 073H - DB 033H - DB 000H - DB 09DH - DB 0A3H - DB 0B1H - DB 0D5H - DB 056H - DB 06CH - DB 0D0H - DB 01DH - DB 09FH - DB 0D1H - DB 0B3H - DB 0D7H - DB 04DH - DB 0B5H - DB 01BH - DB 0B9H - DB 0C6H - DB 0D3H - DB 0C4H - DB 0C1H - DB 0CDH - DB 0B7H - DB 000H - DB 0BBH - -KTBLC: DB 0F0H - DB 0F0H - DB 0E2H - DB 0C1H - DB 0E0H - DB 0F0H - DB 000H - DB 0E5H - DB 0F0H - DB 0F0H - DB 0C2H - DB 0CFH - DB 0CEH - DB 0C3H - DB 0E3H - DB 0F3H - DB 0F0H - DB 0F0H - DB 0E4H - DB 0C4H - DB 0F7H - DB 0F6H - DB 0C6H - DB 0F2H - DB 0F0H - DB 0F0H - DB 0F9H - DB 0C5H - DB 0FAH - DB 0F8H - DB 0FEH - DB 0F0H - DB 0F0H - DB 0F0H - DB 0E1H - DB 0FFH - DB 0FCH - DB 0FBH - DB 0F0H - DB 0FDH - DB 0EFH - DB 0F4H - DB 0E6H - DB 0CCH - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - DB 0F0H - DB 0EBH - DB 0F0H - DB 0F0H - DB 0F0H - DB 0EEH - DB 0F0H - -?BRK: LD A,0F0H - LD (KEYPA),A - NOP - LD A,(KEYPB) - OR A - RLA - JR NC,L0D37 - RRA - RRA - JR NC,L0D27 - RRA - JR NC,L0D2B - CCF - RET - -L0D27: LD A,040H - SCF - RET - -L0D2B: LD A,(KDATW) - LD A,001H - LD (KDATW),A - LD A,010H - SCF - RET - -L0D37: AND 002H - RET Z - - LD A,020H - SCF - RET - -L0D3E: PUSH AF - LD A,003H - LD (KEYPF),A - CALL L0759 - CALL L0759 - LD A,002H - LD (KEYPF),A - CALL L0759 - CALL L0759 - POP AF - RET - -L0D57: PUSH AF - LD A,003H - LD (KEYPF),A - CALL L0759 - CALL L0759 - CALL L0759 - CALL L0759 - LD A,002H - LD (KEYPF),A - CALL L0759 - CALL L0759 - CALL L0759 - CALL L0760 - POP AF - RET - -?DSPA: CP 008H - JR Z,L0D90 -L0D80: RRC (HL) - DJNZ L0D80 - SET 0,(HL) - RES 1,(HL) - LD B,A -L0D89: RLC (HL) - DJNZ L0D89 -DSP04: JP CURSR -L0D90: INC HL - SET 0,(HL) - RES 1,(HL) - JR DSP04 -DSP02: SET 7,(HL) - INC HL - RES 0,(HL) - JR DSP04 - - -MSG_1: DB 07FH, 020H -MSG_2: DB 050H, 04CH, 041H, 059H, 00DH, 0F3H - -?BLNK: RET - -DLY12: PUSH BC - LD B,023H -DLY12A: CALL DLY3 - DJNZ DLY12A - POP BC - RET - - ; BELL DATA -?BELD: DB 0D7H, 041H, 030H, 00DH - -?DSP: PUSH AF - PUSH BC - PUSH DE - PUSH HL - LD B,A - CALL ?PONT - LD (HL),B - LD HL,(DSPXY) - LD A,L -DSP01: CP COLW - 1 ; End of line. - JR NZ,DSP04 - CALL .MANG - JR C,DSP04 - LD A,(SPAGE) - OR A - JP NZ,.DSP03 - EX DE,HL - LD A,B - CP 007H - JR Z,DSP02 - JR ?DSPA - - ; Unused memory. - INC H - DI - -?DPCT: PUSH AF ; Display control, character is mapped to a function call. - PUSH BC - PUSH DE - PUSH HL - LD B,A - AND 0F0H - CP 0C0H - JP NZ,?RSTR - XOR B - RLCA - LD C,A - LD B,000H - LD HL,CTBL - LD A,(SPAGE) - OR A - JR Z,DPCT1 - LD HL,.CTBL -DPCT1: ADD HL,BC - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL - JP (HL) - - -CTBL: DW SCROL - DW CURSD - DW CURSU - DW CURSR - DW CURSL - DW HOME - DW CLRS - DW DEL - DW INST - DW ALPHA - DW KANA - DW ?RSTR - DW REV - DW CR - DW ROLUP - DW ROLD - -;.CTBL: DW .SCROL -; DW CURSD -; DW CURSU -; DW CURSR -; DW CURSL -; DW HOM0 -; DW CLRS -; DW DEL -; DW INST -; DW ALPHA -; DW KANA -; DW ?RSTR -; DW REV -; DW .CR -; DW ?RSTR -; DW ?RSTR - -SCROL: LD HL,PBIAS - LD C,SCRLW ; Number of 8byte blocks in a line to scroll. - LD A,(ROLEND) - ADD A,C - LD (ROLEND),A - LD A,(ROLTOP) - ADD A,C - LD (ROLTOP),A -SCROL1: LD A,C - ADD A,(HL) - LD (HL),A - CALL L09C7 - LD HL,(PAGETP) - LD DE,SCRNSZ - ADD HL,DE ; HL=PAGETOP + 1000/2000 - LD B,COLW - XOR A -SCROL2: RES 3,H - LD (HL),A - INC HL - DJNZ SCROL2 - LD A,(PBIAS) ; PBIAS is the offest for hardware scroll. - LD L,A - LD H,SCLBASE ; Hardware scroll region, E2 - LD A,(HL) - LD HL,MANGE - OR A - LD B,007H -SCROL3: RR (HL) - DEC HL - DJNZ SCROL3 - JP ?RSTR - -CURSD: LD HL,(DSPXY) - LD A,H - CP ROW - 1 - JR Z,CURS4 - INC H -CURS1: CALL MGP.I -CURS3: LD (DSPXY),HL - JR ?RSTR - -CURSU: LD HL,(DSPXY) - LD A,H - OR A - JR Z,CURS5 - DEC H -CURSU1: CALL MGP.D - JR CURS3 - -CURSR: LD HL,(DSPXY) - LD A,L - CP COLW - 1 ; End of line - JR NC,CURS2 - INC L - JR CURS3 -CURS2: LD L,000H - INC H - LD A,H - CP ROW - JR C,CURS1 - LD H,ROW - 1 - LD (DSPXY),HL -CURS4: JR CURS6 - -CURSL: LD HL,(DSPXY) - LD A,L - OR A - JR Z,CURS5A - DEC L - JR CURS3 -CURS5A: LD L,COLW - 1 ; End of line - DEC H - JP P,CURSU1 - LD H,000H - LD (DSPXY),HL -CURS5: LD A,(SPAGE) - OR A - JR NZ,?RSTR - JP ROLD - -CLRS: LD HL,MANG - LD B,01BH - CALL ?CLER - LD HL,SCRN - PUSH HL - CALL L09E2 - POP HL - LD A,(SPAGE) - OR A - JR NZ,CLRS1 - LD (PAGETP),HL - LD A,07DH - LD (ROLEND),A -CLRS1: LD A,(SCLDSP) -HOM00: JP HOM0 - -CURS6: LD A,(SPAGE) - OR A - JP NZ,.SCROL - JP ROLU - -ALPHA: XOR A -ALPHI: LD (KANAF),A -?RSTR: POP HL -?RSTR1: POP DE - POP BC - POP AF - RET - - ; Unused memory - DEC C - DEC C - DEC C - DEC C - -KANA: LD A,001H - JR ALPHI - -DEL: LD HL,(DSPXY) - LD A,H - OR L - JR Z,?RSTR - LD A,L - OR A - JR NZ,DEL1 - CALL .MANG - JR C,DEL1 - CALL ?PONT - DEC HL - LD (HL),000H - JR CURSL -DEL1: CALL .MANG - RRCA - LD A,COLW - JR NC,L0F13 - RLCA -L0F13: SUB L - LD B,A - CALL ?PONT - PUSH HL - POP DE - DEC DE - SET 4,D -DEL2: RES 3,H - RES 3,D - LD A,(HL) - LD (DE),A - INC HL - INC DE - DJNZ DEL2 - DEC HL - LD (HL),000H - JP CURSL - -INST: CALL .MANG - RRCA - LD L,COLW - 1 ; End of line - LD A,L - JR NC,INST1A - INC H -INST1A: CALL ?PNT1 - PUSH HL - LD HL,(DSPXY) - JR NC,INST2 - LD A,(COLW*2)-1 ; 04FH -INST2: SUB L - LD B,A - POP DE - LD A,(DE) - OR A - JR NZ,?RSTR - CALL ?PONT - LD A,(HL) - LD (HL),000H -INST1: INC HL - RES 3,H - LD E,(HL) - LD (HL),A - LD A,E - DJNZ INST1 - JR ?RSTR - -ROLD: LD HL,PBIAS - LD A,(ROLTOP) - CP (HL) - JR Z,?RSTR - CALL MGP.D - LD A,(HL) - SUB SCRLW ; Number of 8byte blocks in a line to scroll. -ROL2: LD (HL),A - LD L,A - LD H,SCLBASE - LD A,(HL) - CALL L09C7 - JP ?RSTR - -CR: CALL .MANG - RRCA - JP NC,CURS2 - LD L,000H - INC H - LD A,H - CP ROW - 1 ; End of line? - JR Z,CR3 - JR NC,CR2 - CALL MGP.I - INC H - JP CURS1 -CR2: DEC H - LD (DSPXY),HL - LD HL,ROLU - PUSH HL - PUSH AF - PUSH BC - PUSH DE - CALL ROLU -CR3: LD (DSPXY),HL - CALL MGP.I - -ROLU: LD HL,PBIAS - LD A,(ROLEND) - CP (HL) - JP Z,SCROL -ROLU1: CALL MGP.I - LD A,(HL) - ADD A,SCRLW ; Number of 8byte blocks in a line to scroll. - JR ROL2 - -?PONT: LD HL,(DSPXY) -?PNT1: PUSH AF - PUSH BC - PUSH DE - PUSH HL - POP BC - LD DE,COLW - LD HL,SCRN - COLW - LD A,(SPAGE) - OR A - JR NZ,?PNT2 - LD HL,(PAGETP) - SBC HL,DE -?PNT2: ADD HL,DE - DEC B - JP P,?PNT2 - LD B,000H - ADD HL,BC - RES 3,H - POP DE - POP BC - POP AF - RET - -?CLER: XOR A - JR ?DINT -?CLRFF: LD A,0FFH -?DINT: LD (HL),A - INC HL - DJNZ ?DINT - RET - -GAPCK: PUSH BC - PUSH DE - PUSH HL - LD BC,KEYPB - LD DE,KEYPC -GAPCK1: LD H,064H -GAPCK2: CALL EDGE - JR C,GAPCK3 - CALL DLY3 - LD A,(DE) - AND 020H - JR NZ,GAPCK1 - DEC H - JR NZ,GAPCK2 -GAPCK3: JP RET3 - - ALIGN_NOPS 0D000H - - ; Bring in additional macros. - INCLUDE "macros.asm" - - ; MONITOR WORK AREA - ; (MZ700) - -STACK: EQU HL_STACK - - ORG STACK -SPV: -IBUFE: ; TAPE BUFFER (128 BYTES) -ATRB: DS virtual 1 ; ATTRIBUTE -NAME: DS virtual 17 ; FILE NAME -SIZE: DS virtual 2 ; BYTESIZE -DTADR: DS virtual 2 ; DATA ADDRESS -EXADR: DS virtual 2 ; EXECUTION ADDRESS -COMNT: DS virtual 92 ; COMMENT -SWPW: DS virtual 10 ; SWEEP WORK -KDATW: DS virtual 2 ; KEY WORK -KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) -DSPXY: DS virtual 2 ; DISPLAY COORDINATES -MANG: DS virtual 6 ; COLUMN MANAGEMENT -MANGE: DS virtual 1 ; COLUMN MANAGEMENT END -PBIAS: DS virtual 1 ; PAGE BIAS -ROLTOP: DS virtual 1 ; ROLL TOP BIAS -MGPNT: DS virtual 1 ; COLUMN MANAG. POINTER -PAGETP: DS virtual 2 ; PAGE TOP -ROLEND: DS virtual 1 ; ROLL END - DS virtual 14 ; BIAS -FLASH: DS virtual 1 ; FLASHING DATA -SFTLK: DS virtual 1 ; SHIFT LOCK -REVFLG: DS virtual 1 ; REVERSE FLAG -SPAGE: DS virtual 1 ; PAGE CHANGE -FLSDT: DS virtual 1 ; CURSOR DATA -STRGF: DS virtual 1 ; STRING FLAG -DPRNT: DS virtual 1 ; TAB COUNTER -TMCNT: DS virtual 2 ; TAPE MARK COUNTER -SUMDT: DS virtual 2 ; CHECK SUM DATA -CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA -AMPM: DS virtual 1 ; AMPM DATA -TIMFG: DS virtual 1 ; TIME FLAG -SWRK: DS virtual 1 ; KEY SOUND FLAG -TEMPW: DS virtual 1 ; TEMPO WORK -ONTYO: DS virtual 1 ; ONTYO WORK -OCTV: DS virtual 1 ; OCTAVE WORK -RATIO: DS virtual 2 ; ONPU RATIO -BUFER: DS virtual 81 ; GET LINE BUFFER - -HL_MONIT:EQU 0C000h -HL_STACK:EQU 0BEF0H -USRROM: EQU 0E800H ; Address of 2K User Rom. -FLPROM: EQU 0F000H ; Address of 4K Floppy control Rom. - - ; EQU TABLE I/O REPORT - -SCRN: EQU 0D000H -ARAM: EQU 0D800H -DSPCTL: EQU 0DFFFH ; Screen 40/80 select register (bit 7) -KEYPA: EQU 0E000H -KEYPB: EQU 0E001H -KEYPC: EQU 0E002H -KEYPF: EQU 0E003H -CSTR: EQU 0E002H -CSTPT: EQU 0E003H -CONT0: EQU 0E004H -CONT1: EQU 0E005H -CONT2: EQU 0E006H -CONTF: EQU 0E007H -SUNDG: EQU 0E008H -TEMP: EQU 0E008H -MEMSW: EQU 0E00CH -MEMSWR: EQU 0E010H -INVDSP: EQU 0E014H -NRMDSP: EQU 0E015H -SCLDSP: EQU 0E200H -SCLBASE:EQU 0E2H diff --git a/software/asm/sfd700.asm b/software/asm/sfd700.asm deleted file mode 100644 index aec43a2..0000000 --- a/software/asm/sfd700.asm +++ /dev/null @@ -1,1658 +0,0 @@ -; ROM of K&P SFD700 interface - -; data areas - -; 1000 1 Latest FDC command byte -; 1001 1 Motor on flag, 01 = on, 00 = off -; 1002 4 Track 0 flags for each drive ( 1 to 4 ) -; 1006 1 Retry count -; 1007 1 Not sure of this one? -; 1008 1 Drive Number ( 0 to 3 ) -; 1009 2 Logical Sector Number ( 0 to 1119 ) -; 100B 1 Bytes to read (after all sectors are read) -; 100C 1 Number of sectors to read -; or -; 100B 2 Bytes to read -; 100D 2 Memory Load address -; 100F 1 Current track No. ( 0 to 69 ) -; 1010 1 Current Sector No. ( 1 to 16 ) -; 1011 1 Start track No. ( 0 to 69 ) -; 1012 1 Start Sector No. ( 1 to 16 ) - - -; Controller register -; $D8 ; Command Register (write) -; $D8 ; Status Register (read) -; $D9 ; Track Register (write) -: $DA ; Sector Register (write) -: $DB ; Data Register (read/write) -; $DC ; Drive/Motor select (write) -; $DD ; Side/Head select (write) - - -f000 00 NOP ;ID for interface detection -f001 110810 LD DE,1008H ;nach -f004 21DDF0 LD HL,0F0DDH ;von -f007 010B00 LD BC,000BH ;11 bytes 00 00 00 00 01 00 CE 00 00 00 00 -f00a EDB0 LDIR ;BC=0, HL=F0E8, DE=1013 -f00c CD51F1 CALL 0F151H ;init 1001-1005, port $DC mit $00 -f00f CD0900 CALL 0009H ;NL -f012 11A1F0 LD DE,0F0A1H ;msg BOOT DRIVE? -f015 CD1500 CALL 0015H ;prt -f018 11A311 LD DE,11A3H ;kbd buffer -f01b CD0300 CALL 0003H ;get line -f01e 1A LD A,(DE) ;get 1st char -f01f FE1B CP 1BH ;brk? -f021 CA8900 JP Z,0098H ;yes -f024 210C00 LD HL,000CH -f027 19 ADD HL,DE ;skip around msg, 11A3+0C=11AF -f028 7E LD A,(HL) ;get char -f029 FE0D CP 0DH ;CR? -f02b 280D JR Z,0F03AH ;yes, default drive 1 -f02d CDF903 CALL 03F9H ;ASCII to hex (A) -f030 38DD JR C,0F00FH ;nohex, error, again -f032 3D DEC A ;-1 -f033 FE04 CP 04H ;drive >4? -f035 30D8 JR NC,0F00FH ;error, again -f037 320810 LD (1008H),A ;save drive no -1 (0 to 3) -f03a DD210810 LD IX,1008H ;drive no -f03e CDBAF1 CALL 0F1BAH ;read sector 1 of trk 0 -f041 2100CE LD HL,0CE00H ;dsk buffer -f044 11CCF0 LD DE,0F0CCH ;=02 mst dsk flag (changed to 03) -f047 0607 LD B,07H ;check for #02,"IPLPRO" -f049 4E LD C,(HL) -f04a 1A LD A,(DE) -f04b B9 CP C -f04c C28CF0 JP NZ,0F08CH ;error no master dsk -f04f 23 INC HL ;nxt char -f050 13 INC DE ;nxt char -f051 10F6 DJNZ 0F049H ;nxt char -f053 CD0900 CALL 0009H ;NL -f056 11BCF0 LD DE,0F0BCH -f059 CD1500 CALL 0015H ;msg K&P IS LOADING -f05c 1107CE LD DE,0CE07H -f05f CD1500 CALL 0015H ;prt prog name -f062 2A16CE LD HL,(0CE16H) ;load address -f065 DD7505 LD (IX+05H),L ;to 100D/100E -f068 DD7406 LD (IX+06H),H -f06b 2A14CE LD HL,(0CE14H) ;size -f06e DD7503 LD (IX+03H),L ;to 100B/100C -f071 DD7404 LD (IX+04H),H -f074 2A1ECE LD HL,(0CE1EH) ;logical sector number -f077 DD7501 LD (IX+01H),L ;to 1009/100A -f07a DD7402 LD (IX+02H),H -f07d CDBAF1 CALL 0F1BAH -f080 CD51F1 CALL 0F151H -f083 2A18CE LD HL,(0CE18H) ;exec address -f086 E9 JP (HL) - -f087 11AEF0 LD DE,0F0AEH ;msg LOADING ERROR -f08a 1803 JR 0F08FH - -f08c 11E8F0 LD DE,0F0E8H ;msg THIS DISKETTE IS NOT MASTER -f08f CD0900 CALL 0009H -f092 CD1500 CALL 0015H -f095 CD0900 CALL 0009H -f098 11D3F0 LD DE,0F0D3H -f09b CD3000 CALL 0030H ;play melody -f09e C3A200 JP 00A2H ;warm start - -f0a1 db "BOOT DRIVE ?",#0D - -f0ae db "LOADING ERROR",#0D - -f0bc db "K&P IS LOADING ",#0D - -f0cc db #02 ; changed to 03 -f0cd db "IPLPRO" - -;melody data -f0d3 db "A0",#D7,"ARA",#D7,"AR",#0D -f0dd db ,#00,#00,#00,#00,#01,#00,#CE,#00,#00,#00,#00 - -f0e8 db "THIS DISKETTE IS NOT MASTER",#0D - -f104 3A0110 LD A,(1001H) ;motor on flag -f107 0F RRCA ;motor off? -f108 D438F1 CALL NC,0F138H ;yes, set motor on and wait -f10b DD7E00 LD A,(IX+00H) ;drive no -f10e F684 OR 84H ; -f110 D3DC OUT (0DCH),A ;Motor on for drive 0-3 -f112 AF XOR A -f113 320010 LD (1000H),A ;clr latest FDC command byte -f116 210000 LD HL,0000H -f119 2B DEC HL -f11a 7C LD A,H -f11b B5 OR L -f11c CA9DF2 JP Z,0F29DH ;reset and msg THIS DISKETTE IS NOT MASTER -f11f DBD8 IN A,(0D8H) ;state reg -f121 2F CPL -f122 07 RLCA -f123 38F4 JR C,0F119H ;wait on motor off (bit 7) -f125 DD4E00 LD C,(IX+00H) ;drive no -f128 210210 LD HL,1002H ;1 track 0 flag for each drive -f12b 0600 LD B,00H -f12d 09 ADD HL,BC ;compute related flag 1002/1003/1004/1005 -f12e CB46 BIT 0,(HL) ; -f130 2005 JR NZ,0F137H ;no -f132 CD64F1 CALL 0F164H ; -f135 CBC6 SET 0,(HL) ;set bit 0 of trk 0 flag -f137 C9 RET - -;motor on -f138 3E80 LD A,80H -f13a D3DC OUT (0DCH),A ;Motor on -f13c 0610 LD B,10H -f13e CDC7F2 CALL 0F2C7H ;wait loop2 -f141 10FB DJNZ 0F13EH ;16 times -f143 3E01 LD A,01H -f145 320110 LD (1001H),A ;motor on flag on -f148 C9 RET - -;command 1b output -f149 3E1B LD A,1BH ;1x = SEEK -f14b CD71F1 CALL 0F171H ;command 1b output -f14e E699 AND 99H -f150 C9 RET - -;init/reset flags, set motor off -f151 AF XOR A -f152 D3DC OUT (0DCH),A ;Motor on/off -f154 320210 LD (1002H),A ;track 0 flag drive 1 -f157 320310 LD (1003H),A ;track 0 flag drive 2 -f15a 320410 LD (1004H),A ;track 0 flag drive 3 -f15d 320510 LD (1005H),A ;track 0 flag drive 4 -f160 320110 LD (1001H),A :motor on flag -f163 C9 RET - -f164 3E0B LD A,0BH ;0x = RESTORE (seek track 0) -f166 CD71F1 CALL 0F171H -f169 E685 AND 85H ; -f16b EE04 XOR 04H ; -f16d C8 RET Z ; -f16e F3 DI -f16f 9D SBC A,L -f170 C23200 JP NZ,0032H ;??? - -f171 320010 ld (1000H),a ;latest FDC command 0b/1b - -f173 2F CPL ;f4/e4 -f175 D3D8 OUT (0D8H),A ;Command reg -f177 CD7EF1 CALL 0F17EH ;wait on ready -f17a DBD8 IN A,(0D8H) ;state reg -f17c 2F CPL -f17d C9 RET - -;Wait on ready -f17e D5 PUSH DE -f17f E5 PUSH HL -f180 CDC0F2 CALL 0F2C0H ;wait loop1 -f183 1E07 LD E,07H -f185 210000 LD HL,0000H -f188 2B DEC HL -f189 7C LD A,H -f18a B5 OR L -f18b 2809 JR Z,0F196H -f18d DBD8 IN A,(0D8H) ;state reg -f18f 2F CPL -f190 0F RRCA -f191 38F5 JR C,0F188H ;wait on busy (bit 0) -f193 E1 POP HL -f194 D1 POP DE -f195 C9 RET - -f196 1D DEC E -f197 20EC JR NZ,0F185H -f199 C39DF2 JP 0F29DH - -;wait on bit1=0 of state reg -f19c D5 PUSH DE -f19d E5 PUSH HL -f19e CDC0F2 CALL 0F2C0H ;wait loop1 -f1a1 1E07 LD E,07H ;init next wait loop -f1a3 210000 LD HL,0000H -f1a6 2B DEC HL -f1a7 7C LD A,H -f1a8 B5 OR L -f1a9 2809 JR Z,0F1B4H -f1ab DBD8 IN A,(0D8H) ;state reg -f1ad 2F CPL -f1ae 0F RRCA -f1af 30F5 JR NC,0F1A6H ;wait on not busy (bit 0) -f1b1 E1 POP HL -f1b2 D1 POP DE -f1b3 C9 RET - -f1b4 1D DEC E -f1b5 20EC JR NZ,0F1A3H ;wait loop -f1b7 C39DF2 JP 0F29DH - -f1ba CD20F2 CALL 0F220H ;compute logical sector-no to track-no & sector-no, retries=10 -f1bd CD29F2 CALL 0F229H ;set current track & sector, get load address to HL -f1c0 CD49F2 CALL 0F249H ;set side reg -f1c3 CD49F1 CALL 0F149H ;command 1b output (seek) -f1c6 204E JR NZ,0F216H ; -f1c8 CD59F2 CALL 0F259H ;set track & sector reg -f1cb DDE5 PUSH IX ;save 1008 -f1cd DD2100F3 LD IX,0F300H -f1d1 FD21DFF1 LD IY,0F1DFH ;ret addr -f1d5 F3 DI -f1d6 3E94 LD A,94H ;latest FDC command byte -f1d8 CD8AF2 CALL 0F28AH ;set command reg, wait ready -f1db 0600 LD B,00H -f1dd DDE9 JP (IX) ;to F300 & return to f1df - -;get chars from disk sector to area beginning at CE00 -f1df EDA2 INI -f1e1 C200F3 JP NZ,0F300H -f1e4 DDE1 POP IX -f1e6 DD3408 INC (IX+08H) ;current sector number -f1e9 DD7E08 LD A,(IX+08H) ;current sector number -f1ec DDE5 PUSH IX ;save 1008 -f1ee DD2100F3 LD IX,0F300H -f1f2 FE11 CP 11H ;sector 17? -f1f4 2805 JR Z,0F1FBH -f1f6 15 DEC D -f1f7 20E2 JR NZ,0F1DBH -f1f9 1801 JR 0F1FCH - -f1fb 15 DEC D -f1fc CD94F2 CALL 0F294H -f1ff CDD2F2 CALL 0F2D2H -f202 DDE1 POP IX ;1008 -f204 DBD8 IN A,(0D8H) ;state reg -f206 2F CPL -f207 E6FF AND 0FFH -f209 200B JR NZ,0F216H -f20b CD78F2 CALL 0F278H -f20e CA1BF2 JP Z,0F21BH ;if D=0 -f211 DD7E07 LD A,(IX+07H) ;current track no -f214 18AA JR 0F1C0H - -; -f216 CD6AF2 CALL 0F26AH -f219 18A2 JR 0F1BDH - -f21b 3E80 LD A,80H -f21d D3DC OUT (0DCH),A ;Motor on -f21f C9 RET - -f220 CDA3F2 CALL 0F2A3H ;compute logical sector no to track no & sector no -f223 3E0A LD A,0AH -f225 320610 LD (1006H),A ;10 retries -f228 C9 RET - -;set current track & sector, get load address to HL -f229 CD04F1 CALL 0F104H -f22c DD5604 LD D,(IX+04H) ;number of sectors to read -f22f DD7E03 LD A,(IX+03H) ;bytes to read -f232 B7 OR A ;0? -f233 2801 JR Z,0F236H ;yes -f235 14 INC D ;number of sectors to read + 1 -f236 DD7E0A LD A,(IX+0AH) ;start sector number -f239 DD7708 LD (IX+08H),A ;to current sector number -f23c DD7E09 LD A,(IX+09H) ;start track number -f23f DD7707 LD (IX+07H),A ;to current track number -f242 DD6E05 LD L,(IX+05H) ;load address low byte -f245 DD6606 LD H,(IX+06H) ;load address high byte -f248 C9 RET - -;compute side/head -f249 CB3F SRL A ;track number even? -f24b 2F CPL ; -f24c D3DB OUT (0DBH),A ;output track no -f24e 3004 JR NC,0F254H ;yes, even, set side/head 0 -f250 3E01 LD A,01H ;no, odd, set side/head 1 -f252 1801 JR 0F255H - -;set side/head reg -f254 AF XOR A -f255 2F CPL ; -f256 D3DD OUT (0DDH),A ;side/head reg -f258 C9 RET - -;set track & sector reg -f259 0EDB LD C,0DBH -f25b DD7E07 LD A,(IX+07H) ;current track number -f25e CB3F SRL A ; -f260 2F CPL ; -f261 D3D9 OUT (0D9H),A ;track reg -f263 DD7E08 LD A,(IX+08H) ;current sector number -f266 2F CPL ; -f267 D3DA OUT (0DAH),A ;sector reg -f269 C9 RET - -f26a 3A0610 LD A,(1006H) ;retry count - 1 -f26d 3D DEC A -f26e 320610 LD (1006H),A ;retry count -f271 CA9DF2 JP Z,0F29DH -f274 CD64F1 CALL 0F164H -f277 C9 RET - -f278 DD7E08 LD A,(IX+08H) ;current sector number -f27b FE11 CP 11H -f27d 2008 JR NZ,0F287H ;no, not 17 -f27f 3E01 LD A,01H -f281 DD7708 LD (IX+08H),A ;current sector number = 1 -f284 DD3407 INC (IX+07H) ;current track number + 1 -f287 7A LD A,D -f288 B7 OR A ; -f289 C9 RET - -;output to command reg and wait on ready -f28a 320010 LD (1000H),A ;latest FDC command byte -f28d 2F CPL -f28e D3D8 OUT (0D8H),A ;command reg -f290 CD9CF1 CALL 0F19CH ;wait on not busy -f293 C9 RET - -:force interrupt -f294 3ED8 LD A,0D8H ;force interrupt code -f296 2F CPL -f297 D3D8 OUT (0D8H),A ;force interrupt -f299 CD7EF1 CALL 0F17EH -f29c C9 RET - -f29d CD51F1 CALL 0F151H ;reset flags -f2a0 C387F0 JP 0F087H ;loading error - -; compute logical sector no to physical track no and sector no -f2a3 0600 LD B,00H -f2a5 111000 LD DE,0010H ;no of sectors per trk (16) -f2a8 DD6E01 LD L,(IX+01H) ;logical sector number -f2ab DD6602 LD H,(IX+02H) ;2 bytes in length -f2ae AF XOR A -f2af ED52 SBC HL,DE ;subtract 16 sectors/trk -f2b1 3803 JR C,0F2B6H ;yes, negative value -f2b3 04 INC B ;count track -f2b4 18F9 JR 0F2AFH ;loop - -f2b6 19 ADD HL,DE ;reset HL to the previous -f2b7 60 LD H,B ;track -f2b8 2C INC L ;correction +1 -f2b9 DD7409 LD (IX+09H),H ;start track no -f2bc DD750A LD (IX+0AH),L ;start sector no -f2bf C9 RET - -;wait loop1 -f2c0 D5 PUSH DE -f2c1 110700 LD DE,0007H -f2c4 C3CBF2 JP 0F2CBH ;wait loop - -; Wait loop2 -f2c7 D5 PUSH DE -f2c8 111310 LD DE,1013H -f2cb 1B DEC DE ;see f2c0, value set to 0007 -f2cc 7B LD A,E -f2cd B2 OR D -f2ce 20FB JR NZ,0F2CBH ;wait loop -f2d0 D1 POP DE -f2d1 C9 RET - -f2d2 F5 PUSH AF -f2d3 3A9C11 LD A,(119CH) ;time flag -f2d6 FEF0 CP 0F0H -f2d8 2001 JR NZ,0F2DBH -f2da FB EI -f2db F1 POP AF -f2dc C9 RET - - -;should never be executed automatically! -f2dd 11E5F2 LD DE,0F2E5H -f2e0 CD1500 CALL 0015H ;msg (C) 1983 F.Scheider -f2e3 1824 JR 0F309H - -f2e5 db "(C) 1983 F.Scheider ",#0D - -f2f9 FF RST 38H -f2fa FF RST 38H -f2fb FF RST 38H -f2fc FF RST 38H -f2fd FF RST 38H -f2fe FF RST 38H -f2ff FF RST 38H - -;wait on bit 0 and bit 1 = 0 of state reg -f300 DBD8 IN A,(0D8H) ;state reg -f302 0F RRCA -f303 38FB JR C,0F300H ;wait on not busy -f305 0F RRCA -f306 38F8 JR C,0F300H ;wait on data reg ready -f308 FDE9 JP (IY) ;to f1df - - -;should never be executed automatically!! -f30a 1112F3 LD DE,0F312H -f30d CD1500 CALL 0015H ;msg Hardware: K.Minor -f310 1812 JR 0F324H - -f312 db "Hardware: K.Minor",#0D - - -;should never be executed automatically!! -f324 112CF3 LD DE,0F32CH -f327 CD1500 CALL 0015H ;msg K&P,West Germany -f32a 18B1 JR 0F2DDH - -f32c db "K&P,West Germany ",#0D - -f33e FF RST 38H -f33f FF RST 38H -f340 FF RST 38H -f341 FF RST 38H -f342 FF RST 38H -f343 FF RST 38H -f344 FF RST 38H -f345 FF RST 38H -f346 FF RST 38H -f347 FF RST 38H -f348 FF RST 38H -f349 FF RST 38H -f34a FF RST 38H -f34b FF RST 38H -f34c FF RST 38H -f34d FF RST 38H -f34e FF RST 38H -f34f FF RST 38H -f350 FF RST 38H -f351 FF RST 38H -f352 FF RST 38H -f353 FF RST 38H -f354 FF RST 38H -f355 FF RST 38H -f356 FF RST 38H -f357 FF RST 38H -f358 FF RST 38H -f359 FF RST 38H -f35a FF RST 38H -f35b FF RST 38H -f35c FF RST 38H -f35d FF RST 38H -f35e FF RST 38H -f35f FF RST 38H -f360 FF RST 38H -f361 FF RST 38H -f362 FF RST 38H -f363 FF RST 38H -f364 FF RST 38H -f365 FF RST 38H -f366 FF RST 38H -f367 FF RST 38H -f368 FF RST 38H -f369 FF RST 38H -f36a FF RST 38H -f36b FF RST 38H -f36c FF RST 38H -f36d FF RST 38H -f36e FF RST 38H -f36f FF RST 38H -f370 FF RST 38H -f371 FF RST 38H -f372 FF RST 38H -f373 FF RST 38H -f374 FF RST 38H -f375 FF RST 38H -f376 FF RST 38H -f377 FF RST 38H -f378 FF RST 38H -f379 FF RST 38H -f37a FF RST 38H -f37b FF RST 38H -f37c FF RST 38H -f37d FF RST 38H -f37e FF RST 38H -f37f FF RST 38H -f380 FF RST 38H -f381 FF RST 38H -f382 FF RST 38H -f383 FF RST 38H -f384 FF RST 38H -f385 FF RST 38H -f386 FF RST 38H -f387 FF RST 38H -f388 FF RST 38H -f389 FF RST 38H -f38a FF RST 38H -f38b FF RST 38H -f38c FF RST 38H -f38d FF RST 38H -f38e FF RST 38H -f38f FF RST 38H -f390 FF RST 38H -f391 FF RST 38H -f392 FF RST 38H -f393 FF RST 38H -f394 FF RST 38H -f395 FF RST 38H -f396 FF RST 38H -f397 FF RST 38H -f398 FF RST 38H -f399 FF RST 38H -f39a FF RST 38H -f39b FF RST 38H -f39c FF RST 38H -f39d FF RST 38H -f39e FF RST 38H -f39f FF RST 38H -f3a0 FF RST 38H -f3a1 FF RST 38H -f3a2 FF RST 38H -f3a3 FF RST 38H -f3a4 FF RST 38H -f3a5 FF RST 38H -f3a6 FF RST 38H -f3a7 FF RST 38H -f3a8 FF RST 38H -f3a9 FF RST 38H -f3aa FF RST 38H -f3ab FF RST 38H -f3ac FF RST 38H -f3ad FF RST 38H -f3ae FF RST 38H -f3af FF RST 38H -f3b0 FF RST 38H -f3b1 FF RST 38H -f3b2 FF RST 38H -f3b3 FF RST 38H -f3b4 FF RST 38H -f3b5 FF RST 38H -f3b6 FF RST 38H -f3b7 FF RST 38H -f3b8 FF RST 38H -f3b9 FF RST 38H -f3ba FF RST 38H -f3bb FF RST 38H -f3bc FF RST 38H -f3bd FF RST 38H -f3be FF RST 38H -f3bf FF RST 38H -f3c0 FF RST 38H -f3c1 FF RST 38H -f3c2 FF RST 38H -f3c3 FF RST 38H -f3c4 FF RST 38H -f3c5 FF RST 38H -f3c6 FF RST 38H -f3c7 FF RST 38H -f3c8 FF RST 38H -f3c9 FF RST 38H -f3ca FF RST 38H -f3cb FF RST 38H -f3cc FF RST 38H -f3cd FF RST 38H -f3ce FF RST 38H -f3cf FF RST 38H -f3d0 FF RST 38H -f3d1 FF RST 38H -f3d2 FF RST 38H -f3d3 FF RST 38H -f3d4 FF RST 38H -f3d5 FF RST 38H -f3d6 FF RST 38H -f3d7 FF RST 38H -f3d8 FF RST 38H -f3d9 FF RST 38H -f3da FF RST 38H -f3db FF RST 38H -f3dc FF RST 38H -f3dd FF RST 38H -f3de FF RST 38H -f3df FF RST 38H -f3e0 FF RST 38H -f3e1 FF RST 38H -f3e2 FF RST 38H -f3e3 FF RST 38H -f3e4 FF RST 38H -f3e5 FF RST 38H -f3e6 FF RST 38H -f3e7 FF RST 38H -f3e8 FF RST 38H -f3e9 FF RST 38H -f3ea FF RST 38H -f3eb FF RST 38H -f3ec FF RST 38H -f3ed FF RST 38H -f3ee FF RST 38H -f3ef FF RST 38H -f3f0 FF RST 38H -f3f1 FF RST 38H -f3f2 FF RST 38H -f3f3 FF RST 38H -f3f4 FF RST 38H -f3f5 FF RST 38H -f3f6 FF RST 38H -f3f7 FF RST 38H -f3f8 FF RST 38H -f3f9 FF RST 38H -f3fa FF RST 38H -f3fb FF RST 38H -f3fc FF RST 38H -f3fd FF RST 38H - -f3fe FDE9 JP (IY) - -f400 00 NOP -f401 FF RST 38H -f402 00 NOP -f403 00 NOP -f404 FF RST 38H -f405 FF RST 38H -f406 00 NOP -f407 00 NOP -f408 FF RST 38H -f409 FF RST 38H -f40a 00 NOP -f40b 00 NOP -f40c FF RST 38H -f40d FF RST 38H -f40e 00 NOP -f40f 00 NOP -f410 FF RST 38H -f411 FF RST 38H -f412 00 NOP -f413 00 NOP -f414 FF RST 38H -f415 FF RST 38H -f416 00 NOP -f417 00 NOP -f418 FF RST 38H -f419 FF RST 38H -f41a 00 NOP -f41b 00 NOP -f41c FF RST 38H -f41d FF RST 38H -f41e 00 NOP -f41f 00 NOP -f420 FF RST 38H -f421 FF RST 38H -f422 00 NOP -f423 00 NOP -f424 FF RST 38H -f425 FF RST 38H -f426 00 NOP -f427 00 NOP -f428 FF RST 38H -f429 FF RST 38H -f42a 00 NOP -f42b 00 NOP -f42c FF RST 38H -f42d FF RST 38H -f42e 00 NOP -f42f 00 NOP -f430 FF RST 38H -f431 FF RST 38H -f432 00 NOP -f433 00 NOP -f434 FF RST 38H -f435 FF RST 38H -f436 00 NOP -f437 00 NOP -f438 FF RST 38H -f439 FF RST 38H -f43a 00 NOP -f43b 00 NOP -f43c FF RST 38H -f43d FF RST 38H -f43e 00 NOP -f43f 00 NOP -f440 FF RST 38H -f441 FF RST 38H -f442 00 NOP -f443 00 NOP -f444 FF RST 38H -f445 FF RST 38H -f446 00 NOP -f447 00 NOP -f448 FF RST 38H -f449 FF RST 38H -f44a 00 NOP -f44b 00 NOP -f44c FF RST 38H -f44d FF RST 38H -f44e 00 NOP -f44f 00 NOP -f450 FF RST 38H -f451 FF RST 38H -f452 00 NOP -f453 00 NOP -f454 FF RST 38H -f455 FF RST 38H -f456 00 NOP -f457 00 NOP -f458 FF RST 38H -f459 FF RST 38H -f45a 00 NOP -f45b 00 NOP -f45c FF RST 38H -f45d FF RST 38H -f45e 00 NOP -f45f 00 NOP -f460 FF RST 38H -f461 FF RST 38H -f462 00 NOP -f463 00 NOP -f464 FF RST 38H -f465 FF RST 38H -f466 00 NOP -f467 00 NOP -f468 FF RST 38H -f469 FF RST 38H -f46a 00 NOP -f46b 00 NOP -f46c FF RST 38H -f46d FF RST 38H -f46e 00 NOP -f46f 00 NOP -f470 FF RST 38H -f471 FF RST 38H -f472 00 NOP -f473 00 NOP -f474 FF RST 38H -f475 FF RST 38H -f476 00 NOP -f477 00 NOP -f478 FF RST 38H -f479 FF RST 38H -f47a 00 NOP -f47b 00 NOP -f47c FF RST 38H -f47d FF RST 38H -f47e 00 NOP -f47f 00 NOP -f480 FF RST 38H -f481 FF RST 38H -f482 00 NOP -f483 00 NOP -f484 FF RST 38H -f485 FF RST 38H -f486 00 NOP -f487 00 NOP -f488 FF RST 38H -f489 FF RST 38H -f48a 00 NOP -f48b 00 NOP -f48c FF RST 38H -f48d FF RST 38H -f48e 00 NOP -f48f 00 NOP -f490 FF RST 38H -f491 FF RST 38H -f492 00 NOP -f493 00 NOP -f494 FF RST 38H -f495 FF RST 38H -f496 00 NOP -f497 00 NOP -f498 FF RST 38H -f499 FF RST 38H -f49a 00 NOP -f49b 00 NOP -f49c FF RST 38H -f49d FF RST 38H -f49e 00 NOP -f49f 00 NOP -f4a0 FF RST 38H -f4a1 FF RST 38H -f4a2 00 NOP -f4a3 00 NOP -f4a4 FF RST 38H -f4a5 FF RST 38H -f4a6 00 NOP -f4a7 00 NOP -f4a8 FF RST 38H -f4a9 FF RST 38H -f4aa 00 NOP -f4ab 00 NOP -f4ac FF RST 38H -f4ad FF RST 38H -f4ae 00 NOP -f4af 00 NOP -f4b0 FF RST 38H -f4b1 FF RST 38H -f4b2 00 NOP -f4b3 00 NOP -f4b4 FF RST 38H -f4b5 FF RST 38H -f4b6 00 NOP -f4b7 00 NOP -f4b8 FF RST 38H -f4b9 FF RST 38H -f4ba 00 NOP -f4bb 00 NOP -f4bc FF RST 38H -f4bd FF RST 38H -f4be 00 NOP -f4bf 00 NOP -f4c0 FF RST 38H -f4c1 FF RST 38H -f4c2 00 NOP -f4c3 00 NOP -f4c4 FF RST 38H -f4c5 FF RST 38H -f4c6 00 NOP -f4c7 00 NOP -f4c8 FF RST 38H -f4c9 FF RST 38H -f4ca 00 NOP -f4cb 00 NOP -f4cc FF RST 38H -f4cd FF RST 38H -f4ce 00 NOP -f4cf 00 NOP -f4d0 FF RST 38H -f4d1 FF RST 38H -f4d2 00 NOP -f4d3 00 NOP -f4d4 FF RST 38H -f4d5 FF RST 38H -f4d6 00 NOP -f4d7 00 NOP -f4d8 FF RST 38H -f4d9 FF RST 38H -f4da 00 NOP -f4db 00 NOP -f4dc FF RST 38H -f4dd FF RST 38H -f4de 00 NOP -f4df 00 NOP -f4e0 FF RST 38H -f4e1 FF RST 38H -f4e2 00 NOP -f4e3 00 NOP -f4e4 FF RST 38H -f4e5 FF RST 38H -f4e6 00 NOP -f4e7 00 NOP -f4e8 FF RST 38H -f4e9 FF RST 38H -f4ea 00 NOP -f4eb 00 NOP -f4ec FF RST 38H -f4ed FF RST 38H -f4ee 00 NOP -f4ef 00 NOP -f4f0 FF RST 38H -f4f1 FF RST 38H -f4f2 00 NOP -f4f3 00 NOP -f4f4 FF RST 38H -f4f5 FF RST 38H -f4f6 00 NOP -f4f7 00 NOP -f4f8 FF RST 38H -f4f9 FF RST 38H -f4fa 00 NOP -f4fb 00 NOP -f4fc FF RST 38H -f4fd FF RST 38H -f4fe 00 NOP -f4ff 00 NOP -f500 00 NOP -f501 00 NOP -f502 FF RST 38H -f503 FF RST 38H -f504 00 NOP -f505 00 NOP -f506 FF RST 38H -f507 FF RST 38H -f508 00 NOP -f509 00 NOP -f50a FF RST 38H -f50b FF RST 38H -f50c 00 NOP -f50d 00 NOP -f50e FF RST 38H -f50f FF RST 38H -f510 00 NOP -f511 00 NOP -f512 FF RST 38H -f513 FF RST 38H -f514 00 NOP -f515 00 NOP -f516 FF RST 38H -f517 FF RST 38H -f518 00 NOP -f519 00 NOP -f51a FF RST 38H -f51b FF RST 38H -f51c 00 NOP -f51d 00 NOP -f51e FF RST 38H -f51f FF RST 38H -f520 00 NOP -f521 00 NOP -f522 FF RST 38H -f523 FF RST 38H -f524 00 NOP -f525 00 NOP -f526 FF RST 38H -f527 FF RST 38H -f528 00 NOP -f529 00 NOP -f52a FF RST 38H -f52b FF RST 38H -f52c 00 NOP -f52d 00 NOP -f52e FF RST 38H -f52f FF RST 38H -f530 00 NOP -f531 00 NOP -f532 FF RST 38H -f533 FF RST 38H -f534 00 NOP -f535 00 NOP -f536 FF RST 38H -f537 FF RST 38H -f538 00 NOP -f539 00 NOP -f53a FF RST 38H -f53b FF RST 38H -f53c 00 NOP -f53d 00 NOP -f53e FF RST 38H -f53f FF RST 38H -f540 00 NOP -f541 00 NOP -f542 FF RST 38H -f543 FF RST 38H -f544 00 NOP -f545 00 NOP -f546 FF RST 38H -f547 FF RST 38H -f548 00 NOP -f549 00 NOP -f54a FF RST 38H -f54b FF RST 38H -f54c 00 NOP -f54d 00 NOP -f54e FF RST 38H -f54f FF RST 38H -f550 00 NOP -f551 00 NOP -f552 FF RST 38H -f553 FF RST 38H -f554 00 NOP -f555 00 NOP -f556 FF RST 38H -f557 FF RST 38H -f558 00 NOP -f559 00 NOP -f55a FF RST 38H -f55b FF RST 38H -f55c 00 NOP -f55d 00 NOP -f55e FF RST 38H -f55f FF RST 38H -f560 00 NOP -f561 00 NOP -f562 FF RST 38H -f563 FF RST 38H -f564 00 NOP -f565 00 NOP -f566 FF RST 38H -f567 FF RST 38H -f568 00 NOP -f569 00 NOP -f56a FF RST 38H -f56b FF RST 38H -f56c 00 NOP -f56d 00 NOP -f56e FF RST 38H -f56f FF RST 38H -f570 00 NOP -f571 00 NOP -f572 FF RST 38H -f573 FF RST 38H -f574 00 NOP -f575 00 NOP -f576 FF RST 38H -f577 FF RST 38H -f578 00 NOP -f579 00 NOP -f57a FF RST 38H -f57b FF RST 38H -f57c 00 NOP -f57d 00 NOP -f57e FF RST 38H -f57f FF RST 38H -f580 00 NOP -f581 00 NOP -f582 FF RST 38H -f583 FF RST 38H -f584 00 NOP -f585 00 NOP -f586 FF RST 38H -f587 FF RST 38H -f588 00 NOP -f589 00 NOP -f58a FF RST 38H -f58b FF RST 38H -f58c 00 NOP -f58d 00 NOP -f58e FF RST 38H -f58f FF RST 38H -f590 00 NOP -f591 00 NOP -f592 FF RST 38H -f593 FF RST 38H -f594 00 NOP -f595 00 NOP -f596 FF RST 38H -f597 FF RST 38H -f598 00 NOP -f599 00 NOP -f59a FF RST 38H -f59b FF RST 38H -f59c 00 NOP -f59d 00 NOP -f59e FF RST 38H -f59f FF RST 38H -f5a0 00 NOP -f5a1 00 NOP -f5a2 FF RST 38H -f5a3 FF RST 38H -f5a4 00 NOP -f5a5 00 NOP -f5a6 FF RST 38H -f5a7 FF RST 38H -f5a8 00 NOP -f5a9 00 NOP -f5aa FF RST 38H -f5ab FF RST 38H -f5ac 00 NOP -f5ad 00 NOP -f5ae FF RST 38H -f5af FF RST 38H -f5b0 00 NOP -f5b1 00 NOP -f5b2 FF RST 38H -f5b3 FF RST 38H -f5b4 00 NOP -f5b5 00 NOP -f5b6 FF RST 38H -f5b7 FF RST 38H -f5b8 00 NOP -f5b9 00 NOP -f5ba FF RST 38H -f5bb FF RST 38H -f5bc 00 NOP -f5bd 00 NOP -f5be FF RST 38H -f5bf FF RST 38H -f5c0 00 NOP -f5c1 00 NOP -f5c2 FF RST 38H -f5c3 FF RST 38H -f5c4 00 NOP -f5c5 00 NOP -f5c6 FF RST 38H -f5c7 FF RST 38H -f5c8 00 NOP -f5c9 00 NOP -f5ca FF RST 38H -f5cb FF RST 38H -f5cc 00 NOP -f5cd 00 NOP -f5ce FF RST 38H -f5cf FF RST 38H -f5d0 00 NOP -f5d1 00 NOP -f5d2 FF RST 38H -f5d3 FF RST 38H -f5d4 00 NOP -f5d5 00 NOP -f5d6 FF RST 38H -f5d7 FF RST 38H -f5d8 00 NOP -f5d9 00 NOP -f5da FF RST 38H -f5db FF RST 38H -f5dc 00 NOP -f5dd 00 NOP -f5de FF RST 38H -f5df FF RST 38H -f5e0 00 NOP -f5e1 00 NOP -f5e2 FF RST 38H -f5e3 FF RST 38H -f5e4 00 NOP -f5e5 00 NOP -f5e6 FF RST 38H -f5e7 FF RST 38H -f5e8 00 NOP -f5e9 00 NOP -f5ea FF RST 38H -f5eb FF RST 38H -f5ec 00 NOP -f5ed 00 NOP -f5ee FF RST 38H -f5ef FF RST 38H -f5f0 00 NOP -f5f1 00 NOP -f5f2 FF RST 38H -f5f3 FF RST 38H -f5f4 00 NOP -f5f5 00 NOP -f5f6 FF RST 38H -f5f7 FF RST 38H -f5f8 00 NOP -f5f9 00 NOP -f5fa FF RST 38H -f5fb FF RST 38H -f5fc 00 NOP -f5fd 00 NOP -f5fe FF RST 38H -f5ff FF RST 38H -f600 FF RST 38H -f601 FF RST 38H -f602 00 NOP -f603 00 NOP -f604 FF RST 38H -f605 FF RST 38H -f606 00 NOP -f607 00 NOP -f608 FF RST 38H -f609 FF RST 38H -f60a 00 NOP -f60b 00 NOP -f60c FF RST 38H -f60d FF RST 38H -f60e 00 NOP -f60f 00 NOP -f610 FF RST 38H -f611 FF RST 38H -f612 00 NOP -f613 00 NOP -f614 FF RST 38H -f615 FF RST 38H -f616 00 NOP -f617 00 NOP -f618 FF RST 38H -f619 FF RST 38H -f61a 00 NOP -f61b 00 NOP -f61c FF RST 38H -f61d FF RST 38H -f61e 00 NOP -f61f 00 NOP -f620 FF RST 38H -f621 FF RST 38H -f622 00 NOP -f623 00 NOP -f624 FF RST 38H -f625 FF RST 38H -f626 00 NOP -f627 00 NOP -f628 FF RST 38H -f629 FF RST 38H -f62a 00 NOP -f62b 00 NOP -f62c FF RST 38H -f62d FF RST 38H -f62e 00 NOP -f62f 00 NOP -f630 FF RST 38H -f631 FF RST 38H -f632 00 NOP -f633 00 NOP -f634 FF RST 38H -f635 FF RST 38H -f636 00 NOP -f637 00 NOP -f638 FF RST 38H -f639 FF RST 38H -f63a 00 NOP -f63b 00 NOP -f63c FF RST 38H -f63d FF RST 38H -f63e 00 NOP -f63f 00 NOP -f640 FF RST 38H -f641 FF RST 38H -f642 00 NOP -f643 00 NOP -f644 FF RST 38H -f645 FF RST 38H -f646 00 NOP -f647 00 NOP -f648 FF RST 38H -f649 FF RST 38H -f64a 00 NOP -f64b 00 NOP -f64c FF RST 38H -f64d FF RST 38H -f64e 00 NOP -f64f 00 NOP -f650 FF RST 38H -f651 FF RST 38H -f652 00 NOP -f653 00 NOP -f654 FF RST 38H -f655 FF RST 38H -f656 00 NOP -f657 00 NOP -f658 FF RST 38H -f659 FF RST 38H -f65a 00 NOP -f65b 00 NOP -f65c FF RST 38H -f65d FF RST 38H -f65e 00 NOP -f65f 00 NOP -f660 FF RST 38H -f661 FF RST 38H -f662 00 NOP -f663 00 NOP -f664 FF RST 38H -f665 FF RST 38H -f666 00 NOP -f667 00 NOP -f668 FF RST 38H -f669 FF RST 38H -f66a 00 NOP -f66b 00 NOP -f66c FF RST 38H -f66d FF RST 38H -f66e 00 NOP -f66f 00 NOP -f670 FF RST 38H -f671 FF RST 38H -f672 00 NOP -f673 00 NOP -f674 FF RST 38H -f675 FF RST 38H -f676 00 NOP -f677 00 NOP -f678 FF RST 38H -f679 FF RST 38H -f67a 00 NOP -f67b 00 NOP -f67c FF RST 38H -f67d FF RST 38H -f67e 00 NOP -f67f 00 NOP -f680 FF RST 38H -f681 FF RST 38H -f682 00 NOP -f683 00 NOP -f684 FF RST 38H -f685 FF RST 38H -f686 00 NOP -f687 00 NOP -f688 FF RST 38H -f689 FF RST 38H -f68a 00 NOP -f68b 00 NOP -f68c FF RST 38H -f68d FF RST 38H -f68e 00 NOP -f68f 00 NOP -f690 FF RST 38H -f691 FF RST 38H -f692 00 NOP -f693 00 NOP -f694 FF RST 38H -f695 FF RST 38H -f696 00 NOP -f697 00 NOP -f698 FF RST 38H -f699 FF RST 38H -f69a 00 NOP -f69b 00 NOP -f69c FF RST 38H -f69d FF RST 38H -f69e 00 NOP -f69f 00 NOP -f6a0 FF RST 38H -f6a1 FF RST 38H -f6a2 00 NOP -f6a3 00 NOP -f6a4 FF RST 38H -f6a5 FF RST 38H -f6a6 00 NOP -f6a7 00 NOP -f6a8 FF RST 38H -f6a9 FF RST 38H -f6aa 00 NOP -f6ab 00 NOP -f6ac FF RST 38H -f6ad FF RST 38H -f6ae 00 NOP -f6af 00 NOP -f6b0 FF RST 38H -f6b1 FF RST 38H -f6b2 00 NOP -f6b3 00 NOP -f6b4 FF RST 38H -f6b5 FF RST 38H -f6b6 00 NOP -f6b7 00 NOP -f6b8 FF RST 38H -f6b9 FF RST 38H -f6ba 00 NOP -f6bb 00 NOP -f6bc FF RST 38H -f6bd FF RST 38H -f6be 00 NOP -f6bf 00 NOP -f6c0 FF RST 38H -f6c1 FF RST 38H -f6c2 00 NOP -f6c3 00 NOP -f6c4 FF RST 38H -f6c5 FF RST 38H -f6c6 00 NOP -f6c7 00 NOP -f6c8 FF RST 38H -f6c9 FF RST 38H -f6ca 00 NOP -f6cb 00 NOP -f6cc FF RST 38H -f6cd FF RST 38H -f6ce 00 NOP -f6cf 00 NOP -f6d0 FF RST 38H -f6d1 FF RST 38H -f6d2 00 NOP -f6d3 00 NOP -f6d4 FF RST 38H -f6d5 FF RST 38H -f6d6 00 NOP -f6d7 00 NOP -f6d8 FF RST 38H -f6d9 FF RST 38H -f6da 00 NOP -f6db 00 NOP -f6dc FF RST 38H -f6dd FF RST 38H -f6de 00 NOP -f6df 00 NOP -f6e0 FF RST 38H -f6e1 FF RST 38H -f6e2 00 NOP -f6e3 00 NOP -f6e4 FF RST 38H -f6e5 FF RST 38H -f6e6 00 NOP -f6e7 00 NOP -f6e8 FF RST 38H -f6e9 FF RST 38H -f6ea 00 NOP -f6eb 00 NOP -f6ec FF RST 38H -f6ed FF RST 38H -f6ee 00 NOP -f6ef 00 NOP -f6f0 FF RST 38H -f6f1 FF RST 38H -f6f2 00 NOP -f6f3 00 NOP -f6f4 FF RST 38H -f6f5 FF RST 38H -f6f6 00 NOP -f6f7 00 NOP -f6f8 FF RST 38H -f6f9 FF RST 38H -f6fa 00 NOP -f6fb 00 NOP -f6fc FF RST 38H -f6fd FF RST 38H -f6fe 00 NOP -f6ff 00 NOP -f700 00 NOP -f701 00 NOP -f702 FF RST 38H -f703 FF RST 38H -f704 00 NOP -f705 00 NOP -f706 FF RST 38H -f707 FF RST 38H -f708 00 NOP -f709 00 NOP -f70a FF RST 38H -f70b FF RST 38H -f70c 00 NOP -f70d 00 NOP -f70e FF RST 38H -f70f FF RST 38H -f710 00 NOP -f711 00 NOP -f712 FF RST 38H -f713 FF RST 38H -f714 00 NOP -f715 00 NOP -f716 FF RST 38H -f717 FF RST 38H -f718 00 NOP -f719 00 NOP -f71a FF RST 38H -f71b FF RST 38H -f71c 00 NOP -f71d 00 NOP -f71e FF RST 38H -f71f FF RST 38H -f720 00 NOP -f721 00 NOP -f722 FF RST 38H -f723 FF RST 38H -f724 00 NOP -f725 00 NOP -f726 FF RST 38H -f727 FF RST 38H -f728 00 NOP -f729 00 NOP -f72a FF RST 38H -f72b FF RST 38H -f72c 00 NOP -f72d 00 NOP -f72e FF RST 38H -f72f FF RST 38H -f730 00 NOP -f731 00 NOP -f732 FF RST 38H -f733 FF RST 38H -f734 00 NOP -f735 00 NOP -f736 FF RST 38H -f737 FF RST 38H -f738 00 NOP -f739 00 NOP -f73a FF RST 38H -f73b FF RST 38H -f73c 00 NOP -f73d 00 NOP -f73e FF RST 38H -f73f FF RST 38H -f740 00 NOP -f741 00 NOP -f742 FF RST 38H -f743 FF RST 38H -f744 00 NOP -f745 00 NOP -f746 FF RST 38H -f747 FF RST 38H -f748 00 NOP -f749 00 NOP -f74a FF RST 38H -f74b FF RST 38H -f74c 00 NOP -f74d 00 NOP -f74e FF RST 38H -f74f FF RST 38H -f750 00 NOP -f751 00 NOP -f752 FF RST 38H -f753 FF RST 38H -f754 00 NOP -f755 00 NOP -f756 FF RST 38H -f757 FF RST 38H -f758 00 NOP -f759 00 NOP -f75a FF RST 38H -f75b FF RST 38H -f75c 00 NOP -f75d 00 NOP -f75e FF RST 38H -f75f FF RST 38H -f760 00 NOP -f761 00 NOP -f762 FF RST 38H -f763 FF RST 38H -f764 00 NOP -f765 00 NOP -f766 FF RST 38H -f767 FF RST 38H -f768 00 NOP -f769 00 NOP -f76a FF RST 38H -f76b FF RST 38H -f76c 00 NOP -f76d 00 NOP -f76e FF RST 38H -f76f FF RST 38H -f770 00 NOP -f771 00 NOP -f772 FF RST 38H -f773 FF RST 38H -f774 00 NOP -f775 00 NOP -f776 FF RST 38H -f777 FF RST 38H -f778 00 NOP -f779 00 NOP -f77a FF RST 38H -f77b FF RST 38H -f77c 00 NOP -f77d 00 NOP -f77e FF RST 38H -f77f FF RST 38H -f780 00 NOP -f781 00 NOP -f782 FF RST 38H -f783 FF RST 38H -f784 00 NOP -f785 00 NOP -f786 FF RST 38H -f787 FF RST 38H -f788 00 NOP -f789 00 NOP -f78a FF RST 38H -f78b FF RST 38H -f78c 00 NOP -f78d 00 NOP -f78e FF RST 38H -f78f FF RST 38H -f790 00 NOP -f791 00 NOP -f792 FF RST 38H -f793 FF RST 38H -f794 00 NOP -f795 00 NOP -f796 FF RST 38H -f797 FF RST 38H -f798 00 NOP -f799 00 NOP -f79a FF RST 38H -f79b FF RST 38H -f79c 00 NOP -f79d 00 NOP -f79e FF RST 38H -f79f FF RST 38H -f7a0 00 NOP -f7a1 00 NOP -f7a2 FF RST 38H -f7a3 FF RST 38H -f7a4 00 NOP -f7a5 00 NOP -f7a6 FF RST 38H -f7a7 FF RST 38H -f7a8 00 NOP -f7a9 00 NOP -f7aa FF RST 38H -f7ab FF RST 38H -f7ac 00 NOP -f7ad 00 NOP -f7ae FF RST 38H -f7af FF RST 38H -f7b0 00 NOP -f7b1 00 NOP -f7b2 FF RST 38H -f7b3 FF RST 38H -f7b4 00 NOP -f7b5 00 NOP -f7b6 FF RST 38H -f7b7 FF RST 38H -f7b8 00 NOP -f7b9 00 NOP -f7ba FF RST 38H -f7bb FF RST 38H -f7bc 00 NOP -f7bd 00 NOP -f7be FF RST 38H -f7bf FF RST 38H -f7c0 00 NOP -f7c1 00 NOP -f7c2 FF RST 38H -f7c3 FF RST 38H -f7c4 00 NOP -f7c5 00 NOP -f7c6 FF RST 38H -f7c7 FF RST 38H -f7c8 00 NOP -f7c9 00 NOP -f7ca FF RST 38H -f7cb FF RST 38H -f7cc 00 NOP -f7cd 00 NOP -f7ce FF RST 38H -f7cf FF RST 38H -f7d0 00 NOP -f7d1 00 NOP -f7d2 FF RST 38H -f7d3 FF RST 38H -f7d4 00 NOP -f7d5 00 NOP -f7d6 FF RST 38H -f7d7 FF RST 38H -f7d8 00 NOP -f7d9 00 NOP -f7da FF RST 38H -f7db FF RST 38H -f7dc 00 NOP -f7dd 00 NOP -f7de FF RST 38H -f7df FF RST 38H -f7e0 00 NOP -f7e1 00 NOP -f7e2 FF RST 38H -f7e3 FF RST 38H -f7e4 00 NOP -f7e5 00 NOP -f7e6 FF RST 38H -f7e7 FF RST 38H -f7e8 00 NOP -f7e9 00 NOP -f7ea FF RST 38H -f7eb FF RST 38H -f7ec 00 NOP -f7ed 00 NOP -f7ee FF RST 38H -f7ef FF RST 38H -f7f0 00 NOP -f7f1 00 NOP -f7f2 FF RST 38H -f7f3 FF RST 38H -f7f4 00 NOP -f7f5 00 NOP -f7f6 FF RST 38H -f7f7 FF RST 38H -f7f8 00 NOP -f7f9 00 NOP -f7fa FF RST 38H -f7fb FF RST 38H -f7fc 00 NOP -f7fd 00 NOP -f7fe FF RST 38H -f7ff FF RST 38H diff --git a/software/asm/sharpmz-test.asm b/software/asm/sharpmz-test.asm deleted file mode 100644 index c08c31f..0000000 --- a/software/asm/sharpmz-test.asm +++ /dev/null @@ -1,1780 +0,0 @@ -;-------------------------------------------------------------------------------------------------------- -;- -;- Name: sharpmz-test.asm -;- Created: October 2018 -;- Author(s): Philip Smart -;- Description: Sharp MZ series tester utility. -;- This assembly language program is written to aid in testing components -;- of the SharpMZ Series FPGA emulation. -;- -;- Currently it aids in testing: -;- 1. Tape Read -;- 2. Tape Write -;- 3. Memory Test -;- 4. Graphics RAM Test -;- -;- Credits: -;- Copyright: (c) 2018-2023 Philip Smart -;- -;- History: October 2018 - Merged 2 utilities to create this compilation. -;- -;-------------------------------------------------------------------------------------------------------- -;- This source file is free software: you can redistribute it and-or modify -;- it under the terms of the GNU General Public License as published -;- by the Free Software Foundation, either version 3 of the License, or -;- (at your option) any later version. -;- -;- This source file is distributed in the hope that it will be useful, -;- but WITHOUT ANY WARRANTY; without even the implied warranty of -;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;- GNU General Public License for more details. -;- -;- You should have received a copy of the GNU General Public License -;- along with this program. If not, see . -;-------------------------------------------------------------------------------------------------------- - -KEYPA: EQU 0E000h -KEYPB: EQU 0E001h -KEYPC: EQU 0E002h -KEYPF: EQU 0E003h -CSTR: EQU 0E002h -CSTPT: EQU 0E003h -CONT0: EQU 0E004h -CONT1: EQU 0E005h -CONT2: EQU 0E006h -CONTF: EQU 0E007h -SUNDG: EQU 0E008h -TEMP: EQU 0E008h -GETL: EQU 00003h -LETNL: EQU 00006h -NL: EQU 00009h -PRNTS: EQU 0000Ch -PRNT: EQU 00012h -MSG: EQU 00015h -MSGX: EQU 00018h -MONIT: EQU 00086h -ST1: EQU 00095h -PRTHL: EQU 003BAh -PRTHX: EQU 003C3h -DPCT: EQU 00DDCh -?BRK: EQU 00D11h -?RSTR1: EQU 00EE6h -TPSTART: EQU 010F0h -MEMSTART: EQU 01200h -GRAMSTART: EQU 0C000h -GRAMEND: EQU 0FFFFh -MSTART: EQU 0BF00h -GRCTL: EQU 0C8h -GRREDFLT: EQU 0C9h -GRGRNFLT: EQU 0CAh -GRBLUFLT: EQU 0CBh -GRENABLE: EQU 0CCh -GRDISABLE: EQU 0CDh - - - ORG TPSTART - -SPV: -IBUFE: ; TAPE BUFFER (128 BYTES) -;ATRB: DS virtual 1 ; ATTRIBUTE -ATRB: DB 01h ; Code Type, 01 = Machine Code. -;NAME: DS virtual 17 ; FILE NAME -NAME: DB "SHARPMZ TEST V1", 0Dh, 00h ; Title/Name (17 bytes). -;SIZE: DS virtual 2 ; BYTESIZE -SIZE: DW MEND - MSTART ; Size of program. -;DTADR: DS virtual 2 ; DATA ADDRESS -DTADR: DW MSTART ; Load address of program. -;EXADR: DS virtual 2 ; EXECUTION ADDRESS -EXADR: DW MSTART ; Exec address of program. -COMNT: DS 104 ; COMMENT -KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) -DSPXY: DS virtual 2 ; DISPLAY COORDINATES -MANG: DS virtual 27 ; COLUMN MANAGEMENT -FLASH: DS virtual 1 ; FLASHING DATA -FLPST: DS virtual 2 ; FLASHING POSITION -FLSST: DS virtual 1 ; FLASHING STATUS -FLSDT: DS virtual 1 ; CURSOR DATA -STRGF: DS virtual 1 ; STRING FLAG -DPRNT: DS virtual 1 ; TAB COUNTER -TMCNT: DS virtual 2 ; TAPE MARK COUNTER -SUMDT: DS virtual 2 ; CHECK SUM DATA -CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA -AMPM: DS virtual 1 ; AMPM DATA -TIMFG: DS virtual 1 ; TIME FLAG -SWRK: DS virtual 1 ; KEY SOUND FLAG -TEMPW: DS virtual 1 ; TEMPO WORK -ONTYO: DS virtual 1 ; ONTYO WORK -OCTV: DS virtual 1 ; OCTAVE WORK -RATIO: DS virtual 2 ; ONPU RATIO -BUFER: DS virtual 81 ; GET LINE BUFFER - - - - ORG MSTART - JP START - - ; Graphics Initialisation. Needs to be in memory before C000-FFFF - ; -GRAMINIT: OUT (GRCTL),A - OUT (GRENABLE),A -GRAM0: LD HL,GRAMSTART - LD BC,GRAMEND - GRAMSTART -GRAM1: LD A,000h - LD (HL),A - INC HL - DEC BC - LD A,B - OR C - JR NZ,GRAM1 - OUT (GRDISABLE),A - RET - - ; Graphics Test. Needs to be in memory before C000-FFFF - ; -GRAMTEST: OUT (GRCTL),A - OUT (GRENABLE),A - LD E,080h -GRAMTEST0: LD HL,GRAMSTART - LD BC,GRAMEND - GRAMSTART -GRAMTEST1: LD A,E - LD (HL),A - INC HL - DEC BC - LD A,B - OR C - JR NZ,GRAMTEST1 - SRL E - JR NZ,GRAMTEST0 - JR C,GRAMTEST0 - OUT (GRDISABLE),A - RET - - ; Graphics Test routine. - ; - ; Graphics mode:- 7/6 = Operator (00=OR,01=AND,10=NAND,11=XOR), - ; 5 = GRAM Output Enable 0 = active. - ; 4 = VRAM Output Enable, 0 = active. - ; 3/2 = Write mode (00=Page 1:Red, 01=Page 2:Green, 10=Page 3:Blue, 11=Indirect), - ; 1/0 = Read mode (00=Page 1:Red, 01=Page2:Green, 10=Page 3:Blue, 11=Not used). - ; -GRAPHICS: LD A,000h - CALL GRAMTEST - LD A,005h - CALL GRAMTEST - LD A,00Ah - CALL GRAMTEST - LD A,0AAh ; Set Red filter. - OUT (GRREDFLT),A - LD A,055h ; Set Green filter. - OUT (GRGRNFLT),A - LD A,0FFh ; Set Blue filter. - OUT (GRBLUFLT),A - LD A, 00Ch ; Set graphics mode to Indirect Page write. - CALL GRAMTEST - LD A, 0CCh ; Set graphics mode to Indirect Page write. - OUT (GRCTL),A - JR GETL1 - - ; Graphics progress bar indicator. Needs to be in memory before C000-FFFF - ; -GRPHIND: LD HL,(GRPHPOS) ; Get position of graphics progress line. - OUT (GRENABLE),A ; Enable graphics memory. - LD A,0FFh - LD (HL),A - OUT (GRDISABLE),A; Disable graphics memory. - INC HL - LD (GRPHPOS),HL - RET - - - ; - ; Start of main program. - ; -START: CALL LETNL - LD DE,TITLE - CALL MSG - CALL LETNL - CALL LETNL - ; -INITGRPH: LD DE,MSG_INITGR - CALL MSG - CALL LETNL - LD A,0FFh ; Set Red filter. - OUT (GRREDFLT),A - LD A,000h ; Set Green filter. - OUT (GRGRNFLT),A - LD A,000h ; Set Blue filter. - OUT (GRBLUFLT),A - LD A,000h - CALL GRAMINIT - LD A,005h - CALL GRAMINIT - LD A,00Ah - CALL GRAMINIT - LD A, 0CCh ; Set graphics mode to Indirect Page write. - OUT (GRCTL),A - LD HL,0DE00h - LD (GRPHPOS),HL - ; -INITMEM: LD DE,MSG_INITM - CALL MSG - CALL LETNL - LD HL,1200h - LD BC,MSTART - 1200h -CLEAR1: LD A,00h - LD (HL),A - INC HL - DEC BC - LD A,B - OR C - JP NZ,CLEAR1 -GETL1: CALL NL - LD A,03EH - CALL PRNT - LD DE,BUFER - CALL GETL -GETL2: LD A,(DE) - INC DE - CP 00DH - JR Z,GETL1 - CP 'G' ; Graphics Test - JP Z,GRAPHICS - CP 'H' ; Command Synopsis - JP Z,HELP - CP 'M' ; Memory Test - JR Z,MEMTEST - CP 'R' ; Read Test - JP Z,LOAD - CP 'T' ; Timer Test - JP Z,TIMERTST - CP 'W' ; Write Test - JP Z,SAVE - CP 'Q' ; Quit? - JP Z,ST1 - JR GETL2 - - -MEMTEST: LD B,240 ; Number of loops -LOOP: LD HL,MEMSTART ; Start of checked memory, - LD D,0BFh ; End memory check BF00 -LOOP1: LD A,000h - CP L - JR NZ,LOOP1b - CALL PRTHL ; Print HL as 4digit hex. - LD A,0C4h ; Move cursor left. - LD E,004h ; 4 times. -LOOP1a: CALL DPCT - DEC E - JR NZ,LOOP1a -LOOP1b: INC HL - LD A,H - CP D ; Have we reached end of memory. - JR Z,LOOP3 ; Yes, exit. - LD A,(HL) ; Read memory location under test, ie. 0. - CPL ; Subtract, ie. FF - A, ie FF - 0 = FF. - LD (HL),A ; Write it back, ie. FF. - SUB (HL) ; Subtract written memory value from A, ie. should be 0. - JR NZ,LOOP2 ; Not zero, we have an error. - LD A,(HL) ; Reread memory location, ie. FF - CPL ; Subtract FF - FF - LD (HL),A ; Write 0 - SUB (HL) ; Subtract 0 - JR Z,LOOP1 ; Loop if the same, ie. 0 -LOOP2: LD A,16h - CALL PRNT ; Print A - CALL PRTHX ; Print HL as 4 digit hex. - CALL PRNTS ; Print space. - XOR A - LD (HL),A - LD A,(HL) ; Get into A the failing bits. - CALL PRTHX ; Print A as 2 digit hex. - CALL PRNTS ; Print space. - LD A,0FFh ; Repeat but first load FF into memory - LD (HL),A - LD A,(HL) - CALL PRTHX ; Print A as 2 digit hex. - NOP - JR LOOP4 - -LOOP3: CALL PRTHL - LD DE,OKCHECK - CALL MSG ; Print check message in DE - LD A,B ; Print loop count. - CALL PRTHX - LD DE,OKMSG - CALL MSG ; Print ok message in DE - CALL NL - CALL GRPHIND - DEC B - JR NZ,LOOP - LD DE,DONEMSG - CALL MSG ; Print check message in DE - JP GETL1 - -LOOP4: LD B,09h - CALL PRNTS ; Print space. - XOR A ; Zero A - SCF ; Set Carry -LOOP5: PUSH AF ; Store A and Flags - LD (HL),A ; Store 0 to bad location. - LD A,(HL) ; Read back - CALL PRTHX ; Print A as 2 digit hex. - CALL PRNTS ; Print space - POP AF ; Get back A (ie. 0 + C) - RLA ; Rotate left A. Bit LSB becomes Carry (ie. 1 first instance), Carry becomes MSB - DJNZ LOOP5 ; Loop if not zero, ie. print out all bit locations written and read to memory to locate bad bit. - XOR A ; Zero A, clears flags. - LD A,80h - LD B,08h -LOOP6: PUSH AF ; Repeat above but AND memory location with original A (ie. 80) - LD C,A ; Basically walk through all the bits to find which one is stuck. - LD (HL),A - LD A,(HL) - AND C - NOP - JR Z,LOOP8 ; If zero then print out the bit number - NOP - NOP - LD A,C - CPL - LD (HL),A - LD A,(HL) - AND C - JR NZ,LOOP8 ; As above, if the compliment doesnt yield zero, print out the bit number. -LOOP7: POP AF - RRCA - NOP - DJNZ LOOP6 - JP GETL1 - -LOOP8: CALL LETNL ; New line. - LD DE,BITMSG ; BIT message - CALL MSG ; Print message in DE - LD A,B - DEC A - CALL PRTHX ; Print A as 2 digit hex, ie. BIT number. - CALL LETNL ; New line - LD DE,BANKMSG ; BANK message - CALL MSG ; Print message in DE - LD A,H - CP 50h ; 'P' - JR NC,LOOP9 ; Work out bank number, 1, 2 or 3. - LD A,01h - JR LOOP11 - -LOOP9: CP 90h - JR NC,LOOP10 - LD A,02h - JR LOOP11 - -LOOP10: LD A,03h -LOOP11: CALL PRTHX ; Print A as 2 digit hex, ie. BANK number. - JR LOOP7 - - - ; - ; LOAD COMMAND - ; -LOAD: CALL ?RDI - JP C,?ER -LOA0: CALL NL - LD DE,MSG_LOADFROM - CALL MSG - LD HL,(DTADR) - CALL PRTHL - CALL NL - LD DE,MSG_LOADEXEC - CALL MSG - LD HL,(EXADR) - CALL PRTHL - CALL NL - LD DE,MSG_LOADSIZE - CALL MSG - LD HL,(SIZE) - CALL PRTHL - CALL NL - LD DE,MSG_LOADFILE - CALL MSGX - LD DE,NAME - CALL MSGX - CALL NL - CALL ?RDD - JP C,?ER - LD HL,(EXADR) - LD A,H - CP 12h - JP C,GETL1 - JP (HL) - - - ; SAVE COMMAND - -SAVE: LD HL,TESTBUF - LD DE,IBUFE - LD BC,128 - LDIR - LD DE,TITLE_SAVE - CALL MSG - CALL LETNL - CALL LETNL - LD DE,MSG_SAVEFROM - CALL MSG - LD HL,(DTADR) - CALL PRTHL - CALL NL - LD DE,MSG_SAVEEXEC - CALL MSG - LD HL,(EXADR) - CALL PRTHL - CALL NL - LD DE,MSG_SAVESIZE - CALL MSG - LD HL,(SIZE) - CALL PRTHL - CALL NL - LD DE,MSG_SAVEFILE - CALL MSGX - LD DE,NAME - CALL MSGX - CALL NL - LD A,01H ; ATTRIBUTE: OBJECT CODE - LD (ATRB),A - ; - LD DE,MSG_WHDR - CALL MSGX - CALL NL - CALL QWRI - JP C,QER ; WRITE ERROR - ; - LD DE,MSG_WDATA - CALL MSGX - CALL NL - ; - CALL QWRD ; DATA - JP C,QER - CALL NL - LD DE,MSGOK ; OK MESSAGE - CALL MSGX ; CALL MSGX - JP GETL1 - - ; - ; ERROR (LOADING) - ; -QER: CP 02h - JP Z,GETL1 - LD DE,MSG_ERRWRITE - CALL MSG - JP GETL1 - ; - ; ERROR (LOADING) - ; -?ER: CP 02h - JP Z,GETL1 - LD DE,MSG_ERRCHKSUM - CALL MSG - JP GETL1 - ; - ; READ INFORMATION - ; - ; EXIT ACC = 0 : OK CF=0 - ; = 1 : ER CF=1 - ; = 2 : BREAK CF=1 - ; -?RDI: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D2h - LD E,0CCh - LD BC,80h - LD HL,IBUFE -RD1: CALL MOTOR - JP C,RTP6 - CALL TMARK - JP C,RTP6 -; CALL PRTHL - CALL RTAPE - POP HL - POP BC - POP DE - ;CALL MSTOP - PUSH AF - LD A,(TIMFG) - CP 0F0h - JR NZ,RD2 - EI -RD2: POP AF - RET - - ; - ; READ DATA - ; -?RDD: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D2h - LD E,53h - LD BC,(SIZE) - LD HL,(DTADR) - LD A,B - OR C - JP Z,RDD1 - JR RD1 -RDD1: POP HL - POP BC - POP DE - ;CALL MSTOP - PUSH AF - LD A,(TIMFG) - CP 0F0h - JR NZ,RDD2 - EI -RDD2: POP AF - RET - - ; - ; READ TAPE - ; -RTAPE: ;PUSH BC - ;PUSH DE - ;LD DE,MSG_READTAPE - ;CALL MSG - ;CALL NL - ;POP DE - ;POP BC - PUSH DE - PUSH BC - PUSH HL - LD H,2 -RTP1: LD BC,KEYPB - LD DE,CSTR -RTP2: CALL EDGE - JP C,RTP6 - CALL DLY3 - LD A,(DE) - AND 20h - JP Z,RTP2 - LD D,H - LD HL,0 - LD (SUMDT),HL - POP HL - POP BC - PUSH BC - PUSH HL -RTP3: CALL RBYTE - JP C,RTP6 - LD (HL),A - INC HL - DEC BC - LD A,B - OR C - JP NZ,RTP3 - LD HL,(SUMDT) - CALL RBYTE ; Checksum MSB - JP C,RTP6 - LD D,A - CALL RBYTE ; Checksum LSB - JP C,RTP6 - LD E,A - CP L - JP NZ,RTP5 - LD A,D - CP H - JP NZ,RTP5 -RTP0: XOR A - ; - PUSH HL - PUSH DE - PUSH DE - LD DE,MSG_CHKSUM_MZ1 - CALL MSGX - CALL PRTHL - CALL NL - LD DE,MSG_CHKSUM_TP1 - CALL MSGX - POP DE - EX DE,HL - CALL PRTHL - CALL NL - POP DE - POP HL - ; -RTP4: -RET2: POP HL - POP BC - POP DE - CALL MSTOP - PUSH AF - LD A,(TIMFG) - CP 0F0h - JR NZ,RTP8 - EI -RTP8: POP AF - RET - -RTP5: PUSH HL - PUSH DE - PUSH DE - LD DE,MSG_CHKSUM_MZ2 - CALL MSGX - CALL PRTHL - CALL NL - LD DE,MSG_CHKSUM_TP2 - CALL MSGX - POP DE - EX DE,HL - CALL PRTHL - CALL NL - POP DE - POP HL - ; - LD D,1 - DEC D - JR Z,RTP7 - LD H,D - CALL GAPCK - JP RTP1 -RTP7: LD A,1 - JR RTP9 -RTP6: LD A,2 -RTP9: SCF - JR RTP4 - - - ; - ; EDGE - ; BC = KEYPB - ; DE = CSTR - ; EXIT CF = 0 : EDGE - ; = 1 : BREAK - ; -EDGE: LD A,0F0h - LD (KEYPA),A - NOP -EDG1: LD A,(BC) - AND 81h ; SHIFT & BREAK - JP NZ,EDG0 - SCF - RET -EDG0: LD A,(DE) - AND 20h - JP NZ,EDG1 -EDG2: LD A,(BC) - AND 81h - JP NZ,EDG3 - SCF - RET -EDG3: LD A,(DE) - AND 20h - JP Z,EDG2 - RET - - - ; - ; 1 BYTE READ - ; - ; EXIT SUMDT=STORE - ; CF = 1 : BREAK - ; = 0 : DATA=ACC - ; -RBYTE: PUSH BC - PUSH DE - PUSH HL - LD HL,0800h - LD BC,KEYPB - LD DE,CSTR -RBY1: CALL EDGE - JP C,RBY3 - CALL DLY3 - LD A,(DE) - AND 20h - JP Z,RBY2 - PUSH HL - LD HL,(SUMDT) - INC HL - LD (SUMDT),HL - POP HL - SCF -RBY2: LD A,L - RLA - LD L,A - DEC H - JP NZ,RBY1 - CALL EDGE - LD A,L -RBY3: POP HL - POP DE - POP BC - RET - - ; - ; TAPE MARK DETECT - ; - ; E=@L@ : INFORMATION - ; =@S@ : DATA - ; EXIT CF = 0 : OK - ; = 1 : BREAK - ; -TMARK: CALL GAPCK - PUSH BC - PUSH DE - PUSH HL - PUSH BC - PUSH DE - LD DE,MSG_TAPEMARK - CALL MSG - CALL NL - POP DE - POP BC - LD HL,2828h - LD A,E - CP 0CCh - JP Z,TM0 - LD HL,1414h -TM0: LD (TMCNT),HL - LD BC,KEYPB - LD DE,CSTR -TM1: LD HL,(TMCNT) -TM2: CALL EDGE - JP C,TM4 - CALL DLY3 - LD A,(DE) - AND 20h - JP Z,TM1 - DEC H - JP NZ,TM2 -; CALL PRTHL -TM3: CALL EDGE - JP C,TM4 - CALL DLY3 - LD A,(DE) - AND 20h - JP NZ,TM1 - DEC L - JP NZ,TM3 - CALL EDGE -RET3: -TM4: POP HL - POP DE - POP BC - RET - -TM4A: CALL NL - CALL PRTHL ; Print HL as 4digit hex. - LD A,0C4h ; Move cursor left. -TM4B: CALL DPCT - CALL DPCT - CALL DPCT - CALL DPCT - CALL NL - JP GETL1 - - ; - ; MOTOR ON - ; - ; D=@W@ : WRITE - ; =@R@ : READ - ; EXIT CF=0 : OK - ; =1 : BREAK -MOTOR: PUSH BC - PUSH DE - PUSH HL - PUSH BC - PUSH DE - LD DE,MSG_MOTORTG - CALL MSG - CALL NL - POP DE - POP BC - LD B,10 -MOT1: LD A,(CSTR) - AND 10h - JR Z,MOT4 -MOT2: LD B,0A6h -MOT3: CALL DLY12 - DJNZ MOT3 - XOR A -MOT7: JR RET3 -MOT4: LD A,06h - LD HL,CSTPT - LD (HL),A - INC A - LD (HL),A - DJNZ MOT1 - CALL NL - LD A,D - CP 0D7h - JR Z,MOT8 - LD DE,MSG1 - JR MOT9 -MOT8: LD DE,MSG3 - CALL MSGX - LD DE,MSG2 -MOT9: CALL MSGX -MOT5: LD A,(CSTR) - AND 10h - JR NZ,MOT2 - CALL ?BRK - JR NZ,MOT5 - SCF - JR MOT7 - - ; - ; MOTOR STOP - ; -MSTOP: PUSH AF - PUSH BC - PUSH DE - PUSH BC - PUSH DE - LD DE,MSG_MOTORSTP - CALL MSG - CALL NL - POP DE - POP BC - LD B,10 -MST1: LD A,(CSTR) - AND 10H - JR Z,MST3 -MST2: LD A,06h - LD (CSTPT),A - INC A - LD (CSTPT),A - DJNZ MST1 -MST3: JP ?RSTR1 - - ; - ; CHECK SUM - ; - ; BC = SIZE - ; HL = DATA ADR - ; EXIT SUMDT=STORE - ; CSMDT=STORE - ; -CKSUM: PUSH BC - PUSH DE - PUSH HL - LD DE,0 -CKS1: LD A,B - OR C - JR NZ,CKS2 - EX DE,HL - LD (SUMDT),HL - LD (CSMDT),HL - POP HL - POP DE - POP BC - RET -CKS2: LD A,(HL) - PUSH BC - LD B,+8 -CKS3: RLCA - JR NC,CKS4 - INC DE -CKS4: DJNZ CKS3 - POP BC - INC HL - DEC BC - JR CKS1 - - - ; - ; 107 uS DELAY - ; -DLY1: LD A,14 -DLY1A: DEC A - JP NZ,DLY1A - RET - - ; - ; 240 uS DELAY - ; -DLY2: LD A,13 -DLY2A: DEC A - JP NZ,DLY2A - RET - - ; - ; 240 uS x 3 DELAY - ; -DLY3: NEG - NEG - LD A,42 - JP DLY2A - - ; - ; 12mS DELAY -DLY12: PUSH BC - LD B,35 -DLY12A: CALL DLY3 - DJNZ DLY12A - POP BC - RET - - - ; - ; GAP * TAPEMARK - ; - ; E = @L@ : LONG GAP - ; = @S@ : SHORT GAP - ; -GAP: PUSH BC - PUSH DE - PUSH HL - LD A,E - LD BC,55F0h ;Number of pulses for the Long Gap. - LD DE,2828h ;40 + 40 LTM - CP 0CCh - JP Z,GAP0 - LD BC,2AF8h ;Number of pulses for a Short Gap. - LD DE,1414h ;20 + 20 LTM -GAP0: PUSH DE - LD DE,MSG_WGAPS - CALL MSG - ; -GAP1: CALL SHORT ;22000 short GAP pulses. - LD H,B - LD L,C - LD A,000h - CP L - JR NZ,GAP1D - CALL PRTHL ; Print HL as 4digit hex. - LD A,0C4h ; Move cursor left. - LD E,004h ; 4 times. -GAP1B: CALL DPCT - DEC E - JR NZ,GAP1B -GAP1D: DEC BC - LD A,B - OR C - JR NZ,GAP1 - LD H,B - LD L,C - CALL PRTHL ; Print HL as 4digit hex. - LD DE,MSG_SPC - CALL MSG - CALL LETNL - POP DE - ; - LD BC,20000 ; 2 Second delay -GAP1C: CALL DLY1 - DEC BC - LD A,B - OR C - JR NZ,GAP1C - ; - PUSH DE -GAP1A: LD DE,MSG_WGAPL - CALL MSGX - POP DE -GAP2: PUSH DE - CALL LONG ;40 or 20 Long Pulses (LTM or STM) - LD H,00h - LD L,D - CALL PRTHL ; Print HL as 4digit hex. - LD A,0C4h ; Move cursor left. - LD E,004h ; 4 times. -GAP2B: CALL DPCT - DEC E - JR NZ,GAP2B - LD BC,1000 ; .1 Second delay -GAP2D: CALL DLY1 - DEC BC - LD A,B - OR C - JR NZ,GAP2D - POP DE - DEC D - JR NZ,GAP2 - LD H,000h - LD L,D - CALL PRTHL ; Print HL as 4digit hex. - PUSH DE - LD DE,MSG_SPC - CALL MSG - CALL LETNL - POP DE - ; - LD BC,20000 ; 2 Second delay -GAP2C: CALL DLY1 - DEC BC - LD A,B - OR C - JR NZ,GAP2C - ; -GAP2A: PUSH DE - LD DE,MSG_WGAPS2 - CALL MSGX - POP DE -GAP3: PUSH DE - CALL SHORT ;40 or 20 Short Pulses (LTM or STM) - LD H,00h - LD L,E - CALL PRTHL ; Print HL as 4digit hex. - LD A,0C4h ; Move cursor left. - LD E,004h ; 4 times. -GAP3B: CALL DPCT - DEC E - JR NZ,GAP3B - LD BC,1000 ; .1 Second delay -GAP3D: CALL DLY1 - DEC BC - LD A,B - OR C - JR NZ,GAP3D - POP DE - DEC E - JR NZ,GAP3 - LD H,000h - LD L,E - CALL PRTHL ; Print HL as 4digit hex. - PUSH DE - LD DE,MSG_SPC - CALL MSGX - CALL LETNL - POP DE - ; - LD BC,20000 ; 2 Second delay -GAP3C: CALL DLY1 - DEC BC - LD A,B - OR C - JR NZ,GAP3C - ; -GAP3A: PUSH DE - LD DE,MSG_WGAPL2 - CALL MSGX - CALL LETNL - POP DE - CALL LONG ;1 Long Pulse - POP HL - POP DE - POP BC - RET - - ;GAP Test - fixed 80 x short, 80 x long to see if hardware is receiving and counting correctly. - ; -;GAP: PUSH BC -; PUSH DE -;GAP0: LD BC,050h ;Number of pulses for the Long Gap. -;GAP1: CALL SHORT -;GAP1A: DEC BC -; LD A,B -; OR C -; JR NZ,GAP1 -; LD BC,0050h ;Number of pulses for the Long Gap. -;GAP2: CALL LONG -;GAP2A: DEC BC -; LD A,B -; OR C -; JR NZ,GAP2 -;GAP3A: JR GAP3A -;GAP3: POP DE -; POP BC -; RET - - - ; - ; GAP CHECK - ; -GAPCK: PUSH BC - PUSH DE - PUSH HL - LD DE,MSG_GAPCK - CALL MSG - CALL NL - LD BC,KEYPB - LD DE,CSTR -GAPCK1: LD H,100 -GAPCK2: CALL EDGE - JR C,GAPCK3 - CALL DLY3 - LD A,(DE) - AND 20h - JR NZ,GAPCK1 - DEC H - JR NZ,GAPCK2 -GAPCK3: JP RET3 - - ; - ; 1 bit write - ; Short Pulse - ; -SHORT: PUSH AF - LD A,03h - LD (CSTPT),A - CALL DLY1 - CALL DLY1 - LD A,02h - LD (CSTPT),A - CALL DLY1 - CALL DLY1 - POP AF - RET - - ; - ; 1 bit write - ; Long Pulse - ; -LONG: PUSH AF - LD A,03h - LD (CSTPT),A - CALL DLY1 - CALL DLY1 - CALL DLY1 - CALL DLY1 - LD A,02h - LD (CSTPT),A - CALL DLY1 - CALL DLY1 - CALL DLY1 - CALL DLY2 - POP AF - RET - - - ; WRITE INFORMATION - -QWRI: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D7H ; "W" - LD E,0CCH ; "L" - LD HL,IBUFE ; 10F0H - LD BC,80H ; WRITE BYTE SIZE -WRI1: CALL CKSUM ; CHECK SUM - CALL MOTOR ; MOTOR ON - JR C,WRI3 - LD A,E - CP 0CCH ; "L" - Long Gap/Tape Mark? - JR NZ,WRI2 - CALL NL - PUSH DE - LD DE,MSGN7 ; WRITING - RST 18H ; CALL MSGX - LD DE,NAME ; FILE NAME - RST 18H ; CALL MSGX - CALL NL - POP DE -WRI2: CALL GAP - CALL WTAPE -WRI3: JP RET2 - - - ; WRITE DATA - ; EXIT CF=0 : OK - ; =1 : BREAK - -QWRD: DI - PUSH DE - PUSH BC - PUSH HL - LD D,0D7H ; "W" - LD E,53H ; "S" -L047D: LD BC,(SIZE) ; WRITE DATA BYTE SIZE - LD HL,(DTADR) ; WRITE DATA ADDRESS - LD A,B - OR C - JP Z,RET1 - JR WRI1 - - ; TAPE WRITE - ; BC=BYTE SIZE - ; HL=DATA LOW ADDRESS - ; EXIT CF=0 : OK - ; =1 : BREAK - -WTAPE: PUSH DE - PUSH BC - PUSH HL - LD D,02H - LD A,0F0H ; 88H WOULD BE BETTER!! - LD (KEYPA),A ; E000H -WTAP1: LD A,(HL) - CALL WBYTE ; 1 BYTE WRITE - LD A,(KEYPB) ; E001H - AND 81H ; SHIFT & BREAK - JP NZ,WTAP2 - LD A,02H ; BREAK IN CODE - SCF - JR WTAP3 - -WTAP2: INC HL - DEC BC - LD A,B - OR C - JP NZ,WTAP1 - LD HL,(SUMDT) ; SUM DATA SET - LD A,H - CALL WBYTE ; Send Checksum - LD A,L - CALL WBYTE -WTAP3A: PUSH DE - LD DE,MSG_WGAPL2 - CALL MSGX - CALL LETNL - POP DE - CALL LONG - DEC D - JP NZ,L04C2 ; Another copy to be sent? - OR A - JP WTAP3 - -L04C2: PUSH DE - LD DE,MSG_SPCS - CALL MSGX - POP DE - LD B,0 ; Send 256 short pulses. - -L04C4: CALL SHORT - LD H,00h - LD L,B - CALL PRTHL ; Print HL as 4digit hex. - LD A,0C4h ; Move cursor left. - LD E,004h ; 4 times. -SPCS2: CALL DPCT - DEC E - JR NZ,SPCS2 - DEC B - JP NZ,L04C4 - LD H,00h - LD L,B - CALL PRTHL ; Print HL as 4digit hex. - LD BC,2500 ; .25 Second delay -SPCS3: CALL DLY1 - DEC BC - LD A,B - OR C - JR NZ,SPCS3 - CALL LETNL - POP HL ; Retrieve saved location and size - POP BC - PUSH BC - PUSH HL - JP WTAP1 ; Repeat send. - -WTAP3: -RET1: POP HL - POP BC - POP DE - RET - - DB 2FH - DB 4EH - - ; VERIFY (FROM $CMT) - ; EXIT ACC=0 : OK CF=0 - ; =1 : ER CF=1 - ; =2 : BREAK CF=1 - -QVRFY: DI - PUSH DE - PUSH BC - PUSH HL - LD BC,(SIZE) - LD HL,(DTADR) - LD D,0D2H ; "R" - LD E,53H ; "S" - LD A,B - OR C - JP Z,RTP4 ; END - CALL CKSUM - CALL MOTOR - JP C,RTP6 ; BRK - CALL TMARK ; TAPE MARK DETECT - JP C,RTP6 ; BRK - CALL TVRFY - JP RTP4 - - ; DATA VERIFY - ; BC=SIZE - ; HL=DATA LOW ADDRESS - ; CSMDT=CHECK SUM - ; EXIT ACC=0 : OK CF=0 - ; =1 : ER =1 - ; =2 : BREAK =1 - -TVRFY: PUSH DE - PUSH BC - PUSH HL - LD H,02H ; COMPARE TWICE -TVF1: LD BC,KEYPB - LD DE,CSTR -TVF2: CALL EDGE - JP C,RTP6 ; BRK - CALL DLY3 ; CALL DLY2*3 - LD A,(DE) - AND 20H - JP Z,TVF2 - LD D,H - POP HL - POP BC - PUSH BC - PUSH HL - ; COMPARE TAPE DATA AND STORAGE -TVF3: CALL RBYTE - JP C,RTP6 ; BRK - CP (HL) - JP NZ,RTP7 ; ERROR, NOT EQUAL - INC HL ; STORAGE ADDRESS + 1 - DEC BC ; SIZE - 1 - LD A,B - OR C - JR NZ,TVF3 - ; COMPARE CHECK SUM (1199H/CSMDT) AND TAPE - LD HL,(CSMDT) - CALL RBYTE - CP H - JP NZ,RTP7 ; ERROR, NOT EQUAL - CALL RBYTE - CP L - JP NZ,RTP7 ; ERROR, NOT EQUAL - DEC D ; NUMBER OF COMPARES (2) - 1 - JP Z,RTP8 ; OK, 2 COMPARES - LD H,D ; (-->05C7H), SAVE NUMBER OF COMPARES - JR TVF1 ; NEXT COMPARE - - ; 1 BYTE WRITE - -WBYTE: PUSH BC - LD B,8 - CALL LONG -WBY1: RLCA - CALL C,LONG - CALL NC,SHORT - DEC B - JP NZ,WBY1 - POP BC - RET - -ARARA: POP HL - JP ABCD - -DLY1S: PUSH AF - PUSH BC - LD C,10 -L0324: CALL DLY12 - DEC C - JR NZ,L0324 - POP BC - POP AF - RET - - ; Test the 8253 Timer, configure it as per the monitor and display the read back values. -TIMERTST: CALL NL - LD DE,MSG_TIMERTST - CALL MSG - CALL NL - LD DE,MSG_TIMERVAL - CALL MSG - LD A,01h - LD DE,8000h - CALL ?TMST -NDE: JP NDE - JP GETL1 -?TMST: DI - PUSH BC - PUSH DE - PUSH HL - LD (AMPM),A - LD A,0F0H - LD (TIMFG),A -ABCD: LD HL,0A8C0H - XOR A - SBC HL,DE - PUSH HL - INC HL - EX DE,HL - - LD HL,CONTF ; Control Register - LD (HL),0B0H ; 10110000 Control Counter 2 10, Write 2 bytes 11, 000 Interrupt on Terminal Count, 0 16 bit binary - LD (HL),074H ; 01110100 Control Counter 1 01, Write 2 bytes 11, 010 Rate Generator, 0 16 bit binary - LD (HL),030H ; 00110100 Control Counter 1 01, Write 2 bytes 11, 010 interrupt on Terminal Count, 0 16 bit binary - - LD HL,CONT2 ; Counter 2 - LD (HL),E - LD (HL),D - - LD HL,CONT1 ; Counter 1 - LD (HL),00AH - LD (HL),000H - - LD HL,CONT0 ; Counter 0 - LD (HL),00CH - LD (HL),0C0H - -; LD HL,CONT2 ; Counter 2 -; LD C,(HL) -; LD A,(HL) -; CP D -; JP NZ,L0323 -; LD A,C -; CP E -; JP Z,CDEF - ; - -L0323: PUSH AF - PUSH BC - PUSH DE - PUSH HL - ; - LD HL,CONTF ; Control Register - LD (HL),080H - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - ;CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),040H - LD HL,CONT1 ; Counter 1 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - ;CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),000H - LD HL,CONT0 ; Counter 0 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - ;CALL DLY1S - ; - LD A,0C4h ; Move cursor left. - LD E,0Eh ; 4 times. -L0330: CALL DPCT - DEC E - JR NZ,L0330 - ; -; LD C,20 -;L0324: CALL DLY12 -; DEC C -; JR NZ,L0324 - ; - POP HL - POP DE - POP BC - POP AF - ; - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CP D - JP NZ,L0323 - LD A,C - CP E - JP NZ,L0323 - ; - ; - PUSH AF - PUSH BC - PUSH DE - PUSH HL - CALL NL - CALL NL - CALL NL - LD DE,MSG_TIMERVAL2 - CALL MSG - POP HL - POP DE - POP BC - POP AF - - ; -CDEF: POP DE - LD HL,CONT1 - LD (HL),00CH - LD (HL),07BH - INC HL - -L0336: PUSH AF - PUSH BC - PUSH DE - PUSH HL - ; - LD HL,CONTF ; Control Register - LD (HL),080H - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),040H - LD HL,CONT1 ; Counter 1 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),000H - LD HL,CONT0 ; Counter 0 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL DLY1S - ; - LD A,0C4h ; Move cursor left. - LD E,0Eh ; 4 times. -L0340: CALL DPCT - DEC E - JR NZ,L0340 - ; - POP HL - POP DE - POP BC - POP AF - - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CP D - JR NZ,L0336 - LD A,C - CP E - JR NZ,L0336 - CALL NL - LD DE,MSG_TIMERVAL3 - CALL MSG - POP HL - POP DE - POP BC - EI - RET - -?TMRD: PUSH HL - LD HL,CONTF - LD (HL),080H - DEC HL - DI - LD E,(HL) - LD D,(HL) - EI - LD A,E - OR D - JR Z,?TMR1 - XOR A - LD HL,0A8C0H - SBC HL,DE - JR C,?TMR2 - EX DE,HL - LD A,(AMPM) - POP HL - RET - -?TMR1: LD DE,0A8C0H -?TMR1A: LD A,(AMPM) - XOR 001H - POP HL - RET - -?TMR2: DI - LD HL,CONT2 - LD A,(HL) - CPL - LD E,A - LD A,(HL) - CPL - LD D,A - EI - INC DE - JR ?TMR1A - -TIMIN: PUSH AF - PUSH BC - PUSH DE - PUSH HL - LD HL,AMPM - LD A,(HL) - XOR 001H - LD (HL),A - LD HL,CONTF - LD (HL),080H - DEC HL - PUSH HL - LD E,(HL) - LD D,(HL) - LD HL,0A8C0H - ADD HL,DE - DEC HL - DEC HL - EX DE,HL - POP HL - LD (HL),E - LD (HL),D - POP HL - POP DE - POP BC - POP AF - EI - RET - - ; Help/Synoposis of commands available. - ; -HELP: CALL LETNL - LD DE,MSG_HELP1 - CALL MSG - CALL LETNL - LD DE,MSG_HELP2 - CALL MSG - CALL LETNL - LD DE,MSG_HELP3 - CALL MSG - CALL LETNL - LD DE,MSG_HELP4 - CALL MSG - CALL LETNL - LD DE,MSG_HELP5 - CALL MSG - CALL LETNL - LD DE,MSG_HELP6 - CALL MSG - CALL LETNL - CALL LETNL - JP GETL1 - -MSG_HELP1: DB "COMMANDS: G TEST GRAPHICS", 0Dh, 00h -MSG_HELP2: DB " M TEST MEMORY", 0Dh, 00h -MSG_HELP3: DB " R LOAD TAPE", 0Dh, 00h -MSG_HELP4: DB " T TIMER TEST", 0Dh, 00h -MSG_HELP5: DB " W WRITE TEST TAPE", 0Dh, 00h -MSG_HELP6: DB " Q QUIT TO MONITOR", 0Dh, 00h - -TITLE: DB "SHARPMZ TESTER (C) P.SMART 2018", 0Dh, 00h -MSG_INITGR:DB "INIT GRAPHICS", 0Dh -MSG_INITM: DB "INIT MEMORY", 0Dh -TITLE_SAVE:DB "WRITE TEST TAPE", 0Dh - -MSG1: DW 207Fh -MSG2: DB "PLAY", 0Dh, 00h -MSG3: DW 207Fh ; PRESS RECORD - DB "RECORD.", 0Dh, 00h -MSGN7: DB "WRITING ", 0Dh, 00h -MSGOK: DB "OK", 0Dh, 00h -MSG_ERRCHKSUM: - DB "CHECKSUM ERROR", 0Dh -MSG_ERRWRITE: - DB "WRITE ERROR", 0Dh - -MSG_READTAPE: - DB "READ TAPE", 0Dh, 00h -MSG_TAPEMARK: - DB "TAPEMARK", 0Dh, 00h -MSG_MOTORTG: - DB "MOTOR TOGGLE", 0Dh, 00h -MSG_MOTORSTP: - DB "MOTOR STOP", 0Dh, 00h -MSG_TPMARK: - DB "TAPE MARK START", 0Dh, 00h -MSG_GAPCK: - DB "GAP CHECK", 0Dh, 00h -MSG_LOADFILE: - DB "LOAD FILE = ",0Dh, 00h -MSG_LOADFROM: - DB "LOAD ADDRESS = ", 0Dh, 00h -MSG_LOADEXEC: - DB "EXEC ADDRESS = ", 0Dh, 00h -MSG_LOADSIZE: - DB "LOAD SIZE = ", 0Dh, 00h -MSG_SAVEFILE: - DB "SAVE FILE = ",0Dh, 00h -MSG_SAVEFROM: - DB "SAVE ADDRESS = ", 0Dh, 00h -MSG_SAVEEXEC: - DB "SAVE EXEC ADDRESS = ", 0Dh, 00h -MSG_SAVESIZE: - DB "SAVE SIZE = ", 0Dh, 00h -MSG_CHKSUM_MZ1: - DB " MZ CHECKSUM (OK) = ", 0Dh, 00h -MSG_CHKSUM_TP1: - DB "TAPE CHECKSUM (OK) = ", 0Dh, 00h -MSG_CHKSUM_MZ2: - DB " MZ CHECKSUM (ER) = ", 0Dh, 00h -MSG_CHKSUM_TP2: - DB "TAPE CHECKSUM (ER) = ", 0Dh, 00h -MSG_WHDR: DB "WRITE HEADER...", 0Dh -MSG_WDATA: DB "WRITE DATA...", 0Dh -MSGGAP: DB "GAP WRITTEN", 0Dh, 00h -MSG_WGAPS: DB "WRITE GAP: ", 0Dh, 00h -MSG_WGAPS2:DB "WRITE TM SHORT: ", 0Dh, 00h -MSG_WGAPL: DB "WRITE TM LONG: ", 0Dh, 00h -MSG_WGAPL2:DB "WRITE 1 LONG BIT", 0Dh, 00h -MSG_SPCS: DB "WRITE 256 SHORT: ", 0Dh, 00h -MSG_SPC: DB ", WAIT.", 0Dh, 00h -MSGTAPE DB "HEADER WRITTEN", 0Dh, 00h -MSG_TIMERTST: - DB "8253 TIMER TEST", 0Dh, 00h -MSG_TIMERVAL: - DB "READ VALUE 1: ", 0Dh, 00h -MSG_TIMERVAL2: - DB "READ VALUE 2: ", 0Dh, 00h -MSG_TIMERVAL3: - DB "READ DONE.", 0Dh, 00h - -OKCHECK: DB ", CHECK: ", 0Dh -OKMSG: DB " OK.", 0Dh -DONEMSG: DB 11h - DB "RAM TEST COMPLETE.", 0Dh - -BITMSG: DB " BIT: ", 0Dh -BANKMSG: DB " BANK: ", 0Dh - -GRPHPOS: DB 00h, 00h - - ; Test tape image to save. -TESTBUF: ; TAPE BUFFER (128 BYTES) -TATRB: DB 02h ; Code Type, 01 = Machine Code. -TNAME: DB "TEST TAPE SAVE", 0Dh, 00h, 00h ; Title/Name (17 bytes). -TSIZE: DW TESTEND - TESTSTART ; Size of program. -TDTADR: DW TESTSTART ; Load address of program. -TEXADR: DW TESTSTART ; Exec address of program. -TCOMNT: DB "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" - -TESTSTART: DB 01h - DB 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 - DB 16,17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 - DB 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47 - DB 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 - DB 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79 - DB 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95 - DB 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111 - DB 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127 - DB 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143 - DB 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159 - DB 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175 - DB 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191 - DB 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207 - DB 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223 - DB 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239 - DB 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 -TESTEND: - -MEND: diff --git a/software/build.sh b/software/build.sh deleted file mode 100755 index 8f1a00a..0000000 --- a/software/build.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -ROOT_DIR=/dvlp/Projects/dev/github/MZ80A_RFS/ -SW_DIR=${ROOT_DIR}/software -PROCESS_MZF_FILES=0 -if [ "x$1" = '-m' ]; then - PROCESS_MZF_FILES=1 -fi - - -( -cd $SW_DIR -tools/assemble_rfs.sh -if [ $? != 0 ]; then - echo "RFS assembly failed..." - exit 1 -fi -tools/assemble_cpm.sh -if [ $? != 0 ]; then - echo "CPM assembly failed..." - exit 1 -fi -tools/assemble_roms.sh -if [ $? != 0 ]; then - echo "ROMS assembly failed..." - exit 1 -fi - -# Only needed if the program source tree changes, takes too long to run on every build! -if [[ ${PROCESS_MFZ_FILES} -eq 1 ]]; then - tools/processMZFfiles.sh - if [ $? != 0 ]; then - echo "Failed to process MZF files into sectored variants...." - exit 1 - fi -fi -tools/make_roms.sh -if [ $? != 0 ]; then - echo "ROM disk assembly failed..." - exit 1 -fi -tools/make_cpmdisks.sh -if [ $? != 0 ]; then - echo "CPM disks assembly failed..." - exit 1 -fi -tools/make_sdcard.sh -if [ $? != 0 ]; then - echo "SD card assembly failed..." - exit 1 -fi -) -if [ $? != 0 ]; then - exit 1 -fi -echo "Done!" diff --git a/software/config/diskdefs b/software/config/diskdefs deleted file mode 100644 index 3af24bb..0000000 --- a/software/config/diskdefs +++ /dev/null @@ -1,1623 +0,0 @@ -# 320K Disk for the MZ80A - Same format as the MZ800 -# but implements a cylinder in uniform manner (ie. 1 cyl -# = 1 track x 2(heads) where as the MZ800 implements as -# 160 tracks, 80 x Head 1 0->79 then 80 x Head 2 80->159. -diskdef MZ80A-A - seclen 256 - tracks 40 - sectrk 32 - blocksize 2048 - maxdir 64 - skew 0 - boottrk 1 - os 2.2 -end - -# A standard format 1.44Mb Floppy format for the MZ80A -diskdef MZ80A-1440 - seclen 512 - tracks 80 - sectrk 36 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 0 - os 2.2 -end - -# A standard format 720K Floppy format for the MZ80A. -diskdef MZ80A-720 - seclen 256 - tracks 80 - sectrk 36 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 0 - os 2.2 -end - -# A 240K Rom Filing System ROM Drive image. -diskdef MZ80A-RFS - seclen 128 - tracks 15 - sectrk 128 - blocksize 1024 - maxdir 32 - skew 0 - boottrk 0 - os 2.2 -end - -# A 320K Rom Filing System ROM Drive image. -diskdef MZ80A-RFS-320 - seclen 128 - tracks 20 - sectrk 128 - blocksize 2048 - maxdir 32 - skew 0 - boottrk 0 - os 2.2 -end - -# A 16Mb fixed disk SD Card Image. -diskdef MZ80A-SDC16M - seclen 512 - tracks 1024 - sectrk 32 - blocksize 8192 - maxdir 512 - skew 0 - boottrk 0 - os 2.2 -end - -# Definition for the MZ800 CP/M Boot Disk. The reserved -# track is in inverted data format but this is skipped in -# CPM Tools. -diskdef MZ800-BOOT - seclen 256 - tracks 80 - sectrk 16 - blocksize 2048 - maxdir 64 - skew 0 - boottrk 1 - os 2.2 -end - -# Definition for the MZ800 CP/M Data disk. No reserved tracks. -diskdef MZ800-DATA - seclen 256 - tracks 80 - sectrk 16 - blocksize 2048 - maxdir 64 - skew 0ones, 1 - boottrk 0 - os 2.2 -end - -diskdef hd0 - seclen 512 - tracks 512 - sectrk 32 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 1 - os 2.2 -end - -diskdef multcomphd0 - seclen 512 - tracks 512 - sectrk 32 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 1 - os 2.2 -end - -diskdef multcomphd1 - seclen 512 - tracks 1024 - sectrk 32 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 512 - os 2.2 -end - -diskdef multcomphd2 - seclen 512 - tracks 1536 - sectrk 32 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 1024 - os 2.2 -end - -diskdef multcomphd3 - seclen 512 - tracks 2048 - sectrk 32 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 1536 - os 2.2 -end - -diskdef multcomphd4 - seclen 512 - tracks 2560 - sectrk 32 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 2048 - os 2.2 -end - -# Z20-MBC DISK 0 (TWO RESERVED TRACK FOR CP/M) -diskdef z80mbc-d0 - seclen 128 - tracks 32 - sectrk 32 - blocksize 1024 - maxdir 64 - skew 0 - boottrk 2 - os 2.2 -end - -# Z20-MBC DISK 1 -diskdef z80mbc-d1 - seclen 128 - tracks 32 - sectrk 32 - blocksize 1024 - maxdir 64 - skew 0 - boottrk 0 - os 2.2 -end - -# Z20-MBC2 CP/M 2.2 DISK 0 ONLY (ONE RESERVED TRACK FOR CP/M 2.2) -diskdef z80mbc2-d0 - seclen 512 - tracks 512 - sectrk 32 - blocksize 4096 - maxdir 512 - skew 0 - boottrk 1 - os 2.2 -end - -# Z20-MBC2 CP/M 2.2 DISK 1-15 -diskdef z80mbc2-d1 - seclen 512 - tracks 512 - sectrk 32 - blocksize 4096 - maxdir 512 - skew 0 - boottrk 0 - os 2.2 -end - -# Z20-MBC2 CP/M 3 (DISK 0-15) -diskdef z80mbc2-cpm3 - seclen 512 - tracks 512 - sectrk 32 - blocksize 4096 - maxdir 512 - skew 0 - boottrk 1 - os 3 -end - -diskdef ibm-3740 - seclen 128 - tracks 77 - sectrk 26 - blocksize 1024 - maxdir 64 - skew 6 - boottrk 2 - os 2.2 -end - -diskdef 4mb-hd - seclen 128 - tracks 1024 - sectrk 32 - blocksize 2048 - maxdir 256 - skew 1 - boottrk 0 - os p2dos -end - -diskdef pcw - seclen 512 - tracks 40 - sectrk 9 - blocksize 1024 - maxdir 64 - skew 1 - boottrk 1 - os 3 - libdsk:format pcw180 -end - -diskdef pc1.2m - seclen 512 - tracks 80 - # this format uses 15 sectors per track, but 30 per cylinder - sectrk 30 - blocksize 4096 - maxdir 256 - skew 1 - boottrk 0 - os 3 -end - -# CP/M 86 on 1.44MB floppies -diskdef cpm86-144feat - seclen 512 - tracks 160 - sectrk 18 - blocksize 4096 - maxdir 256 - skew 1 - boottrk 2 - os 3 - libdsk:format ibm1440 -end - -# CP/M 86 on 720KB floppies -diskdef cpm86-720 - seclen 512 - tracks 160 - sectrk 9 - blocksize 2048 - maxdir 256 - skew 1 - boottrk 2 - os 3 -end - -diskdef cf2dd - seclen 512 - tracks 160 - sectrk 9 - blocksize 2048 - maxdir 256 - skew 1 - boottrk 1 - os 3 - libdsk:format pcw720 -end - -#amstrad: values are read from super block (special name hardcoded) - -# Royal alphatronic -# setfdprm /dev/fd1 dd ssize=256 cyl=40 sect=16 head=2 -diskdef alpha - seclen 256 - tracks 40 - sectrk 32 - blocksize 2048 - maxdir 128 - skew 1 - boottrk 2 - os 2.2 -end - -# Apple II CP/M skew o Apple II DOS 3.3 skew -diskdef apple-do - seclen 256 - tracks 35 - sectrk 16 - blocksize 1024 - maxdir 64 - skewtab 0,6,12,3,9,15,14,5,11,2,8,7,13,4,10,1 - boottrk 3 - os 2.2 -end - -# Apple II CP/M skew o Apple II PRODOS skew -diskdef apple-po - seclen 256 - tracks 35 - sectrk 16 - blocksize 1024 - maxdir 64 - skewtab 0,9,3,12,6,15,1,10,4,13,7,8,2,11,5,14 - boottrk 3 - os 2.2 -end - -# MYZ80 hard drive (only works with libdsk, because it has a 256-byte header) -diskdef myz80 - seclen 1024 - tracks 64 - sectrk 128 - blocksize 4096 - maxdir 1024 - skew 1 - boottrk 0 - os 3 - libdsk:format pcw720 -end - -# Despite being Amstrad formats, CPC System and CPC Data don't have an Amstrad -# superblock. You'll need to use libdsk to access them because the Linux -# and Windows kernel drivers won't touch them. -diskdef cpcsys - seclen 512 - tracks 40 - sectrk 9 - blocksize 1024 - maxdir 64 - skew 1 - boottrk 2 - os 3 - libdsk:format cpcsys -end -diskdef cpcdata - seclen 512 - tracks 40 - sectrk 9 - blocksize 1024 - maxdir 64 - skew 1 - boottrk 0 - os 3 - libdsk:format cpcdata -end - -# after being read in with no sector skew. -diskdef nigdos - seclen 512 - # NigDos double sided disk format, 42 tracks * 2 sides - tracks 84 - sectrk 10 - blocksize 2048 - maxdir 128 - skew 1 - boottrk 0 - # this format wastes half of the directory entry - logicalextents 1 - os 3 -end - -diskdef epsqx10 - seclen 512 - tracks 40 - sectrk 20 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 2 - os 2.2 -end - -diskdef ibm-8ss - seclen 512 - tracks 40 - sectrk 8 - blocksize 1024 - maxdir 64 - skew 0 - boottrk 1 - os 2.2 -end - -diskdef ibm-8ds - seclen 512 - tracks 40 - sectrk 8 - blocksize 1024 - maxdir 64 - skew 0 - boottrk 1 - os 2.2 -end - -diskdef electroglas - seclen 512 - tracks 80 - sectrk 10 - blocksize 2048 - maxdir 256 - skew 0 - boottrk 1 - os 3 -end - -# IBM CP/M-86 -# setfdprm /dev/fd1 sect=8 dtr=1 hd ssize=512 tpi=48 head=1 -diskdef ibmpc-514ss - seclen 512 - tracks 40 - sectrk 8 - blocksize 1024 - maxdir 64 - skew 1 - boottrk 1 - os 2.2 - libdsk:format ibm160 -end - -# IBM CP/M-86 -# setfdprm /dev/fd1 sect=8 dtr=1 hd ssize=512 tpi=48 -diskdef ibmpc-514ds - seclen 512 - tracks 80 - sectrk 8 - blocksize 2048 - maxdir 64 - skew 0 - boottrk 2 - os 2.2 - libdsk:format ibm320 -end - -diskdef p112 - seclen 512 - tracks 160 - sectrk 18 - blocksize 2048 - maxdir 256 - skew 1 - boottrk 2 - os 3 -end - -diskdef p112-old - seclen 512 - tracks 160 - sectrk 18 - blocksize 2048 - maxdir 128 - skew 1 - boottrk 1 - os 3 -end - -diskdef gide-cfa - seclen 512 - tracks 1000 - sectrk 16 - blocksize 4096 - maxdir 1024 - skew 0 - boottrk 2 - os 3 -end - -diskdef gide-cfb - seclen 512 - tracks 1000 - sectrk 16 - blocksize 4096 - maxdir 1024 - skew 0 - boottrk 0 -# Start of second partition - offset 1000trk - os 3 -end - -# AT&T/Olivetti Word Processor -diskdef attwp - seclen 256 - tracks 80 - sectrk 32 - blocksize 2048 - maxdir 128 - boottrk 1 - logicalextents 1 - skewtab 0,2,4,6,8,10,12,14,1,3,5,7,9,11,13,15,16,18,20,22,24,26,28,30,17,19,21,23,25,27,29,31 - os 2.2 -end - -# setfdprm /dev/fd0 zerobased SS DD ssize=512 cyl=40 sect=10 head=1 -# Kaypro II -diskdef kpii - seclen 512 - tracks 40 - sectrk 10 - blocksize 1024 - maxdir 64 - skew 0 - boottrk 1 - os 2.2 -end - -# setfdprm /dev/fd0 zerobased DS DD ssize=512 cyl=40 sect=10 head=2 -# Kayro IV -diskdef kpiv - seclen 512 - tracks 80 - sectrk 10 - blocksize 2048 - maxdir 64 - skew 0 - boottrk 1 - os 2.2 -end - -# setfdprm /dev/fd0 dd sect=10 -diskdef interak - seclen 512 - tracks 80 - sectrk 20 - blocksize 4096 - maxdir 256 - skew 1 - boottrk 2 - os 2.2 -end - -# Timex FDD3000 3" -diskdef fdd3000 - seclen 256 - tracks 40 - sectrk 16 - blocksize 1024 - maxdir 128 - boottrk 4 - os 2.2 - skew 7 -end - -# Timex FDD3000 3" -diskdef fdd3000_2 - seclen 256 - tracks 40 - sectrk 16 - blocksize 1024 - maxdir 128 - boottrk 2 - os 2.2 - skew 5 -end - -# Robotron 1715 -diskdef 1715 - seclen 1024 - tracks 40 - sectrk 5 - blocksize 1024 - maxdir 64 - skew 0 - boottrk 3 - os 2.2 -end - -# Robotron 1715 with SCP3 -diskdef 17153 - seclen 1024 - tracks 160 - sectrk 5 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 4 - os 3 -end - -#DDR -diskdef scp624 - seclen 256 - tracks 160 - sectrk 16 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 2 - os 2.2 -end - -diskdef scp640 - seclen 256 - tracks 160 - sectrk 16 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 0 - os 2.2 -end - -diskdef scp780 - seclen 1024 - tracks 160 - sectrk 5 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 2 - os 2.2 -end - -diskdef scp800 - seclen 1024 - tracks 160 - sectrk 5 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 0 - os 2.2 -end - -diskdef z9001 - seclen 1024 - tracks 160 - sectrk 5 - blocksize 2048 - maxdir 192 - skew 0 - boottrk 0 - os 2.2 -end - -# Visual Technology Visual 1050 computer -diskdef v1050 - seclen 512 - tracks 80 - sectrk 10 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 2 - os 3 -end - -# Microbee 40 track 5.25" disks -diskdef microbee40 - seclen 512 - tracks 80 - sectrk 10 - blocksize 2048 - maxdir 128 - skewtab 1,4,7,0,3,6,9,2,5,8 - boottrk 2 - os 2.2 -end - -diskdef dreamdisk40 - seclen 512 - tracks 80 - sectrk 10 - blocksize 2048 - maxdir 128 - skewtab 1,4,7,0,3,6,9,2,5,8 - boottrk 2 - os 2.2 -end - -diskdef dreamdisk80 - seclen 512 - tracks 160 - sectrk 10 - blocksize 2048 - maxdir 256 - skewtab 1,4,7,0,3,6,9,2,5,8 - boottrk 2 - os 2.2 -end - -diskdef rc759 - seclen 1024 - tracks 154 - sectrk 8 - blocksize 2048 - maxdir 512 - boottrk 4 - os 3 -end - -# ICL Comet: 40 track 5.25" Single Sided -# -diskdef icl-comet-525ss - seclen 512 - tracks 40 - sectrk 10 - blocksize 1024 - maxdir 64 - skewtab 0,3,6,9,2,5,8,1,4,7 - boottrk 2 - os 2.2 -end - -diskdef z80pack-hd - seclen 128 - tracks 255 - sectrk 128 - blocksize 2048 - maxdir 1024 - skew 0 - boottrk 0 - os 2.2 -end - -diskdef z80pack-hdb - seclen 128 - tracks 256 - sectrk 16384 - blocksize 16384 - maxdir 8192 - skew 0 - boottrk 0 - os 2.2 -end - -# Bondwell 12 and 14 disk images in IMD raw binary format -diskdef bw12 - seclen 256 - tracks 40 - sectrk 18 - blocksize 2048 - maxdir 64 - skew 1 - boottrk 2 - os 2.2 -end - -diskdef bw14 - seclen 256 - tracks 80 - sectrk 18 - blocksize 2048 - maxdir 64 - skew 1 - boottrk 2 - os 2.2 -end - -############################ -# north star cp/m disks -############################ - -#North Star floppy 360K - -diskdef nsfd - seclen 512 - tracks 70 - sectrk 10 - blocksize 2048 - maxdir 64 - skew 5 - boottrk 2 - os 2.2 -end - - -#North Star CP/M Virtual-Disk file on Hard Disk -# prepared with allocation factor = 4 -# as in "CR CPMB 4000 4" -# needs to be copied off hard drive before you can -# work on it with cpmtools - -diskdef nshd4 - seclen 512 - tracks 512 - sectrk 16 - blocksize 4096 - maxdir 256 - skew 0 - boottrk 0 - os 2.2 -end - - -#North Star CP/M Virtual-Disk file on Hard Disk -# prepared with allocation factor = 8 -# as in "CR CPMB 6000 8" -# needs to be copied off hard drive before you can -# work on it with cpmtools - -diskdef nshd8 - seclen 512 - tracks 1024 - sectrk 16 - blocksize 8192 - maxdir 256 - skew 0 - boottrk 0 - os 2.2 -end - -# Northstar Micro-Disk System MDS-A-D 175 -diskdef mdsad175 - seclen 512 - blocksize 1024 - tracks 35 - maxdir 64 - boottrk 2 - sectrk 10 - skew 5 - os 2.2 -end - - -# Northstar Micro-Disk System MDS-A-D 350 -diskdef mdsad350 - seclen 512 - blocksize 2048 - tracks 70 - maxdir 64 - boottrk 2 - sectrk 10 - skew 5 - os 2.2 -end - - -# Osborne 1 -diskdef osborne1 - seclen 1024 - tracks 40 - sectrk 5 - blocksize 1024 - maxdir 64 - boottrk 3 - os 2.2 -end - -# Osborne Nuevo/Vixen/4 -diskdef osborne4 - seclen 1024 - tracks 80 - sectrk 5 - blocksize 2048 - maxdir 128 - skew 2 - boottrk 2 - os 2.2 -end - -# Lobo Max-80 8" CP/M 2 -diskdef lobo2 - seclen 256 - tracks 77 - sectrk 30 - blocksize 2048 - maxdir 64 - skew 0 - boottrk 2 - os 2.2 -end - -#Lobo Max-80 8" CP/M 3 -diskdef lobo3 - seclen 512 - tracks 77 - sectrk 17 - blocksize 2048 - maxdir 64 - skew 0 - boottrk 2 - os 3 -end - -# PRO CP/M RZ50 DZ format (Perhaps only 79 tracks should be used?) -diskdef dec_pro - seclen 512 - tracks 80 - sectrk 10 - blocksize 2048 - maxdir 128 - skew 2 - boottrk 2 - os 2.2 -end - -# TDOS with DateStamper -diskdef tdos-ds - seclen 1024 - tracks 77 - sectrk 16 - blocksize 2048 - maxdir 256 - skew 0 - boottrk 1 - os zsys -end - -# The following entires are tested and working -# Most of the images are either from Don Maslin's archive or from -# Dave Dunfield's site, but not all - they are noted as well as -# their size. - -# PMC Micromate -# Dave Dunfield's Imagedisk information from DSK conversion from IMD: -# IMageDisk Utility 1.18 / Mar 07 2012 -# IMD 1.14: 10/03/2007 11:13:27 -# PMC-101 MicroMate -# CP/M Plus -# System Master -# Assuming 1:1 for Binary output -# 0/0 250 kbps DD 5x1024 -# 80 tracks(40/40), 400 sectors (12 Compressed) -# Entry derived from above - image size = 409,600, from Dave Dunfield -diskdef pmc101 - seclen 1024 - tracks 80 - sectrk 5 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 2 - os 3 -end - -# BEGIN td143ssdd8 Turbo Dos 1.43 - SSDD 8" - 512 x 16 -# Test OK - image size = 630,784, from Don Maslin's archive -diskdef td143ssdd8 - seclen 512 - tracks 77 - sectrk 9 - blocksize 1024 - maxdir 64 - skew 0 - boottrk 0 - os 2.2 -# DENSITY MFM ,LOW -end - -# BEGIN headsdd8 Heath H89, Magnolia CP/M - SSDD 8" - 512 x 16 -# Test OK - image size = 630,784, from Don Maslin's archive -diskdef heassdd8 - seclen 512 - tracks 77 - sectrk 16 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 2 - os 2.2 -# DENSITY MFM ,LOW -end - -# Morrow Designs Micro-Decision DOUBLE -# 64k CP/M Vers. 2.2 Rev.2.3 SIDED -# Copyright '76, '77, '78, '79, '80 -# Digital Research -# Copyright 1982,1983 Morrow Designs, Inc. -# Assuming 1:1 for Binary output -# 0/0 250 kbps DD 5x1024 -# 80 tracks(40/40), 400 sectors (128 Compressed) -# Entry derived from above data -# Test OK - image siae = 409600, from Dave Dunfield -diskdef mordsdd - seclen 1024 - tracks 80 - sectrk 5 - blocksize 2048 - maxdir 128 - skew 3 - boottrk 2 - OS 2.2 -end - - -# BEGIN morsddd Morrow MD2 - SSDD 48 tpi 5.25" - 1024 x 5 -# Test OK - image size = 204,800, from Don Maslin's archive -# Also tested with image from Dave Dunfield -diskdef morsddd - seclen 1024 - tracks 40 - sectrk 5 - blocksize 2048 - maxdir 128 - skew 3 - boottrk 2 - os 2.2 -# DENSITY MFM ,LOW -# BSH 4 BLM 15 EXM 1 DSM 94 DRM 127 AL0 0C0H AL1 0 OFS 2 -end - -# BEGIN osb1sssd Osborne 1 - SSSD 48 tpi 5.25" - 256 x 10 -# Test OK - image size = 102,400, from Don Maslin's archive -diskdef osb1sssd - seclen 256 - tracks 40 - sectrk 10 - blocksize 2048 - maxdir 64 - skew 2 - boottrk 3 - os 2.2 -# DENSITY MFM ,LOW -# BSH 4 BLM 15 EXM 1 DSM 45 DRM 63 AL0 080H AL1 0 OFS 3 -end - -# BEGIN ampdsdd Ampro - DSDD 48 tpi 5.25" - 512 x 10 -# Test OK - image size = 409,600, from Don Maslin's archive -diskdef ampdsdd - seclen 1024 - tracks 80 - sectrk 5 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 2 - os 2.2 - libdsk:format ampro400d -# DENSITY MFM ,LOW -# BSH 4 BLM 15 EXM 1 DSM 194 DRM 127 AL0 0C0H AL1 0 OFS 2 -end - -# BEGIN ampdsdd80 Ampro - DSDD 96 tpi 5.25" - 512 x 10 -# Test OK - image size = 819,200, from Don Maslin's archive -diskdef ampdsdd80 - seclen 1024 - tracks 160 - sectrk 5 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 2 - os 2.2 - libdsk:format ampro800 -# DENSITY MFM ,LOW -# BSH 4 BLM 15 EXM 1 DSM 194 DRM 127 AL0 0C0H AL1 0 OFS 2 -end - -# BEGIN altdsdd Altos - DSDD 5" - 512 x 9 -# Test OK - both CP/M and MP/M - image size = 737,280, from Dave Dunfield -diskdef altdsdd - seclen 512 - tracks 160 - sectrk 9 - blocksize 4096 - maxdir 177 - skew 0 - boottrk 2 - os 3 -# DENSITY MFM ,HIGH -# BSH 5 BLM 31 EXM 3 DSM 176 DRM 176 AL0 0C0H AL1 0 OFS 2 -end - -# BEGIN trsomsssd TRS-80 Model 1, Omikron CP/M - SSSD 48 tpi 5.25" - 128 x 18 -# Test OK - image size = 80,640, from TRS-80 Yahoo Group posting -diskdef trsomsssd - seclen 128 - tracks 35 - sectrk 18 - blocksize 1024 - maxdir 64 - skew 4 - boottrk 3 - os 2.2 -# DENSITY FM ,LOW -# BSH 3 BLM 7 EXM 0 DSM 71 DRM 63 AL0 0C0H AL1 0 OFS 3 -end - -# Memotech type 03, ie: 3.5" or 5.25", D/S, D/D, S/T -# 40 tracks, 2 sides, 16 sectors/track, 256 bytes/sector -# Bytes on the media = 2*40*16*256 = 327680 -# CP/M sees 26 128 byte records per track (similar to 8" disks). -# Tracks = 327680/(26*128) = 98 -# Data is in 2048 byte blocks, on track 2 onwards -# Blocks = ((98-2)*26*128)/2048 = 156, which agrees with DPB - -diskdef memotech-type03 - seclen 128 - tracks 98 - sectrk 26 - blocksize 2048 - maxdir 64 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 07, ie: 3.5" or 5.25", D/S, D/D, D/T -# 80 tracks, 2 sides, 16 sectors/track, 256 bytes/sector -# Bytes on the media = 2*80*16*256 = 655360 -# CP/M sees 26 128 byte records per track (similar to 8" disks). -# Tracks = 655360/(26*128) = 196 -# Data is in 2048 byte blocks, on track 2 onwards -# Blocks = ((196-2)*26*128)/2048 = 315, which agrees with DPB - -diskdef memotech-type07 - seclen 128 - tracks 196 - sectrk 26 - blocksize 2048 - maxdir 128 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 43, ie: 1MB Silicon Disc -# CP/M sees 26 128 byte records per track -# Note: Unlike common practice with real physical disks, with real geometry, -# the DPB for Silicon Discs includes blocks on the last incomplete track -# Tracks = 1048576/(26*128) = 315.07 -# Data is in 4096 byte blocks, on track 2 onwards -# Blocks = (1048576-2*26*128)/4096 = 254, which agrees with DPB -# Blocks = ((315-2)*26*128)/4096 = 254, so we don't need the 0.07 track -diskdef memotech-type43 - seclen 128 - tracks 315 - sectrk 26 - blocksize 4096 - maxdir 256 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 47, ie: 2MB Silicon Disc -# CP/M sees 26 128 byte records per track -# Note: Unlike common practice with real physical disks, with real geometry, -# the DPB for Silicon Discs includes blocks on the last incomplete track -# Tracks = 2097152/(26*128) = 630.15 -# Data is in 4096 byte blocks, on track 2 onwards -# Blocks = (2097152-2*26*128)/4096 = 510, which agrees with DPB -# Blocks = ((630-2)*26*128)/4096 = 510, so we don't need the 0.15 track -diskdef memotech-type47 - seclen 128 - tracks 630 - sectrk 26 - blocksize 4096 - maxdir 256 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 4B, ie: 4MB Silicon Disc -# CP/M sees 26 128 byte records per track -# Note: Unlike common practice with real physical disks, with real geometry, -# the DPB for Silicon Discs includes blocks on the last incomplete track -# Tracks = 4194304/(26*128) = 1260.3 -# Data is in 4096 byte blocks, on track 2 onwards -# Blocks = (4194304-2*26*128)/4096 = 1022, which agrees with DPB -# Blocks = ((1260-2)*26*128)/4096 = 1022, so we don't need the 0.3 track -diskdef memotech-type4B - seclen 128 - tracks 1260 - sectrk 26 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 4F, ie: 8MB Silicon Disc -# CP/M sees 26 128 byte records per track -# Note: Unlike common practice with real physical disks, with real geometry, -# the DPB for Silicon Discs includes blocks on the last incomplete track -# Tracks = 8388608/(26*128) = 2520.61 -# Data is in 4096 byte blocks, on track 2 onwards -# Blocks = (8388608-2*26*128)/4096 = 2046, which agrees with DPB -# Blocks = ((2520-2)*26*128)/4096 = 2045, so we need the extra 0.61 track -diskdef memotech-type4F - seclen 128 - tracks 2521 - sectrk 26 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 18, ie: 8MB SD Card -# CP/M sees 26 128 byte records per track -# Note: Unlike common practice with real physical disks, with real geometry, -# the DPB for SD Cards includes blocks on the last incomplete track -# Tracks = 8388608/(26*128) = 2520.61 -# Data is in 4096 byte blocks, on track 2 onwards -# Blocks = (8388608-2*26*128)/4096 = 2046, which agrees with DPB -# Blocks = ((2520-2)*26*128)/4096 = 2045, so we need the extra 0.61 track -diskdef memotech-type18 - seclen 128 - tracks 2521 - sectrk 26 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 19, ie: 8MB SD Card -diskdef memotech-type19 - seclen 128 - tracks 2521 - sectrk 26 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 2 - os 2.2 - offset 8M -end - -# Memotech type 1A, ie: 8MB SD Card -diskdef memotech-type1A - seclen 128 - tracks 2521 - sectrk 26 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 2 - os 2.2 - offset 16M -end - -# Memotech type 1B, ie: 8MB SD Card -diskdef memotech-type1B - seclen 128 - tracks 2521 - sectrk 26 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 2 - os 2.2 - offset 24M -end - -# Memotech type 1C, ie: 8MB SD Card -diskdef memotech-type1C - seclen 128 - tracks 2521 - sectrk 26 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 2 - os 2.2 - offset 32M -end - -# Memotech type 1D, ie: 8MB SD Card -diskdef memotech-type1D - seclen 128 - tracks 2521 - sectrk 26 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 2 - os 2.2 - offset 40M -end - -# Memotech type 1E, ie: 8MB SD Card -diskdef memotech-type1E - seclen 128 - tracks 2521 - sectrk 26 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 2 - os 2.2 - offset 48M -end - -# Memotech type 1F, ie: 8MB SD Card -diskdef memotech-type1F - seclen 128 - tracks 2521 - sectrk 26 - blocksize 4096 - maxdir 512 - skew 1 - boottrk 2 - os 2.2 - offset 56M -end - -# Memotech type 50, ie: 256KB RAM Disc -# CP/M sees 26 128 byte records per track -# Note: Unlike common practice with real physical disks, with real geometry, -# the DPB for RAM Discs includes blocks on the last incomplete track -# Tracks = 262144/(26*128) = 78.76 -# Data is in 1024 byte blocks, on track 2 onwards -# Blocks = (262144-2*26*128)/1024 = 249, which agrees with DPB -# Blocks = ((78-2)*26*128)/1024 = 247, so we need the extra 0.76 track -diskdef memotech-type50 - seclen 128 - tracks 79 - sectrk 26 - blocksize 1024 - maxdir 64 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 51, ie: 512KB RAM Disc -# CP/M sees 26 128 byte records per track -# Note: Unlike common practice with real physical disks, with real geometry, -# the DPB for RAM Discs includes blocks on the last incomplete track -# Tracks = 524288/(26*128) = 157.53 -# Data is in 2048 byte blocks, on track 2 onwards -# Blocks = (524288-2*26*128)/2048 = 252, which agrees with DPB -# Blocks = ((157-2)*26*128)/2048 = 251, so we need the extra 0.53 track -diskdef memotech-type51 - seclen 128 - tracks 158 - sectrk 26 - blocksize 2048 - maxdir 128 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 51, as used in Italy, ie: 480KB RAM Disc -# CP/M sees 26 128 byte records per track -# Note: Unlike common practice with real physical disks, with real geometry, -# the DPB for RAM Discs includes blocks on the last incomplete track -# Tracks = 491520/(26*128) = 147.69 -# Data is in 2048 byte blocks, on track 2 onwards -# Blocks = (491520-2*26*128)/2048 = 236, which agrees with DPB -# Blocks = ((147-2)*26*128)/2048 = 235, so we need the extra 0.69 track -diskdef memotech-type51-italy - seclen 128 - tracks 148 - sectrk 26 - blocksize 2048 - maxdir 128 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 51, after S2R64.COM, ie: 448KB RAM Disc -# CP/M sees 26 128 byte records per track -# Note: Unlike common practice with real physical disks, with real geometry, -# the DPB for RAM Discs includes blocks on the last incomplete track -# Tracks = 458752/(26*128) = 137.84 -# Data is in 2048 byte blocks, on track 2 onwards -# Blocks = (458752-2*26*128)/2048 = 220, which agrees with DPB, after S2R64.COM -# Blocks = ((137-2)*26*128)/2048 = 219, so we need the extra 0.84 track -diskdef memotech-type51-s2r64 - seclen 128 - tracks 138 - sectrk 26 - blocksize 2048 - maxdir 128 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 51, after S2R.COM, ie: 144KB RAM Disc -# CP/M sees 26 128 byte records per track -# Note: Unlike common practice with real physical disks, with real geometry, -# the DPB for RAM Discs includes blocks on the last incomplete track -# Tracks = 147456/(26*128) = 44.3 -# Data is in 2048 byte blocks, on track 2 onwards -# Blocks = (147456-2*26*128)/2048 = 68, which agrees with DPB, after S2R.COM -# Blocks = ((44-2)*26*128)/2048 = 68, so we don't need the extra 0.3 track -diskdef memotech-type51-s2r - seclen 128 - tracks 44 - sectrk 26 - blocksize 2048 - maxdir 128 - skew 1 - boottrk 2 - os 2.2 -end - -# Memotech type 52, ie: 320KB RAM Disc -# Added for REMEMOTECH -# CP/M sees 26 128 byte records per track -# Note: Unlike common practice with real physical disks, with real geometry, -# the DPB for RAM Discs includes blocks on the last incomplete track -# Tracks = 327680/(26*128) = 98.46 -# Data is in 2048 byte blocks, on track 2 onwards -# Blocks = (327680-2*26*128)/2048 = 156 -# Blocks = ((98-2)*26*128)/2048 = 156, so we don't need the extra 0.46 track -# This type very deliberately and conveniently exactly matches type 03 -diskdef memotech-type52 - seclen 128 - tracks 98 - sectrk 26 - blocksize 2048 - maxdir 64 - skew 1 - boottrk 2 - os 2.2 -end - -# Research Machines 380Z/480Z 5.25" "Single Density" or "MDS" format. -# All tracks are formatted FM 16x128. -diskdef rm-sd - seclen 128 - tracks 40 - sectrk 16 - blocksize 1024 - maxdir 64 - skew 3 - boottrk 3 - os 2.2 -end - -# Research Machines 380Z/480Z 5.25" "Double Density" or "MD" format. -# Track 0 is formatted FM 16x128; 1+ are MFM 9x512. -# If you're working with an image file, make sure that track 0 is -# padded to be the same size as the other tracks. -diskdef rm-dd - seclen 512 - tracks 40 - sectrk 9 - blocksize 1024 - maxdir 64 - skew 5 - boottrk 3 - os 2.2 -end - -# Research Machines 380Z/480Z 5.25" "Quad Density" or "MQ" format. -# Track 0 is formatted FM 16x128; 1+ are MFM 9x512. -diskdef rm-qd - seclen 512 - tracks 80 - sectrk 9 - blocksize 2048 - maxdir 128 - skew 5 - boottrk 3 - os 2.2 -end - -# Ampro Little Board Z80 running CP/M 2.21 -# BEGIN AMP1 Ampro - SSDD 48 tpi 5.25" -# DENSITY MFM, LOW -# CYLINDERS 40 SIDES 1 SECTORS 10,512 SKEW 2 -# SIDE1 0 1,2,3,4,5,6,7,8,9,10 -# BSH 4 BLM 15 EXM 1 DSM 94 DRM 63 AL0 080H AL1 0 OFS 2 -# END - -diskdef amp1 - seclen 512 #= Sectors xx,512 - tracks 40 #= (Cylinders * Sides) = 40*1 = 40 - sectrk 10 #= Sectors 10,xxx - blocksize 2048 #= (128*(BLM+1)) = 2048 - maxdir 64 #(DRM+1) = 64 - skew 0 #= SKEW = 0 - boottrk 2 #= OFS = 2 - os 2.2 -end - -#BEGIN AMP2 Ampro - DSDD 48 tpi 5.25" -#DENSITY MFM, LOW -#CYLINDERS 40 SIDES 2 -#SECTORS 10,512 -#SKEW 2 -#SIDE1 0 17,18,19,20,21,22,23,24,25,26 -#SIDE2 1 17,18,19,20,21,22,23,24,25,26 -#ORDER SIDES -#BSH 4 BLM 15 EXM 1 DSM 194 DRM 127 AL0 0C0H AL1 0 OFS 2 -#END - -# setfdprm /dev/fd0 DS DD ssize=512 cyl=40 sect=10 head=2 -diskdef amp2 - seclen 512 - tracks 80 - sectrk 10 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 2 - os 2.2 -end - -#BEGIN AMP3 Ampro - SSDD 96 tpi 3.5" -#DENSITY MFM, LOW -#CYLINDERS 80 SIDES 1 SECTORS 5,1024 SKEW 2 -#SIDE1 0 1,2,3,4,5 -#BSH 4 BLM 15 EXM 1 DSM 194 DRM 127 AL0 0C0H AL1 0 OFS 2 -#END - -# setfdprm /dev/fd0 SS DD ssize=1024 cyl=80 sect=5 head=1 -diskdef amp3 - seclen 1024 - tracks 80 - sectrk 5 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 2 - os 2.2 -end - -#BEGIN AMP4 Ampro - DSDD 96 tpi 3.5" -#DENSITY MFM, LOW -#CYLINDERS 80 SIDES 2 SECTORS 5,1024 SKEW 2 -#SIDE1 0 17,18,19,20,21 -#SIDE2 1 17,18,19,20,21 -#ORDER SIDES -#BSH 4 BLM 15 EXM 0 DSM 394 DRM 255 AL0 0F0H AL1 0 OFS 2 -#END - -# setfdprm /dev/fd0 DS DD ssize=1024 cyl=80 sect=5 head=2 -diskdef amp4 - seclen 1024 - tracks 160 - sectrk 5 - blocksize 2048 - maxdir 256 - skew 0 - boottrk 2 - os 2.2 -end - -#BEGIN AMP5 Ampro - SSDD 3.5" -#DENSITY MFM, LOW -#CYLINDERS 80 SIDES 1 SECTORS 5,1024 SKEW 2 -#SIDE1 0 1,2,3,4,5 -#BSH 4 BLM 15 EXM 1 DSM 194 DRM 127 AL0 0C0H AL1 0 OFS 2 -#END - -# setfdprm /dev/fd0 SS DD ssize=1024 cyl=80 sect=5 head=1 -diskdef amp5 - seclen 1024 - tracks 80 - sectrk 5 - blocksize 2048 - maxdir 128 - skew 0 - boottrk 2 - os 2.2 -end - -#BEGIN AMP6 Ampro - DSDD 3.5" -#DENSITY MFM, LOW -#CYLINDERS 80 SIDES 2 SECTORS 5,1024 SKEW 2 -#SIDE1 0 17,18,19,20,21 -#SIDE2 1 17,18,19,20,21 -#ORDER SIDES -#BSH 4 BLM 15 EXM 0 DSM 394 DRM 255 AL0 0F0H AL1 0 OFS 2 -#END - -# setfdprm /dev/fd0 DS DD ssize=1024 cyl=80 sect=5 head=2 -diskdef amp6 - seclen 1024 - tracks 160 - sectrk 5 - blocksize 2048 - maxdir 256 - skew 0 - boottrk 2 - os 2.2 -end - -diskdef ampro800 - seclen 1024 - tracks 160 - sectrk 5 - blocksize 2048 - maxdir 256 - skew 0 - boottrk 2 - os 2.2 -end diff --git a/software/dis/SA-5510/SA-5510.asm b/software/dis/SA-5510/SA-5510.asm deleted file mode 100644 index bd04394..0000000 --- a/software/dis/SA-5510/SA-5510.asm +++ /dev/null @@ -1,7511 +0,0 @@ -; Disassembly of the file "SA-5510.bin" -; -; CPU Type: Z80 -; -; Created with dZ80 2.1 -; -; on Saturday, 03 of April 2021 at 12:48 AM -; -PRTC EQU 0FEH -PRTD EQU 0FFH -GETL EQU 00003H -LETNL EQU 00006H -NL EQU 00009H -PRNTS EQU 0000CH -PRNTT EQU 0000FH -PRNT EQU 00012H -MSG EQU 00015H -MSGX EQU 00018H -GETKY EQU 0001BH -BRKEY EQU 0001EH -?WRI EQU 00021H -?WRD EQU 00024H -?RDI EQU 00027H -?RDD EQU 0002AH -?VRFY EQU 0002DH -MELDY EQU 00030H -?TMST EQU 00033H -TIMRD EQU 0003BH -BELL EQU 0003EH -XTEMP EQU 00041H -MSTA EQU 00044H -MSTP EQU 00047H -MONIT EQU 00000H -SS EQU 00089H -ST1 EQU 00095H -HLHEX EQU 00410H -_2HEX EQU 0041FH -?MODE EQU 0074DH -?KEY EQU 008CAH -PRNT3 EQU 0096CH -?ADCN EQU 00BB9H -?DACN EQU 00BCEH -?DSP EQU 00DB5H -?BLNK EQU 00DA6H -?DPCT EQU 00DDCH -PRTHL EQU 003BAH -PRTHX EQU 003C3H -ASC EQU 003DAH -HEX EQU 003F9H -DPCT EQU 00DDCH -DLY12 EQU 00DA7H -DLY12A EQU 00DAAH -?RSTR1 EQU 00EE6H -MOTOR EQU 006A3H -CKSUM EQU 0071AH -GAP EQU 0077AH -WTAPE EQU 00485H -MSTOP EQU 00700H -LINEBUFR EQU 0490DH -ATRB EQU 010F0H -NAME EQU 010F1H -SIZE EQU 01102H -DTADR EQU 01104H -EXADR EQU 01106H -COMNT EQU 01108H -SWPW EQU 01164H -KDATW EQU 0116EH -KANAF EQU 01170H -DSPXY EQU 01171H -MANG EQU 01173H -MANGE EQU 01179H -PBIAS EQU 0117AH -ROLTOP EQU 0117BH -MGPNT EQU 0117CH -PAGETP EQU 0117DH -ROLEND EQU 0117FH -FLASH EQU 0118EH -SFTLK EQU 0118FH -REVFLG EQU 01190H -SPAGE EQU 01191H -FLSDT EQU 01192H -STRGF EQU 01193H -DPRNT EQU 01194H -TMCNT EQU 01195H -SUMDT EQU 01197H -CSMDT EQU 01199H -AMPM EQU 0119BH -TIMFG EQU 0119CH -SWRK EQU 0119DH -TEMPW EQU 0119EH -ONTYO EQU 0119FH -OCTV EQU 011A0H -RATIO EQU 011A1H -BUFER EQU 011A3H -PRGSTART EQU 011FDH - - ORG PRGSTART - -TAPECOPY: JP L41EC - -COLDSTRT: LD HL,048FFH - LD D,0D0H -L1205: INC HL - LD A,H - CP D - JR Z,L1214 ; (+00aH) - LD A,PRTD - LD (HL),A - SUB (HL) - JR NZ,L1214 ; (+004H) - LD (HL),A - CP (HL) - JR Z,L1205 ; (-00fH) -L1214: LD (04908H),HL - LD (0490AH),HL - LD SP,HL - CALL BELL - XOR A - LD D,A - LD E,A - CALL ?TMST - CALL L132C - CALL L1313 - LD DE,TITLEMSG - CALL L1329 - LD DE,COPYRMSG - CALL L1329 - CALL L131E - CALL L1944 - LD BC,0000AH - CALL L184D - CALL L1841 - CALL MSGNL - LD DE,BYTESMSG - CALL MSGX -WARMSTRT: NOP - NOP -WARMSTRTMON:NOP ; Sharp defined BASIC restart location from Monitor. - NOP - NOP - NOP - NOP - NOP - NOP - NOP - LD SP,(0490AH) - LD DE,READYMSG - CALL MSGNL -L1262: LD HL,L12B8 - PUSH HL -L1266: LD HL,0504DH - CALL L19BA - CALL L19BA - CALL NL - LD DE,LINEBUFR - LD A,(L2A83) - OR A - JR Z,L1299 ; (+01eH) - LD HL,(L2A84) - PUSH HL - LD BC,(02A86H) - ADD HL,BC - JR C,L12A6 ; (+020H) - LD (L2A84),HL - POP HL - PUSH DE - CALL STRTONUM - EX DE,HL - LD (HL),020H - INC HL - LD (HL),00DH - EX DE,HL - POP DE - CALL MSGX -L1299: CALL L1338 - LD A,(DE) - CP 01BH - RET NZ - XOR A - LD (L2A83),A - JR L1299 ; (-00dH) - -L12A6: XOR A - LD (L2A83),A - JP SYNTAXERR - - CALL L1266 - LD A,(DE) - CP 00DH - RET Z - LD HL,(0490AH) - LD SP,HL -L12B8: CALL L146A - CALL L14F8 - LD HL,(04A10H) - LD A,L - OR H - JR NZ,L12D4 ; (+00fH) - LD HL,04A12H - LD (05051H),HL - CALL EXECNOTCHR - DB 00DH - DW L1B5F - JP L1262 - -L12D4: CALL L12DA - JP L1262 - -L12DA: CALL L145E - CALL L1459 - CALL L18B0 - RET PE - LD (DE),A - CALL Z,L1302 - LD A,(04A12H) - CP 00DH - RET Z - CALL L18B3 - DI - LD (DE),A - LD (04A0EH),HL - EX DE,HL - LD HL,04A0EH - CALL L18F2 - CALL L18A2 - JR L130C ; (+00aH) - -L1302: CALL L18F2 - EX DE,HL - CALL L1873 - CALL L1762 -L130C: CALL L19C3 - EX DE,HL - JP L18EA - -L1313: LD B,021H -L1315: LD A,0CFH - CALL PRNT - DJNZ L1315 ; (-007H) - JR L132C ; (+00eH) - -L131E: LD B,021H -L1320: LD A,0D7H - CALL PRNT - DJNZ L1320 ; (-007H) - JR L132C ; (+003H) - -L1329: CALL MSGX -L132C: CALL LETNL - JP LETNL - -MSGNL: CALL NL - JP MSGX - -L1338: CALL GETL - LD A,0C9H - CALL ?DPCT - LD A,000H - LD HL,SFTLK - LD (HL),A - RET - -TITLEMSG: DB " BASIC ",0A6H,0B0H,096H,092H,09DH,09EH,09DH,092H,096H,092H,09DH," SA-5510" - DB 00DH -COPYRMSG: DB " C",0B7H,09EH,0BDH,09DH,0A6H,097H,098H,096H," 1981 ",09AH,0BDH," SHARP C",0B7H,09DH,09EH,"." - DB 00DH -READYMSG: DB "R",092H,0A1H,09CH,0BDH - DB 00DH -ERRORMSG: DB "*E",09DH,09DH,0B7H,09DH - DB 00DH -INMSG: DB " ",0A6H,0B0H - DB 00DH -BREAKMSG: DB "*B",09DH,092H,0A1H,0A9H - DB 00DH -BYTESMSG: DB " B",0BDH,096H,092H,0A4H - DB 00DH -ERRCODE: DB 012H - DB 000H -L13A5: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -SYNTAXERR: DB 03EH - DB 001H - DB 001H -OVFLERR: DB 03EH - DB 002H - DB 001H -ILDATERR: DB 03EH - DB 003H - DB 001H -DATMISERR: DB 03EH - DB 004H - DB 001H -STRLENERR: DB 03EH - DB 005H - DB 001H -MEMERR: DB 03EH - DB 006H - DB 001H - DB 03EH - DB 007H - DB 001H -LINELENERR: DB 03EH - DB 008H - DB 001H -GOSUBERR: DB 03EH - DB 00AH - DB 001H -FORNEXTERR: DB 03EH - DB 00BH - DB 001H -FUNCERR: DB 03EH - DB 00CH - DB 001H -NEXTFORERR: DB 03EH - DB 00DH - DB 001H -RETGOSBERR: DB 03EH - DB 00EH - DB 001H -UNDEFFNERR: DB 03EH - DB 00FH - DB 001H -LINEERR: DB 03EH - DB 010H - DB 001H -CONTERR: DB 03EH - DB 011H - DB 001H -BADWRERR: DB 03EH - DB 012H - DB 001H -CMDSTMTERR: DB 03EH - DB 013H - DB 001H -READDATAERR:DB 03EH - DB 018H - DB 001H -OPENERR: DB 03EH - DB 02BH - DB 001H -UNKNWNERR: DB 03EH - DB 03CH - DB 001H -OUTFILEERR: DB 03EH - DB 03FH - DB 001H -PRTNRDYERR: DB 03EH - DB 041H - DB 001H -PRTHWERR: DB 03EH - DB 042H - DB 001H -PRTPAPERERR:DB 03EH - DB 043H - DB 001H -CHKSUMERR: DB 03EH - DB 046H - JR L1403 ; (+009H) - -L13FA: LD IY,L1400 - RET - - NOP -L1400: LD A,(013FFH) -L1403: LD (ERRCODE),A - CALL L1ABF - CALL L1AB8 - JR Z,L142A ; (+01cH) - LD HL,05056H - LD A,(HL) - CP 001H - JR NZ,L1421 ; (+00bH) - INC (HL) - LD HL,(0490AH) - LD SP,HL - LD HL,(05057H) - JP L1EAA - -L1421: CALL L1991 - CALL L1978 - CALL L199E -L142A: LD DE,ERRORMSG - CALL MSGNL - LD HL,(ERRCODE) - CALL L1453 - JR L143E ; (+006H) - -L1438: LD DE,BREAKMSG - CALL MSGNL -L143E: LD BC,WARMSTRT - PUSH BC - XOR A - LD (L2A83),A - CALL BELL - CALL L1AB8 - RET Z - LD DE,INMSG - CALL MSGX -L1453: CALL L1841 - JP MSGX - -L1459: XOR A - LD (L1463),A - RET - -L145E: XOR A - LD (05059H),A - RET - -L1463: NOP -L1464: SBC A,C - LD H,D - RET Z - RRCA - SUB B - LD H,D -L146A: LD HL,LINEBUFR - CALL L17F6 - LD (04A10H),DE - LD DE,04A12H - LD C,000H -L1479: CALL L1561 - RET Z - OR A - JP M,SYNTAXERR - DEC DE - PUSH HL - LD HL,L1479 - EX (SP),HL - CP 03FH - LD B,088H - JR Z,L1498 ; (+00bH) - DEC HL - PUSH DE - LD DE,CMDWORDTBL - CALL L14C7 - JR NZ,L14A8 ; (+011H) - POP DE -L1498: LD A,080H - CALL L14B3 - CP 084H - RET NC -L14A0: CALL L1595 - CP 03AH - RET Z - POP AF - RET - -L14A8: LD DE,UNUSEDTBL1 - CALL L14C7 - JR NZ,L14B9 ; (+009H) - POP DE - LD A,081H -L14B3: LD (DE),A - INC DE -L14B5: LD A,B - LD (DE),A - INC DE - RET - -L14B9: LD DE,OPERATORTBL - LD B,083H - CALL L14C9 - POP DE - JR Z,L14B5 ; (-00fH) - INC HL - INC DE - RET - -L14C7: LD B,080H -L14C9: PUSH HL -L14CA: CALL SKIPSPACE - OR A - JP M,L14F1 - EX DE,HL - CALL SKIPSPACE - EX DE,HL - SUB (HL) - INC HL - INC DE - JR Z,L14CA ; (-011H) - ADD A,080H - JR NZ,L14E2 ; (+003H) - INC SP - INC SP - RET - -L14E2: POP HL - DEC DE -L14E4: LD A,(DE) - INC DE - OR A - JR Z,L14EF ; (+006H) - JP P,L14E4 - INC B - JR L14C9 ; (-026H) - -L14EF: DEC A - RET - -L14F1: POP HL - CALL SKIPSPACE - DEC A - LD A,(HL) - RET - -L14F8: LD HL,(04A10H) - LD DE,LINEBUFR - LD C,0B2H - CALL L17FE - LD A,020H - LD (DE),A - INC DE - LD HL,04A12H -L150A: CALL L1561 - RET Z - SUB 080H - JR C,L150A ; (-008H) - DEC DE - DEC C - CP 003H - JR C,L1525 ; (+00dH) - SUB 002H - LD B,A - PUSH HL - LD HL,OPERATORTBL -L151F: CALL L1554 - POP HL - JR L150A ; (-01bH) - -L1525: EX AF,AF' - LD A,(HL) - INC HL - SUB 07FH - LD B,A - PUSH HL - EX AF,AF' - OR A - JR Z,L153D ; (+00dH) - LD HL,L151F - PUSH HL - LD HL,UNUSEDTBL1 - DEC A - RET Z - LD HL,UNUSEDTBL2 - RET - -L153D: PUSH BC - LD HL,CMDWORDTBL - CALL L1554 - POP AF - LD HL,L150A - EX (SP),HL - CP 004H - RET NC - JP L14A0 - -L154F: BIT 7,(HL) - INC HL - JR Z,L154F ; (-005H) -L1554: DJNZ L154F ; (-007H) -L1556: CALL L158A - ADD A,080H - JR NC,L1556 ; (-007H) - DEC DE - LD (DE),A - INC DE - RET - -L1561: CALL L158A - RET Z - CALL L1575 - JR Z,L1561 ; (-009H) - CP 022H - RET NZ - CALL L1581 - CP 00DH - JR NZ,L1561 ; (-013H) - RET - -L1575: CP 020H - RET Z - CP PRTD - RET Z - CP 028H - RET Z - CP 029H - RET - -L1581: CALL L158A - RET Z - CP 022H - JR NZ,L1581 ; (-008H) - RET - -L158A: LD A,(HL) - LD (DE),A - INC HL - INC DE - INC C - JP Z,LINELENERR - CP 00DH - RET - -L1595: CALL L158A - RET Z - CP 03AH - RET Z - CP 022H - JR NZ,L1595 ; (-00bH) - CALL L1581 - CP 00DH - JR NZ,L1595 ; (-012H) - RET - -CMDWORDTBL: DB "RE" - DB 0CDH - DB "DAT" - DB 0C1H - DB 0FFH - DB 0FFH - DB "REA" - DB 0C4H - DB "LIS" - DB 0D4H - DB "RU" - DB 0CEH - DB "NE" - DB 0D7H - DB "PRIN" - DB 0D4H - DB "LE" - DB 0D4H - DB "FO" - DB 0D2H - DB "I" - DB 0C6H - DB "THE" - DB 0CEH - DB "GOT" - DB 0CFH - DB "GOSU" - DB 0C2H - DB "RETUR" - DB 0CEH - DB "NEX" - DB 0D4H - DB "STO" - DB 0D0H - DB "EN" - DB 0C4H - DB 0FFH - DB "O" - DB 0CEH - DB "LOA" - DB 0C4H - DB "SAV" - DB 0C5H - DB "VERIF" - DB 0D9H - DB "POK" - DB 0C5H - DB "DI" - DB 0CDH - DB "DEF F" - DB 0CEH - DB "INPU" - DB 0D4H - DB "RESTOR" - DB 0C5H - DB "CL" - DB 0D2H - DB "MUSI" - DB 0C3H - DB "TEMP" - DB 0CFH - DB "USR" - DB 0A8H - DB "WOPE" - DB 0CEH - DB "ROPE" - DB 0CEH - DB "CLOS" - DB 0C5H - DB "MO" - DB 0CEH - DB "LIMI" - DB 0D4H - DB "CON" - DB 0D4H - DB "GE" - DB 0D4H - DB "INP" - DB 0C0H - DB "OUT" - DB 0C0H - DB "CURSO" - DB 0D2H - DB "SE" - DB 0D4H - DB "RESE" - DB 0D4H - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB "AUT" - DB 0CFH - DB 0FFH - DB 0FFH - DB "COPY/" - DB 0D0H - DB "PAGE/" - DB 0D0H - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 000H -UNUSEDTBL1: DB 0FFH - DB 000H -UNUSEDTBL2: DB 0FFH - DB 000H -OPERATORTBL:DB ">" - DB 0BCH - DB "<" - DB 0BEH - DB "=" - DB 0BCH - DB "<" - DB 0BDH - DB "=" - DB 0BEH - DB ">" - DB 0BDH - DB 0FFH - DB 0BEH - DB 0BCH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB 0FFH - DB "T" - DB 0CFH - DB "STE" - DB 0D0H - DB "LEFT$" - DB 0A8H - DB "RIGHT$" - DB 0A8H - DB "MID$" - DB 0A8H - DB "LEN" - DB 0A8H - DB "CHR$" - DB 0A8H - DB "STR$" - DB 0A8H - DB "ASC" - DB 0A8H - DB "VAL" - DB 0A8H - DB "PEEK" - DB 0A8H - DB "TAB" - DB 0A8H - DB "SPACE$" - DB 0A8H - DB "SIZ" - DB 0C5H - DB 0FFH,0FFH - DB 0FFH - DB "STRING" - DB 024H - DB 0A8H - DB 0FFH - DB "CHARACTER$" - DB 0A8H - DB "CS" - DB 0D2H - DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH - DB 0FFH - DB "RND" - DB 0A8H - DB "SIN" - DB 0A8H - DB "COS" - DB 0A8H - DB "TAN" - DB 0A8H - DB "ATN" - DB 0A8H - DB "EXP" - DB 0A8H - DB "INT" - DB 0A8H - DB "LOG" - DB 0A8H - DB "LN" - DB 0A8H - DB "ABS" - DB 0A8H - DB "SGN" - DB 0A8H - DB "SQR" - DB 0A8H - DB 0FFH,000H -L173A: LD HL,(05051H) - DEC HL -INCSKIPSPCE:INC HL -SKIPSPACE: LD A,(HL) - CP 020H - RET NZ - JR INCSKIPSPCE ; (-007H) - -L1745: PUSH AF - LD A,00DH -L1748: CP (HL) - INC HL - JR NZ,L1748 ; (-004H) - POP AF - RET - -L174E: INC HL -L174F: CALL L193B - RET Z - CP 022H - JR NZ,L174E ; (-009H) -L1757: INC HL - LD A,(HL) - CP 00DH - RET Z - CP 022H - JR NZ,L1757 ; (-009H) - JR L174E ; (-014H) - -L1762: LD A,C - CPL - LD C,A - LD A,B - CPL - LD B,A - INC BC - RET - -L176A: CALL SKIPSPACE - SUB 030H - CP 00AH - LD A,(HL) - RET - -L1773: LD A,H - SUB D - RET NZ - LD A,L - SUB E - RET - -L1779: POP HL ; Get address after call and jump to it via a RET command. -L177A: EX (SP),HL -EXECHL: PUSH AF - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - POP AF - EX (SP),HL - RET - -L1783: POP HL -L1784: EX (SP),HL - INC HL - INC HL - EX (SP),HL - RET - -L1789: LD HL,(04E94H) - INC HL - INC HL - INC HL - INC HL - INC HL - RET - -L1792: LD HL,(05051H) -EXECNOTCHR: CALL SKIPSPACE ; Scan for character after command - EX (SP),HL - CP (HL) - INC HL - JR NZ,EXECHL ; (-022H) - INC HL - JR L17AB ; (+00bH) - -L17A0: LD HL,(05051H) -MATCHCHR: CALL SKIPSPACE - EX (SP),HL - CP (HL) - JP NZ,SYNTAXERR -L17AB: INC HL - EX (SP),HL - JR INCSKIPSPCE ; (-071H) - -L17AF: XOR A - CP H - JR Z,L17B7 ; (+004H) - EX DE,HL - CP H - JR NZ,L177A ; (-03dH) -L17B7: LD A,L - LD L,H -L17B9: OR A - JR Z,L17CC ; (+010H) - RRA - JR NC,L17C2 ; (+003H) - ADD HL,DE - JR C,L177A ; (-048H) -L17C2: OR A - JR Z,L17CC ; (+007H) - EX DE,HL - ADD HL,HL - EX DE,HL - JR NC,L17B9 ; (-011H) - JR L177A ; (-052H) - -L17CC: EX DE,HL - JR L1784 ; (-04bH) - -L17CF: CALL L17AF - OR C - INC DE - RET - -L17D5: LD DE,MONIT - LD B,D -L17D9: CALL L176A - JR NC,L1784 ; (-05aH) - AND 00FH - LD C,A - XOR A - PUSH HL - LD L,E - LD H,D - ADD HL,HL - RRA - ADD HL,HL - RRA - ADD HL,DE - RRA - ADD HL,HL - RRA - ADD HL,BC - EX DE,HL - POP HL - INC HL - ADC A,A - JR NC,L17D9 ; (-01bH) - JR L177A ; (-07cH) - -L17F6: CALL L17D5 - XOR E - INC DE - RET - -STRTONUM: LD C,000H -L17FE: LD A,020H - LD (DE),A - INC DE - PUSH DE - LD B,000H - LD DE,L2710 - CALL L1827 - LD DE,003E8H - CALL L1827 - LD DE,00064H - CALL L1827 - LD DE,0000AH - CALL L1827 - LD A,L - POP HL - OR 030H - LD (HL),A - INC HL - LD (HL),00DH - EX DE,HL - RET - -L1827: LD A,PRTD -L1829: INC A - OR A - SBC HL,DE - JR NC,L1829 ; (-006H) - ADD HL,DE - OR A - JR NZ,L1836 ; (+003H) - OR B - RET Z - XOR A -L1836: INC B - OR 030H - POP DE - EX (SP),HL - LD (HL),A - INC HL - EX (SP),HL - PUSH DE - INC C - RET - -L1841: LD DE,04AB3H - PUSH DE - CALL STRTONUM - POP DE - RET - -L184A: LD BC,MONIT -L184D: LD HL,(04E94H) - ADD HL,BC - JR C,L185C ; (+009H) - EX DE,HL - LD HL,0FF9CH - ADD HL,SP - XOR A - SBC HL,DE - RET NC -L185C: JP MEMERR - -L185F: PUSH HL - PUSH DE - CALL L184D - POP DE - POP HL - RET - -L1867: LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - EX DE,HL - LD A,L - OR H - RET - -L1873: PUSH BC - PUSH HL - PUSH DE - EX DE,HL - ADD HL,BC - EX DE,HL - CALL L1789 - LD A,L - SUB E - LD C,A - LD A,H - SBC A,D - LD B,A - INC BC - POP HL - PUSH HL - EX DE,HL - JR L18A8 ; (+020H) - -L1888: CALL L185F - PUSH BC - PUSH HL - PUSH DE - CALL L1789 - PUSH HL - ADD HL,BC - EX (SP),HL - LD A,L - SUB E - LD C,A - LD A,H - SBC A,D - LD B,A - INC BC - POP DE - LDDR -L189E: POP DE - POP HL - POP BC - RET - -L18A2: CALL L1888 -L18A5: PUSH BC - PUSH HL - PUSH DE -L18A8: LD A,C - OR B - JR Z,L189E ; (-00eH) - LDIR - JR L189E ; (-012H) - -L18B0: LD (L18BF),HL -L18B3: LD HL,0505CH -L18B6: PUSH HL - CALL L1867 - JP Z,L1779 - PUSH HL - DB 021H -L18BF: DB 0AAH - DB 00FH - CALL L1773 - POP HL - JP Z,L1783 - JP C,L1783 - POP AF - JR L18B6 ; (-018H) - -L18CE: PUSH HL - LD E,(HL) - INC HL - LD D,(HL) - LD A,E - OR D - JP Z,L1779 - DB 021H -L18D8: DB 042H - DB 04CH - CALL L1773 - POP HL - INC HL - INC HL - JP L1784 - -L18E3: ADD HL,BC - EX DE,HL - POP HL - LD (HL),E - INC HL - LD (HL),D - EX DE,HL -L18EA: PUSH HL - CALL L1867 - JR NZ,L18E3 ; (-00dH) - POP HL - RET - -L18F2: PUSH HL - LD BC,00004H - ADD HL,BC - CALL L1900 - INC BC - POP HL - RET - -L18FD: LD BC,MONIT -L1900: PUSH HL - LD A,00DH -L1903: CP (HL) - INC HL - INC BC - JR NZ,L1903 ; (-005H) - DEC BC - POP HL - RET - -L190B: CALL L1921 -L190E: LD A,E - EX DE,HL - LD BC,MONIT - LD HL,(04E92H) - DEC HL -L1917: INC HL - ADD HL,BC - CP (HL) - INC HL - LD C,(HL) - INC HL - JR NZ,L1917 ; (-008H) - EX DE,HL - RET - -L1921: LD A,D - OR A - RET NZ - JR L1929 ; (+003H) - -L1926: LD A,D - OR A - RET Z -L1929: JP DATMISERR - -L192C: LD HL,(04E94H) - EX DE,HL -L1930: LD BC,00005H - LDIR - RET - -L1936: LD HL,(04E94H) - JR L1930 ; (-00bH) - -L193B: CALL SKIPSPACE - CP 00DH - RET Z - CP 03AH - RET - -L1944: LD HL,MONIT - LD (04E4CH),HL - CALL L1957 - CALL L199E - CALL L1978 - CALL L1459 - RET - -L1957: LD HL,0505CH - CALL L19BA - LD DE,04E4EH -L1960: PUSH HL - LD HL,04E96H - XOR A - SBC HL,DE - LD B,L - SRL B - POP HL - EX DE,HL -L196C: XOR A - LD (HL),E - INC HL - LD (HL),D - INC HL - LD (DE),A - INC DE - LD (DE),A - INC DE - DJNZ L196C ; (-00bH) - RET - -L1978: LD HL,05040H - LD (04E9AH),HL - LD HL,04FD7H - LD (04E98H),HL - LD HL,04EBAH - LD (04E96H),HL - LD HL,05053H - CALL L19BA - LD (HL),A -L1991: XOR A - LD (05056H),A - RET - -L1996: LD HL,(04E84H) - LD DE,04E84H - JR L1960 ; (-03eH) - -L199E: LD HL,04DF2H - LD B,05AH -L19A3: LD (HL),000H - INC HL - DJNZ L19A3 ; (-005H) - LD B,01AH - LD HL,04E50H -L19AD: LD E,(HL) - INC HL - LD D,(HL) - INC HL - PUSH HL - EX DE,HL - CALL L2E09 - POP HL - DJNZ L19AD ; (-00cH) - RET - -L19BA: XOR A -L19BB: LD (HL),A - INC HL - LD (HL),A - INC HL - RET - -L19C0: CALL L1888 -L19C3: PUSH HL - LD A,E - EX AF,AF' - LD A,D - LD HL,04E94H -L19CA: LD E,(HL) - INC HL - LD D,(HL) - CP D - JR C,L19D7 ; (+007H) - JR NZ,L19E2 ; (+010H) - EX AF,AF' - CP E - JR NC,L19E1 ; (+00bH) - EX AF,AF' -L19D7: EX DE,HL - ADD HL,BC - EX DE,HL - LD (HL),D - DEC HL - LD (HL),E - DEC HL - DEC HL - JR L19CA ; (-017H) - -L19E1: EX AF,AF' -L19E2: LD D,A - EX AF,AF' - LD E,A - POP HL - RET - -L19E7: CALL L1873 - PUSH BC - CALL L1762 - CALL L19C3 - POP BC - RET - -L19F3: CALL SKIPSPACE - LD DE,00D2CH - LD BC,MONIT - CP 022H - JR NZ,L1A02 ; (+002H) - LD E,A - INC HL -L1A02: PUSH HL -L1A03: LD A,(HL) - CP D - JR Z,L1A0F ; (+008H) - CP E - INC HL - JR Z,L1A0F ; (+004H) - INC BC - JR L1A03 ; (-00bH) - -L1A0E: PUSH HL -L1A0F: EX (SP),HL - PUSH HL - CALL L1A1E - EX DE,HL - EX (SP),HL - CALL L18A5 - POP DE - POP HL - JP SKIPSPACE - -L1A1E: PUSH BC - XOR A - LD E,A - LD HL,(04E92H) - JR L1A2B ; (+005H) - -L1A26: INC HL - LD C,(HL) - INC HL - INC HL - ADD HL,BC -L1A2B: INC E - CP (HL) - JR NZ,L1A26 ; (-009H) - POP BC - PUSH BC - INC BC - INC BC - INC BC - EX DE,HL - CALL L1888 - EX DE,HL - PUSH HL - ADD HL,BC - DEC HL - LD (HL),00DH - LD HL,(04E94H) - ADD HL,BC - LD (04E94H),HL - POP HL - POP BC - LD (HL),E - INC HL - LD (HL),C - INC HL - LD D,001H - RET - -L1A4E: PUSH HL - LD HL,(04E94H) - LD DE,MONIT - LD A,(HL) - OR A - JP P,L1779 - CP 0C1H - JR C,L1A72 ; (+014H) - SUB 0D1H - JP NC,L1779 - LD E,003H - ADD HL,DE - LD E,(HL) - INC HL - LD D,(HL) - JR L1A6F ; (+004H) - -L1A6B: SRL D - RR E -L1A6F: INC A - JR NZ,L1A6B ; (-007H) -L1A72: JP L1783 - -L1A75: CALL EXECNOTCHR - DB 00DH - DW L1A7E - JP L177A - -L1A7E: PUSH HL - DEC HL -L1A80: CALL L1A91 - JR Z,L1A80 ; (-005H) - CP 00DH - JP NZ,L1779 - POP HL - CALL L2333 - JP L1784 - -L1A91: CALL INCSKIPSPCE - CP 045H - RET Z -L1A97: CALL L176A - JR NC,L1A9E ; (+002H) - CP (HL) - RET - -L1A9E: CP 02EH - RET Z - CP 02BH - RET Z - CP 02DH - RET - -L1AA7: PUSH HL - CALL L1AB8 - POP HL - RET Z - JR L1AB5 ; (+006H) - -L1AAF: PUSH HL - CALL L1AB8 - POP HL - RET NZ -L1AB5: JP CMDSTMTERR - -L1AB8: LD HL,(0504FH) - LD A,H - OR L - RET - -L1ABE: NOP -L1ABF: LD HL,L1ABE - XOR A - CP (HL) - LD (HL),A - JR NZ,L1AEE ; (+027H) -L1AC7: LD HL,0505CH -L1ACA: LD E,(HL) - INC HL - LD D,(HL) - DEC HL - LD A,E - OR D - RET Z - CALL L1773 - RET C - EX DE,HL - ADD HL,DE - EX DE,HL - LD (HL),E - INC HL - LD (HL),D - EX DE,HL - JR L1ACA ; (-014H) - -L1ADE: LD HL,(04E4EH) - LD DE,0505CH - DEC HL - DEC HL - XOR A - SBC HL,DE - LD B,H - LD C,L - JP L19E7 - -L1AEE: CALL L1ADE -L1AF1: CALL L1996 - CALL L199E - CALL L1978 - RET - - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - PUSH BC - CALL L1AEE - POP BC - LD A,B - OR A - JR NZ,L1B10 ; (+004H) - LD A,C - CP 003H - RET C -L1B10: PUSH BC - DEC BC - DEC BC - LD DE,0505CH - CALL L19C0 - POP BC - RET - -L1B1B: LD HL,0505CH -L1B1E: LD E,(HL) - INC HL - LD D,(HL) - DEC HL - LD A,D - OR E - RET Z - CALL L1773 - RET NC - PUSH DE - EX DE,HL - XOR A - SBC HL,DE - EX DE,HL - LD (HL),E - INC HL - LD (HL),D - POP HL - JR L1B1E ; (-017H) - -L1B35: LD HL,(05051H) -L1B38: CALL SKIPSPACE -L1B3B: CP 00DH - JR Z,L1B45 ; (+006H) - CALL MATCHCHR - DB 03AH - JR L1B5C ; (+017H) - -L1B45: LD HL,(0504DH) - LD A,H - OR L - JP Z,WARMSTRT -L1B4D: LD A,(HL) - INC HL - OR (HL) - DEC HL - JP Z,L1D17 - LD DE,0504DH - LD BC,00004H - LDIR -L1B5C: LD (05051H),HL -L1B5F: LD A,(05056H) - DEC A - CALL Z,L1B9F - CALL BRKEY - JR NZ,L1B73 ; (+008H) - LD A,002H - CALL L29EB - JP L1438 - -L1B73: LD HL,(04E92H) - CALL L19BA - LD (04E94H),HL - CALL L173A -L1B7F: SUB 080H - JP C,CMDLET - INC HL - LD C,(HL) - INC HL - PUSH HL - LD HL,CMDJMPTBL - JP NZ,SYNTAXERR - LD A,C - ADD A,080H - JP NC,SYNTAXERR - LD C,A -L1B95: LD B,000H - ADD HL,BC - ADD HL,BC - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - EX (SP),HL - RET - -L1B9F: CALL L1AB8 - RET Z - LD DE,L13A5 - LD HL,0504DH - JR NZ,L1BAC ; (+001H) - EX DE,HL -L1BAC: LD BC,LETNL - LDIR - RET - -CMDJMPTBL: DW CMDREMDATA - DW CMDREMDATA - DW SYNTAXERR - DW SYNTAXERR - DW CMDREAD - DW CMDLIST - DW CMDRUN - DW CMDNEW - DW CMDPRINT - DW CMDLET - DW CMDFOR - DW CMDIF - DW SYNTAXERR - DW CMDGOTO - DW CMDGOSUB - DW CMDRETURN - DW CMDNEXT - DW CMDSTOP - DW CMDEND - DW SYNTAXERR - DW CMDON - DW CMDLOAD - DW CMDSAVE - DW CMDVERIFY - DW CMDPOKE - DW CMDDIM - DW CMDDEFFN - DW CMDINPUT - DW CMDRESTORE - DW CMDCLS - DW CMDMUSIC - DW CMDTEMPO - DW CMDUSRN - DW CMDWOPEN - DW CMDROPEN - DW CMDCLOSE - DW CMDMON - DW CMDLIMIT - DW CMDCONT - DW CMDGET - DW CMDINP - DW CMDOUT - DW CMDCURSOR - DW CMDSET - DW CMDRESET - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW CMDAUTO - DW SYNTAXERR - DW SYNTAXERR - DW CMDCOPY - DW CMDPAGE - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR -L1C32: CALL L193B - JP NZ,SYNTAXERR - LD (05051H),HL - RET - -CMDREMDATA: CALL L174F - JP L1B38 - -CMDNEW: XOR A - LD (L1463),A - CALL L1944 -L1C49: JP WARMSTRT - -L1C4C: DB 006H -CMDLIST: XOR A - LD (L1CAB),A - CALL EXECNOTCHR - DB 02FH - DW L1C60 - CALL MATCHCHR - DB 050H - LD A,001H - LD (L1CAB),A -L1C60: CALL L1AA7 - DB 03EH - LD A,(BC) - LD (L1C4C),A - PUSH HL - LD HL,04AB3H - CALL L19BA - DEC A - CALL L19BB - POP HL - CALL L193B - CALL NZ,L1CF3 - LD (05051H),HL - LD HL,0505CH -L1C80: PUSH HL - CALL L1867 - POP HL -L1C85: JR Z,L1C49 ; (-03eH) - CALL L18F2 - LD DE,04A0EH - LDIR - LD HL,(04AB3H) - EX DE,HL - LD HL,(04A10H) - CALL L1773 - JR C,L1CDF ; (+044H) - EX DE,HL - LD HL,(04AB5H) - CALL L1773 - JR C,L1CDF ; (+03bH) - CALL L14F8 - LD DE,LINEBUFR - DB 03EH -L1CAB: DB 000H - OR A - JR Z,L1CBA ; (+00bH) - CALL L31A2 - CALL L3246 - CALL L31A7 - JR L1CC7 ; (+00dH) - -L1CBA: CALL MSGNL - LD A,(L1C4C) - DEC A - LD (L1C4C),A - CALL Z,L1CE4 -L1CC7: CALL BRKEY - JR Z,L1C85 ; (-047H) -L1CCC: CALL GETKY - CP 020H - JR Z,L1CCC ; (-007H) - CP 03FH - JR NZ,L1CDF ; (+008H) - LD BC,L2000 -L1CDA: DEC BC - LD A,B - OR C - JR NZ,L1CDA ; (-005H) -L1CDF: LD HL,(04A0EH) - JR L1C80 ; (-064H) - -L1CE4: INC A - LD (L1C4C),A - PUSH BC - LD BC,00001H -L1CEC: DEC BC - LD A,B - OR C - JR NZ,L1CEC ; (-005H) - POP BC - RET - -L1CF3: CALL L17F6 - LD (04AB3H),DE - CALL L193B - JR Z,L1D0A ; (+00bH) - CALL MATCHCHR - DB 02DH - CALL L193B - RET Z - CALL L17F6 -L1D0A: LD (04AB5H),DE - CALL L193B - RET Z - JP SYNTAXERR - -CMDEND: DB 0AFH - DB 001H -L1D17: LD A,001H - EX AF,AF' - CALL L1AAF - EX AF,AF' - OR A - CALL Z,L1D24 - JR L1D41 ; (+01dH) - -L1D24: CALL L1C32 - LD A,001H - JP L29EB - -CMDSTOP: CALL L1AAF - CALL L1D24 - LD HL,(0504FH) - LD DE,L1D44 - CALL MSGX - CALL L1841 - CALL MSGX -L1D41: JP WARMSTRT - -L1D44: DB "*S",096H,0B7H,09EH," ",0A6H,0B0H,00DH -CMDRESTORE: CALL L17F6 - CALL L1C32 - LD BC,L1B35 - PUSH BC - LD A,D - OR E - JP Z,L145E - LD BC,L2D46 - PUSH BC -L1D60: EX DE,HL -L1D61: CALL L18B0 - PUSH DE - INC DE - RET Z - JP LINEERR - -CMDLET: PUSH HL -L1D6B: CALL L193B - JP Z,SYNTAXERR - CP 03DH - INC HL - JR NZ,L1D6B ; (-00bH) - CALL L2293 - LD (05051H),HL - CALL L1D95 - POP HL - CALL L267F - CALL L24B2 - CALL MATCHCHR - DB 03DH - CALL L1D9A - CALL L1DA5 - DW DATMISERR - JP L1B35 - -L1D95: LD HL,04900H - JR L1D9D ; (+003H) - -L1D9A: LD HL,04904H -L1D9D: LD (HL),C - INC HL - LD (HL),B - INC HL - LD (HL),E - INC HL - LD (HL),D - RET - -L1DA5: LD HL,04903H - LD B,(HL) - INC HL - LD C,(HL) - INC HL - LD A,(HL) - LD DE,(04906H) - OR A - JR NZ,L1DBD ; (+009H) - OR B - JP NZ,L177A - CALL L1936 - JR L1DF2 ; (+035H) - -L1DBD: XOR A - OR B - JP Z,L177A - LD HL,L1DF5 - XOR A - LD B,A - SBC HL,DE - JR Z,L1DFE ; (+033H) - LD HL,(04900H) - XOR A - SBC HL,BC - LD B,H - LD C,L - JR C,L1DDA ; (+005H) - CALL L1888 - JR L1DE2 ; (+008H) - -L1DDA: PUSH BC - CALL L1762 - CALL L1873 - POP BC -L1DE2: CALL L19C3 - LD HL,(04902H) - EX DE,HL - CALL L190E - EX DE,HL - DEC DE - DEC HL - INC BC - LDIR -L1DF2: JP L1784 - -L1DF5: JR NC,L1E27 ; (+030H) - DEC C - JR NC,L1E2A ; (+030H) - DEC C - JR NC,L1E2D ; (+030H) - DEC C -L1DFE: LD HL,(04902H) - EX DE,HL - CALL L190B - EX DE,HL - LD DE,L1DF5 - PUSH DE - LD B,003H -L1E0C: LD C,002H -L1E0E: CALL L176A - JR NC,L1E5D ; (+04aH) - LD (DE),A - INC DE - INC HL - DEC C - JR NZ,L1E0E ; (-00bH) - LD A,00DH - LD (DE),A - INC DE - DEC B - JR NZ,L1E0C ; (-014H) - CALL EXECNOTCHR - DB 00DH - DW ILDATERR - POP HL -L1E27: CALL L1E69 -L1E2A: LD B,000H - LD A,E -L1E2D: CP 018H - JR NC,L1E5D ; (+02cH) - SUB 00CH - JR C,L1E37 ; (+002H) - LD E,A - INC B -L1E37: LD A,B - PUSH AF - PUSH HL - LD HL,00E10H - CALL L17CF - POP HL - PUSH DE - INC HL - CALL L1E69 - LD A,E - CP 03CH - JR NC,L1E5D ; (+012H) - PUSH HL - LD HL,0003CH - CALL L17CF - POP HL - EX (SP),HL - ADD HL,DE - EX (SP),HL - INC HL - CALL L1E69 - LD A,E - CP 03CH -L1E5D: JR NC,L1E8E ; (+02fH) - POP HL - ADD HL,DE - EX DE,HL - POP AF - CALL ?TMST - JP L1784 - -L1E69: EXX - LD BC,00005H - CALL L1E7F - CALL L2333 - CALL L1926 - CALL L1A4E - OR C - INC DE - EXX - LD BC,0FFFBH -L1E7F: LD HL,(04E94H) - ADD HL,BC - LD (04E94H),HL - EXX - RET - -GETNUM: CALL L1E69 - LD A,D - OR A - RET Z -L1E8E: JP ILDATERR - -CMDRUN: XOR A - LD (L2A83),A - LD (L30E2),A - CALL L2E94 - CALL L145E - CALL L1459 - CALL L176A - JR NC,L1EAF ; (+009H) -CMDGOTO: CALL L17F6 -L1EA9: EX DE,HL -L1EAA: CALL L1D61 - JR L1EC4 ; (+015H) - -L1EAF: CALL L193B - JP NZ,SYNTAXERR - CALL L1991 - CALL L1978 - CALL L1996 - CALL L199E - LD HL,0505CH -L1EC4: JP L1B4D - -CMDGOSUB: CALL L1AAF - CALL L17F6 -L1ECD: CALL L1C32 - CALL L1D60 - EXX - LD HL,05055H - LD A,(HL) - CP 00FH - JP Z,GOSUBERR - INC (HL) - DEC HL - DEC HL - LD DE,(04E9AH) - DEC DE - LD BC,00007H - LDDR - INC DE - LD (04E9AH),DE - LD C,007H - ADD HL,BC - LD (HL),000H - EXX - JP L1B4D - -CMDRETURN: CALL L1AAF - LD HL,05055H - XOR A - CP (HL) - JP Z,RETGOSBERR - DEC (HL) -L1F04: LD HL,05053H - LD A,(HL) - OR A - JR Z,L1F1A ; (+00fH) - DEC (HL) - INC HL - DEC (HL) - LD HL,(04E98H) - LD BC,00013H - ADD HL,BC - LD (04E98H),HL - JR L1F04 ; (-016H) - -L1F1A: LD HL,(04E9AH) - LD DE,0504DH - LD BC,00007H - LDIR - LD (04E9AH),HL - JP L1B35 - -CMDFOR: CALL L267F - CALL MATCHCHR - DB 03DH - PUSH DE - CALL L1FB7 - POP HL - LD (05040H),HL - EX DE,HL - CALL L24BD - CALL L1936 - CALL L17A0 - SBC A,(HL) - CALL L1FB7 - LD DE,05048H - CALL L1936 - CALL L1792 - SBC A,A - LD E,H - RRA - CALL L1FB7 - LD HL,(04E94H) - JR L1F5F ; (+003H) - - LD HL,L2A88 -L1F5F: LD DE,05042H - LD A,(HL) - LD (05047H),A - LD BC,00005H - LDIR - LD HL,(04E98H) - LD DE,(05040H) - LD A,(05053H) - INC A -L1F76: DEC A - JR Z,L1F98 ; (+01fH) - EX AF,AF' - LD A,(HL) - SUB E - LD B,A - INC HL - LD A,(HL) - SUB D - OR B - LD BC,PRNT - ADD HL,BC - JR Z,L1F8A ; (+003H) - EX AF,AF' - JR L1F76 ; (-014H) - -L1F8A: LD (04E98H),HL - EX AF,AF' - DEC A - LD HL,05053H - LD B,(HL) - LD (HL),A - SUB B - INC HL - ADD A,(HL) - LD (HL),A -L1F98: LD HL,05054H - LD A,(HL) - CP 00FH - JP Z,FORNEXTERR - INC (HL) - DEC HL - INC (HL) - DEC HL - LD DE,(04E98H) - LD BC,00013H - DEC DE - LDDR - INC DE - EX DE,HL - LD (04E98H),HL - JP L1B35 - -L1FB7: CALL L2333 - LD (05051H),HL - JP L1926 - -CMDNEXT: LD A,(05053H) - OR A -L1FC4: JP Z,NEXTFORERR - CALL L2640 - LD (05051H),HL - LD HL,(04E98H) - CALL NC,L2039 -L1FD3: LD A,E - SUB (HL) - INC HL - LD B,A - LD A,D - SUB (HL) - OR B - JR Z,L1FF1 ; (+015H) - EXX - LD HL,05053H - LD A,(HL) - DEC A - JR Z,L1FC4 ; (-020H) - LD (HL),A - INC HL - DEC (HL) - EXX - LD BC,PRNT - ADD HL,BC - LD (04E98H),HL - JR L1FD3 ; (-01eH) - -L1FF1: INC HL - CALL L24BD - PUSH DE - PUSH HL - CALL L3405 - POP HL - POP DE - LD BC,00005H - ADD HL,BC -L2000: LD A,(HL) - INC HL - PUSH HL - OR A - JP P,L201B - EX DE,HL - CALL L3A66 - POP HL - LD BC,00005H - JR C,L2025 ; (+014H) -L2011: ADD HL,BC - LD DE,0504DH - INC C - LDIR - JP L1B35 - -L201B: CALL L3A66 - POP HL - LD BC,00005H - CCF - JR C,L2011 ; (-014H) -L2025: LD C,00BH - ADD HL,BC - LD (04E98H),HL - LD HL,05053H - DEC (HL) - INC HL - DEC (HL) - CALL L1792 - INC L - DEC (HL) - DEC DE - JR CMDNEXT ; (-079H) - -L2039: LD E,(HL) - INC HL - LD D,(HL) - DEC HL - RET - -CMDON: CALL L1AAF - CALL L2333 - CALL L1926 - CALL L1A4E - DB 04CH - DB 020H - CALL MATCHCHR - DB 080H - SUB 08DH - CP 002H - JP NC,SYNTAXERR - EX AF,AF' - INC HL - LD A,E - OR A - JR Z,L2061 ; (+004H) - LD A,D - OR A - JR Z,L206F ; (+00eH) -L2061: JP CMDREMDATA - -L2064: CALL L193B - JP Z,L1B3B - CP 02CH - INC HL - JR NZ,L2064 ; (-00bH) -L206F: DEC E - JR NZ,L2064 ; (-00eH) - CALL L17F6 - CALL L174F - EX AF,AF' - OR A - JP NZ,L1ECD - JP L1EA9 - -CMDDIM: CALL L267F - LD BC,MONIT - CP 024H - JR NZ,L208C ; (+002H) - INC HL - INC B -L208C: CALL MATCHCHR - DB 028H - CALL L2107 - JR NZ,L20E5 ; (+050H) - PUSH HL - LD HL,(L2105) - LD E,H - LD D,A - LD H,A - INC HL - INC DE - CALL L17AF - CP D - INC DE - LD A,(L2104) - OR A - POP HL - PUSH DE - PUSH HL - LD HL,00002H - JR NZ,L20B1 ; (+002H) - LD L,005H -L20B1: CALL L17AF - CP D - INC DE - LD HL,00004H - ADD HL,DE - JP C,MEMERR - LD B,H - LD C,L - POP DE - CALL L19C0 - LD HL,(L18D8) - EX DE,HL - LD (HL),E - INC HL - LD (HL),D - INC HL - LD DE,(02105H) - LD (HL),E - INC HL - LD (HL),D - INC HL - POP BC - LD A,(L2104) - OR A - JR Z,L20F0 ; (+016H) -L20DA: LD (HL),000H - INC HL - LD (HL),00DH - INC HL - DEC BC - LD A,B - OR C - JR NZ,L20DA ; (-00bH) -L20E5: LD HL,(L2102) - CALL EXECNOTCHR - DB 02CH - DW L1B38 - JR CMDDIM ; (-070H) - -L20F0: EX DE,HL -L20F1: PUSH BC - LD HL,L2A8D - LD BC,00005H - LDIR - POP BC - DEC BC - LD A,B - OR C - JR NZ,L20F1 ; (-00fH) - JR L20E5 ; (-01dH) - -L2102: XOR (HL) - LD H,C -L2104: DB 001H -L2105: DB 00BH - DB 001H -L2107: PUSH DE - PUSH BC - CALL GETNUM - POP BC - LD A,(HL) - CP 02CH - CALL Z,L2185 - CALL MATCHCHR - DB 029H - LD (L2102),HL - POP HL - LD (L18D8),HL - EX DE,HL - LD (L2105),HL - LD A,B - LD (L2104),A - LD HL,04E86H - LD DE,LETNL - OR A - JR Z,L2130 ; (+001H) - ADD HL,DE -L2130: LD A,C - LD E,002H - OR A - JR NZ,L2137 ; (+001H) - ADD HL,DE -L2137: LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL -L213B: CALL L18CE - LD L,(HL) - LD HL,L2E28 - LD E,(HL) - INC HL - PUSH HL - LD L,(HL) - LD D,000H - LD H,D - INC HL - INC DE - CALL L17CF - LD A,(L2104) - OR A - JR NZ,L215F ; (+00bH) - LD HL,00005H - CALL L17CF - POP HL - ADD HL,DE - INC HL - JR L213B ; (-024H) - -L215F: POP HL - INC HL - LD B,000H -L2163: LD C,(HL) - INC HL - INC HL - ADD HL,BC - DEC DE - LD A,D - OR E - JR NZ,L2163 ; (-009H) - JR L213B ; (-033H) - - XOR A - RET - - LD C,(HL) - INC HL - LD B,(HL) - INC HL - LD DE,(02105H) - LD A,B - CP D - JR C,L217E ; (+002H) - LD A,C - CP E -L217E: JP C,ILDATERR - LD A,001H - OR A - RET - -L2185: INC C - PUSH BC - PUSH DE - INC HL - CALL GETNUM - LD A,E - POP DE - LD D,A - POP BC - RET - -CMDPOKE: CALL L299F - CALL L2E94 - PUSH DE - CALL L299F - LD A,D - OR A - JP NZ,ILDATERR - EX (SP),HL - LD (HL),E - POP HL -L21A3: JP L1B38 - -CMDCLS: PUSH HL - CALL L1AF1 - POP HL - JR L21A3 ; (-00aH) - -CMDIF: CALL L1AAF - CALL EXECNOTCHR - DB 0AEH - DW L21D3 - CALL L2DBA - JP Z,SYNTAXERR - LD B,A - CALL L2712 - PUSH HL - LD A,B - CALL L2DC1 - RST 038H - RST 038H - LD BC,00008H - ADD HL,BC - LD A,(HL) - POP HL - OR A - JR NZ,L21E3 ; (+013H) -L21D0: JP L1B45 - -L21D3: CALL L2293 - CALL L1926 - LD IX,(04E94H) - BIT 7,(IX+004H) - JR Z,L21D0 ; (-013H) -L21E3: CALL MATCHCHR - ADD A,B - SUB 08CH - INC HL - CP 002H - JP Z,CMDGOSUB -L21EF: JP NC,SYNTAXERR - OR A - CALL Z,L21F9 - JP CMDGOTO - -L21F9: CALL L176A - RET C - POP BC - JP L1B7F - -CMDDEFFN: CALL SKIPSPACE - SUB 041H - CP 01AH - JR NC,L21EF ; (-01bH) - LD E,(HL) - INC HL - CALL MATCHCHR - DB 028H - SUB 041H - CP 01AH - JR NC,L21EF ; (-027H) - LD D,(HL) - INC HL - CALL MATCHCHR - DB 029H - CALL MATCHCHR - DB 03DH - PUSH HL - CALL L174F - POP BC - PUSH HL - XOR A - SBC HL,BC - PUSH BC - PUSH HL - LD HL,(04E84H) -L222E: LD A,(HL) - CP E - JR Z,L224D ; (+01bH) - OR A - JR Z,L223C ; (+007H) - INC HL - INC HL - CALL L1745 - JR L222E ; (-00eH) - -L223C: EX DE,HL - LD BC,GETL - CALL L19C0 - EX DE,HL - LD (HL),E - INC HL - LD (HL),D - INC HL - LD (HL),00DH - EX DE,HL - JR L225D ; (+010H) - -L224D: INC HL - LD (HL),D - INC HL - PUSH HL - CALL L174F - POP DE - XOR A - SBC HL,DE - LD B,H - LD C,L - CALL L19E7 -L225D: POP BC - POP HL - CALL L18A2 - CALL L19C3 - POP HL -L2266: JP L1B38 - -CMDMUSIC: CALL L193B - JR Z,L2266 ; (-008H) - CALL L2333 - CALL L193B - JR Z,L2277 ; (+001H) - INC HL -L2277: CALL L190B - CALL MELDY - JP C,L1438 - JR CMDMUSIC ; (-019H) - -CMDTEMPO: CALL GETNUM - LD A,E - DEC A - CP 007H - JP NC,ILDATERR - INC A - CALL XTEMP - JR L2266 ; (-02cH) - -L2292: INC HL -L2293: CALL L2333 -L2296: CP 03DH - JR NZ,L229C ; (+002H) - LD A,089H -L229C: CP 083H - RET C - CP 090H - RET NC - SUB 083H - EX AF,AF' - LD A,D - OR A - JR NZ,L22B4 ; (+00bH) - EX AF,AF' - EXX - LD BC,L2296 - LD DE,L2332 - JP L23BB - -L22B4: EX AF,AF' - PUSH DE - PUSH AF - CALL L2332 - POP AF - EX AF,AF' - EX (SP),HL - CALL L190B - LD A,C - PUSH AF - EX DE,HL - CALL L190B - POP AF - LD B,A - CALL L2305 - LD HL,L22F3 - PUSH HL - LD HL,L22E1 - EX AF,AF' - LD C,A - LD B,000H - ADD HL,BC - ADD HL,BC - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - EX AF,AF' - OR A - LD A,001H - JP (HL) - -L22E1: DW L231B - DW L231B - DW L231E - DW L231E - DW L2322 - DW L2322 - DW L2325 - DW L2328 - DW L232F -L22F3: LD DE,L2A92 - OR A - JR NZ,L22FC ; (+003H) - LD DE,L2A8D -L22FC: CALL L192C - POP HL - CALL L23FA - JR L2296 ; (-06fH) - -L2305: LD A,B - OR C - RET Z - LD A,C - CP B - JR NZ,L2315 ; (+009H) -L230C: LD A,(DE) - SUB (HL) - JR NZ,L2315 ; (+005H) - INC HL - INC DE - DJNZ L230C ; (-008H) - RET - -L2315: LD A,001H - DB 0D0H - LD A,080H - RET - -L231B: RET NZ - XOR A - RET - -L231E: RET Z - RET M - XOR A - RET - -L2322: RET P - XOR A - RET - -L2325: RET Z - XOR A - RET - -L2328: LD A,000H - RET Z - RET M - LD A,001H - RET - -L232F: RET M - XOR A - RET - -L2332: INC HL -L2333: LD A,(HL) - CP 020H - JR Z,L2332 ; (-006H) - CP 02BH - JR Z,L2348 ; (+00cH) - CP 02DH - JR NZ,L2349 ; (+009H) - CALL L2392 - CALL L2410 - JR L234C ; (+004H) - -L2348: INC HL -L2349: CALL L2393 -L234C: CP 02BH - JR Z,L2356 ; (+006H) - CP 02DH - RET NZ - LD A,00DH - DB 001H -L2356: LD A,00CH - EX AF,AF' - LD A,D - OR A - JR NZ,L2367 ; (+00aH) - EX AF,AF' - EXX - LD BC,L234C - LD DE,L2392 - JR L23BB ; (+054H) - -L2367: EX AF,AF' - CP 00CH - JP NZ,SYNTAXERR - PUSH DE - CALL L2392 - EX (SP),HL - PUSH DE - CALL L190B - LD A,C - PUSH AF - EX DE,HL - CALL L190B - POP AF - ADD A,C - JP C,STRLENERR - PUSH AF - EX DE,HL - CALL L18A2 - CALL L19C3 - POP AF - LD C,A - DEC DE - LD (DE),A - POP DE - POP HL - LD A,(HL) - JR L234C ; (-046H) - -L2392: INC HL -L2393: CALL L23AC -L2396: CP 02FH - JR Z,L23A0 ; (+006H) - CP 02AH - RET NZ - LD A,00EH - DB 001H -L23A0: LD A,00FH - EXX - LD BC,L2396 - LD DE,L23AB - JR L23BB ; (+010H) - -L23AB: INC HL -L23AC: CALL L2402 -L23AF: CP 05EH - RET NZ - LD A,010H - EXX - LD BC,L23AF - LD DE,L2401 -L23BB: PUSH BC - LD HL,(04E94H) - LD BC,00005H - ADD HL,BC - LD (04E94H),HL - LD HL,L2691 - LD C,A - ADD HL,BC - ADD HL,BC - LD C,(HL) - INC HL - LD B,(HL) - PUSH BC - LD HL,L23DC - PUSH HL - PUSH DE - EXX - LD A,D - OR A - RET Z -L23D9: JP DATMISERR - -L23DC: LD A,D - OR A - JR NZ,L23D9 ; (-007H) - POP IY - PUSH HL - LD HL,(04E94H) - LD BC,0FFFBH - LD E,L - LD D,H - ADD HL,BC - LD (04E94H),HL - EX DE,HL - LD BC,L23F9 - PUSH BC - JP (IY) - -L23F6: CALL L192C -L23F9: POP HL -L23FA: LD BC,00005H - LD D,B - LD E,B - LD A,(HL) - RET - -L2401: INC HL -L2402: CALL SKIPSPACE - CP 02BH - JR Z,L2425 ; (+01cH) - CP 02DH - JR NZ,L2426 ; (+019H) - CALL L2425 -L2410: EXX - LD HL,(04E94H) - PUSH HL - LD BC,00004H - ADD HL,BC - LD A,(HL) - POP HL - OR A - JR Z,L2422 ; (+004H) - LD A,(HL) - ADD A,080H - LD (HL),A -L2422: EXX - LD A,(HL) - RET - -L2425: INC HL -L2426: CALL L2640 - JR NC,L2447 ; (+01cH) - LD A,046H - CP E - JR NZ,L2436 ; (+006H) - LD A,04EH - CP D - JP Z,L24F0 -L2436: CALL L24B2 - PUSH HL - LD A,B - OR A - JR Z,L23F6 ; (-048H) - EX DE,HL - LD B,000H - CALL L1A0E - POP HL - LD A,(HL) - RET - -L2447: CP 080H - JR C,L2481 ; (+036H) - CP PRTD - JR Z,L24A8 ; (+059H) - CP 0C0H - JR C,L2472 ; (+01fH) - SUB 0C0H - PUSH AF - CALL L2332 - CALL L1926 - CALL MATCHCHR - DB 029H - POP AF - PUSH HL - LD HL,L23F9 - PUSH HL - LD HL,(04E94H) - EX DE,HL - LD HL,L26DB - PUSH HL - LD C,A - JP L1B95 - -L2472: SUB 0A0H - JR C,L248F ; (+019H) - LD C,A - CALL INCSKIPSPCE - PUSH HL - LD HL,L26B3 - JP L1B95 - -L2481: CP 028H - JR Z,L2492 ; (+00dH) - CP 022H - JP Z,L19F3 - CALL L1A97 - JR Z,L249E ; (+00fH) -L248F: JP SYNTAXERR - -L2492: LD BC,MONIT - CALL L185F - CALL L2292 - JP L2712 - -L249E: LD DE,(04E94H) - CALL L3670 - JP L23FA - -L24A8: CALL INCSKIPSPCE - PUSH HL - LD DE,L2A97 - JP L23F6 - -L24B2: LD A,(HL) - CP 024H - JP Z,L256F - CP 028H - JP Z,L25FE -L24BD: PUSH HL - LD HL,(04E8AH) - LD BC,00005H -L24C4: LD A,(HL) - CP E - INC HL - JR NZ,L24CD ; (+004H) - LD A,(HL) - CP D - JR Z,L24EB ; (+01eH) -L24CD: OR A - JR Z,L24D4 ; (+004H) - INC HL - ADD HL,BC - JR L24C4 ; (-010H) - -L24D4: LD C,007H - DEC HL - PUSH DE - EX DE,HL - LD HL,L2A8D - DEC HL - DEC HL - CALL L18A2 - CALL L19C3 - EX DE,HL - POP DE - LD (HL),E - INC HL - LD (HL),D - LD C,005H -L24EB: INC HL - EX DE,HL - POP HL - LD A,(HL) - RET - -L24F0: LD A,(HL) - SUB 041H - CP 01AH - JP NC,SYNTAXERR - LD E,(HL) - INC HL - CALL MATCHCHR - DB 028H - PUSH DE - CALL L2333 - CALL L1926 - CALL L2712 - POP DE - PUSH HL - LD HL,(04E84H) -L250D: LD A,(HL) - OR A - JP Z,UNDEFFNERR - CP E - JR Z,L251C ; (+007H) - INC HL - INC HL - CALL L1745 - JR L250D ; (-00fH) - -L251C: INC HL - LD E,(HL) - INC HL - PUSH HL - PUSH DE - LD D,020H - CALL L24BD - POP HL - PUSH DE - PUSH HL - LD HL,(04E96H) - LD DE,04E9CH - CALL L1773 - JP Z,FUNCERR - LD BC,0FFFAH - ADD HL,BC - LD (04E96H),HL - POP DE - LD (HL),E - INC HL - POP DE - LD BC,00005H - EX DE,HL - CALL L18A5 - EX DE,HL - LD HL,(04E94H) - CALL L18A5 - POP HL - CALL L2333 - CALL L1926 - CALL L193B - JP NZ,SYNTAXERR - LD HL,(04E96H) - LD E,(HL) - INC HL - LD D,020H - CALL L24BD - CALL L18A5 - ADD HL,BC - LD (04E96H),HL - JP L23F9 - -L256F: CALL INCSKIPSPCE - CP 028H - JP Z,L25F9 - PUSH HL - LD HL,04954H - XOR A - SBC HL,DE - JR Z,L25B2 ; (+032H) - EX DE,HL - LD (L18D8),HL - LD HL,(04E90H) -L2587: CALL L18CE - SUB (HL) - DEC H - JR Z,L25AA ; (+01cH) - LD B,000H - LD C,(HL) - ADD HL,BC - INC HL - INC HL - JR L2587 ; (-00fH) - - LD BC,00004H - EX DE,HL - LD HL,L18D8 - CALL L18A2 - CALL L19C3 - EX DE,HL - ADD HL,BC - DEC HL - LD (HL),00DH - DEC HL - LD (HL),B -L25AA: LD C,(HL) - INC HL - LD B,001H - EX DE,HL - POP HL - LD A,(HL) - RET - -L25B2: CALL TIMRD - EX DE,HL - OR A - JR Z,L25BB ; (+002H) - LD A,00CH -L25BB: EXX - LD HL,L1DF5 - PUSH HL - EXX - LD DE,0F1F0H - CALL L25D9 - LD DE,0FFC4H - CALL L25D8 - LD A,L - CALL L25E2 - POP DE - LD BC,00106H - POP HL - LD A,(HL) - RET - -L25D8: XOR A -L25D9: ADD HL,DE - JR NC,L25DF ; (+003H) - INC A - JR L25D9 ; (-006H) - -L25DF: OR A - SBC HL,DE -L25E2: LD BC,L30F6 -L25E5: ADD A,C - JR NC,L25EB ; (+003H) - INC B - JR L25E5 ; (-006H) - -L25EB: ADD A,03AH - EX AF,AF' - LD A,B - EXX - LD (HL),A - INC HL - EX AF,AF' - LD (HL),A - INC HL - LD (HL),00DH - EXX - RET - -L25F9: LD BC,00100H - JR L2601 ; (+003H) - -L25FE: LD BC,MONIT -L2601: INC HL - CALL L2107 - JP Z,ILDATERR - PUSH HL - LD L,C - LD H,000H - LD C,E - LD E,D - LD B,H - LD D,H - PUSH BC - INC HL - CALL L17CF - POP HL - ADD HL,DE - EX DE,HL - LD A,(L2104) - OR A - JR NZ,L262B ; (+00dH) - LD HL,00005H - CALL L17CF - POP HL - ADD HL,DE - LD BC,00005H - JR L263A ; (+00fH) - -L262B: POP HL - LD B,000H -L262E: LD C,(HL) - INC HL - LD A,D - OR E - JR Z,L2639 ; (+005H) - ADD HL,BC - INC HL - DEC DE - JR L262E ; (-00bH) - -L2639: INC B -L263A: EX DE,HL - LD HL,(L2102) - LD A,(HL) - RET - -L2640: CALL SKIPSPACE - LD BC,L411A - SUB B - CP C - LD A,(HL) - RET NC - LD E,A - LD D,020H -L264D: INC HL - LD A,(HL) - CP D - JR Z,L264D ; (-005H) - SUB B - CP C - JR C,L265A ; (+004H) - SUB 0EFH - CP 00AH -L265A: LD A,(HL) - CCF - RET C - LD D,A - CP 04EH - JR NZ,L2667 ; (+005H) - LD A,046H - CP E - JR Z,L267A ; (+013H) -L2667: INC HL - LD A,(HL) - CP 020H - JR Z,L2667 ; (-006H) - SUB B - CP C - JR C,L2667 ; (-00aH) - SUB 0EFH - CP 00AH - JR C,L2667 ; (-010H) -L2677: LD A,(HL) - SCF - RET - -L267A: CALL INCSKIPSPCE - SCF - RET - -L267F: CALL L2640 - JR NC,L268E ; (+00aH) - LD A,046H - CP E - JR NZ,L268C ; (+003H) - LD A,04EH - CP D -L268C: JR NZ,L2677 ; (-017H) -L268E: JP SYNTAXERR - -L2691: DW L3B62 - DW L3B62 - DW L3B87 - DW L3B87 - DW L3B8B - DW L3B8B - DW L3B7F - DW L3B73 - DW L3B77 - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW L3405 - DW L3403 - DW L3500 - DW L35D0 - DW L4159 -L26B3: DW L26F3 - DW L270F - DW L273E - DW L2765 - DW L2772 - DW L277F - DW L27B4 - DW L279A - DW L27F9 - DW L2801 - DW L2804 - DW L2895 - DW SYNTAXERR - DW SYNTAXERR - DW SYNTAXERR - DW L2824 - DW SYNTAXERR - DW L2841 - DW L287C - DW SYNTAXERR -L26DB: DW L3B98 - DW L3C16 - DW L3D05 - DW L3D14 - DW L4076 - DW L3E03 - DW L3A86 - DW L4064 - DW L3F35 - DW L289D - DW L28A2 - DW L3D3F -L26F3: DB 0CDH - DB 033H - DB 023H - DB 0CDH - DB 094H - DB 02EH -L26F9: PUSH DE - CALL GETNUM - CALL L2712 - EX (SP),HL - PUSH HL - EX DE,HL - CALL L190B - LD A,C - SUB L - JR C,L273A ; (+030H) - PUSH HL - LD C,A - ADD HL,DE - JR L2732 ; (+023H) - -L270F: DB 0CDH -L2710: DB 017H - DB 027H -L2712: CALL MATCHCHR - DB 029H - RET - - CALL L2333 - CALL L2E94 - PUSH DE - CALL GETNUM - JR L2724 ; (+001H) - -L2723: PUSH BC -L2724: EX (SP),HL - PUSH HL - EX DE,HL - CALL L190B - LD A,C - SUB L - JR C,L273A ; (+00cH) - PUSH HL - LD C,A - LD L,E - LD H,D -L2732: EX DE,HL - CALL L19E7 - POP BC - DEC HL - LD (HL),C - INC HL -L273A: POP DE - POP HL - LD A,(HL) - RET - -L273E: CALL L2333 - CALL L2E94 - PUSH DE - PUSH BC - CALL GETNUM - POP BC - LD A,E - OR A - JP Z,ILDATERR - LD A,C - SUB E - JR NC,L2755 ; (+002H) - LD A,PRTD -L2755: INC A - LD E,A - POP BC - CALL L2723 - CALL L2E94 - CP 02DH - JR NZ,L26F9 ; (-069H) - INC HL - JR L2712 ; (-053H) - -L2765: CALL L2333 - CALL L190B - CALL L2712 - PUSH HL - LD A,C - JR L27C4 ; (+052H) - -L2772: CALL L299F - CALL L2712 - LD A,E - LD BC,00001H - JP L280F - -L277F: CALL L2333 - CALL L1926 - CALL L2712 - PUSH HL - LD HL,(04E94H) - LD DE,04AB3H - PUSH DE - CALL L38BB - POP HL - CALL L19F3 - POP HL - LD A,(HL) - RET - -L279A: CALL L2333 - CALL L190B - CALL L2712 - PUSH HL - EX DE,HL - JR L27AA ; (+003H) - - LD HL,L27B2 -L27AA: CALL L1A75 - AND A - DAA - POP HL - LD A,(HL) - RET - -L27B2: DB 030H - DB 00DH -L27B4: CALL L2333 - CALL L190B - CALL L2712 - LD A,C - OR A - JP Z,ILDATERR -L27C2: LD A,(DE) - PUSH HL -L27C4: LD E,A - LD D,000H -L27C7: CALL L27CD - POP HL - LD A,(HL) - RET - -L27CD: LD B,080H - LD A,D - OR E - JR Z,L27E7 ; (+014H) - LD B,0D0H - LD A,D - OR A - JR NZ,L27DE ; (+005H) - LD B,0C8H - LD D,E - LD E,000H -L27DE: EX DE,HL -L27DF: BIT 7,H - JR NZ,L27E6 ; (+003H) - ADD HL,HL - DJNZ L27DF ; (-007H) -L27E6: EX DE,HL -L27E7: LD HL,(04E94H) - LD (HL),B - INC HL - CALL L19BA - LD (HL),E - INC HL - LD (HL),D - LD BC,00005H - LD DE,MONIT - RET - -L27F9: CALL L299F - CALL L2712 - JR L27C2 ; (-03fH) - -L2801: JP SYNTAXERR - -L2804: CALL GETNUM - CALL L2712 - LD A,020H - LD C,E - LD B,000H -L280F: PUSH HL - PUSH AF - CALL L1A1E - POP AF - PUSH DE - PUSH BC - LD B,C - INC B - JR L281D ; (+002H) - -L281B: LD (HL),A - INC HL -L281D: DJNZ L281B ; (-004H) - POP BC - POP DE - POP HL - LD A,(HL) - RET - -L2824: CALL L2333 - CALL L2E94 - PUSH DE - CALL GETNUM - CALL L2712 - EX (SP),HL - PUSH DE - EX DE,HL - CALL L190B - LD A,C - OR A - JP Z,ILDATERR - LD A,(DE) - POP BC - POP HL - JR L280F ; (-032H) - -L2841: CALL L1E69 - LD A,E - CP 028H -L2847: JP NC,ILDATERR - PUSH AF - CALL MATCHCHR - DB 02CH - CALL GETNUM - CALL MATCHCHR - DB 029H - LD A,E - CP 019H - JR NC,L2847 ; (-014H) - POP AF - LD C,A - LD B,E - INC B - PUSH HL - LD HL,(PAGETP) - LD D,000H - LD E,028H - XOR A - SBC HL,DE -L286A: ADD HL,DE - DJNZ L286A ; (-003H) - ADD HL,BC - CALL L2878 - POP HL - LD BC,00001H - JP L280F - -L2878: LD A,(HL) - JP ?DACN - -L287C: CALL EXECNOTCHR - DB 056H - DW L288C - LD A,(01172H) -L2885: LD D,000H - LD E,A - PUSH HL - JP L27C7 - -L288C: CALL MATCHCHR - DB 048H - LD A,(DSPXY) - JR L2885 ; (-010H) - -L2895: PUSH HL - CALL L184A - EX DE,HL - JP L27C7 - -L289D: LD A,(DE) - OR 080H - LD (DE),A - RET - -L28A2: LD A,(DE) - LD DE,L192C - PUSH DE - LD DE,L2A92 - OR A - RET P - LD DE,L2A88 - CP 080H - RET NZ - LD DE,L2A8D - RET - -CMDMON: JP MONIT - -CMDCURSOR: CALL GETNUM - LD A,E - CP 028H -L28BF: JP NC,ILDATERR - PUSH AF - CALL MATCHCHR - DB 02CH - CALL GETNUM - LD A,E - CP 019H - JR NC,L28BF ; (-010H) - PUSH HL - LD HL,(DSPXY) - LD A,E - SUB H - LD H,A - LD A,(MGPNT) - JP M,L28F8 - ADD A,H - SUB 032H - JR NC,L28E3 ; (+002H) - ADD A,032H -L28E3: LD (MGPNT),A - EX DE,HL - LD H,L - POP DE - POP AF - LD L,A - LD (DSPXY),HL - NOP - NOP - NOP - LD (DPRNT),A - EX DE,HL - JP L1B38 - -L28F8: ADD A,H - JP P,L28E3 - ADD A,032H - JR L28E3 ; (-01dH) - - NOP - NOP -CMDGET: CALL L267F - CALL L24B2 - LD (05051H),HL - CALL L1D9A - CALL GETKY - PUSH AF - LD A,(04905H) - OR A - JR Z,L292D ; (+015H) - POP AF - LD BC,MONIT - OR A - JR Z,L2920 ; (+001H) - INC BC -L2920: CALL L280F -L2923: CALL L1D95 - CALL L1DA5 - DW DATMISERR - JR L2998 ; (+06bH) - -L292D: POP AF - LD DE,MONIT - CALL L2939 -L2934: CALL L27CD - JR L2923 ; (-016H) - -L2939: OR A - RET Z - SUB 030H - CP 00AH - RET NC - LD E,A - RET - -CMDUSRN: CALL L299F - PUSH DE - CALL EXECNOTCHR - DB 02CH - DW L2959 - CALL L267F - CALL L24B2 - LD A,B - OR A - JP Z,DATMISERR - LD B,000H -L2959: CALL L2712 - LD (05051H),HL - CALL L13FA - LD HL,L1B35 - EX (SP),HL - JP (HL) - -CMDLIMIT: LD DE,L299B - CALL L14C7 - JR NZ,L2977 ; (+008H) - LD (05051H),HL - LD HL,(04908H) - JR L2994 ; (+01dH) - -L2977: CALL L299F - LD (05051H),HL - LD HL,(04908H) - CALL L1773 - JP C,ILDATERR - LD HL,(04E94H) - LD BC,000C8H - ADD HL,BC - CALL L1773 - JP NC,BADWRERR - EX DE,HL -L2994: LD (0490AH),HL - LD SP,HL -L2998: JP L1B35 - -L299B: LD C,L - LD B,C - RET C - NOP -L299F: CALL EXECNOTCHR - DB 024H - DW L29CB - LD DE,MONIT -L29A8: CALL L176A - JR NC,L29C2 ; (+015H) -L29AD: AND 00FH - LD C,A - LD B,000H - LD A,D - AND 0F0H - JP NZ,ILDATERR - EX DE,HL - ADD HL,HL - ADD HL,HL - ADD HL,HL - ADD HL,HL - ADD HL,BC - EX DE,HL - INC HL - JR L29A8 ; (-01aH) - -L29C2: SUB 041H - CP 006H - RET NC - ADD A,00AH - JR L29AD ; (-01eH) - -L29CB: JP L1E69 - -CMDCONT: CALL L1AA7 - LD A,(L1463) - OR A - JP Z,CONTERR - PUSH AF - XOR A - CALL L29EB - POP AF - LD HL,(05051H) - OR A - JP M,L2C56 - DEC A - JR Z,L2998 ; (-050H) - JP L1B5F - -L29EB: LD (L1463),A - LD DE,L1464 - LD BC,LETNL - LD HL,0504DH - OR A - JR NZ,L29FB ; (+001H) - EX DE,HL -L29FB: LDIR - RET - -CMDINP: CALL GETNUM - CALL L2E94 - LD A,E - LD (L2A15),A - CALL L267F - CALL L24B2 - LD (05051H),HL - CALL L1D9A - DB 0DBH -L2A15: DB 0FFH - LD E,A - LD D,000H - JP L2934 - -CMDOUT: CALL GETNUM - CALL L2E94 - LD A,E - LD (L2A2B),A - CALL GETNUM - LD A,E - DB 0D3H -L2A2B: DB 0FFH -L2A2C: JP L1B38 - -CMDAUTO: CALL L1AA7 - CALL L193B - JR Z,L2A5F ; (+028H) - CALL EXECNOTCHR - DB 02CH - DW L2A3F - JR L2A71 ; (+032H) - -L2A3F: CALL L2A7A - LD (02A84H),DE - CALL L193B - JR Z,L2A6C ; (+021H) - CALL EXECNOTCHR - DB 02CH - DW SYNTAXERR -L2A51: CALL L2A7A - LD (02A86H),DE -L2A58: LD A,001H - LD (L2A83),A - JR L2A2C ; (-033H) - -L2A5F: LD DE,0000AH - LD (02A84H),DE -L2A66: LD (02A86H),DE - JR L2A58 ; (-014H) - -L2A6C: LD DE,0000AH - JR L2A66 ; (-00bH) - -L2A71: LD DE,0000AH - LD (02A84H),DE - JR L2A51 ; (-029H) - -L2A7A: CALL L1E69 - LD A,D - OR E - RET NZ - JP SYNTAXERR - -L2A83: DB 000H -L2A84: DB 00AH - DB 000H - DB 00AH - DB 000H -L2A88: DB 0C1H - DB 000H - DB 000H - DB 000H - DB 080H -L2A8D: DB 080H - DB 000H - DB 000H - DB 000H - DB 000H -L2A92: DB 041H - DB 000H - DB 000H - DB 000H - DB 080H -L2A97: DB 0C2H - DB 0A1H - DB 0DAH - DB 00FH - DB 0C9H - AND 00FH - ADD A,030H - CP 03AH - RET C - ADD A,007H - RET - -CMDSET: LD A,001H - JR L2AAB ; (+001H) - -CMDRESET: XOR A -L2AAB: PUSH AF - CALL GETNUM - PUSH DE - CALL MATCHCHR - DB 02CH - CALL GETNUM - LD (05051H),HL - LD A,E -L2ABB: SUB 032H - JR NC,L2ABB ; (-004H) - ADD A,032H - LD E,A - POP BC - LD A,C -L2AC4: SUB 050H - JR NC,L2AC4 ; (-004H) - ADD A,050H - LD C,A - XOR A - SRL C - JR NC,L2ADE ; (+00eH) - SRL E - JR NC,L2AD8 ; (+004H) - ADD A,004H -L2AD6: ADD A,002H -L2AD8: ADD A,001H -L2ADA: ADD A,001H - JR L2AE4 ; (+006H) - -L2ADE: SRL E - JR NC,L2ADA ; (-008H) - JR L2AD6 ; (-00eH) - -L2AE4: PUSH AF - LD HL,(PAGETP) - LD A,028H -L2AEA: ADD HL,DE - DEC A - JR NZ,L2AEA ; (-004H) - ADD HL,BC - RES 3,H - LD A,(HL) - CP 0F0H - JR NC,L2AF8 ; (+002H) - LD A,0F0H -L2AF8: POP BC - LD C,A - POP AF - OR A - LD A,B - JR Z,L2B02 ; (+003H) - OR C - JR L2B04 ; (+002H) - -L2B02: CPL - AND C -L2B04: CP 0F0H - JR NZ,L2B09 ; (+001H) - XOR A -L2B09: LD (HL),A - JP L1B35 - -CMDPRINT: CALL EXECNOTCHR ; Check to see if a stream, ie. /T = Tape is given. The 02FH below is / and the function after is called if it doesnt match /. - DB 02FH - DW L2B18 - CALL L2E9B - JR L2B1E ; (+006H) - -L2B18: CALL L2DBA - CALL L2E94 -L2B1E: CALL L193B - JR NZ,L2B2F ; (+00cH) - LD (05051H),HL -L2B26: LD HL,L2BEF - CALL L2BE3 - JP L1B35 - -L2B2F: CALL EXECNOTCHR - DB 03BH - DW L2B35 -L2B35: LD BC,L2B4D - PUSH BC - CP 02CH - RET NZ - INC HL - LD A,(04DD4H) - OR A - RET P - AND 07FH - JP Z,PRNTT - CP 002H - RET NZ - JP L326E - -L2B4D: CALL L193B - LD (05051H),HL - JP NZ,L2B60 - LD A,(04DD4H) - OR A - JP M,L1B35 - JP L2B26 - -L2B60: CP 03BH - JR Z,L2B66 ; (+002H) - CP 02CH -L2B66: JP Z,L2B2F - CALL EXECNOTCHR - DB 0A9H - DW L2B9A - CALL GETNUM - CALL MATCHCHR - DB 029H - LD D,013H - LD A,(DPRNT) - LD B,A - LD A,(04DD4H) - CP 080H - JR Z,L2B8D ; (+00aH) - LD D,020H - CP 082H - JR NZ,L2BBD ; (+034H) - LD A,(L32D3) - LD B,A -L2B8D: LD A,E - SUB B - JR C,L2B2F ; (-062H) - LD C,A - LD B,000H - LD A,D - CALL L280F - JR L2B9D ; (+003H) - -L2B9A: CALL L2293 -L2B9D: PUSH HL - LD HL,LINEBUFR - LD A,D - OR A - CALL Z,L2BC0 - CALL NZ,L2BD0 - LD HL,L2BF7 - CALL L2BE3 - LD HL,L2B1E - EX (SP),HL - CALL L193B - RET Z - CP 03BH - RET Z - CP 02CH - RET Z -L2BBD: JP SYNTAXERR - -L2BC0: PUSH AF - PUSH HL - EX DE,HL - LD HL,(04E94H) - CALL L38BB - POP HL - CALL L18FD - JP L2BD9 - -L2BD0: PUSH AF - CALL L190B - EX DE,HL - CALL L18A5 - EX DE,HL -L2BD9: DEC HL - LD (HL),C - INC HL - PUSH HL - ADD HL,BC - LD (HL),00DH - POP DE - POP AF -L2BE2: RET - -L2BE3: LD A,(04DD4H) - ADD A,080H - CALL L13FA - CALL L2E12 - JP (HL) - -L2BEF: LD B,000H - XOR E - INC DE - AND A - LD SP,L2BE2 -L2BF7: DEC D - NOP - XOR E - INC DE - OR H - LD SP,L3064 -CMDINPUT: CALL L1AAF - CALL EXECNOTCHR - DB 02FH - DW L2C0E - CALL L2E9B - JP L2C62 - -L2C0E: CALL L2DBA - CALL SKIPSPACE - CP 022H - LD DE,L2C5F - JR NZ,L2C25 ; (+00aH) - CALL L2333 - CALL MATCHCHR - DB 03BH - CALL L190B -L2C25: LD (05051H),HL -L2C28: CALL MSG - LD A,(DPRNT) - LD B,A - LD L,A - LD H,000H - LD DE,LINEBUFR - ADD HL,DE - LD (L2C8C),HL - CALL GETL - EX DE,HL - LD A,(HL) - CP 01BH - JR NZ,L2C4A ; (+008H) - LD A,080H - CALL L29EB - JP L1438 - -L2C4A: INC B - LD A,00DH -L2C4D: CP (HL) - JR Z,L2C56 ; (+006H) - INC HL - DJNZ L2C4D ; (-006H) - JP L2C8E - -L2C56: CALL NL - LD DE,L2C5F - JP L2C28 - -L2C5F: CCF - JR NZ,L2C6F ; (+00dH) -L2C62: CALL L2E94 - LD (05051H),HL -L2C68: LD DE,LINEBUFR - PUSH DE - LD HL,L2C84 -L2C6F: CALL L2BE3 - POP HL - DEC HL - LD (HL),C - INC HL - LD A,B - OR A - JP NZ,STRLENERR - CALL L1A0E - LD HL,L2C68 - JP L2CC8 - -L2C84: XOR E - INC DE - XOR E - INC DE - XOR E - INC DE - ADC A,A - DB 030H -L2C8C: DB 00FH - DB 049H -L2C8E: LD A,(04DD4H) - CP 081H - JP Z,L2D1D - LD HL,(L2C8C) - CALL L18FD - LD DE,LINEBUFR - PUSH DE - INC BC - LDIR - POP HL - LD (L2C8C),HL - CALL SKIPSPACE - CP 00DH - JP Z,L2C56 - CALL EXECNOTCHR - DB 02CH - DW L2CBF - PUSH HL - LD DE,L2D11 - CALL L19F3 - POP HL - JR L2CC2 ; (+003H) - -L2CBF: CALL L19F3 -L2CC2: LD (L2C8C),HL - LD HL,L2C8E -L2CC8: PUSH HL - CALL L1D95 - LD HL,(05051H) - CALL L267F - CALL L24B2 - LD (05051H),HL - CALL L1D9A -L2CDB: CALL L1DA5 - DW L2CF4 - LD HL,(05051H) - CALL L193B - JR NZ,L2CEC ; (+004H) - POP AF - JP L1B35 - -L2CEC: CALL MATCHCHR - DB 02CH - LD (05051H),HL - RET - -L2CF4: LD DE,(04902H) - CALL L190B - EX DE,HL - CALL EXECNOTCHR - DB 00DH - DW L2D05 - LD HL,L2D10 -L2D05: CALL L1A75 - OR H - INC DE - CALL L1D95 - JP L2CDB - -L2D10: DB 030H -L2D11: DB 00DH -CMDREAD: LD (05051H),HL - LD A,081H - LD (04DD4H),A - CALL L1AAF -L2D1D: LD A,(05059H) - OR A - CALL Z,L2D43 - LD HL,(0505AH) - CALL L193B - JR NZ,L2D32 ; (+006H) - CALL L2D6B - JP L2D1D - -L2D32: CALL L19F3 - CALL L2E94 - LD (0505AH),HL - LD HL,LINEBUFR - LD (HL),00DH - JP L2CC2 - -L2D43: LD HL,0505CH -L2D46: XOR A - LD (05059H),A -L2D4A: LD A,(HL) - INC HL - OR (HL) - INC HL - JP Z,READDATAERR - INC HL - INC HL -L2D53: CALL EXECNOTCHR - DB 080H - DW L2D68 - CALL EXECNOTCHR - DB 081H - DW L2D68 - LD (0505AH),HL - LD A,001H - LD (05059H),A - RET - -L2D68: CALL L174F -L2D6B: INC HL - CP 03AH - JP Z,L2D53 - JP L2D4A - -L2D74: DB 001H -CMDLOAD: CALL EXECNOTCHR - DB 02FH - DW L2EDA - CALL MATCHCHR - DB 054H - JP L2EDA - -CMDSAVE: CALL L1AA7 - CALL EXECNOTCHR - DB 02FH - DW L2FE0 - CALL MATCHCHR - DB 054H - JP L2FE0 - -CMDROPEN: CALL EXECNOTCHR - DB 02FH - DW L311E - CALL MATCHCHR - DB 054H - JP L311E - -CMDWOPEN: CALL EXECNOTCHR - DB 02FH - DW L30E5 - CALL MATCHCHR - DB 054H - JP L30E5 - - NOP -CMDCLOSE: CALL EXECNOTCHR - DB 02FH - DW L3171 - CALL MATCHCHR - DB 054H - JP L3171 - -L2DBA: LD A,080H - LD (04DD4H),A - OR A - RET - -L2DC1: LD HL,04DF2H - LD DE,NL - LD B,00AH -L2DC9: CP (HL) - JR Z,L2DD2 ; (+006H) - ADD HL,DE - DJNZ L2DC9 ; (-006H) - JP L177A - -L2DD2: LD A,00AH - SUB B - JP L1784 - -L2DD8: LD A,B - OR C - JR Z,L2DDE ; (+002H) - INC BC - INC BC -L2DDE: LD E,(HL) - INC HL - LD D,(HL) - DEC HL - PUSH HL - LD H,B - LD L,C - CALL L1773 - POP HL - JR Z,L2DF7 ; (+00cH) - EX DE,HL - PUSH BC - LD C,L - LD B,H - CALL L19E7 - POP BC - CALL L19C0 - EX DE,HL -L2DF7: LD D,H - LD E,L - LD A,C - OR B - RET Z - LD (HL),C - INC HL - LD (HL),B - DEC HL - DEC BC - DEC BC - RET - - CALL L2DD8 - INC HL - INC HL - RET - -L2E09: PUSH BC - LD BC,MONIT - CALL L2DD8 - POP BC - RET - -L2E12: ADD A,A - ADD A,L - LD L,A - JR NC,L2E18 ; (+001H) - INC H -L2E18: LD A,(HL) - INC HL - LD H,(HL) - LD L,A - RET - -L2E1D: LD DE,CMTFNAME ; Compare loaded filename against name given by user. - PUSH HL - INC HL - LD B,010H -L2E24: LD A,(DE) - CP (HL) - JR NZ,L2E31 ; (+009H) -L2E28: INC HL - INC DE - CP 00DH - JR Z,L2E31 ; (+003H) - DEC B - JR NZ,L2E24 ; (-00dH) -L2E31: POP HL - RET - -CMTBUF: DB 002H -CMTFNAME: DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - PUSH HL - LD HL,GETL - LD (04DD6H),HL - LD HL,04DD8H - LD B,005H -L2E5F: LD (HL),000H - INC HL - DJNZ L2E5F ; (-005H) - LD HL,CMTFNAME - LD B,011H -L2E69: LD (HL),00DH - INC HL - DJNZ L2E69 ; (-005H) - LD B,00EH -L2E70: LD (HL),000H - INC HL - DJNZ L2E70 ; (-005H) - POP HL - CALL L2E94 - CALL L2333 - LD A,D - OR A - JP Z,UNKNWNERR - LD A,C - DEC A - CP 010H - JP NC,UNKNWNERR - PUSH HL - CALL L190B - LD HL,CMTFNAME - EX DE,HL - LDIR - POP HL - RET - -L2E94: CALL EXECNOTCHR - DB 02CH - DW L2E9A -L2E9A: RET - -L2E9B: LD B,000H - LD DE,L2EB0 - CALL L14C9 - JP NZ,SYNTAXERR - CALL L2E94 - LD A,B - ADD A,082H - LD (04DD4H),A - RET - -L2EB0: DB 0D0H - DB 0D4H - DB 000H -CMDVERIFY: CALL L1AA7 - XOR A - JR L2EDC ; (+023H) - -L2EB9: LD A,(ATRB) - CP 002H - JR NZ,L2EE6 ; (+026H) - CALL L2F62 - CALL L1B1B - CALL ?VRFY - PUSH AF - CALL L1AC7 - POP AF - JP C,L30B3 - LD DE,L2FDD - CALL MSGNL - JP L1B35 - -L2EDA: LD A,001H -L2EDC: LD (L2D74),A - LD BC,L2EE6 - PUSH BC - JP L2FE4 - -L2EE6: CALL ?RDI - JP C,L30B3 - CALL L2F67 - LD HL,ATRB - LD A,(HL) - OR A - JR Z,L2EE6 ; (-010H) - CP 004H - JR NC,L2EE6 ; (-014H) - LD DE,CMTFNAME - LD A,(DE) - CP 00DH - JR Z,L2F07 ; (+005H) - CALL L2E1D - JR NZ,L2EE6 ; (-021H) -L2F07: LD A,(L2D74) - OR A - JR Z,L2EB9 ; (-054H) - LD A,(ATRB) - CP 001H - JP Z,L2F8E - CP 002H - JR NZ,L2EE6 ; (-033H) - CALL L1944 - LD HL,(SIZE) - DEC HL - DEC HL - LD C,L - LD B,H - LD DE,0505CH - CALL L1888 - CALL L19C3 - LD (DTADR),DE - CALL L2F6C - CALL ?RDD - JR C,L2F3E ; (+006H) - CALL L1ABF - JP L1B35 - -L2F3E: PUSH AF - CALL L2F4B - POP AF - PUSH AF - CALL L1944 - POP AF - JP L30B3 - -L2F4B: LD DE,0505EH - LD HL,04E4EH - XOR A - SBC HL,DE - RET Z - LD C,L - LD B,H - DEC DE - DEC DE - CALL L1873 - CALL L1762 - JP L19C3 - -L2F62: LD DE,L2FD2 - JR L2F6F ; (+008H) - -L2F67: LD DE,L2FC2 - JR L2F6F ; (+003H) - -L2F6C: LD DE,L2FC9 -L2F6F: CALL MSGNL - LD DE,NAME - LD A,(DE) - CP 00DH - RET Z - PUSH DE - CALL L2F86 - POP DE - LD A,00DH - LD (01101H),A - CALL MSGX -L2F86: LD DE,L2F8C - JP MSGX - -L2F8C: DB 022H - DB 00DH -L2F8E: LD HL,(DTADR) - EX DE,HL - LD HL,(0490AH) - DEC HL - CALL L1773 - JR NC,L2FB6 ; (+01bH) - LD HL,(SIZE) - ADD HL,DE - JR C,L2FBC ; (+01bH) - EX DE,HL - LD HL,(04908H) - CALL L1773 - JR C,L2FBC ; (+012H) - CALL L2F6C - CALL ?RDD - JP C,L30B3 - JP L1B35 - -L2FB6: CALL MSTOP - JP BADWRERR - -L2FBC: CALL MSTOP - JP MEMERR - -L2FC2: DB "F",0B7H,0A5H,0B0H,09CH," " - DB 00DH -L2FC9: DB "L",0B7H,0A1H,09CH,0A6H,0B0H,097H," " - DB 00DH -L2FD2: DB "V",092H,09DH,0A6H,0AAH,0BDH,0A6H,0B0H,097H," " - DB 00DH -L2FDD: DB "OK" - DB 00DH -L2FE0: LD BC,L3038 - PUSH BC -L2FE4: CALL EXECNOTCHR - DB 02CH - DW L2FEA -L2FEA: PUSH HL - LD HL,CMTBUF - LD (HL),002H -L2FF0: LD B,011H -L2FF2: INC HL - LD (HL),00DH - DJNZ L2FF2 ; (-005H) - CALL L1459 - POP HL - CALL L193B - LD (05051H),HL - RET Z - CALL L2333 - CALL L193B - JP NZ,SYNTAXERR - LD (05051H),HL - LD A,D - OR A - JP Z,UNKNWNERR - CALL L190B - LD A,C - OR A - RET Z - CP 011H - JP NC,UNKNWNERR - EX DE,HL - LD DE,CMTFNAME - LDIR - RET - -L3025: LD DE,ATRB - LD HL,CMTBUF - LD BC,PRNT - LDIR - LD B,06EH -L3032: XOR A - LD (DE),A - INC DE - DJNZ L3032 ; (-005H) - RET - -L3038: CALL L3025 - LD HL,0505CH - LD (DTADR),HL - LD DE,0505CH - LD HL,(04E4EH) - XOR A - SBC HL,DE - LD (SIZE),HL - CALL ?WRI - JP C,L30B8 - CALL L1B1B - CALL ?WRD - PUSH AF - CALL L1ABF - POP AF - JP C,L30B8 - JP WARMSTRT - -L3064: CALL L1459 - LD A,(L30E2) - CP 001H - JR NZ,L309A ; (+02cH) - LD HL,(L30E3) -L3071: PUSH DE - LD DE,04DD3H - CALL L1773 - JR C,L3082 ; (+008H) - CALL ?WRD - JR C,L30B8 ; (+039H) - LD HL,04CD3H -L3082: POP DE - LD A,(DE) - LD (HL),A - INC HL - INC DE - CP 00DH - JR NZ,L3071 ; (-01aH) - LD (L30E3),HL - RET - - CALL L1459 - LD A,(L30E2) - PUSH DE - LD C,000H - CP 002H -L309A: JP NZ,OUTFILEERR - LD (L2D74),A - LD HL,(L30E3) -L30A3: PUSH DE - LD DE,04DD3H - CALL L1773 - JR C,L30BE ; (+012H) - PUSH BC - CALL ?RDD - POP BC - JR NC,L30BB ; (+008H) -L30B3: CP 002H - JP NZ,CHKSUMERR -L30B8: JP L1438 - -L30BB: LD HL,04CD3H -L30BE: LD A,(HL) - LD B,A - CP PRTD - JR NZ,L30CC ; (+008H) - LD A,(L2D74) - CP 002H - JP Z,OUTFILEERR -L30CC: XOR A - LD (L2D74),A - LD A,B - POP DE - LD (DE),A - INC HL - INC DE - INC C - CP 00DH - JR NZ,L30A3 ; (-037H) - DEC C - POP DE - LD (L30E3),HL - LD B,000H - RET - -L30E2: NOP -L30E3: NOP - NOP -L30E5: CALL L1AAF - LD A,(L30E2) - OR A - JP NZ,OPENERR - LD BC,L30FC - PUSH BC - PUSH HL - DB 021H - DB 033H -L30F6: DB 02EH - LD (HL),003H - JP L2FF0 - -L30FC: CALL L3025 - LD HL,00100H - LD (SIZE),HL - LD HL,04CD3H - LD (L30E3),HL - LD (DTADR),HL - CALL ?WRI -L3111: JR C,L30B8 ; (-05bH) - CALL MSTOP - LD A,001H - LD (L30E2),A -L311B: JP L1B35 - -L311E: CALL L1AAF - LD A,(L30E2) - OR A - JP NZ,OPENERR - LD BC,L313A - PUSH BC - LD A,002H - LD (L2D74),A - PUSH HL - LD HL,CMTBUF - LD (HL),004H - JP L2FF0 - -L313A: CALL ?RDI - JP C,L30B3 - LD HL,ATRB - LD A,(HL) - CP 003H - JR NZ,L313A ; (-00eH) - LD DE,CMTFNAME - LD A,(DE) - CP 00DH - JR Z,L3155 ; (+005H) - CALL L2E1D - JR NZ,L313A ; (-01bH) -L3155: LD A,002H - LD (L30E2),A - CALL MSTOP - LD HL,04CD3H - LD (DTADR),HL - LD HL,00100H - LD (SIZE),HL - LD HL,04DD3H - LD (L30E3),HL - JR L311B ; (-056H) - -L3171: CALL L1459 - LD A,(L30E2) - OR A - JR Z,L3195 ; (+01bH) - PUSH HL - DEC A - JR NZ,L3190 ; (+012H) - LD HL,(L30E3) - LD DE,04DD3H - CALL L1773 - JR NC,L3198 ; (+00fH) -L3189: LD (HL),PRTD - CALL ?WRD -L318E: JR C,L3111 ; (-07fH) -L3190: XOR A - LD (L30E2),A - POP HL -L3195: JP CMDREMDATA - -L3198: CALL ?WRD - JR C,L318E ; (-00fH) - LD HL,04CD3H - JR L3189 ; (-019H) - -L31A2: LD A,(L32D3) - OR A - RET Z -L31A7: CALL L32C2 - LD A,00DH - CALL L3291 - XOR A - LD (L32D3),A - RET - - PUSH BC - PUSH DE - LD A,(L32D3) - LD B,A -L31BA: LD A,(DE) - CP 00DH - JP Z,L3258 - CP 020H - CALL C,L31CC - CALL L3291 - INC B - INC DE - JR L31BA ; (-012H) - -L31CC: CP 005H - JR Z,L31F0 ; (+020H) - CP 006H - JR Z,L3200 ; (+02cH) - CP 010H - JR Z,L3221 ; (+049H) - CP 011H - JR Z,L31F9 ; (+01dH) - CP 012H - JR Z,L31F5 ; (+015H) - CP 013H - JR Z,L3226 ; (+042H) - CP 014H - JR Z,L322A ; (+042H) - CP 015H - JR Z,L3238 ; (+04cH) - POP AF - INC DE - JR L31BA ; (-036H) - -L31F0: LD A,00FH -L31F2: LD B,PRTD - RET - -L31F5: LD A,00BH - JR L31F2 ; (-007H) - -L31F9: LD A,009H - LD (L326D),A - JR L31F2 ; (-00eH) - -L3200: LD A,00CH - CALL L3291 - LD A,009H - CALL L3291 - LD A,009H - CALL L3291 - LD A,00BH - CALL L3291 - LD A,00AH - CALL L3291 - CALL L3267 - CALL L3291 - JR L31F0 ; (-031H) - -L3221: CALL L3267 - JR L31F2 ; (-034H) - -L3226: LD A,00CH - JR L31F2 ; (-038H) - -L322A: LD A,009H - CALL L3291 - LD A,009H - CALL L3291 - LD A,009H - JR L31F2 ; (-046H) - -L3238: LD A,009H - CALL L3291 - LD A,009H - CALL L3291 - LD A,00BH - JR L31F2 ; (-054H) - -L3246: PUSH BC - PUSH DE - LD A,(L32D3) - LD B,A -L324C: LD A,(DE) - CP 00DH - JR Z,L3258 ; (+007H) - CALL L3291 - INC DE - INC B - JR L324C ; (-00cH) - -L3258: LD A,B - CP 0A0H - JR C,L325F ; (+002H) - SUB 0A0H -L325F: LD (L32D3),A - POP DE - POP BC - JP L32C2 - -L3267: LD A,00AH - LD (L326D),A - RET - -L326D: LD A,(BC) -L326E: PUSH BC - PUSH DE - LD A,(L32D3) - LD B,A -L3274: LD A,020H - CALL L3291 - INC B - LD A,B -L327B: SUB 00AH - JR C,L3274 ; (-00bH) - JR NZ,L327B ; (-006H) - JP L3258 - -L3284: CALL L3291 - CALL L32A5 - IN A,(PRTC) - RRCA - RRCA - RET - -L328F: LD A,01BH -L3291: PUSH AF - CALL L32A5 - POP AF - OUT (PRTD),A - LD A,080H - OUT (PRTC),A - LD A,001H - CALL L32A6 - XOR A - OUT (PRTC),A - RET - -L32A5: XOR A -L32A6: PUSH BC - PUSH DE - LD C,A - LD B,00FH - LD DE,MONIT -L32AE: IN A,(PRTC) - AND 00DH - CP C - JR Z,L32BF ; (+00aH) - DEC DE - LD A,D - OR E - JR NZ,L32AE ; (-00cH) - DJNZ L32AE ; (-00eH) - JP PRTNRDYERR - -L32BF: POP DE - POP BC - RET - -L32C2: LD A,007H - CALL L3284 - JP NC,PRTPAPERERR - LD A,008H - CALL L3284 - RET C - JP PRTHWERR - -L32D3: NOP -CMDPAGE: CALL GETNUM - LD A,E - OR A - JP Z,ILDATERR - LD A,009H - CALL L3291 - LD A,009H - CALL L3291 - LD A,E - PUSH AF - RRCA - RRCA - RRCA - RRCA - CALL ASC - CALL L3291 - POP AF - CALL ASC - CALL L3291 - JP L1B38 - -L32FC: CALL L31A7 - JP L1B35 - - CALL L193B - LD (05051H),HL - JR Z,L32FC ; (-00eH) - PUSH HL - CALL L338A - LD BC,00500H - CALL L2DD8 - POP HL -L3315: CALL L193B - LD (05051H),HL - JR Z,L3373 ; (+056H) - CALL L2E94 - CALL EXECNOTCHR - DB 03BH - DW L3326 -L3326: CALL L2293 - PUSH HL - LD HL,(04E80H) - PUSH BC - LD BC,003F0H - ADD HL,BC - POP BC - LD A,D - OR A - CALL Z,L2BC0 - CALL NZ,L2BD0 - LD A,B - OR C - JR Z,L3362 ; (+023H) - PUSH DE - LD HL,(04E80H) - INC HL - INC HL - LD E,(HL) - INC HL - LD D,(HL) - DEC HL - PUSH DE - PUSH HL - EX DE,HL - ADD HL,BC - XOR A - EX DE,HL - LD HL,003E8H - SBC HL,DE - JP C,ILDATERR - POP HL - LD (HL),E - INC HL - LD (HL),D - INC HL - POP DE - ADD HL,DE - POP DE - EX DE,HL - LDIR -L3362: LD HL,L3315 - EX (SP),HL - CALL L193B - RET Z - CP 03BH - RET Z - CP 02CH - RET Z - JP SYNTAXERR - -L3373: LD HL,(04E80H) - INC HL - INC HL - LD E,(HL) - INC HL - LD D,(HL) - LD A,D - OR E - JR Z,L3387 ; (+008H) - INC HL - EX DE,HL - CALL L3390 - CALL L338A -L3387: JP L1B35 - -L338A: LD HL,(04E80H) - JP L2E09 - -L3390: CALL L328F - LD A,018H - CALL L3291 - LD A,L - CALL L3291 - LD A,H - CALL L3291 -L33A0: LD A,(DE) - CALL L3291 - INC DE - DEC HL - LD A,H - OR L - JR NZ,L33A0 ; (-00aH) - RET - -CMDCOPY: CALL L193B - JP Z,SYNTAXERR - INC HL - LD (05051H),HL - SUB 034H - JP Z,SYNTAXERR - INC A - JP Z,SYNTAXERR - INC A - JP Z,SYNTAXERR - INC A - JP NZ,SYNTAXERR - LD HL,(PAGETP) - LD C,019H -L33CB: CALL L31A7 - LD A,028H - LD B,A -L33D1: CALL L2878 - OR A - JR Z,L33DB ; (+004H) - CP 00DH - JR NZ,L33DD ; (+002H) -L33DB: LD A,020H -L33DD: CALL L3291 - CALL BRKEY - JR Z,L33FD ; (+018H) - INC HL - DJNZ L33D1 ; (-017H) - DEC C - JR NZ,L33CB ; (-020H) - CALL L31A7 - JP L1B35 - -L33F1: CALL L328F - LD A,(L326D) - JP L3291 - - CALL L33F1 -L33FD: JP L1438 - -L3400: DB 000H -L3401: DB 080H -L3402: DB 086H -L3403: XOR A - DB 001H -L3405: LD A,080H - PUSH DE - XOR (HL) - CPL - LD C,A - LD A,(DE) - AND 080H - LD B,A - XOR C - CPL - AND 080H - LD C,A -L3414: PUSH BC - LD B,(HL) - RES 7,B - LD A,(DE) - AND 07FH - CP B - JR NC,L3428 ; (+00aH) - POP BC - EX DE,HL - LD A,B - XOR C - CPL - AND 080H - LD B,A - JR L3414 ; (-014H) - -L3428: LD C,A - ADD A,040H - LD (L3402),A - LD A,C - SUB B - POP BC - LD (03400H),BC - PUSH DE - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD C,(HL) - INC HL - LD B,(HL) - POP HL - INC HL - JR Z,L345C ; (+01aH) -L3442: CP 008H - JR NC,L3453 ; (+00dH) -L3446: SRL B - RR C - RR D - RR E - DEC A - JR NZ,L3446 ; (-00bH) - JR L345C ; (+009H) - -L3453: LD E,D - LD D,C - LD C,B - LD B,000H - SUB 008H - JR NZ,L3442 ; (-01aH) -L345C: LD A,(L3400) - OR A - JR Z,L349C ; (+03aH) - LD A,(HL) - INC HL - ADD A,E - LD E,A - LD A,(HL) - INC HL - ADC A,D - LD D,A - LD A,(HL) - INC HL - ADC A,C - LD C,A - LD A,(HL) - ADC A,B - LD B,A - JR NC,L347F ; (+00cH) - RR B - RR C - RR D - RR E - LD HL,L3402 - INC (HL) -L347F: LD HL,L3402 - LD A,(HL) - SUB 040H - JR C,L348E ; (+007H) - JP M,OVFLERR - DEC HL - OR (HL) - JR L3491 ; (+003H) - -L348E: CALL L3CDE -L3491: POP HL -L3492: LD (HL),A - INC HL - LD (HL),E - INC HL - LD (HL),D - INC HL - LD (HL),C - INC HL - LD (HL),B - RET - -L349C: LD A,(HL) - INC HL - SUB E - LD E,A - LD A,(HL) - INC HL - SBC A,D - LD D,A - LD A,(HL) - INC HL - SBC A,C - LD C,A - LD A,(HL) - SBC A,B - LD B,A - CALL C,L34E4 - OR C - OR D - JR NZ,L34B7 ; (+005H) - LD A,E - CP 03FH - JR C,L348E ; (-029H) -L34B7: LD HL,L3402 -L34BA: LD A,B - OR A - JP M,L347F - JR NZ,L34D4 ; (+013H) - LD A,(HL) - SUB 008H - JR C,L348E ; (-038H) - LD (HL),A - LD A,C - OR D - OR E - JR Z,L348E ; (-03eH) - LD B,C - LD C,D - LD D,E - LD E,000H - JP L34BA - -L34D4: DEC (HL) - JR C,L348E ; (-049H) - SLA E - RL D - RL C - RL B - JP P,L34D4 - JR L347F ; (-065H) - -L34E4: LD HL,L3401 - LD A,(HL) - ADD A,080H - LD (HL),A - LD A,E - CPL - ADD A,001H - LD E,A - LD A,D - CPL - ADC A,000H - LD D,A - LD A,C - CPL - ADC A,000H - LD C,A - LD A,B - CPL - ADC A,000H - LD B,A - RET - -L3500: PUSH DE - LD A,(DE) - XOR (HL) - CPL - AND 080H - LD (L3401),A - LD B,(HL) - RES 7,B - LD A,(DE) - AND 07FH - ADD A,B - JP Z,L348E - DEC A -L3514: CP 030H - JP C,L348E - CP 0E0H - JP NC,OVFLERR - LD (L3402),A - XOR A - LD (L3400),A - LD BC,00004H - ADD HL,BC - LD A,(HL) - OR A - JP P,L348E - PUSH HL - POP IY - LD C,B - EX DE,HL - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - PUSH HL - LD H,B - LD L,B - EXX - POP HL - LD E,(HL) - INC HL - LD D,(HL) - LD HL,MONIT - LD A,D - OR A - JP P,L348E - LD C,004H -L354A: LD A,(IY+000H) - LD B,008H - OR A - JR Z,L35C5 ; (+073H) -L3552: RLA - JR NC,L3569 ; (+014H) - EX AF,AF' - EXX - LD A,B - ADD A,C - LD C,A - ADC HL,DE - EXX - ADC HL,DE - JR NC,L3568 ; (+007H) - LD A,(L3400) - INC A - LD (L3400),A -L3568: EX AF,AF' -L3569: SRL D - RR E - EXX - RR D - RR E - RR B - EXX - DJNZ L3552 ; (-025H) -L3577: DEC IY - DEC C - JR NZ,L354A ; (-032H) - LD A,(L3400) - OR A - JR Z,L3599 ; (+017H) - LD B,A - LD A,(L3402) - ADD A,B - LD (L3402),A -L358A: SCF - RR H - RR L - EXX - RR H - RR L - RR C - EXX - DJNZ L358A ; (-00fH) -L3599: EXX - LD A,C - OR A - JP P,L35BD - LD DE,00001H - ADD HL,DE - EXX - LD DE,MONIT - ADC HL,DE - JR NC,L35BC ; (+011H) - RR H - RR L - EXX - RR H - RR L - EXX - LD A,(L3402) - INC A - LD (L3402),A -L35BC: EXX -L35BD: PUSH HL - EXX - LD B,H - LD C,L - POP DE - JP L34B7 - -L35C5: LD A,E - LD E,D - LD D,000H - EXX - LD B,E - LD E,D - LD D,A - EXX - JR L3577 ; (-059H) - -L35D0: PUSH DE - LD A,(DE) - XOR (HL) - CPL - AND 080H - LD (L3401),A - LD B,(HL) - RES 7,B - LD A,(DE) - AND 07FH - SUB B - ADD A,081H -L35E2: CP 030H - JP C,L348E - CP 0E0H - JP NC,OVFLERR - LD (L3402),A - INC HL - INC DE - EX DE,HL - LD C,(HL) - INC HL - LD B,(HL) - INC HL - PUSH HL - EX DE,HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD A,L - EX AF,AF' - LD A,H - LD H,B - LD L,C - EXX - POP HL - LD C,(HL) - INC HL - LD B,(HL) - LD H,A - EX AF,AF' - LD L,A - LD E,(HL) - INC HL - LD D,(HL) - LD H,B - LD L,C - LD A,D - OR A - JP P,OVFLERR - LD C,004H -L3615: LD B,008H -L3617: BIT 7,H - JR NZ,L3633 ; (+018H) - OR A -L361C: RLA - EXX - ADD HL,HL - EXX - ADC HL,HL - DJNZ L3617 ; (-00dH) - PUSH AF - DEC C - JR NZ,L3615 ; (-013H) -L3628: POP AF - LD E,A - POP AF - LD D,A - POP AF - LD C,A - POP AF - LD B,A - JP L34B7 - -L3633: EXX - OR A - SBC HL,DE - EXX - SBC HL,DE - CCF - JR C,L361C ; (-021H) - EXX - ADD HL,DE - EXX - ADC HL,DE - OR A - RLA - EXX - ADD HL,HL - EXX - ADC HL,HL - DEC B - JR NZ,L3652 ; (+006H) - PUSH AF - LD B,008H - DEC C - JR Z,L3628 ; (-02aH) -L3652: EXX - OR A - SBC HL,DE - EXX - SBC HL,DE - SCF - RLA - DEC B - JR NZ,L3664 ; (+006H) - PUSH AF - LD B,008H - DEC C - JR Z,L3628 ; (-03cH) -L3664: EXX - ADD HL,HL - EXX - ADC HL,HL - JR NC,L3617 ; (-054H) - JR L3652 ; (-01bH) - -L366D: DEC E -L366E: XOR C - LD D,B -L3670: LD A,(HL) - PUSH HL - POP IX - EX DE,HL - LD (L366E),HL - EX AF,AF' - XOR A - LD (L366D),A - LD H,A - LD L,A - EXX - LD H,A - LD L,A - LD B,A - LD C,A - EX AF,AF' - CP 02EH - JR Z,L369D ; (+014H) - SUB 030H -L368B: CALL L3772 - CALL L3768 - SUB 030H - CP 00AH - JR C,L368B ; (-00cH) - ADD A,030H - CP 02EH - JR NZ,L36AD ; (+010H) -L369D: CALL L3768 - SUB 030H - CP 00AH - JR NC,L36AB ; (+005H) - CALL L3780 - JR L369D ; (-00eH) - -L36AB: ADD A,030H -L36AD: CP 045H - JR NZ,L36F5 ; (+044H) - EXX - CALL L3768 - LD B,001H - CP 02BH - JR Z,L36C1 ; (+006H) - CP 02DH - JP NZ,SYNTAXERR - DEC B -L36C1: LD A,B - OR A - EX AF,AF' - CALL L3768 - SUB 030H - NOP - NOP - CP 00AH - JR NC,L36EB ; (+01cH) - LD B,A - CALL L3768 - SUB 030H - CP 00AH - JR NC,L36EB ; (+012H) - LD C,A - CALL L3768 - SUB 030H - CP 00AH - JP C,OVFLERR - LD A,B - ADD A,A - ADD A,A - ADD A,B - ADD A,A - ADD A,C - LD B,A -L36EB: EX AF,AF' - LD A,B - JR NZ,L36F1 ; (+002H) - CPL - INC A -L36F1: LD (L366D),A - EXX -L36F5: PUSH IX - LD A,(L366D) - ADD A,01DH - ADD A,C - LD (L366D),A - CP 030H - JR C,L370B ; (+007H) - CP 080H - JP C,OVFLERR - JR L375D ; (+052H) - -L370B: LD A,080H - LD (L3401),A - LD A,0A0H - LD (L3402),A - PUSH HL - EXX - POP BC - LD D,H - LD E,L - LD HL,L3725 - PUSH HL - LD HL,(L366E) - PUSH HL - JP L34B7 - -L3725: LD A,(L366D) - LD L,A - LD C,A - LD H,000H - LD B,H - ADD HL,HL - ADD HL,HL - ADD HL,BC - LD BC,L37AE - ADD HL,BC - LD DE,(0366EH) - LD A,080H - LD (L3401),A - LD A,020H - ADD A,(HL) - LD B,A - LD A,(DE) - AND 07FH - ADD A,B - JP C,OVFLERR - SUB 021H - JR NC,L374D ; (+001H) - XOR A -L374D: LD BC,L3755 - PUSH BC - PUSH DE - JP L3514 - -L3755: POP HL - LD BC,00005H - LD D,B - LD E,B - LD A,(HL) - RET - -L375D: LD HL,L3755 - PUSH HL - LD HL,(L366E) - PUSH HL - JP L348E - -L3768: INC IX - LD A,(IX+000H) - CP 020H - RET NZ - JR L3768 ; (-00aH) - -L3772: OR A - JR NZ,L3778 ; (+003H) - OR B - RET Z - XOR A -L3778: EX AF,AF' - LD A,B - CP 009H - JR NZ,L378E ; (+010H) - INC C - RET - -L3780: OR A - JR NZ,L3788 ; (+005H) - DEC C - OR B - RET Z - INC C - XOR A -L3788: EX AF,AF' - LD A,B - CP 009H - RET Z - DEC C -L378E: INC B - LD D,H - LD E,L - EXX - LD D,H - LD E,L - XOR A - ADD HL,HL - RLA - ADD HL,HL - RLA - ADD HL,DE - LD D,000H - ADC A,D - ADD HL,HL - RLA - EX AF,AF' - LD E,A - EX AF,AF' - ADD HL,DE - ADC A,D - EXX - ADD HL,HL - ADD HL,HL - ADD HL,DE - ADD HL,HL - LD D,000H - LD E,A - ADD HL,DE - RET - -L37AE: DB 0E0H - DB 0F5H - DB 0F7H - DB 0D2H - DB 0CAH - DB 0E3H - DB 0F3H - DB 0B5H - DB 087H - DB 0FDH - DB 0E7H - DB 0B8H - DB 0D1H - DB 074H - DB 09EH - DB 0EAH - DB 025H - DB 006H - DB 012H - DB 0C6H - DB 0EDH - DB 0AFH - DB 087H - DB 096H - DB 0F7H - DB 0F1H - DB 0CDH - DB 014H - DB 0BEH - DB 09AH - DB 0F4H - DB 001H - DB 09AH - DB 06DH - DB 0C1H - DB 0F7H - DB 081H - DB 000H - DB 0C9H - DB 0F1H - DB 0FBH - DB 050H - DB 0A0H - DB 01DH - DB 097H -L37DB: DB 0FEH - DB 065H - DB 008H - DB 0E5H - DB 0BCH - DB 001H - DB 07EH - DB 04AH - DB 01EH - DB 0ECH - DB 005H - DB 08FH - DB 0EEH - DB 092H - DB 093H - DB 008H - DB 032H - DB 0AAH - DB 077H - DB 0B8H - DB 00BH - DB 0BFH - DB 094H - DB 095H - DB 0E6H - DB 00FH - DB 0F7H - DB 07CH - DB 01DH - DB 090H - DB 012H - DB 035H - DB 0DCH - DB 024H - DB 0B4H - DB 015H - DB 042H - DB 013H - DB 02EH - DB 0E1H - DB 019H - DB 009H - DB 0CCH - DB 0BCH - DB 08CH - DB 01CH - DB 00CH - DB 0FFH - DB 0EBH - DB 0AFH - DB 01FH - DB 0CFH - DB 0FEH - DB 0E6H - DB 0DBH - DB 023H - DB 041H - DB 05FH - DB 070H - DB 089H - DB 026H - DB 012H - DB 077H - DB 0CCH - DB 0ABH - DB 029H - DB 0D6H - DB 094H - DB 0BFH - DB 0D6H - DB 02DH - DB 006H - DB 0BDH - DB 037H - DB 086H - DB 030H - DB 047H - DB 0ACH - DB 0C5H - DB 0A7H - DB 033H - DB 059H - DB 017H - DB 0B7H - DB 0D1H - DB 037H - DB 098H - DB 06EH - DB 012H - DB 083H - DB 03AH - DB 03DH - DB 00AH - DB 0D7H - DB 0A3H - DB 03DH - DB 0CDH - DB 0CCH - DB 0CCH - DB 0CCH - DB 041H - DB 000H - DB 000H - DB 000H - DB 080H - DB 044H - DB 000H - DB 000H - DB 000H - DB 0A0H - DB 047H - DB 000H - DB 000H - DB 000H - DB 0C8H - DB 04AH - DB 000H - DB 000H - DB 000H - DB 0FAH - DB 04EH - DB 000H - DB 000H - DB 040H - DB 09CH - DB 051H - DB 000H - DB 000H - DB 050H - DB 0C3H - DB 054H - DB 000H - DB 000H - DB 024H - DB 0F4H - DB 058H - DB 000H - DB 080H - DB 096H - DB 098H - DB 05BH - DB 000H - DB 020H - DB 0BCH - DB 0BEH - DB 05EH - DB 000H - DB 028H - DB 06BH - DB 0EEH - DB 062H - DB 000H - DB 0F9H - DB 002H - DB 095H - DB 065H - DB 040H - DB 0B7H - DB 043H - DB 0BAH - DB 068H - DB 010H - DB 0A5H - DB 0D4H - DB 0E8H - DB 06CH - DB 02AH - DB 0E7H - DB 084H - DB 091H - DB 06FH - DB 0F5H - DB 020H - DB 0E6H - DB 0B5H - DB 072H - DB 032H - DB 0A9H - DB 05FH - DB 0E3H - DB 076H - DB 0BFH - DB 0C9H - DB 01BH - DB 08EH - DB 079H - DB 02FH - DB 0BCH - DB 0A2H - DB 0B1H - DB 07CH - DB 03AH - DB 06BH - DB 00BH - DB 0DEH - DB 080H - DB 005H - DB 023H - DB 0C7H - DB 08AH -L38A3: DB 08DH - DB 06CH -L38A5: DB 001H -L38A6: DB 020H -L38A7: DB 031H -L38A8: DB 02EH - DB 035H - DB 00DH - DB 00DH - DB 00DH - DB 00DH - DB 00DH -L38AF: DB 00DH -L38B0: DB 00DH -L38B1: DB 000H -L38B2: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L38BB: PUSH DE - CALL L3997 - LD A,(L38A5) - OR A - JP Z,L3960 - JP M,L38CF - CP 009H - JR C,L392B ; (+05eH) - JR L38D4 ; (+005H) - -L38CF: CP PRTD - JP NC,L395B -L38D4: LD A,02EH - LD (L38A7),A - LD HL,L38B0 - XOR A -L38DD: DEC HL - CP (HL) - JR Z,L38DD ; (-004H) - LD A,(HL) - CP 02EH - JP Z,L398A - INC HL - LD (HL),045H - INC HL - LD A,(L38A5) - LD B,02BH - OR A - JP P,L38FD - CP 0EDH - JP C,L398A - LD B,02DH - CPL - INC A -L38FD: LD (HL),B - INC HL - LD BC,0FF0AH -L3902: INC B - SUB C - JR NC,L3902 ; (-004H) - ADD A,C - LD (HL),B - INC HL - LD (HL),A - INC HL - LD (HL),00DH -L390D: LD HL,L38A6 -L3910: INC HL - LD A,(HL) - CP 00DH - JR Z,L391D ; (+007H) - JR NC,L3910 ; (-008H) - OR 030H - LD (HL),A - JR L3910 ; (-00dH) - -L391D: LD DE,L38A6 - XOR A - SBC HL,DE - LD B,H - LD C,L - POP HL - EX DE,HL - INC BC - LDIR - RET - -L392B: LD HL,L38A8 - LD DE,L38A7 - LD B,A - INC B -L3933: DEC B - JR Z,L393C ; (+006H) - LD A,(HL) - LD (DE),A - INC HL - INC DE - JR L3933 ; (-009H) - -L393C: LD A,02EH - LD (DE),A - LD HL,L38B0 -L3942: LD (HL),00DH - DEC HL - LD A,(HL) - OR A - JR Z,L3942 ; (-007H) - CP 02EH - JR NZ,L394F ; (+002H) - LD (HL),00DH -L394F: LD HL,L38A7 - LD A,(HL) - CP 00DH - JR NZ,L390D ; (-04aH) - LD (HL),000H - JR L390D ; (-04eH) - -L395B: LD DE,L38B2 - JR L3963 ; (+003H) - -L3960: LD DE,L38B1 -L3963: LD HL,L38AF - LD A,00DH - LD (DE),A - PUSH DE - DEC DE - LD BC,00008H - LDDR - EX DE,HL - LD A,(L38A5) - OR A - JR Z,L397A ; (+003H) - LD (HL),000H - DEC HL -L397A: LD (HL),02EH - DEC HL - LD (HL),000H - POP HL -L3980: DEC HL - LD A,(HL) - CP 000H - JR NZ,L390D ; (-079H) - LD (HL),00DH - JR L3980 ; (-00aH) - -L398A: LD HL,L3994 - LD BC,GETL - POP DE - LDIR - RET - -L3994: JR NZ,L39C6 ; (+030H) - DEC C -L3997: LD (L38A3),HL - LD A,(HL) - LD B,020H - OR A - JP M,L39A3 - LD B,02DH -L39A3: AND 07FH - LD (HL),A - LD A,B - LD (L38A6),A - EX DE,HL - LD HL,L37DB - LD A,0ECH - EX AF,AF' -L39B1: EX AF,AF' - INC A - EX AF,AF' - LD BC,00005H - ADD HL,BC - PUSH HL - PUSH DE - LD A,(DE) - CALL L3A73 - POP DE - POP HL - JR NC,L39B1 ; (-011H) - EX AF,AF' - LD (L38A5),A -L39C6: PUSH DE - LD BC,L39D8 - PUSH BC - PUSH DE - LD A,080H - LD (L3401),A - LD A,(DE) - SUB (HL) - ADD A,081H - JP L35E2 - -L39D8: LD HL,L38A7 - LD (HL),000H - INC HL - EX (SP),HL - LD A,(HL) - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - PUSH HL - EX DE,HL - EXX - POP HL - LD E,(HL) - INC HL - LD D,(HL) - EX DE,HL - SUB 0C0H - JR NC,L39FE ; (+00dH) -L39F1: SRL H - RR L - EXX - RR H - RR L - EXX - INC A - JR NZ,L39F1 ; (-00dH) -L39FE: POP BC - LD A,009H -L3A01: EX AF,AF' - XOR A - LD D,H - LD E,L - EXX - LD D,H - LD E,L - ADD HL,HL - EXX - ADC HL,HL - RLA - EXX - ADD HL,HL - EXX - ADC HL,HL - RLA - EXX - ADD HL,DE - EXX - ADC HL,DE - LD D,000H - ADC A,D - EXX - ADD HL,HL - EXX - ADC HL,HL - RLA - LD (BC),A - INC BC - EX AF,AF' - DEC A - JR NZ,L3A01 ; (-026H) -L3A27: LD HL,L38B0 - LD A,(HL) - LD (HL),000H - CP 005H - LD C,000H - JR C,L3A34 ; (+001H) - INC C -L3A34: LD B,00AH -L3A36: DEC B - JR Z,L3A47 ; (+00eH) - DEC HL - LD A,(HL) - ADD A,C - LD (HL),A - SUB 00AH - LD C,000H - JR C,L3A36 ; (-00dH) - INC C - LD (HL),A - JR L3A36 ; (-011H) - -L3A47: LD A,(L38A7) - OR A - RET Z - LD HL,L38AF - LD DE,L38B0 - LD BC,NL - LDDR - EX DE,HL - LD (HL),000H - LD A,(L38A5) - INC A - LD (L38A5),A - JR L3A27 ; (-03cH) - -L3A63: LD BC,00005H -L3A66: LD A,(DE) - OR A - JP M,L3A73 - BIT 7,(HL) - JR Z,L3A71 ; (+002H) - SCF - RET - -L3A71: EX DE,HL - LD A,(DE) -L3A73: CP (HL) - RET NZ - DEC C - ADD HL,BC - EX DE,HL - ADD HL,BC - EX DE,HL - LD B,003H -L3A7C: LD A,(DE) - CP (HL) - RET NZ - DEC HL - DEC DE - DJNZ L3A7C ; (-007H) - LD A,(DE) - CP (HL) - RET - -L3A86: EX DE,HL - CALL L3997 - LD A,(L38A6) - LD B,080H - CP 020H - JR Z,L3A95 ; (+002H) - LD B,000H -L3A95: LD A,B - LD (L3401),A - OR A - JR Z,L3B1A ; (+07eH) - LD A,(L38A5) - DEC A - JP M,L3B50 - LD HL,L38B0 - LD B,00DH - LD (HL),B - SUB 008H - JR NC,L3AB3 ; (+006H) -L3AAD: LD (HL),B - DEC HL - INC A - JR NZ,L3AAD ; (-005H) - DEC A -L3AB3: INC A - LD (L366D),A - LD IX,L38A7 - XOR A - LD H,A - LD L,A - EXX - LD B,A - LD C,A - LD H,A - LD L,A -L3AC3: LD A,(IX+000H) - CP 00DH - JR Z,L3AD1 ; (+007H) - CALL L3772 - INC IX - JR L3AC3 ; (-00eH) - -L3AD1: LD A,(L366D) - ADD A,01DH - ADD A,C - LD (L366D),A - LD A,0A0H - LD (L3402),A - PUSH HL - EXX - POP BC - LD D,H - LD E,L - LD HL,L3AEF - PUSH HL - LD HL,(L38A3) - PUSH HL - JP L34B7 - -L3AEF: LD A,(L366D) - LD C,A - LD L,A - LD H,000H - LD B,H - ADD HL,HL - ADD HL,HL - ADD HL,BC - LD BC,L37AE - ADD HL,BC - LD DE,(038A3H) - XOR A - LD (L3400),A - LD A,020H - ADD A,(HL) - LD B,A - LD A,(DE) - AND 07FH - ADD A,B - JP C,OVFLERR - SUB 021H - JR NC,L3B16 ; (+001H) - XOR A -L3B16: PUSH DE - JP L3514 - -L3B1A: LD A,(L38A5) - DEC A - JP M,L3B55 - LD HL,L38B0 - LD BC,00D00H - LD (HL),B - SUB 008H - JR NC,L3B3B ; (+00fH) - JR L3B36 ; (+008H) - -L3B2E: EX AF,AF' - LD A,(HL) - OR A - JR Z,L3B34 ; (+001H) - INC C -L3B34: LD (HL),B - EX AF,AF' -L3B36: DEC HL - INC A - JR NZ,L3B2E ; (-00cH) - DEC A -L3B3B: EX AF,AF' - LD A,C - OR A - JR Z,L3B4C ; (+00cH) -L3B40: LD A,(HL) - INC A - LD (HL),A - CP 00AH - JR NZ,L3B4C ; (+005H) - LD (HL),000H - DEC HL - JR L3B40 ; (-00cH) - -L3B4C: EX AF,AF' - JP L3AB3 - -L3B50: LD DE,L2A8D - JR L3B58 ; (+003H) - -L3B55: LD DE,L2A92 -L3B58: LD HL,(L38A3) - EX DE,HL -L3B5C: LD BC,00005H - LDIR - RET - -L3B62: PUSH DE - CALL L3A63 - JR Z,L3B6D ; (+005H) -L3B68: LD HL,L2A92 - JR L3B70 ; (+003H) - -L3B6D: LD HL,L2A8D -L3B70: POP DE - JR L3B5C ; (-017H) - -L3B73: PUSH DE - EX DE,HL - JR L3B78 ; (+001H) - -L3B77: PUSH DE -L3B78: CALL L3A63 - JR C,L3B68 ; (-015H) - JR L3B6D ; (-012H) - -L3B7F: PUSH DE - CALL L3A63 - JR Z,L3B68 ; (-01dH) - JR L3B6D ; (-01aH) - -L3B87: PUSH DE - EX DE,HL - JR L3B8C ; (+001H) - -L3B8B: PUSH DE -L3B8C: CALL L3A63 - JR C,L3B6D ; (-024H) - JR L3B68 ; (-02bH) - -L3B93: CP (HL) - DEC (HL) - JR Z,L3B73 ; (-024H) - RST 008H -L3B98: PUSH DE - EX DE,HL - LD A,(HL) - LD BC,00004H - ADD HL,BC - XOR (HL) - JP M,L3BC4 - LD DE,L3B93 - PUSH DE - LD HL,L3BE9 - CALL L3500 - POP HL - PUSH HL - LD A,(HL) - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD C,(HL) - INC HL - LD B,(HL) - CP 0C1H - CALL NC,L3BD2 - POP HL - PUSH HL - CALL L3492 - JR L3BCE ; (+00aH) - -L3BC4: LD DE,L3B93 - LD HL,L3BE4 - PUSH DE - CALL L3B5C -L3BCE: POP HL - POP DE - JR L3B5C ; (-076H) - -L3BD2: SUB 0C0H -L3BD4: SLA E - RL D - RL C - RL B - DEC A - JR NZ,L3BD4 ; (-00bH) - LD A,0C0H - JP L3CC5 - -L3BE4: CP (HL) - DEC (HL) - JR Z,L3BC4 ; (-024H) - RST 008H -L3BE9: DB 0C5H - DB 000H - DB 000H - DB 000H - DB 0B8H -L3BEE: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L3BF3: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L3BF8: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L3BFD: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L3C02: LD DE,L3BEE - JP L3405 - -L3C08: CALL L3C02 -L3C0B: LD HL,L3BF3 -L3C0E: LD DE,L3BEE - JP L3500 - -L3C14: NOP -L3C15: NOP -L3C16: PUSH DE - LD HL,L3CE7 - CALL L35D0 - POP HL - PUSH HL - LD A,(HL) - LD (L3C15),A - OR 080H - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD C,(HL) - INC HL - LD B,(HL) - CP 0C3H - JR C,L3C43 ; (+012H) - SUB 0C2H -L3C33: SLA E - RL D - RL C - RL B - DEC A - JR NZ,L3C33 ; (-00bH) - LD A,0C2H - CALL L3CC5 -L3C43: LD HL,08000H - CP 0C2H - JR C,L3C50 ; (+006H) - LD H,L - RES 7,B - CALL L3CC5 -L3C50: CP 0C1H - JR C,L3C5A ; (+006H) - INC L - RES 7,B - CALL L3CC5 -L3C5A: EX AF,AF' - LD A,(L3C15) - XOR H - CPL - AND 080H - LD H,A - LD (L3C14),HL - EX AF,AF' - POP HL - PUSH HL - CALL L3492 - LD A,(L3C14) - OR A - JR Z,L3C7A ; (+008H) - POP DE - PUSH DE - LD HL,L2A88 - CALL L3403 -L3C7A: POP HL - PUSH HL - LD A,(HL) - AND 07FH - LD B,A - LD A,(L3C15) - OR B - LD (HL),A - LD DE,L3BEE - CALL L3B5C - LD DE,L3BF3 - LD HL,L3BEE - CALL L3B5C - CALL L3C0B - LD DE,L3BF3 - LD HL,L3BEE - CALL L3B5C - LD HL,L3CEC - CALL L3C0E - LD HL,L3CF1 - CALL L3C08 - LD HL,L3CF6 - CALL L3C08 - LD HL,L3CFB - CALL L3C08 - LD HL,L3D00 - CALL L3C02 - POP DE - LD HL,L3BEE - JP L3500 - -L3CC5: BIT 7,B - RET NZ - EX AF,AF' - LD A,B - OR C - OR E - OR D - JR Z,L3CDE ; (+00fH) - EX AF,AF' -L3CD0: BIT 7,B - RET NZ - SLA E - RL D - RL C - RL B - DEC A - JR NZ,L3CD0 ; (-00eH) -L3CDE: LD BC,MONIT - LD DE,MONIT - LD A,080H - RET - -L3CE7: DB 0C1H - DB 0A1H - DB 0DAH - DB 00FH - DB 0C9H -L3CEC: DB 0B4H - DB 0DCH - DB 00FH - DB 00AH - DB 09FH -L3CF1: DB 039H - DB 061H - DB 08FH - DB 029H - DB 099H -L3CF6: DB 0BDH - DB 0C8H - DB 077H - DB 034H - DB 0A3H -L3CFB: DB 040H - DB 085H - DB 0E1H - DB 05DH - DB 0A5H -L3D00: DB 0C1H - DB 094H - DB 0DAH - DB 00FH - DB 0C9H -L3D05: PUSH DE - LD HL,L3CE7 - CALL L3403 - POP HL - CALL L4193 - EX DE,HL - JP L3C16 - -L3D14: PUSH DE - EX DE,HL - LD DE,L3BFD - CALL L3B5C - POP DE - PUSH DE - CALL L3D05 - POP HL - PUSH HL - LD DE,L3BF8 - CALL L3B5C - POP DE - PUSH DE - LD HL,L3BFD - CALL L3B5C - POP DE - PUSH DE - CALL L3C16 - POP DE - LD HL,L3BF8 - JP L35D0 - -L3D3D: NOP -L3D3E: NOP -L3D3F: LD A,003H - LD (L3D3D),A - PUSH DE - EX DE,HL - LD A,(HL) - ADD A,080H - JP NC,ILDATERR - JR NZ,L3D5B ; (+00dH) - EX AF,AF' - LD BC,00004H - ADD HL,BC - LD A,(HL) - SBC HL,BC - OR A - JP P,L3DBA - EX AF,AF' -L3D5B: BIT 0,A - JR NZ,L3DD5 ; (+076H) - LD (L3D3E),A - LD (HL),0C0H - LD DE,L3BEE - CALL L3B5C - LD HL,L3DED - CALL L3C0E - LD HL,L3DF2 -L3D73: CALL L3C02 -L3D76: LD DE,L3BF3 - POP HL - PUSH HL - CALL L3B5C - LD DE,L3BF3 - LD HL,L3BEE - CALL L35D0 - LD HL,L3BF3 - CALL L3C02 - LD HL,L3BEE - LD A,(HL) - AND 07FH - DEC A - JR C,L3DBA ; (+024H) - OR 080H - LD (HL),A - LD A,(L3D3D) - DEC A - LD (L3D3D),A - JR NZ,L3D76 ; (-02cH) - LD A,(L3D3E) - CP 040H - CALL NZ,L3DC1 - LD B,(HL) - RES 7,B - ADD A,B - SUB 040H - JR C,L3DBA ; (+008H) - JP M,OVFLERR - OR 080H - LD (HL),A - JR L3DBD ; (+003H) - -L3DBA: LD HL,L2A8D -L3DBD: POP DE - JP L3B5C - -L3DC1: JR C,L3DCA ; (+007H) - SUB 040H - SRL A - ADD A,040H - RET - -L3DCA: LD B,A - LD A,040H - SUB B - SRL A - LD B,A - LD A,040H - SUB B - RET - -L3DD5: INC A - LD (L3D3E),A - LD (HL),0BFH - LD DE,L3BEE - CALL L3B5C - LD HL,L3DF7 - CALL L3C0E - LD HL,L3DFC - JP L3D73 - -L3DED: DB 0C0H - DB 000H - DB 000H - DB 000H - DB 090H -L3DF2: DB 0BFH - DB 000H - DB 000H - DB 000H - DB 0E0H -L3DF7: DB 0C0H - DB 000H - DB 000H - DB 000H - DB 0E0H -L3DFC: DB 0BFH - DB 000H - DB 000H - DB 000H - DB 090H -L3E01: NOP -L3E02: NOP -L3E03: PUSH DE - LD A,(DE) - AND 080H - LD (L3E01),A - LD A,(DE) - OR 080H - LD (DE),A - LD HL,L3F2D - CALL L35D0 - POP HL - PUSH HL - LD A,040H - LD (L3E02),A - LD A,(HL) - SUB 0C1H - CALL NC,L3EBB - POP DE - PUSH DE - LD HL,L3F28 - CALL L3403 - POP HL - PUSH HL - LD DE,L3BEE - CALL L3B5C - LD HL,L3F05 - CALL L3C0E - LD HL,L3F0A - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD HL,L3F0F - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD HL,L3F14 - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD HL,L3F19 - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD HL,L3F1E - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD HL,L3F23 - CALL L3C02 - LD HL,L3BEE - LD B,(HL) - RES 7,B - LD A,(L3E02) - ADD A,B - JP C,L3EFC - SUB 03FH - JR C,L3EEC ; (+067H) - JP M,L3EFC - OR 080H - LD (HL),A - LD A,(L3E01) - OR A - JR Z,L3E98 ; (+007H) - LD HL,L3BEE - POP DE - JP L3B5C - -L3E98: POP DE - PUSH DE - LD HL,L2A88 - CALL L3B5C - POP DE - PUSH DE - LD A,(DE) - CP 0FCH - PUSH AF - JR C,L3EAA ; (+002H) - DEC A - LD (DE),A -L3EAA: LD HL,L3BEE - CALL L35D0 - POP AF - POP HL - RET C - LD A,(HL) - DEC A - LD (HL),A - RET M - PUSH HL - JP L348E - -L3EBB: INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD C,(HL) - INC HL - LD B,(HL) - PUSH HL - INC A - LD H,A - XOR A -L3EC7: SLA E - RL D - RL C - RL B - RLA - JR C,L3EFA ; (+028H) - DEC H - JR NZ,L3EC7 ; (-00eH) - ADD A,040H - JR C,L3EFA ; (+021H) - LD (L3E02),A - LD A,0C0H - CALL L3CC5 - POP HL - LD (HL),B - DEC HL - LD (HL),C - DEC HL - LD (HL),D - DEC HL - LD (HL),E - DEC HL - LD (HL),A - RET - -L3EEC: LD A,(L3E01) - OR A - JP Z,OVFLERR -L3EF3: LD HL,L2A8D - POP DE - JP L3B5C - -L3EFA: POP AF - POP AF -L3EFC: LD A,(L3E01) - OR A - JP NZ,OVFLERR - JR L3EF3 ; (-012H) - -L3F05: DB 0B3H - DB 07CH - DB 08CH - DB 090H - DB 0E3H -L3F0A: DB 0B6H - DB 01FH - DB 0DFH - DB 062H - DB 0F8H -L3F0F: DB 0B9H - DB 0E2H - DB 06DH - DB 0DDH - DB 0DEH -L3F14: DB 0BCH - DB 08BH - DB 033H - DB 0C1H - DB 0A0H -L3F19: DB 0BEH - DB 089H - DB 04AH - DB 0F1H - DB 0ADH -L3F1E: DB 0BFH - DB 034H - DB 033H - DB 0F2H - DB 0FAH -L3F23: DB 0C0H - DB 036H - DB 0F3H - DB 004H - DB 0B5H -L3F28: DB 0C0H - DB 000H - DB 000H - DB 000H - DB 080H -L3F2D: DB 0C0H - DB 0F8H - DB 017H - DB 072H - DB 0B1H -L3F32: DB 000H -L3F33: DB 000H -L3F34: DB 000H -L3F35: PUSH DE - LD A,080H - LD (L3F33),A - LD (L3F32),A - EX DE,HL - LD A,(HL) - OR A - JP P,OVFLERR - CP 08AH - JR NC,L3F53 ; (+00bH) - XOR A - LD (L3F32),A - EX DE,HL - CALL L3D3F - POP HL - PUSH HL - LD A,(HL) -L3F53: CP 0C1H - CALL C,L4011 - LD B,000H - CP 0C1H - JR Z,L3F64 ; (+006H) - SUB 0C1H - LD B,A - LD A,0C1H - LD (HL),A -L3F64: LD A,B - LD (L3F34),A - LD DE,L3BEE - CALL L3B5C - POP DE - PUSH DE - LD HL,L4055 - CALL L3403 - LD HL,L4055 - CALL L3C02 - POP DE - PUSH DE - LD HL,L3BEE - CALL L35D0 - POP DE - PUSH DE - LD HL,L405A - CALL L3500 - POP HL - PUSH HL - LD DE,L3BF3 - CALL L3B5C - POP HL - PUSH HL - LD DE,L3BF3 - CALL L3500 - LD DE,L3BEE - LD HL,L3BF3 - CALL L3B5C - LD HL,L4041 - CALL L3C0E - LD HL,L4046 - CALL L3C08 - LD HL,L404B - CALL L3C08 - LD HL,L4050 - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - LD DE,L3BF3 - LD HL,L3BEE - CALL L3B5C - LD A,(L3F34) - ADD A,A - INC A - LD B,A - LD A,008H -L3FD3: BIT 7,B - JR NZ,L3FDC ; (+005H) - SLA B - DEC A - JR NZ,L3FD3 ; (-009H) -L3FDC: ADD A,0C0H - LD HL,L3BEE - LD (HL),A - INC HL - XOR A - LD (HL),A - INC HL - LD (HL),A - INC HL - LD (HL),A - INC HL - LD (HL),B - LD HL,L405F - CALL L3C0E - LD HL,L3BF3 - CALL L3C02 - LD HL,L3BEE - LD A,(L3F33) - CALL L4191 - POP DE - PUSH DE - CALL L3B5C - POP DE - LD A,(L3F32) - OR A - RET NZ - LD HL,L3BEE - JP L3405 - -L4011: PUSH HL - LD DE,L3BEE - CALL L3B5C - POP DE - PUSH DE - LD HL,L2A88 - CALL L3B5C - POP DE - PUSH DE - LD HL,L3BEE - CALL L35D0 - POP HL - LD A,(HL) - CP 0C1H - JR NC,L4039 ; (+00bH) - PUSH HL - EX DE,HL - LD HL,L2A88 - CALL L3B5C - POP HL - LD A,0C1H -L4039: EX AF,AF' - LD A,000H - LD (L3F33),A - EX AF,AF' - RET - -L4041: DB 0ADH - DB 0A4H - DB 062H - DB 0CCH - DB 0AFH -L4046: DB 0B2H - DB 09FH - DB 0E9H - DB 047H - DB 0F9H -L404B: DB 0B8H - DB 0A4H - DB 082H - DB 0AAH - DB 0DCH -L4050: DB 0BFH - DB 0BFH - DB 0CCH - DB 0B0H - DB 0AFH -L4055: DB 0C1H - DB 033H - DB 0F3H - DB 004H - DB 0B5H -L405A: DB 0C3H - DB 099H - DB 079H - DB 082H - DB 0BAH -L405F: DB 0BFH - DB 0F8H - DB 017H - DB 072H - DB 0B1H -L4064: PUSH DE - CALL L3F35 - POP DE - LD HL,L406F - JP L3500 - -L406F: DB 0BFH - DB 0A9H - DB 0D8H - DB 05BH - DB 0DEH -L4074: DB 000H -L4075: DB 000H -L4076: PUSH DE - EX DE,HL - LD A,(HL) - AND 080H - LD (L4074),A - SET 7,(HL) - LD DE,L2A88 - CALL L3A63 - LD A,080H - JR NC,L40A3 ; (+019H) - LD DE,L3BEE - POP HL - PUSH HL - CALL L3B5C - POP DE - PUSH DE - LD HL,L2A88 - CALL L3B5C - POP DE - PUSH DE - LD HL,L3BEE - CALL L35D0 - XOR A -L40A3: LD (L4075),A - POP HL - PUSH HL - LD DE,L3BEE - CALL L3B5C - POP HL - PUSH HL - CALL L3C0E - LD HL,L3BEE - LD DE,L3BF3 - CALL L3B5C - LD HL,L4121 - CALL L3C0E - LD HL,L4126 - CALL L3C08 - LD HL,L412B - CALL L3C08 - LD HL,L4130 - CALL L3C08 - LD HL,L4135 - CALL L3C08 - LD HL,L413A - CALL L3C08 - LD HL,L413F - CALL L3C08 - LD HL,L4144 - CALL L3C08 - LD HL,L4149 - CALL L3C08 - LD HL,L2A88 - CALL L3C02 - POP HL - PUSH HL - CALL L3C0E - POP DE - PUSH DE - LD HL,L3BEE - CALL L3B5C - LD A,(L4075) - OR A - JR NZ,L411B ; (+010H) - POP DE - PUSH DE - LD HL,L3CE7 - CALL L3B5C - POP DE - PUSH DE - LD HL,L3BEE - DB 0CDH - DB 003H -L411A: DB 034H -L411B: POP HL - LD A,(L4074) - JR L4191 ; (+070H) - -L4121: DB 037H - DB 0CAH - DB 09AH - DB 056H - DB 0DFH -L4126: DB 0BAH - DB 012H - DB 077H - DB 0CCH - DB 0ABH -L412B: DB 03BH - DB 023H - DB 0B2H - DB 05EH - DB 0F8H -L4130: DB 0BCH - DB 020H - DB 063H - DB 090H - DB 0E9H -L4135: DB 03DH - DB 0EEH - DB 03DH - DB 0E0H - DB 0AAH -L413A: DB 0BDH - DB 04FH - DB 01AH - DB 0D5H - DB 0DFH -L413F: DB 03EH - DB 0E3H - DB 0AFH - DB 003H - DB 092H -L4144: DB 0BEH - DB 02AH - DB 07BH - DB 0C7H - DB 0CCH -L4149: DB 03FH - DB 017H - DB 096H - DB 0AAH - DB 0AAH -L414E: DB 000H - DB 000H - DB 000H - DB 000H -L4152: DB 000H -L4153: DB 000H -L4154: DB 000H - DB 000H - DB 000H - DB 000H - DB 000H -L4159: PUSH DE - LD DE,L4154 - CALL L3B5C - POP HL - PUSH HL - LD BC,00004H - ADD HL,BC - LD A,(HL) - OR A - POP HL - PUSH HL - JP P,L348E - LD A,(HL) - AND 080H - LD (L4153),A - SET 7,(HL) - EX DE,HL - CALL L3F35 - LD A,(L4153) - OR A - CALL Z,L41A4 - POP DE - PUSH DE - LD HL,L4154 - CALL L3500 - POP DE - PUSH DE - CALL L3E03 - POP HL - LD A,(L4153) -L4191: OR A - RET NZ -L4193: LD BC,00004H - ADD HL,BC - BIT 7,(HL) - PUSH AF - XOR A - SBC HL,BC - POP AF - RET Z - LD A,(HL) - ADD A,080H - LD (HL),A - RET - -L41A4: LD HL,L4154 - LD DE,L414E - CALL L3B5C - LD DE,L4154 - CALL L3A86 - LD DE,L414E - LD HL,L4154 - CALL L3403 - LD HL,L4152 - LD A,(HL) - OR A - JP M,ILDATERR - LD HL,L4154 - LD A,(HL) - INC HL - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD C,(HL) - INC HL - LD B,(HL) - AND 07FH - SUB 041H - JR C,L41E6 ; (+010H) - JR Z,L41E3 ; (+00bH) -L41D8: SLA E - RL D - RL C - RL B - DEC A - JR NZ,L41D8 ; (-00bH) -L41E3: RL B - RET C -L41E6: LD A,080H - LD (L4153),A - RET - -L41EC: NOP - LD DE,ATRB - LD HL,L4223 - LD BC,PRNT - LDIR - LD HL,TAPECOPY - LD (DTADR),HL - LD DE,L41EC - EX DE,HL - XOR A - SBC HL,DE - INC HL - LD (SIZE),HL - LD HL,COLDSTRT - LD (EXADR),HL - CALL ?WRI - RET C - LD HL,L41EC - LD A,0C9H - LD (HL),A - CALL ?WRD - PUSH AF - LD A,000H - LD (HL),A - POP AF - RET C - RET - -L4223: DB 001H,"BASIC SA-5510",00DH - NOP diff --git a/software/dis/SA-5510/SA-5510.ini b/software/dis/SA-5510/SA-5510.ini deleted file mode 100644 index 9c01a64..0000000 --- a/software/dis/SA-5510/SA-5510.ini +++ /dev/null @@ -1,568 +0,0 @@ ----------------------------------------- --- dZ80 configuration file ----------------------------------------- - ----------------------------------------- --- Disassembly control ----------------------------------------- - -cpu="z80" -inputfile="SA-5510.bin" -outputfile="SA-5510.asm" ---fileheadersize=27 -filebaseaddr=4605 -disstart=0 -disend=16946 ---disstart=0 ---disend=3584 ---quiet=0 -labelledoutput=1 - ----------------------------------------- --- Layout ----------------------------------------- - -labelreference=1 -addresscolumn=1 -opcodecolumn=1 -relativejumpcomment=1 -uppercase=1 -autoblanklines=1 -db="db" -comment="; " -radix=16 -numprefix="0" -numsuffix="H" - ----------------------------------------- --- Scripts ----------------------------------------- - ---script="scripts\\spectrum.lua" - ----------------------------------------- --- References ----------------------------------------- - -referencefile="SA-5510.ref" -inportreference=1 -outportreference=1 -addressreference=1 -indirectaddressreference=1 -limitreferences=1 - ----------------------------------------- --- Opcode mapfile and code/data areas ----------------------------------------- - ---opmapfile="mayhem.map" - --- Code Region isnt required as v2.x sets the entire region to code unless a data region overrides it. --- d_SetCodeRegion(4608, 2464) - --- Set the known data regions, either as a data region (byte), word or string. The type affects the assembly output definitions and word --- regions will attempt to map to an address, ie. jump tables will be setup with labels rather than constants. -d_SetDataRegion( hex("1347"), 100) -- 0x1347 -d_SetStringRegion(hex("1347"), 28) -d_SetStringRegion(hex("1364"), 31) -d_SetStringRegion(hex("1384"), 5) -d_SetStringRegion(hex("138A"), 6) -d_SetStringRegion(hex("1391"), 3) -d_SetStringRegion(hex("1395"), 6) -d_SetStringRegion(hex("139C"), 6) -d_SetDataRegion( hex("2FC2"), 30) -d_SetStringRegion(hex("2FC2"), 6) -d_SetStringRegion(hex("2FC9"), 8) -d_SetStringRegion(hex("2FD2"), 10) -d_SetStringRegion(hex("2FDD"), 2) -d_SetStringRegion(hex("1D44"), 9) - --- Reserved key words. -d_SetDataRegion( hex("15A8"), 402) -- 0x15A8 Start of tokens. -d_SetStringRegion(hex("15A8"), 2) -- 0 - REM -d_SetStringRegion(hex("15AB"), 3) -- 1 - DATA -d_SetStringRegion(hex("15AF"), 0) -- 2 - undefined -d_SetStringRegion(hex("15B0"), 0) -- 3 - undefined -d_SetStringRegion(hex("15B1"), 3) -- 4 - READ -d_SetStringRegion(hex("15B5"), 3) -- 5 - LIST -d_SetStringRegion(hex("15B9"), 2) -- 6 - RUN -d_SetStringRegion(hex("15BC"), 2) -- 7 - NEW -d_SetStringRegion(hex("15BF"), 4) -- 8 - PRINT -d_SetStringRegion(hex("15C4"), 2) -- 9 - LET -d_SetStringRegion(hex("15C7"), 2) -- 10 - FOR -d_SetStringRegion(hex("15CA"), 1) -- 11 - IF -d_SetStringRegion(hex("15CC"), 3) -- 12 - THEN -d_SetStringRegion(hex("15D0"), 3) -- 13 - GOTO -d_SetStringRegion(hex("15D4"), 4) -- 14 - GOSUB -d_SetStringRegion(hex("15D9"), 5) -- 15 - RETURN -d_SetStringRegion(hex("15DF"), 3) -- 16 - NEXT -d_SetStringRegion(hex("15E3"), 3) -- 17 - STOP -d_SetStringRegion(hex("15E7"), 2) -- 18 - END -d_SetStringRegion(hex("15EA"), 0) -- 19 - undefined -d_SetStringRegion(hex("15EB"), 1) -- 20 - ON -d_SetStringRegion(hex("15ED"), 3) -- 21 - LOAD -d_SetStringRegion(hex("15F1"), 3) -- 22 - SAVE -d_SetStringRegion(hex("15F5"), 5) -- 23 - VERIFY -d_SetStringRegion(hex("15FB"), 3) -- 24 - POKE -d_SetStringRegion(hex("15FF"), 2) -- 25 - DIM -d_SetStringRegion(hex("1602"), 5) -- 26 - DEF FN -d_SetStringRegion(hex("1608"), 4) -- 27 - INPUT -d_SetStringRegion(hex("160D"), 6) -- 28 - RESTORE -d_SetStringRegion(hex("1614"), 2) -- 29 - CLS -d_SetStringRegion(hex("1617"), 4) -- 30 - MUSIC -d_SetStringRegion(hex("161C"), 4) -- 31 - TEMPO -d_SetStringRegion(hex("1621"), 3) -- 32 - USRN -d_SetStringRegion(hex("1625"), 4) -- 33 - WOPEN -d_SetStringRegion(hex("162A"), 4) -- 34 - ROPEN -d_SetStringRegion(hex("162F"), 4) -- 35 - CLOSE -d_SetStringRegion(hex("1634"), 2) -- 36 - MON -d_SetStringRegion(hex("1637"), 4) -- 37 - LIMIT -d_SetStringRegion(hex("163C"), 3) -- 38 - CONT -d_SetStringRegion(hex("1640"), 2) -- 39 - GET -d_SetStringRegion(hex("1643"), 3) -- 40 - INP@ -d_SetStringRegion(hex("1647"), 3) -- 41 - OUT@ -d_SetStringRegion(hex("164B"), 5) -- 42 - CURSOR -d_SetStringRegion(hex("1651"), 2) -- 43 - SET -d_SetStringRegion(hex("1654"), 4) -- 44 - RESET -d_SetStringRegion(hex("1659"), 0) -- 45 - undefined -d_SetStringRegion(hex("165A"), 0) -- 46 - undefined -d_SetStringRegion(hex("165B"), 0) -- 47 - undefined -d_SetStringRegion(hex("165C"), 0) -- 48 - undefined -d_SetStringRegion(hex("165D"), 0) -- 49 - undefined -d_SetStringRegion(hex("165E"), 0) -- 59 - undefined -d_SetStringRegion(hex("165F"), 3) -- 51 - AUTO -d_SetStringRegion(hex("1663"), 0) -- 52 - undefined -d_SetStringRegion(hex("1664"), 0) -- 53 - undefined -d_SetStringRegion(hex("1665"), 5) -- 54 - COPY/P -d_SetStringRegion(hex("166B"), 5) -- 55 - PAGE/P -d_SetStringRegion(hex("1671"), 0) -- 56 - undefined -d_SetStringRegion(hex("1672"), 0) -- 57 - undefined -d_SetStringRegion(hex("1673"), 0) -- 58 - undefined -d_SetStringRegion(hex("1674"), 0) -- 59 - undefined -d_SetStringRegion(hex("1675"), 0) -- 60 - undefined -d_SetStringRegion(hex("1676"), 0) -- 61 - undefined -d_SetStringRegion(hex("1677"), 0) -- 62 - undefined -d_SetStringRegion(hex("1678"), 0) -- 63 - undefined -d_SetStringRegion(hex("1679"), 0) -- 64 - undefined -d_SetStringRegion(hex("167A"), 0) -- 65 - undefined -d_SetStringRegion(hex("167B"), 1) -- 66 - undefined -d_SetStringRegion(hex("167D"), 1) -- 67 - undefined - --- Functions -d_SetStringRegion(hex("167F"), 1) -- >= -d_SetStringRegion(hex("1681"), 1) -- <> -d_SetStringRegion(hex("1683"), 1) -- =< -d_SetStringRegion(hex("1685"), 1) -- <= -d_SetStringRegion(hex("1687"), 1) -- <= -d_SetStringRegion(hex("1689"), 1) -- <= -d_SetStringRegion(hex("168B"), 0) -- undefined -d_SetStringRegion(hex("168C"), 0) -- <= -d_SetStringRegion(hex("168D"), 0) -- <= -d_SetStringRegion(hex("168E"), 0) -- undefined -d_SetStringRegion(hex("168F"), 0) -- undefined -d_SetStringRegion(hex("1690"), 0) -- undefined -d_SetStringRegion(hex("1691"), 0) -- undefined -d_SetStringRegion(hex("1692"), 0) -- undefined -d_SetStringRegion(hex("1693"), 0) -- undefined -d_SetStringRegion(hex("1694"), 0) -- undefined -d_SetStringRegion(hex("1695"), 0) -- undefined -d_SetStringRegion(hex("1696"), 0) -- undefined -d_SetStringRegion(hex("1697"), 0) -- undefined -d_SetStringRegion(hex("1698"), 0) -- undefined -d_SetStringRegion(hex("1699"), 0) -- undefined -d_SetStringRegion(hex("169A"), 0) -- undefined -d_SetStringRegion(hex("169B"), 0) -- undefined -d_SetStringRegion(hex("169C"), 0) -- undefined -d_SetStringRegion(hex("169D"), 0) -- undefined -d_SetStringRegion(hex("168E"), 0) -- undefined -d_SetStringRegion(hex("168F"), 0) -- undefined -d_SetStringRegion(hex("16A0"), 1) -- TO -d_SetStringRegion(hex("16A2"), 3) -- STEP -d_SetStringRegion(hex("16A6"), 5) -- LEFT$( -d_SetStringRegion(hex("16AC"), 6) -- RIGHT$( -d_SetStringRegion(hex("16B3"), 4) -- MID$( -d_SetStringRegion(hex("16B8"), 3) -- LEN( -d_SetStringRegion(hex("16BC"), 4) -- CHR$( -d_SetStringRegion(hex("16C1"), 4) -- STR$( -d_SetStringRegion(hex("16C6"), 3) -- ASC( -d_SetStringRegion(hex("16CA"), 3) -- VAL( -d_SetStringRegion(hex("16CE"), 4) -- PEEK( -d_SetStringRegion(hex("16D3"), 3) -- TAB( -d_SetStringRegion(hex("16D7"), 6) -- SPACE$( -d_SetStringRegion(hex("16DE"), 3) -- SIZE -d_SetStringRegion(hex("16E2"), 2) -- undefined -d_SetStringRegion(hex("16E5"), 6) -- STRING$( -d_SetStringRegion(hex("16ED"), 0) -- undefined -d_SetStringRegion(hex("16EE"), 10) -- CHARACTER$( -d_SetStringRegion(hex("16F9"), 2) -- CSR -d_SetStringRegion(hex("16FC"), 12) -- undefined -d_SetStringRegion(hex("1709"), 3) -- RND( -d_SetStringRegion(hex("170D"), 3) -- SIN( -d_SetStringRegion(hex("1711"), 3) -- COS( -d_SetStringRegion(hex("1715"), 3) -- TAN( -d_SetStringRegion(hex("1719"), 3) -- ATN( -d_SetStringRegion(hex("171D"), 3) -- EXP( -d_SetStringRegion(hex("1721"), 3) -- INT( -d_SetStringRegion(hex("1725"), 3) -- LOG( -d_SetStringRegion(hex("1729"), 2) -- LN( -d_SetStringRegion(hex("172C"), 3) -- ABS( -d_SetStringRegion(hex("1730"), 3) -- SGN( -d_SetStringRegion(hex("1734"), 3) -- SQR( -d_SetStringRegion(hex("1738"), 2) -- End of Table - - -d_SetDataRegion( hex("13AB"), 77) -- 0x13AB -d_SetStringRegion(hex("4223"), 15) -- 0x4223 BASIC SA-5510 -d_SetDataRegion( hex("1D15"), 2) -- 0x1D15 Data -d_SetDataRegion( hex("1C4C"), 1) -d_SetDataRegion( hex("1C63"), 1) -- 0x1C63 Data -d_SetWordRegion( hex("1BB2"), 128) -- 0x1BB2 Data -d_SetDataRegion( hex("3400"), 3) -- 0x3400 Data -d_SetDataRegion( hex("3404"), 1) -- 0x3404 Data -d_SetDataRegion( hex("2355"), 1) -- 0x2355 Data -d_SetDataRegion( hex("239F"), 1) -- 0x239f Data -d_SetWordRegion( hex("2691"), 34) -d_SetWordRegion( hex("26B3"), 40) -d_SetWordRegion( hex("26DB"), 24) -d_SetDataRegion( hex("26F3"), 6) -d_SetDataRegion( hex("27B2"), 2) -- 0x27B2 Data -d_SetDataRegion( hex("2884"), 1) -- 0x2885 Data -d_SetDataRegion( hex("2A83"), 25) -- 0x2A83 Data ---d_SetDataRegion( hex("2B3D"), 2) -- 0x2B3D Data ---d_SetDataRegion( hex("2D1D"), 2) -- 0x2D1D Data - --- Function table. -d_SetWordRegion( hex("22E1"), 18) - --- Function calls, CALL -d_SetDataRegion( hex("204A"), 2) -d_SetDataRegion( hex("12CE"), 1) -d_SetWordRegion( hex("12CF"), 2) -d_SetDataRegion( hex("1A78"), 1) -d_SetWordRegion( hex("1A79"), 2) -d_SetDataRegion( hex("1C54"), 1) -d_SetWordRegion( hex("1C55"), 2) -d_SetDataRegion( hex("1E23"), 1) -d_SetWordRegion( hex("1E24"), 2) -d_SetDataRegion( hex("20EB"), 1) -d_SetWordRegion( hex("20EC"), 2) -d_SetDataRegion( hex("21B3"), 1) -d_SetWordRegion( hex("21B4"), 2) -d_SetDataRegion( hex("287F"), 1) -d_SetWordRegion( hex("2880"), 2) -d_SetDataRegion( hex("2949"), 1) -d_SetWordRegion( hex("294A"), 2) -d_SetDataRegion( hex("29A2"), 1) -d_SetWordRegion( hex("29A3"), 2) -d_SetDataRegion( hex("2A3A"), 1) -d_SetWordRegion( hex("2A3B"), 2) -d_SetDataRegion( hex("2A4E"), 1) -d_SetWordRegion( hex("2A4F"), 2) -d_SetDataRegion( hex("2B10"), 1) -d_SetWordRegion( hex("2B11"), 2) -d_SetDataRegion( hex("2B32"), 1) -d_SetWordRegion( hex("2B33"), 2) -d_SetDataRegion( hex("2B6C"), 1) -d_SetWordRegion( hex("2B6D"), 2) -d_SetDataRegion( hex("2C05"), 1) -d_SetWordRegion( hex("2C06"), 2) -d_SetDataRegion( hex("2CFF"), 1) -d_SetWordRegion( hex("2D00"), 2) -d_SetDataRegion( hex("2D56"), 1) -d_SetWordRegion( hex("2D57"), 2) -d_SetDataRegion( hex("2D5C"), 1) -d_SetWordRegion( hex("2D5D"), 2) -d_SetDataRegion( hex("2CB2"), 1) -d_SetWordRegion( hex("2CB3"), 2) -d_SetDataRegion( hex("2D78"), 1) -d_SetWordRegion( hex("2D79"), 2) -d_SetDataRegion( hex("2D88"), 1) -d_SetWordRegion( hex("2D89"), 2) -d_SetDataRegion( hex("2D95"), 1) -d_SetWordRegion( hex("2D96"), 2) -d_SetDataRegion( hex("2DA2"), 1) -d_SetWordRegion( hex("2DA3"), 2) -d_SetDataRegion( hex("2DB0"), 1) -d_SetWordRegion( hex("2DB1"), 2) -d_SetDataRegion( hex("2E97"), 1) -d_SetWordRegion( hex("2E98"), 2) -d_SetDataRegion( hex("2FE7"), 1) -d_SetWordRegion( hex("2FE8"), 2) -d_SetDataRegion( hex("3323"), 1) -d_SetWordRegion( hex("3324"), 2) - -d_SetDataRegion( hex("2D74"), 1) - -d_SetDataRegion( hex("2E33"), 32) -d_SetDataRegion( hex("2EB0"), 3) -d_SetDataRegion( hex("2F8C"), 2) -d_SetDataRegion( hex("2FE8"), 2) -d_SetDataRegion( hex("37AE"), 269) -d_SetDataRegion( hex("3CE7"), 30) -d_SetDataRegion( hex("3F05"), 48) -d_SetDataRegion( hex("4041"), 35) -d_SetDataRegion( hex("406F"), 7) -d_SetDataRegion( hex("4121"), 56) - - -d_SetDataRegion( hex("18BE"), 3) -d_SetDataRegion( hex("18D7"), 3) -d_SetDataRegion( hex("1CAA"), 2) -d_SetWordRegion( hex("1D90"), 2) -d_SetDataRegion( hex("2104"), 3) ---d_SetDataRegion( hex("2221"), 3) -d_SetDataRegion( hex("2317"), 1) -d_SetDataRegion( hex("270F"), 3) -d_SetWordRegion( hex("2929"), 2) -d_SetDataRegion( hex("2A14"), 2) -d_SetDataRegion( hex("2A2A"), 2) -d_SetDataRegion( hex("2C8B"), 3) -d_SetWordRegion( hex("2CDE"), 2) -d_SetDataRegion( hex("2D10"), 2) -d_SetWordRegion( hex("2D90"), 2) -d_SetDataRegion( hex("30F4"), 3) -d_SetDataRegion( hex("3BE9"), 25) -d_SetDataRegion( hex("4118"), 3) - -d_SetDataRegion( hex("3DED"), 5) -d_SetDataRegion( hex("3DF2"), 5) -d_SetDataRegion( hex("3DF7"), 5) -d_SetDataRegion( hex("3DFC"), 5) - -d_SetDataRegion( hex("1B42"), 1) -d_SetDataRegion( hex("1C5A"), 1) -d_SetDataRegion( hex("1D02"), 1) -d_SetDataRegion( hex("1D89"), 1) -d_SetDataRegion( hex("1F31"), 1) -d_SetDataRegion( hex("204F"), 1) -d_SetDataRegion( hex("208F"), 1) -d_SetDataRegion( hex("2116"), 1) -d_SetDataRegion( hex("220F"), 1) -d_SetDataRegion( hex("221B"), 1) -d_SetDataRegion( hex("221F"), 1) -d_SetDataRegion( hex("245F"), 1) -d_SetDataRegion( hex("24FD"), 1) -d_SetDataRegion( hex("2715"), 1) -d_SetDataRegion( hex("284E"), 1) -d_SetDataRegion( hex("2855"), 1) -d_SetDataRegion( hex("288F"), 1) -d_SetDataRegion( hex("28C6"), 1) -d_SetDataRegion( hex("2AB3"), 1) -d_SetDataRegion( hex("2B75"), 1) -d_SetDataRegion( hex("2C21"), 1) -d_SetDataRegion( hex("2CEF"), 1) -d_SetDataRegion( hex("2D7E"), 1) -d_SetDataRegion( hex("2D8E"), 1) -d_SetDataRegion( hex("2D9B"), 1) -d_SetDataRegion( hex("2DA8"), 1) -d_SetDataRegion( hex("2DB6"), 1) - - --- Create a mapping table of known Sharp I/O ports and 8 bit constants. --- --- Format Addr IsAddr Label : IsAddr = 0, value is a constant, = 1, value is an address. -d_SetByteEquate(hex("FE") , 1, "PRTC" ) -d_SetByteEquate(hex("FF") , 1, "PRTD" ) - --- Create a mapping table of known Sharp MZ BIOS/Memory Mapped Hardware addresses which dz80 --- can use to replace an address with the label. The EQU list will also be output at the start --- of the disassembly file so it can compile. --- Format Addr IsAddr Label : IsAddr = 0, value is a constant, = 1, value is an address. -d_SetWordEquate(hex("0003"), 1, "GETL" ) -d_SetWordEquate(hex("0006"), 1, "LETNL" ) -d_SetWordEquate(hex("0009"), 1, "NL" ) -d_SetWordEquate(hex("000C"), 1, "PRNTS" ) -d_SetWordEquate(hex("000F"), 1, "PRNTT" ) -d_SetWordEquate(hex("0012"), 1, "PRNT" ) -d_SetWordEquate(hex("0015"), 1, "MSG" ) -d_SetWordEquate(hex("0018"), 1, "MSGX" ) -d_SetWordEquate(hex("001B"), 1, "GETKY" ) -d_SetWordEquate(hex("001E"), 1, "BRKEY" ) -d_SetWordEquate(hex("0021"), 1, "?WRI" ) -d_SetWordEquate(hex("0024"), 1, "?WRD" ) -d_SetWordEquate(hex("0027"), 1, "?RDI" ) -d_SetWordEquate(hex("002A"), 1, "?RDD" ) -d_SetWordEquate(hex("002D"), 1, "?VRFY" ) -d_SetWordEquate(hex("0030"), 1, "MELDY" ) -d_SetWordEquate(hex("0033"), 1, "?TMST" ) -d_SetWordEquate(hex("003B"), 1, "TIMRD" ) -d_SetWordEquate(hex("003E"), 1, "BELL" ) -d_SetWordEquate(hex("0041"), 1, "XTEMP" ) -d_SetWordEquate(hex("0044"), 1, "MSTA" ) -d_SetWordEquate(hex("0047"), 1, "MSTP" ) -d_SetWordEquate(hex("0000"), 1, "MONIT" ) -d_SetWordEquate(hex("0089"), 1, "SS" ) -d_SetWordEquate(hex("0095"), 1, "ST1" ) -d_SetWordEquate(hex("0410"), 1, "HLHEX" ) -d_SetWordEquate(hex("041F"), 1, "_2HEX" ) -d_SetWordEquate(hex("074D"), 1, "?MODE" ) -d_SetWordEquate(hex("08CA"), 1, "?KEY" ) -d_SetWordEquate(hex("096C"), 1, "PRNT3" ) -d_SetWordEquate(hex("0BB9"), 1, "?ADCN" ) -d_SetWordEquate(hex("0BCE"), 1, "?DACN" ) -d_SetWordEquate(hex("0DB5"), 1, "?DSP" ) -d_SetWordEquate(hex("0DA6"), 1, "?BLNK" ) -d_SetWordEquate(hex("0DDC"), 1, "?DPCT" ) -d_SetWordEquate(hex("03BA"), 1, "PRTHL" ) -d_SetWordEquate(hex("03C3"), 1, "PRTHX" ) -d_SetWordEquate(hex("03DA"), 1, "ASC" ) -d_SetWordEquate(hex("03F9"), 1, "HEX" ) -d_SetWordEquate(hex("0DDC"), 1, "DPCT" ) -d_SetWordEquate(hex("0DA7"), 1, "DLY12" ) -d_SetWordEquate(hex("0DAA"), 1, "DLY12A" ) -d_SetWordEquate(hex("0EE6"), 1, "?RSTR1" ) -d_SetWordEquate(hex("06A3"), 1, "MOTOR" ) -d_SetWordEquate(hex("071A"), 1, "CKSUM" ) -d_SetWordEquate(hex("077A"), 1, "GAP" ) -d_SetWordEquate(hex("0485"), 1, "WTAPE" ) -d_SetWordEquate(hex("0700"), 1, "MSTOP" ) -d_SetWordEquate(hex("11FD"), 1, "TAPECOPY" ) -d_SetWordEquate(hex("1200"), 1, "COLDSTRT" ) -d_SetWordEquate(hex("1250"), 1, "WARMSTRTMON") -d_SetWordEquate(hex("15A8"), 1, "CMDWORDTBL" ) -d_SetWordEquate(hex("1BB2"), 1, "CMDJMPTBL" ) -d_SetWordEquate(hex("2E33"), 1, "CMTBUF" ) -d_SetWordEquate(hex("2E34"), 1, "CMTFNAME" ) - -d_SetWordEquate(hex("1C3C"), 1, "CMDREMDATA" ) -d_SetWordEquate(hex("13AB"), 1, "SYNTAXERR" ) -d_SetWordEquate(hex("2D12"), 1, "CMDREAD" ) -d_SetWordEquate(hex("1C4D"), 1, "CMDLIST" ) -d_SetWordEquate(hex("1E91"), 1, "CMDRUN" ) -d_SetWordEquate(hex("1C42"), 1, "CMDNEW" ) -d_SetWordEquate(hex("2B0D"), 1, "CMDPRINT" ) -d_SetWordEquate(hex("1D6A"), 1, "CMDLET" ) -d_SetWordEquate(hex("1F2B"), 1, "CMDFOR" ) -d_SetWordEquate(hex("21AD"), 1, "CMDIF" ) -d_SetWordEquate(hex("13AB"), 1, "CMDTHEN" ) -d_SetWordEquate(hex("1EA6"), 1, "CMDGOTO" ) -d_SetWordEquate(hex("1EC7"), 1, "CMDGOSUB" ) -d_SetWordEquate(hex("1EF8"), 1, "CMDRETURN" ) -d_SetWordEquate(hex("1FC0"), 1, "CMDNEXT" ) -d_SetWordEquate(hex("1D2C"), 1, "CMDSTOP" ) -d_SetWordEquate(hex("1D15"), 1, "CMDEND" ) -d_SetWordEquate(hex("203E"), 1, "CMDON" ) -d_SetWordEquate(hex("2D75"), 1, "CMDLOAD" ) -d_SetWordEquate(hex("2D82"), 1, "CMDSAVE" ) -d_SetWordEquate(hex("2EB3"), 1, "CMDVERIFY" ) -d_SetWordEquate(hex("2191"), 1, "CMDPOKE" ) -d_SetWordEquate(hex("2080"), 1, "CMDDIM" ) -d_SetWordEquate(hex("2201"), 1, "CMDDEFFN" ) -d_SetWordEquate(hex("2BFF"), 1, "CMDINPUT" ) -d_SetWordEquate(hex("1D4D"), 1, "CMDRESTORE" ) -d_SetWordEquate(hex("21A6"), 1, "CMDCLS" ) -d_SetWordEquate(hex("2269"), 1, "CMDMUSIC" ) -d_SetWordEquate(hex("2282"), 1, "CMDTEMPO" ) -d_SetWordEquate(hex("2942"), 1, "CMDUSRN" ) -d_SetWordEquate(hex("2D9F"), 1, "CMDWOPEN" ) -d_SetWordEquate(hex("2D92"), 1, "CMDROPEN" ) -d_SetWordEquate(hex("2DAD"), 1, "CMDCLOSE" ) -d_SetWordEquate(hex("28B6"), 1, "CMDMON" ) -d_SetWordEquate(hex("2967"), 1, "CMDLIMIT" ) -d_SetWordEquate(hex("29CE"), 1, "CMDCONT" ) -d_SetWordEquate(hex("2902"), 1, "CMDGET" ) -d_SetWordEquate(hex("29FE"), 1, "CMDINP" ) -d_SetWordEquate(hex("2A1C"), 1, "CMDOUT" ) -d_SetWordEquate(hex("28B9"), 1, "CMDCURSOR" ) -d_SetWordEquate(hex("2AA6"), 1, "CMDSET" ) -d_SetWordEquate(hex("2AAA"), 1, "CMDRESET" ) -d_SetWordEquate(hex("2A2F"), 1, "CMDAUTO" ) -d_SetWordEquate(hex("33AB"), 1, "CMDCOPY" ) -d_SetWordEquate(hex("32D4"), 1, "CMDPAGE" ) - -d_SetWordEquate(hex("13AE"), 1, "OVFLERR" ) -d_SetWordEquate(hex("13B1"), 1, "ILDATERR" ) -d_SetWordEquate(hex("13B4"), 1, "DATMISERR" ) -d_SetWordEquate(hex("13B7"), 1, "STRLENERR" ) -d_SetWordEquate(hex("13BA"), 1, "MEMERR" ) -d_SetWordEquate(hex("13C0"), 1, "LINELENERR" ) -d_SetWordEquate(hex("13C3"), 1, "GOSUBERR" ) -d_SetWordEquate(hex("13C6"), 1, "FORNEXTERR" ) -d_SetWordEquate(hex("13C9"), 1, "FUNCERR" ) -d_SetWordEquate(hex("13CC"), 1, "NEXTFORERR" ) -d_SetWordEquate(hex("13CF"), 1, "RETGOSBERR" ) -d_SetWordEquate(hex("13D2"), 1, "UNDEFFNERR" ) -d_SetWordEquate(hex("13D5"), 1, "LINEERR" ) -d_SetWordEquate(hex("13D8"), 1, "CONTERR" ) -d_SetWordEquate(hex("13DB"), 1, "BADWRERR" ) -d_SetWordEquate(hex("13DE"), 1, "CMDSTMTERR" ) -d_SetWordEquate(hex("13E1"), 1, "READDATAERR") -d_SetWordEquate(hex("13E4"), 1, "OPENERR" ) -d_SetWordEquate(hex("13E7"), 1, "UNKNWNERR" ) -d_SetWordEquate(hex("13EA"), 1, "OUTFILEERR" ) -d_SetWordEquate(hex("13ED"), 1, "PRTNRDYERR" ) -d_SetWordEquate(hex("13F0"), 1, "PRTHWERR" ) -d_SetWordEquate(hex("13F3"), 1, "PRTPAPERERR") -d_SetWordEquate(hex("13F6"), 1, "CHKSUMERR" ) - -d_SetWordEquate(hex("1347"), 1, "TITLEMSG" ) -d_SetWordEquate(hex("1364"), 1, "COPYRMSG" ) -d_SetWordEquate(hex("1384"), 1, "READYMSG" ) -d_SetWordEquate(hex("138A"), 1, "ERRORMSG" ) -d_SetWordEquate(hex("1391"), 1, "INMSG" ) -d_SetWordEquate(hex("1395"), 1, "BREAKMSG" ) -d_SetWordEquate(hex("139C"), 1, "BYTESMSG" ) -d_SetWordEquate(hex("13A3"), 1, "ERRCODE" ) - -d_SetWordEquate(hex("1332"), 1, "MSGNL" ) -d_SetWordEquate(hex("167B"), 1, "UNUSEDTBL1" ) -d_SetWordEquate(hex("167D"), 1, "UNUSEDTBL2" ) -d_SetWordEquate(hex("124E"), 1, "WARMSTRT" ) -d_SetWordEquate(hex("167F"), 1, "OPERATORTBL") -d_SetWordEquate(hex("17FC"), 1, "STRTONUM" ) -d_SetWordEquate(hex("1E88"), 1, "GETNUM" ) -d_SetWordEquate(hex("173F"), 1, "SKIPSPACE" ) -d_SetWordEquate(hex("173E"), 1, "INCSKIPSPCE") -d_SetWordEquate(hex("177B"), 1, "EXECHL" ) -d_SetWordEquate(hex("1795"), 1, "EXECNOTCHR" ) -d_SetWordEquate(hex("17A3"), 1, "MATCHCHR" ) -d_SetWordEquate(hex("490D"), 0, "LINEBUFR" ) - - -d_SetComment( hex("1795"), "Scan for character after command" ) -d_SetComment( hex("1779"), "Get address after call and jump to it via a RET command." ) -d_SetComment( hex("2E1D"), "Compare loaded filename against name given by user." ) -d_SetComment( hex("2B0D"), "Check to see if a stream, ie. /T = Tape is given. The 02FH below is / and the function after is called if it doesnt match /." ) -d_SetComment( hex("1250"), "Sharp defined BASIC restart location from Monitor." ) - --- Known Sharp Constants. -d_SetWordEquate(hex("10F0"), 0, "ATRB" ) -- ATTRIBUTE -d_SetWordEquate(hex("10F1"), 0, "NAME" ) -- FILE NAME -d_SetWordEquate(hex("1102"), 0, "SIZE" ) -- BYTESIZE -d_SetWordEquate(hex("1104"), 0, "DTADR" ) -- DATA ADDRESS -d_SetWordEquate(hex("1106"), 0, "EXADR" ) -- EXECUTION ADDRESS -d_SetWordEquate(hex("1108"), 0, "COMNT" ) -- COMMENT -d_SetWordEquate(hex("1164"), 0, "SWPW" ) -- SWEEP WORK -d_SetWordEquate(hex("116E"), 0, "KDATW" ) -- KEY WORK -d_SetWordEquate(hex("1170"), 0, "KANAF" ) -- KANA FLAG (01=GRAPHIC MODE) -d_SetWordEquate(hex("1171"), 0, "DSPXY" ) -- DISPLAY COORDINATES -d_SetWordEquate(hex("1173"), 0, "MANG" ) -- COLUMN MANAGEMENT -d_SetWordEquate(hex("1179"), 0, "MANGE" ) -- COLUMN MANAGEMENT END -d_SetWordEquate(hex("117A"), 0, "PBIAS" ) -- PAGE BIAS -d_SetWordEquate(hex("117B"), 0, "ROLTOP" ) -- ROLL TOP BIAS -d_SetWordEquate(hex("117C"), 0, "MGPNT" ) -- COLUMN MANAG. POINTER -d_SetWordEquate(hex("117D"), 0, "PAGETP" ) -- PAGE TOP -d_SetWordEquate(hex("117F"), 0, "ROLEND" ) -- ROLL END -d_SetWordEquate(hex("118E"), 0, "FLASH" ) -- FLASHING DATA -d_SetWordEquate(hex("118F"), 0, "SFTLK" ) -- SHIFT LOCK -d_SetWordEquate(hex("1190"), 0, "REVFLG" ) -- REVERSE FLAG -d_SetWordEquate(hex("1191"), 0, "SPAGE" ) -- PAGE CHANGE -d_SetWordEquate(hex("1192"), 0, "FLSDT" ) -- CURSOR DATA -d_SetWordEquate(hex("1193"), 0, "STRGF" ) -- STRING FLAG -d_SetWordEquate(hex("1194"), 0, "DPRNT" ) -- TAB COUNTER -d_SetWordEquate(hex("1195"), 0, "TMCNT" ) -- TAPE MARK COUNTER -d_SetWordEquate(hex("1197"), 0, "SUMDT" ) -- CHECK SUM DATA -d_SetWordEquate(hex("1199"), 0, "CSMDT" ) -- FOR COMPARE SUM DATA -d_SetWordEquate(hex("119B"), 0, "AMPM" ) -- AMPM DATA -d_SetWordEquate(hex("119C"), 0, "TIMFG" ) -- TIME FLAG -d_SetWordEquate(hex("119D"), 0, "SWRK" ) -- KEY SOUND FLAG -d_SetWordEquate(hex("119E"), 0, "TEMPW" ) -- TEMPO WORK -d_SetWordEquate(hex("119F"), 0, "ONTYO" ) -- ONTYO WORK -d_SetWordEquate(hex("11A0"), 0, "OCTV" ) -- OCTAVE WORK -d_SetWordEquate(hex("11A1"), 0, "RATIO" ) -- ONPU RATIO -d_SetWordEquate(hex("11A3"), 0, "BUFER" ) -- GET LINE BUFFER - - ----------------------------------------- --- End of configuration file ----------------------------------------- diff --git a/software/dis/SA-5510/SA-5510.ref b/software/dis/SA-5510/SA-5510.ref deleted file mode 100644 index 0fec0fd..0000000 --- a/software/dis/SA-5510/SA-5510.ref +++ /dev/null @@ -1,2643 +0,0 @@ -dZ80 2.1 Reference file from the disassembly of "SA-5510.bin". - -Input Port Reference (2 entries) --------------------------------- - -Input Port 000feH. 2 references: --------------------------------- - - 0328aH: IN A,(0FEH) - 032aeH: IN A,(0FEH) - - -Output Port Reference (3 entries) ---------------------------------- - -Output Port 000feH. 2 references: ---------------------------------- - - 0329aH: OUT (0FEH),A - 032a2H: OUT (0FEH),A - -Output Port 000ffH. 1 references: ---------------------------------- - - 03296H: OUT (0FFH),A - - -Direct address Reference (598 entries) --------------------------------------- - -Direct address 00000H. 20 references: -------------------------------------- - - 017d5H: LD DE,00000H - 0184aH: LD BC,00000H - 018fdH: LD BC,00000H - 01910H: LD BC,00000H - 01944H: LD HL,00000H - 019f9H: LD BC,00000H - 01a52H: LD DE,00000H - 02083H: LD BC,00000H - 02492H: LD BC,00000H - 025feH: LD BC,00000H - 027f5H: LD DE,00000H - 02919H: LD BC,00000H - 0292eH: LD DE,00000H - 029a5H: LD DE,00000H - 02e0aH: LD BC,00000H - 032abH: LD DE,00000H - 03540H: LD HL,00000H - 035a4H: LD DE,00000H - 03cdeH: LD BC,00000H - 03ce1H: LD DE,00000H - -Direct address 00001H. 4 references: ------------------------------------- - - 01ce9H: LD BC,00001H - 02779H: LD BC,00001H - 02872H: LD BC,00001H - 0359fH: LD DE,00001H - -Direct address 00002H. 1 references: ------------------------------------- - - 020aaH: LD HL,00002H - -Direct address 00003H. 3 references: ------------------------------------- - - 0223dH: LD BC,00003H - 02e54H: LD HL,00003H - 0398dH: LD BC,00003H - -Direct address 00004H. 10 references: -------------------------------------- - - 018f3H: LD BC,00004H - 01b57H: LD BC,00004H - 020b6H: LD HL,00004H - 02415H: LD BC,00004H - 02596H: LD BC,00004H - 03525H: LD BC,00004H - 03b9bH: LD BC,00004H - 03d4fH: LD BC,00004H - 04162H: LD BC,00004H - 04193H: LD BC,00004H - -Direct address 00005H. 19 references: -------------------------------------- - - 01930H: LD BC,00005H - 01e6aH: LD BC,00005H - 01f66H: LD BC,00005H - 01ffcH: LD BC,00005H - 0200cH: LD BC,00005H - 0201fH: LD BC,00005H - 020f5H: LD BC,00005H - 02154H: LD HL,00005H - 023bfH: LD BC,00005H - 023faH: LD BC,00005H - 024c1H: LD BC,00005H - 02540H: LD BC,00005H - 0261eH: LD HL,00005H - 02626H: LD BC,00005H - 027f2H: LD BC,00005H - 03756H: LD BC,00005H - 039b4H: LD BC,00005H - 03a63H: LD BC,00005H - 03b5cH: LD BC,00005H - -Direct address 00006H. 3 references: ------------------------------------- - - 01bacH: LD BC,00006H - 02129H: LD DE,00006H - 029f1H: LD BC,00006H - -Direct address 00007H. 2 references: ------------------------------------- - - 01ee5H: LD BC,00007H - 01f20H: LD BC,00007H - -Direct address 00008H. 2 references: ------------------------------------- - - 021c7H: LD BC,00008H - 0396bH: LD BC,00008H - -Direct address 00009H. 2 references: ------------------------------------- - - 02dc4H: LD DE,00009H - 03a52H: LD BC,00009H - -Direct address 0000aH. 5 references: ------------------------------------- - - 0123cH: LD BC,0000AH - 01817H: LD DE,0000AH - 02a5fH: LD DE,0000AH - 02a6cH: LD DE,0000AH - 02a71H: LD DE,0000AH - -Direct address 00012H. 4 references: ------------------------------------- - - 01f81H: LD BC,00012H - 01fe8H: LD BC,00012H - 0302bH: LD BC,00012H - 041f3H: LD BC,00012H - -Direct address 00013H. 2 references: ------------------------------------- - - 01f11H: LD BC,00013H - 01fa9H: LD BC,00013H - -Direct address 0003cH. 1 references: ------------------------------------- - - 01e4cH: LD HL,0003CH - -Direct address 00064H. 1 references: ------------------------------------- - - 01811H: LD DE,00064H - -Direct address 000c8H. 1 references: ------------------------------------- - - 02989H: LD BC,000C8H - -Direct address 00100H. 3 references: ------------------------------------- - - 025f9H: LD BC,00100H - 030ffH: LD HL,00100H - 03163H: LD HL,00100H - -Direct address 00106H. 1 references: ------------------------------------- - - 025d2H: LD BC,00106H - -Direct address 003e8H. 2 references: ------------------------------------- - - 0180bH: LD DE,003E8H - 0334fH: LD HL,003E8H - -Direct address 003f0H. 1 references: ------------------------------------- - - 0332eH: LD BC,003F0H - -Direct address 00500H. 1 references: ------------------------------------- - - 0330eH: LD BC,00500H - -Direct address 00d00H. 1 references: ------------------------------------- - - 03b24H: LD BC,00D00H - -Direct address 00d2cH. 1 references: ------------------------------------- - - 019f6H: LD DE,00D2CH - -Direct address 00e10H. 1 references: ------------------------------------- - - 01e3aH: LD HL,00E10H - -Direct address ATRB. 4 references: ----------------------------------- - - 02eefH: LD HL,010F0H - 03025H: LD DE,010F0H - 03140H: LD HL,010F0H - 041edH: LD DE,010F0H - -Direct address NAME. 1 references: ----------------------------------- - - 02f72H: LD DE,010F1H - -Direct address DTADR. 1 references: ------------------------------------ - - 02f2cH: LD (01104H),DE - -Direct address SFTLK. 1 references: ------------------------------------ - - 01342H: LD HL,0118FH - -Direct address 011fdH. 1 references: ------------------------------------- - - 041f8H: LD HL,011FDH - -Direct address 01200H. 1 references: ------------------------------------- - - 04209H: LD HL,01200H - -Direct address 0124eH. 1 references: ------------------------------------- - - 0143eH: LD BC,0124EH - -Direct address 012b8H. 1 references: ------------------------------------- - - 01262H: LD HL,012B8H - -Direct address 01347H. 1 references: ------------------------------------- - - 0122aH: LD DE,01347H - -Direct address 01364H. 1 references: ------------------------------------- - - 01230H: LD DE,01364H - -Direct address 01384H. 1 references: ------------------------------------- - - 0125cH: LD DE,01384H - -Direct address 0138aH. 1 references: ------------------------------------- - - 0142aH: LD DE,0138AH - -Direct address 01391H. 1 references: ------------------------------------- - - 0144dH: LD DE,01391H - -Direct address 01395H. 1 references: ------------------------------------- - - 01438H: LD DE,01395H - -Direct address 0139cH. 1 references: ------------------------------------- - - 01248H: LD DE,0139CH - -Direct address 013a5H. 1 references: ------------------------------------- - - 01ba3H: LD DE,013A5H - -Direct address 013abH. 29 references: -------------------------------------- - - 01bb6H: XOR E - 01bb8H: XOR E - 01bcaH: XOR E - 01bd8H: XOR E - 01c0cH: XOR E - 01c0eH: XOR E - 01c10H: XOR E - 01c12H: XOR E - 01c14H: XOR E - 01c16H: XOR E - 01c1aH: XOR E - 01c1cH: XOR E - 01c22H: XOR E - 01c24H: XOR E - 01c26H: XOR E - 01c28H: XOR E - 01c2aH: XOR E - 01c2cH: XOR E - 01c2eH: XOR E - 01c30H: XOR E - 026a3H: XOR E - 026a5H: XOR E - 026a7H: XOR E - 026cbH: XOR E - 026cdH: XOR E - 026cfH: XOR E - 026d3H: XOR E - 026d9H: XOR E - 02a4fH: XOR E - -Direct address 013b1H. 1 references: ------------------------------------- - - 01e24H: OR C - -Direct address 013b4H. 2 references: ------------------------------------- - - 01d90H: OR H - 02929H: OR H - -Direct address 01400H. 1 references: ------------------------------------- - - 013faH: LD IY,01400H - -Direct address 01464H. 1 references: ------------------------------------- - - 029eeH: LD DE,01464H - -Direct address 01479H. 1 references: ------------------------------------- - - 01483H: LD HL,01479H - -Direct address 0150aH. 1 references: ------------------------------------- - - 01545H: LD HL,0150AH - -Direct address 0151fH. 1 references: ------------------------------------- - - 01530H: LD HL,0151FH - -Direct address 015a8H. 2 references: ------------------------------------- - - 0148fH: LD DE,015A8H - 0153eH: LD HL,015A8H - -Direct address 0167bH. 2 references: ------------------------------------- - - 014a8H: LD DE,0167BH - 01534H: LD HL,0167BH - -Direct address 0167dH. 1 references: ------------------------------------- - - 01539H: LD HL,0167DH - -Direct address 0167fH. 2 references: ------------------------------------- - - 014b9H: LD DE,0167FH - 0151cH: LD HL,0167FH - -Direct address 018d8H. 1 references: ------------------------------------- - - 0259aH: LD HL,018D8H - -Direct address 0192cH. 1 references: ------------------------------------- - - 028a3H: LD DE,0192CH - -Direct address 01a7eH. 1 references: ------------------------------------- - - 01a79H: LD A,(HL) - -Direct address 01abeH. 1 references: ------------------------------------- - - 01abfH: LD HL,01ABEH - -Direct address 01b35H. 2 references: ------------------------------------- - - 01d53H: LD BC,01B35H - 02962H: LD HL,01B35H - -Direct address 01b38H. 1 references: ------------------------------------- - - 020ecH: JR C,02109H - -Direct address 01b5fH. 1 references: ------------------------------------- - - 012cfH: LD E,A - -Direct address 01bb2H. 1 references: ------------------------------------- - - 01b88H: LD HL,01BB2H - -Direct address 01c3cH. 2 references: ------------------------------------- - - 01bb2H: INC A - 01bb4H: INC A - -Direct address 01c42H. 1 references: ------------------------------------- - - 01bc0H: LD B,D - -Direct address 01c4dH. 1 references: ------------------------------------- - - 01bbcH: LD C,L - -Direct address 01c60H. 1 references: ------------------------------------- - - 01c55H: LD H,B - -Direct address 01d15H. 1 references: ------------------------------------- - - 01bd6H: DEC D - -Direct address 01d2cH. 1 references: ------------------------------------- - - 01bd4H: INC L - -Direct address 01d44H. 1 references: ------------------------------------- - - 01d35H: LD DE,01D44H - -Direct address 01d4dH. 1 references: ------------------------------------- - - 01beaH: LD C,L - -Direct address 01d6aH. 1 references: ------------------------------------- - - 01bc4H: LD L,D - -Direct address 01df5H. 3 references: ------------------------------------- - - 01dc2H: LD HL,01DF5H - 01e06H: LD DE,01DF5H - 025bcH: LD HL,01DF5H - -Direct address 01e91H. 1 references: ------------------------------------- - - 01bbeH: SUB C - -Direct address 01ea6H. 1 references: ------------------------------------- - - 01bccH: AND (HL) - -Direct address 01ec7H. 1 references: ------------------------------------- - - 01bceH: RST 000H - -Direct address 01ef8H. 1 references: ------------------------------------- - - 01bd0H: RET M - -Direct address 01f2bH. 1 references: ------------------------------------- - - 01bc6H: DEC HL - -Direct address 01fc0H. 1 references: ------------------------------------- - - 01bd2H: RET NZ - -Direct address 02000H. 1 references: ------------------------------------- - - 01cd7H: LD BC,02000H - -Direct address 0203eH. 1 references: ------------------------------------- - - 01bdaH: LD A,020H - -Direct address 02080H. 1 references: ------------------------------------- - - 01be4H: ADD A,B - -Direct address 02105H. 2 references: ------------------------------------- - - 020cbH: LD DE,(02105H) - 02174H: LD DE,(02105H) - -Direct address 02191H. 1 references: ------------------------------------- - - 01be2H: SUB C - -Direct address 021a6H. 1 references: ------------------------------------- - - 01becH: AND (HL) - -Direct address 021adH. 1 references: ------------------------------------- - - 01bc8H: XOR L - -Direct address 021d3H. 1 references: ------------------------------------- - - 021b4H: OUT (021H),A - -Direct address 02201H. 1 references: ------------------------------------- - - 01be6H: LD BC,0FF22H - -Direct address 02269H. 1 references: ------------------------------------- - - 01beeH: LD L,C - -Direct address 02282H. 1 references: ------------------------------------- - - 01bf0H: ADD A,D - -Direct address 02296H. 1 references: ------------------------------------- - - 022abH: LD BC,02296H - -Direct address 022e1H. 1 references: ------------------------------------- - - 022cfH: LD HL,022E1H - -Direct address 022f3H. 1 references: ------------------------------------- - - 022cbH: LD HL,022F3H - -Direct address 0231bH. 2 references: ------------------------------------- - - 022e1H: DEC DE - 022e3H: DEC DE - -Direct address 0231eH. 2 references: ------------------------------------- - - 022e5H: LD E,023H - 022e7H: LD E,023H - -Direct address 02322H. 2 references: ------------------------------------- - - 022e9H: LD (02223H),HL - 022ebH: LD (02523H),HL - -Direct address 02325H. 1 references: ------------------------------------- - - 022edH: DEC H - -Direct address 02328H. 1 references: ------------------------------------- - - 022efH: JR Z,02314H - -Direct address 0232fH. 1 references: ------------------------------------- - - 022f1H: CPL - -Direct address 02332H. 1 references: ------------------------------------- - - 022aeH: LD DE,02332H - -Direct address 0234cH. 1 references: ------------------------------------- - - 0235fH: LD BC,0234CH - -Direct address 02392H. 1 references: ------------------------------------- - - 02362H: LD DE,02392H - -Direct address 02396H. 1 references: ------------------------------------- - - 023a3H: LD BC,02396H - -Direct address 023abH. 1 references: ------------------------------------- - - 023a6H: LD DE,023ABH - -Direct address 023afH. 1 references: ------------------------------------- - - 023b5H: LD BC,023AFH - -Direct address 023dcH. 1 references: ------------------------------------- - - 023d0H: LD HL,023DCH - -Direct address 023f9H. 2 references: ------------------------------------- - - 023f0H: LD BC,023F9H - 02462H: LD HL,023F9H - -Direct address 02401H. 1 references: ------------------------------------- - - 023b8H: LD DE,02401H - -Direct address 02691H. 1 references: ------------------------------------- - - 023c6H: LD HL,02691H - -Direct address 026b3H. 1 references: ------------------------------------- - - 0247bH: LD HL,026B3H - -Direct address 026dbH. 1 references: ------------------------------------- - - 0246aH: LD HL,026DBH - -Direct address 026f3H. 1 references: ------------------------------------- - - 026b3H: DI - -Direct address 0270fH. 1 references: ------------------------------------- - - 026b5H: RRCA - -Direct address 02710H. 1 references: ------------------------------------- - - 01805H: LD DE,02710H - -Direct address 0273eH. 1 references: ------------------------------------- - - 026b7H: LD A,027H - -Direct address 02765H. 1 references: ------------------------------------- - - 026b9H: LD H,L - -Direct address 02772H. 1 references: ------------------------------------- - - 026bbH: LD (HL),D - -Direct address 0277fH. 1 references: ------------------------------------- - - 026bdH: LD A,A - -Direct address 0279aH. 1 references: ------------------------------------- - - 026c1H: SBC A,D - -Direct address 027b2H. 1 references: ------------------------------------- - - 027a7H: LD HL,027B2H - -Direct address 027b4H. 1 references: ------------------------------------- - - 026bfH: OR H - -Direct address 027f9H. 1 references: ------------------------------------- - - 026c3H: LD SP,HL - -Direct address 02801H. 1 references: ------------------------------------- - - 026c5H: LD BC,00428H - -Direct address 02804H. 1 references: ------------------------------------- - - 026c7H: INC B - -Direct address 02824H. 1 references: ------------------------------------- - - 026d1H: INC H - -Direct address 02841H. 1 references: ------------------------------------- - - 026d5H: LD B,C - -Direct address 0287cH. 1 references: ------------------------------------- - - 026d7H: LD A,H - -Direct address 0288cH. 1 references: ------------------------------------- - - 02880H: ADC A,H - -Direct address 02895H. 1 references: ------------------------------------- - - 026c9H: SUB L - -Direct address 0289dH. 1 references: ------------------------------------- - - 026edH: SBC A,L - -Direct address 028a2H. 1 references: ------------------------------------- - - 026efH: AND D - -Direct address 028b6H. 1 references: ------------------------------------- - - 01bfaH: OR (HL) - -Direct address 028b9H. 1 references: ------------------------------------- - - 01c06H: CP C - -Direct address 02902H. 1 references: ------------------------------------- - - 01c00H: LD (BC),A - -Direct address 02942H. 1 references: ------------------------------------- - - 01bf2H: LD B,D - -Direct address 02959H. 1 references: ------------------------------------- - - 0294aH: LD E,C - -Direct address 02967H. 1 references: ------------------------------------- - - 01bfcH: LD H,A - -Direct address 0299bH. 1 references: ------------------------------------- - - 02967H: LD DE,0299BH - -Direct address 029cbH. 1 references: ------------------------------------- - - 029a3H: SRA C - -Direct address 029ceH. 1 references: ------------------------------------- - - 01bfeH: ADC A,029H - -Direct address 029feH. 1 references: ------------------------------------- - - 01c02H: CP 029H - -Direct address 02a1cH. 1 references: ------------------------------------- - - 01c04H: INC E - -Direct address 02a2fH. 1 references: ------------------------------------- - - 01c18H: CPL - -Direct address 02a3fH. 1 references: ------------------------------------- - - 02a3bH: CCF - -Direct address 02a84H. 3 references: ------------------------------------- - - 02a42H: LD (02A84H),DE - 02a62H: LD (02A84H),DE - 02a74H: LD (02A84H),DE - -Direct address 02a86H. 3 references: ------------------------------------- - - 0127fH: LD BC,(02A86H) - 02a54H: LD (02A86H),DE - 02a66H: LD (02A86H),DE - -Direct address 02a88H. 9 references: ------------------------------------- - - 01f5cH: LD HL,02A88H - 028acH: LD DE,02A88H - 03c74H: LD HL,02A88H - 03e9aH: LD HL,02A88H - 0401aH: LD HL,02A88H - 04030H: LD HL,02A88H - 04080H: LD DE,02A88H - 04094H: LD HL,02A88H - 040f2H: LD HL,02A88H - -Direct address 02a8dH. 8 references: ------------------------------------- - - 020f2H: LD HL,02A8DH - 022f9H: LD DE,02A8DH - 024d9H: LD HL,02A8DH - 028b2H: LD DE,02A8DH - 03b50H: LD DE,02A8DH - 03b6dH: LD HL,02A8DH - 03dbaH: LD HL,02A8DH - 03ef3H: LD HL,02A8DH - -Direct address 02a92H. 4 references: ------------------------------------- - - 022f3H: LD DE,02A92H - 028a7H: LD DE,02A92H - 03b55H: LD DE,02A92H - 03b68H: LD HL,02A92H - -Direct address 02a97H. 1 references: ------------------------------------- - - 024acH: LD DE,02A97H - -Direct address 02aa6H. 1 references: ------------------------------------- - - 01c08H: AND (HL) - -Direct address 02aaaH. 1 references: ------------------------------------- - - 01c0aH: XOR D - -Direct address 02b0dH. 1 references: ------------------------------------- - - 01bc2H: DEC C - -Direct address 02b18H. 1 references: ------------------------------------- - - 02b11H: JR 02B3EH - -Direct address 02b1eH. 1 references: ------------------------------------- - - 02bafH: LD HL,02B1EH - -Direct address 02b35H. 1 references: ------------------------------------- - - 02b33H: DEC (HL) - -Direct address 02b4dH. 1 references: ------------------------------------- - - 02b35H: LD BC,02B4DH - -Direct address 02b9aH. 1 references: ------------------------------------- - - 02b6dH: SBC A,D - -Direct address 02be2H. 1 references: ------------------------------------- - - 02bf4H: LD SP,02BE2H - -Direct address 02befH. 1 references: ------------------------------------- - - 02b26H: LD HL,02BEFH - -Direct address 02bf7H. 1 references: ------------------------------------- - - 02ba9H: LD HL,02BF7H - -Direct address 02bffH. 1 references: ------------------------------------- - - 01be8H: RST 038H - -Direct address 02c0eH. 1 references: ------------------------------------- - - 02c06H: LD C,02CH - -Direct address 02c5fH. 2 references: ------------------------------------- - - 02c16H: LD DE,02C5FH - 02c59H: LD DE,02C5FH - -Direct address 02c68H. 1 references: ------------------------------------- - - 02c7eH: LD HL,02C68H - -Direct address 02c84H. 1 references: ------------------------------------- - - 02c6cH: LD HL,02C84H - -Direct address 02c8eH. 1 references: ------------------------------------- - - 02cc5H: LD HL,02C8EH - -Direct address 02cbfH. 1 references: ------------------------------------- - - 02cb3H: CP A - -Direct address 02cf4H. 1 references: ------------------------------------- - - 02cdeH: CALL P,02A2CH - -Direct address 02d05H. 1 references: ------------------------------------- - - 02d00H: DEC B - -Direct address 02d10H. 1 references: ------------------------------------- - - 02d02H: LD HL,02D10H - -Direct address 02d11H. 1 references: ------------------------------------- - - 02cb6H: LD DE,02D11H - -Direct address 02d12H. 1 references: ------------------------------------- - - 01bbaH: LD (DE),A - -Direct address 02d46H. 1 references: ------------------------------------- - - 01d5cH: LD BC,02D46H - -Direct address 02d68H. 2 references: ------------------------------------- - - 02d57H: LD L,B - 02d5dH: LD L,B - -Direct address 02d75H. 1 references: ------------------------------------- - - 01bdcH: LD (HL),L - -Direct address 02d82H. 1 references: ------------------------------------- - - 01bdeH: ADD A,D - -Direct address 02d92H. 1 references: ------------------------------------- - - 01bf6H: SUB D - -Direct address 02d9fH. 1 references: ------------------------------------- - - 01bf4H: SBC A,A - -Direct address 02dadH. 1 references: ------------------------------------- - - 01bf8H: XOR L - -Direct address 02e28H. 1 references: ------------------------------------- - - 0213fH: LD HL,02E28H - -Direct address 02e33H. 3 references: ------------------------------------- - - 02febH: LD HL,02E33H - 03028H: LD HL,02E33H - 03132H: LD HL,02E33H - -Direct address 02e34H. 6 references: ------------------------------------- - - 02e1dH: LD DE,02E34H - 02e64H: LD HL,02E34H - 02e8cH: LD HL,02E34H - 02efaH: LD DE,02E34H - 0301fH: LD DE,02E34H - 03148H: LD DE,02E34H - -Direct address 02e9aH. 1 references: ------------------------------------- - - 02e98H: SBC A,D - -Direct address 02eb0H. 1 references: ------------------------------------- - - 02e9dH: LD DE,02EB0H - -Direct address 02eb3H. 1 references: ------------------------------------- - - 01be0H: OR E - -Direct address 02edaH. 1 references: ------------------------------------- - - 02d79H: JP C,0CD2EH - -Direct address 02ee6H. 1 references: ------------------------------------- - - 02edfH: LD BC,02EE6H - -Direct address 02f8cH. 1 references: ------------------------------------- - - 02f86H: LD DE,02F8CH - -Direct address 02fc2H. 1 references: ------------------------------------- - - 02f67H: LD DE,02FC2H - -Direct address 02fc9H. 1 references: ------------------------------------- - - 02f6cH: LD DE,02FC9H - -Direct address 02fd2H. 1 references: ------------------------------------- - - 02f62H: LD DE,02FD2H - -Direct address 02fddH. 1 references: ------------------------------------- - - 02ed1H: LD DE,02FDDH - -Direct address 02fe0H. 1 references: ------------------------------------- - - 02d89H: RET PO - -Direct address 02feaH. 1 references: ------------------------------------- - - 02fe8H: JP PE,0E52FH - -Direct address 03038H. 1 references: ------------------------------------- - - 02fe0H: LD BC,03038H - -Direct address 03064H. 1 references: ------------------------------------- - - 02bfcH: LD SP,03064H - -Direct address 030e5H. 1 references: ------------------------------------- - - 02da3H: PUSH HL - -Direct address 030f6H. 1 references: ------------------------------------- - - 025e2H: LD BC,030F6H - -Direct address 030fcH. 1 references: ------------------------------------- - - 030efH: LD BC,030FCH - -Direct address 0311eH. 1 references: ------------------------------------- - - 02d96H: LD E,031H - -Direct address 0313aH. 1 references: ------------------------------------- - - 03128H: LD BC,0313AH - -Direct address 03171H. 1 references: ------------------------------------- - - 02db1H: LD (HL),C - -Direct address 032d4H. 1 references: ------------------------------------- - - 01c20H: CALL NC,0AB32H - -Direct address 03315H. 1 references: ------------------------------------- - - 03362H: LD HL,03315H - -Direct address 03326H. 1 references: ------------------------------------- - - 03324H: LD H,033H - -Direct address 033abH. 1 references: ------------------------------------- - - 01c1eH: XOR E - -Direct address 03400H. 1 references: ------------------------------------- - - 03431H: LD (03400H),BC - -Direct address 03401H. 1 references: ------------------------------------- - - 034e4H: LD HL,03401H - -Direct address 03402H. 3 references: ------------------------------------- - - 0347bH: LD HL,03402H - 0347fH: LD HL,03402H - 034b7H: LD HL,03402H - -Direct address 03403H. 1 references: ------------------------------------- - - 026abH: INC BC - -Direct address 03405H. 1 references: ------------------------------------- - - 026a9H: DEC B - -Direct address 03500H. 1 references: ------------------------------------- - - 026adH: NOP - -Direct address 035d0H. 1 references: ------------------------------------- - - 026afH: RET NC - -Direct address 0366eH. 1 references: ------------------------------------- - - 03734H: LD DE,(0366EH) - -Direct address 03725H. 1 references: ------------------------------------- - - 0371aH: LD HL,03725H - -Direct address 03755H. 2 references: ------------------------------------- - - 0374dH: LD BC,03755H - 0375dH: LD HL,03755H - -Direct address 037aeH. 2 references: ------------------------------------- - - 03730H: LD BC,037AEH - 03afaH: LD BC,037AEH - -Direct address 037dbH. 1 references: ------------------------------------- - - 039abH: LD HL,037DBH - -Direct address 038a3H. 1 references: ------------------------------------- - - 03afeH: LD DE,(038A3H) - -Direct address 038a6H. 2 references: ------------------------------------- - - 0390dH: LD HL,038A6H - 0391dH: LD DE,038A6H - -Direct address 038a7H. 4 references: ------------------------------------- - - 0392eH: LD DE,038A7H - 0394fH: LD HL,038A7H - 039d8H: LD HL,038A7H - 03ab7H: LD IX,038A7H - -Direct address 038a8H. 1 references: ------------------------------------- - - 0392bH: LD HL,038A8H - -Direct address 038afH. 2 references: ------------------------------------- - - 03963H: LD HL,038AFH - 03a4cH: LD HL,038AFH - -Direct address 038b0H. 6 references: ------------------------------------- - - 038d9H: LD HL,038B0H - 0393fH: LD HL,038B0H - 03a27H: LD HL,038B0H - 03a4fH: LD DE,038B0H - 03aa3H: LD HL,038B0H - 03b21H: LD HL,038B0H - -Direct address 038b1H. 1 references: ------------------------------------- - - 03960H: LD DE,038B1H - -Direct address 038b2H. 1 references: ------------------------------------- - - 0395bH: LD DE,038B2H - -Direct address 03994H. 1 references: ------------------------------------- - - 0398aH: LD HL,03994H - -Direct address 039d8H. 1 references: ------------------------------------- - - 039c7H: LD BC,039D8H - -Direct address 03a86H. 1 references: ------------------------------------- - - 026e7H: ADD A,(HL) - -Direct address 03aefH. 1 references: ------------------------------------- - - 03ae4H: LD HL,03AEFH - -Direct address 03b62H. 2 references: ------------------------------------- - - 02691H: LD H,D - 02693H: LD H,D - -Direct address 03b73H. 1 references: ------------------------------------- - - 0269fH: LD (HL),E - -Direct address 03b77H. 1 references: ------------------------------------- - - 026a1H: LD (HL),A - -Direct address 03b7fH. 1 references: ------------------------------------- - - 0269dH: LD A,A - -Direct address 03b87H. 2 references: ------------------------------------- - - 02695H: ADD A,A - 02697H: ADD A,A - -Direct address 03b8bH. 2 references: ------------------------------------- - - 02699H: ADC A,E - 0269bH: ADC A,E - -Direct address 03b93H. 2 references: ------------------------------------- - - 03ba3H: LD DE,03B93H - 03bc4H: LD DE,03B93H - -Direct address 03b98H. 1 references: ------------------------------------- - - 026dbH: SBC A,B - -Direct address 03be4H. 1 references: ------------------------------------- - - 03bc7H: LD HL,03BE4H - -Direct address 03be9H. 1 references: ------------------------------------- - - 03ba7H: LD HL,03BE9H - -Direct address 03beeH. 29 references: -------------------------------------- - - 03c02H: LD DE,03BEEH - 03c0eH: LD DE,03BEEH - 03c85H: LD DE,03BEEH - 03c8eH: LD HL,03BEEH - 03c9aH: LD HL,03BEEH - 03cbfH: LD HL,03BEEH - 03d64H: LD DE,03BEEH - 03d81H: LD HL,03BEEH - 03d8dH: LD HL,03BEEH - 03ddbH: LD DE,03BEEH - 03e2bH: LD DE,03BEEH - 03e74H: LD HL,03BEEH - 03e91H: LD HL,03BEEH - 03eaaH: LD HL,03BEEH - 03f68H: LD DE,03BEEH - 03f7eH: LD HL,03BEEH - 03f9cH: LD DE,03BEEH - 03fc5H: LD HL,03BEEH - 03fdeH: LD HL,03BEEH - 03ff7H: LD HL,03BEEH - 0400bH: LD HL,03BEEH - 04012H: LD DE,03BEEH - 04022H: LD HL,03BEEH - 0408aH: LD DE,03BEEH - 0409cH: LD HL,03BEEH - 040a8H: LD DE,03BEEH - 040b3H: LD HL,03BEEH - 040ffH: LD HL,03BEEH - 04115H: LD HL,03BEEH - -Direct address 03bf3H. 12 references: -------------------------------------- - - 03c0bH: LD HL,03BF3H - 03c8bH: LD DE,03BF3H - 03c97H: LD DE,03BF3H - 03d76H: LD DE,03BF3H - 03d7eH: LD DE,03BF3H - 03d87H: LD HL,03BF3H - 03f8eH: LD DE,03BF3H - 03f96H: LD DE,03BF3H - 03f9fH: LD HL,03BF3H - 03fc2H: LD DE,03BF3H - 03ff1H: LD HL,03BF3H - 040b6H: LD DE,03BF3H - -Direct address 03bf8H. 2 references: ------------------------------------- - - 03d23H: LD DE,03BF8H - 03d37H: LD HL,03BF8H - -Direct address 03bfdH. 2 references: ------------------------------------- - - 03d16H: LD DE,03BFDH - 03d2bH: LD HL,03BFDH - -Direct address 03c16H. 1 references: ------------------------------------- - - 026ddH: LD D,03CH - -Direct address 03ce7H. 3 references: ------------------------------------- - - 03c17H: LD HL,03CE7H - 03d06H: LD HL,03CE7H - 0410dH: LD HL,03CE7H - -Direct address 03cecH. 1 references: ------------------------------------- - - 03ca0H: LD HL,03CECH - -Direct address 03cf1H. 1 references: ------------------------------------- - - 03ca6H: LD HL,03CF1H - -Direct address 03cf6H. 1 references: ------------------------------------- - - 03cacH: LD HL,03CF6H - -Direct address 03cfbH. 1 references: ------------------------------------- - - 03cb2H: LD HL,03CFBH - -Direct address 03d00H. 1 references: ------------------------------------- - - 03cb8H: LD HL,03D00H - -Direct address 03d05H. 1 references: ------------------------------------- - - 026dfH: DEC B - -Direct address 03d14H. 1 references: ------------------------------------- - - 026e1H: INC D - -Direct address 03d3fH. 1 references: ------------------------------------- - - 026f1H: CCF - -Direct address 03dedH. 1 references: ------------------------------------- - - 03d6aH: LD HL,03DEDH - -Direct address 03df2H. 1 references: ------------------------------------- - - 03d70H: LD HL,03DF2H - -Direct address 03df7H. 1 references: ------------------------------------- - - 03de1H: LD HL,03DF7H - -Direct address 03dfcH. 1 references: ------------------------------------- - - 03de7H: LD HL,03DFCH - -Direct address 03e03H. 1 references: ------------------------------------- - - 026e5H: INC BC - -Direct address 03f05H. 1 references: ------------------------------------- - - 03e31H: LD HL,03F05H - -Direct address 03f0aH. 1 references: ------------------------------------- - - 03e37H: LD HL,03F0AH - -Direct address 03f0fH. 1 references: ------------------------------------- - - 03e42H: LD HL,03F0FH - -Direct address 03f14H. 1 references: ------------------------------------- - - 03e4dH: LD HL,03F14H - -Direct address 03f19H. 1 references: ------------------------------------- - - 03e58H: LD HL,03F19H - -Direct address 03f1eH. 1 references: ------------------------------------- - - 03e63H: LD HL,03F1EH - -Direct address 03f23H. 1 references: ------------------------------------- - - 03e6eH: LD HL,03F23H - -Direct address 03f28H. 1 references: ------------------------------------- - - 03e23H: LD HL,03F28H - -Direct address 03f2dH. 1 references: ------------------------------------- - - 03e0eH: LD HL,03F2DH - -Direct address 03f35H. 1 references: ------------------------------------- - - 026ebH: DEC (HL) - -Direct address 04041H. 1 references: ------------------------------------- - - 03fa5H: LD HL,04041H - -Direct address 04046H. 1 references: ------------------------------------- - - 03fabH: LD HL,04046H - -Direct address 0404bH. 1 references: ------------------------------------- - - 03fb1H: LD HL,0404BH - -Direct address 04050H. 1 references: ------------------------------------- - - 03fb7H: LD HL,04050H - -Direct address 04055H. 2 references: ------------------------------------- - - 03f70H: LD HL,04055H - 03f76H: LD HL,04055H - -Direct address 0405aH. 1 references: ------------------------------------- - - 03f86H: LD HL,0405AH - -Direct address 0405fH. 1 references: ------------------------------------- - - 03febH: LD HL,0405FH - -Direct address 04064H. 1 references: ------------------------------------- - - 026e9H: LD H,H - -Direct address 0406fH. 1 references: ------------------------------------- - - 04069H: LD HL,0406FH - -Direct address 04076H. 1 references: ------------------------------------- - - 026e3H: HALT - -Direct address 0411aH. 1 references: ------------------------------------- - - 02643H: LD BC,0411AH - -Direct address 04121H. 1 references: ------------------------------------- - - 040bcH: LD HL,04121H - -Direct address 04126H. 1 references: ------------------------------------- - - 040c2H: LD HL,04126H - -Direct address 0412bH. 1 references: ------------------------------------- - - 040c8H: LD HL,0412BH - -Direct address 04130H. 1 references: ------------------------------------- - - 040ceH: LD HL,04130H - -Direct address 04135H. 1 references: ------------------------------------- - - 040d4H: LD HL,04135H - -Direct address 0413aH. 1 references: ------------------------------------- - - 040daH: LD HL,0413AH - -Direct address 0413fH. 1 references: ------------------------------------- - - 040e0H: LD HL,0413FH - -Direct address 04144H. 1 references: ------------------------------------- - - 040e6H: LD HL,04144H - -Direct address 04149H. 1 references: ------------------------------------- - - 040ecH: LD HL,04149H - -Direct address 0414eH. 2 references: ------------------------------------- - - 041a7H: LD DE,0414EH - 041b3H: LD DE,0414EH - -Direct address 04152H. 1 references: ------------------------------------- - - 041bcH: LD HL,04152H - -Direct address 04154H. 6 references: ------------------------------------- - - 0415aH: LD DE,04154H - 04182H: LD HL,04154H - 041a4H: LD HL,04154H - 041adH: LD DE,04154H - 041b6H: LD HL,04154H - 041c4H: LD HL,04154H - -Direct address 04159H. 1 references: ------------------------------------- - - 026b1H: LD E,C - -Direct address 041ecH. 2 references: ------------------------------------- - - 041feH: LD DE,041ECH - 04213H: LD HL,041ECH - -Direct address 04223H. 1 references: ------------------------------------- - - 041f0H: LD HL,04223H - -Direct address 048ffH. 1 references: ------------------------------------- - - 01200H: LD HL,048FFH - -Direct address 04900H. 1 references: ------------------------------------- - - 01d95H: LD HL,04900H - -Direct address 04902H. 1 references: ------------------------------------- - - 02cf4H: LD DE,(04902H) - -Direct address 04903H. 1 references: ------------------------------------- - - 01da5H: LD HL,04903H - -Direct address 04904H. 1 references: ------------------------------------- - - 01d9aH: LD HL,04904H - -Direct address 04906H. 1 references: ------------------------------------- - - 01dadH: LD DE,(04906H) - -Direct address 0490aH. 1 references: ------------------------------------- - - 01258H: LD SP,(0490AH) - -Direct address LINEBUFR. 9 references: --------------------------------------- - - 01272H: LD DE,0490DH - 0146aH: LD HL,0490DH - 014fbH: LD DE,0490DH - 01ca7H: LD DE,0490DH - 02b9eH: LD HL,0490DH - 02c32H: LD DE,0490DH - 02c68H: LD DE,0490DH - 02c9cH: LD DE,0490DH - 02d3bH: LD HL,0490DH - -Direct address 04954H. 1 references: ------------------------------------- - - 02578H: LD HL,04954H - -Direct address 04a0eH. 2 references: ------------------------------------- - - 012f7H: LD HL,04A0EH - 01c8aH: LD DE,04A0EH - -Direct address 04a10H. 1 references: ------------------------------------- - - 01470H: LD (04A10H),DE - -Direct address 04a12H. 3 references: ------------------------------------- - - 012c5H: LD HL,04A12H - 01474H: LD DE,04A12H - 01507H: LD HL,04A12H - -Direct address 04ab3H. 4 references: ------------------------------------- - - 01841H: LD DE,04AB3H - 01c69H: LD HL,04AB3H - 01cf6H: LD (04AB3H),DE - 0278cH: LD DE,04AB3H - -Direct address 04ab5H. 1 references: ------------------------------------- - - 01d0aH: LD (04AB5H),DE - -Direct address 04cd3H. 5 references: ------------------------------------- - - 0307fH: LD HL,04CD3H - 030bbH: LD HL,04CD3H - 03105H: LD HL,04CD3H - 0315dH: LD HL,04CD3H - 0319dH: LD HL,04CD3H - -Direct address 04dd3H. 4 references: ------------------------------------- - - 03072H: LD DE,04DD3H - 030a4H: LD DE,04DD3H - 03169H: LD HL,04DD3H - 03181H: LD DE,04DD3H - -Direct address 04dd8H. 1 references: ------------------------------------- - - 02e5aH: LD HL,04DD8H - -Direct address 04df2H. 2 references: ------------------------------------- - - 0199eH: LD HL,04DF2H - 02dc1H: LD HL,04DF2H - -Direct address 04e4eH. 2 references: ------------------------------------- - - 0195dH: LD DE,04E4EH - 02f4eH: LD HL,04E4EH - -Direct address 04e50H. 1 references: ------------------------------------- - - 019aaH: LD HL,04E50H - -Direct address 04e84H. 1 references: ------------------------------------- - - 01999H: LD DE,04E84H - -Direct address 04e86H. 1 references: ------------------------------------- - - 02126H: LD HL,04E86H - -Direct address 04e94H. 2 references: ------------------------------------- - - 019c7H: LD HL,04E94H - 0249eH: LD DE,(04E94H) - -Direct address 04e96H. 1 references: ------------------------------------- - - 01961H: LD HL,04E96H - -Direct address 04e98H. 1 references: ------------------------------------- - - 01fa5H: LD DE,(04E98H) - -Direct address 04e9aH. 2 references: ------------------------------------- - - 01ee0H: LD DE,(04E9AH) - 01eebH: LD (04E9AH),DE - -Direct address 04e9cH. 1 references: ------------------------------------- - - 0252cH: LD DE,04E9CH - -Direct address 04ebaH. 1 references: ------------------------------------- - - 01984H: LD HL,04EBAH - -Direct address 04fd7H. 1 references: ------------------------------------- - - 0197eH: LD HL,04FD7H - -Direct address 05040H. 2 references: ------------------------------------- - - 01978H: LD HL,05040H - 01f6eH: LD DE,(05040H) - -Direct address 05042H. 1 references: ------------------------------------- - - 01f5fH: LD DE,05042H - -Direct address 05048H. 1 references: ------------------------------------- - - 01f48H: LD DE,05048H - -Direct address 0504dH. 6 references: ------------------------------------- - - 01266H: LD HL,0504DH - 01b54H: LD DE,0504DH - 01ba6H: LD HL,0504DH - 01f1dH: LD DE,0504DH - 02012H: LD DE,0504DH - 029f4H: LD HL,0504DH - -Direct address 05053H. 5 references: ------------------------------------- - - 0198aH: LD HL,05053H - 01f04H: LD HL,05053H - 01f8fH: LD HL,05053H - 01fddH: LD HL,05053H - 0202bH: LD HL,05053H - -Direct address 05054H. 1 references: ------------------------------------- - - 01f98H: LD HL,05054H - -Direct address 05055H. 2 references: ------------------------------------- - - 01ed4H: LD HL,05055H - 01efbH: LD HL,05055H - -Direct address 05056H. 1 references: ------------------------------------- - - 0140eH: LD HL,05056H - -Direct address 0505cH. 12 references: -------------------------------------- - - 018b3H: LD HL,0505CH - 01957H: LD HL,0505CH - 01ac7H: LD HL,0505CH - 01ae1H: LD DE,0505CH - 01b13H: LD DE,0505CH - 01b1bH: LD HL,0505CH - 01c7dH: LD HL,0505CH - 01ec1H: LD HL,0505CH - 02d43H: LD HL,0505CH - 02f23H: LD DE,0505CH - 0303bH: LD HL,0505CH - 03041H: LD DE,0505CH - -Direct address 0505eH. 1 references: ------------------------------------- - - 02f4bH: LD DE,0505EH - -Direct address 08000H. 1 references: ------------------------------------- - - 03c43H: LD HL,08000H - -Direct address 0f1f0H. 1 references: ------------------------------------- - - 025c1H: LD DE,0F1F0H - -Direct address 0ff0aH. 1 references: ------------------------------------- - - 038ffH: LD BC,0FF0AH - -Direct address 0ff9cH. 1 references: ------------------------------------- - - 01854H: LD HL,0FF9CH - -Direct address 0ffc4H. 1 references: ------------------------------------- - - 025c7H: LD DE,0FFC4H - -Direct address 0fffaH. 1 references: ------------------------------------- - - 02535H: LD BC,0FFFAH - -Direct address 0fffbH. 2 references: ------------------------------------- - - 01e7cH: LD BC,0FFFBH - 023e6H: LD BC,0FFFBH - - -Indirect address Reference (316 entries) ----------------------------------------- - -Indirect address ATRB. 2 references: ------------------------------------- - - 02eb9H: LD A,(010F0H) - 02f0dH: LD A,(010F0H) - -Indirect address 01101H. 1 references: --------------------------------------- - - 02f80H: LD (01101H),A - -Indirect address SIZE. 6 references: ------------------------------------- - - 02f1cH: LD HL,(01102H) - 02f9bH: LD HL,(01102H) - 0304aH: LD (01102H),HL - 03102H: LD (01102H),HL - 03166H: LD (01102H),HL - 04206H: LD (01102H),HL - -Indirect address DTADR. 5 references: -------------------------------------- - - 02f8eH: LD HL,(01104H) - 0303eH: LD (01104H),HL - 0310bH: LD (01104H),HL - 03160H: LD (01104H),HL - 041fbH: LD (01104H),HL - -Indirect address EXADR. 1 references: -------------------------------------- - - 0420cH: LD (01106H),HL - -Indirect address DSPXY. 3 references: -------------------------------------- - - 02890H: LD A,(01171H) - 028d0H: LD HL,(01171H) - 028ebH: LD (01171H),HL - -Indirect address 01172H. 1 references: --------------------------------------- - - 02882H: LD A,(01172H) - -Indirect address MGPNT. 2 references: -------------------------------------- - - 028d6H: LD A,(0117CH) - 028e3H: LD (0117CH),A - -Indirect address PAGETP. 3 references: --------------------------------------- - - 02860H: LD HL,(0117DH) - 02ae5H: LD HL,(0117DH) - 033c6H: LD HL,(0117DH) - -Indirect address DPRNT. 3 references: -------------------------------------- - - 028f1H: LD (01194H),A - 02b78H: LD A,(01194H) - 02c2bH: LD A,(01194H) - -Indirect address 013a3H. 2 references: --------------------------------------- - - 01403H: LD (013A3H),A - 01430H: LD HL,(013A3H) - -Indirect address 013ffH. 1 references: --------------------------------------- - - 01400H: LD A,(013FFH) - -Indirect address 01463H. 4 references: --------------------------------------- - - 0145aH: LD (01463H),A - 01c43H: LD (01463H),A - 029d1H: LD A,(01463H) - 029ebH: LD (01463H),A - -Indirect address 018bfH. 1 references: --------------------------------------- - - 018b0H: LD (018BFH),HL - -Indirect address 018d8H. 3 references: --------------------------------------- - - 020c3H: LD HL,(018D8H) - 0211bH: LD (018D8H),HL - 02581H: LD (018D8H),HL - -Indirect address 01c4cH. 4 references: --------------------------------------- - - 01c65H: LD (01C4CH),A - 01cbdH: LD A,(01C4CH) - 01cc1H: LD (01C4CH),A - 01ce5H: LD (01C4CH),A - -Indirect address 01cabH. 2 references: --------------------------------------- - - 01c4eH: LD (01CABH),A - 01c5dH: LD (01CABH),A - -Indirect address 02102H. 3 references: --------------------------------------- - - 020e5H: LD HL,(02102H) - 02117H: LD (02102H),HL - 0263bH: LD HL,(02102H) - -Indirect address 02104H. 5 references: --------------------------------------- - - 020a3H: LD A,(02104H) - 020d4H: LD A,(02104H) - 02123H: LD (02104H),A - 0214eH: LD A,(02104H) - 02618H: LD A,(02104H) - -Indirect address 02105H. 2 references: --------------------------------------- - - 02096H: LD HL,(02105H) - 0211fH: LD (02105H),HL - -Indirect address 02a15H. 1 references: --------------------------------------- - - 02a05H: LD (02A15H),A - -Indirect address 02a2bH. 1 references: --------------------------------------- - - 02a23H: LD (02A2BH),A - -Indirect address 02a83H. 6 references: --------------------------------------- - - 01275H: LD A,(02A83H) - 012a1H: LD (02A83H),A - 012a7H: LD (02A83H),A - 01443H: LD (02A83H),A - 01e92H: LD (02A83H),A - 02a5aH: LD (02A83H),A - -Indirect address 02a84H. 2 references: --------------------------------------- - - 0127bH: LD HL,(02A84H) - 01286H: LD (02A84H),HL - -Indirect address 02c8cH. 4 references: --------------------------------------- - - 02c36H: LD (02C8CH),HL - 02c96H: LD HL,(02C8CH) - 02ca4H: LD (02C8CH),HL - 02cc2H: LD (02C8CH),HL - -Indirect address 02d74H. 6 references: --------------------------------------- - - 02edcH: LD (02D74H),A - 02f07H: LD A,(02D74H) - 0309dH: LD (02D74H),A - 030c4H: LD A,(02D74H) - 030cdH: LD (02D74H),A - 0312eH: LD (02D74H),A - -Indirect address 030e2H. 9 references: --------------------------------------- - - 01e95H: LD (030E2H),A - 03067H: LD A,(030E2H) - 03092H: LD A,(030E2H) - 030e8H: LD A,(030E2H) - 03118H: LD (030E2H),A - 03121H: LD A,(030E2H) - 03157H: LD (030E2H),A - 03174H: LD A,(030E2H) - 03191H: LD (030E2H),A - -Indirect address 030e3H. 7 references: --------------------------------------- - - 0306eH: LD HL,(030E3H) - 0308bH: LD (030E3H),HL - 030a0H: LD HL,(030E3H) - 030dcH: LD (030E3H),HL - 03108H: LD (030E3H),HL - 0316cH: LD (030E3H),HL - 0317eH: LD HL,(030E3H) - -Indirect address 0326dH. 3 references: --------------------------------------- - - 031fbH: LD (0326DH),A - 03269H: LD (0326DH),A - 033f4H: LD A,(0326DH) - -Indirect address 032d3H. 7 references: --------------------------------------- - - 02b89H: LD A,(032D3H) - 031a2H: LD A,(032D3H) - 031b0H: LD (032D3H),A - 031b6H: LD A,(032D3H) - 03248H: LD A,(032D3H) - 0325fH: LD (032D3H),A - 03270H: LD A,(032D3H) - -Indirect address 03400H. 6 references: --------------------------------------- - - 0345cH: LD A,(03400H) - 03522H: LD (03400H),A - 03561H: LD A,(03400H) - 03565H: LD (03400H),A - 0357cH: LD A,(03400H) - 03b03H: LD (03400H),A - -Indirect address 03401H. 6 references: --------------------------------------- - - 03506H: LD (03401H),A - 035d6H: LD (03401H),A - 0370dH: LD (03401H),A - 0373aH: LD (03401H),A - 039ceH: LD (03401H),A - 03a96H: LD (03401H),A - -Indirect address 03402H. 9 references: --------------------------------------- - - 0342bH: LD (03402H),A - 0351eH: LD (03402H),A - 03583H: LD A,(03402H) - 03587H: LD (03402H),A - 035b5H: LD A,(03402H) - 035b9H: LD (03402H),A - 035ecH: LD (03402H),A - 03712H: LD (03402H),A - 03adcH: LD (03402H),A - -Indirect address 0366dH. 9 references: --------------------------------------- - - 0367aH: LD (0366DH),A - 036f1H: LD (0366DH),A - 036f7H: LD A,(0366DH) - 036fdH: LD (0366DH),A - 03725H: LD A,(0366DH) - 03ab4H: LD (0366DH),A - 03ad1H: LD A,(0366DH) - 03ad7H: LD (0366DH),A - 03aefH: LD A,(0366DH) - -Indirect address 0366eH. 3 references: --------------------------------------- - - 03675H: LD (0366EH),HL - 0371eH: LD HL,(0366EH) - 03761H: LD HL,(0366EH) - -Indirect address 038a3H. 3 references: --------------------------------------- - - 03997H: LD (038A3H),HL - 03ae8H: LD HL,(038A3H) - 03b58H: LD HL,(038A3H) - -Indirect address 038a5H. 8 references: --------------------------------------- - - 038bfH: LD A,(038A5H) - 038ebH: LD A,(038A5H) - 03971H: LD A,(038A5H) - 039c3H: LD (038A5H),A - 03a5aH: LD A,(038A5H) - 03a5eH: LD (038A5H),A - 03a9cH: LD A,(038A5H) - 03b1aH: LD A,(038A5H) - -Indirect address 038a6H. 2 references: --------------------------------------- - - 039a7H: LD (038A6H),A - 03a8aH: LD A,(038A6H) - -Indirect address 038a7H. 2 references: --------------------------------------- - - 038d6H: LD (038A7H),A - 03a47H: LD A,(038A7H) - -Indirect address 03c14H. 2 references: --------------------------------------- - - 03c63H: LD (03C14H),HL - 03c6cH: LD A,(03C14H) - -Indirect address 03c15H. 3 references: --------------------------------------- - - 03c20H: LD (03C15H),A - 03c5bH: LD A,(03C15H) - 03c80H: LD A,(03C15H) - -Indirect address 03d3dH. 3 references: --------------------------------------- - - 03d41H: LD (03D3DH),A - 03d99H: LD A,(03D3DH) - 03d9dH: LD (03D3DH),A - -Indirect address 03d3eH. 3 references: --------------------------------------- - - 03d5fH: LD (03D3EH),A - 03da2H: LD A,(03D3EH) - 03dd6H: LD (03D3EH),A - -Indirect address 03e01H. 4 references: --------------------------------------- - - 03e07H: LD (03E01H),A - 03e8bH: LD A,(03E01H) - 03eecH: LD A,(03E01H) - 03efcH: LD A,(03E01H) - -Indirect address 03e02H. 3 references: --------------------------------------- - - 03e18H: LD (03E02H),A - 03e7aH: LD A,(03E02H) - 03ed9H: LD (03E02H),A - -Indirect address 03f32H. 3 references: --------------------------------------- - - 03f3bH: LD (03F32H),A - 03f49H: LD (03F32H),A - 04006H: LD A,(03F32H) - -Indirect address 03f33H. 3 references: --------------------------------------- - - 03f38H: LD (03F33H),A - 03ffaH: LD A,(03F33H) - 0403cH: LD (03F33H),A - -Indirect address 03f34H. 2 references: --------------------------------------- - - 03f65H: LD (03F34H),A - 03fcbH: LD A,(03F34H) - -Indirect address 04074H. 2 references: --------------------------------------- - - 0407bH: LD (04074H),A - 0411cH: LD A,(04074H) - -Indirect address 04075H. 2 references: --------------------------------------- - - 040a3H: LD (04075H),A - 04105H: LD A,(04075H) - -Indirect address 04153H. 4 references: --------------------------------------- - - 04170H: LD (04153H),A - 04179H: LD A,(04153H) - 0418eH: LD A,(04153H) - 041e8H: LD (04153H),A - -Indirect address 04900H. 1 references: --------------------------------------- - - 01dcbH: LD HL,(04900H) - -Indirect address 04902H. 2 references: --------------------------------------- - - 01de5H: LD HL,(04902H) - 01dfeH: LD HL,(04902H) - -Indirect address 04905H. 1 references: --------------------------------------- - - 02912H: LD A,(04905H) - -Indirect address 04908H. 4 references: --------------------------------------- - - 01214H: LD (04908H),HL - 02972H: LD HL,(04908H) - 0297dH: LD HL,(04908H) - 02fa2H: LD HL,(04908H) - -Indirect address 0490aH. 5 references: --------------------------------------- - - 01217H: LD (0490AH),HL - 012b4H: LD HL,(0490AH) - 01417H: LD HL,(0490AH) - 02994H: LD (0490AH),HL - 02f92H: LD HL,(0490AH) - -Indirect address 04a0eH. 2 references: --------------------------------------- - - 012f3H: LD (04A0EH),HL - 01cdfH: LD HL,(04A0EH) - -Indirect address 04a10H. 3 references: --------------------------------------- - - 012beH: LD HL,(04A10H) - 014f8H: LD HL,(04A10H) - 01c93H: LD HL,(04A10H) - -Indirect address 04a12H. 1 references: --------------------------------------- - - 012e8H: LD A,(04A12H) - -Indirect address 04ab3H. 1 references: --------------------------------------- - - 01c8fH: LD HL,(04AB3H) - -Indirect address 04ab5H. 1 references: --------------------------------------- - - 01c9cH: LD HL,(04AB5H) - -Indirect address 04dd4H. 8 references: --------------------------------------- - - 02b3dH: LD A,(04DD4H) - 02b56H: LD A,(04DD4H) - 02b7cH: LD A,(04DD4H) - 02be3H: LD A,(04DD4H) - 02c8eH: LD A,(04DD4H) - 02d17H: LD (04DD4H),A - 02dbcH: LD (04DD4H),A - 02eacH: LD (04DD4H),A - -Indirect address 04dd6H. 1 references: --------------------------------------- - - 02e57H: LD (04DD6H),HL - -Indirect address 04e4cH. 1 references: --------------------------------------- - - 01947H: LD (04E4CH),HL - -Indirect address 04e4eH. 2 references: --------------------------------------- - - 01adeH: LD HL,(04E4EH) - 03044H: LD HL,(04E4EH) - -Indirect address 04e80H. 4 references: --------------------------------------- - - 0332aH: LD HL,(04E80H) - 03340H: LD HL,(04E80H) - 03373H: LD HL,(04E80H) - 0338aH: LD HL,(04E80H) - -Indirect address 04e84H. 3 references: --------------------------------------- - - 01996H: LD HL,(04E84H) - 0222bH: LD HL,(04E84H) - 0250aH: LD HL,(04E84H) - -Indirect address 04e8aH. 1 references: --------------------------------------- - - 024beH: LD HL,(04E8AH) - -Indirect address 04e90H. 1 references: --------------------------------------- - - 02584H: LD HL,(04E90H) - -Indirect address 04e92H. 3 references: --------------------------------------- - - 01913H: LD HL,(04E92H) - 01a21H: LD HL,(04E92H) - 01b73H: LD HL,(04E92H) - -Indirect address 04e94H. 23 references: ---------------------------------------- - - 01789H: LD HL,(04E94H) - 0184dH: LD HL,(04E94H) - 0192cH: LD HL,(04E94H) - 01936H: LD HL,(04E94H) - 01a3eH: LD HL,(04E94H) - 01a42H: LD (04E94H),HL - 01a4fH: LD HL,(04E94H) - 01b79H: LD (04E94H),HL - 01e7fH: LD HL,(04E94H) - 01e83H: LD (04E94H),HL - 01f57H: LD HL,(04E94H) - 021d9H: LD IX,(04E94H) - 023bcH: LD HL,(04E94H) - 023c3H: LD (04E94H),HL - 023e3H: LD HL,(04E94H) - 023ecH: LD (04E94H),HL - 02411H: LD HL,(04E94H) - 02466H: LD HL,(04E94H) - 02548H: LD HL,(04E94H) - 02789H: LD HL,(04E94H) - 027e7H: LD HL,(04E94H) - 02986H: LD HL,(04E94H) - 02bc3H: LD HL,(04E94H) - -Indirect address 04e96H. 5 references: --------------------------------------- - - 01987H: LD (04E96H),HL - 02529H: LD HL,(04E96H) - 02539H: LD (04E96H),HL - 0255bH: LD HL,(04E96H) - 02569H: LD (04E96H),HL - -Indirect address 04e98H. 9 references: --------------------------------------- - - 01981H: LD (04E98H),HL - 01f0eH: LD HL,(04E98H) - 01f15H: LD (04E98H),HL - 01f6bH: LD HL,(04E98H) - 01f8aH: LD (04E98H),HL - 01fb1H: LD (04E98H),HL - 01fcdH: LD HL,(04E98H) - 01fecH: LD (04E98H),HL - 02028H: LD (04E98H),HL - -Indirect address 04e9aH. 3 references: --------------------------------------- - - 0197bH: LD (04E9AH),HL - 01f1aH: LD HL,(04E9AH) - 01f25H: LD (04E9AH),HL - -Indirect address 05040H. 1 references: --------------------------------------- - - 01f37H: LD (05040H),HL - -Indirect address 05047H. 1 references: --------------------------------------- - - 01f63H: LD (05047H),A - -Indirect address 0504dH. 1 references: --------------------------------------- - - 01b45H: LD HL,(0504DH) - -Indirect address 0504fH. 2 references: --------------------------------------- - - 01ab8H: LD HL,(0504FH) - 01d32H: LD HL,(0504FH) - -Indirect address 05051H. 32 references: ---------------------------------------- - - 012c8H: LD (05051H),HL - 0173aH: LD HL,(05051H) - 01792H: LD HL,(05051H) - 017a0H: LD HL,(05051H) - 01b35H: LD HL,(05051H) - 01b5cH: LD (05051H),HL - 01c38H: LD (05051H),HL - 01c7aH: LD (05051H),HL - 01d79H: LD (05051H),HL - 01fbaH: LD (05051H),HL - 01fcaH: LD (05051H),HL - 02908H: LD (05051H),HL - 0295cH: LD (05051H),HL - 0296fH: LD (05051H),HL - 0297aH: LD (05051H),HL - 029deH: LD HL,(05051H) - 02a0eH: LD (05051H),HL - 02ab7H: LD (05051H),HL - 02b23H: LD (05051H),HL - 02b50H: LD (05051H),HL - 02c25H: LD (05051H),HL - 02c65H: LD (05051H),HL - 02cccH: LD HL,(05051H) - 02cd5H: LD (05051H),HL - 02ce0H: LD HL,(05051H) - 02cf0H: LD (05051H),HL - 02d12H: LD (05051H),HL - 02ffeH: LD (05051H),HL - 0300bH: LD (05051H),HL - 03305H: LD (05051H),HL - 03318H: LD (05051H),HL - 033b2H: LD (05051H),HL - -Indirect address 05053H. 2 references: --------------------------------------- - - 01f72H: LD A,(05053H) - 01fc0H: LD A,(05053H) - -Indirect address 05056H. 2 references: --------------------------------------- - - 01992H: LD (05056H),A - 01b5fH: LD A,(05056H) - -Indirect address 05057H. 1 references: --------------------------------------- - - 0141bH: LD HL,(05057H) - -Indirect address 05059H. 4 references: --------------------------------------- - - 0145fH: LD (05059H),A - 02d1dH: LD A,(05059H) - 02d47H: LD (05059H),A - 02d64H: LD (05059H),A - -Indirect address 0505aH. 3 references: --------------------------------------- - - 02d24H: LD HL,(0505AH) - 02d38H: LD (0505AH),HL - 02d5fH: LD (0505AH),HL - - -End of reference file for "SA-5510.bin" - diff --git a/software/dis/SA-5510/dz80.ini b/software/dis/SA-5510/dz80.ini deleted file mode 120000 index 4617f95..0000000 --- a/software/dis/SA-5510/dz80.ini +++ /dev/null @@ -1 +0,0 @@ -SA-5510.ini \ No newline at end of file diff --git a/software/dis/XPATCH/XPATCH-5510.asm b/software/dis/XPATCH/XPATCH-5510.asm deleted file mode 100644 index 244cab5..0000000 --- a/software/dis/XPATCH/XPATCH-5510.asm +++ /dev/null @@ -1,1894 +0,0 @@ -; Disassembly of the file "XPATCH-5510.bin" -; -; CPU Type: Z80 -; -; Created with dZ80 2.1 -; -; on Sunday, 04 of April 2021 at 03:43 PM -; -PRTC EQU 0FEH -PRTD EQU 0FFH -GETL EQU 00003H -LETNL EQU 00006H -NL EQU 00009H -PRNTS EQU 0000CH -PRNTT EQU 0000FH -PRNT EQU 00012H -MSG EQU 00015H -MSGX EQU 00018H -GETKY EQU 0001BH -BRKEY EQU 0001EH -?WRI EQU 00021H -?WRD EQU 00024H -?RDI EQU 00027H -?RDD EQU 0002AH -?VRFY EQU 0002DH -MELDY EQU 00030H -?TMST EQU 00033H -TIMRD EQU 0003BH -BELL EQU 0003EH -XTEMP EQU 00041H -MSTA EQU 00044H -MSTP EQU 00047H -MONIT EQU 00000H -SS EQU 00089H -ST1 EQU 00095H -HLHEX EQU 00410H -_2HEX EQU 0041FH -?MODE EQU 0074DH -?KEY EQU 008CAH -PRNT3 EQU 0096CH -?ADCN EQU 00BB9H -?DACN EQU 00BCEH -?DSP EQU 00DB5H -?BLNK EQU 00DA6H -?DPCT EQU 00DDCH -PRTHL EQU 003BAH -PRTHX EQU 003C3H -ASC EQU 003DAH -HEX EQU 003F9H -DPCT EQU 00DDCH -DLY12 EQU 00DA7H -DLY12A EQU 00DAAH -?RSTR1 EQU 00EE6H -MOTOR EQU 006A3H -CKSUM EQU 0071AH -GAP EQU 0077AH -WTAPE EQU 00485H -MSTOP EQU 00700H -TAPECOPY EQU 011FDH -COLDSTRT EQU 01200H -WARMSTRTMON EQU 01250H -CMDWORDTBL EQU 015A8H -CMDJMPTBL EQU 01BB2H -CMTBUF EQU 02E33H -CMTFNAME EQU 02E34H -CMDREMDATA EQU 01C3CH -SYNTAXERR EQU 013ABH -CMDREAD EQU 02D12H -CMDLIST EQU 01C4DH -CMDRUN EQU 01E91H -CMDNEW EQU 01C42H -CMDPRINT EQU 02B0DH -CMDLET EQU 01D6AH -CMDFOR EQU 01F2BH -CMDIF EQU 021ADH -CMDTHEN EQU 013ABH -CMDGOTO EQU 01EA6H -CMDGOSUB EQU 01EC7H -CMDRETURN EQU 01EF8H -CMDNEXT EQU 01FC0H -CMDSTOP EQU 01D2CH -CMDEND EQU 01D15H -CMDON EQU 0203EH -CMDLOAD EQU 02D75H -CMDSAVE EQU 02D82H -CMDVERIFY EQU 02EB3H -CMDPOKE EQU 02191H -CMDDIM EQU 02080H -CMDDEFFN EQU 02201H -CMDINPUT EQU 02BFFH -CMDRESTORE EQU 01D4DH -CMDCLS EQU 021A6H -CMDMUSIC EQU 02269H -CMDTEMPO EQU 02282H -CMDUSRN EQU 02942H -CMDWOPEN EQU 02D9FH -CMDROPEN EQU 02D92H -CMDCLOSE EQU 02DADH -CMDMON EQU 028B6H -CMDLIMIT EQU 02967H -CMDCONT EQU 029CEH -CMDGET EQU 02902H -CMDINP EQU 029FEH -CMDOUT EQU 02A1CH -CMDCURSOR EQU 028B9H -CMDSET EQU 02AA6H -CMDRESET EQU 02AAAH -CMDAUTO EQU 02A2FH -CMDCOPY EQU 033ABH -CMDPAGE EQU 032D4H -OVFLERR EQU 013AEH -ILDATERR EQU 013B1H -DATMISERR EQU 013B4H -STRLENERR EQU 013B7H -MEMERR EQU 013BAH -LINELENERR EQU 013C0H -GOSUBERR EQU 013C3H -FORNEXTERR EQU 013C6H -FUNCERR EQU 013C9H -NEXTFORERR EQU 013CCH -RETGOSBERR EQU 013CFH -UNDEFFNERR EQU 013D2H -LINEERR EQU 013D5H -CONTERR EQU 013D8H -BADWRERR EQU 013DBH -CMDSTMTERR EQU 013DEH -READDATAERR EQU 013E1H -OPENERR EQU 013E4H -UNKNWNERR EQU 013E7H -OUTFILEERR EQU 013EAH -PRTNRDYERR EQU 013EDH -PRTHWERR EQU 013F0H -PRTPAPERERR EQU 013F3H -CHKSUMERR EQU 013F6H -TITLEMSG EQU 01347H -COPYRMSG EQU 01364H -READYMSG EQU 01384H -ERRORMSG EQU 0138AH -INMSG EQU 01391H -BREAKMSG EQU 01395H -BYTESMSG EQU 0139CH -ERRCODE EQU 013A3H -MSGNL EQU 01332H -UNUSEDTBL1 EQU 0167BH -UNUSEDTBL2 EQU 0167DH -WARMSTRT EQU 0124EH -OPERATORTBL EQU 0167FH -STRTONUM EQU 017FCH -GETNUM EQU 01E88H -SKIPSPACE EQU 0173FH -INCSKIPSPCE EQU 0173EH -EXECHL EQU 0177BH -EXECNOTCHR EQU 01795H -MATCHCHR EQU 017A3H -LINEBUFR EQU 0490DH -ATRB EQU 010F0H -NAME EQU 010F1H -SIZE EQU 01102H -DTADR EQU 01104H -EXADR EQU 01106H -COMNT EQU 01108H -SWPW EQU 01164H -KDATW EQU 0116EH -KANAF EQU 01170H -DSPXY EQU 01171H -MANG EQU 01173H -MANGE EQU 01179H -PBIAS EQU 0117AH -ROLTOP EQU 0117BH -MGPNT EQU 0117CH -PAGETP EQU 0117DH -ROLEND EQU 0117FH -FLASH EQU 0118EH -SFTLK EQU 0118FH -REVFLG EQU 01190H -SPAGE EQU 01191H -FLSDT EQU 01192H -STRGF EQU 01193H -DPRNT EQU 01194H -TMCNT EQU 01195H -SUMDT EQU 01197H -CSMDT EQU 01199H -AMPM EQU 0119BH -TIMFG EQU 0119CH -SWRK EQU 0119DH -TEMPW EQU 0119EH -ONTYO EQU 0119FH -OCTV EQU 011A0H -RATIO EQU 011A1H -BUFER EQU 011A3H -PRGSTART EQU 0505CH - - ORG PRGSTART - -L505C: NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP - NOP -L506B: NOP - NOP -L506D: LD BC,01B35H - PUSH BC - CALL L5098 - JP Z,L5150 - LD DE,L507D - JP MSGNL - -L507D: DB "RANGE ERROR" - DB 00DH -L5089: DB "OVERFLOW ERROR",00DH -L5098: LD DE,MONIT - LD (05063H),DE - DEC DE - DEC DE - LD (05065H),DE - CALL 017D5H - OR C - INC DE - LD A,02DH - CP (HL) - JR NZ,L50C0 ; (+011H) - LD (05063H),DE - INC HL - CALL 048A0H - CPL - JR Z,L50D2 ; (+018H) - LD (05065H),DE - JR L50D2 ; (+012H) - -L50C0: LD A,E - OR D - JR Z,L50CC ; (+008H) - LD (05063H),DE - LD (05065H),DE -L50CC: LD A,02FH - CP (HL) - JR NZ,L50D2 ; (+001H) - INC HL -L50D2: CALL 048A0H - INC L - JR NZ,L50DB ; (+003H) - LD DE,0000AH -L50DB: LD (05067H),DE - CALL 048A0H - NOP - JR NZ,L50E8 ; (+003H) - LD DE,0000AH -L50E8: LD (05069H),DE - LD (05051H),HL - LD BC,(05063H) - LD HL,(05065H) - OR A - SBC HL,BC -L50F9: JP C,SYNTAXERR - CALL L52BB - JR C,L50F9 ; (-008H) - CALL 01773H - JR Z,L5118 ; (+012H) - EX DE,HL - CALL 01867H - LD HL,(05067H) - EX DE,HL - SBC HL,DE - JR C,L5118 ; (+006H) - CALL L5118 -L5115: XOR A - INC A - RET - -L5118: LD BC,(05065H) - INC BC - CALL L52BB - JR NC,L5136 ; (+014H) - EX DE,HL - CALL 01867H - CALL L526C - EX DE,HL - CCF - JR C,L5149 ; (+01cH) -L512D: LD DE,L5089 - CALL MSG - JP 01438H - -L5136: PUSH DE - CALL 01867H - EX DE,HL - EX (SP),HL - CALL 01867H - CALL L526C - EX DE,HL - POP DE - JR C,L512D ; (-019H) - CALL 01773H -L5149: LD (L506B),HL - JR NC,L5115 ; (-039H) - XOR A - RET - -L5150: CALL 01AF1H - LD HL,(01958H) - PUSH HL - POP DE -L5158: PUSH HL - OR A - SBC HL,DE - JP C,MEMERR - LD BC,00080H - SBC HL,BC - POP HL - JR NC,L517E ; (+017H) - LD BC,00100H - EX DE,HL - CALL 01888H - EX DE,HL - ADD HL,BC - PUSH HL - PUSH DE - CALL 018EAH - LD HL,(04E94H) - ADD HL,BC - LD (04E94H),HL - POP DE - POP HL -L517E: PUSH DE - LD A,(HL) - LDI - OR (HL) - JR Z,L519C ; (+017H) - LDI - LD A,(HL) - LDI - LD B,(HL) - LD C,A - LDI - INC BC - CALL L51D1 - POP HL - LD C,(HL) - LD (HL),E - INC HL - LD B,(HL) - LD (HL),D - PUSH BC - POP HL - JR L5158 ; (-044H) - -L519C: LD (DE),A - INC DE - EX DE,HL - LD (04E4EH),HL - POP HL - CALL 0195AH - LD BC,(05063H) - CALL L52BB - LD BC,(05067H) -L51B1: PUSH HL - CALL 01867H - JR Z,L51CF ; (+018H) - PUSH HL - LD HL,(05065H) - SBC HL,DE - POP HL - JR C,L51CF ; (+00fH) - EX (SP),HL - INC HL - INC HL - LD (HL),C - INC HL - LD (HL),B - LD HL,(05069H) - ADD HL,BC - PUSH HL - POP BC - POP HL - JR L51B1 ; (-01eH) - -L51CF: POP HL - RET - -L51D1: CALL L52D5 - RET Z - CP 080H - JR NZ,L51D1 ; (-008H) - CALL L52D5 - CP 08CH - JR Z,L51EC ; (+00cH) - CP 08DH - JR Z,L51EC ; (+008H) - CP 08EH - JR Z,L51EC ; (+004H) - CP 09CH - JR NZ,L51D1 ; (-01bH) -L51EC: CALL L52D5 - DEC DE - DEC HL - SUB 030H - CP 00AH - JR NC,L51D1 ; (-026H) - CALL L5204 - LD A,02CH - CP (HL) - JR NZ,L51D1 ; (-02eH) - LD (DE),A - INC DE - INC HL - JR L51EC ; (-018H) - -L5204: PUSH DE - PUSH BC - CALL 017F6H - POP BC - CALL L526C - EX (SP),HL - JR NC,L523C ; (+02cH) - PUSH DE - PUSH HL - CALL NL - EX DE,HL - LD DE,L5255 - LD A,00DH - LD (DSPXY),A - CALL L5244 - LD DE,L525C - CALL MSG - XOR A - LD (DSPXY),A - LD D,B - LD E,C - CALL L526C - EX DE,HL - LD DE,L5257 - CALL L5244 - POP HL - LD (HL),070H - INC HL - POP DE -L523C: EX DE,HL - PUSH BC - CALL 01802H - POP BC - POP HL - RET - -L5244: PUSH BC - CALL MSG - LD DE,L505C - PUSH DE - CALL STRTONUM - POP DE - CALL MSG - POP BC - RET - -L5255: DB 03AH - DB 020H -L5257: DB "LINE" - DB 00DH -L525C: DB " DOES NOT EXIST" - DB 00DH -L526C: PUSH BC - PUSH HL - PUSH DE - XOR A - LD B,D - LD C,E - LD HL,(05065H) - SBC HL,DE - JR C,L52AB ; (+032H) - EX DE,HL - LD DE,(05063H) - SBC HL,DE - JR C,L52AB ; (+029H) - LD B,D - LD C,E - CALL L52BB - JR C,L52AB ; (+022H) - POP BC - LD DE,(05067H) - PUSH DE -L528F: CALL 01867H - JR Z,L52A7 ; (+013H) - EX DE,HL - XOR A - SBC HL,BC - JR Z,L52B2 ; (+018H) - JR NC,L52A7 ; (+00bH) - EX DE,HL - EX (SP),HL - LD DE,(05069H) - ADD HL,DE - EX (SP),HL - JR NC,L528F ; (-017H) - CPL -L52A7: OR A - CCF - JR L52AC ; (+001H) - -L52AB: XOR A -L52AC: POP DE -L52AD: LD D,B - LD E,C - POP HL - POP BC - RET - -L52B2: LD H,B - LD L,C - POP BC - SBC HL,BC - SCF - CCF - JR L52AD ; (-00eH) - -L52BB: LD HL,(01958H) - PUSH HL - JR L52C3 ; (+002H) - -L52C1: EX (SP),HL - EX DE,HL -L52C3: PUSH HL - CALL 01867H - JR Z,L52D1 ; (+008H) - EX DE,HL - SBC HL,BC - POP HL - JR C,L52C1 ; (-00eH) - POP DE - RET - -L52D1: POP HL - POP DE - SCF - RET - -L52D5: LD A,(HL) - LD (DE),A - CP 020H - INC HL - INC DE - JR Z,L52D5 ; (-008H) - CP 00DH - RET Z - CP 022H - RET NZ -L52E3: LD A,(HL) - LD (DE),A - INC HL - INC DE - CP 00DH - RET Z - CP 022H - JR NZ,L52E3 ; (-00bH) - OR A - RET - -L52F0: CALL 03327H - LD HL,(04AB3H) - CALL 018B0H - OR C - INC DE - PUSH HL - POP DE -L52FD: PUSH DE - LD A,(HL) - LDI - OR (HL) - JR Z,L532B ; (+027H) - LDI - LD A,(HL) - LDI - LD B,(HL) - LD C,A - LDI - PUSH HL - LD HL,(04AB5H) - OR A - SBC HL,BC - POP HL - JR C,L531C ; (+005H) - CALL L5338 - JR L5323 ; (+007H) - -L531C: LD A,(HL) - LDI - CP 00DH - JR NZ,L531C ; (-007H) -L5323: EX (SP),HL - LD (HL),E - INC HL - LD (HL),D - EX (SP),HL - POP AF - JR L52FD ; (-02eH) - -L532B: LDI - EX DE,HL - LD (04E4EH),HL - POP HL - CALL 0195AH - JP 01B35H - -L5338: PUSH DE -L5339: CALL SKIPSPACE - CALL L52D5 - JR NZ,L5343 ; (+002H) - POP BC - RET - -L5343: CP 080H - JR NZ,L5339 ; (-00eH) - CP (HL) - JR NZ,L5339 ; (-011H) - DEC DE - CALL 0174EH - INC HL - CP 03AH - JR Z,L5339 ; (-01aH) - EX (SP),HL - OR A - SBC HL,DE - POP HL - DEC DE - LD A,00DH - LD (DE),A - INC DE - RET C - DEC DE - DEC DE - DEC DE - DEC DE - RET - -L5363: XOR A - LD (L5465),A - CALL L536D - JP WARMSTRT - -L536D: LD A,(0504EH) - OR A - JP NZ,SYNTAXERR - CALL 0193BH - RET Z - LD DE,LINEBUFR - PUSH DE - CALL 0150AH - POP HL - CALL L546D - LD (L5467),A - LD DE,BUFER - LDIR - LD A,(L5465) - CP 001H - JR NZ,L53B7 ; (+025H) - LD DE,L5446 - CALL LETNL - CALL MSG - LD A,(DPRNT) - PUSH AF - LD DE,LINEBUFR - PUSH DE - CALL GETL - POP HL - XOR A - LD B,A - POP AF - LD C,A - ADD HL,BC - CALL L546D - LD DE,011CCH - LD (L5468),A - LDIR -L53B7: LD A,(L5467) - LD B,A - LD HL,(01958H) -L53BE: PUSH BC - PUSH HL - CALL 01867H - POP HL - JR NZ,L53D3 ; (+00dH) - CALL LETNL - POP BC - XOR A - RET - -L53CC: POP BC - POP DE - LD HL,(04A0EH) - JR L53BE ; (-015H) - -L53D3: CALL 018F2H - LD DE,04A0EH - CALL 018A5H - CALL 014F8H - POP BC - CALL BRKEY - JP Z,WARMSTRT - LD DE,BUFER - LD HL,0490FH -L53EC: LD A,(HL) - CP 020H - INC HL - JR NZ,L53EC ; (-006H) -L53F2: PUSH DE - PUSH BC - DEC HL -L53F5: INC HL - LD A,(HL) - CP 000H - JR Z,L53F5 ; (-006H) - CP 00DH - JR Z,L53CC ; (-033H) - EX DE,HL - CP (HL) - EX DE,HL - JR NZ,L53F5 ; (-00fH) - LD (L5469),HL -L5407: INC DE - DEC B - JR Z,L5423 ; (+018H) - LD A,(DE) - CP 020H - JR Z,L5407 ; (-009H) -L5410: INC HL - LD A,(HL) - CP 020H - JR Z,L5410 ; (-006H) - CP 00DH - JR Z,L53CC ; (-04eH) - EX DE,HL - CP (HL) - EX DE,HL - JR Z,L5407 ; (-018H) - POP BC - POP DE - JR L53F2 ; (-031H) - -L5423: INC HL - LD (L546B),HL - LD DE,LINEBUFR - CALL LETNL - CALL L5589 - POP BC - POP DE - LD A,(L5465) - OR A - RET NZ - CALL L543C - JR L53F2 ; (-04aH) - -L543C: CALL 03302H - CALL BRKEY - JP Z,L57D8 - RET - -L5446: DB " CHANGE TO? " - DB 00DH -L5453: DB "CHANGE IT? (Y/N) " - DB 00DH -L5465: DB 000H -L5466: DB 000H -L5467: DB 001H -L5468: DB 000H -L5469: DB 000H - DB 000H -L546B: DB 000H - DB 000H -L546D: LD A,(HL) - CP 020H - JP C,WARMSTRT - CP 022H - JR NZ,L5478 ; (+001H) - INC HL -L5478: CALL 018FDH - LD A,C - CP 028H - JP NC,ILDATERR - INC C - RET - -L5483: LD A,(HL) - CP 021H - JR NZ,L548A ; (+002H) - INC HL - XOR A -L548A: LD (L5466),A - RET - -L548E: LD A,001H - LD (L5465),A - CALL L5483 - CALL L536D -L5499: JP Z,WARMSTRT - CALL LETNL - LD A,(L5466) - OR A - JR NZ,L54BC ; (+017H) - LD DE,L5453 - CALL L59E3 - JR Z,L54BC ; (+00fH) - LD HL,(L546B) - LD DE,BUFER - LD A,(L5467) - LD B,A - CALL L53F2 - JR L5499 ; (-023H) - -L54BC: CALL 014F8H - LD HL,(L546B) - LD BC,(05469H) - OR A - SBC HL,BC - LD A,(L5468) - CP L - JR Z,L552E ; (+05fH) - JR C,L5517 ; (+046H) - PUSH BC - SUB L - LD C,A - LD B,000H - PUSH BC - LD HL,LINEBUFR - CALL 018FDH - INC C - LD A,C - POP BC - PUSH AF - ADD A,C - LD C,A - CP 050H - JR C,L5501 ; (+01aH) - LD DE,L55B3 - CALL LETNL - CALL MSG - POP AF - POP BC - LD HL,(04A0EH) - LD A,(L5467) - LD B,A - LD C,000H - LD DE,BUFER - JP L5565 - -L5501: LD HL,LINEBUFR - PUSH HL - ADD HL,BC - EX DE,HL - POP HL - POP AF - LD C,A - ADD HL,BC - POP BC - PUSH HL - OR A - SBC HL,BC - LD B,H - LD C,L - POP HL - LDDR - JR L552E ; (+017H) - -L5517: LD H,A - LD A,L - SUB H - LD L,A - LD H,000H - PUSH HL - LD HL,(L546B) - CALL 018FDH - INC C - POP DE - PUSH HL - OR A - SBC HL,DE - EX DE,HL - POP HL - LDIR -L552E: LD HL,011CCH - LD DE,(05469H) - LD A,(L5468) - OR A - JR Z,L5540 ; (+005H) - LD C,A - LD B,000H - LDIR -L5540: CALL 0146AH -L5543: LD HL,(04A10H) - CALL 018B0H - OR C - INC DE - CALL 01302H - CALL 018B3H - LD D,E - LD D,L - LD A,(L5465) - CP 001H - RET NZ - CALL 012F3H - LD DE,LINEBUFR - CALL MSGX - CALL LETNL -L5565: LD BC,L5499 - PUSH BC - LD DE,BUFER - LD HL,(L5469) - LD A,(L5468) - ADD A,L - LD L,A - LD A,(L5467) - LD B,A - LD C,000H - PUSH HL - LD HL,(04A0EH) - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - LD (04A0EH),HL - POP HL - JP L53F2 - -L5589: PUSH DE - LD DE,L55AB - CALL MSG - POP DE - PUSH HL - CALL 00FB1H - CALL MSGX - LD A,(L5469) - ADD A,01BH - LD C,A - LD B,000H - XOR A - ADC HL,BC - LD A,0C2H - LD (HL),A - POP HL - CALL LETNL - RET - -L55AB: LD DE,01211H - LD (DE),A - DEC C - NOP - NOP - NOP -L55B3: DB "LINE IS TOO LONG!",00DH -L55C5: LD A,002H - LD (L5465),A - CALL L5483 - CALL L536D -L55D0: JP Z,WARMSTRT - CALL LETNL - LD A,(L5466) - OR A - JR NZ,L55E9 ; (+00dH) - LD DE,L55F8 - CALL L59E3 - JR Z,L55E9 ; (+005H) - LD HL,(04A0EH) - JR L55EC ; (+003H) - -L55E9: CALL L5543 -L55EC: LD DE,BUFER - LD A,(L5467) - LD B,A - CALL L53BE - JR L55D0 ; (-028H) - -L55F8: DB "DELETE THIS LINE (Y/N)? ",00DH -L5611: NOP -L5612: NOP - NOP - NOP - NOP -L5616: XOR A - LD (L5611),A - CALL EXECNOTCHR - CPL - DEC HL - LD D,(HL) - CALL EXECNOTCHR - LD D,B - XOR E - INC DE - LD A,001H - LD (L5611),A - CALL 03327H - LD HL,(04AB3H) - CALL 018B0H - OR C - INC DE - PUSH HL - CALL 01AF1H - POP HL -L563B: LD A,(HL) - INC HL - OR (HL) - JP Z,L574F - INC HL - LD C,(HL) - INC HL - LD B,(HL) - PUSH HL - OR A - LD HL,(04AB5H) - SBC HL,BC - POP HL - JP C,L574F - PUSH BC - POP IY -L5653: INC HL -L5654: LD A,(HL) - INC HL - CP 020H - JR Z,L5654 ; (-006H) - CP 00DH - JR Z,L563B ; (-023H) - CP 080H - JR C,L5676 ; (+014H) - JR NZ,L5654 ; (-010H) - CP (HL) - JR Z,L566C ; (+005H) - CALL L588A - JR NZ,L5654 ; (-018H) -L566C: CALL 0174EH - INC HL - CP 00DH - JR Z,L563B ; (-039H) - JR L5654 ; (-022H) - -L5676: CP 022H - JR NZ,L5686 ; (+00cH) -L567A: LD A,(HL) - INC HL - CP 00DH - JR Z,L563B ; (-045H) - CP 022H - JR NZ,L567A ; (-00aH) - JR L5654 ; (-032H) - -L5686: DEC HL - CALL 02640H - JR NC,L5653 ; (-039H) - LD A,046H - CP E - JR NZ,L5696 ; (+005H) - LD A,04EH - CP D - JR Z,L5653 ; (-043H) -L5696: LD BC,MONIT - LD A,(HL) - CP 024H - JR NZ,L56A1 ; (+003H) - LD C,006H - INC HL -L56A1: LD (05614H),DE - LD (L5612),HL - LD A,(HL) - CP 028H - JR Z,L56B3 ; (+006H) - LD A,C - ADD A,004H - LD C,A - JR L56CB ; (+018H) - -L56B3: INC HL -L56B4: LD A,(HL) - INC HL - CP 028H - JR NZ,L56C1 ; (+007H) -L56BA: LD A,(HL) - INC HL - CP 029H - JR NZ,L56BA ; (-006H) - LD A,(HL) -L56C1: CP 02CH - JR Z,L56CB ; (+006H) - CP 029H - JR NZ,L56B4 ; (-015H) - INC C - INC C -L56CB: LD HL,04E86H - ADD HL,BC - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - LD DE,(05614H) -L56D7: LD A,(HL) - INC HL - CP E - JR C,L56E6 ; (+00aH) - JR NZ,L56F2 ; (+014H) - LD A,(HL) - CP D - JR C,L56E9 ; (+007H) - JR Z,L5705 ; (+021H) - JR L56F2 ; (+00cH) - -L56E6: OR (HL) - JR Z,L56F2 ; (+009H) -L56E9: INC HL - LD C,(HL) - LD B,000H - INC HL - ADD HL,BC - ADD HL,BC - JR L56D7 ; (-01bH) - -L56F2: DEC HL - EX DE,HL - LD BC,GETL - CALL 019C0H - LD HL,(05614H) - EX DE,HL - LD (HL),E - INC HL - LD (HL),D - INC HL - XOR A - JR L570B ; (+006H) - -L5705: INC HL - LD A,(HL) - CP PRTD - JR Z,L573C ; (+031H) -L570B: INC A - LD (HL),A - PUSH HL - LD B,A -L570F: INC HL - LD E,(HL) - INC HL - LD D,(HL) - PUSH HL - PUSH IY - POP HL - OR A - SBC HL,DE - POP HL - JR C,L5726 ; (+009H) - JR NZ,L5724 ; (+005H) - DEC A - POP HL - LD (HL),A - JR L5736 ; (+012H) - -L5724: DJNZ L570F ; (-017H) -L5726: POP AF - DEC HL - EX DE,HL - LD BC,00002H - CALL 019C0H - EX DE,HL - PUSH IY - POP BC - LD (HL),C - INC HL - LD (HL),B -L5736: LD HL,(L5612) - JP L5654 - -L573C: LD A,E - CALL L57DE - LD A,D - CALL L57DE - LD DE,L5807 - CALL L57FC - CALL L57ED - JR L5736 ; (-019H) - -L574F: LD IX,04E84H -L5753: CALL L57FC - INC IX - INC IX - PUSH IX - POP HL - LD A,L - CP 092H - JR NC,L57D8 ; (+076H) - SUB 086H - LD B,000H - LD C,A - RLC C - RLC C - LD HL,L5820 - CP 005H - JR C,L5775 ; (+003H) - LD HL,L5807 -L5775: ADD HL,BC - PUSH HL - POP IY - LD L,(IX+000H) - LD H,(IX+001H) -L577F: PUSH IY - POP DE - LD A,(HL) - LD B,A - INC HL - OR (HL) - JR Z,L5753 ; (-035H) - LD A,B - CALL L57DE - LD A,(HL) - CP 020H - JR Z,L5799 ; (+008H) - CALL L57DE - CALL L57ED - JR L57A1 ; (+008H) - -L5799: CALL L57ED - LD A,020H - CALL L57DE -L57A1: LD A,(DE) - CP 024H - LD A,020H - CALL NZ,L57DE - INC HL - LD B,(HL) - INC HL -L57AC: PUSH BC - LD E,(HL) - INC HL - LD D,(HL) - INC HL - PUSH HL - EX DE,HL - LD DE,LINEBUFR - PUSH DE - CALL STRTONUM - LD C,020H - EX DE,HL -L57BD: LD A,L - CP 015H - JR NC,L57C6 ; (+004H) - LD (HL),C - INC HL - JR L57BD ; (-009H) - -L57C6: LD (HL),00DH - POP DE - CALL L57ED - POP HL - CALL L543C - POP BC - DJNZ L57AC ; (-027H) - CALL L57FC - JR L577F ; (-059H) - -L57D8: CALL 01AF1H - JP WARMSTRT - -L57DE: PUSH BC - LD B,A - CALL PRNT - LD A,(L5611) - OR A - LD A,B - POP BC - RET Z - JP 03291H - -L57ED: PUSH BC - LD B,A - CALL MSG - LD A,(L5611) - OR A - LD A,B - POP BC - RET Z - JP 031B4H - -L57FC: CALL LETNL - LD A,(L5611) - OR A - RET Z - JP 031A7H - -L5807: DB " HAS MORE THAN 255 REFS" - DB 00DH - DB 024H -L5820: DB 028H - DB 02CH - DB 029H - DB 020H - DB 00DH - DB 00DH - DB 00DH - DB "$() " - DB 00DH - DB 00DH - DB 00DH - DB "$ " - DB 00DH - DB 00DH - DB 00DH - DB 000H -L5838: CALL 014C7H - JP Z,01497H - LD B,0B8H - LD DE,L585D - CALL 014C9H - JP 01495H - -L5849: LD A,B - CP 039H - JR NC,L5854 ; (+006H) - LD HL,CMDWORDTBL - JP 01541H - -L5854: SUB 038H - LD B,A - LD HL,L585D - JP 01541H - -L585D: DB "RENU" - DB 0CDH - DB "APPEN" - DB 0C4H - DB "COMPRES" - DB 0D3H - DB "DELET" - DB 0C5H - DB "FIN" - DB 0C4H - DB "CHANG" - DB 0C5H - DB "SDE" - DB 0CCH - DB "XRE" - DB 0C6H - DB 000H - DB 000H -L588A: LD A,(HL) - CP 081H - RET Z - RET C - CALL INCSKIPSPCE - CP 02FH - RET NZ - INC HL - INC HL - OR A - RET - -L5899: CALL LETNL - CALL LETNL - LD DE,L58A5 - JP 01329H - -L58A5: LD B,L - LD E,B - LD D,B - LD B,C - LD C,(HL) - LD B,H - LD B,L - LD B,H - JR NZ,L58F1 ; (+042H) - LD B,C - LD D,E - LD C,C - LD B,E - JR NZ,L58EA ; (+035H) - DEC (HL) - LD SP,02035H - DEC L - JR NZ,L5905 ; (+049H) - LD C,(HL) - LD B,E - LD C,H - LD D,L - LD B,H - LD B,L - LD D,E - LD A,(0430DH) - OR A - SBC A,(HL) - CP L - SBC A,L - AND (HL) - SUB A - SBC A,B - SUB (HL) - JR NZ,L5913 ; (+043H) - LD L,044H - LD L,020H - LD C,B - SUB D - AND C - SBC A,L - OR B - JR NZ,L590C ; (+031H) - ADD HL,SP - JR C,L5915 ; (+037H) - JR NZ,L58ED ; (+00dH) -L58E0: CALL 03296H - LD A,00AH - CALL 03296H - LD A,00DH -L58EA: RET - -L58EB: CALL SKIPSPACE - CP 030H - JR NZ,L58F6 ; (+004H) - LD A,0C3H - JR L58FD ; (+007H) - -L58F6: CP 031H - JP NZ,SYNTAXERR - LD A,0CDH -L58FD: LD (L58E0),A - INC HL -L5901: LD (05051H),HL -L5904: JP 01B35H - -L5907: LD A,0C6H - CALL ?DPCT -L590C: JR L5901 ; (-00dH) - -L590E: XOR A - LD (L5466),A - CALL L5098 -L5915: JR NZ,L591C ; (+005H) - CALL L5150 - JR L5904 ; (-018H) - -L591C: LD BC,(05063H) - CALL L52BB - JR Z,L5935 ; (+010H) - PUSH HL - LD BC,(05065H) - INC BC - CALL L52BB - POP DE - OR A - SBC HL,DE - JP Z,WARMSTRT -L5935: LD HL,(01958H) - JR L593C ; (+002H) - -L593A: POP HL - POP AF -L593C: PUSH HL - CALL 01867H - JR Z,L5989 ; (+047H) - PUSH HL - LD HL,(L506B) - SBC HL,DE - JR C,L593A ; (-010H) - LD HL,(05067H) - PUSH DE - EX DE,HL - SBC HL,DE - POP DE - JR C,L593A ; (-01aH) - LD HL,(05065H) - SBC HL,DE - JR C,L5963 ; (+008H) - LD HL,(05063H) - EX DE,HL - SBC HL,DE - JR NC,L593A ; (-029H) -L5963: LD A,(L5466) - OR A - JR NZ,L597B ; (+012H) - LD DE,L59C7 - CALL L59E0 - JR Z,L5976 ; (+005H) - POP HL - POP DE - JP 01B35H - -L5976: LD A,001H - LD (L5466),A -L597B: POP HL - POP DE - OR A - SBC HL,DE - LD B,H - LD C,L - PUSH DE - CALL 01306H - POP HL - JR L593C ; (-04dH) - -L5989: CALL L5150 -L598C: LD HL,(01958H) - CALL 01867H - JR Z,L59C4 ; (+030H) - PUSH DE - POP BC -L5996: PUSH HL - CALL 01867H - JR Z,L59C4 ; (+028H) - LD A,B - SUB D - JR NZ,L59A2 ; (+002H) - LD A,C - SUB E -L59A2: LD C,E - LD B,D - POP DE - JR C,L5996 ; (-011H) - PUSH BC - SBC HL,DE - LD B,H - LD C,L - LD HL,04A0EH - EX DE,HL - PUSH HL - PUSH BC - LDIR - POP BC - POP DE - CALL 01306H - POP HL - CALL 018B0H - CP A - LD E,C - CALL 012F3H - JR L598C ; (-038H) - -L59C4: JP WARMSTRT - -L59C7: DB "OK TO DELETE DUP LINES? " - DB 00DH -L59E0: CALL LETNL -L59E3: CALL MSG -L59E6: CALL BRKEY - JP Z,01438H - CALL 009B3H - CALL ?DACN - CALL 02305H - CP 059H - JR Z,L59FE ; (+005H) - CP 04EH - JR NZ,L59E6 ; (-017H) - OR A -L59FE: PUSH AF - CALL LETNL - POP AF - RET - -L5A04: DW L58EB - DW CMDAUTO - DW L5907 - DW L590E - DW CMDCOPY - DW CMDPAGE - DW L506D - DW 04806H - DW L52F0 - DW 0488EH - DW L5363 - DW L548E - DW L55C5 - DW L5616 -L5A20: DB "LIN" - DB 0C5H - DB "AUT" - DB 0CFH - DB "CL" - DB 0D3H - DB "MOV" - DB 0C5H - DB "COPY/" - DB 0D0H - DB "PAGE/" - DB 0D0H - DB 000H -L5A3C: CP 091H - RET C - CP 0BEH - RET NC - CALL ?ADCN - CP 081H - JR C,L5A4F ; (+006H) - CP 09BH - JR NC,L5A4F ; (+002H) - SUB 080H -L5A4F: JP ?DACN - -L5A52: DB "XP BASIC SA-551" -L5A61: DB 035H - DB 00DH -XPINIT: LD HL,L5A04 - LD DE,01C16H - LD BC,0001CH - LDIR - LD HL,L5A3C - PUSH HL - LD DE,L5A20 - SBC HL,DE - PUSH HL - POP BC - EX DE,HL - LD DE,0165EH - LDIR - POP HL - LD DE,02305H - LD BC,00016H - LDIR - LD HL,03338H - LD (022C9H),HL - LD HL,03302H - LD (01CCDH),HL - LD HL,MONIT - LD (01CCFH),HL - LD (01CD1H),HL - LD HL,03311H - LD (02B11H),HL - LD HL,048C1H - LD (0307BH),HL - LD (0318CH),HL - LD (03199H),HL - LD HL,02F6CH - LD (0315BH),HL - LD A,0CDH - LD (03140H),A - LD HL,0330BH - LD (03141H),HL - LD A,0C3H - LD HL,L5849 - LD (0153EH),A - LD (0153FH),HL - LD HL,L5838 - LD (01492H),A - LD (01493H),HL - LD A,(0322EH) - CP 0C3H - JR NZ,L5AF2 ; (+017H) - LD (031ADH),A - LD HL,L58E0 - LD (031AEH),HL - LD A,036H - JR L5AF4 ; (+00cH) - - LD A,0ABH - LD (01C16H),A - LD A,013H - LD (01C17H),A -L5AF2: LD A,035H -L5AF4: LD HL,L58B7 - LD (HL),A - LD HL,L5A61 - LD (HL),A - XOR A - LD (041ECH),A - LD HL,L5A52 - LD DE,04224H - LD BC,00011H - LDIR - LD HL,L5A04 - LD (01958H),HL - LD (018B4H),HL - LD (01AC8H),HL - LD (01AE2H),HL - LD (01B14H),HL - LD (01B1CH),HL - LD (01C7EH),HL - LD (01EC2H),HL - LD (02D44H),HL - LD (02F24H),HL - LD (0303CH),HL - LD (03042H),HL - INC HL - LD (01201H),HL - LD (041FFH),HL - LD HL,L5899 - LD (01225H),HL - LD HL,RELOC3302 - LD DE,03302H - LD BC,0005BH - LDIR - LD DE,04806H - LD BC,000F8H - LDIR - JP COLDSTRT - -RELOC3302: CALL GETKY ; Relocated to 0x3302 for 0x5B bytes. - CP 020H - JP Z,009B3H - RET - - LD HL,ATRB - JP 02F67H - - CALL EXECNOTCHR - LD B,B - JR L5B95 ; (+02bH) - - LD A,0C9H - LD (028F5H),A - CALL CMDCURSOR - LD A,0C3H - LD (028F5H),A - JP 02B18H - - LD A,0C9H - LD (01C7DH),A - CALL 01C68H - LD A,021H - LD (01C7DH),A - RET - - NOP - NOP - NOP - LD A,B - OR C - RET Z - LD A,B - SUB C - JR NC,L5B93 ; (+001H) - XOR A -L5B93: ADD A,C - LD B,A -L5B95: LD A,(DE) - CALL 02305H - LD C,A - PUSH AF - LD A,(HL) - CALL 02305H - LD C,A - POP AF - OR A - SUB C - JR NZ,L5BAA ; (+005H) - INC DE - INC HL - DJNZ L5B95 ; (-014H) - RET - -L5BAA: LD A,001H - RET NC - LD A,080H - RET - -RELOC4806: CALL 048EEH ; Relocated to 0x4806 for 0xF8 bytes. - LD HL,0FFFFH - CALL 018B0H - LD DE,0E548H - EX DE,HL - LD BC,(SIZE) - DEC BC - DEC BC - CALL 01888H - CALL 019C3H - LD (DTADR),DE - CALL 02F6CH - CALL ?RDD - JR C,L5BFB ; (+026H) - POP HL - CALL 01ACAH - LD HL,(DTADR) - PUSH HL - INC HL - INC HL - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - CALL 018B0H - LD A,048H - POP BC - OR A - SBC HL,BC - JP NC,01B35H - LD DE,(DTADR) - CALL 0485EH - LD A,047H - JP 01403H - -L5BFB: POP DE - PUSH DE - CALL 0485EH - POP HL - XOR A - LD (HL),A - INC HL - LD (HL),A - JP CHKSUMERR - - LD BC,(SIZE) - DEC BC - DEC BC - JP 02F59H - - CALL 03327H - LD HL,(04AB5H) - LD A,H - AND L - CP PRTD - JP Z,ILDATERR - PUSH HL - LD HL,(04AB3H) - LD A,H - OR L - JP Z,ILDATERR - CALL 018B0H - OR C - INC DE - EX (SP),HL - INC HL - CALL 018B0H - ADC A,C - LD C,B - POP DE - OR A - SBC HL,DE - RET - - CALL 04867H - JR Z,L5C44 ; (+007H) - JR C,L5C47 ; (+008H) - PUSH HL - POP BC - CALL 01306H -L5C44: JP 01B35H - -L5C47: JP OVFLERR - - PUSH BC - CALL 017F6H - POP BC - LD A,E - OR D - EX (SP),HL - LD A,(HL) - INC HL - EX (SP),HL - PUSH AF - CP (HL) - JR Z,L5C66 ; (+00dH) - LD A,00DH - CP (HL) - JR Z,L5C63 ; (+005H) - LD A,03AH - CP (HL) - JR NZ,L5C47 ; (-01cH) -L5C63: POP AF - SCF - RET - -L5C66: CALL INCSKIPSPCE - POP AF - RET - - DI - PUSH DE - PUSH BC - PUSH HL - LD DE,0D753H - LD BC,(SIZE) - LD HL,(DTADR) - LD A,B - OR C - JP Z,004CBH - CALL CKSUM - CALL MOTOR - JP C,00552H - CALL 048E3H - JP 00461H - - PUSH BC - PUSH DE - LD BC,00200H - LD DE,01414H - JP 0078EH - - LD A,0C9H - LD (02F19H),A - CALL 02EDAH - LD A,0CDH - LD (02F19H),A - JP 01AF1H - - NOP ; End of Relocated code. - NOP - NOP - NOP - NOP diff --git a/software/dis/XPATCH/XPATCH-5510.ref b/software/dis/XPATCH/XPATCH-5510.ref deleted file mode 100644 index b10ee48..0000000 --- a/software/dis/XPATCH/XPATCH-5510.ref +++ /dev/null @@ -1,875 +0,0 @@ -dZ80 2.1 Reference file from the disassembly of "XPATCH-5510.bin". - -Direct address Reference (127 entries) --------------------------------------- - -Direct address 00000H. 3 references: ------------------------------------- - - 05098H: LD DE,00000H - 05696H: LD BC,00000H - 05a94H: LD HL,00000H - -Direct address 00002H. 1 references: ------------------------------------- - - 05729H: LD BC,00002H - -Direct address 00003H. 1 references: ------------------------------------- - - 056f4H: LD BC,00003H - -Direct address 0000aH. 2 references: ------------------------------------- - - 050d8H: LD DE,0000AH - 050e5H: LD DE,0000AH - -Direct address 00011H. 1 references: ------------------------------------- - - 05b06H: LD BC,00011H - -Direct address 00016H. 1 references: ------------------------------------- - - 05a83H: LD BC,00016H - -Direct address 0001cH. 1 references: ------------------------------------- - - 05a69H: LD BC,0001CH - -Direct address 0005bH. 1 references: ------------------------------------- - - 05b45H: LD BC,0005BH - -Direct address 00080H. 1 references: ------------------------------------- - - 0515fH: LD BC,00080H - -Direct address 000f8H. 1 references: ------------------------------------- - - 05b4dH: LD BC,000F8H - -Direct address 00100H. 1 references: ------------------------------------- - - 05167H: LD BC,00100H - -Direct address 00200H. 1 references: ------------------------------------- - - 05c8fH: LD BC,00200H - -Direct address ATRB. 1 references: ----------------------------------- - - 05b5eH: LD HL,010F0H - -Direct address SIZE. 3 references: ----------------------------------- - - 05bbdH: LD BC,(01102H) - 05c08H: LD BC,(01102H) - 05c72H: LD BC,(01102H) - -Direct address DTADR. 2 references: ------------------------------------ - - 05bc9H: LD (01104H),DE - 05befH: LD DE,(01104H) - -Direct address BUFER. 6 references: ------------------------------------ - - 05386H: LD DE,011A3H - 053e6H: LD DE,011A3H - 054b0H: LD DE,011A3H - 054fbH: LD DE,011A3H - 05569H: LD DE,011A3H - 055ecH: LD DE,011A3H - -Direct address 011ccH. 2 references: ------------------------------------- - - 053afH: LD DE,011CCH - 0552eH: LD HL,011CCH - -Direct address 01211H. 1 references: ------------------------------------- - - 055abH: LD DE,01211H - -Direct address 01414H. 1 references: ------------------------------------- - - 05c92H: LD DE,01414H - -Direct address 015a8H. 1 references: ------------------------------------- - - 0584eH: LD HL,015A8H - -Direct address 0165eH. 1 references: ------------------------------------- - - 05a7aH: LD DE,0165EH - -Direct address 01b35H. 1 references: ------------------------------------- - - 0506dH: LD BC,01B35H - -Direct address 01c16H. 1 references: ------------------------------------- - - 05a66H: LD DE,01C16H - -Direct address 02035H. 1 references: ------------------------------------- - - 058b6H: LD SP,02035H - -Direct address 02305H. 1 references: ------------------------------------- - - 05a80H: LD DE,02305H - -Direct address 02a2fH. 1 references: ------------------------------------- - - 05a06H: CPL - -Direct address 02f6cH. 1 references: ------------------------------------- - - 05aafH: LD HL,02F6CH - -Direct address 032d4H. 1 references: ------------------------------------- - - 05a0eH: CALL NC,06D32H - -Direct address 03302H. 2 references: ------------------------------------- - - 05a8eH: LD HL,03302H - 05b42H: LD DE,03302H - -Direct address 0330bH. 1 references: ------------------------------------- - - 05abaH: LD HL,0330BH - -Direct address 03311H. 1 references: ------------------------------------- - - 05a9dH: LD HL,03311H - -Direct address 03338H. 1 references: ------------------------------------- - - 05a88H: LD HL,03338H - -Direct address 033abH. 1 references: ------------------------------------- - - 05a0cH: XOR E - -Direct address 04224H. 1 references: ------------------------------------- - - 05b03H: LD DE,04224H - -Direct address 04806H. 2 references: ------------------------------------- - - 05a12H: LD B,048H - 05b4aH: LD DE,04806H - -Direct address 0488eH. 1 references: ------------------------------------- - - 05a16H: ADC A,(HL) - -Direct address 048c1H. 1 references: ------------------------------------- - - 05aa3H: LD HL,048C1H - -Direct address LINEBUFR. 7 references: --------------------------------------- - - 05378H: LD DE,0490DH - 0539fH: LD DE,0490DH - 05427H: LD DE,0490DH - 054d7H: LD HL,0490DH - 05501H: LD HL,0490DH - 0555cH: LD DE,0490DH - 057b3H: LD DE,0490DH - -Direct address 0490fH. 1 references: ------------------------------------- - - 053e9H: LD HL,0490FH - -Direct address 04a0eH. 2 references: ------------------------------------- - - 053d6H: LD DE,04A0EH - 059acH: LD HL,04A0EH - -Direct address 04e84H. 1 references: ------------------------------------- - - 0574fH: LD IX,04E84H - -Direct address 04e86H. 1 references: ------------------------------------- - - 056cbH: LD HL,04E86H - -Direct address 0505cH. 1 references: ------------------------------------- - - 05248H: LD DE,0505CH - -Direct address 05063H. 7 references: ------------------------------------- - - 0509bH: LD (05063H),DE - 050afH: LD (05063H),DE - 050c4H: LD (05063H),DE - 050efH: LD BC,(05063H) - 051a6H: LD BC,(05063H) - 0527aH: LD DE,(05063H) - 0591cH: LD BC,(05063H) - -Direct address 05065H. 5 references: ------------------------------------- - - 050a1H: LD (05065H),DE - 050baH: LD (05065H),DE - 050c8H: LD (05065H),DE - 05118H: LD BC,(05065H) - 05926H: LD BC,(05065H) - -Direct address 05067H. 3 references: ------------------------------------- - - 050dbH: LD (05067H),DE - 051adH: LD BC,(05067H) - 0528aH: LD DE,(05067H) - -Direct address 05069H. 2 references: ------------------------------------- - - 050e8H: LD (05069H),DE - 0529eH: LD DE,(05069H) - -Direct address 0506dH. 1 references: ------------------------------------- - - 05a10H: LD L,L - -Direct address 0507dH. 1 references: ------------------------------------- - - 05077H: LD DE,0507DH - -Direct address 05089H. 1 references: ------------------------------------- - - 0512dH: LD DE,05089H - -Direct address 05255H. 1 references: ------------------------------------- - - 05216H: LD DE,05255H - -Direct address 05257H. 1 references: ------------------------------------- - - 05231H: LD DE,05257H - -Direct address 0525cH. 1 references: ------------------------------------- - - 05221H: LD DE,0525CH - -Direct address 052f0H. 1 references: ------------------------------------- - - 05a14H: RET P - -Direct address 05363H. 1 references: ------------------------------------- - - 05a18H: LD H,E - -Direct address 05446H. 1 references: ------------------------------------- - - 05392H: LD DE,05446H - -Direct address 05453H. 1 references: ------------------------------------- - - 054a5H: LD DE,05453H - -Direct address 05469H. 2 references: ------------------------------------- - - 054c2H: LD BC,(05469H) - 05531H: LD DE,(05469H) - -Direct address 0548eH. 1 references: ------------------------------------- - - 05a1aH: ADC A,(HL) - -Direct address 05499H. 1 references: ------------------------------------- - - 05565H: LD BC,05499H - -Direct address 055abH. 1 references: ------------------------------------- - - 0558aH: LD DE,055ABH - -Direct address 055b3H. 1 references: ------------------------------------- - - 054e7H: LD DE,055B3H - -Direct address 055c5H. 1 references: ------------------------------------- - - 05a1cH: PUSH BC - -Direct address 055f8H. 1 references: ------------------------------------- - - 055dcH: LD DE,055F8H - -Direct address 05614H. 2 references: ------------------------------------- - - 056a1H: LD (05614H),DE - 056d3H: LD DE,(05614H) - -Direct address 05616H. 1 references: ------------------------------------- - - 05a1eH: LD D,056H - -Direct address 05807H. 2 references: ------------------------------------- - - 05744H: LD DE,05807H - 05772H: LD HL,05807H - -Direct address 05820H. 1 references: ------------------------------------- - - 0576bH: LD HL,05820H - -Direct address 05838H. 1 references: ------------------------------------- - - 05acbH: LD HL,05838H - -Direct address 05849H. 1 references: ------------------------------------- - - 05ac2H: LD HL,05849H - -Direct address 0585dH. 2 references: ------------------------------------- - - 05840H: LD DE,0585DH - 05857H: LD HL,0585DH - -Direct address 05899H. 1 references: ------------------------------------- - - 05b39H: LD HL,05899H - -Direct address 058a5H. 1 references: ------------------------------------- - - 0589fH: LD DE,058A5H - -Direct address 058b7H. 1 references: ------------------------------------- - - 05af4H: LD HL,058B7H - -Direct address 058e0H. 1 references: ------------------------------------- - - 05adeH: LD HL,058E0H - -Direct address 058ebH. 1 references: ------------------------------------- - - 05a04H: EX DE,HL - -Direct address 05907H. 1 references: ------------------------------------- - - 05a08H: RLCA - -Direct address 0590eH. 1 references: ------------------------------------- - - 05a0aH: LD C,059H - -Direct address 059c7H. 1 references: ------------------------------------- - - 05969H: LD DE,059C7H - -Direct address 05a04H. 2 references: ------------------------------------- - - 05a63H: LD HL,05A04H - 05b0bH: LD HL,05A04H - -Direct address 05a20H. 1 references: ------------------------------------- - - 05a72H: LD DE,05A20H - -Direct address 05a3cH. 1 references: ------------------------------------- - - 05a6eH: LD HL,05A3CH - -Direct address 05a52H. 1 references: ------------------------------------- - - 05b00H: LD HL,05A52H - -Direct address 05a61H. 1 references: ------------------------------------- - - 05af8H: LD HL,05A61H - -Direct address 05b55H. 1 references: ------------------------------------- - - 05b3fH: LD HL,05B55H - -Direct address 0d753H. 1 references: ------------------------------------- - - 05c6fH: LD DE,0D753H - -Direct address 0e548H. 1 references: ------------------------------------- - - 05bb9H: LD DE,0E548H - -Direct address 0ffffH. 1 references: ------------------------------------- - - 05bb3H: LD HL,0FFFFH - - -Indirect address Reference (120 entries) ----------------------------------------- - -Indirect address DTADR. 2 references: -------------------------------------- - - 05bd9H: LD HL,(01104H) - 05c76H: LD HL,(01104H) - -Indirect address DSPXY. 2 references: -------------------------------------- - - 0521bH: LD (01171H),A - 05228H: LD (01171H),A - -Indirect address DPRNT. 1 references: -------------------------------------- - - 0539bH: LD A,(01194H) - -Indirect address 01201H. 1 references: --------------------------------------- - - 05b33H: LD (01201H),HL - -Indirect address 01225H. 1 references: --------------------------------------- - - 05b3cH: LD (01225H),HL - -Indirect address 01492H. 1 references: --------------------------------------- - - 05aceH: LD (01492H),A - -Indirect address 01493H. 1 references: --------------------------------------- - - 05ad1H: LD (01493H),HL - -Indirect address 0153eH. 1 references: --------------------------------------- - - 05ac5H: LD (0153EH),A - -Indirect address 0153fH. 1 references: --------------------------------------- - - 05ac8H: LD (0153FH),HL - -Indirect address 018b4H. 1 references: --------------------------------------- - - 05b11H: LD (018B4H),HL - -Indirect address 01958H. 6 references: --------------------------------------- - - 05153H: LD HL,(01958H) - 052bbH: LD HL,(01958H) - 053bbH: LD HL,(01958H) - 05935H: LD HL,(01958H) - 0598cH: LD HL,(01958H) - 05b0eH: LD (01958H),HL - -Indirect address 01ac8H. 1 references: --------------------------------------- - - 05b14H: LD (01AC8H),HL - -Indirect address 01ae2H. 1 references: --------------------------------------- - - 05b17H: LD (01AE2H),HL - -Indirect address 01b14H. 1 references: --------------------------------------- - - 05b1aH: LD (01B14H),HL - -Indirect address 01b1cH. 1 references: --------------------------------------- - - 05b1dH: LD (01B1CH),HL - -Indirect address 01c16H. 1 references: --------------------------------------- - - 05aeaH: LD (01C16H),A - -Indirect address 01c17H. 1 references: --------------------------------------- - - 05aefH: LD (01C17H),A - -Indirect address 01c7dH. 2 references: --------------------------------------- - - 05b7cH: LD (01C7DH),A - 05b84H: LD (01C7DH),A - -Indirect address 01c7eH. 1 references: --------------------------------------- - - 05b20H: LD (01C7EH),HL - -Indirect address 01ccdH. 1 references: --------------------------------------- - - 05a91H: LD (01CCDH),HL - -Indirect address 01ccfH. 1 references: --------------------------------------- - - 05a97H: LD (01CCFH),HL - -Indirect address 01cd1H. 1 references: --------------------------------------- - - 05a9aH: LD (01CD1H),HL - -Indirect address 01ec2H. 1 references: --------------------------------------- - - 05b23H: LD (01EC2H),HL - -Indirect address 022c9H. 1 references: --------------------------------------- - - 05a8bH: LD (022C9H),HL - -Indirect address 028f5H. 2 references: --------------------------------------- - - 05b6cH: LD (028F5H),A - 05b74H: LD (028F5H),A - -Indirect address 02b11H. 1 references: --------------------------------------- - - 05aa0H: LD (02B11H),HL - -Indirect address 02d44H. 1 references: --------------------------------------- - - 05b26H: LD (02D44H),HL - -Indirect address 02f19H. 2 references: --------------------------------------- - - 05c9aH: LD (02F19H),A - 05ca2H: LD (02F19H),A - -Indirect address 02f24H. 1 references: --------------------------------------- - - 05b29H: LD (02F24H),HL - -Indirect address 0303cH. 1 references: --------------------------------------- - - 05b2cH: LD (0303CH),HL - -Indirect address 03042H. 1 references: --------------------------------------- - - 05b2fH: LD (03042H),HL - -Indirect address 0307bH. 1 references: --------------------------------------- - - 05aa6H: LD (0307BH),HL - -Indirect address 03140H. 1 references: --------------------------------------- - - 05ab7H: LD (03140H),A - -Indirect address 03141H. 1 references: --------------------------------------- - - 05abdH: LD (03141H),HL - -Indirect address 0315bH. 1 references: --------------------------------------- - - 05ab2H: LD (0315BH),HL - -Indirect address 0318cH. 1 references: --------------------------------------- - - 05aa9H: LD (0318CH),HL - -Indirect address 03199H. 1 references: --------------------------------------- - - 05aacH: LD (03199H),HL - -Indirect address 031adH. 1 references: --------------------------------------- - - 05adbH: LD (031ADH),A - -Indirect address 031aeH. 1 references: --------------------------------------- - - 05ae1H: LD (031AEH),HL - -Indirect address 0322eH. 1 references: --------------------------------------- - - 05ad4H: LD A,(0322EH) - -Indirect address 041ecH. 1 references: --------------------------------------- - - 05afdH: LD (041ECH),A - -Indirect address 041ffH. 1 references: --------------------------------------- - - 05b36H: LD (041FFH),HL - -Indirect address 0430dH. 1 references: --------------------------------------- - - 058c3H: LD A,(0430DH) - -Indirect address 04a0eH. 5 references: --------------------------------------- - - 053ceH: LD HL,(04A0EH) - 054f2H: LD HL,(04A0EH) - 0557bH: LD HL,(04A0EH) - 05582H: LD (04A0EH),HL - 055e4H: LD HL,(04A0EH) - -Indirect address 04a10H. 1 references: --------------------------------------- - - 05543H: LD HL,(04A10H) - -Indirect address 04ab3H. 3 references: --------------------------------------- - - 052f3H: LD HL,(04AB3H) - 0562eH: LD HL,(04AB3H) - 05c1fH: LD HL,(04AB3H) - -Indirect address 04ab5H. 3 references: --------------------------------------- - - 0530eH: LD HL,(04AB5H) - 05647H: LD HL,(04AB5H) - 05c14H: LD HL,(04AB5H) - -Indirect address 04e4eH. 2 references: --------------------------------------- - - 0519fH: LD (04E4EH),HL - 0532eH: LD (04E4EH),HL - -Indirect address 04e94H. 2 references: --------------------------------------- - - 05175H: LD HL,(04E94H) - 05179H: LD (04E94H),HL - -Indirect address 0504eH. 1 references: --------------------------------------- - - 0536dH: LD A,(0504EH) - -Indirect address 05051H. 2 references: --------------------------------------- - - 050ecH: LD (05051H),HL - 05901H: LD (05051H),HL - -Indirect address 05063H. 1 references: --------------------------------------- - - 0595bH: LD HL,(05063H) - -Indirect address 05065H. 4 references: --------------------------------------- - - 050f3H: LD HL,(05065H) - 051b8H: LD HL,(05065H) - 05272H: LD HL,(05065H) - 05954H: LD HL,(05065H) - -Indirect address 05067H. 2 references: --------------------------------------- - - 0510aH: LD HL,(05067H) - 0594aH: LD HL,(05067H) - -Indirect address 05069H. 1 references: --------------------------------------- - - 051c6H: LD HL,(05069H) - -Indirect address 0506bH. 2 references: --------------------------------------- - - 05149H: LD (0506BH),HL - 05943H: LD HL,(0506BH) - -Indirect address 05465H. 6 references: --------------------------------------- - - 05364H: LD (05465H),A - 0538bH: LD A,(05465H) - 05432H: LD A,(05465H) - 05490H: LD (05465H),A - 05553H: LD A,(05465H) - 055c7H: LD (05465H),A - -Indirect address 05466H. 6 references: --------------------------------------- - - 0548aH: LD (05466H),A - 0549fH: LD A,(05466H) - 055d6H: LD A,(05466H) - 0590fH: LD (05466H),A - 05963H: LD A,(05466H) - 05978H: LD (05466H),A - -Indirect address 05467H. 6 references: --------------------------------------- - - 05383H: LD (05467H),A - 053b7H: LD A,(05467H) - 054b3H: LD A,(05467H) - 054f5H: LD A,(05467H) - 05574H: LD A,(05467H) - 055efH: LD A,(05467H) - -Indirect address 05468H. 4 references: --------------------------------------- - - 053b2H: LD (05468H),A - 054c9H: LD A,(05468H) - 05535H: LD A,(05468H) - 0556fH: LD A,(05468H) - -Indirect address 05469H. 3 references: --------------------------------------- - - 05404H: LD (05469H),HL - 0556cH: LD HL,(05469H) - 05598H: LD A,(05469H) - -Indirect address 0546bH. 4 references: --------------------------------------- - - 05424H: LD (0546BH),HL - 054adH: LD HL,(0546BH) - 054bfH: LD HL,(0546BH) - 0551eH: LD HL,(0546BH) - -Indirect address 05611H. 5 references: --------------------------------------- - - 05617H: LD (05611H),A - 05628H: LD (05611H),A - 057e3H: LD A,(05611H) - 057f2H: LD A,(05611H) - 057ffH: LD A,(05611H) - -Indirect address 05612H. 2 references: --------------------------------------- - - 056a5H: LD (05612H),HL - 05736H: LD HL,(05612H) - -Indirect address 05614H. 1 references: --------------------------------------- - - 056faH: LD HL,(05614H) - -Indirect address 058e0H. 1 references: --------------------------------------- - - 058fdH: LD (058E0H),A - - -End of reference file for "XPATCH-5510.bin" - diff --git a/software/dis/XPATCH/XPATCH.ini b/software/dis/XPATCH/XPATCH.ini deleted file mode 100644 index 8cf8def..0000000 --- a/software/dis/XPATCH/XPATCH.ini +++ /dev/null @@ -1,330 +0,0 @@ ----------------------------------------- --- dZ80 configuration file ----------------------------------------- - ----------------------------------------- --- Disassembly control ----------------------------------------- - -cpu="z80" -inputfile="XPATCH-5510.bin" -outputfile="XPATCH-5510.asm" ---fileheadersize=27 -filebaseaddr=20572 -disstart=0 -disend=23724 ---disstart=0 ---disend=3584 ---quiet=0 -labelledoutput=1 - ----------------------------------------- --- Layout ----------------------------------------- - -labelreference=1 -addresscolumn=1 -opcodecolumn=1 -relativejumpcomment=1 -uppercase=1 -autoblanklines=1 -db="db" -comment="; " -radix=16 -numprefix="0" -numsuffix="H" - ----------------------------------------- --- Scripts ----------------------------------------- - ---script="scripts\\spectrum.lua" - ----------------------------------------- --- References ----------------------------------------- - -referencefile="XPATCH-5510.ref" -inportreference=1 -outportreference=1 -addressreference=1 -indirectaddressreference=1 -limitreferences=1 - ----------------------------------------- --- Opcode mapfile and code/data areas ----------------------------------------- - ---opmapfile="mayhem.map" - --- Code Region isnt required as v2.x sets the entire region to code unless a data region overrides it. -d_SetCodeRegion(20572, 3152) - --- Set the known data regions, either as a data region (byte), word or string. The type affects the assembly output definitions and word --- regions will attempt to map to an address, ie. jump tables will be setup with labels rather than constants. -d_SetDataRegion( hex("507D"), 27) -d_SetStringRegion( hex("507D"), 11) -d_SetStringRegion( hex("5089"), 15) -d_SetDataRegion( hex("5255"), 23) -d_SetStringRegion( hex("5257"), 4) -d_SetStringRegion( hex("525C"), 15) - -d_SetDataRegion( hex("5446"), 31) -d_SetStringRegion( hex("5446"), 12) -d_SetStringRegion( hex("5453"), 17) -d_SetDataRegion( hex("5465"), 8) -d_SetStringRegion( hex("55B3"), 18) -d_SetStringRegion( hex("55F8"), 25) - -d_SetDataRegion( hex("5807"), 49) -d_SetStringRegion( hex("5807"), 23) ---d_SetStringRegion( hex("581F"), 5) -d_SetStringRegion( hex("5827"), 5) -d_SetStringRegion( hex("582F"), 5) - -d_SetDataRegion( hex("585D"), 45) -d_SetStringRegion( hex("585D"), 4) -d_SetStringRegion( hex("5862"), 5) -d_SetStringRegion( hex("5868"), 7) -d_SetStringRegion( hex("5870"), 5) -d_SetStringRegion( hex("5876"), 3) -d_SetStringRegion( hex("587A"), 5) -d_SetStringRegion( hex("5880"), 3) -d_SetStringRegion( hex("5884"), 3) - ---d_SetStringRegion( hex("585D"), 4) ---d_SetDataRegion( hex("58A5"), 59) ---d_SetStringRegion( hex("58A5"), 17) ---d_SetStringRegion( hex("58B7"), 40) - -d_SetDataRegion( hex("59C7"), 25) -d_SetStringRegion( hex("59C7"), 24) - -d_SetDataRegion( hex("5A04"), 56) -d_SetWordRegion( hex("5A04"), 28) - --- Reserved key words. -d_SetDataRegion( hex("5A20"), 28) -d_SetStringRegion( hex("5A20"), 3) -- LINE -d_SetStringRegion( hex("5A24"), 3) -- AUTO -d_SetStringRegion( hex("5A28"), 2) -- CLR -d_SetStringRegion( hex("5A2B"), 3) -- MOVE -d_SetStringRegion( hex("5A2F"), 5) -- COPY/P -d_SetStringRegion( hex("5A35"), 5) -- PAGE/P - -d_SetDataRegion( hex("5A52"), 17) -d_SetStringRegion( hex("5A52"), 15) - --- Create a mapping table of known Sharp I/O ports and 8 bit constants. --- --- Format Addr IsAddr Label : IsAddr = 0, value is a constant, = 1, value is an address. -d_SetByteEquate(hex("FE") , 1, "PRTC" ) -d_SetByteEquate(hex("FF") , 1, "PRTD" ) - --- Create a mapping table of known Sharp MZ BIOS/Memory Mapped Hardware addresses which dz80 --- can use to replace an address with the label. The EQU list will also be output at the start --- of the disassembly file so it can compile. --- Format Addr IsAddr Label : IsAddr = 0, value is a constant, = 1, value is an address. -d_SetWordEquate(hex("0003"), 1, "GETL" ) -d_SetWordEquate(hex("0006"), 1, "LETNL" ) -d_SetWordEquate(hex("0009"), 1, "NL" ) -d_SetWordEquate(hex("000C"), 1, "PRNTS" ) -d_SetWordEquate(hex("000F"), 1, "PRNTT" ) -d_SetWordEquate(hex("0012"), 1, "PRNT" ) -d_SetWordEquate(hex("0015"), 1, "MSG" ) -d_SetWordEquate(hex("0018"), 1, "MSGX" ) -d_SetWordEquate(hex("001B"), 1, "GETKY" ) -d_SetWordEquate(hex("001E"), 1, "BRKEY" ) -d_SetWordEquate(hex("0021"), 1, "?WRI" ) -d_SetWordEquate(hex("0024"), 1, "?WRD" ) -d_SetWordEquate(hex("0027"), 1, "?RDI" ) -d_SetWordEquate(hex("002A"), 1, "?RDD" ) -d_SetWordEquate(hex("002D"), 1, "?VRFY" ) -d_SetWordEquate(hex("0030"), 1, "MELDY" ) -d_SetWordEquate(hex("0033"), 1, "?TMST" ) -d_SetWordEquate(hex("003B"), 1, "TIMRD" ) -d_SetWordEquate(hex("003E"), 1, "BELL" ) -d_SetWordEquate(hex("0041"), 1, "XTEMP" ) -d_SetWordEquate(hex("0044"), 1, "MSTA" ) -d_SetWordEquate(hex("0047"), 1, "MSTP" ) -d_SetWordEquate(hex("0000"), 1, "MONIT" ) -d_SetWordEquate(hex("0089"), 1, "SS" ) -d_SetWordEquate(hex("0095"), 1, "ST1" ) -d_SetWordEquate(hex("0410"), 1, "HLHEX" ) -d_SetWordEquate(hex("041F"), 1, "_2HEX" ) -d_SetWordEquate(hex("074D"), 1, "?MODE" ) -d_SetWordEquate(hex("08CA"), 1, "?KEY" ) -d_SetWordEquate(hex("096C"), 1, "PRNT3" ) -d_SetWordEquate(hex("0BB9"), 1, "?ADCN" ) -d_SetWordEquate(hex("0BCE"), 1, "?DACN" ) -d_SetWordEquate(hex("0DB5"), 1, "?DSP" ) -d_SetWordEquate(hex("0DA6"), 1, "?BLNK" ) -d_SetWordEquate(hex("0DDC"), 1, "?DPCT" ) -d_SetWordEquate(hex("03BA"), 1, "PRTHL" ) -d_SetWordEquate(hex("03C3"), 1, "PRTHX" ) -d_SetWordEquate(hex("03DA"), 1, "ASC" ) -d_SetWordEquate(hex("03F9"), 1, "HEX" ) -d_SetWordEquate(hex("0DDC"), 1, "DPCT" ) -d_SetWordEquate(hex("0DA7"), 1, "DLY12" ) -d_SetWordEquate(hex("0DAA"), 1, "DLY12A" ) -d_SetWordEquate(hex("0EE6"), 1, "?RSTR1" ) -d_SetWordEquate(hex("06A3"), 1, "MOTOR" ) -d_SetWordEquate(hex("071A"), 1, "CKSUM" ) -d_SetWordEquate(hex("077A"), 1, "GAP" ) -d_SetWordEquate(hex("0485"), 1, "WTAPE" ) -d_SetWordEquate(hex("0700"), 1, "MSTOP" ) -d_SetWordEquate(hex("11FD"), 1, "TAPECOPY" ) -d_SetWordEquate(hex("1200"), 1, "COLDSTRT" ) -d_SetWordEquate(hex("1250"), 1, "WARMSTRTMON") -d_SetWordEquate(hex("15A8"), 1, "CMDWORDTBL" ) -d_SetWordEquate(hex("1BB2"), 1, "CMDJMPTBL" ) -d_SetWordEquate(hex("2E33"), 1, "CMTBUF" ) -d_SetWordEquate(hex("2E34"), 1, "CMTFNAME" ) - --- Known BASIC SA-5510 labels/addresses. -d_SetWordEquate(hex("1C3C"), 1, "CMDREMDATA" ) -d_SetWordEquate(hex("13AB"), 1, "SYNTAXERR" ) -d_SetWordEquate(hex("2D12"), 1, "CMDREAD" ) -d_SetWordEquate(hex("1C4D"), 1, "CMDLIST" ) -d_SetWordEquate(hex("1E91"), 1, "CMDRUN" ) -d_SetWordEquate(hex("1C42"), 1, "CMDNEW" ) -d_SetWordEquate(hex("2B0D"), 1, "CMDPRINT" ) -d_SetWordEquate(hex("1D6A"), 1, "CMDLET" ) -d_SetWordEquate(hex("1F2B"), 1, "CMDFOR" ) -d_SetWordEquate(hex("21AD"), 1, "CMDIF" ) -d_SetWordEquate(hex("13AB"), 1, "CMDTHEN" ) -d_SetWordEquate(hex("1EA6"), 1, "CMDGOTO" ) -d_SetWordEquate(hex("1EC7"), 1, "CMDGOSUB" ) -d_SetWordEquate(hex("1EF8"), 1, "CMDRETURN" ) -d_SetWordEquate(hex("1FC0"), 1, "CMDNEXT" ) -d_SetWordEquate(hex("1D2C"), 1, "CMDSTOP" ) -d_SetWordEquate(hex("1D15"), 1, "CMDEND" ) -d_SetWordEquate(hex("203E"), 1, "CMDON" ) -d_SetWordEquate(hex("2D75"), 1, "CMDLOAD" ) -d_SetWordEquate(hex("2D82"), 1, "CMDSAVE" ) -d_SetWordEquate(hex("2EB3"), 1, "CMDVERIFY" ) -d_SetWordEquate(hex("2191"), 1, "CMDPOKE" ) -d_SetWordEquate(hex("2080"), 1, "CMDDIM" ) -d_SetWordEquate(hex("2201"), 1, "CMDDEFFN" ) -d_SetWordEquate(hex("2BFF"), 1, "CMDINPUT" ) -d_SetWordEquate(hex("1D4D"), 1, "CMDRESTORE" ) -d_SetWordEquate(hex("21A6"), 1, "CMDCLS" ) -d_SetWordEquate(hex("2269"), 1, "CMDMUSIC" ) -d_SetWordEquate(hex("2282"), 1, "CMDTEMPO" ) -d_SetWordEquate(hex("2942"), 1, "CMDUSRN" ) -d_SetWordEquate(hex("2D9F"), 1, "CMDWOPEN" ) -d_SetWordEquate(hex("2D92"), 1, "CMDROPEN" ) -d_SetWordEquate(hex("2DAD"), 1, "CMDCLOSE" ) -d_SetWordEquate(hex("28B6"), 1, "CMDMON" ) -d_SetWordEquate(hex("2967"), 1, "CMDLIMIT" ) -d_SetWordEquate(hex("29CE"), 1, "CMDCONT" ) -d_SetWordEquate(hex("2902"), 1, "CMDGET" ) -d_SetWordEquate(hex("29FE"), 1, "CMDINP" ) -d_SetWordEquate(hex("2A1C"), 1, "CMDOUT" ) -d_SetWordEquate(hex("28B9"), 1, "CMDCURSOR" ) -d_SetWordEquate(hex("2AA6"), 1, "CMDSET" ) -d_SetWordEquate(hex("2AAA"), 1, "CMDRESET" ) -d_SetWordEquate(hex("2A2F"), 1, "CMDAUTO" ) -d_SetWordEquate(hex("33AB"), 1, "CMDCOPY" ) -d_SetWordEquate(hex("32D4"), 1, "CMDPAGE" ) - -d_SetWordEquate(hex("13AE"), 1, "OVFLERR" ) -d_SetWordEquate(hex("13B1"), 1, "ILDATERR" ) -d_SetWordEquate(hex("13B4"), 1, "DATMISERR" ) -d_SetWordEquate(hex("13B7"), 1, "STRLENERR" ) -d_SetWordEquate(hex("13BA"), 1, "MEMERR" ) -d_SetWordEquate(hex("13C0"), 1, "LINELENERR" ) -d_SetWordEquate(hex("13C3"), 1, "GOSUBERR" ) -d_SetWordEquate(hex("13C6"), 1, "FORNEXTERR" ) -d_SetWordEquate(hex("13C9"), 1, "FUNCERR" ) -d_SetWordEquate(hex("13CC"), 1, "NEXTFORERR" ) -d_SetWordEquate(hex("13CF"), 1, "RETGOSBERR" ) -d_SetWordEquate(hex("13D2"), 1, "UNDEFFNERR" ) -d_SetWordEquate(hex("13D5"), 1, "LINEERR" ) -d_SetWordEquate(hex("13D8"), 1, "CONTERR" ) -d_SetWordEquate(hex("13DB"), 1, "BADWRERR" ) -d_SetWordEquate(hex("13DE"), 1, "CMDSTMTERR" ) -d_SetWordEquate(hex("13E1"), 1, "READDATAERR") -d_SetWordEquate(hex("13E4"), 1, "OPENERR" ) -d_SetWordEquate(hex("13E7"), 1, "UNKNWNERR" ) -d_SetWordEquate(hex("13EA"), 1, "OUTFILEERR" ) -d_SetWordEquate(hex("13ED"), 1, "PRTNRDYERR" ) -d_SetWordEquate(hex("13F0"), 1, "PRTHWERR" ) -d_SetWordEquate(hex("13F3"), 1, "PRTPAPERERR") -d_SetWordEquate(hex("13F6"), 1, "CHKSUMERR" ) - -d_SetWordEquate(hex("1347"), 1, "TITLEMSG" ) -d_SetWordEquate(hex("1364"), 1, "COPYRMSG" ) -d_SetWordEquate(hex("1384"), 1, "READYMSG" ) -d_SetWordEquate(hex("138A"), 1, "ERRORMSG" ) -d_SetWordEquate(hex("1391"), 1, "INMSG" ) -d_SetWordEquate(hex("1395"), 1, "BREAKMSG" ) -d_SetWordEquate(hex("139C"), 1, "BYTESMSG" ) -d_SetWordEquate(hex("13A3"), 1, "ERRCODE" ) - -d_SetWordEquate(hex("1332"), 1, "MSGNL" ) -d_SetWordEquate(hex("167B"), 1, "UNUSEDTBL1" ) -d_SetWordEquate(hex("167D"), 1, "UNUSEDTBL2" ) -d_SetWordEquate(hex("124E"), 1, "WARMSTRT" ) -d_SetWordEquate(hex("167F"), 1, "OPERATORTBL") -d_SetWordEquate(hex("17FC"), 1, "STRTONUM" ) -d_SetWordEquate(hex("1E88"), 1, "GETNUM" ) -d_SetWordEquate(hex("173F"), 1, "SKIPSPACE" ) -d_SetWordEquate(hex("173E"), 1, "INCSKIPSPCE") -d_SetWordEquate(hex("177B"), 1, "EXECHL" ) -d_SetWordEquate(hex("1795"), 1, "EXECNOTCHR" ) -d_SetWordEquate(hex("17A3"), 1, "MATCHCHR" ) -d_SetWordEquate(hex("490D"), 0, "LINEBUFR" ) - --- XPATCH labels/addresses. -d_SetWordEquate(hex("5A63"), 1, "XPINIT" ) -d_SetWordEquate(hex("5B55"), 1, "RELOC3302" ) -d_SetWordEquate(hex("5BB0"), 1, "RELOC4806" ) - --- Comments to be added at fixed addresses. -d_SetComment( hex("1250"), "Sharp defined BASIC restart location from Monitor." ) -d_SetComment( hex("5B55"), "Relocated to 0x3302 for 0x5B bytes." ) -d_SetComment( hex("5BB0"), "Relocated to 0x4806 for 0xF8 bytes." ) -d_SetComment( hex("5CA8"), "End of Relocated code." ) - --- Known Sharp Constants. -d_SetWordEquate(hex("10F0"), 0, "ATRB" ) -- ATTRIBUTE -d_SetWordEquate(hex("10F1"), 0, "NAME" ) -- FILE NAME -d_SetWordEquate(hex("1102"), 0, "SIZE" ) -- BYTESIZE -d_SetWordEquate(hex("1104"), 0, "DTADR" ) -- DATA ADDRESS -d_SetWordEquate(hex("1106"), 0, "EXADR" ) -- EXECUTION ADDRESS -d_SetWordEquate(hex("1108"), 0, "COMNT" ) -- COMMENT -d_SetWordEquate(hex("1164"), 0, "SWPW" ) -- SWEEP WORK -d_SetWordEquate(hex("116E"), 0, "KDATW" ) -- KEY WORK -d_SetWordEquate(hex("1170"), 0, "KANAF" ) -- KANA FLAG (01=GRAPHIC MODE) -d_SetWordEquate(hex("1171"), 0, "DSPXY" ) -- DISPLAY COORDINATES -d_SetWordEquate(hex("1173"), 0, "MANG" ) -- COLUMN MANAGEMENT -d_SetWordEquate(hex("1179"), 0, "MANGE" ) -- COLUMN MANAGEMENT END -d_SetWordEquate(hex("117A"), 0, "PBIAS" ) -- PAGE BIAS -d_SetWordEquate(hex("117B"), 0, "ROLTOP" ) -- ROLL TOP BIAS -d_SetWordEquate(hex("117C"), 0, "MGPNT" ) -- COLUMN MANAG. POINTER -d_SetWordEquate(hex("117D"), 0, "PAGETP" ) -- PAGE TOP -d_SetWordEquate(hex("117F"), 0, "ROLEND" ) -- ROLL END -d_SetWordEquate(hex("118E"), 0, "FLASH" ) -- FLASHING DATA -d_SetWordEquate(hex("118F"), 0, "SFTLK" ) -- SHIFT LOCK -d_SetWordEquate(hex("1190"), 0, "REVFLG" ) -- REVERSE FLAG -d_SetWordEquate(hex("1191"), 0, "SPAGE" ) -- PAGE CHANGE -d_SetWordEquate(hex("1192"), 0, "FLSDT" ) -- CURSOR DATA -d_SetWordEquate(hex("1193"), 0, "STRGF" ) -- STRING FLAG -d_SetWordEquate(hex("1194"), 0, "DPRNT" ) -- TAB COUNTER -d_SetWordEquate(hex("1195"), 0, "TMCNT" ) -- TAPE MARK COUNTER -d_SetWordEquate(hex("1197"), 0, "SUMDT" ) -- CHECK SUM DATA -d_SetWordEquate(hex("1199"), 0, "CSMDT" ) -- FOR COMPARE SUM DATA -d_SetWordEquate(hex("119B"), 0, "AMPM" ) -- AMPM DATA -d_SetWordEquate(hex("119C"), 0, "TIMFG" ) -- TIME FLAG -d_SetWordEquate(hex("119D"), 0, "SWRK" ) -- KEY SOUND FLAG -d_SetWordEquate(hex("119E"), 0, "TEMPW" ) -- TEMPO WORK -d_SetWordEquate(hex("119F"), 0, "ONTYO" ) -- ONTYO WORK -d_SetWordEquate(hex("11A0"), 0, "OCTV" ) -- OCTAVE WORK -d_SetWordEquate(hex("11A1"), 0, "RATIO" ) -- ONPU RATIO -d_SetWordEquate(hex("11A3"), 0, "BUFER" ) -- GET LINE BUFFER - - ----------------------------------------- --- End of configuration file ----------------------------------------- diff --git a/software/dis/XPATCH/XPATCH_5510_V2.2.MZF b/software/dis/XPATCH/XPATCH_5510_V2.2.MZF deleted file mode 100644 index 14c0ce3..0000000 Binary files a/software/dis/XPATCH/XPATCH_5510_V2.2.MZF and /dev/null differ diff --git a/software/dis/XPATCH/dz80.ini b/software/dis/XPATCH/dz80.ini deleted file mode 120000 index 4193260..0000000 --- a/software/dis/XPATCH/dz80.ini +++ /dev/null @@ -1 +0,0 @@ -XPATCH.ini \ No newline at end of file diff --git a/software/hdr/CPM_RFS_1.hdr b/software/hdr/CPM_RFS_1.hdr deleted file mode 100644 index d1f5951..0000000 Binary files a/software/hdr/CPM_RFS_1.hdr and /dev/null differ diff --git a/software/hdr/CPM_RFS_2.hdr b/software/hdr/CPM_RFS_2.hdr deleted file mode 100644 index f2f2077..0000000 Binary files a/software/hdr/CPM_RFS_2.hdr and /dev/null differ diff --git a/software/hdr/cpm22.hdr b/software/hdr/cpm22.hdr deleted file mode 100644 index 79aac98..0000000 Binary files a/software/hdr/cpm22.hdr and /dev/null differ diff --git a/software/hdr/sdtest.hdr b/software/hdr/sdtest.hdr deleted file mode 100644 index 2214679..0000000 Binary files a/software/hdr/sdtest.hdr and /dev/null differ diff --git a/software/proc_mzf.sh b/software/proc_mzf.sh deleted file mode 100755 index b88609e..0000000 --- a/software/proc_mzf.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -ROOTDIR=/dvlp/Projects/dev/github -MZFDIR=${ROOTDIR}/MZF -MZBDIR=${ROOTDIR}/MZB - -ls -l *.MZF *.mzf | sed 's/ / /g' | sed 's/ / /g' | cut -d' ' -f5,9- > /tmp/filelist - -IFS=' '; while read -r FSIZE FNAME; -do - TNAME=`echo $FNAME | sed 's/mzf/MZF/g'` - if [ "$FNAME" != "$TNAME" ]; then - mv "$FNAME" "$TNAME" - fi - for BLOCKSIZE in 256 512 1024 2048 4096 - do - for SECTORSIZE in `seq -s ' ' ${BLOCKSIZE} ${BLOCKSIZE} 65536` - do - BASE=`basename "$TNAME" .MZF` - if [ `echo ${FSIZE} - ${SECTORSIZE} | bc` -le 0 ]; - then - echo $BASE $TNAME $SECTORSIZE - dd if=/dev/zero ibs=1 count=$SECTORSIZE 2>/dev/null | tr "\000" "\377" > "${MZBDIR}/$BASE.${BLOCKSIZE}.bin" - dd if="${MZFDIR}/$TNAME" of="${MZBDIR}/$BASE.${BLOCKSIZE}.bin" conv=notrunc 2>/dev/null - break; - fi - done - done -done -## -## History: March 2020 - Initial script written. -## -## Notes: Optional component enables: -## -######################################################################################################### -## This source file is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This source file is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -######################################################################################################### -BASE = -CC = $(BASE)zcc -LD = $(BASE)zcc -AS = $(BASE)zcc -#CP = $(BASE) -#DUMP = $(BASE) - -BASEDIR = ../.. -#BASEDIR = ../../.. -SWDIR = $(BASEDIR)/software - -# we use printf from here -COMMON_DIR = $(SWDIR)/common -PFS_DIR = $(SWDIR)/common/PetitFS -INCLUDE_DIR = $(SWDIR)/include - -# Working directory to build object files. -BUILD_DIR = pff_obj - -COMMON_SRC = #$(COMMON_DIR)/sdmmc.c -PFS_SRC = $(PFS_DIR)/sdmmc.c $(PFS_DIR)/pff_func.c $(PFS_DIR)/pff_dir.c $(PFS_DIR)/pff_read.c $(PFS_DIR)/pff_write.c $(PFS_DIR)/pff_open.c $(PFS_DIR)/pff_mount.c - -COMMON_OBJ = $(patsubst $(COMMON_DIR)/%.c,$(BUILD_DIR)/%.o,$(COMMON_SRC)) -PFS_OBJ = $(patsubst $(PFS_DIR)/%.c,$(BUILD_DIR)/%.o,$(PFS_SRC)) -COMMON_ASM = $(patsubst $(COMMON_DIR)/%.c,$(BUILD_DIR)/%.asm,$(COMMON_SRC)) -PFS_ASM = $(patsubst $(PFS_DIR)/%.c,$(BUILD_DIR)/%.asm,$(PFS_SRC)) - -MAIN_PRJ = sdtest -MAIN_ASM = $(COMMON_ASM) $(PFS_ASM) $(patsubst %.c,$(BUILD_DIR)/%.asm,$(MAIN_SRC)) -MAIN_SRC = sdtest.c -MAIN_OBJ = $(COMMON_OBJ) $(PFS_OBJ) $(patsubst %.c,$(BUILD_DIR)/%.o,$(MAIN_SRC)) -MAIN_PRAGMA = rfs.inc - -ROM_PRJ = rom -ROM_SRC = -ROM_OBJ = $(COMMON_OBJ) $(PFS_OBJ) $(patsubst %.c,$(BUILD_DIR)/%.o,$(ROM_SRC)) - -# Commandline options for each tool. -# To disable use of a given instruction, prefix it with no- -TARGET = +mz -VERBOSITY = -vn -OPTIMISATION = -O3 -CFLAGS = $(TARGET) -pragma-define:REGISTER_SP=0xd000 -pragma-include:$(MAIN_PRAGMA) $(OPTIMISATION) -I. -I$(COMMON_DIR) -I$(PFS_DIR) -I$(INCLUDE_DIR) -lm $(VERBOSITY) -# -# Enable debug output. -OFLAGS += -DDEBUG -LFLAGS = $(TARGET) $(VERBOSITY) -pragma-define:REGISTER_SP=0xd000 -pragma-include:$(MAIN_PRAGMA) -lm -create-app -m -# -# Assembler flags. -ASFLAGS = $(TARGET) $(VERBOSITY) -c -I. -I$(COMMON_DIR) -I$(INCLUDE_DIR) -I$(STARTUP_DIR) -# - -# Our target. -all: $(BUILD_DIR) $(MAIN_PRJ) #$(MAIN_ASM) #$(ROM_PRJ) -# -$(MAIN_PRJ): $(BUILD_DIR) $(MAIN_OBJ) #$(MAIN_PRJ).asm - - -$(MAIN_ASM): $(BUILD_DIR) - -clean: - rm -f $(BUILD_DIR)/*.o *.hex *.lss *.elf *.map *.lst *.srec $(MAIN_PRJ) *~ */*.o *.bin *.srec *.dmp *.rpt *.ihx *.sym *.rel *.noi *.lk *.err *.mzt *.o - - -# Convert ELF binary to bin file. -%.bin: %.elf - @$(CP) -O binary $< $@ - -# Convert ELF to srec format for serial upload. -%.srec: %.elf - @$(CP) -O srec $< $@ - - -# Link - this produces an ELF binary. -$(MAIN_PRJ): $(MAIN_OBJ) - $(CC) $(LFLAGS) $(MAIN_OBJ) -o $@ $(LIBS) - -$(ROM_PRJ): $(ROM_OBJ) - $(CC) +z80 $(VERBOSITY) -pragma-define:REGISTER_SP=0xd000 -pragma-include:$(MAIN_PRAGMA) -lm -m $(ROM_OBJ) -o $@ $(LIBS) - -$(BUILD_DIR)/%.o: %.c Makefile - $(CC) $(CFLAGS) $(OFLAGS) -o $@ -c $< - -$(BUILD_DIR)/%.asm: %.c Makefile - $(CC) $(CFLAGS) $(OFLAGS) -a -o $@ -c $< - -$(BUILD_DIR)/%.o: %.cpp Makefile - $(CC) $(CFLAGS) $(OFLAGS) -o $@ -c $< - -$(BUILD_DIR)/%.o: %.asm Makefile - $(AS) $(ASFLAGS) -o $@ -c $< - -$(BUILD_DIR)/%.o: $(COMMON_DIR)/%.c Makefile - $(CC) $(CFLAGS) $(OFLAGS) -o $@ -c $< - -$(BUILD_DIR)/%.o: $(PFS_DIR)/%.c Makefile - $(CC) $(CFLAGS) $(OFLAGS) -o $@ -c $< - -$(BUILD_DIR)/%.o: %.s - $(AS) $(ASFLAGS) -o $@ $< - -$(BUILD_DIR)/%.o: $(STARTUP_DIR)/%.s - $(AS) $(ASFLAGS) -o $@ $< - -$(BUILD_DIR): - mkdir $(BUILD_DIR) - diff --git a/software/src/PetitFS/diskio.asm b/software/src/PetitFS/diskio.asm deleted file mode 100644 index 2c617d5..0000000 --- a/software/src/PetitFS/diskio.asm +++ /dev/null @@ -1,95 +0,0 @@ -;-------------------------------------------------------- -; File Created by SDCC : free open source ANSI-C Compiler -; Version 4.0.0 #11528 (Linux) -;-------------------------------------------------------- - .module diskio - .optsdcc -mz80 - -;-------------------------------------------------------- -; Public variables in this module -;-------------------------------------------------------- - .globl _disk_initialize - .globl _disk_readp - .globl _disk_writep -;-------------------------------------------------------- -; special function registers -;-------------------------------------------------------- -;-------------------------------------------------------- -; ram data -;-------------------------------------------------------- - .area _DATA -;-------------------------------------------------------- -; ram data -;-------------------------------------------------------- - .area _INITIALIZED -;-------------------------------------------------------- -; absolute external ram data -;-------------------------------------------------------- - .area _DABS (ABS) -;-------------------------------------------------------- -; global & static initialisations -;-------------------------------------------------------- - .area _HOME - .area _GSINIT - .area _GSFINAL - .area _GSINIT -;-------------------------------------------------------- -; Home -;-------------------------------------------------------- - .area _HOME - .area _HOME -;-------------------------------------------------------- -; code -;-------------------------------------------------------- - .area _CODE -;diskio.c:12: DSTATUS disk_initialize (void) -; --------------------------------- -; Function disk_initialize -; --------------------------------- -_disk_initialize:: - push ix - ld ix,#0 - add ix,sp - dec sp -;diskio.c:18: return stat; - ld l, -1 (ix) -00101$: -;diskio.c:19: } - inc sp - pop ix - ret -;diskio.c:27: DRESULT disk_readp ( -; --------------------------------- -; Function disk_readp -; --------------------------------- -_disk_readp:: - push ix - ld ix,#0 - add ix,sp - dec sp -;diskio.c:38: return res; - ld l, -1 (ix) -00101$: -;diskio.c:39: } - inc sp - pop ix - ret -;diskio.c:47: DRESULT disk_writep ( -; --------------------------------- -; Function disk_writep -; --------------------------------- -_disk_writep:: - push ix - ld ix,#0 - add ix,sp - dec sp -;diskio.c:71: return res; - ld l, -1 (ix) -00103$: -;diskio.c:72: } - inc sp - pop ix - ret - .area _CODE - .area _INITIALIZER - .area _CABS (ABS) diff --git a/software/src/PetitFS/diskiotmp.c b/software/src/PetitFS/diskiotmp.c deleted file mode 100644 index 5b303b8..0000000 --- a/software/src/PetitFS/diskiotmp.c +++ /dev/null @@ -1,73 +0,0 @@ -/*-----------------------------------------------------------------------*/ -/* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2014 */ -/*-----------------------------------------------------------------------*/ - -#include "diskio.h" - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize (void) -{ - DSTATUS stat; - - // Put your code here - - return stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Partial Sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_readp ( - BYTE* buff, /* Pointer to the destination object */ - DWORD sector, /* Sector number (LBA) */ - UINT offset, /* Offset in the sector */ - UINT count /* Byte count (bit15:destination) */ -) -{ - DRESULT res; - - // Put your code here - - return res; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Partial Sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_writep ( - BYTE* buff, /* Pointer to the data to be written, NULL:Initiate/Finalize write operation */ - DWORD sc /* Sector number (LBA) or Number of bytes to send */ -) -{ - DRESULT res; - - - if (!buff) { - if (sc) { - - // Initiate write process - - } else { - - // Finalize write process - - } - } else { - - // Send data to the disk - - } - - return res; -} - diff --git a/software/src/PetitFS/pff.asm b/software/src/PetitFS/pff.asm deleted file mode 100644 index 8c5b6d5..0000000 --- a/software/src/PetitFS/pff.asm +++ /dev/null @@ -1,4534 +0,0 @@ -;-------------------------------------------------------- -; File Created by SDCC : free open source ANSI-C Compiler -; Version 4.0.0 #11528 (Linux) -;-------------------------------------------------------- - .module pff - .optsdcc -mz80 - -;-------------------------------------------------------- -; Public variables in this module -;-------------------------------------------------------- - .globl _disk_initialize - .globl _disk_readp - .globl _disk_writep - .globl _pf_mount - .globl _pf_open - .globl _pf_read - .globl _pf_write - .globl _pf_lseek - .globl _pf_opendir - .globl _pf_readdir -;-------------------------------------------------------- -; special function registers -;-------------------------------------------------------- -;-------------------------------------------------------- -; ram data -;-------------------------------------------------------- - .area _DATA -_FatFs: - .ds 2 -;-------------------------------------------------------- -; ram data -;-------------------------------------------------------- - .area _INITIALIZED -;-------------------------------------------------------- -; absolute external ram data -;-------------------------------------------------------- - .area _DABS (ABS) -;-------------------------------------------------------- -; global & static initialisations -;-------------------------------------------------------- - .area _HOME - .area _GSINIT - .area _GSFINAL - .area _GSINIT -;-------------------------------------------------------- -; Home -;-------------------------------------------------------- - .area _HOME - .area _HOME -;-------------------------------------------------------- -; code -;-------------------------------------------------------- - .area _CODE -;diskio.c:12: DSTATUS disk_initialize (void) -; --------------------------------- -; Function disk_initialize -; --------------------------------- -_disk_initialize:: -;diskio.c:18: return stat; - ld iy, #-1 - add iy, sp - ld l, 0 (iy) -l_disk_initialize_00101$: -;diskio.c:19: } - ret -;diskio.c:27: DRESULT disk_readp ( -; --------------------------------- -; Function disk_readp -; --------------------------------- -_disk_readp:: -;diskio.c:38: return res; - ld iy, #-1 - add iy, sp - ld l, 0 (iy) -l_disk_readp_00101$: -;diskio.c:39: } - ret -;diskio.c:47: DRESULT disk_writep ( -; --------------------------------- -; Function disk_writep -; --------------------------------- -_disk_writep:: -;diskio.c:71: return res; - ld iy, #-1 - add iy, sp - ld l, 0 (iy) -l_disk_writep_00103$: -;diskio.c:72: } - ret -;pff.c:384: static WORD ld_word (const BYTE* ptr) /* Load a 2-byte little-endian word */ -; --------------------------------- -; Function ld_word -; --------------------------------- -_ld_word: - call ___sdcc_enter_ix -;pff.c:388: rv = ptr[1]; - ld l, 4 (ix) - ld h, 5 (ix) - inc hl - ld c, (hl) - ld b, #0x00 -;pff.c:389: rv = rv << 8 | ptr[0]; - ld b, c - ld c, #0x00 - ld l, 4 (ix) - ld h, 5 (ix) - ld e, (hl) - ld d, #0x00 - ld a, c - or a, e - ld l, a - ld a, b - or a, d - ld h, a -;pff.c:390: return rv; -l_ld_word_00101$: -;pff.c:391: } - pop ix - ret -;pff.c:393: static DWORD ld_dword (const BYTE* ptr) /* Load a 4-byte little-endian word */ -; --------------------------------- -; Function ld_dword -; --------------------------------- -_ld_dword: - call ___sdcc_enter_ix - push af - push af -;pff.c:397: rv = ptr[3]; - ld l, 4 (ix) - ld h, 5 (ix) - inc hl - inc hl - inc hl - ld c, (hl) - ld b, #0x00 - ld e, #0x00 - ld d, #0x00 -;pff.c:398: rv = rv << 8 | ptr[2]; - ld -3 (ix), c - ld -2 (ix), b - ld -1 (ix), e - xor a, a - ld -4 (ix), a - ld l, 4 (ix) - ld h, 5 (ix) - inc hl - inc hl - ld c, (hl) - ld b, #0x00 - ld e, #0x00 - ld d, #0x00 - ld a, c - or a, -4 (ix) - ld c, a - ld a, b - or a, -3 (ix) - ld b, a - ld a, e - or a, -2 (ix) - ld e, a - ld a, d - or a, -1 (ix) - ld d, a -;pff.c:399: rv = rv << 8 | ptr[1]; - ld -3 (ix), c - ld -2 (ix), b - ld -1 (ix), e - xor a, a - ld -4 (ix), a - ld l, 4 (ix) - ld h, 5 (ix) - inc hl - ld c, (hl) - ld b, #0x00 - ld e, #0x00 - ld d, #0x00 - ld a, c - or a, -4 (ix) - ld c, a - ld a, b - or a, -3 (ix) - ld b, a - ld a, e - or a, -2 (ix) - ld e, a - ld a, d - or a, -1 (ix) - ld d, a -;pff.c:400: rv = rv << 8 | ptr[0]; - ld -3 (ix), c - ld -2 (ix), b - ld -1 (ix), e - xor a, a - ld -4 (ix), a - ld l, 4 (ix) - ld h, 5 (ix) - ld c, (hl) - ld b, #0x00 - ld e, #0x00 - ld d, #0x00 - ld a, -4 (ix) - or a, c - ld l, a - ld a, -3 (ix) - or a, b - ld h, a - ld a, -2 (ix) - or a, e - ld e, a - ld a, -1 (ix) - or a, d - ld d, a -;pff.c:401: return rv; -l_ld_dword_00101$: -;pff.c:402: } - ld sp, ix - pop ix - ret -;pff.c:411: static void mem_set (void* dst, int val, int cnt) { -; --------------------------------- -; Function mem_set -; --------------------------------- -_mem_set: - call ___sdcc_enter_ix -;pff.c:412: char *d = (char*)dst; - ld e, 4 (ix) - ld d, 5 (ix) -;pff.c:413: while (cnt--) *d++ = (char)val; - ld c, 8 (ix) - ld b, 9 (ix) -l_mem_set_00101$: - ld l, c - ld h, b - dec bc - ld a, h - or a, l - jp Z, l_mem_set_00104$ - ld a, 6 (ix) - ld (de), a - inc de - jp l_mem_set_00101$ -l_mem_set_00104$: -;pff.c:414: } - pop ix - ret -;pff.c:417: static int mem_cmp (const void* dst, const void* src, int cnt) { -; --------------------------------- -; Function mem_cmp -; --------------------------------- -_mem_cmp: - call ___sdcc_enter_ix - push af - push af -;pff.c:418: const char *d = (const char *)dst, *s = (const char *)src; - ld a, 4 (ix) - ld -4 (ix), a - ld a, 5 (ix) - ld -3 (ix), a - ld a, 6 (ix) - ld -2 (ix), a - ld a, 7 (ix) - ld -1 (ix), a -;pff.c:419: int r = 0; - ld hl, #0x0000 -;pff.c:420: while (cnt-- && (r = *d++ - *s++) == 0) ; - ld c, 8 (ix) - ld b, 9 (ix) -l_mem_cmp_00102$: - ld e, c - ld d, b - dec bc - ld a, d - or a, e - jp Z, l_mem_cmp_00104$ - pop hl - push hl - ld e, (hl) - inc -4 (ix) - jp NZ, l_mem_cmp_00118$ - inc -3 (ix) -l_mem_cmp_00118$: - ld d, #0x00 - ld l, -2 (ix) - ld h, -1 (ix) - ld l, (hl) - inc -2 (ix) - jp NZ, l_mem_cmp_00119$ - inc -1 (ix) -l_mem_cmp_00119$: - ld h, #0x00 - ld a, e - sub a, l - ld e, a - ld a, d - sbc a, h - ld d, a - ld l, e - ld h, d - ld a, d - or a, e - jp Z, l_mem_cmp_00102$ -l_mem_cmp_00104$: -;pff.c:421: return r; -l_mem_cmp_00105$: -;pff.c:422: } - ld sp, ix - pop ix - ret -;pff.c:430: static CLUST get_fat ( /* 1:IO error, Else:Cluster status */ -; --------------------------------- -; Function get_fat -; --------------------------------- -_get_fat: - call ___sdcc_enter_ix - ld hl, #-14 - add hl, sp - ld sp, hl -;pff.c:435: FATFS *fs = FatFs; - ld bc, (_FatFs) -;pff.c:440: if (clst < 2 || clst >= fs->n_fatent) return 1; /* Range check */ - ld a, 4 (ix) - sub a, #0x02 - ld a, 5 (ix) - sbc a, #0x00 - ld a, 6 (ix) - sbc a, #0x00 - ld a, 7 (ix) - sbc a, #0x00 - jp C, l_get_fat_00101$ - ld l, c - ld h, b - ld de, #0x0006 - add hl, de - ld e, (hl) - inc hl - ld d, (hl) - inc hl - inc hl - ld a, (hl) - dec hl - ld l, (hl) - ld h, a - ld a, 4 (ix) - sub a, e - ld a, 5 (ix) - sbc a, d - ld a, 6 (ix) - sbc a, l - ld a, 7 (ix) - sbc a, h - jp C, l_get_fat_00102$ -l_get_fat_00101$: - ld l, #0x01 - ld h, #0x00 - ld e, #0x00 - ld d, #0x00 - jp l_get_fat_00108$ -l_get_fat_00102$: -;pff.c:442: switch (fs->fs_type) { - ld a, (bc) - sub a, #0x03 - jp NZ,l_get_fat_00125$ - jp l_get_fat_00126$ -l_get_fat_00125$: - jp l_get_fat_00107$ -l_get_fat_00126$: -;pff.c:464: if (disk_readp(buf, fs->fatbase + clst / 128, ((UINT)clst % 128) * 4, 4)) break; - ld l, 4 (ix) - ld a, 5 (ix) - res 7, l - ld h, #0x00 - add hl, hl - add hl, hl - ld -10 (ix), l - ld -9 (ix), h - ld l, c - ld h, b - ld de, #0x000a - add hl, de - ld a, (hl) - ld -8 (ix), a - inc hl - ld a, (hl) - ld -7 (ix), a - inc hl - ld a, (hl) - ld -6 (ix), a - inc hl - ld a, (hl) - ld -5 (ix), a - ld e, 4 (ix) - ld d, 5 (ix) - ld l, 6 (ix) - ld h, 7 (ix) - ld b, #0x07 -l_get_fat_00127$: - srl h - rr l - rr d - rr e -l_get_fat_00128$: - djnz l_get_fat_00127$ - ld a, -8 (ix) - add a, e - ld -4 (ix), a - ld a, -7 (ix) - adc a, d - ld -3 (ix), a - ld a, -6 (ix) - adc a, l - ld -2 (ix), a - ld a, -5 (ix) - adc a, h - ld -1 (ix), a - ld hl, #0 - add hl, sp - ex de, hl - ld c, e - ld b, d - push de - ld hl, #0x0004 - push hl - ld l, -10 (ix) - ld h, -9 (ix) - push hl - ld l, -2 (ix) - ld h, -1 (ix) - push hl - ld l, -4 (ix) - ld h, -3 (ix) - push hl - push bc - call _disk_readp - ld iy, #10 - add iy, sp - ld sp, iy - ld a, l - pop de - or a, a - jp NZ, l_get_fat_00107$ -;pff.c:465: return ld_dword(buf) & 0x0FFFFFFF; - push de - call _ld_dword - pop af - ld a, d - and a, #0x0f - ld d, a - jp l_get_fat_00108$ -;pff.c:467: } -l_get_fat_00107$: -;pff.c:469: return 1; /* An error occured at the disk I/O layer */ - ld l, #0x01 - ld h, #0x00 - ld e, #0x00 - ld d, #0x00 -l_get_fat_00108$: -;pff.c:470: } - ld sp, ix - pop ix - ret -;pff.c:479: static DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ -; --------------------------------- -; Function clust2sect -; --------------------------------- -_clust2sect: - call ___sdcc_enter_ix - push af - push af -;pff.c:483: FATFS *fs = FatFs; - ld bc, (_FatFs) -;pff.c:486: clst -= 2; - ld a, 4 (ix) - add a, #0xfe - ld 4 (ix), a - ld a, 5 (ix) - adc a, #0xff - ld 5 (ix), a - ld a, 6 (ix) - adc a, #0xff - ld 6 (ix), a - ld a, 7 (ix) - adc a, #0xff - ld 7 (ix), a -;pff.c:487: if (clst >= (fs->n_fatent - 2)) return 0; /* Invalid cluster# */ - ld l, c - ld h, b - ld de, #0x0006 - add hl, de - ld e, (hl) - inc hl - ld d, (hl) - inc hl - inc hl - ld a, (hl) - dec hl - ld l, (hl) - ld h, a - ld a, e - add a, #0xfe - ld e, a - ld a, d - adc a, #0xff - ld d, a - ld a, l - adc a, #0xff - ld l, a - ld a, h - adc a, #0xff - ld h, a - ld a, 4 (ix) - sub a, e - ld a, 5 (ix) - sbc a, d - ld a, 6 (ix) - sbc a, l - ld a, 7 (ix) - sbc a, h - jp C, l_clust2sect_00102$ - ld l, #0x00 - ld h, #0x00 - ld e, #0x00 - ld d, #0x00 - jp l_clust2sect_00103$ -l_clust2sect_00102$: -;pff.c:488: return (DWORD)clst * fs->csize + fs->database; - ld l, c - ld h, b - inc hl - inc hl - ld e, (hl) - ld d, #0x00 - ld l, #0x00 - ld h, #0x00 - push bc - push hl - push de - ld l, 6 (ix) - ld h, 7 (ix) - push hl - ld l, 4 (ix) - ld h, 5 (ix) - push hl - call __mullong - pop af - pop af - pop af - pop af - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d - pop bc - ld l, c - ld h, b - ld de, #0x0012 - add hl, de - ld c, (hl) - inc hl - ld b, (hl) - inc hl - ld e, (hl) - inc hl - ld d, (hl) - ld a, -4 (ix) - add a, c - ld l, a - ld a, -3 (ix) - adc a, b - ld h, a - ld a, -2 (ix) - adc a, e - ld e, a - ld a, -1 (ix) - adc a, d - ld d, a -l_clust2sect_00103$: -;pff.c:489: } - ld sp, ix - pop ix - ret -;pff.c:492: static CLUST get_clust ( -; --------------------------------- -; Function get_clust -; --------------------------------- -_get_clust: - call ___sdcc_enter_ix - push af - push af -;pff.c:501: clst = ld_word(dir+DIR_FstClusHI); - ld a, 4 (ix) - add a, #0x14 - ld c, a - ld a, 5 (ix) - adc a, #0x00 - ld b, a - push bc - call _ld_word - pop af - ld c, #0x00 - ld b, #0x00 -;pff.c:502: clst <<= 16; - ld -2 (ix), l - ld -1 (ix), h - xor a, a - ld -4 (ix), a - ld -3 (ix), a -;pff.c:504: clst |= ld_word(dir+DIR_FstClusLO); - ld a, 4 (ix) - add a, #0x1a - ld c, a - ld a, 5 (ix) - adc a, #0x00 - ld b, a - push bc - call _ld_word - pop af - ld c, #0x00 - ld b, #0x00 - ld a, -4 (ix) - or a, l - ld l, a - ld a, -3 (ix) - or a, h - ld h, a - ld a, -2 (ix) - or a, c - ld e, a - ld a, -1 (ix) - or a, b - ld d, a -;pff.c:506: return clst; -l_get_clust_00105$: -;pff.c:507: } - ld sp, ix - pop ix - ret -;pff.c:514: static FRESULT dir_rewind ( -; --------------------------------- -; Function dir_rewind -; --------------------------------- -_dir_rewind: - call ___sdcc_enter_ix - push af - push af - push af - push af -;pff.c:519: FATFS *fs = FatFs; - ld hl, (_FatFs) - ex (sp), hl -;pff.c:522: dj->index = 0; - ld a, 4 (ix) - ld -6 (ix), a - ld a, 5 (ix) - ld -5 (ix), a - pop bc - pop hl - push hl - push bc - xor a, a - ld (hl), a - inc hl - ld (hl), a -;pff.c:523: clst = dj->sclust; - pop bc - pop hl - push hl - push bc - ld de, #0x0004 - add hl, de - ld c, (hl) - inc hl - ld b, (hl) - inc hl - ld e, (hl) - inc hl - ld d, (hl) -;pff.c:524: if (clst == 1 || clst >= fs->n_fatent) { /* Check start cluster range */ - ld a, c - dec a - or a, b - or a, e - or a, d - jp NZ,l_dir_rewind_00128$ - jp l_dir_rewind_00101$ -l_dir_rewind_00128$: - pop hl - push hl - push bc - ld bc, #0x0006 - add hl, bc - pop bc - ld a, (hl) - ld -4 (ix), a - inc hl - ld a, (hl) - ld -3 (ix), a - inc hl - ld a, (hl) - ld -2 (ix), a - inc hl - ld a, (hl) - ld -1 (ix), a - ld a, c - sub a, -4 (ix) - ld a, b - sbc a, -3 (ix) - ld a, e - sbc a, -2 (ix) - ld a, d - sbc a, -1 (ix) - jp C, l_dir_rewind_00106$ -l_dir_rewind_00101$: -;pff.c:525: return FR_DISK_ERR; - ld l, #0x01 - jp l_dir_rewind_00109$ -;pff.c:527: if (PF_FS_FAT32 && !clst && (_FS_32ONLY || fs->fs_type == FS_FAT32)) { /* Replace cluster# 0 with root cluster# if in FAT32 */ -l_dir_rewind_00106$: - ld a, d - or a, e - or a, b - or a, c - jp NZ, l_dir_rewind_00105$ -;pff.c:528: clst = (CLUST)fs->dirbase; - pop hl - push hl - ld de, #0x000e - add hl, de - ld c, (hl) - inc hl - ld b, (hl) - inc hl - ld e, (hl) - inc hl - ld d, (hl) -l_dir_rewind_00105$: -;pff.c:530: dj->clust = clst; /* Current cluster */ - ld a, -6 (ix) - add a, #0x08 - ld l, a - ld a, -5 (ix) - adc a, #0x00 - ld h, a - ld (hl), c - inc hl - ld (hl), b - inc hl - ld (hl), e - inc hl - ld (hl), d -;pff.c:531: dj->sect = (_FS_32ONLY || clst) ? clust2sect(clst) : fs->dirbase; /* Current sector */ - ld a, -6 (ix) - add a, #0x0c - ld l, a - ld a, -5 (ix) - adc a, #0x00 - ld h, a - push hl - push de - push bc - call _clust2sect - pop af - pop af - ld c, l - ld b, h - pop hl - ld (hl), c - inc hl - ld (hl), b - inc hl - ld (hl), e - inc hl - ld (hl), d -;pff.c:533: return FR_OK; /* Seek succeeded */ - ld l, #0x00 -l_dir_rewind_00109$: -;pff.c:534: } - ld sp, ix - pop ix - ret -;pff.c:543: static FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table */ -; --------------------------------- -; Function dir_next -; --------------------------------- -_dir_next: - call ___sdcc_enter_ix - ld hl, #-14 - add hl, sp - ld sp, hl -;pff.c:549: FATFS *fs = FatFs; - ld hl, (_FatFs) - ex (sp), hl -;pff.c:552: i = dj->index + 1; - ld c, 4 (ix) - ld b, 5 (ix) - ld l, c - ld h, b - ld e, (hl) - inc hl - ld d, (hl) - inc de - ld -12 (ix), e - ld -11 (ix), d -;pff.c:553: if (!i || !dj->sect) return FR_NO_FILE; /* Report EOT when index has reached 65535 */ - ld a, -11 (ix) - or a, -12 (ix) - jp Z, l_dir_next_00101$ - ld hl, #0x000c - add hl, bc - ld -10 (ix), l - ld -9 (ix), h - ld l, -10 (ix) - ld h, -9 (ix) - ld e, (hl) - inc hl - ld d, (hl) - inc hl - inc hl - ld a, (hl) - dec hl - ld l, (hl) - ld h, a - ld a, h - or a, l - or a, d - or a, e - jp NZ, l_dir_next_00102$ -l_dir_next_00101$: - ld l, #0x03 - jp l_dir_next_00117$ -l_dir_next_00102$: -;pff.c:555: if (!(i % 16)) { /* Sector changed? */ - ld a, -12 (ix) - ld -8 (ix), a - ld a, -11 (ix) - ld -7 (ix), a - ld a, -8 (ix) - and a, #0x0f - jp NZ,l_dir_next_00154$ - jp l_dir_next_00155$ -l_dir_next_00154$: - jp l_dir_next_00116$ -l_dir_next_00155$: -;pff.c:556: dj->sect++; /* Next sector */ - ld a, e - add a, #0x01 - ld -4 (ix), a - ld a, d - adc a, #0x00 - ld -3 (ix), a - ld a, l - adc a, #0x00 - ld -2 (ix), a - ld a, h - adc a, #0x00 - ld -1 (ix), a - push bc - ld e, -10 (ix) - ld d, -9 (ix) - ld hl, #0x000c - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:558: if (dj->clust == 0) { /* Static table */ - ld hl, #0x0008 - add hl, bc - ld -6 (ix), l - ld -5 (ix), h - push bc - ld e, -6 (ix) - ld d, -5 (ix) - ld hl, #0x000c - add hl, sp - ex de, hl - ld bc, #0x0004 - ldir - pop bc - ld a, -1 (ix) - or a, -2 (ix) - or a, -3 (ix) - or a, -4 (ix) - jp NZ, l_dir_next_00113$ -;pff.c:559: if (i >= fs->n_rootdir) return FR_NO_FILE; /* Report EOT when end of table */ - pop hl - push hl - ld de, #0x0004 - add hl, de - ld e, (hl) - inc hl - ld d, (hl) - ld a, -12 (ix) - sub a, e - ld a, -11 (ix) - sbc a, d - jp C, l_dir_next_00116$ - ld l, #0x03 - jp l_dir_next_00117$ -l_dir_next_00113$: -;pff.c:562: if (((i / 16) & (fs->csize - 1)) == 0) { /* Cluster changed? */ - ld e, -8 (ix) - ld d, -7 (ix) - ld a, #0x04 -l_dir_next_00156$: - srl d - rr e - dec a - jp NZ, l_dir_next_00156$ - pop hl - push hl - inc hl - inc hl - ld l, (hl) - ld h, #0x00 - dec hl - ld a, l - and a, e - ld e, a - ld a, h - and a, d - or a, e - jp NZ, l_dir_next_00116$ -;pff.c:563: clst = get_fat(dj->clust); /* Get next cluster */ - push bc - ld l, -2 (ix) - ld h, -1 (ix) - push hl - ld l, -4 (ix) - ld h, -3 (ix) - push hl - call _get_fat - pop af - pop af - pop bc - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d -;pff.c:564: if (clst <= 1) return FR_DISK_ERR; - ld a, #0x01 - cp a, -4 (ix) - ld a, #0x00 - sbc a, -3 (ix) - ld a, #0x00 - sbc a, -2 (ix) - ld a, #0x00 - sbc a, -1 (ix) - jp C, l_dir_next_00107$ - ld l, #0x01 - jp l_dir_next_00117$ -l_dir_next_00107$: -;pff.c:565: if (clst >= fs->n_fatent) return FR_NO_FILE; /* Report EOT when it reached end of dynamic table */ - pop hl - push hl - ld de, #0x0006 - add hl, de - ld e, (hl) - inc hl - ld d, (hl) - inc hl - inc hl - ld a, (hl) - dec hl - ld l, (hl) - ld h, a - ld a, -4 (ix) - sub a, e - ld a, -3 (ix) - sbc a, d - ld a, -2 (ix) - sbc a, l - ld a, -1 (ix) - sbc a, h - jp C, l_dir_next_00109$ - ld l, #0x03 - jp l_dir_next_00117$ -l_dir_next_00109$: -;pff.c:566: dj->clust = clst; /* Initialize data for new cluster */ - push bc - ld e, -6 (ix) - ld d, -5 (ix) - ld hl, #0x000c - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:567: dj->sect = clust2sect(clst); - push bc - ld l, -2 (ix) - ld h, -1 (ix) - push hl - ld l, -4 (ix) - ld h, -3 (ix) - push hl - call _clust2sect - pop af - pop af - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d - pop bc - push bc - ld e, -10 (ix) - ld d, -9 (ix) - ld hl, #0x000c - add hl, sp - ld bc, #0x0004 - ldir - pop bc -l_dir_next_00116$: -;pff.c:572: dj->index = i; - ld a, -12 (ix) - ld (bc), a - inc bc - ld a, -11 (ix) - ld (bc), a -;pff.c:574: return FR_OK; - ld l, #0x00 -l_dir_next_00117$: -;pff.c:575: } - ld sp, ix - pop ix - ret -;pff.c:584: static FRESULT dir_find ( -; --------------------------------- -; Function dir_find -; --------------------------------- -_dir_find: - call ___sdcc_enter_ix - ld hl, #-9 - add hl, sp - ld sp, hl -;pff.c:593: res = dir_rewind(dj); /* Rewind directory object */ - ld l, 4 (ix) - ld h, 5 (ix) - push hl - call _dir_rewind - pop af -;pff.c:594: if (res != FR_OK) return res; - ld a, l - or a, a - jp Z, l_dir_find_00122$ - jp l_dir_find_00113$ -;pff.c:596: do { -l_dir_find_00122$: - ld c, 4 (ix) - ld b, 5 (ix) - ld -5 (ix), c - ld -4 (ix), b -l_dir_find_00110$: -;pff.c:597: res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ld l, c - ld h, b - ld e, (hl) - inc hl - ld d, (hl) - ld a, e - and a, #0x0f - ld l, a - ld h, #0x00 - add hl, hl - add hl, hl - add hl, hl - add hl, hl - add hl, hl - ld e, l - ld d, h - ld l, -5 (ix) - ld h, -4 (ix) - push bc - ld bc, #0x000c - add hl, bc - pop bc - ld a, (hl) - ld -9 (ix), a - inc hl - ld a, (hl) - ld -8 (ix), a - inc hl - ld a, (hl) - ld -7 (ix), a - inc hl - ld a, (hl) - ld -6 (ix), a - push bc - ld hl, #0x0020 - push hl - push de - ld l, -7 (ix) - ld h, -6 (ix) - push hl - ld l, -9 (ix) - ld h, -8 (ix) - push hl - ld l, 6 (ix) - ld h, 7 (ix) - push hl - call _disk_readp - ld iy, #10 - add iy, sp - ld sp, iy - ld a, l - pop bc - or a, a - jp Z, l_dir_find_00115$ -;pff.c:598: ? FR_DISK_ERR : FR_OK; - ld de, #0x0001 - jp l_dir_find_00116$ -l_dir_find_00115$: - ld de, #0x0000 -l_dir_find_00116$: - ld -3 (ix), e -;pff.c:599: if (res != FR_OK) break; - ld a, -3 (ix) - or a, a - jp NZ, l_dir_find_00112$ -;pff.c:600: c = dir[DIR_Name]; /* First character */ - ld l, 6 (ix) - ld h, 7 (ix) - ld a, (hl) -;pff.c:601: if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - or a, a - jp NZ, l_dir_find_00106$ - ld -3 (ix), #0x03 - jp l_dir_find_00112$ -l_dir_find_00106$: -;pff.c:602: if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dj->fn, 11)) break; /* Is it a valid entry? */ - ld de, #0x000b - add hl, de - ld a, (hl) - bit 3, a - jp NZ,l_dir_find_00147$ - jp l_dir_find_00148$ -l_dir_find_00147$: - jp l_dir_find_00108$ -l_dir_find_00148$: - ld l, c - ld h, b - inc hl - inc hl - ld e, (hl) - inc hl - ld d, (hl) - ld -2 (ix), e - ld -1 (ix), d - ld e, 6 (ix) - ld d, 7 (ix) - push bc - ld hl, #0x000b - push hl - ld l, -2 (ix) - ld h, -1 (ix) - push hl - push de - call _mem_cmp - pop af - pop af - pop af - pop bc - ld a, h - or a, l - jp Z, l_dir_find_00112$ -l_dir_find_00108$: -;pff.c:603: res = dir_next(dj); /* Next entry */ - push bc - push bc - call _dir_next - pop af - pop bc - ld -3 (ix), l -;pff.c:604: } while (res == FR_OK); - ld a, -3 (ix) - or a, a - jp Z, l_dir_find_00110$ -l_dir_find_00112$: -;pff.c:606: return res; - ld l, -3 (ix) -l_dir_find_00113$: -;pff.c:607: } - ld sp, ix - pop ix - ret -;pff.c:616: static FRESULT dir_read ( -; --------------------------------- -; Function dir_read -; --------------------------------- -_dir_read: - call ___sdcc_enter_ix - push af - push af - push af -;pff.c:625: res = FR_NO_FILE; - ld e, #0x03 -;pff.c:626: while (dj->sect) { - ld c, 4 (ix) - ld b, 5 (ix) - ld hl, #0x000c - add hl, bc - ex (sp), hl -l_dir_read_00111$: - push de - push bc - ld e, -6 (ix) - ld d, -5 (ix) - ld hl, #0x0006 - add hl, sp - ex de, hl - ld bc, #0x0004 - ldir - pop bc - pop de - ld a, -1 (ix) - or a, -2 (ix) - or a, -3 (ix) - or a, -4 (ix) - jp Z, l_dir_read_00113$ -;pff.c:627: res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ld l, c - ld h, b - ld e, (hl) - inc hl - ld d, (hl) - ld a, e - and a, #0x0f - ld l, a - ld h, #0x00 - add hl, hl - add hl, hl - add hl, hl - add hl, hl - add hl, hl - push bc - ld de, #0x0020 - push de - push hl - ld l, -2 (ix) - ld h, -1 (ix) - push hl - ld l, -4 (ix) - ld h, -3 (ix) - push hl - ld l, 6 (ix) - ld h, 7 (ix) - push hl - call _disk_readp - ld iy, #10 - add iy, sp - ld sp, iy - ld a, l - pop bc - or a, a - jp Z, l_dir_read_00118$ -;pff.c:628: ? FR_DISK_ERR : FR_OK; - ld de, #0x0001 - jp l_dir_read_00119$ -l_dir_read_00118$: - ld de, #0x0000 -l_dir_read_00119$: -;pff.c:629: if (res != FR_OK) break; - ld a, e - or a, a - jp NZ, l_dir_read_00113$ -;pff.c:630: c = dir[DIR_Name]; - ld l, 6 (ix) - ld h, 7 (ix) - ld a, (hl) -;pff.c:631: if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - or a, a - jp NZ, l_dir_read_00104$ - ld e, #0x03 - jp l_dir_read_00113$ -l_dir_read_00104$: -;pff.c:632: a = dir[DIR_Attr] & AM_MASK; - push bc - ld bc, #0x000b - add hl, bc - pop bc - ld d, (hl) - push af - ld a, d - and a, #0x3f - ld d, a - pop af -;pff.c:633: if (c != 0xE5 && c != '.' && !(a & AM_VOL)) break; /* Is it a valid entry? */ - cp a, #0xe5 - jp NZ,l_dir_read_00160$ - jp l_dir_read_00106$ -l_dir_read_00160$: - sub a, #0x2e - jp NZ,l_dir_read_00161$ - jp l_dir_read_00106$ -l_dir_read_00161$: - bit 3, d - jp NZ,l_dir_read_00162$ - jp l_dir_read_00113$ -l_dir_read_00162$: -l_dir_read_00106$: -;pff.c:634: res = dir_next(dj); /* Next entry */ - push bc - push bc - call _dir_next - pop af - ld a, l - pop bc - ld e, a -;pff.c:635: if (res != FR_OK) break; - ld a, e - or a, a - jp Z, l_dir_read_00111$ -l_dir_read_00113$: -;pff.c:638: if (res != FR_OK) dj->sect = 0; - ld a, e - or a, a - jp Z, l_dir_read_00115$ - pop hl - push hl - xor a, a - ld (hl), a - inc hl - ld (hl), a - inc hl - ld (hl), a - inc hl - ld (hl), a -l_dir_read_00115$: -;pff.c:640: return res; - ld l, e -l_dir_read_00116$: -;pff.c:641: } - ld sp, ix - pop ix - ret -;pff.c:651: static FRESULT create_name ( -; --------------------------------- -; Function create_name -; --------------------------------- -_create_name: - call ___sdcc_enter_ix - push af - push af - push af - dec sp -;pff.c:663: sfn = dj->fn; - ld l, 4 (ix) - ld h, 5 (ix) - inc hl - inc hl - ld c, (hl) - inc hl - ld b, (hl) -;pff.c:664: mem_set(sfn, ' ', 11); - ld e, c - ld d, b - push bc - ld hl, #0x000b - push hl - ld l, #0x20 - push hl - push de - call _mem_set - pop af - pop af - pop af - pop bc -;pff.c:665: si = i = 0; ni = 8; - xor a, a - ld -1 (ix), a - ld -7 (ix), #0x08 -;pff.c:666: p = *path; - ld a, 6 (ix) - ld -6 (ix), a - ld a, 7 (ix) - ld -5 (ix), a - ld l, -6 (ix) - ld h, -5 (ix) - ld a, (hl) - ld -4 (ix), a - inc hl - ld a, (hl) - ld -3 (ix), a - ld e, #0x00 -l_create_name_00120$: -;pff.c:668: c = p[si++]; - ld l, -4 (ix) - ld h, -3 (ix) - ld d, #0x00 - add hl, de - inc e - ld d, (hl) -;pff.c:669: if (c <= ' ' || c == '/') break; /* Break on end of segment */ - ld a, #0x20 - sub a, d - ld a, #0x00 - rla - ld -2 (ix), a - bit 0, -2 (ix) - jp Z, l_create_name_00119$ - ld a, d - sub a, #0x2f - jp NZ,l_create_name_00161$ - jp l_create_name_00119$ -l_create_name_00161$: -;pff.c:670: if (c == '.' || i >= ni) { - ld a, d - sub a, #0x2e - jp NZ,l_create_name_00162$ - ld a,#0x01 - jp l_create_name_00163$ -l_create_name_00162$: - xor a,a -l_create_name_00163$: - ld l, a - ld a, l - or a, a - jp NZ, l_create_name_00107$ - ld a, -1 (ix) - sub a, -7 (ix) - jp C, l_create_name_00111$ -l_create_name_00107$: -;pff.c:671: if (ni != 8 || c != '.') break; - ld a, -7 (ix) - sub a, #0x08 - jp NZ,l_create_name_00164$ - jp l_create_name_00165$ -l_create_name_00164$: - jp l_create_name_00119$ -l_create_name_00165$: - bit 0, l - jp Z, l_create_name_00119$ -;pff.c:672: i = 8; ni = 11; - ld -1 (ix), #0x08 - ld -7 (ix), #0x0b -;pff.c:673: continue; - jp l_create_name_00120$ -;pff.c:683: if (PF_USE_LCC && IsLower(c)) c -= 0x20; /* toupper */ -l_create_name_00111$: -;pff.c:684: sfn[i++] = c; - ld l, -1 (ix) - inc -1 (ix) - ld h, #0x00 - add hl, bc - ld (hl), d - jp l_create_name_00120$ -l_create_name_00119$: -;pff.c:687: *path = &p[si]; /* Rerurn pointer to the next segment */ - ld a, e - add a, -4 (ix) - ld e, a - ld a, #0x00 - adc a, -3 (ix) - ld d, a - ld l, -6 (ix) - ld h, -5 (ix) - ld (hl), e - inc hl - ld (hl), d -;pff.c:689: sfn[11] = (c <= ' ') ? 1 : 0; /* Set last segment flag if end of path */ - ld hl, #0x000b - add hl, bc - bit 0, -2 (ix) - jp NZ, l_create_name_00123$ - ld bc, #0x0001 - jp l_create_name_00124$ -l_create_name_00123$: - ld bc, #0x0000 -l_create_name_00124$: - ld (hl), c -;pff.c:691: return FR_OK; - ld l, #0x00 -l_create_name_00121$: -;pff.c:692: } - ld sp, ix - pop ix - ret -;pff.c:701: static void get_fileinfo ( /* No return code */ -; --------------------------------- -; Function get_fileinfo -; --------------------------------- -_get_fileinfo: - call ___sdcc_enter_ix - push af - push af - push af -;pff.c:711: p = fno->fname; - ld c, 8 (ix) - ld b, 9 (ix) - ld hl, #0x0009 - add hl, bc - ex (sp), hl -;pff.c:712: if (dj->sect) { - ld l, 4 (ix) - ld h, 5 (ix) - ld de, #0x000c - add hl, de - ld a, (hl) - ld -4 (ix), a - inc hl - ld a, (hl) - ld -3 (ix), a - inc hl - ld a, (hl) - ld -2 (ix), a - inc hl - ld a, (hl) - ld -1 (ix), a - ld a, -1 (ix) - or a, -2 (ix) - or a, -3 (ix) - or a, -4 (ix) - jp Z, l_get_fileinfo_00112$ -;pff.c:713: for (i = 0; i < 8; i++) { /* Copy file name body */ - pop de - push de - xor a, a - ld -1 (ix), a -l_get_fileinfo_00113$: -;pff.c:714: c = dir[i]; - ld a, 6 (ix) - add a, -1 (ix) - ld l, a - ld a, 7 (ix) - adc a, #0x00 - ld h, a - ld a, (hl) -;pff.c:715: if (c == ' ') break; - cp a, #0x20 - jp NZ,l_get_fileinfo_00156$ - jp l_get_fileinfo_00126$ -l_get_fileinfo_00156$: -;pff.c:716: if (c == 0x05) c = 0xE5; - cp a, #0x05 - jp NZ,l_get_fileinfo_00157$ - jp l_get_fileinfo_00158$ -l_get_fileinfo_00157$: - jp l_get_fileinfo_00104$ -l_get_fileinfo_00158$: - ld a, #0xe5 -l_get_fileinfo_00104$: -;pff.c:717: *p++ = c; - ld (de), a - inc de -;pff.c:713: for (i = 0; i < 8; i++) { /* Copy file name body */ - inc -1 (ix) - ld a, -1 (ix) - sub a, #0x08 - jp C, l_get_fileinfo_00113$ -l_get_fileinfo_00126$: - inc sp - inc sp - push de -;pff.c:719: if (dir[8] != ' ') { /* Copy file name extension */ - ld l, 6 (ix) - ld h, 7 (ix) - push bc - ld bc, #0x0008 - add hl, bc - pop bc - ld a, (hl) - sub a, #0x20 - jp NZ,l_get_fileinfo_00159$ - jp l_get_fileinfo_00110$ -l_get_fileinfo_00159$: -;pff.c:720: *p++ = '.'; - ld a, #0x2e - ld (de), a - inc de -;pff.c:721: for (i = 8; i < 11; i++) { - ld -1 (ix), #0x08 -l_get_fileinfo_00115$: -;pff.c:722: c = dir[i]; - ld a, 6 (ix) - add a, -1 (ix) - ld l, a - ld a, 7 (ix) - adc a, #0x00 - ld h, a - ld a, (hl) -;pff.c:723: if (c == ' ') break; - cp a, #0x20 - jp NZ,l_get_fileinfo_00160$ - jp l_get_fileinfo_00127$ -l_get_fileinfo_00160$: -;pff.c:724: *p++ = c; - ld (de), a - inc de -;pff.c:721: for (i = 8; i < 11; i++) { - inc -1 (ix) - ld a, -1 (ix) - sub a, #0x0b - jp C, l_get_fileinfo_00115$ -l_get_fileinfo_00127$: - inc sp - inc sp - push de -l_get_fileinfo_00110$: -;pff.c:727: fno->fattrib = dir[DIR_Attr]; /* Attribute */ - ld hl, #0x0008 - add hl, bc - ex de, hl - ld l, 6 (ix) - ld h, 7 (ix) - push bc - ld bc, #0x000b - add hl, bc - pop bc - ld a, (hl) - ld (de), a -;pff.c:728: fno->fsize = ld_dword(dir+DIR_FileSize); /* Size */ - ld a, 6 (ix) - add a, #0x1c - ld e, a - ld a, 7 (ix) - adc a, #0x00 - ld d, a - push bc - push de - call _ld_dword - pop af - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d - pop bc - push bc - ld e, c - ld d, b - ld hl, #0x0004 - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:729: fno->fdate = ld_word(dir+DIR_WrtDate); /* Date */ - ld hl, #0x0004 - add hl, bc - ld a, 6 (ix) - add a, #0x18 - ld e, a - ld a, 7 (ix) - adc a, #0x00 - ld d, a - push hl - push bc - push de - call _ld_word - pop af - ld e, l - ld d, h - pop bc - pop hl - ld (hl), e - inc hl - ld (hl), d -;pff.c:730: fno->ftime = ld_word(dir+DIR_WrtTime); /* Time */ - ld hl, #0x0006 - add hl, bc - ld a, 6 (ix) - add a, #0x16 - ld c, a - ld a, 7 (ix) - adc a, #0x00 - ld b, a - push hl - push bc - call _ld_word - pop af - ld c, l - ld b, h - pop hl - ld (hl), c - inc hl - ld (hl), b -l_get_fileinfo_00112$: -;pff.c:732: *p = 0; - pop hl - push hl - ld (hl), #0x00 -l_get_fileinfo_00117$: -;pff.c:733: } - ld sp, ix - pop ix - ret -;pff.c:742: static FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ -; --------------------------------- -; Function follow_path -; --------------------------------- -_follow_path: - call ___sdcc_enter_ix - ld hl, #-10 - add hl, sp - ld sp, hl -;pff.c:751: while (*path == ' ') path++; /* Strip leading spaces */ - ld l, 8 (ix) - ld h, 9 (ix) -l_follow_path_00101$: - ld a, (hl) - ld e, l - ld d, h - inc de - cp a, #0x20 - jp NZ,l_follow_path_00168$ - jp l_follow_path_00169$ -l_follow_path_00168$: - jp l_follow_path_00131$ -l_follow_path_00169$: - ld l, e - ld h, d - ld 8 (ix), e - ld 9 (ix), d - jp l_follow_path_00101$ -l_follow_path_00131$: - ld 8 (ix), l - ld 9 (ix), h -;pff.c:752: if (*path == '/') path++; /* Strip heading separator if exist */ - sub a, #0x2f - jp NZ,l_follow_path_00170$ - jp l_follow_path_00171$ -l_follow_path_00170$: - jp l_follow_path_00105$ -l_follow_path_00171$: - ld 8 (ix), e - ld 9 (ix), d -l_follow_path_00105$: -;pff.c:753: dj->sclust = 0; /* Set start directory (always root dir) */ - ld c, 4 (ix) - ld b, 5 (ix) - ld hl, #0x0004 - add hl, bc - xor a, a - ld (hl), a - inc hl - ld (hl), a - inc hl - ld (hl), a - inc hl - ld (hl), a -;pff.c:755: if ((BYTE)*path < ' ') { /* Null path means the root directory */ - ld e, 8 (ix) - ld d, 9 (ix) - ld a, (de) - sub a, #0x20 - jp NC, l_follow_path_00130$ -;pff.c:756: res = dir_rewind(dj); - push bc - call _dir_rewind - pop af - ld a, l - ld e, a -;pff.c:757: dir[0] = 0; - ld c, 6 (ix) - ld b, 7 (ix) - xor a, a - ld (bc), a - jp l_follow_path_00117$ -l_follow_path_00130$: - inc sp - inc sp - push bc - ld a, 6 (ix) - ld -8 (ix), a - ld a, 7 (ix) - ld -7 (ix), a - ld -6 (ix), c - ld -5 (ix), b -l_follow_path_00118$: -;pff.c:761: res = create_name(dj, &path); /* Get a segment */ - ld hl, #18 - add hl, sp - push bc - push hl - push bc - call _create_name - pop af - pop af - ld a, l - pop bc - ld e, a -;pff.c:762: if (res != FR_OK) break; - ld a, e - or a, a - jp NZ, l_follow_path_00117$ -;pff.c:763: res = dir_find(dj, dir); /* Find it */ - push bc - ld l, 6 (ix) - ld h, 7 (ix) - push hl - push bc - call _dir_find - pop af - pop af - ld a, l - pop bc - ld e, a -;pff.c:764: if (res != FR_OK) break; /* Could not find the object */ - ld a, e - or a, a - jp NZ, l_follow_path_00117$ -;pff.c:765: if (dj->fn[11]) break; /* Last segment match. Function completed. */ - pop hl - push hl - inc hl - inc hl - ld d, (hl) - inc hl - ld h, (hl) - ld l, d - push bc - ld bc, #0x000b - add hl, bc - pop bc - ld a, (hl) - or a, a - jp NZ, l_follow_path_00117$ -;pff.c:766: if (!(dir[DIR_Attr] & AM_DIR)) { /* Cannot follow path because it is a file */ - ld l, -8 (ix) - ld h, -7 (ix) - ld de, #0x000b - add hl, de - ld a, (hl) - bit 4, a - jp NZ,l_follow_path_00172$ - jp l_follow_path_00173$ -l_follow_path_00172$: - jp l_follow_path_00113$ -l_follow_path_00173$: -;pff.c:767: res = FR_NO_FILE; break; - ld e, #0x03 - jp l_follow_path_00117$ -l_follow_path_00113$: -;pff.c:769: dj->sclust = get_clust(dir); /* Follow next */ - ld a, -6 (ix) - add a, #0x04 - ld e, a - ld a, -5 (ix) - adc a, #0x00 - ld d, a - push bc - push de - ld l, 6 (ix) - ld h, 7 (ix) - push hl - call _get_clust - pop af - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d - pop de - pop bc - push bc - ld hl, #0x0008 - add hl, sp - ld bc, #0x0004 - ldir - pop bc - jp l_follow_path_00118$ -l_follow_path_00117$: -;pff.c:773: return res; - ld l, e -l_follow_path_00120$: -;pff.c:774: } - ld sp, ix - pop ix - ret -;pff.c:783: static BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record, 3:Error */ -; --------------------------------- -; Function check_fs -; --------------------------------- -_check_fs: - call ___sdcc_enter_ix -;pff.c:788: if (disk_readp(buf, sect, 510, 2)) { /* Read the boot record */ - ld hl, #0x0002 - push hl - ld hl, #0x01fe - push hl - ld l, 8 (ix) - ld h, 9 (ix) - push hl - ld l, 6 (ix) - ld h, 7 (ix) - push hl - ld l, 4 (ix) - ld h, 5 (ix) - push hl - call _disk_readp - ld iy, #10 - add iy, sp - ld sp, iy - ld a, l - or a, a - jp Z, l_check_fs_00102$ -;pff.c:789: return 3; - ld l, #0x03 - jp l_check_fs_00113$ -l_check_fs_00102$: -;pff.c:791: if (ld_word(buf) != 0xAA55) { /* Check record signature */ - ld l, 4 (ix) - ld h, 5 (ix) - push hl - call _ld_word - pop af - ld a, l - sub a, #0x55 - jp NZ,l_check_fs_00135$ - ld a, h - sub a, #0xaa - jp NZ,l_check_fs_00135$ - jp l_check_fs_00111$ -l_check_fs_00135$: -;pff.c:792: return 2; - ld l, #0x02 - jp l_check_fs_00113$ -;pff.c:798: if (PF_FS_FAT32 && !disk_readp(buf, sect, BS_FilSysType32, 2) && ld_word(buf) == 0x4146) { /* Check FAT32 */ -l_check_fs_00111$: - ld hl, #0x0002 - push hl - ld l, #0x52 - push hl - ld l, 8 (ix) - ld h, 9 (ix) - push hl - ld l, 6 (ix) - ld h, 7 (ix) - push hl - ld l, 4 (ix) - ld h, 5 (ix) - push hl - call _disk_readp - ld iy, #10 - add iy, sp - ld sp, iy - ld a, l - or a, a - jp NZ, l_check_fs_00110$ - ld l, 4 (ix) - ld h, 5 (ix) - push hl - call _ld_word - pop af - ld a, l - sub a, #0x46 - jp NZ,l_check_fs_00136$ - ld a, h - sub a, #0x41 - jp NZ,l_check_fs_00136$ - jp l_check_fs_00137$ -l_check_fs_00136$: - jp l_check_fs_00110$ -l_check_fs_00137$: -;pff.c:799: return 0; - ld l, #0x00 - jp l_check_fs_00113$ -l_check_fs_00110$: -;pff.c:801: return 1; - ld l, #0x01 -l_check_fs_00113$: -;pff.c:802: } - pop ix - ret -;pff.c:819: FRESULT pf_mount ( -; --------------------------------- -; Function pf_mount -; --------------------------------- -_pf_mount:: - call ___sdcc_enter_ix - ld hl, #-60 - add hl, sp - ld sp, hl -;pff.c:827: FatFs = 0; - ld hl, #0x0000 - ld (_FatFs), hl -;pff.c:828: if (disk_initialize() & STA_NOINIT) { /* Check if the drive is ready or not */ - call _disk_initialize - ld a, l - rrca - jp C,l_pf_mount_00194$ - jp l_pf_mount_00102$ -l_pf_mount_00194$: -;pff.c:829: return FR_NOT_READY; - ld l, #0x02 - jp l_pf_mount_00137$ -l_pf_mount_00102$: -;pff.c:833: bsect = 0; - xor a, a - ld -60 (ix), a - ld -59 (ix), a - ld -58 (ix), a - ld -57 (ix), a -;pff.c:834: fmt = check_fs(buf, bsect); /* Check sector 0 as an SFD format */ - ld hl, #4 - add hl, sp - ld -20 (ix), l - ld -19 (ix), h - ld c, -20 (ix) - ld b, -19 (ix) - ld hl, #0x0000 - push hl - ld hl, #0x0000 - push hl - push bc - call _check_fs - pop af - pop af - pop af - ld -5 (ix), l -;pff.c:840: if (buf[4]) { /* Is the partition existing? */ - ld a, -20 (ix) - add a, #0x04 - ld -2 (ix), a - ld a, -19 (ix) - adc a, #0x00 - ld -1 (ix), a -;pff.c:835: if (fmt == 1) { /* Not an FAT boot record, it may be FDISK format */ - ld a, -5 (ix) - dec a - jp NZ,l_pf_mount_00195$ - jp l_pf_mount_00196$ -l_pf_mount_00195$: - jp l_pf_mount_00109$ -l_pf_mount_00196$: -;pff.c:837: if (disk_readp(buf, bsect, MBR_Table, 16)) { /* 1st partition entry */ - ld a, -20 (ix) - ld -4 (ix), a - ld a, -19 (ix) - ld -3 (ix), a - ld hl, #0x0010 - push hl - ld hl, #0x01be - push hl - ld hl, #0x0000 - push hl - ld hl, #0x0000 - push hl - ld l, -4 (ix) - ld h, -3 (ix) - push hl - call _disk_readp - ld iy, #10 - add iy, sp - ld sp, iy - ld a, l - or a, a - jp Z, l_pf_mount_00106$ -;pff.c:838: fmt = 3; - ld -5 (ix), #0x03 - jp l_pf_mount_00109$ -l_pf_mount_00106$: -;pff.c:840: if (buf[4]) { /* Is the partition existing? */ - ld l, -2 (ix) - ld h, -1 (ix) - ld a, (hl) - or a, a - jp Z, l_pf_mount_00109$ -;pff.c:841: bsect = ld_dword(&buf[8]); /* Partition offset in LBA */ - ld a, -20 (ix) - add a, #0x08 - ld c, a - ld a, -19 (ix) - adc a, #0x00 - ld b, a - push bc - call _ld_dword - pop af - ld -60 (ix), l - ld -59 (ix), h - ld -58 (ix), e - ld -57 (ix), d -;pff.c:842: fmt = check_fs(buf, bsect); /* Check the partition */ - ld c, -20 (ix) - ld b, -19 (ix) - ld l, -58 (ix) - ld h, -57 (ix) - push hl - ld l, -60 (ix) - ld h, -59 (ix) - push hl - push bc - call _check_fs - pop af - pop af - pop af - ld -5 (ix), l -l_pf_mount_00109$: -;pff.c:846: if (fmt == 3) return FR_DISK_ERR; - ld a, -5 (ix) - sub a, #0x03 - jp NZ,l_pf_mount_00197$ - jp l_pf_mount_00198$ -l_pf_mount_00197$: - jp l_pf_mount_00111$ -l_pf_mount_00198$: - ld l, #0x01 - jp l_pf_mount_00137$ -l_pf_mount_00111$: -;pff.c:847: if (fmt) return FR_NO_FILESYSTEM; /* No valid FAT patition is found */ - ld a, -5 (ix) - or a, a - jp Z, l_pf_mount_00113$ - ld l, #0x06 - jp l_pf_mount_00137$ -l_pf_mount_00113$: -;pff.c:850: if (disk_readp(buf, bsect, 13, sizeof (buf))) return FR_DISK_ERR; - ld c, -20 (ix) - ld b, -19 (ix) - ld hl, #0x0024 - push hl - ld l, #0x0d - push hl - ld l, -58 (ix) - ld h, -57 (ix) - push hl - ld l, -60 (ix) - ld h, -59 (ix) - push hl - push bc - call _disk_readp - ld iy, #10 - add iy, sp - ld sp, iy - ld a, l - or a, a - jp Z, l_pf_mount_00115$ - ld l, #0x01 - jp l_pf_mount_00137$ -l_pf_mount_00115$: -;pff.c:852: fsize = ld_word(buf+BPB_FATSz16-13); /* Number of sectors per FAT */ - ld a, -20 (ix) - add a, #0x09 - ld c, a - ld a, -19 (ix) - adc a, #0x00 - ld b, a - push bc - call _ld_word - pop af - ld c, l - ld b, h - ld e, #0x00 - ld d, #0x00 -;pff.c:853: if (!fsize) fsize = ld_dword(buf+BPB_FATSz32-13); - ld a, d - or a, e - or a, b - or a, c - jp NZ, l_pf_mount_00117$ - ld a, -20 (ix) - add a, #0x17 - ld c, a - ld a, -19 (ix) - adc a, #0x00 - ld b, a - push bc - call _ld_dword - pop af - ld c, l - ld b, h -l_pf_mount_00117$: -;pff.c:855: fsize *= buf[BPB_NumFATs-13]; /* Number of sectors in FAT area */ - ld l, -20 (ix) - ld h, -19 (ix) - inc hl - inc hl - inc hl - ld a, (hl) - ld -6 (ix), a - xor a, a - ld -5 (ix), a - ld -4 (ix), a - ld -3 (ix), a - ld l, -4 (ix) - ld h, -3 (ix) - push hl - ld l, -6 (ix) - ld h, -5 (ix) - push hl - push de - push bc - call __mullong - pop af - pop af - pop af - pop af - ld -18 (ix), l - ld -17 (ix), h - ld -16 (ix), e - ld -15 (ix), d -;pff.c:856: fs->fatbase = bsect + ld_word(buf+BPB_RsvdSecCnt-13); /* FAT start sector (lba) */ - ld c, 4 (ix) - ld b, 5 (ix) - ld hl, #0x000a - add hl, bc - ld -14 (ix), l - ld -13 (ix), h - ld a, -20 (ix) - add a, #0x01 - ld -6 (ix), a - ld a, -19 (ix) - adc a, #0x00 - ld -5 (ix), a - ld e, -6 (ix) - ld d, -5 (ix) - push bc - push de - call _ld_word - pop af - pop bc - ld e, #0x00 - ld d, #0x00 - ld a, -60 (ix) - add a, l - ld -10 (ix), a - ld a, -59 (ix) - adc a, h - ld -9 (ix), a - ld a, -58 (ix) - adc a, e - ld -8 (ix), a - ld a, -57 (ix) - adc a, d - ld -7 (ix), a - push bc - ld e, -14 (ix) - ld d, -13 (ix) - ld hl, #0x0034 - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:857: fs->csize = buf[BPB_SecPerClus-13]; /* Number of sectors per cluster */ - ld hl, #0x0002 - add hl, bc - ld -12 (ix), l - ld -11 (ix), h - ld l, -20 (ix) - ld h, -19 (ix) - ld a, (hl) - ld l, -12 (ix) - ld h, -11 (ix) - ld (hl), a -;pff.c:858: fs->n_rootdir = ld_word(buf+BPB_RootEntCnt-13); /* Nmuber of root directory entries */ - ld hl, #0x0004 - add hl, bc - ld -10 (ix), l - ld -9 (ix), h - ld e, -2 (ix) - ld d, -1 (ix) - push bc - push de - call _ld_word - pop af - ld e, l - ld d, h - pop bc - ld l, -10 (ix) - ld h, -9 (ix) - ld (hl), e - inc hl - ld (hl), d -;pff.c:859: tsect = ld_word(buf+BPB_TotSec16-13); /* Number of sectors on the file system */ - ld a, -20 (ix) - add a, #0x06 - ld e, a - ld a, -19 (ix) - adc a, #0x00 - ld d, a - push bc - push de - call _ld_word - pop af - pop bc - ld e, #0x00 - ld d, #0x00 - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d -;pff.c:860: if (!tsect) tsect = ld_dword(buf+BPB_TotSec32-13); - ld a, d - or a, e - or a, h - or a, l - jp NZ, l_pf_mount_00119$ - ld a, -20 (ix) - add a, #0x13 - ld e, a - ld a, -19 (ix) - adc a, #0x00 - ld d, a - push bc - push de - call _ld_dword - pop af - pop bc - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d -l_pf_mount_00119$: -;pff.c:862: - ld_word(buf+BPB_RsvdSecCnt-13) - fsize - fs->n_rootdir / 16 - ld e, -6 (ix) - ld d, -5 (ix) - push bc - push de - call _ld_word - pop af - pop bc - ld e, #0x00 - ld d, #0x00 - ld a, -4 (ix) - sub a, l - ld l, a - ld a, -3 (ix) - sbc a, h - ld h, a - ld a, -2 (ix) - sbc a, e - ld e, a - ld a, -1 (ix) - sbc a, d - ld d, a - ld a, l - sub a, -18 (ix) - ld -8 (ix), a - ld a, h - sbc a, -17 (ix) - ld -7 (ix), a - ld a, e - sbc a, -16 (ix) - ld -6 (ix), a - ld a, d - sbc a, -15 (ix) - ld -5 (ix), a - ld l, -10 (ix) - ld h, -9 (ix) - ld e, (hl) - inc hl - ld d, (hl) - ld a, #0x04 -l_pf_mount_00199$: - srl d - rr e - dec a - jp NZ, l_pf_mount_00199$ - ld l, #0x00 - ld h, #0x00 - ld a, -8 (ix) - sub a, e - ld -4 (ix), a - ld a, -7 (ix) - sbc a, d - ld -3 (ix), a - ld a, -6 (ix) - sbc a, l - ld -2 (ix), a - ld a, -5 (ix) - sbc a, h - ld -1 (ix), a -;pff.c:863: ) / fs->csize + 2; - ld l, -12 (ix) - ld h, -11 (ix) - ld e, (hl) - ld d, #0x00 - ld l, #0x00 - ld h, #0x00 - push bc - push hl - push de - ld l, -2 (ix) - ld h, -1 (ix) - push hl - ld l, -4 (ix) - ld h, -3 (ix) - push hl - call __divulong - pop af - pop af - pop af - pop af - pop bc - ld a, l - add a, #0x02 - ld -4 (ix), a - ld a, h - adc a, #0x00 - ld -3 (ix), a - ld a, e - adc a, #0x00 - ld -2 (ix), a - ld a, d - adc a, #0x00 - ld -1 (ix), a -;pff.c:864: fs->n_fatent = (CLUST)mclst; - ld hl, #0x0006 - add hl, bc - ex de, hl - push bc - ld hl, #0x003a - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:866: fmt = 0; /* Determine the FAT sub type */ - ld e, #0x00 -;pff.c:869: if (PF_FS_FAT32 && mclst >= 0xFFF7) fmt = FS_FAT32; - ld a, -4 (ix) - sub a, #0xf7 - ld a, -3 (ix) - sbc a, #0xff - ld a, -2 (ix) - sbc a, #0x00 - ld a, -1 (ix) - sbc a, #0x00 - jp C, l_pf_mount_00128$ - ld e, #0x03 -l_pf_mount_00128$: -;pff.c:870: if (!fmt) return FR_NO_FILESYSTEM; - ld a, e - or a, a - jp NZ, l_pf_mount_00131$ - ld l, #0x06 - jp l_pf_mount_00137$ -l_pf_mount_00131$: -;pff.c:871: fs->fs_type = fmt; - ld a, e - ld (bc), a -;pff.c:874: fs->dirbase = ld_dword(buf+(BPB_RootClus-13)); /* Root directory start cluster */ - ld hl, #0x000e - add hl, bc - ex de, hl - ld a, -20 (ix) - add a, #0x1f - ld l, a - ld a, -19 (ix) - adc a, #0x00 - ld h, a - push bc - push de - push hl - call _ld_dword - pop af - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d - pop de - pop bc - push bc - ld hl, #0x003a - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:878: fs->database = fs->fatbase + fsize + fs->n_rootdir / 16; /* Data start sector (lba) */ - ld hl, #0x0012 - add hl, bc - ld -2 (ix), l - ld -1 (ix), h - ld l, -14 (ix) - ld h, -13 (ix) - ld e, (hl) - inc hl - ld d, (hl) - inc hl - inc hl - ld a, (hl) - dec hl - ld l, (hl) - ld h, a - ld a, e - add a, -18 (ix) - ld -6 (ix), a - ld a, d - adc a, -17 (ix) - ld -5 (ix), a - ld a, l - adc a, -16 (ix) - ld -4 (ix), a - ld a, h - adc a, -15 (ix) - ld -3 (ix), a - ld l, -10 (ix) - ld h, -9 (ix) - ld e, (hl) - inc hl - ld d, (hl) - ld a, #0x04 -l_pf_mount_00200$: - srl d - rr e - dec a - jp NZ, l_pf_mount_00200$ - ld l, #0x00 - ld h, #0x00 - ld a, e - add a, -6 (ix) - ld -10 (ix), a - ld a, d - adc a, -5 (ix) - ld -9 (ix), a - ld a, l - adc a, -4 (ix) - ld -8 (ix), a - ld a, h - adc a, -3 (ix) - ld -7 (ix), a - push bc - ld e, -2 (ix) - ld d, -1 (ix) - ld hl, #0x0034 - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:880: fs->flag = 0; - ld e, c - ld d, b - inc de - xor a, a - ld (de), a -;pff.c:881: FatFs = fs; - ld (_FatFs), bc -;pff.c:883: return FR_OK; - ld l, #0x00 -l_pf_mount_00137$: -;pff.c:884: } - ld sp, ix - pop ix - ret -;pff.c:893: FRESULT pf_open ( -; --------------------------------- -; Function pf_open -; --------------------------------- -_pf_open:: - call ___sdcc_enter_ix - ld hl, #-68 - add hl, sp - ld sp, hl -;pff.c:900: FATFS *fs = FatFs; - ld bc, (_FatFs) -;pff.c:903: if (!fs) return FR_NOT_ENABLED; /* Check file system */ - ld a, b - or a, c - jp NZ, l_pf_open_00102$ - ld l, #0x05 - jp l_pf_open_00108$ -l_pf_open_00102$: -;pff.c:905: fs->flag = 0; - ld hl, #0x0001 - add hl, bc - ld -8 (ix), l - ld -7 (ix), h - ld l, -8 (ix) - ld h, -7 (ix) - ld (hl), #0x00 -;pff.c:906: dj.fn = sp; - ld hl, #0 - add hl, sp - ex de, hl - ld hl, #0x0002 - add hl, de - ld -4 (ix), l - ld -3 (ix), h - ld hl, #16 - add hl, sp - ld -2 (ix), l - ld -1 (ix), h - ld l, -4 (ix) - ld h, -3 (ix) - ld a, -2 (ix) - ld (hl), a - inc hl - ld a, -1 (ix) - ld (hl), a -;pff.c:907: res = follow_path(&dj, dir, path); /* Follow the file path */ - ld hl, #28 - add hl, sp - ld -6 (ix), l - ld -5 (ix), h - ld a, -6 (ix) - ld -2 (ix), a - ld a, -5 (ix) - ld -1 (ix), a - push bc - ld l, 4 (ix) - ld h, 5 (ix) - push hl - ld l, -2 (ix) - ld h, -1 (ix) - push hl - push de - call _follow_path - pop af - pop af - pop af - ld a, l - pop bc - ld l, a -;pff.c:908: if (res != FR_OK) return res; /* Follow failed */ - or a, a - jp Z, l_pf_open_00104$ - jp l_pf_open_00108$ -l_pf_open_00104$: -;pff.c:909: if (!dir[0] || (dir[DIR_Attr] & AM_DIR)) return FR_NO_FILE; /* It is a directory */ - ld l, -6 (ix) - ld h, -5 (ix) - ld a, (hl) - or a, a - jp Z, l_pf_open_00105$ - ld l, -6 (ix) - ld h, -5 (ix) - ld de, #0x000b - add hl, de - ld a, (hl) - bit 4, a - jp NZ,l_pf_open_00125$ - jp l_pf_open_00106$ -l_pf_open_00125$: -l_pf_open_00105$: - ld l, #0x03 - jp l_pf_open_00108$ -l_pf_open_00106$: -;pff.c:911: fs->org_clust = get_clust(dir); /* File start cluster */ - ld hl, #0x001e - add hl, bc - ex de, hl - ld l, -6 (ix) - ld h, -5 (ix) - push bc - push de - push hl - call _get_clust - pop af - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d - pop de - pop bc - push bc - ld hl, #0x0042 - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:912: fs->fsize = ld_dword(dir+DIR_FileSize); /* File size */ - ld hl, #0x001a - add hl, bc - ex de, hl - ld a, -6 (ix) - add a, #0x1c - ld l, a - ld a, -5 (ix) - adc a, #0x00 - ld h, a - push bc - push de - push hl - call _ld_dword - pop af - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d - pop de - pop bc - push bc - ld hl, #0x0042 - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:913: fs->fptr = 0; /* File pointer */ - ld hl, #0x0016 - add hl, bc - xor a, a - ld (hl), a - inc hl - ld (hl), a - inc hl - ld (hl), a - inc hl - ld (hl), a -;pff.c:914: fs->flag = FA_OPENED; - ld l, -8 (ix) - ld h, -7 (ix) - ld (hl), #0x01 -;pff.c:916: return FR_OK; - ld l, #0x00 -l_pf_open_00108$: -;pff.c:917: } - ld sp, ix - pop ix - ret -;pff.c:927: FRESULT pf_read ( -; --------------------------------- -; Function pf_read -; --------------------------------- -_pf_read:: - call ___sdcc_enter_ix - ld hl, #-34 - add hl, sp - ld sp, hl -;pff.c:937: BYTE cs, *rbuff = buff; - ld a, 4 (ix) - ld -2 (ix), a - ld a, 5 (ix) - ld -1 (ix), a -;pff.c:938: FATFS *fs = FatFs; - ld hl, (_FatFs) - ld -4 (ix), l - ld -3 (ix), h -;pff.c:941: *br = 0; - ld a, 8 (ix) - ld -30 (ix), a - ld a, 9 (ix) - ld -29 (ix), a - ld l, -30 (ix) - ld h, -29 (ix) - xor a, a - ld (hl), a - inc hl - ld (hl), a -;pff.c:942: if (!fs) return FR_NOT_ENABLED; /* Check file system */ - ld a, -3 (ix) - or a, -4 (ix) - jp NZ, l_pf_read_00102$ - ld l, #0x05 - jp l_pf_read_00127$ -l_pf_read_00102$: -;pff.c:943: if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ - ld a, -4 (ix) - add a, #0x01 - ld -28 (ix), a - ld a, -3 (ix) - adc a, #0x00 - ld -27 (ix), a - ld l, -28 (ix) - ld h, -27 (ix) - ld a, (hl) - rrca - jp C,l_pf_read_00194$ - jp l_pf_read_00195$ -l_pf_read_00194$: - jp l_pf_read_00104$ -l_pf_read_00195$: - ld l, #0x04 - jp l_pf_read_00127$ -l_pf_read_00104$: -;pff.c:945: remain = fs->fsize - fs->fptr; - ld a, -4 (ix) - ld -6 (ix), a - ld a, -3 (ix) - ld -5 (ix), a - ld l, -6 (ix) - ld h, -5 (ix) - ld de, #0x001a - add hl, de - ld a, (hl) - ld -16 (ix), a - inc hl - ld a, (hl) - ld -15 (ix), a - inc hl - ld a, (hl) - ld -14 (ix), a - inc hl - ld a, (hl) - ld -13 (ix), a - ld a, -4 (ix) - add a, #0x16 - ld -26 (ix), a - ld a, -3 (ix) - adc a, #0x00 - ld -25 (ix), a - ld e, -26 (ix) - ld d, -25 (ix) - ld hl, #0x0016 - add hl, sp - ex de, hl - ld bc, #0x0004 - ldir - ld a, -16 (ix) - sub a, -12 (ix) - ld -8 (ix), a - ld a, -15 (ix) - sbc a, -11 (ix) - ld -7 (ix), a - ld a, -14 (ix) - sbc a, -10 (ix) - ld -6 (ix), a - ld a, -13 (ix) - sbc a, -9 (ix) - ld -5 (ix), a -;pff.c:946: if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - ld a, 6 (ix) - ld -12 (ix), a - ld a, 7 (ix) - ld -11 (ix), a - xor a, a - ld -10 (ix), a - ld -9 (ix), a - ld a, -8 (ix) - sub a, -12 (ix) - ld a, -7 (ix) - sbc a, -11 (ix) - ld a, -6 (ix) - sbc a, -10 (ix) - ld a, -5 (ix) - sbc a, -9 (ix) - jp NC, l_pf_read_00140$ - ld a, -8 (ix) - ld 6 (ix), a - ld a, -7 (ix) - ld 7 (ix), a -;pff.c:948: while (btr) { /* Repeat until all data transferred */ -l_pf_read_00140$: - ld a, -4 (ix) - add a, #0x22 - ld -24 (ix), a - ld a, -3 (ix) - adc a, #0x00 - ld -23 (ix), a - ld a, -4 (ix) - ld -22 (ix), a - ld a, -3 (ix) - ld -21 (ix), a - ld a, -4 (ix) - ld -20 (ix), a - ld a, -3 (ix) - ld -19 (ix), a - ld a, -4 (ix) - add a, #0x26 - ld -18 (ix), a - ld a, -3 (ix) - adc a, #0x00 - ld -17 (ix), a -l_pf_read_00124$: - ld a, 7 (ix) - or a, 6 (ix) - jp Z, l_pf_read_00126$ -;pff.c:949: if ((fs->fptr % 512) == 0) { /* On the sector boundary? */ - ld e, -26 (ix) - ld d, -25 (ix) - ld hl, #0x0019 - add hl, sp - ex de, hl - ld bc, #0x0004 - ldir - ld a, -9 (ix) - or a, a - jp NZ,l_pf_read_00196$ - bit 0, -8 (ix) - jp NZ,l_pf_read_00196$ - jp l_pf_read_00197$ -l_pf_read_00196$: - jp l_pf_read_00117$ -l_pf_read_00197$: -;pff.c:950: cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - ld a, -8 (ix) - ld -13 (ix), a - ld a, -7 (ix) - ld -12 (ix), a - ld a, -6 (ix) - ld -11 (ix), a - xor a, a - ld -10 (ix), a - srl -11 (ix) - rr -12 (ix) - rr -13 (ix) - ld l, -20 (ix) - ld h, -19 (ix) - inc hl - inc hl - ld a, (hl) - ld -3 (ix), a - dec -3 (ix) - ld a, -3 (ix) - ld -5 (ix), a - ld a, -13 (ix) - ld -3 (ix), a - ld a, -3 (ix) - and a, -5 (ix) - ld -3 (ix), a - ld a, -3 (ix) - ld -4 (ix), a -;pff.c:951: if (!cs) { /* On the cluster boundary? */ - ld a, -3 (ix) - or a, a - jp NZ, l_pf_read_00113$ -;pff.c:952: if (fs->fptr == 0) { /* On the top of the file? */ - ld a, -6 (ix) - or a, -7 (ix) - or a, -8 (ix) - or a, -9 (ix) - jp NZ, l_pf_read_00108$ -;pff.c:953: clst = fs->org_clust; - ld l, -22 (ix) - ld h, -21 (ix) - ld de, #0x001e - add hl, de - ld a, (hl) - ld -8 (ix), a - inc hl - ld a, (hl) - ld -7 (ix), a - inc hl - ld a, (hl) - ld -6 (ix), a - inc hl - ld a, (hl) - ld -5 (ix), a - jp l_pf_read_00109$ -l_pf_read_00108$: -;pff.c:955: clst = get_fat(fs->curr_clust); - ld l, -24 (ix) - ld h, -23 (ix) - ld c, (hl) - inc hl - ld b, (hl) - inc hl - ld e, (hl) - inc hl - ld d, (hl) - push de - push bc - call _get_fat - pop af - pop af - ld -8 (ix), l - ld -7 (ix), h - ld -6 (ix), e - ld -5 (ix), d -l_pf_read_00109$: -;pff.c:957: if (clst <= 1) ABORT(FR_DISK_ERR); - ld a, #0x01 - cp a, -8 (ix) - ld a, #0x00 - sbc a, -7 (ix) - ld a, #0x00 - sbc a, -6 (ix) - ld a, #0x00 - sbc a, -5 (ix) - jp C, l_pf_read_00111$ - ld l, -28 (ix) - ld h, -27 (ix) - ld (hl), #0x00 - ld l, #0x01 - jp l_pf_read_00127$ -l_pf_read_00111$: -;pff.c:958: fs->curr_clust = clst; /* Update current cluster */ - ld e, -24 (ix) - ld d, -23 (ix) - ld hl, #0x001a - add hl, sp - ld bc, #0x0004 - ldir -l_pf_read_00113$: -;pff.c:960: sect = clust2sect(fs->curr_clust); /* Get current sector */ - ld e, -24 (ix) - ld d, -23 (ix) - ld hl, #0x001a - add hl, sp - ex de, hl - ld bc, #0x0004 - ldir - ld l, -6 (ix) - ld h, -5 (ix) - push hl - ld l, -8 (ix) - ld h, -7 (ix) - push hl - call _clust2sect - pop af - pop af - ld -8 (ix), l - ld -7 (ix), h - ld -6 (ix), e - ld -5 (ix), d - ld hl, #21 - add hl, sp - ex de, hl - ld hl, #26 - add hl, sp - ld bc, #4 - ldir -;pff.c:961: if (!sect) ABORT(FR_DISK_ERR); - ld a, -5 (ix) - or a, -6 (ix) - or a, -7 (ix) - or a, -8 (ix) - jp NZ, l_pf_read_00115$ - ld l, -28 (ix) - ld h, -27 (ix) - ld (hl), #0x00 - ld l, #0x01 - jp l_pf_read_00127$ -l_pf_read_00115$: -;pff.c:962: fs->dsect = sect + cs; - ld a, -4 (ix) - ld -9 (ix), a - xor a, a - ld -8 (ix), a - ld -7 (ix), a - ld -6 (ix), a - ld a, -13 (ix) - add a, -9 (ix) - ld -34 (ix), a - ld a, -12 (ix) - adc a, -8 (ix) - ld -33 (ix), a - ld a, -11 (ix) - adc a, -7 (ix) - ld -32 (ix), a - ld a, -10 (ix) - adc a, -6 (ix) - ld -31 (ix), a - ld e, -18 (ix) - ld d, -17 (ix) - ld hl, #0x0000 - add hl, sp - ld bc, #0x0004 - ldir -l_pf_read_00117$: -;pff.c:945: remain = fs->fsize - fs->fptr; - ld l, -26 (ix) - ld h, -25 (ix) - ld c, (hl) - inc hl - ld a, (hl) -;pff.c:964: rcnt = 512 - (UINT)fs->fptr % 512; /* Get partial sector data from sector buffer */ - ld -4 (ix), c - and a, #0x01 - ld -3 (ix), a - xor a, a - sub a, -4 (ix) - ld -16 (ix), a - ld a, #0x02 - sbc a, -3 (ix) - ld -15 (ix), a -;pff.c:965: if (rcnt > btr) rcnt = btr; - ld a, 6 (ix) - sub a, -16 (ix) - ld a, 7 (ix) - sbc a, -15 (ix) - jp NC, l_pf_read_00119$ - ld a, 6 (ix) - ld -16 (ix), a - ld a, 7 (ix) - ld -15 (ix), a -l_pf_read_00119$: -;pff.c:966: dr = disk_readp(rbuff, fs->dsect, (UINT)fs->fptr % 512, rcnt); - ld l, -18 (ix) - ld h, -17 (ix) - ld c, (hl) - inc hl - ld b, (hl) - inc hl - ld e, (hl) - inc hl - ld d, (hl) - ld l, -16 (ix) - ld h, -15 (ix) - push hl - ld l, -4 (ix) - ld h, -3 (ix) - push hl - push de - push bc - ld l, -2 (ix) - ld h, -1 (ix) - push hl - call _disk_readp - ld iy, #10 - add iy, sp - ld sp, iy - ld a, l -;pff.c:967: if (dr) ABORT(FR_DISK_ERR); - or a, a - jp Z, l_pf_read_00121$ - ld l, -28 (ix) - ld h, -27 (ix) - ld (hl), #0x00 - ld l, #0x01 - jp l_pf_read_00127$ -l_pf_read_00121$: -;pff.c:968: fs->fptr += rcnt; /* Advances file read pointer */ - ld e, -26 (ix) - ld d, -25 (ix) - ld hl, #0x0014 - add hl, sp - ex de, hl - ld bc, #0x0004 - ldir - ld a, -16 (ix) - ld -10 (ix), a - ld a, -15 (ix) - ld -9 (ix), a - xor a, a - ld -8 (ix), a - ld -7 (ix), a - ld a, -14 (ix) - add a, -10 (ix) - ld -6 (ix), a - ld a, -13 (ix) - adc a, -9 (ix) - ld -5 (ix), a - ld a, -12 (ix) - adc a, -8 (ix) - ld -4 (ix), a - ld a, -11 (ix) - adc a, -7 (ix) - ld -3 (ix), a - ld e, -26 (ix) - ld d, -25 (ix) - ld hl, #0x001c - add hl, sp - ld bc, #0x0004 - ldir -;pff.c:969: btr -= rcnt; *br += rcnt; /* Update read counter */ - ld a, 6 (ix) - sub a, -16 (ix) - ld 6 (ix), a - ld a, 7 (ix) - sbc a, -15 (ix) - ld 7 (ix), a - ld l, -30 (ix) - ld h, -29 (ix) - ld a, (hl) - ld -6 (ix), a - inc hl - ld a, (hl) - ld -5 (ix), a - ld a, -6 (ix) - add a, -16 (ix) - ld -4 (ix), a - ld a, -5 (ix) - adc a, -15 (ix) - ld -3 (ix), a - ld l, -30 (ix) - ld h, -29 (ix) - ld a, -4 (ix) - ld (hl), a - inc hl - ld a, -3 (ix) - ld (hl), a -;pff.c:970: if (rbuff) rbuff += rcnt; /* Advances the data pointer if destination is memory */ - ld a, -1 (ix) - or a, -2 (ix) - jp Z, l_pf_read_00124$ - ld a, -16 (ix) - add a, -2 (ix) - ld -2 (ix), a - ld a, -15 (ix) - adc a, -1 (ix) - ld -1 (ix), a - jp l_pf_read_00124$ -l_pf_read_00126$: -;pff.c:973: return FR_OK; - ld l, #0x00 -l_pf_read_00127$: -;pff.c:974: } - ld sp, ix - pop ix - ret -;pff.c:984: FRESULT pf_write ( -; --------------------------------- -; Function pf_write -; --------------------------------- -_pf_write:: - call ___sdcc_enter_ix - ld hl, #-27 - add hl, sp - ld sp, hl -;pff.c:992: const BYTE *p = buff; - ld a, 4 (ix) - ld -2 (ix), a - ld a, 5 (ix) - ld -1 (ix), a -;pff.c:995: FATFS *fs = FatFs; - ld hl, (_FatFs) - ld -23 (ix), l - ld -22 (ix), h -;pff.c:998: *bw = 0; - ld a, 8 (ix) - ld -21 (ix), a - ld a, 9 (ix) - ld -20 (ix), a - ld l, -21 (ix) - ld h, -20 (ix) - xor a, a - ld (hl), a - inc hl - ld (hl), a -;pff.c:999: if (!fs) return FR_NOT_ENABLED; /* Check file system */ - ld a, -22 (ix) - or a, -23 (ix) - jp NZ, l_pf_write_00102$ - ld l, #0x05 - jp l_pf_write_00139$ -l_pf_write_00102$: -;pff.c:1000: if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ - ld a, -23 (ix) - add a, #0x01 - ld -19 (ix), a - ld a, -22 (ix) - adc a, #0x00 - ld -18 (ix), a - ld l, -19 (ix) - ld h, -18 (ix) - ld a, (hl) - bit 0, a - jp NZ,l_pf_write_00236$ - jp l_pf_write_00237$ -l_pf_write_00236$: - jp l_pf_write_00104$ -l_pf_write_00237$: - ld l, #0x04 - jp l_pf_write_00139$ -l_pf_write_00104$: -;pff.c:1003: if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR); - and a, #0x40 - ld c, a - ld b, #0x00 -;pff.c:1002: if (!btw) { /* Finalize request */ - ld a, 7 (ix) - or a, 6 (ix) - jp NZ, l_pf_write_00111$ -;pff.c:1003: if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR); - ld a, b - or a, c - jp Z, l_pf_write_00106$ - ld hl, #0x0000 - push hl - ld hl, #0x0000 - push hl - ld l, #0x00 - push hl - call _disk_writep - pop af - pop af - pop af - ld a, l - or a, a - jp Z, l_pf_write_00106$ - ld l, -19 (ix) - ld h, -18 (ix) - ld (hl), #0x00 - ld l, #0x01 - jp l_pf_write_00139$ -l_pf_write_00106$: -;pff.c:1004: fs->flag &= ~FA__WIP; - ld l, -19 (ix) - ld h, -18 (ix) - ld a, (hl) - res 6, a - ld l, -19 (ix) - ld h, -18 (ix) - ld (hl), a -;pff.c:1005: return FR_OK; - ld l, #0x00 - jp l_pf_write_00139$ -l_pf_write_00111$: -;pff.c:1008: fs->fptr &= 0xFFFFFE00; - ld a, -23 (ix) - add a, #0x16 - ld -4 (ix), a - ld a, -22 (ix) - adc a, #0x00 - ld -3 (ix), a -;pff.c:1007: if (!(fs->flag & FA__WIP)) { /* Round-down fptr to the sector boundary */ - ld a, b - or a, c - jp NZ, l_pf_write_00112$ -;pff.c:1008: fs->fptr &= 0xFFFFFE00; - ld e, -4 (ix) - ld d, -3 (ix) - ld hl, #0x000f - add hl, sp - ex de, hl - ld bc, #0x0004 - ldir - ld -8 (ix), #0x00 - ld a, -11 (ix) - and a, #0xfe - ld -7 (ix), a - ld a, -10 (ix) - ld -6 (ix), a - ld a, -9 (ix) - ld -5 (ix), a - ld e, -4 (ix) - ld d, -3 (ix) - ld hl, #0x0013 - add hl, sp - ld bc, #0x0004 - ldir -l_pf_write_00112$: -;pff.c:1011: remain = fs->fsize - fs->fptr; - ld l, -23 (ix) - ld h, -22 (ix) - ld de, #0x001a - add hl, de - ld c, (hl) - inc hl - ld b, (hl) - inc hl - ld e, (hl) - inc hl - ld d, (hl) - ld a, -4 (ix) - ld -17 (ix), a - ld a, -3 (ix) - ld -16 (ix), a - push de - push bc - ld e, -4 (ix) - ld d, -3 (ix) - ld hl, #0x0019 - add hl, sp - ex de, hl - ld bc, #0x0004 - ldir - pop bc - pop de - ld a, c - sub a, -6 (ix) - ld c, a - ld a, b - sbc a, -5 (ix) - ld b, a - ld a, e - sbc a, -4 (ix) - ld e, a - ld a, d - sbc a, -3 (ix) - ld d, a -;pff.c:1012: if (btw > remain) btw = (UINT)remain; /* Truncate btw by remaining bytes */ - ld a, 6 (ix) - ld -6 (ix), a - ld a, 7 (ix) - ld -5 (ix), a - xor a, a - ld -4 (ix), a - ld -3 (ix), a - ld a, c - sub a, -6 (ix) - ld a, b - sbc a, -5 (ix) - ld a, e - sbc a, -4 (ix) - ld a, d - sbc a, -3 (ix) - jp NC, l_pf_write_00157$ - ld 6 (ix), c - ld 7 (ix), b -;pff.c:1014: while (btw) { /* Repeat until all data transferred */ -l_pf_write_00157$: - ld a, -23 (ix) - add a, #0x22 - ld -15 (ix), a - ld a, -22 (ix) - adc a, #0x00 - ld -14 (ix), a - ld a, -23 (ix) - ld -13 (ix), a - ld a, -22 (ix) - ld -12 (ix), a - ld a, -23 (ix) - ld -11 (ix), a - ld a, -22 (ix) - ld -10 (ix), a -l_pf_write_00136$: - ld a, 7 (ix) - or a, 6 (ix) - jp Z, l_pf_write_00138$ -;pff.c:1015: if ((UINT)fs->fptr % 512 == 0) { /* On the sector boundary? */ - ld l, -17 (ix) - ld h, -16 (ix) - ld c, (hl) - inc hl - ld b, (hl) - inc hl - ld e, (hl) - inc hl - ld d, (hl) - ld l, c - ld h, b - ld a, l - or a, a - jp NZ,l_pf_write_00238$ - bit 0, h - jp NZ,l_pf_write_00238$ - jp l_pf_write_00239$ -l_pf_write_00238$: - jp l_pf_write_00127$ -l_pf_write_00239$: -;pff.c:1016: cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - ld -6 (ix), b - ld -5 (ix), e - ld -4 (ix), d - xor a, a - ld -3 (ix), a - srl -4 (ix) - rr -5 (ix) - rr -6 (ix) - ld l, -11 (ix) - ld h, -10 (ix) - inc hl - inc hl - ld l, (hl) - dec l - ld a, -6 (ix) - and a, l - ld -9 (ix), a -;pff.c:1017: if (!cs) { /* On the cluster boundary? */ - or a, a - jp NZ, l_pf_write_00121$ -;pff.c:1018: if (fs->fptr == 0) { /* On the top of the file? */ - ld a, d - or a, e - or a, b - or a, c - jp NZ, l_pf_write_00116$ -;pff.c:1019: clst = fs->org_clust; - ld l, -13 (ix) - ld h, -12 (ix) - ld de, #0x001e - add hl, de - ld a, (hl) - ld -6 (ix), a - inc hl - ld a, (hl) - ld -5 (ix), a - inc hl - ld a, (hl) - ld -4 (ix), a - inc hl - ld a, (hl) - ld -3 (ix), a - jp l_pf_write_00117$ -l_pf_write_00116$: -;pff.c:1021: clst = get_fat(fs->curr_clust); - ld l, -15 (ix) - ld h, -14 (ix) - ld c, (hl) - inc hl - ld b, (hl) - inc hl - ld e, (hl) - inc hl - ld d, (hl) - push de - push bc - call _get_fat - pop af - pop af - ld -6 (ix), l - ld -5 (ix), h - ld -4 (ix), e - ld -3 (ix), d -l_pf_write_00117$: -;pff.c:1023: if (clst <= 1) ABORT(FR_DISK_ERR); - ld a, #0x01 - cp a, -6 (ix) - ld a, #0x00 - sbc a, -5 (ix) - ld a, #0x00 - sbc a, -4 (ix) - ld a, #0x00 - sbc a, -3 (ix) - jp C, l_pf_write_00119$ - ld l, -19 (ix) - ld h, -18 (ix) - ld (hl), #0x00 - ld l, #0x01 - jp l_pf_write_00139$ -l_pf_write_00119$: -;pff.c:1024: fs->curr_clust = clst; /* Update current cluster */ - ld e, -15 (ix) - ld d, -14 (ix) - ld hl, #0x0015 - add hl, sp - ld bc, #0x0004 - ldir -l_pf_write_00121$: -;pff.c:1026: sect = clust2sect(fs->curr_clust); /* Get current sector */ - ld l, -15 (ix) - ld h, -14 (ix) - ld c, (hl) - inc hl - ld b, (hl) - inc hl - ld e, (hl) - inc hl - ld d, (hl) - push de - push bc - call _clust2sect - pop af - pop af - ld -8 (ix), l - ld -7 (ix), h - ld -6 (ix), e - ld -5 (ix), d -;pff.c:1027: if (!sect) ABORT(FR_DISK_ERR); - ld a, d - or a, e - or a, h - or a, l - jp NZ, l_pf_write_00123$ - ld l, -19 (ix) - ld h, -18 (ix) - ld (hl), #0x00 - ld l, #0x01 - jp l_pf_write_00139$ -l_pf_write_00123$: -;pff.c:1028: fs->dsect = sect + cs; - ld a, -23 (ix) - add a, #0x26 - ld -4 (ix), a - ld a, -22 (ix) - adc a, #0x00 - ld -3 (ix), a - ld c, -9 (ix) - ld b, #0x00 - ld e, #0x00 - ld d, #0x00 - ld a, -8 (ix) - add a, c - ld c, a - ld a, -7 (ix) - adc a, b - ld b, a - ld a, -6 (ix) - adc a, e - ld e, a - ld a, -5 (ix) - adc a, d - ld d, a - ld l, -4 (ix) - ld h, -3 (ix) - ld (hl), c - inc hl - ld (hl), b - inc hl - ld (hl), e - inc hl - ld (hl), d -;pff.c:1029: if (disk_writep(0, fs->dsect)) ABORT(FR_DISK_ERR); /* Initiate a sector write operation */ - push de - push bc - ld hl, #0x0000 - push hl - call _disk_writep - pop af - pop af - pop af - ld a, l - or a, a - jp Z, l_pf_write_00125$ - ld l, -19 (ix) - ld h, -18 (ix) - ld (hl), #0x00 - ld l, #0x01 - jp l_pf_write_00139$ -l_pf_write_00125$: -;pff.c:1030: fs->flag |= FA__WIP; - ld l, -19 (ix) - ld h, -18 (ix) - ld a, (hl) - set 6, a - ld l, -19 (ix) - ld h, -18 (ix) - ld (hl), a -l_pf_write_00127$: -;pff.c:1032: wcnt = 512 - (UINT)fs->fptr % 512; /* Number of bytes to write to the sector */ - ld l, -17 (ix) - ld h, -16 (ix) - ld c, (hl) - inc hl - ld a, (hl) - and a, #0x01 - ld b, a - xor a, a - sub a, c - ld c, a - ld a, #0x02 - sbc a, b - ld e, a -;pff.c:1033: if (wcnt > btw) wcnt = btw; - ld a, 6 (ix) - sub a, c - ld a, 7 (ix) - sbc a, e - jp NC, l_pf_write_00129$ - ld c, 6 (ix) - ld e, 7 (ix) -l_pf_write_00129$: -;pff.c:1034: if (disk_writep(p, wcnt)) ABORT(FR_DISK_ERR); /* Send data to the sector */ - ld -27 (ix), c - ld -26 (ix), e - xor a, a - ld -25 (ix), a - ld -24 (ix), a - push bc - push de - ld l, -25 (ix) - ld h, -24 (ix) - push hl - ld l, -27 (ix) - ld h, -26 (ix) - push hl - ld l, -2 (ix) - ld h, -1 (ix) - push hl - call _disk_writep - pop af - pop af - pop af - ld a, l - pop de - pop bc - or a, a - jp Z, l_pf_write_00131$ - ld l, -19 (ix) - ld h, -18 (ix) - ld (hl), #0x00 - ld l, #0x01 - jp l_pf_write_00139$ -l_pf_write_00131$: -;pff.c:1035: fs->fptr += wcnt; p += wcnt; /* Update pointers and counters */ - ld l, -17 (ix) - ld h, -16 (ix) - ld b, (hl) - inc hl - ld d, (hl) - inc hl - inc hl - ld a, (hl) - dec hl - ld l, (hl) - ld h, a - ld a, b - add a, -27 (ix) - ld -6 (ix), a - ld a, d - adc a, -26 (ix) - ld -5 (ix), a - ld a, l - adc a, -25 (ix) - ld -4 (ix), a - ld a, h - adc a, -24 (ix) - ld -3 (ix), a - push de - push bc - ld e, -17 (ix) - ld d, -16 (ix) - ld hl, #0x0019 - add hl, sp - ld bc, #0x0004 - ldir - pop bc - pop de - ld a, -2 (ix) - add a, c - ld -2 (ix), a - ld a, -1 (ix) - adc a, e - ld -1 (ix), a -;pff.c:1036: btw -= wcnt; *bw += wcnt; - ld a, 6 (ix) - sub a, c - ld 6 (ix), a - ld a, 7 (ix) - sbc a, e - ld 7 (ix), a - ld l, -21 (ix) - ld h, -20 (ix) - ld b, (hl) - inc hl - ld d, (hl) - ld a, b - add a, c - ld -8 (ix), a - ld a, d - adc a, e - ld -7 (ix), a - ld l, -21 (ix) - ld h, -20 (ix) - ld a, -8 (ix) - ld (hl), a - inc hl - ld a, -7 (ix) - ld (hl), a -;pff.c:1037: if ((UINT)fs->fptr % 512 == 0) { - ld a, -6 (ix) - ld -4 (ix), a - ld a, -5 (ix) - ld -3 (ix), a - ld a, -4 (ix) - or a, a - jp NZ,l_pf_write_00242$ - bit 0, -3 (ix) - jp NZ,l_pf_write_00242$ - jp l_pf_write_00243$ -l_pf_write_00242$: - jp l_pf_write_00136$ -l_pf_write_00243$: -;pff.c:1038: if (disk_writep(0, 0)) ABORT(FR_DISK_ERR); /* Finalize the currtent secter write operation */ - ld hl, #0x0000 - push hl - ld hl, #0x0000 - push hl - ld l, #0x00 - push hl - call _disk_writep - pop af - pop af - pop af - ld a, l - or a, a - jp Z, l_pf_write_00133$ - ld l, -19 (ix) - ld h, -18 (ix) - ld (hl), #0x00 - ld l, #0x01 - jp l_pf_write_00139$ -l_pf_write_00133$: -;pff.c:1039: fs->flag &= ~FA__WIP; - ld l, -19 (ix) - ld h, -18 (ix) - ld a, (hl) - res 6, a - ld l, -19 (ix) - ld h, -18 (ix) - ld (hl), a - jp l_pf_write_00136$ -l_pf_write_00138$: -;pff.c:1043: return FR_OK; - ld l, #0x00 -l_pf_write_00139$: -;pff.c:1044: } - ld sp, ix - pop ix - ret -;pff.c:1054: FRESULT pf_lseek ( -; --------------------------------- -; Function pf_lseek -; --------------------------------- -_pf_lseek:: - call ___sdcc_enter_ix - ld hl, #-26 - add hl, sp - ld sp, hl -;pff.c:1060: FATFS *fs = FatFs; - ld bc, (_FatFs) -;pff.c:1063: if (!fs) return FR_NOT_ENABLED; /* Check file system */ - ld a, b - or a, c - jp NZ, l_pf_lseek_00102$ - ld l, #0x05 - jp l_pf_lseek_00121$ -l_pf_lseek_00102$: -;pff.c:1064: if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ - ld hl, #0x0001 - add hl, bc - ld -22 (ix), l - ld -21 (ix), h - ld l, -22 (ix) - ld h, -21 (ix) - ld a, (hl) - rrca - jp C,l_pf_lseek_00173$ - jp l_pf_lseek_00174$ -l_pf_lseek_00173$: - jp l_pf_lseek_00104$ -l_pf_lseek_00174$: - ld l, #0x04 - jp l_pf_lseek_00121$ -l_pf_lseek_00104$: -;pff.c:1066: if (ofs > fs->fsize) ofs = fs->fsize; /* Clip offset with the file size */ - ld l, c - ld h, b - ld de, #0x001a - add hl, de - ld a, (hl) - ld -4 (ix), a - inc hl - ld a, (hl) - ld -3 (ix), a - inc hl - ld a, (hl) - ld -2 (ix), a - inc hl - ld a, (hl) - ld -1 (ix), a - ld a, -4 (ix) - sub a, 4 (ix) - ld a, -3 (ix) - sbc a, 5 (ix) - ld a, -2 (ix) - sbc a, 6 (ix) - ld a, -1 (ix) - sbc a, 7 (ix) - jp NC, l_pf_lseek_00106$ - push bc - ld hl, #32 - add hl, sp - ex de, hl - ld hl, #24 - add hl, sp - ld bc, #4 - ldir - pop bc -l_pf_lseek_00106$: -;pff.c:1067: ifptr = fs->fptr; - ld hl, #0x0016 - add hl, bc - ld -20 (ix), l - ld -19 (ix), h - push bc - ld e, -20 (ix) - ld d, -19 (ix) - ld hl, #0x0002 - add hl, sp - ex de, hl - ld bc, #0x0004 - ldir - pop bc -;pff.c:1068: fs->fptr = 0; - ld l, -20 (ix) - ld h, -19 (ix) - xor a, a - ld (hl), a - inc hl - ld (hl), a - inc hl - ld (hl), a - inc hl - ld (hl), a -;pff.c:1069: if (ofs > 0) { - ld a, 7 (ix) - or a, 6 (ix) - or a, 5 (ix) - or a, 4 (ix) - jp Z, l_pf_lseek_00120$ -;pff.c:1070: bcs = (DWORD)fs->csize * 512; /* Cluster size (byte) */ - ld hl, #0x0002 - add hl, bc - ld -18 (ix), l - ld -17 (ix), h - ld l, -18 (ix) - ld h, -17 (ix) - ld e, (hl) - ld d, #0x00 - ld l, #0x00 - ld h, #0x00 - ld -15 (ix), e - ld -14 (ix), d - ld -13 (ix), l - ld -16 (ix), #0x00 - sla -15 (ix) - rl -14 (ix) - rl -13 (ix) -;pff.c:1075: clst = fs->curr_clust; - ld hl, #0x0022 - add hl, bc - ld -12 (ix), l - ld -11 (ix), h -;pff.c:1071: if (ifptr > 0 && - ld a, -23 (ix) - or a, -24 (ix) - or a, -25 (ix) - or a, -26 (ix) - jp Z, l_pf_lseek_00108$ -;pff.c:1072: (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - ld a, 4 (ix) - add a, #0xff - ld -4 (ix), a - ld a, 5 (ix) - adc a, #0xff - ld -3 (ix), a - ld a, 6 (ix) - adc a, #0xff - ld -2 (ix), a - ld a, 7 (ix) - adc a, #0xff - ld -1 (ix), a - push bc - ld l, -14 (ix) - ld h, -13 (ix) - push hl - ld l, -16 (ix) - ld h, -15 (ix) - push hl - ld l, -2 (ix) - ld h, -1 (ix) - push hl - ld l, -4 (ix) - ld h, -3 (ix) - push hl - call __divulong - pop af - pop af - pop af - pop af - ld -8 (ix), l - ld -7 (ix), h - ld -6 (ix), e - ld -5 (ix), d - pop bc - ld a, -26 (ix) - add a, #0xff - ld -4 (ix), a - ld a, -25 (ix) - adc a, #0xff - ld -3 (ix), a - ld a, -24 (ix) - adc a, #0xff - ld -2 (ix), a - ld a, -23 (ix) - adc a, #0xff - ld -1 (ix), a - push bc - ld l, -14 (ix) - ld h, -13 (ix) - push hl - ld l, -16 (ix) - ld h, -15 (ix) - push hl - ld l, -2 (ix) - ld h, -1 (ix) - push hl - ld l, -4 (ix) - ld h, -3 (ix) - push hl - call __divulong - pop af - pop af - pop af - pop af - pop bc - ld a, -8 (ix) - sub a, l - ld a, -7 (ix) - sbc a, h - ld a, -6 (ix) - sbc a, e - ld a, -5 (ix) - sbc a, d - jp C, l_pf_lseek_00108$ -;pff.c:1073: fs->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ld a, -16 (ix) - add a, #0xff - ld e, a - ld a, -15 (ix) - adc a, #0xff - ld d, a - ld a, -14 (ix) - adc a, #0xff - ld l, a - ld a, -13 (ix) - adc a, #0xff - cpl - ld h, a - ld a, e - cpl - push af - ld a, d - cpl - ld e, a - ld a, l - cpl - ld l, a - pop af - and a, -4 (ix) - ld -8 (ix), a - ld a, e - and a, -3 (ix) - ld -7 (ix), a - ld a, l - and a, -2 (ix) - ld -6 (ix), a - ld a, h - and a, -1 (ix) - ld -5 (ix), a - push bc - ld e, -20 (ix) - ld d, -19 (ix) - ld hl, #0x0014 - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:1074: ofs -= fs->fptr; - ld a, 4 (ix) - sub a, -8 (ix) - ld 4 (ix), a - ld a, 5 (ix) - sbc a, -7 (ix) - ld 5 (ix), a - ld a, 6 (ix) - sbc a, -6 (ix) - ld 6 (ix), a - ld a, 7 (ix) - sbc a, -5 (ix) - ld 7 (ix), a -;pff.c:1075: clst = fs->curr_clust; - push bc - ld e, -12 (ix) - ld d, -11 (ix) - ld hl, #0x0012 - add hl, sp - ex de, hl - ld bc, #0x0004 - ldir - pop bc - jp l_pf_lseek_00131$ -l_pf_lseek_00108$: -;pff.c:1077: clst = fs->org_clust; /* start from the first cluster */ - ld l, c - ld h, b - ld de, #0x001e - add hl, de - ld a, (hl) - ld -10 (ix), a - inc hl - ld a, (hl) - ld -9 (ix), a - inc hl - ld a, (hl) - ld -8 (ix), a - inc hl - ld a, (hl) - ld -7 (ix), a -;pff.c:1078: fs->curr_clust = clst; - push bc - ld e, -12 (ix) - ld d, -11 (ix) - ld hl, #0x0012 - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:1080: while (ofs > bcs) { /* Cluster following loop */ -l_pf_lseek_00131$: - ld -6 (ix), c - ld -5 (ix), b -l_pf_lseek_00114$: - ld a, -16 (ix) - sub a, 4 (ix) - ld a, -15 (ix) - sbc a, 5 (ix) - ld a, -14 (ix) - sbc a, 6 (ix) - ld a, -13 (ix) - sbc a, 7 (ix) - jp NC, l_pf_lseek_00116$ -;pff.c:1081: clst = get_fat(clst); /* Follow cluster chain */ - push bc - ld l, -8 (ix) - ld h, -7 (ix) - push hl - ld l, -10 (ix) - ld h, -9 (ix) - push hl - call _get_fat - pop af - pop af - pop bc - ld -10 (ix), l - ld -9 (ix), h - ld -8 (ix), e - ld -7 (ix), d -;pff.c:1082: if (clst <= 1 || clst >= fs->n_fatent) ABORT(FR_DISK_ERR); - ld a, #0x01 - cp a, -10 (ix) - ld a, #0x00 - sbc a, -9 (ix) - ld a, #0x00 - sbc a, -8 (ix) - ld a, #0x00 - sbc a, -7 (ix) - jp NC, l_pf_lseek_00111$ - ld l, -6 (ix) - ld h, -5 (ix) - ld de, #0x0006 - add hl, de - ld e, (hl) - inc hl - ld d, (hl) - inc hl - inc hl - ld a, (hl) - dec hl - ld l, (hl) - ld h, a - ld a, -10 (ix) - sub a, e - ld a, -9 (ix) - sbc a, d - ld a, -8 (ix) - sbc a, l - ld a, -7 (ix) - sbc a, h - jp C, l_pf_lseek_00112$ -l_pf_lseek_00111$: - ld l, -22 (ix) - ld h, -21 (ix) - ld (hl), #0x00 - ld l, #0x01 - jp l_pf_lseek_00121$ -l_pf_lseek_00112$: -;pff.c:1083: fs->curr_clust = clst; - push bc - ld e, -12 (ix) - ld d, -11 (ix) - ld hl, #0x0012 - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:1084: fs->fptr += bcs; - ld l, -20 (ix) - ld h, -19 (ix) - ld e, (hl) - inc hl - ld d, (hl) - inc hl - inc hl - ld a, (hl) - dec hl - ld l, (hl) - ld h, a - ld a, e - add a, -16 (ix) - ld -4 (ix), a - ld a, d - adc a, -15 (ix) - ld -3 (ix), a - ld a, l - adc a, -14 (ix) - ld -2 (ix), a - ld a, h - adc a, -13 (ix) - ld -1 (ix), a - push bc - ld e, -20 (ix) - ld d, -19 (ix) - ld hl, #0x0018 - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:1085: ofs -= bcs; - ld a, 4 (ix) - sub a, -16 (ix) - ld 4 (ix), a - ld a, 5 (ix) - sbc a, -15 (ix) - ld 5 (ix), a - ld a, 6 (ix) - sbc a, -14 (ix) - ld 6 (ix), a - ld a, 7 (ix) - sbc a, -13 (ix) - ld 7 (ix), a - jp l_pf_lseek_00114$ -l_pf_lseek_00116$: -;pff.c:1087: fs->fptr += ofs; - push bc - ld e, -20 (ix) - ld d, -19 (ix) - ld hl, #0x000e - add hl, sp - ex de, hl - ld bc, #0x0004 - ldir - pop bc - ld a, -14 (ix) - add a, 4 (ix) - ld -4 (ix), a - ld a, -13 (ix) - adc a, 5 (ix) - ld -3 (ix), a - ld a, -12 (ix) - adc a, 6 (ix) - ld -2 (ix), a - ld a, -11 (ix) - adc a, 7 (ix) - ld -1 (ix), a - push bc - ld e, -20 (ix) - ld d, -19 (ix) - ld hl, #0x0018 - add hl, sp - ld bc, #0x0004 - ldir - pop bc -;pff.c:1088: sect = clust2sect(clst); /* Current sector */ - push bc - ld l, -8 (ix) - ld h, -7 (ix) - push hl - ld l, -10 (ix) - ld h, -9 (ix) - push hl - call _clust2sect - pop af - pop af - pop bc - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d -;pff.c:1089: if (!sect) ABORT(FR_DISK_ERR); - ld a, d - or a, e - or a, h - or a, l - jp NZ, l_pf_lseek_00118$ - ld l, -22 (ix) - ld h, -21 (ix) - ld (hl), #0x00 - ld l, #0x01 - jp l_pf_lseek_00121$ -l_pf_lseek_00118$: -;pff.c:1090: fs->dsect = sect + (fs->fptr / 512 & (fs->csize - 1)); - ld hl, #0x0026 - add hl, bc - ld -6 (ix), l - ld -5 (ix), h - ld l, -20 (ix) - ld h, -19 (ix) - ld c, (hl) - inc hl - ld b, (hl) - inc hl - ld d, (hl) - inc hl - ld e, (hl) - ld c, b - ld b, d - ld d, #0x00 - srl e - rr b - rr c - ld l, -18 (ix) - ld h, -17 (ix) - ld l, (hl) - ld h, #0x00 - dec hl - ld -10 (ix), l - ld a, h - ld -9 (ix), a - rla - sbc a, a - ld -8 (ix), a - ld -7 (ix), a - ld a, c - and a, -10 (ix) - ld c, a - ld a, b - and a, -9 (ix) - ld b, a - ld a, e - and a, -8 (ix) - ld e, a - ld a, d - and a, -7 (ix) - ld d, a - ld a, c - add a, -4 (ix) - ld c, a - ld a, b - adc a, -3 (ix) - ld b, a - ld a, e - adc a, -2 (ix) - ld e, a - ld a, d - adc a, -1 (ix) - ld d, a - ld l, -6 (ix) - ld h, -5 (ix) - ld (hl), c - inc hl - ld (hl), b - inc hl - ld (hl), e - inc hl - ld (hl), d -l_pf_lseek_00120$: -;pff.c:1093: return FR_OK; - ld l, #0x00 -l_pf_lseek_00121$: -;pff.c:1094: } - ld sp, ix - pop ix - ret -;pff.c:1104: FRESULT pf_opendir ( -; --------------------------------- -; Function pf_opendir -; --------------------------------- -_pf_opendir:: - call ___sdcc_enter_ix - ld hl, #-48 - add hl, sp - ld sp, hl -;pff.c:1114: if (!fs) { /* Check file system */ - ld iy, #_FatFs - ld a, 1 (iy) - or a, 0 (iy) - jp NZ, l_pf_opendir_00111$ -;pff.c:1115: res = FR_NOT_ENABLED; - ld c, #0x05 - jp l_pf_opendir_00112$ -l_pf_opendir_00111$: -;pff.c:1117: dj->fn = sp; - ld a, 4 (ix) - ld -2 (ix), a - ld a, 5 (ix) - ld -1 (ix), a - ld c, -2 (ix) - ld b, -1 (ix) - inc bc - inc bc - ld hl, #0 - add hl, sp - ex de, hl - ld a, e - ld (bc), a - inc bc - ld a, d - ld (bc), a -;pff.c:1118: res = follow_path(dj, dir, path); /* Follow the path to the directory */ - ld hl, #12 - add hl, sp - ex de, hl - ld c, e - ld b, d - push de - ld l, 6 (ix) - ld h, 7 (ix) - push hl - push bc - ld l, -2 (ix) - ld h, -1 (ix) - push hl - call _follow_path - pop af - pop af - pop af - ld a, l - pop de - ld c, a -;pff.c:1119: if (res == FR_OK) { /* Follow completed */ - ld a, c - or a, a - jp NZ, l_pf_opendir_00112$ -;pff.c:1120: if (dir[0]) { /* It is not the root dir */ - ld a, (de) - or a, a - jp Z, l_pf_opendir_00105$ -;pff.c:1121: if (dir[DIR_Attr] & AM_DIR) { /* The object is a directory */ - ld l, e - ld h, d - push bc - ld bc, #0x000b - add hl, bc - pop bc - ld a, (hl) - bit 4, a - jp NZ,l_pf_opendir_00140$ - jp l_pf_opendir_00102$ -l_pf_opendir_00140$: -;pff.c:1122: dj->sclust = get_clust(dir); - ld a, -2 (ix) - add a, #0x04 - ld l, a - ld a, -1 (ix) - adc a, #0x00 - ld h, a - push hl - push bc - push de - call _get_clust - pop af - ld -4 (ix), l - ld -3 (ix), h - ld -2 (ix), e - ld -1 (ix), d - pop bc - pop hl - push bc - ld e, l - ld d, h - ld hl, #0x002e - add hl, sp - ld bc, #0x0004 - ldir - pop bc - jp l_pf_opendir_00105$ -l_pf_opendir_00102$: -;pff.c:1124: res = FR_NO_FILE; - ld c, #0x03 -l_pf_opendir_00105$: -;pff.c:1127: if (res == FR_OK) { - ld a, c - or a, a - jp NZ, l_pf_opendir_00112$ -;pff.c:1128: res = dir_rewind(dj); /* Rewind dir */ - ld l, 4 (ix) - ld h, 5 (ix) - push hl - call _dir_rewind - pop af - ld a, l - ld c, a -l_pf_opendir_00112$: -;pff.c:1133: return res; - ld l, c -l_pf_opendir_00113$: -;pff.c:1134: } - ld sp, ix - pop ix - ret -;pff.c:1143: FRESULT pf_readdir ( -; --------------------------------- -; Function pf_readdir -; --------------------------------- -_pf_readdir:: - call ___sdcc_enter_ix - ld hl, #-46 - add hl, sp - ld sp, hl -;pff.c:1153: if (!fs) { /* Check file system */ - ld iy, #_FatFs - ld a, 1 (iy) - or a, 0 (iy) - jp NZ, l_pf_readdir_00111$ -;pff.c:1154: res = FR_NOT_ENABLED; - ld l, #0x05 - jp l_pf_readdir_00112$ -l_pf_readdir_00111$: -;pff.c:1156: dj->fn = sp; - ld c, 4 (ix) - ld b, 5 (ix) - ld e, c - ld d, b - inc de - inc de - ld hl, #0 - add hl, sp - ld -2 (ix), l - ld -1 (ix), h - ld a, -2 (ix) - ld (de), a - inc de - ld a, -1 (ix) - ld (de), a -;pff.c:1157: if (!fno) { - ld a, 7 (ix) - or a, 6 (ix) - jp NZ, l_pf_readdir_00108$ -;pff.c:1158: res = dir_rewind(dj); - push bc - call _dir_rewind - pop af - jp l_pf_readdir_00112$ -l_pf_readdir_00108$: -;pff.c:1160: res = dir_read(dj, dir); /* Get current directory item */ - ld hl, #12 - add hl, sp - ex de, hl - ld l, e - ld h, d - push bc - push de - push hl - push bc - call _dir_read - pop af - pop af - pop de - pop bc -;pff.c:1161: if (res == FR_NO_FILE) res = FR_OK; - ld a, l - sub a, #0x03 - jp NZ,l_pf_readdir_00140$ - jp l_pf_readdir_00141$ -l_pf_readdir_00140$: - jp l_pf_readdir_00102$ -l_pf_readdir_00141$: - ld l, #0x00 -l_pf_readdir_00102$: -;pff.c:1162: if (res == FR_OK) { /* A valid entry is found */ - ld a, l - or a, a - jp NZ, l_pf_readdir_00112$ -;pff.c:1163: get_fileinfo(dj, dir, fno); /* Get the object information */ - ld l, 6 (ix) - ld h, 7 (ix) - push hl - push de - push bc - call _get_fileinfo - pop af - pop af - pop af -;pff.c:1164: res = dir_next(dj); /* Increment read index for next */ - ld l, 4 (ix) - ld h, 5 (ix) - push hl - call _dir_next - pop af -;pff.c:1165: if (res == FR_NO_FILE) res = FR_OK; - ld a, l - sub a, #0x03 - jp NZ,l_pf_readdir_00142$ - jp l_pf_readdir_00143$ -l_pf_readdir_00142$: - jp l_pf_readdir_00112$ -l_pf_readdir_00143$: - ld l, #0x00 -l_pf_readdir_00112$: -;pff.c:1170: return res; -l_pf_readdir_00113$: -;pff.c:1171: } - ld sp, ix - pop ix - ret - .area _CODE - .area _INITIALIZER - .area _CABS (ABS) diff --git a/software/src/PetitFS/pff.c b/software/src/PetitFS/pff.c deleted file mode 100644 index c2ad382..0000000 --- a/software/src/PetitFS/pff.c +++ /dev/null @@ -1,1119 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module R0.03a -/-----------------------------------------------------------------------------/ -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ Petit FatFs module is an open source software. Redistribution and use of -/ Petit FatFs in source and binary forms, with or without modification, are -/ permitted provided that the following condition is met: -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/-----------------------------------------------------------------------------/ -/ Jun 15,'09 R0.01a First release. -/ -/ Dec 14,'09 R0.02 Added multiple code page support. -/ Added write funciton. -/ Changed stream read mode interface. -/ Dec 07,'10 R0.02a Added some configuration options. -/ Fixed fails to open objects with DBCS character. - -/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. -/ Added _USE_LCC option. -/ Added _FS_FAT16 option. -/ -/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. -/ Removed _WORD_ACCESS option. -/ Changed prefix of configuration options, _ to PF_. -/ Added some code pages. -/ Removed some code pages actually not valid. -/ -/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in -/ banked ROMS as part of the RFS on the Sharp MZ80A. -/----------------------------------------------------------------------------*/ - -#include -#include -#include "pff.h" /* Petit FatFs configurations and declarations */ -#include "sdmmc.h" /* Declarations of low level disk I/O functions */ - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - - -#if PF_DEFINED != 8088 /* Revision ID */ -#error Wrong include file (pff.h). -#endif - -#define _FS_32ONLY 1 - -#define ABORT(err) {fs->flag = 0; return err;} - - - -/*--------------------------------------------------------*/ -/* DBCS code ranges and SBCS extend char conversion table */ -/*--------------------------------------------------------*/ - -#if PF_USE_LCC == 0 /* ASCII upper case character only */ - -#elif PF_CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif PF_CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif PF_CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif PF_CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif PF_CODE_PAGE == 437 /* U.S. */ -#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 720 /* Arabic */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 737 /* Greek */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xEF,0xF5,0xF0,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 771 /* KBL */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDC,0xDE,0xDE, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFE,0xFF} - -#elif PF_CODE_PAGE == 775 /* Baltic */ -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F, \ - 0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 850 /* Latin 1 */ -#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x41,0x43,0x45,0x45,0x45,0x49,0x49,0x49,0x41,0x41, \ - 0x45,0x92,0x92,0x4F,0x4F,0x4F,0x55,0x55,0x59,0x4F,0x55,0x4F,0x9C,0x4F,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0x41,0x41,0x41,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0x41,0x41,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD1,0xD1,0x45,0x45,0x45,0x49,0x49,0x49,0x49,0xD9,0xDA,0xDB,0xDC,0xDD,0x49,0xDF, \ - 0x4F,0xE1,0x4F,0x4F,0x4F,0x4F,0xE6,0xE8,0xE8,0x55,0x55,0x55,0x59,0x59,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 852 /* Latin 2 */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0xAC, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif PF_CODE_PAGE == 855 /* Cyrillic */ -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F, \ - 0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF, \ - 0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 857 /* Turkish */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0x49,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0xED,0xEE,0xEF, \ - -#elif PF_CODE_PAGE == 860 /* Portuguese */ -#define _EXCVT {0x80,0x9A,0x90,0x8F,0x8E,0x91,0x86,0x80,0x89,0x89,0x92,0x8B,0x8C,0x98,0x8E,0x8F, \ - 0x90,0x91,0x92,0x8C,0x99,0xA9,0x96,0x9D,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x86,0x8B,0x9F,0x96,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 861 /* Icelandic */ -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x8B,0x8B,0x8D,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x8D,0x55,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA4,0xA5,0xA6,0xA7,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 862 /* Hebrew */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 863 /* Canadian French */ -#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x41,0x8F, \ - 0x45,0x45,0x45,0x4F,0x45,0x49,0x55,0x55,0x98,0x4F,0x55,0x9B,0x9C,0x55,0x55,0x9F, \ - 0xA0,0xA1,0x4F,0x55,0xA4,0xA5,0xA6,0xA7,0x49,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 864 /* Arabic */ -#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 865 /* Nordic */ -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 866 /* Russian */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 869 /* Greek 2 */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x86,0x9C,0x8D,0x8F,0x90, \ - 0x91,0x90,0x92,0x95,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xA4,0xA5,0xA6,0xD9,0xDA,0xDB,0xDC,0xA7,0xA8,0xDF, \ - 0xA9,0xAA,0xAC,0xAD,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xCF,0xCF,0xD0,0xEF, \ - 0xF0,0xF1,0xD1,0xD2,0xD3,0xF5,0xD4,0xF7,0xF8,0xF9,0xD5,0x96,0x95,0x98,0xFE,0xFF} - -#else -#error Unknown code page. - -#endif - - - -/* Character code support macros */ - -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) - -#if PF_USE_LCC && !defined(_EXCVT) /* DBCS configuration */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* SBCS configuration */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _EXCVT */ - - -/* FatFs refers the members in the FAT structures with byte offset instead -/ of structure member because there are incompatibility of the packing option -/ between various compilers. */ - -#define BS_jmpBoot 0 -#define BS_OEMName 3 -#define BPB_BytsPerSec 11 -#define BPB_SecPerClus 13 -#define BPB_RsvdSecCnt 14 -#define BPB_NumFATs 16 -#define BPB_RootEntCnt 17 -#define BPB_TotSec16 19 -#define BPB_Media 21 -#define BPB_FATSz16 22 -#define BPB_SecPerTrk 24 -#define BPB_NumHeads 26 -#define BPB_HiddSec 28 -#define BPB_TotSec32 32 -#define BS_55AA 510 - -#define BS_DrvNum 36 -#define BS_BootSig 38 -#define BS_VolID 39 -#define BS_VolLab 43 -#define BS_FilSysType 54 - -#define BPB_FATSz32 36 -#define BPB_ExtFlags 40 -#define BPB_FSVer 42 -#define BPB_RootClus 44 -#define BPB_FSInfo 48 -#define BPB_BkBootSec 50 -#define BS_DrvNum32 64 -#define BS_BootSig32 66 -#define BS_VolID32 67 -#define BS_VolLab32 71 -#define BS_FilSysType32 82 - -#define MBR_Table 446 - -#define DIR_Name 0 -#define DIR_Attr 11 -#define DIR_NTres 12 -#define DIR_CrtTime 14 -#define DIR_CrtDate 16 -#define DIR_FstClusHI 20 -#define DIR_WrtTime 22 -#define DIR_WrtDate 24 -#define DIR_FstClusLO 26 -#define DIR_FileSize 28 - - - - -/*-------------------------------------------------------------------------- - - Private Functions - ----------------------------------------------------------------------------*/ - - -static FATFS *FatFs; /* Pointer to the file system object (logical drive) */ - - -/*-----------------------------------------------------------------------*/ -/* Load multi-byte word in the FAT structure */ -/*-----------------------------------------------------------------------*/ - -static WORD ld_word (const BYTE* ptr) /* Load a 2-byte little-endian word */ -{ - WORD rv; - - rv = ptr[1]; - rv = rv << 8 | ptr[0]; - return rv; -} - -static DWORD ld_dword (const BYTE* ptr) /* Load a 4-byte little-endian word */ -{ - DWORD rv; - - rv = ptr[3]; - rv = rv << 8 | ptr[2]; - rv = rv << 8 | ptr[1]; - rv = rv << 8 | ptr[0]; - return rv; -} - - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Fill memory block */ -static void mem_set (void* dst, int val, int cnt) { - char *d = (char*)dst; - while (cnt--) *d++ = (char)val; -} - -/* Compare memory block */ -static int mem_cmp (const void* dst, const void* src, int cnt) { - const char *d = (const char *)dst, *s = (const char *)src; - int r = 0; - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ - -static CLUST get_fat ( /* 1:IO error, Else:Cluster status */ - CLUST clst /* Cluster# to get the link information */ -) -{ - BYTE buf[4]; - FATFS *fs = FatFs; - - if (clst < 2 || clst >= fs->n_fatent) return 1; /* Range check */ - - switch (fs->fs_type) { - case FS_FAT32 : - if (disk_readp(buf, fs->fatbase + clst / 128, ((UINT)clst % 128) * 4, 4)) break; - return ld_dword(buf) & 0x0FFFFFFF; - } - - return 1; /* An error occured at the disk I/O layer */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# / Get cluster field from directory entry */ -/*-----------------------------------------------------------------------*/ - -static DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - CLUST clst /* Cluster# to be converted */ -) -{ - FATFS *fs = FatFs; - - clst -= 2; - if (clst >= (fs->n_fatent - 2)) return 0; /* Invalid cluster# */ - return (DWORD)clst * fs->csize + fs->database; -} - - -static CLUST get_clust ( - BYTE* dir /* Pointer to directory entry */ -) -{ - FATFS *fs = FatFs; - CLUST clst = 0; - - - clst = ld_word(dir+DIR_FstClusHI); - clst <<= 16; - clst |= ld_word(dir+DIR_FstClusLO); - - return clst; -} - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Rewind directory index */ -/*-----------------------------------------------------------------------*/ - -static FRESULT dir_rewind ( - DIR *dj /* Pointer to directory object */ -) -{ - CLUST clst; - FATFS *fs = FatFs; - - - dj->index = 0; - clst = dj->sclust; - if (clst == 1 || clst >= fs->n_fatent) { /* Check start cluster range */ - return FR_DISK_ERR; - } - if(!clst) - { - clst = (CLUST)fs->dirbase; - } - dj->clust = clst; /* Current cluster */ - dj->sect = clust2sect(clst); /* Current sector */ - return FR_OK; /* Seek succeeded */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory index next */ -/*-----------------------------------------------------------------------*/ - -static FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table */ - DIR *dj /* Pointer to directory object */ -) -{ - CLUST clst; - WORD i; - FATFS *fs = FatFs; - - - i = dj->index + 1; - if (!i || !dj->sect) return FR_NO_FILE; /* Report EOT when index has reached 65535 */ - - if (!(i % 16)) { /* Sector changed? */ - dj->sect++; /* Next sector */ - - if (dj->clust == 0) { /* Static table */ - if (i >= fs->n_rootdir) return FR_NO_FILE; /* Report EOT when end of table */ - } - else { /* Dynamic table */ - if (((i / 16) & (fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dj->clust); /* Get next cluster */ - if (clst <= 1) return FR_DISK_ERR; - if (clst >= fs->n_fatent) return FR_NO_FILE; /* Report EOT when it reached end of dynamic table */ - dj->clust = clst; /* Initialize data for new cluster */ - dj->sect = clust2sect(clst); - } - } - } - - dj->index = i; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static FRESULT dir_find ( - DIR *dj, /* Pointer to the directory object linked to the file name */ - BYTE *dir /* 32-byte working buffer */ -) -{ - FRESULT res; - BYTE c; - - - res = dir_rewind(dj); /* Rewind directory object */ - if (res != FR_OK) return res; - - do { - res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ? FR_DISK_ERR : FR_OK; - if (res != FR_OK) break; - c = dir[DIR_Name]; /* First character */ - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dj->fn, 11)) break; /* Is it a valid entry? */ - res = dir_next(dj); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -static FRESULT dir_read ( - DIR *dj, /* Pointer to the directory object to store read object name */ - BYTE *dir /* 32-byte working buffer */ -) -{ - FRESULT res; - BYTE a, c; - - - res = FR_NO_FILE; - while (dj->sect) { - - res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ? FR_DISK_ERR : FR_OK; - if (res != FR_OK) break; - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; - if (c != 0xE5 && c != '.' && !(a & AM_VOL)) break; /* Is it a valid entry? */ - res = dir_next(dj); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dj->sect = 0; - - return res; -} - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - - -static FRESULT create_name ( - DIR *dj, /* Pointer to the directory object */ - const char **path /* Pointer to pointer to the segment in the path string */ -) -{ - BYTE c, d, ni, si, i, *sfn; - const char *p; -#if PF_USE_LCC && defined(_EXCVT) - static const BYTE cvt[] = _EXCVT; -#endif - - /* Create file name in directory form */ - sfn = dj->fn; - mem_set(sfn, ' ', 11); - si = i = 0; ni = 8; - p = *path; - for (;;) { - c = p[si++]; - if (c <= ' ' || c == '/') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') break; - i = 8; ni = 11; - continue; - } -#if PF_USE_LCC && defined(_EXCVT) - if (c >= 0x80) c = cvt[c - 0x80]; /* To upper extended char (SBCS) */ -#endif - if (IsDBCS1(c) && i < ni - 1) { /* DBC 1st byte? */ - d = p[si++]; /* Get 2nd byte */ - sfn[i++] = c; - sfn[i++] = d; - } else { /* Single byte code */ - if (PF_USE_LCC && IsLower(c)) c -= 0x20; /* toupper */ - sfn[i++] = c; - } - } - *path = &p[si]; /* Rerurn pointer to the next segment */ - - sfn[11] = (c <= ' ') ? 1 : 0; /* Set last segment flag if end of path */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -static void get_fileinfo ( /* No return code */ - DIR *dj, /* Pointer to the directory object */ - BYTE *dir, /* 32-byte working buffer */ - FILINFO *fno /* Pointer to store the file information */ -) -{ - BYTE i, c; - char *p; - - - p = fno->fname; - if (dj->sect) { - for (i = 0; i < 8; i++) { /* Copy file name body */ - c = dir[i]; - if (c == ' ') break; - if (c == 0x05) c = 0xE5; - *p++ = c; - } - if (dir[8] != ' ') { /* Copy file name extension */ - *p++ = '.'; - for (i = 8; i < 11; i++) { - c = dir[i]; - if (c == ' ') break; - *p++ = c; - } - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = ld_dword(dir+DIR_FileSize); /* Size */ - fno->fdate = ld_word(dir+DIR_WrtDate); /* Date */ - fno->ftime = ld_word(dir+DIR_WrtTime); /* Time */ - } - *p = 0; -} - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR *dj, /* Directory object to return last directory and found object */ - BYTE *dir, /* 32-byte working buffer */ - const char *path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - - - while (*path == ' ') path++; /* Strip leading spaces */ - if (*path == '/') path++; /* Strip heading separator if exist */ - dj->sclust = 0; /* Set start directory (always root dir) */ - - if ((BYTE)*path < ' ') { /* Null path means the root directory */ - res = dir_rewind(dj); - dir[0] = 0; - - } else { /* Follow path */ - for (;;) { - res = create_name(dj, &path); /* Get a segment */ - if (res != FR_OK) break; - res = dir_find(dj, dir); /* Find it */ - if (res != FR_OK) break; /* Could not find the object */ - if (dj->fn[11]) break; /* Last segment match. Function completed. */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* Cannot follow path because it is a file */ - res = FR_NO_FILE; break; - } - dj->sclust = get_clust(dir); /* Follow next */ - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check a sector if it is an FAT boot record */ -/*-----------------------------------------------------------------------*/ - -static BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record, 3:Error */ - BYTE *buf, /* Working buffer */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - if (disk_readp(buf, sect, 510, 2)) { /* Read the boot record */ - return 3; - } - if (ld_word(buf) != 0xAA55) { /* Check record signature */ - return 2; - } - -// if (!_FS_32ONLY && !disk_readp(buf, sect, BS_FilSysType, 2) && ld_word(buf) == 0x4146) { /* Check FAT12/16 */ -// return 0; -// } - if (!disk_readp(buf, sect, BS_FilSysType32, 2) && ld_word(buf) == 0x4146) { /* Check FAT32 */ - return 0; - } - return 1; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Locical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_mount ( - FATFS *fs /* Pointer to new file system object */ -) -{ - BYTE fmt, buf[36]; - DWORD bsect, fsize, tsect, mclst; - - - FatFs = 0; - if (disk_initialize() & STA_NOINIT) { /* Check if the drive is ready or not */ - return FR_NOT_READY; - } - - /* Search FAT partition on the drive */ - bsect = 0; - fmt = check_fs(buf, bsect); /* Check sector 0 as an SFD format */ - if (fmt == 1) { /* Not an FAT boot record, it may be FDISK format */ - /* Check a partition listed in top of the partition table */ - if (disk_readp(buf, bsect, MBR_Table, 16)) { /* 1st partition entry */ - fmt = 3; - } else { - if (buf[4]) { /* Is the partition existing? */ - bsect = ld_dword(&buf[8]); /* Partition offset in LBA */ - fmt = check_fs(buf, bsect); /* Check the partition */ - } - } - } - if (fmt == 3) return FR_DISK_ERR; - if (fmt) return FR_NO_FILESYSTEM; /* No valid FAT patition is found */ - - /* Initialize the file system object */ - if (disk_readp(buf, bsect, 13, sizeof (buf))) return FR_DISK_ERR; - - fsize = ld_word(buf+BPB_FATSz16-13); /* Number of sectors per FAT */ - if (!fsize) fsize = ld_dword(buf+BPB_FATSz32-13); - - fsize *= buf[BPB_NumFATs-13]; /* Number of sectors in FAT area */ - fs->fatbase = bsect + ld_word(buf+BPB_RsvdSecCnt-13); /* FAT start sector (lba) */ - fs->csize = buf[BPB_SecPerClus-13]; /* Number of sectors per cluster */ - fs->n_rootdir = ld_word(buf+BPB_RootEntCnt-13); /* Nmuber of root directory entries */ - tsect = ld_word(buf+BPB_TotSec16-13); /* Number of sectors on the file system */ - if (!tsect) tsect = ld_dword(buf+BPB_TotSec32-13); - mclst = (tsect /* Last cluster# + 1 */ - - ld_word(buf+BPB_RsvdSecCnt-13) - fsize - fs->n_rootdir / 16 - ) / fs->csize + 2; - fs->n_fatent = (CLUST)mclst; - - fmt = 0; /* Determine the FAT sub type */ - if (mclst >= 0xFFF7) fmt = FS_FAT32; - if (!fmt) return FR_NO_FILESYSTEM; - fs->fs_type = fmt; - -// if (_FS_32ONLY || (PF_FS_FAT32 && fmt == FS_FAT32)) { - fs->dirbase = ld_dword(buf+(BPB_RootClus-13)); /* Root directory start cluster */ -// } else { -// fs->dirbase = fs->fatbase + fsize; /* Root directory start sector (lba) */ -// } - fs->database = fs->fatbase + fsize + fs->n_rootdir / 16; /* Data start sector (lba) */ - - fs->flag = 0; - FatFs = fs; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_open ( - const char *path /* Pointer to the file name */ -) -{ - FRESULT res; - DIR dj; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - - fs->flag = 0; - dj.fn = sp; - res = follow_path(&dj, dir, path); /* Follow the file path */ - if (res != FR_OK) return res; /* Follow failed */ - if (!dir[0] || (dir[DIR_Attr] & AM_DIR)) return FR_NO_FILE; /* It is a directory */ - - fs->org_clust = get_clust(dir); /* File start cluster */ - fs->fsize = ld_dword(dir+DIR_FileSize); /* File size */ - fs->fptr = 0; /* File pointer */ - fs->flag = FA_OPENED; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ -FRESULT pf_read ( - void* buff, /* Pointer to the read buffer (NULL:Forward data to the stream)*/ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - DRESULT dr; - CLUST clst; - DWORD sect, remain; - UINT rcnt; - BYTE cs, *rbuff = buff; - FATFS *fs = FatFs; - - - *br = 0; - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ - - remain = fs->fsize - fs->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - while (btr) { /* Repeat until all data transferred */ - if ((fs->fptr % 512) == 0) { /* On the sector boundary? */ - cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - if (!cs) { /* On the cluster boundary? */ - if (fs->fptr == 0) { /* On the top of the file? */ - clst = fs->org_clust; - } else { - clst = get_fat(fs->curr_clust); - } - if (clst <= 1) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; /* Update current cluster */ - } - sect = clust2sect(fs->curr_clust); /* Get current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + cs; - } - rcnt = 512 - (UINT)fs->fptr % 512; /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; - dr = disk_readp(rbuff, fs->dsect, (UINT)fs->fptr % 512, rcnt); - if (dr) ABORT(FR_DISK_ERR); - fs->fptr += rcnt; /* Advances file read pointer */ - btr -= rcnt; *br += rcnt; /* Update read counter */ - if (rbuff) rbuff += rcnt; /* Advances the data pointer if destination is memory */ - } - - return FR_OK; -} - - -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ -FRESULT pf_write ( - const void* buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write (0:Finalize the current write operation) */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - CLUST clst; - DWORD sect, remain; - const BYTE *p = buff; - BYTE cs; - UINT wcnt; - FATFS *fs = FatFs; - - - *bw = 0; - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ - - if (!btw) { /* Finalize request */ - if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR); - fs->flag &= ~FA__WIP; - return FR_OK; - } else { /* Write data request */ - if (!(fs->flag & FA__WIP)) { /* Round-down fptr to the sector boundary */ - fs->fptr &= 0xFFFFFE00; - } - } - remain = fs->fsize - fs->fptr; - if (btw > remain) btw = (UINT)remain; /* Truncate btw by remaining bytes */ - - while (btw) { /* Repeat until all data transferred */ - if ((UINT)fs->fptr % 512 == 0) { /* On the sector boundary? */ - cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - if (!cs) { /* On the cluster boundary? */ - if (fs->fptr == 0) { /* On the top of the file? */ - clst = fs->org_clust; - } else { - clst = get_fat(fs->curr_clust); - } - if (clst <= 1) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; /* Update current cluster */ - } - sect = clust2sect(fs->curr_clust); /* Get current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + cs; - if (disk_writep(0, fs->dsect)) ABORT(FR_DISK_ERR); /* Initiate a sector write operation */ - fs->flag |= FA__WIP; - } - wcnt = 512 - (UINT)fs->fptr % 512; /* Number of bytes to write to the sector */ - if (wcnt > btw) wcnt = btw; - if (disk_writep(p, wcnt)) ABORT(FR_DISK_ERR); /* Send data to the sector */ - fs->fptr += wcnt; p += wcnt; /* Update pointers and counters */ - btw -= wcnt; *bw += wcnt; - if ((UINT)fs->fptr % 512 == 0) { - if (disk_writep(0, 0)) ABORT(FR_DISK_ERR); /* Finalize the currtent secter write operation */ - fs->flag &= ~FA__WIP; - } - } - - return FR_OK; -} - - -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ -#if PF_USE_LSEEK - -FRESULT pf_lseek ( - DWORD ofs /* File pointer from top of file */ -) -{ - CLUST clst; - DWORD bcs, sect, ifptr; - FATFS *fs = FatFs; - - - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ - - if (ofs > fs->fsize) ofs = fs->fsize; /* Clip offset with the file size */ - ifptr = fs->fptr; - fs->fptr = 0; - if (ofs > 0) { - bcs = (DWORD)fs->csize * 512; /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fs->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fs->fptr; - clst = fs->curr_clust; - } else { /* When seek to back cluster, */ - clst = fs->org_clust; /* start from the first cluster */ - fs->curr_clust = clst; - } - while (ofs > bcs) { /* Cluster following loop */ - clst = get_fat(clst); /* Follow cluster chain */ - if (clst <= 1 || clst >= fs->n_fatent) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; - fs->fptr += bcs; - ofs -= bcs; - } - fs->fptr += ofs; - sect = clust2sect(clst); /* Current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + (fs->fptr / 512 & (fs->csize - 1)); - } - - return FR_OK; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directroy Object */ -/*-----------------------------------------------------------------------*/ -FRESULT pf_opendir ( - DIR *dj, /* Pointer to directory object to create */ - const char *path /* Pointer to the directory path */ -) -{ - FRESULT res; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) { /* Check file system */ - res = FR_NOT_ENABLED; - } else { - dj->fn = sp; - res = follow_path(dj, dir, path); /* Follow the path to the directory */ - if (res == FR_OK) { /* Follow completed */ - if (dir[0]) { /* It is not the root dir */ - if (dir[DIR_Attr] & AM_DIR) { /* The object is a directory */ - dj->sclust = get_clust(dir); - } else { /* The object is not a directory */ - res = FR_NO_FILE; - } - } - if (res == FR_OK) { - res = dir_rewind(dj); /* Rewind dir */ - } - } - } - - return res; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entry in Sequense */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_readdir ( - DIR *dj, /* Pointer to the open directory object */ - FILINFO *fno /* Pointer to file information to return */ -) -{ - FRESULT res; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) { /* Check file system */ - res = FR_NOT_ENABLED; - } else { - dj->fn = sp; - if (!fno) { - res = dir_rewind(dj); - } else { - res = dir_read(dj, dir); /* Get current directory item */ - // if (res == FR_NO_FILE) res = FR_OK; - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dj, dir, fno); /* Get the object information */ - res = dir_next(dj); /* Increment read index for next */ - if (res == FR_NO_FILE) res = FR_OK; - } - } - } - - return res; -} diff --git a/software/src/PetitFS/pff.c.asm b/software/src/PetitFS/pff.c.asm deleted file mode 100644 index df6ceee..0000000 --- a/software/src/PetitFS/pff.c.asm +++ /dev/null @@ -1,4033 +0,0 @@ -;* * * * * Small-C/Plus z88dk * * * * * -; Version: 16120-f784809cf-20200301 -; -; Reconstructed for z80 Module Assembler -; -; Module compile time: Fri Mar 13 16:31:35 2020 - - - - MODULE pff_c - - - INCLUDE "z80_crt0.hdr" - - - SECTION code_compiler - -; Function ld_word flags 0x00000200 __smallc -; unsigned int WORDld_word(const unsigned char BYTE*ptr) -; parameter 'const unsigned char BYTE*ptr' at 2 size(2) -._ld_word - push bc - ld hl,4 ;const - add hl,sp - call l_gint ; - inc hl - ld l,(hl) - ld h,0 - pop bc - push hl - ld h,l - ld l,0 - push hl - ld hl,6 ;const - add hl,sp - call l_gint ; - ld l,(hl) - pop de - ld h,d - ld a,l - or e - ld l,a - pop bc - ret - - - -; Function ld_dword flags 0x00000200 __smallc -; unsigned long DWORDld_dword(const unsigned char BYTE*ptr) -; parameter 'const unsigned char BYTE*ptr' at 2 size(2) -._ld_dword - push bc - push bc - ld hl,0 ;const - add hl,sp - push hl - ld hl,8 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - inc hl - ld l,(hl) - ld h,0 - ld de,0 - pop bc - call l_plong - ld hl,0 ;const - add hl,sp - push hl - ld a,(hl) - inc hl - ld e,(hl) - inc hl - ld d,(hl) - ld h,a - ld l,0 - push de - push hl - ld hl,12 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - ld l,(hl) - pop de - ld h,d - ld a,l - or e - ld l,a - pop de - pop bc - call l_plong - ld hl,0 ;const - add hl,sp - push hl - ld a,(hl) - inc hl - ld e,(hl) - inc hl - ld d,(hl) - ld h,a - ld l,0 - push de - push hl - ld hl,12 ;const - add hl,sp - call l_gint ; - inc hl - ld l,(hl) - pop de - ld h,d - ld a,l - or e - ld l,a - pop de - pop bc - call l_plong - ld hl,0 ;const - add hl,sp - push hl - ld a,(hl) - inc hl - ld e,(hl) - inc hl - ld d,(hl) - ld h,a - ld l,0 - push de - push hl - ld hl,12 ;const - add hl,sp - call l_gint ; - ld l,(hl) - pop de - ld h,d - ld a,l - or e - ld l,a - pop de - pop bc - call l_plong - ld hl,0 ;const - add hl,sp - call l_glong - pop bc - pop bc - ret - - - -; Function mem_set flags 0x00000200 __smallc -; void mem_set(void *dst, int val, int cnt) -; parameter 'int cnt' at 2 size(2) -; parameter 'int val' at 4 size(2) -; parameter 'void *dst' at 6 size(2) -._mem_set - ld hl,6 ;const - add hl,sp - call l_gint ; - push hl -.i_2 - ld hl,4 ;const - add hl,sp - dec (hl) - ld a,(hl) - inc hl - cp 255 - jr nz,ASMPC+3 - dec (hl) - ld h,(hl) - ld l,a - inc hl - ld a,h - or l - jp z,i_3 - pop hl - inc hl - push hl - dec hl - push hl - ld hl,8 ;const - add hl,sp - call l_gint ; - ld a,l - call l_sxt - ld a,l - call l_sxt - pop de - ld a,l - ld (de),a - jp i_2 -.i_3 - pop bc - ret - - - -; Function mem_cmp flags 0x00000200 __smallc -; int mem_cmp(const void *dst, const void *src, int cnt) -; parameter 'int cnt' at 2 size(2) -; parameter 'const void *src' at 4 size(2) -; parameter 'const void *dst' at 6 size(2) -._mem_cmp - ld hl,6 ;const - call l_g2intspsp ; - ld hl,0 ;const - push hl -.i_4 - ld hl,8 ;const - add hl,sp - dec (hl) - ld a,(hl) - inc hl - cp 255 - jr nz,ASMPC+3 - dec (hl) - ld h,(hl) - ld l,a - inc hl - ld a,h - or l - jp z,i_6 - ld hl,4 ;const - add hl,sp - inc (hl) - ld a,(hl) - inc hl - jr nz,ASMPC+3 - inc (hl) - ld h,(hl) - ld l,a - dec hl - call l_gchar - push hl - ld hl,4 ;const - add hl,sp - inc (hl) - ld a,(hl) - inc hl - jr nz,ASMPC+3 - inc (hl) - ld h,(hl) - ld l,a - dec hl - call l_gchar - pop de - ex de,hl - and a - sbc hl,de - pop bc - push hl - ld a,h - or l - jp nz,i_6 - inc hl - jr i_7 -.i_6 - ld hl,0 ;const -.i_7 - ld a,h - or l - jp nz,i_4 -.i_5 - pop hl - pop bc - pop bc - ret - - - -; Function get_fat flags 0x00000200 __smallc -; unsigned long DWORDget_fat(unsigned long clst) -; parameter 'unsigned long clst' at 2 size(4) -._get_fat - push bc - push bc - ld hl,(_FatFs) - push hl - ld hl,8 ;const - add hl,sp - call l_glong - ld a,l - sub 2 - ld a,h - sbc 0 - ld a,e - sbc 0 - ld a,d - sbc 0 - jp c,i_9 - ld hl,8 ;const - add hl,sp - call l_glong2sp - ld hl,4 ;const - add hl,sp - call l_gint ; - ld bc,6 - add hl,bc - call l_glong - call l_long_uge - jp nc,i_8 -.i_9 - ld hl,1 ;const - ld de,0 - pop bc - pop bc - pop bc - ret - - -.i_8 - pop hl - push hl - ld l,(hl) - ld h,0 -.i_13 - ld a,l - cp +(3% 256) - jp nz,i_12 -.i_14 - ld hl,2 ;const - add hl,sp - push hl - dec hl - dec hl - call l_gint ; - ld bc,10 - add hl,bc - call l_glong2sp - ld hl,14 ;const - add hl,sp - call l_glong2sp - ld l,+(7 % 256) - call l_long_asr_u - call l_long_add - push de - push hl - ld hl,14 ;const - add hl,sp - call l_glong - ld a,l - and +(127 % 256) - ld l,a - ld h,0 - add hl,hl - add hl,hl - push hl - ld hl,4 ;const - push hl - call _disk_readp - pop bc - pop bc - pop bc - pop bc - pop bc - ld a,h - or l - jp nz,i_12 -.i_15 - ld hl,2 ;const - add hl,sp - push hl - call _ld_dword - pop bc - ld a,d - and +(15 % 256) - ld d,a - pop bc - pop bc - pop bc - ret - - -.i_12 - ld hl,1 ;const - ld de,0 - pop bc - pop bc - pop bc - ret - - - -; Function clust2sect flags 0x00000200 __smallc -; unsigned long DWORDclust2sect(unsigned long clst) -; parameter 'unsigned long clst' at 2 size(4) -._clust2sect - ld hl,(_FatFs) - push hl - ld hl,4 ;const - add hl,sp - push hl - call l_glong - ld bc,65534 - add hl,bc - jr c,ASMPC+3 - dec de - pop bc - call l_plong - ld hl,4 ;const - add hl,sp - call l_glong2sp - ld hl,4 ;const - add hl,sp - call l_gint ; - ld bc,6 - add hl,bc - call l_glong - ld bc,65534 - add hl,bc - jr c,ASMPC+3 - dec de - call l_long_uge - jp nc,i_16 - ld hl,0 ;const - ld d,h - ld e,l - pop bc - ret - - -.i_16 - ld hl,4 ;const - add hl,sp - call l_glong2sp - ld hl,4 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - ld l,(hl) - ld h,0 - ld de,0 - call l_long_mult - push de - push hl - ld hl,4 ;const - add hl,sp - call l_gint ; - ld bc,18 - add hl,bc - call l_glong - call l_long_add - pop bc - ret - - - -; Function get_clust flags 0x00000200 __smallc -; unsigned long DWORDget_clust(unsigned char BYTE*dir) -; parameter 'unsigned char BYTE*dir' at 2 size(2) -._get_clust - ld hl,(_FatFs) - push hl - ld hl,0 ;const - ld d,h - ld e,l - push de - push hl - ld hl,0 ;const - add hl,sp - push hl - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,20 - add hl,bc - push hl - call _ld_word - pop bc - ld de,0 - pop bc - call l_plong - ld hl,0 ;const - add hl,sp - push hl - call l_glong - ex de,hl - ld hl,0 ;const - pop bc - call l_plong - ld hl,0 ;const - add hl,sp - push hl - call l_glong2sp - ld hl,14 ;const - add hl,sp - call l_gint ; - ld bc,26 - add hl,bc - push hl - call _ld_word - pop bc - pop de - call l_or - pop de - pop bc - call l_plong - ld hl,0 ;const - add hl,sp - call l_glong - pop bc - pop bc - pop bc - ret - - - -; Function dir_rewind flags 0x00000200 __smallc -; const int FRESULTdir_rewind(struct 0__anonstruct_5 DIR*dj) -; parameter 'struct 0__anonstruct_5 DIR*dj' at 2 size(2) -._dir_rewind - push bc - push bc - ld hl,(_FatFs) - push hl - ld hl,8 ;const - add hl,sp - ld a,(hl) - inc hl - ld h,(hl) - ld l,a - xor a - ld (hl),a - inc hl - ld (hl),a - ld hl,2 ;const - add hl,sp - push hl - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,4 - add hl,bc - call l_glong - pop bc - call l_plong - ld hl,2 ;const - add hl,sp - call l_glong2sp - ld hl,1 ;const - ld de,0 - call l_long_eq - jp c,i_18 - ld hl,2 ;const - add hl,sp - call l_glong2sp - ld hl,4 ;const - add hl,sp - call l_gint ; - ld bc,6 - add hl,bc - call l_glong - call l_long_uge - jp nc,i_17 -.i_18 - ld hl,1 ;const - pop bc - pop bc - pop bc - ret - - -.i_17 - ld hl,2 ;const - add hl,sp - call l_glong - call l_long_lneg - jp nc,i_20 - ld hl,2 ;const - add hl,sp - push hl - dec hl - dec hl - call l_gint ; - ld bc,14 - add hl,bc - call l_glong - pop bc - call l_plong -.i_20 - ld hl,8 ;const - add hl,sp - call l_gint ; - ld bc,8 - add hl,bc - push hl - ld hl,4 ;const - add hl,sp - call l_glong - pop bc - call l_plong - ld hl,8 ;const - add hl,sp - call l_gint ; - ld bc,12 - add hl,bc - push hl - jp i_21 - ld hl,4 ;const - add hl,sp - call l_glong - ld a,h - or l - or d - or e - jp nz,i_21 - ld hl,0 ;const - jr i_22 -.i_21 - ld hl,1 ;const -.i_22 - jp nc,i_23 - ld hl,4 ;const - add hl,sp - call l_glong - push de - push hl - call _clust2sect - pop bc - pop bc - jp i_24 -.i_23 - pop bc - pop hl - push hl - push bc - ld bc,14 - add hl,bc - call l_glong -.i_24 - pop bc - call l_plong - ld hl,8 ;const - add hl,sp - call l_gint ; - ld bc,12 - add hl,bc - push hl - ld hl,4 ;const - add hl,sp - call l_glong - push de - push hl - call _clust2sect - pop bc - pop bc - pop bc - call l_plong - ld hl,0 ;const - pop bc - pop bc - pop bc - ret - - - -; Function dir_next flags 0x00000200 __smallc -; const int FRESULTdir_next(struct 0__anonstruct_5 DIR*dj) -; parameter 'struct 0__anonstruct_5 DIR*dj' at 2 size(2) -._dir_next - push bc - push bc - push bc - ld hl,(_FatFs) - push hl - ld hl,10 ;const - add hl,sp - call l_gint ; - call l_gint ; - inc hl - pop de - pop bc - push hl - push de - call l_lneg - jp c,i_26 - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,12 - add hl,bc - call l_glong - call l_long_lneg - jp nc,i_25 -.i_26 - ld hl,3 ;const - pop bc - pop bc - pop bc - pop bc - ret - - -.i_25 - pop bc - pop hl - push hl - push bc - ld a,l - and +(15 % 256) - jp nz,i_28 - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,12 - add hl,bc - push hl - call l_glong - call l_inclong - pop bc - call l_plong - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,8 - add hl,bc - call l_glong - ld a,d - or e - or h - or l - jp nz,i_29 - ld hl,2 ;const - call l_gintspsp ; - pop bc - pop hl - push hl - push bc - ld bc,4 - add hl,bc - call l_gint ; - pop de - call l_uge - jp nc,i_30 - ld hl,3 ;const - pop bc - pop bc - pop bc - pop bc - ret - - -.i_30 - jp i_31 -.i_29 - pop bc - pop hl - push hl - push bc - ld de,4 - call l_asr_u_hl_by_e - pop de - push de - push hl - ex de,hl - inc hl - inc hl - ld l,(hl) - ld h,0 - dec hl - pop de - call l_and - ld a,h - or l - jp nz,i_32 - ld hl,4 ;const - add hl,sp - push hl - ld hl,12 ;const - add hl,sp - call l_gint ; - ld bc,8 - add hl,bc - call l_glong - push de - push hl - call _get_fat - pop bc - pop bc - pop bc - call l_plong - ld hl,4 ;const - add hl,sp - call l_glong2sp - ld hl,1 ;const - ld de,0 - call l_long_ule - jp nc,i_33 - ld hl,1 ;const - pop bc - pop bc - pop bc - pop bc - ret - - -.i_33 - ld hl,4 ;const - add hl,sp - call l_glong2sp - ld hl,4 ;const - add hl,sp - call l_gint ; - ld bc,6 - add hl,bc - call l_glong - call l_long_uge - jp nc,i_34 - ld hl,3 ;const - pop bc - pop bc - pop bc - pop bc - ret - - -.i_34 - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,8 - add hl,bc - push hl - ld hl,6 ;const - add hl,sp - call l_glong - pop bc - call l_plong - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,12 - add hl,bc - push hl - ld hl,6 ;const - add hl,sp - call l_glong - push de - push hl - call _clust2sect - pop bc - pop bc - pop bc - call l_plong -.i_32 -.i_31 -.i_28 - ld hl,10 ;const - call l_gintspsp ; - ld hl,4 ;const - add hl,sp - call l_gint ; - pop de - call l_pint - ld hl,0 ;const - pop bc - pop bc - pop bc - pop bc - ret - - - -; Function dir_find flags 0x00000200 __smallc -; const int FRESULTdir_find(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir) -; parameter 'unsigned char BYTE*dir' at 2 size(2) -; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) -._dir_find - push bc - dec sp - ld hl,1 ;const - add hl,sp - push hl - ld hl,9 ;const - add hl,sp - call l_gint ; - push hl - call _dir_rewind - pop bc - pop de - call l_pint - ld hl,1 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp z,i_35 - ld hl,1 ;const - add hl,sp - call l_gint ; - inc sp - pop bc - ret - - -.i_35 -.i_38 - ld hl,1 ;const - add hl,sp - push hl - ld hl,7 ;const - call l_gintspsp ; - ld hl,11 ;const - add hl,sp - call l_gint ; - ld bc,12 - add hl,bc - call l_glong2sp - ld hl,15 ;const - add hl,sp - call l_gint ; - ld a,(hl) - and +(15 % 256) - ld l,a - ld h,0 - add hl,hl - add hl,hl - add hl,hl - add hl,hl - add hl,hl - push hl - ld hl,32 ;const - push hl - call _disk_readp - pop bc - pop bc - pop bc - pop bc - pop bc - ld a,h - or l - jp z,i_39 - ld hl,1 ;const - jp i_40 -.i_39 - ld hl,0 ;const -.i_40 - pop de - call l_pint - ld hl,1 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp nz,i_37 -.i_41 - ld hl,0 ;const - add hl,sp - push hl - ld hl,7 ;const - add hl,sp - call l_gint ; - ld a,(hl) - pop de - ld (de),a - pop hl - push hl - ld h,0 - ld a,l - and a - jp nz,i_42 - ld hl,1 ;const - add hl,sp - ld de,3 ;const - ex de,hl - call l_pint - jp i_37 -.i_42 - ld hl,5 ;const - add hl,sp - call l_gint ; - ld bc,11 - add hl,bc - ld a,(hl) - and +(8 % 256) - jp nz,i_44 - ld hl,5 ;const - call l_gintspsp ; - ld hl,9 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - ld e,(hl) - inc hl - ld d,(hl) - push de - ld hl,11 ;const - push hl - call _mem_cmp - pop bc - pop bc - pop bc - call l_lneg - jr c,i_45_i_44 -.i_44 - jp i_43 -.i_45_i_44 - jp i_37 -.i_43 - ld hl,1 ;const - add hl,sp - push hl - ld hl,9 ;const - add hl,sp - call l_gint ; - push hl - call _dir_next - pop bc - pop de - call l_pint -.i_36 - ld hl,1 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp z,i_38 -.i_37 - ld hl,1 ;const - add hl,sp - call l_gint ; - inc sp - pop bc - ret - - - -; Function dir_read flags 0x00000200 __smallc -; const int FRESULTdir_read(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir) -; parameter 'unsigned char BYTE*dir' at 2 size(2) -; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) -._dir_read - ld hl,3 ;const - push hl - push bc -.i_46 - ld hl,8 ;const - add hl,sp - call l_gint ; - ld bc,12 - add hl,bc - call l_glong - ld a,h - or l - or d - or e - jp z,i_47 - ld hl,i_1+0 - push hl - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,12 - add hl,bc - call l_glong2sp - ld hl,14 ;const - add hl,sp - call l_gint ; - call l_gint ; - push hl - ld a,4 - call printf - pop bc - pop bc - pop bc - pop bc - ld hl,6 ;const - call l_gintspsp ; - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,12 - add hl,bc - call l_glong2sp - ld hl,14 ;const - add hl,sp - call l_gint ; - ld a,(hl) - and +(15 % 256) - ld l,a - ld h,0 - add hl,hl - add hl,hl - add hl,hl - add hl,hl - add hl,hl - push hl - ld hl,32 ;const - push hl - call _disk_readp - pop bc - pop bc - pop bc - pop bc - pop bc - ld a,h - or l - jp z,i_48 - ld hl,1 ;const - jp i_49 -.i_48 - ld hl,0 ;const -.i_49 - pop de - pop bc - push hl - push de - ld a,h - or l - jp nz,i_47 -.i_50 - ld hl,0 ;const - add hl,sp - push hl - ld hl,8 ;const - add hl,sp - call l_gint ; - ld a,(hl) - pop de - ld (de),a - pop hl - push hl - ld h,0 - ld a,l - and a - jp nz,i_51 - ld hl,3 ;const - pop de - pop bc - push hl - push de - jp i_47 -.i_51 - ld hl,1 ;const - add hl,sp - push hl - ld hl,8 ;const - add hl,sp - call l_gint ; - ld bc,11 - add hl,bc - ld a,(hl) - and +(63 % 256) - ld l,a - ld h,0 - pop de - ld a,l - ld (de),a - ld hl,0 ;const - add hl,sp - ld a,(hl) - cp 229 - jp z,i_53 - pop hl - push hl - ld h,0 - ld de,46 - and a - sbc hl,de - scf - jr nz,ASMPC+3 - ccf - jp nc,i_53 - pop hl - push hl - ld l,h - ld h,0 - ld a,+(8 % 256) - and l - ld l,a - call l_lneg - jr c,i_54_i_53 -.i_53 - jp i_52 -.i_54_i_53 - jp i_47 -.i_52 - ld hl,8 ;const - add hl,sp - call l_gint ; - push hl - call _dir_next - pop bc - pop de - pop bc - push hl - push de - ld a,h - or l - jr nz,i_47 -.i_55 - jp i_46 -.i_47 - pop bc - pop hl - push hl - push bc - ld a,h - or l - jp z,i_56 - ld hl,8 ;const - add hl,sp - call l_gint ; - ld bc,12 - add hl,bc - push hl - ld hl,0 ;const - ld d,h - ld e,l - pop bc - call l_plong -.i_56 - pop bc - pop hl - ret - - - -; Function create_name flags 0x00000200 __smallc -; const int FRESULTcreate_name(struct 0__anonstruct_5 DIR*dj, const char **path) -; parameter 'const char **path' at 2 size(2) -; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) -._create_name - push bc - push bc - push bc - push bc - dec sp - ld hl,13 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - call l_gint ; - pop de - pop bc - push hl - push de - ld hl,2 ;const - call l_gintspsp ; - ld hl,32 ;const - push hl - ld hl,11 ;const - push hl - call _mem_set - pop bc - pop bc - pop bc - ld hl,5 ;const - add hl,sp - push hl - ld hl,6 ;const - add hl,sp - ld (hl),+(0 % 256 % 256) - ld l,(hl) - ld h,0 - pop de - ld a,l - ld (de),a - ld hl,6 ;const - add hl,sp - ld (hl),+(8 % 256 % 256) - ld hl,11 ;const - add hl,sp - call l_gint ; - call l_gint ; - pop bc - push hl -.i_57 -.i_59 - ld hl,8 ;const - add hl,sp - push hl - ld hl,2 ;const - call l_gintspsp ; - ld hl,9 ;const - add hl,sp - inc (hl) - ld l,(hl) - ld h,0 - dec l - pop de - add hl,de - pop de - ld a,(hl) - ld (de),a - ld hl,8 ;const - add hl,sp - ld e,(hl) - ld d,0 - ld hl,32 - and a - sbc hl,de - ccf - jp c,i_61 - ld hl,8 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld de,47 - and a - sbc hl,de - jr nz,i_60 -.i_61 - jp i_58 -.i_60 - ld hl,8 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld de,46 - and a - sbc hl,de - scf - jr z,ASMPC+3 - ccf - jp c,i_64 - ld hl,4 ;const - add hl,sp - ld e,(hl) - ld d,0 - ld hl,6 ;const - add hl,sp - ld l,(hl) - ld h,0 - call l_uge - jp nc,i_63 -.i_64 - ld hl,6 ;const - add hl,sp - ld a,(hl) - cp 8 - jr z,ASMPC+3 - scf - jp c,i_67 - ld hl,8 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld de,46 - and a - sbc hl,de - scf - jr nz,ASMPC+3 - ccf - jr nc,i_66 -.i_67 - jp i_58 -.i_66 - ld hl,4 ;const - add hl,sp - ld (hl),+(8 % 256 % 256) - ld hl,6 ;const - add hl,sp - ld (hl),+(11 % 256 % 256) - ld l,(hl) - ld h,0 - jp i_57 -.i_63 - jp i_70 - ld hl,4 ;const - add hl,sp - ld l,(hl) - ld h,0 - push hl - ld hl,8 ;const - add hl,sp - ld l,(hl) - ld h,0 - dec hl - pop de - ex de,hl - and a - sbc hl,de - jr c,i_71_i_70 -.i_70 - jp i_69 -.i_71_i_70 - ld hl,7 ;const - add hl,sp - push hl - ld hl,2 ;const - call l_gintspsp ; - ld hl,9 ;const - add hl,sp - inc (hl) - ld l,(hl) - ld h,0 - dec l - pop de - add hl,de - pop de - ld a,(hl) - ld (de),a - ld hl,2 ;const - call l_gintspsp ; - ld hl,6 ;const - add hl,sp - inc (hl) - ld l,(hl) - ld h,0 - dec l - pop de - add hl,de - ex de,hl - ld hl,8 ;const - add hl,sp - ld a,(hl) - ld (de),a - ld hl,2 ;const - call l_gintspsp ; - ld hl,6 ;const - add hl,sp - inc (hl) - ld l,(hl) - ld h,0 - dec l - pop de - add hl,de - push hl - ld hl,9 ;const - add hl,sp - ld a,(hl) - pop de - ld (de),a - ld l,a - ld h,0 - jp i_72 -.i_69 - jp i_74 - ld hl,8 ;const - add hl,sp - ld e,(hl) - ld d,0 - ld hl,97 - call l_uge - jp nc,i_75 - ld hl,8 ;const - add hl,sp - ld e,(hl) - ld d,0 - ld hl,122 - and a - sbc hl,de - ccf - jr c,i_76_i_75 -.i_75 - jp i_74 -.i_76_i_75 - jr i_77_i_74 -.i_74 - jp i_73 -.i_77_i_74 - ld hl,8 ;const - add hl,sp - ld a,(hl) - add a,+(-32 % 256) - ld (hl),a -.i_73 - ld hl,2 ;const - call l_gintspsp ; - ld hl,6 ;const - add hl,sp - inc (hl) - ld l,(hl) - ld h,0 - dec l - pop de - add hl,de - push hl - ld hl,10 ;const - add hl,sp - ld a,(hl) - pop de - ld (de),a - ld l,a - ld h,0 -.i_72 - jp i_57 -.i_58 - ld hl,11 ;const - call l_gintspsp ; - ld hl,2 ;const - add hl,sp - ld e,(hl) - inc hl - ld d,(hl) - ld hl,7 ;const - add hl,sp - ld l,(hl) - ld h,0 - add hl,de - pop de - call l_pint - pop bc - pop hl - push hl - push bc - ld bc,11 - add hl,bc - push hl - ld hl,10 ;const - add hl,sp - ld e,(hl) - ld d,0 - ld hl,32 - and a - sbc hl,de - ccf - jp nc,i_78 - ld hl,1 ;const - jp i_79 -.i_78 - ld hl,0 ;const -.i_79 - pop de - ld a,l - ld (de),a - ld hl,0 ;const - inc sp - pop bc - pop bc - pop bc - pop bc - ret - - - -; Function get_fileinfo flags 0x00000200 __smallc -; void get_fileinfo(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir, struct 0__anonstruct_6 FILINFO*fno) -; parameter 'struct 0__anonstruct_6 FILINFO*fno' at 2 size(2) -; parameter 'unsigned char BYTE*dir' at 4 size(2) -; parameter 'struct 0__anonstruct_5 DIR*dj' at 6 size(2) -._get_fileinfo - push bc - push bc - ld hl,6 ;const - add hl,sp - call l_gint ; - ld bc,9 - add hl,bc - pop bc - push hl - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,12 - add hl,bc - call l_glong - ld a,h - or l - or d - or e - jp z,i_80 - ld hl,3 ;const - add hl,sp - ld (hl),+(0 % 256 % 256) - ld l,(hl) - ld h,0 - jp i_83 -.i_81 - ld hl,3 ;const - add hl,sp - inc (hl) -.i_83 - ld hl,3 ;const - add hl,sp - ld a,(hl) - sub 8 - jp nc,i_82 - ld hl,2 ;const - add hl,sp - push hl - ld hl,10 ;const - add hl,sp - ld e,(hl) - inc hl - ld d,(hl) - ld hl,5 ;const - add hl,sp - ld l,(hl) - ld h,0 - add hl,de - ld a,(hl) - pop de - ld (de),a - ld hl,2 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld de,32 - and a - sbc hl,de - jp z,i_82 -.i_84 - ld hl,2 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld a,l - cp 5 - jp nz,i_85 - ld hl,2 ;const - add hl,sp - ld (hl),+(229 % 256 % 256) -.i_85 - pop hl - inc hl - push hl - dec hl - push hl - ld hl,4 ;const - add hl,sp - ld l,(hl) - ld a,l - rla - sbc a - ld h,a - pop de - ld a,l - ld (de),a - jp i_81 -.i_82 - ld hl,8 ;const - add hl,sp - call l_gint ; - ld bc,8 - add hl,bc - ld l,(hl) - ld h,0 - ld de,32 - and a - sbc hl,de - scf - jr nz,ASMPC+3 - ccf - jp nc,i_86 - pop hl - ld (hl),+(46 % 256) - inc hl - push hl - ld hl,3 ;const - add hl,sp - ld (hl),+(8 % 256 % 256) - ld l,(hl) - ld h,0 - jp i_89 -.i_87 - ld hl,3 ;const - add hl,sp - inc (hl) -.i_89 - ld hl,3 ;const - add hl,sp - ld a,(hl) - sub 11 - jp nc,i_88 - ld hl,2 ;const - add hl,sp - push hl - ld hl,10 ;const - add hl,sp - ld e,(hl) - inc hl - ld d,(hl) - ld hl,5 ;const - add hl,sp - ld l,(hl) - ld h,0 - add hl,de - ld a,(hl) - pop de - ld (de),a - ld hl,2 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld de,32 - and a - sbc hl,de - jp z,i_88 -.i_90 - pop hl - inc hl - push hl - dec hl - push hl - ld hl,4 ;const - add hl,sp - ld l,(hl) - ld a,l - rla - sbc a - ld h,a - pop de - ld a,l - ld (de),a - jp i_87 -.i_88 -.i_86 - ld hl,6 ;const - add hl,sp - call l_gint ; - ld bc,8 - add hl,bc - push hl - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,11 - add hl,bc - ld a,(hl) - pop de - ld (de),a - ld hl,6 ;const - call l_gintspsp ; - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,28 - add hl,bc - push hl - call _ld_dword - pop bc - pop bc - call l_plong - ld hl,6 ;const - add hl,sp - call l_gint ; - ld bc,4 - add hl,bc - push hl - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,24 - add hl,bc - push hl - call _ld_word - pop bc - pop de - call l_pint - ld hl,6 ;const - add hl,sp - call l_gint ; - ld bc,6 - add hl,bc - push hl - ld hl,10 ;const - add hl,sp - call l_gint ; - ld bc,22 - add hl,bc - push hl - call _ld_word - pop bc - pop de - call l_pint -.i_80 - pop de - push de - ld hl,0 ;const - ld a,l - ld (de),a - pop bc - pop bc - ret - - - -; Function follow_path flags 0x00000200 __smallc -; const int FRESULTfollow_path(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir, const char *path) -; parameter 'const char *path' at 2 size(2) -; parameter 'unsigned char BYTE*dir' at 4 size(2) -; parameter 'struct 0__anonstruct_5 DIR*dj' at 6 size(2) -._follow_path - push bc -.i_91 - ld hl,4 ;const - add hl,sp - call l_gint ; - ld a,(hl) - cp 32 - jp nz,i_92 - ld hl,4 ;const - add hl,sp - inc (hl) - ld a,(hl) - inc hl - jr nz,ASMPC+3 - inc (hl) - ld h,(hl) - ld l,a - dec hl - jp i_91 -.i_92 - ld hl,4 ;const - add hl,sp - call l_gint ; - ld a,(hl) - cp 47 - jp nz,i_93 - ld hl,4 ;const - add hl,sp - inc (hl) - ld a,(hl) - inc hl - jr nz,ASMPC+3 - inc (hl) -.i_93 - ld hl,8 ;const - add hl,sp - call l_gint ; - ld bc,4 - add hl,bc - xor a - ld (hl),a - inc hl - ld (hl),a - inc hl - ld (hl),a - inc hl - ld (hl),a - ld hl,4 ;const - add hl,sp - call l_gint ; - ld l,(hl) - ld h,0 - ld de,32 - and a - sbc hl,de - jp nc,i_94 - ld hl,8 ;const - add hl,sp - call l_gint ; - push hl - call _dir_rewind - pop bc - pop bc - push hl - ld hl,6 ;const - add hl,sp - ld e,(hl) - inc hl - ld d,(hl) - ld hl,0 % 256 ;const - ld a,l - ld (de),a - jp i_95 -.i_94 -.i_96 -.i_98 - ld hl,8 ;const - call l_gintspsp ; - ld hl,6 ;const - add hl,sp - push hl - call _create_name - pop bc - pop bc - pop bc - push hl - ld a,h - or l - jp nz,i_97 -.i_99 - ld hl,8 ;const - call l_gintspsp ; - ld hl,8 ;const - add hl,sp - call l_gint ; - push hl - call _dir_find - pop bc - pop bc - pop bc - push hl - ld a,h - or l - jp nz,i_97 -.i_100 - ld hl,8 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - call l_gint ; - ld bc,11 - add hl,bc - ld l,(hl) - ld h,0 - ld a,h - or l - jp nz,i_97 -.i_101 - ld hl,6 ;const - add hl,sp - call l_gint ; - ld bc,11 - add hl,bc - ld a,(hl) - and +(16 % 256) - jp nz,i_102 - ld hl,3 ;const - pop bc - push hl - jp i_97 -.i_102 - ld hl,8 ;const - add hl,sp - call l_gint ; - ld bc,4 - add hl,bc - push hl - ld hl,8 ;const - add hl,sp - call l_gint ; - push hl - call _get_clust - pop bc - pop bc - call l_plong - jp i_96 -.i_97 -.i_95 - pop hl - ret - - - -; Function check_fs flags 0x00000200 __smallc -; unsigned char BYTEcheck_fs(unsigned char BYTE*buf, unsigned long sect) -; parameter 'unsigned long sect' at 2 size(4) -; parameter 'unsigned char BYTE*buf' at 6 size(2) -._check_fs - ld hl,6 ;const - call l_gintspsp ; - ld hl,4 ;const - add hl,sp - call l_glong2sp - ld hl,510 ;const - push hl - ld hl,2 ;const - push hl - call _disk_readp - pop bc - pop bc - pop bc - pop bc - pop bc - ld a,h - or l - jp z,i_103 - ld hl,3 % 256 ;const - ret - - -.i_103 - ld hl,6 ;const - add hl,sp - call l_gint ; - push hl - call _ld_word - pop bc - ld de,43605 - and a - sbc hl,de - scf - jr nz,ASMPC+3 - ccf - jp nc,i_104 - ld hl,2 % 256 ;const - ret - - -.i_104 - ld hl,6 ;const - call l_gintspsp ; - ld hl,4 ;const - add hl,sp - call l_glong2sp - ld hl,82 ;const - push hl - ld hl,2 ;const - push hl - call _disk_readp - pop bc - pop bc - pop bc - pop bc - pop bc - call l_lneg - jp nc,i_106 - ld hl,6 ;const - add hl,sp - call l_gint ; - push hl - call _ld_word - pop bc - ld de,16710 - and a - sbc hl,de - jr z,i_107_i_106 -.i_106 - jp i_105 -.i_107_i_106 - ld hl,0 % 256 ;const - ret - - -.i_105 - ld hl,1 % 256 ;const - ret - - - -; Function pf_mount flags 0x00000200 __smallc -; const int FRESULTpf_mount(struct 0__anonstruct_4 FATFS*fs) -; parameter 'struct 0__anonstruct_4 FATFS*fs' at 2 size(2) -._pf_mount - ld hl,65483 ;const - add hl,sp - ld sp,hl - ld hl,0 ;const - ld (_FatFs),hl - call _disk_initialize - ld a,l - and +(1 % 256) - jp z,i_108 - ld hl,53 ;const - add hl,sp - ld sp,hl - ld hl,2 ;const - ret - - -.i_108 - ld hl,12 ;const - add hl,sp - xor a - ld (hl),a - inc hl - ld (hl),a - inc hl - ld (hl),a - inc hl - ld (hl),a - ld hl,52 ;const - add hl,sp - push hl - ld hl,18 ;const - add hl,sp - push hl - ld hl,16 ;const - add hl,sp - call l_glong - push de - push hl - call _check_fs - pop bc - pop bc - pop bc - pop de - ld a,l - ld (de),a - ld hl,52 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld a,l - cp 1 - jp nz,i_109 - ld hl,16 ;const - add hl,sp - push hl - ld hl,14 ;const - add hl,sp - call l_glong2sp - ld hl,446 ;const - push hl - ld hl,16 ;const - push hl - call _disk_readp - pop bc - pop bc - pop bc - pop bc - pop bc - ld a,h - or l - jp z,i_110 - ld hl,52 ;const - add hl,sp - ld (hl),+(3 % 256 % 256) - ld l,(hl) - ld h,0 - jp i_111 -.i_110 - ld hl,20 ;const - add hl,sp - ld a,(hl) - and a - jp z,i_112 - ld hl,12 ;const - add hl,sp - push hl - ld hl,26 ;const - add hl,sp - push hl - call _ld_dword - pop bc - pop bc - call l_plong - ld hl,52 ;const - add hl,sp - push hl - ld hl,18 ;const - add hl,sp - push hl - ld hl,16 ;const - add hl,sp - call l_glong - push de - push hl - call _check_fs - pop bc - pop bc - pop bc - pop de - ld a,l - ld (de),a -.i_112 -.i_111 -.i_109 - ld hl,52 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld a,l - cp 3 - jp nz,i_113 - ld hl,53 ;const - add hl,sp - ld sp,hl - ld hl,1 ;const - ret - - -.i_113 - ld hl,52 ;const - add hl,sp - ld a,(hl) - and a - jp z,i_114 - ld hl,53 ;const - add hl,sp - ld sp,hl - ld hl,6 ;const - ret - - -.i_114 - ld hl,16 ;const - add hl,sp - push hl - ld hl,14 ;const - add hl,sp - call l_glong2sp - ld hl,13 ;const - push hl - ld hl,36 ;const - push hl - call _disk_readp - pop bc - pop bc - pop bc - pop bc - pop bc - ld a,h - or l - jp z,i_115 - ld hl,53 ;const - add hl,sp - ld sp,hl - ld hl,1 ;const - ret - - -.i_115 - ld hl,8 ;const - add hl,sp - push hl - ld hl,27 ;const - add hl,sp - push hl - call _ld_word - pop bc - ld de,0 - pop bc - call l_plong - ld hl,8 ;const - add hl,sp - call l_glong - call l_long_lneg - jp nc,i_116 - ld hl,8 ;const - add hl,sp - push hl - ld hl,41 ;const - add hl,sp - push hl - call _ld_dword - pop bc - pop bc - call l_plong -.i_116 - ld hl,8 ;const - add hl,sp - push hl - call l_glong2sp - ld hl,25 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld de,0 - call l_long_mult - pop bc - call l_plong - ld hl,55 ;const - add hl,sp - call l_gint ; - ld bc,10 - add hl,bc - push hl - ld hl,14 ;const - add hl,sp - call l_glong2sp - ld hl,23 ;const - add hl,sp - push hl - call _ld_word - pop bc - ld de,0 - call l_long_add - pop bc - call l_plong - ld hl,55 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - ex de,hl - ld hl,16 ;const - add hl,sp - ld a,(hl) - ld (de),a - ld hl,55 ;const - add hl,sp - call l_gint ; - ld bc,4 - add hl,bc - push hl - ld hl,22 ;const - add hl,sp - push hl - call _ld_word - pop bc - pop de - call l_pint - ld hl,4 ;const - add hl,sp - push hl - ld hl,24 ;const - add hl,sp - push hl - call _ld_word - pop bc - ld de,0 - pop bc - call l_plong - ld hl,4 ;const - add hl,sp - call l_glong - call l_long_lneg - jp nc,i_117 - ld hl,4 ;const - add hl,sp - push hl - ld hl,37 ;const - add hl,sp - push hl - call _ld_dword - pop bc - pop bc - call l_plong -.i_117 - ld hl,0 ;const - add hl,sp - push hl - ld hl,6 ;const - add hl,sp - call l_glong2sp - ld hl,23 ;const - add hl,sp - push hl - call _ld_word - pop bc - ld de,0 - call l_long_sub - push de - push hl - ld hl,14 ;const - add hl,sp - call l_glong - call l_long_sub - push de - push hl - ld hl,61 ;const - add hl,sp - call l_gint ; - ld bc,4 - add hl,bc - call l_gint ; - ld de,4 - call l_asr_u_hl_by_e - ld de,0 - call l_long_sub - push de - push hl - ld hl,61 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - ld l,(hl) - ld h,0 - ld de,0 - call l_long_div_u - ld bc,2 - add hl,bc - jr nc,ASMPC+3 - inc de - pop bc - call l_plong - ld hl,55 ;const - add hl,sp - call l_gint ; - ld bc,6 - add hl,bc - push hl - ld hl,2 ;const - add hl,sp - call l_glong - pop bc - call l_plong - ld hl,52 ;const - add hl,sp - ld (hl),+(0 % 256 % 256) - ld hl,0 ;const - add hl,sp - call l_glong2sp - ld hl,65527 ;const - ld de,0 - call l_long_uge - jp nc,i_118 - ld hl,52 ;const - add hl,sp - ld (hl),+(3 % 256 % 256) -.i_118 - ld hl,52 ;const - add hl,sp - ld a,(hl) - and a - jp nz,i_119 - ld hl,53 ;const - add hl,sp - ld sp,hl - ld hl,6 ;const - ret - - -.i_119 - ld hl,55 ;const - call l_gintspsp ; - ld hl,54 ;const - add hl,sp - ld a,(hl) - pop de - ld (de),a - ld hl,55 ;const - add hl,sp - call l_gint ; - ld bc,14 - add hl,bc - push hl - ld hl,49 ;const - add hl,sp - push hl - call _ld_dword - pop bc - pop bc - call l_plong - ld hl,55 ;const - add hl,sp - call l_gint ; - ld bc,18 - add hl,bc - push hl - ld hl,57 ;const - add hl,sp - call l_gint ; - ld bc,10 - add hl,bc - call l_glong2sp - ld hl,14 ;const - add hl,sp - call l_glong - call l_long_add - push de - push hl - ld hl,61 ;const - add hl,sp - call l_gint ; - ld bc,4 - add hl,bc - call l_gint ; - ld de,4 - call l_asr_u_hl_by_e - ld de,0 - call l_long_add - pop bc - call l_plong - ld hl,55 ;const - add hl,sp - call l_gint ; - inc hl - ld (hl),+(0 % 256 % 256) - ld hl,55 ;const - add hl,sp - call l_gint ; - ld (_FatFs),hl - ld hl,53 ;const - add hl,sp - ld sp,hl - ld hl,0 ;const - ret - - - -; Function pf_open flags 0x00000200 __smallc -; const int FRESULTpf_open(const char *path) -; parameter 'const char *path' at 2 size(2) -._pf_open - ld hl,65474 ;const - add hl,sp - ld sp,hl - ld hl,(_FatFs) - push hl - call l_lneg - jp nc,i_120 - ld hl,64 ;const - add hl,sp - ld sp,hl - ld hl,5 ;const - ret - - -.i_120 - pop hl - push hl - inc hl - ld (hl),+(0 % 256 % 256) - ld hl,48 ;const - add hl,sp - push hl - ld hl,36 ;const - add hl,sp - pop de - call l_pint - ld hl,62 ;const - add hl,sp - push hl - ld hl,48 ;const - add hl,sp - push hl - ld hl,6 ;const - add hl,sp - push hl - ld hl,72 ;const - add hl,sp - call l_gint ; - push hl - call _follow_path - pop bc - pop bc - pop bc - pop de - call l_pint - ld hl,62 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp z,i_121 - ld hl,62 ;const - add hl,sp - call l_gint ; - exx - ld hl,64 ;const - add hl,sp - ld sp,hl - exx - ret - - -.i_121 - ld hl,2 ;const - add hl,sp - ld a,(hl) - and a - jp z,i_123 - ld hl,13 ;const - add hl,sp - ld a,+(16 % 256) - and (hl) - jp z,i_122 -.i_123 - ld hl,64 ;const - add hl,sp - ld sp,hl - ld hl,3 ;const - ret - - -.i_122 - pop hl - push hl - ld bc,30 - add hl,bc - push hl - ld hl,4 ;const - add hl,sp - push hl - call _get_clust - pop bc - pop bc - call l_plong - pop hl - push hl - ld bc,26 - add hl,bc - push hl - ld hl,32 ;const - add hl,sp - push hl - call _ld_dword - pop bc - pop bc - call l_plong - pop hl - push hl - ld bc,22 - add hl,bc - xor a - ld (hl),a - inc hl - ld (hl),a - inc hl - ld (hl),a - inc hl - ld (hl),a - pop hl - push hl - inc hl - ld (hl),+(1 % 256 % 256) - ld hl,64 ;const - add hl,sp - ld sp,hl - ld hl,0 ;const - ret - - - -; Function pf_read flags 0x00000200 __smallc -; const int FRESULTpf_read(void *buff, unsigned int btr, unsigned int UINT*br) -; parameter 'unsigned int UINT*br' at 2 size(2) -; parameter 'unsigned int btr' at 4 size(2) -; parameter 'void *buff' at 6 size(2) -._pf_read - ld hl,65519 ;const - add hl,sp - ld sp,hl - ld hl,23 ;const - add hl,sp - ld e,(hl) - inc hl - ld d,(hl) - push de - ld hl,(_FatFs) - push hl - ld hl,23 ;const - add hl,sp - ld a,(hl) - inc hl - ld h,(hl) - ld l,a - xor a - ld (hl),a - inc hl - ld (hl),a - pop hl - push hl - call l_lneg - jp nc,i_125 - ld hl,21 ;const - add hl,sp - ld sp,hl - ld hl,5 ;const - ret - - -.i_125 - pop hl - push hl - inc hl - ld a,(hl) - and +(1 % 256) - jp nz,i_126 - ld hl,21 ;const - add hl,sp - ld sp,hl - ld hl,4 ;const - ret - - -.i_126 - ld hl,7 ;const - add hl,sp - pop de - push de - push hl - ex de,hl - ld bc,26 - add hl,bc - call l_glong2sp - ld hl,6 ;const - add hl,sp - call l_gint ; - ld bc,22 - add hl,bc - call l_glong - call l_long_sub - pop bc - call l_plong - ld hl,25 ;const - call l_gintspsp ; - ld hl,9 ;const - add hl,sp - call l_glong - exx - pop hl - ld de,0 - push de - push hl - exx - call l_long_ugt - jp nc,i_127 - ld hl,25 ;const - add hl,sp - push hl - ld hl,9 ;const - add hl,sp - call l_glong - pop de - call l_pint -.i_127 -.i_128 - ld hl,25 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp z,i_129 - pop hl - push hl - ld bc,22 - add hl,bc - call l_glong2sp - ld hl,512 ;const - ld de,0 - call l_long_div_u - exx - ld a,d - or e - or h - or l - jp nz,i_130 - ld hl,4 ;const - add hl,sp - pop de - push de - push hl - ex de,hl - ld bc,22 - add hl,bc - call l_glong2sp - ld hl,512 ;const - ld de,0 - call l_long_div_u - push de - push hl - ld hl,6 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - ld l,(hl) - ld h,0 - dec hl - ld de,0 - call l_long_and - pop de - ld a,l - ld (de),a - ld hl,4 ;const - add hl,sp - ld a,(hl) - and a - jp nz,i_131 - pop hl - push hl - ld bc,22 - add hl,bc - call l_glong - ld a,d - or e - or h - or l - jp nz,i_132 - ld hl,15 ;const - add hl,sp - pop de - push de - push hl - ex de,hl - ld bc,30 - add hl,bc - call l_glong - pop bc - call l_plong - jp i_133 -.i_132 - ld hl,15 ;const - add hl,sp - pop de - push de - push hl - ex de,hl - ld bc,34 - add hl,bc - call l_glong - push de - push hl - call _get_fat - pop bc - pop bc - pop bc - call l_plong -.i_133 - ld hl,15 ;const - add hl,sp - call l_glong2sp - ld hl,1 ;const - ld de,0 - call l_long_ule - jp nc,i_134 - pop hl - push hl - inc hl - ld (hl),+(0 % 256 % 256) - ld hl,21 ;const - add hl,sp - ld sp,hl - ld hl,1 ;const - ret - - -.i_134 - pop hl - push hl - ld bc,34 - add hl,bc - push hl - ld hl,17 ;const - add hl,sp - call l_glong - pop bc - call l_plong -.i_131 - ld hl,11 ;const - add hl,sp - pop de - push de - push hl - ex de,hl - ld bc,34 - add hl,bc - call l_glong - push de - push hl - call _clust2sect - pop bc - pop bc - pop bc - call l_plong - ld hl,11 ;const - add hl,sp - call l_glong - call l_long_lneg - jp nc,i_135 - pop hl - push hl - inc hl - ld (hl),+(0 % 256 % 256) - ld hl,21 ;const - add hl,sp - ld sp,hl - ld hl,1 ;const - ret - - -.i_135 - pop hl - push hl - ld bc,38 - add hl,bc - push hl - ld hl,13 ;const - add hl,sp - call l_glong2sp - ld hl,10 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld de,0 - call l_long_add - pop bc - call l_plong -.i_130 - ld hl,5 ;const - add hl,sp - pop de - push de - push hl - ex de,hl - ld bc,22 - add hl,bc - call l_gint - ld de,512 - ex de,hl - call l_div_u - ld hl,512 - and a - sbc hl,de - pop de - call l_pint - ld hl,5 ;const - call l_gintspsp ; - ld hl,27 ;const - add hl,sp - call l_gint ; - pop de - and a - sbc hl,de - jp nc,i_136 - ld hl,5 ;const - add hl,sp - ex de,hl - ld hl,25 ;const - add hl,sp - call l_gint ; - call l_pint -.i_136 - ld hl,19 ;const - add hl,sp - push hl - ld hl,4 ;const - call l_gintspsp ; - ld hl,4 ;const - add hl,sp - call l_gint ; - ld bc,38 - add hl,bc - call l_glong2sp - ld hl,8 ;const - add hl,sp - call l_gint ; - ld bc,22 - add hl,bc - call l_gint - ld de,512 - ex de,hl - call l_div_u - ex de,hl - push hl - ld hl,15 ;const - add hl,sp - call l_gint ; - push hl - call _disk_readp - pop bc - pop bc - pop bc - pop bc - pop bc - pop de - call l_pint - ld hl,19 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp z,i_137 - pop hl - push hl - inc hl - ld (hl),+(0 % 256 % 256) - ld hl,21 ;const - add hl,sp - ld sp,hl - ld hl,1 ;const - ret - - -.i_137 - pop hl - push hl - ld bc,22 - add hl,bc - push hl - call l_glong2sp - ld hl,11 ;const - add hl,sp - call l_gint ; - ld de,0 - call l_long_add - pop bc - call l_plong - ld hl,25 ;const - add hl,sp - push hl - ld e,(hl) - inc hl - ld d,(hl) - ld hl,7 ;const - add hl,sp - call l_gint - ex de,hl - and a - sbc hl,de - pop de - call l_pint - ld hl,23 ;const - add hl,sp - call l_gint ; - push hl - ld e,(hl) - inc hl - ld d,(hl) - ld hl,7 ;const - add hl,sp - call l_gint - add hl,de - pop de - call l_pint - pop bc - pop hl - push hl - push bc - ld a,h - or l - jp z,i_138 - ld hl,2 ;const - call l_gintspsp ; - ld hl,7 ;const - add hl,sp - call l_gint ; - pop de - add hl,de - pop de - pop bc - push hl - push de -.i_138 - jp i_128 -.i_129 - ld hl,21 ;const - add hl,sp - ld sp,hl - ld hl,0 ;const - ret - - - -; Function pf_write flags 0x00000200 __smallc -; const int FRESULTpf_write(const void *buff, unsigned int btw, unsigned int UINT*bw) -; parameter 'unsigned int UINT*bw' at 2 size(2) -; parameter 'unsigned int btw' at 4 size(2) -; parameter 'const void *buff' at 6 size(2) -._pf_write - ld hl,65524 ;const - add hl,sp - ld sp,hl - ld hl,18 ;const - add hl,sp - call l_gint ; - push hl - push bc - dec sp - ld hl,(_FatFs) - push hl - ld hl,21 ;const - add hl,sp - ld a,(hl) - inc hl - ld h,(hl) - ld l,a - xor a - ld (hl),a - inc hl - ld (hl),a - pop hl - push hl - call l_lneg - jp nc,i_139 - ld hl,19 ;const - add hl,sp - ld sp,hl - ld hl,5 ;const - ret - - -.i_139 - pop hl - push hl - inc hl - ld a,(hl) - and +(1 % 256) - jp nz,i_140 - ld hl,19 ;const - add hl,sp - ld sp,hl - ld hl,4 ;const - ret - - -.i_140 - ld hl,23 ;const - add hl,sp - call l_gint ; - call l_lneg - jp nc,i_141 - pop hl - push hl - inc hl - ld a,+(64 % 256) - and (hl) - jp z,i_143 - ld hl,0 ;const - push hl - ld d,h - ld e,l - push de - push hl - call _disk_writep - pop bc - pop bc - pop bc - ld a,h - or l - jr nz,i_144_i_143 -.i_143 - jp i_142 -.i_144_i_143 - pop hl - push hl - inc hl - ld (hl),+(0 % 256 % 256) - ld hl,19 ;const - add hl,sp - ld sp,hl - ld hl,1 ;const - ret - - -.i_142 - pop hl - push hl - inc hl - push hl - ld a,(hl) - and 191 - ld l,a - ld h,0 - pop de - ld a,l - ld (de),a - ld hl,19 ;const - add hl,sp - ld sp,hl - ld hl,0 ;const - ret - - -.i_141 - pop hl - push hl - inc hl - ld a,(hl) - and +(64 % 256) - jp nz,i_146 - pop hl - push hl - ld bc,22 - add hl,bc - push hl - call l_glong2sp - ld hl,65024 ;const - ld de,65535 - call l_long_and - pop bc - call l_plong -.i_146 -.i_145 - ld hl,7 ;const - add hl,sp - pop de - push de - push hl - ex de,hl - ld bc,26 - add hl,bc - call l_glong2sp - ld hl,6 ;const - add hl,sp - call l_gint ; - ld bc,22 - add hl,bc - call l_glong - call l_long_sub - pop bc - call l_plong - ld hl,23 ;const - call l_gintspsp ; - ld hl,9 ;const - add hl,sp - call l_glong - exx - pop hl - ld de,0 - push de - push hl - exx - call l_long_ugt - jp nc,i_147 - ld hl,23 ;const - add hl,sp - push hl - ld hl,9 ;const - add hl,sp - call l_glong - pop de - call l_pint -.i_147 -.i_148 - ld hl,23 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp z,i_149 - pop hl - push hl - ld bc,22 - add hl,bc - call l_gint - ld de,512 - ex de,hl - call l_div_u - ex de,hl - ld a,h - or l - jp nz,i_150 - ld hl,4 ;const - add hl,sp - pop de - push de - push hl - ex de,hl - ld bc,22 - add hl,bc - call l_glong2sp - ld hl,512 ;const - ld de,0 - call l_long_div_u - push de - push hl - ld hl,6 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - ld l,(hl) - ld h,0 - dec hl - ld de,0 - call l_long_and - pop de - ld a,l - ld (de),a - ld hl,4 ;const - add hl,sp - ld a,(hl) - and a - jp nz,i_151 - pop hl - push hl - ld bc,22 - add hl,bc - call l_glong - ld a,d - or e - or h - or l - jp nz,i_152 - ld hl,15 ;const - add hl,sp - pop de - push de - push hl - ex de,hl - ld bc,30 - add hl,bc - call l_glong - pop bc - call l_plong - jp i_153 -.i_152 - ld hl,15 ;const - add hl,sp - pop de - push de - push hl - ex de,hl - ld bc,34 - add hl,bc - call l_glong - push de - push hl - call _get_fat - pop bc - pop bc - pop bc - call l_plong -.i_153 - ld hl,15 ;const - add hl,sp - call l_glong2sp - ld hl,1 ;const - ld de,0 - call l_long_ule - jp nc,i_154 - pop hl - push hl - inc hl - ld (hl),+(0 % 256 % 256) - ld hl,19 ;const - add hl,sp - ld sp,hl - ld hl,1 ;const - ret - - -.i_154 - pop hl - push hl - ld bc,34 - add hl,bc - push hl - ld hl,17 ;const - add hl,sp - call l_glong - pop bc - call l_plong -.i_151 - ld hl,11 ;const - add hl,sp - pop de - push de - push hl - ex de,hl - ld bc,34 - add hl,bc - call l_glong - push de - push hl - call _clust2sect - pop bc - pop bc - pop bc - call l_plong - ld hl,11 ;const - add hl,sp - call l_glong - call l_long_lneg - jp nc,i_155 - pop hl - push hl - inc hl - ld (hl),+(0 % 256 % 256) - ld hl,19 ;const - add hl,sp - ld sp,hl - ld hl,1 ;const - ret - - -.i_155 - pop hl - push hl - ld bc,38 - add hl,bc - push hl - ld hl,13 ;const - add hl,sp - call l_glong2sp - ld hl,10 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld de,0 - call l_long_add - pop bc - call l_plong - pop hl - push hl - ld bc,0 - push bc - ld bc,38 - add hl,bc - call l_glong - push de - push hl - call _disk_writep - pop bc - pop bc - pop bc - ld a,h - or l - jp z,i_156 - pop hl - push hl - inc hl - ld (hl),+(0 % 256 % 256) - ld hl,19 ;const - add hl,sp - ld sp,hl - ld hl,1 ;const - ret - - -.i_156 - pop hl - push hl - inc hl - ld a,(hl) - or 64 - ld (hl),a -.i_150 - pop hl - push hl - ld bc,22 - add hl,bc - call l_gint - ld de,512 - ex de,hl - call l_div_u - ld hl,512 - and a - sbc hl,de - pop de - pop bc - push hl - push de - ld hl,2 ;const - call l_gintspsp ; - ld hl,25 ;const - add hl,sp - call l_gint ; - pop de - and a - sbc hl,de - jp nc,i_157 - ld hl,23 ;const - add hl,sp - call l_gint ; - pop de - pop bc - push hl - push de -.i_157 - ld hl,5 ;const - call l_gintspsp ; - ld hl,4 ;const - add hl,sp - call l_gint ; - ld de,0 - push de - push hl - call _disk_writep - pop bc - pop bc - pop bc - ld a,h - or l - jp z,i_158 - pop hl - push hl - inc hl - ld (hl),+(0 % 256 % 256) - ld hl,19 ;const - add hl,sp - ld sp,hl - ld hl,1 ;const - ret - - -.i_158 - pop hl - push hl - ld bc,22 - add hl,bc - push hl - call l_glong2sp - ld hl,8 ;const - add hl,sp - call l_gint ; - ld de,0 - call l_long_add - pop bc - call l_plong - ld hl,5 ;const - add hl,sp - push hl - ld e,(hl) - inc hl - ld d,(hl) - ld hl,4 ;const - add hl,sp - call l_gint - add hl,de - pop de - call l_pint - ld hl,23 ;const - add hl,sp - push hl - ld e,(hl) - inc hl - ld d,(hl) - ld hl,4 ;const - add hl,sp - call l_gint - ex de,hl - and a - sbc hl,de - pop de - call l_pint - ld hl,21 ;const - add hl,sp - call l_gint ; - push hl - ld e,(hl) - inc hl - ld d,(hl) - ld hl,4 ;const - add hl,sp - call l_gint - add hl,de - pop de - call l_pint - pop hl - push hl - ld bc,22 - add hl,bc - call l_gint - ld de,512 - ex de,hl - call l_div_u - ex de,hl - ld a,h - or l - jp nz,i_159 - push hl - ld hl,0 ;const - ld d,h - ld e,l - push de - push hl - call _disk_writep - pop bc - pop bc - pop bc - ld a,h - or l - jp z,i_160 - pop hl - push hl - inc hl - ld (hl),+(0 % 256 % 256) - ld hl,19 ;const - add hl,sp - ld sp,hl - ld hl,1 ;const - ret - - -.i_160 - pop hl - push hl - inc hl - push hl - ld a,(hl) - and 191 - ld l,a - ld h,0 - pop de - ld a,l - ld (de),a -.i_159 - jp i_148 -.i_149 - ld hl,19 ;const - add hl,sp - ld sp,hl - ld hl,0 ;const - ret - - - -; Function pf_opendir flags 0x00000200 __smallc -; const int FRESULTpf_opendir(struct 0__anonstruct_5 DIR*dj, const char *path) -; parameter 'const char *path' at 2 size(2) -; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) -._pf_opendir - ld hl,65490 ;const - add hl,sp - ld sp,hl - ld hl,(_FatFs) - push hl - call l_lneg - jp nc,i_161 - ld hl,46 ;const - add hl,sp - ld de,5 ;const - ex de,hl - call l_pint - jp i_162 -.i_161 - ld hl,i_1+33 - push hl - ld a,1 - call printf - pop bc - ld hl,52 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - push hl - ld hl,36 ;const - add hl,sp - pop de - call l_pint - ld hl,46 ;const - add hl,sp - push hl - ld hl,54 ;const - call l_gintspsp ; - ld hl,6 ;const - add hl,sp - push hl - ld hl,56 ;const - add hl,sp - call l_gint ; - push hl - call _follow_path - pop bc - pop bc - pop bc - pop de - call l_pint - ld hl,i_1+42 - push hl - ld hl,48 ;const - add hl,sp - call l_gint ; - push hl - ld a,2 - call printf - pop bc - pop bc - ld hl,46 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp nz,i_163 - ld hl,2 ;const - add hl,sp - ld a,(hl) - and a - jp z,i_164 - ld hl,i_1+55 - push hl - ld hl,4 ;const - add hl,sp - ld l,(hl) - ld h,0 - push hl - ld a,2 - call printf - pop bc - pop bc - ld hl,13 ;const - add hl,sp - ld a,+(16 % 256) - and (hl) - jp z,i_165 - ld hl,52 ;const - add hl,sp - call l_gint ; - ld bc,4 - add hl,bc - push hl - ld hl,4 ;const - add hl,sp - push hl - call _get_clust - pop bc - pop bc - call l_plong - jp i_166 -.i_165 - ld hl,46 ;const - add hl,sp - ld de,3 ;const - ex de,hl - call l_pint -.i_166 -.i_164 - ld hl,46 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp nz,i_167 - ld hl,46 ;const - add hl,sp - push hl - ld hl,54 ;const - add hl,sp - call l_gint ; - push hl - call _dir_rewind - pop bc - pop de - call l_pint -.i_167 -.i_163 -.i_162 - ld hl,46 ;const - add hl,sp - call l_gint ; - exx - ld hl,48 ;const - add hl,sp - ld sp,hl - exx - ret - - - -; Function pf_readdir flags 0x00000200 __smallc -; const int FRESULTpf_readdir(struct 0__anonstruct_5 DIR*dj, struct 0__anonstruct_6 FILINFO*fno) -; parameter 'struct 0__anonstruct_6 FILINFO*fno' at 2 size(2) -; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) -._pf_readdir - ld hl,65490 ;const - add hl,sp - ld sp,hl - ld hl,(_FatFs) - push hl - call l_lneg - jp nc,i_168 - ld hl,46 ;const - add hl,sp - ld de,5 ;const - ex de,hl - call l_pint - jp i_169 -.i_168 - ld hl,52 ;const - add hl,sp - call l_gint ; - inc hl - inc hl - push hl - ld hl,36 ;const - add hl,sp - pop de - call l_pint - ld hl,50 ;const - add hl,sp - call l_gint ; - call l_lneg - jp nc,i_170 - ld hl,46 ;const - add hl,sp - push hl - ld hl,54 ;const - add hl,sp - call l_gint ; - push hl - call _dir_rewind - pop bc - pop de - call l_pint - jp i_171 -.i_170 - ld hl,i_1+70 - push hl - ld a,1 - call printf - pop bc - ld hl,46 ;const - add hl,sp - push hl - ld hl,54 ;const - call l_gintspsp ; - ld hl,6 ;const - add hl,sp - push hl - call _dir_read - pop bc - pop bc - pop de - call l_pint - ld hl,46 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp nz,i_172 - ld hl,52 ;const - call l_gintspsp ; - ld hl,4 ;const - add hl,sp - push hl - ld hl,54 ;const - add hl,sp - call l_gint ; - push hl - call _get_fileinfo - pop bc - pop bc - pop bc - ld hl,46 ;const - add hl,sp - push hl - ld hl,54 ;const - add hl,sp - call l_gint ; - push hl - call _dir_next - pop bc - pop de - call l_pint - ld hl,46 ;const - add hl,sp - call l_gint ; - ld de,3 - and a - sbc hl,de - jp nz,i_173 - ld hl,46 ;const - add hl,sp - ld de,0 ;const - ex de,hl - call l_pint -.i_173 -.i_172 -.i_171 -.i_169 - ld hl,46 ;const - add hl,sp - call l_gint ; - exx - ld hl,48 ;const - add hl,sp - ld sp,hl - exx - ret - - - SECTION rodata_compiler -.i_1 - defm "dir_read: sector:%ld, index:%l" - defm "d" - defb 10 - - defm "" - defb 0 - - defm "OPENDIR" - defb 10 - - defm "" - defb 0 - - defm "RESDIR:%02x" - defb 10 - - defm "" - defb 0 - - defm "IS A DIR:%02x" - defb 10 - - defm "" - defb 0 - - defm "Readdir" - defb 10 - - defm "" - defb 0 - - -; --- Start of Static Variables --- - - SECTION bss_compiler -._FatFs defs 2 - SECTION code_compiler - - -; --- Start of Scope Defns --- - - GLOBAL open - GLOBAL creat - GLOBAL close - GLOBAL read - GLOBAL write - GLOBAL lseek - GLOBAL readbyte - GLOBAL writebyte - GLOBAL getcwd - GLOBAL chdir - GLOBAL getwd - GLOBAL rmdir - GLOBAL _RND_BLOCKSIZE - GLOBAL rnd_loadblock - GLOBAL rnd_saveblock - GLOBAL rnd_erase - GLOBAL __FOPEN_MAX - GLOBAL __sgoioblk - GLOBAL __sgoioblk_end - GLOBAL fopen_zsock - GLOBAL fopen - GLOBAL freopen - GLOBAL fdopen - GLOBAL _freopen1 - GLOBAL fmemopen - GLOBAL funopen - GLOBAL fclose - GLOBAL fflush - GLOBAL closeall - GLOBAL fgets - GLOBAL fputs - GLOBAL fputc - GLOBAL fputs_callee - GLOBAL fputc_callee - GLOBAL fgetc - GLOBAL ungetc - GLOBAL feof - GLOBAL ferror - GLOBAL puts - GLOBAL ftell - GLOBAL fgetpos - GLOBAL fseek - GLOBAL fread - GLOBAL fwrite - GLOBAL gets - GLOBAL printf - GLOBAL fprintf - GLOBAL sprintf - GLOBAL snprintf - GLOBAL vfprintf - GLOBAL vsnprintf - GLOBAL printn - GLOBAL scanf - GLOBAL fscanf - GLOBAL sscanf - GLOBAL vfscanf - GLOBAL vsscanf - GLOBAL getarg - GLOBAL fchkstd - GLOBAL fgetc_cons - GLOBAL fgetc_cons_inkey - GLOBAL fputc_cons - GLOBAL fgets_cons - GLOBAL puts_cons - GLOBAL fabandon - GLOBAL fdtell - GLOBAL fdgetpos - GLOBAL rename - GLOBAL remove - GLOBAL getk - GLOBAL getk_inkey - GLOBAL printk - GLOBAL perror - GLOBAL atoi - GLOBAL atol - GLOBAL itoa - GLOBAL itoa_callee - GLOBAL ltoa - GLOBAL ltoa_callee - GLOBAL strtol - GLOBAL strtol_callee - GLOBAL strtoul - GLOBAL strtoul_callee - GLOBAL ultoa - GLOBAL ultoa_callee - GLOBAL utoa - GLOBAL utoa_callee - GLOBAL rand - GLOBAL srand - GLOBAL mallinit - GLOBAL sbrk - GLOBAL sbrk_callee - GLOBAL calloc - GLOBAL calloc_callee - GLOBAL free - GLOBAL malloc - GLOBAL realloc - GLOBAL realloc_callee - GLOBAL mallinfo - GLOBAL mallinfo_callee - GLOBAL HeapCreate - GLOBAL HeapSbrk - GLOBAL HeapSbrk_callee - GLOBAL HeapCalloc - GLOBAL HeapCalloc_callee - GLOBAL HeapFree - GLOBAL HeapFree_callee - GLOBAL HeapAlloc - GLOBAL HeapAlloc_callee - GLOBAL HeapRealloc - GLOBAL HeapRealloc_callee - GLOBAL HeapInfo - GLOBAL HeapInfo_callee - GLOBAL exit - GLOBAL atexit - GLOBAL getopt - GLOBAL _optarg - GLOBAL _opterr - GLOBAL _optind - GLOBAL _optopt - GLOBAL _optreset - GLOBAL l_bsearch - GLOBAL l_bsearch_callee - GLOBAL l_qsort - GLOBAL l_qsort_callee - GLOBAL qsort_sccz80 - GLOBAL qsort_sccz80_callee - GLOBAL qsort_sdcc - GLOBAL qsort_sdcc_callee - GLOBAL _div_ - GLOBAL _div__callee - GLOBAL _divu_ - GLOBAL _divu__callee - GLOBAL _ldiv_ - GLOBAL _ldiv__callee - GLOBAL _ldivu_ - GLOBAL _ldivu__callee - GLOBAL abs - GLOBAL labs - GLOBAL isqrt - GLOBAL inp - GLOBAL outp - GLOBAL outp_callee - GLOBAL swapendian - GLOBAL bpoke - GLOBAL bpoke_callee - GLOBAL wpoke - GLOBAL wpoke_callee - GLOBAL bpeek - GLOBAL wpeek - GLOBAL t_delay - GLOBAL sleep - GLOBAL msleep - GLOBAL extract_bits - GLOBAL extract_bits_callee - GLOBAL wcmatch - GLOBAL unbcd - GLOBAL _pf_mount - GLOBAL _pf_open - GLOBAL _pf_read - GLOBAL _pf_write - GLOBAL _pf_lseek - GLOBAL _pf_opendir - GLOBAL _pf_readdir - GLOBAL _disk_initialize - GLOBAL _disk_readp - GLOBAL _disk_writep - - -; --- End of Scope Defns --- - - -; --- End of Compilation --- diff --git a/software/src/PetitFS/pff.h b/software/src/PetitFS/pff.h deleted file mode 100644 index fd6c5c0..0000000 --- a/software/src/PetitFS/pff.h +++ /dev/null @@ -1,486 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module include file R0.03a -/----------------------------------------------------------------------------/ -/ Petit FatFs module is an open source software to implement FAT file system to -/ small embedded systems. This is a free software and is opened for education, -/ research and commercial developments under license policy of following trems. -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ * The Petit FatFs module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/----------------------------------------------------------------------------*/ - -#ifndef PF_DEFINED -#define PF_DEFINED 8088 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -/*---------------------------------------------------------------------------/ -/ Locale and Namespace Configurations -/---------------------------------------------------------------------------*/ - -#define PF_USE_LCC 0 /* Allow lower case ASCII and non-ASCII chars */ -#define _FS_32ONLY 1 - -#define ABORT(err) {fs->flag = 0; return err;} - -#define PF_CODE_PAGE 437 -/* The PF_CODE_PAGE specifies the code page to be used on the target system. -/ SBCS code pages with PF_USE_LCC == 1 requiers a 128 byte of case conversion -/ table. It might occupy RAM on some platforms, e.g. avr-gcc. -/ When PF_USE_LCC == 0, PF_CODE_PAGE has no effect. -/ -/ 437 - U.S. -/ 720 - Arabic -/ 737 - Greek -/ 771 - KBL -/ 775 - Baltic -/ 850 - Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 860 - Portuguese -/ 861 - Icelandic -/ 862 - Hebrew -/ 863 - Canadian French -/ 864 - Arabic -/ 865 - Nordic -/ 866 - Russian -/ 869 - Greek 2 -/ 932 - Japanese (DBCS) -/ 936 - Simplified Chinese (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese (DBCS) -*/ - -/* Integer types used for FatFs API */ - -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */ -#include -typedef unsigned int UINT; /* int must be 16-bit or 32-bit */ -typedef unsigned char BYTE; /* char must be 8-bit */ -typedef uint16_t WORD; /* 16-bit unsigned integer */ -typedef uint16_t WCHAR; /* 16-bit unsigned integer */ -typedef uint32_t DWORD; /* 32-bit unsigned integer */ -#else /* Earlier than C99 */ -typedef unsigned int UINT; /* int must be 16-bit or 32-bit */ -typedef unsigned char BYTE; /* char must be 8-bit */ -typedef unsigned short WORD; /* 16-bit unsigned integer */ -typedef unsigned short WCHAR; /* 16-bit unsigned integer */ -typedef unsigned long DWORD; /* 32-bit unsigned integer */ -#endif -#define PF_INTDEF 1 -#define CLUST DWORD - - -/* File system object structure */ - -typedef struct { - BYTE fs_type; /* FAT sub type */ - BYTE flag; /* File status flags */ - BYTE csize; /* Number of sectors per cluster */ - BYTE pad1; - WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */ - CLUST n_fatent; /* Number of FAT entries (= number of clusters + 2) */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */ - DWORD database; /* Data start sector */ - DWORD fptr; /* File R/W pointer */ - DWORD fsize; /* File size */ - CLUST org_clust; /* File start cluster */ - CLUST curr_clust; /* File current cluster */ - DWORD dsect; /* File current data sector */ -} FATFS; - - - -/* Directory object structure */ - -typedef struct { - WORD index; /* Current read/write index number */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ - CLUST sclust; /* Table start cluster (0:Static table) */ - CLUST clust; /* Current cluster */ - DWORD sect; /* Current sector */ -} DIR; - - - -/* File status structure */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - char fname[13]; /* File name */ -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* 0 */ - FR_DISK_ERR, /* 1 */ - FR_NOT_READY, /* 2 */ - FR_NO_FILE, /* 3 */ - FR_NOT_OPENED, /* 4 */ - FR_NOT_ENABLED, /* 5 */ - FR_NO_FILESYSTEM /* 6 */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* Petit FatFs module application interface */ - -FRESULT pf_mount (FATFS* fs); /* Mount/Unmount a logical drive */ -FRESULT pf_open (const char* path); /* Open a file */ -FRESULT pf_read (void* buff, UINT btr, UINT* br); /* Read data from the open file */ -FRESULT pf_write (const void* buff, UINT btw, UINT* bw); /* Write data to the open file */ -FRESULT pf_lseek (DWORD ofs); /* Move file pointer of the open file */ -FRESULT pf_opendir (DIR* dj, const char* path); /* Open a directory */ -FRESULT pf_readdir (DIR* dj, FILINFO* fno); /* Read a directory item from the open directory */ - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - - -/* File status flag (FATFS.flag) */ -#define FA_OPENED 0x01 -#define FA_WPRT 0x02 -#define FA__WIP 0x40 - - -/* FAT sub type (FATFS.fs_type) */ -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - -/*--------------------------------------------------------*/ -/* DBCS code ranges and SBCS extend char conversion table */ -/*--------------------------------------------------------*/ - -#if PF_USE_LCC == 0 /* ASCII upper case character only */ - -#elif PF_CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif PF_CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif PF_CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif PF_CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif PF_CODE_PAGE == 437 /* U.S. */ -#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 720 /* Arabic */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 737 /* Greek */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xEF,0xF5,0xF0,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 771 /* KBL */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDC,0xDE,0xDE, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFE,0xFF} - -#elif PF_CODE_PAGE == 775 /* Baltic */ -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F, \ - 0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 850 /* Latin 1 */ -#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x41,0x43,0x45,0x45,0x45,0x49,0x49,0x49,0x41,0x41, \ - 0x45,0x92,0x92,0x4F,0x4F,0x4F,0x55,0x55,0x59,0x4F,0x55,0x4F,0x9C,0x4F,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0x41,0x41,0x41,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0x41,0x41,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD1,0xD1,0x45,0x45,0x45,0x49,0x49,0x49,0x49,0xD9,0xDA,0xDB,0xDC,0xDD,0x49,0xDF, \ - 0x4F,0xE1,0x4F,0x4F,0x4F,0x4F,0xE6,0xE8,0xE8,0x55,0x55,0x55,0x59,0x59,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 852 /* Latin 2 */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0xAC, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif PF_CODE_PAGE == 855 /* Cyrillic */ -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F, \ - 0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF, \ - 0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 857 /* Turkish */ -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0x49,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0xED,0xEE,0xEF, \ - -#elif PF_CODE_PAGE == 860 /* Portuguese */ -#define _EXCVT {0x80,0x9A,0x90,0x8F,0x8E,0x91,0x86,0x80,0x89,0x89,0x92,0x8B,0x8C,0x98,0x8E,0x8F, \ - 0x90,0x91,0x92,0x8C,0x99,0xA9,0x96,0x9D,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x86,0x8B,0x9F,0x96,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 861 /* Icelandic */ -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x8B,0x8B,0x8D,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x8D,0x55,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA4,0xA5,0xA6,0xA7,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 862 /* Hebrew */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 863 /* Canadian French */ -#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x41,0x8F, \ - 0x45,0x45,0x45,0x4F,0x45,0x49,0x55,0x55,0x98,0x4F,0x55,0x9B,0x9C,0x55,0x55,0x9F, \ - 0xA0,0xA1,0x4F,0x55,0xA4,0xA5,0xA6,0xA7,0x49,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 864 /* Arabic */ -#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 865 /* Nordic */ -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ - 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 866 /* Russian */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif PF_CODE_PAGE == 869 /* Greek 2 */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ - 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x86,0x9C,0x8D,0x8F,0x90, \ - 0x91,0x90,0x92,0x95,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ - 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xA4,0xA5,0xA6,0xD9,0xDA,0xDB,0xDC,0xA7,0xA8,0xDF, \ - 0xA9,0xAA,0xAC,0xAD,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xCF,0xCF,0xD0,0xEF, \ - 0xF0,0xF1,0xD1,0xD2,0xD3,0xF5,0xD4,0xF7,0xF8,0xF9,0xD5,0x96,0x95,0x98,0xFE,0xFF} - -#else -#error Unknown code page. - -#endif - - - -/* Character code support macros */ - -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) - -#if PF_USE_LCC && !defined(_EXCVT) /* DBCS configuration */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* SBCS configuration */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _EXCVT */ - - -/* FatFs refers the members in the FAT structures with byte offset instead -/ of structure member because there are incompatibility of the packing option -/ between various compilers. */ - -#define BS_jmpBoot 0 -#define BS_OEMName 3 -#define BPB_BytsPerSec 11 -#define BPB_SecPerClus 13 -#define BPB_RsvdSecCnt 14 -#define BPB_NumFATs 16 -#define BPB_RootEntCnt 17 -#define BPB_TotSec16 19 -#define BPB_Media 21 -#define BPB_FATSz16 22 -#define BPB_SecPerTrk 24 -#define BPB_NumHeads 26 -#define BPB_HiddSec 28 -#define BPB_TotSec32 32 -#define BS_55AA 510 - -#define BS_DrvNum 36 -#define BS_BootSig 38 -#define BS_VolID 39 -#define BS_VolLab 43 -#define BS_FilSysType 54 - -#define BPB_FATSz32 36 -#define BPB_ExtFlags 40 -#define BPB_FSVer 42 -#define BPB_RootClus 44 -#define BPB_FSInfo 48 -#define BPB_BkBootSec 50 -#define BS_DrvNum32 64 -#define BS_BootSig32 66 -#define BS_VolID32 67 -#define BS_VolLab32 71 -#define BS_FilSysType32 82 - -#define MBR_Table 446 - -#define DIR_Name 0 -#define DIR_Attr 11 -#define DIR_NTres 12 -#define DIR_CrtTime 14 -#define DIR_CrtDate 16 -#define DIR_FstClusHI 20 -#define DIR_WrtTime 22 -#define DIR_WrtDate 24 -#define DIR_FstClusLO 26 -#define DIR_FileSize 28 - - -extern FATFS *FatFs; /* Pointer to the file system object (logical drive) */ - -#ifdef __cplusplus -} -#endif - -#endif /* _PFATFS */ - diff --git a/software/src/PetitFS/pff_dir.c b/software/src/PetitFS/pff_dir.c deleted file mode 100644 index 7ce1129..0000000 --- a/software/src/PetitFS/pff_dir.c +++ /dev/null @@ -1,302 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module R0.03a -/-----------------------------------------------------------------------------/ -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ Petit FatFs module is an open source software. Redistribution and use of -/ Petit FatFs in source and binary forms, with or without modification, are -/ permitted provided that the following condition is met: -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/-----------------------------------------------------------------------------/ -/ Jun 15,'09 R0.01a First release. -/ -/ Dec 14,'09 R0.02 Added multiple code page support. -/ Added write funciton. -/ Changed stream read mode interface. -/ Dec 07,'10 R0.02a Added some configuration options. -/ Fixed fails to open objects with DBCS character. - -/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. -/ Added _USE_LCC option. -/ Added _FS_FAT16 option. -/ -/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. -/ Removed _WORD_ACCESS option. -/ Changed prefix of configuration options, _ to PF_. -/ Added some code pages. -/ Removed some code pages actually not valid. -/ -/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in -/ banked ROMS as part of the RFS on the Sharp MZ80A. -/----------------------------------------------------------------------------*/ - -#include -#include -#include "pff.h" /* Petit FatFs configurations and declarations */ -#include "sdmmc.h" /* Declarations of low level disk I/O functions */ -#include "pff_func.h" -#define PFF_DIR_C -#include "pff_dir.h" - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Rewind directory index */ -/*-----------------------------------------------------------------------*/ - -FRESULT dir_rewind ( - DIR *dj /* Pointer to directory object */ -) -{ - CLUST clst; - FATFS *fs = FatFs; - - - dj->index = 0; - clst = dj->sclust; - if (clst == 1 || clst >= fs->n_fatent) { /* Check start cluster range */ - return FR_DISK_ERR; - } - if(!clst) - { - clst = (CLUST)fs->dirbase; - } - dj->clust = clst; /* Current cluster */ - dj->sect = clust2sect(clst); /* Current sector */ - return FR_OK; /* Seek succeeded */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory index next */ -/*-----------------------------------------------------------------------*/ - -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table */ - DIR *dj /* Pointer to directory object */ -) -{ - CLUST clst; - WORD i; - FATFS *fs = FatFs; - - - i = dj->index + 1; - if (!i || !dj->sect) return FR_NO_FILE; /* Report EOT when index has reached 65535 */ - - if (!(i % 16)) { /* Sector changed? */ - dj->sect++; /* Next sector */ - - if (dj->clust == 0) { /* Static table */ - if (i >= fs->n_rootdir) return FR_NO_FILE; /* Report EOT when end of table */ - } - else { /* Dynamic table */ - if (((i / 16) & (fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dj->clust); /* Get next cluster */ - if (clst <= 1) return FR_DISK_ERR; - if (clst >= fs->n_fatent) return FR_NO_FILE; /* Report EOT when it reached end of dynamic table */ - dj->clust = clst; /* Initialize data for new cluster */ - dj->sect = clust2sect(clst); - } - } - } - - dj->index = i; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT dir_find ( - DIR *dj, /* Pointer to the directory object linked to the file name */ - BYTE *dir /* 32-byte working buffer */ -) -{ - FRESULT res; - BYTE c; - - - res = dir_rewind(dj); /* Rewind directory object */ - if (res != FR_OK) return res; - - do { - res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ? FR_DISK_ERR : FR_OK; - if (res != FR_OK) break; - c = dir[DIR_Name]; /* First character */ - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dj->fn, 11)) break; /* Is it a valid entry? */ - res = dir_next(dj); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -FRESULT dir_read ( - DIR *dj, /* Pointer to the directory object to store read object name */ - BYTE *dir /* 32-byte working buffer */ -) -{ - FRESULT res; - BYTE a, c; - - - res = FR_NO_FILE; - while (dj->sect) { - - res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ? FR_DISK_ERR : FR_OK; - if (res != FR_OK) break; - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; - if (c != 0xE5 && c != '.' && !(a & AM_VOL)) break; /* Is it a valid entry? */ - res = dir_next(dj); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dj->sect = 0; - - return res; -} - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -void get_fileinfo ( /* No return code */ - DIR *dj, /* Pointer to the directory object */ - BYTE *dir, /* 32-byte working buffer */ - FILINFO *fno /* Pointer to store the file information */ -) -{ - BYTE i, c; - char *p; - - - p = fno->fname; - if (dj->sect) { - for (i = 0; i < 8; i++) { /* Copy file name body */ - c = dir[i]; - if (c == ' ') break; - if (c == 0x05) c = 0xE5; - *p++ = c; - } - if (dir[8] != ' ') { /* Copy file name extension */ - *p++ = '.'; - for (i = 8; i < 11; i++) { - c = dir[i]; - if (c == ' ') break; - *p++ = c; - } - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = ld_dword(dir+DIR_FileSize); /* Size */ - fno->fdate = ld_word(dir+DIR_WrtDate); /* Date */ - fno->ftime = ld_word(dir+DIR_WrtTime); /* Time */ - } - *p = 0; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directroy Object */ -/*-----------------------------------------------------------------------*/ -FRESULT pf_opendir ( - DIR *dj, /* Pointer to directory object to create */ - const char *path /* Pointer to the directory path */ -) -{ - FRESULT res; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) { /* Check file system */ - res = FR_NOT_ENABLED; - } else { - dj->fn = sp; - res = follow_path(dj, dir, path); /* Follow the path to the directory */ - if (res == FR_OK) { /* Follow completed */ - if (dir[0]) { /* It is not the root dir */ - if (dir[DIR_Attr] & AM_DIR) { /* The object is a directory */ - dj->sclust = get_clust(dir); - } else { /* The object is not a directory */ - res = FR_NO_FILE; - } - } - if (res == FR_OK) { - res = dir_rewind(dj); /* Rewind dir */ - } - } - } - - return res; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entry in Sequense */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_readdir ( - DIR *dj, /* Pointer to the open directory object */ - FILINFO *fno /* Pointer to file information to return */ -) -{ - FRESULT res; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) { /* Check file system */ - res = FR_NOT_ENABLED; - } else { - dj->fn = sp; - if (!fno) { - res = dir_rewind(dj); - } else { - res = dir_read(dj, dir); /* Get current directory item */ - if (res == FR_NO_FILE) res = FR_OK; - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dj, dir, fno); /* Get the object information */ - res = dir_next(dj); /* Increment read index for next */ - // if (res == FR_NO_FILE) res = FR_OK; - } - } - } - - return res; -} diff --git a/software/src/PetitFS/pff_dir.h b/software/src/PetitFS/pff_dir.h deleted file mode 100644 index 68108bc..0000000 --- a/software/src/PetitFS/pff_dir.h +++ /dev/null @@ -1,39 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module include file R0.03a -/----------------------------------------------------------------------------/ -/ Petit FatFs module is an open source software to implement FAT file system to -/ small embedded systems. This is a free software and is opened for education, -/ research and commercial developments under license policy of following trems. -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ * The Petit FatFs module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/----------------------------------------------------------------------------*/ - -#ifndef PF_DIR_DEFINED -#define PF_DIR_DEFINED 8088 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - - -/*--------------------------------------------------------------*/ -/* Petit FatFs module application interface */ -FRESULT dir_rewind(DIR *dj); -FRESULT dir_next(DIR *dj); -FRESULT dir_find(DIR *dj, BYTE *dir); -FRESULT dir_read(DIR *dj, BYTE *dir); -void get_fileinfo(DIR *dj, BYTE *dir, FILINFO *fno); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/software/src/PetitFS/pff_func.c b/software/src/PetitFS/pff_func.c deleted file mode 100644 index 4df59cf..0000000 --- a/software/src/PetitFS/pff_func.c +++ /dev/null @@ -1,272 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module R0.03a -/-----------------------------------------------------------------------------/ -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ Petit FatFs module is an open source software. Redistribution and use of -/ Petit FatFs in source and binary forms, with or without modification, are -/ permitted provided that the following condition is met: -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/-----------------------------------------------------------------------------/ -/ Jun 15,'09 R0.01a First release. -/ -/ Dec 14,'09 R0.02 Added multiple code page support. -/ Added write funciton. -/ Changed stream read mode interface. -/ Dec 07,'10 R0.02a Added some configuration options. -/ Fixed fails to open objects with DBCS character. - -/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. -/ Added _USE_LCC option. -/ Added _FS_FAT16 option. -/ -/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. -/ Removed _WORD_ACCESS option. -/ Changed prefix of configuration options, _ to PF_. -/ Added some code pages. -/ Removed some code pages actually not valid. -/ -/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in -/ banked ROMS as part of the RFS on the Sharp MZ80A. -/----------------------------------------------------------------------------*/ - -#include -#include -#include "pff.h" /* Petit FatFs configurations and declarations */ -#include "sdmmc.h" /* Declarations of low level disk I/O functions */ -#define PFF_FUNC_C -#include "pff_func.h" - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - - -/*-------------------------------------------------------------------------- - - Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Load multi-byte word in the FAT structure */ -/*-----------------------------------------------------------------------*/ - -WORD ld_word (const BYTE* ptr) /* Load a 2-byte little-endian word */ -{ - WORD rv; - - rv = ptr[1]; - rv = rv << 8 | ptr[0]; - return rv; -} - -DWORD ld_dword (const BYTE* ptr) /* Load a 4-byte little-endian word */ -{ - DWORD rv; - - rv = ptr[3]; - rv = rv << 8 | ptr[2]; - rv = rv << 8 | ptr[1]; - rv = rv << 8 | ptr[0]; - return rv; -} - - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Fill memory block */ -void mem_set (void* dst, int val, int cnt) { - char *d = (char*)dst; - while (cnt--) *d++ = (char)val; -} - -/* Compare memory block */ -int mem_cmp (const void* dst, const void* src, int cnt) { - const char *d = (const char *)dst, *s = (const char *)src; - int r = 0; - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ - -CLUST get_fat ( /* 1:IO error, Else:Cluster status */ - CLUST clst /* Cluster# to get the link information */ -) -{ - BYTE buf[4]; - FATFS *fs = FatFs; - - if (clst < 2 || clst >= fs->n_fatent) return 1; /* Range check */ - - switch (fs->fs_type) { - case FS_FAT32 : - if (disk_readp(buf, fs->fatbase + clst / 128, ((UINT)clst % 128) * 4, 4)) break; - return ld_dword(buf) & 0x0FFFFFFF; - } - - return 1; /* An error occured at the disk I/O layer */ -} - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# / Get cluster field from directory entry */ -/*-----------------------------------------------------------------------*/ - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - CLUST clst /* Cluster# to be converted */ -) -{ - FATFS *fs = FatFs; - - clst -= 2; - if (clst >= (fs->n_fatent - 2)) return 0; /* Invalid cluster# */ - return (DWORD)clst * fs->csize + fs->database; -} - - -CLUST get_clust ( - BYTE* dir /* Pointer to directory entry */ -) -{ - FATFS *fs = FatFs; - CLUST clst = 0; - - - clst = ld_word(dir+DIR_FstClusHI); - clst <<= 16; - clst |= ld_word(dir+DIR_FstClusLO); - - return clst; -} - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - - -FRESULT create_name ( - DIR *dj, /* Pointer to the directory object */ - const char **path /* Pointer to pointer to the segment in the path string */ -) -{ - BYTE c, d, ni, si, i, *sfn; - const char *p; -#if PF_USE_LCC && defined(_EXCVT) - static const BYTE cvt[] = _EXCVT; -#endif - - /* Create file name in directory form */ - sfn = dj->fn; - mem_set(sfn, ' ', 11); - si = i = 0; ni = 8; - p = *path; - for (;;) { - c = p[si++]; - if (c <= ' ' || c == '/') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') break; - i = 8; ni = 11; - continue; - } -#if PF_USE_LCC && defined(_EXCVT) - if (c >= 0x80) c = cvt[c - 0x80]; /* To upper extended char (SBCS) */ -#endif - if (IsDBCS1(c) && i < ni - 1) { /* DBC 1st byte? */ - d = p[si++]; /* Get 2nd byte */ - sfn[i++] = c; - sfn[i++] = d; - } else { /* Single byte code */ - if (PF_USE_LCC && IsLower(c)) c -= 0x20; /* toupper */ - sfn[i++] = c; - } - } - *path = &p[si]; /* Rerurn pointer to the next segment */ - - sfn[11] = (c <= ' ') ? 1 : 0; /* Set last segment flag if end of path */ - - return FR_OK; -} - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR *dj, /* Directory object to return last directory and found object */ - BYTE *dir, /* 32-byte working buffer */ - const char *path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - - - while (*path == ' ') path++; /* Strip leading spaces */ - if (*path == '/') path++; /* Strip heading separator if exist */ - dj->sclust = 0; /* Set start directory (always root dir) */ - - if ((BYTE)*path < ' ') { /* Null path means the root directory */ - res = dir_rewind(dj); - dir[0] = 0; - - } else { /* Follow path */ - for (;;) { - res = create_name(dj, &path); /* Get a segment */ - if (res != FR_OK) break; - res = dir_find(dj, dir); /* Find it */ - if (res != FR_OK) break; /* Could not find the object */ - if (dj->fn[11]) break; /* Last segment match. Function completed. */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* Cannot follow path because it is a file */ - res = FR_NO_FILE; break; - } - dj->sclust = get_clust(dir); /* Follow next */ - } - } - - return res; -} - - -/*-----------------------------------------------------------------------*/ -/* Check a sector if it is an FAT boot record */ -/*-----------------------------------------------------------------------*/ - -BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record, 3:Error */ - BYTE *buf, /* Working buffer */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - if (disk_readp(buf, sect, 510, 2)) { /* Read the boot record */ - return 3; - } - if (ld_word(buf) != 0xAA55) { /* Check record signature */ - return 2; - } - -// if (!_FS_32ONLY && !disk_readp(buf, sect, BS_FilSysType, 2) && ld_word(buf) == 0x4146) { /* Check FAT12/16 */ -// return 0; -// } - if (!disk_readp(buf, sect, BS_FilSysType32, 2) && ld_word(buf) == 0x4146) { /* Check FAT32 */ - return 0; - } - return 1; -} diff --git a/software/src/PetitFS/pff_func.h b/software/src/PetitFS/pff_func.h deleted file mode 100644 index d586421..0000000 --- a/software/src/PetitFS/pff_func.h +++ /dev/null @@ -1,47 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module include file R0.03a -/----------------------------------------------------------------------------/ -/ Petit FatFs module is an open source software to implement FAT file system to -/ small embedded systems. This is a free software and is opened for education, -/ research and commercial developments under license policy of following trems. -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ * The Petit FatFs module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/----------------------------------------------------------------------------*/ - -#ifndef PF_FUNC_DEFINED -#define PF_FUNC_DEFINED 8088 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - - -/*--------------------------------------------------------------*/ -/* Petit FatFs module application interface */ -WORD ld_word (const BYTE* ptr); -DWORD ld_dword (const BYTE* ptr); -void mem_set (void* dst, int val, int cnt); -int mem_cmp (const void* dst, const void* src, int cnt); -CLUST get_fat(CLUST clst); -DWORD clust2sect( CLUST clst); -FRESULT create_name (DIR *dj, const char **path); -FRESULT follow_path ( DIR *dj, BYTE *dir, const char *path); -CLUST get_clust(BYTE* dir); -BYTE check_fs(BYTE *buf, DWORD sect); - -extern FRESULT dir_rewind(DIR *dj); -extern FRESULT dir_find(DIR *dj, BYTE *dir); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/software/src/PetitFS/pff_mount.c b/software/src/PetitFS/pff_mount.c deleted file mode 100644 index ce66165..0000000 --- a/software/src/PetitFS/pff_mount.c +++ /dev/null @@ -1,116 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module R0.03a -/-----------------------------------------------------------------------------/ -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ Petit FatFs module is an open source software. Redistribution and use of -/ Petit FatFs in source and binary forms, with or without modification, are -/ permitted provided that the following condition is met: -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/-----------------------------------------------------------------------------/ -/ Jun 15,'09 R0.01a First release. -/ -/ Dec 14,'09 R0.02 Added multiple code page support. -/ Added write funciton. -/ Changed stream read mode interface. -/ Dec 07,'10 R0.02a Added some configuration options. -/ Fixed fails to open objects with DBCS character. - -/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. -/ Added _USE_LCC option. -/ Added _FS_FAT16 option. -/ -/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. -/ Removed _WORD_ACCESS option. -/ Changed prefix of configuration options, _ to PF_. -/ Added some code pages. -/ Removed some code pages actually not valid. -/ -/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in -/ banked ROMS as part of the RFS on the Sharp MZ80A. -/----------------------------------------------------------------------------*/ - -#include -#include -#include "pff.h" /* Petit FatFs configurations and declarations */ -#include "sdmmc.h" /* Declarations of low level disk I/O functions */ -#define PFF_MOUNT_C -#include "pff_func.h" - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Locical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_mount ( - FATFS *fs /* Pointer to new file system object */ -) -{ - BYTE fmt, buf[36]; - DWORD bsect, fsize, tsect, mclst; - - - FatFs = 0; - if (disk_initialize() & STA_NOINIT) { /* Check if the drive is ready or not */ - return FR_NOT_READY; - } - - /* Search FAT partition on the drive */ - bsect = 0; - fmt = check_fs(buf, bsect); /* Check sector 0 as an SFD format */ - if (fmt == 1) { /* Not an FAT boot record, it may be FDISK format */ - /* Check a partition listed in top of the partition table */ - if (disk_readp(buf, bsect, MBR_Table, 16)) { /* 1st partition entry */ - fmt = 3; - } else { - if (buf[4]) { /* Is the partition existing? */ - bsect = ld_dword(&buf[8]); /* Partition offset in LBA */ - fmt = check_fs(buf, bsect); /* Check the partition */ - } - } - } - if (fmt == 3) return FR_DISK_ERR; - if (fmt) return FR_NO_FILESYSTEM; /* No valid FAT patition is found */ - - /* Initialize the file system object */ - if (disk_readp(buf, bsect, 13, sizeof (buf))) return FR_DISK_ERR; - - fsize = ld_word(buf+BPB_FATSz16-13); /* Number of sectors per FAT */ - if (!fsize) fsize = ld_dword(buf+BPB_FATSz32-13); - - fsize *= buf[BPB_NumFATs-13]; /* Number of sectors in FAT area */ - fs->fatbase = bsect + ld_word(buf+BPB_RsvdSecCnt-13); /* FAT start sector (lba) */ - fs->csize = buf[BPB_SecPerClus-13]; /* Number of sectors per cluster */ - fs->n_rootdir = ld_word(buf+BPB_RootEntCnt-13); /* Nmuber of root directory entries */ - tsect = ld_word(buf+BPB_TotSec16-13); /* Number of sectors on the file system */ - if (!tsect) tsect = ld_dword(buf+BPB_TotSec32-13); - mclst = (tsect /* Last cluster# + 1 */ - - ld_word(buf+BPB_RsvdSecCnt-13) - fsize - fs->n_rootdir / 16 - ) / fs->csize + 2; - fs->n_fatent = (CLUST)mclst; - - fmt = 0; /* Determine the FAT sub type */ - if (mclst >= 0xFFF7) fmt = FS_FAT32; - if (!fmt) return FR_NO_FILESYSTEM; - fs->fs_type = fmt; - -// if (_FS_32ONLY || (PF_FS_FAT32 && fmt == FS_FAT32)) { - fs->dirbase = ld_dword(buf+(BPB_RootClus-13)); /* Root directory start cluster */ -// } else { -// fs->dirbase = fs->fatbase + fsize; /* Root directory start sector (lba) */ -// } - fs->database = fs->fatbase + fsize + fs->n_rootdir / 16; /* Data start sector (lba) */ - - fs->flag = 0; - FatFs = fs; - - return FR_OK; -} diff --git a/software/src/PetitFS/pff_mount.h b/software/src/PetitFS/pff_mount.h deleted file mode 100644 index 729c2a3..0000000 --- a/software/src/PetitFS/pff_mount.h +++ /dev/null @@ -1,36 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module include file R0.03a -/----------------------------------------------------------------------------/ -/ Petit FatFs module is an open source software to implement FAT file system to -/ small embedded systems. This is a free software and is opened for education, -/ research and commercial developments under license policy of following trems. -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ * The Petit FatFs module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/----------------------------------------------------------------------------*/ - -#ifndef PF_MOUNT_DEFINED -#define PF_MOUNT_DEFINED 8088 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - - -/*--------------------------------------------------------------*/ -/* Petit FatFs module application interface */ -extern FRESULT dir_rewind(DIR *dj); -extern FRESULT dir_find(DIR *dj, BYTE *dir); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/software/src/PetitFS/pff_open.c b/software/src/PetitFS/pff_open.c deleted file mode 100644 index 3f389f3..0000000 --- a/software/src/PetitFS/pff_open.c +++ /dev/null @@ -1,78 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module R0.03a -/-----------------------------------------------------------------------------/ -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ Petit FatFs module is an open source software. Redistribution and use of -/ Petit FatFs in source and binary forms, with or without modification, are -/ permitted provided that the following condition is met: -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/-----------------------------------------------------------------------------/ -/ Jun 15,'09 R0.01a First release. -/ -/ Dec 14,'09 R0.02 Added multiple code page support. -/ Added write funciton. -/ Changed stream read mode interface. -/ Dec 07,'10 R0.02a Added some configuration options. -/ Fixed fails to open objects with DBCS character. - -/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. -/ Added _USE_LCC option. -/ Added _FS_FAT16 option. -/ -/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. -/ Removed _WORD_ACCESS option. -/ Changed prefix of configuration options, _ to PF_. -/ Added some code pages. -/ Removed some code pages actually not valid. -/ -/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in -/ banked ROMS as part of the RFS on the Sharp MZ80A. -/----------------------------------------------------------------------------*/ - -#include -#include -#include "pff.h" /* Petit FatFs configurations and declarations */ -#include "sdmmc.h" /* Declarations of low level disk I/O functions */ -#include "pff_func.h" -#define PFF_OPEN_C - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_open ( - const char *path /* Pointer to the file name */ -) -{ - FRESULT res; - DIR dj; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - - fs->flag = 0; - dj.fn = sp; - res = follow_path(&dj, dir, path); /* Follow the file path */ - if (res != FR_OK) return res; /* Follow failed */ - if (!dir[0] || (dir[DIR_Attr] & AM_DIR)) return FR_NO_FILE; /* It is a directory */ - - fs->org_clust = get_clust(dir); /* File start cluster */ - fs->fsize = ld_dword(dir+DIR_FileSize); /* File size */ - fs->fptr = 0; /* File pointer */ - fs->flag = FA_OPENED; - - return FR_OK; -} diff --git a/software/src/PetitFS/pff_read.c b/software/src/PetitFS/pff_read.c deleted file mode 100644 index c8f8c81..0000000 --- a/software/src/PetitFS/pff_read.c +++ /dev/null @@ -1,99 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module R0.03a -/-----------------------------------------------------------------------------/ -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ Petit FatFs module is an open source software. Redistribution and use of -/ Petit FatFs in source and binary forms, with or without modification, are -/ permitted provided that the following condition is met: -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/-----------------------------------------------------------------------------/ -/ Jun 15,'09 R0.01a First release. -/ -/ Dec 14,'09 R0.02 Added multiple code page support. -/ Added write funciton. -/ Changed stream read mode interface. -/ Dec 07,'10 R0.02a Added some configuration options. -/ Fixed fails to open objects with DBCS character. - -/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. -/ Added _USE_LCC option. -/ Added _FS_FAT16 option. -/ -/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. -/ Removed _WORD_ACCESS option. -/ Changed prefix of configuration options, _ to PF_. -/ Added some code pages. -/ Removed some code pages actually not valid. -/ -/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in -/ banked ROMS as part of the RFS on the Sharp MZ80A. -/----------------------------------------------------------------------------*/ - -#include -#include -#include "pff.h" /* Petit FatFs configurations and declarations */ -#include "sdmmc.h" /* Declarations of low level disk I/O functions */ -#include "pff_func.h" -#define PFF_READ_C - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ -FRESULT pf_read ( - void* buff, /* Pointer to the read buffer (NULL:Forward data to the stream)*/ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - DRESULT dr; - CLUST clst; - DWORD sect, remain; - UINT rcnt; - BYTE cs, *rbuff = buff; - FATFS *fs = FatFs; - - - *br = 0; - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ - - remain = fs->fsize - fs->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - while (btr) { /* Repeat until all data transferred */ - if ((fs->fptr % 512) == 0) { /* On the sector boundary? */ - cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - if (!cs) { /* On the cluster boundary? */ - if (fs->fptr == 0) { /* On the top of the file? */ - clst = fs->org_clust; - } else { - clst = get_fat(fs->curr_clust); - } - if (clst <= 1) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; /* Update current cluster */ - } - sect = clust2sect(fs->curr_clust); /* Get current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + cs; - } - rcnt = 512 - (UINT)fs->fptr % 512; /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; - dr = disk_readp(rbuff, fs->dsect, (UINT)fs->fptr % 512, rcnt); - if (dr) ABORT(FR_DISK_ERR); - fs->fptr += rcnt; /* Advances file read pointer */ - btr -= rcnt; *br += rcnt; /* Update read counter */ - if (rbuff) rbuff += rcnt; /* Advances the data pointer if destination is memory */ - } - - return FR_OK; -} diff --git a/software/src/PetitFS/pff_seek.c b/software/src/PetitFS/pff_seek.c deleted file mode 100644 index 2500807..0000000 --- a/software/src/PetitFS/pff_seek.c +++ /dev/null @@ -1,90 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module R0.03a -/-----------------------------------------------------------------------------/ -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ Petit FatFs module is an open source software. Redistribution and use of -/ Petit FatFs in source and binary forms, with or without modification, are -/ permitted provided that the following condition is met: -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/-----------------------------------------------------------------------------/ -/ Jun 15,'09 R0.01a First release. -/ -/ Dec 14,'09 R0.02 Added multiple code page support. -/ Added write funciton. -/ Changed stream read mode interface. -/ Dec 07,'10 R0.02a Added some configuration options. -/ Fixed fails to open objects with DBCS character. - -/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. -/ Added _USE_LCC option. -/ Added _FS_FAT16 option. -/ -/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. -/ Removed _WORD_ACCESS option. -/ Changed prefix of configuration options, _ to PF_. -/ Added some code pages. -/ Removed some code pages actually not valid. -/ -/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in -/ banked ROMS as part of the RFS on the Sharp MZ80A. -/----------------------------------------------------------------------------*/ - -#include -#include -#include "pff.h" /* Petit FatFs configurations and declarations */ -#include "sdmmc.h" /* Declarations of low level disk I/O functions */ -#include "pff_func.h" -#define PFF_SEEK_C - -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ -FRESULT pf_lseek ( DWORD ofs ) /* File pointer from top of file */ -{ - CLUST clst; - DWORD bcs, sect, ifptr; - FATFS *fs = FatFs; - - - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ - - if (ofs > fs->fsize) ofs = fs->fsize; /* Clip offset with the file size */ - ifptr = fs->fptr; - fs->fptr = 0; - if (ofs > 0) { - bcs = (DWORD)fs->csize * 512; /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fs->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fs->fptr; - clst = fs->curr_clust; - } else { /* When seek to back cluster, */ - clst = fs->org_clust; /* start from the first cluster */ - fs->curr_clust = clst; - } - while (ofs > bcs) { /* Cluster following loop */ - clst = get_fat(clst); /* Follow cluster chain */ - if (clst <= 1 || clst >= fs->n_fatent) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; - fs->fptr += bcs; - ofs -= bcs; - } - fs->fptr += ofs; - sect = clust2sect(clst); /* Current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + (fs->fptr / 512 & (fs->csize - 1)); - } - - return FR_OK; -} diff --git a/software/src/PetitFS/pff_write.c b/software/src/PetitFS/pff_write.c deleted file mode 100644 index 4ab7762..0000000 --- a/software/src/PetitFS/pff_write.c +++ /dev/null @@ -1,112 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module R0.03a -/-----------------------------------------------------------------------------/ -/ -/ Copyright (C) 2019, ChaN, all right reserved. -/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 -/ -/ Petit FatFs module is an open source software. Redistribution and use of -/ Petit FatFs in source and binary forms, with or without modification, are -/ permitted provided that the following condition is met: -/ -/ 1. Redistributions of source code must retain the above copyright notice, -/ this condition and the following disclaimer. -/ -/ This software is provided by the copyright holder and contributors "AS IS" -/ and any warranties related to this software are DISCLAIMED. -/ The copyright owner or contributors be NOT LIABLE for any damages caused -/ by use of this software. -/-----------------------------------------------------------------------------/ -/ Jun 15,'09 R0.01a First release. -/ -/ Dec 14,'09 R0.02 Added multiple code page support. -/ Added write funciton. -/ Changed stream read mode interface. -/ Dec 07,'10 R0.02a Added some configuration options. -/ Fixed fails to open objects with DBCS character. - -/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. -/ Added _USE_LCC option. -/ Added _FS_FAT16 option. -/ -/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. -/ Removed _WORD_ACCESS option. -/ Changed prefix of configuration options, _ to PF_. -/ Added some code pages. -/ Removed some code pages actually not valid. -/ -/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in -/ banked ROMS as part of the RFS on the Sharp MZ80A. -/----------------------------------------------------------------------------*/ - -#include -#include -#include "pff.h" /* Petit FatFs configurations and declarations */ -#include "sdmmc.h" /* Declarations of low level disk I/O functions */ -#include "pff_func.h" -#define PFF_WRITE_C - -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ -FRESULT pf_write ( - const void* buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write (0:Finalize the current write operation) */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - CLUST clst; - DWORD sect, remain; - const BYTE *p = buff; - BYTE cs; - UINT wcnt; - FATFS *fs = FatFs; - - - *bw = 0; - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ - - if (!btw) { /* Finalize request */ - if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR); - fs->flag &= ~FA__WIP; - return FR_OK; - } else { /* Write data request */ - if (!(fs->flag & FA__WIP)) { /* Round-down fptr to the sector boundary */ - fs->fptr &= 0xFFFFFE00; - } - } - remain = fs->fsize - fs->fptr; - if (btw > remain) btw = (UINT)remain; /* Truncate btw by remaining bytes */ - - while (btw) { /* Repeat until all data transferred */ - if ((UINT)fs->fptr % 512 == 0) { /* On the sector boundary? */ - cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - if (!cs) { /* On the cluster boundary? */ - if (fs->fptr == 0) { /* On the top of the file? */ - clst = fs->org_clust; - } else { - clst = get_fat(fs->curr_clust); - } - if (clst <= 1) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; /* Update current cluster */ - } - sect = clust2sect(fs->curr_clust); /* Get current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + cs; - if (disk_writep(0, fs->dsect)) ABORT(FR_DISK_ERR); /* Initiate a sector write operation */ - fs->flag |= FA__WIP; - } - wcnt = 512 - (UINT)fs->fptr % 512; /* Number of bytes to write to the sector */ - if (wcnt > btw) wcnt = btw; - if (disk_writep(p, wcnt)) ABORT(FR_DISK_ERR); /* Send data to the sector */ - fs->fptr += wcnt; p += wcnt; /* Update pointers and counters */ - btw -= wcnt; *bw += wcnt; - if ((UINT)fs->fptr % 512 == 0) { - if (disk_writep(0, 0)) ABORT(FR_DISK_ERR); /* Finalize the currtent secter write operation */ - fs->flag &= ~FA__WIP; - } - } - - return FR_OK; -} diff --git a/software/src/PetitFS/pffconf.h b/software/src/PetitFS/pffconf.h deleted file mode 100644 index bc16c30..0000000 --- a/software/src/PetitFS/pffconf.h +++ /dev/null @@ -1,58 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ Petit FatFs - Configuration file -/---------------------------------------------------------------------------*/ - -#ifndef PFCONF_DEF -#define PFCONF_DEF 8088 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Function Configurations (0:Disable, 1:Enable) -/---------------------------------------------------------------------------*/ - -//#define PF_USE_READ 1 /* pf_read() function */ -//#define PF_USE_DIR 1 /* pf_opendir() and pf_readdir() function */ -//#define PF_USE_LSEEK 1 /* pf_lseek() function */ -//#define PF_USE_WRITE 1 /* pf_write() function */ - -//#define PF_FS_FAT12 1 /* FAT12 */ -//#define PF_FS_FAT16 1 /* FAT16 */ -//#define PF_FS_FAT32 1 /* FAT32 */ - - -/*---------------------------------------------------------------------------/ -/ Locale and Namespace Configurations -/---------------------------------------------------------------------------*/ - -#define PF_USE_LCC 0 /* Allow lower case ASCII and non-ASCII chars */ - -#define PF_CODE_PAGE 437 -/* The PF_CODE_PAGE specifies the code page to be used on the target system. -/ SBCS code pages with PF_USE_LCC == 1 requiers a 128 byte of case conversion -/ table. It might occupy RAM on some platforms, e.g. avr-gcc. -/ When PF_USE_LCC == 0, PF_CODE_PAGE has no effect. -/ -/ 437 - U.S. -/ 720 - Arabic -/ 737 - Greek -/ 771 - KBL -/ 775 - Baltic -/ 850 - Latin 1 -/ 852 - Latin 2 -/ 855 - Cyrillic -/ 857 - Turkish -/ 860 - Portuguese -/ 861 - Icelandic -/ 862 - Hebrew -/ 863 - Canadian French -/ 864 - Arabic -/ 865 - Nordic -/ 866 - Russian -/ 869 - Greek 2 -/ 932 - Japanese (DBCS) -/ 936 - Simplified Chinese (DBCS) -/ 949 - Korean (DBCS) -/ 950 - Traditional Chinese (DBCS) -*/ - - -#endif /* PF_CONF */ diff --git a/software/src/PetitFS/rfs.inc b/software/src/PetitFS/rfs.inc deleted file mode 100644 index e69de29..0000000 diff --git a/software/src/PetitFS/sdmmc.c b/software/src/PetitFS/sdmmc.c deleted file mode 100644 index e898b2a..0000000 --- a/software/src/PetitFS/sdmmc.c +++ /dev/null @@ -1,789 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Name: sdmmc.c -// Created: March 2020 -// Author(s): ChaN (framework), Philip Smart (Sharp MZ80A/RFS Z80 code and customisation) -// Description: Functionality to enable connectivity between the PetitFS ((C) ChaN) and the RFS -// subsystem of the Sharp MZ80A for SD drives. This module provides the public -// interfaces to interact with the hardware. -// Low level functions were written in C and the two disk_ methods were -// initially written in C but then converted into Z80 and optimised. The end purpose is -// to use the functions in this module inside the RFS roms. -// -// Credits: -// Copyright: (C) 2013, ChaN, all rights reserved - framework. -// Copyright: (C) 2020 Philip Smart -// -// History: March 2020 - Initial development. -// -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// This source file is free software: you can redistribute it and#or modify -// it under the terms of the GNU General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This source file is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include "pff.h" /* Obtains integer types for Petit FatFs */ -#include "sdmmc.h" /* Common include file for the disk I/O layer */ - -/*-------------------------------------------------------------------------*/ -/* Platform dependent macros and functions needed to be modified */ -/*-------------------------------------------------------------------------*/ - -#define SPI_OUT 0xFF -#define SPI_IN 0xFE -#define DOUT_LOW 0x00 -#define DOUT_HIGH 0x04 -#define DOUT_MASK 0x04 -#define DIN_LOW 0x00 -#define DIN_HIGH 0x01 -#define CLOCK_LOW 0x00 -#define CLOCK_HIGH 0x02 -#define CLOCK_MASK 0xFD -#define CS_LOW 0x00 -#define CS_HIGH 0x01 - -/*-------------------------------------------------------------------------- - Module Private Functions ----------------------------------------------------------------------------*/ - -/* MMC/SD command (SPI mode) */ -#define CMD0 64 + 0 /* GO_IDLE_STATE */ -#define CMD1 64 + 1 /* SEND_OP_COND */ -#define ACMD41 0x40+41 /* SEND_OP_COND (SDC) */ -#define CMD8 64 + 8 /* SEND_IF_COND */ -#define CMD9 64 + 9 /* SEND_CSD */ -#define CMD10 64 + 10 /* SEND_CID */ -#define CMD12 64 + 12 /* STOP_TRANSMISSION */ -#define CMD13 64 + 13 /* SEND_STATUS */ -#define ACMD13 0x40+13 /* SD_STATUS (SDC) */ -#define CMD16 64 + 16 /* SET_BLOCKLEN */ -#define CMD17 64 + 17 /* READ_SINGLE_BLOCK */ -#define CMD18 64 + 18 /* READ_MULTIPLE_BLOCK */ -#define CMD23 64 + 23 /* SET_BLOCK_COUNT */ -#define ACMD23 0x40+23 /* SET_WR_BLK_ERASE_COUNT (SDC) */ -#define CMD24 64 + 24 /* WRITE_BLOCK */ -#define CMD25 64 + 25 /* WRITE_MULTIPLE_BLOCK */ -#define CMD32 64 + 32 /* ERASE_ER_BLK_START */ -#define CMD33 64 + 33 /* ERASE_ER_BLK_END */ -#define CMD38 64 + 38 /* ERASE */ -#define CMD55 64 + 55 /* APP_CMD */ -#define CMD58 64 + 58 /* READ_OCR */ -#define SECTOR_SIZE 512 /* Default size of an SD Sector */ - -/* Card type flags (CardType) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC CT_SD1|CT_SD2 /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - -static DSTATUS Stat = STA_NOINIT; /* Disk status */ -BYTE SDBUF[11]; -BYTE SDVER; -BYTE SDCAP; -static DRESULT RESULT; -static UINT BYTECNT; -static UINT WRITECNT; -//static BYTE d; - - -/*-------------------------------------------------------------------------- - Public Functions ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ -DSTATUS disk_initialize (void) -{ -#asm - ; Method to initialise the SD card. - ; -SDINIT: LD A,$00 ; CS to high - CALL SPICS - ; - CALL SPIINIT ; Train SD with our clock. - ; - LD A,$FF ; CS to low - CALL SPICS - LD BC,$FFFF - -SDINIT1: LD A,CMD0 ; Command 0 - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - - PUSH BC - LD A,(_SDBUF+6) ; Get response code. - DEC A ; Set Z flag to test if response is 0x01 - JP Z,SDINIT2 ; Command response 0x01? Exit if match. - POP BC - DEC BC - LD A,B - OR C - JR NZ,SDINIT1 ; Retry for BC times. - LD A,1 - JP SD_EXIT ; Error, card is not responding to CMD0 -SDINIT2: POP BC - ; Now send CMD8 to get card details. This command can only be sent - ; when the card is idle. - LD A,CMD8 ; CMD8 has 0x00001AA as parameter, load up registers and call command routine. - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$AA01 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - - ; Version 2 card, check its voltage range. IF not in the 2.7-3.6V dont try the ACMD41 to get capabilities. -SDINIT3: LD A,1 ; Check that we receive 0x0001AA in response. - LD (_SDVER),A ; Indicate this is not a version 2 card. - LD A,(_SDBUF+9) - CP 1 - JP NZ,SDINIT8 - LD A,(_SDBUF+10) - CP $AA - JP NZ,SDINIT8 - -SDINIT4: LD A,2 ; This is a version 2 card. -SDINIT5: LD (_SDVER),A ; Indicate this is not a version 2 card. - - CALL SDACMD41 - JR Z,SDINIT6 - LD A,2 ; Error, card is not responding to ACMD41 - JP SD_EXIT - -SDINIT6: LD A,CMD58 ; CMD58 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(_SDBUF+6) - CP $40 - LD A,CT_SD2 - JR Z,SDINIT7 - LD A,CT_SD2 | CT_BLOCK -SDINIT7: LD (_SDCAP),A ; Set the capabilities according to the returned flag. - JR SDINIT14 - - - ; Version 1 card or MMC v3. -SDINIT8: CALL SDACMD41 - LD A, CT_SD1 - LD E,ACMD41 ; SD1 cards we use the ACMD41 command. - JR Z,SDINIT9 - LD A,CT_MMC - LD E,CMD1 ; MMC cards we use the CMD1 command. -SDINIT9: LD (_SDCAP),A - LD A,E - CP ACMD41 - JR NZ,SDINIT10 - CALL SDACMD41 - JR Z,SDINIT14 - LD A,3 ; Exit code, failed to initialise v1 card. - JP SD_EXIT - -SDINIT10: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. -SDINIT11: PUSH BC - LD A,CMD1 ; CMD1 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - OR A - JR Z,SDINIT13 - LD BC,$FFFF ; Delay for at least 200mS for the card to recover and be ready. -SDINIT12: DEC BC ; 6T - LD A,B ; 9T - OR C ; 4T - JR NZ,SDINIT12 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS - ; - POP BC - DEC BC - LD A,B - OR C - JR NZ,SDINIT11 - LD A,4 ; Exit code, failed to initialise v1 MMC card. - JP SD_EXIT - -SDINIT13: LD A,CMD16 ; No response from the card for an ACMD41/CMD1 so try CMD16 with parameter 0x00000200 - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0002 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(_SDBUF+6) - OR A - JR Z,SDINIT14 - LD A,0 - LD (_SDCAP),A ; No capabilities on this unknown card. -SDINIT14: LD A,0 - JR SD_EXIT -SD_EXIT: LD L,A ; Return value goes into HL. - LD H,0 -#endasm -} - - -#asm - ; Method to initialise communications with the SD card. We basically train it to our clock characteristics. - ; This is important, as is maintaining the same clock for read or write otherwise the card may not respond. -SPIINIT: LD B,80 -SPIINIT1: LD A,DOUT_HIGH | CLOCK_HIGH | CS_HIGH ; Output a 1 - OUT (SPI_OUT),A - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Output a 1 - OUT (SPI_OUT),A - DJNZ SPIINIT1 - RET - - ; Method to set the Chip Select level on the SD card. The Chip Select is active LOW. - ; - ; A = 0 - Set CS HIGH - ; A = 0xFF - Set CS LOW -SPICS: OR A - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Set CS High if parameter = 0 (ie. disable) - JR Z, SPICS0 - LD A,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Set CS Low if parameter != 0 (ie. disable) -SPICS0: OUT (SPI_OUT),A - RET - - ; Method to send a command to the card and receive back a response. - ; - ; A = CMD to send - ; LHED = Argument, ie. CMD = A, L, H, E, D, CRC - ; -SDCMD: LD (_SDBUF),A - LD (_SDBUF+1),HL - EX DE,HL - LD (_SDBUF+3),HL - ; - LD B,5 ; R1 + 32bit argument for CMD8, CMD58 - CP CMD8 - LD C,135 - JP Z,SDCMD0 - LD C,1 ; CMD58 is not CRC checked so just set to 0x01. - CP CMD58 - LD B,5 ; R1 + 32bit argument - JP Z,SDCMD0 - ; - LD B,1 ; Default, expect R1 which is 1 byte. - CP CMD0 ; Work out the CRC based on the command. CRC checking is - LD C,149 ; not implemented but certain commands require a fixed argument and CRC. - JP Z,SDCMD0 - LD C,1 ; Remaining commands are not CRC checked so just set to 0x01. -SDCMD0: PUSH BC ; Save the CRC and the number of bytes to be returned, - LD A,C ; Store the CRC - LD (_SDBUF+5),A - LD A,255 ; Preamble byte - CALL SPIOUT - LD HL,_SDBUF - LD B,6 -SDCMD1: PUSH BC - LD A,(HL) - INC HL - CALL SPIOUT ; Send the command and parameters. - POP BC - DJNZ SDCMD1 - PUSH HL -SDCMD2: CALL SPIIN - CP $FF - JR Z,SDCMD2 - JR SDCMD4 -SDCMD3: PUSH BC - PUSH HL - CALL SPIIN ; -SDCMD4: POP HL - LD (HL),A - INC HL - POP BC ; Get back number of expected bytes. HL = place in buffer to store response. - DJNZ SDCMD3 - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH - OUT (SPI_OUT),A - RET - - ; Method to send an Application Command to the SD Card. This involves sending CMD55 followed by the required command. - ; - ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC - ; -SDACMD: PUSH AF - PUSH DE - PUSH HL - LD A,CMD55 ; CMD55 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - DEC A - JR NZ,SDACMD - - POP HL - POP DE - POP AF - CALL SDCMD - LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - OR A - RET - - ; Method to send Application Command 41 to the SD card. This command involves retries and delays - ; hence coded seperately. - ; - ; Returns Z set if successful, else NZ. - ; -SDACMD41: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. -SDACMD1: PUSH BC - LD A,ACMD41 ; ACMD41 has 0x40000000 as parameter, load up registers and call command routine. - LD HL,$0040 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDACMD - LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - OR A - JR Z,SDACMD3 - LD BC,12903 ; Delay for at least 200mS for the card to recover and be ready. -SDACMD2: DEC BC ; 6T - LD A,B ; 9T - OR C ; 4T - JR NZ,SDACMD2 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS - ; - POP BC - DEC BC - LD A,B - OR C - JR NZ,SDACMD1 - LD A,1 -SDACMD3: OR A - RET - - ; Method to send a byte to the SD card via the SPI protocol. - ; This method uses the bitbang technique, change if hardware spi is available. - ; - ; Input A = Byte to send. - ; -SPIOUT: RLCA ; 65432107 - RLCA ; 54321076 - RLCA ; 43210765 - Adjust so that starting bit is same position as Data line. - LD E,A ; E = Character to send. - LD B,8 ; B = Bit count -SPIOUT0: LD A,E - AND DOUT_MASK ; Data bit to data line, clock and cs low. - RLC E -SPIOUT1: OUT (SPI_OUT),A - OR CLOCK_HIGH ; Clock high - OUT (SPI_OUT),A - AND CLOCK_MASK ; Clock low - OUT (SPI_OUT),A - DJNZ SPIOUT0 ; Perform actions for the full 8 bits. - RET - - ; Method to receive a byte from the SD card via the SPI protocol. - ; This method uses the bitbang technique, change if hardware spi is available. - ; NB. Timing must be very similar in SPIOUT and SPIIN. - ; - ; Output: A = received byte. - ; -SPIIN: LD BC,$800 | SPI_OUT ; B = Bit count, C = clock port - LD L,0 ; L = Character being read. - LD D,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Output a 0 - OUT (C),D ; To start ensure clock is low and CS is low. - LD E,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Output a 0 -SPIIN1: OUT (C),E ; Clock to high. - IN A,(SPI_IN) ; Input the received bit - OUT (C),D ; Clock to low. - SRL A - RL L - DJNZ SPIIN1 ; Perform actions for the full 8 bits. - LD A,L ; return value - RET - - ; A function from the z88dk stdlib, a delay loop with T state accuracy. - ; - ; enter : hl = tstates >= 141 - ; uses : af, bc, hl -T_DELAY: LD BC,-141 - ADD HL,BC - LD BC,-23 -TDELAYLOOP: ADD HL,BC - JR C, TDELAYLOOP - LD A,L - ADD A,15 - JR NC, TDELAYG0 - CP 8 - JR C, TDELAYG1 - OR 0 -TDELAYG0: INC HL -TDELAYG1: RRA - JR C, TDELAYB0 - NOP -TDELAYB0: RRA - JR NC, TDELAYB1 - OR 0 -TDELAYB1: RRA - RET NC - RET - - ; Method to skip over an SD card input stream to arrive at the required bytes, - ; - ; Input: BC = Number of bytes to skip. - ; -SPISKIP: PUSH BC - CALL SPIIN - POP BC - DEC BC - LD A,B - OR C - JR NZ,SPISKIP - RET - - ; Method to convert an LBA value into a physical byte address. This is achieved by multiplying the block x 512. - ; We take the value off the stack, shift left 9 times then store the result back onto the stack. - ; - ; Input: HL = Stack offset. -LBATOADDR: ADD HL,SP ; Retrieve sector from stack. - PUSH HL - LD A,(HL) - INC HL - LD E,(HL) - INC HL - LD D,(HL) - LD H,A - LD L,0 - SLA H ; Shift the long left by 9 to effect a x512 - RL E - RL D - POP BC - LD A,L - LD (BC),A - INC BC - LD A,H - LD (BC),A - INC BC - LD A,E - LD (BC),A - INC BC - LD A,D - LD (BC),A - RET -#endasm - - -/*-----------------------------------------------------------------------*/ -/* Read partial sector */ -/*-----------------------------------------------------------------------*/ -DRESULT disk_readp ( BYTE *buff, /* Pointer to the read buffer (NULL:Read bytes are forwarded to the stream) */ - DWORD sector, /* Sector number (LBA) */ - UINT offset, /* Byte offset to read from (0..511) */ - UINT count ) /* Number of bytes to read (ofs + cnt mus be <= 512) */ -{ -#asm - ; parameter 'unsigned int count' at 2 size(2) - ; parameter 'unsigned int offset' at 4 size(2) - ; parameter 'unsigned long sector' at 6 size(4) - ; parameter 'unsigned char BYTE*buff' at 10 size(2) - - LD A,0 - CALL SPICS ; Set CS low (active). - - LD HL,(_SDCAP) ; Test to see if CT_BLOCK is available. - LD H,0 - LD A,CT_BLOCK - AND L - JP NZ,READP_3 ; If it has CT_BLOCK then use sector numbers otherwise multiply up to bytes. - - LD HL,6 + 2 ; It isnt so we need to convert the block to bytes by x512. - CALL LBATOADDR - -READP_3: LD HL,1 - LD (_RESULT),HL - - ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC - LD HL,6 ; Sector is stored as 3rd paramneter at offset 6, retrieve and arrange in little endian order in LHED - ADD HL,SP - LD D,(HL) - INC HL - LD E,(HL) - INC HL - PUSH DE - LD D,(HL) - INC HL - LD E,(HL) - LD A,CMD17 ; Send CMD17 to read a sector. - POP HL - EX DE,HL - CALL SDCMD - LD A,(_SDBUF+6) ; Fetch result and store. - AND A - JP NZ,READP_4 - - LD HL,1000 ; Sit in a tight loop waiting for the data packet arrival (ie. not 0xFF). -READP_7: PUSH HL - LD HL,200 - CALL T_DELAY - CALL SPIIN - POP HL - CP 255 - JP NZ,READP_6 - DEC HL - LD A,H - OR L - JR NZ,READP_7 - -READP_6: CP 254 - JP NZ,READP_4 - LD HL,4 - ADD HL,SP - LD E,(HL) - INC HL - LD D,(HL) - LD HL,514 - AND A - SBC HL,DE - EX DE,HL - POP BC - POP HL - PUSH HL - PUSH BC - EX DE,HL - AND A - SBC HL,DE - LD (_BYTECNT),HL - - LD HL,4 - ADD HL,SP - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - LD A,H - OR L - JP Z,READP_11 - - PUSH HL - POP BC - CALL SPISKIP - -READP_11: LD HL,10 ; Get the buffer pointer from where to read data. - ADD HL,SP - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - LD A,H - OR L - JP Z,READP_12 - -READP_15: PUSH HL - CALL SPIIN - POP HL - LD (HL),A - INC HL - PUSH HL - POP BC - - LD HL,10 ; Update the pointer on the stack with register copy. - ADD HL,SP - LD (HL),C - INC HL - LD (HL),B -READP_13: POP DE ; Return address. - POP HL ; Count - DEC HL ; Decrement count - PUSH HL ; And return stack to previous state. - PUSH DE - LD A,H - OR L - PUSH BC - POP HL - JP NZ,READP_15 - -READP_12: LD HL,(_BYTECNT) - PUSH HL - POP BC - CALL SPISKIP - LD HL,0 - LD (_RESULT),HL -READP_4: - LD A,0 - CALL SPICS - LD HL,(_RESULT) -#endasm -} - - - -/*-----------------------------------------------------------------------*/ -/* Write partial sector */ -/*-----------------------------------------------------------------------*/ -DRESULT disk_writep ( const BYTE *buff, /* Pointer to the bytes to be written (NULL:Initiate/Finalize sector write) */ - DWORD sc ) /* Number of bytes to send, Sector number (LBA) or zero */ -{ -#asm - ; parameter 'unsigned long sc' at 2 size(4) - ; parameter 'const unsigned char BYTE*buff' at 6 size(2) - LD HL,1 - LD (_RESULT),HL - - LD A,$FF ; Activate CS (set low). - CALL SPICS - - LD HL,6 ; If buffer is not null, we are writing data, otherwise we are instigating a write transaction. - ADD HL,SP - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - LD A,H - OR L - JP Z,WRITEP_3 ; NULL so we are performing a transaction open/close. - - LD HL,2 ; Get the sector into DEHL. - ADD HL,SP - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - LD (_BYTECNT),HL ; Only interested in the lower 16bit value of the long. - -WRITEP_4: LD A,H ; So long as we have bytes in the buffer, send to the card for writing. - OR L - JP Z,WRITEP_5 - LD HL,(_WRITECNT) ; Count of bytes to write. - LD A,H - OR L - JR Z,WRITEP_5 ; If either the max count (512) or the requested count (_BYTECNT) have expired, exit. - - LD HL,6 ; Load the buffer pointer. - ADD HL,SP - INC (HL) - LD A,(HL) - INC HL - JR NZ,WRITEP_2 ; Increment by 1 carrying overflow into MSB. - INC (HL) -WRITEP_2: LD H,(HL) - LD L,A - DEC HL ; Back to current byte. - LD A,(HL) - CALL SPIOUT - LD HL,(_WRITECNT) ; Decrement the max count. - DEC HL - LD (_WRITECNT),HL - LD HL,(_BYTECNT) ; Decrement the requested count. - DEC HL - LD (_BYTECNT),HL - JP WRITEP_4 - -WRITEP_5: LD HL,0 - LD (_RESULT),HL - JP WRITEP_8 - -WRITEP_3: LD HL,2 ; Get the sector number into DEHL to test. - ADD HL,SP - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - EX DE,HL - LD A,H - OR L - OR D - OR E - JP Z,WRITEP_9 ; Sector is 0 so finalise the write transaction. - - LD HL,(_SDCAP) ; Check to see if the card has block addressing. - LD H,0 - LD A,CT_BLOCK - AND L - JP NZ,WRITEP_10 ; If it hasnt then we need to multiply up to the correct byte. - - LD HL,2 + 2 ; Fetch the sector number, multiply (by left shift x 9) x512 and store. - CALL LBATOADDR - - ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC -WRITEP_10: LD HL,2 ; Sector is stored as 3rd paramneter at offset 6, retrieve and arrange in little endian order in LHED - ADD HL,SP - LD D,(HL) - INC HL - LD E,(HL) - INC HL - PUSH DE - LD D,(HL) - INC HL - LD E,(HL) - LD A,CMD24 ; Send CMD24 to write a sector. - POP HL - EX DE,HL - CALL SDCMD - LD A,(_SDBUF+6) ; Fetch result and store. - ;LD (_d),A - AND A - JP NZ,WRITEP_8 - LD A,255 - CALL SPIOUT - LD A,254 - CALL SPIOUT - LD HL,512 - LD (_WRITECNT),HL - LD HL,0 - LD (_RESULT),HL - JP WRITEP_8 - -WRITEP_9: LD HL,(_WRITECNT) - INC HL - INC HL - LD (_BYTECNT),HL -WRITEP_13: - LD HL,(_BYTECNT) - DEC HL - LD (_BYTECNT),HL - INC HL - LD A,H - OR L - JP Z,WRITEP_14 - LD A,0 - CALL SPIOUT - JP WRITEP_13 -WRITEP_14: - CALL SPIIN - AND $1F - LD L,A - LD H,0 - CP 5 - JP NZ,WRITEP_15 - - LD HL,10000 - PUSH HL - JR WRITEP_18 -WRITEP_20: DEC HL - PUSH HL - LD HL,200 - CALL T_DELAY -WRITEP_18: CALL SPIIN - POP HL - CP 255 - JP Z,WRITEP_17 - LD A,H - OR L - JR NZ,WRITEP_20 - -WRITEP_17: LD A,H - OR L - JP Z,WRITEP_15 - LD HL,0 - LD (_RESULT),HL -WRITEP_15: LD A,$00 - CALL SPICS -WRITEP_8: LD HL,(_RESULT) - -#endasm -} diff --git a/software/src/PetitFS/sdmmc.c.asm b/software/src/PetitFS/sdmmc.c.asm deleted file mode 100644 index 689de2d..0000000 --- a/software/src/PetitFS/sdmmc.c.asm +++ /dev/null @@ -1,1267 +0,0 @@ -;* * * * * Small-C/Plus z88dk * * * * * -; Version: 16120-f784809cf-20200301 -; -; Reconstructed for z80 Module Assembler -; -; Module compile time: Fri Mar 13 16:31:35 2020 - - - - MODULE sdmmc_c - - - INCLUDE "z80_crt0.hdr" - - - SECTION data_compiler -._Stat - defb 1 - SECTION code_compiler - -; Function spi_init flags 0x00000200 __smallc -; int spi_init() -._spi_init - LD A, 0x04 | 0x00 | 0x00 ; Clock and MOSI High. - OUT ( 0xFF ),A - LD B,80 - LD A, 0x04 | 0x00 | 0x00 ; Output a 1 -SPIINIT1: OUT ( 0xFF ),A - NOP - NOP - LD A, 0x04 | 0x02 | 0x00 ; Output a 1 - OUT ( 0xFF ),A - NOP - NOP - DJNZ SPIINIT1 - LD A, 0x04 | 0x00 | 0x00 ; Output a 1 - OUT ( 0xFF ),A - LD HL,0 ; hl is the return parameter - ret - - - -; Function spi_cs flags 0x00000200 __smallc -; int spi_cs(unsigned char b) -; parameter 'unsigned char b' at 2 size(1) -._spi_cs - ret - - - -; Function spi_out flags 0x00000200 __smallc -; int spi_out(unsigned char b) -; parameter 'unsigned char b' at 2 size(1) -._spi_out - LD HL,2 - ADD HL,SP ; skip over return address on stack - LD A,(HL) ; a = b, "char b" occupies 16 bits on stack - ; but only the LSB is relevant - LD E,A ; E = Character to send. - LD B,08H ; B = Bit count -SPIOUT0: RL E - LD A, 0x00 | 0x00 | 0x00 ; Output a 0 - JR NC,SPIOUT1 - LD A, 0x04 | 0x00 | 0x00 ; Output a 1 -SPIOUT1: OUT ( 0xFF ),A - LD D,A - OR 0x02 - OUT ( 0xFF ),A - LD A,D - OUT ( 0xFF ),A - DJNZ SPIOUT0 ; Perform actions for the full 8 bits. - ;LD A, 0x04 | 0x00 | 0x00 ; Return clock and MOSI to high. - ;OUT ( 0xFF ),A - LD HL,0 ; hl is the return parameter - ret - - - -; Function spi_in flags 0x00000200 __smallc -; unsigned char uint8_tspi_in() -._spi_in - LD BC,0800H ; B = Bit count, C = Character being read. -SPIIN0: LD A, 0x04 | 0x00 | 0x00 ; Output a 0 -SPIIN1: OUT ( 0xFF ),A - LD D,A - OR 0x02 - OUT ( 0xFF ),A - NOP - IN A,( 0xFE ) ; Input the received bit - SRL A - RL C - LD A,D - OUT ( 0xFF ),A - DJNZ SPIIN0 ; Perform actions for the full 8 bits. - LD L,C ; hl is the return parameter - LD H,0 - ret - - - -; Function spi_skip flags 0x00000200 __smallc -; void spi_skip(unsigned int n) -; parameter 'unsigned int n' at 2 size(2) -._spi_skip - dec sp -.i_5 - ld hl,0 ;const - add hl,sp - push hl - call _spi_in - pop de - ld a,l - ld (de),a -.i_3 - ld hl,3 ;const - add hl,sp - dec (hl) - ld a,(hl) - inc hl - cp 255 - jr nz,ASMPC+3 - dec (hl) - ld h,(hl) - ld l,a - ld a,h - or l - jp nz,i_5 -.i_4 - inc sp - ret - - - -; Function send_cmd flags 0x00000200 __smallc -; unsigned char BYTEsend_cmd(unsigned char cmd, unsigned long arg) -; parameter 'unsigned long arg' at 2 size(4) -; parameter 'unsigned char cmd' at 6 size(1) -._send_cmd - push bc - ld hl,8 ;const - add hl,sp - ld a,+(128 % 256) - and (hl) - jp z,i_6 - ld hl,8 ;const - add hl,sp - push hl - ld a,(hl) - and +(127 % 256) - ld l,a - ld h,0 - pop de - ld a,l - ld (de),a - ld hl,0 ;const - add hl,sp - push hl - ld hl,55 ;const - push hl - ld hl,0 ;const - ld d,h - ld e,l - push de - push hl - call _send_cmd - pop bc - pop bc - pop bc - pop de - ld a,l - ld (de),a - pop hl - push hl - ld h,0 - ld a,1 - sub l - jp nc,i_7 - pop hl - push hl - ld h,0 - pop bc - ret - - -.i_7 -.i_6 - ld hl,255 ;const - push hl - call _spi_cs - pop bc - ld hl,8 ;const - add hl,sp - ld l,(hl) - ld h,0 - push hl - call _spi_out - pop bc - ld hl,7 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld de,0 - push hl - call _spi_out - pop bc - ld hl,6 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld de,0 - push hl - call _spi_out - pop bc - ld hl,5 ;const - add hl,sp - ld e,(hl) - inc hl - inc hl - ld l,(hl) - ld h,0 - ex de,hl - ld h,0 - push hl - call _spi_out - pop bc - ld hl,4 ;const - add hl,sp - call l_glong - ld h,0 - push hl - call _spi_out - pop bc - ld hl,1 ;const - add hl,sp - ld (hl),+(1 % 256 % 256) - ld hl,8 ;const - add hl,sp - ld a,(hl) - and a - jp nz,i_8 - ld hl,1 ;const - add hl,sp - ld (hl),+(149 % 256 % 256) -.i_8 - ld hl,8 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld a,l - cp 8 - jp nz,i_9 - ld hl,1 ;const - add hl,sp - ld (hl),+(135 % 256 % 256) -.i_9 - pop hl - push hl - ld l,h - ld h,0 - push hl - call _spi_out - pop bc - ld hl,1 ;const - add hl,sp - ld (hl),+(10 % 256 % 256) -.i_12 - ld hl,0 ;const - add hl,sp - push hl - call _spi_in - pop de - ld a,l - ld (de),a -.i_10 - pop hl - push hl - ld h,0 - ld a,l - and +(128 % 256) - jp z,i_13 - ld hl,1 ;const - add hl,sp - dec (hl) - ld a,(hl) - and a - jr nz,i_14_i_13 -.i_13 - jp i_11 -.i_14_i_13 - jp i_12 -.i_11 - pop hl - push hl - ld h,0 - pop bc - ret - - - -; Function disk_initialize flags 0x00000200 __smallc -; unsigned char DSTATUSdisk_initialize() -._disk_initialize - push bc - push bc - push bc - push bc - dec sp - call _spi_init - ld hl,6 ;const - add hl,sp - ld (hl),+(0 % 256 % 256) - ld hl,0 ;const - push hl - ld d,h - ld e,l - push de - push hl - call _send_cmd - pop bc - pop bc - pop bc - ld a,l - cp 1 - jp nz,i_15 - ld hl,8 ;const - push hl - ld hl,426 ;const - ld de,0 - push de - push hl - call _send_cmd - pop bc - pop bc - pop bc - ld a,l - cp 1 - jp nz,i_16 - ld hl,i_1+0 - push hl - ld a,1 - call printf - pop bc - ld hl,8 ;const - add hl,sp - ld (hl),+(0 % 256 % 256) - ld l,(hl) - ld h,0 - jp i_19 -.i_17 - ld hl,8 ;const - add hl,sp - inc (hl) -.i_19 - ld hl,8 ;const - add hl,sp - ld a,(hl) - sub 4 - jp nc,i_18 - ld hl,2 ;const - add hl,sp - ex de,hl - ld hl,8 ;const - add hl,sp - ld l,(hl) - ld h,0 - add hl,de - push hl - call _spi_in - pop de - ld a,l - ld (de),a - jp i_17 -.i_18 - ld hl,4 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld a,l - cp 1 - jp nz,i_21 - ld hl,5 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld a,l - cp 170 - jr z,i_22_i_21 -.i_21 - jp i_20 -.i_22_i_21 - ld hl,1000 ;const - pop bc - push hl - jp i_25 -.i_23 - pop hl - dec hl - push hl - inc hl -.i_25 - pop hl - push hl - ld a,h - or l - jp z,i_24 - ld hl,169 ;const - push hl - ld hl,0 ;const - ld de,16384 - push de - push hl - call _send_cmd - pop bc - pop bc - pop bc - ld a,l - and a - jp z,i_24 -.i_26 - ld hl,2000 ;const - call t_delay - jp i_23 -.i_24 - pop hl - push hl - ld a,h - or l - jp z,i_28 - ld hl,58 ;const - push hl - ld hl,0 ;const - ld d,h - ld e,l - push de - push hl - call _send_cmd - pop bc - pop bc - pop bc - ld a,l - and a - jr z,i_29_i_28 -.i_28 - jp i_27 -.i_29_i_28 - ld hl,8 ;const - add hl,sp - ld (hl),+(0 % 256 % 256) - ld l,(hl) - ld h,0 - jp i_32 -.i_30 - ld hl,8 ;const - add hl,sp - inc (hl) -.i_32 - ld hl,8 ;const - add hl,sp - ld a,(hl) - sub 4 - jp nc,i_31 - ld hl,2 ;const - add hl,sp - ex de,hl - ld hl,8 ;const - add hl,sp - ld l,(hl) - ld h,0 - add hl,de - push hl - call _spi_in - pop de - ld a,l - ld (de),a - jp i_30 -.i_31 - ld hl,6 ;const - add hl,sp - push hl - ld hl,4 ;const - add hl,sp - ld a,+(64 % 256) - and (hl) - jp z,i_33 - ld hl,12 ;const - jp i_34 -.i_33 - ld hl,4 ;const -.i_34 - pop de - ld a,l - ld (de),a -.i_27 -.i_20 - jp i_35 -.i_16 - ld hl,i_1+20 - push hl - ld a,1 - call printf - pop bc - ld hl,169 ;const - push hl - ld hl,0 ;const - ld d,h - ld e,l - push de - push hl - call _send_cmd - pop bc - pop bc - pop bc - ld a,1 - sub l - ccf - jp nc,i_36 - ld hl,6 ;const - add hl,sp - ld (hl),+(2 % 256 % 256) - ld hl,7 ;const - add hl,sp - ld (hl),+(169 % 256 % 256) - ld l,(hl) - ld h,0 - jp i_37 -.i_36 - ld hl,6 ;const - add hl,sp - ld (hl),+(1 % 256 % 256) - ld hl,7 ;const - add hl,sp - ld (hl),+(1 % 256 % 256) -.i_37 - ld hl,1000 ;const - pop bc - push hl - jp i_40 -.i_38 - pop hl - dec hl - push hl - inc hl -.i_40 - pop hl - push hl - ld a,h - or l - jp z,i_39 - ld hl,7 ;const - add hl,sp - ld l,(hl) - ld h,0 - push hl - ld hl,0 ;const - ld d,h - ld e,l - push de - push hl - call _send_cmd - pop bc - pop bc - pop bc - ld a,l - and a - jp z,i_39 -.i_41 - ld hl,2000 ;const - call t_delay - jp i_38 -.i_39 - pop hl - push hl - call l_lneg - jp c,i_43 - ld hl,16 ;const - push hl - ld hl,512 ;const - ld de,0 - push de - push hl - call _send_cmd - pop bc - pop bc - pop bc - ld a,l - and a - jp z,i_42 -.i_43 - ld hl,6 ;const - add hl,sp - ld (hl),+(0 % 256 % 256) - ld l,(hl) - ld h,0 -.i_42 -.i_35 -.i_15 - ld hl,6 ;const - add hl,sp - ld a,(hl) - ld (_CardType),a - ld hl,255 ;const - push hl - call _spi_cs - pop bc - ld hl,6 ;const - add hl,sp - ld a,(hl) - and a - jp z,i_45 - ld hl,0 ;const - jp i_46 -.i_45 - ld hl,1 ;const -.i_46 - ld h,0 - inc sp - pop bc - pop bc - pop bc - pop bc - ret - - - -; Function disk_readp flags 0x00000200 __smallc -; const int DRESULTdisk_readp(unsigned char BYTE*buff, unsigned long sector, unsigned int offset, unsigned int count) -; parameter 'unsigned int count' at 2 size(2) -; parameter 'unsigned int offset' at 4 size(2) -; parameter 'unsigned long sector' at 6 size(4) -; parameter 'unsigned char BYTE*buff' at 10 size(2) -._disk_readp - push bc - push bc - push bc - dec sp - ld hl,0 ;const - push hl - call _spi_cs - pop bc - ld hl,(_CardType) - ld h,0 - ld a,+(8 % 256) - and l - ld l,a - call l_lneg - jp nc,i_47 - ld hl,13 ;const - add hl,sp - push hl - call l_glong2sp - ld hl,512 ;const - ld de,0 - call l_long_mult - pop bc - call l_plong -.i_47 - ld hl,5 ;const - add hl,sp - ld (hl),+(1 % 256) - inc hl - ld (hl),+(1 / 256) - ld hl,17 ;const - push hl - ld hl,15 ;const - add hl,sp - call l_glong - push de - push hl - call _send_cmd - pop bc - pop bc - pop bc - ld a,l - and a - jp nz,i_48 - ld hl,1000 ;const - pop bc - push hl -.i_51 - ld hl,200 ;const - call t_delay - ld hl,4 ;const - add hl,sp - push hl - call _spi_in - pop de - ld a,l - ld (de),a -.i_49 - ld hl,4 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld a,l - cp 255 - jp nz,i_52 - pop hl - dec hl - push hl - ld a,h - or l - jr nz,i_53_i_52 -.i_52 - jp i_50 -.i_53_i_52 - jp i_51 -.i_50 - ld hl,4 ;const - add hl,sp - ld l,(hl) - ld h,0 - ld a,l - cp 254 - jp nz,i_54 - ld hl,11 ;const - add hl,sp - ld e,(hl) - inc hl - ld d,(hl) - ld hl,514 - and a - sbc hl,de - ex de,hl - ld hl,9 ;const - add hl,sp - call l_gint ; - ex de,hl - and a - sbc hl,de - pop de - pop bc - push hl - push de - ld hl,11 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp z,i_55 - ld hl,11 ;const - add hl,sp - call l_gint ; - push hl - call _spi_skip - pop bc -.i_55 - ld hl,17 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp z,i_56 -.i_59 - ld hl,4 ;const - add hl,sp - push hl - call _spi_in - pop de - ld a,l - ld (de),a - ld hl,17 ;const - add hl,sp - inc (hl) - ld a,(hl) - inc hl - jr nz,ASMPC+3 - inc (hl) - ld h,(hl) - ld l,a - dec hl - push hl - ld hl,6 ;const - add hl,sp - ld a,(hl) - pop de - ld (de),a -.i_57 - ld hl,9 ;const - add hl,sp - dec (hl) - ld a,(hl) - inc hl - cp 255 - jr nz,ASMPC+3 - dec (hl) - ld h,(hl) - ld l,a - ld a,h - or l - jp nz,i_59 -.i_58 - jp i_60 -.i_56 -.i_63 - ld hl,4 ;const - add hl,sp - push hl - call _spi_in - pop de - ld a,l - ld (de),a -.i_61 - ld hl,9 ;const - add hl,sp - dec (hl) - ld a,(hl) - inc hl - cp 255 - jr nz,ASMPC+3 - dec (hl) - ld h,(hl) - ld l,a - ld a,h - or l - jp nz,i_63 -.i_62 -.i_60 - pop bc - pop hl - push hl - push bc - push hl - call _spi_skip - pop bc - ld hl,5 ;const - add hl,sp - ld de,0 ;const - ex de,hl - call l_pint -.i_54 -.i_48 - ld hl,255 ;const - push hl - call _spi_cs - pop bc - ld hl,5 ;const - add hl,sp - call l_gint ; - inc sp - pop bc - pop bc - pop bc - ret - - - -; Function disk_writep flags 0x00000200 __smallc -; const int DRESULTdisk_writep(const unsigned char BYTE*buff, unsigned long sc) -; parameter 'unsigned long sc' at 2 size(4) -; parameter 'const unsigned char BYTE*buff' at 6 size(2) -._disk_writep - push bc - push bc - push bc - ld hl,4 ;const - add hl,sp - ld (hl),+(1 % 256) - inc hl - ld (hl),+(1 / 256) - ld hl,0 ;const - push hl - call _spi_cs - pop bc - ld hl,12 ;const - add hl,sp - call l_gint ; - ld a,h - or l - jp z,i_64 - ld hl,8 ;const - add hl,sp - call l_glong - pop de - pop bc - push hl - push de -.i_65 - pop bc - pop hl - push hl - push bc - ld a,h - or l - jp z,i_67 - ld hl,(_st_disk_writep_wc) - ld a,h - or l - jr nz,i_68_i_67 -.i_67 - jp i_66 -.i_68_i_67 - ld hl,12 ;const - add hl,sp - inc (hl) - ld a,(hl) - inc hl - jr nz,ASMPC+3 - inc (hl) - ld h,(hl) - ld l,a - dec hl - ld l,(hl) - ld h,0 - push hl - call _spi_out - pop bc - ld hl,(_st_disk_writep_wc) - dec hl - ld (_st_disk_writep_wc),hl - pop de - pop hl - dec hl - push hl - push de - inc hl - jp i_65 -.i_66 - ld hl,4 ;const - add hl,sp - ld de,0 ;const - ex de,hl - call l_pint - jp i_69 -.i_64 - ld hl,8 ;const - add hl,sp - call l_glong - ld a,h - or l - or d - or e - jp z,i_70 - ld hl,(_CardType) - ld h,0 - ld a,+(8 % 256) - and l - ld l,a - call l_lneg - jp nc,i_71 - ld hl,8 ;const - add hl,sp - push hl - call l_glong2sp - ld hl,512 ;const - ld de,0 - call l_long_mult - pop bc - call l_plong -.i_71 - ld hl,24 ;const - push hl - ld hl,10 ;const - add hl,sp - call l_glong - push de - push hl - call _send_cmd - pop bc - pop bc - pop bc - ld a,l - and a - jp nz,i_72 - ld hl,255 ;const - push hl - call _spi_out - pop bc - ld hl,254 ;const - push hl - call _spi_out - pop bc - ld hl,512 ;const - ld (_st_disk_writep_wc),hl - ld hl,4 ;const - add hl,sp - ld de,0 ;const - ex de,hl - call l_pint -.i_72 - jp i_73 -.i_70 - ld hl,(_st_disk_writep_wc) - inc hl - inc hl - pop de - pop bc - push hl - push de -.i_74 - pop de - pop hl - dec hl - push hl - push de - inc hl - ld a,h - or l - jp z,i_75 - ld hl,0 ;const - push hl - call _spi_out - pop bc - jp i_74 -.i_75 - call _spi_in - ld a,l - and +(31 % 256) - ld l,a - ld h,0 - cp 5 - jp nz,i_76 - ld hl,10000 ;const - pop bc - push hl - jp i_79 -.i_77 - pop hl - dec hl - push hl - inc hl -.i_79 - call _spi_in - ld a,l - cp 255 - jp z,i_80 - pop hl - push hl - ld a,h - or l - jr nz,i_81_i_80 -.i_80 - jp i_78 -.i_81_i_80 - ld hl,200 ;const - call t_delay - jp i_77 -.i_78 - pop hl - push hl - ld a,h - or l - jp z,i_82 - ld hl,4 ;const - add hl,sp - ld de,0 ;const - ex de,hl - call l_pint -.i_82 -.i_76 - ld hl,255 ;const - push hl - call _spi_cs - pop bc -.i_73 -.i_69 - ld hl,4 ;const - add hl,sp - call l_gint ; - pop bc - pop bc - pop bc - ret - - - SECTION rodata_compiler -.i_1 - defm "Identified v2 card" - defb 10 - - defm "" - defb 0 - - defm "Identified v1 card" - defb 10 - - defm "" - defb 0 - - -; --- Start of Static Variables --- - - SECTION bss_compiler -._CardType defs 1 -._st_disk_writep_wc defs 2 - SECTION code_compiler - - -; --- Start of Scope Defns --- - - GLOBAL open - GLOBAL creat - GLOBAL close - GLOBAL read - GLOBAL write - GLOBAL lseek - GLOBAL readbyte - GLOBAL writebyte - GLOBAL getcwd - GLOBAL chdir - GLOBAL getwd - GLOBAL rmdir - GLOBAL _RND_BLOCKSIZE - GLOBAL rnd_loadblock - GLOBAL rnd_saveblock - GLOBAL rnd_erase - GLOBAL __FOPEN_MAX - GLOBAL __sgoioblk - GLOBAL __sgoioblk_end - GLOBAL fopen_zsock - GLOBAL fopen - GLOBAL freopen - GLOBAL fdopen - GLOBAL _freopen1 - GLOBAL fmemopen - GLOBAL funopen - GLOBAL fclose - GLOBAL fflush - GLOBAL closeall - GLOBAL fgets - GLOBAL fputs - GLOBAL fputc - GLOBAL fputs_callee - GLOBAL fputc_callee - GLOBAL fgetc - GLOBAL ungetc - GLOBAL feof - GLOBAL ferror - GLOBAL puts - GLOBAL ftell - GLOBAL fgetpos - GLOBAL fseek - GLOBAL fread - GLOBAL fwrite - GLOBAL gets - GLOBAL printf - GLOBAL fprintf - GLOBAL sprintf - GLOBAL snprintf - GLOBAL vfprintf - GLOBAL vsnprintf - GLOBAL printn - GLOBAL scanf - GLOBAL fscanf - GLOBAL sscanf - GLOBAL vfscanf - GLOBAL vsscanf - GLOBAL getarg - GLOBAL fchkstd - GLOBAL fgetc_cons - GLOBAL fgetc_cons_inkey - GLOBAL fputc_cons - GLOBAL fgets_cons - GLOBAL puts_cons - GLOBAL fabandon - GLOBAL fdtell - GLOBAL fdgetpos - GLOBAL rename - GLOBAL remove - GLOBAL getk - GLOBAL getk_inkey - GLOBAL printk - GLOBAL perror - GLOBAL atoi - GLOBAL atol - GLOBAL itoa - GLOBAL itoa_callee - GLOBAL ltoa - GLOBAL ltoa_callee - GLOBAL strtol - GLOBAL strtol_callee - GLOBAL strtoul - GLOBAL strtoul_callee - GLOBAL ultoa - GLOBAL ultoa_callee - GLOBAL utoa - GLOBAL utoa_callee - GLOBAL rand - GLOBAL srand - GLOBAL mallinit - GLOBAL sbrk - GLOBAL sbrk_callee - GLOBAL calloc - GLOBAL calloc_callee - GLOBAL free - GLOBAL malloc - GLOBAL realloc - GLOBAL realloc_callee - GLOBAL mallinfo - GLOBAL mallinfo_callee - GLOBAL HeapCreate - GLOBAL HeapSbrk - GLOBAL HeapSbrk_callee - GLOBAL HeapCalloc - GLOBAL HeapCalloc_callee - GLOBAL HeapFree - GLOBAL HeapFree_callee - GLOBAL HeapAlloc - GLOBAL HeapAlloc_callee - GLOBAL HeapRealloc - GLOBAL HeapRealloc_callee - GLOBAL HeapInfo - GLOBAL HeapInfo_callee - GLOBAL exit - GLOBAL atexit - GLOBAL getopt - GLOBAL _optarg - GLOBAL _opterr - GLOBAL _optind - GLOBAL _optopt - GLOBAL _optreset - GLOBAL l_bsearch - GLOBAL l_bsearch_callee - GLOBAL l_qsort - GLOBAL l_qsort_callee - GLOBAL qsort_sccz80 - GLOBAL qsort_sccz80_callee - GLOBAL qsort_sdcc - GLOBAL qsort_sdcc_callee - GLOBAL _div_ - GLOBAL _div__callee - GLOBAL _divu_ - GLOBAL _divu__callee - GLOBAL _ldiv_ - GLOBAL _ldiv__callee - GLOBAL _ldivu_ - GLOBAL _ldivu__callee - GLOBAL abs - GLOBAL labs - GLOBAL isqrt - GLOBAL inp - GLOBAL outp - GLOBAL outp_callee - GLOBAL swapendian - GLOBAL bpoke - GLOBAL bpoke_callee - GLOBAL wpoke - GLOBAL wpoke_callee - GLOBAL bpeek - GLOBAL wpeek - GLOBAL t_delay - GLOBAL sleep - GLOBAL msleep - GLOBAL extract_bits - GLOBAL extract_bits_callee - GLOBAL wcmatch - GLOBAL unbcd - GLOBAL _pf_mount - GLOBAL _pf_open - GLOBAL _pf_read - GLOBAL _pf_write - GLOBAL _pf_lseek - GLOBAL _pf_opendir - GLOBAL _pf_readdir - GLOBAL _disk_initialize - GLOBAL _disk_readp - GLOBAL _disk_writep - GLOBAL _spi_init - GLOBAL _spi_cs - GLOBAL _spi_out - GLOBAL _spi_in - GLOBAL _spi_skip - - -; --- End of Scope Defns --- - - -; --- End of Compilation --- diff --git a/software/src/PetitFS/sdmmc.c.bak b/software/src/PetitFS/sdmmc.c.bak deleted file mode 100644 index 7af754b..0000000 --- a/software/src/PetitFS/sdmmc.c.bak +++ /dev/null @@ -1,1006 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Name: sdmmc.c -// Created: March 2020 -// Author(s): ChaN (framework), Philip Smart (Sharp MZ80A/RFS customisation) -// Description: Functionality to enable connectivity between the PetitFS ((C) ChaN) and the RFS -// subsystem of the Sharp MZ80A for SD drives. This module provides the public -// interfaces to interact with the hardware. -// -// Credits: -// Copyright: (C) 2013, ChaN, all rights reserved - framework. -// Copyright: (C) 2020 Philip Smart -// -// History: March 2020 - Initial development. -// -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// This source file is free software: you can redistribute it and#or modify -// it under the terms of the GNU General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This source file is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include "pff.h" /* Obtains integer types for Petit FatFs */ -#include "sdmmc.h" /* Common include file for the disk I/O layer */ - -/*-------------------------------------------------------------------------*/ -/* Platform dependent macros and functions needed to be modified */ -/*-------------------------------------------------------------------------*/ - -#define SPI_OUT 0xFF -#define SPI_IN 0xFE -#define DOUT_LOW 0x00 -#define DOUT_HIGH 0x04 -#define DOUT_MASK 0x04 -#define DIN_LOW 0x00 -#define DIN_HIGH 0x01 -#define CLOCK_LOW 0x00 -#define CLOCK_HIGH 0x02 -#define CLOCK_MASK 0xFD -#define CS_LOW 0x00 -#define CS_HIGH 0x01 - -/*-------------------------------------------------------------------------- - Module Private Functions ----------------------------------------------------------------------------*/ - -/* MMC/SD command (SPI mode) */ -#define CMD0 64 + 0 /* GO_IDLE_STATE */ -#define CMD1 64 + 1 /* SEND_OP_COND */ -#define ACMD41 0x40+41 /* SEND_OP_COND (SDC) */ -#define CMD8 64 + 8 /* SEND_IF_COND */ -#define CMD9 64 + 9 /* SEND_CSD */ -#define CMD10 64 + 10 /* SEND_CID */ -#define CMD12 64 + 12 /* STOP_TRANSMISSION */ -#define CMD13 64 + 13 /* SEND_STATUS */ -#define ACMD13 0x40+13 /* SD_STATUS (SDC) */ -#define CMD16 64 + 16 /* SET_BLOCKLEN */ -#define CMD17 64 + 17 /* READ_SINGLE_BLOCK */ -#define CMD18 64 + 18 /* READ_MULTIPLE_BLOCK */ -#define CMD23 64 + 23 /* SET_BLOCK_COUNT */ -#define ACMD23 0x40+23 /* SET_WR_BLK_ERASE_COUNT (SDC) */ -#define CMD24 64 + 24 /* WRITE_BLOCK */ -#define CMD25 64 + 25 /* WRITE_MULTIPLE_BLOCK */ -#define CMD32 64 + 32 /* ERASE_ER_BLK_START */ -#define CMD33 64 + 33 /* ERASE_ER_BLK_END */ -#define CMD38 64 + 38 /* ERASE */ -#define CMD55 64 + 55 /* APP_CMD */ -#define CMD58 64 + 58 /* READ_OCR */ -#define SECTOR_SIZE 512 /* Default size of an SD Sector */ - -/* Card type flags (CardType) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_SDC CT_SD1|CT_SD2 /* SD */ -#define CT_BLOCK 0x08 /* Block addressing */ - -static DSTATUS Stat = STA_NOINIT; /* Disk status */ -BYTE SDBUF[11]; -BYTE SDVER; -BYTE SDCAP; - -/*-------------------------------------------------------------------------- - Public Functions ----------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - - -// Method to initialise the SPI hardware. -// -//int spi_init(void) -//{ -//#asm -// ; Method to initialise communications with the SD card. We basically train it to our clock characteristics. -// ; This is important, as is maintaining the same clock for read or write otherwise the card may not respond. -// LD B,80 -//SPI_INIT1: LD A,DOUT_HIGH | CLOCK_HIGH | CS_HIGH ; Output a 1 -// OUT (SPI_OUT),A -// LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Output a 1 -// OUT (SPI_OUT),A -// DJNZ SPI_INIT1 -// LD HL,0 ; hl is the return parameter -//#endasm -//} - -// Method to select/deselect the SD card within the SPI hardware -// addressing mechanism. -// -// Input: b = 0, deselect SD Card -// b = 1, select SD Card. -//int spi_cs(unsigned char b) -//{ -//#asm -// ; Method to set the Chip Select level on the SD card. The Chip Select is active LOW. -// ; -// ; A = 0 - Set CS HIGH -// ; A = 0xFF - Set CS LOW -// LD HL,2 -// ADD HL,SP ; skip over return address on stack -// LD A,(HL) ; a = b, "char b" occupies 16 bits on stack -// ; but only the LSB is relevant -// OR A -// LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Set CS High if parameter = 0 (ie. disable) -// JR Z, SPI_CS0 -// LD A,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Set CS Low if parameter != 0 (ie. disable) -//SPI_CS0: OUT (SPI_OUT),A -// LD HL,0 ; hl is the return parameter -//#endasm -//} - -// Method to transmit a byte via SPI. -// -// Input: b = 8 bit character to send. -// -//int spi_out(unsigned char b) -//{ -//#asm -// ; Method to send a byte to the SD card via the SPI protocol. -// ; This method uses the bitbang technique, change if hardware spi is available. -// ; -// ; Input A = Byte to send. -// ; -// LD HL,2 -// ADD HL,SP ; skip over return address on stack -// LD A,(HL) ; a = b, "char b" occupies 16 bits on stack -// ; but only the LSB is relevant -// RLCA ; 65432107 -// RLCA ; 54321076 -// RLCA ; 43210765 - Adjust so that starting bit is same position as Data line. -// LD E,A ; E = Character to send. -// LD B,8 ; B = Bit count -//SPI_OUT0: LD A,E -// AND DOUT_MASK ; Data bit to data line, clock and cs low. -// RLC E -//SPI_OUT1: OUT (SPI_OUT),A -// OR CLOCK_HIGH ; Clock high -// OUT (SPI_OUT),A -// AND CLOCK_MASK ; Clock low -// OUT (SPI_OUT),A -// DJNZ SPI_OUT0 ; Perform actions for the full 8 bits. -// LD HL,0 ; hl is the return parameter -//#endasm -//} - -// Method to receive a character from the SPI. -// -// Returns: 8 bit byte. -// -//uint8_t spi_in(void) -//{ -//#asm -// ; Method to receive a byte from the SD card via the SPI protocol. -// ; This method uses the bitbang technique, change if hardware spi is available. -// ; NB. Timing must be very similar in SPIOUT and SPIIN. -// ; -// ; Output: A = received byte. -// ; -// LD BC,$800 | SPI_OUT ; B = Bit count, C = clock port -// LD L,0 ; L = Character being read. -// LD D,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Output a 0 -// OUT (C),D ; To start ensure clock is low and CS is low. -// LD E,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Output a 0 -//SPI_IN1: OUT (C),E ; Clock to high. -// IN A,(SPI_IN) ; Input the received bit -// OUT (C),D ; Clock to low. -// SRL A -// RL L -// DJNZ SPI_IN1 ; Perform actions for the full 8 bits. -// LD H,0 ; hl is the return parameter, L already set to received byte. -//#endasm -//} - -// Method to skip data being sent over the SPI. -// -// Input: n = number of bytes to skip or flush. -// -//void spi_skip(UINT n) -//{ -//#asm -// LD HL,2 -// ADD HL,SP ; skip over return address on stack -// LD C,(HL) ; n occupies 16 bits on stack -// INC HL -// LD B,(HL) -// -//SPISKIP0: PUSH BC -// CALL SPIIN -// POP BC -// DEC BC -// LD A,B -// OR C -// JR NZ,SPISKIP0 -//#endasm -//} - -/*-----------------------------------------------------------------------*/ -/* Send a command packet to MMC */ -/*-----------------------------------------------------------------------*/ -// -//BYTE send_cmd (BYTE cmd, /* Command byte */ -// DWORD arg /* Argument */ -// ) -//{ -//#asm -// ; Method to send a command to the card and receive back a response. -// ; -// ; A = CMD to send -// ; LHED = Argument, ie. CMD = A, L, H, E, D, CRC -// ; -// LD HL,2 -// ADD HL,SP ; skip over return address on stack -// LD A,(HL) -// LD (_SDBUF+4),A -// INC HL -// LD A,(HL) -// LD (_SDBUF+3),A -// INC HL -// LD A,(HL) -// LD (_SDBUF+2),A -// INC HL -// LD A,(HL) -// LD (_SDBUF+1),A -// INC HL -// LD A,(HL) -// LD (_SDBUF),A -// ; -// LD B,5 ; R1 + 32bit argument for CMD8, CMD58 -// CP CMD8 -// LD C,135 -// JP Z,SD_CMD0 -// LD C,1 ; CMD58 is not CRC checked so just set to 0x01. -// CP CMD58 -// LD B,5 ; R1 + 32bit argument -// JP Z,SD_CMD0 -// ; -// LD B,1 ; Default, expect R1 which is 1 byte. -// CP CMD0 ; Work out the CRC based on the command. CRC checking is -// LD C,149 ; not implemented but certain commands require a fixed argument and CRC. -// JP Z,SD_CMD0 -// LD C,1 ; Remaining commands are not CRC checked so just set to 0x01. -//SD_CMD0: PUSH BC ; Save the CRC and the number of bytes to be returned, -// LD A,C ; Store the CRC -// LD (_SDBUF+5),A -// LD A,255 ; Preamble byte -// CALL SPIOUT -// LD HL,_SDBUF -// LD B,6 -//SD_CMD1: PUSH BC -// LD A,(HL) -// INC HL -// CALL SPIOUT ; Send the command and parameters. -// POP BC -// DJNZ SD_CMD1 -// PUSH HL -//SD_CMD2: CALL SPIIN -// CP $FF -// JR Z,SD_CMD2 -// JR SD_CMD4 -//SD_CMD3: PUSH BC -// PUSH HL -// CALL SPIIN ; -//SD_CMD4: POP HL -// LD (HL),A -// INC HL -// POP BC ; Get back number of expected bytes. HL = place in buffer to store response. -// DJNZ SD_CMD3 -// LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH -// OUT (SPI_OUT),A -// LD A,(_SDBUF+6) -// LD L,A -// LD H,0 -//#endasm -//} - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ -DSTATUS disk_initialize (void) -{ -#asm - ; Method to initialise the SD card. - ; -SDINIT: LD A,$00 ; CS to high - CALL SPICS - ; - CALL SPIINIT ; Train SD with our clock. - ; - LD A,$FF ; CS to low - CALL SPICS - LD BC,$FFFF - -SDINIT1: LD A,CMD0 ; Command 0 - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - - PUSH BC - LD A,(_SDBUF+6) ; Get response code. - DEC A ; Set Z flag to test if response is 0x01 - JP Z,SDINIT2 ; Command response 0x01? Exit if match. - POP BC - DEC BC - LD A,B - OR C - JR NZ,SDINIT1 ; Retry for BC times. - LD A,1 - JP SD_EXIT ; Error, card is not responding to CMD0 -SDINIT2: POP BC - ; Now send CMD8 to get card details. This command can only be sent - ; when the card is idle. - LD A,CMD8 ; CMD8 has 0x00001AA as parameter, load up registers and call command routine. - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$AA01 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - - ; Version 2 card, check its voltage range. IF not in the 2.7-3.6V dont try the ACMD41 to get capabilities. -SDINIT3: LD A,1 ; Check that we receive 0x0001AA in response. - LD (_SDVER),A ; Indicate this is not a version 2 card. - LD A,(_SDBUF+9) - CP 1 - JP NZ,SDINIT8 - LD A,(_SDBUF+10) - CP $AA - JP NZ,SDINIT8 - -SDINIT4: LD A,2 ; This is a version 2 card. -SDINIT5: LD (_SDVER),A ; Indicate this is not a version 2 card. - - CALL SDACMD41 - JR Z,SDINIT6 - LD A,2 ; Error, card is not responding to ACMD41 - JP SD_EXIT - -SDINIT6: LD A,CMD58 ; CMD58 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(_SDBUF+6) - CP $40 - LD A,CT_SD2 - JR Z,SDINIT7 - LD A,CT_SD2 | CT_BLOCK -SDINIT7: LD (_SDCAP),A ; Set the capabilities according to the returned flag. - JR SDINIT14 - - - ; Version 1 card or MMC v3. -SDINIT8: CALL SDACMD41 - LD A, CT_SD1 - LD E,ACMD41 ; SD1 cards we use the ACMD41 command. - JR Z,SDINIT9 - LD A,CT_MMC - LD E,CMD1 ; MMC cards we use the CMD1 command. -SDINIT9: LD (_SDCAP),A - LD A,E - CP ACMD41 - JR NZ,SDINIT10 - CALL SDACMD41 - JR Z,SDINIT14 - LD A,3 ; Exit code, failed to initialise v1 card. - JP SD_EXIT - -SDINIT10: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. -SDINIT11: PUSH BC - LD A,CMD1 ; CMD1 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - OR A - JR Z,SDINIT13 - LD BC,$FFFF ; Delay for at least 200mS for the card to recover and be ready. -SDINIT12: DEC BC ; 6T - LD A,B ; 9T - OR C ; 4T - JR NZ,SDINIT12 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS - ; - POP BC - DEC BC - LD A,B - OR C - JR NZ,SDINIT11 - LD A,4 ; Exit code, failed to initialise v1 MMC card. - JP SD_EXIT - -SDINIT13: LD A,CMD16 ; No response from the card for an ACMD41/CMD1 so try CMD16 with parameter 0x00000200 - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0002 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(_SDBUF+6) - OR A - JR Z,SDINIT14 - LD A,0 - LD (_SDCAP),A ; No capabilities on this unknown card. -SDINIT14: LD A,0 - JR SD_EXIT -SD_EXIT: LD L,A ; Return value goes into HL. - LD H,0 - RET - -#endasm -} - - -static DRESULT res; -static UINT bc; -static static UINT wc; -static BYTE d; - -#asm - ; Method to initialise communications with the SD card. We basically train it to our clock characteristics. - ; This is important, as is maintaining the same clock for read or write otherwise the card may not respond. -SPIINIT: LD B,80 -SPIINIT1: LD A,DOUT_HIGH | CLOCK_HIGH | CS_HIGH ; Output a 1 - OUT (SPI_OUT),A - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Output a 1 - OUT (SPI_OUT),A - DJNZ SPIINIT1 - RET - - ; Method to set the Chip Select level on the SD card. The Chip Select is active LOW. - ; - ; A = 0 - Set CS HIGH - ; A = 0xFF - Set CS LOW -SPICS: OR A - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Set CS High if parameter = 0 (ie. disable) - JR Z, SPICS0 - LD A,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Set CS Low if parameter != 0 (ie. disable) -SPICS0: OUT (SPI_OUT),A - RET - - ; Method to send a command to the card and receive back a response. - ; - ; A = CMD to send - ; LHED = Argument, ie. CMD = A, L, H, E, D, CRC - ; -SDCMD: LD (_SDBUF),A - LD (_SDBUF+1),HL - EX DE,HL - LD (_SDBUF+3),HL - ; - LD B,5 ; R1 + 32bit argument for CMD8, CMD58 - CP CMD8 - LD C,135 - JP Z,SDCMD0 - LD C,1 ; CMD58 is not CRC checked so just set to 0x01. - CP CMD58 - LD B,5 ; R1 + 32bit argument - JP Z,SDCMD0 - ; - LD B,1 ; Default, expect R1 which is 1 byte. - CP CMD0 ; Work out the CRC based on the command. CRC checking is - LD C,149 ; not implemented but certain commands require a fixed argument and CRC. - JP Z,SDCMD0 - LD C,1 ; Remaining commands are not CRC checked so just set to 0x01. -SDCMD0: PUSH BC ; Save the CRC and the number of bytes to be returned, - LD A,C ; Store the CRC - LD (_SDBUF+5),A - LD A,255 ; Preamble byte - CALL SPIOUT - LD HL,_SDBUF - LD B,6 -SDCMD1: PUSH BC - LD A,(HL) - INC HL - CALL SPIOUT ; Send the command and parameters. - POP BC - DJNZ SDCMD1 - PUSH HL -SDCMD2: CALL SPIIN - CP $FF - JR Z,SDCMD2 - JR SDCMD4 -SDCMD3: PUSH BC - PUSH HL - CALL SPIIN ; -SDCMD4: POP HL - LD (HL),A - INC HL - POP BC ; Get back number of expected bytes. HL = place in buffer to store response. - DJNZ SDCMD3 - LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH - OUT (SPI_OUT),A - RET - - ; Method to send an Application Command to the SD Card. This involves sending CMD55 followed by the required command. - ; - ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC - ; -SDACMD: PUSH AF - PUSH DE - PUSH HL - LD A,CMD55 ; CMD55 has 0x00000000 as parameter, load up registers and call command routine. - LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDCMD - LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - DEC A - JR NZ,SDACMD - - POP HL - POP DE - POP AF - CALL SDCMD - LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - OR A - RET - - ; Method to send Application Command 41 to the SD card. This command involves retries and delays - ; hence coded seperately. - ; - ; Returns Z set if successful, else NZ. - ; -SDACMD41: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. -SDACMD1: PUSH BC - LD A,ACMD41 ; ACMD41 has 0x40000000 as parameter, load up registers and call command routine. - LD HL,$0040 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. - LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. - CALL SDACMD - LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. - OR A - JR Z,SDACMD3 - LD BC,12903 ; Delay for at least 200mS for the card to recover and be ready. -SDACMD2: DEC BC ; 6T - LD A,B ; 9T - OR C ; 4T - JR NZ,SDACMD2 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS - ; - POP BC - DEC BC - LD A,B - OR C - JR NZ,SDACMD1 - LD A,1 -SDACMD3: OR A - RET - - ; Method to send a byte to the SD card via the SPI protocol. - ; This method uses the bitbang technique, change if hardware spi is available. - ; - ; Input A = Byte to send. - ; -SPIOUT: RLCA ; 65432107 - RLCA ; 54321076 - RLCA ; 43210765 - Adjust so that starting bit is same position as Data line. - LD E,A ; E = Character to send. - LD B,8 ; B = Bit count -SPIOUT0: LD A,E - AND DOUT_MASK ; Data bit to data line, clock and cs low. - RLC E -SPIOUT1: OUT (SPI_OUT),A - OR CLOCK_HIGH ; Clock high - OUT (SPI_OUT),A - AND CLOCK_MASK ; Clock low - OUT (SPI_OUT),A - DJNZ SPIOUT0 ; Perform actions for the full 8 bits. - RET - - ; Method to receive a byte from the SD card via the SPI protocol. - ; This method uses the bitbang technique, change if hardware spi is available. - ; NB. Timing must be very similar in SPIOUT and SPIIN. - ; - ; Output: A = received byte. - ; -SPIIN: LD BC,$800 | SPI_OUT ; B = Bit count, C = clock port - LD L,0 ; L = Character being read. - LD D,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Output a 0 - OUT (C),D ; To start ensure clock is low and CS is low. - LD E,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Output a 0 -SPIIN1: OUT (C),E ; Clock to high. - IN A,(SPI_IN) ; Input the received bit - OUT (C),D ; Clock to low. - SRL A - RL L - DJNZ SPIIN1 ; Perform actions for the full 8 bits. - LD A,L ; return value - RET - - ; enter : hl = tstates >= 141 - ; - ; uses : af, bc, hl -T_DELAY: LD BC,-141 - ADD HL,BC - LD BC,-23 -TDELAYLOOP: ADD HL,BC - JR C, TDELAYLOOP - LD A,L - ADD A,15 - JR NC, TDELAYG0 - CP 8 - JR C, TDELAYG1 - OR 0 -TDELAYG0: INC HL -TDELAYG1: RRA - JR C, TDELAYB0 - NOP -TDELAYB0: RRA - JR NC, TDELAYB1 - OR 0 -TDELAYB1: RRA - RET NC - RET - - ; Method to skip over an SD card input stream to arrive at the required bytes, - ; - ; Input: BC = Number of bytes to skip. - ; -SPISKIP: PUSH BC - CALL SPIIN - POP BC - DEC BC - LD A,B - OR C - JR NZ,SPISKIP - RET - - ; Method to convert an LBA value into a physical byte address. This is achieved by multiplying the block x 512. - ; We take the value off the stack, shift left 9 times then store the result back onto the stack. - ; - ; Input: HL = Stack offset. -LBATOADDR: ADD HL,SP ; Retrieve sector from stack. - PUSH HL - LD A,(HL) - INC HL - LD E,(HL) - INC HL - LD D,(HL) - LD H,A - LD L,0 - SLA H ; Shift the long left by 9 to effect a x512 - RL E - RL D - POP BC - LD A,L - LD (BC),A - INC BC - LD A,H - LD (BC),A - INC BC - LD A,E - LD (BC),A - INC BC - LD A,D - LD (BC),A - RET -#endasm - - -/*-----------------------------------------------------------------------*/ -/* Read partial sector */ -/*-----------------------------------------------------------------------*/ -DRESULT disk_readp ( BYTE *buff, /* Pointer to the read buffer (NULL:Read bytes are forwarded to the stream) */ - DWORD sector, /* Sector number (LBA) */ - UINT offset, /* Byte offset to read from (0..511) */ - UINT count ) /* Number of bytes to read (ofs + cnt mus be <= 512) */ -{ -#asm - ; parameter 'unsigned int count' at 2 size(2) - ; parameter 'unsigned int offset' at 4 size(2) - ; parameter 'unsigned long sector' at 6 size(4) - ; parameter 'unsigned char BYTE*buff' at 10 size(2) - - LD A,0 - CALL SPICS ; Set CS low (active). - - LD HL,(_SDCAP) ; Test to see if CT_BLOCK is available. - LD H,0 - LD A,CT_BLOCK - AND L - JP NZ,READP_3 ; If it has CT_BLOCK then use sector numbers otherwise multiply up to bytes. - - LD HL,6 + 2 ; It isnt so we need to convert the block to bytes by x512. - CALL LBATOADDR - -READP_3: LD HL,1 - LD (_res),HL - - ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC - LD HL,6 ; Sector is stored as 3rd paramneter at offset 6, retrieve and arrange in little endian order in LHED - ADD HL,SP - LD D,(HL) - INC HL - LD E,(HL) - INC HL - PUSH DE - LD D,(HL) - INC HL - LD E,(HL) - LD A,CMD17 ; Send CMD17 to read a sector. - POP HL - EX DE,HL - CALL SDCMD - LD A,(_SDBUF+6) ; Fetch result and store. - LD (_d),A - AND A - JP NZ,READP_4 - - LD HL,1000 ; Sit in a tight loop waiting for the data packet arrival (ie. not 0xFF). -READP_7: PUSH HL - LD HL,200 - CALL T_DELAY - CALL SPIIN - LD (_d),A - POP HL - CP 255 - JP NZ,READP_6 - DEC HL - LD A,H - OR L - JR NZ,READP_7 - -READP_6: CP 254 - JP NZ,READP_4 - LD HL,4 - ADD HL,SP - LD E,(HL) - INC HL - LD D,(HL) - LD HL,514 - AND A - SBC HL,DE - EX DE,HL - POP BC - POP HL - PUSH HL - PUSH BC - EX DE,HL - AND A - SBC HL,DE - LD (_bc),HL - - LD HL,4 - ADD HL,SP - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - LD A,H - OR L - JP Z,READP_11 - - PUSH HL - POP BC - CALL SPISKIP -READP_11: - LD HL,10 - ADD HL,SP - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - LD A,H - OR L - JP Z,READP_12 - -READP_15: CALL SPIIN - LD (_d),A - LD HL,10 - ADD HL,SP - INC (HL) - LD A,(HL) - INC HL - JR NZ,READP_14 - INC (HL) -READP_14: LD H,(HL) - LD L,A - DEC HL - EX DE,HL - LD HL,_d - LD A,(HL) - LD (DE),A -READP_13: - POP DE - POP HL - DEC HL - PUSH HL - PUSH DE - LD A,H - OR L - JP NZ,READP_15 -READP_12: - LD HL,(_bc) - PUSH HL - POP BC - CALL SPISKIP - LD HL,0 - LD (_res),HL -READP_4: - LD A,0 - CALL SPICS - LD HL,(_res) - -#endasm -} - - - -/*-----------------------------------------------------------------------*/ -/* Write partial sector */ -/*-----------------------------------------------------------------------*/ -DRESULT disk_writep ( const BYTE *buff, /* Pointer to the bytes to be written (NULL:Initiate/Finalize sector write) */ - DWORD sc ) /* Number of bytes to send, Sector number (LBA) or zero */ -{ -#asm - ; parameter 'unsigned long sc' at 2 size(4) - ; parameter 'const unsigned char BYTE*buff' at 6 size(2) - LD HL,1 - LD (_res),HL - - LD A,$FF ; Activate CS (set low). - CALL SPICS - - LD HL,6 ; If buffer is not null, we are writing data, otherwise we are instigating a write transaction. - ADD HL,SP - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - LD A,H - OR L - JP Z,WRITEP_3 ; NULL so we are performing a transaction open/close. - - LD HL,2 ; Get the sector into DEHL. - ADD HL,SP - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - LD (_bc),HL ; Only interested in the lower 16bit value of the long. - -WRITEP_4: LD A,H ; So long as we have bytes in the buffer, send to the card for writing. - OR L - JP Z,WRITEP_5 - LD HL,(_wc) ; Count of bytes to write. - LD A,H - OR L - JR Z,WRITEP_5 ; If either the max count (512) or the requested count (_bc) have expired, exit. - - LD HL,6 ; Load the buffer pointer. - ADD HL,SP - INC (HL) - LD A,(HL) - INC HL - JR NZ,WRITEP_2 ; Increment by 1 carrying overflow into MSB. - INC (HL) -WRITEP_2: LD H,(HL) - LD L,A - DEC HL ; Back to current byte. - LD A,(HL) - CALL SPIOUT - LD HL,(_wc) ; Decrement the max count. - DEC HL - LD (_wc),HL - LD HL,(_bc) ; Decrement the requested count. - DEC HL - LD (_bc),HL - JP WRITEP_4 - -WRITEP_5: LD HL,0 - LD (_res),HL - JP WRITEP_8 - -WRITEP_3: LD HL,2 ; Get the sector number into DEHL to test. - ADD HL,SP - LD E,(HL) - INC HL - LD D,(HL) - INC HL - LD A,(HL) - INC HL - LD H,(HL) - LD L,A - EX DE,HL - LD A,H - OR L - OR D - OR E - JP Z,WRITEP_9 ; Sector is 0 so finalise the write transaction. - - LD HL,(_SDCAP) ; Check to see if the card has block addressing. - LD H,0 - LD A,CT_BLOCK - AND L - JP NZ,WRITEP_10 ; If it hasnt then we need to multiply up to the correct byte. - - LD HL,2 + 2 ; Fetch the sector number, multiply (by left shift x 9) x512 and store. - CALL LBATOADDR - - ; A = ACMD to send - ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC -WRITEP_10: LD HL,2 ; Sector is stored as 3rd paramneter at offset 6, retrieve and arrange in little endian order in LHED - ADD HL,SP - LD D,(HL) - INC HL - LD E,(HL) - INC HL - PUSH DE - LD D,(HL) - INC HL - LD E,(HL) - LD A,CMD24 ; Send CMD24 to write a sector. - POP HL - EX DE,HL - CALL SDCMD - LD A,(_SDBUF+6) ; Fetch result and store. - LD (_d),A - AND A - JP NZ,WRITEP_8 - LD A,255 - CALL SPIOUT - LD A,254 - CALL SPIOUT - LD HL,512 - LD (_wc),HL - LD HL,0 - LD (_res),HL - JP WRITEP_8 - -WRITEP_9: LD HL,(_wc) - INC HL - INC HL - LD (_bc),HL -WRITEP_13: - LD HL,(_bc) - DEC HL - LD (_bc),HL - INC HL - LD A,H - OR L - JP Z,WRITEP_14 - LD A,0 - CALL SPIOUT - JP WRITEP_13 -WRITEP_14: - CALL SPIIN - AND $1F - LD L,A - LD H,0 - CP 5 - JP NZ,WRITEP_15 - - LD HL,10000 - PUSH HL - JR WRITEP_18 -WRITEP_20: DEC HL - PUSH HL - LD HL,200 - CALL T_DELAY -WRITEP_18: CALL SPIIN - POP HL - CP 255 - JP Z,WRITEP_17 - LD A,H - OR L - JR NZ,WRITEP_20 - -WRITEP_17: LD A,H - OR L - JP Z,WRITEP_15 - LD HL,0 - LD (_res),HL -WRITEP_15: LD A,$00 - CALL SPICS -WRITEP_8: LD HL,(_res) - -#endasm -} diff --git a/software/src/PetitFS/sdmmc.h b/software/src/PetitFS/sdmmc.h deleted file mode 100644 index fc74d9e..0000000 --- a/software/src/PetitFS/sdmmc.h +++ /dev/null @@ -1,69 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Name: sdmmc.c -// Created: March 2020 -// Author(s): ChaN (framework), Philip Smart (Sharp MZ80A/RFS customisation) -// Description: Low level disk interface module include file. -// Functionality to enable connectivity between the PetitFS ((C) ChaN) and the RFS -// subsystem of the Sharp MZ80A for SD drives. This module provides the public -// interfaces to interact with the hardware. -// -// Credits: -// Copyright: (C) 2013, ChaN, all rights reserved - framework. -// Copyright: (C) 2020 Philip Smart -// -// History: March 2020 - Initial development. -// -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// This source file is free software: you can redistribute it and#or modify -// it under the terms of the GNU General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This source file is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef _SDMMC_H -#define _SDMCC_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "pff.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Function succeeded */ - RES_ERROR, /* 1: Disk error */ - RES_NOTRDY, /* 2: Not ready */ - RES_PARERR /* 3: Invalid parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - -DSTATUS disk_initialize (void); -DRESULT disk_readp (BYTE* buff, DWORD sector, UINT offser, UINT count); -DRESULT disk_writep (const BYTE* buff, DWORD sc); - -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SDMMC_H */ diff --git a/software/src/PetitFS/sdtest b/software/src/PetitFS/sdtest deleted file mode 100644 index 71d44b2..0000000 Binary files a/software/src/PetitFS/sdtest and /dev/null differ diff --git a/software/src/PetitFS/sdtest.asm b/software/src/PetitFS/sdtest.asm deleted file mode 100644 index 9d8f539..0000000 --- a/software/src/PetitFS/sdtest.asm +++ /dev/null @@ -1,857 +0,0 @@ -;* * * * * Small-C/Plus z88dk * * * * * -; Version: 16120-f784809cf-20200301 -; -; Reconstructed for z80 Module Assembler -; -; Module compile time: Fri Mar 13 22:46:08 2020 - - - - MODULE sdtest_c - - - INCLUDE "z80_crt0.hdr" - - - SECTION code_compiler - -; Function die flags 0x00000200 __smallc -; void die(const int rc) -; parameter 'const int rc' at 2 size(2) -._die - ld hl,i_1+0 - push hl - ld hl,4 ;const - call l_gintsp ; - push hl - ld a,2 - call printf - pop bc - pop bc - ld hl,i_1+20 - push hl - ld a,1 - call printf - pop bc - ld hl,10 ;const - call sleep - ret - - - -; Function main flags 0x00000000 __stdc -; int main() -._main - ld hl,65381 ;const - add hl,sp - ld sp,hl - ld hl,i_1+41 - push hl - ld a,1 - call printf - pop bc - ld hl,i_1+86 - push hl - ld a,1 - call printf - pop bc - ld hl,3 ;const - add hl,sp - ld de,5 ;const - ex de,hl - call l_pint - call _disk_initialize - call l_lneg - jp nc,i_2 - ld hl,i_1+115 - push hl - ld a,1 - call printf - pop bc - ld hl,3 ;const - add hl,sp - push hl - ld hl,115 ;const - add hl,sp - push hl - call _pf_mount - pop bc - call l_pint_pop - ld hl,3 ;const - call l_gintsp ; - ld a,h - or l - jp z,i_3 - ld hl,i_1+137 - push hl - ld a,1 - call printf - pop bc - ld hl,3 ;const - call l_gintsp ; - push hl - call _die - pop bc -.i_3 - ld hl,i_1+192 - push hl - ld a,1 - call printf - pop bc -.i_2 - ld hl,i_1+209 - push hl - ld hl,115 ;const - add hl,sp - ld l,(hl) - ld h,0 - push hl - ld hl,118 ;const - add hl,sp - ld l,(hl) - ld h,0 - push hl - ld hl,121 ;const - add hl,sp - ld l,(hl) - ld h,0 - push hl - ld hl,124 ;const - add hl,sp - ld l,(hl) - ld h,0 - push hl - ld hl,129 ;const - add hl,sp - call l_glong2sp - ld hl,137 ;const - call l_glongsp ; - ld a,9 - call printf - ld hl,18 ;const - add hl,sp - ld sp,hl - ld hl,i_1+275 - push hl - ld hl,129 ;const - add hl,sp - call l_glong2sp - ld hl,137 ;const - add hl,sp - call l_glong2sp - ld hl,145 ;const - add hl,sp - call l_glong2sp - ld hl,153 ;const - add hl,sp - call l_glong2sp - ld hl,161 ;const - add hl,sp - call l_glong2sp - ld hl,169 ;const - add hl,sp - call l_glong2sp - ld hl,177 ;const - call l_glongsp ; - ld a,15 - call printf - ld hl,30 ;const - add hl,sp - ld sp,hl - ld hl,10 ;const - call sleep - ld hl,i_1+365 - push hl - ld a,1 - call printf - pop bc - ld hl,3 ;const - add hl,sp - push hl - ld hl,99 ;const - add hl,sp - push hl - ld hl,i_1+19 - push hl - call _pf_opendir - pop bc - pop bc - call l_pint_pop - ld hl,3 ;const - call l_gintsp ; - ld a,h - or l - jp z,i_4 - ld hl,3 ;const - call l_gintsp ; - push hl - call _die - pop bc -.i_4 - ld hl,i_1+388 - push hl - ld a,1 - call printf - pop bc -.i_5 -.i_7 - ld hl,3 ;const - add hl,sp - push hl - ld hl,99 ;const - add hl,sp - push hl - ld hl,79 ;const - add hl,sp - push hl - call _pf_readdir - pop bc - pop bc - call l_pint_pop - ld hl,3 ;const - call l_gintsp ; - ld a,h - or l - jp nz,i_9 - ld hl,75 ;const - call l_gcharsp ; - call l_lneg - jr nc,i_8 -.i_9 - jp i_6 -.i_8 - ld hl,83 ;const - add hl,sp - ld a,+(16 % 256) - and (hl) - jp z,i_11 - ld hl,i_1+411 - push hl - ld hl,86 ;const - add hl,sp - push hl - ld a,2 - call printf - pop bc - pop bc - jp i_12 -.i_11 - ld hl,i_1+425 - push hl - ld hl,77 ;const - add hl,sp - call l_glong2sp - ld hl,90 ;const - add hl,sp - push hl - ld a,4 - call printf - pop bc - pop bc - pop bc - pop bc -.i_12 - jp i_5 -.i_6 - ld hl,3 ;const - call l_gintsp ; - ld a,h - or l - jp z,i_13 - ld hl,3 ;const - call l_gintsp ; - push hl - call _die - pop bc -.i_13 - ld hl,i_1+435 - push hl - ld a,1 - call printf - pop bc - ld hl,3 ;const - add hl,sp - push hl - ld hl,i_1+469 - push hl - call _pf_open - pop bc - call l_pint_pop - ld hl,3 ;const - call l_gintsp ; - ld a,h - or l - jp z,i_14 - ld hl,3 ;const - call l_gintsp ; - push hl - call _die - pop bc -.i_14 - ld hl,i_1+481 - push hl - ld a,1 - call printf - pop bc -.i_15 - ld hl,3 ;const - add hl,sp - push hl - ld hl,7 ;const - add hl,sp - push hl - ld hl,64 ;const - push hl - ld hl,77 ;const - add hl,sp - push hl - call _pf_read - pop bc - pop bc - pop bc - call l_pint_pop - ld hl,3 ;const - call l_gintsp ; - ld a,h - or l - jp nz,i_18 - ld hl,71 ;const - call l_gintsp ; - call l_lneg - jr nc,i_17 -.i_18 - jp i_16 -.i_17 - ld hl,69 ;const - add hl,sp - ld de,0 ;const - ex de,hl - call l_pint - jp i_22 -.i_20 - ld hl,69 ;const - add hl,sp - inc (hl) - ld a,(hl) - inc hl - jr nz,ASMPC+3 - inc (hl) -.i_22 - ld hl,69 ;const - call l_gintspsp ; - ld hl,73 ;const - call l_gintsp ; - pop de - ex de,hl - and a - sbc hl,de - jp nc,i_21 - ld hl,5 ;const - add hl,sp - ex de,hl - ld hl,69 ;const - call l_gintsp ; - add hl,de - ld a,(hl) - cp 13 - jp z,i_23 - ld hl,5 ;const - add hl,sp - ex de,hl - ld hl,69 ;const - call l_gintsp ; - add hl,de - ld l,(hl) - ld h,0 - push hl - ld hl,__sgoioblk+10 - push hl - call fputc_callee -.i_23 - jp i_20 -.i_21 - jp i_15 -.i_16 - ld hl,3 ;const - call l_gintsp ; - ld a,h - or l - jp z,i_24 - ld hl,3 ;const - call l_gintsp ; - push hl - call _die - pop bc -.i_24 - ld hl,20 ;const - call sleep - ld hl,i_1+506 - push hl - ld a,1 - call printf - pop bc - ld hl,3 ;const - add hl,sp - push hl - ld hl,i_1+543 - push hl - call _pf_open - pop bc - call l_pint_pop - ld hl,3 ;const - call l_gintsp ; - ld a,h - or l - jp z,i_25 - ld hl,3 ;const - call l_gintsp ; - push hl - call _die - pop bc -.i_25 - ld hl,i_1+554 - push hl - ld a,1 - call printf - pop bc -.i_26 -.i_28 - ld hl,3 ;const - add hl,sp - push hl - ld hl,i_1+590 - push hl - ld hl,14 ;const - push hl - ld hl,79 ;const - add hl,sp - push hl - call _pf_write - pop bc - pop bc - pop bc - call l_pint_pop - ld hl,3 ;const - call l_gintsp ; - ld a,h - or l - jp nz,i_30 - ld hl,73 ;const - call l_gintsp ; - call l_lneg - jr nc,i_29 -.i_30 - jp i_27 -.i_29 - jp i_26 -.i_27 - ld hl,3 ;const - call l_gintsp ; - ld a,h - or l - jp z,i_32 - ld hl,3 ;const - call l_gintsp ; - push hl - call _die - pop bc -.i_32 - ld hl,i_1+605 - push hl - ld a,1 - call printf - pop bc - ld hl,3 ;const - add hl,sp - push hl - ld hl,0 ;const - push hl - push hl - ld hl,79 ;const - add hl,sp - push hl - call _pf_write - pop bc - pop bc - pop bc - call l_pint_pop - ld hl,3 ;const - call l_gintsp ; - ld a,h - or l - jp z,i_33 - ld hl,3 ;const - call l_gintsp ; - push hl - call _die - pop bc -.i_33 - ld hl,i_1+641 - push hl - ld a,1 - call printf - pop bc -.i_34 -.i_36 - jp i_34 -.i_35 - ld hl,155 ;const - add hl,sp - ld sp,hl - ret - - - SECTION rodata_compiler -.i_1 - defm "Failed with rc=%u." - defb 10 - - defm "" - defb 0 - - defm "Please press reset." - defb 10 - - defm "" - defb 0 - - defm "Hello Philip, this C program i" - defm "s working...." - defb 10 - - defm "" - defb 0 - - defm "Firstly, initialise SD card" - defb 10 - - defm "" - defb 0 - - defm "" - defb 10 - - defm "Now Mount a volume." - defb 10 - - defm "" - defb 0 - - defm "Failed to initialise sd card 0" - defm ", please init manually." - defb 10 - - defm "" - defb 0 - - defm "Volume mounted." - defb 10 - - defm "" - defb 0 - - defm "FSTYPE:%d, FLAG:%d, CSIZE:%d, " - defm "PADL:%d, N_FATENT:%ld, FATBASE" - defm ":%;d" - defb 10 - - defm "" - defb 0 - - defm "DIRBASE:%ld, DATABASE:%ld, FPT" - defm "R:%ld, FSIZE:%ld, ORG_CLUST:%l" - defm "d, CURR_CLUST:%ld, DSECT:%ld" - defb 10 - - defm "" - defb 0 - - defm "" - defb 10 - - defm "Open root directory." - defb 10 - - defm "" - defb 0 - - defm "" - defb 10 - - defm "Directory listing..." - defb 10 - - defm "" - defb 0 - - defm " %s" - defb 10 - - defm "" - defb 0 - - defm "%8lu %s" - defb 10 - - defm "" - defb 0 - - defm "" - defb 10 - - defm "Open a test file (message.txt)" - defm "." - defb 10 - - defm "" - defb 0 - - defm "MESSAGE.TXT" - defb 0 - - defm "" - defb 10 - - defm "Type the file content." - defb 10 - - defm "" - defb 0 - - defm "" - defb 10 - - defm "Open a file to write (readme.t" - defm "xt)." - defb 10 - - defm "" - defb 0 - - defm "README.TXT" - defb 0 - - defm "" - defb 10 - - defm "Write a text data. (Hello worl" - defm "d!)" - defb 10 - - defm "" - defb 0 - - defm "Hello world!" - defb 13 - - defm "" - defb 10 - - defm "" - defb 0 - - defm "" - defb 10 - - defm "Terminate the file write proce" - defm "ss." - defb 10 - - defm "" - defb 0 - - defm "" - defb 10 - - defm "Test completed." - defb 10 - - defm "" - defb 0 - - -; --- Start of Static Variables --- - - SECTION bss_compiler -._FatFs defs 2 - SECTION code_compiler - - -; --- Start of Scope Defns --- - - GLOBAL open - GLOBAL creat - GLOBAL close - GLOBAL read - GLOBAL write - GLOBAL lseek - GLOBAL readbyte - GLOBAL writebyte - GLOBAL getcwd - GLOBAL chdir - GLOBAL getwd - GLOBAL rmdir - GLOBAL _RND_BLOCKSIZE - GLOBAL rnd_loadblock - GLOBAL rnd_saveblock - GLOBAL rnd_erase - GLOBAL __FOPEN_MAX - GLOBAL __sgoioblk - GLOBAL __sgoioblk_end - GLOBAL fopen_zsock - GLOBAL fopen - GLOBAL freopen - GLOBAL fdopen - GLOBAL _freopen1 - GLOBAL fmemopen - GLOBAL funopen - GLOBAL fclose - GLOBAL fflush - GLOBAL closeall - GLOBAL fgets - GLOBAL fputs - GLOBAL fputc - GLOBAL fputs_callee - GLOBAL fputc_callee - GLOBAL fgetc - GLOBAL ungetc - GLOBAL feof - GLOBAL ferror - GLOBAL puts - GLOBAL ftell - GLOBAL fgetpos - GLOBAL fseek - GLOBAL fread - GLOBAL fwrite - GLOBAL gets - GLOBAL printf - GLOBAL fprintf - GLOBAL sprintf - GLOBAL snprintf - GLOBAL vfprintf - GLOBAL vsnprintf - GLOBAL printn - GLOBAL scanf - GLOBAL fscanf - GLOBAL sscanf - GLOBAL vfscanf - GLOBAL vsscanf - GLOBAL getarg - GLOBAL fchkstd - GLOBAL fgetc_cons - GLOBAL fgetc_cons_inkey - GLOBAL fputc_cons - GLOBAL fgets_cons - GLOBAL puts_cons - GLOBAL fabandon - GLOBAL fdtell - GLOBAL fdgetpos - GLOBAL rename - GLOBAL remove - GLOBAL getk - GLOBAL getk_inkey - GLOBAL printk - GLOBAL perror - GLOBAL atoi - GLOBAL atol - GLOBAL itoa - GLOBAL itoa_callee - GLOBAL ltoa - GLOBAL ltoa_callee - GLOBAL strtol - GLOBAL strtol_callee - GLOBAL strtoul - GLOBAL strtoul_callee - GLOBAL ultoa - GLOBAL ultoa_callee - GLOBAL utoa - GLOBAL utoa_callee - GLOBAL rand - GLOBAL srand - GLOBAL mallinit - GLOBAL sbrk - GLOBAL sbrk_callee - GLOBAL calloc - GLOBAL calloc_callee - GLOBAL free - GLOBAL malloc - GLOBAL realloc - GLOBAL realloc_callee - GLOBAL mallinfo - GLOBAL mallinfo_callee - GLOBAL HeapCreate - GLOBAL HeapSbrk - GLOBAL HeapSbrk_callee - GLOBAL HeapCalloc - GLOBAL HeapCalloc_callee - GLOBAL HeapFree - GLOBAL HeapFree_callee - GLOBAL HeapAlloc - GLOBAL HeapAlloc_callee - GLOBAL HeapRealloc - GLOBAL HeapRealloc_callee - GLOBAL HeapInfo - GLOBAL HeapInfo_callee - GLOBAL exit - GLOBAL atexit - GLOBAL getopt - GLOBAL _optarg - GLOBAL _opterr - GLOBAL _optind - GLOBAL _optopt - GLOBAL _optreset - GLOBAL l_bsearch - GLOBAL l_bsearch_callee - GLOBAL l_qsort - GLOBAL l_qsort_callee - GLOBAL qsort_sccz80 - GLOBAL qsort_sccz80_callee - GLOBAL qsort_sdcc - GLOBAL qsort_sdcc_callee - GLOBAL _div_ - GLOBAL _div__callee - GLOBAL _divu_ - GLOBAL _divu__callee - GLOBAL _ldiv_ - GLOBAL _ldiv__callee - GLOBAL _ldivu_ - GLOBAL _ldivu__callee - GLOBAL abs - GLOBAL labs - GLOBAL isqrt - GLOBAL inp - GLOBAL outp - GLOBAL outp_callee - GLOBAL swapendian - GLOBAL bpoke - GLOBAL bpoke_callee - GLOBAL wpoke - GLOBAL wpoke_callee - GLOBAL bpeek - GLOBAL wpeek - GLOBAL t_delay - GLOBAL sleep - GLOBAL msleep - GLOBAL extract_bits - GLOBAL extract_bits_callee - GLOBAL wcmatch - GLOBAL unbcd - GLOBAL _pf_mount - GLOBAL _pf_open - GLOBAL _pf_read - GLOBAL _pf_write - GLOBAL _pf_lseek - GLOBAL _pf_opendir - GLOBAL _pf_readdir - GLOBAL _FatFs - GLOBAL _disk_initialize - GLOBAL _disk_readp - GLOBAL _disk_writep - GLOBAL _die - GLOBAL _main - - -; --- End of Scope Defns --- - - -; --- End of Compilation --- diff --git a/software/src/PetitFS/sdtest.c b/software/src/PetitFS/sdtest.c deleted file mode 100644 index dc3e8c2..0000000 --- a/software/src/PetitFS/sdtest.c +++ /dev/null @@ -1,122 +0,0 @@ -/*----------------------------------------------------------------------*/ -/* Petit FatFs sample project for generic uC (C)ChaN, 2010 */ -/*----------------------------------------------------------------------*/ - -#include -#include -#include "pff.h" -#include "sdmmc.h" - -FATFS *FatFs; /* Pointer to the file system object (logical drive) */ -extern BYTE SDBUF[]; - -void die ( /* Stop with dying message */ - FRESULT rc /* FatFs return value */ -) -{ - printf("Failed with rc=%u.\n", rc); - printf("Please press reset.\n"); - sleep(10); - for (;;) ; -} - -/*-----------------------------------------------------------------------*/ -/* Program Main */ -/*-----------------------------------------------------------------------*/ - -int main (void) -{ - FATFS fatfs; /* File system object */ - DIR dir; /* Directory object */ - FILINFO fno; /* File information object */ - UINT bw, br, i; - BYTE buff[64]; - FRESULT rc; /* FatFs return value */ - unsigned char idx; - unsigned char b; - unsigned char ib; - - printf("Petit FatFS Test Program, Sharp MZ80A\n"); - - printf("Firstly, initialise SD card\n"); - rc = FR_NOT_ENABLED; - DSTATUS res = disk_initialize(); - if(!res) - { - printf("\nNow Mount a volume.\n"); - rc = pf_mount(&fatfs); - if (rc) - { - printf("Failed to initialise sd card 0, please init manually.\n"); - die(rc); - } else - { - printf("Volume mounted.\n"); - } - } else - { - printf("Failed disk initialise, RES=%02x.\n", res); - die(res); - } - BYTE *p = SDBUF; - for(i = 0; i < 11; i++) - printf("%02x", *p++); - printf("\n"); - printf("SDVER:%02x, SDCAP:%02x\n", SDVER, SDCAP); - sleep(1); - - printf("FSTYPE:%d, FLAG:%d, CSIZE:%d, PADL:%d, N_FATENT:%ld, FATBASE:%;d\n", fatfs.fs_type, fatfs.flag, fatfs.csize, fatfs.pad1, fatfs.n_fatent, fatfs.fatbase); - printf("DIRBASE:%ld, DATABASE:%ld, FPTR:%ld, FSIZE:%ld, ORG_CLUST:%ld, CURR_CLUST:%ld, DSECT:%ld\n", fatfs.dirbase, fatfs.database,fatfs.fptr, fatfs.fsize, fatfs.org_clust, fatfs.curr_clust, fatfs.dsect); - sleep(1); - - printf("\nOpen root directory.\n"); - rc = pf_opendir(&dir, ""); - if (rc) die(rc); - - printf("\nDirectory listing...\n"); - for (;;) { - rc = pf_readdir(&dir, &fno); /* Read a directory item */ - if (rc || !fno.fname[0]) break; /* Error or end of dir */ - if (fno.fattrib & AM_DIR) - printf(" %s\n", fno.fname); - else - printf("%8lu %s\n", fno.fsize, fno.fname); - } - if (rc && rc != FR_NO_FILE) die(rc); - - printf("\nOpen file to read (message.txt).\n"); - rc = pf_open("MESSAGE.TXT"); - if (rc) die(rc); - - printf("\nOutput contents.\n"); - while(1) - { - rc = pf_read(buff, sizeof(buff), &br); /* Read a chunk of file */ - if (rc || !br) break; /* Error or end of file */ - for (i = 0; i < br; i++) /* Type the data */ - if(buff[i] != 0x0d) - putchar(buff[i]); - } - if (rc) die(rc); - - sleep(5); - - printf("\nOpen file to write (readme.txt).\n"); - rc = pf_open("README.TXT"); - if (rc) die(rc); - - printf("\nWrite some repetitive text. (Hello world!)\n"); - for (;;) { - rc = pf_write("Hello world!\r\n", 14, &bw); - if (rc || !bw) break; - } - if (rc) die(rc); - - printf("\nClose the file.\n"); - rc = pf_write(0, 0, &bw); - if (rc) die(rc); - - - printf("\nTest completed.\n"); - for (;;) ; -} diff --git a/software/src/PetitFS/sdtest.cmp b/software/src/PetitFS/sdtest.cmp deleted file mode 100644 index 3e99d39..0000000 Binary files a/software/src/PetitFS/sdtest.cmp and /dev/null differ diff --git a/software/src/PetitFS/sdtest.mzt b/software/src/PetitFS/sdtest.mzt deleted file mode 100644 index 0045847..0000000 Binary files a/software/src/PetitFS/sdtest.mzt and /dev/null differ diff --git a/software/src/PetitFS/test.asm b/software/src/PetitFS/test.asm deleted file mode 100644 index 5e0cebb..0000000 --- a/software/src/PetitFS/test.asm +++ /dev/null @@ -1,66 +0,0 @@ -;-------------------------------------------------------- -; File Created by SDCC : free open source ANSI-C Compiler -; Version 4.0.0 #11528 (Linux) -;-------------------------------------------------------- - .module test - .optsdcc -mz80 - -;-------------------------------------------------------- -; Public variables in this module -;-------------------------------------------------------- - .globl _main -;-------------------------------------------------------- -; special function registers -;-------------------------------------------------------- -;-------------------------------------------------------- -; ram data -;-------------------------------------------------------- - .area _DATA -;-------------------------------------------------------- -; ram data -;-------------------------------------------------------- - .area _INITIALIZED -;-------------------------------------------------------- -; absolute external ram data -;-------------------------------------------------------- - .area _DABS (ABS) -;-------------------------------------------------------- -; global & static initialisations -;-------------------------------------------------------- - .area _HOME - .area _GSINIT - .area _GSFINAL - .area _GSINIT -;-------------------------------------------------------- -; Home -;-------------------------------------------------------- - .area _HOME - .area _HOME -;-------------------------------------------------------- -; code -;-------------------------------------------------------- - .area _CODE -;test.c:3: int main() -; --------------------------------- -; Function main -; --------------------------------- -_main:: -;test.c:7: for ( a = 0; a < 10; a++ ) - ld bc, #0x000a -00104$: - ld e, c - ld d, b - dec de - ld c, e - ld b, d - ld a, d - or a, e - jp NZ, 00104$ -;test.c:11: return 0; - ld hl, #0x0000 -00105$: -;test.c:12: } - ret - .area _CODE - .area _INITIALIZER - .area _CABS (ABS) diff --git a/software/src/PetitFS/test.c b/software/src/PetitFS/test.c deleted file mode 100644 index 965e8eb..0000000 --- a/software/src/PetitFS/test.c +++ /dev/null @@ -1,12 +0,0 @@ -#include - -int main() -{ - int a; - - for ( a = 0; a < 10; a++ ) - { - } - - return 0; -} diff --git a/software/src/PetitFS/zcc_opt.def b/software/src/PetitFS/zcc_opt.def deleted file mode 100644 index d6e6b54..0000000 --- a/software/src/PetitFS/zcc_opt.def +++ /dev/null @@ -1,8 +0,0 @@ - -IF !DEFINED_REGISTER_SP - defc DEFINED_REGISTER_SP = 1 - defc REGISTER_SP = 53248 - IFNDEF REGISTER_SP - ENDIF -ENDIF - diff --git a/software/src/tools/Makefile b/software/src/tools/Makefile deleted file mode 100644 index d17f503..0000000 --- a/software/src/tools/Makefile +++ /dev/null @@ -1,147 +0,0 @@ -######################################################################################################### -## -## Name: Makefile -## Created: March 2020 -## Author(s): Philip Smart -## Description: Helper tools for the MZ80A RFS upgrade -## This makefile builds tools written in C which help with building/setting up the -## RFS images for use in the RFS adapter. -## -## Credits: -## Copyright: (c) 2020 Philip Smart -## -## History: March 2020 - Initial Makefile creation -## -## Notes: -## -######################################################################################################### -## This source file is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This source file is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -######################################################################################################### -BASE = -CC = $(BASE)gcc -LD = $(BASE)gcc -AS = $(BASE)as -CP = $(BASE)objcopy -DUMP = $(BASE)objdump - -BASEDIR = ../../.. -SWDIR = $(BASEDIR)/software/src -INSTALLDIR = $(BASEDIR)/software/tools - -# we use printf from here -COMMON_DIR = $(SWDIR)/common -INCLUDE_DIR = $(SWDIR)/include - -# Working directory to build object files. -BUILD_DIR = tools_obj - -COMMON_SRC = #$(COMMON_DIR)/sdtool.c -COMMON_OBJ = $(patsubst $(COMMON_DIR)/%.c,$(BUILD_DIR)/%.o,$(COMMON_SRC)) - -SDTOOL_PRJ = sdtool -SDTOOL_SRC = sdtool.c -SDTOOL_OBJ = $(COMMON_OBJ) $(patsubst %.c,$(BUILD_DIR)/%.o,$(SDTOOL_SRC)) - -MZFDC2_PRJ = mzfdc2 -MZFDC2_SRC = mz-fdc2.c -MZFDC2_OBJ = $(COMMON_OBJ) $(patsubst %.c,$(BUILD_DIR)/%.o,$(MZFDC2_SRC)) - -MZFDC3_PRJ = mzfdc3 -MZFDC3_SRC = mz-fdc3.c -MZFDC3_OBJ = $(COMMON_OBJ) $(patsubst %.c,$(BUILD_DIR)/%.o,$(MZFDC3_SRC)) - -# Commandline options for each tool. -OPTS = - -CFLAGS = -I. -I$(COMMON_DIR) -I$(INCLUDE_DIR) -O3 -# Enable debug output. -OFLAGS += -DDEBUG -LFLAGS = -Wl,--gc-sections -Wl,--relax -Os -# -# Assembler flags. -ASFLAGS = -I. -I$(COMMON_DIR) -I$(INCLUDE_DIR) -I$(STARTUP_DIR) -# - -# Our target. -all: clean $(BUILD_DIR) $(SDTOOL_PRJ) $(MZFDC2_PRJ) $(MZFDC3_PRJ) - -install: all - cp $(SDTOOL_PRJ) $(MZFDC2_PRJ) $(INSTALLDIR) - -clean: - rm -f $(BUILD_DIR)/*.o *.hex *.lss *.elf *.map *.lst *.srec *~ */*.o *.bin *.srec *.dmp *.vhd *.rpt $(SDTOOL_PRJ) - -$(SDTOOL_PRJ): $(SDTOOL_PRJ).elf $(SDTOOL_PRJ).dmp $(SDTOOL_PRJ).lss - -$(MZFDC2_PRJ): $(MZFDC2_PRJ).elf $(MZFDC2_PRJ).dmp $(MZFDC2_PRJ).lss - -$(MZFDC3_PRJ): $(MZFDC3_PRJ).elf $(MZFDC3_PRJ).dmp $(MZFDC3_PRJ).lss - -# Convert ELF binary to bin file. -%.bin: %.elf - @$(CP) -O binary $< $@ - -# Convert ELF to srec format for serial upload. -%.srec: %.elf - @$(CP) -O srec $< $@ - -%.dmp: %.elf - @$(DUMP) -x $< >>$@ - -# Create extended listing file from ELF output file. -# testing: option -C -%.lss: %.elf - @echo - @$(DUMP) -h -S -C $< > $@ - -$(SDTOOL_PRJ): $(SDTOOL_OBJ) - $(CC) $(LFLAGS) $(SDTOOL_OBJ) -o $@ $(LIBS) - chmod +x $@ - -$(MZFDC2_PRJ): $(MZFDC2L_OBJ) - $(CC) $(LFLAGS) $(MZFDC2_OBJ) -o $@ $(LIBS) - chmod +x $@ - -$(MZFDC3_PRJ): $(MZFDC3L_OBJ) - $(CC) $(LFLAGS) $(MZFDC3_OBJ) -o $@ $(LIBS) - chmod +x $@ - -# Link - this produces an ELF binary. -$(SDTOOL_PRJ).elf: $(SDTOOL_OBJ) - $(LD) $(LFLAGS) -o $@ $+ $(LIBS) - -$(MZFDC2_PRJ).elf: $(MZFDC2_OBJ) - $(LD) $(LFLAGS) -o $@ $+ $(LIBS) - -$(MZFDC3_PRJ).elf: $(MZFDC3_OBJ) - $(LD) $(LFLAGS) -o $@ $+ $(LIBS) - -$(BUILD_DIR)/%.o: %.c Makefile - $(CC) $(CFLAGS) $(OFLAGS) -o $@ -c $< - -$(BUILD_DIR)/%.o: %.cpp Makefile - $(CC) $(CFLAGS) $(OFLAGS) -o $@ -c $< - -$(BUILD_DIR)/%.o: $(COMMON_DIR)/%.c Makefile - $(CC) $(CFLAGS) $(OFLAGS) -o $@ -c $< - -$(BUILD_DIR)/%.o: %.s - $(AS) $(ASFLAGS) -o $@ $< - -$(BUILD_DIR)/%.o: $(STARTUP_DIR)/%.s - $(AS) $(ASFLAGS) -o $@ $< - -$(BUILD_DIR): - mkdir $(BUILD_DIR) - diff --git a/software/src/tools/mz-fdc.c b/software/src/tools/mz-fdc.c deleted file mode 100644 index 26c36f0..0000000 --- a/software/src/tools/mz-fdc.c +++ /dev/null @@ -1,412 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Name: mz-fdc.c -// Created: January 2019 -// Author(s): Philip Smart -// Description: MZ-80A FDC file image manipulator. -// This program manipulates stored floppy images from the format used on physical disks -// to/from an ordered linear image. -// -// Credits: -// Copyright: (c) 2020 Philip Smart -// -// History: January 2020 - Initial script written. -// -// Notes: -// -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// This source file is free software: you can redistribute it and#or modify -// it under the terms of the GNU General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This source file is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include - -// MZ-80A/B Floppy disk description. -#define MAX_FDC_TRACKS 100 -#define MAX_FDC_SECTORS 20 -#define MAX_FDC_SECTORSIZE 256 -#define MAX_FDC_SIDES 2 - -typedef struct { - char name[34]; - char creator[14]; - uint8_t tracks; - uint8_t sides; - uint8_t unused[2]; - uint8_t track_table[MAX_FDC_TRACKS * MAX_FDC_SIDES ]; -} t_diskinfoblock; - -typedef struct { - uint8_t track; - uint8_t side; - uint8_t sectorid; - uint8_t sectorsize; - uint8_t fdcstatus1; - uint8_t fdcstatus2; - uint8_t datalen[2]; -} t_sectorinfolist; - -typedef struct { - char id[13]; - uint8_t unused[3]; - uint8_t track; - uint8_t side; - uint8_t unused2[2]; - uint8_t sectorsize; - uint8_t numsectors; - uint8_t gap3len; - uint8_t filler; - t_sectorinfolist sectorinfolist[MAX_FDC_SECTORS]; -} t_trackinfoblock; - -// Store the track data in preallocated memory, no point using dynamic memory as the floppy is so small. -typedef struct { - char track[MAX_FDC_SECTORS * MAX_FDC_SECTORSIZE]; -} t_track; -static t_track tracks[MAX_FDC_TRACKS]; -typedef struct { - char block[ MAX_FDC_SECTORSIZE ]; -} t_block; -typedef struct { - char block1[ 128 ]; - char block2[ 128 ]; -} t_infoblock; -static t_block blocks[MAX_FDC_TRACKS * MAX_FDC_SIDES * MAX_FDC_SECTORS ]; -t_diskinfoblock *diskInfoBlock; -t_sectorinfolist *sectorInfoList; -t_trackinfoblock *trackInfoBlock; -t_infoblock infoBlock; - -char *sectors[MAX_FDC_TRACKS][MAX_FDC_SIDES][MAX_FDC_SECTORS]; - -int main(int argc, char *argv[]) -{ - - int opt; - int option_index = 0; - int mode_flag = -1; - int idx; - int idx2; - int secidx; - int sideidx; - int trkidx; - int numTracks; - int numSides; - int numSectors; - int maxBlocks; - int trackNo; - int sectorNo; - int sideNo; - int sectorSize; - int FDC_TRACKS; - int FDC_SECTORS; - int FDC_SECTORSIZE; - int FDC_INVERT = 0; - int trackSize; - char inputFile[1024]; - char outputFile[1024]; - long fileSize; - FILE *inFile; - FILE *outFile; - - static struct option long_options[] = - { - {"from-linear", no_argument, 0, 'f'}, - {"to-linear", no_argument, 0, 't'}, - {"input", required_argument, 0, 'i'}, - {"output", required_argument, 0, 'o'}, - {0, 0, 0, 0} - }; - - // Initialise variables to defaults. - inputFile[0] = 0x00; - outputFile[0] = 0x00; - - // Parse the command line options. - // - while((opt = getopt_long(argc, argv, ":tfi:o:", long_options, &option_index)) != -1) - { - switch(opt) - { - case 'f': - mode_flag = 0; - printf("Mode flag set to 0\n"); - break; - - case 't': - mode_flag = 1; - printf("Mode flag set to 1\n"); - break; - - case 'i': - strcpy(inputFile, optarg); - printf("Input file set to:%s\n", inputFile); - break; - - case 'o': - strcpy(outputFile, optarg); - printf("Output file set to:%s\n", outputFile); - break; - - case ':': - printf("Option %s needs a value\n", argv[optind-1]); - break; - case '?': - printf("Unknown option: %s, ignoring!\n", argv[optind-1]); - break; - } - } - - if(strlen(inputFile) == 0 ) - { - printf("Input file not specified.\n"); - exit(10); - } - if(strlen(outputFile) == 0 ) - { - printf("Output file not specified.\n"); - exit(11); - } - if(mode_flag == -1) - { - printf("Mode not set, should be --to-linear or --from-linear.\n"); - exit(12); - } - inFile = fopen(inputFile, "r"); - outFile = fopen(outputFile, "w"); - if(inFile == NULL) - { - printf("Couldnt open the input file:%s.\n", inputFile); - exit(20); - } - if(outFile == NULL) - { - printf("Couldnt open the output file:%s.\n", outputFile); - exit(21); - } - fseek(inFile, 0, SEEK_END); - fileSize = ftell(inFile); - fseek(inFile, 0, SEEK_SET); - switch(fileSize) - { - case 358144: - FDC_TRACKS = 82; - FDC_SECTORS = 17; - FDC_SECTORSIZE = 256; - FDC_INVERT = 2; - break; - - case 357632: - FDC_TRACKS = 82; - FDC_SECTORS = 17; - FDC_SECTORSIZE = 256; - FDC_INVERT = 2; - break; - - case 304640: - FDC_TRACKS = 70; - FDC_SECTORS = 17; - FDC_SECTORSIZE = 256; - FDC_INVERT = 2; - break; - - case 286720: - FDC_TRACKS = 70; - FDC_SECTORS = 16; - FDC_SECTORSIZE = 256; - FDC_INVERT = 2; - break; - - case 327680: - FDC_TRACKS = 80; - FDC_SECTORS = 16; - FDC_SECTORSIZE = 256; - FDC_INVERT = 1; - break; - - case 348416: - FDC_TRACKS = 80; - FDC_SECTORS = 17; - FDC_SECTORSIZE = 256; - FDC_INVERT = 1; - break; - - case 184576: - FDC_TRACKS = 80; - FDC_SECTORS = 16; - FDC_SECTORSIZE = 128; - FDC_INVERT = 0; - break; - - default: - printf("Unrecognised file size:%d\n", fileSize); - exit(22); - } - trackSize = FDC_SECTORS * FDC_SECTORSIZE; - -// FDC_TRACKS = fileSize / (FDC_SECTORSIZE * -// if(fileSize < (FDC_TRACKS * FDC_SECTORS * FDC_SECTORSIZE)) -// { -// printf("Input file is too small, configuration is:\n Tracks = %d, Sectors = %d, Sector Size = %d, Total Floppy Size = %ld\n", FDC_TRACKS, FDC_SECTORS, FDC_SECTORSIZE, (FDC_TRACKS * FDC_SECTORS * FDC_SECTORSIZE)); -// exit(22); -// } -// if(fileSize > (FDC_TRACKS * FDC_SECTORS * FDC_SECTORSIZE)) -// { -// printf("Input file is too large, configuration is:\n Tracks = %d, Sectors = %d, Sector Size = %d, Total Floppy Size = %ld\n", FDC_TRACKS, FDC_SECTORS, FDC_SECTORSIZE, (FDC_TRACKS * FDC_SECTORS * FDC_SECTORSIZE)); -// exit(23); -// } -// - idx = 0; - while(!feof(inFile)) - { - fread(blocks[idx].block, 1, FDC_SECTORSIZE, inFile); - idx++; - } - maxBlocks = idx; - printf("Read in %d blocks\n", maxBlocks); - - // Verify disk information block. - // - diskInfoBlock = (t_diskinfoblock *)&blocks[0].block; - if(strncmp(diskInfoBlock->name, "EXTENDED CPC DSK File\r\nDisk-Info\r\n", 34) == 0) - { - memcpy((char *)&infoBlock.block1, blocks[0].block, sizeof(blocks[0].block)); - memcpy((char *)&infoBlock.block2, blocks[1].block, sizeof(blocks[1].block)); - diskInfoBlock = (t_diskinfoblock *)&infoBlock; - - printf("Image is in Extended CPC DiSK Format\n"); - printf("Name of creator:%s\n", diskInfoBlock->creator); - numTracks = (int)diskInfoBlock->tracks; - numSides = (int)diskInfoBlock->sides; - printf("Number of tracks:%d\n", numTracks); - printf("Number of sides:%d\n", numSides); - } else - { - printf("Image header is not correct, name=%s\n", diskInfoBlock->name); - exit(30); - } - - idx = 2; - while(idx < maxBlocks) - { - trackInfoBlock = (t_trackinfoblock *)&blocks[idx].block; - if(strncmp(trackInfoBlock->id, "Track-Info\r\n", 13) == 0) - { - memcpy((char *)&infoBlock.block1, blocks[idx].block, 128); //sizeof(blocks[idx].block)); - memcpy((char *)&infoBlock.block2, blocks[idx+1].block, 128); //sizeof(blocks[idx+1].block)); - trackInfoBlock = (t_trackinfoblock *)&infoBlock; - idx+=2; - - printf("Block %d is a track information block.\n", idx); - trackNo = (int)trackInfoBlock->track; - sideNo = (int)trackInfoBlock->side; - sectorSize = (int)trackInfoBlock->sectorsize; - numSectors = (int)trackInfoBlock->numsectors; - switch(sectorSize) - { - case 1: - sectorSize = 128; - break; - - case 2: - sectorSize = 256; - //numSectors *= 2; - break; - - default: - break; - } - - printf("Track Number: %d\n", trackNo); - printf("Side Number: %d\n", sideNo); - printf("Sector Size: %d\n", sectorSize); - printf("# Sectors: %d\n", numSectors); - - for(secidx=0; secidx < numSectors; secidx++) - { - sectorInfoList = (t_sectorinfolist *)&trackInfoBlock->sectorinfolist[secidx]; - printf("--> Sector ID: %d\n", (int)sectorInfoList->sectorid); - sectors[trackNo][sideNo][(int)sectorInfoList->sectorid - 1] = (char *)&blocks[idx].block; - printf("%08lx, %08lx\n", §ors[trackNo][sideNo][((int)sectorInfoList->sectorid - 1)], blocks[idx].block ); - idx++; - if(sectorSize == 256) - { - secidx++; - sectorInfoList = (t_sectorinfolist *)&trackInfoBlock->sectorinfolist[secidx]; - printf("--> Sector ID: %d\n", (int)sectorInfoList->sectorid); - sectors[trackNo][sideNo][(int)sectorInfoList->sectorid - 1] = (char *)&blocks[idx].block; - printf("%08lx, %08lx\n", §ors[trackNo][sideNo][((int)sectorInfoList->sectorid - 1)], blocks[idx].block ); - idx++; - } - //idx++; - //fwrite(blocks[idx].block, 1, sectorSize, outFile); - } - } else - { - idx++; - } - } - - for(idx=0; idx < numTracks; idx++) - { - for(sideidx=0; sideidx -// -// History: January 2020 - Initial script written. -// -// Notes: -// -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// This source file is free software: you can redistribute it and#or modify -// it under the terms of the GNU General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This source file is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include - -// MZ-80A/B Floppy disk description. -#define MAX_FDC_TRACKS 100 -#define MAX_FDC_SECTORS 20 -#define MAX_FDC_SECTORSIZE 256 - -// Store the track data in preallocated memory, no point using dynamic memory as the floppy is so small. -typedef struct { - char track[MAX_FDC_SECTORS * MAX_FDC_SECTORSIZE]; -} t_track; - -static t_track tracks[MAX_FDC_TRACKS]; - -typedef struct { - int srcTrack; - int linearTrack; - int physicalTrack; - int physicalHead; - int offset; -} t_trackmapping; - -// Mapping table from Floppy image (Amstrad CPC Extended as raw) to linear image. -static t_trackmapping trackMapping[] = { - { 1, 0, 31, 1, 0 }, - { 0, 1, 32, 0, 4352 }, - { 3, 2, 32, 1, 8704 }, - { 2, 3, 33, 0, 13056 }, - { 5, 4, 33, 1, 17408 }, - { 4, 5, 34, 0, 21760 }, - { 7, 6, 34, 1, 26112 }, - { 6, 7, 28, 0, 30464 }, - { 9, 8, 28, 1, 34816 }, - { 8, 9, 29, 0, 39168 }, - { 11, 10, 29, 1, 43520 }, - { 10, 11, 30, 0, 47872 }, - { 13, 12, 30, 1, 52224 }, - { 12, 13, 31, 0, 56576 }, - { 15, 14, 24, 1, 60928 }, - { 14, 15, 25, 0, 65280 }, - { 17, 16, 25, 1, 69632 }, - { 16, 17, 26, 0, 73984 }, - { 19, 18, 26, 1, 78336 }, - { 18, 19, 27, 0, 82688 }, - { 21, 20, 27, 1, 87040 }, - { 20, 21, 21, 0, 91392 }, - { 23, 22, 21, 1, 95744 }, - { 22, 23, 22, 0, 100096 }, - { 25, 24, 22, 1, 104448 }, - { 24, 25, 23, 0, 108800 }, - { 27, 26, 23, 1, 113152 }, - { 26, 27, 24, 0, 117504 }, - { 29, 28, 17, 1, 121856 }, - { 28, 29, 18, 0, 126208 }, - { 31, 30, 18, 1, 130560 }, - { 30, 31, 19, 0, 134912 }, - { 33, 32, 19, 1, 139264 }, - { 32, 33, 20, 0, 143616 }, - { 35, 34, 20, 1, 147968 }, - { 34, 35, 14, 0, 152320 }, - { 37, 36, 14, 1, 156672 }, - { 36, 37, 15, 0, 161024 }, - { 39, 38, 15, 1, 165376 }, - { 38, 39, 16, 0, 169728 }, - { 41, 40, 16, 1, 174080 }, - { 40, 41, 17, 0, 178432 }, - { 43, 42, 10, 1, 182784 }, - { 42, 43, 11, 0, 187136 }, - { 45, 44, 11, 1, 191488 }, - { 44, 45, 12, 0, 195840 }, - { 47, 46, 12, 1, 200192 }, - { 46, 47, 13, 0, 204544 }, - { 49, 48, 13, 1, 208896 }, - { 48, 49, 7, 0, 213248 }, - { 51, 50, 7, 1, 217600 }, - { 50, 51, 8, 0, 221952 }, - { 53, 52, 8, 1, 226304 }, - { 52, 53, 9, 0, 230656 }, - { 55, 54, 9, 1, 235008 }, - { 54, 55, 10, 0, 239360 }, - { 57, 56, 3, 1, 243712 }, - { 56, 57, 4, 0, 248064 }, - { 59, 58, 4, 1, 252416 }, - { 58, 59, 5, 0, 256768 }, - { 61, 60, 5, 1, 261120 }, - { 60, 61, 6, 0, 265472 }, - { 63, 62, 6, 1, 269824 }, - { 62, 63, 0, 0, 274176 }, - { 65, 64, 0, 1, 278528 }, - { 64, 65, 1, 0, 282880 }, - { 67, 66, 1, 1, 287232 }, - { 66, 67, 2, 0, 291584 }, - { 69, 68, 2, 1, 295936 }, - { 68, 69, 3, 0, 300288 }, - { 71, 70, 2, 1, 295936 }, - { 70, 71, 3, 0, 300288 }, - { 73, 72, 2, 1, 295936 }, - { 72, 73, 3, 0, 300288 }, - { 75, 74, 2, 1, 295936 }, - { 74, 75, 3, 0, 300288 }, - { 77, 76, 2, 1, 295936 }, - { 76, 77, 3, 0, 300288 }, - { 79, 78, 2, 1, 295936 }, - { 78, 79, 3, 0, 300288 }, - { 81, 80, 2, 1, 295936 }, - { 80, 81, 3, 0, 300288 }, -}; - - -int main(int argc, char *argv[]) -{ - - int opt; - int option_index = 0; - int mode_flag = -1; - int idx; - int idx2; - int trkidx; - int FDC_TRACKS; - int FDC_SECTORS; - int FDC_SECTORSIZE; - int FDC_INVERT = 0; - int trackSize; - char inputFile[1024]; - char outputFile[1024]; - long fileSize; - FILE *inFile; - FILE *outFile; - - static struct option long_options[] = - { - {"from-linear", no_argument, 0, 'f'}, - {"to-linear", no_argument, 0, 't'}, - {"input", required_argument, 0, 'i'}, - {"output", required_argument, 0, 'o'}, - {0, 0, 0, 0} - }; - - // Initialise variables to defaults. - inputFile[0] = 0x00; - outputFile[0] = 0x00; - - // Parse the command line options. - // - while((opt = getopt_long(argc, argv, ":tfi:o:", long_options, &option_index)) != -1) - { - switch(opt) - { - case 'f': - mode_flag = 0; - printf("Mode flag set to 0\n"); - break; - - case 't': - mode_flag = 1; - printf("Mode flag set to 1\n"); - break; - - case 'i': - strcpy(inputFile, optarg); - printf("Input file set to:%s\n", inputFile); - break; - - case 'o': - strcpy(outputFile, optarg); - printf("Output file set to:%s\n", outputFile); - break; - - case ':': - printf("Option %s needs a value\n", argv[optind-1]); - break; - case '?': - printf("Unknown option: %s, ignoring!\n", argv[optind-1]); - break; - } - } - - if(strlen(inputFile) == 0 ) - { - printf("Input file not specified.\n"); - exit(10); - } - if(strlen(outputFile) == 0 ) - { - printf("Output file not specified.\n"); - exit(11); - } - if(mode_flag == -1) - { - printf("Mode not set, should be --to-linear or --from-linear.\n"); - exit(12); - } - inFile = fopen(inputFile, "r"); - outFile = fopen(outputFile, "w"); - if(inFile == NULL) - { - printf("Couldnt open the input file:%s.\n", inputFile); - exit(20); - } - if(outFile == NULL) - { - printf("Couldnt open the output file:%s.\n", outputFile); - exit(21); - } - fseek(inFile, 0, SEEK_END); - fileSize = ftell(inFile); - fseek(inFile, 0, SEEK_SET); - switch(fileSize) - { - case 358144: - FDC_TRACKS = 82; - FDC_SECTORS = 17; - FDC_SECTORSIZE = 256; - FDC_INVERT = 2; - break; - - case 357632: - FDC_TRACKS = 82; - FDC_SECTORS = 17; - FDC_SECTORSIZE = 256; - FDC_INVERT = 2; - break; - - case 304640: - FDC_TRACKS = 70; - FDC_SECTORS = 17; - FDC_SECTORSIZE = 256; - FDC_INVERT = 2; - break; - - case 286720: - FDC_TRACKS = 70; - FDC_SECTORS = 16; - FDC_SECTORSIZE = 256; - FDC_INVERT = 2; - break; - - case 327680: - FDC_TRACKS = 80; - FDC_SECTORS = 16; - FDC_SECTORSIZE = 256; - FDC_INVERT = 1; - break; - - default: - printf("Unrecognised file size:%d\n", fileSize); - exit(22); - } - trackSize = FDC_SECTORS * FDC_SECTORSIZE; - -// FDC_TRACKS = fileSize / (FDC_SECTORSIZE * -// if(fileSize < (FDC_TRACKS * FDC_SECTORS * FDC_SECTORSIZE)) -// { -// printf("Input file is too small, configuration is:\n Tracks = %d, Sectors = %d, Sector Size = %d, Total Floppy Size = %ld\n", FDC_TRACKS, FDC_SECTORS, FDC_SECTORSIZE, (FDC_TRACKS * FDC_SECTORS * FDC_SECTORSIZE)); -// exit(22); -// } -// if(fileSize > (FDC_TRACKS * FDC_SECTORS * FDC_SECTORSIZE)) -// { -// printf("Input file is too large, configuration is:\n Tracks = %d, Sectors = %d, Sector Size = %d, Total Floppy Size = %ld\n", FDC_TRACKS, FDC_SECTORS, FDC_SECTORSIZE, (FDC_TRACKS * FDC_SECTORS * FDC_SECTORSIZE)); -// exit(23); -// } - - for(idx=0; idx < FDC_TRACKS; idx++) - { - fread(tracks[idx].track, 1, trackSize, inFile); - } - - for(idx=0; idx < FDC_TRACKS; idx++) - { - switch(mode_flag) - { - // from linear - case 0: - for(trkidx=0; trkidx < FDC_TRACKS && trackMapping[trkidx].linearTrack != idx; trkidx++); - printf("Mapping track:%d for src track:%d\n", trkidx, idx); - break; - - // to linear - case 1: - for(trkidx=0; trkidx < FDC_TRACKS && trackMapping[trkidx].srcTrack != idx; trkidx++); - printf("Mapping track:%d to track:%d\n", idx, trkidx); - break; - - } - if(trkidx < FDC_TRACKS) - { - if(FDC_INVERT == 2 || (FDC_INVERT == 1 && trkidx == 1)) - { - for(idx2=0; idx2 < (FDC_SECTORS * FDC_SECTORSIZE); idx2++) - { - tracks[trkidx].track[idx2] = ~tracks[trkidx].track[idx2]; - } - } - fwrite(tracks[trkidx].track, 1, trackSize, outFile); - } - } - - fclose(inFile); - fclose(outFile); -} diff --git a/software/src/tools/mzfdc2 b/software/src/tools/mzfdc2 deleted file mode 100755 index aefe354..0000000 Binary files a/software/src/tools/mzfdc2 and /dev/null differ diff --git a/software/src/tools/sdtest.c b/software/src/tools/sdtest.c deleted file mode 100644 index b133961..0000000 --- a/software/src/tools/sdtest.c +++ /dev/null @@ -1,84 +0,0 @@ -/*----------------------------------------------------------------------*/ -/* Petit FatFs sample project for generic uC (C)ChaN, 2010 */ -/*----------------------------------------------------------------------*/ - -#include -#include "pff.h" - - -void die ( /* Stop with dying message */ - FRESULT rc /* FatFs return value */ -) -{ - printf("Failed with rc=%u.\n", rc); - for (;;) ; -} - - -/*-----------------------------------------------------------------------*/ -/* Program Main */ -/*-----------------------------------------------------------------------*/ - -int main (void) -{ - FATFS fatfs; /* File system object */ - DIR dir; /* Directory object */ - FILINFO fno; /* File information object */ - UINT bw, br, i; - BYTE buff[64]; - - - printf("\nMount a volume.\n"); - rc = pf_mount(&fatfs); - if (rc) die(rc); - - printf("\nOpen a test file (message.txt).\n"); - rc = pf_open("MESSAGE.TXT"); - if (rc) die(rc); - - printf("\nType the file content.\n"); - for (;;) { - rc = pf_read(buff, sizeof(buff), &br); /* Read a chunk of file */ - if (rc || !br) break; /* Error or end of file */ - for (i = 0; i < br; i++) /* Type the data */ - putchar(buff[i]); - } - if (rc) die(rc); - -#if PF_USE_WRITE - printf("\nOpen a file to write (write.txt).\n"); - rc = pf_open("WRITE.TXT"); - if (rc) die(rc); - - printf("\nWrite a text data. (Hello world!)\n"); - for (;;) { - rc = pf_write("Hello world!\r\n", 14, &bw); - if (rc || !bw) break; - } - if (rc) die(rc); - - printf("\nTerminate the file write process.\n"); - rc = pf_write(0, 0, &bw); - if (rc) die(rc); -#endif - -#if PF_USE_DIR - printf("\nOpen root directory.\n"); - rc = pf_opendir(&dir, ""); - if (rc) die(rc); - - printf("\nDirectory listing...\n"); - for (;;) { - rc = pf_readdir(&dir, &fno); /* Read a directory item */ - if (rc || !fno.fname[0]) break; /* Error or end of dir */ - if (fno.fattrib & AM_DIR) - printf(" %s\n", fno.fname); - else - printf("%8lu %s\n", fno.fsize, fno.fname); - } - if (rc) die(rc); -#endif - - printf("\nTest completed.\n"); - for (;;) ; -} diff --git a/software/src/tools/sdtool b/software/src/tools/sdtool deleted file mode 100755 index e334937..0000000 Binary files a/software/src/tools/sdtool and /dev/null differ diff --git a/software/src/tools/sdtool.c b/software/src/tools/sdtool.c deleted file mode 100644 index cfa57f9..0000000 --- a/software/src/tools/sdtool.c +++ /dev/null @@ -1,772 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Name: sdtool.c -// Created: January 2019 -// Author(s): Philip Smart -// Description: MZ-80A SD Card Drive file image manipulator. -// This program creates and manipulates an SD Card image for the Sharp MZ80A with the -// Rom Filing System addition. The image contains the Rom Filing System disk at -// the beginning of the image (contains original Sharp MZ80A programs) along -// with 1 or more CPM disk drive images. The resultant image is copied directly -// onto an sd card using DD or equivalent. -// -// The format of the image is as follows: -// SECTOR FUNCTION -// 00000000 --------------------------------------------------------------------------- -// | ROM FILING SYSTEM IMAGE | -// | | -// 00000000 | RFS DIRECTORY ENTRY 000 (32BYTE) | -// | .. | -// | .. | -// 00001FE0 | RFS DIRECTORY ENTRY 255 (32BYTE) | -// 00002000 --------------------------------------------------------------------------- -// | | -// | CP/M DISK IMAGE 1 | -// | | -// | | -// | | -// | | -// --------------------------------------------------------------------------- -// | | -// | CP/M DISK IMAGE 2 | -// | | -// | | -// | | -// | | -// --------------------------------------------------------------------------- -// | | -// | CP/M DISK IMAGE 3 | -// | | -// | | -// | | -// | | -// --------------------------------------------------------------------------- -// | | -// | CP/M DISK IMAGE ... | -// | | -// | | -// | | -// | | -// --------------------------------------------------------------------------- -// -// The Rom Filing System directory entry is based on the MZF Header format and is as follows: -// | FLAG1 | FLAG2 | FILE NAME | START SECTOR | SIZE | LOAD ADDR | EXEC ADDR | RESERVED -// | 1 Byte | 1 Byte | 17 Bytes | 4 Bytes | 2 Bytes | 2 Bytes | 2 Bytes | 3 Bytes -// -// FLAG1 : BIT 7 = 1, Valid directory entry, 0 = inactive. -// FLAG2 : MZF Execution Code, 0x01 = Binary -// FILENAME : Standard MZF format filename. -// START SECTOR : Sector in the SD card where the program starts. It always starts at position 0 of the sector. -// SIZE : Size in bytes of the program. Each file block occupies 64Kbyte space (as per a tape) and this -// parameter provides the actual space occupied by the program at the current time. -// LOAD ADDR : Start address in memory where data should be loaded. -// EXEC ADDR : If a binary then this parameter specifies the location to auto execute once loaded. -// RESERVED : Not used at the moemnt. -// -// Caveat: This program was just intended to be a simple helper hence not properly split into methods, -// it may need updating as it becomes more complex!! -// -// Credits: -// Copyright: (c) 2020 Philip Smart -// -// History: March 2020 - Initial program written. -// -// Notes: -// -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// This source file is free software: you can redistribute it and#or modify -// it under the terms of the GNU General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This source file is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include -#include - -#define VERSION "1.0" -#define RFS_MAX_DIR_ENTRIES 256 -#define RFS_DIR_ENTRY_SIZE 32 -#define RFS_DIRENT_INUSE 0x80 -#define RFS_FILESIZE 65536 -#define RFS_IMAGESIZE (RFS_FILESIZE * RFS_MAX_DIR_ENTRIES) + (RFS_DIR_ENTRY_SIZE * RFS_MAX_DIR_ENTRIES) -#define RFS_FILEBLOCK_START (RFS_DIR_ENTRY_SIZE * RFS_MAX_DIR_ENTRIES) -#define CPM_DRIVE_IMAGES 4 -#define CPM_SECTOR_LEN 512 -#define CPM_TRACKS 512 -#define CPM_SECTORS 32 -#define CPM_BLOCKSIZE 4096 -#define CPM_MAXDIR_ENTRIES 512 - -// Structure to represent an RFS directory entry within the RFS SD Card druve image. -// -typedef struct __attribute__((__packed__)) { - uint8_t flag1; - uint8_t flag2; - uint8_t fileName[17]; - uint32_t startSector; - uint16_t size; - uint16_t loadAddr; - uint16_t execAddr; - uint8_t reserved[3]; -} rfs_dirent; - -// Structure to represent an MZF header. -// -typedef struct __attribute__((__packed__)) { - uint8_t ATRB; - uint8_t NAME[17]; - uint16_t SIZE; - uint16_t DTADR; - uint16_t EXADR; - uint8_t COMNT[104]; -} mzf_dirent; - -// Mapping table from Sharp MZ80A Ascii to real Ascii. -// -typedef struct { - uint8_t asciiCode; - char asciiPrintable[6]; -} t_asciiMap; - -static t_asciiMap asciiMap[] = { - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, // 0x0F - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, // 0x1F - { 0x20, "SPACE"}, - { 0x21, "!" }, - { 0x22, "\"" }, - { 0x23, "#" }, - { 0x24, "$" }, - { 0x25, "%" }, - { 0x26, "&" }, - { 0x27, "'" }, - { 0x28, "(" }, - { 0x29, ")" }, - { 0x2A, "*" }, - { 0x2B, "+" }, - { 0x2C, "," }, - { 0x2D, "-" }, - { 0x2E, "." }, - { 0x2F, "/" }, // 0x2F - { 0x30, "0" }, - { 0x31, "1" }, - { 0x32, "2" }, - { 0x33, "3" }, - { 0x34, "4" }, - { 0x35, "5" }, - { 0x36, "6" }, - { 0x37, "7" }, - { 0x38, "8" }, - { 0x39, "9" }, - { 0x3A, ":" }, - { 0x3B, ";" }, - { 0x3C, "<" }, - { 0x3D, "=" }, - { 0x3E, ">" }, - { 0x3F, "?" }, // 0x3F - { 0x40, "@" }, - { 0x41, "A" }, - { 0x42, "B" }, - { 0x43, "C" }, - { 0x44, "D" }, - { 0x45, "E" }, - { 0x46, "F" }, - { 0x47, "G" }, - { 0x48, "H" }, - { 0x49, "I" }, - { 0x4A, "J" }, - { 0x4B, "K" }, - { 0x4C, "L" }, - { 0x4D, "M" }, - { 0x4E, "N" }, - { 0x4F, "O" }, // 0x4F - { 0x50, "P" }, - { 0x51, "Q" }, - { 0x52, "R" }, - { 0x53, "S" }, - { 0x54, "T" }, - { 0x55, "U" }, - { 0x56, "V" }, - { 0x57, "W" }, - { 0x58, "X" }, - { 0x59, "Y" }, - { 0x5A, "Z" }, - { 0x5B, "[" }, - { 0x5C, "\\" }, - { 0x5D, "]" }, - { 0x5E, "^" }, - { 0x5F, "_" }, // 0x5F - { 0x20, "SPACE"}, // 0x60 - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, // 0x6F - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, // 0x7F - - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, // 0x8F - - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x65, "e" }, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x74, "t" }, - { 0x67, "g" }, - { 0x68, "h" }, - { 0x20, "SPACE"}, - { 0x62, "b" }, - { 0x78, "x" }, - { 0x64, "d" }, - { 0x72, "r" }, - { 0x70, "p" }, - { 0x63, "c" }, // 0x9F - - { 0x71, "q" }, - { 0x61, "a" }, - { 0x7A, "z" }, - { 0x77, "w" }, - { 0x73, "s" }, - { 0x75, "u" }, - { 0x69, "i" }, - { 0x20, "SPACE"}, - { 0x4F, "O" }, // O with umlaut - { 0x6B, "k" }, - { 0x66, "f" }, - { 0x76, "v" }, - { 0x20, "SPACE"}, - { 0x75, "u" }, // u with umlaut - { 0x42, "B" }, // Strasse S - { 0x6A, "j" }, // 0XAF - - { 0x6E, "n" }, - { 0x20, "SPACE"}, - { 0x55, "U" }, // U with umlaut - { 0x6D, "m" }, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x6F, "o" }, - { 0x6C, "l" }, - { 0x41, "A" }, // A with umlaut - { 0x6F, "o" }, // o with umlaut - { 0x61, "a" }, // a with umlaut - { 0x20, "SPACE"}, - { 0x79, "y" }, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, // 0xBF - - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, // 0XCF - - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, // 0XDF - - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, // 0XEF - - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"}, - { 0x20, "SPACE"} // 0XFF -}; - -// Simple function to convert an ascii filename into a Sharp filename using the asciimap table in reverse. -void convertToSharpFileName(char *filename) -{ - char *p = filename; - - while(*p != 0x00) - { - for(uint32_t idx=0; idx <= 255; idx++) - { - if(*p == asciiMap[idx].asciiPrintable[0] && strlen(asciiMap[idx].asciiPrintable) == 1) - { - *p = (char)idx; - } - } - p++; - } - -} - - -// Simple help screen to remmber how this utility works!! -// -void usage(void) -{ - printf("SDTOOL v%s\n", VERSION); - printf("\nOptions:-\n"); - printf(" -a | --add Add given file into the Image.\n"); - printf(" -A | --attribute For a binary file, set the MZF attribute to the given val, default=0x01.\n"); - printf(" -b | --binary Indicate file being added is a binary file, not an MZF format file.\n"); - printf(" -c | --create-image Create or re-initialise the given image file.\n"); - printf(" -e | --exec-addr For a binary file, set the execution address to be written into the directory entry.\n"); - printf(" -h | --help This help test.\n"); - printf(" -d | --list-dir List the image directory contents.\n"); - printf(" -l | --load-addr For a binary file, set the load address to be written into the directory entry.\n"); - printf(" -i | --image Image file to be created or manipulated.\n"); - printf(" -v | --verbose Output more messages.\n"); - - printf("\nExamples:\n"); - printf(" sdtool --image MZ80A_1.img --list-dir List the directory entries in the image.\n"); - printf(" sdtool --image MZ80A_1.img --create-image Initialise MZ80A_1.img to a new empty state.\n"); - printf(" sdtool --image MZ80A_1.img --add CLOCK.MZF Add the CLOCK.MZF file into the image and update the directory with the MZF header details.\n"); - printf(" sdtool --image MZ80A_1.img --add CLOCK.BIN \\\n"); - printf(" --binary \\\n"); - printf(" --exec-addr 4608 --load-addr 4608 Add the CLOCK.BIN binary file into the image with the given load and exec addresses. Update directory.\n"); - -} - -// Method to convert a little endian <-> big endian 32bit unsigned. -// -uint32_t swap_endian(uint32_t value) -{ - uint32_t b[4]; - b[0] = ((value & 0x000000ff) << 24u); - b[1] = ((value & 0x0000ff00) << 8u); - b[2] = ((value & 0x00ff0000) >> 8u); - b[3] = ((value & 0xff000000) >> 24u); - - return(b[0] | b[1] | b[2] | b[3]); -} - - -// Main program, to be split up into methods at a later date!! Just quick write as Im concentrating on the SD Card with RFS and CPM. -// -int main(int argc, char *argv[]) -{ - - int opt; - int option_index = 0; - int binary_flag = 0; - int help_flag = 0; - int listDir_flag = 0; - int createImage_flag = 0; - int verbose_flag = 0; - uint8_t attribute = 0x01; - uint16_t loadAddr = 0x1200; - uint16_t execAddr = 0x1200; - char imageFile[1024]; - char addFile[1024]; - long fileSize; - FILE *fpImage; - FILE *fpAdd; - rfs_dirent rfs_directory[RFS_MAX_DIR_ENTRIES]; - mzf_dirent mzf_header; - - // Initialise other variables. - // - addFile[0] = 0x00; - imageFile[0] = 0x00; - - // Modes of operation. - // sdtool --add file [--binary] --image file --create-image - // sdtool --add file [--binary] --image file - // sdtool - static struct option long_options[] = - { - {"add", required_argument, 0, 'a'}, - {"attribute", required_argument, 0, 'A'}, - {"binary", no_argument, 0, 'b'}, - {"create-image",no_argument, 0, 'c'}, - {"exec-addr", required_argument, 0, 'e'}, - {"help", no_argument, 0, 'h'}, - {"list-dir", no_argument, 0, 'd'}, - {"load-addr", required_argument, 0, 'l'}, - {"image", required_argument, 0, 'i'}, - {"verbose", no_argument, 0, 'v'}, - {0, 0, 0, 0} - }; - - // Parse the command line options. - // - while((opt = getopt_long(argc, argv, ":bcdha;A:i:l:e:", long_options, &option_index)) != -1) - { - switch(opt) - { - case 'a': - strcpy(addFile, optarg); - break; - - case 'A': - attribute = (uint8_t)atoi(optarg); - break; - - case 'b': - binary_flag = 1; - break; - - case 'c': - createImage_flag = 1; - break; - - case 'd': - listDir_flag = 1; - break; - - case 'e': - execAddr = atoi(optarg); - break; - - case 'h': - help_flag = 1; - break; - - case 'i': - strcpy(imageFile, optarg); - break; - - case 'l': - loadAddr = atoi(optarg); - break; - - case 'v': - verbose_flag = 1; - break; - - case ':': - printf("Option %s needs a value\n", argv[optind-1]); - break; - case '?': - printf("Unknown option: %s, ignoring!\n", argv[optind-1]); - break; - } - } - - // Validate the input. - if(help_flag == 1) - { - usage(); - exit(0); - } - if(strlen(imageFile) == 0 ) - { - printf("Image file not specified.\n"); - exit(10); - } - if(strlen(addFile) == 0 && listDir_flag == 0 && createImage_flag == 0) - { - printf("File to add not specified.\n"); - exit(11); - } - if(createImage_flag == 1 && listDir_flag == 1) - { - printf("Meaningless option, create image will result in an empty directory so no point listing the directory!!\n"); - exit(12); - } - - // If the create flag is set, initialise the base RFS image. - if(createImage_flag) - { - fpImage = fopen(imageFile, "w"); - if(fpImage == NULL) - { - printf("Couldnt create the image file:%s.\n", imageFile); - exit(30); - } else - { - for(uint32_t idx=0; idx < RFS_IMAGESIZE; idx++) - fputc(0x00, fpImage); - } - fclose(fpImage); - - // All done if we are not adding a file. - if(addFile[0] == 0x00) - { - if(verbose_flag) - printf("Image file created.\n"); - exit(0); - } - } - - // Open the image file for read/write operations - fpImage = fopen(imageFile, "r+"); - if(fpImage == NULL) - { - printf("Couldnt open the image file:%s.\n", imageFile); - exit(20); - } - - // Get the directory into memory. - size_t result=fread(&rfs_directory, 1, sizeof(rfs_dirent) * RFS_MAX_DIR_ENTRIES, fpImage); - if(result < (RFS_MAX_DIR_ENTRIES * RFS_DIR_ENTRY_SIZE)) - { - printf("Failed to read RFS directory from image, is image corrupt? (%d)\n", result); - exit(40); - } - - // List directory? - if(listDir_flag == 1) - { - printf("FileName Start Sector Size Load Addr Exec Addr\n"); - printf("-------- ------------ ---- --------- ---------\n"); - for(uint16_t idx=0; idx < RFS_MAX_DIR_ENTRIES; idx++) - { - if((rfs_directory[idx].flag1 & RFS_DIRENT_INUSE) != 0) - { - uint8_t canPrint = 1; - for(uint16_t idx2=0; idx2 < 17; idx2++) - { - if(rfs_directory[idx].fileName[idx2] == 0x0d || rfs_directory[idx].fileName[idx2] == 0x00) - canPrint = 0; - - if(canPrint == 1) - putchar(asciiMap[rfs_directory[idx].fileName[idx2]].asciiCode); - else - putchar(' '); - } - - printf(" %08lx %04x %04x %04x\n", swap_endian(rfs_directory[idx].startSector), rfs_directory[idx].size, rfs_directory[idx].loadAddr, rfs_directory[idx].execAddr); - } - } - exit(0); - } - - // Open the MZF file to add in read only mode. - fpAdd = fopen(addFile, "r"); - if(fpAdd == NULL) - { - printf("Couldnt open the file to add:%s.\n", addFile); - exit(21); - } - - // Get size of image file. - fseek(fpImage, 0, SEEK_END); - fileSize = ftell(fpImage); - fseek(fpImage, 0, SEEK_SET); - if(fileSize < RFS_IMAGESIZE) - { - printf("Image size is too small, please recreate with --create-image flag.\n"); - } - - // Get size of file where adding. - fseek(fpAdd, 0, SEEK_END); - fileSize = ftell(fpAdd); - fseek(fpAdd, 0, SEEK_SET); - - // If this is an MZF file, get header. - if(binary_flag == 0) - { - result=fread(&mzf_header, 1, sizeof(mzf_dirent), fpAdd); - if(result < sizeof(mzf_dirent)) - { - printf("Failed to read MZF header from MZF file, is image an MZF file?\n"); - exit(50); - } - } - - // Locate the first empty slot to add the file. - uint16_t dirEntry = 0; - while((rfs_directory[dirEntry].flag1 & RFS_DIRENT_INUSE) != 0) - { - dirEntry++; - if(dirEntry > 255) - { - printf("Image directory is full, cannot add file.\n"); - exit(60); - } - } - - // Ok, we now have a valid image file, slot in the directory which is free and the MZF file details, populate the directory entry, write it and then - // write the file into the image. - rfs_directory[dirEntry].flag1 = RFS_DIRENT_INUSE; - if(binary_flag == 0) - { - rfs_directory[dirEntry].flag2 = mzf_header.ATRB; - memcpy(rfs_directory[dirEntry].fileName, mzf_header.NAME, 17); - rfs_directory[dirEntry].fileName[16] = 0x00; - rfs_directory[dirEntry].startSector = swap_endian((RFS_FILEBLOCK_START + (dirEntry * RFS_FILESIZE))/512);; - rfs_directory[dirEntry].size = mzf_header.SIZE; - rfs_directory[dirEntry].loadAddr = mzf_header.DTADR; - rfs_directory[dirEntry].execAddr = mzf_header.EXADR; - } else - { - // Extract the filename for insertion into the MZF header. - char *baseFileName = basename(addFile); - if(baseFileName == NULL) - { - printf("Error processing filename to extract basename.\n"); - exit(50); - } - char *dot=strchr(baseFileName, '.'); - if(dot != NULL) - { - *dot = 0x00; - } - convertToSharpFileName(baseFileName); - - rfs_directory[dirEntry].flag2 = attribute; - for(int idx=0; idx < 17; idx++) - { - rfs_directory[dirEntry].fileName[idx] = (idx >= strlen(baseFileName) ? 0x0d : baseFileName[idx]); - } - rfs_directory[dirEntry].startSector = swap_endian((RFS_FILEBLOCK_START + (dirEntry * RFS_FILESIZE))/512); - rfs_directory[dirEntry].size = fileSize; - rfs_directory[dirEntry].loadAddr = loadAddr; - rfs_directory[dirEntry].execAddr = execAddr; - } - fseek(fpImage, 0, SEEK_SET); - result=fwrite(&rfs_directory, 1, sizeof(rfs_dirent) * RFS_MAX_DIR_ENTRIES, fpImage); - if(result < (RFS_MAX_DIR_ENTRIES * RFS_DIR_ENTRY_SIZE)) - { - printf("Failed to write RFS directory into image file, disk full or wrong permissions?\n"); - exit(50); - } - - // Seek to the correct 64K block then write out 64K. - fseek(fpImage, (RFS_FILEBLOCK_START + (dirEntry * RFS_FILESIZE)), SEEK_SET); - for(uint32_t idx=0; idx < RFS_FILESIZE; idx++) - { - int c = fgetc(fpAdd); - if(feof(fpAdd)) - c = 0xFF; - fputc(c, fpImage); - } - - if(verbose_flag) - printf("Added %s to image.\n", addFile); - - // Tidy up, close and finish. - fclose(fpAdd); - fclose(fpImage); - if(verbose_flag) - printf("Image file updated.\n"); -} diff --git a/software/test b/software/test deleted file mode 100644 index e69de29..0000000 diff --git a/software/tools/assemble_cpm.sh b/software/tools/assemble_cpm.sh deleted file mode 100755 index 47a0021..0000000 --- a/software/tools/assemble_cpm.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -######################################################################################################### -## -## Name: assemble_cpm.sh -## Created: August 2018 -## Author(s): Philip Smart -## Description: Sharp MZ series CPM assembly tool -## This script builds a CPM version compatible with the MZ-80A RFS system. -## -## Credits: -## Copyright: (c) 2020-23 Philip Smart -## -## History: January 2020 - Initial script written. -## -######################################################################################################### -## This source file is free software: you can redistribute it and#or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This source file is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -######################################################################################################### - -ROOTDIR=../../MZ80A_RFS -TOOLDIR=${ROOTDIR}/software/tools -JARDIR=${ROOTDIR}/software/tools -ASM=glass.jar -BUILDROMLIST="cbios cbios_bank1 cbios_bank2 cbios_bank3 cbios_bank4 cpm22" -BUILDMZFLIST="" -ASMDIR=${ROOTDIR}/software/asm -ASMTMPDIR=${ROOTDIR}/software/tmp -INCDIR=${ROOTDIR}/software/asm/include -ROMDIR=${ROOTDIR}/software/roms # Compiled or source ROM files. -MZFDIR=${ROOTDIR}/software/MZF/Common # MZF Format source files. -MZBDIR=${ROOTDIR}/software/MZB/Common -BLOCKSIZELIST="128 256" - -# Go through list and build images. -# -for f in ${BUILDROMLIST} -do - echo "Assembling: $f..." - - # Assemble the source. - echo "java -jar ${JARDIR}/${ASM} ${ASMDIR}/${f}.asm ${ASMTMPDIR}/${f}.obj ${ASMTMPDIR}/${f}.sym" - java -jar ${JARDIR}/${ASM} ${ASMDIR}/${f}.asm ${ASMTMPDIR}/${f}.obj ${ASMTMPDIR}/${f}.sym -I ${INCDIR} - - # On successful compile, perform post actions else go onto next build. - # - if [ $? = 0 ] - then - # The object file is binary, no need to link, copy according to build group. - if [[ ${BUILDROMLIST} = *"${f}"* ]]; then - echo "Copy ${ASMDIR}/${f}.obj to ${ROMDIR}/${f}.rom" - cp ${ASMTMPDIR}/${f}.obj ${ROMDIR}/${f}.rom - fi - if [[ ${BUILDMZFLIST} = *"${f}"* ]]; then - # Build standard MZF files for inclusion in the SD Drive. - echo "Copy ${ASMDIR}/${f}.obj to ${MZFDIR}/${f}.mzf" - cp ${ASMTMPDIR}/${f}.obj ${MZFDIR}/${f}.mzf - - # Create sectored versions of file for inclusion into the ROM Drives. - for BLOCKSIZE in ${BLOCKSIZELIST} - do - FILESIZE=$(stat -c%s "${ASMTMPDIR}/${f}.obj") - if [ $((${FILESIZE} % ${BLOCKSIZE})) -ne 0 ]; then - FILESIZE=$(( ((${FILESIZE} / ${BLOCKSIZE})+1 ) * ${BLOCKSIZE} )) - fi - - dd if=/dev/zero ibs=1 count=${FILESIZE} 2>/dev/null | tr "\000" "\377" > "${MZBDIR}/${f}.${BLOCKSIZE}.bin" - dd if="${ASMTMPDIR}/${f}.obj" of="${MZBDIR}/${f}.${BLOCKSIZE}.bin" conv=notrunc 2>/dev/null - done - fi - fi -done diff --git a/software/tools/assemble_rfs.sh b/software/tools/assemble_rfs.sh deleted file mode 100755 index 4f0c38a..0000000 --- a/software/tools/assemble_rfs.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -######################################################################################################### -## -## Name: assemble_rfs.sh -## Created: August 2018 -## Author(s): Philip Smart -## Description: Sharp MZ series RFS ROM assembly tool -## This script takes Sharp MZ RFS ROMS in assembler format and compiles/assembles them -## into a ROM file using the GLASS Z80 assembler. -## -## Credits: -## Copyright: (c) 2018-23 Philip Smart -## -## History: August 2018 - Initial script written. -## -######################################################################################################### -## This source file is free software: you can redistribute it and#or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This source file is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -######################################################################################################### - -ROOTDIR=../../MZ80A_RFS -TOOLDIR=${ROOTDIR}/software/tools -JARDIR=${ROOTDIR}/software/tools -ASM=glass.jar -BUILDROMLIST="rfs rfs_mrom" -BUILDMZFLIST="" -ASMDIR=${ROOTDIR}/software/asm -ASMTMPDIR=${ROOTDIR}/software/tmp -INCDIR=${ROOTDIR}/software/asm/include -ROMDIR=${ROOTDIR}/software/roms -MZFDIR=${ROOTDIR}/software/MZB/Common - -# Go through list and build image. -# -for f in ${BUILDROMLIST} ${BUILDMZFLIST} -do - echo "Assembling: $f..." - - # Assemble the source. - echo "java -jar ${JARDIR}/${ASM} ${ASMDIR}/${f}.asm ${ASMTMPDIR}/${f}.obj ${ASMTMPDIR}/${f}.sym" - java -jar ${JARDIR}/${ASM} ${ASMDIR}/${f}.asm ${ASMTMPDIR}/${f}.obj ${ASMTMPDIR}/${f}.sym -I ${INCDIR} - - # On successful compile, perform post actions else go onto next build. - # - if [ $? = 0 ] - then - # The object file is binary, no need to link, copy according to build group. - if [[ ${BUILDROMLIST} = *"${f}"* ]]; then - echo "Copy ${ASMTMPDIR}/${f}.obj to ${ROMDIR}/${f}.rom" - cp ${ASMTMPDIR}/${f}.obj ${ROMDIR}/${f}.rom - else - echo "Copy ${ASMTMPDIR}/${f}.obj to ${MZFDIR}/${f}.mzf" - cp ${ASMTMPDIR}/${f}.obj ${MZFDIR}/${f}.mzf - fi - fi -done diff --git a/software/tools/assemble_roms.sh b/software/tools/assemble_roms.sh deleted file mode 100755 index b10b389..0000000 --- a/software/tools/assemble_roms.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -######################################################################################################### -## -## Name: assemble_roms.sh -## Created: August 2018 -## Author(s): Philip Smart -## Description: Sharp MZ series ROM assembly tool -## This script takes Sharp MZ ROMS in assembler format and compiles/assembles them -## into a ROM file using the GLASS Z80 assembler. -## -## Credits: -## Copyright: (c) 2018-23 Philip Smart -## -## History: August 2018 - Initial script written. -## March 2021 - Updated to compile different versions of Microsoft BASIC. -## -######################################################################################################### -## This source file is free software: you can redistribute it and#or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This source file is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -######################################################################################################### - -ROOTDIR=../../MZ80A_RFS -TOOLDIR=${ROOTDIR}/software/tools -JARDIR=${ROOTDIR}/software/tools -ASM=glass.jar -#BUILDROMLIST="MZ80AFI rfs rfs_mrom IPL monitor_SA1510 monitor_80c_SA1510 monitor_mz-1r12 quickdisk_mz-1e05 quickdisk_mz-1e14 monitor_1Z-013A monitor_80c_1Z-013A" -BUILDROMLIST="monitor_sa1510_hiload monitor_80c_sa1510_hiload monitor_80c_sa1510 mz80afi monitor_sa1510 monitor_80c_sa1510 monitor_1z-013a monitor_80c_1z-013a ipl" -#BUILDMZFLIST="hi-ramcheck sharpmz-test" -BUILDMZFLIST="sa-5510_rfs msbasic_mz80a msbasic_rfs40 msbasic_rfs80 sharpmz-test" -ASMDIR=${ROOTDIR}/software/asm -ASMTMPDIR=${ROOTDIR}/software/tmp -INCDIR=${ROOTDIR}/software/asm/include -ROMDIR=${ROOTDIR}/software/roms -MZFDIR=${ROOTDIR}/software/MZF/Common -MZBDIR=${ROOTDIR}/software/MZB/Common -BLOCKSIZELIST="128 256" - -# Go through list and build image. -# -for f in ${BUILDROMLIST} ${BUILDMZFLIST} -do - echo "Assembling: $f..." - - SRCNAME=${f} - ASMNAME=${f}.asm - OBJNAME=${f}.obj - SYMNAME=${f}.sym - ROMNAME=${f}.rom - MZFNAME=${f}.MZF - - # Special handling for the 4 version of MS BASIC. - if [[ ${SRCNAME} = "msbasic_mz80a" ]]; then - ASMNAME="msbasic.asm" - echo "BUILD_VERSION EQU 0" > ${INCDIR}/MSBASIC_BuildVersion.asm - elif [[ ${SRCNAME} = "msbasic_rfs40" ]]; then - ASMNAME="msbasic.asm" - echo "BUILD_VERSION EQU 1" > ${INCDIR}/MSBASIC_BuildVersion.asm - elif [[ ${SRCNAME} = "msbasic_rfs80" ]]; then - ASMNAME="msbasic.asm" - echo "BUILD_VERSION EQU 2" > ${INCDIR}/MSBASIC_BuildVersion.asm - elif [[ ${SRCNAME} = "msbasic_rfstz" ]]; then - ASMNAME="msbasic.asm" - echo "BUILD_VERSION EQU 3" > ${INCDIR}/MSBASIC_BuildVersion.asm - elif [[ ${SRCNAME} = "msbasic_tzfs" ]]; then - ASMNAME="msbasic.asm" - echo "BUILD_VERSION EQU 4" > ${INCDIR}/MSBASIC_BuildVersion.asm - fi - - # Assemble the source. - echo "java -jar ${JARDIR}/${ASM} ${ASMDIR}/${ASMNAME} ${ASMTMPDIR}/${OBJNAME} ${ASMTMPDIR}/${SYMNAME}" - java -jar ${JARDIR}/${ASM} ${ASMDIR}/${ASMNAME} ${ASMTMPDIR}/${OBJNAME} ${ASMTMPDIR}/${SYMNAME} -I ${INCDIR} - - # On successful compile, perform post actions else go onto next build. - # - if [ $? = 0 ] - then - # The object file is binary, no need to link, copy according to build group. - if [[ ${BUILDROMLIST} = *"${SRCNAME}"* ]]; then - echo "Copy ${ASMTMPDIR}/${OBJNAME} to ${ROMDIR}/${ROMNAME}" - cp ${ASMTMPDIR}/${OBJNAME} ${ROMDIR}/${ROMNAME} - else - # Build standard MZF files for inclusion in the SD Drive. - echo "Copy ${ASMTMPDIR}/${OBJNAME} to ${MZFDIR}/${MZFNAME}" - cp ${ASMTMPDIR}/${OBJNAME} ${MZFDIR}/${MZFNAME} - - # Create sectored versions of file for inclusion into the ROM Drives. - for BLOCKSIZE in ${BLOCKSIZELIST} - do - FILESIZE=$(stat -c%s "${ASMTMPDIR}/${OBJNAME}") - if [ $((${FILESIZE} % ${BLOCKSIZE})) -ne 0 ]; then - FILESIZE=$(( ((${FILESIZE} / ${BLOCKSIZE})+1 ) * ${BLOCKSIZE} )) - fi - - dd if=/dev/zero ibs=1 count=${FILESIZE} 2>/dev/null | tr "\000" "\377" > "${MZBDIR}/${SRCNAME}.${BLOCKSIZE}.bin" - dd if="${ASMTMPDIR}/${OBJNAME}" of="${MZBDIR}/${SRCNAME}.${BLOCKSIZE}.bin" conv=notrunc 2>/dev/null - done - fi - fi -done - - diff --git a/software/tools/dz80 b/software/tools/dz80 deleted file mode 100755 index dc8f14c..0000000 Binary files a/software/tools/dz80 and /dev/null differ diff --git a/software/tools/glass-0.5.1.jar b/software/tools/glass-0.5.1.jar deleted file mode 100755 index db07912..0000000 Binary files a/software/tools/glass-0.5.1.jar and /dev/null differ diff --git a/software/tools/glass-0.5.jar b/software/tools/glass-0.5.jar deleted file mode 100755 index 7cb301c..0000000 Binary files a/software/tools/glass-0.5.jar and /dev/null differ diff --git a/software/tools/glass.jar b/software/tools/glass.jar deleted file mode 100755 index db07912..0000000 Binary files a/software/tools/glass.jar and /dev/null differ diff --git a/software/tools/make_cpmdisks.sh b/software/tools/make_cpmdisks.sh deleted file mode 100755 index 9fdbd11..0000000 --- a/software/tools/make_cpmdisks.sh +++ /dev/null @@ -1,271 +0,0 @@ -#!/bin/bash -######################################################################################################### -## -## Name: make_cpmdisks.sh -## Created: January 2020 -## Author(s): Philip Smart -## Description: Script to build CPM Disks for the MZ80A -## This is a very basic script to assemble all the CPM source disks into a format -## which can be read by the MZ80A version of CPM. -## The source is composed of directories of actual original CPM disk contents which have -## been assembled or copied from original floppies by people on the internet. -## Credit goes to Grant Searle for the CPM_MC series of disks which can be found on his -## multicomputer project and to the various CPM archives on the net. -## Credits: -## Copyright: (c) 2020-2023 Philip Smart -## -## History: Jan 2020 - Initial script written. -## May 2020 - Updated to allow 240/320K Rom RFS images to be built -## -######################################################################################################### -## This source file is free software: you can redistribute it and#or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This source file is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -######################################################################################################### - -# These two variables configure which CPM images and disks to build. If only 1 CPM_RFS ROM Drive is needed, -# remove it fro the lists. -#BUILDCPMLIST="cpm22 CPM_RFS_1" -BUILDCPMLIST="cpm22 CPM_RFS_1 CPM_RFS_2 sdtest" -#SOURCEDIRS="CPM_RFS_[1] CPM[0-9][0-9]_* CPM_MC_5 CPM_MC_C? CPM_MC_D? CPM_MC_E? CPM_MC_F? CPM[0-9][0-9]_MZ800*" -SOURCEDIRS="CPM_RFS_[1-2] CPM[0-9][0-9]_* CPM_MC_5 CPM_MC_C? CPM_MC_D? CPM_MC_E? CPM_MC_F? CPM[0-9][0-9]_MZ800*" - -ROOTDIR=`realpath ../../MZ80A_RFS` -CPM_PATH=${ROOTDIR}/software/CPM -ROMDIR=${ROOTDIR}/software/roms # Compiled or source ROM files. -MZFDIR=${ROOTDIR}/software/MZF/Common # MZF Format source files. -HDRDIR=${ROOTDIR}/software/hdr # MZF Header directory for building images. -MZBDIR=${ROOTDIR}/software/MZB/Common # MZF Binary sectored output files to go into ROMS. -DISKSDIR=${ROOTDIR}/software/disks # MZF Binary sectored output files to go into ROMS. -ROMRFSDIR=${ROOTDIR}/software/CPM/ROMRFS/RAW # ROM RFS Drive raw image. -FD1M44_PATH=${CPM_PATH}/1M44 -FD1M44_CYLS=80 -FD1M44_HEADS=2 -FD1M44_SECTORS=36 -FD1M44_GAP3=78 -FD1M44_INTERLEAVE=4 -ROMRFS_PATH=${CPM_PATH}/ROMRFS -ROMRFS_CYLS=20 # Set to 15 for a 240K disk, 20 for a 320K disk -ROMRFS_HEADS=1 -ROMRFS_SECTORS=128 -ROMRFS_GAP3=78 -ROMRFS_INTERLEAVE=1 - -SDC16M_PATH=${CPM_PATH}/SDC16M -SDC16M_CYLS=1024 -SDC16M_HEADS=1 -SDC16M_SECTORS=32 -SDC16M_GAP3=78 -SDC16M_INTERLEAVE=1 -#BLOCKSIZELIST="256 512 1024 4096" # List of required output files in target RFS sector size. -BLOCKSIZELIST="128 256" # List of required output files in target RFS sector size. -MAXIMAGESIZE=524288 # Largest expected image size (generally 1 ROM less 16K Rom Banks). - -echo "Creating CPM Disks from all the directories in:$CPM_PATH} matching this filter:${SOURCEDIRS}.." -(cd ${CPM_PATH} - rm -f ${ROMRFS_PATH}/RAW/*.RAW - rm -f ${FD1M44_PATH}/RAW/*.RAW - rm -f ${FD1M44_PATH}/DSK/*.DSK - rm -f ${SDC16M_PATH}/RAW/*.RAW - rm -f ${SDC16M_PATH}/DSK/*.DSK - for src in ${SOURCEDIRS} - do - # Different processing for the ROM RFS drives. - if [[ ${src} == "CPM_RFS"* ]]; then - - # If the directory exists then build the ROM Drive image. - if [ -d ${src} ]; then - - # Print out useful information so capactity can be seen on the ROM drive. - echo "Building ROM Drive:${src}...Size:`du -sh --apparent-size ${src} | cut -f1`, Dir Entries:`ls -l ${src} | wc -l`" - - # Copy a blank image to create the new disk. - if [[ ${ROMRFS_CYLS} == 15 ]]; then - echo "Creating 240K ROM RFS Drive Image..." - cp ${CPM_PATH}/BLANKFD/BLANK_240K.RAW ${ROMRFS_PATH}/RAW/${src}.RAW; - - # Copy the CPM files from the linux filesystem into the CPM Disk under the CPM filesystem. - cpmcp -f MZ80A-RFS ${ROMRFS_PATH}/RAW/${src}.RAW ${CPM_PATH}/${src}/*.* 0: - elif [[ ${ROMRFS_CYLS} == 20 ]]; then - echo "Creating 320K ROM RFS Drive Image..." - cp ${CPM_PATH}/BLANKFD/BLANK_320K.RAW ${ROMRFS_PATH}/RAW/${src}.RAW; - - # Copy the CPM files from the linux filesystem into the CPM Disk under the CPM filesystem. - cpmcp -f MZ80A-RFS-320 ${ROMRFS_PATH}/RAW/${src}.RAW ${CPM_PATH}/${src}/*.* 0: - else - echo "ROMRFS config error, ROMRFS_CYLS should = 15 or 20" - exit 1 - fi - fi - else - # Place size of disk in the name, useful when using the Floppy Emulator. - NEWDSKNAME=`echo ${src} | sed 's/_/_1M44_/'` - - # Copy a blank image to create the new disk. - cp ${CPM_PATH}/BLANKFD/BLANK_1M44.RAW ${FD1M44_PATH}/RAW/${NEWDSKNAME}.RAW; - - # Copy the CPM files from the linux filesystem into the CPM Disk under the CPM filesystem. - cpmcp -f MZ80A-1440 ${FD1M44_PATH}/RAW/${NEWDSKNAME}.RAW ${CPM_PATH}/${src}/*.* 0: - - # Convert the raw image into an Extended DSK format suitable for writing to a Floppy or using with the Lotharek HxC Floppy Emulator. - samdisk copy ${FD1M44_PATH}/RAW/${NEWDSKNAME}.RAW ${FD1M44_PATH}/DSK/${NEWDSKNAME}.DSK --cyls=${FD1M44_CYLS} --head=${FD1M44_HEADS} --gap3=${FD1M44_GAP3} --sectors=${FD1M44_SECTORS} --interleave=${FD1M44_INTERLEAVE} - fi - done - - # Build the SD Card images, these images differ as they are larger and combine more programs in one disk under different user numbers. - - # Copy a blank image to create the new disk. - cp ${CPM_PATH}/BLANKFD/BLANK_16M.RAW ${SDC16M_PATH}/RAW/SDCDISK1.RAW; - - # Copy the CPM files from the linux filesystem into the CPM Disk under the CPM filesystem. - cp ${CPM_PATH}/BLANKFD/BLANK_16M.RAW ${SDC16M_PATH}/RAW/SDCDISK0.RAW; - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM00_SYSTEM/*.* 0: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM01_TURBOP/*.* 1: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM02_HI_C/*.* 2: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM03_FORTRAN80/*.* 3: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM04_MBASIC/*.* 4: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM05_COBOL80_v13/*.* 5: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM06_COBOL80_v20/*.* 6: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM07_COBOL80/*.* 7: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM08_Z80FORTH/*.* 8: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM09_CPMTEX/*.* 9: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM10_DISKUTILFUNC5/*.* 10: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM11_MAC80/*.* 11: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM29_ZSID_v14/*.* 12: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM32_ZCPR3/*.* 13: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK0.RAW ${CPM_PATH}/CPM33_ZCPR3_COMMON/*.* 14: - - cp ${CPM_PATH}/BLANKFD/BLANK_16M.RAW ${SDC16M_PATH}/RAW/SDCDISK1.RAW; - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM12_PASCALMTP_v561/*.* 0: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM26_TPASCAL_v300a/*.* 1: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM13_MTPUG_01/*.* 2: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM14_MTPUG_02/*.* 3: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM15_MTPUG_03/*.* 4: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM16_MTPUG_04/*.* 5: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM17_MTPUG_05/*.* 6: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM18_MTPUG_06/*.* 7: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM19_MTPUG_07/*.* 8: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM20_MTPUG_08/*.* 9: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM21_MTPUG_09/*.* 10: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK1.RAW ${CPM_PATH}/CPM22_MTPUG_10/*.* 11: - - cp ${CPM_PATH}/BLANKFD/BLANK_16M.RAW ${SDC16M_PATH}/RAW/SDCDISK2.RAW; - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK2.RAW ${CPM_PATH}/CPM23_PLI/*.* 0: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK2.RAW ${CPM_PATH}/CPM24_PLI80_v13/*.* 1: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK2.RAW ${CPM_PATH}/CPM25_PLI80_v14/*.* 2: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK2.RAW ${CPM_PATH}/CPM28_PLM80/*.* 3: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK2.RAW ${CPM_PATH}/CPM27_WORDSTAR_v30/*.* 4: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK2.RAW ${CPM_PATH}/CPM31_WORDSTAR_v330/*.* 5: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK2.RAW ${CPM_PATH}/CPM30_WORDSTAR_v400/*.* 6: - - cp ${CPM_PATH}/BLANKFD/BLANK_16M.RAW ${SDC16M_PATH}/RAW/SDCDISK3.RAW; - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK3.RAW ${CPM_PATH}/CPM_MC_C0/*.* 0: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK3.RAW ${CPM_PATH}/CPM_MC_C1/*.* 1: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK3.RAW ${CPM_PATH}/CPM_MC_C2/*.* 2: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK3.RAW ${CPM_PATH}/CPM_MC_C3/*.* 3: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK3.RAW ${CPM_PATH}/CPM_MC_C4/*.* 4: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK3.RAW ${CPM_PATH}/CPM_MC_C5/*.* 5: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK3.RAW ${CPM_PATH}/CPM_MC_C6/*.* 6: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK3.RAW ${CPM_PATH}/CPM_MC_C7/*.* 7: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK3.RAW ${CPM_PATH}/CPM_MC_C8/*.* 8: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK3.RAW ${CPM_PATH}/CPM_MC_C9/*.* 9: - - cp ${CPM_PATH}/BLANKFD/BLANK_16M.RAW ${SDC16M_PATH}/RAW/SDCDISK4.RAW; - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK4.RAW ${CPM_PATH}/CPM_MC_D0/*.* 0: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK4.RAW ${CPM_PATH}/CPM_MC_D1/*.* 1: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK4.RAW ${CPM_PATH}/CPM_MC_D2/*.* 2: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK4.RAW ${CPM_PATH}/CPM_MC_D3/*.* 3: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK4.RAW ${CPM_PATH}/CPM_MC_D4/*.* 4: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK4.RAW ${CPM_PATH}/CPM_MC_D5/*.* 5: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK4.RAW ${CPM_PATH}/CPM_MC_D6/*.* 6: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK4.RAW ${CPM_PATH}/CPM_MC_D7/*.* 7: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK4.RAW ${CPM_PATH}/CPM_MC_D8/*.* 8: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK4.RAW ${CPM_PATH}/CPM_MC_D9/*.* 9: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK4.RAW ${CPM_PATH}/CPM_MC_D9/*.* 9: - - cp ${CPM_PATH}/BLANKFD/BLANK_16M.RAW ${SDC16M_PATH}/RAW/SDCDISK5.RAW; - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK5.RAW ${CPM_PATH}/CPM_MC_E0/*.* 0: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK5.RAW ${CPM_PATH}/CPM_MC_E1/*.* 1: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK5.RAW ${CPM_PATH}/CPM_MC_E2/*.* 2: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK5.RAW ${CPM_PATH}/CPM_MC_E3/*.* 3: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK5.RAW ${CPM_PATH}/CPM_MC_E4/*.* 4: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK5.RAW ${CPM_PATH}/CPM_MC_E5/*.* 5: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK5.RAW ${CPM_PATH}/CPM_MC_E6/*.* 6: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK5.RAW ${CPM_PATH}/CPM_MC_E7/*.* 7: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK5.RAW ${CPM_PATH}/CPM_MC_E8/*.* 8: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK5.RAW ${CPM_PATH}/CPM_MC_E9/*.* 9: - - cp ${CPM_PATH}/BLANKFD/BLANK_16M.RAW ${SDC16M_PATH}/RAW/SDCDISK6.RAW; - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK6.RAW ${CPM_PATH}/CPM_MC_F0/*.* 0: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK6.RAW ${CPM_PATH}/CPM_MC_F1/*.* 1: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK6.RAW ${CPM_PATH}/CPM_MC_F2/*.* 2: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK6.RAW ${CPM_PATH}/CPM_MC_F3/*.* 3: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK6.RAW ${CPM_PATH}/CPM_MC_F4/*.* 4: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK6.RAW ${CPM_PATH}/CPM_MC_F5/*.* 5: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK6.RAW ${CPM_PATH}/CPM_MC_F6/*.* 6: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK6.RAW ${CPM_PATH}/CPM_MC_F7/*.* 7: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK6.RAW ${CPM_PATH}/CPM_MC_F8/*.* 8: - cpmcp -f MZ80A-SDC16M ${SDC16M_PATH}/RAW/SDCDISK6.RAW ${CPM_PATH}/CPM_MC_F9/*.* 9: -) - -# Create the CPM boot image and Drive images. -echo "Building CPM images..." -> /tmp/filelist -for f in ${BUILDCPMLIST} -do - if [ -f "${ROMDIR}/${f}.rom" ]; then - CPMIMAGE="${ROMDIR}/${f}.rom" - elif [ -f "${DISKSDIR}/${f}.RAW" ]; then - CPMIMAGE="${DISKSDIR}/${f}.RAW" - elif [ -f "${ROMRFSDIR}/${f}.RAW" ]; then - CPMIMAGE="${ROMRFSDIR}/${f}.RAW" - else - CPMIMAGE="" - echo "ALERT! ALERT! Couldnt find CPM image:${f}.RAW, not creating MZF file!" - fi - if [ "${CPMIMAGE}" != "" ]; then - # Building is just a matter of concatenating together the heaader and the rom image. - #echo "cat \"${HDRDIR}/${f}.hdr\" \"${CPMIMAGE}\" > \"${MZFDIR}/${f}.mzf\"" - cat "${HDRDIR}/${f}.hdr" "${CPMIMAGE}" > "${MZFDIR}/${f}.mzf" - - # Place the name of the file into the MZF list so that we create an MZF format binary from this image. - (cd ${MZFDIR}; ls -l ${f}.MZF ${f}.mzf 2>/dev/null | sed 's/ / /g' | sed 's/ / /g' | cut -d' ' -f5,9- >> /tmp/filelist 2>/dev/null) - fi -done - -# Build sectored images of the CPM Boot images and rom drives as they need to be stored in ROM in the RFS. -IFS=' '; while read -r FSIZE FNAME; -do - TNAME=`echo $FNAME | sed 's/mzf/MZF/g'` - if [ "$FNAME" != "$TNAME" ]; then - mv "${MZFDIR}/$FNAME" "${MZFDIR}/$TNAME" - fi - for BLOCKSIZE in ${BLOCKSIZELIST} - do - for SECTORSIZE in `seq -s ' ' ${BLOCKSIZE} ${BLOCKSIZE} ${MAXIMAGESIZE}` - do - BASE=`basename "$TNAME" .MZF` - if [ `echo ${FSIZE} - ${SECTORSIZE} | bc` -le 0 ]; - then - echo "Generating sectored MZF image: $BASE $TNAME $SECTORSIZE to target:${MZBDIR}/$BASE.${BLOCKSIZE}.bin" - dd if=/dev/zero ibs=1 count=$SECTORSIZE 2>/dev/null | tr "\000" "\377" > "${MZBDIR}/${BASE}.${BLOCKSIZE}.bin" - dd if="${MZFDIR}/$TNAME" of="${MZBDIR}/${BASE}.${BLOCKSIZE}.bin" conv=notrunc 2>/dev/null - break; - fi - done - done -done -## -## History: January 2020 - Initial script written. -## March 2021 - Updates for the RFS v2.1 board. -## April 2021 - Removed the CPM ROM Drive functionality as it provided no benefit -## over SD card and SD cards are larger. -## -######################################################################################################### -## This source file is free software: you can redistribute it and#or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This source file is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -######################################################################################################### - -ROOTDIR=../../MZ80A_RFS -MZB_PATH=${ROOTDIR}/software/MZB -ROM_PATH=${ROOTDIR}/software/roms/ -ROM_LIST_FILE=/tmp/ROMLIST -SECTORSIZE=256 -#CPMDISKMODE=SPLIT -MZFTOOL=${ROOTDIR}/software/tools/mzftool.pl -MONITOR_ROM=/tmp/mrom.rom -USER_ROM_I=/tmp/user.rom -USER_ROM_II=/tmp/user2.rom -USER_ROM_III=/tmp/user3.rom - -# Monitor/User ROM 1/2/3 = empty. -> ${MONITOR_ROM} -> ${USER_ROM_I} -> ${USER_ROM_II} -> ${USER_ROM_III} - -# Create a file with a list of programs placed into the ROM. This list can then be used by the SD -# card script to ensure no duplication occurs when building the SD RFS program directory. -rm -f ${ROM_LIST_FILE} - -# Place the monitor roms into the MROM at the beginning for banked page usage. -echo "cat ${ROM_PATH}/monitor_sa1510.rom ${ROM_PATH}/monitor_80c_sa1510.rom ${ROM_PATH}/cbios.rom ${ROM_PATH}/rfs_mrom.rom ${ROM_PATH}/monitor_1z-013a.rom ${ROM_PATH}/monitor_80c_1z-013a.rom ${ROM_PATH}/ipl.rom ${ROM_PATH}/blank_mrom.rom > /tmp/mrom.rom" -cat ${ROM_PATH}/monitor_sa1510.rom ${ROM_PATH}/monitor_80c_sa1510.rom \ - ${ROM_PATH}/cbios.rom ${ROM_PATH}/rfs_mrom.rom \ - ${ROM_PATH}/monitor_1z-013a.rom ${ROM_PATH}/monitor_80c_1z-013a.rom \ - ${ROM_PATH}/ipl.rom ${ROM_PATH}/blank_mrom.rom \ - >> ${MONITOR_ROM} - -# Place the RFS rom into the User ROM at the beginning as it contains all the banked pages. -echo "cat ${ROM_PATH}/rfs.rom ${ROM_PATH}/cbios_bank1.rom ${ROM_PATH}/cbios_bank2.rom ${ROM_PATH}/cbios_bank3.rom ${ROM_PATH}/cbios_bank4.rom > ${USER_ROM_I}" -cat ${ROM_PATH}/rfs.rom ${ROM_PATH}/cbios_bank1.rom ${ROM_PATH}/cbios_bank2.rom \ - ${ROM_PATH}/cbios_bank3.rom ${ROM_PATH}/cbios_bank4.rom \ - >> ${USER_ROM_I} - -# For CPM, to be safe, we manually copy the required files rather than use the list below. The CP/M boot image must be in User ROM 1. -echo "cat ${MZB_PATH}/Common/cpm22.${SECTORSIZE}.bin >> ${USER_ROM_I}" -cat ${MZB_PATH}/Common/cpm22.${SECTORSIZE}.bin >> ${USER_ROM_I} - -# According to flag set above, either put the CPM Disks in the first ROM, or place one in each ROM allowing for better write spread and larger disks. -# -#if [ "${CPMDISKMODE}" != "SPLIT" ]; then -# # CPM RFS Disks currently only in User ROM. -# for f in 1 2 -# do -# if [ -f ${MZB_PATH}/Common/CPM_RFS_${f}.${SECTORSIZE}.bin ]; then -# echo "cat ${MZB_PATH}/Common/CPM_RFS_${f}.${SECTORSIZE}.bin >> ${USER_ROM_I}" -# cat ${MZB_PATH}/Common/CPM_RFS_${f}.${SECTORSIZE}.bin >> ${USER_ROM_I} -# basename "${f}" .${SECTORSIZE}.bin >> ${ROM_LIST_FILE} -# fi -# done -#else -# if [ -f ${MZB_PATH}/Common/CPM_RFS_1.${SECTORSIZE}.bin ]; then -# echo "cat ${MZB_PATH}/Common/CPM_RFS_1.${SECTORSIZE}.bin >> ${USER_ROM_I}" -# cat ${MZB_PATH}/Common/CPM_RFS_1.${SECTORSIZE}.bin >> ${USER_ROM_I} -# basename "${f}" .${SECTORSIZE}.bin >> ${ROM_LIST_FILE} -# fi -# -# if [ -f ${MZB_PATH}/Common/CPM_RFS_2.${SECTORSIZE}.bin ]; then -# echo "cat ${MZB_PATH}/Common/CPM_RFS_2.${SECTORSIZE}.bin >> ${USER_ROM_II}" -# cat ${MZB_PATH}/Common/CPM_RFS_2.${SECTORSIZE}.bin >> ${USER_ROM_II} -# basename "${f}" .${SECTORSIZE}.bin >> ${ROM_LIST_FILE} -# fi -#fi - -# Manually choose the programs you want installed into the ROMS. The files will be first placed into the USER ROM and when full into the -# Monitor ROM. Thus order is important if you want a particular program in a particular ROM. -# -# NB: A Double Hash (##) indicates a program found not to work on the Sharp MZ-80A. -# -ROM_INCLUDE="" -# -# Common -# -ROM_INCLUDE+="${MZB_PATH}/Common/sa-5510_rfs.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/basic_sa5510.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/basic_sa6510.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/msbasic_mz80a.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/msbasic_rfs40.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/msbasic_rfs80.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/sa-5510_compiler.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/bas_mod_v374.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/xpatch_5510_v2.2.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/basic_sp5025.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/basic_sp5030.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/basic_sp-5035mc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/solo_basic.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/basic_om-500.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/basic_om-1000.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/basic_om-1001.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/hu-basic_v1.3_k.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/hucompilmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/compiler_a2.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/express_compiler.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/k_a_converter.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/hisoft_pascal4.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/z80assembler2mc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/editor-assembler_sp2202mc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/zen.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/8048_cpu_disas.mc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/6502betrmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/6502demo2mc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/6502demomc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/fortransosz80.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/mz700_forth1.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/kniforth.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/tinylispmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/apollo_word_1.9mmc_.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/hucalc_80a_m.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/send-1.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/Common/apollo_chess_v2a.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/Common/5z009-1b.mzf:" -#ROM_INCLUDE+="${MZB_PATH}/Common/basic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/Common/cpm22.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/Common/cpm223.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/Common/sharpmz-test.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/Common/testtz.${SECTORSIZE}.bin:" -# -# MZ-80A -# -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/sa-6510.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/3-d_maze.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/80a_pencil.a2_c2.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/80a_pencil.a2_s.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/a-basic_sa-5510.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/adventuregame.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/air_lander.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/alien_attack.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/alien_attack_machinecode.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/alien_eagle.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/alligator.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/apollo_chess_v2a.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/basic80a.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/basic_sa-5510.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/basic.sa-5510.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/blocking.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/bouncing_ball.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/breakout.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/breakout_mc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/brickstop.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/bytesaver_sa5510.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/cells_and_serps.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/colony.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/cosmiad-a.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/cosmiad-k.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/cursedchamber.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/dcs_mz80a_append.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/dcs_mz80a_renum.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/defender(2).${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/defender.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/defender_bizzarri.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/diamond.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/digger.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/dog_and_flea.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/dog_star_2.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/duck_shoot.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/epidemic.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/escape.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/escape_force.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/flying_mission.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/forest_of_doom.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/fruit_machine.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/galaxy_invaders.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/greedy_gremlins.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/hangman2.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/horse_race2.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/hucalc_80a_c2.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/hucalc_80a_m.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/hucalc_80a_s.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/land_escape.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/laser_defence.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/le_mans.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/ludo.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/lunarlander.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/mad_max_2.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/man-hunt.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/m_c_breakout_2.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/m_c_race_chase.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/minotaur.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/missile_attack.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/munchers_2.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/MZ-80A_galactic.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/navvy.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/new_invaders.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/noughts_crosses.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/numbercrunch.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/obstacles.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/pinball.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/puckman.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/qbert.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/quest.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/race_chase.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/ribbit_v2.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/sa-5510_compiler.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/sa-5510_kn.comm.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/sargon_2.71.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/scramble_a.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/send-1.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/serendipity.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/ski_run.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/space_combat.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/space_fighter.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/space_invaders.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/spooks.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/starship_mk2.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/star_wars.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/super_tilt.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/the_lily_pond.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/the_meanies.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/tunnel_run.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/ufo.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/wiggly_worm.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80A/witches.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80A/xpatch_5510_v2.2.${SECTORSIZE}.bin:" -# -# MZ-80K -# -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/3dspacecbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/3-d_way_out_bbg_software.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/6502betrmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/6502demo2mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/6502demomc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/8048_cpu_disas.mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/a-basic_sa-5510.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/abenteuebasic.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/advance-guardmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/advance_guard_wics_1983.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/aimemc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/alienmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/andromedamc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/apollo_word_1.9mmc_.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/ascii_gamebasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/atcf_datamc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/attackerscramblemc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/barcode_reader_1basic.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/barcode_reader_2basic.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/barcode_reader_3basic.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/barcode_reader_4basic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/base_ballbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/baseballbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/basic_sp-5035mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/block_kuzushimc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/bomberbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/bomberman_hudson_soft_1983.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/boueisakusenbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/boxing_mzmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/breakout_sharp_corporation.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/bugfire_1.1_wics.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/bugfire-newmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/bugfire-oldmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/bugfire_wics.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/cannon_ball_hudson_soft_1983.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/car-racemc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/clever_cribber.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/code_hu_convertmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/cosmic_cruiser1mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/cosmic_cruiser2mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/cosmic_cruiser3pr1mc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/cowboy_duelmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/crazy-climber_pt1mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/crazy-climber_pt2mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/crystallmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/daikaisenbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/d-day_sharp_corporation.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/defendermc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/defend_the_citybasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/don_chackbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/donkey_derby.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/editor-assembler_sp2202mc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/elektronic_musicmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/empire_climbermc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/empire_climber_wics.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/executivebasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/f-1_racemc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/fdcontromc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/filecardmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/form_map-listmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/formmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/forth_simulatorbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/fortressmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/galacticabasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/galaxianbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/gens3_1mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/gokiburibasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/goldminebasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/gomokumc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/hat_the_boxbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/home_budget_mk2basic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/hucompilermc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/hucompilmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/identi-kit.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/jampacmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/jintorimc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/jumping_bunnymc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/ladybugmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/laser_commandmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/loaderckmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/lunar_lander.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/lunar_landingmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/machine_language_sp2001mc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/machin_lang.monmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/mannenbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/master_mindbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/mazemanmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/micropedemc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/minotaur's_cavemc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/miz-mazebasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/mogurabasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/monaco-gpmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/monitormc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/monitorrmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/munchiesmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/nautic_crisisbasic.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/neptunmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/notutoribasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/nsc-rallymc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/one_key_organmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/othellomc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/otori_attackmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/pacmanmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/pascal_sp-6610mc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/phoenixmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/printmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/puckmanmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/racemc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/ralleymc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/ranger_specialpacmanmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/sargonchessmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/scashbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/schlogesmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/scramble.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/scramblemc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/shooting-ufobasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/shougibasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_defendermc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_drivescramblemc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_fighter_sharp_corporation_1979.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_invader1mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_invader.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_invader2intro-jpnmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_invader2no_intromc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_invader3mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_invader4mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space-invadermc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_mouse2mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_mousemc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_mouse_wics.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_panicmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_ruinerdeffendermc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/space_ruiner_wics_1982.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/spider_maze.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/startrekbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/star_trek_jpnbasic.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/star_trek_sharp_corporation.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/star_warsmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/star-warsmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/stoneworldbasic.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/sub-monitor_48kmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/superdefendermc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/super-monitormc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/supertargmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/superwurmmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/survivemc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/tankwarmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/tapecopymc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/ten-pin_bowling.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/test_match.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/the_munchies_c_smith.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/time_bombbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/tinylispmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/tomahawk_hiroshi_masuko.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/tomahawkmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/toweringmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/trapmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/turtlegdemo1mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/turtlegdemo2mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/turtle-grafikmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/tycoonbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/ubootjagmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/ufo_cavesmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/ufo_huntermc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/undameshibasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/videoflippermc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/view-findermc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/view_finder_wics_1983.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/vikingmc.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-80K/voicemc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/war_of_conbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/westernmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/western_wics_1983.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/wilhelm-tellmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/willhelm_tellmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/yakyukenbasic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/z80assembler2mc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/zardosmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/zardos_mz_soft_group.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/zeichengmc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-80K/zeroidmc.${SECTORSIZE}.bin:" -# -# MZ-700 -# -ROM_INCLUDE+="${MZB_PATH}/MZ-700/1z-013b.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/2z009e.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/3-d_car_race.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/3-d_graphikpaket.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/3dmuehle.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/3d-way_out.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/6502_betriebssys.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/700_poker.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/ace_racer.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/advancedchess.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/airbus_a_310.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/aliens.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/amityville.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/antares.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/anthill_raider.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/apollo.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/apollo2_8-200785.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/apprentissage_nombres.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/asteroid_belt.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/astro-blaster.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/attack-a-tank.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/auto_run.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/backgammon.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/bas700tutorial.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/basezero.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/basic_1z-013b.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/basic_700-vers.4.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/basic_mz-5z008_2.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/basic_mz-5z008.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/battle_game.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/bio-700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/blastoff.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/bloktekeningen.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/bomberman_mz700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/boulder_dash.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/breuken_1.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/cadre_diabolique.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/calendrier.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/cannon_ball.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/catacombes.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/caterpillar.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/centro-anl.disk.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/centro-anleitung.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/circus_star.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/club_golf.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/c-master.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/codewoord.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/commando_plain.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/competitie.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/comput-a-slot.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/computertekenen.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/connect_four.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/converter_a_700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/conveyor.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/copy-cf.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/cosmo_blaster_mz700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/cribbage.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/croaker.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/cyfax.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/database_filer.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/datei_universal.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/dbp-701.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/delete.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/demasaso.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/demo-lissajou.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/demo_sin-berg.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/descente_aux_enfers.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/destructeurs.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/domination.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/donkey_gorilla.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/exploding_atoms.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/express_bas_700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/f1200.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/fantastic_grove.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/fdcopy.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/fd_editor_mz700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/fighter_command.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/fire!!!.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/fisherman_fred.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/flugsim_mz700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/flugsimulator.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/fortransosz80.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/full_speed.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/gate-crasher.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/gdp9-ba.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/geboortedatum.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/global_war_3.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/globule.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/gobbler.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/greedy_gremlins.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/grid.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/guerre_spatiale.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/hdc_orgel.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/hp4tmz7.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/hp4tmz7l.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/hunchy.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/impossible_mission.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/isola.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/jeux_intergalactiques.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/jumping_runner.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/jungle-jinks.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/kalender.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/kamertje.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/kasboek.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/k-basic_v.5.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/kentucky_derby.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/kniforth.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/knight's_castle.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/knights_ufo.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/kp_dbasic.800b.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/k.s.m._pt._1.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/k.s.m._pt._2.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/k.s.m._pt._3.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-700/kuma_interpr..${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/kup80z354.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/kup80z355.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/lady-bug.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/land_escape.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/le_mans.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/lightning_patrol.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/lijnenspel.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/logo_v30.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/mac_pac.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/mad_maze.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/man-hunt.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/manza.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/mastermind.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/math_pendu.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/maze_escape.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/messing.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/mission_a.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/mission_alpha.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/mission_delta.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/ml-sp_8002_bbg.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/moleatta.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/monitor.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/monitor3.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/monitor6.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/morpion.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/morpius.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/moty.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/moving_searcher.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/mucmac700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/munroe_manor.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/music.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/musique_suisse.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/mz-1p01.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/mz-2z009.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/mz700bas.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/MZ-700_demo.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/mz700_forth1.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/MZ-700_forth.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/MZ-700_klavier.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/MZ-700_plot.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/nakamoto.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/nakamoto_mz700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/nibbler_part1.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/nibbler_part2.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/nightmare_park2.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/nightmare_park.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/nightm_prk.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/nite_flite.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/octopussy.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/pac-man.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/painful_man.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/panique.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/para_shoot.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/pascal_sp-4015.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/pascal_sp-4015_c.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/patrol_alpha.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/pcgaid.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/pcgaid_europe.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/pcg_basic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/pcg_basic_mz700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/pendu.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/printerfiguren1.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/puissance_4.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/puzzle.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/qd_bas_5z008_mz700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/qdcopy.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/qd-pascal_c.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/quixi.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/realfort.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/rebond.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/rescue_plane.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/reverse.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/rollsroyce1906.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/round_shoot.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/safe-cracker.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/s-basic-cent-2.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/s-basic-comp-cnt.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/s-basic-compiler.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/s-basic-compiler-original.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/s-basicode_2.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/schach2_mz700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/schach700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/send-1.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/send-1_mz700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/sh7ced1.3g.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/shogun.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/sky_chaos.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/s-master.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/snake-and-snake.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/snake_snake_exp1.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/soudard.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/south_pacific.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/space_fighter.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/space_guerilla.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/space_invaders.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/spa_data.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/squash_700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/star_fighter.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/startrek.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/stkeeper2bas700a.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/strip_poker.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/submarine_shooter.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/sub-monitor-700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/suicide_run.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/super-bandit.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/super_biorhythm.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/super_helicopter.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/super_puck-man.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/super_spy_obj.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/supertypen.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/super_vrac.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/sutam1f.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/sutamc9.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/sutapeba.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/sutapemo.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/systeme_expert.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/tapeworm.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/tbasic_bm_pk.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/t-basic_(uitleg).${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/telefontarieven.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/three_card_brag.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/tomahawk.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/tracker.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/trans.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/trucker.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/typen.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/ufo.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/uni700basic.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/urania_ii.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/uras-700.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/vicious_viper.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/vol_676.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/vragendmaken.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/wizard_castle.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/wonderhouse.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/wookya.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/wookyb.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/xanagrams.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/xbc.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/xbc_f_1_02.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/yams.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/MZ-700/z80_desassembleur.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/MZ-700/zen.${SECTORSIZE}.bin:" - -# Set the pointer which indicates the next ROM to be filled with applications. -GENROM=0 - -IFS=":"; for f in ${ROM_INCLUDE} -do - if [ -f ${f} ]; then - - # Identify type of file. - ${MZFTOOL} --command=IDENT --mzffile=${f} >/dev/null - FILETYPE=$? - - if [ ${FILETYPE} == 1 ]; then - - # Fill the User ROM as these get listed first. - if (( ${GENROM} == 0 )); then - cat ${USER_ROM_I} "${f}" > /tmp/tmp.size - FILESIZE=$(stat -c%s "/tmp/tmp.size") - if (( ${FILESIZE} < 524288 )); then - echo "Adding $f to User I Rom" - cat "${f}" >> ${USER_ROM_I} - basename "${f}" .${SECTORSIZE}.bin >> ${ROM_LIST_FILE} - else - GENROM=1 - fi - fi - - if (( ${GENROM} == 1 )); then - cat ${MONITOR_ROM} "${f}" > /tmp/tmp.size - FILESIZE=$(stat -c%s "/tmp/tmp.size") - if (( ${FILESIZE} < 524288 )); then - echo "Adding $f to Monitor Rom" - cat "${f}" >> ${MONITOR_ROM} - basename "${f}" .${SECTORSIZE}.bin >> ${ROM_LIST_FILE} - else - GENROM=2 - fi - fi - - # User ROM II and III are optional. - if (( ${GENROM} == 2 )); then - cat ${USER_ROM_II} "${f}" > /tmp/tmp.size - FILESIZE=$(stat -c%s "/tmp/tmp.size") - if (( ${FILESIZE} < 524288 )); then - echo "Adding $f to User II Rom" - cat "${f}" >> ${USER_ROM_II} - basename "${f}" .${SECTORSIZE}.bin >> ${ROM_LIST_FILE} - else - GENROM=3 - fi - fi - - if (( ${GENROM} == 3 )); then - cat ${USER_ROM_III} "${f}" > /tmp/tmp.size - FILESIZE=$(stat -c%s "/tmp/tmp.size") - if (( ${FILESIZE} < 524288 )); then - echo "Adding $f to User III Rom" - cat "${f}" >> ${USER_ROM_III} - basename "${f}" .${SECTORSIZE}.bin >> ${ROM_LIST_FILE} - else - GENROM=4 - fi - fi - - if (( ${GENROM} == 4 )); then - echo "Limit reached ROMS full, skipping from ${f}..." - break - fi - else - echo "File:${f},Type:${FILETYPE} is not machine code, skipping.." - fi - else - echo "ALERT! File:${f} not found." - fi -done -if [ -f ${USER_ROM_I} ]; then - mv ${USER_ROM_I} ${ROM_PATH}/USER_ROM_${SECTORSIZE}.bin - FILESIZE=$(stat -c%s "${ROM_PATH}USER_ROM_${SECTORSIZE}.bin") - echo "USER ROM I SIZE (${ROM_PATH}USER_ROM_${SECTORSIZE}.bin) = ${FILESIZE} Bytes" -fi -if [ -f ${USER_ROM_II} ]; then - mv ${USER_ROM_II} ${ROM_PATH}/USER_ROM_II_${SECTORSIZE}.bin - FILESIZE=$(stat -c%s "${ROM_PATH}USER_ROM_II_${SECTORSIZE}.bin") - echo "USER ROM II SIZE (${ROM_PATH}USER_ROM_II_${SECTORSIZE}.bin) = ${FILESIZE} Bytes" -fi -if [ -f ${USER_ROM_III} ]; then - mv ${USER_ROM_III} ${ROM_PATH}/USER_ROM_III_${SECTORSIZE}.bin - FILESIZE=$(stat -c%s "${ROM_PATH}USER_ROM_III_${SECTORSIZE}.bin") - echo "USER ROM III SIZE (${ROM_PATH}USER_ROM_III_${SECTORSIZE}.bin) = ${FILESIZE} Bytes" -fi -if [ -f ${MONITOR_ROM} ]; then - mv ${MONITOR_ROM} ${ROM_PATH}/MROM_${SECTORSIZE}.bin - FILESIZE=$(stat -c%s "${ROM_PATH}/MROM_${SECTORSIZE}.bin") - echo "MROM SIZE (${ROM_PATH}/MROM_${SECTORSIZE}.bin) = ${FILESIZE} Bytes" -fi -exit 0 diff --git a/software/tools/make_sdcard.sh b/software/tools/make_sdcard.sh deleted file mode 100755 index de71bc0..0000000 --- a/software/tools/make_sdcard.sh +++ /dev/null @@ -1,254 +0,0 @@ -#!/bin/bash -######################################################################################################### -## -## Name: make_sdcard.sh -## Created: August 2018 -## Author(s): Philip Smart -## Description: Sharp MZ series SD Card Packaging tool -## This is a very basic script to package programs into images for writing onto an -## SD Card as used in the Rom Filing System. The image is comprised of several parts, -## ie. + .. . -## -## Credits: -## Copyright: (c) 2020-23 Philip Smart -## -## History: March 2020 - Initial script written. -## March 2021 - Updated the file list and filter out files stored in the ROM Drives. -## -######################################################################################################### -## This source file is free software: you can redistribute it and#or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This source file is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -######################################################################################################### - -ROOTDIR=../../MZ80A_RFS -MZF_PATH=${ROOTDIR}/software/MZF -TOOL_DIR=${ROOTDIR}/software/tools -IMAGE_DIR=${ROOTDIR}/software/roms -CPM_DIR=${ROOTDIR}/software/CPM/SDC16M/RAW -SDTOOL=${TOOL_DIR}/sdtool -RFS_IMAGE_FILE=${IMAGE_DIR}/SHARP_MZ80A_RFS_IMAGE_ -RFS_IMAGE_EXT=img -RFS_IMAGE_DRIVES=10 -RFS_IMAGE_DRIVE_LIST=`seq -s ' ' 0 $((${RFS_IMAGE_DRIVES}-1))` -CPM_IMAGE_FILES="SDCDISK0.RAW SDCDISK1.RAW SDCDISK2.RAW SDCDISK3.RAW SDCDISK4.RAW SDCDISK5.RAW SDCDISK6.RAW" -SD_IMAGE_FILE=${IMAGE_DIR}/SHARP_MZ80A_RFS_CPM_IMAGE_1.img -ROM_LIST_FILE=/tmp/ROMLIST -MZFTOOL=${ROOTDIR}/software/tools/mzftool.pl - -# Function to add a given file/type into an RFS Drive. -function addFileToImage -{ - # Parameters. - local DRIVENO=$1 - local FILETYPE=$2 - local FORMAT=$3 - local FILEATTR=$4 - local FILTER=$5 - local FILENAME=$6 - local result=0 - - # Identify type of file. - ${MZFTOOL} --command=IDENT --mzffile=${FILENAME} >/dev/null - ft=$? - - # Use the File Type and ROM File List to filter out duplicates. - # - if [[ ${FILETYPE} == $ft ]] || [[ ${FORMAT} -eq 1 ]]; then - grep `basename "${FILENAME}" .mzf` ${ROM_LIST_FILE} > /dev/null - if [ $? -eq 1 -o ${FILTER} -eq 0 ]; then - - # Filter out CPM ROM Drive images. - if [[ "${FILENAME}" != *CPM22-DRV* ]] && [[ "${FILENAME}" != *CPM_RFS_* ]]; then - echo "Adding ${FILENAME} to RFS Drive:${DRIVENO}..." - - # Add according to format. - if [[ ${FORMAT} -eq 1 ]]; then - ${SDTOOL} --image ${RFS_IMAGE_FILE}${DRIVENO}.${RFS_IMAGE_EXT} --add ${FILENAME} --binary --exec-addr 0x1200 --attribute ${FILEATTR} - elif [[ ${FORMAT} -eq 0 ]]; then - ${SDTOOL} --image ${RFS_IMAGE_FILE}${DRIVENO}.${RFS_IMAGE_EXT} --add ${FILENAME} - else - echo "Unrecognised File Type Format, 0 = MZF, 1 = Binary, aborting..." - result=12 - fi - result=$? - if [ $result -ne 0 ]; then - if [ $result = 60 ]; then - result=10 - else - echo "Failed to add:${FILENAME} into the RFS Drive Image:${RFS_IMAGE_FILE}${DRIVENO}.${RFS_IMAGE_EXT}, aborting." - result=11 - fi - fi - fi - fi - else - result=1 - fi - return $result -} - -# Function to add a directory of files belonging to a machine type to a given RFS image. Machine code files are added to the requested -# image, BASIC are added onto drives 7..9 according to type. -# -function addMachineFiles -{ - # Parameters. - local DRIVENO=$1 - local SRCDIR=$2 - local FILTER=$3 - local FORMAT=$4 - local FILEATTR=$5 - local result=0 - - if [[ ${FORMAT} -eq 1 ]] && [[ "${SRCDIR}" == "CAS" ]]; then - FILELIST=`(cd ${MZF_PATH}/${SRCDIR}; ls *.cas)` - elif [[ ${FORMAT} -eq 1 ]] && [[ "${SRCDIR}" == "BAS" ]]; then - FILELIST=`(cd ${MZF_PATH}/${SRCDIR}; ls *.bas)` - else - FILELIST=`(cd ${MZF_PATH}/${SRCDIR}; ls *.mzf)` - fi - - for f in ${FILELIST} - do - addFileToImage ${DRIVENO} 1 ${FORMAT} ${FILEATTR} ${FILTER} ${MZF_PATH}/${SRCDIR}/${f} - result=$? - if [[ ${result} -eq 1 ]] && [[ "${SRCDIR}" = "MZ-80A" ]]; then - addFileToImage 5 2 ${FORMAT} ${FILEATTR} ${FILTER} ${MZF_PATH}/${SRCDIR}/${f} - result=$? - fi - if [[ ${result} -eq 1 ]] && [[ "${SRCDIR}" = "MZ-80K" ]]; then - addFileToImage 6 2 ${FORMAT} ${FILEATTR} ${FILTER} ${MZF_PATH}/${SRCDIR}/${f} - result=$? - fi - if [[ ${result} -eq 1 ]] && [[ "${SRCDIR}" = "MZ-700" ]]; then - addFileToImage 7 5 ${FORMAT} ${FILEATTR} ${FILTER} ${MZF_PATH}/${SRCDIR}/${f} - result=$? - fi - if [[ ${result} -eq 1 ]] && [[ "${SRCDIR}" = "MZ-800" ]]; then - addFileToImage 7 5 ${FORMAT} ${FILEATTR} ${FILTER} ${MZF_PATH}/${SRCDIR}/${f} - result=$? - fi - if [ ${result} -ne 0 -a ${result} -ne 1 ]; then - echo "Failed to add file:${MZF_PATH}/${SRCDIR}/${f} to Drive:0, aborting for manual check." - result=1 - fi - done - return $result -} - -# Initialise the target SD image. -> ${SD_IMAGE_FILE} - -# Create the initial RFS drive images. -for d in ${RFS_IMAGE_DRIVE_LIST} -do - ${SDTOOL} --image ${RFS_IMAGE_FILE}${d}.${RFS_IMAGE_EXT} --create - if [ $? != 0 ]; then - echo "Failed to create RFS Drive Image:${RFS_IMAGE_FILE}${d}.${RFS_IMAGE_EXT}, aborting." - exit 1 - fi -done - -# There are upto 10 RFS Drives so the software is apportioned as follows: -# Drive Description -# ----- ----------- -# 0 Common and MZ-80A Machine Code programs. -# 1 MZ-80K Machine Code programs. -# 2 MZ-700 Machine Code programs. -# 3 MZ-800 Machine Code programs. -# 3 MZ-1500 Machine Code programs. -# 4 MZ-2000 Machine Code programs. -# 4 MZ-80B Machine Code programs. -# 5 BASIC programs, type 2 (MZ80A) -# 6 BASIC programs, type 2 (MZ80K) -# 7 BASIC programs, type 5 (MZ700/800) -# 8 MS-BASIC programs. -# 9 Other programs. -# -# Files are filtered out if they already exist in the Flash RAMS. The script make_roms.sh creates -# a list of files it adds into the Flash RAMS which is used by this script. -# NB: A maximum of 256 files can be added due to the limit of the RFS directory. -# -addMachineFiles 0 Common 0 0 1 -RESULT=$? -if [ ${RESULT} -eq 0 ]; then - addMachineFiles 0 MZ-80A 1 0 1 - RESULT=$? -fi -if [ ${RESULT} -eq 0 ]; then - addMachineFiles 1 MZ-80K 1 0 1 - RESULT=$? -fi -if [ ${RESULT} -eq 0 ]; then - addMachineFiles 2 MZ-700 1 0 1 - RESULT=$? -fi -if [ ${RESULT} -eq 0 ]; then - addMachineFiles 3 MZ-800 1 0 1 - RESULT=$? -fi -if [ ${RESULT} -eq 0 ]; then - addMachineFiles 3 MZ-1500 1 0 1 - RESULT=$? -fi -if [ ${RESULT} -eq 0 ]; then - addMachineFiles 4 MZ-2000 1 0 1 - RESULT=$? -fi -if [ ${RESULT} -eq 0 ]; then - addMachineFiles 4 MZ-80B 1 0 1 - RESULT=$? -fi -if [ ${RESULT} -eq 0 ]; then - addMachineFiles 8 CAS 1 1 126 - RESULT=$? -fi -if [ ${RESULT} -eq 0 ]; then - addMachineFiles 8 BAS 1 1 127 - RESULT=$? -fi -if [ ${RESULT} -ne 0 ]; then - echo "Aborting due to earlier errors..." - exit 1 -fi - -# Confirmation listing of the drives and contents. -IFS=" "; for d in ${RFS_IMAGE_DRIVE_LIST} -do - echo "RFS Drive: ${RFS_IMAGE_FILE}${d}.${RFS_IMAGE_EXT}" - ${SDTOOL} --image ${RFS_IMAGE_FILE}${d}.${RFS_IMAGE_EXT} --list-dir -done - -# Concatenate the RFS and CPM images to make a final SD card image. -# -IFS=" "; for d in ${RFS_IMAGE_DRIVE_LIST} -do - echo "Adding RFS Drive Image:${RFS_IMAGE_FILE}${d}.${RFS_IMAGE_EXT} to start of SD Card image." - cat ${RFS_IMAGE_FILE}${d}.${RFS_IMAGE_EXT} >> ${SD_IMAGE_FILE} -done -# Pad the file to 0x10000000 before adding CPM images. This takes into account the RFS Drives plus padding to a round address. -truncate -s 268435456 ${SD_IMAGE_FILE} -IFS=" "; for f in ${CPM_IMAGE_FILES} -do - echo "Adding CPM Drive Image:${f} to SD Card image." - cat ${CPM_DIR}/${f} >> ${SD_IMAGE_FILE} -done -echo "SD Card image generated, file:${SD_IMAGE_FILE}" -echo "" -echo "" -echo "Using a suitable tool, such as dd under Linux, copy the SD Card image onto an SD Card." -echo "ie. dd if=${SD_IMAGE_FILE} of=/dev/sdd bs=512" -echo "No disk partitioning is needed as the SDFS image starts at sector 0 on the SD Card." -echo "Once the image has been copied, place into the SD Card Reader on the RFS Board." - -exit 0 diff --git a/software/tools/mzfdc2 b/software/tools/mzfdc2 deleted file mode 100755 index aefe354..0000000 Binary files a/software/tools/mzfdc2 and /dev/null differ diff --git a/software/tools/mzftool.pl b/software/tools/mzftool.pl deleted file mode 100755 index 44db196..0000000 --- a/software/tools/mzftool.pl +++ /dev/null @@ -1,1147 +0,0 @@ -#! /usr/bin/perl -######################################################################################################### -## -## Name: mzftool.pl -## Created: August 2018 -## Author(s): Philip Smart -## Description: Sharp MZ series MZF (Sharp Tape File) management tool. -## This script identifies the type of MZF file and can add or delete headers as required. -## Useful for seperating MZF compilations into Basic/Pascal/Machine Code etc. -## Also useful to add headers to homegrow machine code programs. -## -## Credits: -## Copyright: (c) 2018-2023 Philip Smart -## -## History: August 2018 - Initial script written. -## March 2021 - Updated to fix MZF header files. Some programs have encoded ASCII -## into the header along with other strange characters, these need to -## be in Sharp ASCII format. -## February 2023 - POSIX::tmpnam obsolete, using File::Temp::tmpnam -## -######################################################################################################### -## This source file is free software: you can redistribute it and#or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This source file is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -######################################################################################################### - -# Title and Versioning. -# -$TITLE = "MZF Tool"; -$VERSION = "0.2"; -$VERSIONDATE = "23.03.2021"; - -# Global Modules. -# -#use strict -use Getopt::Long; -use IO::File; -use File::stat; -use File::Copy; -use Time::localtime; -use File::Temp qw(tmpnam); -use Env qw(KPLUSHOME3 SYBASE SYBASE_OCS DSQUERY); -use sigtrap qw(die normal-signals); - -# Error return codes. -# -$ERR_BADFILENAME = 1; -$ERR_BADFILEDATA = 2; -$ERR_BADFILECREATE = 3; -$ERR_BADFUNCARGS = 4; -$ERR_BADSYSCALL = 5; -$ERR_BADCHECK = 6; -$ERR_BADENV = 7; -$ERR_SYBSERVER = 8; -$ERR_BADARGUMENTS = 9; - -# Run-time constants. -# -$PROGNAME = $0; - -# Run-time globals. Although in Perl you can just specify variables, keeping with most -# high-order languages it is good practise to specify non-local variables in a global header -# which aids visual variable tracking etc. -# -$dbh = 0; # Handle to a Sybase object. -$logh = 0; # Handle to open log file. -$logName = ""; # Temporary name of log file. -$logMode = "terminal"; # Default logging mode for logger. - - -# Configurables!! -# -$SENDMAIL = "/usr/lib/sendmail -t"; -@errorMailRecipients = ( "philip.smart\@net2net.org" ); -$errorMailFrom = "error\@localhost"; -$errorMailSubject = "MZF Tool Errors..."; -$PERL = "perl"; -$PERLFLAGS = ""; - -# ASCII to Sharp Display Code mapping table. -@ASCIIToSharpCode = ( - 0xCC, # NUL '\0' (null character) - 0xE0, # SOH (start of heading) - 0xF2, # STX (start of text) - 0xF3, # ETX (end of text) - 0xCE, # EOT (end of transmission) - 0xCF, # ENQ (enquiry) - 0xF6, # ACK (acknowledge) - 0xF7, # BEL '\a' (bell) - 0xF8, # BS '\b' (backspace) - 0xF9, # HT '\t' (horizontal tab) - 0xFA, # LF '\n' (new line) - 0xFB, # VT '\v' (vertical tab) - 0xFC, # FF '\f' (form feed) - 0xFD, # CR '\r' (carriage ret) - 0xFE, # SO (shift out) - 0xFF, # SI (shift in) - 0xE1, # DLE (data link escape) - 0xC1, # DC1 (device control 1) - 0xC2, # DC2 (device control 2) - 0xC3, # DC3 (device control 3) - 0xC4, # DC4 (device control 4) - 0xC5, # NAK (negative ack.) - 0xC6, # SYN (synchronous idle) - 0xE2, # ETB (end of trans. blk) - 0xE3, # CAN (cancel) - 0xE4, # EM (end of medium) - 0xE5, # SUB (substitute) - 0xE6, # ESC (escape) - 0xEB, # FS (file separator) - 0xEE, # GS (group separator) - 0xEF, # RS (record separator) - 0xF4, # US (unit separator) - 0x00, # SPACE - 0x61, # ! - 0x62, # " - 0x63, # # - 0x64, # $ - 0x65, # % - 0x66, # & - 0x67, # ' - 0x68, # ( - 0x69, # ) - 0x6B, # * - 0x6A, # + - 0x2F, # , - 0x2A, # - - 0x2E, # . - 0x2D, # / - 0x20, # 0 - 0x21, # 1 - 0x22, # 2 - 0x23, # 3 - 0x24, # 4 - 0x25, # 5 - 0x26, # 6 - 0x27, # 7 - 0x28, # 8 - 0x29, # 9 - 0x4F, # : - 0x2C, # ; - 0x51, # < - 0x2B, # = - 0x57, # > - 0x49, # ? - 0x55, # @ - 0x01, # A - 0x02, # B - 0x03, # C - 0x04, # D - 0x05, # E - 0x06, # F - 0x07, # G - 0x08, # H - 0x09, # I - 0x0A, # J - 0x0B, # K - 0x0C, # L - 0x0D, # M - 0x0E, # N - 0x0F, # O - 0x10, # P - 0x11, # Q - 0x12, # R - 0x13, # S - 0x14, # T - 0x15, # U - 0x16, # V - 0x17, # W - 0x18, # X - 0x19, # Y - 0x1A, # Z - 0x52, # [ - 0x59, # \ '\\' - 0x54, # ] - 0xBE, # ^ - 0x3C, # _ - 0xC7, # ` - 0x81, # a - 0x82, # b - 0x83, # c - 0x84, # d - 0x85, # e - 0x86, # f - 0x87, # g - 0x88, # h - 0x89, # i - 0x8A, # j - 0x8B, # k - 0x8C, # l - 0x8D, # m - 0x8E, # n - 0x8F, # o - 0x90, # p - 0x91, # q - 0x92, # r - 0x93, # s - 0x94, # t - 0x95, # u - 0x96, # v - 0x97, # w - 0x98, # x - 0x99, # y - 0x9A, # z - 0xBC, # { - 0x80, # | - 0x40, # } - 0xA5, # ~ - 0xC0 # DEL -); - -# Sharp Display Code to ASCII mapping tables. -# -@SharpCodeToASCII = ( - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, # 0x0F - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, # 0x1F - 0x20, - 0x21, - 0x22, - 0x23, - 0x24, - 0x25, - 0x26, - 0x27, - 0x28, - 0x29, - 0x2A, - 0x2B, - 0x2C, - 0x2D, - 0x2E, - 0x2F, # 0x2F - 0x30, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x3A, - 0x3B, - 0x3C, - 0x3D, - 0x3E, - 0x3F, # 0x3F - 0x40, - 0x41, - 0x42, - 0x43, - 0x44, - 0x45, - 0x46, - 0x47, - 0x48, - 0x49, - 0x4A, - 0x4B, - 0x4C, - 0x4D, - 0x4E, - 0x4F, # 0x4F - 0x50, - 0x51, - 0x52, - 0x53, - 0x54, - 0x55, - 0x56, - 0x57, - 0x58, - 0x59, - 0x5A, - 0x5B, - 0x5C, - 0x5D, - 0x5E, - 0x5F, # 0x5F - 0x20, # 0x60 - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, # 0x6F - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, # 0x7F - - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, # 0x8F - - 0x20, - 0x20, - 0x65, - 0x20, - 0x20, - 0x20, - 0x74, - 0x67, - 0x68, - 0x20, - 0x62, - 0x78, - 0x64, - 0x72, - 0x70, - 0x63, # 0x9F - - 0x71, - 0x61, - 0x7A, - 0x77, - 0x73, - 0x75, - 0x69, - 0x20, - 0x4F, # O with umlaut - 0x6B, - 0x66, - 0x76, - 0x20, - 0x75, # u with umlaut - 0x42, # Strasse S - 0x6A, # 0XAF - - 0x6E, - 0x20, - 0x55, # U with umlaut - 0x6D, - 0x20, - 0x20, - 0x20, - 0x6F, - 0x6C, - 0x41, # A with umlaut - 0x6F, # o with umlaut - 0x61, # a with umlaut - 0x20, - 0x79, - 0x20, - 0x20, # 0xBF - - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, # 0XCF - - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, # 0XDF - - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, # 0XEF - - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20, - 0x20 # 0XFF -); - - -################################################################################## -# GENERIC SUB-ROUTINES -################################################################################## - -# Sub-routine to close the log file and email its contents to required participants. -# -sub logClose -{ - # Locals. - local( $idx, $line, @mailRecipients, $mailFrom, $mailSubject, $mailHeader ); - - # No point closing log if one wasnt created!! - # - if($logName eq "" || $sendEmail == 0) - { - return; - } - - # Back to beginning of file, to copy into email. - # - seek($logh, 0, 0); - - # Build up an email to required recipients and send. - # - open(SENDMAIL, "|$SENDMAIL") or die "Cannot open $SENDMAIL: $!"; - for($idx=0; $idx < @errorMailRecipients; $idx++) - { - print SENDMAIL "To: $errorMailRecipients[$idx]\n"; - } - print SENDMAIL "Reply-to: $errorMailFrom\n"; - print SENDMAIL "From: $errorMailFrom\n"; - print SENDMAIL "Subject: $errorMailSubject\n"; - print SENDMAIL "Content-type: text/plain\n\n"; - while( $line = <$logh> ) - { - chomp($line); - print SENDMAIL "$line\n"; - } - close(SENDMAIL); - - # Delete the logfile, not needed. - # - unlink($logName) or die "Couldn't unlink Error File $logName : $!"; -} - -# Function to write a message into a log file. The logfile is a temporary buffer, used -# to store all messages until program end. Upon completion, the buffer is emailed to required -# participants. -# -sub logWrite -{ - # Get parameters, define locals. - local( $mode, $text ) = @_; - local( $date ); - - # Get current date and time for timestamping the log message. - # - $date = `date +'%Y.%m.%d %H:%M:%S'`; - chomp($date); - - # In terminal mode (=interactive mode), always log to STDOUT. - # - if($logMode eq "terminal") - { - if(index($mode, "ND") == -1) - { - print "$date "; - } - print "$text"; - if(index($mode, "NR") == -1) - { - print "\n"; - } - - # Die if required. - # - if (index($mode, 'die') != -1) - { - print "$date Terminating at program request.\n"; - exit 1; - } - return; - } - - # If the logfile hasnt been opened, open it. - # - if($logName eq "") - { - # Try new temporary filenames until we get one that doesnt already exist. - do { - $logName = tmpnam(); - } until $logh = IO::File->new($logName, O_RDWR|O_CREAT|O_EXCL); - - # Automatically flush out log. - $logh->autoflush(1); - - # Only send email if we explicitly die. - # - $sendEmail = 0; - - # Install an atexit-style handler so that when we exit or die, - # we automatically dispatch the log. - END { logClose($logh, $logName); } - } - - # Print to log with date and time stamp. - # - print $logh "$date $text\n"; - - # Print to stdout for user view if in debug mode. - # - if($debugMode > 0) - { - print "$date $text\n"; - } - - # If requested, log termination message and abort program. - # - if (index($mode, 'die') != -1) - { - print $logh "$date Terminating at program request.\n"; - $sendEmail = 1; - exit 1; - } -} - -# Sub-routine to truncate whitespace at the front (left) of a string, returning the -# truncated string. -# -sub cutWhiteSpace -{ - local( $srcString ) = @_; - local( $c, $dstString, $idx ); - $dstString = ""; - - for($idx=0; $idx < length($srcString); $idx++) - { - # If the character is a space or tab, delete. - # - $c = substr($srcString, $idx, 1); - if(length($dstString) == 0) - { - if($c ne " " && $c ne "\t") - { - $dstString = $dstString . $c; - } - } else - { - $dstString = $dstString . $c; - } - } - return($dstString); -} - -# Perl trim function to remove whitespace from the start and end of the string -# -sub trim($) -{ - my $string = shift; - $string =~ s/^\s+//; - $string =~ s/\s+$//; - return $string; -} - -# Left trim function to remove leading whitespace -# -sub ltrim($) -{ - my $string = shift; - $string =~ s/^\s+//; - return $string; -} - -# Right trim function to remove trailing whitespace -# -sub rtrim($) -{ - my $string = shift; - $string =~ s/\s+$//; - return $string; -} - -# Sub-routine to test if a string is empty, and if so, replace -# with an alternative string. The case of the returned string -# can be adjusted according to the $convertCase parameter. -# -sub trString -{ - local( $tstString, $replaceString, $convertCase ) = @_; - local( $dstString ); - - $tstString=cutWhitespace($tstString); - $replaceString=cutWhitespace($replaceString); - if($tstString eq "") - { - $dstString = $replaceString; - } else - { - $dstString = $tstString; - } - - # Convert to Lower Case? - # - if($convertCase == 1) - { - $dstString =~ lc($dstString); - } - # Convert to Upper Case? - # - elsif($convertCase == 2) - { - $dstString =~ uc($dstString); - } - return($dstString); -} - -# Sub-routine to test if a numeric is empty, and if so, set to a -# given value. -# -sub trNumeric -{ - local( $tstNumber, $replaceNumber ) = @_; - local( $dstNumber ); - - if(!defined($tstNumber) || $tstNumber eq "" || cutWhitespace($tstNumber) eq "") - { - $dstNumber = $replaceNumber; - } else - { - $dstNumber = $tstNumber; - } - - return($dstNumber); -} - -# Function to look at a string and decide wether its contents -# indicate Yes or No. If the subroutine cannot determine a Yes, -# then it defaults to No. -# -sub yesNo -{ - local( $srcString ) = @_; - local( $dstString, $yesNo ); - $yesNo = "N"; - - $dstString=lc(cutWhiteSpace($srcString)); - if($dstString eq "y" || $dstString eq "yes" || $dstString eq "ye") - { - $yesNo = "Y"; - } - return( $yesNo ); -} - -# Sub-routine to encrypt an input string, typically a password, -# using the Collateral Management Encrypt utility. -# -sub encrypt -{ - local( $srcPasswd ) = @_; - local( $encPasswd ); - $encPasswd=""; - - # Call external function to perform the encryption. - # - if($srcPasswd ne "") - { - $encPasswd=`$PROG_ENCRYPT -p $srcPasswd 2>&1`; - chomp($encPasswd); - } - return($encPasswd); -} - -# Sub-routine to test if a string is empty, and if so, replace -# with an alternative string. The case of the returned string -# can be adjusted according to the $convertCase parameter. -# -sub testAndReplace -{ - local( $tstString, $replaceString, $convertCase ) = @_; - local( $dstString ); -#printf("Input:$tstString,$replaceString\n"); - $tstString=cutWhiteSpace($tstString); - $replaceString=cutWhiteSpace($replaceString); - if($tstString eq "") - { - $dstString = $replaceString; - } else - { - $dstString = $tstString; - } - - # Convert to Lower Case? - # - if($convertCase == 1) - { - $dstString =~ lc($dstString); - } - # Convert to Upper Case? - # - elsif($convertCase == 2) - { - $dstString =~ uc($dstString); - } -#printf("Output:$dstString:\n"); - return($dstString); -} - -# Subroutine to generate a unique name by adding 2 digits onto the end of it. A hash of existing -# names is given to compare the new value against. -# -sub getUniqueName -{ - local( $cnt, $uniqueName ) = ( 0, "" ); - local( $startName, $maxLen, $usedNames ) = @_; - - # Go through looping, adding a unique number onto the end of the string, then looking it - # up to see if it already exists. - # - $uniqueName = substr($startName, 0, $maxLen); - while(defined($$usedNames{$uniqueName})) - { - $uniqueName = substr($uniqueName, 0, $maxLen-2) . sprintf("%02d", $cnt); - $cnt++; - if($cnt > 99) - { - logWrite("die", "Unique identifier > 99: $uniqueName"); - } - } - - # Return unique name. - # - return($uniqueName); -} - -# Sub-routine to process command line arguments. New style POSIX argument format used. -# -sub argOptions -{ - local ( $writeUsage, $msg, $exitCode ) = @_; - - if( $writeUsage == 1 ) - { - print STDOUT "Usage: $PROGNAME [] \n"; - print STDOUT " commands= --help |\n"; - print STDOUT " --verbose |\n"; - print STDOUT " --command= |\n"; - print STDOUT " --mzffile= {IDENT|ADDHEADER|DELHEADER|FIXHEADER}|\n"; - print STDOUT " --srcfile= {ADDHEADER} |\n"; - print STDOUT " --dstfile= {DELHEADER|FIXHEADER} |\n"; - print STDOUT " --filename= (ADDHEADER} |\n"; - print STDOUT " --loadaddr= (ADDHEADER} |\n"; - print STDOUT " --execaddr= (ADDHEADER} |\n"; - print STDOUT " --tapetype=<1 byte type value> (ADDHEADER} |\n"; - print STDOUT " --comment= (ADDHEADER} |\n"; - print STDOUT " options = --debug=<1=ON, 0=OFF>\n"; - print STDOUT "\n"; - } - if($msg ne "") - { - print STDOUT "Error: $msg\n"; - } - exit( $exitCode ); -} - -# Method to map an ASCII standard character, as a value, into a Sharp ASCII value. -# -sub getSharpASCIICode -{ - local($matchChar) = @_; - $matchcnt = 0; - foreach (@SharpCodeToASCII) - { - if($matchChar eq $_) - { - return($matchcnt); - } - $matchcnt = $matchcnt + 1; - } - return(0xF0); -} - -################################################################################## -# END OF GENERIC SUB-ROUTINES -################################################################################## - - -################################################################################## -# -# MAIN PROGRAM -# -################################################################################## - -# Locals. -# -local( $time, $date, $mzfExists, $a_mromExists, $b_mromExists, $k_mromExists, $m7_mromExists, $m8_mromExists, $m12_mromExists, $m20_mromExists, - $a_80c_mromExists, $b_80c_mromExists, $k_80c_mromExists, $m7_80c_mromExists, $m8_80c_mromExists, $m12_80c_mromExists, $m20_80c_mromExists, - $mzf_type, $mzf_filename, $mzf_size, $mzf_loadaddr, $mzf_execaddr, $mzf_comment); - -# Get current time and date. -# -$time = `date +'%H:%M:%S'`; -$date = `date +'%d.%m.%Y'`; -chomp($time); -chomp($date); - -# Sign-on. -# -print STDOUT "$TITLE (v$VERSION) \@ ${VERSIONDATE}\n\n"; - -# Parse arguments and put into required variables. -# -$verbose = 0; -$fileName = ""; -$s_loadAddr = ""; -$s_execAddr = ""; -$s_tapeType = ""; -$comment = ""; -GetOptions( "debug=n" => \$debugMode, # Debug Mode? - "verbose" => \$verbose, # Show details? - "mzffile=s" => \$mzfFile, # MZF file. - "dstfile=s" => \$dstFile, # Destination file (for header removal or MZF file with updated header). - "srcfile=s" => \$srcFile, # Source file (for header adding). - "filename=s" => \$fileName, # Filename to insert into header. - "loadaddr=s" => \$s_loadAddr, # Tape load address. - "execaddr=s" => \$s_execAddr, # Tape execution address. - "tapetype=s" => \$s_tapeType, # Tape type (ie. 01 = Machine Code). - "comment=s" => \$comment, # Tape comment string. - "command=s" => \$command, # Command to execute. - "help" => \$help, # Help required on commands/options? - ); - -# Help required? -# -if(defined($help)) -{ - argOptions(1, ""); -} - -# Convert number arguments from string to decimal. -# -if($s_loadAddr ne "") -{ - $loadAddr = oct($s_loadAddr); -} -if($s_execAddr ne "") -{ - $execAddr = oct($s_execAddr); -} -if($s_tapeType ne "") -{ - $tapeType = oct($s_tapeType); -} - -# Verify command. -# -if($command eq "IDENT" || $command eq "ADDHEADER" || $command eq "DELHEADER" || $command eq "FIXHEADER") -{ - 1; -} -else -{ - argOptions(1, "Illegal command given on command line:$command.\n",$ERR_BADARGUMENTS); -} - -# Check that the additional parameters have been provided for the ADDHEADER command. -if($command eq "ADDHEADER" && ($fileName eq "" || !defined($loadAddr) || !defined($execAddr) || !defined($tapeType)) ) -{ - argOptions(3, "ADDHEADER command requires the following parameters to be provided: --filename, --loadaddr, --execaddr, --tapetype\n",$ERR_BADARGUMENTS); -} -if($command eq "FIXHEADER" && $dstFile eq "") -{ - argOptions(3, "FIXHEADER command requires the following parameter to be provided: --dstfile\n",$ERR_BADARGUMENTS); -} - -# For ident or delete header commands, we need to open and read the mzf file. -# -if(($command eq "IDENT" || $command eq "DELHEADER" || $command eq "FIXHEADER") && defined($mzfFile) && $mzfFile ne "") -{ - # If defined, can we open it? - # - if( ! open(MZFFILE, "<".$mzfFile) ) - { - argOptions(1, "Cannot open MZF file: $mzfFile.\n",$ERR_BADFILENAME); - } - - @MZF = (); - binmode(MZFFILE); - local $/ = \1; - $cnt = 0; - $skip = 0; - while ( my $byte = ) - { - $MZF[$cnt] = $byte; - $cnt++; - } - $MZF_SIZE = $cnt; - - # Once the MZF is in memory, analyse the details and output. - # - $mzf_header = pack('a'x24, @MZF); - ($mzf_type, $mzf_filename, $mzf_size, $mzf_loadaddr, $mzf_execaddr) = unpack 'c1 a17 v4 v4 v4 a104', $mzf_header; - # Comment is unpacked seperately as there appears to be a perl bug where the first char becomes 0 when unpacking in the above list. - $mzf_comment = pack('a'x104, @MZF[24..128]); - $mzf_filename =~ s/\r|\n//g; - - # Output detail if requested. - # - if($verbose) - { - printf STDOUT "File Name : %s\n", $mzf_filename; - printf STDOUT "File Type : %02x\n", $mzf_type; - printf STDOUT "File Size : %04x\n", $mzf_size; - printf STDOUT "File Load Address : %04x\n", $mzf_loadaddr; - printf STDOUT "File Exec Address : %04x\n", $mzf_execaddr; - printf STDOUT "Comment : %s\n", $mzf_comment; - } - - # For the DELHEADER/FIXHEADER command, a destination needs to be provided and opened. - if(($command eq "DELHEADER" || $command eq "FIXHEADER") && defined($dstFile) && $dstFile ne "") - { - if( ! open(DSTFILE, ">".$dstFile) ) - { - argOptions(1, "Cannot open the destination file: $dstFile.\n",$ERR_BADFILENAME); - } - } - - # For the FIXHEADER, look at the filename and correct if it doesnt use Sharp ASCII. - # - if($command eq "FIXHEADER") - { - # Remove start and trailing space. - $mzf_filename = trim($mzf_filename); - - # Go through the string and convert the stored filename to Sharp format. - $new_mzf_filename = ""; - for $idx (0..length($mzf_filename)-1) - { - $hdrChar = substr($mzf_filename, $idx, 1); - $mapIdx = ord($hdrChar); - if($hdrChar =~ m/[^a-z]/) - { - $new_mzf_filename = $new_mzf_filename . pack("C1", $mapIdx); - } else - { - $new_mzf_filename = $new_mzf_filename . pack("C1", getSharpASCIICode($mapIdx)); - } - } - - # Remove start and trailing space. - $new_mzf_filename = trim($new_mzf_filename); - - # Pad to length of filename field with NULL bytes. - for $idx (length($new_mzf_filename)..17-1) - { - $new_mzf_filename = $new_mzf_filename . pack("C1", 0x00); - } - - # Repack the header with the updated filename. - $new_mzf_header = pack('c1 a17 v v v', $mzf_type, $new_mzf_filename, $mzf_size, $mzf_loadaddr, $mzf_execaddr); - $new_mzf_header .= pack('a104', $mzf_comment) ; - } -} -elsif($command eq "ADDHEADER" && defined($mzfFile) && $mzfFile ne "") -{ - # If defined, can we create it? - # - if( ! open(MZFFILE, ">".$mzfFile) ) - { - argOptions(1, "Cannot create MZF file: $mzfFile.\n",$ERR_BADFILENAME); - } - - # For this command, a source file needs to exist and opened. - if(defined($srcFile) && $srcFile ne "") - { - if( ! open(SRCFILE, "<".$srcFile) ) - { - argOptions(1, "Cannot open the source file: $srcFile.\n",$ERR_BADFILENAME); - } - - @SRC = (); - binmode(SRCFILE); - local $/ = \1; - $cnt = 0; - $skip = 0; - while ( my $byte = ) - { - $SRC[$cnt] = $byte; - $cnt++; - } - $SRC_SIZE = $cnt; - } -} -else -{ - argOptions(2, "No MZF file given, use --mzffile=.\n"); -} - -# Process command as necessary. -# -if($command eq "ADDHEADER") -{ - # Build the header based on given information and size of src file. - $mzf_size = scalar @SRC; - $mzf_type = $tapeType; # For exit code. - $mzf_header = pack('c1 a17 v v v', $tapeType, $fileName, $mzf_size, $loadAddr, $execAddr); - $mzf_header .= pack('a104', $comment) ; - - # Store in file. - print MZFFILE $mzf_header; - - # Now add the source data. - foreach my $byte (@SRC) { print MZFFILE $byte; } - - # All done. - close MZFFILE; - - # Output detail if requested. - # - if($verbose) - { - printf STDOUT "File Name : %s\n", $fileName; - printf STDOUT "File Type : %02x\n", $tapeType; - printf STDOUT "File Size : %04x\n", $mzf_size; - printf STDOUT "File Load Address : %04x\n", $loadAddr; - printf STDOUT "File Exec Address : %04x\n", $execAddr; - printf STDOUT "Comment : %s\n", $comment; - } -} -# For delete, simply write out the tape contents less the header (first 128 bytes). -elsif($command eq "DELHEADER") -{ - my $cnt = 0; - foreach my $byte (@MZF) { if($cnt++ >= 128) { print DSTFILE $byte; } } - close DSTFILE; -} -elsif($command eq "FIXHEADER") -{ - # Can we create the destination file, ie. the file containing the MZF program with a corrected header? - # - if( ! open(DSTFILE, ">".$dstFile) ) - { - argOptions(1, "Cannot open the destination file: $dstFile.\n",$ERR_BADFILENAME); - } - - # Strip off the old header. - splice(@MZF, 0, 128); - - # Now add the new header and source data into the destination file. - print DSTFILE $new_mzf_header; - foreach my $byte (@MZF) { print DSTFILE $byte; } - - # All done. - close DSTFILE; -} - -# Exit code is the type of MZF file. -exit $mzf_type; diff --git a/software/tools/nasconv b/software/tools/nasconv deleted file mode 100755 index ac9b7dc..0000000 Binary files a/software/tools/nasconv and /dev/null differ diff --git a/software/tools/processMZFfiles.sh b/software/tools/processMZFfiles.sh deleted file mode 100755 index a5449f1..0000000 --- a/software/tools/processMZFfiles.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -######################################################################################################### -## -## Name: processMZFfiles.sh -## Created: August 2018 -## Author(s): Philip Smart -## Description: Sharp MZ series MZF sectoring tool -## This is a very basic tool which takes MZF images and resizes them to the correct -## sector size used in the RFS Flash Roms. It currently generates many sector size -## variants and the packaging tool make_roms.sh chooses the correct sector size -## according to its configuration. -## -## Credits: -## Copyright: (c) 2020-2023 Philip Smart -## -## History: January 2020 - Initial script written. -## March 2021 - Small updates to pull programs from machine model sorted directories. -## -######################################################################################################### -## This source file is free software: you can redistribute it and#or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## This source file is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program. If not, see . -######################################################################################################### - -ROOTDIR=../../MZ80A_RFS/ -MZFDIR=${ROOTDIR}/software/MZF -MZBDIR=${ROOTDIR}/software/MZB -#BLOCKSIZELIST="256 512 1024 2048 4096" -BLOCKSIZELIST="128 256" - -# Build list of files to process. -for SUBDIR in Common MZ-80A MZ-80K MZ-700 MZ-800 MZ-1500 MZ-2000 MZ-80B -do - cd ${MZFDIR} - ls -l ${SUBDIR}/*.MZF ${SUBDIR}/*.mzf 2>/dev/null |\ - sed 's/ / /g' | sed 's/ / /g' | cut -d' ' -f5,9- > /tmp/filelist.tmp 2>/dev/null - if [ $# = 1 ]; then - cat /tmp/filelist.tmp | grep $1 > /tmp/filelist - else - cat /tmp/filelist.tmp > /tmp/filelist - fi - cd .. - - # Clear out the old staging directory. Checks to ensure the variable has value otherwise delete could take place in root! - mkdir -p ${MZBDIR}/${SUBDIR} - if [ "x${MZBDIR}/${SUBDIR}" != "x" ]; then - echo "Clearing directory:${SUBDIR}..." - rm -f ${ROOTDIR}/software/MZB/${SUBDIR}/* - fi - - IFS=' '; while read -r FSIZE FNAME; - do - FDIRNAME=`dirname ${FNAME}` - FILENAME=`basename ${FNAME}` - TNAME=`echo $FILENAME | sed 's/MZF/mzf/g'` - if [ "${FILENAME}" != "${TNAME}" ]; then - mv "${FILENAME}" "${TNAME}" - fi - set +x - for BLOCKSIZE in ${BLOCKSIZELIST} - do - for SECTORSIZE in `seq -s ' ' ${BLOCKSIZE} ${BLOCKSIZE} 524288` - do - BASE=`basename "$TNAME" .mzf` - if [ `echo ${FSIZE} - ${SECTORSIZE} | bc` -le 0 ]; - then - echo $BASE $TNAME $SECTORSIZE - dd if=/dev/zero ibs=1 count=$SECTORSIZE 2>/dev/null | tr "\000" "\377" > "${MZBDIR}/${FDIRNAME}/${BASE}.${BLOCKSIZE}.bin" - dd if="${MZFDIR}/${FDIRNAME}/$TNAME" of="${MZBDIR}/${FDIRNAME}/${BASE}.${BLOCKSIZE}.bin" conv=notrunc 2>/dev/null - break; - fi - done - done - done