Skip to content

Commit

Permalink
handle invalid slots from the user in the fileioc api
Browse files Browse the repository at this point in the history
  • Loading branch information
mateoconlechuga committed Sep 21, 2021
1 parent dc410e7 commit a2d5025
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/fileioc/fileioc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -876,14 +876,11 @@ ti_Close:
pop de
pop bc
push bc
ld b, 3
mlt bc
ld hl, variable_offsets - 1
add hl, bc
; upper byte of offset = slot * 3
ld (hl), c
ex de, hl
jp (hl)
push de
call util_is_slot_open
jq nz, util_ret_null
ld (hl), 255
ret

;-------------------------------------------------------------------------------
ti_DetectAny:
Expand Down Expand Up @@ -1550,6 +1547,8 @@ util_is_slot_open:
; zf = open
; (curr_slot) = slot
ld a, c
cp a, 6
jr nc, .not_open
ld (curr_slot), a
ld b, 3
mlt bc
Expand All @@ -1558,6 +1557,10 @@ util_is_slot_open:
ld a, b
cp a, (hl)
ret
.not_open:
xor a, a
inc a
ret

util_get_vat_ptr:
ld a, (curr_slot)
Expand Down Expand Up @@ -1636,5 +1639,6 @@ util_post_gc_handler := $-3
; Internal library data
;-------------------------------------------------------------------------------

db 255 ; handle edge case of 0 for slot
variable_offsets:
dl -1, -1, -1, -1, -1
2 changes: 1 addition & 1 deletion tools/convimg

0 comments on commit a2d5025

Please sign in to comment.