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

  1. #include asm86.h
  2. #include ti86asm.inc
  3.  
  4. .org _asm_exec_ram
  5.  
  6. ;------------------AShell / Rascall Description-------------------------
  7.     nop         ;Identifies the table
  8.     jp Initialize
  9. .dw $0000   ;Version # of Table
  10. .dw Title   ;Absolute pointer to program description
  11.  
  12. ;---------------------------Begin Program --------------------------------
  13.  
  14. Initialize:
  15.         call _runindicoff       ;Run Indicator Off
  16.     call _clrLCD        ;Clears the Screen
  17.         
  18. StartGame:
  19.         call NewVarInit         ;Sets up variables
  20.         call ScreenSetup        ;Sets up the Screen
  21.     call DispHighScore    ;Displays the High Score
  22.     call DispShip        ;Displays the Ship
  23.         jr GameLoop             ;Goto GameLoop
  24.  
  25. LevelUp:
  26.         call _clrLCD
  27.         ld a,(Level)
  28.         inc a
  29.         ld (Level),a
  30.         call ScreenSetup
  31.         call DispHighScore
  32.         call DispShip
  33.         call DispEnemyII
  34.         ld a,(Level)
  35.         cp 3
  36.         call z,DispEnemyIII
  37.         
  38. ;---------------------------
  39. ;|GetKey Loop and Movement
  40. ;---------------------------
  41.  
  42. GameLoop:
  43.     ld     a,0ffh        ;Reset keyport
  44.         out     (1),a           ;Clear Port
  45.     ld     a,0feh        ;Load desired port
  46.         out   (1),a             ;Clear Keys
  47.         in      a,(1)           ;Input Key
  48.         cp      251             ;If key is right
  49.         jp      z,M_Right       ;Goto Right
  50.         cp      253             ;If key is left
  51.         jp      z,M_Left        ;Goto Left
  52.     ld     a,0ffh        ;Reset keyport
  53.         out     (1),a           ;Clear Port
  54.     ld     a,0bfh        ;Load desired port
  55.         out   (1),a             ;Clear Keys
  56.         in      a,(1)           ;Input Key
  57.         cp      223             ;Is it 2nd
  58.     jp     z,Fire        ;Fire if so
  59.     cp 127            ;Is it Delete?
  60.     call z,Pause        ;Pause!
  61.         cp      191             ;Is it Exit 
  62.         ret     z               ;Return if so
  63.  
  64. NoKeyLoop:
  65.     call MoveTarget        ;Move the Target
  66.     call MoveEnemy        ;Move the Enemy
  67.     call CheckEnemyHit    ;See if you hit the enemy
  68.     
  69. CheckDeath:                     ;Checks to see if you are dead
  70.     ld a,(Lives)        ;Lives into A
  71.         or a                    ;Is it 0?
  72.     jp z,EndOfGame        ;Goto End Of Game
  73.  
  74. ContinueNKL:
  75.     call CheckFire        ;Checks the FireBall
  76.         ld a,(Level)
  77.         cp 3
  78.         jr z,GameLoop
  79.         ld a,(Hits)             ;Hits into A
  80.         cp 15                   ;Is it 15?
  81.         jp z,LevelUp
  82.         jr GameLoop             ;Goto GameLoop
  83.  
  84. M_Right:                        ;Move Right
  85.     ld a,(ShipX)        ;Ship X into A
  86.         cp 74                   ;Is it 74 [Line]
  87.     jr z,GameLoop        ;ReLoop, don't move
  88.         cp 75                   ;Is it 75 [Line]
  89.     jr z,GameLoop        ;ReLoop, don't move
  90.     call DispShip        ;Clear Ship
  91.     ld a,(ShipX)        ;Ship X back into A
  92.         inc a                   ;Increment it
  93.         inc a                   ;Increment it
  94.     ld (ShipX),a        ;A back into ShipX
  95.     call DispShip        ;RePut Ship
  96.     jr NoKeyLoop        ;Goto NoKeyLoop
  97.  
  98. M_Left:                ;Move Left
  99.     ld a,(ShipX)        ;Ship X into A
  100.         cp 3                    ;Is it 3 [Line]
  101.     jr z,GameLoop        ;ReLoop, don't move
  102.         cp 4                    ;Is it 4 [Line]
  103.     jr z,GameLoop        ;ReLoop, don't move
  104.     call DispShip        ;Clear Ship
  105.     ld a,(ShipX)        ;Ship X back into A
  106.         dec a                   ;Decrement it
  107.         dec a                   ;Decrement it
  108.     ld (ShipX),a        ;A back into ShipX
  109.     call DispShip        ;RePut Ship
  110.     jr NoKeyLoop        ;Goto NoKeyLoop
  111.  
  112. DispShip:                ;XORs the Ship Sprite on/off the screen
  113.         ld a,(ShipY)                    ;Ship Y into A
  114.         ld e,a                          ;A goes into E, E = Y Coord
  115.         ld a,(ShipX)                    ;Ship X into A
  116.     ld hl,PlayerShip        ;Sprite name into HL
  117.         call PutSprite                  ;XOR it!
  118.     ret                ;Return to call
  119.  
  120. DispTarget:                ;XORs the Target Sprite on/off the screen
  121.         ld a,(TargetY)                  ;Target Y into A
  122.         ld e,a                          ;A into E , E = Y Coord
  123.         ld a,(TargetX)                  ;Target X Coord into A
  124.     ld hl,TargetShip        ;Sprite Name into HL
  125.         call PutSprite                  ;XOR it!
  126.         ret                             ;Return to Call
  127.  
  128. DispEnemy:                      ;XORs the Enemy Sprite on/off the screen
  129.     ld a,(EnemyY)        ;Enemy Y into A
  130.     ld e,a            ;A goes into E, E = Y Coord
  131.     ld a,(EnemyX)        ;Enemy X into A
  132.     ld hl,EnemyShip        ;Sprite name into HL
  133.     call PutSprite        ;XOR it!
  134.         ret                     ;Return to call
  135.  
  136. DispEnemyII:                     ;XORs the Enemy Sprite on/off the screen
  137.         ld a,(Enemy2Y)          ;Enemy Y into A
  138.     ld e,a            ;A goes into E, E = Y Coord
  139.         ld a,(Enemy2X)          ;Enemy X into A
  140.         ld hl,Enemy2Ship        ;Sprite name into HL
  141.     call PutSprite        ;XOR it!
  142.         ret                     ;Return to call
  143.  
  144. DispEnemyIII:                   ;XORs the Enemy Sprite on/off the screen
  145.         ld a,(Enemy3Y)          ;Enemy Y into A
  146.     ld e,a            ;A goes into E, E = Y Coord
  147.         ld a,(Enemy3X)          ;Enemy X into A
  148.         ld hl,Enemy3Ship        ;Sprite name into HL
  149.     call PutSprite        ;XOR it!
  150.         ret                     ;Return to call
  151.  
  152. DispFire:                       ;XORs the Ship Sprite on/off the screen
  153.     ld a,(FireY)        ;Fire Y into A
  154.     ld e,a            ;A goes into E, E = Y Coord
  155.     ld a,(FireX)        ;Fire X into A
  156.     ld hl,FireBall        ;Sprite name into HL
  157.     call PutSprite        ;XOR it!
  158.         ret                     ;Return to call
  159.  
  160.  
  161. Pause:
  162.     call _getkey
  163.     ret
  164.  
  165. ;----------------------
  166. ;|Fire Routine
  167. ;----------------------
  168.  
  169. Fire:
  170.     ld a,(FireZ)        ;Loads FireZ into A
  171.         or a                    ;If it is 0 [No Fire]
  172.     jr z,NewFire        ;Put a new fireball
  173.     jp nz,NoKeyLoop        ;NoKeyLoop otherwise
  174.  
  175. NewFire:                        ;Creates new FireBall
  176.     ld a,1            ;1 into A
  177.     ld (FireZ),a        ;A into FireZ
  178.     ld a,(ShipX)        ;Ship X into A
  179.     ld (FireX),a        ;Loads A into FireX
  180.     ld a,(ShipY)        ;ShipY into A
  181.     ld (FireY),a        ;A into FireY
  182.     call DispFire        ;Display FireBall
  183.     jp NoKeyLoop        ;Goto NoKeyLoop
  184.  
  185. CheckFire:
  186.     call Delay            ;Creates a Short Delay
  187.         ld a,(FireZ)                    ;FireZ into a
  188.     or a                ;If it is 0 [No Fire]
  189.     ret z                ;Return, no need to bother
  190.         ld a,(FireY)                    ;FireY into A
  191.     or a                ;If it is 0
  192.         jr z,CheckHit                   ;Check for Hit
  193.         call DispFire                   ;Clear Fire
  194.         ld a,(FireY)                    ;Fire Y into A again
  195.     dec a                ;Decrease it
  196.         ld (FireY),a                    ;A into FireY
  197.         call DispFire                   ;RePut Fire
  198.     ret                ;Return
  199.  
  200. CheckHit:                               ;Checks if you hit target
  201.     ld a,(FireX)            ;Loads Fire X into A
  202.     add a,8                ;Add 8 to A [End of Sprite]
  203.     ld b,a                ;Loads A into B
  204.     ld a,(TargetX)            ;Loads TargetX into A
  205.         cp b                            ;Compares a to b
  206.     jp c,ContinueCheck        ;Continue Checking if a>b
  207.  
  208. MissHit:
  209.         call DecScore
  210.         call DecScore
  211.         call DecScore
  212.         call DecScore
  213.         call DecScore
  214.     ld hl,34*256+88            ;Load Coords into HL
  215.     ld (_penCol),hl            ;Loads PenCol into HL
  216.     ld hl,BlankStr            ;Blank String into HL
  217.         call _vputs                     ;Display it
  218.         ld hl,27*256+105                ;Set Coords into HL
  219.     ld (_penCol),hl            ;Loads HL into PenCol
  220.     ld hl,(Score)            ;Variable into HL
  221.         call DispHL                     ;Display HL
  222.         call ResetFire                  ;Reset the Fire Otherwise
  223.         ret                             ;Return from Call
  224.     
  225. DecScore:
  226.         ld       de,(Score)
  227.         ld       a,d
  228.         or       e
  229.         ret      z
  230.         dec      de
  231.         ld       (Score),de
  232.         ret
  233.  
  234. ContinueCheck:
  235.     ld a,(TargetX)            ;Target X into A
  236.     add a,8                ;Add 8 to A [End of Sprite]
  237.     ld b,a                ;Loads A into B
  238.     ld a,(FireX)            ;Fire X into A
  239.         cp b                            ;Compare A to B
  240.     jp c,HitTarget            ;If b>a then you hit it
  241.     jp MissHit
  242.         ret                             ;Return to Call
  243.  
  244. HitTarget:
  245.     call ResetFire            ;Reset the Fire
  246.     ld hl,(Score)            ;Load Score into HL
  247.         ld bc,25                        ;Loads 25 into bc
  248.         add hl,bc                       ;Adds BC and HL
  249.     ld (Score),hl            ;Load HL back into Score
  250.     ld hl,34*256+88            ;Load Coords into HL
  251.     ld (_penCol),hl            ;Loads PenCol into HL
  252.     ld hl,BlankStr            ;Blank String into HL
  253.         call _vputs                     ;Display it
  254.         ld hl,27*256+105                ;Set Coords into HL
  255.     ld (_penCol),hl            ;Loads HL into PenCol
  256.     ld hl,(Score)            ;Variable into HL
  257.         call DispHL                     ;Display HL
  258.         ld a,(Hits)
  259.         inc a
  260.         ld (Hits),a
  261.         ret                             ;Return from Call
  262.  
  263. ResetFire:                              ;Reset the Fire
  264.     call DispFire            ;Clears the Fire
  265.         xor a                           ;Loads 0 into A
  266.     ld (FireZ),a            ;Reset FireZ
  267.     ld (FireX),a            ;Reset FireX
  268.     ld (FireY),a            ;Reset FireY
  269.         ret                             ;Return from Call
  270.  
  271. CheckEnemyHit:
  272.         call Delay                      ;Creates a Short Delay
  273.     ld a,(FireZ)            ;FireZ into a
  274.         or a                            ;If it is 0 [No Fire]
  275.         ret z                           ;Return, no need to bother
  276.     ld a,(FireY)            ;FireY into A
  277.         cp 30                           ;Is it 30?
  278.         jr z,CheckEHit                  ;Check for Hit
  279.         ld a,(Level)                    ;Level # into A
  280.         cp 1                            ;Is it 1?
  281.         jp nz,CheckE2Hit                ;Check Enemy II Hit Otherwise
  282.         jp DecFire
  283.                                         ;Return
  284.  
  285. CheckEHit:                              ;Checks if you hit target
  286.     ld a,(FireX)            ;Loads Fire X into A
  287.     add a,8                ;Add 8 to A [End of Sprite]
  288.     ld b,a                ;Loads A into B
  289.     ld a,(EnemyX)            ;Loads EnemyX into A
  290.         cp b                            ;Compares a to b
  291.     jp c,ContinueECheck        ;Continue Checking if a>b
  292.         ret                             ;Return from Call Otherwise
  293.  
  294. ContinueECheck:
  295.     ld a,(EnemyX)            ;Enemy X into A
  296.     add a,8                ;Add 8 to A [End of Sprite]
  297.     ld b,a                ;Loads A into B
  298.     ld a,(FireX)            ;Fire X into A
  299.         cp b                            ;Compare A to B
  300.     jp c,HitEnemy            ;If b>a then you hit it
  301.         ret                             ;Return to Call Otherwise
  302.  
  303. CheckE2Hit:                             ;Checks if you hit target 2
  304.         ld a,(Level)
  305.         cp 1
  306.         jp z,DecFire
  307.     ld a,(FireX)            ;Loads Fire X into A
  308.     add a,8                ;Add 8 to A [End of Sprite]
  309.     ld b,a                ;Loads A into B
  310.         ld a,(Enemy2X)                  ;Loads Enemy2X into A
  311.         cp b                            ;Compares a to b
  312.         jp c,ContinueE2Check            ;Continue Checking if a>b
  313.         jp CheckE3Hit
  314.  
  315. DecFire:
  316.         call DispFire
  317.         ld a,(FireY)
  318.         dec a
  319.         ld (FireY),a
  320.         call DispFire
  321.         ret
  322.  
  323. ContinueE2Check:
  324.         ld a,(Enemy2X)                  ;Enemy 2X into A
  325.     add a,8                ;Add 8 to A [End of Sprite]
  326.     ld b,a                ;Loads A into B
  327.     ld a,(FireX)            ;Fire X into A
  328.         cp b                            ;Compare A to B
  329.         jp c,CheckE2Y                   ;If b>a then you hit it
  330.         jp CheckE3Hit
  331.  
  332. CheckE2Y:
  333.         ld a,(FireY)                    ;Loads FireY into A
  334.     add a,4                ;Add 8 to A [End of Sprite]
  335.     ld b,a                ;Loads A into B
  336.         ld a,(Enemy2Y)                  ;Loads Enemy Y into A
  337.         cp b                            ;Compares a to b
  338.         jp c,ContinueCheck2Y            ;Continue Checking if a>b
  339.         jp CheckE3Hit                   ;Missed Otherwise
  340.        
  341. ContinueCheck2Y:
  342.         ld a,(Enemy2Y)                  ;Enemy Y into A
  343.     add a,4                ;Add 8 to A [End of Sprite]
  344.     ld b,a                ;Loads A into B
  345.         ld a,(FireY)                    ;Fire Y into A
  346.         cp b                            ;Compare A to B
  347.         jp c,HitEnemy2                  ;If b>a then hit
  348.         jp CheckE3Hit                   ;You missed otherwise
  349.  
  350. CheckE3Hit:                             ;Checks if you hit target 3
  351.         ld a,(Level)
  352.         cp 3
  353.         jp nz,DecFire
  354.     ld a,(FireX)            ;Loads Fire X into A
  355.     add a,8                ;Add 8 to A [End of Sprite]
  356.     ld b,a                ;Loads A into B
  357.         ld a,(Enemy3X)                  ;Loads Enemy3X into A
  358.         cp b                            ;Compares a to b
  359.         jp c,ContinueE3Check            ;Continue Checking if a>b
  360.         jp DecFire
  361.  
  362. ContinueE3Check:
  363.         ld a,(Enemy3X)                  ;Enemy 3X into A
  364.     add a,8                ;Add 8 to A [End of Sprite]
  365.     ld b,a                ;Loads A into B
  366.     ld a,(FireX)            ;Fire X into A
  367.         cp b                            ;Compare A to B
  368.         jp c,CheckE3Y                   ;If b>a then you hit it
  369.         jp DecFire                      ;Decrease Fire and Return otherwise
  370.  
  371. CheckE3Y:
  372.         ld a,(FireY)                    ;Loads FireY into A
  373.     add a,4                ;Add 8 to A [End of Sprite]
  374.     ld b,a                ;Loads A into B
  375.         ld a,(Enemy3Y)                  ;Loads Enemy Y into A
  376.         cp b                            ;Compares a to b
  377.         jp c,ContinueCheck3Y            ;Continue Checking if a>b
  378.         jp DecFire                      ;Missed Otherwise
  379.        
  380. ContinueCheck3Y:
  381.         ld a,(Enemy3Y)                  ;Enemy Y into A
  382.     add a,4                ;Add 8 to A [End of Sprite]
  383.     ld b,a                ;Loads A into B
  384.         ld a,(FireY)                    ;Fire Y into A
  385.         cp b                            ;Compare A to B
  386.         jp c,HitEnemy3                  ;If b>a then hit
  387.         jp DecFire                      ;You missed otherwise
  388.  
  389.  
  390. HitEnemy:
  391.         call Delay                      ;Creates a short delay
  392.     call DispFire            ;Views the Fire
  393.     ld a,(FireY)            ;Loads Y into A
  394.         inc a                           ;Increases It
  395.     ld (FireY),a            ;Back into A
  396.     call DispFire            ;Redisplays
  397.     ld a,(FireY)            ;Loads Y into A
  398.         cp 54                           ;Is it 54?
  399.     jp nz,HitEnemy            ;If not, reloop
  400.     jr CheckYouHit            ;Check if you are hit
  401.  
  402. CheckYouHit:                            ;Checks if you die
  403.     ld a,(FireX)            ;Loads Fire X into A
  404.         add a,6                         ;Add 8 to A [End of Sprite]
  405.     ld b,a                ;Loads A into B
  406.     ld a,(ShipX)            ;Loads ShipX into A
  407.         cp b                            ;Compares a to b
  408.     jp c,ContinueUCheck        ;Continue Checking if a>b
  409.     call ResetFire            ;Reset Fire
  410.         ret                             ;Return from Call Otherwise
  411.  
  412. ContinueUCheck:
  413.     ld a,(EnemyX)            ;Enemy X into A
  414.         add a,6                         ;Add 6 to A [End of Sprite]
  415.     ld b,a                ;Loads A into B
  416.     ld a,(ShipX)            ;Fire X into A
  417.         cp b                            ;Compare A to B
  418.         jp c,HitYou                     ;If b>a then you hit it
  419.     call ResetFire            ;ResetFire
  420.         ret                             ;Return to Call Otherwise
  421.  
  422. HitEnemy2:
  423.         call Delay                      ;Creates a short delay
  424.     call DispFire            ;Views the Fire
  425.     ld a,(FireY)            ;Loads Y into A
  426.         inc a                           ;Increases It
  427.     ld (FireY),a            ;Back into A
  428.     call DispFire            ;Redisplays
  429.     ld a,(FireY)            ;Loads Y into A
  430.         cp 54                           ;Is it 54?
  431.         jp nz,HitEnemy2                 ;If not, reloop
  432.         jr CheckYou2Hit                 ;Check if you are hit
  433.  
  434. CheckYou2Hit:                           ;Checks if you die
  435.     ld a,(FireX)            ;Loads Fire X into A
  436.         add a,6                         ;Add 6 to A [End of Sprite]
  437.     ld b,a                ;Loads A into B
  438.     ld a,(ShipX)            ;Loads ShipX into A
  439.         cp b                            ;Compares a to b
  440.         jp c,ContinueU2Check            ;Continue Checking if a>b
  441.     call ResetFire            ;Reset Fire
  442.         ret                             ;Return from Call Otherwise
  443.  
  444. ContinueU2Check:
  445.         ld a,(Enemy2X)                   ;Enemy X into A
  446.         add a,6                         ;Add 8 to A [End of Sprite]
  447.     ld b,a                ;Loads A into B
  448.     ld a,(ShipX)            ;Fire X into A
  449.         cp b                            ;Compare A to B
  450.         jp c,HitYou                     ;If b>a then you hit it
  451.     call ResetFire            ;ResetFire
  452.         ret                             ;Return to Call Otherwise
  453.  
  454. HitYou:
  455.         call DecScore
  456.         call DecScore
  457.         call DecScore
  458.         call DecScore
  459.         call DecScore
  460.         call DecScore
  461.         call DecScore
  462.         call DecScore
  463.         call DecScore
  464.         call DecScore
  465.         call DecScore
  466.     call ResetFire
  467.     ld a,(Lives)            ;Load lives into A
  468.         dec a                           ;decrease A
  469.     ld (Lives),a            ;Load a back
  470.         ld hl,20*256+105                ;Set Coords into HL
  471.     ld (_penCol),hl            ;Loads HL into PenCol
  472.     ld hl,BlankStr            ;BlankStr into HL
  473.         call _vputs                     ;Display it!
  474.         ld hl,20*256+105                ;Set Coords into HL
  475.     ld (_penCol),hl            ;Loads HL into PenCol
  476.     ld a,(Lives)            ;Variable into A
  477.         call DispA                      ;Display A
  478.     ld hl,34*256+88            ;Load Coords into HL
  479.     ld (_penCol),hl            ;Loads PenCol into HL
  480.     ld hl,BlankStr            ;Blank String into HL
  481.         call _vputs                     ;Display it
  482.         ld hl,27*256+105                ;Set Coords into HL
  483.     ld (_penCol),hl            ;Loads HL into PenCol
  484.     ld hl,(Score)            ;Variable into HL
  485.         call DispHL                     ;Display HL
  486.         ret                             ;Return!
  487.  
  488. HitEnemy3:
  489.         call Delay                      ;Creates a short delay
  490.     call DispFire            ;Views the Fire
  491.     ld a,(FireY)            ;Loads Y into A
  492.         inc a                           ;Increases It
  493.     ld (FireY),a            ;Back into A
  494.     call DispFire            ;Redisplays
  495.     ld a,(FireY)            ;Loads Y into A
  496.         cp 54                           ;Is it 54?
  497.         jp nz,HitEnemy3                 ;If not, reloop
  498.         jp CheckYou2Hit                 ;Check if you are hit
  499.  
  500. CheckYou3Hit:                           ;Checks if you die
  501.     ld a,(FireX)            ;Loads Fire X into A
  502.         add a,6                         ;Add 6 to A [End of Sprite]
  503.     ld b,a                ;Loads A into B
  504.     ld a,(ShipX)            ;Loads ShipX into A
  505.         cp b                            ;Compares a to b
  506.         jp c,ContinueU3Check            ;Continue Checking if a>b
  507.     call ResetFire            ;Reset Fire
  508.         ret                             ;Return from Call Otherwise
  509.  
  510. ContinueU3Check:
  511.         ld a,(Enemy3X)                   ;Enemy X into A
  512.         add a,6                         ;Add 8 to A [End of Sprite]
  513.     ld b,a                ;Loads A into B
  514.     ld a,(ShipX)            ;Fire X into A
  515.         cp b                            ;Compare A to B
  516.         jp c,HitYou                     ;If b>a then you hit it
  517.     call ResetFire            ;ResetFire
  518.         ret                             ;Return to Call Otherwise
  519.  
  520. ;--------------------------------
  521. ;|Target Routine, to Move Target
  522. ;--------------------------------
  523.  
  524. MoveTarget:
  525.     call DispTarget            ;XOR the Target Ship on the Screen
  526.     ld a,(TargetD)            ;Target Direction into A
  527.         or a                            ;Is it 0
  528.     jr z,M_T_Right            ;Move Target Right
  529.     jr nz,M_T_Left            ;Otherwise Move Left
  530.  
  531. M_T_Right:
  532.     ld a,(TargetX)            ;Target X into A
  533.         cp 75                           ;Is it 75
  534.         jr z,ResetTargetMove            ;Reset Target to Move Other Direction
  535.         cp 74                           ;Is it 74
  536.     jr z,ResetTargetMove        ;Reset Target to Move Other Direction
  537.         inc a                           ;Increase it again
  538.     ld (TargetX),a            ;Into TargetX
  539.     call DispTarget            ;Replace Target on Screen
  540.         ret                             ;Return
  541.  
  542. M_T_Left:
  543.     ld a,(TargetX)            ;Target X into A
  544.         cp 3                            ;Is it 3
  545.     jr z,ResetTargetMove        ;Reset Target to Move Other Direction
  546.         cp 4                            ;Is it 4
  547.     jr z,ResetTargetMove        ;Reset Target to Move Other Direction
  548.         dec a                           ;Decrease it
  549.     ld (TargetX),a            ;Into TargetX
  550.     call DispTarget            ;Replace Target on Screen
  551.         ret                             ;Return
  552.  
  553. ResetTargetMove:
  554.     ld a,(TargetD)            ;Load Target Direction into A
  555.         or a                            ;Is it 0?
  556.     jr z,ResetLeft            ;Reset it to go left!
  557.         xor a                           ;Loads 0 into a
  558.     ld (TargetD),a            ;Loads A into Direction 
  559.     jr M_T_Right            ;Move Right
  560.  
  561. ResetLeft:
  562.     ld a,1                ;Load 1 into A
  563.     ld (TargetD),a            ;Loads A into Target Direction
  564.         jr M_T_Left                     ;Move Left
  565.  
  566. ;--------------------------------
  567. ;|Enemy Routine, to Move Enemy
  568. ;--------------------------------
  569.  
  570. MoveEnemy:
  571.         ld a,(Level)
  572.         cp 1
  573.         jp z,Level1Enemy
  574.         cp 2
  575.         jp z,Level2Enemy
  576.         jp nz,Level3Enemy
  577.  
  578. Level3Enemy:
  579.         call Level1Enemy
  580.         call Level2Enemy
  581.         call DispEnemyIII
  582.         ld a,(Enemy3D)
  583.         or a
  584.         jp nz,M_E_DownLeft
  585.  
  586. M_E_UpRight:
  587.         ld a,(Enemy3Y)                  ;Y Coordinate into A
  588.         cp 12                           ;Is it 12?
  589.         jp z,Reset_E3_Dir               ;Change the Direction if so
  590.         ld a,(Enemy3Y)                  ;Y Coord into A
  591.         dec a                           ;Decrease it [Going Up]
  592.         ld (Enemy3Y),a                  ;A into Enemy 2 Y
  593.         ld a,(Enemy3X)                  ;Load Enemy 2 X into A
  594.         inc a                           ;Increment it
  595.         ld (Enemy3X),a                  ;Loads A into Enemy2X
  596.         call DispEnemyIII               ;Display Enemy III
  597.         ret                             ;Return
  598.  
  599. Level2Enemy:
  600.         call Level1Enemy                ;Call Level1 Enemy, so it will move
  601.         call DispEnemyII                ;XOR Enemy II
  602.         ld a,(Enemy2D)
  603.         or a                            ;Is it 0?
  604.         jp nz,M_E_DownRight             ;No?? Then move down/right
  605.  
  606. M_E_UpLeft:
  607.         ld a,(Enemy2Y)                  ;Y Coordinate into A
  608.         cp 12                           ;Is it 12?
  609.         jp z,Reset_E2_Dir               ;Change the Direction if so
  610.         ld a,(Enemy2Y)                  ;Y Coord into A
  611.         dec a                           ;Decrease it [Going Up]
  612.         ld (Enemy2Y),a                  ;A into Enemy 2 Y
  613.         ld a,(Enemy2X)                  ;Load Enemy 2 X into A
  614.         dec a                           ;Decrement it
  615.         ld (Enemy2X),a                  ;Loads A into Enemy2X
  616.         call DispEnemyII                ;Display Enemy II
  617.         ret                             ;Return
  618.  
  619. M_E_DownLeft:
  620.         ld a,(Enemy3Y)                  ;Y Coordinate into A
  621.         cp 46                           ;Is it 46?
  622.         jp z,Reset_E3_Dir               ;Change the Direction if so
  623.         ld a,(Enemy3Y)                  ;Y Coord into A
  624.         inc a                           ;Increase it [Going Down]
  625.         ld (Enemy3Y),a                  ;A into Enemy 2 Y
  626.         ld a,(Enemy3X)                  ;Load Enemy 2 X into A
  627.         dec a                           ;Increment it
  628.         ld (Enemy3X),a                  ;Loads A into Enemy2X
  629.         call DispEnemyIII               ;Display Enemy III
  630.         ret                             ;Return
  631.  
  632.  
  633. M_E_DownRight:
  634.         ld a,(Enemy2Y)                  ;Y Coordinate into A
  635.         cp 46                           ;Is it 46?
  636.         jp z,Reset_E2_Dir               ;Change the Direction if so
  637.         ld a,(Enemy2Y)                  ;Y Coord into A
  638.         inc a                           ;Increase it [Going Down]
  639.         ld (Enemy2Y),a                  ;A into Enemy 2 Y
  640.         ld a,(Enemy2X)                  ;Load Enemy 2 X into A
  641.         inc a                           ;Increment it
  642.         ld (Enemy2X),a                  ;Loads A into Enemy2X
  643.         call DispEnemyII                ;Display Enemy II
  644.         ret                             ;Return
  645.  
  646. Level1Enemy:
  647.     call DispEnemy            ;XOR the Enemy Ship on the Screen
  648.     ld a,(EnemyD)            ;Enemy Direction into A
  649.         or a                            ;Is it 0
  650.     jr z,M_E_Right            ;Move Target Right
  651.     jr nz,M_E_Left            ;Otherwise Move Left
  652.  
  653. M_E_Right:
  654.     ld a,(EnemyX)            ;Enemy X into A
  655.         cp 75                           ;Is it 75
  656.     jr z,ResetEnemyMove        ;Reset Target to Move Other Direction
  657.         cp 74                           ;Is it 74
  658.     jr z,ResetEnemyMove        ;Reset Target to Move Other Direction
  659.         inc a                           ;Increase it again
  660.         inc a                           ;Increase it again
  661.     ld (EnemyX),a            ;Into EnemyX
  662.     call DispEnemy            ;Replace Enemy on Screen
  663.         ret                             ;Return
  664.  
  665. M_E_Left:
  666.     ld a,(EnemyX)            ;Enemy X into A
  667.         cp 3                            ;Is it 3
  668.     jr z,ResetEnemyMove        ;Reset Enemy to Move Other Direction
  669.         cp 4                            ;Is it 4
  670.         jr z,ResetEnemyMove             ;Reset Enemy to Move Other Direction
  671.         dec a                           ;Decrease it
  672.         dec a                           ;Decrease it again
  673.     ld (EnemyX),a            ;Into EnemyX
  674.     call DispEnemy            ;Replace Enemy on Screen
  675.         ret                             ;Return
  676.  
  677. ResetEnemyMove:
  678.     ld a,(EnemyD)            ;Load Enemy Direction into A
  679.         or a                            ;Is it 0?
  680.     jr z,ResetELeft            ;Reset it to go left!
  681.         xor a                           ;Loads 0 into a
  682.     ld (EnemyD),a            ;Loads A into Direction 
  683.     jr M_E_Right            ;Move Right
  684.  
  685. ResetELeft:
  686.     ld a,1                ;Load 1 into A
  687.     ld (EnemyD),a            ;Loads A into Target Direction
  688.         jr M_E_Left                     ;Move Left
  689.  
  690. Reset_E2_Dir:
  691.         ld a,(Enemy2D)                  ;Load Direction into a
  692.         inc a                           ;Increase it
  693.         cp 2                            ;If it is 2
  694.         jp z,Make_E2Dir_UL              ;that means it was 1, d/r.. so switch
  695.         ld a,1                          ;Otherwise, it was u/l, so switch
  696.         ld (Enemy2D),a                  ;Load 1 into Direction
  697.         jp M_E_DownRight               ;Goto DownRight Movement
  698.  
  699. Make_E2Dir_UL:
  700.         xor a                            ;Make a be = to 0
  701.         ld (Enemy2D),a                 ;Make that the direction
  702.         jp M_E_UpLeft                   ;Move Up/Left
  703.  
  704. Reset_E3_Dir:
  705.         ld a,(Enemy3D)                  ;Load Direction into a
  706.         inc a                           ;Increase it
  707.         cp 2                            ;If it is 2
  708.         jp z,Make_E3Dir_UR              ;that means it was 1, d/l.. so switch
  709.         ld a,1                          ;Otherwise, it was u/r, so switch
  710.         ld (Enemy3D),a                  ;Load 1 into Direction
  711.         jp M_E_DownLeft                 ;Goto DownLeft Movement
  712.  
  713. Make_E3Dir_UR:
  714.         xor a                          ;Make a be = to 0
  715.         ld (Enemy3D),a                 ;Make that the direction
  716.         jp M_E_UpRight                 ;Move Up/Right
  717.  
  718. ;----------------------
  719. ;|End of Game Routines
  720. ;----------------------
  721. EndOfGame:
  722.   ld hl,DiesStr                ;String Name in HL
  723.  
  724. Message:    
  725.   push hl                               ;Pushes it
  726.   call Wee                              ;Scrolls
  727.   ld hl,$404                ;Loads Coords
  728.   ld (_curRow),hl                       ;Into Cursor Row
  729.   pop hl                                ;Pops the String
  730.   call _puts                ;Displays it
  731.   call _getkey                ;Waits for a key
  732.   call _clrLCD                          ;Returns from Prog
  733.   jr GameAllDone                        ;Game All Done, Check for Score, etc.
  734.  
  735. Wee:
  736.   ld a,64
  737. Byee:
  738.    ld hl,$FC10
  739.    ld de,$FC00
  740.    ld bc,$3F0
  741.    ldir
  742.    halt
  743.    halt
  744.    dec a
  745.    jr nz,Byee
  746.    ret
  747.  
  748. GameAllDone:                ;we're working on score
  749.     call UpdateScore
  750.     ld hl,(Score)           ;Score into HL
  751.     ex de,hl                ;We want your score in de
  752.     ld hl,(HighScore)       ;get the high score
  753.     or a                    ;clear carry flag
  754.     sbc hl,de               ;because this subtraction includes the carry flag
  755.     ret nc                  ;but it sets the carry flag if subtraction went over
  756.                             ;if high is higher, go all the way back to start
  757.     ex de,hl                ;now put _your_ score in hl, it was in de
  758.     ld (HighScore),hl       ;and put in new high score
  759.     ld hl,HighScoreName     ;this is used later
  760.     jr HighScoreTime        ;and go to enter the initials
  761.  
  762. UpdateScore:
  763.     ld hl,(Score)          ;now we get score
  764.     ld de,StringPlace+4     ;start of unpacking
  765.     ld b,5                  ;5 digits
  766. UpdateScore2:
  767.     call UNPACK_HL          ;divide hl by 10 and a contains remainder
  768.     add a,'0'               ;asciiize it
  769.     ld (de),a               ;put it in
  770.     dec de                  ;next digit place to load
  771.     djnz UpdateScore2       ;keep going
  772.     ret
  773.  
  774. ;-----------------
  775. ;enters the high scores
  776. HighScoreTime:
  777.     push hl                 ;saves the table to enter initials
  778.     call _clrLCD            ;first we clear the screen, dum, de, dum
  779.     ld hl,$0500             ;this is place for text
  780.     ld (_curRow),hl         ;load it in
  781.     ld hl,HighScoreStr      ;High Score!
  782.     call _puts              ;put string
  783.     ld hl,$0801             ;place for first initial
  784.     ld (_curRow),hl         ;load it
  785.     ld hl,StringPlace       ;this has your previous high score, from UpdateScore
  786.     call _puts              ;put that score
  787.     ld b,3                  ;3 initials as counter
  788.     ld hl,$0903             ;place to put first initial
  789.     ld (_curRow),hl         ;right there
  790.     pop hl                  ;now this is the place to store initials, from before
  791. InputLoop:
  792.     push bc                 ;save the counter
  793.     push hl                 ;save place to store initials
  794.     ld a,$DF                ;this is ti-ascii for the cursor
  795.     call _putc              ;put the cursor
  796.     ld hl,_curCol           ;this is the after putting the cursor
  797.     dec (hl)                ;put it back to where the cursor is
  798. KeyLoop:
  799.     call GET_KEY            ;gets the key
  800.     ld c,a                  ;get table value from InputTable
  801.     ld b,0                  ;
  802.     ld hl,InputTable
  803.     add hl,bc               ;by adding the keyvalue to InputTable
  804.     ld a,(hl)               ;and get the value
  805.     or a                    ;if it is zero
  806.     jr z,KeyLoop            ;we still need a key
  807.     pop hl                  ;get the initial address back
  808.     ld (hl),a               ;and load the first initial
  809.     inc hl                  ;and move to the next initial
  810.     call _putc              ;put that initial
  811.     pop bc                  ;counter...
  812.     djnz InputLoop          ;and get all three
  813.     ld de,$FFFF             ;or not, at which point we set up a delay
  814. LoopWait:
  815.     dec de                  ;you've seen this before
  816.     ld a,d
  817.     or e
  818.     jr nz,LoopWait
  819.     ret                     ;and all done, so go back to intro screen
  820.  
  821. ;----------------------
  822. ;|Screen Setups
  823. ;----------------------
  824.  
  825. ScreenSetup:
  826.     call GraphBufClear        ;Clear GraphBuffer [so ILine doesn't mess up]
  827.     call ScreenBox            ;Draws a box around the screen
  828.     ld b,85                ;Set coordinates for line
  829.     ld c,0                ;These coordinates specify
  830.     ld d,85                ;the line that seperates
  831.     ld e,64                ;the game screen from the stats screen
  832.         ld h,1                          ;h=1 is to let it draw points, not erase or xor
  833.         call _ILine                     ;This tells the calc to draw the line
  834.     ld b,86                ;Setting coordinates for another line
  835.        ld c,48                ;this line is the line under
  836.         ld d,128                        ;the "Poke v 1.0" title
  837.        ld e,48                ;setting coords to draw it
  838.       ld h,1                ;h = 1 so it would draw
  839.       call  _ILine            ;Draw the line!
  840.     ld hl,2*256+90            ;Setting Col = 90, Row = 2
  841.     ld (_penCol),hl            ;Putting that into PenCol
  842.     ld hl,PokeStr            ;Loading string into HL 
  843.         call _vputs                     ;Display it! Small text, "Poke v 1.0"
  844.     ld hl,9*256+95            ;Sets Coords into HL
  845.     ld (_penCol),hl            ;Sets it into PenCol
  846.     ld hl,ByMeStr            ;String name into HL
  847.         call _vputs                     ;Display, small size font [By: AE]
  848.     ld hl,20*256+88            ;Sets Coords agian
  849.     ld (_penCol),hl            ;Into PenCol
  850.     ld hl,LiveStr            ;String name into HL
  851.         call _vputs                     ;Display it! [Lvs:]
  852.     ld hl,27*256+88            ;Sets Coords again
  853.     ld (_penCol),hl            ;Load HL into PenCol
  854.     ld hl,ScorStr            ;Load string name into HL
  855.         call _vputs                     ;Display it! [Scr:]
  856.     ld hl,41*256+88            ;Sets Coords again
  857.     ld (_penCol),hl            ;Load into HL
  858.     ld hl,HScrStr            ;Load String Name into HL
  859.         call _vputs                     ;Display it! [High Scr:]
  860.         ;---------------------Variable Setup---------------------
  861.     ld a,54                ;54 into A
  862.     ld (ShipY),a            ;A into Ship's Y Coord
  863.     ld a,30                ;Loads 30 into A
  864.     ld (EnemyY),a            ;Loads A into EnemyY
  865.         xor a                           ;Loads 0 into A
  866.     ld (TargetD),a            ;Loads A into Target Direction
  867.     ld (EnemyD),a            ;Loads A into Enemy Direction
  868.         ld (Enemy2D),a                  ;Loads A into Enemy 2 Direction
  869.         ld (Enemy3D),a                  ;Loads A into Enemy 3 Direction
  870.         ld (Hits),a                     ;Number of hits = 0
  871.         ld a,40                         ;Loads 40 into A
  872.         ld (Enemy2Y),a                  ;Loads A into Enemy2Y
  873.         ld (Enemy3Y),a                  ;Loads A into Enemy3Y
  874.         ld a,65                         ;Loads 65 into A
  875.         ld (Enemy2X),a                  ;A into Enemy2X
  876.         ld a,12
  877.         ld (Enemy3X),a
  878.     ld a,2                ;Loads 2 into A
  879.     ld (TargetY),a            ;Loads A into Target Y
  880.     ld a,43                ;43 into A
  881.     ld (EnemyX),a            ;A into EnemyX
  882.     ld (ShipX),a            ;A into ShipX
  883.     ld (TargetX),a            ;A into TargetX
  884.         ;-----------------Finish Initializing----------------
  885.         ld hl,27*256+105                ;Set Coords into HL
  886.     ld (_penCol),hl            ;Loads HL into PenCol
  887.     ld hl,(Score)            ;Variable into HL
  888.         call DispHL                     ;Display HL
  889.         ld hl,20*256+105                ;Set Coords into HL
  890.     ld (_penCol),hl            ;Loads HL into PenCol
  891.     ld a,(Lives)            ;Variable into A
  892.         call DispA                      ;Display A
  893.     call DispTarget            ;Display Target
  894.     call DispEnemy            ;Display Enemy
  895.         ret                             ;Return
  896.  
  897. NewVarInit:
  898.         ld a,5                ;Loads 5 into A
  899.     ld (Lives),a            ;Loads A into Lives
  900.         ld a,1
  901.         ld (Level),a
  902.     ld hl,0                ;Load 0 into HL
  903.     ld (Score),hl            ;Load HL into Score
  904.         ret
  905.  
  906. ScreenBox:                              ;Draws a box around the screen
  907.     ld b,0                ;Sets Coordinates
  908.     ld c,0                ;Setting Coords
  909.     ld d,0                ;Setting Coords
  910.     ld e,64                ;Setting Coords
  911.     ld h,1                ;h = 1 for shading
  912.         call _ILine                     ;Draw a line!
  913.         ld b,126                        ;Set Coord for line
  914.     ld c,0                ;Set Coords
  915.         ld d,126                        ;Set Coords
  916.     ld e,64                ;Set Coords
  917.     ld h,1                ;H = 1 for shading
  918.         call _ILine                     ;Draw the Line!
  919.     ld b,0                ;Setting Coords
  920.        ld c,63                ;Set Coords
  921.         ld d,128                        ;Set Coords
  922.        ld e,63                ;Set Coords
  923.       ld h,1                ;H = 1 for Shading [2 = Unshade, 3 = XOR]
  924.       call  _ILine            ;Draw the Line!
  925.     ld b,0                ;Setting Coords
  926.        ld c,1                ;Set Coords
  927.         ld d,128                        ;Set Coords
  928.        ld e,1                ;Set Coords
  929.       ld h,1                ;H = 1 for Shading
  930.       call  _ILine            ;Draw the line!
  931.         ret                             ;Return!
  932.  
  933. ;-----------------------------------------------------------------------------
  934. ;|High Score Stuff, Obtained from Kollums 2.0, By: Alan Bailey
  935. ;------------------------------------------------------------------------------
  936.  
  937. DispHighScore:               ;now it works on the information
  938.     ld hl,48*256+88         ;Loads Coords for text
  939.     ld (_penCol),hl         ;Into PenCol
  940.     ld hl,HighScore          ;High Score is our wanted Variable
  941.     push hl                  ;Hides it in stack
  942.     call LD_HL_MHL           ;gets the high score from mem
  943.     ld de,StringPlace+4      ;sets de for putting score
  944.     ld b,5                   ;5 characters in score
  945. UpdateHigh:
  946.     call UNPACK_HL           ;divides hl by 10 and has the remainder in a,
  947.     add a,'0'                ;make digit ascii
  948.     ld (de),a                ;load it into stringplace, ready for displaying
  949.     dec de                   ;next spot to load
  950.     djnz UpdateHigh          ;and go to UpdateHigh for next 4 characters
  951.     ld hl,StringPlace        ;now it contains the score, asciiized and zero-terminated
  952.     call _vputs              ;display the score
  953.     ld a,(_penCol)           ;get the Col from mem
  954.     ld b,4                   ;increase it
  955.     add a,b                  ;like that
  956.     ld (_penCol),a           ;and load it back
  957.     pop hl                   ;this is the address to high score
  958.     inc hl                   ;right after it is Initials, so this increments to that
  959.     inc hl                   ;increment again
  960.     call _vputs              ;and put the Initials of High Scorer
  961.     ret                      ;Return from call
  962.  
  963. ;------------------------------
  964. ;|Misc. Routines
  965. ;------------------------------
  966.  
  967. GraphBufClear:                     ;Clears the graph buffer, so _ILine doesn't mess up
  968.     ld hl,GRAPH_MEM                 ;GraphMem into HL
  969.     ld (hl),0                    ;Loads 0 into it
  970.     ld de,GRAPH_MEM+1            ;Loads GraphMem+1 into de
  971.         ld bc,1024                      ;Loads the 1024 into bc
  972.         ldir                            ;Draws on screen
  973.     set graphdraw,(iy+graphflags)    ;Sets Flag
  974.         ret                             ;Return from Call
  975.  
  976. DispA:                    ;Routine to Display A [By: Matthew Shepcar]
  977.  ld l,a                    ;Loads a into l
  978.  ld h,0                    ;0 into H
  979. DispHL:                    ;Displays HL [By: Matthew Shepcar]
  980.  xor a                    ;Loads 0 into A
  981.  ld de,-1                               ;Loads -1 into DE
  982.  ld (_curRow),de                        ;Loads de into CurRow
  983.  call 4A33h                             ;Calls 4A33h
  984.  dec hl                    ;Decrease it
  985.  jp _vputs                              ;Put on screen and return
  986.  
  987. Delay:                    ;Delay Loop, converted from Dan Eble's 85 Bounce
  988.     PUSH AF                ;hide current AF value
  989.     PUSH BC                ;hide current BC value 
  990.         LD BC,$1000                     ;dlay length->bc
  991. delayLoop:
  992.     DEC BC                ;bc-1->bc
  993.     LD A, B                ;Loads b into a
  994.         OR C                            ;Checks if c=0
  995.         JR NZ, delayLoop                ;if not, continue loop 
  996.     POP BC                ;unhide current BC value
  997.     POP AF                ;unhide current AF value 
  998.         ret                             ;Return to Call
  999.  
  1000.  
  1001. ;-----------------------------
  1002. ;|Sprites
  1003. ;-----------------------------
  1004.  
  1005. PlayerShip:
  1006.     .db %00000000
  1007.     .db %00000000
  1008.     .db %00000000
  1009.     .db %00000000
  1010.     .db %11111111
  1011.     .db %11010101
  1012.     .db %10101011
  1013.     .db %11111111
  1014.  
  1015. EnemyShip:
  1016.     .db %00000000
  1017.     .db %00000000
  1018.     .db %00000000
  1019.     .db %11111111
  1020.     .db %11111111
  1021.     .db %00000000
  1022.     .db %00000000
  1023.     .db %00000000
  1024.  
  1025. Enemy2Ship:
  1026.         .db %00000000
  1027.         .db %00000000
  1028.         .db %00000000
  1029.         .db %10101010
  1030.         .db %11111111
  1031.         .db %01010101
  1032.         .db %00000000
  1033.         .db %00000000
  1034.  
  1035. Enemy3Ship:
  1036.         .db %00000000
  1037.         .db %00000000
  1038.         .db %00000000
  1039.         .db %10101010
  1040.         .db %10000001
  1041.         .db %01010101
  1042.         .db %00000000
  1043.         .db %00000000
  1044.  
  1045.  
  1046. TargetShip:
  1047.     .db %11111111
  1048.     .db %10011001
  1049.     .db %10011001
  1050.     .db %11111111
  1051.     .db %00000000
  1052.     .db %00000000
  1053.     .db %00000000
  1054.     .db %00000000
  1055.  
  1056. FireBall:
  1057.     .db %00000000
  1058.     .db %00000000
  1059.     .db %00011000
  1060.     .db %00111100
  1061.     .db %01111110
  1062.     .db %00111100
  1063.     .db %00011000
  1064.     .db %00000000
  1065.  
  1066.  
  1067. ;----------------------
  1068. ;|Sprite Routine [XOR]
  1069. ;----------------------
  1070. ;------------------------------------------------------
  1071. ;|This Routine was converted by AVD from Movax's 83
  1072. ;|Special thanks to ScaBBy for making it XOR Routine!
  1073. ;------------------------------------------------------
  1074.  
  1075. ;hl = image
  1076. ;a = x coord
  1077. ;e = y coord
  1078.  
  1079. PutSprite:
  1080.        push    hl              ; Save sprite address
  1081.  
  1082. ;████   Calculate the address in graphbuf   ████
  1083.  
  1084.         ld      hl,0            ; Do y*12
  1085.         ld      d,0
  1086.     ex    de,hl
  1087.     add    hl,hl
  1088.     add    hl,hl
  1089.     add    hl,hl
  1090.     add    hl,hl
  1091.  
  1092.         ld      d,0             ; Do x/8
  1093.         ld      e,a
  1094.         srl     e
  1095.         srl     e
  1096.         srl     e
  1097.         add     hl,de
  1098.  
  1099.         ld      de,$FC00
  1100.         add     hl,de           ; Add address to graphbuf
  1101.  
  1102.         ld      b,00000111b     ; Get the remainder of x/8
  1103.         and     b
  1104.         cp    0               ; Is this sprite aligned to 8*n,y?
  1105.         jp      z,ALIGN
  1106.  
  1107.  
  1108. ;████   Non aligned sprite blit starts here   ████
  1109.  
  1110.         pop     ix              ; ix->sprite
  1111.         ld      d,a             ; d=how many bits to shift each line
  1112.  
  1113.         ld      e,8             ; Line loop
  1114. LILOP:  ld      b,(ix+0)        ; Get sprite data
  1115.  
  1116.         ld      c,0             ; Shift loop
  1117.         push    de
  1118. SHLOP:  srl     b
  1119.         rr      c
  1120.         dec     d
  1121.         jp      nz,SHLOP
  1122.         pop     de
  1123.  
  1124.         ld      a,b             ; Write line to graphbuf
  1125.         xor     (hl)
  1126.         ld      (hl),a
  1127.         inc     hl
  1128.         ld      a,c
  1129.         xor     (hl)
  1130.         ld      (hl),a
  1131.  
  1132.         ld      bc,15           ; Calculate next line address
  1133.         add     hl,bc
  1134.         inc     ix              ; Inc spritepointer
  1135.  
  1136.         dec     e
  1137.         jp      nz,LILOP        ; Next line
  1138.  
  1139.         jp      DONE1
  1140.  
  1141.  
  1142. ;████   Aligned sprite blit starts here   ████
  1143.  
  1144. ALIGN:                          ; Blit an aligned sprite to graphbuf
  1145.         pop     de              ; de->sprite
  1146.         ld      b,8
  1147. ALOP1:  ld      a,(de)
  1148.         xor      (hl)            ; xor=erase/blit
  1149.         ld      (hl),a
  1150.         inc     de
  1151.         push    bc
  1152.         ld      bc,16
  1153.         add     hl,bc
  1154.         pop     bc
  1155.         djnz    ALOP1
  1156.  
  1157. DONE1:
  1158.         ret
  1159. ;▄████████████▄ SPRITE ▄███████████████████████████████████████████████████████
  1160.  
  1161.  
  1162. ;------------------------------------
  1163. ;|Begin Data [Text, Variables, Etc.]
  1164. ;------------------------------------
  1165.  
  1166. Title:    .db    "Poke 1.0 - By: Ahmed El-Helw",0
  1167. PokeStr:    .db    "Poke 1.0",0
  1168. ByMeStr:    .db    "By: AE  ",0
  1169. LiveStr:    .db    "Lvs:",0
  1170. ScorStr:    .db    "Scr:",0
  1171. HScrStr:    .db    "High Scr:",0
  1172. DiesStr:    .db    "- Game Over -",0
  1173. BlankStr:       .db     "             ",0
  1174. HighScoreStr:   .db     "High Score!",0
  1175.  
  1176. ShipX:        .db    0            ;Ship's X Coord
  1177. ShipY:        .db    0            ;Ship's Y Coord [Constant]
  1178. FireX:        .db    0            ;Weapon's X Coord
  1179. FireY:        .db    0            ;Weapon's Y Coord
  1180. FireZ:        .db    0            ;Weapon Fired or No?
  1181. TargetX:        .db     0                       ;Target's X Coord
  1182. TargetY:        .db     0                       ;Target's Y Coord
  1183. TargetD:        .db     0                       ;Target's Direction
  1184. EnemyX:        .db    0            ;Enemy's X Coord
  1185. EnemyY:        .db    0            ;Enemy's Y Coord
  1186. EnemyD:        .db    0            ;Enemy's Direction
  1187. Enemy2X:        .db     0
  1188. Enemy2Y:        .db     0
  1189. Enemy2D:        .db     0
  1190. Enemy3X:        .db     0
  1191. Enemy3Y:        .db     0
  1192. Enemy3D:        .db     0
  1193. Lives:        .db    0            ;Lives Remaining
  1194. Hits:           .db     0                       ;The Number of Hits
  1195. Level:          .db     0                       ;The Level you are on
  1196.  
  1197. Temp:           .db     0,0                     ;Temporary Variable
  1198. Score:        .db    0,0            ;Current Score
  1199.  
  1200. HighScore:      .db $01,$00
  1201. HighScoreName:  .db 'A','R','E',$00 
  1202. StringPlace:    .db 0,0,0,0,0,0
  1203.  
  1204. ;This is the key table, takes the value from call GET_KEY
  1205. ;and converts it to this ascii character
  1206.  
  1207. InputTable:
  1208.     .db 0,0,0,0,0,0,0,0,0,0
  1209.     .db 'X','T','O','J','E',0,0
  1210.     .db ' ','W','S','N','I','D',0,0
  1211.     .db 'Z','V','R','M','H','C',0,0
  1212.     .db 'Y','U','Q','L','G','B',0,0,0,0
  1213.     .db 'P','K','F','A',0,0,0,0,0,0,0,0,0,0
  1214.  
  1215. .end
  1216. END
  1217.