Manic Miner: Routine at 34436

| Routines

34436: Start the game (or demo mode)

Used by the routine at 34252.
34436 | LD HL,33829 | Initialise the score at 33829
34439 | LD DE,33830
34442 | LD BC,9
34445 | LD (HL),48
34447 | LDIR
This entry point is used by the routines at 34574 (when teleporting into a cavern or reinitialising the current cavern after Willy has lost a life) and 36904.
34449 | LD A,(33799) | Pick up the number of the current cavern from 33799
34452 | SLA A | Point HL at the first byte of the cavern definition
34454 | SLA A
34456 | ADD A,176
34458 | LD H,A
34459 | LD L,0
34461 | LD DE,24064 | Copy the cavern's attribute bytes into the buffer at 24064
34464 | LD BC,512
34467 | LDIR
34469 | LD DE,32768 | Copy the rest of the cavern definition into the game status buffer at 32768
34472 | LD BC,512
34475 | LDIR
34477 | CALL 35445 | Draw the current cavern to the screen buffer at 28672
34480 | LD HL,20480 | Clear the bottom third of the display file
34483 | LD DE,20481
34486 | LD BC,2047
34489 | LD (HL),0
34491 | LDIR
34493 | LD IX,32768 | Print the cavern name (see 32768) at (16,0)
34497 | LD C,32
34499 | LD DE,20480
34502 | CALL 37562
34505 | LD IX,33816 | Print 'AIR' (see 33816) at (17,0)
34509 | LD C,3
34511 | LD DE,20512
34514 | CALL 37562
34517 | LD A,82 | Initialise A to 82; this is the MSB of the display file address at which to start drawing the bar that represents the air supply
34519 | LD H,A | Prepare HL and DE for drawing a row of pixels in the air bar
34520 | LD D,A
34521 | LD L,36
34523 | LD E,37
34525 | LD B,A | Save the display file address MSB in B briefly
34526 | LD A,(32956) | Pick up the value of the initial air supply from 32956
34529 | SUB 36 | Now C determines the length of the air bar (in cell widths)
34531 | LD C,A
34532 | LD A,B | Restore the display file address MSB to A
34533 | LD B,0 | Now BC determines the length of the air bar (in cell widths)
34535 | LD (HL),255 | Draw a single row of pixels across C cells
34537 | LDIR
34539 | INC A | Increment the display file address MSB in A (moving down to the next row of pixels)
34540 | CP 86 | Have we drawn all four rows of pixels in the air bar yet?
34542 | JR NZ,34519 | If not, jump back to draw the next one
34544 | LD IX,33839 | Print 'High Score 000000 Score 000000' (see 33839) at (19,0)
34548 | LD DE,20576
34551 | LD C,32
34553 | CALL 37562
34556 | LD A,(32883) | Pick up the border colour for the current cavern from 32883
34559 | LD C,254 | Set the border colour
34561 | OUT (C),A
34563 | LD A,(33882) | Pick up the game mode indicator from 33882
34566 | OR A | Are we in demo mode?
34567 | JR Z,34574 | If not, enter the main loop now
34569 | LD A,64 | Reset the game mode indicator at 33882 to 64 (we're in demo mode)
34571 | LD (33882),A
This routine continues into the main loop at 34574.