Prev: 38003 Up: Map Next: 38205
38024: Initialise data and start a new game
Used by the routine at 37689.
Input
IY 23610
38024 LD A,(23672) Load A with LSB of frame counter...
38027 AND 127 ...and clear bit 7 to leave random number between 0 and 127
38029 JR Z,38024 If number is zero then loop back to 38024
38031 LD B,A Load B with generated number
38032 AND 96 If neither bit 5 not bit 6 is set (see trivia)...
38034 JR Z,38024 ...then loop back to 38024 to generate another number
38036 LD A,B Load A with generated number...
38037 LD (23484),A ...and store at 23484 as current password number
38040 LD HL,51742 Point HL at start of "---" segment for password number in Rachel's help text at 51709
38043 CALL 46837 Splice numeric password data as a string into Rachel's help text
38046 CALL 47897 Play upward scale sound
38049 LD A,70 Store 70 (yellow INK, black PAPER, BRIGHT) at 23695...
38051 LD (23695),A ...
38054 LD HL,49282 Copy data from 49282 - 49353 (characters' initial stats)...
38057 LD DE,24768 ...to 24768 - 24839 (characters' current stats)...
38060 LD BC,72 ...
38063 LDIR ...
38065 LD HL,48603 Copy data from 48603 - 48610 (Magic Knight's initial data)...
38068 LD BC,8 ...to 24840 - 24847 (Magic Knight's current data)...
38071 LDIR ...
38073 LD HL,48611 Copy data from 48611 - 48660 (characters' initial inventories)...
38076 LD BC,50 ...to 24848 - 24897 (characters' current inventories)...
38079 LDIR ...
38081 LD HL,48661 Copy data from 48661 - 48684 (characters' initial positions)...
38084 LD BC,24 ...to 24898 - 24921 (characters' current positions)...
38087 LDIR ...
38089 LD HL,48685 Copy data from 48685 - 48810 (objects' initial positions)...
38092 LD BC,126 ...to 24922 - 25047 (objects' current positions)...
38095 LDIR ...
38097 CALL 46183 Set Magic Knight's available action flags
38100 XOR A Load A and HL with zero...
38101 LD H,A ...
38102 LD L,A ...
38103 LD (23560),A Clear last pressed key
38106 LD (40605),A Reset Bearwoolf-removed flag
38109 LD (23486),A Store zero at 23486 (see trivia)
38112 LD (23460),A Set 1/50 second counter (time elapsed since last second) to zero
38115 LD (23458),HL Set minute counter and second counter to zero
38118 LD (23675),HL Reset all interrupt routine flags
38121 NOP Do nothing (see trivia)...
38122 NOP ...
38123 NOP ...
38124 LD (23673),HL Set two most significant bytes of frame counter to zero
The next instruction relates to the "locate" command. See trivia.
38127 LD (23471),HL Set x- & y- coordinates of top-left character of currently glowing "locate compass" component to zero
38130 INC A Set animate-puff-of-smoke flag...
38131 LD (23480),A ...
38134 LD (64688),A Set do-not-draw-storm-cloud flag
38137 LD A,36 Set number of hours left to 36...
38139 LD (23457),A ...
38142 LD A,135 Set room layout data instruction at 59866...
38144 LD (59866),A ...to 135 (draw security door 1/3)
38147 INC A Set room layout data instruction at 59867...
38148 LD (59867),A ...to 136 (draw security door 2/3)
38151 INC A Set room layout data instruction at 59868...
38152 LD (59868),A ...to 137 (draw security door 3/3)
38155 LD HL,59006 Set room layout data pointer for room 3 to 59006...
38158 LD (58847),HL ...i.e. include Grunter graphic in room layout
38161 LD B,6 Load A with random number in range 0-5...
38163 CALL 64829 ...
38166 LD (23703),A ...and store as index of required disquise
38169 LD A,(23672) Load A with LSB of frame counter...
38172 AND 7 ...clear bits 3-7 to leave random number between 0 and 7...
38174 LD (23713),A ...and set index of current Crystal Ball substring to this value
38177 ADD A,4 Add four to A...
38179 AND 7 ...clear bits 3-7 to leave random number between 0 and 7...
38181 LD (23714),A ...and set index of current Scroll substring to this value
38184 LD A,36 Set index of next object to be laid by Chicken to 36 (Golden Egg)...
38186 LD (23466),A ...
38189 LD A,12 Set Storm Cloud's current room to 12 (Outdoors, 11, The Spooky Forest, 3)...
38191 LD (23715),A ...
38194 LD A,7 Move Magic Knight into Outdoors, 6 (The Sword in the Concrete), draw room and initialise room-specific data...
38196 CALL 38841 ...
38199 SET 0,(IY+65) Set game-in-progress flag
38203 JR 38208 Jump into main game loop (process keyboard input and move Magic Knight or enter menus)
Prev: 38003 Up: Map Next: 38205