home *** CD-ROM | disk | FTP | other *** search
- ;----------------------------------------------------------------------------
- ;|>Poke 1.1, By: Ahmed El-Helw
- ;|>Completed for the 82 on 2/28/1998
- ;|>You may use parts of this in your programs, as long as you give me and/or
- ;|>whoever created the routine credit.
- ;|>Note: Not all comments are accurate, due to the port from my 86 version
- ;------------------------------------------------------------------------------
-
- #INCLUDE "CRASH82.INC"
- .DB "Poke 1.1 By: AE ",0
-
- string = TEXT_MEM
-
-
- Initialize:
- ROM_CALL(CLEARLCD) ;Clear Screen
-
- StartGame:
- SET 7,(IY+$14)
- call NewVarInit ;Sets up variables
- call ScreenSetup ;Sets up the Screen
- call DispHighScore ;Displays the High Score
- call DispShip ;Displays the Ship
- jr GameLoop ;Goto GameLoop
-
- LevelUp:
- ROM_CALL(CLEARLCD)
- call BUFCLR
- ld a,(Level)
- inc a
- ld (Level),a
- call ScreenSetup
- call DispHighScore
- call DispShip
- call DispEnemyII
- ld a,(Level)
- cp 3
- call z,DispEnemyIII
-
- ;---------------------------
- ;|GetKey Loop and Movement
- ;---------------------------
-
- GameLoop:
- ld a,0ffh ;Reset keyport
- out (1),a ;Clear Port
- ld a,0feh ;Load desired port
- out (1),a ;Clear Keys
- in a,(1) ;Input Key
- cp 251 ;If key is right
- jp z,M_Right ;Goto Right
- cp 253 ;If key is left
- jp z,M_Left ;Goto Left
- ld a,0ffh ;Reset keyport
- out (1),a ;Clear Port
- ld a,0bfh ;Load desired port
- out (1),a ;Clear Keys
- in a,(1) ;Input Key
- cp 223 ;Is it 2nd
- jp z,Fire ;Fire if so
- cp 127 ;Is it Delete?
- call z,Pause ;Pause!
- cp 191 ;Is it Exit
- ret z ;Return if so
-
- NoKeyLoop:
- call MoveTarget ;Move the Target
- call MoveEnemy ;Move the Enemy
- call CheckEnemyHit ;See if you hit the enemy
-
- CheckDeath: ;Checks to see if you are dead
- ld a,(Lives) ;Lives into A
- or a ;Is it 0?
- jp z,EndOfGame ;Goto End Of Game
-
- ContinueNKL:
- call CheckFire ;Checks the FireBall
- ld a,(Level)
- cp 3
- jr z,GameLoop
- ld a,(Hits) ;Hits into A
- cp 15 ;Is it 15?
- jp z,LevelUp
- jr GameLoop ;Goto GameLoop
-
- M_Right: ;Move Right
- ld a,(ShipX) ;Ship X into A
- cp 49 ;Is it 74 [Line]
- jr z,GameLoop ;ReLoop, don't move
- cp 50 ;Is it 75 [Line]
- jr z,GameLoop ;ReLoop, don't move
- call DispShip ;Clear Ship
- ld a,(ShipX) ;Ship X back into A
- inc a ;Increment it
- inc a ;Increment it
- ld (ShipX),a ;A back into ShipX
- call DispShip ;RePut Ship
- call CR_GRBCopy
- jr NoKeyLoop ;Goto NoKeyLoop
-
- M_Left: ;Move Left
- ld a,(ShipX) ;Ship X into A
- cp 3 ;Is it 3 [Line]
- jr z,GameLoop ;ReLoop, don't move
- cp 4 ;Is it 4 [Line]
- jr z,GameLoop ;ReLoop, don't move
- call DispShip ;Clear Ship
- ld a,(ShipX) ;Ship X back into A
- dec a ;Decrement it
- dec a ;Decrement it
- ld (ShipX),a ;A back into ShipX
- call DispShip ;RePut Ship
- call CR_GRBCopy
- jr NoKeyLoop ;Goto NoKeyLoop
-
- DispShip: ;XORs the Ship Sprite on/off the screen
- ld a,(ShipY) ;Ship Y into A
- ld e,a ;A goes into E, E = Y Coord
- ld a,(ShipX) ;Ship X into A
- ld bc,PlayerShip ;Sprite name into HL
- call PutSprite ;XOR it!
- ret ;Return to call
-
- DispTarget: ;XORs the Target Sprite on/off the screen
- ld a,(TargetY) ;Target Y into A
- ld e,a ;A into E , E = Y Coord
- ld a,(TargetX) ;Target X Coord into A
- ld bc,TargetShip ;Sprite Name into HL
- call PutSprite ;XOR it!
- ret ;Return to Call
-
- DispEnemy: ;XORs the Enemy Sprite on/off the screen
- ld a,(EnemyY) ;Enemy Y into A
- ld e,a ;A goes into E, E = Y Coord
- ld a,(EnemyX) ;Enemy X into A
- ld bc,EnemyShip ;Sprite name into HL
- call PutSprite ;XOR it!
- ret ;Return to call
-
- DispEnemyII: ;XORs the Enemy Sprite on/off the screen
- ld a,(Enemy2Y) ;Enemy Y into A
- ld e,a ;A goes into E, E = Y Coord
- ld a,(Enemy2X) ;Enemy X into A
- ld bc,Enemy2Ship ;Sprite name into HL
- call PutSprite ;XOR it!
- ret ;Return to call
-
- DispEnemyIII: ;XORs the Enemy Sprite on/off the screen
- ld a,(Enemy3Y) ;Enemy Y into A
- ld e,a ;A goes into E, E = Y Coord
- ld a,(Enemy3X) ;Enemy X into A
- ld bc,Enemy3Ship ;Sprite name into HL
- call PutSprite ;XOR it!
- ret ;Return to call
-
- DispFire: ;XORs the Ship Sprite on/off the screen
- ld a,(FireY) ;Fire Y into A
- ld e,a ;A goes into E, E = Y Coord
- ld a,(FireX) ;Fire X into A
- ld bc,FireBall ;Sprite name into HL
- call PutSprite ;XOR it!
- ret ;Return to call
-
-
- Pause:
- call CR_KHAND
- ret
-
- ;----------------------
- ;|Fire Routine
- ;----------------------
-
- Fire:
- ld a,(FireZ) ;Loads FireZ into A
- or a ;If it is 0 [No Fire]
- jr z,NewFire ;Put a new fireball
- jp nz,NoKeyLoop ;NoKeyLoop otherwise
-
- NewFire: ;Creates new FireBall
- ld a,1 ;1 into A
- ld (FireZ),a ;A into FireZ
- ld a,(ShipX) ;Ship X into A
- ld (FireX),a ;Loads A into FireX
- ld a,(ShipY) ;ShipY into A
- ld (FireY),a ;A into FireY
- call DispFire ;Display FireBall
- jp NoKeyLoop ;Goto NoKeyLoop
-
- CheckFire:
- call Delay ;Creates a Short Delay
- ld a,(FireZ) ;FireZ into a
- or a ;If it is 0 [No Fire]
- ret z ;Return, no need to bother
- ld a,(FireY) ;FireY into A
- or a ;If it is 0
- jr z,CheckHit ;Check for Hit
- call DispFire ;Clear Fire
- ld a,(FireY) ;Fire Y into A again
- dec a ;Decrease it
- ld (FireY),a ;A into FireY
- call DispFire ;RePut Fire
- ret ;Return
-
- CheckHit: ;Checks if you hit target
- ld a,(FireX) ;Loads Fire X into A
- add a,8 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(TargetX) ;Loads TargetX into A
- cp b ;Compares a to b
- jp c,ContinueCheck ;Continue Checking if a>b
-
- MissHit:
- call DecScore
- call DecScore
- call DecScore
- call DecScore
- call DecScore
- ld hl,34*256+75 ;Load Coords into HL
- ld (CURSOR_X),hl ;Loads PenCol into HL
- ld hl,BlankStr ;Blank String into HL
- ROM_CALL(D_ZM_STR) ;Display it
- ld hl,27*256+75 ;Set Coords into HL
- ld (CURSOR_X),hl ;Loads HL into PenCol
- ld hl,(Score) ;Variable into HL
- call DispHL ;Display HL
- call ResetFire ;Reset the Fire Otherwise
- ret ;Return from Call
-
- DecScore:
- ld de,(Score)
- ld a,d
- or e
- ret z
- dec de
- ld (Score),de
- ret
-
- ContinueCheck:
- ld a,(TargetX) ;Target X into A
- add a,8 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(FireX) ;Fire X into A
- cp b ;Compare A to B
- jp c,HitTarget ;If b>a then you hit it
- jp MissHit
- ret ;Return to Call
-
- HitTarget:
- call ResetFire ;Reset the Fire
- ld hl,(Score) ;Load Score into HL
- ld bc,25 ;Loads 25 into bc
- add hl,bc ;Adds BC and HL
- ld (Score),hl ;Load HL back into Score
- ld hl,34*256+75 ;Load Coords into HL
- ld (CURSOR_X),hl ;Loads PenCol into HL
- ld hl,BlankStr ;Blank String into HL
- ROM_CALL(D_ZM_STR) ;Display it
- ld hl,27*256+75 ;Set Coords into HL
- ld (CURSOR_X),hl ;Loads HL into PenCol
- ld hl,(Score) ;Variable into HL
- call DispHL ;Display HL
- ld a,(Hits)
- inc a
- ld (Hits),a
- ret ;Return from Call
-
- ResetFire: ;Reset the Fire
- call DispFire ;Clears the Fire
- call CR_GRBCopy
- xor a ;Loads 0 into A
- ld (FireZ),a ;Reset FireZ
- ld (FireX),a ;Reset FireX
- ld (FireY),a ;Reset FireY
- ret ;Return from Call
-
- CheckEnemyHit:
- call Delay ;Creates a Short Delay
- ld a,(FireZ) ;FireZ into a
- or a ;If it is 0 [No Fire]
- ret z ;Return, no need to bother
- ld a,(FireY) ;FireY into A
- cp 30 ;Is it 30?
- jr z,CheckEHit ;Check for Hit
- ld a,(Level) ;Level # into A
- cp 1 ;Is it 1?
- jp nz,CheckE2Hit ;Check Enemy II Hit Otherwise
- jp DecFire
- ;Return
-
- CheckEHit: ;Checks if you hit target
- ld a,(FireX) ;Loads Fire X into A
- add a,8 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(EnemyX) ;Loads EnemyX into A
- cp b ;Compares a to b
- jp c,ContinueECheck ;Continue Checking if a>b
- ret ;Return from Call Otherwise
-
- ContinueECheck:
- ld a,(EnemyX) ;Enemy X into A
- add a,8 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(FireX) ;Fire X into A
- cp b ;Compare A to B
- jp c,HitEnemy ;If b>a then you hit it
- ret ;Return to Call Otherwise
-
- CheckE2Hit: ;Checks if you hit target 2
- ld a,(Level)
- cp 1
- jp z,DecFire
- ld a,(FireX) ;Loads Fire X into A
- add a,8 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(Enemy2X) ;Loads Enemy2X into A
- cp b ;Compares a to b
- jp c,ContinueE2Check ;Continue Checking if a>b
- jp CheckE3Hit
-
- DecFire:
- call DispFire
- ld a,(FireY)
- dec a
- ld (FireY),a
- call DispFire
- call CR_GRBCopy
- ret
-
- ContinueE2Check:
- ld a,(Enemy2X) ;Enemy 2X into A
- add a,8 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(FireX) ;Fire X into A
- cp b ;Compare A to B
- jp c,CheckE2Y ;If b>a then you hit it
- jp CheckE3Hit
-
- CheckE2Y:
- ld a,(FireY) ;Loads FireY into A
- add a,4 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(Enemy2Y) ;Loads Enemy Y into A
- cp b ;Compares a to b
- jp c,ContinueCheck2Y ;Continue Checking if a>b
- jp CheckE3Hit ;Missed Otherwise
-
- ContinueCheck2Y:
- ld a,(Enemy2Y) ;Enemy Y into A
- add a,4 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(FireY) ;Fire Y into A
- cp b ;Compare A to B
- jp c,HitEnemy2 ;If b>a then hit
- jp CheckE3Hit ;You missed otherwise
-
- CheckE3Hit: ;Checks if you hit target 3
- ld a,(Level)
- cp 3
- jp nz,DecFire
- ld a,(FireX) ;Loads Fire X into A
- add a,8 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(Enemy3X) ;Loads Enemy3X into A
- cp b ;Compares a to b
- jp c,ContinueE3Check ;Continue Checking if a>b
- jp DecFire
-
- ContinueE3Check:
- ld a,(Enemy3X) ;Enemy 3X into A
- add a,8 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(FireX) ;Fire X into A
- cp b ;Compare A to B
- jp c,CheckE3Y ;If b>a then you hit it
- jp DecFire ;Decrease Fire and Return otherwise
-
- CheckE3Y:
- ld a,(FireY) ;Loads FireY into A
- add a,4 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(Enemy3Y) ;Loads Enemy Y into A
- cp b ;Compares a to b
- jp c,ContinueCheck3Y ;Continue Checking if a>b
- jp DecFire ;Missed Otherwise
-
- ContinueCheck3Y:
- ld a,(Enemy3Y) ;Enemy Y into A
- add a,4 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(FireY) ;Fire Y into A
- cp b ;Compare A to B
- jp c,HitEnemy3 ;If b>a then hit
- jp DecFire ;You missed otherwise
-
-
- HitEnemy:
- call Delay ;Creates a short delay
- call DispFire ;Views the Fire
- ld a,(FireY) ;Loads Y into A
- inc a ;Increases It
- ld (FireY),a ;Back into A
- call DispFire ;Redisplays
- call CR_GRBCopy
- ld a,(FireY) ;Loads Y into A
- cp 54 ;Is it 54?
- jp nz,HitEnemy ;If not, reloop
- jr CheckYouHit ;Check if you are hit
-
- CheckYouHit: ;Checks if you die
- ld a,(FireX) ;Loads Fire X into A
- add a,6 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(ShipX) ;Loads ShipX into A
- cp b ;Compares a to b
- jp c,ContinueUCheck ;Continue Checking if a>b
- call ResetFire ;Reset Fire
- ret ;Return from Call Otherwise
-
- ContinueUCheck:
- ld a,(EnemyX) ;Enemy X into A
- add a,6 ;Add 6 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(ShipX) ;Fire X into A
- cp b ;Compare A to B
- jp c,HitYou ;If b>a then you hit it
- call ResetFire ;ResetFire
- ret ;Return to Call Otherwise
-
- HitEnemy2:
- call Delay ;Creates a short delay
- call DispFire ;Views the Fire
- ld a,(FireY) ;Loads Y into A
- inc a ;Increases It
- ld (FireY),a ;Back into A
- call DispFire ;Redisplays
- call CR_GRBCopy
- ld a,(FireY) ;Loads Y into A
- cp 54 ;Is it 54?
- jp nz,HitEnemy2 ;If not, reloop
- jr CheckYou2Hit ;Check if you are hit
-
- CheckYou2Hit: ;Checks if you die
- ld a,(FireX) ;Loads Fire X into A
- add a,6 ;Add 6 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(ShipX) ;Loads ShipX into A
- cp b ;Compares a to b
- jp c,ContinueU2Check ;Continue Checking if a>b
- call ResetFire ;Reset Fire
- ret ;Return from Call Otherwise
-
- ContinueU2Check:
- ld a,(Enemy2X) ;Enemy X into A
- add a,6 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(ShipX) ;Fire X into A
- cp b ;Compare A to B
- jp c,HitYou ;If b>a then you hit it
- call ResetFire ;ResetFire
- ret ;Return to Call Otherwise
-
- HitYou:
- call DecScore
- call DecScore
- call DecScore
- call DecScore
- call DecScore
- call DecScore
- call DecScore
- call DecScore
- call DecScore
- call DecScore
- call DecScore
- call ResetFire
- ld a,(Lives) ;Load lives into A
- dec a ;decrease A
- ld (Lives),a ;Load a back
- ld hl,20*256+75 ;Set Coords into HL
- ld (CURSOR_X),hl ;Loads HL into PenCol
- ld hl,BlankStr ;BlankStr into HL
- ROM_CALL(D_ZM_STR) ;Display it!
- ld hl,20*256+75 ;Set Coords into HL
- ld (CURSOR_X),hl ;Loads HL into PenCol
- ld a,(Lives) ;Variable into A
- call DispA ;Display A
- ld hl,34*256+75 ;Load Coords into HL
- ld (CURSOR_X),hl ;Loads PenCol into HL
- ld hl,BlankStr ;Blank String into HL
- ROM_CALL(D_ZM_STR) ;Display it
- ld hl,27*256+75 ;Set Coords into HL
- ld (CURSOR_X),hl ;Loads HL into PenCol
- ld hl,(Score) ;Variable into HL
- call DispHL ;Display HL
- ret ;Return!
-
- HitEnemy3:
- call Delay ;Creates a short delay
- call DispFire ;Views the Fire
- ld a,(FireY) ;Loads Y into A
- inc a ;Increases It
- ld (FireY),a ;Back into A
- call DispFire ;Redisplays
- call CR_GRBCopy
- ld a,(FireY) ;Loads Y into A
- cp 54 ;Is it 54?
- jp nz,HitEnemy3 ;If not, reloop
- jp CheckYou2Hit ;Check if you are hit
-
- CheckYou3Hit: ;Checks if you die
- ld a,(FireX) ;Loads Fire X into A
- add a,6 ;Add 6 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(ShipX) ;Loads ShipX into A
- cp b ;Compares a to b
- jp c,ContinueU3Check ;Continue Checking if a>b
- call ResetFire ;Reset Fire
- ret ;Return from Call Otherwise
-
- ContinueU3Check:
- ld a,(Enemy3X) ;Enemy X into A
- add a,6 ;Add 8 to A [End of Sprite]
- ld b,a ;Loads A into B
- ld a,(ShipX) ;Fire X into A
- cp b ;Compare A to B
- jp c,HitYou ;If b>a then you hit it
- call ResetFire ;ResetFire
- ret ;Return to Call Otherwise
-
- ;--------------------------------
- ;|Target Routine, to Move Target
- ;--------------------------------
-
- MoveTarget:
- call DispTarget ;XOR the Target Ship on the Screen
- ld a,(TargetD) ;Target Direction into A
- or a ;Is it 0
- jr z,M_T_Right ;Move Target Right
- jr nz,M_T_Left ;Otherwise Move Left
-
- M_T_Right:
- ld a,(TargetX) ;Target X into A
- cp 49 ;Is it 75
- jr z,ResetTargetMove ;Reset Target to Move Other Direction
- cp 50 ;Is it 74
- jr z,ResetTargetMove ;Reset Target to Move Other Direction
- inc a ;Increase it again
- ld (TargetX),a ;Into TargetX
- call DispTarget ;Replace Target on Screen
- call CR_GRBCopy
- ret ;Return
-
- M_T_Left:
- ld a,(TargetX) ;Target X into A
- cp 3 ;Is it 3
- jr z,ResetTargetMove ;Reset Target to Move Other Direction
- cp 4 ;Is it 4
- jr z,ResetTargetMove ;Reset Target to Move Other Direction
- dec a ;Decrease it
- ld (TargetX),a ;Into TargetX
- call DispTarget ;Replace Target on Screen
- call CR_GRBCopy
- ret ;Return
-
- ResetTargetMove:
- ld a,(TargetD) ;Load Target Direction into A
- or a ;Is it 0?
- jr z,ResetLeft ;Reset it to go left!
- xor a ;Loads 0 into a
- ld (TargetD),a ;Loads A into Direction
- jr M_T_Right ;Move Right
-
- ResetLeft:
- ld a,1 ;Load 1 into A
- ld (TargetD),a ;Loads A into Target Direction
- jr M_T_Left ;Move Left
-
- ;--------------------------------
- ;|Enemy Routine, to Move Enemy
- ;--------------------------------
-
- MoveEnemy:
- ld a,(Level)
- cp 1
- jp z,Level1Enemy
- cp 2
- jp z,Level2Enemy
- jp nz,Level3Enemy
-
- Level3Enemy:
- call Level1Enemy
- call Level2Enemy
- call DispEnemyIII
- ld a,(Enemy3D)
- or a
- jp nz,M_E_DownLeft
-
- M_E_UpRight:
- ld a,(Enemy3Y) ;Y Coordinate into A
- cp 12 ;Is it 12?
- jp z,Reset_E3_Dir ;Change the Direction if so
- ld a,(Enemy3Y) ;Y Coord into A
- dec a ;Decrease it [Going Up]
- ld (Enemy3Y),a ;A into Enemy 2 Y
- ld a,(Enemy3X) ;Load Enemy 2 X into A
- inc a ;Increment it
- ld (Enemy3X),a ;Loads A into Enemy2X
- call DispEnemyIII ;Display Enemy III
- call CR_GRBCopy
- ret ;Return
-
- Level2Enemy:
- call Level1Enemy ;Call Level1 Enemy, so it will move
- call DispEnemyII ;XOR Enemy II
- ld a,(Enemy2D)
- or a ;Is it 0?
- jp nz,M_E_DownRight ;No?? Then move down/right
-
- M_E_UpLeft:
- ld a,(Enemy2Y) ;Y Coordinate into A
- cp 12 ;Is it 12?
- jp z,Reset_E2_Dir ;Change the Direction if so
- ld a,(Enemy2Y) ;Y Coord into A
- dec a ;Decrease it [Going Up]
- ld (Enemy2Y),a ;A into Enemy 2 Y
- ld a,(Enemy2X) ;Load Enemy 2 X into A
- dec a ;Decrement it
- ld (Enemy2X),a ;Loads A into Enemy2X
- call DispEnemyII ;Display Enemy II
- call CR_GRBCopy
- ret ;Return
-
- M_E_DownLeft:
- ld a,(Enemy3Y) ;Y Coordinate into A
- cp 40 ;Is it 46?
- jp z,Reset_E3_Dir ;Change the Direction if so
- ld a,(Enemy3Y) ;Y Coord into A
- inc a ;Increase it [Going Down]
- ld (Enemy3Y),a ;A into Enemy 2 Y
- ld a,(Enemy3X) ;Load Enemy 2 X into A
- dec a ;Increment it
- ld (Enemy3X),a ;Loads A into Enemy2X
- call DispEnemyIII ;Display Enemy III
- call CR_GRBCopy
- ret ;Return
-
-
- M_E_DownRight:
- ld a,(Enemy2Y) ;Y Coordinate into A
- cp 46 ;Is it 46?
- jp z,Reset_E2_Dir ;Change the Direction if so
- ld a,(Enemy2Y) ;Y Coord into A
- inc a ;Increase it [Going Down]
- ld (Enemy2Y),a ;A into Enemy 2 Y
- ld a,(Enemy2X) ;Load Enemy 2 X into A
- inc a ;Increment it
- ld (Enemy2X),a ;Loads A into Enemy2X
- call DispEnemyII ;Display Enemy II
- call CR_GRBCopy
- ret ;Return
-
- Level1Enemy:
- call DispEnemy ;XOR the Enemy Ship on the Screen
- ld a,(EnemyD) ;Enemy Direction into A
- or a ;Is it 0
- jr z,M_E_Right ;Move Target Right
- jr nz,M_E_Left ;Otherwise Move Left
-
- M_E_Right:
- ld a,(EnemyX) ;Enemy X into A
- cp 49 ;Is it 75
- jr z,ResetEnemyMove ;Reset Target to Move Other Direction
- cp 50 ;Is it 74
- jr z,ResetEnemyMove ;Reset Target to Move Other Direction
- inc a ;Increase it again
- inc a ;Increase it again
- ld (EnemyX),a ;Into EnemyX
- call DispEnemy ;Replace Enemy on Screen
- call CR_GRBCopy
- ret ;Return
-
- M_E_Left:
- ld a,(EnemyX) ;Enemy X into A
- cp 3 ;Is it 3
- jr z,ResetEnemyMove ;Reset Enemy to Move Other Direction
- cp 4 ;Is it 4
- jr z,ResetEnemyMove ;Reset Enemy to Move Other Direction
- dec a ;Decrease it
- dec a ;Decrease it again
- ld (EnemyX),a ;Into EnemyX
- call DispEnemy ;Replace Enemy on Screen
- call CR_GRBCopy
- ret ;Return
-
- ResetEnemyMove:
- ld a,(EnemyD) ;Load Enemy Direction into A
- or a ;Is it 0?
- jr z,ResetELeft ;Reset it to go left!
- xor a ;Loads 0 into a
- ld (EnemyD),a ;Loads A into Direction
- jr M_E_Right ;Move Right
-
- ResetELeft:
- ld a,1 ;Load 1 into A
- ld (EnemyD),a ;Loads A into Target Direction
- jr M_E_Left ;Move Left
-
- Reset_E2_Dir:
- ld a,(Enemy2D) ;Load Direction into a
- inc a ;Increase it
- cp 2 ;If it is 2
- jp z,Make_E2Dir_UL ;that means it was 1, d/r.. so switch
- ld a,1 ;Otherwise, it was u/l, so switch
- ld (Enemy2D),a ;Load 1 into Direction
- jp M_E_DownRight ;Goto DownRight Movement
-
- Make_E2Dir_UL:
- xor a ;Make a be = to 0
- ld (Enemy2D),a ;Make that the direction
- jp M_E_UpLeft ;Move Up/Left
-
- Reset_E3_Dir:
- ld a,(Enemy3D) ;Load Direction into a
- inc a ;Increase it
- cp 2 ;If it is 2
- jp z,Make_E3Dir_UR ;that means it was 1, d/l.. so switch
- ld a,1 ;Otherwise, it was u/r, so switch
- ld (Enemy3D),a ;Load 1 into Direction
- jp M_E_DownLeft ;Goto DownLeft Movement
-
- Make_E3Dir_UR:
- xor a ;Make a be = to 0
- ld (Enemy3D),a ;Make that the direction
- jp M_E_UpRight ;Move Up/Right
-
- ;----------------------
- ;|End of Game Routines
- ;----------------------
- EndOfGame:
- ROM_CALL(CLEARLCD) ;Returns from Prog
- RES 7,(IY+$14)
-
- finish:
- ld hl,(Score) ;final score
- ld de,(HighScore) ;load high score
- call CP_HL_DE ;compare score w/ hi score
- jp nc,hisco ;if score is more
- ;or equal
- ret
-
- ; Input routine - made by Jimmy Mσrdell 97-03-05
- ; Reads a sentence entered from the keyboard. Only uppercase letters
- ; and space are allowed. Left arrowkey = backspace.
- ;
- ; When calling, HL should point to where the string should be stored
- ; and A should hold the maximum length of the string. Be sure there
- ; are enough space (A+1) to store the nullterminated string at HL!
- ; ($800C) should hold the screen position where the string starts.
- ;
- ; This input routine will also have a flashing cursor. If you don't like
- ; it, remove all rows where the explanation starts with a *.
- ;
- ; IMPORTANT: The input must NOT wrap to a new row! Then it will not work
- ; properly. The last char on a row should not be used either (if cursorcol=0
- ; when calling, the maximum char length is 20). If you have a cursor, the
- ; two last chars should not be used (max length 19 if the screen location
- ; starts to the far left).
- ;
- ; The routine requires one temporary variable, noLet.
-
- ; largely indented stuff added by Adamman
-
- hisco:
- ROM_CALL(CLEARLCD)
- ld hl,(Score)
- ld (HighScore),hl
- ld hl,0
- ld (CURSOR_X),hl
- ld hl,HiScr
- ROM_CALL(D_ZM_STR)
- ld hl,0*256+79
- ld (CURSOR_X),hl
- ld hl,(Score)
- call DispHL
- ld de, $0504 ;initials entered at 5,4
- ld ($800C), de ;load location
- ld hl,htext+12 ;hl points to initials
- ld a,3 ;max chars = 3
- call INPUT
- ret
-
- INPUT:
- ; push bc
- ; push de
- ; push hl
- ; ei
- ; set 2,(iy+12) ; * Turn cursor blinking on (interrupts must be enabled)
- ld (noLet),a ; Store the maximum lenght of the string
- ld e,0 ; E = numbers of letters written so far
- WaK:
- ; ld a,32
- ; ld ($800E),a ; * Set "character under cursor" to space
- push hl ; Save HL since GET_KEY destroys it's content
- ld a, 217
- ROM_CALL(TX_CHARPUT)
- ld hl, $800D
- dec (hl)
- call GET_KEY ;get key press
- cp G_MODE
- jr z,exit_last
- cp $02 ; $02 = left key
- jr z,BackSpace
- cp $09 ; $09 = enter
- jr z,NameDone ;if enter then your done
- or a
- jr nz,CheckLetter
- pop hl
- jr WaK
- CheckLetter:
- ld hl,Letters
- ld bc,26 ; 26 letters to check
- cpir ; Compare A with each letter until a match is found
- ld d,c ; Then C = the letter. Store in D
- pop hl ; HL -> current position in string
- jr nz,WaK ; If not valid keystroke, wait for new key
- ld a,65 ; 65 = ascii char for A
- add a,d ; A now holds the ascii char for the letter pressed
- PutLetter:
- ld c,a
- ld a,(noLet) ; A = max letters
- cp e ; Check if max size is reached
- jr z,WaK ; If so, wait for a new key
- ld (hl),c ; If not, store the key entered
- inc hl ; Point to the next byte in the string
- inc e ; And increase the letter counter
- ld a,c
- ROM_CALL(TX_CHARPUT) ; Show the chars pressed on the screen
- jr WaK ; And jump back and wait for a new key
- BackSpace:
- pop hl ; HL -> current position in string
- ld a,e
- or a ; Check if string size = 0
- jr z,WaK ; If so, backspace is impossible. Check for new key.
- ;res 2,(iy+12) ; * Stopp cursor blinking
- dec e ; Decrease string size
- dec hl ; And string pointer
- push hl ;temporary storage of hl
- ld hl,$800D ; HL -> x cursor position
- dec (hl) ; Decrease it
- ld a,32 ; Overwrite the last letter with a space
- ROM_CALL(TX_CHARPUT) ; Put the space over the chars
- ROM_CALL(TX_CHARPUT) ; * And over the (non) blinking cursor
- dec (hl) ; * Decrease the x coordinate twice
- dec (hl) ;decrease hl by 1
- pop hl ;recall hl
- ;set 2,(iy+12) ; * Stopp cursor blinking
- jr WaK ; Wait for a key
- NameDone:
- pop hl ; HL -> current position in string
- ld (hl),0 ; Put a terminating zero at the end of the string
- ; res 2,(iy+12) ; * Stopp cursor blinking
- ; pop hl
- ; pop de
- ; pop bc
- ret
- exit_last:
- pop hl
- pop hl
- ret
-
- ; The keycodes of the letters A-Z stored backways
-
- Letters:
- .db $1A,$22,$2A ;ZYX
- .db $0B,$13,$1B,$23,$2B ;WVUTS
- .db $0C,$14,$1C,$24,$2C ;RQPON
- .db $0D,$15,$1D,$25,$2D ;MLKJI
- .db $0E,$16,$1E,$26,$2E ;HGFED
- .db $1F,$27,$2F ;CBA
-
- HighScore:
- .db $00, $00
-
-
- ;----------------------
- ;|Screen Setups
- ;----------------------
-
- ScreenSetup:
- ld hl,2*256+65 ;Setting Col = 90, Row = 2
- ld (CURSOR_X),hl ;Putting that into PenCol
- ld hl,PokeStr ;Loading string into HL
- ROM_CALL(D_ZM_STR) ;Display it! Small text, "Poke v 1.0"
- ld hl,9*256+68 ;Sets Coords into HL
- ld (CURSOR_X),hl ;Sets it into PenCol
- ld hl,ByMeStr ;String name into HL
- ROM_CALL(D_ZM_STR) ;Display, small size font [By: AE]
- ld hl,20*256+60 ;Sets Coords agian
- ld (CURSOR_X),hl ;Into PenCol
- ld hl,LiveStr ;String name into HL
- ROM_CALL(D_ZM_STR) ;Display it! [Lvs:]
- ld hl,27*256+60 ;Sets Coords again
- ld (CURSOR_X),hl ;Load HL into PenCol
- ld hl,ScorStr ;Load string name into HL
- ROM_CALL(D_ZM_STR) ;Display it! [Scr:]
- ;---------------------Variable Setup---------------------
- ld a,54 ;54 into A
- ld (ShipY),a ;A into Ship's Y Coord
- ld a,30 ;Loads 30 into A
- ld (EnemyY),a ;Loads A into EnemyY
- xor a ;Loads 0 into A
- ld (TargetD),a ;Loads A into Target Direction
- ld (EnemyD),a ;Loads A into Enemy Direction
- ld (Enemy2D),a ;Loads A into Enemy 2 Direction
- ld (Enemy3D),a ;Loads A into Enemy 3 Direction
- ld (Hits),a ;Number of hits = 0
- ld a,40 ;Loads 40 into A
- ld (Enemy2Y),a ;Loads A into Enemy2Y
- ld (Enemy3Y),a ;Loads A into Enemy3Y
- ld a,65 ;Loads 65 into A
- ld (Enemy2X),a ;A into Enemy2X
- ld a,12
- ld (Enemy3X),a
- ld a,2 ;Loads 2 into A
- ld (TargetY),a ;Loads A into Target Y
- ld a,43 ;43 into A
- ld (EnemyX),a ;A into EnemyX
- ld (ShipX),a ;A into ShipX
- ld (TargetX),a ;A into TargetX
- ;-----------------Finish Initializing----------------
- ld hl,27*256+75 ;Set Coords into HL
- ld (CURSOR_X),hl ;Loads HL into PenCol
- ld hl,(Score) ;Variable into HL
- call DispHL ;Display HL
- ld hl,20*256+75 ;Set Coords into HL
- ld (CURSOR_X),hl ;Loads HL into PenCol
- ld a,(Lives) ;Variable into A
- call DispA ;Display A
- call DispTarget ;Display Target
- call DispEnemy ;Display Enemy
- ret ;Return
-
- NewVarInit:
- ld a,5 ;Loads 5 into A
- ld (Lives),a ;Loads A into Lives
- ld a,1
- ld (Level),a
- ld hl,0 ;Load 0 into HL
- ld (Score),hl ;Load HL into Score
- ret
-
- ;----------------------
- ;|High Score Stuff
- ;----------------------
-
- DispHighScore:
- ld hl,41*256+60 ;Loads Coords for text
- ld (CURSOR_X),hl ;Into PenCol
- ld hl,HighStr ;High Score is our wanted Variable
- ROM_CALL(D_ZM_STR)
- ld hl,55*256+60 ;Loads Coords for text
- ld (CURSOR_X),hl ;Into PenCol
- ld hl,htext+12 ;High Score is our wanted Variable
- ROM_CALL(D_ZM_STR)
- ld hl,48*256+60 ;Loads Coords for text
- ld (CURSOR_X),hl ;Into PenCol
- ld hl,(HighScore)
- jr DispHL
-
- ;------------------------------
- ;|Misc. Routines
- ;------------------------------
-
- DispA:
- ld h,0
- ld l,a
- DispHL:
- push de
- push hl
- ld de,string+5
- xor a
- ld (de),a
- Repeat:
- call UNPACK_HL
- add a,'0'
- dec de
- ld (de),a
- ld a,h
- or l
- jr nz,Repeat
- ex de,hl
- ROM_CALL(D_ZM_STR)
- pop hl
- pop de
- ret
-
-
- BUFCLR:
- ld hl,$88B8
- ld de,$88B9
- ld bc,$2FF
- ld (hl),0
- ldir
- ret
-
- Delay: ;Delay Loop, converted from Dan Eble's 85 Bounce
- PUSH AF ;hide current AF value
- PUSH BC ;hide current BC value
- LD BC,$1000 ;dlay length->bc
- delayLoop:
- DEC BC ;bc-1->bc
- LD A, B ;Loads b into a
- OR C ;Checks if c=0
- JR NZ, delayLoop ;if not, continue loop
- POP BC ;unhide current BC value
- POP AF ;unhide current AF value
- ret ;Return to Call
-
-
- ;-----------------------------
- ;|Sprites
- ;-----------------------------
-
- PlayerShip:
- .db %00000000
- .db %00000000
- .db %00000000
- .db %00000000
- .db %11111111
- .db %11010101
- .db %10101011
- .db %11111111
-
- EnemyShip:
- .db %00000000
- .db %00000000
- .db %00000000
- .db %11111111
- .db %11111111
- .db %00000000
- .db %00000000
- .db %00000000
-
- Enemy2Ship:
- .db %00000000
- .db %00000000
- .db %00000000
- .db %10101010
- .db %11111111
- .db %01010101
- .db %00000000
- .db %00000000
-
- Enemy3Ship:
- .db %00000000
- .db %00000000
- .db %00000000
- .db %10101010
- .db %10000001
- .db %01010101
- .db %00000000
- .db %00000000
-
-
- TargetShip:
- .db %11111111
- .db %10011001
- .db %10011001
- .db %11111111
- .db %00000000
- .db %00000000
- .db %00000000
- .db %00000000
-
- FireBall:
- .db %00000000
- .db %00000000
- .db %00011000
- .db %00111100
- .db %01111110
- .db %00111100
- .db %00011000
- .db %00000000
-
-
- ;┌────────────────┬────────────────┬─────────────────────┬───────┬────────────┐
- ;│█████ Z80 ██████│ Sprite83 │█████████████████████│ movax │████████████│
- ;└────────────────┴────────────────┴─────────────────────┴───────┴────────────┘
-
- ; Sprite xor routine v1.0
- ; Coded by Hannes Edfeldt in 1997
-
- ; This routine uses xor to draw the sprite, therefore you can erase the sprite
- ; by just drawing it again at the same x and y coordinates. See xordemo.z80
- ; for an example of how to use this routine.
-
- ; Feel free to use this routine in your own productions as long as you give me
- ; some credit.
-
- ; This file should of course be viewed in a DOS texteditor ;)
-
- ; Hannes Edfeldt -+- movax@algonet.se -+- http://www.algonet.se/~movax
-
-
- ;▄████████████▀ SPRXOR ▀███████████████████████████████████████████████████████
- ;┌────────────────────────────────────────────────────────────────────────────┐
- ;│ Xor 8x8 sprite ■ a=x, e=y, bc=sprite address │
- ;└────────────────────────────────────────────────────────────────────────────┘
- PutSprite:
-
- push bc ; Save sprite address
-
- ;████ Calculate the address in graphbuf ████
-
- ld hl,0 ; Do y*12
- ld d,0
- add hl,de
- add hl,de
- add hl,de
- add hl,hl
- add hl,hl
-
- ld d,0 ; Do x/8
- ld e,a
- srl e
- srl e
- srl e
- add hl,de
-
- ld de,$88B8
- add hl,de ; Add address to graphbuf
-
- ld b,00000111b ; Get the remainder of x/8
- and b
- cp 0 ; Is this sprite aligned to 8*n,y?
- jp z,ALIGN
-
-
- ;████ Non aligned sprite blit starts here ████
-
- pop ix ; ix->sprite
- ld d,a ; d=how many bits to shift each line
-
- ld e,8 ; Line loop
- LILOP: ld b,(ix+0) ; Get sprite data
-
- ld c,0 ; Shift loop
- push de
- SHLOP: srl b
- rr c
- dec d
- jp nz,SHLOP
- pop de
-
- ld a,b ; Write line to graphbuf
- xor (hl)
- ld (hl),a
- inc hl
- ld a,c
- xor (hl)
- ld (hl),a
-
- ld bc,11 ; Calculate next line address
- add hl,bc
- inc ix ; Inc spritepointer
-
- dec e
- jp nz,LILOP ; Next line
-
- jp DONE1
-
-
- ;████ Aligned sprite blit starts here ████
-
- ALIGN: ; Blit an aligned sprite to graphbuf
- pop de ; de->sprite
- ld b,8
- ALOP1: ld a,(de)
- xor (hl)
- ld (hl),a
- inc de
- push bc
- ld bc,12
- add hl,bc
- pop bc
- djnz ALOP1
-
- DONE1:
- ret
-
- ;▄████████████▄ SPRXOR ▄███████████████████████████████████████████████████████
-
-
- ;┌────────────────┬────────────────┬─────────────────────┬───────┬────────────┐
- ;│█████ Z80 ██████│ Sprite83 │█████████████████████│ movax │████████████│
- ;└────────────────┴────────────────┴─────────────────────┴───────┴────────────┘
-
-
-
- ;------------------------------------
- ;|Begin Data [Text, Variables, Etc.]
- ;------------------------------------
-
- PokeStr: .db "Poke 1.1",0
- ByMeStr: .db "By: AE ",0
- LiveStr: .db "Lvs:",0
- ScorStr: .db "Scr:",0
- HighStr: .db "High:",0
- HiScr: .db "New High Score!",0
- htext: .db "HighScore---ARE",0
- BlankStr: .db " ",0
-
- noLet: .db 0
- ShipX: .db 0 ;Ship's X Coord
- ShipY: .db 0 ;Ship's Y Coord [Constant]
- FireX: .db 0 ;Weapon's X Coord
- FireY: .db 0 ;Weapon's Y Coord
- FireZ: .db 0 ;Weapon Fired or No?
- TargetX: .db 0 ;Target's X Coord
- TargetY: .db 0 ;Target's Y Coord
- TargetD: .db 0 ;Target's Direction
- EnemyX: .db 0 ;Enemy's X Coord
- EnemyY: .db 0 ;Enemy's Y Coord
- EnemyD: .db 0 ;Enemy's Direction
- Enemy2X: .db 0
- Enemy2Y: .db 0
- Enemy2D: .db 0
- Enemy3X: .db 0
- Enemy3Y: .db 0
- Enemy3D: .db 0
- Lives: .db 0 ;Lives Remaining
- Hits: .db 0 ;The Number of Hits
- Level: .db 0 ;The Level you are on
-
- Temp: .db 0,0 ;Temporary Variable
- Score: .db 0,0 ;Current Score
-
-
- .end
- END
-