Skip to content

Commit

Permalink
Use exact file size when loading a prg from SDcard, to get correct va…
Browse files Browse the repository at this point in the history
…rtab
  • Loading branch information
zeldin committed Oct 1, 2022
1 parent 3dbb331 commit db0b672
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
18 changes: 16 additions & 2 deletions rom/source/fileselector.s
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ cluster3: .res files_per_page
blocks_high: .res files_per_page
blocks_mid: .res files_per_page
blocks_low: .res files_per_page
size_low: .res files_per_page
size_high: .res files_per_page
; upper 16 bits of file size not needed, as it can be
; computed from the number of blocks if needed

filename: .res 27

Expand Down Expand Up @@ -228,10 +232,12 @@ next_page:
ror
sta blocks_mid,x
lda direntry+29
sta size_high,x
ror
sta blocks_low,x
bcs @residue
lda direntry+28
sta size_low,x
bcs @residue
beq @noresidue
@residue:
inc blocks_low,x
Expand Down Expand Up @@ -397,6 +403,10 @@ selection:
jsr fatfs_open_subdir
jmp next_dir
@regular_file:
lda size_low,x
pha
lda size_high,x
pha
lda blocks_low,x
pha
lda blocks_mid,x
Expand All @@ -418,7 +428,11 @@ selection:
pla
tax
pla
jmp index_file
jsr index_file
pla
tax
pla
rts


colorize:
Expand Down
15 changes: 11 additions & 4 deletions rom/source/loader.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@

.import initstream, getstreamdata

.importzp vreg
.importzp vreg, vscrn

vartab = $2d
ndx = $c6
keyd = $277

loader:
sec
sbc #2
sta vscrn
bcs @nowrap
dex
@nowrap:
stx vscrn+1
ldx #0
stx $df04
stx $df05
Expand Down Expand Up @@ -42,10 +49,10 @@ loader:
sta $df02
lda vreg+1
sta $df03
lda #$fe
lda vscrn
sta $df07
dex
stx $df08
lda vscrn+1
sta $df08
lda #$81
sta $df01

Expand Down

0 comments on commit db0b672

Please sign in to comment.