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

  1. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  2. ;
  3. ;                       ▓▓     ▓▓     ▒▒    ░   ░   ░
  4. ;                       ▓ ▓   ▓  ▓   ▒  ▒   ░░ ░░   ░
  5. ;                       ▓▓    ▓  ▓   ▒  ▒   ░ ░ ░   ░
  6. ;                       ▓ ▓   ▓  ▓   ▒  ▒   ░   ░    
  7. ;                       ▓▓     ▓▓     ▒▒    ░   ░   ░
  8. ;
  9. ; Boom!
  10. ; ver: 1.0
  11. ; Author: Bruce Herr 2
  12. ; E-mail: herrs@hsonline.net
  13. ;
  14. ; Date Started: 7/5/1998
  15. ; Date Finished: 7/13/1998
  16. ; Date released: 8//1998
  17. ;
  18. ; A "Kaboom!" type game.  Not as efficient as I'd like, but its a good start
  19. ; considering its my first assembly language game for the TI-86.  
  20. ;
  21. ; This game needs a big speed boost.  Once I figure out a way to do that, 
  22. ; this game will be perfect.  If you have any suggestions please E-mail me.
  23. ;
  24. ; I'd like to give a big thanks to Larry Kaplan for making the original game,
  25. ; "Kaboom!", for the Atari 2600 from which I got my game idea.
  26. ;
  27. ; I'd like to give a special thanks to TIcalc.org, TI-Files, and to the many  
  28. ; people who posted their source there, providing me with lots of sources from 
  29. ; which to learn from. 
  30. ;
  31. ; This is Freeware, so if you would like to use some of my source, please give
  32. ; credit where credit is due.  If you happen to change this source and make
  33. ; something cool out of it, please send me it.
  34. ;
  35. ; If anyone has a Putsprite routine that can put 16*16,8*8,and 12*13 sprites
  36. ; and possibly XOR it.  Then please E-Mail me a copy.  I would be glad to put
  37. ; you in the credits for my game.
  38. ;
  39. ; Also, If anyone knows how to save high scores, please E-Mail me an explanation.
  40. ; Right now I'm stumped on how to do it.  =(
  41. ;
  42. ; Please pardon some of my commenting.  After commenting about 700 lines of 
  43. ; code you get a little bit lazy, but I'm sure most of it is comprehendable.:>
  44. ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  45.  
  46. #include "asm86.h"
  47. #include "ti86asm.inc"
  48. .org _asm_exec_ram
  49.  
  50.     nop
  51.     jp Main_Prog
  52.     .dw $0000
  53.     .dw Description
  54.  
  55. Main_Prog:
  56.     call _clrLCD            ;cls
  57.     call _graphbufclr
  58.     call _runindicoff       ;turn off annoying run indicator
  59.     call Draw_Opening       ;draw opening screen
  60.  
  61. Key_Loop:
  62.     halt
  63.     call GET_KEY
  64.     cp K_EXIT
  65.     jp z,Game_Exit
  66.     cp K_ALPHA
  67.     jp z,Game_Init
  68.     jp Key_Loop
  69.  
  70. Game_Exit:
  71.     ld hl,0
  72.     ld (_curRow),hl 
  73.     set appTextSave,(iy+appflags)   ; clear _textShadow with _clrScrn
  74.     call _clrScrn
  75.     call _clrLCD
  76.     ret
  77.  
  78. Game_Init:
  79.     ld a,3
  80.     ld (Lives),a            ;lives = 3
  81.     ld a,0
  82.     ld (MoveCtr),a          ;ld the Move counter for the enemy w/ 0
  83.     ld (Level),a            ;level = 0 (Lev_Loop will inc it to 1)
  84.     ld hl,$0000
  85.     ld (Score),hl           ;score = 0
  86.     ld a,50
  87.     ld (E_X),a              ;starting x coord. for the bomb droppa
  88.     ld (x),a                ;starting x
  89.     ld (lx),a               ;ditto
  90.     ld hl,E_Dir
  91.     ld (hl),1       
  92.     call _clrLCD
  93.     call Draw_Screen
  94.     xor a
  95.     ld (Temp2),a
  96.     ld a,51
  97.     ld (Temp),a
  98. Init_Bucket:
  99.     ld a,(Temp)             ;ld the y
  100.     ld e,a
  101.     ld a,(x)                ;ld the x
  102.     ld hl,S_Bucket_1        ;ld the sprite
  103.     call PutSprite          ;put it!
  104.     ld a,(Temp)             ;ld the y
  105.     ld e,a
  106.     ld a,(x)                ;ld the x
  107.     add a,8
  108.     ld hl,S_Bucket_2        ;ld the sprite
  109.     call PutSprite          ;put it!
  110.     ld a,(Temp)             ;\
  111.     add a,5                 ;add 5 to the y
  112.     ld (Temp),a             ;/
  113.     ld a,(Temp2)
  114.     inc a
  115.     ld (Temp2),a
  116.     cp 3                    ;if its not 3 then
  117.     jp nz,Init_Bucket       ;do more buckets
  118.     
  119. Lev_Loop:
  120.     ld hl,55*256+102        ;row*256+col    
  121.     ld (_penCol),hl
  122.     ld a,(Level)
  123.     inc a                   ;inc level
  124.     ld (Level),a            ;/
  125.     call DispA              ;disp Level
  126.     ld a,(Level)            ;ld a w/ level
  127.     cp 51
  128.     jp z,You_Win
  129.     add a,a                 ;double a
  130.     add a,4                 ;and add 4
  131.     ld (NumBombs),a         ;save it into NumBombs (= 4+2*level)
  132.     ld (BombsLeft),a        ;save it into BombsLeft
  133.     ld h,a
  134.     ld a,225
  135.     sub h
  136.     cp -1
  137.     jp p,Keep_Delay
  138.     ld a,0
  139. Keep_Delay:
  140.     ld (ELevDel),a          ;ld the delay w/ 100 - (4+4*level)
  141.     ld a,0                  ;ld a w/ the loop counter
  142.     ld bc,bx                ;ld bc w/ the pointer to the bomb x array
  143.     ld de,by                ;ld de w/ the pointer to the bomb y array
  144.     ld hl,bl                ;ld hl w/ the pointer to the bomb life array
  145. Init_Bomb:
  146.     ex af,af'               ;save a
  147.     xor a
  148.     ld (bc),a               ;bombx(a) = 0
  149.     ld (de),a               ;bomby(a) = 0
  150.     ld (hl),a               ;bomblife(a) = 0
  151.     inc bc                  ;goto the next subscript
  152.     inc de                  ;ditto
  153.     inc hl                  ;ditto
  154.     ex af,af'               ;load a
  155.     inc a                   ;++loop counter
  156.     push de
  157.     ld d,a
  158.     ld a,(NumBombs)
  159.     inc a
  160.     ld e,a
  161.     ld a,d
  162.     cp e                    ;if its <> NumBombs + 1 then keep looping
  163.     pop de
  164.     jp nz,Init_Bomb
  165.     xor a
  166.     ld (EDelay),a
  167.     ld (BombsDropped),a
  168.     call Hit_2nd
  169. Wait_Loop:        
  170.     halt
  171.     ld a,0ffh               ;Reset keyport
  172.     out (1),a               ;Clear Port
  173.     ld a,%01111110          ;bit 0 is zero, checking for {-,-,-,UP,RIGHT,LEFT,DN}
  174.     out (1),a               ;put it out the port
  175.     nop
  176.     in a,(1)                ;reading...
  177.     ld h,a
  178.     bit 2,a                 ;checking if key is {--,--,--,UP,RIGHT,LEFT,DOWN}
  179.     call z,M_Right          ;if the bit was set, the common key in both sets (Right) was pressed.
  180.     ld a,h
  181.     bit 1,a                 ;checks for LEFT
  182.     call z,M_Left
  183.     ld a,%00111111          ;bit 6 is zero for checking for (EXIT)
  184.     out (1),a               ;put it out the port
  185.     nop
  186.     in a,(1)                ;reading...
  187.     bit 6,a                 ;check the 6th bit to see if its on (EXIT) 
  188.     jp z,Exit_Game          ;if it is then goto the main screen
  189.     ld c,a
  190.     bit 5,a                 ;if its 2nd then
  191.     call z,Erase_Line
  192.     ld a,c
  193.     bit 5,a                 ;if its 2nd then
  194.     jp z,Game_Loop          ;go play game
  195.     call Draw_Bucket        ;update the buckets
  196.     jp Wait_Loop
  197.  
  198. Game_Loop:
  199.     ld hl,ELevDel
  200.     ld b,2
  201. Pause_Again:        
  202.     ld a,b
  203.     ld b,(hl)
  204. Pause_Loop:
  205.     djnz Pause_Loop
  206.     ld b,a
  207.     djnz Pause_Again
  208.     ld a,0ffh               ;Reset keyport
  209.     out (1),a               ;Clear Port
  210.     ld a,%01111110          ;bit 0 is zero, checking for {-,-,-,UP,RIGHT,LEFT,DN}
  211.     out (1),a               ;put it out the port
  212.     nop
  213.     in a,(1)                ;reading...
  214.     ld h,a
  215.     bit 2,a                 ;checking if key is {--,--,--,UP,RIGHT,LEFT,DOWN}
  216.     call z,M_Right          ;if the bit was set, the common key in both sets (Right) was pressed.
  217.     ld a,h
  218.     bit 1,a                 ;checks for LEFT
  219.     call z,M_Left
  220.     ld a,%00111111          ;bit 6 is zero for checking for (EXIT)
  221.     out (1),a               ;put it out the port
  222.     nop
  223.     in a,(1)                ;reading...
  224.     bit 6,a                 ;check the 6th bit to see if its on (EXIT) 
  225.     jp z,Exit_Game          ;if it is then goto the main screen
  226.     bit 7,a                 ;if its More then
  227.     call z,Pause_Game       ;Pause
  228.     call Draw_Bucket        ;update the buckets
  229.     call Move_Enemy         ;move the enemy bomb droppa
  230.     call Move_Bomb
  231. ;Beginning of collision detection routine.
  232.     ld bc,0                 ;offset
  233. Check_Loop:
  234.     ld hl,bl                ;hl is a pointer to the bomb life
  235.     add hl,bc               ;add the offset
  236.     xor a
  237.     cp (hl)                 ;if it is dead then
  238.     jp z,Not_There          ;skip stuff
  239.     ld e,-1
  240.     ld a,51
  241.     ld (Temp),a
  242. _Col_Loop:
  243.     call _Collisions        ;check for a collision
  244.     cp 1                    ;if a collision occured react
  245.     jp z,_Col_Occured       ;/
  246.     inc e                   ;otherwise inc loop counter
  247.     ld a,(Temp)             ;\
  248.     add a,5                 ;+5 to the y 
  249.     ld (Temp),a             ;/
  250.     ld a,(Lives)            ;if lives are greater 
  251.     cp e                    ;than the loop then 
  252.     jp p,_Col_Loop          ;loop again
  253.     ld hl,by                ;ld hl w/ the bomb y coord
  254.     add hl,bc               ;add the offset                                              
  255.     ld a,(hl)               ;ld the value into a
  256.     cp 55                   ;if its not at the bottom then                        
  257.     jp nz,Not_There         ;skip to prepare for another
  258.     ld a,(Lives)
  259.     dec a
  260.     ld (Lives),a
  261.     cp 0
  262.     jp z,You_Lose           ;does you lose stuff 
  263.     ld a,(Level)
  264.     dec a                   ;-1 to level (lev loop will bring it back to the same level)
  265.     ld (Level),a
  266.     ld a,(E_Dir)            ;\
  267.     neg                     ;reverse the enemies direction   
  268.     ld (E_Dir),a            ;/
  269.     jp Next_Round
  270. Not_There:
  271.     inc c                   ;inc the offset      
  272.     ld a,(NumBombs)         ;ld a w/ the NumBombs for this level
  273.     inc a
  274.     cp c                    ;compare the two
  275.     jp z,Game_Loop          ;if its zero then goto game loop
  276.     jp Check_Loop           ;else loop again
  277. ;end of collision detection routine
  278.  
  279. _Col_Occured:
  280.     ld hl,(Score)           ;Score = Score + Level
  281.     ld a,(Level)            ;/
  282.     ld e,a
  283.     ld d,0                  ;/
  284.     add hl,de               ;/
  285.     ld (Score),hl           ;/
  286.     call Display_Score      ;put score on the screen
  287.     ld hl,bl
  288.     add hl,bc
  289.     ld (hl),0
  290.     ld hl,by        
  291.     add hl,bc
  292.     ld e,(hl)
  293.     ld hl,bx
  294.     add hl,bc
  295.     ld a,(hl)
  296.     push bc
  297.     ld hl,S_Bomb
  298.     call PutSprite          ;XOR it!
  299.     pop bc
  300.     ld a,(BombsLeft)
  301.     dec a                   ;-1 to the number of bombs left
  302.     ld (BombsLeft),a
  303.     cp 0
  304.     jp z,Lev_Loop
  305.     jp Not_There            ;skip to prepare for another
  306.  
  307. Move_Bomb:
  308.     ld bc,0                 ;offset
  309. Chk_Loop:
  310.     ld hl,bl                ;hl is a pointer to the bomb life
  311.     add hl,bc               ;add the offset
  312.     ld a,(hl)               ;ld the life pointed to by hl into a
  313.     cp 0                    
  314.     jp z,Not_Living         
  315.     push bc                 ;save offset
  316.     ld hl,by                ;ld hl w/ the bomb y pointer
  317.     add hl,bc               ;add the offset
  318.     ld e,(hl)               ;save the value into e
  319.     inc (hl)
  320.     ld hl,bx                ;ld hl w/ the bomb x pointer
  321.     add hl,bc               ;add the offset
  322.     ld a,(hl)               ;put the value in a
  323.     ld d,a                  
  324.     push de                 ;save the coords.
  325.     ld hl,S_Bomb            ;load the bomb sprite pointer
  326.     call PutSprite          ;xor it!
  327.     pop de                  ;load the coords
  328.     inc e                   ; and inc the y 
  329.     ld a,d                  ;put the x into a
  330.     ld hl,S_Bomb            ;load the bomb sprite
  331.     call PutSprite          ;and put it!
  332.     pop bc                  ;get the offset back
  333. Not_Living:
  334.     inc c                   ;inc the offset      
  335.     ld a,(NumBombs)         ;ld a w/ the NumBombs for this level
  336.     inc a
  337.     cp c                    ;compare the two
  338.     ret z                   ;if its zero then return
  339.     jp Chk_Loop             ;else loop again
  340.  
  341. _Collisions:                    
  342.     ld hl,bx                ;ld hl w/ bomb x
  343.     add hl,bc               ;add the offset
  344.     ld d,(hl)               ;load d w/ badguyX coord.
  345.     inc d
  346.     ld a,(x)                ;load a w/ x coord.
  347.     sub 8                   ;sub width of sprite from x
  348.     cp d                    ;IF x - (width) <= badguyX THEN
  349.     jp m,good_col           ;do some more checking
  350.     ld a,0                  ;ELSE there wasn't a collision
  351.     ret                     ;return
  352. good_col:
  353.     add a,12+8              ;add the width + 8
  354.     dec d
  355.     dec d
  356.     cp d                    ;IF x + (width) > badguyX THEN
  357.     jp p,still_good         ;do even more checking
  358.     ld a,0                  ;ELSE there wasn't a collision
  359.     ret                     ;return
  360. still_good:
  361.     ld hl,by                ;ld hl w/ bomb y
  362.     add hl,bc               ;add the offset
  363.     ld a,(hl)               ;load d w/ badguyY coord.
  364.     add a,9                 ;goto bottom of sprite
  365.     ld d,a
  366.     ld a,(Temp)             ;ld a w/y
  367.     cp d
  368.     jp m,still_good2        ;do even more checking
  369.     ld a,0                  ;ELSE there wasn't a collision
  370.     ret                     ;return
  371. still_good2:
  372.     add a,3                 ;add the heighth 
  373.     cp d                    ;IF y + (heighth) > badguyY THEN
  374.     jp p,all_good           ;there was a collision! oohh yeee!
  375.     ld a,0                  ;ELSE there wasn't a collision
  376.     ret                     ;return
  377. all_good:
  378.     ld a,1                  ;tell 'em there was collision
  379.     ret                     ;return                
  380.  
  381. Next_Round:
  382.     ld bc,0                  ;ld the offset (bc) w/ 0
  383. Next_Loop:
  384.     ld hl,bl                ;ld a pointer to the bomb life array
  385.     add hl,bc               ;add the offset
  386.     ld a,1                  ;if there is a one
  387.     cp (hl)                 ;in that spot 
  388.     call z,Live_One         ;Then show an explosion there
  389.     inc c                   ;inc the offset
  390.     ld a,(NumBombs)         ;loop until c = Numbombs + 1
  391.     inc a
  392.     cp c                    ;NumBombs
  393.     jp nz,Next_Loop         ;/
  394.     call Hit_2nd
  395. Next_Pause:
  396.     halt
  397.     call GET_KEY            ;Pause until they hit second or 
  398.     cp K_EXIT               ;exit if they hit exit
  399.     jp z,Exit_Game
  400.     cp K_SECOND
  401.     jp nz,Next_Pause
  402.     call Erase_Line
  403.     ld bc,0                  ;ld the offset w/ 0
  404. Next_Lop:
  405.     ld hl,bl                ;ld hl w/ the pointer to the bomb life array
  406.     add hl,bc               ;add the offset
  407.     ld a,1                  ;if its one then
  408.     cp (hl)                 ;erase the explosion
  409.     call z,Kill_One         ;and set its life to 0
  410.     inc c                   ;inc the offset
  411.     ld a,(NumBombs)         ;loop until c = Numbombs + 1
  412.     inc a
  413.     cp c                    
  414.     jp nz,Next_Lop          
  415.     ld a,(Lives)            ;ld the lives
  416.     cp 1                    ;if one is left then
  417.     jp z,One_Life           ;y = 56
  418.     ld a,61                 ;else y = 61
  419.     ld (Temp),a             ;/
  420.     jp Erase_Buc            ;/
  421. One_Life:
  422.     ld a,56                 ;y = 56
  423.     ld (Temp),a             ;/
  424. Erase_Buc:
  425.     ld e,a                  ;ld e, w/ y
  426.     ld a,(x)                ;ld the x coord
  427.     ld hl,S_Bucket_1        ;ld the first bucket sprite
  428.     call PutSprite          ;XOR it!
  429.     ld a,(Temp)             ;ld the y coord
  430.     ld e,a                  ;into e
  431.     ld a,(x)                ;ld the x coord
  432.     add a,8                 ;and add 8
  433.     ld hl,S_Bucket_2        ;ld the second bucket sprite
  434.     call PutSprite          ;XOR it!
  435.     jp Lev_Loop             ;Do Lev over
  436.  
  437. Live_One:
  438.     push bc
  439.     ld hl,by
  440.     add hl,bc
  441.     ld e,(hl)
  442.     ld hl,bx
  443.     add hl,bc
  444.     ld a,(hl)
  445.     ld d,a
  446.     push de
  447.     ld hl,S_Bomb
  448.     call PutSprite          ;XOR it!
  449.     pop de
  450.     ld a,d
  451.     ld hl,S_Explosion
  452.     call PutSprite          ;Put an Explosion!
  453.     pop bc
  454.     ret
  455.  
  456. Kill_One:
  457.     push bc
  458.     ld hl,by
  459.     add hl,bc
  460.     ld e,(hl)
  461.     ld hl,bx
  462.     add hl,bc
  463.     ld a,(hl)
  464.     ld d,a
  465.     ld hl,S_Explosion
  466.     call PutSprite          ;XOR it!
  467.     pop bc
  468.     ret
  469.  
  470. Draw_Enemy:        
  471.     ld e,0
  472.     ld a,(E_X)
  473.     ld hl,S_E_UL
  474.     call PutSprite
  475.     ld e,0
  476.     ld a,(E_X)
  477.     add a,8
  478.     ld hl,S_E_UR
  479.     call PutSprite
  480.     ld e,8
  481.     ld a,(E_X)
  482.     add a,8
  483.     ld hl,S_E_LR
  484.     call PutSprite
  485.     ld e,8
  486.     ld a,(E_X)
  487.     ld hl,S_E_LL
  488.     call PutSprite
  489.     ld e,16
  490.     ld a,(E_X)
  491.     ld hl,S_E_Hand
  492.     call PutSprite
  493.     ld e,16
  494.     ld a,(E_X)
  495.     add a,11
  496.     ld hl,S_E_Hand
  497.     call PutSprite
  498.     ret
  499.  
  500. Hit_2nd:
  501.     ld hl,23*256+0                  ;row*256+col    
  502.     ld (_penCol),hl
  503.     ld hl,T_Hit_2nd                 ;disp "Hit 2nd!!"
  504.     call _vputs
  505.     ret
  506.  
  507. Erase_Line:
  508.     ld de,23*256-1                 ;row*256+col           
  509.     ld b,50
  510. Erase_Loop:
  511.     inc de
  512.     ld (_penCol),de
  513.     ld hl,T_Blank                 ;disp "        "
  514.     call _vputs
  515.     djnz Erase_Loop
  516.     ret
  517.  
  518. Exit_Game:
  519.     call Hit_2nd
  520.     ld a,4
  521.     ld (_curRow),a
  522.     ld (_curCol),a
  523.     ld hl,T_Game_Over                 ;disp "Game Over"
  524.     call _puts
  525. Exit_Loop
  526.     halt
  527.     call GET_KEY
  528.     cp K_SECOND
  529.     jp nz,Exit_Loop
  530.     jp Main_Prog
  531.  
  532. Pause_Game:
  533.     halt
  534.     call GET_KEY
  535.     cp K_EXIT
  536.     jp z,Exit_Game
  537.     cp K_SECOND
  538.     jp nz,Pause_Game
  539.     ret
  540.  
  541. M_Left:
  542.     ld a,(x)
  543.     cp 0
  544.     ret z
  545.     dec a
  546.     ld (x),a
  547.     ret
  548.  
  549. M_Right:
  550.     ld a,(x)
  551.     cp 88
  552.     ret z
  553.     inc a
  554.     ld (x),a
  555.     ret
  556.  
  557. Move_Enemy:
  558.     ld a,(NumBombs)         ;ld d w/ the number of bombs
  559.     ld d,a                  ;/
  560.     ld a,(BombsDropped)     ;ld a w/ the number of bombs dropped
  561.     cp d                    ;if they are equal then
  562.     ret z                   ;don't move the enemy
  563.     call Draw_Enemy         ;XOR the enemy!
  564.     ld a,(E_Dir)            ;ld e the enemy's dir
  565.     ld e,a                  ;/
  566.     ld a,(E_X)              ;ld a w enemies x
  567.     add a,e                 ;E_X = E_X + E_Dir
  568.     ld (E_X),a              ;/
  569.     call Draw_Enemy         ;put the dang enemy!
  570.     ld a,(E_X)
  571.     cp 1                    ;if at 0 then 
  572.     jp m,Neg_E_Dir          ;changes the dir
  573.     cp 83                   ;if at 84 then
  574.     jp p,Neg_E_Dir          ;changes the dir
  575.     ld a,255
  576.     call Random
  577.     cp 1
  578.     jp z,Neg_E_Dir
  579. Ch_Dir:
  580.     ld a,(MoveCtr)
  581.     inc a                   ;inc move ctr
  582.     ld (MoveCtr),a          ;ld a w/ move counter
  583.     cp 25                   ;if its not __ then
  584.     ret nz                  ;return 
  585.     xor a                   ;a=0
  586.     ld (MoveCtr),a          ;else reset move counter
  587.     ld a,(BombsDropped)
  588.     inc a                   ;inc bombs dropped
  589.     ld (BombsDropped),a     ;ld bc w/ it and use it as the offset
  590.     ld b,0
  591.     ld c,a
  592.     ld hl,bx                ;ld hl w/ bomb's x array
  593.     add hl,bc               ;add the offset
  594.     ld a,(E_X)              ;put the enemy's x into a
  595.     add a,4                 ;add 4 to it (to center it)
  596.     ld (hl),a               ;ld that value into the bomb's x
  597.     ld hl,by                ;ld hl w/ the bomb y array
  598.     add hl,bc               ;add the offset
  599.     ld (hl),20              ;ld it w/ 20
  600.     ld hl,bl                ;ld hl w/ the bomb life
  601.     add hl,bc               ;add the offset
  602.     ld (hl),1               ;ld a one into it
  603.     ld e,20                 ;assign e the x value
  604.     ld a,(E_X)              ;get the Enemy's x coord
  605.     add a,4                 ;add 4 to it
  606.     ld hl,S_Bomb            ;ld the bomb sprite pointer
  607.     call PutSprite          ;Put it!
  608.     ret                     ;return
  609.  
  610. Neg_E_Dir:
  611.     ld a,(E_Dir)            ;ld a w/ the direction the enemy is heading
  612.     neg                     ;switch the sign (1 to -1 or -1 to 1)
  613.     ld (E_Dir),a            ;save it back into E_Dir
  614.     jp Ch_Dir               ;jump to Ch_Dir
  615.  
  616. Draw_Bucket:
  617.     ld a,(lx)               ;ld the last x into a
  618.     ld hl,x
  619.     cp (hl)                 ;if its not different then
  620.     jp z,Buc_Delay
  621.     xor a
  622.     ld (Temp2),a            ;ld temp2 w/ offset & loop counter
  623.     ld a,51
  624.     ld (Temp),a             ;ld temp w/ 51 (y value)
  625. Draw_Loop:
  626.     ld a,(Temp)             ;ld the y
  627.     ld e,a
  628.     ld a,(lx)               ;ld the lx
  629.     ld hl,S_Bucket_1        ;ld the sprite
  630.     call PutSprite          ;XOR it!
  631.     ld a,(Temp)             ;ld the y
  632.     ld e,a
  633.     ld a,(lx)               ;ld the lx
  634.     add a,8
  635.     ld hl,S_Bucket_2        ;ld the sprite
  636.     call PutSprite          ;XOR it!
  637.     ld a,(Temp)             ;ld the y
  638.     ld e,a
  639.     ld a,(x)                ;ld the x
  640.     ld hl,S_Bucket_1        ;ld the sprite
  641.     call PutSprite          ;put it!
  642.     ld a,(Temp)             ;ld the y
  643.     ld e,a
  644.     ld a,(x)                ;ld the x
  645.     add a,8
  646.     ld hl,S_Bucket_2        ;ld the sprite
  647.     call PutSprite          ;put it!
  648.     ld a,(Temp)             ;\
  649.     add a,5                 ;add 5 to Temp
  650.     ld (Temp),a             ;/
  651.     ld a,(Temp2)            ;ld it into a
  652.     inc a                   ;inc the loop counter
  653.     ld e,a
  654.     ld (Temp2),a            ;/
  655.     ld a,(Lives)            ;if lives are greater 
  656.     inc e
  657.     cp e                    ;than the loop then 
  658.     jp p,Draw_Loop          ;loop again
  659. Done_Bucket:
  660.     ld a,(x)
  661.     ld (lx),a               ;lx = x
  662.     ret                     ;return
  663.  
  664. Buc_Delay:                      
  665.     ld hl,200               
  666.     ld a,(ELevDel)          
  667.     ld e,a
  668.     ld d,0
  669.     add hl,de
  670.     ex de,hl
  671.     ld hl,0
  672. Buck_Loop:                       
  673.     inc hl
  674.     call CP_HL_DE
  675.     jp nz,Buck_Loop
  676.     jp Done_Bucket
  677.      
  678. You_Lose:
  679.     ld hl,by                ;ld hl w/ the bomb y coord
  680.     add hl,bc               ;add the offset                                              
  681.     ld e,(hl)               ;ld the value into a
  682.     ld hl,bx                ;ld hl w/ the bomb x coord
  683.     add hl,bc               ;add the offset
  684.     ld a,(hl)               ;save it into d
  685.     ld d,a                  ;
  686.     push de                 ;save the coords.
  687.     ld hl,S_Bomb            ;ld the bomb sprite
  688.     call PutSprite          ;XOR it off!
  689.     pop de                  ;get the coords. back
  690.     ld a,d
  691.     ld hl,S_Explosion
  692.     call PutSprite          ;put a dang explosion freakin' there
  693.     set 3,(iy+$05)          ;draw in inverse text
  694.     ld a,4
  695.     ld (_curRow),a
  696.     ld (_curCol),a
  697.     ld hl,T_You_Lose        ;disp "You lose"
  698.     call _puts
  699.     res 3,(iy+$05)          ;res to reg. text
  700.     call Hit_2nd
  701. Lose_Loop:
  702.     call GET_KEY
  703.     cp K_SECOND
  704.     jp nz,Lose_Loop
  705.     jp Main_Prog
  706.  
  707. You_Win:
  708.     set 3,(iy+$05)          ;draw in inverse text
  709.     ld a,4
  710.     ld (_curRow),a
  711.     ld (_curCol),a
  712.     ld hl,T_You_Win         ;disp "You Win!!"
  713.     call _puts
  714.     res 3,(iy+$05)          ;res to reg. text
  715.     call Hit_2nd
  716. Win_Loop:
  717.     call GET_KEY
  718.     cp K_SECOND
  719.     jp nz,Win_Loop
  720.     jp Main_Prog
  721.  
  722. _graphbufclr:                          ;clears the graph buffer, so _ILine doesn't mess up
  723.     ld hl,_plotSScreen             ;graphmem into HL
  724.     ld (hl),0                      ;loads 0 into it
  725.     ld de,_plotSScreen+1           ;loads graphmem+1 into de
  726.     ld bc,1024                     ;loads the 1024 into bc
  727.     ldir                           ;draws on screen
  728.     set graphdraw,(iy+graphflags)  ;sets flag
  729.     ret                            ;return from call
  730.  
  731. Display_Score:
  732.     ld hl,40*256+102                  ;row*256+col    
  733.     ld (_penCol),hl
  734.     ld hl,(Score)                     
  735.     call DispHL
  736.     ret
  737.  
  738. Draw_Opening:
  739.     ld a,3
  740.     ld (_curRow),a
  741.     ld a,6
  742.     ld (_curCol),a
  743.     ld hl,T_Boom            ;disp "B O O M !"
  744.     call _puts                             
  745.     ld hl,47*256+99         ;row*256+col    
  746.     ld (_penCol),hl
  747.     ld a,2
  748.     call DispA              ;draw a little ² next to "By: Bruce Herr"
  749.     ld a,6
  750.     ld (_curRow),a
  751.     ld a,3
  752.     ld (_curCol),a
  753.     ld hl,T_Me              ;disp "By: Bruce Herr"
  754.     call _puts                             
  755.     ld hl,57*256+45         ;row*256+col    
  756.     ld (_penCol),hl
  757.     ld hl,T_Press_ALPHA     ;disp "Press ALPHA"
  758.     call _vputs
  759.     ld a,24
  760.     ld e,a
  761.     ld hl,S_Bomb
  762.     call PutSprite
  763.     ld a,93
  764.     ld e,24
  765.     ld hl,S_Bomb
  766.     call PutSprite
  767.     ld a,56
  768.     ld (E_X),a
  769.     call Draw_Enemy
  770.     ld b,0                        ;x1
  771.     ld c,48                         ;y1
  772.     ld d,126                        ;x2
  773.     ld e,c                          ;y2
  774.     ld h,1                          ;h = 1 for Shading (2 = unshade, 3 = xor)
  775.     call  _ILine                    ;draw the line
  776.     ret
  777.  
  778. Draw_Screen:
  779.     call _graphbufclr
  780.     ld b,100                        ;x1
  781.     ld c,1                          ;y1
  782.     ld d,126                        ;x2
  783.     ld e,c                          ;y2
  784.     ld h,1                          ;h = 1 for Shading (2 = unshade, 3 = xor)
  785.     call  _ILine                    ;draw the line
  786.     ld b,100                        ;x1
  787.     ld c,0                          ;y1
  788.     ld d,b                          ;x2
  789.     ld e,63                         ;y2
  790.     ld h,1                          ;h = 1 for Shading (2 = unshade, 3 = xor)
  791.     call  _ILine                    ;draw the line
  792.     ld b,100                        ;x1
  793.     ld c,63                         ;y1
  794.     ld d,126                        ;x2
  795.     ld e,c                          ;y2
  796.     ld h,1                          ;h = 1 for Shading (2 = unshade, 3 = xor)
  797.     call  _ILine                    ;draw the line
  798.     ld b,126                        ;x1
  799.     ld c,63                         ;y1
  800.     ld d,b                          ;x2
  801.     ld e,0                          ;y2
  802.     ld h,1                          ;h = 1 for Shading (2 = unshade, 3 = xor)
  803.     call  _ILine                    ;draw the line
  804.     ld b,126                        ;x1
  805.     ld c,16                         ;y1
  806.     ld d,100                        ;x2
  807.     ld e,c                          ;y2
  808.     ld h,1                          ;h = 1 for Shading (2 = unshade, 3 = xor)
  809.     call  _ILine                    ;draw the line
  810.     ld b,126                        ;x1
  811.     ld c,32                         ;y1
  812.     ld d,100                        ;x2
  813.     ld e,c                          ;y2
  814.     ld h,1                          ;h = 1 for Shading (2 = unshade, 3 = xor)
  815.     call  _ILine                    ;draw the line
  816.     ld b,126                        ;x1
  817.     ld c,42                         ;y1
  818.     ld d,100                        ;x2
  819.     ld e,c                          ;y2
  820.     ld h,1                          ;h = 1 for Shading (2 = unshade, 3 = xor)
  821.     call  _ILine                    ;draw the line
  822.     ld b,100                        ;x1
  823.     ld c,48                         ;y1
  824.     ld d,0                          ;x2
  825.     ld e,c                          ;y2
  826.     ld h,1                          ;h = 1 for Shading (2 = unshade, 3 = xor)
  827.     call  _ILine                    ;draw the line
  828.     ld hl,49*256+103                ;row*256+col    
  829.     ld (_penCol),hl
  830.     ld hl,T_Level                   ;disp "Level:"
  831.     call _vputs
  832.     ld hl,33*256+103                ;row*256+col    
  833.     ld (_penCol),hl
  834.     ld hl,T_Score                   ;disp "Score:"
  835.     call _vputs
  836.     call Display_Score              ;disp Score
  837.     ld hl,23*256+103                ;row*256+col    
  838.     ld (_penCol),hl
  839.     ld hl,T_BH2                     ;disp "By:BH2"
  840.     call _vputs
  841.     ld a,102                        ;title x
  842.     ld e,3                          ;title y
  843.     ld hl,S_Title_A                 ;title pointer
  844.     call PutSprite                  ;Put it!
  845.     ld a,110                        ;title x
  846.     ld e,3                          ;title y
  847.     ld hl,S_Title_B                 ;title pointer
  848.     call PutSprite                  ;Put it!
  849.     ld a,118                        ;title x
  850.     ld e,3                          ;title y
  851.     ld hl,S_Title_C                 ;title pointer
  852.     call PutSprite                  ;Put it!
  853.     ld a,102                        ;title x
  854.     ld e,11                         ;title y
  855.     ld hl,S_Title_D                 ;title pointer
  856.     call PutSprite                  ;Put it!
  857.     ld a,110                        ;title x
  858.     ld e,11                         ;title y
  859.     ld hl,S_Title_E                 ;title pointer
  860.     call PutSprite                  ;Put it!
  861.     ld a,118                        ;title x
  862.     ld e,11                         ;title y
  863.     ld hl,S_Title_F                 ;title pointer
  864.     call PutSprite                  ;Put it!
  865.     call Draw_Enemy                 ;draw where the bomb droppa is
  866.     ret
  867.  
  868. ;  |)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))|
  869. ;--|Randomization routine by Jimmy Mardell (used in ZTetris v3.0)|--
  870. ;  |<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|
  871. Random:               ; Creates a pseudorandom number 0 <= x < A
  872.    ld b,a
  873.    ld a,r
  874.    add a,a
  875.    ld hl,0
  876.    ld d,0
  877.    ld e,a
  878. RMul:
  879.    add hl,de
  880.    djnz RMul
  881.    ld a,h
  882.    ret
  883.  
  884.  
  885. ;-----Display HL Routine [By: SCaBBy]-----
  886. DispA:
  887.  ld l,a
  888.  ld h,0
  889. DispHL:                                 ;dipslay 5 digits from hl
  890.  xor a
  891.  ld de,-1
  892.  ld (_curRow),de
  893.  call 4A33h
  894.  dec hl
  895.  jp _vputs
  896.  
  897. ;----------------------
  898. ;|Sprite Routine [XOR]
  899. ;----------------------
  900. ;------------------------------------------------------
  901. ;|This Routine was converted by AVD from Movax's 83
  902. ;|Special thanks to ScaBBy for making it XOR Routine!
  903. ;------------------------------------------------------
  904.  
  905. ;hl = image
  906. ;a = x coord
  907. ;e = y coord
  908.  
  909. PutSprite:
  910.        push    hl              ; Save sprite address
  911.  
  912. ;████   Calculate the address in graphbuf   ████
  913.  
  914.     ld      hl,0            ; Do y*12
  915.     ld      d,0
  916.     ex      de,hl
  917.     add     hl,hl
  918.     add     hl,hl
  919.     add     hl,hl
  920.     add     hl,hl
  921.  
  922.     ld      d,0             ; Do x/8
  923.     ld      e,a
  924.     srl     e
  925.     srl     e
  926.     srl     e
  927.     add     hl,de
  928.  
  929.     ld      de,$FC00
  930.     add     hl,de           ; Add address to graphbuf
  931.  
  932.     ld      b,00000111b     ; Get the remainder of x/8
  933.     and     b
  934.     cp      0               ; Is this sprite aligned to 8*n,y?
  935.     jp      z,ALIGN
  936.  
  937.  
  938. ;████   Non aligned sprite blit starts here   ████
  939.  
  940.     pop     ix              ; ix->sprite
  941.     ld      d,a             ; d=how many bits to shift each line
  942.  
  943.     ld      e,8             ; Line loop
  944. LILOP:  ld      b,(ix+0)        ; Get sprite data
  945.  
  946.     ld      c,0             ; Shift loop
  947.     push    de
  948. SHLOP:  srl     b
  949.     rr      c
  950.     dec     d
  951.     jp      nz,SHLOP
  952.     pop     de
  953.  
  954.     ld      a,b             ; Write line to graphbuf
  955.     xor     (hl)
  956.     ld      (hl),a
  957.     inc     hl
  958.     ld      a,c
  959.     xor     (hl)
  960.     ld      (hl),a
  961.  
  962.     ld      bc,15           ; Calculate next line address
  963.     add     hl,bc
  964.     inc     ix              ; Inc spritepointer
  965.  
  966.     dec     e
  967.     jp      nz,LILOP        ; Next line
  968.  
  969.     jp      DONE1
  970.  
  971.  
  972. ;████   Aligned sprite blit starts here   ████
  973.  
  974. ALIGN:                          ; Blit an aligned sprite to graphbuf
  975.     pop     de              ; de->sprite
  976.     ld      b,8
  977. ALOP1:  ld      a,(de)
  978.     xor      (hl)            ; xor=erase/blit
  979.     ld      (hl),a
  980.     inc     de
  981.     push    bc
  982.     ld      bc,16
  983.     add     hl,bc
  984.     pop     bc
  985.     djnz    ALOP1
  986.  
  987. DONE1:
  988.     ret
  989.  
  990.  
  991. ;Variables:
  992. bl:
  993.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  994.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  995.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  996.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  997.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  998. bx: 
  999.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1000.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1001.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1002.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1003.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1004. by:
  1005.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1006.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1007.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1008.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1009.     .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1010.  
  1011. Temp: .db 0,0
  1012. Temp2: .db 0,0
  1013. EDelay: .db 0
  1014. ELevDel: .db 0
  1015. lx: .db 0
  1016. x: .db 0
  1017. Score: .db 0,0
  1018. Lives: .db 0
  1019. Level: .db 0
  1020. BombsLeft: .db 0
  1021. NumBombs: .db 0
  1022. BombsDropped: .db 0
  1023. MoveCtr: .db 0
  1024. E_Dir: .db 0
  1025. E_X: .db 0
  1026.  
  1027. ;Sprites:
  1028. S_Bomb:
  1029.     .db %00010000
  1030.     .db %00111100
  1031.     .db %01110110
  1032.     .db %11111011
  1033.     .db %11111111
  1034.     .db %11111111
  1035.     .db %01111110
  1036.     .db %00111100
  1037. S_Explosion:
  1038.     .db %11000011
  1039.     .db %11100111
  1040.     .db %01100110
  1041.     .db %00011000
  1042.     .db %00011000
  1043.     .db %01100110
  1044.     .db %11100111
  1045.     .db %11000011
  1046. S_Blank:
  1047.     .db %00000000
  1048.     .db %00000000
  1049.     .db %00000000
  1050.     .db %00000000
  1051.     .db %00000000
  1052.     .db %00000000
  1053.     .db %00000000
  1054.     .db %00000000
  1055. S_E_UL:
  1056.     .db %00000111
  1057.     .db %00001000
  1058.     .db %00011111
  1059.     .db %00011101
  1060.     .db %00011111
  1061.     .db %00010001
  1062.     .db %00010100
  1063.     .db %01111011
  1064. S_E_UR:
  1065.     .db %11100000
  1066.     .db %00010000
  1067.     .db %11111000
  1068.     .db %10111000
  1069.     .db %11111000
  1070.     .db %10001000
  1071.     .db %00101000
  1072.     .db %11011110
  1073. S_E_LL:
  1074.     .db %10000111
  1075.     .db %11111111
  1076.     .db %10001000
  1077.     .db %11111111
  1078.     .db %10001000
  1079.     .db %11111111
  1080.     .db %10001000
  1081.     .db %00000000
  1082. S_E_LR:
  1083.     .db %11100001
  1084.     .db %11111111
  1085.     .db %00010001
  1086.     .db %11111111
  1087.     .db %00010001
  1088.     .db %11111111
  1089.     .db %00010001
  1090.     .db %00000000
  1091. S_E_Hand:
  1092.     .db %10001000
  1093.     .db %11011000
  1094.     .db %01110000
  1095.     .db %00000000
  1096.     .db %00000000
  1097.     .db %00000000
  1098.     .db %00000000
  1099.     .db %00000000
  1100.  
  1101. S_Bucket_1:
  1102.     .db %01111111
  1103.     .db %11000000
  1104.     .db %01111111
  1105.     .db %00000000
  1106.     .db %00000000
  1107.     .db %00000000
  1108.     .db %00000000
  1109.     .db %00000000
  1110. S_Bucket_2:
  1111.     .db %11100000
  1112.     .db %00110000
  1113.     .db %11100000
  1114.     .db %00000000
  1115.     .db %00000000
  1116.     .db %00000000
  1117.     .db %00000000
  1118.     .db %00000000
  1119. S_Title_A:
  1120.     .db %11111100
  1121.     .db %10000010
  1122.     .db %10010010
  1123.     .db %10111010
  1124.     .db %10010010
  1125.     .db %10000010
  1126.     .db %10000100
  1127.     .db %10001000
  1128. S_Title_B:        
  1129.     .db %00000010
  1130.     .db %00000100
  1131.     .db %00001111
  1132.     .db %00011101
  1133.     .db %00011110
  1134.     .db %00011111
  1135.     .db %00001111
  1136.     .db %00000000
  1137. S_Title_C:        
  1138.     .db %00000010
  1139.     .db %00000010
  1140.     .db %00000010
  1141.     .db %10000010
  1142.     .db %10000010
  1143.     .db %10000010
  1144.     .db %00000010
  1145.     .db %00000010
  1146. S_Title_D:        
  1147.     .db %10001000
  1148.     .db %10000100
  1149.     .db %10000010
  1150.     .db %10010010
  1151.     .db %10111010
  1152.     .db %10010010
  1153.     .db %10000010
  1154.     .db %11111100
  1155. S_Title_E:        
  1156.     .db %11101110
  1157.     .db %10101010
  1158.     .db %10101010
  1159.     .db %10101010
  1160.     .db %10101010
  1161.     .db %10101010
  1162.     .db %10101010
  1163.     .db %11101110
  1164. S_Title_F:        
  1165.     .db %11011010
  1166.     .db %11011010
  1167.     .db %11111010
  1168.     .db %10101000
  1169.     .db %10101000
  1170.     .db %10001010
  1171.     .db %10001010
  1172.     .db %10001010
  1173.  
  1174. T_Level: .db "Level:",0
  1175.  
  1176. T_Score: .db "Score:",0
  1177.  
  1178. T_BH2:   .db "By:BH2",0
  1179.  
  1180. T_You_Lose: .db "You Lose",0
  1181.  
  1182. T_You_Win: .db "You Win!!",0
  1183.  
  1184. T_Hit_2nd: .db "Hit 2nd!!",0
  1185.  
  1186. T_Game_Over: .db "Game Over",0
  1187.  
  1188. T_Blank: .db " ",0
  1189.  
  1190. T_Boom: .db "B O O M !",0
  1191.  
  1192. T_Me: .db "By: Bruce Herr",0
  1193.  
  1194. T_Press_ALPHA: .db "Press ALPHA",0
  1195.  
  1196. Description: .db "Boom! 1.0 by: Bruce Herr 2",0
  1197.  
  1198. .end
  1199.           
  1200.