Prev: DEE1 Up: Map Next: E03D
DF08: Build the 2x2 window of map cells, and bring in the objects they hold
Used by the routines at start_landscape, fly_in_step and scroll_landscape.
HL is the map column (0-95, wrapping at both ends) and row. The four tile bytes -- (column, row), (column, row+1), (column+1, row), (column+1, row+1) -- are read from the map landscape_map (96 bytes a row, read_map_cell) into map_window_tile_bytes, and their tile records' addresses from tile_table into map_window_tiles. At row 28 the lower two are tile $20, at row 29 all four. In the fly-in, tile $3E is drawn as $AA.
In play (map_rebuild zero) it then refreshes the objects: the last two slots of ground_objects, kept for the player's items, are freed if their objects have left the window (drop_far_objects); each of the current player's 19 item records (from +$1D of score; four bytes: map column, map row, x, y; bit 7 of the first set when gone) that lies in the window is put into a free special slot as kind $0C or $1E, unless it is in one already (same_item_in_slot); the four ground-object slots at ground_objects are freed likewise; and spawn_column_objects brings in the map's objects for the window's two columns.
Input
HL Map column (L) and row (H)
load_map_window DF08 LD DE,$0060 Wrap the column; reset the window's pointer.
DF0B LD A,L
DF0C CP $FF
DF0E JR NZ,load_map_window_0
DF10 LD L,$5F
load_map_window_0 DF12 CP $60
DF14 JR NZ,load_map_window_1
DF16 LD L,$00
load_map_window_1 DF18 LD (view_column),HL
DF1B LD BC,map_window_tiles
DF1E LD (map_window_pointer),BC
DF22 PUSH HL The four tile bytes.
DF23 CALL read_map_cell
DF26 LD (map_window_tile_bytes),A
DF29 ADD HL,DE
DF2A LD A,(HL)
DF2B LD (map_window_tile_below),A
DF2E POP HL
DF2F INC L
DF30 CALL read_map_cell
DF33 LD (map_window_tile_right),A
DF36 ADD HL,DE
DF37 LD A,(HL)
DF38 LD (map_window_tile_below_right),A
DF3B LD A,(view_row) Below the map (rows $1C and $1D): never reached in the build's sessions.
DF3E CP $1C
DF40 JR NZ,load_map_window_2
DF42 LD A,$20
DF44 LD (map_window_tile_below),A
DF47 LD (map_window_tile_below_right),A
load_map_window_2 DF4A CP $1D
DF4C JR NZ,load_map_window_3
DF4E LD BC,$2020
DF51 LD (map_window_tile_bytes),BC
DF55 LD (map_window_tile_right),BC
load_map_window_3 DF59 LD A,(map_rebuild) Fly-in: tile $3E becomes $AA. (No tile $3E came into a fly-in in the build's sessions.)
DF5C BIT 7,A
DF5E JR Z,load_map_window_6
DF60 LD B,$04
DF62 LD HL,map_window_tile_bytes
load_map_window_4 DF65 LD A,(HL)
DF66 CP $3E
DF68 JR NZ,load_map_window_5
DF6A LD (HL),$AA
load_map_window_5 DF6C INC HL
DF6D DJNZ load_map_window_4
load_map_window_6 DF6F LD BC,map_window_tile_bytes The four tile-record addresses.
DF72 LD A,$04
load_map_window_7 DF74 EX AF,AF'
DF75 LD A,(BC)
DF76 LD L,A
DF77 LD H,$00
DF79 LD DE,tile_table
DF7C ADD HL,HL
DF7D ADD HL,DE
DF7E LD E,(HL)
DF7F INC HL
DF80 LD D,(HL)
DF81 LD HL,(map_window_pointer)
DF84 LD (HL),E
DF85 INC HL
DF86 LD (HL),D
DF87 INC HL
DF88 LD (map_window_pointer),HL
DF8B INC BC
DF8C EX AF,AF'
DF8D DEC A
DF8E JR NZ,load_map_window_7
DF90 LD A,(map_rebuild) Fly-in: no objects.
DF93 AND A
DF94 RET NZ
DF95 LD A,$0C Free the special slots whose objects have left.
DF97 LD (scratch_count),A
DF9A LD IX,pickup_record
DF9E LD B,$02
DFA0 CALL drop_far_objects
DFA3 LD IX,player_places The player's item records: the first 11 are numbered 0-10 with kind $0C, the last 8 numbered 0-7 with kind $1E.
DFA7 LD HL,(view_column)
DFAA LD A,(right_map_column)
DFAD LD D,A
DFAE LD BC,$1300
load_map_window_8 DFB1 LD A,C
DFB2 SUB $0B
DFB4 JR NZ,load_map_window_9
DFB6 LD C,A
DFB7 LD A,$1E
DFB9 LD (scratch_count),A
load_map_window_9 DFBC BIT 7,(IX+$00) Skip items gone or outside the window.
DFC0 JR NZ,load_map_window_13
DFC2 LD A,(IX+$00)
DFC5 CP L
DFC6 JR Z,load_map_window_10
DFC8 CP D
DFC9 JR NZ,load_map_window_13
load_map_window_10 DFCB LD A,H
DFCC INC A
DFCD CP (IX+$01)
DFD0 JR Z,load_map_window_11
DFD2 LD A,H
DFD3 CP (IX+$01)
DFD6 JR NZ,load_map_window_13
load_map_window_11 DFD8 LD IY,pickup_record Skip items already in a special slot.
DFDC CALL same_item_in_slot
DFDF JR Z,load_map_window_13
DFE1 LD IY,second_pickup_record
DFE5 CALL same_item_in_slot
DFE8 JR Z,load_map_window_13
DFEA LD IY,pickup_record Into the first free special slot: map column, row, x, y, item number, kind.
DFEE LD A,(IY+$00)
DFF1 INC A
DFF2 JR Z,load_map_window_12
DFF4 LD IY,second_pickup_record
load_map_window_12 DFF8 LD A,(IX+$00)
DFFB LD (IY+$01),A
DFFE LD A,(IX+$01)
E001 LD (IY+$04),A
E004 LD A,(IX+$02)
E007 LD (IY+$02),A
E00A LD A,(IX+$03)
E00D LD (IY+$05),A
E010 LD (IY+$13),C
E013 LD (IY+$0D),$FF
E017 LD A,(scratch_count)
E01A LD (IY+$00),A
load_map_window_13 E01D INC IX Next item.
E01F INC IX
E021 INC IX
E023 INC IX
E025 INC C
E026 DJNZ load_map_window_8
E028 LD IX,pickup_record Tidy the special slots; free the ground-object slots that have left; bring in the map's.
E02C LD B,$02
E02E CALL spawn_column_objects_3
E031 LD IX,ground_objects
E035 LD B,$04
E037 CALL drop_far_objects
E03A JP spawn_column_objects
Prev: DEE1 Up: Map Next: E03D