![]() |
Routines |
| Prev: ADBE | Up: Map | Next: AE98 |
|
Used by the routines at start_at_edge and prepare_draw.
The world is a grid of pages the size of the play area, 224 pixels across and 160 lines down; an object's position is its page column (+1) and x within that page (+2), and its page row (+4) and y within it (+5). The view's page column and row are kept in view_column and view_row, and the x and y in those pages at the play area's left edge and top in view_x and view_y; the landscape's scroll (scroll_landscape) keeps the screen offsets in origin_x and origin_y at 8 less the view's x and $B7 less its y, so that the screen x is the page x plus the one and the screen y the page y plus the other. The page column to the right of the view's is kept in right_map_column.
Across: an object in the view's page is visible from the view's x on, or straddling it -- and if it starts nine or more pixels left of it, so that it would be off the left of the screen, it is drawn in left-clip mode (+$10 bit 6, sprite_left_clip). One in the next page is visible if its x is short of the view's. One in the page to the left is kept only if it was drawn last pass and lies at the right of its page, when it is worked out as straddling the view's left edge (the $30 and $B0 keep the sums in range). Any other is freed (+0 = $FF): objects are dropped once they are out of the two pages the view spans.
Down: an object in the view's page row is visible if its bottom is below the view's top; one in the row below if its top is above the view's bottom. Any other is freed. An object that is in range but out of sight returns without being marked as on the screen, and so is not drawn this pass. A visible one has its screen x and y put in new_sprite_x and new_sprite_y and in +$11 and +$12, and bit 7 of +$10 set.
|
||||||||||
| place_on_screen | ADD8 | LD A,(DE) | Its width in pixels, and height | |||||||
| ADD9 | ADD A,A | |||||||||
| ADDA | ADD A,A | |||||||||
| ADDB | ADD A,A | |||||||||
| ADDC | LD B,A | |||||||||
| ADDD | INC DE | |||||||||
| ADDE | LD A,(DE) | |||||||||
| ADDF | LD C,A | |||||||||
| ADE0 | LD A,(view_x) | The view's x; the object's, made even | ||||||||
| ADE3 | LD E,A | |||||||||
| ADE4 | LD A,(IX+$02) | |||||||||
| ADE7 | AND $FE | |||||||||
| ADE9 | LD L,A | |||||||||
| ADEA | LD A,(right_map_column) | In the next page to the right? | ||||||||
| ADED | CP (IX+$01) | |||||||||
| ADF0 | JP Z,place_on_screen_5 | |||||||||
| ADF3 | LD A,(view_column) | In the view's page? | ||||||||
| ADF6 | CP (IX+$01) | |||||||||
| ADF9 | JR Z,place_on_screen_0 | |||||||||
| ADFB | LD A,(old_sprite_rows) | Neither: free it unless it was drawn last pass | ||||||||
| ADFE | AND A | |||||||||
| ADFF | JP Z,place_on_screen_9 | |||||||||
| AE02 | LD A,L | ...and it reaches the right end of the page to the left | ||||||||
| AE03 | ADD A,$17 | |||||||||
| AE05 | ADD A,B | |||||||||
| AE06 | JP NC,place_on_screen_9 | |||||||||
| AE09 | LD A,(IX+$02) | |||||||||
| AE0C | CP $80 | |||||||||
| AE0E | JP C,place_on_screen_9 | |||||||||
| AE11 | LD A,E | Shift both x's to keep the comparison in range | ||||||||
| AE12 | ADD A,$B0 | |||||||||
| AE14 | LD E,A | |||||||||
| AE15 | LD A,L | |||||||||
| AE16 | SUB $30 | |||||||||
| AE18 | LD L,A | |||||||||
| place_on_screen_0 | AE19 | LD A,L | From the view's x on: visible | |||||||
| AE1A | CP E | |||||||||
| AE1B | JR NC,place_on_screen_2 | |||||||||
| AE1D | ADD A,B | Left of the view's x: wholly left of it is out of sight | ||||||||
| AE1E | JR C,place_on_screen_1 | |||||||||
| AE20 | DEC A | |||||||||
| AE21 | CP E | |||||||||
| AE22 | RET C | |||||||||
| place_on_screen_1 | AE23 | LD A,E | Straddling, by nine pixels or more: left-clip mode | |||||||
| AE24 | SUB L | |||||||||
| AE25 | SUB $09 | |||||||||
| AE27 | JR C,place_on_screen_2 | |||||||||
| AE29 | SET 6,(IX+$10) | |||||||||
| AE2D | LD A,$01 | |||||||||
| AE2F | LD (sprite_left_clip),A | |||||||||
| place_on_screen_2 | AE32 | LD A,(view_column) | The page to the left: screen x is x less the view's x plus 8 | |||||||
| AE35 | CP (IX+$01) | |||||||||
| AE38 | JR Z,place_on_screen_3 | |||||||||
| AE3A | LD A,(right_map_column) | |||||||||
| AE3D | CP (IX+$01) | |||||||||
| AE40 | JR Z,place_on_screen_3 | |||||||||
| AE42 | LD A,L | |||||||||
| AE43 | SUB E | |||||||||
| AE44 | ADD A,$08 | |||||||||
| AE46 | LD L,A | |||||||||
| AE47 | JR place_on_screen_4 | |||||||||
| place_on_screen_3 | AE49 | LD A,(origin_x) | The view's page and the next: x plus the screen offset | |||||||
| AE4C | ADD A,L | |||||||||
| place_on_screen_4 | AE4D | LD (new_sprite_x),A | The screen x | |||||||
| AE50 | LD (IX+$11),A | |||||||||
| AE53 | JP place_on_screen_6 | |||||||||
| place_on_screen_5 | AE56 | LD A,L | The next page: visible only short of the view's x; 224 pixels on | |||||||
| AE57 | CP E | |||||||||
| AE58 | RET NC | |||||||||
| AE59 | ADD A,$E0 | |||||||||
| AE5B | LD L,A | |||||||||
| AE5C | JR place_on_screen_2 | |||||||||
| place_on_screen_6 | AE5E | LD L,(IX+$05) | Its y, and the view's | |||||||
| AE61 | LD A,(view_y) | |||||||||
| AE64 | LD E,A | |||||||||
| AE65 | LD A,(view_row) | In the view's page row? | ||||||||
| AE68 | CP (IX+$04) | |||||||||
| AE6B | JR NZ,place_on_screen_8 | |||||||||
| AE6D | LD A,L | Yes: visible if its bottom is below the view's top | ||||||||
| AE6E | DEC A | |||||||||
| AE6F | CP E | |||||||||
| AE70 | RET C | |||||||||
| AE71 | ADD A,$61 | |||||||||
| AE73 | LD L,A | |||||||||
| place_on_screen_7 | AE74 | LD A,(origin_y) | The screen y; it is on the screen | |||||||
| AE77 | ADD A,L | |||||||||
| AE78 | LD (new_sprite_y),A | |||||||||
| AE7B | LD (IX+$12),A | |||||||||
| AE7E | SET 7,(IX+$10) | |||||||||
| AE82 | RET | |||||||||
| place_on_screen_8 | AE83 | INC A | In the row below? If not, free it | |||||||
| AE84 | CP (IX+$04) | |||||||||
| AE87 | JP NZ,place_on_screen_9 | |||||||||
| AE8A | LD A,L | Visible if its top is above the view's bottom | ||||||||
| AE8B | SUB C | |||||||||
| AE8C | JR C,place_on_screen_7 | |||||||||
| AE8E | CP E | |||||||||
| AE8F | RET NC | |||||||||
| AE90 | JP place_on_screen_7 | |||||||||
| place_on_screen_9 | AE93 | LD (IX+$00),$FF | Free the record | |||||||
| AE97 | RET | |||||||||
| Prev: ADBE | Up: Map | Next: AE98 |