Prev: 44295 Up: Map Next: 44521
44446: Restore Item Rows
Used by the routines at RunFrame and RunGame.
Replays the table of item records built by BuildDrawList and PrepareEntityItem. For each record, the rows of the screen buffer saved in the record are copied back to the address in the record header, working upwards one row at a time.
RestoreItemRows 44446 LD A,(62720) Read how many item records there are.
44449 AND A Return when there are none.
44450 RET Z
The alternate accumulator counts the records. The first byte of a header is the step back to the previous row.
44451 LD HL,62721 Start at the first record.
RestoreItemRows_Loop 44454 EX AF,AF' Remember how many records remain.
44455 LD A,(HL) Patch the step back to the previous row.
44456 LD (44510),A
44459 INC HL Move on to the screen address.
44460 LD E,(HL) Read the screen address from the header.
44461 INC HL
44462 LD D,(HL)
44463 INC HL
44464 LD A,(HL) Patch the row loop with the width.
44465 LD (44517),A
44468 INC HL Move on to the row count.
44469 LD B,(HL) Read how many rows.
44470 INC HL
44471 LD C,255 Keep the byte count from carrying into the row count.
44473 JP RestoreItemRows_Rows Join the row loop.
RestoreItemRows_Next 44476 EX AF,AF' Repeat for the remaining records.
44477 DEC A
44478 JP NZ,RestoreItemRows_Loop
44481 RET Return.
Copy three words from the stack. The patched jump cannot reach this for a width of up to six bytes, so it is not used.
RestoreItemRows_Words 44482 POP DE Copy three words from the stack.
44483 LD (HL),E
44484 INC HL
44485 LD (HL),D
44486 INC HL
44487 POP DE
44488 LD (HL),E
44489 INC HL
44490 LD (HL),D
44491 INC HL
44492 POP DE
44493 LD (HL),E
44494 INC HL
44495 LD (HL),D
Copy one byte of the row for each of these that the patched jump reaches. A wider row starts further up the list.
RestoreItemRows_Copy 44496 LDI Copy a byte and move on.
44498 LDI Copy a byte and move on.
44500 LDI Copy a byte and move on.
44502 LDI Copy a byte and move on.
44504 LDI Copy a byte and move on.
44506 LDI Copy a byte and move on.
Move back one row. The distance subtracted below is patched from the record header.
RestoreItemRows_Step 44508 LD A,E Step back to the previous row.
44509 SUB 0
44511 LD E,A
44512 JP NC,RestoreItemRows_Rows Stay on this page if the step did not borrow.
44515 DEC D Move to the previous page.
RestoreItemRows_Rows 44516 DJNZ RestoreItemRows_Rows Repeat for the remaining rows. The displacement is patched.
44518 JP RestoreItemRows_Next Go on to the next record.
Prev: 44295 Up: Map Next: 44521