Prev: 67A9 Up: Map Next: 67F6
67B6: Handler: Score
Adds points to the current score and awards a bonus life if the score reaches 10,000 points.
Check if the game is running in demo mode.
Handler_Score 67B6 LD A,($66F3) Jump to AddToScore if *Flag_ActiveDemoMode is not active.
67B9 OR A
67BA JR Z,AddToScore
Demo mode is active, so just reset the score.
67BC LD DE,$6528 DE=ScoreBuffer.
67BF LD B,$00 Set B to 00 to skip any scoring addition.
67C1 JR Reset_ScoreBuffer Jump to Reset_ScoreBuffer.
Proceed with adding the points to the current score.
AddToScore 67C3 LD HL,$6519 Point HL at 6519 (the current score).
67C6 LD DE,$652E Point DE at 652E (the points to add).
67C9 LD B,$06 Set a counter in B for 06 score digits.
AddToScore_Loop 67CB LD A,(DE) Fetch the points digit and add it to the corresponding score digit.
67CC ADD A,(HL)
67CD SUB $30 Convert the value from ASCII by subtracing 30.
67CF CP $3A Jump to AddToScore_Store if the result is less than 3A (no carry).
67D1 JR C,AddToScore_Store
67D3 SUB $0A Subtract 0A to handle the carry.
67D5 DEC HL Move to the next higher digit position.
67D6 INC (HL) Add the carry to the next higher digit.
67D7 INC HL Move back to the current digit position.
AddToScore_Store 67D8 LD (HL),A Write the resulting digit to the score.
67D9 DEC DE Move to the previous points digit in the points buffer.
67DA DEC HL Move to the previous digit in the score.
67DB DJNZ AddToScore_Loop Decrease the score digit counter by one and loop back to AddToScore_Loop until all of the scoring digits have been processed.
Reset_ScoreBuffer 67DD PUSH DE Copy the score buffer pointer to HL (using the stack).
67DE POP HL
67DF INC DE Increment the score buffer destination pointer by one.
67E0 LD C,$06 Set a counter in C for 06 score digits.
67E2 LD (HL),$30 Write 30 ("0") to the score buffer.
67E4 LDIR Copy 30 ("0") across the remaining five score buffer digits.
Check if the score is at least "10,000".
67E6 LD A,($6515) Return if *6515 (the "ten-thousands" digit) is not equal to 31 ("1").
67E9 CP $31
67EB RET NZ
67EC LD HL,$66EF Return if Flag_ExtraLife says that no extra life should be awarded.
67EF LD A,(HL)
67F0 OR A
67F1 RET Z
Award an extra life to the player.
67F2 DEC (HL) Reset Flag_ExtraLife as an extra life has been "awarded".
67F3 INC HL Move to the lives counter at Player_Lives.
67F4 INC (HL) Award one extra life.
67F5 RET Return.
Prev: 67A9 Up: Map Next: 67F6