Prev: 53901 Up: Map Next: 54098
53921: Game Initialisation
Used by the routine at Game_Loop.
Input
HL Pointer to level data
Game_Initialisation 53921 LD C,(HL) The first byte is the length of the level data, store this in C.
53922 LD A,C A=data length.
53923 LD B,0 Initialise B to 0 for the copy command.
53925 INC HL Increment the level data pointer by one.
53926 LD DE,58023 Copy the level data from the current level data to 58023.
53929 LDIR
53931 LD DE,55317 The next 0018 bytes are timers for the doors and cracks, each level has a different set. Copy these starting at Timer_DoorTop.
53934 LD BC,18
53937 LDIR
53939 LD E,(HL) Fetch the pointer for the level graphics data and write this to *LevelGraphicsData.
53940 INC HL
53941 LD D,(HL)
53942 LD (55442),DE
53946 LD HL,55391 HL=55391.
53949 LD B,12 B=12.
Game_Initialisation_0 53951 LD (HL),1 Write 1 to *HL.
53953 INC HL Increment HL by one.
53954 DJNZ Game_Initialisation_0 Decrease counter by one and loop back to Game_Initialisation_0 until counter is zero.
53956 LD DE,57953 Copy 0049 bytes of data from 54513 to InGame_Tiles_Top.
53959 LD HL,54513
53962 LD BC,49
53965 LDIR
Populates Table_Tiles with:
58003 58004 58005 58006 58007
1 2 3 4 5
58008 58009 58010 58011 58012
6 7 8 9 10
58013 58014 58015 58016 58017
11 12 13 14 15
58018 58019 58020 58021 58022
16 17 18 19 20
53967 LD HL,58003 HL=Table_Tiles.
53970 LD B,20 Set a counter in B for each tile (5x4).
53972 LD A,1 Tile numbering starts from 1.
PopulateTileTable_Loop 53974 LD (HL),A Write the tile ID to *HL.
53975 INC HL Increment the tile table pointer by one.
53976 INC A Increment the tile ID by one.
53977 DJNZ PopulateTileTable_Loop Decrease the tile counter by one and loop back to PopulateTileTable_Loop until the table has been populated.
Copy default values to 55336.
53979 LD HL,55417 HL=Defaults.
53982 LD DE,55336 DE=55336.
PopulateDefaults_Loop 53985 LD A,(HL) Load the byte from *HL and store it in A.
53986 CP 255 Jump to PopulateDefaults_Done if this byte is the terminator (255).
53988 JR Z,PopulateDefaults_Done
53990 LD B,A Load the byte into B this is the count/ repeater value.
53991 INC HL Increment the defaults pointer by one.
53992 LD A,(HL) Load the defaults byte from *HL and store it in A.
53993 INC HL Increment the defaults pointer by one.
RepeatDefault_Loop 53994 LD (DE),A Write the defaults byte to the destination.
53995 INC DE Increment the destination pointer by one.
53996 DJNZ RepeatDefault_Loop Decrease repeater count by one and loop back to RepeatDefault_Loop until the defaults byte has been written this number of times.
53998 JR PopulateDefaults_Loop Jump back to PopulateDefaults_Loop.
The computed values are done, copy the last six values over.
PopulateDefaults_Done 54000 INC HL Copy the last 0006 bytes from 55432 to 55370.
54001 LD BC,6
54004 LDIR
Write three random numbers between 1-32 to 55376, 55377 and 55378.
54006 LD B,3 B=3.
PickThreeRandomNumbers_Loop 54008 LD A,R A=the contents of the Memory Refresh Register.
54010 AND %00011111 Ensure this number is between 1-32.
54012 INC A
54013 LD (DE),A Write this number to the destination pointer.
54014 INC DE Increment the destination pointer by one.
54015 DJNZ PickThreeRandomNumbers_Loop Decrease counter by one and loop back to PickThreeRandomNumbers_Loop until counter is zero.
54017 LD HL,55839 Write 55839 to:
54020 LD (55379),HL
54023 LD (55381),HL
54026 LD (55383),HL
54029 LD (55385),HL
54032 LD HL,58002 HL=58002.
54035 LD BC,2000 BC=2000.
54038 LD A,R A=the contents of the Memory Refresh Register.
54040 ADD A,C A+=C.
54041 LD C,A C=A.
Game_Initialisation_1 54042 PUSH BC Stash BC, HL and HL on the stack.
54043 PUSH HL
54044 PUSH HL
54045 CALL GenerateRandomNumber Call GenerateRandomNumber.
54048 ADD HL,BC HL+=random number.
54049 EX DE,HL Exchange the DE and HL registers.
54050 POP HL Restore HL from the stack.
54051 CALL GenerateRandomNumber Call GenerateRandomNumber.
54054 ADD HL,BC HL+=random number.
54055 LD B,(HL) B=*HL.
54056 LD A,(DE) Write *DE to *HL.
54057 LD (HL),A
54058 LD A,B Write B to *DE.
54059 LD (DE),A
54060 POP HL Restore HL and BC from the stack.
54061 POP BC
54062 DEC BC Decrease BC by one.
54063 LD A,B Jump to Game_Initialisation_1 if BC is not zero.
54064 OR C
54065 JR NZ,Game_Initialisation_1
Populate the level, bonus and score numbering in the dashboard.
54067 CALL Print_Level Call Print_Level.
54070 CALL Print_Bonus Call Print_Bonus.
54073 CALL Print_Score Call Print_Score.
Paint the preview grid pattern.
54076 CALL Colourise_PreviewGrid Call Colourise_PreviewGrid.
Small pause...
54079 LD BC,40000 BC=40000.
SetUp_Pause_Loop 54082 DEC BC Decrease BC by one.
54083 LD A,B Jump to SetUp_Pause_Loop until BC is zero.
54084 OR C
54085 JR NZ,SetUp_Pause_Loop
Play the "static" animation in the preview area.
54087 CALL StaticAnimation Call StaticAnimation.
Display the current preview image.
54090 LD IX,(55442) IX=*LevelGraphicsData.
54094 CALL GeneratePicture Call GeneratePicture.
54097 RET Return.
Prev: 53901 Up: Map Next: 54098