home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 82 / asm / source / crash / poke82.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  41.5 KB  |  1,240 lines

  1. ;----------------------------------------------------------------------------
  2. ;|>Poke 1.1, By: Ahmed El-Helw
  3. ;|>Completed for the 82 on 2/28/1998
  4. ;|>You may use parts of this in your programs, as long as you give me and/or
  5. ;|>whoever created the routine credit.
  6. ;|>Note: Not all comments are accurate, due to the port from my 86 version
  7. ;------------------------------------------------------------------------------
  8.  
  9. #INCLUDE "CRASH82.INC"
  10. .DB "Poke 1.1 By: AE ",0
  11.  
  12. string    =    TEXT_MEM
  13.  
  14.  
  15. Initialize:
  16.         ROM_CALL(CLEARLCD)    ;Clear Screen
  17.         
  18. StartGame:
  19.     SET 7,(IY+$14)
  20.     call NewVarInit         ;Sets up variables
  21.         call ScreenSetup        ;Sets up the Screen
  22.     call DispHighScore    ;Displays the High Score
  23.     call DispShip        ;Displays the Ship
  24.         jr GameLoop             ;Goto GameLoop
  25.  
  26. LevelUp:
  27.     ROM_CALL(CLEARLCD)
  28.     call BUFCLR
  29.         ld a,(Level)
  30.         inc a
  31.         ld (Level),a
  32.         call ScreenSetup
  33.         call DispHighScore
  34.     call DispShip
  35.     call DispEnemyII
  36.         ld a,(Level)
  37.         cp 3
  38.         call z,DispEnemyIII
  39.         
  40. ;---------------------------
  41. ;|GetKey Loop and Movement
  42. ;---------------------------
  43.  
  44. GameLoop:
  45.     ld     a,0ffh        ;Reset keyport
  46.         out     (1),a           ;Clear Port
  47.     ld     a,0feh        ;Load desired port
  48.         out     (1),a           ;Clear Keys
  49.         in      a,(1)           ;Input Key
  50.         cp      251             ;If key is right
  51.         jp      z,M_Right       ;Goto Right
  52.         cp      253             ;If key is left
  53.         jp      z,M_Left        ;Goto Left
  54.     ld     a,0ffh        ;Reset keyport
  55.         out     (1),a           ;Clear Port
  56.     ld     a,0bfh        ;Load desired port
  57.         out     (1),a           ;Clear Keys
  58.         in      a,(1)           ;Input Key
  59.         cp      223             ;Is it 2nd
  60.     jp     z,Fire        ;Fire if so
  61.     cp 127            ;Is it Delete?
  62.     call z,Pause        ;Pause!
  63.         cp      191             ;Is it Exit 
  64.         ret z          ;Return if so
  65.  
  66. NoKeyLoop:
  67.     call MoveTarget        ;Move the Target
  68.     call MoveEnemy        ;Move the Enemy
  69.     call CheckEnemyHit    ;See if you hit the enemy
  70.     
  71. CheckDeath:                     ;Checks to see if you are dead
  72.     ld a,(Lives)        ;Lives into A
  73.         or a                    ;Is it 0?
  74.     jp z,EndOfGame        ;Goto End Of Game
  75.  
  76. ContinueNKL:
  77.     call CheckFire        ;Checks the FireBall
  78.         ld a,(Level)
  79.         cp 3
  80.         jr z,GameLoop
  81.         ld a,(Hits)             ;Hits into A
  82.         cp 15                   ;Is it 15?
  83.         jp z,LevelUp
  84.         jr GameLoop             ;Goto GameLoop
  85.  
  86. M_Right:                        ;Move Right
  87.     ld a,(ShipX)        ;Ship X into A
  88.         cp 49                   ;Is it 74 [Line]
  89.     jr z,GameLoop        ;ReLoop, don't move
  90.         cp 50                   ;Is it 75 [Line]
  91.     jr z,GameLoop        ;ReLoop, don't move
  92.     call DispShip        ;Clear Ship
  93.     ld a,(ShipX)        ;Ship X back into A
  94.         inc a                   ;Increment it
  95.         inc a                   ;Increment it
  96.     ld (ShipX),a        ;A back into ShipX
  97.     call DispShip        ;RePut Ship
  98.     call CR_GRBCopy
  99.     jr NoKeyLoop        ;Goto NoKeyLoop
  100.  
  101. M_Left:                ;Move Left
  102.     ld a,(ShipX)        ;Ship X into A
  103.         cp 3                    ;Is it 3 [Line]
  104.     jr z,GameLoop        ;ReLoop, don't move
  105.         cp 4                    ;Is it 4 [Line]
  106.     jr z,GameLoop        ;ReLoop, don't move
  107.     call DispShip        ;Clear Ship
  108.     ld a,(ShipX)        ;Ship X back into A
  109.         dec a                   ;Decrement it
  110.         dec a                   ;Decrement it
  111.     ld (ShipX),a        ;A back into ShipX
  112.     call DispShip        ;RePut Ship
  113.     call CR_GRBCopy
  114.     jr NoKeyLoop        ;Goto NoKeyLoop
  115.  
  116. DispShip:                ;XORs the Ship Sprite on/off the screen
  117.         ld a,(ShipY)                    ;Ship Y into A
  118.         ld e,a                          ;A goes into E, E = Y Coord
  119.         ld a,(ShipX)                    ;Ship X into A
  120.     ld bc,PlayerShip        ;Sprite name into HL
  121.         call PutSprite                  ;XOR it!
  122.     ret                ;Return to call
  123.  
  124. DispTarget:                ;XORs the Target Sprite on/off the screen
  125.         ld a,(TargetY)                  ;Target Y into A
  126.         ld e,a                          ;A into E , E = Y Coord
  127.         ld a,(TargetX)                  ;Target X Coord into A
  128.     ld bc,TargetShip        ;Sprite Name into HL
  129.         call PutSprite                  ;XOR it!
  130.         ret                             ;Return to Call
  131.  
  132. DispEnemy:                      ;XORs the Enemy Sprite on/off the screen
  133.     ld a,(EnemyY)        ;Enemy Y into A
  134.     ld e,a            ;A goes into E, E = Y Coord
  135.     ld a,(EnemyX)        ;Enemy X into A
  136.     ld bc,EnemyShip        ;Sprite name into HL
  137.     call PutSprite        ;XOR it!
  138.         ret                     ;Return to call
  139.  
  140. DispEnemyII:                     ;XORs the Enemy Sprite on/off the screen
  141.         ld a,(Enemy2Y)          ;Enemy Y into A
  142.     ld e,a            ;A goes into E, E = Y Coord
  143.         ld a,(Enemy2X)          ;Enemy X into A
  144.         ld bc,Enemy2Ship        ;Sprite name into HL
  145.     call PutSprite        ;XOR it!
  146.         ret                     ;Return to call
  147.  
  148. DispEnemyIII:                   ;XORs the Enemy Sprite on/off the screen
  149.         ld a,(Enemy3Y)          ;Enemy Y into A
  150.     ld e,a            ;A goes into E, E = Y Coord
  151.         ld a,(Enemy3X)          ;Enemy X into A
  152.         ld bc,Enemy3Ship        ;Sprite name into HL
  153.     call PutSprite        ;XOR it!
  154.         ret                     ;Return to call
  155.  
  156. DispFire:                       ;XORs the Ship Sprite on/off the screen
  157.     ld a,(FireY)        ;Fire Y into A
  158.     ld e,a            ;A goes into E, E = Y Coord
  159.     ld a,(FireX)        ;Fire X into A
  160.     ld bc,FireBall        ;Sprite name into HL
  161.     call PutSprite        ;XOR it!
  162.         ret                     ;Return to call
  163.  
  164.  
  165. Pause:
  166.     call CR_KHAND
  167.     ret
  168.  
  169. ;----------------------
  170. ;|Fire Routine
  171. ;----------------------
  172.  
  173. Fire:
  174.     ld a,(FireZ)        ;Loads FireZ into A
  175.         or a                    ;If it is 0 [No Fire]
  176.     jr z,NewFire        ;Put a new fireball
  177.     jp nz,NoKeyLoop        ;NoKeyLoop otherwise
  178.  
  179. NewFire:                        ;Creates new FireBall
  180.     ld a,1            ;1 into A
  181.     ld (FireZ),a        ;A into FireZ
  182.     ld a,(ShipX)        ;Ship X into A
  183.     ld (FireX),a        ;Loads A into FireX
  184.     ld a,(ShipY)        ;ShipY into A
  185.     ld (FireY),a        ;A into FireY
  186.     call DispFire        ;Display FireBall
  187.     jp NoKeyLoop        ;Goto NoKeyLoop
  188.  
  189. CheckFire:
  190.     call Delay            ;Creates a Short Delay
  191.         ld a,(FireZ)                    ;FireZ into a
  192.     or a                ;If it is 0 [No Fire]
  193.     ret z                ;Return, no need to bother
  194.         ld a,(FireY)                    ;FireY into A
  195.     or a                ;If it is 0
  196.         jr z,CheckHit                   ;Check for Hit
  197.         call DispFire                   ;Clear Fire
  198.         ld a,(FireY)                    ;Fire Y into A again
  199.     dec a                ;Decrease it
  200.         ld (FireY),a                    ;A into FireY
  201.         call DispFire                   ;RePut Fire
  202.     ret                ;Return
  203.  
  204. CheckHit:                               ;Checks if you hit target
  205.     ld a,(FireX)            ;Loads Fire X into A
  206.     add a,8                ;Add 8 to A [End of Sprite]
  207.     ld b,a                ;Loads A into B
  208.     ld a,(TargetX)            ;Loads TargetX into A
  209.         cp b                            ;Compares a to b
  210.     jp c,ContinueCheck        ;Continue Checking if a>b
  211.  
  212. MissHit:
  213.         call DecScore
  214.         call DecScore
  215.         call DecScore
  216.         call DecScore
  217.         call DecScore
  218.     ld hl,34*256+75            ;Load Coords into HL
  219.     ld (CURSOR_X),hl         ;Loads PenCol into HL
  220.     ld hl,BlankStr            ;Blank String into HL
  221.         ROM_CALL(D_ZM_STR)              ;Display it
  222.         ld hl,27*256+75                 ;Set Coords into HL
  223.     ld (CURSOR_X),hl            ;Loads HL into PenCol
  224.     ld hl,(Score)            ;Variable into HL
  225.         call DispHL                     ;Display HL
  226.         call ResetFire                  ;Reset the Fire Otherwise
  227.         ret                             ;Return from Call
  228.     
  229. DecScore:
  230.         ld       de,(Score)
  231.         ld       a,d
  232.         or       e
  233.         ret      z
  234.         dec      de
  235.         ld       (Score),de
  236.         ret
  237.  
  238. ContinueCheck:
  239.     ld a,(TargetX)            ;Target X into A
  240.     add a,8                ;Add 8 to A [End of Sprite]
  241.     ld b,a                ;Loads A into B
  242.     ld a,(FireX)            ;Fire X into A
  243.         cp b                            ;Compare A to B
  244.     jp c,HitTarget            ;If b>a then you hit it
  245.     jp MissHit
  246.         ret                             ;Return to Call
  247.  
  248. HitTarget:
  249.     call ResetFire            ;Reset the Fire
  250.     ld hl,(Score)            ;Load Score into HL
  251.         ld bc,25                        ;Loads 25 into bc
  252.         add hl,bc                       ;Adds BC and HL
  253.     ld (Score),hl            ;Load HL back into Score
  254.     ld hl,34*256+75            ;Load Coords into HL
  255.     ld (CURSOR_X),hl             ;Loads PenCol into HL
  256.     ld hl,BlankStr            ;Blank String into HL
  257.         ROM_CALL(D_ZM_STR)              ;Display it
  258.         ld hl,27*256+75                 ;Set Coords into HL
  259.     ld (CURSOR_X),hl        ;Loads HL into PenCol
  260.     ld hl,(Score)            ;Variable into HL
  261.         call DispHL                     ;Display HL
  262.         ld a,(Hits)
  263.         inc a
  264.         ld (Hits),a
  265.         ret                             ;Return from Call
  266.  
  267. ResetFire:                              ;Reset the Fire
  268.     call DispFire            ;Clears the Fire
  269.     call CR_GRBCopy
  270.         xor a                           ;Loads 0 into A
  271.     ld (FireZ),a            ;Reset FireZ
  272.     ld (FireX),a            ;Reset FireX
  273.     ld (FireY),a            ;Reset FireY
  274.         ret                             ;Return from Call
  275.  
  276. CheckEnemyHit:
  277.         call Delay                      ;Creates a Short Delay
  278.     ld a,(FireZ)            ;FireZ into a
  279.         or a                            ;If it is 0 [No Fire]
  280.         ret z                           ;Return, no need to bother
  281.     ld a,(FireY)            ;FireY into A
  282.         cp 30                           ;Is it 30?
  283.         jr z,CheckEHit                  ;Check for Hit
  284.         ld a,(Level)                    ;Level # into A
  285.         cp 1                            ;Is it 1?
  286.         jp nz,CheckE2Hit                ;Check Enemy II Hit Otherwise
  287.         jp DecFire
  288.                                         ;Return
  289.  
  290. CheckEHit:                              ;Checks if you hit target
  291.     ld a,(FireX)            ;Loads Fire X into A
  292.     add a,8                ;Add 8 to A [End of Sprite]
  293.     ld b,a                ;Loads A into B
  294.     ld a,(EnemyX)            ;Loads EnemyX into A
  295.         cp b                            ;Compares a to b
  296.     jp c,ContinueECheck        ;Continue Checking if a>b
  297.         ret                             ;Return from Call Otherwise
  298.  
  299. ContinueECheck:
  300.     ld a,(EnemyX)            ;Enemy X into A
  301.     add a,8                ;Add 8 to A [End of Sprite]
  302.     ld b,a                ;Loads A into B
  303.     ld a,(FireX)            ;Fire X into A
  304.         cp b                            ;Compare A to B
  305.     jp c,HitEnemy            ;If b>a then you hit it
  306.         ret                             ;Return to Call Otherwise
  307.  
  308. CheckE2Hit:                             ;Checks if you hit target 2
  309.         ld a,(Level)
  310.         cp 1
  311.         jp z,DecFire
  312.     ld a,(FireX)            ;Loads Fire X into A
  313.     add a,8                ;Add 8 to A [End of Sprite]
  314.     ld b,a                ;Loads A into B
  315.         ld a,(Enemy2X)                  ;Loads Enemy2X into A
  316.         cp b                            ;Compares a to b
  317.         jp c,ContinueE2Check            ;Continue Checking if a>b
  318.         jp CheckE3Hit
  319.  
  320. DecFire:
  321.         call DispFire
  322.         ld a,(FireY)
  323.         dec a
  324.         ld (FireY),a
  325.         call DispFire
  326.     call CR_GRBCopy
  327.         ret
  328.  
  329. ContinueE2Check:
  330.         ld a,(Enemy2X)                  ;Enemy 2X into A
  331.     add a,8                ;Add 8 to A [End of Sprite]
  332.     ld b,a                ;Loads A into B
  333.     ld a,(FireX)            ;Fire X into A
  334.         cp b                            ;Compare A to B
  335.         jp c,CheckE2Y                   ;If b>a then you hit it
  336.         jp CheckE3Hit
  337.  
  338. CheckE2Y:
  339.         ld a,(FireY)                    ;Loads FireY into A
  340.     add a,4                ;Add 8 to A [End of Sprite]
  341.     ld b,a                ;Loads A into B
  342.         ld a,(Enemy2Y)                  ;Loads Enemy Y into A
  343.         cp b                            ;Compares a to b
  344.         jp c,ContinueCheck2Y            ;Continue Checking if a>b
  345.         jp CheckE3Hit                   ;Missed Otherwise
  346.        
  347. ContinueCheck2Y:
  348.         ld a,(Enemy2Y)                  ;Enemy Y into A
  349.     add a,4                ;Add 8 to A [End of Sprite]
  350.     ld b,a                ;Loads A into B
  351.         ld a,(FireY)                    ;Fire Y into A
  352.         cp b                            ;Compare A to B
  353.         jp c,HitEnemy2                  ;If b>a then hit
  354.         jp CheckE3Hit                   ;You missed otherwise
  355.  
  356. CheckE3Hit:                             ;Checks if you hit target 3
  357.         ld a,(Level)
  358.         cp 3
  359.         jp nz,DecFire
  360.     ld a,(FireX)            ;Loads Fire X into A
  361.     add a,8                ;Add 8 to A [End of Sprite]
  362.     ld b,a                ;Loads A into B
  363.         ld a,(Enemy3X)                  ;Loads Enemy3X into A
  364.         cp b                            ;Compares a to b
  365.         jp c,ContinueE3Check            ;Continue Checking if a>b
  366.         jp DecFire
  367.  
  368. ContinueE3Check:
  369.         ld a,(Enemy3X)                  ;Enemy 3X into A
  370.     add a,8                ;Add 8 to A [End of Sprite]
  371.     ld b,a                ;Loads A into B
  372.     ld a,(FireX)            ;Fire X into A
  373.         cp b                            ;Compare A to B
  374.         jp c,CheckE3Y                   ;If b>a then you hit it
  375.         jp DecFire                      ;Decrease Fire and Return otherwise
  376.  
  377. CheckE3Y:
  378.         ld a,(FireY)                    ;Loads FireY into A
  379.     add a,4                ;Add 8 to A [End of Sprite]
  380.     ld b,a                ;Loads A into B
  381.         ld a,(Enemy3Y)                  ;Loads Enemy Y into A
  382.         cp b                            ;Compares a to b
  383.         jp c,ContinueCheck3Y            ;Continue Checking if a>b
  384.         jp DecFire                      ;Missed Otherwise
  385.        
  386. ContinueCheck3Y:
  387.         ld a,(Enemy3Y)                  ;Enemy Y into A
  388.     add a,4                ;Add 8 to A [End of Sprite]
  389.     ld b,a                ;Loads A into B
  390.         ld a,(FireY)                    ;Fire Y into A
  391.         cp b                            ;Compare A to B
  392.         jp c,HitEnemy3                  ;If b>a then hit
  393.         jp DecFire                      ;You missed otherwise
  394.  
  395.  
  396. HitEnemy:
  397.         call Delay                      ;Creates a short delay
  398.     call DispFire            ;Views the Fire
  399.     ld a,(FireY)            ;Loads Y into A
  400.         inc a                           ;Increases It
  401.     ld (FireY),a            ;Back into A
  402.     call DispFire            ;Redisplays
  403.     call CR_GRBCopy
  404.     ld a,(FireY)            ;Loads Y into A
  405.         cp 54                           ;Is it 54?
  406.     jp nz,HitEnemy            ;If not, reloop
  407.     jr CheckYouHit            ;Check if you are hit
  408.  
  409. CheckYouHit:                            ;Checks if you die
  410.     ld a,(FireX)            ;Loads Fire X into A
  411.         add a,6                         ;Add 8 to A [End of Sprite]
  412.     ld b,a                ;Loads A into B
  413.     ld a,(ShipX)            ;Loads ShipX into A
  414.         cp b                            ;Compares a to b
  415.     jp c,ContinueUCheck        ;Continue Checking if a>b
  416.     call ResetFire            ;Reset Fire
  417.         ret                             ;Return from Call Otherwise
  418.  
  419. ContinueUCheck:
  420.     ld a,(EnemyX)            ;Enemy X into A
  421.         add a,6                         ;Add 6 to A [End of Sprite]
  422.     ld b,a                ;Loads A into B
  423.     ld a,(ShipX)            ;Fire X into A
  424.         cp b                            ;Compare A to B
  425.         jp c,HitYou                     ;If b>a then you hit it
  426.     call ResetFire            ;ResetFire
  427.         ret                             ;Return to Call Otherwise
  428.  
  429. HitEnemy2:
  430.         call Delay                      ;Creates a short delay
  431.     call DispFire            ;Views the Fire
  432.     ld a,(FireY)            ;Loads Y into A
  433.         inc a                           ;Increases It
  434.     ld (FireY),a            ;Back into A
  435.     call DispFire            ;Redisplays
  436.     call CR_GRBCopy
  437.     ld a,(FireY)            ;Loads Y into A
  438.         cp 54                           ;Is it 54?
  439.         jp nz,HitEnemy2                 ;If not, reloop
  440.         jr CheckYou2Hit                 ;Check if you are hit
  441.  
  442. CheckYou2Hit:                           ;Checks if you die
  443.     ld a,(FireX)            ;Loads Fire X into A
  444.         add a,6                         ;Add 6 to A [End of Sprite]
  445.     ld b,a                ;Loads A into B
  446.     ld a,(ShipX)            ;Loads ShipX into A
  447.         cp b                            ;Compares a to b
  448.         jp c,ContinueU2Check            ;Continue Checking if a>b
  449.     call ResetFire            ;Reset Fire
  450.         ret                             ;Return from Call Otherwise
  451.  
  452. ContinueU2Check:
  453.         ld a,(Enemy2X)                   ;Enemy X into A
  454.         add a,6                         ;Add 8 to A [End of Sprite]
  455.     ld b,a                ;Loads A into B
  456.     ld a,(ShipX)            ;Fire X into A
  457.         cp b                            ;Compare A to B
  458.         jp c,HitYou                     ;If b>a then you hit it
  459.     call ResetFire            ;ResetFire
  460.         ret                             ;Return to Call Otherwise
  461.  
  462. HitYou:
  463.         call DecScore
  464.         call DecScore
  465.         call DecScore
  466.         call DecScore
  467.         call DecScore
  468.         call DecScore
  469.         call DecScore
  470.         call DecScore
  471.         call DecScore
  472.         call DecScore
  473.         call DecScore
  474.     call ResetFire
  475.     ld a,(Lives)            ;Load lives into A
  476.         dec a                           ;decrease A
  477.     ld (Lives),a            ;Load a back
  478.         ld hl,20*256+75                 ;Set Coords into HL
  479.     ld (CURSOR_X),hl            ;Loads HL into PenCol
  480.     ld hl,BlankStr            ;BlankStr into HL
  481.         ROM_CALL(D_ZM_STR)              ;Display it!
  482.         ld hl,20*256+75                 ;Set Coords into HL
  483.     ld (CURSOR_X),hl         ;Loads HL into PenCol
  484.     ld a,(Lives)            ;Variable into A
  485.         call DispA                      ;Display A
  486.     ld hl,34*256+75            ;Load Coords into HL
  487.     ld (CURSOR_X),hl         ;Loads PenCol into HL
  488.     ld hl,BlankStr                ;Blank String into HL
  489.         ROM_CALL(D_ZM_STR)              ;Display it
  490.         ld hl,27*256+75                 ;Set Coords into HL
  491.     ld (CURSOR_X),hl        ;Loads HL into PenCol
  492.     ld hl,(Score)            ;Variable into HL
  493.         call DispHL                     ;Display HL
  494.         ret                             ;Return!
  495.  
  496. HitEnemy3:
  497.         call Delay                      ;Creates a short delay
  498.     call DispFire            ;Views the Fire
  499.     ld a,(FireY)            ;Loads Y into A
  500.         inc a                           ;Increases It
  501.     ld (FireY),a            ;Back into A
  502.     call DispFire            ;Redisplays
  503.     call CR_GRBCopy
  504.     ld a,(FireY)            ;Loads Y into A
  505.         cp 54                           ;Is it 54?
  506.         jp nz,HitEnemy3                 ;If not, reloop
  507.         jp CheckYou2Hit                 ;Check if you are hit
  508.  
  509. CheckYou3Hit:                           ;Checks if you die
  510.     ld a,(FireX)            ;Loads Fire X into A
  511.         add a,6                         ;Add 6 to A [End of Sprite]
  512.     ld b,a                ;Loads A into B
  513.     ld a,(ShipX)            ;Loads ShipX into A
  514.         cp b                            ;Compares a to b
  515.         jp c,ContinueU3Check            ;Continue Checking if a>b
  516.     call ResetFire            ;Reset Fire
  517.         ret                             ;Return from Call Otherwise
  518.  
  519. ContinueU3Check:
  520.         ld a,(Enemy3X)                  ;Enemy X into A
  521.         add a,6                         ;Add 8 to A [End of Sprite]
  522.     ld b,a                ;Loads A into B
  523.     ld a,(ShipX)            ;Fire X into A
  524.         cp b                            ;Compare A to B
  525.         jp c,HitYou                     ;If b>a then you hit it
  526.     call ResetFire            ;ResetFire
  527.         ret                             ;Return to Call Otherwise
  528.  
  529. ;--------------------------------
  530. ;|Target Routine, to Move Target
  531. ;--------------------------------
  532.  
  533. MoveTarget:
  534.     call DispTarget            ;XOR the Target Ship on the Screen
  535.     ld a,(TargetD)            ;Target Direction into A
  536.         or a                            ;Is it 0
  537.     jr z,M_T_Right            ;Move Target Right
  538.     jr nz,M_T_Left            ;Otherwise Move Left
  539.  
  540. M_T_Right:
  541.     ld a,(TargetX)            ;Target X into A
  542.         cp 49                           ;Is it 75
  543.         jr z,ResetTargetMove            ;Reset Target to Move Other Direction
  544.         cp 50                           ;Is it 74
  545.     jr z,ResetTargetMove        ;Reset Target to Move Other Direction
  546.         inc a                           ;Increase it again
  547.     ld (TargetX),a            ;Into TargetX
  548.     call DispTarget            ;Replace Target on Screen
  549.     call CR_GRBCopy
  550.         ret                             ;Return
  551.  
  552. M_T_Left:
  553.     ld a,(TargetX)            ;Target X into A
  554.         cp 3                            ;Is it 3
  555.     jr z,ResetTargetMove        ;Reset Target to Move Other Direction
  556.         cp 4                            ;Is it 4
  557.     jr z,ResetTargetMove        ;Reset Target to Move Other Direction
  558.         dec a                           ;Decrease it
  559.     ld (TargetX),a            ;Into TargetX
  560.     call DispTarget            ;Replace Target on Screen
  561.     call CR_GRBCopy
  562.         ret                             ;Return
  563.  
  564. ResetTargetMove:
  565.     ld a,(TargetD)            ;Load Target Direction into A
  566.         or a                            ;Is it 0?
  567.     jr z,ResetLeft            ;Reset it to go left!
  568.         xor a                           ;Loads 0 into a
  569.     ld (TargetD),a            ;Loads A into Direction 
  570.     jr M_T_Right            ;Move Right
  571.  
  572. ResetLeft:
  573.     ld a,1                ;Load 1 into A
  574.     ld (TargetD),a            ;Loads A into Target Direction
  575.         jr M_T_Left                     ;Move Left
  576.  
  577. ;--------------------------------
  578. ;|Enemy Routine, to Move Enemy
  579. ;--------------------------------
  580.  
  581. MoveEnemy:
  582.         ld a,(Level)
  583.         cp 1
  584.         jp z,Level1Enemy
  585.         cp 2
  586.         jp z,Level2Enemy
  587.         jp nz,Level3Enemy
  588.  
  589. Level3Enemy:
  590.         call Level1Enemy
  591.         call Level2Enemy
  592.         call DispEnemyIII
  593.         ld a,(Enemy3D)
  594.         or a
  595.         jp nz,M_E_DownLeft
  596.  
  597. M_E_UpRight:
  598.         ld a,(Enemy3Y)                  ;Y Coordinate into A
  599.         cp 12                           ;Is it 12?
  600.         jp z,Reset_E3_Dir               ;Change the Direction if so
  601.         ld a,(Enemy3Y)                  ;Y Coord into A
  602.         dec a                           ;Decrease it [Going Up]
  603.         ld (Enemy3Y),a                  ;A into Enemy 2 Y
  604.         ld a,(Enemy3X)                  ;Load Enemy 2 X into A
  605.         inc a                           ;Increment it
  606.         ld (Enemy3X),a                  ;Loads A into Enemy2X
  607.         call DispEnemyIII               ;Display Enemy III
  608.     call CR_GRBCopy
  609.         ret                             ;Return
  610.  
  611. Level2Enemy:
  612.         call Level1Enemy                ;Call Level1 Enemy, so it will move
  613.         call DispEnemyII                ;XOR Enemy II
  614.         ld a,(Enemy2D)
  615.         or a                            ;Is it 0?
  616.         jp nz,M_E_DownRight             ;No?? Then move down/right
  617.  
  618. M_E_UpLeft:
  619.         ld a,(Enemy2Y)                  ;Y Coordinate into A
  620.         cp 12                           ;Is it 12?
  621.         jp z,Reset_E2_Dir               ;Change the Direction if so
  622.         ld a,(Enemy2Y)                  ;Y Coord into A
  623.         dec a                           ;Decrease it [Going Up]
  624.         ld (Enemy2Y),a                  ;A into Enemy 2 Y
  625.         ld a,(Enemy2X)                  ;Load Enemy 2 X into A
  626.         dec a                           ;Decrement it
  627.         ld (Enemy2X),a                  ;Loads A into Enemy2X
  628.         call DispEnemyII                ;Display Enemy II
  629.     call CR_GRBCopy
  630.         ret                             ;Return
  631.  
  632. M_E_DownLeft:
  633.         ld a,(Enemy3Y)                  ;Y Coordinate into A
  634.         cp 40                           ;Is it 46?
  635.         jp z,Reset_E3_Dir               ;Change the Direction if so
  636.         ld a,(Enemy3Y)                  ;Y Coord into A
  637.         inc a                           ;Increase it [Going Down]
  638.         ld (Enemy3Y),a                  ;A into Enemy 2 Y
  639.         ld a,(Enemy3X)                  ;Load Enemy 2 X into A
  640.         dec a                           ;Increment it
  641.         ld (Enemy3X),a                  ;Loads A into Enemy2X
  642.         call DispEnemyIII               ;Display Enemy III
  643.     call CR_GRBCopy
  644.         ret                             ;Return
  645.  
  646.  
  647. M_E_DownRight:
  648.         ld a,(Enemy2Y)                  ;Y Coordinate into A
  649.         cp 46                           ;Is it 46?
  650.         jp z,Reset_E2_Dir               ;Change the Direction if so
  651.         ld a,(Enemy2Y)                  ;Y Coord into A
  652.         inc a                           ;Increase it [Going Down]
  653.         ld (Enemy2Y),a                  ;A into Enemy 2 Y
  654.         ld a,(Enemy2X)                  ;Load Enemy 2 X into A
  655.         inc a                           ;Increment it
  656.         ld (Enemy2X),a                  ;Loads A into Enemy2X
  657.         call DispEnemyII                ;Display Enemy II
  658.     call CR_GRBCopy
  659.         ret                             ;Return
  660.  
  661. Level1Enemy:
  662.     call DispEnemy            ;XOR the Enemy Ship on the Screen
  663.     ld a,(EnemyD)            ;Enemy Direction into A
  664.         or a                            ;Is it 0
  665.     jr z,M_E_Right            ;Move Target Right
  666.     jr nz,M_E_Left            ;Otherwise Move Left
  667.  
  668. M_E_Right:
  669.     ld a,(EnemyX)            ;Enemy X into A
  670.         cp 49                           ;Is it 75
  671.     jr z,ResetEnemyMove        ;Reset Target to Move Other Direction
  672.         cp 50                           ;Is it 74
  673.     jr z,ResetEnemyMove        ;Reset Target to Move Other Direction
  674.         inc a                           ;Increase it again
  675.         inc a                           ;Increase it again
  676.     ld (EnemyX),a            ;Into EnemyX
  677.     call DispEnemy            ;Replace Enemy on Screen
  678.     call CR_GRBCopy
  679.         ret                             ;Return
  680.  
  681. M_E_Left:
  682.     ld a,(EnemyX)            ;Enemy X into A
  683.         cp 3                            ;Is it 3
  684.     jr z,ResetEnemyMove        ;Reset Enemy to Move Other Direction
  685.         cp 4                            ;Is it 4
  686.         jr z,ResetEnemyMove             ;Reset Enemy to Move Other Direction
  687.         dec a                           ;Decrease it
  688.         dec a                           ;Decrease it again
  689.     ld (EnemyX),a            ;Into EnemyX
  690.     call DispEnemy            ;Replace Enemy on Screen
  691.     call CR_GRBCopy
  692.         ret                             ;Return
  693.  
  694. ResetEnemyMove:
  695.     ld a,(EnemyD)            ;Load Enemy Direction into A
  696.         or a                            ;Is it 0?
  697.     jr z,ResetELeft            ;Reset it to go left!
  698.         xor a                           ;Loads 0 into a
  699.     ld (EnemyD),a            ;Loads A into Direction 
  700.     jr M_E_Right            ;Move Right
  701.  
  702. ResetELeft:
  703.     ld a,1                ;Load 1 into A
  704.     ld (EnemyD),a            ;Loads A into Target Direction
  705.         jr M_E_Left                     ;Move Left
  706.  
  707. Reset_E2_Dir:
  708.         ld a,(Enemy2D)                  ;Load Direction into a
  709.         inc a                           ;Increase it
  710.         cp 2                            ;If it is 2
  711.         jp z,Make_E2Dir_UL              ;that means it was 1, d/r.. so switch
  712.         ld a,1                          ;Otherwise, it was u/l, so switch
  713.         ld (Enemy2D),a                  ;Load 1 into Direction
  714.         jp M_E_DownRight               ;Goto DownRight Movement
  715.  
  716. Make_E2Dir_UL:
  717.         xor a                            ;Make a be = to 0
  718.         ld (Enemy2D),a                 ;Make that the direction
  719.         jp M_E_UpLeft                   ;Move Up/Left
  720.  
  721. Reset_E3_Dir:
  722.         ld a,(Enemy3D)                  ;Load Direction into a
  723.         inc a                           ;Increase it
  724.         cp 2                            ;If it is 2
  725.         jp z,Make_E3Dir_UR              ;that means it was 1, d/l.. so switch
  726.         ld a,1                          ;Otherwise, it was u/r, so switch
  727.         ld (Enemy3D),a                  ;Load 1 into Direction
  728.         jp M_E_DownLeft                 ;Goto DownLeft Movement
  729.  
  730. Make_E3Dir_UR:
  731.         xor a                          ;Make a be = to 0
  732.         ld (Enemy3D),a                 ;Make that the direction
  733.         jp M_E_UpRight                 ;Move Up/Right
  734.  
  735. ;----------------------
  736. ;|End of Game Routines
  737. ;----------------------
  738. EndOfGame:
  739.   ROM_CALL(CLEARLCD)                          ;Returns from Prog
  740.   RES 7,(IY+$14)
  741.  
  742. finish:  
  743.          ld hl,(Score)            ;final score
  744.      ld de,(HighScore)        ;load high score
  745.       call CP_HL_DE            ;compare score w/ hi score
  746.       jp nc,hisco            ;if score is more
  747.                           ;or equal 
  748.        ret
  749.  
  750. ; Input routine  - made by Jimmy Mσrdell 97-03-05
  751. ; Reads a sentence entered from the keyboard. Only uppercase letters
  752. ; and space are allowed. Left arrowkey = backspace.
  753. ;
  754. ; When calling, HL should point to where the string should be stored
  755. ; and A should hold the maximum length of the string. Be sure there
  756. ; are enough space (A+1) to store the nullterminated string at HL!
  757. ; ($800C) should hold the screen position where the string starts.
  758. ;
  759. ; This input routine will also have a flashing cursor. If you don't like
  760. ; it, remove all rows where the explanation starts with a *.
  761. ;
  762. ; IMPORTANT: The input must NOT wrap to a new row! Then it will not work
  763. ; properly. The last char on a row should not be used either (if cursorcol=0
  764. ; when calling, the maximum char length is 20). If you have a cursor, the
  765. ; two last chars should not be used (max length 19 if the screen location
  766. ; starts to the far left).
  767. ;
  768. ; The routine requires one temporary variable, noLet.
  769.  
  770. ; largely indented stuff added by Adamman
  771.  
  772. hisco:
  773.     ROM_CALL(CLEARLCD)
  774.     ld hl,(Score)
  775.     ld (HighScore),hl
  776.     ld hl,0
  777.     ld (CURSOR_X),hl
  778.     ld hl,HiScr
  779.     ROM_CALL(D_ZM_STR)
  780.     ld hl,0*256+79
  781.     ld (CURSOR_X),hl    
  782.     ld hl,(Score)
  783.     call DispHL
  784.     ld de, $0504            ;initials entered at 5,4
  785.      ld ($800C), de            ;load location
  786.     ld hl,htext+12             ;hl points to initials
  787.         ld a,3                ;max chars = 3
  788.     call INPUT
  789.     ret
  790.  
  791. INPUT:
  792. ; push bc
  793. ; push de
  794. ; push hl
  795. ; ei
  796. ; set 2,(iy+12)         ; * Turn cursor blinking on (interrupts must be enabled)
  797.  ld (noLet),a          ; Store the maximum lenght of the string
  798.  ld e,0                ; E = numbers of letters written so far
  799. WaK:
  800. ; ld a,32
  801. ; ld ($800E),a          ; * Set "character under cursor" to space
  802.  push hl               ; Save HL since GET_KEY destroys it's content
  803.     ld a, 217
  804.     ROM_CALL(TX_CHARPUT)
  805.     ld hl, $800D
  806.     dec (hl)
  807.  call GET_KEY          ;get key press
  808.  cp G_MODE
  809.  jr z,exit_last
  810.  cp $02                ; $02 = left key
  811.  jr z,BackSpace
  812.  cp $09                ; $09 = enter
  813.  jr z,NameDone         ;if enter then your done
  814.  or a
  815.  jr nz,CheckLetter
  816.  pop hl
  817.  jr WaK
  818. CheckLetter:
  819.  ld hl,Letters
  820.  ld bc,26              ; 26 letters to check
  821.  cpir                  ; Compare A with each letter until a match is found
  822.  ld d,c                ; Then C = the letter. Store in D
  823.  pop hl                ; HL -> current position in string
  824.  jr nz,WaK             ; If not valid keystroke, wait for new key
  825.  ld a,65               ; 65 = ascii char for A
  826.  add a,d               ; A now holds the ascii char for the letter pressed
  827. PutLetter:
  828.  ld c,a
  829.  ld a,(noLet)          ; A = max letters
  830.  cp e                  ; Check if max size is reached
  831.  jr z,WaK              ; If so, wait for a new key
  832.  ld (hl),c             ; If not, store the key entered
  833.  inc hl                ; Point to the next byte in the string
  834.  inc e                 ; And increase the letter counter
  835.  ld a,c
  836.  ROM_CALL(TX_CHARPUT)  ; Show the chars pressed on the screen
  837.  jr WaK                ; And jump back and wait for a new key
  838. BackSpace:
  839.  pop hl                ; HL -> current position in string
  840.  ld a,e
  841.  or a                  ; Check if string size = 0
  842.  jr z,WaK              ; If so, backspace is impossible. Check for new key.
  843. ;res 2,(iy+12)         ; * Stopp cursor blinking
  844.  dec e                 ; Decrease string size
  845.  dec hl                ; And string pointer
  846.  push hl               ;temporary storage of hl
  847.  ld hl,$800D           ; HL -> x cursor position
  848.  dec (hl)              ; Decrease it
  849.  ld a,32               ; Overwrite the last letter with a space
  850.  ROM_CALL(TX_CHARPUT)  ; Put the space over the chars
  851.  ROM_CALL(TX_CHARPUT)  ; * And over the (non) blinking cursor
  852.  dec (hl)              ; * Decrease the x coordinate twice
  853.  dec (hl)              ;decrease hl by 1
  854.  pop hl                ;recall hl
  855. ;set 2,(iy+12)         ; * Stopp cursor blinking
  856.  jr WaK                ; Wait for a key
  857. NameDone:
  858.  pop hl                ; HL -> current position in string
  859.  ld (hl),0             ; Put a terminating zero at the end of the string
  860. ; res 2,(iy+12)         ; * Stopp cursor blinking
  861. ; pop hl
  862. ; pop de
  863. ; pop bc
  864.  ret
  865. exit_last:
  866.     pop hl
  867.     pop hl
  868.     ret
  869.  
  870. ; The keycodes of the letters A-Z stored backways
  871.  
  872. Letters:
  873.  .db $1A,$22,$2A         ;ZYX
  874.  .db $0B,$13,$1B,$23,$2B ;WVUTS
  875.  .db $0C,$14,$1C,$24,$2C ;RQPON
  876.  .db $0D,$15,$1D,$25,$2D ;MLKJI
  877.  .db $0E,$16,$1E,$26,$2E ;HGFED
  878.  .db $1F,$27,$2F         ;CBA
  879.  
  880. HighScore:
  881. .db $00, $00
  882.  
  883.  
  884. ;----------------------
  885. ;|Screen Setups
  886. ;----------------------
  887.  
  888. ScreenSetup:
  889.     ld hl,2*256+65            ;Setting Col = 90, Row = 2
  890.     ld (CURSOR_X),hl        ;Putting that into PenCol
  891.     ld hl,PokeStr            ;Loading string into HL 
  892.         ROM_CALL(D_ZM_STR)              ;Display it! Small text, "Poke v 1.0"
  893.     ld hl,9*256+68            ;Sets Coords into HL
  894.     ld (CURSOR_X),hl        ;Sets it into PenCol
  895.     ld hl,ByMeStr            ;String name into HL
  896.         ROM_CALL(D_ZM_STR)              ;Display, small size font [By: AE]
  897.     ld hl,20*256+60            ;Sets Coords agian
  898.     ld (CURSOR_X),hl        ;Into PenCol
  899.     ld hl,LiveStr            ;String name into HL
  900.         ROM_CALL(D_ZM_STR)              ;Display it! [Lvs:]
  901.     ld hl,27*256+60            ;Sets Coords again
  902.     ld (CURSOR_X),hl        ;Load HL into PenCol
  903.     ld hl,ScorStr            ;Load string name into HL
  904.         ROM_CALL(D_ZM_STR)              ;Display it! [Scr:]
  905.         ;---------------------Variable Setup---------------------
  906.     ld a,54                ;54 into A
  907.     ld (ShipY),a            ;A into Ship's Y Coord
  908.     ld a,30                ;Loads 30 into A
  909.     ld (EnemyY),a            ;Loads A into EnemyY
  910.         xor a                           ;Loads 0 into A
  911.     ld (TargetD),a            ;Loads A into Target Direction
  912.     ld (EnemyD),a            ;Loads A into Enemy Direction
  913.         ld (Enemy2D),a                  ;Loads A into Enemy 2 Direction
  914.         ld (Enemy3D),a                  ;Loads A into Enemy 3 Direction
  915.         ld (Hits),a                     ;Number of hits = 0
  916.         ld a,40                         ;Loads 40 into A
  917.         ld (Enemy2Y),a                  ;Loads A into Enemy2Y
  918.         ld (Enemy3Y),a                  ;Loads A into Enemy3Y
  919.         ld a,65                         ;Loads 65 into A
  920.         ld (Enemy2X),a                  ;A into Enemy2X
  921.         ld a,12
  922.         ld (Enemy3X),a
  923.     ld a,2                ;Loads 2 into A
  924.     ld (TargetY),a            ;Loads A into Target Y
  925.     ld a,43                ;43 into A
  926.     ld (EnemyX),a            ;A into EnemyX
  927.     ld (ShipX),a            ;A into ShipX
  928.     ld (TargetX),a            ;A into TargetX
  929.         ;-----------------Finish Initializing----------------
  930.         ld hl,27*256+75                 ;Set Coords into HL
  931.     ld (CURSOR_X),hl        ;Loads HL into PenCol
  932.     ld hl,(Score)            ;Variable into HL
  933.         call DispHL                     ;Display HL
  934.         ld hl,20*256+75                 ;Set Coords into HL
  935.     ld (CURSOR_X),hl        ;Loads HL into PenCol
  936.     ld a,(Lives)            ;Variable into A
  937.         call DispA                      ;Display A
  938.     call DispTarget            ;Display Target
  939.     call DispEnemy            ;Display Enemy
  940.         ret                             ;Return
  941.  
  942. NewVarInit:
  943.         ld a,5                ;Loads 5 into A
  944.     ld (Lives),a            ;Loads A into Lives
  945.         ld a,1
  946.         ld (Level),a
  947.     ld hl,0                ;Load 0 into HL
  948.     ld (Score),hl            ;Load HL into Score
  949.         ret
  950.  
  951. ;----------------------
  952. ;|High Score Stuff
  953. ;----------------------
  954.  
  955. DispHighScore:              
  956.     ld hl,41*256+60         ;Loads Coords for text
  957.     ld (CURSOR_X),hl         ;Into PenCol
  958.     ld hl,HighStr            ;High Score is our wanted Variable
  959.     ROM_CALL(D_ZM_STR)
  960.     ld hl,55*256+60         ;Loads Coords for text
  961.     ld (CURSOR_X),hl         ;Into PenCol
  962.     ld hl,htext+12          ;High Score is our wanted Variable
  963.     ROM_CALL(D_ZM_STR)
  964.     ld hl,48*256+60         ;Loads Coords for text
  965.     ld (CURSOR_X),hl         ;Into PenCol
  966.     ld hl,(HighScore)
  967.     jr DispHL
  968.     
  969. ;------------------------------
  970. ;|Misc. Routines
  971. ;------------------------------
  972.  
  973. DispA:
  974.        ld h,0
  975.       ld l,a
  976. DispHL:
  977.         push de
  978.         push hl
  979.         ld de,string+5
  980.         xor a
  981.         ld (de),a
  982. Repeat:
  983.         call UNPACK_HL
  984.         add a,'0'
  985.         dec de
  986.         ld (de),a
  987.         ld a,h
  988.         or l
  989.         jr nz,Repeat
  990.         ex de,hl
  991.         ROM_CALL(D_ZM_STR)
  992.         pop hl
  993.         pop de
  994.         ret
  995.  
  996.  
  997. BUFCLR:
  998.         ld hl,$88B8
  999.         ld de,$88B9
  1000.         ld bc,$2FF
  1001.         ld (hl),0
  1002.         ldir
  1003.         ret
  1004.  
  1005. Delay:                    ;Delay Loop, converted from Dan Eble's 85 Bounce
  1006.     PUSH AF                ;hide current AF value
  1007.     PUSH BC                ;hide current BC value 
  1008.         LD BC,$1000                     ;dlay length->bc
  1009. delayLoop:
  1010.     DEC BC                ;bc-1->bc
  1011.     LD A, B                ;Loads b into a
  1012.         OR C                            ;Checks if c=0
  1013.         JR NZ, delayLoop                ;if not, continue loop 
  1014.     POP BC                ;unhide current BC value
  1015.     POP AF                ;unhide current AF value 
  1016.         ret                             ;Return to Call
  1017.  
  1018.  
  1019. ;-----------------------------
  1020. ;|Sprites
  1021. ;-----------------------------
  1022.  
  1023. PlayerShip:
  1024.     .db %00000000
  1025.     .db %00000000
  1026.     .db %00000000
  1027.     .db %00000000
  1028.     .db %11111111
  1029.     .db %11010101
  1030.     .db %10101011
  1031.     .db %11111111
  1032.  
  1033. EnemyShip:
  1034.     .db %00000000
  1035.     .db %00000000
  1036.     .db %00000000
  1037.     .db %11111111
  1038.     .db %11111111
  1039.     .db %00000000
  1040.     .db %00000000
  1041.     .db %00000000
  1042.  
  1043. Enemy2Ship:
  1044.         .db %00000000
  1045.         .db %00000000
  1046.         .db %00000000
  1047.         .db %10101010
  1048.         .db %11111111
  1049.         .db %01010101
  1050.         .db %00000000
  1051.         .db %00000000
  1052.  
  1053. Enemy3Ship:
  1054.         .db %00000000
  1055.         .db %00000000
  1056.         .db %00000000
  1057.         .db %10101010
  1058.         .db %10000001
  1059.         .db %01010101
  1060.         .db %00000000
  1061.         .db %00000000
  1062.  
  1063.  
  1064. TargetShip:
  1065.     .db %11111111
  1066.     .db %10011001
  1067.     .db %10011001
  1068.     .db %11111111
  1069.     .db %00000000
  1070.     .db %00000000
  1071.     .db %00000000
  1072.     .db %00000000
  1073.  
  1074. FireBall:
  1075.     .db %00000000
  1076.     .db %00000000
  1077.     .db %00011000
  1078.     .db %00111100
  1079.     .db %01111110
  1080.     .db %00111100
  1081.     .db %00011000
  1082.     .db %00000000
  1083.  
  1084.  
  1085. ;┌────────────────┬────────────────┬─────────────────────┬───────┬────────────┐
  1086. ;│█████ Z80 ██████│    Sprite83    │█████████████████████│ movax │████████████│
  1087. ;└────────────────┴────────────────┴─────────────────────┴───────┴────────────┘
  1088.  
  1089. ; Sprite xor routine v1.0
  1090. ; Coded by Hannes Edfeldt in 1997
  1091.  
  1092. ; This routine uses xor to draw the sprite, therefore you can erase the sprite
  1093. ; by just drawing it again at the same x and y coordinates. See xordemo.z80
  1094. ; for an example of how to use this routine.
  1095.  
  1096. ; Feel free to use this routine in your own productions as long as you give me
  1097. ; some credit.
  1098.  
  1099. ; This file should of course be viewed in a DOS texteditor ;)
  1100.  
  1101. ; Hannes Edfeldt -+- movax@algonet.se -+- http://www.algonet.se/~movax
  1102.  
  1103.  
  1104. ;▄████████████▀ SPRXOR ▀███████████████████████████████████████████████████████
  1105. ;┌────────────────────────────────────────────────────────────────────────────┐
  1106. ;│ Xor 8x8 sprite ■ a=x, e=y, bc=sprite address                               │
  1107. ;└────────────────────────────────────────────────────────────────────────────┘
  1108. PutSprite:
  1109.  
  1110.         push    bc              ; Save sprite address
  1111.  
  1112. ;████   Calculate the address in graphbuf   ████
  1113.  
  1114.         ld      hl,0            ; Do y*12
  1115.         ld      d,0
  1116.         add     hl,de
  1117.         add     hl,de
  1118.         add     hl,de
  1119.         add     hl,hl
  1120.         add     hl,hl
  1121.  
  1122.         ld      d,0             ; Do x/8
  1123.         ld      e,a
  1124.         srl     e
  1125.         srl     e
  1126.         srl     e
  1127.         add     hl,de
  1128.  
  1129.         ld      de,$88B8
  1130.         add     hl,de           ; Add address to graphbuf
  1131.  
  1132.         ld      b,00000111b     ; Get the remainder of x/8
  1133.         and     b
  1134.         cp      0               ; Is this sprite aligned to 8*n,y?
  1135.         jp      z,ALIGN
  1136.  
  1137.  
  1138. ;████   Non aligned sprite blit starts here   ████
  1139.  
  1140.         pop     ix              ; ix->sprite
  1141.         ld      d,a             ; d=how many bits to shift each line
  1142.  
  1143.         ld      e,8             ; Line loop
  1144. LILOP:  ld      b,(ix+0)        ; Get sprite data
  1145.  
  1146.         ld      c,0             ; Shift loop
  1147.         push    de
  1148. SHLOP:  srl     b
  1149.         rr      c
  1150.         dec     d
  1151.         jp      nz,SHLOP
  1152.         pop     de
  1153.  
  1154.         ld      a,b             ; Write line to graphbuf
  1155.         xor     (hl)
  1156.         ld      (hl),a
  1157.         inc     hl
  1158.         ld      a,c
  1159.         xor     (hl)
  1160.         ld      (hl),a
  1161.  
  1162.         ld      bc,11           ; Calculate next line address
  1163.         add     hl,bc
  1164.         inc     ix              ; Inc spritepointer
  1165.  
  1166.         dec     e
  1167.         jp      nz,LILOP        ; Next line
  1168.  
  1169.         jp      DONE1
  1170.  
  1171.  
  1172. ;████   Aligned sprite blit starts here   ████
  1173.  
  1174. ALIGN:                          ; Blit an aligned sprite to graphbuf
  1175.         pop     de              ; de->sprite
  1176.         ld      b,8
  1177. ALOP1:  ld      a,(de)
  1178.         xor     (hl)
  1179.         ld      (hl),a
  1180.         inc     de
  1181.         push    bc
  1182.         ld      bc,12
  1183.         add     hl,bc
  1184.         pop     bc
  1185.         djnz    ALOP1
  1186.  
  1187. DONE1:
  1188.         ret
  1189.  
  1190. ;▄████████████▄ SPRXOR ▄███████████████████████████████████████████████████████
  1191.  
  1192.  
  1193. ;┌────────────────┬────────────────┬─────────────────────┬───────┬────────────┐
  1194. ;│█████ Z80 ██████│    Sprite83    │█████████████████████│ movax │████████████│
  1195. ;└────────────────┴────────────────┴─────────────────────┴───────┴────────────┘
  1196.  
  1197.  
  1198.  
  1199. ;------------------------------------
  1200. ;|Begin Data [Text, Variables, Etc.]
  1201. ;------------------------------------
  1202.  
  1203. PokeStr:    .db    "Poke 1.1",0
  1204. ByMeStr:    .db    "By: AE  ",0
  1205. LiveStr:    .db    "Lvs:",0
  1206. ScorStr:    .db    "Scr:",0
  1207. HighStr:    .db    "High:",0
  1208. HiScr:        .db    "New High Score!",0
  1209. htext:         .db     "HighScore---ARE",0
  1210. BlankStr:    .db    "               ",0
  1211.  
  1212. noLet:        .db    0            
  1213. ShipX:        .db    0            ;Ship's X Coord
  1214. ShipY:        .db    0            ;Ship's Y Coord [Constant]
  1215. FireX:        .db    0            ;Weapon's X Coord
  1216. FireY:        .db    0            ;Weapon's Y Coord
  1217. FireZ:        .db    0            ;Weapon Fired or No?
  1218. TargetX:        .db     0                       ;Target's X Coord
  1219. TargetY:        .db     0                       ;Target's Y Coord
  1220. TargetD:        .db     0                       ;Target's Direction
  1221. EnemyX:        .db    0            ;Enemy's X Coord
  1222. EnemyY:        .db    0            ;Enemy's Y Coord
  1223. EnemyD:        .db    0            ;Enemy's Direction
  1224. Enemy2X:        .db     0
  1225. Enemy2Y:        .db     0
  1226. Enemy2D:        .db     0
  1227. Enemy3X:        .db     0
  1228. Enemy3Y:        .db     0
  1229. Enemy3D:        .db     0
  1230. Lives:        .db    0            ;Lives Remaining
  1231. Hits:           .db     0                       ;The Number of Hits
  1232. Level:          .db     0                       ;The Level you are on
  1233.  
  1234. Temp:           .db     0,0                     ;Temporary Variable
  1235. Score:        .db    0,0            ;Current Score
  1236.  
  1237.  
  1238. .end
  1239. END
  1240.