;; ======================================================================== ;; ;; ADDSCORE Adds a constant, random value from table or register to ;; ;; the player's current score. ;; ;; ======================================================================== ;; ADDSCORE PROC ;; ------------------------------------------------------------ ;; ;; For ADDSCORE.cst, score is in a constant after the CALL. ;; ;; ------------------------------------------------------------ ;; @@cst MVI@ R5, R0 ; Get constant from after call B @@reg ;; ------------------------------------------------------------ ;; ;; For ADDSCORE.rnd, four different scores are packed in R0 ;; ;; and R1. Use the RSEED to pick one of the four scores. ;; ;; ------------------------------------------------------------ ;; @@rnd MVI RSEED, R2 ; \ RLC R2 ; |_ evolve random seed in case ADCR R2 ; | multple RNDSCOs in one tic MVO R2, RSEED ; / RLC R2 ; \ ADCR PC ; |- Pick R1/R0 based on MSB of MOVR R1, R0 ; / random number. RLC R2 ; \ ADCR PC ; |- Pick upper/lower byte based SWAP R0 ; / on next bit ANDI #$FF, R0 @@reg ;; ------------------------------------------------------------ ;; ;; R0 contains # of points to award. Add it to the score. ;; ;; ------------------------------------------------------------ ;; PSHR R1 MVII #SCORE, R4 ; \ SDBD ; |- Add to 16-bit score ADD@ R4, R0 ; / MOVR R1, R4 MVII #SCORE, R4 ; \ MVO@ R0, R4 ; |_ Store it out. SWAP R0 ; | MVO@ R0, R4 ; / SWAP R0 ; Swap it back into normal order ;; ------------------------------------------------------------ ;; ;; R0 now contains the new score. See if it's a new peak ;; ;; score for this game, and a new high score all around. The ;; ;; code is a little funky because the peak and high checks ;; ;; are implemented by the same piece of code in a loop. We ;; ;; do this to save code size. ;; ;; ------------------------------------------------------------ ;; @@peakagain SDBD ; \__ See if this is a new peak score CMP@ R4, R0 ; / so we can record it if it is. BNC @@checkbon ;; ------------------------------------------------------------ ;; ;; Update peak score (first iter) and high score (2nd iter) ;; ;; ------------------------------------------------------------ ;; SUBI #2, R4 MVO@ R0, R4 SWAP R0 MVO@ R0, R4 SWAP R0 ; Swap it back into normal order ;; ------------------------------------------------------------ ;; ;; If we got to here, loop a second time to check for high ;; ;; score. If we've already checked the high score, leave. ;; ;; ------------------------------------------------------------ ;; CMPI #TOPSCO, R4 ; Did we just check peak score? BNEQ @@checkbon ; No, so exit ADD COURSE, R4 ; \_ Yes. Index to this course's ADD COURSE, R4 ; / high score and loop B @@peakagain ;; ------------------------------------------------------------ ;; ;; See if the score crosses a new bonus threshold. If so, ;; ;; award the player a shiny new tank, and update the current ;; ;; bonus pointer to point to the next threshold. ;; ;; ------------------------------------------------------------ ;; @@checkbon MVI CURBON, R1 ; \ ADDI #XTRATNK, R1 ; |_ See if score is above next CMP@ R1, R0 ; | bonus threshold BNC @@nobon ; / SUBI #XTRATNK-1, R1 ; \ MVO R1, CURBON ; | MVI LIVES, R0 ; |- Yes: Advance threshold and INCR R0 ; | increment life count MVO R0, LIVES ; / @@nobon MVII #1, R0 MVO R0, DOSCO PULR R1 JR R5 ENDP ;; ======================================================================== ;; ;; DEFSCORE Adds the deferred score to the current score. ;; ;; ======================================================================== ;; DEFSCORE PROC MVI LANDED, R0 ; \ SARC R0, 2 ; |_ Only do this if we just BNOV JRR5 ; | landed, and landed safely MVO R0, LANDED ; / @@1: ;; ------------------------------------------------------------ ;; ;; Scan for scorable jumpables to the left of us ;; ;; ------------------------------------------------------------ ;; MVII #JMPSCO, R4 ; Array holding "passed it!" flags MVII #SPXYP, R3 ; MVI DEFSCO, R0 ; Get current deferred score PSHR R3 PSHR R2 @@lp MVI@ R4, R1 ; \ TSTR R1 ; |- Is this one scoreable? BEQ @@nxt ; / No: Skip it MVI@ R3, R2 ; \ ANDI #$FF, R2 ; |- Is it to the left of tank? CMP TXLO, R2 ; / BGT @@nxt ; No: Skip it DECR R4 ; \ CLRR R2 ; |- Mark it scored MVO@ R2, R4 ; / @@sc ADDI #Score(500),R0 ; \ DECR R1 ; |- Add some multiple of 500 pts BPL @@sc ; / @@nxt ADDI #2, R3 ; \ CMPI #JMPSCO+5, R4 ; |- Loop over all 5 BGs BNEQ @@lp ; / PULR R2 PULR R3 TSTR R0 ; Points for landing? BEQ JRR5 ; No: Leave CLRR R1 ; \_ Clear previous deferred MVO R1, DEFSCO ; / B ADDSCORE.reg ; Add it in! ENDP ;; ======================================================================== ;; ;; XTRATNK Boundaries at which the player gets an additional tank ;; ;; ======================================================================== ;; XTRATNK PROC DECLE Score(100000), Score(300000), Score(500000), Score(700000) DECLE $FFFF ENDP ;; ======================================================================== ;; ;; WBONUS Wave bonuses ;; ;; ======================================================================== ;; WBONUS PROC DECLE Score(5000), Score(8000), Score(10000) ENDP ;; ======================================================================== ;; ;; DISPFINAL Display final score ;; ;; DISPPEAK Display peak score ;; ;; DISPSCORE Display current score ;; ;; DISPSCORE2 Display arbitrary score that's in R0 ;; ;; ======================================================================== ;; DISPFINAL PROC MVII #FINALTXT, R0 MVII #SCORE, R3 B @@x DISPPEAK MVII #PEAKTXT, R0 MVII #PSCOR, R3 @@x MVII #C_TAN, R1 MVI@ R5, R4 PSHR R5 PSHR R3 CALL P16.R MVII #gen_cstk_card(0, GRAM, White, NoAdvance), R3 PULR R5 B @@y DISPSCORE2 MVI@ R5, R4 PSHR R5 MVII #gen_cstk_card(0, GRAM, White, NoAdvance), R3 B @@z DISPSCORE MVI@ R5, R4 PSHR R5 MVII #SCORE, R5 MVII #gen_cstk_card(0, GRAM, Blue, NoAdvance), R3 @@y: SDBD MVI@ R5, R0 @@z: MVII #$10 * 8, R2 XORR R3, R2 ADDI #6, R4 MVO@ R2, R4 CLRC RRC R0 BNC @@zend MVII #$15 * 8, R2 XORR R3, R2 @@zend SUBI #2, R4 MVO@ R2, R4 MVII #5, R2 SUBI #6, R4 CALL PRNUM16.z PULR PC ENDP FINALTXT S16 "Final score: " PEAKTXT S16 " Peak score: " __ ;* ======================================================================== *; ;* This program is free software; you can redistribute it and/or modify *; ;* it under the terms of the GNU General Public License as published by *; ;* the Free Software Foundation; either version 2 of the License, or *; ;* (at your option) any later version. *; ;* *; ;* This program is distributed in the hope that it will be useful, *; ;* but WITHOUT ANY WARRANTY; without even the implied warranty of *; ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *; ;* General Public License for more details. *; ;* *; ;* You should have received a copy of the GNU General Public License *; ;* along with this program; if not, write to the Free Software *; ;* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *; ;* ======================================================================== *; ;* Copyright (c) 2007, Joseph Zbiciak *; ;* ======================================================================== *; _