Skip to content

Commit 8d8f37d

Browse files
committed
fixed gfx_AllocSprite return value bug
1 parent 047098a commit 8d8f37d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/graphx/graphx.asm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,12 @@ gfx_AllocSprite:
388388
inc de ; de = width * height + 2
389389
push de
390390
call _indcallHL ; hl = malloc(width * height + 2)
391-
pop de ; de = width * height + 2
392-
add hl, de ; this should never carry
393-
sbc hl, de ; check if malloc failed (hl == 0)
394-
pop de ; e = width, d = height
391+
pop de
392+
pop de ; e = width, d = height, ude = unknown
393+
; check if malloc failed (hl == 0)
394+
add hl, de
395+
or a, a
396+
sbc hl, de
395397
ret z ; abort if malloc failed
396398
ld (hl), de ; store width and height
397399
ret

0 commit comments

Comments
 (0)