2019-12-17 22:50:36 +01:00
|
|
|
; Zilog eZ80 ANSI C Compiler Release 3.4
|
|
|
|
; -optsize -noreduceopt -nomodsect -peephole -globalopt
|
|
|
|
; -localcse -const=ROM
|
|
|
|
FILE "SRC\MAIN.C"
|
|
|
|
.assume ADL=1
|
2019-12-19 19:56:26 +01:00
|
|
|
SEGMENT TEXT
|
|
|
|
_bulletAmount:
|
|
|
|
DW 5
|
|
|
|
DB 0
|
|
|
|
_baddieAmount:
|
|
|
|
DW 32
|
|
|
|
DB 0
|
2019-12-17 22:50:36 +01:00
|
|
|
SEGMENT DATA
|
2019-12-19 19:56:26 +01:00
|
|
|
_spriteActive:
|
|
|
|
DW 0
|
|
|
|
DB 0
|
2019-12-17 22:50:36 +01:00
|
|
|
_speed:
|
|
|
|
DF 0.5
|
|
|
|
SEGMENT BSS
|
|
|
|
_i:
|
|
|
|
DS 3
|
|
|
|
_player:
|
|
|
|
DS 16
|
|
|
|
SEGMENT CODE
|
|
|
|
_updatePlayer:
|
2019-12-19 19:56:26 +01:00
|
|
|
LD HL,-18
|
2019-12-17 22:50:36 +01:00
|
|
|
CALL __frameset
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,_player+8
|
|
|
|
LD (IX+-12),BC
|
2019-12-17 22:50:36 +01:00
|
|
|
LD BC,_player
|
2019-12-19 19:56:26 +01:00
|
|
|
LD (IX+-9),BC
|
|
|
|
LD (IX+-6),BC
|
|
|
|
LD BC,_player+8
|
|
|
|
LD (IX+-15),BC
|
|
|
|
LD A,(_player+3)
|
|
|
|
LD E,A
|
|
|
|
LD A,(_player+11)
|
|
|
|
LD HL,(_player)
|
|
|
|
LD BC,(_player+8)
|
|
|
|
CALL __fsub
|
|
|
|
CALL __ftol
|
|
|
|
PUSH BC
|
|
|
|
CALL _abs
|
|
|
|
POP BC
|
|
|
|
LD BC,1
|
|
|
|
OR A,A
|
|
|
|
SBC HL,BC
|
|
|
|
CALL __setflag
|
|
|
|
JP P,L_2
|
|
|
|
LD BC,(IX+-9)
|
|
|
|
LD (IX+-6),BC
|
|
|
|
LD BC,(IX+-12)
|
|
|
|
LD (IX+-15),BC
|
|
|
|
LD IY,(IX+-9)
|
|
|
|
LD HL,(IY+4)
|
|
|
|
LD E,(IY+7)
|
|
|
|
LD IY,(IX+-12)
|
|
|
|
LD BC,(IY+4)
|
|
|
|
LD A,(IY+7)
|
|
|
|
CALL __fsub
|
|
|
|
CALL __ftol
|
|
|
|
PUSH BC
|
|
|
|
CALL _abs
|
|
|
|
POP BC
|
|
|
|
LD BC,1
|
|
|
|
OR A,A
|
|
|
|
SBC HL,BC
|
|
|
|
CALL __setflag
|
|
|
|
JP P,L_2
|
2019-12-17 22:50:36 +01:00
|
|
|
LD HL,(IX+6)
|
2019-12-19 19:56:26 +01:00
|
|
|
OR A,A
|
|
|
|
SBC HL,BC
|
|
|
|
JR NZ,L_3
|
|
|
|
L_2:
|
|
|
|
LD BC,(IX+-6)
|
|
|
|
LD (IX+-3),BC
|
2019-12-17 22:50:36 +01:00
|
|
|
LD IY,(IX+-3)
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,(IY+4)
|
|
|
|
LD A,(IY+7)
|
|
|
|
CALL __ftol
|
|
|
|
PUSH BC
|
2019-12-17 22:50:36 +01:00
|
|
|
LD BC,(IY+0)
|
|
|
|
LD A,(IY+3)
|
2019-12-19 19:56:26 +01:00
|
|
|
CALL __ftol
|
|
|
|
PUSH BC
|
|
|
|
LD BC,_spaceship_data
|
|
|
|
PUSH BC
|
|
|
|
CALL _gfx_Sprite
|
|
|
|
POP BC
|
|
|
|
POP BC
|
|
|
|
POP BC
|
|
|
|
LD BC,(IX+-15)
|
|
|
|
LD (IX+-18),BC
|
|
|
|
LD IY,(IX+-3)
|
|
|
|
LD BC,(IY+0)
|
|
|
|
LD A,(IY+3)
|
|
|
|
LD IY,(IX+-18)
|
2019-12-17 22:50:36 +01:00
|
|
|
LD (IY+0),BC
|
|
|
|
LD (IY+3),A
|
2019-12-19 19:56:26 +01:00
|
|
|
LD IY,(IX+-3)
|
2019-12-17 22:50:36 +01:00
|
|
|
LD BC,(IY+4)
|
|
|
|
LD A,(IY+7)
|
2019-12-19 19:56:26 +01:00
|
|
|
LD IY,(IX+-18)
|
2019-12-17 22:50:36 +01:00
|
|
|
LD (IY+4),BC
|
|
|
|
LD (IY+7),A
|
2019-12-19 19:56:26 +01:00
|
|
|
L_3:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD SP,IX
|
|
|
|
POP IX
|
|
|
|
RET
|
|
|
|
|
|
|
|
|
|
|
|
;**************************** _updatePlayer ***************************
|
|
|
|
;Name Addr/Register Size Type
|
2019-12-19 19:56:26 +01:00
|
|
|
;_spaceship_data IMPORT 1026 variable
|
|
|
|
;_gfx_Sprite IMPORT ----- function
|
|
|
|
;_abs IMPORT ----- function
|
2019-12-17 22:50:36 +01:00
|
|
|
;_player STATIC 16 variable
|
2019-12-19 19:56:26 +01:00
|
|
|
;G_4 IX-15 3 variable
|
|
|
|
;G_0 IX-12 3 variable
|
|
|
|
;G_1 IX-9 3 variable
|
|
|
|
;G_2 IX-6 3 variable
|
|
|
|
;G_3 IX-3 3 variable
|
|
|
|
;bulletsAlive IX+6 3 parameter
|
2019-12-17 22:50:36 +01:00
|
|
|
|
|
|
|
|
2019-12-19 19:56:26 +01:00
|
|
|
; Stack Frame Size: 27 (bytes)
|
2019-12-17 22:50:36 +01:00
|
|
|
; Spill Code: 0 (instruction)
|
|
|
|
|
|
|
|
|
|
|
|
SEGMENT BSS
|
2019-12-19 19:56:26 +01:00
|
|
|
_bulletSpawned:
|
|
|
|
DS 3
|
2019-12-17 22:50:36 +01:00
|
|
|
_bullets:
|
|
|
|
DS 45
|
|
|
|
SEGMENT CODE
|
|
|
|
_spawnBullet:
|
|
|
|
LD HL,-6
|
|
|
|
CALL __frameset
|
|
|
|
LD BC,0
|
|
|
|
LD (_i),BC
|
2019-12-19 19:56:26 +01:00
|
|
|
JR L_8
|
|
|
|
L_6:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD HL,(_i)
|
|
|
|
LD A,9
|
|
|
|
CALL __imul_b
|
|
|
|
LD (IX+-3),HL
|
|
|
|
LD BC,_bullets
|
|
|
|
ADD HL,BC
|
|
|
|
LD IY,HL
|
|
|
|
LD A,(IY+0)
|
|
|
|
CP A,1
|
2019-12-19 19:56:26 +01:00
|
|
|
JR NZ,L_7
|
2019-12-17 22:50:36 +01:00
|
|
|
LD HL,(IX+-3)
|
|
|
|
ADD HL,BC
|
|
|
|
LD (IX+-6),HL
|
|
|
|
LD BC,(IX+6)
|
|
|
|
LD A,(IX+9)
|
|
|
|
LD IY,(IX+-6)
|
|
|
|
LD (IY+1),BC
|
|
|
|
LD (IY+4),A
|
|
|
|
LD BC,(IX+12)
|
|
|
|
LD A,(IX+15)
|
|
|
|
LD (IY+5),BC
|
|
|
|
LD (IY+8),A
|
|
|
|
LD (IY+0),0
|
|
|
|
LD HL,1
|
2019-12-19 19:56:26 +01:00
|
|
|
JR L_10
|
|
|
|
L_7:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD BC,(_i)
|
|
|
|
INC BC
|
|
|
|
LD (_i),BC
|
2019-12-19 19:56:26 +01:00
|
|
|
L_8:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD BC,5
|
|
|
|
LD HL,(_i)
|
|
|
|
OR A,A
|
|
|
|
SBC HL,BC
|
|
|
|
CALL __setflag
|
2019-12-19 19:56:26 +01:00
|
|
|
JP M,L_6
|
2019-12-17 22:50:36 +01:00
|
|
|
OR A,A
|
|
|
|
SBC HL,HL
|
2019-12-19 19:56:26 +01:00
|
|
|
L_10:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD SP,IX
|
|
|
|
POP IX
|
|
|
|
RET
|
|
|
|
|
|
|
|
|
|
|
|
;**************************** _spawnBullet ***************************
|
|
|
|
;Name Addr/Register Size Type
|
|
|
|
;_bullets STATIC 45 variable
|
|
|
|
;_i STATIC 3 variable
|
2019-12-19 19:56:26 +01:00
|
|
|
;G_5 IX-3 3 variable
|
2019-12-17 22:50:36 +01:00
|
|
|
;posY IX+12 4 parameter
|
|
|
|
;posX IX+6 4 parameter
|
|
|
|
|
|
|
|
|
|
|
|
; Stack Frame Size: 24 (bytes)
|
|
|
|
; Spill Code: 0 (instruction)
|
|
|
|
|
|
|
|
|
2019-12-19 19:56:26 +01:00
|
|
|
_updateBullet:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD HL,-12
|
|
|
|
CALL __frameset
|
2019-12-19 19:56:26 +01:00
|
|
|
LD HL,(IX+6)
|
2019-12-17 22:50:36 +01:00
|
|
|
LD A,9
|
|
|
|
CALL __imul_b
|
|
|
|
LD (IX+-3),HL
|
|
|
|
LD BC,_bullets
|
|
|
|
ADD HL,BC
|
|
|
|
LD (IX+-6),HL
|
|
|
|
LD IY,(IX+-6)
|
|
|
|
LD A,(IY+0)
|
|
|
|
OR A,A
|
2019-12-19 19:56:26 +01:00
|
|
|
JR NZ,L_14
|
2019-12-17 22:50:36 +01:00
|
|
|
LD IY,(IX+-6)
|
|
|
|
LD HL,(IY+1)
|
|
|
|
LD E,(IY+4)
|
|
|
|
LD BC,11010048
|
|
|
|
LD A,67
|
|
|
|
CALL __fcmp
|
|
|
|
JP P,L_12
|
|
|
|
LD BC,_bullets
|
|
|
|
LD HL,(IX+-3)
|
|
|
|
ADD HL,BC
|
|
|
|
LD (IX+-12),HL
|
|
|
|
LD IY,(IX+-12)
|
|
|
|
LEA BC,IY+1
|
|
|
|
LD (IX+-9),BC
|
|
|
|
LD HL,(_speed)
|
|
|
|
LD A,(_speed+3)
|
|
|
|
LD IY,(IX+-9)
|
|
|
|
LD BC,(IY+0)
|
|
|
|
LD E,A
|
|
|
|
LD A,(IY+3)
|
|
|
|
CALL __fadd
|
|
|
|
LD (IY+0),BC
|
|
|
|
LD (IY+3),A
|
|
|
|
LD BC,(IY+4)
|
|
|
|
LD A,(IY+7)
|
|
|
|
CALL __ftol
|
|
|
|
PUSH BC
|
|
|
|
LD BC,(IY+0)
|
|
|
|
LD A,(IY+3)
|
|
|
|
CALL __ftol
|
|
|
|
PUSH BC
|
|
|
|
LD BC,_bullet_data
|
|
|
|
PUSH BC
|
|
|
|
CALL _gfx_Sprite
|
|
|
|
POP BC
|
|
|
|
POP BC
|
|
|
|
POP BC
|
2019-12-19 19:56:26 +01:00
|
|
|
LD HL,1
|
2019-12-17 22:50:36 +01:00
|
|
|
JR L_15
|
|
|
|
L_12:
|
|
|
|
LD IY,(IX+-6)
|
|
|
|
LD (IY+0),1
|
2019-12-19 19:56:26 +01:00
|
|
|
LD HL,1
|
|
|
|
JR L_15
|
|
|
|
L_14:
|
2019-12-17 22:50:36 +01:00
|
|
|
OR A,A
|
2019-12-19 19:56:26 +01:00
|
|
|
SBC HL,HL
|
|
|
|
L_15:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD SP,IX
|
|
|
|
POP IX
|
|
|
|
RET
|
|
|
|
|
|
|
|
|
2019-12-19 19:56:26 +01:00
|
|
|
;**************************** _updateBullet ***************************
|
2019-12-17 22:50:36 +01:00
|
|
|
;Name Addr/Register Size Type
|
|
|
|
;_bullet_data IMPORT 258 variable
|
|
|
|
;_gfx_Sprite IMPORT ----- function
|
|
|
|
;_speed STATIC 4 variable
|
|
|
|
;_bullets STATIC 45 variable
|
2019-12-19 19:56:26 +01:00
|
|
|
;G_6 IX-6 3 variable
|
|
|
|
;G_7 IX-3 3 variable
|
|
|
|
;i IX+6 3 parameter
|
2019-12-17 22:50:36 +01:00
|
|
|
|
|
|
|
|
2019-12-19 19:56:26 +01:00
|
|
|
; Stack Frame Size: 21 (bytes)
|
2019-12-17 22:50:36 +01:00
|
|
|
; Spill Code: 0 (instruction)
|
|
|
|
|
|
|
|
|
|
|
|
SEGMENT BSS
|
2019-12-19 19:56:26 +01:00
|
|
|
_baddieSpawned:
|
|
|
|
DS 3
|
2019-12-17 22:50:36 +01:00
|
|
|
_baddies:
|
|
|
|
DS 288
|
|
|
|
SEGMENT CODE
|
2019-12-19 19:56:26 +01:00
|
|
|
_spawnBaddie:
|
|
|
|
LD HL,-6
|
2019-12-17 22:50:36 +01:00
|
|
|
CALL __frameset
|
|
|
|
LD BC,0
|
|
|
|
LD (_i),BC
|
2019-12-19 19:56:26 +01:00
|
|
|
JR L_20
|
|
|
|
L_18:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD HL,(_i)
|
|
|
|
LD A,9
|
|
|
|
CALL __imul_b
|
2019-12-19 19:56:26 +01:00
|
|
|
LD (IX+-3),HL
|
|
|
|
LD BC,_baddies
|
2019-12-17 22:50:36 +01:00
|
|
|
ADD HL,BC
|
2019-12-19 19:56:26 +01:00
|
|
|
LD IY,HL
|
|
|
|
LD A,(IY+0)
|
|
|
|
CP A,1
|
|
|
|
JR NZ,L_19
|
|
|
|
LD HL,(IX+-3)
|
|
|
|
ADD HL,BC
|
|
|
|
LD (IX+-6),HL
|
|
|
|
LD BC,(IX+6)
|
|
|
|
LD A,(IX+9)
|
|
|
|
LD IY,(IX+-6)
|
2019-12-17 22:50:36 +01:00
|
|
|
LD (IY+1),BC
|
2019-12-19 19:56:26 +01:00
|
|
|
LD (IY+4),A
|
|
|
|
LD BC,(IX+12)
|
|
|
|
LD A,(IX+15)
|
2019-12-17 22:50:36 +01:00
|
|
|
LD (IY+5),BC
|
2019-12-19 19:56:26 +01:00
|
|
|
LD (IY+8),A
|
|
|
|
LD (IY+0),0
|
|
|
|
LD HL,1
|
|
|
|
JR L_22
|
|
|
|
L_19:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD BC,(_i)
|
|
|
|
INC BC
|
|
|
|
LD (_i),BC
|
2019-12-19 19:56:26 +01:00
|
|
|
L_20:
|
|
|
|
LD BC,32
|
2019-12-17 22:50:36 +01:00
|
|
|
LD HL,(_i)
|
|
|
|
OR A,A
|
|
|
|
SBC HL,BC
|
2019-12-19 19:56:26 +01:00
|
|
|
JP M,L_18
|
|
|
|
OR A,A
|
|
|
|
SBC HL,HL
|
|
|
|
L_22:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD SP,IX
|
|
|
|
POP IX
|
|
|
|
RET
|
|
|
|
|
|
|
|
|
2019-12-19 19:56:26 +01:00
|
|
|
;**************************** _spawnBaddie ***************************
|
2019-12-17 22:50:36 +01:00
|
|
|
;Name Addr/Register Size Type
|
2019-12-19 19:56:26 +01:00
|
|
|
;_baddies STATIC 288 variable
|
2019-12-17 22:50:36 +01:00
|
|
|
;_i STATIC 3 variable
|
2019-12-19 19:56:26 +01:00
|
|
|
;G_9 IX-3 3 variable
|
|
|
|
;posY IX+12 4 parameter
|
|
|
|
;posX IX+6 4 parameter
|
2019-12-17 22:50:36 +01:00
|
|
|
|
|
|
|
|
2019-12-19 19:56:26 +01:00
|
|
|
; Stack Frame Size: 24 (bytes)
|
2019-12-17 22:50:36 +01:00
|
|
|
; Spill Code: 0 (instruction)
|
|
|
|
|
|
|
|
|
2019-12-19 19:56:26 +01:00
|
|
|
_updateBaddie:
|
|
|
|
LD HL,-12
|
2019-12-17 22:50:36 +01:00
|
|
|
CALL __frameset
|
2019-12-19 19:56:26 +01:00
|
|
|
LD HL,(IX+6)
|
|
|
|
LD A,9
|
|
|
|
CALL __imul_b
|
|
|
|
LD (IX+-3),HL
|
|
|
|
LD BC,_baddies
|
|
|
|
ADD HL,BC
|
|
|
|
LD (IX+-6),HL
|
2019-12-17 22:50:36 +01:00
|
|
|
LD IY,(IX+-6)
|
2019-12-19 19:56:26 +01:00
|
|
|
LD A,(IY+0)
|
2019-12-17 22:50:36 +01:00
|
|
|
OR A,A
|
2019-12-19 19:56:26 +01:00
|
|
|
JR NZ,L_26
|
2019-12-17 22:50:36 +01:00
|
|
|
LD IY,(IX+-6)
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,(IY+1)
|
|
|
|
LD A,(IY+4)
|
2019-12-17 22:50:36 +01:00
|
|
|
OR A,A
|
|
|
|
SBC HL,HL
|
2019-12-19 19:56:26 +01:00
|
|
|
LD E,194
|
2019-12-17 22:50:36 +01:00
|
|
|
CALL __fcmp
|
2019-12-19 19:56:26 +01:00
|
|
|
JP P,L_24
|
|
|
|
LD BC,_baddies
|
|
|
|
LD HL,(IX+-3)
|
|
|
|
ADD HL,BC
|
|
|
|
LD (IX+-12),HL
|
|
|
|
LD IY,(IX+-12)
|
|
|
|
LEA BC,IY+1
|
|
|
|
LD (IX+-9),BC
|
2019-12-17 22:50:36 +01:00
|
|
|
LD HL,(_speed)
|
|
|
|
LD A,(_speed+3)
|
|
|
|
LD IY,(IX+-9)
|
|
|
|
LD BC,(IY+0)
|
|
|
|
LD E,A
|
|
|
|
LD A,(IY+3)
|
|
|
|
CALL __fsub
|
|
|
|
LD (IY+0),BC
|
|
|
|
LD (IY+3),A
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,(IY+4)
|
|
|
|
LD A,(IY+7)
|
|
|
|
CALL __ftol
|
|
|
|
PUSH BC
|
|
|
|
LD BC,(IY+0)
|
|
|
|
LD A,(IY+3)
|
|
|
|
CALL __ftol
|
|
|
|
PUSH BC
|
|
|
|
LD BC,_baddie_data
|
|
|
|
PUSH BC
|
|
|
|
CALL _gfx_Sprite
|
|
|
|
POP BC
|
|
|
|
POP BC
|
|
|
|
POP BC
|
|
|
|
LD HL,1
|
|
|
|
JR L_27
|
|
|
|
L_24:
|
|
|
|
LD IY,(IX+-6)
|
|
|
|
LD (IY+0),1
|
|
|
|
LD HL,1
|
|
|
|
JR L_27
|
|
|
|
L_26:
|
|
|
|
OR A,A
|
|
|
|
SBC HL,HL
|
|
|
|
L_27:
|
|
|
|
LD SP,IX
|
|
|
|
POP IX
|
|
|
|
RET
|
|
|
|
|
|
|
|
|
|
|
|
;**************************** _updateBaddie ***************************
|
|
|
|
;Name Addr/Register Size Type
|
|
|
|
;_baddie_data IMPORT 1026 variable
|
|
|
|
;_gfx_Sprite IMPORT ----- function
|
|
|
|
;_speed STATIC 4 variable
|
|
|
|
;_baddies STATIC 288 variable
|
|
|
|
;G_11 IX-6 3 variable
|
|
|
|
;G_12 IX-3 3 variable
|
|
|
|
;i IX+6 3 parameter
|
|
|
|
|
|
|
|
|
|
|
|
; Stack Frame Size: 21 (bytes)
|
|
|
|
; Spill Code: 0 (instruction)
|
|
|
|
|
|
|
|
|
|
|
|
_handleInput:
|
|
|
|
LD HL,-21
|
|
|
|
CALL __frameset
|
|
|
|
CALL _kb_Scan
|
|
|
|
LD A,(16056350)
|
|
|
|
AND A,1
|
|
|
|
JR Z,L_32
|
|
|
|
LD BC,_player
|
|
|
|
LD (IX+-3),BC
|
|
|
|
LD IY,(IX+-3)
|
|
|
|
LD HL,(IY+4)
|
|
|
|
LD E,(IY+7)
|
|
|
|
LD BC,5242880
|
|
|
|
LD A,67
|
|
|
|
CALL __fcmp
|
|
|
|
JP P,L_32
|
|
|
|
LD HL,(_speed)
|
|
|
|
LD A,(_speed+3)
|
|
|
|
LD IY,(IX+-3)
|
|
|
|
LD BC,(IY+4)
|
|
|
|
LD E,A
|
|
|
|
LD A,(IY+7)
|
|
|
|
CALL __fadd
|
|
|
|
LD (IY+4),BC
|
|
|
|
LD (IY+7),A
|
|
|
|
L_32:
|
|
|
|
LD A,(16056350)
|
|
|
|
AND A,8
|
|
|
|
JR Z,L_35
|
|
|
|
LD BC,_player
|
|
|
|
LD (IX+-6),BC
|
|
|
|
LD IY,(IX+-6)
|
|
|
|
LD BC,(IY+4)
|
|
|
|
LD A,(IY+7)
|
|
|
|
OR A,A
|
|
|
|
SBC HL,HL
|
|
|
|
LD E,0
|
|
|
|
CALL __fcmp
|
|
|
|
JP P,L_35
|
|
|
|
LD HL,(_speed)
|
|
|
|
LD A,(_speed+3)
|
|
|
|
LD IY,(IX+-6)
|
|
|
|
LD BC,(IY+4)
|
|
|
|
LD E,A
|
|
|
|
LD A,(IY+7)
|
|
|
|
CALL __fsub
|
|
|
|
LD (IY+4),BC
|
|
|
|
LD (IY+7),A
|
|
|
|
L_35:
|
|
|
|
LD A,(16056350)
|
|
|
|
AND A,2
|
2019-12-17 22:50:36 +01:00
|
|
|
JR Z,L_38
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,_player
|
|
|
|
LD (IX+-9),BC
|
|
|
|
LD IY,(IX+-9)
|
|
|
|
LD BC,(IY+0)
|
|
|
|
LD A,(IY+3)
|
|
|
|
OR A,A
|
|
|
|
SBC HL,HL
|
|
|
|
LD E,0
|
|
|
|
CALL __fcmp
|
|
|
|
JP P,L_38
|
|
|
|
LD HL,(_speed)
|
|
|
|
LD A,(_speed+3)
|
|
|
|
LD IY,(IX+-9)
|
|
|
|
LD BC,(IY+0)
|
|
|
|
LD E,A
|
|
|
|
LD A,(IY+3)
|
|
|
|
CALL __fsub
|
|
|
|
LD (IY+0),BC
|
|
|
|
LD (IY+3),A
|
|
|
|
L_38:
|
|
|
|
LD A,(16056350)
|
|
|
|
AND A,4
|
|
|
|
JR Z,L_41
|
2019-12-17 22:50:36 +01:00
|
|
|
LD BC,_player
|
|
|
|
LD (IX+-12),BC
|
|
|
|
LD IY,(IX+-12)
|
|
|
|
LD HL,(IY+0)
|
|
|
|
LD E,(IY+3)
|
|
|
|
LD BC,9437184
|
|
|
|
LD A,67
|
|
|
|
CALL __fcmp
|
2019-12-19 19:56:26 +01:00
|
|
|
JP P,L_41
|
2019-12-17 22:50:36 +01:00
|
|
|
LD HL,(_speed)
|
|
|
|
LD A,(_speed+3)
|
|
|
|
LD IY,(IX+-12)
|
|
|
|
LD BC,(IY+0)
|
|
|
|
LD E,A
|
|
|
|
LD A,(IY+3)
|
|
|
|
CALL __fadd
|
|
|
|
LD (IY+0),BC
|
|
|
|
LD (IY+3),A
|
2019-12-19 19:56:26 +01:00
|
|
|
L_41:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD A,(16056338)
|
|
|
|
AND A,32
|
2019-12-19 19:56:26 +01:00
|
|
|
JR Z,L_43
|
2019-12-17 22:50:36 +01:00
|
|
|
LD HL,(_bulletSpawned)
|
|
|
|
CALL __icmpzero
|
2019-12-19 19:56:26 +01:00
|
|
|
JR NZ,L_43
|
2019-12-17 22:50:36 +01:00
|
|
|
LD BC,_player
|
2019-12-19 19:56:26 +01:00
|
|
|
LD (IX+-15),BC
|
|
|
|
LD IY,(IX+-15)
|
2019-12-17 22:50:36 +01:00
|
|
|
LD BC,(IY+4)
|
|
|
|
LD A,(IY+7)
|
|
|
|
OR A,A
|
|
|
|
SBC HL,HL
|
|
|
|
LD E,65
|
|
|
|
CALL __fadd
|
2019-12-19 19:56:26 +01:00
|
|
|
LD (IX+-21),BC ; spill
|
2019-12-17 22:50:36 +01:00
|
|
|
LD C,A
|
|
|
|
LD HL,8388608
|
|
|
|
LD E,65
|
|
|
|
LD B,0
|
|
|
|
PUSH BC
|
2019-12-19 19:56:26 +01:00
|
|
|
LD (IX+-18),HL ; spill
|
|
|
|
LD HL,(IX+-21) ; unspill
|
2019-12-17 22:50:36 +01:00
|
|
|
PUSH HL
|
2019-12-19 19:56:26 +01:00
|
|
|
LD HL,(IX+-18) ; unspill
|
2019-12-17 22:50:36 +01:00
|
|
|
LD BC,(IY+0)
|
|
|
|
LD A,(IY+3)
|
|
|
|
CALL __fadd
|
|
|
|
LD DE,BC
|
|
|
|
LD C,A
|
|
|
|
LD B,0
|
|
|
|
PUSH BC
|
|
|
|
PUSH DE
|
|
|
|
CALL _spawnBullet
|
|
|
|
POP BC
|
|
|
|
POP BC
|
|
|
|
POP BC
|
|
|
|
POP BC
|
|
|
|
LD BC,1
|
|
|
|
LD (_bulletSpawned),BC
|
2019-12-19 19:56:26 +01:00
|
|
|
L_43:
|
2019-12-17 22:50:36 +01:00
|
|
|
LD A,(16056338)
|
|
|
|
CP A,32
|
2019-12-19 19:56:26 +01:00
|
|
|
JR Z,L_46
|
2019-12-17 22:50:36 +01:00
|
|
|
LD BC,0
|
|
|
|
LD (_bulletSpawned),BC
|
2019-12-19 19:56:26 +01:00
|
|
|
L_46:
|
|
|
|
LD A,(16056338)
|
|
|
|
AND A,64
|
|
|
|
JR Z,L_48
|
|
|
|
LD HL,(_baddieSpawned)
|
|
|
|
CALL __icmpzero
|
|
|
|
JR NZ,L_48
|
|
|
|
CALL _random
|
|
|
|
LD BC,209
|
|
|
|
CALL __iremu
|
|
|
|
LD BC,HL
|
|
|
|
XOR A,A
|
|
|
|
CALL __ultof
|
|
|
|
LD DE,BC
|
|
|
|
LD C,A
|
|
|
|
LD B,0
|
2019-12-17 22:50:36 +01:00
|
|
|
PUSH BC
|
2019-12-19 19:56:26 +01:00
|
|
|
PUSH DE
|
|
|
|
LD C,67
|
2019-12-17 22:50:36 +01:00
|
|
|
PUSH BC
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,11534336
|
|
|
|
PUSH BC
|
|
|
|
CALL _spawnBaddie
|
|
|
|
POP BC
|
|
|
|
POP BC
|
|
|
|
POP BC
|
2019-12-17 22:50:36 +01:00
|
|
|
POP BC
|
|
|
|
LD BC,1
|
2019-12-19 19:56:26 +01:00
|
|
|
LD (_baddieSpawned),BC
|
|
|
|
L_48:
|
|
|
|
LD A,(16056338)
|
|
|
|
CP A,64
|
|
|
|
JR Z,L_49
|
|
|
|
LD BC,0
|
|
|
|
LD (_baddieSpawned),BC
|
|
|
|
; 1 // Libraries lol
|
|
|
|
; 2 #include <stddef.h>
|
|
|
|
; 3 #include <stdint.h>
|
|
|
|
; 4 #include <tice.h>
|
|
|
|
; 5 #include <math.h>
|
|
|
|
; 6 #include <stdio.h>
|
|
|
|
; 7 #include <stdlib.h>
|
|
|
|
; 8 #include <string.h>
|
|
|
|
; 9 #include <assert.h>
|
|
|
|
; 10 #include <debug.h>
|
|
|
|
; 11 #include <graphx.h>
|
|
|
|
; 12
|
|
|
|
; 13 // Graphics
|
|
|
|
; 14 #include "gfx/sprites.h"
|
|
|
|
; 15
|
|
|
|
; 16 // set global vars
|
|
|
|
; 17 const int bulletAmount = 5;
|
|
|
|
; 18 const int baddieAmount = 32;
|
|
|
|
; 19 int spriteActive = 0;
|
|
|
|
; 20 float speed = 0.5;
|
|
|
|
; 21 int i;
|
|
|
|
; 22
|
|
|
|
; 23 // Include entity headers
|
|
|
|
; 24 #include "player.h"
|
|
|
|
; 25 #include "bullet.h"
|
|
|
|
; 26 #include "baddie.h"
|
|
|
|
; 27 #include "controls.h"
|
|
|
|
; 28
|
|
|
|
; 29 void setup()
|
|
|
|
; 30 {
|
|
|
|
; 31 boot_Set48MHzModeI();
|
|
|
|
; 32
|
|
|
|
; 33 /* Initialize the 8bpp graphics */
|
|
|
|
; 34 gfx_Begin();
|
|
|
|
; 35 dbg_sprintf(dbgout, "This is the start of a CEmu debugging test\n");
|
|
|
|
; 36 dbg_Debugger();
|
|
|
|
; 37
|
|
|
|
; 38 /* Set up the palette for our sprites */
|
|
|
|
; 39 gfx_SetPalette(sprites_pal, sizeof_sprites_pal, 0);
|
|
|
|
; 40
|
|
|
|
; 41 // Clear screen
|
|
|
|
; 42 gfx_FillScreen(01);
|
|
|
|
; 43
|
|
|
|
; 44 // Player starting position
|
|
|
|
; 45 player.pos.x = 10;
|
|
|
|
; 46 player.pos.y = 136;
|
|
|
|
; 47 player.oldPos.x = 10;
|
|
|
|
; 48 player.oldPos.y = 10;
|
|
|
|
; 49
|
|
|
|
; 50 // Reset all bullets
|
|
|
|
; 51 for (i = 0; i < bulletAmount; i++)
|
|
|
|
; 52 {
|
|
|
|
; 53 bullets[i].dead = true;
|
|
|
|
; 54 bullets[i].pos.x = 0;
|
|
|
|
; 55 bullets[i].pos.y = 0;
|
|
|
|
; 56 }
|
|
|
|
; 57
|
|
|
|
; 58 // Reset all baddies
|
|
|
|
; 59 for (i = 0; i < baddieAmount; i++)
|
|
|
|
; 60 {
|
|
|
|
; 61 baddies[i].dead = true;
|
|
|
|
; 62 baddies[i].pos.x = 0;
|
|
|
|
; 63 baddies[i].pos.y = 0;
|
|
|
|
; 64 }
|
|
|
|
; 65 }
|
|
|
|
; 66
|
|
|
|
; 67 void main(void)
|
|
|
|
; 68 {
|
|
|
|
; 69 setup();
|
|
|
|
; 70 do
|
|
|
|
; 71 {
|
|
|
|
; 72
|
|
|
|
; 73 // Handle user input
|
|
|
|
L_49:
|
|
|
|
LD SP,IX
|
|
|
|
POP IX
|
|
|
|
RET
|
|
|
|
|
|
|
|
|
|
|
|
;**************************** _handleInput ***************************
|
|
|
|
;Name Addr/Register Size Type
|
|
|
|
;_random IMPORT ----- function
|
|
|
|
;_baddieSpawned STATIC 3 variable
|
|
|
|
;_bulletSpawned STATIC 3 variable
|
|
|
|
;_speed STATIC 4 variable
|
|
|
|
;_player STATIC 16 variable
|
|
|
|
;_kb_Scan IMPORT ----- function
|
|
|
|
;G_18 IX-12 3 variable
|
|
|
|
;G_17 IX-9 3 variable
|
|
|
|
;G_16 IX-6 3 variable
|
|
|
|
;G_15 IX-3 3 variable
|
|
|
|
|
|
|
|
|
|
|
|
; Stack Frame Size: 27 (bytes)
|
|
|
|
; Spill Code: 0 (instruction)
|
|
|
|
|
|
|
|
|
|
|
|
_setup:
|
|
|
|
LD HL,-12
|
|
|
|
CALL __frameset
|
|
|
|
CALL _boot_Set48MHzModeI
|
|
|
|
CALL _gfx_Begin
|
|
|
|
LD BC,0
|
2019-12-17 22:50:36 +01:00
|
|
|
PUSH BC
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,26
|
2019-12-17 22:50:36 +01:00
|
|
|
PUSH BC
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,_sprites_pal
|
2019-12-17 22:50:36 +01:00
|
|
|
PUSH BC
|
2019-12-19 19:56:26 +01:00
|
|
|
CALL _gfx_SetPalette
|
2019-12-17 22:50:36 +01:00
|
|
|
POP BC
|
|
|
|
POP BC
|
|
|
|
POP BC
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,1
|
|
|
|
PUSH BC
|
|
|
|
CALL _gfx_FillScreen
|
|
|
|
POP BC
|
|
|
|
LD BC,_player
|
|
|
|
LD (IX+-6),BC
|
|
|
|
LD IY,(IX+-6)
|
|
|
|
LD BC,2097152
|
2019-12-17 22:50:36 +01:00
|
|
|
LD (IY+0),BC
|
2019-12-19 19:56:26 +01:00
|
|
|
LD A,65
|
2019-12-17 22:50:36 +01:00
|
|
|
LD (IY+3),A
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,524288
|
|
|
|
LD (IY+4),BC
|
|
|
|
LD (IY+7),67
|
|
|
|
LD BC,_player+8
|
|
|
|
LD (IX+-3),BC
|
2019-12-17 22:50:36 +01:00
|
|
|
LD IY,(IX+-3)
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,2097152
|
|
|
|
LD (IY+0),BC
|
|
|
|
LD (IY+3),A
|
2019-12-17 22:50:36 +01:00
|
|
|
LD (IY+4),BC
|
|
|
|
LD (IY+7),A
|
2019-12-19 19:56:26 +01:00
|
|
|
LD BC,0
|
|
|
|
LD (_i),BC
|
|
|
|
JR L_55
|
|
|
|
L_53:
|
|
|
|
LD HL,(_i)
|
|
|
|
LD A,9
|
|
|
|
CALL __imul_b
|
|
|
|
LD BC,_bullets
|
|
|
|
ADD HL,BC
|
|
|
|
LD (IX+-9),HL
|
|
|
|
LD IY,(IX+-9)
|
|
|
|
LD (IY+0),1
|
|
|
|
LD BC,0
|
|
|
|
LD (IY+1),BC
|
|
|
|
LD (IY+4),0
|
|
|
|
LD (IY+5),BC
|
|
|
|
LD (IY+8),0
|
|
|
|
LD BC,(_i)
|
|
|
|
INC BC
|
|
|
|
LD (_i),BC
|
|
|
|
L_55:
|
|
|
|
LD BC,5
|
|
|
|
LD HL,(_i)
|
|
|
|
OR A,A
|
|
|
|
SBC HL,BC
|
|
|
|
JP M,L_53
|
|
|
|
LD BC,0
|
|
|
|
LD (_i),BC
|
|
|
|
JR L_59
|
|
|
|
L_57:
|
|
|
|
LD HL,(_i)
|
|
|
|
LD A,9
|
|
|
|
CALL __imul_b
|
|
|
|
LD BC,_baddies
|
|
|
|
ADD HL,BC
|
|
|
|
LD (IX+-12),HL
|
|
|
|
LD IY,(IX+-12)
|
|
|
|
LD (IY+0),1
|
|
|
|
LD BC,0
|
|
|
|
LD (IY+1),BC
|
|
|
|
LD (IY+4),0
|
|
|
|
LD (IY+5),BC
|
|
|
|
LD (IY+8),0
|
|
|
|
LD BC,(_i)
|
|
|
|
INC BC
|
|
|
|
LD (_i),BC
|
|
|
|
L_59:
|
|
|
|
LD BC,32
|
|
|
|
LD HL,(_i)
|
|
|
|
OR A,A
|
|
|
|
SBC HL,BC
|
|
|
|
CALL __setflag
|
|
|
|
JP M,L_57
|
|
|
|
LD SP,IX
|
|
|
|
POP IX
|
|
|
|
RET
|
|
|
|
|
|
|
|
|
|
|
|
;**************************** _setup ***************************
|
|
|
|
;Name Addr/Register Size Type
|
|
|
|
;_baddies STATIC 288 variable
|
|
|
|
;_bullets STATIC 45 variable
|
|
|
|
;_i STATIC 3 variable
|
|
|
|
;_player STATIC 16 variable
|
|
|
|
;_gfx_FillScreen IMPORT ----- function
|
|
|
|
;_sprites_pal IMPORT 26 variable
|
|
|
|
;_gfx_SetPalette IMPORT ----- function
|
|
|
|
;_gfx_Begin IMPORT ----- function
|
|
|
|
;_boot_Set48MHzModeI IMPORT ----- function
|
|
|
|
|
|
|
|
|
|
|
|
; Stack Frame Size: 18 (bytes)
|
|
|
|
; Spill Code: 0 (instruction)
|
|
|
|
|
|
|
|
|
|
|
|
_main:
|
|
|
|
CALL _setup
|
|
|
|
L_74:
|
|
|
|
; 74 handleInput();
|
|
|
|
CALL _handleInput
|
|
|
|
; 75
|
|
|
|
; 76 // Move all alive bullets
|
|
|
|
; 77 for (i = 0; i < bulletAmount; i++)
|
|
|
|
LD BC,0
|
|
|
|
LD (_i),BC
|
|
|
|
JR L_66
|
|
|
|
L_64:
|
|
|
|
; 78 {
|
|
|
|
; 79 if (updateBullet(i) == 1)
|
|
|
|
LD BC,(_i)
|
|
|
|
PUSH BC
|
|
|
|
CALL _updateBullet
|
|
|
|
POP BC
|
|
|
|
LD BC,1
|
|
|
|
OR A,A
|
|
|
|
SBC HL,BC
|
|
|
|
JR NZ,L_65
|
|
|
|
; 80 {
|
|
|
|
; 81 spriteActive = 1;
|
|
|
|
LD (_spriteActive),BC
|
|
|
|
; 82 }
|
|
|
|
; 83 }
|
|
|
|
L_65:
|
|
|
|
LD BC,(_i)
|
|
|
|
INC BC
|
|
|
|
LD (_i),BC
|
|
|
|
L_66:
|
|
|
|
LD BC,5
|
|
|
|
LD HL,(_i)
|
|
|
|
OR A,A
|
|
|
|
SBC HL,BC
|
|
|
|
CALL __setflag
|
|
|
|
JP M,L_64
|
|
|
|
; 84
|
|
|
|
; 85 // Move all alive baddies
|
|
|
|
; 86 for (i = 0; i < baddieAmount; i++)
|
|
|
|
LD BC,0
|
|
|
|
LD (_i),BC
|
|
|
|
JR L_71
|
|
|
|
L_69:
|
|
|
|
; 87 {
|
|
|
|
; 88 if (updateBaddie(i) == 1)
|
|
|
|
LD BC,(_i)
|
|
|
|
PUSH BC
|
|
|
|
CALL _updateBaddie
|
|
|
|
POP BC
|
|
|
|
LD BC,1
|
|
|
|
OR A,A
|
|
|
|
SBC HL,BC
|
|
|
|
JR NZ,L_70
|
|
|
|
; 89 {
|
|
|
|
; 90 spriteActive = 1;
|
|
|
|
LD (_spriteActive),BC
|
|
|
|
; 91 }
|
|
|
|
; 92
|
|
|
|
; 93 }
|
|
|
|
L_70:
|
|
|
|
LD BC,(_i)
|
|
|
|
INC BC
|
|
|
|
LD (_i),BC
|
|
|
|
L_71:
|
|
|
|
LD BC,32
|
|
|
|
LD HL,(_i)
|
|
|
|
OR A,A
|
|
|
|
SBC HL,BC
|
|
|
|
CALL __setflag
|
|
|
|
JP M,L_69
|
|
|
|
; 94
|
|
|
|
; 95 // Redraw player if position has changed or if a bullet has been fired
|
|
|
|
; 96 updatePlayer(spriteActive);
|
|
|
|
LD BC,(_spriteActive)
|
|
|
|
PUSH BC
|
|
|
|
CALL _updatePlayer
|
|
|
|
POP BC
|
|
|
|
; 97
|
|
|
|
; 98 } while (kb_Data[6] != kb_Enter);
|
2019-12-17 22:50:36 +01:00
|
|
|
LD A,(16056348)
|
|
|
|
CP A,1
|
2019-12-19 19:56:26 +01:00
|
|
|
JR NZ,L_74
|
|
|
|
; 99
|
|
|
|
; 100 // Close the graphics
|
|
|
|
; 101 gfx_End();
|
2019-12-17 22:50:36 +01:00
|
|
|
CALL _gfx_End
|
|
|
|
RET
|
|
|
|
|
|
|
|
|
|
|
|
;**************************** _main ***************************
|
|
|
|
;Name Addr/Register Size Type
|
|
|
|
;_gfx_End IMPORT ----- function
|
2019-12-19 19:56:26 +01:00
|
|
|
;_spriteActive STATIC 3 variable
|
|
|
|
;_i STATIC 3 variable
|
|
|
|
|
|
|
|
|
|
|
|
; Stack Frame Size: 6 (bytes)
|
2019-12-17 22:50:36 +01:00
|
|
|
; Spill Code: 0 (instruction)
|
|
|
|
|
|
|
|
|
2019-12-19 19:56:26 +01:00
|
|
|
XREF _kb_Scan:ROM
|
2019-12-17 22:50:36 +01:00
|
|
|
XREF _sprites_pal:ROM
|
2019-12-19 19:56:26 +01:00
|
|
|
XREF _baddie_data:ROM
|
2019-12-17 22:50:36 +01:00
|
|
|
XREF _bullet_data:ROM
|
|
|
|
XREF _spaceship_data:ROM
|
|
|
|
XREF _gfx_Sprite:ROM
|
|
|
|
XREF _gfx_FillScreen:ROM
|
|
|
|
XREF _gfx_SetPalette:ROM
|
|
|
|
XREF _gfx_End:ROM
|
|
|
|
XREF _gfx_Begin:ROM
|
|
|
|
XREF _abs:ROM
|
|
|
|
XREF _boot_Set48MHzModeI:ROM
|
2019-12-19 19:56:26 +01:00
|
|
|
XREF _random:ROM
|
|
|
|
XREF __iremu:ROM
|
2019-12-17 22:50:36 +01:00
|
|
|
XREF __fadd:ROM
|
|
|
|
XREF __fsub:ROM
|
|
|
|
XREF __fcmp:ROM
|
|
|
|
XREF __ftol:ROM
|
2019-12-19 19:56:26 +01:00
|
|
|
XREF __ultof:ROM
|
2019-12-17 22:50:36 +01:00
|
|
|
XREF __frameset:ROM
|
|
|
|
XREF __setflag:ROM
|
|
|
|
XREF __icmpzero:ROM
|
|
|
|
XREF __imul_b:ROM
|
|
|
|
XDEF _main
|
|
|
|
XDEF _setup
|
2019-12-19 19:56:26 +01:00
|
|
|
XDEF _handleInput
|
|
|
|
XDEF _updateBaddie
|
|
|
|
XDEF _spawnBaddie
|
2019-12-17 22:50:36 +01:00
|
|
|
XDEF _baddies
|
2019-12-19 19:56:26 +01:00
|
|
|
XDEF _baddieSpawned
|
|
|
|
XDEF _updateBullet
|
2019-12-17 22:50:36 +01:00
|
|
|
XDEF _spawnBullet
|
|
|
|
XDEF _bullets
|
2019-12-19 19:56:26 +01:00
|
|
|
XDEF _bulletSpawned
|
2019-12-17 22:50:36 +01:00
|
|
|
XDEF _updatePlayer
|
|
|
|
XDEF _player
|
|
|
|
XDEF _i
|
|
|
|
XDEF _speed
|
2019-12-19 19:56:26 +01:00
|
|
|
XDEF _spriteActive
|
|
|
|
XDEF _baddieAmount
|
|
|
|
XDEF _bulletAmount
|
2019-12-17 22:50:36 +01:00
|
|
|
END
|