home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 86 / asm / source / kollums.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  45.5 KB  |  1,415 lines

  1. ;KOLLUMS source for version 2.0
  2. ;
  3. ;Here is the source code for KOLLUMS v2.0
  4. ;I'm distributing it for all those people who want to learn assembly for the 86
  5. ;I've commented it very much, although I got kinda sick of commenting late at night :(
  6. ;
  7. ;
  8. ;Some of the stuff I added in v2.0 I didn't comment, too bad
  9. ;
  10. ;Please learn something from it, and if you do, give me some credit.
  11. ;
  12. ;mail me with anything!! -->  bailela@charlie.cns.iit.edu
  13. ;
  14. ;This source is Copyright (C) 1997 Alan Bailey.  Please don't redistribute any modified
  15. ;version of this program.  You can modify all you want, just don't redistribute.  Feel
  16. ;free to cut and paste something, but give me some credit.  If you see anything wrong, 
  17. ;or see something I could do better, mail me and tell me.
  18. ;
  19. ;If you want to recompile it, get Asm86 from ticalc.org at
  20. ;http://www.ticalc.org/pub/dos/asm/asm86.zip
  21. ;There's some stuff in here that's specific to that
  22. ;
  23. ;Alan Bailey
  24. ;bailela@charlie.cns.iit.edu
  25. ;http://www.iit.edu/~bailela/      <--- check my page out, it's new
  26. ;IRC: Abalone on #calc-ti on EFnet
  27.  
  28.  
  29. #include "asm86.h"         ;I use Asm86 to compile, so I include this
  30. #include "ti86asm.inc"     ;this is TI's include file
  31.  
  32. .org _asm_exec_ram          ;starting point for all asm progs, $D748
  33.  
  34.  
  35. ;      XCoord ->
  36. ;    ----------------
  37. ;   |(0,0)     (15,0)|
  38. ;   |                |  Y     16*7=112 bytes
  39. ;   |                |  C
  40. ;   |                |  o
  41. ;   |                |  o
  42. ;   |                |  r
  43. ;   |(0,7)     (15,7)|  d
  44. ;   |   info line    |  \/
  45. ;    ----------------
  46.  
  47. Start:
  48.     
  49.     call _clrLCD             ;clear the screen!
  50.     ld a,%01010101           ;this is the bitmap for the top seven lines of the intro
  51.     ld b,7                   ;we have seven lines
  52.     ld hl,$FC00              ;this is the first spot we want to write to
  53. Graphxloop:
  54.     push bc                  ;save the counter of lines
  55.     ld b,16                  ;make a new counter of bytes in the line (16)
  56. Graphxloop2:
  57.     ld (hl),a                ;put the bitmap in
  58.     inc hl                   ;increment to the next byte on screen
  59.     djnz Graphxloop2         ;and jump back until line is finished
  60.     cpl                      ;this is equal to <xor 255>, to change the bitmap
  61.     pop bc                   ;get the old counter back
  62.     djnz Graphxloop          ;and keep going until all seven lines done
  63.                         ;now we display some words
  64.     ld bc,$0501              ;now we display the words, $0501 are first coordinates
  65.     ld (_curRow),bc          ;load them in, _curRow gets $01, _curCol gets $05
  66.     ld hl,TitleStr           ;this is absolute address of string "KOLLUMS 1.0"
  67.     call _puts               ;put it out on screen
  68.     ld bc,$0303              ;next coordinates
  69.     ld (_curRow),bc          ;load them in
  70.     ;ld hl,Author            ;this string is right after the previous one, so hl set
  71.     call _puts               ;put it out
  72.     ld bc,$220F
  73.     ld (_penCol),bc
  74.     ;ld hl,Email
  75.     call _vputs              ;this is a variable-width put string
  76.     ld bc,$3103
  77.     ld (_penCol),bc
  78.     ;ld hl,Difficulty
  79.     call _vputs
  80.     call DispDiff            ;this routine displays the boxes (difficulty)
  81.     ld hl,ResumeStr
  82.     ld bc,$3918
  83.     ld (_penCol),bc
  84.     call _vputs
  85. FirstKeyCheck:
  86.     halt                     ;saves valuable battery power when waiting
  87.     call Randomize           ;Randomize the variables
  88.     call GET_KEY             ;gets the recent key pressed
  89.     cp K_EXIT                ;compare it to exit
  90.     jr z,TimetoLeave         ;if it's exit, go to TimetoLeave
  91.     cp K_RIGHT               ;and similar
  92.     jp z,MoveLevelRight
  93.     cp K_LEFT
  94.     jp z,MoveLevelLeft
  95.     cp K_ENTER
  96.     jp z,StartAction
  97.     cp K_SECOND
  98.     jp z,StartAction
  99.     cp K_F1
  100.     jp z,ResumePaused
  101.     jr FirstKeyCheck         ;goes back to check other keys
  102.  
  103. TimetoLeave:
  104.     call LoadData
  105.     call _clrLCD       ;and clear the screen one last time
  106.     ret                ;and leave now that the scores are saved
  107.  
  108. ResumePaused:
  109.     ld a,(SavedGame)
  110.     or a
  111.     jp z,FirstKeyCheck            ;no saved game
  112.     call _clrLCD
  113.     call PutScreen         ;Puts out any blocks in the BlockMem
  114.     ld hl,$3803            ;coords for LevelDiff
  115.     ld (_penCol),hl        ;loads them
  116.     ld a,(LevelDiff)       ;gets LevelDiff
  117.     add a,'0'              ;add '0' to make it ASCII char
  118.     ld b,1                 ;number of chars to display
  119.     ld hl,StringPlace      ;place to store char to display
  120.     ld (hl),a              ;puts it in
  121.     call _vputsn           ;displays 1 char pointed to by hl
  122.     call UpdateScore       ;Puts score
  123.     call UpdateLevel       ;Puts level
  124.     call DispHigh          ;Puts high score
  125.     call DrawCurrent       ;and Draws the current three blocks
  126.     jp keycheck
  127.  
  128.  
  129. ;-----------------------------------
  130. ;This routine moves the difficulty level to the right 
  131. ;from the intro screen, jumps back to FirstKeyCheck
  132. MoveLevelRight:
  133.     ld a,(LevelDiff)          ;gets the LevelDifficulty
  134.     cp 8                      ;the highest it can be
  135.     jp z,FirstKeyCheck        ;if it's the highest, go back now
  136.     inc a                     ;or increment it!
  137.     ld (LevelDiff),a          ;loads it back
  138.     ld a,1                    ;the randoms might be upset by switching the difficulty
  139.     ld (Rand1),a              ;so this restarts all randoms
  140.     ld (Rand2),a
  141.     ld (Rand3),a
  142.     call DispDiff             ;and display the difficulty boxes again
  143.     jp FirstKeyCheck          ;jump back to key check
  144.  
  145. ;-----------------------------------
  146. ;This routine moves the difficulty level to the left 
  147. ;from the intro screen, jumps back to FirstKeyCheck
  148. MoveLevelLeft:                ;this just like MoveLevelRight
  149.     ld a,(LevelDiff)
  150.     cp 3                      ;the lowest point
  151.     jp z,FirstKeyCheck
  152.     dec a
  153.     ld (LevelDiff),a
  154.     ld a,1
  155.     ld (Rand1),a                
  156.     ld (Rand2),a
  157.     ld (Rand3),a
  158.     call DispDiff
  159.     jp FirstKeyCheck
  160.  
  161.  
  162. ;-----------------------------------
  163. ;This routine displays the boxes to represent
  164. ;the difficulty.  Returns when it is done
  165. DispDiff:
  166.     ld a,(LevelDiff)      ;gets the LevelDifficulty = number of boxes
  167.     ld b,a                ;put in b as a counter
  168.     ld a,$01              ;this is the first block bitmap we want to display
  169.     ld de,$0706           ;xy position for first block
  170. DispDiff2:
  171.     push bc               ;saves bc (counter)
  172.     push af               ;saves af (block description)
  173.     push de               ;saves de (xy coords)
  174.     push de               ;no doens't save de, puts de in bc
  175.     pop bc                ;cause we pushed it, now it's popped into a differnet rp
  176.     call DrawBlock        ;and call DrawBlock with a containing block, bc has coords
  177.     pop de                ;gets the saved coords
  178.     inc d                 ;and increment the xcoord
  179.     pop af                ;gets the saved block type
  180.     inc a                 ;and moves to the next block
  181.     pop bc                ;gets the saved counter
  182.     djnz DispDiff2        ;and does all blocks equal to LevelDiff
  183.     ld a,$00              ;these next four lines put a blank block at the end
  184.     push de               ;just in case
  185.     pop bc
  186.     call DrawBlock
  187.     ret                   ;and go back where you came from
  188.  
  189.  
  190. ;---------------------------
  191. ;This part called when all done selecting level
  192. ;and enter or second has been pressed
  193. StartAction:
  194.     sub a                    ;make a zero, literally subtract a from a
  195.     ld (SpeedLevel),a        ;SpeedLevel is now zero
  196.     ld hl,BlockMem
  197.     ld de,BlockMem+1
  198.     ld (hl),0
  199.     ld bc,111
  200.     ldir
  201.     ld hl,$0660              ;This is the first DelayTimer value
  202.     ld (DelayTimer),hl       ;load it in to variable
  203.     ld hl,$0000
  204.     ld (Score),hl
  205.  
  206.     call _clrLCD
  207.     call MakeNewSet        ;make new set of three blocks 
  208.     call PutScreen         ;Puts out any blocks in the BlockMem
  209.     ld hl,$3803            ;coords for LevelDiff
  210.     ld (_penCol),hl        ;loads them
  211.     ld a,(LevelDiff)       ;gets LevelDiff
  212.     add a,'0'              ;add '0' to make it ASCII char
  213.     ld b,1                 ;number of chars to display
  214.     ld hl,StringPlace      ;place to store char to display
  215.     ld (hl),a              ;puts it in
  216.     call _vputsn           ;displays 1 char pointed to by hl
  217.     call UpdateScore       ;Puts score
  218.     call UpdateLevel       ;Puts level
  219.     call DispHigh          ;Puts high score
  220.     call DrawCurrent       ;and Draws the current three blocks
  221. keycheck:
  222.     call Randomize         ;called at random time to make it random
  223.     call GET_KEY           ;same kind of keyloop
  224.     cp K_UP
  225.     jp z,MoveLeft
  226.     cp K_DOWN
  227.     jp z,MoveRight
  228.     cp K_SECOND
  229.     jp z,RotateBlocks
  230.     cp K_EXIT
  231.     jp z,GameAllDone
  232.     cp K_MORE
  233.     jp z,PauseGame
  234.     cp K_F1
  235.     jr z,SuspendGame
  236.     cp K_LEFT
  237.     call z,MoveDown         ;this is a call because MoveDown is a function
  238.                                        ;will return here, no problem
  239.     ld hl,(DelayTimer)      ;gets the time delayed
  240.     dec hl                  ;decrements it
  241.     ld (DelayTimer),hl      ;and load it back
  242.     ld a,l                  ;puts l into a
  243.     or h                    ;ors h with l, if _anything_ is set, it will not be zero
  244.     jr nz,keycheck          ;so if not zero, jr keycheck
  245.  
  246.     call MoveDown           ;Time all decremented, move it down a notch
  247.     ld a,(CurrFinished)     ;CurrFinished is changed in MoveDown
  248.     or a                    
  249.     jp nz,FinishedSet       ;if it is not zero, means finished, and goes to FinishedSet
  250.     ld a,(SpeedLevel)       ;these next eight lines make DelayTimer from SpeedLevel
  251.     rlca                    ;rotate left, so number is multiplied by 2
  252.     ld c,a                  ;puts that offset into bc
  253.     ld b,0                  ;like that
  254.     ld hl,TimerTable        ;now here's the table we want to analyze
  255.     add hl,bc               ;include the offset
  256.     call LD_HL_MHL          ;and get the value pointed to by hl in TimerTable
  257.     ld (DelayTimer),hl      ;that's the current DelayTimer
  258.     jr keycheck             ;and jump back to check the keys
  259.  
  260.  
  261. SuspendGame:
  262.     ld a,1
  263.     ld (SavedGame),a
  264.     call LoadData
  265.     call _clrLCD
  266.     ret
  267.  
  268.  
  269.  
  270. ;-------------------------
  271. ;Simple routine to follow when MORE is pressed
  272. PauseGame:                  ;
  273.     halt                    ;saves some time and battery power
  274.     call GET_KEY            ;gets key
  275.     cp 0                    ;if anything, 
  276.     jp nz,keycheck          ;go back to keycheck
  277.     jr PauseGame            ;or stay in this loop
  278.  
  279.  
  280. ;-----------------------------------
  281. ;Routine to move the blocks around in their set
  282. RotateBlocks:
  283.     ld hl,CurrTop           ;address of the top block
  284.     ld b,(hl)               ;put in b temporarily
  285.     inc hl                  ;go to the middle block
  286.     ld a,(hl)               ;put the middle block in a
  287.     ld (hl),b               ;and the top block in the middle block
  288.     inc hl                  ;go to the lower block
  289.     ld b,(hl)               ;put the lower block in b
  290.     ld (hl),a               ;put the middle block in the lower block
  291.     ld hl,CurrTop           ;get top block again
  292.     ld (hl),b               ;and put lower block in top block
  293.     call DrawCurrent        ;redraw it
  294.     jp keycheck             ;and jump back
  295.  
  296.  
  297.  
  298. ;----------------------
  299. ;Routine to move the set to the left
  300. ;erases it and redraws it
  301. MoveLeft:
  302.     ld hl,(YCoord)       ;gets the y coord and x coord
  303.     ld a,l               ;puts y coord in a
  304.     or a                 ;checks if zero, (at left side 
  305.     jp z,keycheck        ;if at left side, go back now
  306.     push hl              ;puts hl
  307.     pop bc               ;in bc
  308.     dec c                ;dec y coord
  309.     call GetBlock        ;get value of block and address on left side of three
  310.     inc hl               ;next up block
  311.     add a,(hl)           ;get value 
  312.     inc hl               ;next one
  313.     add a,(hl)           ;get value
  314.     jp nz,keycheck       ;basically, just check if any blocks to the left are occupied
  315.  
  316.     ld hl,(YCoord)       ;gets block at bottome
  317.     push hl              ;puts hl
  318.     pop bc               ;in bc
  319.     sub a                ;makes it a blank block
  320.     push bc              ;saves coords for next run through
  321.     call DrawBlock       ;deltes block by putting blanks there
  322.     pop bc               ;gets saved coords
  323.     inc b                ;ready to erase next block
  324.     sub a
  325.     push bc
  326.     call DrawBlock
  327.     pop bc
  328.     inc b
  329.     sub a
  330.     call DrawBlock       ;all three blocks deleted
  331.     ld hl,(YCoord)       ;get coords
  332.     dec l                ;now we decrement it
  333.     ld (YCoord),hl       ;and load it back
  334.     call DrawCurrent     ;and draw it, how fun!
  335.     jp keycheck          ;and go back to checking keys
  336.  
  337. MoveRight:               ;just like MoveLeft, look above, it's very similar
  338.     ld hl,(YCoord)
  339.     ld a,l
  340.     cp 6
  341.     jp z,keycheck
  342.     push hl
  343.     pop bc
  344.     inc c
  345.     call GetBlock
  346.     inc hl
  347.     add a,(hl)
  348.     inc hl
  349.     add a,(hl)
  350.     jp nz,keycheck
  351.     ld hl,(YCoord)
  352.     push hl
  353.     pop bc
  354.     sub a
  355.     push bc
  356.     call DrawBlock
  357.     pop bc
  358.     inc b
  359.     sub a
  360.     push bc
  361.     call DrawBlock
  362.     pop bc
  363.     inc b
  364.     sub a
  365.     call DrawBlock
  366.     ld hl,(YCoord)
  367.     inc l
  368.     ld (YCoord),hl
  369.     call DrawCurrent
  370.     jp keycheck
  371.  
  372.  
  373. ;-------------------
  374. ;This displays the high score for that level
  375. DispHigh:                
  376.     ld hl,$3810          ;place to put high score
  377.     ld (_penCol),hl      ;put it in
  378.     ld hl,HighStr        ;get string High:
  379.     call _vputs          ;put that little string
  380.     ld a,(LevelDiff)
  381.     cp 3
  382.     jr z,DispHigh3       ;if level 3
  383.     cp 4
  384.     jr z,DispHigh4       ;if level 4
  385.     cp 5
  386.     jr z,DispHigh5       ;if level 5
  387.     cp 6
  388.     jr z,DispHigh6
  389.     cp 7
  390.     jr z,DispHigh7
  391.     jr DispHigh8         ;defaults to level 8 if not anything else
  392.     
  393. DispHigh3:               ;gets address for High3
  394.     ld hl,High3
  395.     jr DispHigh2
  396. DispHigh4:
  397.     ld hl,High4          ;gets address for High4
  398.     jr DispHigh2
  399. DispHigh5:
  400.     ld hl,High5
  401.     jr DispHigh2
  402. DispHigh6:
  403.     ld hl,High6
  404.     jr DispHigh2
  405. DispHigh7:
  406.     ld hl,High7
  407.     jr DispHigh2
  408. DispHigh8:
  409.     ld hl,High8
  410.     jr DispHigh2
  411.  
  412.  
  413. DispHigh2:                   ;now it works on the information
  414.     push hl
  415.     call LD_HL_MHL           ;gets the high score from mem
  416.     ld de,StringPlace+4      ;sets de for putting score
  417.     ld b,5                   ;5 characters in score
  418. UpdateHigh:
  419.     call UNPACK_HL           ;divides hl by 10 and has the remainder in a,
  420.     add a,'0'                ;make digit ascii
  421.     ld (de),a                ;load it into stringplace, ready for displaying
  422.     dec de                   ;next spot to load
  423.     djnz UpdateHigh          ;and go to UpdateHigh for next 4 characters
  424.     ld hl,StringPlace        ;now it contains the score, asciiized and zero-terminated
  425.     call _vputs              ;display the score
  426.     ld a,(_penCol)           ;get the Col from mem
  427.     ld b,4                   ;increase it
  428.     add a,b                  ;like that
  429.     ld (_penCol),a           ;and load it back
  430.     pop hl                   ;this is the address to high score
  431.     inc hl                   ;right after it is Initials, so this increments to that
  432.     inc hl
  433.     call _vputs              ;and put the Initials of High Scorer
  434.     ret                      ;leave
  435.  
  436.  
  437. ;-----------------------
  438. ;randomizes the varialbes
  439. ;this is called many times from the keyloops
  440. ;This code is mostly (C) 1996 Mel Tsai from Columns3
  441. ;All commments are Mel Tsai's
  442.  
  443. Randomize:
  444.     ld a, (LevelDiff)                ; this works on the fact  
  445.     inc a                           ; that the computer is so fast 
  446.     ld b, a                         ; that by the time you press a key 
  447.     ld a, (Rand1)                 ; to move, it can increment 3 variables 
  448.     inc a                           ; hundreds of times.  These 3 variables 
  449.     cp b                            ; become the random blocks generated! 
  450.     jr z, RANDINC_1                 
  451.     ld (Rand1), a 
  452.     ret 
  453. RANDINC_1: 
  454.     ld a, 1 
  455.     ld (Rand1), a 
  456.     ld a, (Rand2) 
  457.     inc a 
  458.     cp b 
  459.     jr z, RANDINC_2 
  460.     ld (Rand2), a 
  461.     ret 
  462. RANDINC_2: 
  463.     ld a, 1 
  464.     ld (Rand2), a 
  465.     ld a, (Rand3) 
  466.     inc a 
  467.     cp b 
  468.     jr z, RANDINC_3 
  469.     ld (Rand3), a 
  470.     ret 
  471. RANDINC_3: 
  472.     ld a, 1 
  473.     ld (Rand3), a 
  474.     ret 
  475.  
  476.  
  477.  
  478.  
  479. ;----------------------------------------------------------------
  480. ;----------------------------------------------------------------
  481. ;Huge routine to check all directions for rows of common blocks
  482. ;Runs through the Horizontal, then Vert, then the two diagonals
  483. ;----------------------------------------------------------------
  484. BlockTestTime:
  485.     sub a
  486.     ld (TotalBlockCount),a
  487.  
  488. ;-----------
  489. Horiz:
  490.     ld hl,BlockMem          ;first spot of startingblock
  491.     ld b,7                  ;7 columns
  492. Horiz2:
  493.     push bc                 ;save counter
  494.     push hl                 ;save address of starting block
  495.     ld e,16                 ;16 in a line
  496.     ld a,1                  ;the difference between each block is one byte
  497.     ld (BlockDiff),a        ;like that
  498.     call TestLine           ;now we test that line, which tags them
  499.     pop hl                  ;get address back
  500.     ld de,$0010             ;add 16 to get to the next line
  501.     add hl,de               ;like that
  502.     pop bc                  ;now we get the counter back for all seven
  503.     djnz Horiz2
  504.  
  505. ;-----------
  506. Vert:
  507.     ld hl,BlockMem          ;first spot of startingblock
  508.     ld b,16                 ;opposite of Horiz, so 16 columns
  509. Vert2:
  510.     push bc                 ;save counter
  511.     push hl
  512.     ld e,7                  ;number in line
  513.     ld a,$0010              ;this is the difference now in the other direction
  514.     ld (BlockDiff),a        ;load it
  515.     call TestLine           ;Test that line
  516.     pop hl                  ;get back startingblock
  517.     inc hl                  ;go to next startingblock
  518.     pop bc                  ;for all 16 times
  519.     djnz Vert2              ;checked here
  520.  
  521.  
  522. ;-----------
  523. Diag1:
  524.     ld hl,BlockMem          ;starting position for diagonal
  525.     ld b,10                 ;10 diagonals of length 7
  526. Diag12:
  527.     push bc                 ;save
  528.     push hl                 ;save
  529.     ld e,7                  ;7 blocks in these 10 diagonals
  530.     ld a,$0011              ;this means difference is one line ($10) + one block ($01)
  531.     ld (BlockDiff),a        ;load it into BlockDiff
  532.     call TestLine           ;and test
  533.     pop hl
  534.     inc hl                  ;inc to get to next starting block of diagonal
  535.     pop bc
  536.     djnz Diag12
  537.                             ;these next sets of three lines test the little diagonals
  538.     ld hl,BlockMem+16       ;diagonal of length 6 starting at that block
  539.     ld e,6
  540.     call TestLine           ;Test it! - BlockDiff is always the same
  541.     ld hl,BlockMem+32
  542.     ld e,5
  543.     call TestLine
  544.     ld hl,BlockMem+48
  545.     ld e,4
  546.     call TestLine
  547.     ld hl,BlockMem+64
  548.     ld e,3
  549.     call TestLine
  550.     ld hl,BlockMem+10
  551.     ld e,6
  552.     call TestLine
  553.     ld hl,BlockMem+11
  554.     ld e,5
  555.     call TestLine
  556.     ld hl,BlockMem+12
  557.     ld e,4
  558.     call TestLine
  559.     ld hl,BlockMem+13
  560.     ld e,3
  561.     call TestLine
  562.     ld hl,BlockMem+14
  563.     call TestLine
  564.  
  565. ;------------
  566. Diag2:                  ;refer to Diag1, this is very similar
  567.     ld hl,BlockMem+6
  568.     ld b,10
  569. Diag22:
  570.     push bc
  571.     push hl
  572.     ld e,7
  573.     ld a,$000F        ;this is the only difference, means one less block than a line
  574.     ld (BlockDiff),a
  575.     call TestLine
  576.     pop hl
  577.     inc hl
  578.     pop bc
  579.     djnz Diag22
  580.                       ;this next have the same format, but different numbers
  581.     ld hl,BlockMem+2
  582.     ld e,3
  583.     call TestLine
  584.     ld hl,BlockMem+3
  585.     ld e,4
  586.     call TestLine
  587.     ld hl,BlockMem+4
  588.     ld e,5
  589.     call TestLine
  590.     ld hl,BlockMem+5
  591.     ld e,6
  592.     call TestLine
  593.     ld hl,BlockMem+16+15
  594.     ld e,6
  595.     call TestLine
  596.     ld hl,BlockMem+32+15
  597.     ld e,5
  598.     call TestLine
  599.     ld hl,BlockMem+48+15
  600.     ld e,4
  601.     call TestLine
  602.     ld hl,BlockMem+64+15
  603.     ld e,3
  604.     call TestLine
  605.  
  606.     ret         ;returns with all common blocks tagged ( bit 7 set)
  607.  
  608.  
  609.  
  610.  
  611. ;----------------------------------------
  612. ;Call this with first address in hl, Difference between blocks in (BlockDiff)
  613. ;total blocks in line in e
  614. ;----------------------------------------
  615. ;During this routine, d=block count
  616. ;                     e=blocks to check, like a counter
  617. ;                     a=temporary variable
  618. ;                    hl=address of block being checked
  619. ;                     c=block to test against
  620. ;                     b=counter sometimes, bc temporary variable sometimes 
  621. ;----------------------------------------
  622. TestLine:
  623.     ld d,0              ;d starts at zero
  624.     ld a,e              ;load e into a to test against
  625.     or a                ;cp 0
  626.     ret z               ;if e is zero, blocks in line all checked
  627.     ld a,(hl)           ;gets block at address
  628.     and %01111111       ;mask out top bit, tagged block possibly
  629.     jr z,SkipZeroes     ;if it's a zero, skip it, doesn't matter
  630.     ld (StartBlock),hl  ;that used as the first block in a possible series
  631.     ld c,a              ;c has the block to test against
  632. TestLine2:
  633.     ld a,e              ;check against e again
  634.     or a
  635.     jr z,TestLine3      ;if blocks all done, go here to see if you have three or more
  636.     inc d               ;block count so far
  637.     push bc             ;save bc, variables limited
  638.     ld a,(BlockDiff)    ;get difference between blocks in line
  639.     ld c,a              ;put it in bc
  640.     ld b,0              ;like that
  641.     add hl,bc           ;and get the offset added to the previous block
  642.     pop bc              ;get bc back
  643.     dec e               ;we're done with one block, so decrement total
  644.     ld a,(hl)           ;get the next block
  645.     and %01111111       ;mask out top bit, tagged block
  646.     xor c               ;check block with block being tested
  647.     jr z,TestLine2      ;if same, keep going, we might have a line
  648. TestLine3:              ;this checks if we have 3, if so, tags them
  649.     ld a,d              ;gets block count in common series
  650.     inc a               ;ease testing
  651.     and %11111100       ;if it's 1 or 2, it won't count
  652.     jr z,TestLine       ;so if not 3 or more, go back and continue checking that line
  653.     ld b,d              ;blocks in common are used as counter here
  654.     ld hl,(StartBlock)  ;the starting block in the series
  655. TestLine4:
  656.     set 7,(hl)          ;tag it
  657.     push bc             ;save bc
  658.     ld a,(BlockDiff)    ;add the blockdifference again
  659.     ld c,a
  660.     ld b,0
  661.     add hl,bc           ;like that
  662.     pop bc              ;and get bc back
  663.     ld a,(TotalBlockCount)     ;counts total blocks tagged, used as score
  664.     inc a                      ;increment it because one block tagged
  665.     ld (TotalBlockCount),a     ;save it
  666.     djnz TestLine4             ;continue to tag all in the set
  667.     jr TestLine                ;continue with the next block in the line
  668.  
  669. SkipZeroes:
  670.     push bc             ;save bc!
  671.     ld a,(BlockDiff)    ;add block diff again to get at next block
  672.     ld c,a
  673.     ld b,0
  674.     add hl,bc
  675.     pop bc              ;get bc back
  676.     dec e               ;dec because one block skipped
  677.     jr TestLine         ;anc continue teseting
  678.  
  679.  
  680.  
  681. ;-----------------------------
  682. ;This routine erases all blocks that
  683. ;are tagged (bit 7 set). It just erases them, doens't remove the tags
  684. DeleteBlocks:
  685.     ld hl,BlockMem      ;the first block
  686.     ld de,$0000         ;first coords, (0,0)
  687.     ld b,7              ;there are 7 rows
  688. DeleteBlocks2:
  689.     push bc             ;save that counter
  690.     ld b,16             ;there are 16 rows
  691. DeleteBlocks3:
  692.     push bc             ;save that counter
  693.     push de             ;this puts de
  694.     pop bc              ;into bc for the routine DrawBlock
  695.     bit 7,(hl)          ;test for the tag
  696.     jr z,DeleteBlocks4  ;if it is zero,( not tagged), then go here 
  697.     sub a           ;blank block
  698.     call DrawBlock      ;this draws a blank block (sub a)
  699. DeleteBlocks4:
  700.     inc hl              ;this moves up the address
  701.     inc d               ;inc x coord
  702.     pop bc              ;get first counter
  703.     djnz DeleteBlocks3  ;go back if not done with the row yet
  704.     ld d,0              ;or... now we set the x coord back to zero
  705.     inc e               ;and inc the y coord
  706.     pop bc              ;retrieve this counter
  707.     djnz DeleteBlocks2  ;and do the loop again
  708.     ret                 ;get out of this function
  709.  
  710.  
  711. ;--------------
  712. ;this moves all the blocks down that are tagged and have been
  713. ;erased from the screen
  714. DropDown:
  715.     ld hl,BlockMem      ;first block...
  716.     ld b,7              ;7 rows
  717. DropDown2:
  718.     push bc             ;save the counter
  719.     ld bc,15            ;this is used as amount to move down, for the ldir
  720. DropDown3:
  721.     bit 7,(hl)          ;test the tag
  722.     jr z,DropDown4      ;if it's not tagged, leave this place, or continue on...
  723.     push hl             ;this puts hl (the tagged block)
  724.     pop de              ;into de for the ldir
  725.     inc hl              ;goes to the next block for the ldir
  726.     push bc             ;save bc (will be changed by ldir)
  727.     push hl             ;save hl (will be cahnged by ldir)
  728.     ldir                ;this ldir moves all the blocks above the tagged block down
  729.                         ;one block, therefore erasing the tagged block
  730.     pop hl              ;retrieve hl
  731.     dec hl              ;and dec it because we had to inc it before
  732.     pop bc              ;retrieve bc, (saved from the ldir)
  733.     add hl,bc           ;we getting to the last block in the line
  734.     ld (hl),$00         ;blank out the top block now that we've moved something
  735.     or a                ;reset carry flag
  736.     sbc hl,bc           ;gets back to the block we were on
  737.     jr DropDown3        ;we're going to have to test teh same block again, because we
  738.                         ;just moved a different block into that position
  739.  
  740. DropDown4:           ;or... if not tagged
  741.     inc hl              ;move up to the next block
  742.     dec bc              ;moved up, so the blocks above it is decreased
  743.     ld a,c              ;check if c is zero yet
  744.     or b                ;by testing it against b (always zero)
  745.     jr nz,DropDown3     ;if stuff still to do, go here
  746.     inc hl              ;go to the next line because at the end of the previous line
  747.     pop bc              ;the huge outer loop for each column
  748.     djnz DropDown2      ;go if still more rows to do
  749.     ret                 ;leave this friggin routine
  750.     
  751.  
  752.  
  753. ;------------------
  754. ;called when it is detected that the set of three have hit the bottom
  755. FinishedSet:
  756.     sub a                   ;make a zero
  757.     ld (CurrFinished),a     ;clear the indicator that shows whether set is done
  758.     ld hl,(YCoord)          ;we get the coords
  759.     push hl
  760.     pop bc                  ;and get them into bc
  761.     call GetBlock           ;so we can Get the address of the Block
  762.     ld a,(CurrBot)          ;hl is the address of the block
  763.     ld (hl),a               ;so load the block into the memory
  764.     inc hl                  ;next block will just be one above
  765.     ld a,(CurrMid)          ;now we do the same with the middle one
  766.     ld (hl),a               ;there
  767.     inc hl
  768.     ld a,(CurrTop)
  769.     ld (hl),a               ;and the top one
  770. FinishedSet2:
  771.     call BlockTestTime      ;now that the mem is set, test all the blocks for matches
  772.     call DeleteBlocks       ;erase those blocks that are tagged by BlockTestTime
  773.     ld de,$DFFF             ;this is a small pause to make it look realistic
  774. FinishedSet3:
  775.     dec de                  ;lower counter
  776.     ld a,d                  ;or d
  777.     or e                    ;with e
  778.     jr nz,FinishedSet3      ;if something still there, continue with loop 
  779.     call DropDown           ;now after delay, dropdown the blocks in mem
  780.     call PutScreen          ;and display the whole new screen
  781.     ld a,(TotalBlockCount)  ;this checks if there are more blocks to delete
  782.     ld hl,(Score)           ;add blocks to score
  783.     ld c,a                  ;get a into bc
  784.     ld b,0                  ;like that
  785.     add hl,bc               ;add it to the score
  786.     ld (Score),hl           ;and put it back, yaah
  787.     or a                    ;a still has the blocks deleted
  788.     jr z,FinishedSet4       ;if it is zero (no blocks were deleted), jump to here
  789.     ld de,$6FFF             ;this goes back to check for more blocks after a pause
  790. lilloop:
  791.     dec de                  ;this is the delay loop all over again
  792.     ld a,d
  793.     or e
  794.     jr nz,lilloop
  795.     jr FinishedSet2         ;and go back to check for more blocks
  796. FinishedSet4:               ;all done, now last stuff
  797.     ld hl,(Score)           ;get score
  798.     rl l                    ;these two commands rotate hl left once
  799.     rl h                    ;you need to remember to grab the carry
  800.     ld a,h                  ;we only want the info in h to test if 128 or more
  801.     bit 3,a                 ;if there is more than 1024 points
  802.     jr nz,GameAllDone       ;go to GameAllDone
  803.     ld (SpeedLevel),a       ;the upper portion defines the speed
  804.     rlca                    ;now we use the level to get the value for DelayTimer
  805.     ld c,a                  ;put speed*2 into bc
  806.     ld b,0                  ;like that
  807.     ld hl,TimerTable        ;this is the table at the end of this program
  808.     add hl,bc               ;put the offset on
  809.     call LD_HL_MHL          ;get the value from that address
  810.     ld (DelayTimer),hl      ;and that is the timer value
  811.  
  812.     call UpdateLevel        ;update the level on the screen
  813.     call UpdateScore        ;update the score on the screen
  814.     ld bc,$0D03             ;this is the address of the block to test
  815.     call GetBlock           ;check that block to see if somethngs there
  816.     or a                    ;if something there
  817.     jr nz,GameAllDone       ;if block in that position, game all done
  818.     call MakeNewSet         ;puts in random numbers for next 3
  819.     call DrawCurrent        ;and now we draw those three blocks
  820.     jp keycheck             ;and finally back to the main loop, yahoo!!!
  821.  
  822.  
  823.  
  824. ;--------------
  825. ;Sets vars for the next three blocks
  826. MakeNewSet:
  827.     ld hl,$0D03             ;sets coords for the new three
  828.     ld (YCoord),hl          ;set them
  829.     ld hl,Rand1             ;the address of the three random variables
  830.     ld de,CurrTop           ;the address of the three current blocks
  831.     ld bc,3                 ;move three bytes
  832.     ldir                    ;put randoms into the new blcoks
  833.     ret
  834.  
  835.  
  836. ;-----------------
  837. ;Tests for high scores, enter them, or return if not high
  838. GameAllDone:
  839.     sub a
  840.     ld (SavedGame),a        ;since game all done, no game is saved
  841.     ld hl,(Score)           ;get score
  842.     ex de,hl                ;we just want hl in de
  843.     ld a,(LevelDiff)        ;branches off relative to LevelDiff
  844.     cp 3
  845.     jr z,GameAllDone3
  846.     cp 4
  847.     jr z,GameAllDone4
  848.     cp 5
  849.     jr z,GameAllDone5
  850.     cp 6
  851.     jr z,GameAllDone6
  852.     cp 7
  853.     jr z,GameAllDone7
  854.     jr GameAllDone8
  855.  
  856.  
  857.  
  858. GameAllDone3:               ;we're working on level 3
  859.     ld hl,(High3)           ;get the high score
  860.     or a                    ;clear carry flag
  861.     sbc hl,de               ;because this subtraction includes the carry flag
  862.     jp nc,Start             ;but it sets the carry flag if subtraction went over
  863.                             ;if high is higher, go all the way back to start
  864.     ex de,hl                ;now put _your_ score in hl, it was in de
  865.     ld (High3),hl           ;and put in new high score
  866.     ld hl,High3Name         ;this is used later
  867.     jr HighScoreTime        ;and go to enter the initials
  868. GameAllDone4:
  869.     ld hl,(High4)           ;see above
  870.     or a
  871.     sbc hl,de
  872.     jp nc,Start
  873.     ex de,hl
  874.     ld (High4),hl
  875.     ld hl,High4Name
  876.     jr HighScoreTime
  877. GameAllDone5:               ;see above
  878.     ld hl,(High5)
  879.     or a
  880.     sbc hl,de
  881.     jp nc,Start
  882.     ex de,hl
  883.     ld (High5),hl
  884.     ld hl,High5Name
  885.     jr HighScoreTime
  886. GameAllDone6:               ;see above
  887.     ld hl,(High6)
  888.     or a
  889.     sbc hl,de
  890.     jp nc,Start
  891.     ex de,hl
  892.     ld (High6),hl
  893.     ld hl,High6Name
  894.     jr HighScoreTime
  895. GameAllDone7:               ;see above
  896.     ld hl,(High7)
  897.     or a
  898.     sbc hl,de
  899.     jp nc,Start
  900.     ex de,hl
  901.     ld (High7),hl
  902.     ld hl,High7Name
  903.     jr HighScoreTime
  904. GameAllDone8:               ;see above
  905.     ld hl,(High8)
  906.     or a
  907.     sbc hl,de
  908.     jp nc,Start
  909.     ex de,hl
  910.     ld (High8),hl
  911.     ld hl,High8Name
  912.     jr HighScoreTime
  913.  
  914.  
  915. ;-----------------
  916. ;enters the high scores
  917. HighScoreTime:
  918.     push hl                 ;saves the table to enter initials
  919.     call _clrLCD            ;first we clear the screen, dum, de, dum
  920.     ld hl,$0500             ;this is place for text
  921.     ld (_curRow),hl         ;load it in
  922.     ld hl,HighScore         ;High Score!
  923.     call _puts              ;put string
  924.     ld hl,$0801             ;place for first initial
  925.     ld (_curRow),hl         ;load it
  926.     ld hl,StringPlace       ;this has your previous high score, from UpdateScore
  927.     call _puts              ;put that score
  928.  
  929.     ld b,3                  ;3 initials as counter
  930.     ld hl,$0903             ;place to put first initial
  931.     ld (_curRow),hl         ;right there
  932.     pop hl                  ;now this is the place to store initials, from before
  933. InputLoop:
  934.     push bc                 ;save the counter
  935.     push hl                 ;save place to store initials
  936.     ld a,$DF                ;this is ti-ascii for the cursor
  937.     call _putc              ;put the cursor
  938.     ld hl,_curCol           ;this is the after putting the cursor
  939.     dec (hl)                ;put it back to where the cursor is
  940. KeyLoop:
  941.     call GET_KEY            ;gets the key
  942.     ld c,a                  ;get table value from InputTable
  943.     ld b,0                  ;
  944.     ld hl,InputTable
  945.     add hl,bc               ;by adding the keyvalue to InputTable
  946.     ld a,(hl)               ;and get the value
  947.     or a                    ;if it is zero
  948.     jr z,KeyLoop            ;we still need a key
  949.     pop hl                  ;get the initial address back
  950.     ld (hl),a               ;and load the first initial
  951.     inc hl                  ;and move to the next initial
  952.     call _putc              ;put that initial
  953.     pop bc                  ;counter...
  954.     djnz InputLoop          ;and get all three
  955.     ld de,$FFFF             ;or not, at which point we set up a delay
  956. LoopWait:
  957.     dec de                  ;you've seen this before
  958.     ld a,d
  959.     or e
  960.     jr nz,LoopWait
  961.     jp Start                ;and all done, so go back to intro screen
  962.  
  963.  
  964.  
  965. ;----------------
  966. ;puts the high score on the screen
  967. UpdateLevel:               
  968.     ld hl,$385D             ;coords
  969.     ld (_penCol),hl         ;load in coord address
  970.     ld a,(SpeedLevel)       ;get the level
  971.     add a,$31               ;this adds $30 to make it ascii, and one, to make it 1-8
  972.     ld hl,StringPlace       ;place to store ascii digit
  973.     ld (hl),a               ;put it in
  974.     ld b,1                  ;one char
  975.     call _vputsn            ;and display one char pointed to by hl
  976.     ret
  977.  
  978.  
  979. ;----------------
  980. ;puts the score on screem
  981. UpdateScore:                
  982.     ld hl,$386B             ;this is the cursor place
  983.     ld (_penCol),hl         ;and put it in
  984.     ld hl,(Score)           ;now we get score
  985.     ld de,StringPlace+4     ;start of unpacking
  986.     ld b,5                  ;5 digits
  987. UpdateScore2:
  988.     call UNPACK_HL          ;divide hl by 10 and a contains remainder
  989.     add a,'0'               ;asciiize it
  990.     ld (de),a               ;put it in
  991.     dec de                  ;next digit place to load
  992.     djnz UpdateScore2       ;keep going
  993.     ld hl,StringPlace       ;now we put it back
  994.     call _vputs             ;and display the score
  995.     ret
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003. ;---------------
  1004. ;Draw the current three blocks
  1005. DrawCurrent:
  1006.     ld hl,(YCoord)          ;get coords...
  1007.     push hl                 ;
  1008.     pop bc                  ;in bc
  1009.     ld a,(CurrBot)          ;get bottom block
  1010.     push bc                 ;save coords
  1011.     call DrawBlock          ;and draw it
  1012.     pop bc                  ;get coords back
  1013.     inc b                   ;inc y coord
  1014.     ld a,(CurrMid)
  1015.     push bc                 ;and so forth
  1016.     call DrawBlock
  1017.     pop bc
  1018.     inc b
  1019.     ld a,(CurrTop)
  1020.     call DrawBlock
  1021.     ret
  1022.  
  1023.  
  1024.  
  1025. ;---------------
  1026. ;move the three down a notch
  1027. MoveDown:
  1028.     ld hl,(YCoord)          ;get coords
  1029.     ld a,h                  ;check x coord in a
  1030.     or a                    ;if xcoord zero, lowest possible
  1031.     jr z,IndicateFinish     ;so indicate the finish, and leave
  1032.     dec h                   ;or else decrement x coord to check
  1033.     push hl                 ;
  1034.     pop bc                  ;put in bc
  1035.     call GetBlock           ;this checks the block below, to see if it's done
  1036.     or a                    ;if so
  1037.     jr nz,IndicateFinish    ;indicate the finish, and leave
  1038.     ld hl,(YCoord)          ;if everything okay
  1039.     push hl                 ;save hl
  1040.     push hl                 ;put hl
  1041.     pop bc                  ;and get it in bc
  1042.     inc b                   ;go to the top block to erase that block
  1043.     inc b
  1044.     sub a                   ;blannk block
  1045.     call DrawBlock          ;and draw it at the top
  1046.     pop hl                  ;coords saved
  1047.     dec h                   ;decrement it, xcoord
  1048.     ld (YCoord),hl          ;and load them back
  1049.     call DrawCurrent        ;Draw the Current three over the previous ones
  1050.     ret
  1051. IndicateFinish:
  1052.     ld a,1                  ;indiacte the finish with a boolean value
  1053.     ld (CurrFinished),a     ;boolean to see if current set finished
  1054.     ret
  1055.  
  1056.  
  1057.     
  1058. ;-------------
  1059. ;This gets the value and address of the block specified by bc
  1060. GetBlock:
  1061.     push bc                 ;save coords
  1062.     ld a,c                  ;use coord to find address
  1063.     rlca                    ;mult by 2
  1064.     rlca                    ;mult by 2
  1065.     rlca                    ;mult by 2
  1066.     rlca                    ;mult by 2  - 16 in all
  1067.     add a,b                 ;now we add the ycoord
  1068.     ld c,a
  1069.     ld b,0                  ;put it in bc
  1070.     ld hl,BlockMem          ;get the BlockMem
  1071.     add hl,bc               ;and here's the address
  1072.     ld a,(hl)               ;block ID in a,address in hl
  1073.     pop bc                  ;saves bc
  1074.     ret
  1075.  
  1076.  
  1077. ;----------------
  1078. ;Draws Block ID'd by a at coords b - (0-15) and c - (0-6)
  1079. DrawBlock:
  1080.     push hl                 ;save hl
  1081.     push de                 ;save de
  1082.     push af                 ;save af which holds block
  1083.     rlc c                   ;mult y coord by 2
  1084.     ld e,c                  ;use as offset           
  1085.     ld d,0
  1086.     ld hl,YTable            ;add it to this table
  1087.     add hl,de               ;like that
  1088.     call LD_HL_MHL          ;now has hl row offset
  1089.     ld e,b                  ;now we put the x coord in de
  1090.     ld d,0
  1091.     add hl,de               ;now added the column offset
  1092.     push hl                 ;and now we
  1093.     pop de                  ;put it in de
  1094.     pop af                  ;this gets the block we saved on the stack
  1095.     rlca                    ;mult by 8
  1096.     rlca
  1097.     rlca                    ;like that
  1098.     ld hl,Block0            ;now this contains all the blocks
  1099.     ld c,a                  ;put offset in bc
  1100.     ld b,0
  1101.     add hl,bc               ;now hl points to the bitmap block
  1102.     ld b,8                  ;8 bytes to display
  1103.     ex de,hl                ;de now contains vidmem spot, hl contains table
  1104. Putloop:
  1105.     push bc                 ;save counter
  1106.     ld a,(de)               ;get the bitmap byte from program
  1107.     ld (hl),a               ;put in vidmem
  1108.     inc de                  ;next byte
  1109.     ld bc,$0010             ;but we have to inc the vidmem 16 bytes to nextline
  1110.     add hl,bc               ;like that
  1111.     pop bc                  ;now the counter again
  1112.     djnz Putloop            ;and all eight bytes display
  1113.     pop de                  ;saves de and hl
  1114.     pop hl
  1115.     ret
  1116.  
  1117. ;---------------------
  1118. ;This routine displays the whole screen
  1119. PutScreen:                  ;
  1120.     ld hl,BlockMem          ;first block
  1121.     ld de,$0000             ;first coords
  1122.     ld b,7                  ;7 rows
  1123. PutScreen2:
  1124.     push bc                 ;save that counter
  1125.     ld b,16                 ;16 rows
  1126. PutScreen3:
  1127.     push bc                 ;save that counter
  1128.     push de                 ;put de
  1129.     pop bc                  ;in bc
  1130.     ld a,(hl)               ;get that block!
  1131.     call DrawBlock          ;saves de,hl, put block
  1132.     inc hl                  ;address
  1133.     inc d                   ;x coord
  1134.     pop bc                  ;get that counter
  1135.     djnz PutScreen3         ;loop till row finished
  1136.     ld d,0                  ;xcoord zero
  1137.     inc e                   ;inc y coord
  1138.     pop bc                  ;and this counter
  1139.     djnz PutScreen2         ;and the outer loop
  1140.     ret                     ;screen all done
  1141.  
  1142.  
  1143.  
  1144. LoadData:
  1145.     ld hl,$C089
  1146.     ld (hl),$12        ;variable type     
  1147.     inc hl             ;now to the next spot
  1148.     ld (hl),$07        ;the length
  1149.     inc hl             ;now we put in the name
  1150.     push hl            ;save that 
  1151.     ld hl,searchwords  ;here's the name of program
  1152.     pop de             ;pop it back into de
  1153.     ld bc,7            ;seven bytes for the ldir
  1154.     ldir               ;loads it into the spot
  1155.     rst 10h
  1156.     ld a,b
  1157.     ex de,hl
  1158.     call $4633
  1159.     set 6,a
  1160.     out (5),a
  1161.     inc a
  1162.     out (6),a
  1163.     ld bc,$4000
  1164.     or a
  1165.     sbc hl,bc
  1166.     push hl
  1167.     ld hl,CurrTop
  1168.     ld de,$D748
  1169.     or a
  1170.     sbc hl,de
  1171.     pop de
  1172.     add hl,de
  1173.     ld de,4
  1174.     add hl,de
  1175.     ld de,CurrTop
  1176.     ex de,hl
  1177.     ld bc,175
  1178.     ldir
  1179.     ld a,%00001101
  1180.     out (5),a
  1181.     ld a,%01000001
  1182.     out (6),a
  1183.     ret
  1184.  
  1185.  
  1186. ;---------------------------------------------------------------------------
  1187. ;End of code, start of data
  1188.  
  1189.  
  1190. ;These are the strings
  1191.     ;FORMAT - .db "KOLLUMS 1.0",0
  1192. ;              ^        ^       ^
  1193. ;this is 'define byte'  ^      and a zero on the end for _puts or _vputs
  1194. ;                       ^
  1195. ;                       ^
  1196. ;              Here is the string with quotation marks
  1197. ;
  1198.  
  1199. TitleStr:
  1200.     .db "KOLLUMS 2.0",0
  1201.  
  1202. Author:
  1203.     .db "By: Alan Bailey",0
  1204.  
  1205. Email:
  1206.     .db "<bailela@charlie.cns.iit.edu>",0
  1207.  
  1208. Difficulty:
  1209.     .db "Difficulty (l/r):",0
  1210.  
  1211. HighScore:
  1212.     .db "High Score!",0
  1213.  
  1214. HighStr:
  1215.     .db "High: ",0
  1216.  
  1217. ResumeStr:
  1218.     .db "Press F1 to Resume Game",0
  1219.  
  1220. searchwords:
  1221.     .db "kollums"
  1222.  
  1223.  
  1224. ;This is the key table, takes the value from call GET_KEY
  1225. ;and converts it to this ascii character
  1226. InputTable:
  1227.     .db 0,0,0,0,0,0,0,0,0,0
  1228.     .db 'X','T','O','J','E',0,0
  1229.     .db ' ','W','S','N','I','D',0,0
  1230.     .db 'Z','V','R','M','H','C',0,0
  1231.     .db 'Y','U','Q','L','G','B',0,0,0,0
  1232.     .db 'P','K','F','A',0,0,0,0,0,0,0,0,0,0
  1233.  
  1234.  
  1235. ;This is the value of the timers used to speed up the game
  1236. TimerTable:
  1237.     .dw $0660,$05A0,$04E0,$0420,$0360,$02A0,$01E0,$0120
  1238.  
  1239.  
  1240. ;7 y coord offsets for lookup
  1241. YTable:
  1242.     .dw $FC00,$FC80,$FD00,$FD80,$FE00,$FE80,$FF00
  1243.  
  1244. CurrTop:
  1245.     .db 0
  1246. CurrMid:
  1247.     .db 0
  1248. CurrBot:
  1249.     .db 0
  1250. CurrFinished:
  1251.     .db 0
  1252. Randomed:
  1253.     .db 0
  1254. YCoord:
  1255.     .db 0
  1256. XCoord:
  1257.     .db 0
  1258. Rand1:
  1259.     .db 0
  1260. Rand2:
  1261.     .db 0
  1262. Rand3:
  1263.     .db 0
  1264. StartBlock:
  1265.     .dw $0000
  1266. TotalBlockCount:
  1267.     .db 0
  1268. BlockDiff:
  1269.     .db 0
  1270. DelayTimer:
  1271.     .dw $0660
  1272. Score:
  1273.     .dw $0000
  1274. SpeedLevel:
  1275.     .db 0
  1276. StringPlace:
  1277.     .db 0,0,0,0,0,0
  1278. BlockMem:
  1279.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1280.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1281.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1282.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1283.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1284.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1285.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1286.  
  1287.  
  1288.  
  1289. ;this variable is stored in the program because we want to save it
  1290. LevelDiff:
  1291.     .db $06               ;this one we want to keep
  1292.  
  1293. ;along with these high score variables
  1294. High3:
  1295.     .db $01,$00
  1296. High3Name:
  1297.     .db 'A','B','C',$00     ;plus zero terminator
  1298. High4:
  1299.     .db $01,$00
  1300. High4Name:
  1301.     .db 'D','E','F',$00
  1302. High5:
  1303.     .db $01,$00
  1304. High5Name:
  1305.     .db 'G','H','I',$00
  1306. High6:
  1307.     .db $01,$00
  1308. High6Name:
  1309.     .db 'J','K','L',$00
  1310. High7:
  1311.     .db $01,$00
  1312. High7Name:
  1313.     .db 'M','N','O',$00
  1314. High8:
  1315.     .db $01,$00
  1316. High8Name:
  1317.     .db 'P','Q','R',$00
  1318.  
  1319. SavedGame:
  1320.     .db 0            ;set if a game is saved
  1321.  
  1322.  
  1323. ;this are simple bitmaps of blocks
  1324. Block0:
  1325.     .db %00000000
  1326.     .db %00000000
  1327.     .db %00000000
  1328.     .db %00000000
  1329.     .db %00000000
  1330.     .db %00000000
  1331.     .db %00000000
  1332.     .db %00000000
  1333.  
  1334. Block1:
  1335.     .db %00000000
  1336.     .db %01111111
  1337.     .db %01000001
  1338.     .db %01000001
  1339.     .db %01000001
  1340.     .db %01000001
  1341.     .db %01000001
  1342.     .db %01111111
  1343.  
  1344. Block2:
  1345.     .db %00000000
  1346.     .db %01111111
  1347.     .db %01111111
  1348.     .db %01111111
  1349.     .db %01111111
  1350.     .db %01111111
  1351.     .db %01111111
  1352.     .db %01111111
  1353.  
  1354. Block3:
  1355.     .db %00000000
  1356.     .db %00001000
  1357.     .db %00011100
  1358.     .db %00111110
  1359.     .db %01111111
  1360.     .db %00111110
  1361.     .db %00011100
  1362.     .db %00001000
  1363.  
  1364. Block4:
  1365.     .db %00000000
  1366.     .db %01100011
  1367.     .db %01100011
  1368.     .db %00010100
  1369.     .db %00001000
  1370.     .db %00010100
  1371.     .db %01100011
  1372.     .db %01100011
  1373.  
  1374. Block5:
  1375.     .db %00000000
  1376.     .db %01010101
  1377.     .db %00101010
  1378.     .db %01010101
  1379.     .db %00101010
  1380.     .db %01010101
  1381.     .db %00101010
  1382.     .db %01010101
  1383.  
  1384. Block6:
  1385.     .db %00000000
  1386.     .db %01111111
  1387.     .db %01001001
  1388.     .db %01001001
  1389.     .db %01111111
  1390.     .db %01001001
  1391.     .db %01001001
  1392.     .db %01111111
  1393.  
  1394. Block7:
  1395.     .db %00000000
  1396.     .db %00001000
  1397.     .db %00010100
  1398.     .db %00100010
  1399.     .db %01000001
  1400.     .db %00100010
  1401.     .db %00010100
  1402.     .db %00001000
  1403.  
  1404. Block8:
  1405.     .db %00000000
  1406.     .db %01111111
  1407.     .db %00111110
  1408.     .db %00011100
  1409.     .db %00001000
  1410.     .db %00011100
  1411.     .db %00111110
  1412.     .db %01111111
  1413.  
  1414. .end       ;tells TASM it's all over
  1415.