FshVar Functions now catch Out Of Bounds Exceptions

This commit is contained in:
Stephen Toth 2018-06-24 23:13:44 -04:00
parent 3e1451c007
commit 94ceaddf3b
2 changed files with 13 additions and 0 deletions

Binary file not shown.

View File

@ -7,6 +7,9 @@ fshvarset:
push bc push bc
push de push de
push hl push hl
ld bc, FshVarsSize / 2 + 1
call cpBCDE
jr nc, fshvarsetOOBException
ld bc, FshVars ld bc, FshVars
ex de, hl ex de, hl
add hl, hl add hl, hl
@ -14,6 +17,7 @@ fshvarset:
ld (hl), e ld (hl), e
inc hl inc hl
ld (hl), d ld (hl), d
fshvarsetOOBException:
pop hl pop hl
pop de pop de
pop bc pop bc
@ -28,6 +32,10 @@ fshvarset:
fshvarget: fshvarget:
push bc push bc
push de push de
ld hl, 0
ld bc, FshVarsSize / 2 + 1
call cpBCDE
jr nc, fshvargetOOBException
ld bc, FshVars ld bc, FshVars
ex de, hl ex de, hl
add hl, hl add hl, hl
@ -36,6 +44,7 @@ fshvarget:
inc hl inc hl
ld d, (hl) ld d, (hl)
ex de, hl ex de, hl
fshvargetOOBException:
pop de pop de
pop bc pop bc
ret ret
@ -49,6 +58,9 @@ fshvarcpy:
push bc push bc
push de push de
push hl push hl
ld bc, FshVarsSize / 2 + 1
call cpBCDE
jr nc, fshvarcpyOOBException
ld bc, FshVars ld bc, FshVars
add hl, hl add hl, hl
add hl, bc add hl, bc
@ -61,6 +73,7 @@ fshvarcpy:
inc hl inc hl
ld a, (de) ld a, (de)
ld (hl), a ld (hl), a
fshvarcpyOOBException:
pop hl pop hl
pop de pop de
pop bc pop bc