Routines |
Prev: ABA0 | Up: Map | Next: AC6F |
This draws the zoombox contents.
Used by the routine at zoombox.
|
||||
zoombox_fill | ABF9 | LD A,($AB68) | Fetch zoombox_y | |
ABFC | LD H,A | Multiply it by 128 and store it in DE | ||
ABFD | XOR A | |||
ABFE | SRL H | |||
AC00 | RRA | |||
AC01 | LD E,A | |||
AC02 | LD D,H | |||
AC03 | SRL H | Multiply it by 64 and store it in HL | ||
AC05 | RRA | |||
AC06 | LD L,A | |||
AC07 | ADD HL,DE | Sum the two, producing zoombox_y * 192 | ||
AC08 | LD A,($AB66) | Fetch zoombox_x | ||
AC0B | ADD A,L | Add zoombox_x to zoombox_y * 192 producing the window buffer source offset | ||
AC0C | LD L,A | |||
AC0D | JR NC,zoombox_fill_0 | |||
AC0F | INC H | |||
zoombox_fill_0 | AC10 | LD DE,$F291 | Point DE at window buffer + 1 (TODO: Explain the +1) | |
AC13 | ADD HL,DE | Form the final source pointer | ||
AC14 | EX DE,HL | Free up HL for the next chunk | ||
AC15 | LD A,($AB68) | Fetch zoombox_y again | ||
AC18 | ADD A,A | Multiply it by 16 producing an offset into the game_window_start_addresses array | ||
AC19 | ADD A,A | |||
AC1A | ADD A,A | |||
AC1B | ADD A,A | |||
AC1C | LD HL,$EDD3 | Point HL at the game_window_start_addresses array | ||
AC1F | ADD A,L | Combine it with the offset | ||
AC20 | LD L,A | |||
AC21 | JR NC,zoombox_fill_1 | |||
AC23 | INC H | |||
zoombox_fill_1 | AC24 | LD A,(HL) | Fetch the game window start address | |
AC25 | INC HL | |||
AC26 | LD H,(HL) | |||
AC27 | LD L,A | |||
AC28 | LD A,($AB66) | Fetch zoombox_x again | ||
AC2B | ADD A,L | Combine with game window start address | ||
AC2C | LD L,A | |||
AC2D | EX DE,HL | Get the source pointer back in HL | ||
AC2E | LD A,($AB67) | Fetch zoombox_width | ||
AC31 | LD ($AC55),A | Self modify the 'SUB $00' at AC54 | ||
AC34 | NEG | Compute source skip (24 - width) | ||
AC36 | ADD A,$18 | |||
AC38 | LD ($AC4D),A | Self modify the 'LD A,$00' at AC4C | ||
AC3B | LD A,($AB69) | Fetch zoombox_height (number of rows to copy) | ||
AC3E | LD B,A | Set outer iterations | ||
Start loop (outer) -- once for every row
|
||||
zoombox_fill_2 | AC3F | PUSH BC | Preserve iteration counter | |
AC40 | PUSH DE | Preserve destination pointer | ||
AC41 | LD A,$08 | 8 iterations / 1 row | ||
Start loop (inner) -- once for every line
|
||||
zoombox_fill_3 | AC43 | EX AF,AF' | Bank the counter | |
AC44 | LD A,($AB67) | Fetch zoombox_width into BC | ||
AC47 | LD C,A | |||
AC48 | LD B,$00 | |||
AC4A | LDIR | Copy zoombox_width bytes from HL to DE, then advance those pointers | ||
AC4C | LD A,$00 | Load the (self modified) source skip | ||
AC4E | ADD A,L | Advance the source pointer by source skip bytes | ||
AC4F | LD L,A | |||
AC50 | JR NC,zoombox_fill_4 | |||
AC52 | INC H | |||
zoombox_fill_4 | AC53 | LD A,E | Subtract the (self modified) zoombox_width from the destination pointer to undo LDIR's post-increment | |
AC54 | SUB $00 | |||
AC56 | LD E,A | |||
AC57 | INC D | Move to the next scanline by incrementing high byte | ||
AC58 | EX AF,AF' | Unbank the inner loop counter | ||
AC59 | DEC A | ...loop (inner) | ||
AC5A | JP NZ,zoombox_fill_3 | |||
AC5D | POP DE | Restore the destination pointer | ||
AC5E | EX DE,HL | Exchange | ||
AC5F | LD BC,$0020 | Set the row-to-row delta to 32 | ||
AC62 | LD A,L | Isolate | ||
AC63 | CP $E0 | Is A < 224? This sets the C flag if we're NOT at the end of the current third of the screen | ||
AC65 | JR C,zoombox_fill_5 | Jump over if so | ||
AC67 | LD B,$07 | Otherwise set the stride to $0720 so we will step forward to the next third of the screen. In this case HL is of the binary form 010ttyyy111xxxxx. Adding $0720 - binary 0000011100100000 - will result in 010TTyyy000xxxxx where the 't' bits are incremented, moving the pointer forward to the next screen third | ||
zoombox_fill_5 | AC69 | ADD HL,BC | Step | |
AC6A | EX DE,HL | Exchange back | ||
AC6B | POP BC | Pop the outer loop counter | ||
AC6C | DJNZ zoombox_fill_2 | ...loop (outer) | ||
AC6E | RET | Return |
Prev: ABA0 | Up: Map | Next: AC6F |