Prev: 38269 Up: Map Next: 38307
38280: Reset World Map
Used by the routine at Select_Game_Options.
Writes 0 to the second byte of each of the first 576 entries of the World_Map world map. The second byte of an entry holds the data of a rope (see Set_Up_Rope), which changes during the game.
The counters are set up so that the loop runs 64 times on the first pass and 256 times on each of the next two passes. The last 256 entries of the map (the last sixteen rows of rooms) are not reset.
Reset_World_Map 38280 LD HL,30336 Point at the end of the world map (Start_Game_Selection).
38283 LD DE,28672 Point at the start of the world map (World_Map).
38286 AND A Subtract the start from the end of the map to get the size of the map in bytes.
38287 SBC HL,DE
38289 EX DE,HL Exchange the registers so that DE holds the size and HL the address.
38290 INC HL Move to the second byte of the first entry.
38291 SRL D Halve the size of the map to get the number of entries.
38293 RR E
38295 LD C,D Copy the number of entries into the loop counters (the high byte into C and the low byte into B).
38296 LD B,E
Reset_World_Map_Loop 38297 LD (HL),0 Write 0 to the second byte of the entry.
38299 INC HL Move on to the second byte of the next entry.
38300 INC HL
38301 DJNZ Reset_World_Map_Loop Decrease the entry counter (low byte) and loop back until it is zero.
38303 DEC C Decrease the high byte of the entry counter and loop back until the second byte of every entry has been cleared.
38304 JR NZ,Reset_World_Map_Loop
38306 RET Return.
Prev: 38269 Up: Map Next: 38307