Prev: E859 Up: Map Next: E89C
E87B: Colourise Preview Grid
Used by the routines at DemoEntryPoint, Game_Initialisation and D69F.
This routine is identical to Colourise_PreviewGrid in the main game code.
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 E87B LD B,$04 Set a counter in B for 04 rows.
E87D LD DE,$5896 DE=5896 (attribute buffer location).
E880 LD HL,$E8F1 HL=AttributeData_PreviewGrid.
PreviewGrid_RowCounter_Loop E883 PUSH BC Stash the row counter on the stack.
E884 LD B,$02 Set a counter in B for 02 character blocks per square.
PreviewGrid_BlockCounter_Loop E886 PUSH BC Stash the block counter and the attribute reference pointer on the stack.
E887 PUSH HL
E888 LD BC,$000A Copy 000A bytes from HL to DE.
E88B LDIR
E88D LD HL,$0016 DE+=0016.
E890 ADD HL,DE
E891 EX DE,HL
E892 POP HL Restore the attribute reference pointer and the block counter from the stack.
E893 POP BC
E894 DJNZ PreviewGrid_BlockCounter_Loop Decrease block counter by one and loop back to PreviewGrid_BlockCounter_Loop until the block counter is zero.
E896 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 0A bytes - the data is actually 10 bytes long, to cope with this reference movement.
E897 INC HL Increment the attribute reference pointer by two.
E898 INC HL
E899 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.
E89B RET Return.
Prev: E859 Up: Map Next: E89C