Prev: 60405 Up: Map Next: 60506
60473: Colourise Preview Grid
Used by the routines at Game_Loop, Game_Initialisation and LevelComplete.
Colours in the green checkerboard attribute pattern. Note, it doesn't alter the top row at all - only the rows which will have content in them.
Colourise_PreviewGrid 60473 LD B,4 Set a counter in B for 4 rows.
60475 LD DE,22678 DE=22678 (attribute buffer location).
60478 LD HL,60591 HL=AttributeData_PreviewGrid.
PreviewGrid_RowCounter_Loop 60481 PUSH BC Stash the row counter on the stack.
60482 LD B,2 Set a counter in B for 2 character blocks per square.
PreviewGrid_BlockCounter_Loop 60484 PUSH BC Stash the block counter and the attribute reference pointer on the stack.
60485 PUSH HL
60486 LD BC,10 Copy 0010 bytes from HL to DE.
60489 LDIR
60491 LD HL,22 DE+=0022.
60494 ADD HL,DE
60495 EX DE,HL
60496 POP HL Restore the attribute reference pointer and the block counter from the stack.
60497 POP BC
60498 DJNZ PreviewGrid_BlockCounter_Loop Decrease block counter by one and loop back to PreviewGrid_BlockCounter_Loop until the block counter is zero.
60500 POP BC Restore the row counter from the stack.
This is how it becomes checkered, we move the pointer forward by two (each block is two character blocks wide) and then it can alternate between the two attribute values. Although we copy 10 bytes - the data is actually 16 bytes long, to cope with this reference movement.
60501 INC HL Increment the attribute reference pointer by two.
60502 INC HL
60503 DJNZ PreviewGrid_RowCounter_Loop Decrease the row counter by one and loop back to PreviewGrid_RowCounter_Loop until all the rows have been coloured in.
60505 RET Return.
Prev: 60405 Up: Map Next: 60506