![]() |
Routines |
| Prev: D46B | Up: Map | Next: D4CD |
|
Used by the routine at zero_fg_obj_tail.
A foreground template is six bytes: the graphic, four bytes that become bytes 4 to 7 of the record (half-sizes, height, flags), and an offset byte. The position comes from the room's location byte, which is a cell on a grid: bits 0 to 2 the x cell, bits 3 to 5 the y cell, bits 6 and 7 the level. Cells are 16 units apart starting at $48, and levels 12 units apart starting at the floor height in $5BAE. The offset byte's bits 0 and 1 add half a cell in x and y, and the rest of it, a multiple of 4, is added to the height -- which is how something can stand on top of a block or sit between two cells.
|
||||||||||||
| next_fg_obj_sprite | D46C | LD A,(HL) | graphic into byte 0, then four template bytes into bytes 4 to 7 | |||||||||
| D46D | INC HL | |||||||||||
| D46E | LD (IY+$00),A | |||||||||||
| D471 | LD A,(HL) | |||||||||||
| D472 | INC HL | |||||||||||
| D473 | LD (IY+$04),A | |||||||||||
| D476 | LD A,(HL) | |||||||||||
| D477 | INC HL | |||||||||||
| D478 | LD (IY+$05),A | |||||||||||
| D47B | LD A,(HL) | |||||||||||
| D47C | INC HL | |||||||||||
| D47D | LD (IY+$06),A | |||||||||||
| D480 | LD A,(HL) | |||||||||||
| D481 | INC HL | |||||||||||
| D482 | LD (IY+$07),A | |||||||||||
| D485 | LD A,(IX+$08) | byte 8: the room | ||||||||||
| D488 | LD (IY+$08),A | |||||||||||
| D48B | LD A,(HL) | x = $48 + 16 * the x cell, plus 8 if bit 0 of the offset byte is set | ||||||||||
| D48C | RLCA | |||||||||||
| D48D | RLCA | |||||||||||
| D48E | RLCA | |||||||||||
| D48F | AND $08 | |||||||||||
| D491 | LD E,A | |||||||||||
| D492 | LD A,D | |||||||||||
| D493 | RLCA | |||||||||||
| D494 | RLCA | |||||||||||
| D495 | RLCA | |||||||||||
| D496 | RLCA | |||||||||||
| D497 | AND $70 | |||||||||||
| D499 | ADD A,E | |||||||||||
| D49A | ADD A,$48 | |||||||||||
| D49C | LD (IY+$01),A | |||||||||||
| D49F | LD A,(HL) | y = $48 + 16 * the y cell, plus 8 if bit 1 is set | ||||||||||
| D4A0 | RLCA | |||||||||||
| D4A1 | RLCA | |||||||||||
| D4A2 | AND $08 | |||||||||||
| D4A4 | LD E,A | |||||||||||
| D4A5 | LD A,D | |||||||||||
| D4A6 | RLCA | |||||||||||
| D4A7 | AND $70 | |||||||||||
| D4A9 | ADD A,E | |||||||||||
| D4AA | ADD A,$48 | |||||||||||
| D4AC | LD (IY+$02),A | |||||||||||
| D4AF | LD A,D | z = the floor height + (12 * the level + the offset byte) AND $FC | ||||||||||
| D4B0 | RLCA | |||||||||||
| D4B1 | RLCA | |||||||||||
| D4B2 | AND $03 | |||||||||||
| D4B4 | ADD A,A | |||||||||||
| D4B5 | ADD A,A | |||||||||||
| D4B6 | LD E,A | |||||||||||
| D4B7 | ADD A,A | |||||||||||
| D4B8 | ADD A,E | |||||||||||
| D4B9 | ADD A,(HL) | |||||||||||
| D4BA | INC HL | |||||||||||
| D4BB | AND $FC | |||||||||||
| D4BD | LD E,A | |||||||||||
| D4BE | LD A,($5BAE) | |||||||||||
| D4C1 | ADD A,E | |||||||||||
| D4C2 | LD (IY+$03),A | |||||||||||
| D4C5 | PUSH BC | on to byte 9 of the record; 23 bytes to clear | ||||||||||
| D4C6 | LD BC,$0009 | |||||||||||
| D4C9 | ADD IY,BC | |||||||||||
| D4CB | LD B,$17 | |||||||||||
| Prev: D46B | Up: Map | Next: D4CD |