![]() |
Routines |
| Prev: AD07 | Up: Map | Next: ADE9 |
|
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 | AD9E | LD A,($F500) | Read how many item records there are. | |
| ADA1 | AND A | Return when there are none. | ||
| ADA2 | RET Z | |||
|
The alternate accumulator counts the records. The first byte of a header is the step back to the previous row.
|
||||
| ADA3 | LD HL,$F501 | Start at the first record. | ||
| RestoreItemRows_Loop | ADA6 | EX AF,AF' | Remember how many records remain. | |
| ADA7 | LD A,(HL) | Patch the step back to the previous row. | ||
| ADA8 | LD ($ADDE),A | |||
| ADAB | INC HL | Move on to the screen address. | ||
| ADAC | LD E,(HL) | Read the screen address from the header. | ||
| ADAD | INC HL | |||
| ADAE | LD D,(HL) | |||
| ADAF | INC HL | |||
| ADB0 | LD A,(HL) | Patch the row loop with the width. | ||
| ADB1 | LD ($ADE5),A | |||
| ADB4 | INC HL | Move on to the row count. | ||
| ADB5 | LD B,(HL) | Read how many rows. | ||
| ADB6 | INC HL | |||
| ADB7 | LD C,$FF | Keep the byte count from carrying into the row count. | ||
| ADB9 | JP RestoreItemRows_Rows | Join the row loop. | ||
| RestoreItemRows_Next | ADBC | EX AF,AF' | Repeat for the remaining records. | |
| ADBD | DEC A | |||
| ADBE | JP NZ,RestoreItemRows_Loop | |||
| ADC1 | 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 | ADC2 | POP DE | Copy three words from the stack. | |
| ADC3 | LD (HL),E | |||
| ADC4 | INC HL | |||
| ADC5 | LD (HL),D | |||
| ADC6 | INC HL | |||
| ADC7 | POP DE | |||
| ADC8 | LD (HL),E | |||
| ADC9 | INC HL | |||
| ADCA | LD (HL),D | |||
| ADCB | INC HL | |||
| ADCC | POP DE | |||
| ADCD | LD (HL),E | |||
| ADCE | INC HL | |||
| ADCF | 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 | ADD0 | LDI | Copy a byte and move on. | |
| ADD2 | LDI | Copy a byte and move on. | ||
| ADD4 | LDI | Copy a byte and move on. | ||
| ADD6 | LDI | Copy a byte and move on. | ||
| ADD8 | LDI | Copy a byte and move on. | ||
| ADDA | LDI | Copy a byte and move on. | ||
|
Move back one row. The distance subtracted below is patched from the record header.
|
||||
| RestoreItemRows_Step | ADDC | LD A,E | Step back to the previous row. | |
| ADDD | SUB $00 | |||
| ADDF | LD E,A | |||
| ADE0 | JP NC,RestoreItemRows_Rows | Stay on this page if the step did not borrow. | ||
| ADE3 | DEC D | Move to the previous page. | ||
| RestoreItemRows_Rows | ADE4 | DJNZ RestoreItemRows_Rows | Repeat for the remaining rows. The displacement is patched. | |
| ADE6 | JP RestoreItemRows_Next | Go on to the next record. | ||
| Prev: AD07 | Up: Map | Next: ADE9 |