Prev: 957D Up: Map Next: 95A3
9588: Reset World Map
Used by the routine at Select_Game_Options.
Writes 00 to the second byte of each of the first 0240 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 40 times on the first pass and 0100 times on each of the next two passes. The last 0100 entries of the map (the last sixteen rows of rooms) are not reset.
Reset_World_Map 9588 LD HL,$7680 Point at the end of the world map (Start_Game_Selection).
958B LD DE,$7000 Point at the start of the world map (World_Map).
958E AND A Subtract the start from the end of the map to get the size of the map in bytes.
958F SBC HL,DE
9591 EX DE,HL Exchange the registers so that DE holds the size and HL the address.
9592 INC HL Move to the second byte of the first entry.
9593 SRL D Halve the size of the map to get the number of entries.
9595 RR E
9597 LD C,D Copy the number of entries into the loop counters (the high byte into C and the low byte into B).
9598 LD B,E
Reset_World_Map_Loop 9599 LD (HL),$00 Write 00 to the second byte of the entry.
959B INC HL Move on to the second byte of the next entry.
959C INC HL
959D DJNZ Reset_World_Map_Loop Decrease the entry counter (low byte) and loop back until it is zero.
959F DEC C Decrease the high byte of the entry counter and loop back until the second byte of every entry has been cleared.
95A0 JR NZ,Reset_World_Map_Loop
95A2 RET Return.
Prev: 957D Up: Map Next: 95A3