Prev: AF01 Up: Map Next: AF7F
AF3C: Initialise New Game
Used by the routine at GameStart.
Start a new game: reset display buffers, tick counter, menu glyphs and room state for Learner or Super Berk.
Initialise_New_Game AF3C CALL Backup_Entity_And_Game_State Call Backup_Entity_And_Game_State to backup Entity And Game State.
AF3F LD HL,$63A0 Point HL at Primary Display Buffer (PrimaryDisplayBuffer).
AF42 LD ($72F5),HL Store HL in Pointer: Current Display Buffer (Pointer_CurrentDisplayBuffer).
AF45 XOR A Clear the display-buffer select flag.
AF46 LD ($72EA),A Set Display Buffer Select Flag (DisplayBufferSelectFlag).
AF49 LD A,$64 Load A with 64 as the initial game tick counter.
This entry point is used by the routine at Initialise_Room_Display.
Set the game tick counter, clear both display buffers, and set the border/speaker state.
Initialise_New_Game_SetTickCounter AF4B LD ($72F2),A Set the game tick counter (GameTickCounter).
AF4E CALL Clear_BothDisplayBuffers Call Clear_BothDisplayBuffers to clear both display buffers.
AF51 LD A,$02 Load A with 02.
AF53 CALL Set_BorderSpeakerState Call Set_BorderSpeakerState to set Border And Speaker State.
This entry point is used by the routine at Initialise_Room_Display.
Point the glyph printer at Data_MenuGlyphBitmaps and choose the Learner (7A) vs Super Berk (68) room byte.
Initialise_New_Game_SetGlyphPointer AF56 LD HL,$AD17 Point HL at the menu/glyph bitmap data (Data_MenuGlyphBitmaps).
AF59 LD ($72F9),HL Write the pointer in HL to the temporary screen pointer (Pointer_CurrentCharacterSet).
AF5C LD E,$04 Load E with 04 as a small loop/position count.
AF5E LD A,($72A9) Load A with the Learner Berk mode flag (Flag_LearnerBerkMode).
AF61 OR A Is Learner Berk mode flag zero? If so, jump to Initialise_New_Game_SuperBerkRoomByte.
AF62 JR Z,Initialise_New_Game_SuperBerkRoomByte
AF64 LD A,$7A Load A with 7A.
AF66 JR Initialise_New_Game_WriteRoomByte Jump to Initialise_New_Game_WriteRoomByte to set the temporary room/state byte.
This entry point is used by the routine at Initialise_Room_Display.
Super Berk path: use room/state byte 68.
Initialise_New_Game_SuperBerkRoomByte AF68 LD A,$68 Load A with 68.
This entry point is used by the routine at Initialise_Room_Display.
Advance the small position count before writing the room/state byte.
Initialise_New_Game_Branch AF6A INC E Advance the low byte of the pointer/offset in DE.
Write the room/state byte and prepare to fill the attribute-file base row.
Initialise_New_Game_WriteRoomByte AF6B LD ($7307),A Set the temporary room/state byte (CurrentTextAttribute).
AF6E LD B,$80 Load B with 80 as a loop counter.
AF70 LD D,$00 Clear D (high byte of a pointer/offset).
AF72 LD HL,$5A80 Point HL at the attribute-file base (5A80 (attribute buffer)).
Print a full attribute-file row of glyphs, then initialise the room display.
Initialise_New_Game_PrintAttrRow AF75 CALL Print_Character Call Print_Character to print Character.
AF78 INC HL Advance 5A80 (attribute buffer) by one byte.
AF79 DJNZ Initialise_New_Game_PrintAttrRow Decrease the loop counter in B and jump to Initialise_New_Game_PrintAttrRow if more iterations remain.
AF7B CALL Initialise_Room_Display Call Initialise_Room_Display to initialise the room display.
AF7E RET Return.
Prev: AF01 Up: Map Next: AF7F