diff --git a/System/BIOS.ASM b/System/BIOS.ASM index aff472c..fe8d919 100644 --- a/System/BIOS.ASM +++ b/System/BIOS.ASM @@ -11,8 +11,9 @@ ;V0.7 13.09.23 no IRQs ;V0.8 14.01.24 error correction ;V0.9 25.04.24 $FC & $FD buffered +;V1.0 29.04.24 $1A buffered -VERSION = $09 ;VERSION NUMBER +VERSION = $10 ;VERSION NUMBER ;FORMAT SD 1024 KBYTES/DISK @@ -51,6 +52,8 @@ ROM_MONITOR = $E000 ;Monitor cold start BREAKC = $03 ;BREAK CODE CLS = $0C ;CLEAR SCREEN +BIT_ABS = $2C ;code byte BIT ABS + ;ERROR CODES INVDRV = $F9 ;invalid drive @@ -164,15 +167,11 @@ CONST1 CLC CONIN JSR PUSHIOB JSR ROM_CONIN - PHA JSR PULLIOB - PLA RTS -CONOUT PHA - JSR PUSHIOB - PLA +CONOUT JSR PUSHIOB JSR ROM_CONOUT JSR PULLIOB RTS @@ -218,7 +217,8 @@ SETTRK LDA #$FB ;Sector not found RTS -READ JSR SETLBA ;SET LBA = IMGTAB + SECS/2 +READ JSR PUSH_E0 + JSR SETLBA ;SET LBA = IMGTAB + SECS/2 BCS SD_RDX JSR CHKBLK ;CHECK IF BLOCK VALID BCC SD_RD1 @@ -232,23 +232,25 @@ SD_RD2 LDA BLKBUF,Y STA (DMAV),Y INY BNE SD_RD2 - CLC - RTS + BEQ SD_RD5 SD_RD3 LDA BLKBUF+256,Y STA (DMAV),Y INY BNE SD_RD3 +SD_RD5 JSR PULL_E0 CLC RTS SD_RD4 JSR SD_INIT ;on error retry BCS READ + JSR PULL_E0 SEC SD_RDX RTS -WRITE JSR SETLBA ;WRITE SD card +WRITE JSR PUSH_E0 + JSR SETLBA ;WRITE SD card BCS SD_RDX JSR CHKBLK BCC SD_WR1 @@ -278,13 +280,16 @@ SD_WR4 LDA #$80 CMP #SYS+DIRSCS BCS SD_WR5 JSR SD_WB ;then write SD block immediate + JSR PULL_E0 RTS -SD_WR5 CLC +SD_WR5 JSR PULL_E0 + CLC RTS SD_WRE JSR SD_INIT ;on error 1 retry BCS WRITE + JSR PULL_E0 SEC RTS @@ -392,13 +397,9 @@ S_READ BIT LBA_F ;SD_READ BPL S_READ1 ;if buffer dirty JSR S_SAVE ;SAVE SD_BUFFER BCS S_READX -S_READ1 JSR PUSH_E0 - JSR PUSHIOB - LDX #LBA ;load LBA to BLKBUF +S_READ1 LDX #LBA ;load LBA to BLKBUF LDY #LBA/256 JSR SD_RD_LBLK_BUF - JSR PULL_E0 - JSR PULLIOB BCS S_READX SEC RTS @@ -408,13 +409,9 @@ S_READX JSR SD_UPD ;UPDATE BLK/FLAG INFO RTS -S_SAVE JSR PUSH_E0 - JSR PUSHIOB - LDX #LBA_B ;save old buffer to SD +S_SAVE LDX #LBA_B ;save old buffer to SD LDY #LBA_B/256 JSR SD_WR_LBLK_BUF - JSR PULL_E0 - JSR PULLIOB BCC S_SAVEX CLC RTS @@ -423,14 +420,10 @@ S_SAVEX SEC RTS -SD_WB JSR PUSH_E0 - JSR PUSHIOB - LDX #LBA ;Write SD_ block pysically +SD_WB LDX #LBA ;Write SD_ block pysically LDY #LBA/256 JSR SD_WR_LBLK_BUF BCS S_READX - JSR PULL_E0 - JSR PULLIOB SEC RTS @@ -448,58 +441,47 @@ SD_UPD LDA LBA+3 ;save LBA AND update LBA_FLAG RTS -PUSH_E0 LDX #$E3 ;Save $E3..E0 - LDY #3 ;4 bytes to be saved -PUSH_E1 LDA 0,X - STA E0BUF,Y - DEX +PUSHIOB STY Y_BUF + LDY #ZP_CELL-ZP_IOB-1 ;Save page zero cells for CHR-IO + DB BIT_ABS +PUSH_E0 LDY #ZP_BUF-ZP_IOB-1 ;Save page zero cells + PHA +PUSH_E1 LDX ZP_IOB,Y ;load page zero adr + LDA 0,X ;load cell content + STA ZP_BUF,Y ;and save it DEY BPL PUSH_E1 - LDA TEMP ;save $FC - STA TEMPBUF + INY ;restore IOB + STY IOB + LDA IOBASEH + STA IOB+1 + LDY Y_BUF + PLA RTS -PULL_E0 LDX #$E3 ;Save $E3..E0 - LDY #3 ;4 bytes to be saved - PHA ;save A -PULL_E1 LDA E0BUF,Y - STA 0,X - DEX +PULLIOB STY Y_BUF + LDY #ZP_CELL-ZP_IOB-1 ;restore page zero cells for CHR-IO + DB BIT_ABS +PULL_E0 LDY #ZP_BUF-ZP_IOB-1 ;restore page zero cells + PHA + PHP +PULL_E1 LDX ZP_IOB,Y ;load page zero adr + LDA ZP_BUF,Y ;load cell content + STA 0,X ;and restore it DEY BPL PULL_E1 - LDA TEMPBUF ;restore $FC - STA TEMP - PLA ;A & C unchanged - RTS - -PUSHIOB LDA IOB ;save $14/$15 - STA IOBBUF - LDA IOB+1 - STA IOBBUF+1 - LDA #0 - STA IOB - LDA IOBASEH - STA IOB+1 - LDA YSAV ;save $FD - STA YSAVBUF + LDY Y_BUF + PLP + PLA RTS -PULLIOB LDA IOBBUF ;restore $14/$15 - STA IOB - LDA IOBBUF+1 - STA IOB+1 - LDA YSAVBUF ;restore $FD - STA YSAV - RTS - -E0BUF DS 4,0 -TEMPBUF DB 0 -IOBBUF DS 2,0 -YSAVBUF DB 0 +ZP_IOB DB $14,$15,$FD +ZP_CELL DB $E3,$E2,$E1,$E0,$FC,$1A +ZP_BUF DS ZP_BUF-ZP_IOB,0 -X_CNT DB 0 +Y_BUF DB 0 DMA diff --git a/System/BIOS.COM b/System/BIOS.COM index e951bad..abcbd57 100644 Binary files a/System/BIOS.COM and b/System/BIOS.COM differ