Prev: 858C Up: Map Next: 8684
85CC: Display the title screen and play the theme tune
Used by the routines at 8400, 870E and 8944.
The first thing this routine does is initialise some game status buffer variables in preparation for the next game.
85CC XOR A A=0
85CD LD ($8407),A Initialise the current cavern number at 8407
85D0 LD ($8459),A Initialise the Kempston joystick indicator at 8459
85D3 LD ($845A),A Initialise the game mode indicator at 845A
85D6 LD ($845B),A Initialise the in-game music note index at 845B
85D9 LD ($8458),A Initialise the screen flash counter at 8458
85DC LD A,$02 Initialise the number of lives remaining at 8457
85DE LD ($8457),A
85E1 LD HL,$845C Initialise the keypress flag in bit 0 at 845C
85E4 SET 0,(HL)
Next, prepare the screen.
85E6 LD HL,$4000 Clear the entire display file
85E9 LD DE,$4001
85EC LD BC,$17FF
85EF LD (HL),$00
85F1 LDIR
85F3 LD HL,$A000 Copy the graphic data at A000 to the top two-thirds of the display file
85F6 LD DE,$4000
85F9 LD BC,$1000
85FC LDIR
85FE LD HL,$483D Draw Willy at (9,29)
8601 LD DE,$8240
8604 LD C,$00
8606 CALL $8FF4
8609 LD HL,$FC00 Copy the attribute bytes from FC00 to the top third of the attribute file
860C LD DE,$5800
860F LD BC,$0100
8612 LDIR
8614 LD HL,$9E00 Copy the attribute bytes from 9E00 to the bottom two-thirds of the attribute file
8617 LD BC,$0200
861A LDIR
Now check whether there is a joystick connected.
861C LD BC,$001F This is the joystick port
861F DI Disable interrupts (which are already disabled)
8620 XOR A A=0
8621 IN E,(C) Combine 256 readings of the joystick port in A; if no joystick is connected, some of these readings will have bit 5 set
8623 OR E
8624 DJNZ $8621
8626 AND $20 Is a joystick connected (bit 5 reset)?
8628 JR NZ,$862F Jump if not
862A LD A,$01 Set the Kempston joystick indicator at 8459 to 1
862C LD ($8459),A
And finally, play the theme tune and check for keypresses.
862F LD IY,$846E Point IY at the theme tune data at 846E
8633 CALL $92DC Play the theme tune
8636 JP NZ,$8684 Start the game if ENTER or the fire button was pressed
8639 XOR A Initialise the game status buffer variable at 80DC; this will be used as an index for the message scrolled across the screen
863A LD ($80DC),A
863D LD A,($80DC) Pick up the message index from 80DC
8640 LD IX,$9D00 Point IX at the corresponding location in the message at 9D00
8644 LD IXl,A
8646 LD DE,$5060 Print 32 characters of the message at (19,0)
8649 LD C,$20
864B CALL $92BA
864E LD A,($80DC) Pick up the message index from 80DC
8651 AND $06 Keep only bits 1 and 2, and move them into bits 6 and 7, so that A holds 0x00, 0x40, 0x80 or 0xC0; this value determines the animation frame to use for Willy
8653 RRCA
8654 RRCA
8655 RRCA
8656 LD E,A Point DE at the graphic data for Willy's sprite (8200+A)
8657 LD D,$82
8659 LD HL,$483D Draw Willy at (9,29)
865C LD C,$00
865E CALL $8FF4
8661 LD BC,$0064 Pause for about 0.1s
8664 DJNZ $8664
8666 DEC C
8667 JR NZ,$8664
8669 LD BC,$BFFE Read keys H-J-K-L-ENTER
866C IN A,(C)
866E AND $01 Keep only bit 0 of the result (ENTER)
8670 CP $01 Is ENTER being pressed?
8672 JR NZ,$8684 If so, start the game
8674 LD A,($80DC) Pick up the message index from 80DC
8677 INC A Increment it
8678 CP $E0 Set the zero flag if we've reached the end of the message
867A LD ($80DC),A Store the new message index at 80DC
867D JR NZ,$863D Jump back unless we've finished scrolling the message across the screen
867F LD A,$40 Initialise the game mode indicator at 845A to 0x40: demo mode
8681 LD ($845A),A
This routine continues into the one at 8684.
Prev: 858C Up: Map Next: 8684