From 60d966059ce3fd7115f8dc1232d90c266bb75899 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 2 Jul 2024 16:52:32 -0400 Subject: [PATCH] riven: more work on prodos stuff --- games/riven_hgr/Makefile | 5 +- games/riven_hgr/prorwts_ca65.s | 242 +++++++++++++++++---------------- 2 files changed, 127 insertions(+), 120 deletions(-) diff --git a/games/riven_hgr/Makefile b/games/riven_hgr/Makefile index 1aba5d33..a4ba969c 100644 --- a/games/riven_hgr/Makefile +++ b/games/riven_hgr/Makefile @@ -17,9 +17,12 @@ all: riven_disk00.dsk \ # Note: cadius, put #XXYYYY after filename for type/value -riven_hgr.po: disk01_files/LEVEL_ARRIVAL +riven_hgr.po: disk01_files/LEVEL_ARRIVAL prorwts_ca65.o $(PRODOSDIR)/mkprodosfs riven_hgr.po -n Riven +prorwts_ca65.o: prorwts_ca65.s + ca65 -o prorwts_ca65.o prorwts_ca65.s -l prorwts_ca65.lst + ### #riven_hgr.2mg: \ diff --git a/games/riven_hgr/prorwts_ca65.s b/games/riven_hgr/prorwts_ca65.s index 9508c061..fe48f05c 100644 --- a/games/riven_hgr/prorwts_ca65.s +++ b/games/riven_hgr/prorwts_ca65.s @@ -364,7 +364,7 @@ slot: .if lc_bank=1 lda LCBANK2 lda LCBANK2 - .else ; { ;lc_bank + .else ; ;lc_bank lda ROMIN lda ROMIN .endif ;lc_bank @@ -392,65 +392,68 @@ x80_parms: .if enable_floppy=1 unrelocdsk: -;!pseudopc reloc { -reloc = $D000 +;!pseudopc reloc +.org reloc -opendir ;read volume directory key block +opendir: + ; read volume directory key block unrblocklo=unrelocdsk+(*-reloc) - ldx #2 + ldx #2 unrblockhi=unrelocdsk+(*-reloc) - lda #0 - jsr readdirsel + lda #0 + jsr readdirsel ;include volume directory header in count -readdir - !if might_exist=1 { - ldx dirbuf+37 +readdir: + .if might_exist=1 + ldx dirbuf+37 inx - stx entries - } ;might_exist -firstent lda #<(dirbuf+4) - sta bloklo - lda #>(dirbuf+4) - sta blokhi -nextent ldy #0 - !if might_exist=1 { - sty status - } ;might_exist - lda (bloklo), y - !if (might_exist+allow_subdir)>0 { - and #$f0 + stx entries + .endif ;might_exist +firstent: + lda #<(dirbuf+4) + sta bloklo + lda #>(dirbuf+4) + sta blokhi +nextent: + ldy #0 + .if might_exist=1 + sty status + .endif ;might_exist + lda (bloklo), Y + .if (might_exist+allow_subdir)>0 + and #$f0 - !if might_exist=1 { - ;skip deleted entries without counting + .if might_exist=1 + ; skip deleted entries without counting - beq ++ - } ;might_exist - } ;might_exist or allow_subdir + beq ++ + .endif ; might_exist + .endif ; might_exist or allow_subdir - !if allow_subdir=1 { + .if allow_subdir=1 ;subdirectory entries are seedlings ;but we need to distinguish between them later - cmp #$d0 - beq savetype - } ;allow_subdir + cmp #$d0 + beq savetype + .endif ;allow_subdir - ;watch for seedling and saplings only + ; watch for seedling and saplings only - cmp #$30 - bcs + + cmp #$30 + bcs + - ;remember type + ; remember type -savetype - !if allow_subdir=1 { +savetype: + .if allow_subdir=1 asl asl - } else { ;allow_subdir + .else ;allow_subdir cmp #$20 - } ;allow_subdir + .endif ;allow_subdir php ;match name lengths before attempting to match names @@ -459,7 +462,7 @@ savetype and #$0f tax inx - !byte $2c + .byte $2c - lda (bloklo), y cmp (namlo), y beq foundname @@ -468,15 +471,15 @@ savetype plp + - !if might_exist=1 { + .if might_exist=1 dec entries bne ++ -nodisk +nodisk: unrdrvoff1=unrelocdsk+(*-reloc) lda MOTOROFF inc status rts - } ;might_exist + .endif ;might_exist ;move to next directory in this block, if possible @@ -496,17 +499,18 @@ unrdrvoff1=unrelocdsk+(*-reloc) ;read next directory block when we reach the end of this block - ldx dirbuf+2 - lda dirbuf+3 - jsr readdirsec - bne firstent + ldx dirbuf+2 + lda dirbuf+3 + jsr readdirsec + bne firstent -foundname iny +foundname: + iny dex - bne - - stx entries + bne - + stx entries - !if enable_write=1 { + .if enable_write=1 ldy reqcmd cpy #cmdwrite ;control carry instead of zero bne + @@ -515,85 +519,85 @@ foundname iny ;or nearest block if using aligned reads lda sizelo - !if aligned_read=0 { + .if aligned_read=0 beq + inc sizehi - } else { ;aligned_read + .else ;aligned_read ldx sizehi jsr round sta sizehi - } ;aligned_read + .endif ;aligned_read + - } ;enable_write + .endif ;enable_write ;cache EOF (file size, loaded backwards) ldy #EOF+1 lda (bloklo), y - !if (enable_write+aligned_read)>0 { + .if (enable_write+aligned_read)>0 tax - } else { ;enable_write or aligned_read + .else ;enable_write or aligned_read sta sizehi - } ;enable_write or aligned_read + .endif ;enable_write or aligned_read dey lda (bloklo), y - !if (enable_write+aligned_read)>0 { + .if (enable_write+aligned_read)>0 ;round file size up to nearest sector if writing without aligned reads ;or nearest block if using aligned reads - !if aligned_read=0 { + .if aligned_read=0 bcc ++ beq + inx lda #0 - } else { ;aligned_read - !if enable_write=1 { + .else ;aligned_read + .if enable_write=1 jsr round tax - } else { ;enable_write + .else ;enable_write adc #$fe txa adc #1 and #$fe - } ;enable_write - } ;aligned_read + .endif ;enable_write + .endif ;aligned_read ;set requested size to min(length, requested size) - !if enable_write=1 { + .if enable_write=1 + cpx sizehi bcs + ++ stx sizehi + - } else { ;enable_write + .else ;enable_write sta sizehi - } ;enable_write - } ;enable_write or aligned_read - !if aligned_read=0 { + .endif ;enable_write + .endif ;enable_write or aligned_read + .if aligned_read=0 sta sizelo - } ;aligned_read + .endif ;aligned_read ;cache AUX_TYPE (load offset for binary files) - !if override_adr=0 { - !if allow_subdir=1 { + .if override_adr=0 + .if allow_subdir=1 pla tax - } else { ;allow_subdir + .else ;allow_subdir plp - } ;allow_subdir + .endif ;allow_subdir ldy #AUX_TYPE lda (bloklo), y pha iny lda (bloklo), y pha - !if allow_subdir=1 { + .if allow_subdir=1 txa pha - } ;allow_subdir - } ;override_adr + .endif ;allow_subdir + .endif ;override_adr ;cache KEY_POINTER @@ -607,33 +611,33 @@ foundname iny ;read index block in case of sapling - !if allow_subdir=1 { + .if allow_subdir=1 plp bpl rdwrfile php jsr readdirsec plp - } else { ;allow_subdir - !if override_adr=1 { + .else ;allow_subdir + .if override_adr=1 plp - } ;override_adr + .endif ;override_adr bcc rdwrfile jsr readdirsec - } ;allow_subdir + .endif ;allow_subdir ;restore load offset rdwrfile - !if override_adr=1 { + .if override_adr=1 ldx ldrhi lda ldrlo - } else { ;override_adr + .else ;override_adr pla tax pla - } ;override_adr + .endif ;override_adr - !if allow_subdir=1 { + .if allow_subdir=1 ;check file type and fake size and load address for subdirectories bcc + @@ -642,22 +646,22 @@ rdwrfile ldx #>dirbuf lda #dirbuf sty adrhi - !if aligned_read=0 { + .if aligned_read=0 ldy #2 sty secsize2 - } ;aligned_read + .endif ;aligned_read ldy #cmdread sty command @@ -865,7 +869,7 @@ unrdrvon2=unrelocdsk+(*-reloc) rol sta reqsec - !if aligned_read=0 { + .if aligned_read=0 ;set read size to min(first size, $100) and then read address ldy #0 @@ -874,7 +878,7 @@ unrdrvon2=unrelocdsk+(*-reloc) ldy secsize1 + sty secsize dec secsize2 - } ;aligned_read + .endif ;aligned_read jsr readadr ;if track does not match, then seek @@ -892,7 +896,7 @@ unrdrvon2=unrelocdsk+(*-reloc) checksec jsr cmpsec - !if aligned_read=0 { + .if aligned_read=0 ;return if less than one sector requested tya @@ -904,7 +908,7 @@ checksec jsr cmpsec cmp secsize2 beq readret sta secsize - } ;aligned_read + .endif ;aligned_read inc reqsec inc reqsec @@ -1128,12 +1132,12 @@ epilog_e: .endif ;enable_write bit2tbl = (*+255) & -256 nibtbl = bit2tbl+86 - !if enable_write=1 { + .if enable_write=1 xlattbl = nibtbl+106 dataend = xlattbl+64 - } else { ;enable_write + .else ;enable_write dataend = nibtbl+106 - } ;enable_write + .endif ;enable_write ;hack to error out when code is too large for current address .if reloc<$c000 .if dataend>$c000 @@ -1151,7 +1155,7 @@ dataend = nibtbl+106 unrelochdd: - .org reloc ; !pseudopc reloc { + .org reloc ; !pseudopc reloc hddopendir: ;read volume directory key block @@ -1313,7 +1317,7 @@ hddst_plus_four: ; + .if enable_write=1 jsr hddround tax - .if aligned_read=0 { + .if aligned_read=0 lda #0 .endif ;aligned_read