Prev: 26537 Up: Map Next: 26614
26550: 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 26550 LD A,(26355) Jump to AddToScore if *Flag_ActiveDemoMode is not active.
26553 OR A
26554 JR Z,AddToScore
Demo mode is active, so just reset the score.
26556 LD DE,25896 DE=ScoreBuffer.
26559 LD B,0 Set B to 0 to skip any scoring addition.
26561 JR Reset_ScoreBuffer Jump to Reset_ScoreBuffer.
Proceed with adding the points to the current score.
AddToScore 26563 LD HL,25881 Point HL at 25881 (the current score).
26566 LD DE,25902 Point DE at 25902 (the points to add).
26569 LD B,6 Set a counter in B for 6 score digits.
AddToScore_Loop 26571 LD A,(DE) Fetch the points digit and add it to the corresponding score digit.
26572 ADD A,(HL)
26573 SUB 48 Convert the value from ASCII by subtracing 48.
26575 CP 58 Jump to AddToScore_Store if the result is less than 58 (no carry).
26577 JR C,AddToScore_Store
26579 SUB 10 Subtract 10 to handle the carry.
26581 DEC HL Move to the next higher digit position.
26582 INC (HL) Add the carry to the next higher digit.
26583 INC HL Move back to the current digit position.
AddToScore_Store 26584 LD (HL),A Write the resulting digit to the score.
26585 DEC DE Move to the previous points digit in the points buffer.
26586 DEC HL Move to the previous digit in the score.
26587 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 26589 PUSH DE Copy the score buffer pointer to HL (using the stack).
26590 POP HL
26591 INC DE Increment the score buffer destination pointer by one.
26592 LD C,6 Set a counter in C for 6 score digits.
26594 LD (HL),48 Write 48 ("0") to the score buffer.
26596 LDIR Copy 48 ("0") across the remaining five score buffer digits.
Check if the score is at least "10,000".
26598 LD A,(25877) Return if *25877 (the "ten-thousands" digit) is not equal to 49 ("1").
26601 CP 49
26603 RET NZ
26604 LD HL,26351 Return if Flag_ExtraLife says that no extra life should be awarded.
26607 LD A,(HL)
26608 OR A
26609 RET Z
Award an extra life to the player.
26610 DEC (HL) Reset Flag_ExtraLife as an extra life has been "awarded".
26611 INC HL Move to the lives counter at Player_Lives.
26612 INC (HL) Award one extra life.
26613 RET Return.
Prev: 26537 Up: Map Next: 26614