Fix link_loop writing addresses instead of IDs

This commit is contained in:
pjht 2023-02-05 11:02:32 -06:00
parent 5da40ff553
commit e555f2e7b5
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -52,7 +52,7 @@ ld b, 0
ret
.global mb_read
;Reads a meddage from the MB specified in HL,
;Reads a message from the MB specified in HL,
; and returns the pointer in C:DE:HL.
; Returns 0 in B if the mailbox had a message, and 1 if it was full
mb_read:
@ -118,24 +118,22 @@ ld (mb_next_frame_num), bc
call get_mb_ptr
push hl
pop ix
pop hl
push hl
pop iy
inc hl
/* push hl */
/* pop iy */
link_loop:
inc iyh
ld a, iyh
cp 0xf0
jp nz, iy_ok
ld (ix + 0), l
ld (ix + 1), h
inc hl
inc ixh
ld a, ixh
cp 0xef
jp nz, link_loop
link_loop_done:
ld (ix + 0), 0
ld (ix + 1), 0
jp link_loop_done
iy_ok:
push iy
pop bc
ld (ix + 0), c
ld (ix + 1), b
inc ixh
jp link_loop
link_loop_done:
pop hl
ld (mb_free_list), hl
ld bc, (mb_free_list)
@ -154,9 +152,10 @@ pop ix
ld a, (ix + 0)
ld (mb_free_list), a
ld a, (ix + 1)
ld (mb_free_list), a
ld (mb_free_list + 1), a
ld hl, (temp)
ret
; Clobbers A, BC, DE, and IX
get_mb_ptr:
ld a, h