Prev: $BE08 Up: Map Next: $BFF5
$BE09: Change the characters' names if required
This corresponds to $FA49 in the ZX Spectrum version.
Called from the main loop at $0800.
$BE09 JSR $2E13 Prepare for a new game.
$BE0C LDX #$00 X will count the characters from little boy no. 1 to ERIC.
$BE0E LDY #$01 The second byte of a character's buffer holds his x-coordinate.
$BE10 LDA #$60 Prepare to address the character buffers, starting with little boy no. 1's at $7860.
$BE12 STA $50
$BE14 LDA #$78
$BE16 STA $51
$BE18 TXA Set A to 0.
$BE19 STA ($50),Y Set the x-coordinate of every character to 0. Given that the leftmost column of the skool on screen has been initialised to 32, this places the character off screen to the left.
$BE1B INC $51
$BE1D NOP
$BE1E NOP
$BE1F NOP
$BE20 NOP
$BE21 NOP
$BE22 INX
$BE23 CPX #$15
$BE25 BNE $BE19
$BE27 LDA #$A9 Change the instructions at $333F and $334B to 'LDA #$06' and 'LDA #$00'. This makes the routine at $3326 draw blank blue tiles.
$BE29 STA $333F
$BE2C STA $334B
$BE2F LDA #$06
$BE31 STA $3340
$BE34 LDA #$00
$BE36 STA $334C
$BE39 JSR $3012 Bring a blank screen into view.
$BE3C LDA #$44 $4468 is the address of the message 'Do you want to put in'. Store it at $D6.
$BE3E STA $D7
$BE40 LDA #$68
$BE42 STA $D6
$BE44 LDA #$10 The message will be 16 character cells wide. Store this width at $9D.
$BE46 STA $9D
$BE48 LDA #$80 Store the number of bytes to copy from the text graphic buffer at $31.
$BE4A STA $31
$BE4C JSR $BFF5 Write this message into the text graphic buffer and centre it.
$BE4F LDX #$14 These are the coordinates at which to print the message.
$BE51 LDY #$01
$BE53 JSR $3868 Copy the text graphic buffer to the screen.
$BE56 LDA #$8D $8DE8 is the address of the message 'your own names Y/N?'. Store it at $D6.
$BE58 STA $D7
$BE5A LDA #$E8
$BE5C STA $D6
$BE5E JSR $BFF5 Write this message into the text graphic buffer and centre it.
$BE61 LDX #$14 These are the coordinates at which to print the message.
$BE63 LDY #$02
$BE65 JSR $3868 Copy the text graphic buffer to the screen.
$BE68 LDA #$00 Initialise the keyboard reading at $4C to 0.
$BE6A STA $4C
$BE6C LDA $4C Pick up the keyboard reading at $4C.
$BE6E TAY Transfer the reading to Y.
$BE6F CPY #$59 Was 'Y' pressed?
$BE71 BEQ $BE7A Branch if so.
$BE73 CPY #$4E Was 'N' pressed?
$BE75 BNE $BE6C Branch back if not to get another keyboard reading.
$BE77 JMP $BFDB Jump forward.
The player has pressed 'Y' to change the names.
$BE7A LDA #$8D $8D68 is the address of the message 'CAST OF CHARACTERS'. Store it at $D6.
$BE7C STA $D7
$BE7E LDA #$68
$BE80 STA $D6
$BE82 JSR $BFF5 Write this message into the text graphic buffer and centre it.
$BE85 LDX #$14 These are the coordinates at which to print the message.
$BE87 LDY #$05
$BE89 JSR $3868 Copy the text graphic buffer to the screen.
$BE8C LDA #$14 Set the current character number at $60 to $14 (ERIC).
$BE8E STA $60
$BE90 JSR $3279 Copy the current character's buffer into page 0.
$BE93 LDA $60 Pick up the current character number from $60.
$BE95 CMP #$14 Is it $14 (ERIC)?
$BE97 BNE $BE9C Branch if not.
$BE99 SEC Set the carry flag to prepare for subtraction.
$BE9A SBC #$02 Now A=$12 for ERIC.
$BE9C STA $52 Store the modified character number ($0B-$12) at $52.
$BE9E LDA #$12 Subtract this modified character number from $12 and then add $90. Now A holds $90-$97, the MSB of the address of the message that describes the current character.
$BEA0 SEC
$BEA1 SBC $52
$BEA3 CLC
$BEA4 ADC #$90
$BEA6 STA $D7 Store this address ($9068, $9168, $9268, $9368, $9468, $9568, $9668 or $9768) at $D6.
$BEA8 LDA #$68
$BEAA STA $D6
$BEAC JSR $BFF5 Write the message into the text graphic buffer and centre it.
$BEAF LDX #$14 These are the coordinates at which to print the message.
$BEB1 LDY #$08
$BEB3 JSR $3868 Copy the text graphic buffer to the screen.
$BEB6 LDA $52 Pick up the modified character number ($0B-$12) from $52.
$BEB8 SEC Set the carry flag to prepare for subtraction.
$BEB9 SBC #$0B Now A=$00-$07.
$BEBB TAX Transfer this character identifier to X.
$BEBC LDA $90E8,X Pick up the corresponding character name message address LSB from the table at $90E8 and store it at $72.
$BEBF STA $72
$BEC1 STA $D6 Now the vector at $D6 holds the address of the character's name.
$BEC3 LDA #$47
$BEC5 STA $D7
$BEC7 JSR $BFF5 Write the character's name into the text graphic buffer and centre it.
$BECA LDX #$14 These are the coordinates at which to print the character's name.
$BECC LDY #$11
$BECE JSR $3868 Copy the text graphic buffer to the screen.
$BED1 LDA #$1C Set the character's x-coordinate to 28.
$BED3 STA $FC
$BED5 LDA #$0A Set the character's y-coordinate to 10.
$BED7 STA $FB
$BED9 LDA #$40 Initialise the counter at $AD.
$BEDB STA $AD
$BEDD LDA #$32 Set the character's destination x-coordinate to 50 (approximately the centre of the screen).
$BEDF STA $AC
$BEE1 JSR $33BF Restore the character's buffer from page 0.
$BEE4 JSR $3279 Copy the character's buffer into page 0.
$BEE7 JSR $137B Send the character one step along the way to the centre of the screen.
$BEEA LDX #$3F Pause briefly.
$BEEC LDY #$FF
$BEEE DEY
$BEEF BNE $BEEE
$BEF1 DEX
$BEF2 BNE $BEEC
$BEF4 JSR $33BF Restore the character's buffer from page 0.
$BEF7 JSR $31EA Update the display.
$BEFA LDA $AD Decrement the counter at $AD.
$BEFC BNE $BEE4 Branch back unless it's zero now.
$BEFE LDA #$8E Store $8E68 (PRESS'C'TO CHANGE NAME) at $D6.
$BF00 STA $D7
$BF02 LDA #$68
$BF04 STA $D6
$BF06 JSR $BFF5 Write this message into the text graphic buffer and centre it.
$BF09 LDX #$14 These are the coordinates at which to print the message.
$BF0B LDY #$13
$BF0D JSR $3868 Copy the text graphic buffer to the screen.
$BF10 LDA #$00 Reset the keyboard reading at $4C to zero.
$BF12 STA $4C
$BF14 LDA $4C Wait for a keypress.
$BF16 TAY
$BF17 BEQ $BF14
$BF19 CPY #$43 Was it 'C'?
$BF1B BEQ $BF20 Branch if so.
$BF1D JMP $BFA1 Otherwise jump forward.
'C' was pressed to change the character's name.
$BF20 JSR $8FE8 Wipe the character's name.
$BF23 NOP
$BF24 LDA #$68 Change the address at $D6 to $8F68 (ENTER NEW NAME).
$BF26 STA $D6
$BF28 JSR $BFF5 Write this message into the text graphic buffer and centre it.
$BF2B LDX #$14 These are the coordinates at which to print the message.
$BF2D LDY #$13
$BF2F JSR $3868 Copy the text graphic buffer to the screen.
$BF32 LDX #$0B Clear the character name entry buffer at $4700.
$BF34 LDA #$00
$BF36 STA $4700,X
$BF39 DEX
$BF3A BPL $BF36
$BF3C LDA #$47 Store the address of the (empty) character name entry buffer at $D6.
$BF3E STA $D7
$BF40 LDA #$00
$BF42 STA $D6
$BF44 JSR $BFF5 Write this blank message into the text graphic buffer and centre it.
$BF47 LDX #$14 These are the coordinates at which to print the message.
$BF49 LDY #$11
$BF4B JSR $3868 Copy the text graphic buffer to the screen.
$BF4E LDY #$00 Y will counter the number of letters entered so far.
$BF50 LDA #$00 Initialise the keyboard reading at $4C to 0.
$BF52 STA $4C
$BF54 LDA $4C Pick up the keyboard reading at $4C.
$BF56 BEQ $BF54 Branch back until a key has been pressed.
$BF58 TAX Transfer the keypress code to X.
$BF59 CPX #$20 Was SPACE pressed?
$BF5B BEQ $BF69 Branch if so.
$BF5D CPX #$0D Was RETURN pressed?
$BF5F BEQ $BEFE Branch if so.
$BF61 CPX #$41 Is the character code less than $41 ('A')?
$BF63 BCC $BF50 Branch back if so to get the next keypress.
$BF65 CPX #$5B Is the character code greater than $5A ('Z')?
$BF67 BCS $BF50 Branch back if so to get the next keypress.
$BF69 CPY #$0C Have 12 letters already been entered?
$BF6B BEQ $BF50 Branch back if so to get the next keypress.
$BF6D TXA Transfer the keypress code back to A and store it in the character name buffer at $4700.
$BF6E STA $4700,Y
$BF71 INY Next letter.
$BF72 TYA Save the letter counter on the stack.
$BF73 PHA
$BF74 LDA #$47 Store the address of the character name entry buffer ($4700) at $D6.
$BF76 STA $D7
$BF78 LDA #$00
$BF7A STA $D6
$BF7C JSR $BFF5 Write the name entered so far into the text graphic buffer and centre it.
$BF7F LDX #$14 These are the coordinates at which to print the name.
$BF81 LDY #$11
$BF83 JSR $3868 Copy the text graphic buffer to the screen.
$BF86 PLA Restore the letter counter to Y.
$BF87 TAY
$BF88 LDA #$47 Store the address of the character name entry buffer ($4700) at $4E and the address of the character's existing name at $50.
$BF8A STA $4F
$BF8C STA $51
$BF8E LDA #$00
$BF90 STA $4E
$BF92 LDA $72
$BF94 STA $50
$BF96 DEY Point at the last letter entered in the character name entry buffer and copy it over the corresponding letter in the character's existing name.
$BF97 LDA ($4E),Y
$BF99 STA ($50),Y
$BF9B INY Increment the letter counter.
$BF9C NOP
$BF9D NOP
$BF9E JMP $BF50 Jump back to get another keypress.
The character's name change has finished or been skipped. Time to walk the character off screen.
$BFA1 LDA #$4A Set the character's destination x-coordinate to 74 (off screen to the right).
$BFA3 STA $AC
$BFA5 LDA #$40 Initialise the counter at $AD.
$BFA7 STA $AD
$BFA9 JSR $33BF Restore the character's buffer from page 0.
$BFAC JSR $3279 Copy the character's buffer to page 0.
$BFAF JSR $137B Send the character one step along the way off the screen.
$BFB2 LDX #$3F Pause briefly.
$BFB4 LDY #$FF
$BFB6 DEY
$BFB7 BNE $BFB6
$BFB9 DEX
$BFBA BNE $BFB4
$BFBC JSR $33BF Restore the character's buffer from page 0.
$BFBF JSR $31EA Update the display.
$BFC2 LDA $AD Decrement the counter at $AD.
$BFC4 BNE $BFAC Branch back unless it's zero now.
$BFC6 LDA $60 Pick up the current character number from $60.
$BFC8 CMP #$14 Is it $14 (ERIC)?
$BFCA BNE $BFD0 Branch if not.
$BFCC DEC $60 Decrease the current character number at $60 by two (to $12), thus skipping over ERIC's and BOY WONDER's catapult pellets.
$BFCE DEC $60
$BFD0 DEC $60 Decrement the current character number at $60.
$BFD2 LDA $60 Pick up the current character number from $60.
$BFD4 CMP #$0A Is it $0A (little boy no. 11)?
$BFD6 BEQ $BFDB Branch if so.
$BFD8 JMP $BE90 Otherwise jump back to deal with the next character.
The player either pressed 'N' to leave the names alone, or has finished naming every character.
$BFDB LDA #$B1 Change the instructions at $333F and $334B back to 'LDA ($52),Y' and 'LDA ($54),Y'.
$BFDD STA $333F
$BFE0 STA $334B
$BFE3 LDA #$52
$BFE5 STA $3340
$BFE8 LDA #$54
$BFEA STA $334C
$BFED JSR $2E13 Prepare for a new game.
$BFF0 LDA #$01 Set the game mode indicator at $46 to 1.
$BFF2 STA $46
$BFF4 RTS
Prev: $BE08 Up: Map Next: $BFF5