diff --git a/src/4cade.a b/src/4cade.a index 83a0fc947..361ad0273 100644 --- a/src/4cade.a +++ b/src/4cade.a @@ -102,6 +102,8 @@ gGamesListStore } LastMover !source "src/ui.font.data.a" + !source "src/prodos.impl.a" +EvenLasterMover !if RELBASE = $2000 { !ifdef PASS2 { } else { ;PASS2 diff --git a/src/4cade.init.a b/src/4cade.init.a index ef5343a13..50831d094 100644 --- a/src/4cade.init.a +++ b/src/4cade.init.a @@ -128,9 +128,9 @@ inc @FM+5 bne @FM -+ ldy #$04 ++ ldy #>(255 + EvenLasterMover - LastMover) @LM lda LastMover,x ; relocate font data to $D600 in RAM bank 2 - sta $D600,x + sta $D600,x ; and pseudo-ProDOS to $DA00 in RAM bank 2 inx bne @LM inc @LM+2 diff --git a/src/glue.prorwts2.a b/src/glue.prorwts2.a index a25cb29d8..1737de939 100644 --- a/src/glue.prorwts2.a +++ b/src/glue.prorwts2.a @@ -407,355 +407,3 @@ holepatch ;sta->lda rts holey_stuff !fill 64 - -;------------------------------------------------------------------------------ -; ProDOS_enter -; intercept certain ProDOS requests -; wrap them to ProRWTS2 file requests -; -; in: return address+1 is command and pointer to parameter block -; out: all flags clobbered -; A=0, X and Y preserved -; stack set to next instruction after parameters -;------------------------------------------------------------------------------ -packet = first_zp ;word -buffer = first_zp+2 ;word - -ProDOS_enter -!set CloseHandles = @imp_close - stx ProDOS_savedX+1 - sty ProDOS_savedY+1 - pha - jsr @swap_zp - pla - tax - pla - tay - pla - sta @fetchaddr+1 - pla - sta @fetchaddr+2 - jsr @fetchbyte - sta @request+1 - jsr @fetchbyte - sta packet - jsr @fetchbyte - sta packet+1 - lda @fetchaddr+2 - pha - lda @fetchaddr+1 - pha - tya - pha - php - txa - pha -@request - lda #$d1 - cmp #$80 - beq @do_readblock - cmp #$81 ;I don't remember if I used this, but it's cheap to add - beq @do_writeblock - cmp #$c4 - beq @do_getattrib - cmp #$c6 - beq @do_nothing - cmp #$c7 - beq @do_prefix - cmp #$c8 - beq @do_open - cmp #$ca - beq @do_read - cmp #$cb - beq @do_write - cmp #$cc - beq @do_close - cmp #$ce - beq @do_seek - cmp #$d1 - beq @do_eof - ;;any others?? - jmp ProDOS_fatal -@do_readblock -@do_writeblock - jmp @imp_rdwrblock -@do_getattrib - jmp @imp_getattrib -@do_nothing - jmp @restore_zp -@do_prefix - jmp @imp_prefix -@do_open - jmp @imp_open -@do_read - jmp @imp_read -@do_write - jmp @imp_write -@do_close - jsr @imp_close ;subroutine special case because of dual-use - jmp @restore_zp -@do_seek - jmp @imp_seek -@do_eof - jmp @imp_eof - -@imp_rdwrblock - and #$7f - tay - iny - sty @rdwrop+1 - ldx #$44 - ldy #2 - jsr @setbuffer - iny - lda (packet), y - tax - iny - lda (packet), y -@rdwrop - ldy #$d1 ; SMC - jsr hddseekrd+2 - bcc @jmp_zp2 ;always - -@imp_getattrib - lda packet+1 - pha - lda packet - pha - ldx #namlo - jsr @setbuffer1 - lda #$60 - sta attribpatch - jsr hddopendir - lda #$10 - sta attribpatch - pla - sta packet - pla - sta packet+1 - ldy #5 - lda ldrlo2 - sta (packet), y - iny - lda ldrlo2+1 - sta (packet), y - ldy #$13 - lda (bloklo), y - tax - iny - lda (bloklo), y - ldy #9 - sta (packet), y - txa - dey - sta (packet), y -@jmp_zp2 - jmp @restore_zp - -@imp_prefix - ldx #buffer - jsr @setbuffer1 - ldy ProDOS_prefix - iny - iny - tya - pha - dey -@copy_prefix - lda ProDOS_prefix, y - iny - sta (buffer), y - dey - dey - bne @copy_prefix - pla - sta (buffer), y - lda #'/' - iny - sta (buffer), y - bne @jmp_zp2 - -@imp_open - ldx #namlo - jsr @setbuffer1 - iny - inc @handles+1 -@handles - ldx #0 - iny - lda (packet), y - sta @handle-1, x - jsr @patch_buffer - iny - lda #1 - sta (packet), y - lda #0 - sta reqcmd - sta sizehi - sta sizelo - jsr hddopendir - lda #0 - sta blkidx - beq @jmp_zp ;always - -@imp_seek - jsr @set_rdwrbuff - lda #0 - sta blkidx - sta blkofflo - sta blkoffhi - sta reqcmd - jsr @reset - ldx sizelo - beq @seek64 - sta sizehi - sta sizelo - jsr @seekreset - inc ldrlo - bne @seek64 - inc ldrhi - -@seek64 - lda ldrhi - sta sizehi - lda ldrlo - sta sizelo - jsr @seekreset - lda ldrhi - ora ldrlo - bne @jmp_zp - dec blkidx - beq @jmp_zp ;always - -@seekreset - jsr hddrdwrpart -@reset - lda #$ff - sta blefthi - sta bleftlo - rts - -@imp_read - clc -@imp_write - php - lda #cmdread - adc #0 - sta reqcmd - jsr @set_rdwrbuff - plp - bcc @skip_align - lda sizelo - adc #$fe - lda sizehi - adc #1 - and #$fe - sta sizehi - -@skip_align - jsr hddrdwrpart - ldy #6 - lda sizelo2 - sta (packet), y - iny - lda sizehi2 - sta (packet), y -@jmp_zp - jmp @restore_zp - -@imp_eof - ldy #2 - lda bleftlo - sta (packet), y - iny - lda blefthi - sta (packet), y - bcs @restore_zp ;always - -@imp_close - lda @handles+1 - beq @close_ret - dec @handles+1 - bne @close_ret - lda #>hddencbuf - -@patch_buffer - sta encbufpatch1+1 - sta encbufpatch2+1 - tax - inx - stx dirbufpatch1+1 - inx - stx dirbufpatch2+2 - stx dirbufpatch3+2 - stx dirbufpatch4+2 - stx dirbufpatch6+1 - stx dirbufpatch7+2 - stx dirbufpatch9+2 - stx dirbufpatch10+1 - inx - stx dirbufpatch5+2 - stx dirbufpatch8+2 -@close_ret - rts - -@fetchbyte - inc @fetchaddr+1 - bne @fetchaddr - inc @fetchaddr+2 -@fetchaddr - lda $d1d1 - rts - -@set_rdwrbuff - ldy #1 - lda (packet), y - tax - lda @handle-1, x - jsr @patch_buffer - ldx #ldrlo - iny - jsr @setbuffer - ldx #sizelo - iny - !byte $2c -@setbuffer1 - ldy #1 - -@setbuffer - lda (packet), y - sta $0,x - iny - lda (packet), y - sta $1,x - rts - -@swap_zp - ldx #last_zp-first_zp -@save_zp - lda first_zp,x - ldy @saved_zp,x - sta @saved_zp,x - sty first_zp,x - dex - bpl @save_zp - rts - -@restore_zp - jsr @swap_zp - pla - lsr - lsr - lsr - lsr - and #8 - plp - adc #0 - tax - jmp ProDOS_exit - -@handle - !byte 0, 0 ;only up to two handles at a time - -@saved_zp - !fill (last_zp - first_zp) + 1 diff --git a/src/prodos.impl.a b/src/prodos.impl.a new file mode 100644 index 000000000..c050175e2 --- /dev/null +++ b/src/prodos.impl.a @@ -0,0 +1,359 @@ +;license:MIT +;(c) 2019 by qkumba +; +; Pseudo-ProDOS environment +; + +!pseudopc $DA00 { +;------------------------------------------------------------------------------ +; ProDOS_enter +; intercept certain ProDOS requests +; wrap them to ProRWTS2 file requests +; +; in: return address+1 is command and pointer to parameter block +; out: all flags clobbered +; A=0, X and Y preserved +; stack set to next instruction after parameters +;------------------------------------------------------------------------------ +packet = first_zp ;word +buffer = first_zp+2 ;word + +ProDOS_enter +!set CloseHandles = @imp_close + stx ProDOS_savedX+1 + sty ProDOS_savedY+1 + pha + jsr @swap_zp + pla + tax + pla + tay + pla + sta @fetchaddr+1 + pla + sta @fetchaddr+2 + jsr @fetchbyte + sta @request+1 + jsr @fetchbyte + sta packet + jsr @fetchbyte + sta packet+1 + lda @fetchaddr+2 + pha + lda @fetchaddr+1 + pha + tya + pha + php + txa + pha +@request + lda #$d1 + cmp #$80 + beq @do_readblock + cmp #$81 ;I don't remember if I used this, but it's cheap to add + beq @do_writeblock + cmp #$c4 + beq @do_getattrib + cmp #$c6 + beq @do_nothing + cmp #$c7 + beq @do_prefix + cmp #$c8 + beq @do_open + cmp #$ca + beq @do_read + cmp #$cb + beq @do_write + cmp #$cc + beq @do_close + cmp #$ce + beq @do_seek + cmp #$d1 + beq @do_eof + ;;any others?? + jmp ProDOS_fatal +@do_readblock +@do_writeblock + jmp @imp_rdwrblock +@do_getattrib + jmp @imp_getattrib +@do_nothing + jmp @restore_zp +@do_prefix + jmp @imp_prefix +@do_open + jmp @imp_open +@do_read + jmp @imp_read +@do_write + jmp @imp_write +@do_close + jsr @imp_close ;subroutine special case because of dual-use + jmp @restore_zp +@do_seek + jmp @imp_seek +@do_eof + jmp @imp_eof + +@imp_rdwrblock + and #$7f + tay + iny + sty @rdwrop+1 + ldx #$44 + ldy #2 + jsr @setbuffer + iny + lda (packet), y + tax + iny + lda (packet), y +@rdwrop + ldy #$d1 ; SMC + jsr hddseekrd+2 + bcc @jmp_zp2 ;always + +@imp_getattrib + lda packet+1 + pha + lda packet + pha + ldx #namlo + jsr @setbuffer1 + lda #$60 + sta attribpatch + jsr hddopendir + lda #$10 + sta attribpatch + pla + sta packet + pla + sta packet+1 + ldy #5 + lda ldrlo2 + sta (packet), y + iny + lda ldrlo2+1 + sta (packet), y + ldy #$13 + lda (bloklo), y + tax + iny + lda (bloklo), y + ldy #9 + sta (packet), y + txa + dey + sta (packet), y +@jmp_zp2 + jmp @restore_zp + +@imp_prefix + ldx #buffer + jsr @setbuffer1 + ldy ProDOS_prefix + iny + iny + tya + pha + dey +@copy_prefix + lda ProDOS_prefix, y + iny + sta (buffer), y + dey + dey + bne @copy_prefix + pla + sta (buffer), y + lda #'/' + iny + sta (buffer), y + bne @jmp_zp2 + +@imp_open + ldx #namlo + jsr @setbuffer1 + iny + inc @handles+1 +@handles + ldx #0 + iny + lda (packet), y + sta @handle-1, x + jsr @patch_buffer + iny + lda #1 + sta (packet), y + lda #0 + sta reqcmd + sta sizehi + sta sizelo + jsr hddopendir + lda #0 + sta blkidx + beq @jmp_zp ;always + +@imp_seek + jsr @set_rdwrbuff + lda #0 + sta blkidx + sta blkofflo + sta blkoffhi + sta reqcmd + jsr @reset + ldx sizelo + beq @seek64 + sta sizehi + sta sizelo + jsr @seekreset + inc ldrlo + bne @seek64 + inc ldrhi + +@seek64 + lda ldrhi + sta sizehi + lda ldrlo + sta sizelo + jsr @seekreset + lda ldrhi + ora ldrlo + bne @jmp_zp + dec blkidx + beq @jmp_zp ;always + +@seekreset + jsr hddrdwrpart +@reset + lda #$ff + sta blefthi + sta bleftlo + rts + +@imp_read + clc +@imp_write + php + lda #cmdread + adc #0 + sta reqcmd + jsr @set_rdwrbuff + plp + bcc @skip_align + lda sizelo + adc #$fe + lda sizehi + adc #1 + and #$fe + sta sizehi + +@skip_align + jsr hddrdwrpart + ldy #6 + lda sizelo2 + sta (packet), y + iny + lda sizehi2 + sta (packet), y +@jmp_zp + jmp @restore_zp + +@imp_eof + ldy #2 + lda bleftlo + sta (packet), y + iny + lda blefthi + sta (packet), y + bcs @restore_zp ;always + +@imp_close + lda @handles+1 + beq @close_ret + dec @handles+1 + bne @close_ret + lda #>hddencbuf + +@patch_buffer + sta encbufpatch1+1 + sta encbufpatch2+1 + tax + inx + stx dirbufpatch1+1 + inx + stx dirbufpatch2+2 + stx dirbufpatch3+2 + stx dirbufpatch4+2 + stx dirbufpatch6+1 + stx dirbufpatch7+2 + stx dirbufpatch9+2 + stx dirbufpatch10+1 + inx + stx dirbufpatch5+2 + stx dirbufpatch8+2 +@close_ret + rts + +@fetchbyte + inc @fetchaddr+1 + bne @fetchaddr + inc @fetchaddr+2 +@fetchaddr + lda $d1d1 + rts + +@set_rdwrbuff + ldy #1 + lda (packet), y + tax + lda @handle-1, x + jsr @patch_buffer + ldx #ldrlo + iny + jsr @setbuffer + ldx #sizelo + iny + !byte $2c +@setbuffer1 + ldy #1 + +@setbuffer + lda (packet), y + sta $0,x + iny + lda (packet), y + sta $1,x + rts + +@swap_zp + ldx #last_zp-first_zp +@save_zp + lda first_zp,x + ldy @saved_zp,x + sta @saved_zp,x + sty first_zp,x + dex + bpl @save_zp + rts + +@restore_zp + jsr @swap_zp + pla + lsr + lsr + lsr + lsr + and #8 + plp + adc #0 + tax + jmp ProDOS_exit + +@handle + !byte 0, 0 ;only up to two handles at a time + +@saved_zp + !fill (last_zp - first_zp) + 1 +} diff --git a/src/prorwts2.a b/src/prorwts2.a index 8f18be85b..2364ddf94 100644 --- a/src/prorwts2.a +++ b/src/prorwts2.a @@ -380,6 +380,7 @@ adjpath tya lsr tay ldx DEVADR01HI, y +!if allow_extend = 1 { cpx #$c8 bcc set_slot ldx #$c8 @@ -403,6 +404,7 @@ adjpath tya ldy #$ff lda (bloklo), y beq - +} set_slot stx slot + 2 !if allow_extend = 1 {