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