Skip to content

Commit

Permalink
Loader: ignore files that are too small
Browse files Browse the repository at this point in the history
The smallest mod file is 2108 bytes, which requires at least 5 sectors.
  • Loading branch information
stefandrissen committed Nov 20, 2021
1 parent 559c7f1 commit f50933f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/loader/bdos.s
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ bdos.read.dir:
ld c,a

ld hl,fat
ld de,fat+1
ld bc,16 * 80 - 1
ld (hl),0
ldir

ld hl,fat

ld d,0 ; track

@loop.tracks:
Expand Down Expand Up @@ -307,10 +314,27 @@ bdos.read.dir:
; de = @sector
; hl = directory store

ld a,(de) ; filetype
cp uifa.filetype.code
ret nz

ex de,hl

ld bc,0x0b
ldir ; filetype + filename

ld a,(hl) ; msb sectors
or a
jr nz,@ok

inc l
ld a,(hl) ; lsb sectors
dec l
cp 5 ; smallest mod is 2108 bytes (https://sitomani.github.io/4champ/2020ds/ds_06.html)
jr c,@file.too.small

@ok:

ld c,uifa.timestamp.day - 0x0b
add hl,bc
ldi ; day
Expand All @@ -328,6 +352,17 @@ bdos.read.dir:

ret

@file.too.small:

ex de,hl

ld c,0x0b
or a
sbc hl,bc
ld (hl),0

ret

;-------------------------------------------------------------------------------
@get.volume.label:

Expand Down

0 comments on commit f50933f

Please sign in to comment.