Prev: EACC Up: Map Next: EB4C
EB1A: Make an object record from a type, a place and its template
Used by the routines at DO_ROOM_COMMAND and PLACE_ROOM_OBJECTS.
Makes the record at IX for an object whose type is at HL, from the type's template and the bytes that follow the type, and counts it in OBJECT_COUNT. It serves both the object table (PLACE_ROOM_OBJECTS) and the objects a room's own commands put down in object mode (DO_ROOM_COMMAND), which are written the same way as the table's things without the room.
A type below $46 has an 11-byte template (TEMPLATES) and four bytes after it: +12 (the thing's kind, and whether it can be picked up), then its place, +6 to +8 (along the floor, the height of its top, across the floor). The template gives +0 to +5 (where its sprite goes on the screen, the sprite's size and the sprite), +9 to +11 (its length along, its height and its length across, each from the corner at +6 to +8) and two more bytes: +14, whose low nibble is the kind of movement the object dispatcher (CHE3D) acts on, and +16 (bits 0-4: 0 for an object that stays put, which the object dispatcher passes over, else 16 plus its weight, PICK_UP_LOOK_ON; bit 5 set while it is carried or gone).
A type from $46 has a 9-byte template (LARGE_TEMPLATES, less $46) and nine bytes after it: the place, then six bytes for +13 to +18, which the door code reads (BUMPED). Its +12 is 1, the kind that the object dispatcher passes over. A room's commands only ever put down types below $46 -- they take five bytes each (DO_ROOM_COMMAND), which would not do for these.
The template's screen position is right for an object standing at 50, 50 with its floor at 50, so the record is first given that place (the top is 50 plus the height) and ISO_MOVE moves it from there to the place asked for plus the origin, moving the screen position with it. Then a thing's movement gets its starting state by kind: +15 is 1, and +13 and +17 are set for kinds 3 and 4-10 (and for kind 2, which no template has, so that code never runs).
Input
HL The type, followed by its bytes
IX The record to fill (FREE_RECORD)
Output
HL The byte after them
IX The next record, which FREE_RECORD is left at
PLACE_OBJECT EB1A LD A,(HL) the type, kept for PLACE_ROOM_OBJECTS
EB1B LD (PLACED_TYPE),A
EB1E RES 6,(IY+WORK_RECORD-V) a type from $46: +12 is 1, and bit 6 of IY+$7D says so below
EB22 CP $46
EB24 JR C,PLACE_OBJECT_0
EB26 LD (IX+OBJ_KIND),$01
EB2A SET 6,(IY+WORK_RECORD-V)
PLACE_OBJECT_0 EB2E INC HL past the type; one more record in use
EB2F INC (IY+OBJECT_COUNT-V)
EB32 PUSH IX the templates for types below $46, 11 bytes each...
EB34 EXX
EB35 LD DE,$000B
EB38 LD HL,TEMPLATES
EB3B INC A
EB3C BIT 6,(IY+WORK_RECORD-V) ...or from $46, 9 bytes each
EB40 JR Z,PLACE_FROM_TEMPLATE_0
EB42 LD HL,LARGE_TEMPLATES
EB45 LD DE,$0009
EB48 SUB $46
EB4A JR PLACE_FROM_TEMPLATE_0
Prev: EACC Up: Map Next: EB4C