; Zilog eZ80 ANSI C Compiler Release 3.4 ; -optsize -noreduceopt -nomodsect -peephole -globalopt ; -localcse -const=ROM FILE "SRC\MAIN.C" .assume ADL=1 SEGMENT TEXT _bulletAmount: DW 5 DB 0 _baddieAmount: DW 12 DB 0 SEGMENT DATA _spriteActive: DW 0 DB 0 _gamestate: DW 0 DB 0 _speed: DF 0.5 SEGMENT BSS _i: DS 3 _t: DS 4*1 _dt: DS 4*1 _player: DS 16 SEGMENT CODE _updatePlayer: LD HL,-18 CALL __frameset LD BC,_player+8 LD (IX+-12),BC LD BC,_player 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 LD HL,(IX+6) OR A,A SBC HL,BC JR NZ,L_3 L_2: LD BC,(IX+-6) LD (IX+-3),BC LD IY,(IX+-3) 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,_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) LD (IY+0),BC LD (IY+3),A LD IY,(IX+-3) LD BC,(IY+4) LD A,(IY+7) LD IY,(IX+-18) LD (IY+4),BC LD (IY+7),A L_3: LD SP,IX POP IX RET ;**************************** _updatePlayer *************************** ;Name Addr/Register Size Type ;_spaceship_data IMPORT 1026 variable ;_gfx_Sprite IMPORT ----- function ;_abs IMPORT ----- function ;_player STATIC 16 variable ;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 ;spriteActive IX+6 3 parameter ; Stack Frame Size: 27 (bytes) ; Spill Code: 0 (instruction) SEGMENT BSS _bulletSpawned: DS 3 _bullets: DS 85 SEGMENT CODE _spawnBullet: LD HL,-6 CALL __frameset LD BC,0 LD (_i),BC JR L_8 L_6: LD HL,(_i) LD A,17 CALL __imul_b LD (IX+-3),HL LD BC,_bullets ADD HL,BC LD IY,HL LD A,(IY+0) CP A,1 JR NZ,L_7 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 JR L_10 L_7: LD BC,(_i) INC BC LD (_i),BC L_8: LD BC,5 LD HL,(_i) OR A,A SBC HL,BC CALL __setflag JP M,L_6 OR A,A SBC HL,HL L_10: LD SP,IX POP IX RET ;**************************** _spawnBullet *************************** ;Name Addr/Register Size Type ;_bullets STATIC 85 variable ;_i STATIC 3 variable ;G_5 IX-3 3 variable ;posY IX+12 4 parameter ;posX IX+6 4 parameter ; Stack Frame Size: 24 (bytes) ; Spill Code: 0 (instruction) _updateBullet: LD HL,-30 CALL __frameset LD HL,(IX+6) LD A,17 CALL __imul_b LD (IX+-3),HL LD BC,_bullets ADD HL,BC LD (IX+-9),HL LD IY,(IX+-9) LD A,(IY+0) OR A,A JR NZ,L_17 LD IY,(IX+-9) LD HL,(IY+1) LD E,(IY+4) LD BC,11010048 LD A,67 CALL __fcmp JP P,L_15 LD BC,(IX+-3) LD (IX+-12),BC LD HL,(IX+-3) LD BC,_bullets ADD HL,BC LD (IX+-18),HL LD IY,(IX+-18) LEA BC,IY+1 LD (IX+-15),BC LD HL,(_speed) LD A,(_speed+3) LD IY,(IX+-15) LD BC,(IY+0) LD E,A LD A,(IY+3) CALL __fadd LD (IY+0),BC LD (IY+3),A LD HL,(IY+0) LD E,(IY+3) LD IY,(IX+-18) LD BC,(IY+9) LD A,(IY+12) CALL __fsub CALL __ftol PUSH BC CALL _abs POP BC LD BC,1 OR A,A SBC HL,BC JP P,L_12 LD BC,(IX+-3) LD (IX+-12),BC LD HL,(IX+-3) LD BC,_bullets ADD HL,BC LD (IX+-21),HL LD IY,(IX+-21) LD HL,(IY+5) LD E,(IY+8) LD BC,(IY+13) LD A,(IY+16) CALL __fsub CALL __ftol PUSH BC CALL _abs POP BC LD BC,1 OR A,A SBC HL,BC CALL __setflag JP M,L_13 L_12: LD BC,(IX+-12) LD (IX+-6),BC LD HL,BC LD BC,_bullets ADD HL,BC LD (IX+-27),HL LD IY,(IX+-27) LEA BC,IY+1 LD (IX+-24),BC LD IY,(IX+-24) 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 LD HL,(IX+-6) LD BC,_bullets ADD HL,BC LD (IX+-30),HL LD IY,(IX+-30) LD BC,(IY+1) LD A,(IY+4) LD (IY+9),BC LD (IY+12),A LD BC,(IY+5) LD A,(IY+8) LD (IY+13),BC LD (IY+16),A L_13: LD HL,1 JR L_18 L_15: LD IY,(IX+-9) LD (IY+0),1 LD HL,1 JR L_18 L_17: OR A,A SBC HL,HL L_18: LD SP,IX POP IX RET ;**************************** _updateBullet *************************** ;Name Addr/Register Size Type ;_bullet_data IMPORT 258 variable ;_gfx_Sprite IMPORT ----- function ;_abs IMPORT ----- function ;_speed STATIC 4 variable ;_bullets STATIC 85 variable ;G_9 IX-12 3 variable ;G_6 IX-9 3 variable ;G_10 IX-6 3 variable ;G_7 IX-3 3 variable ;i IX+6 3 parameter ; Stack Frame Size: 39 (bytes) ; Spill Code: 0 (instruction) SEGMENT BSS _baddieSpawned: DS 3 _baddies: DS 204 SEGMENT CODE _spawnBaddie: LD HL,-6 CALL __frameset LD BC,0 LD (_i),BC JR L_23 L_21: LD HL,(_i) LD A,17 CALL __imul_b LD (IX+-3),HL LD BC,_baddies ADD HL,BC LD IY,HL LD A,(IY+0) CP A,1 JR NZ,L_22 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 JR L_25 L_22: LD BC,(_i) INC BC LD (_i),BC L_23: LD BC,12 LD HL,(_i) OR A,A SBC HL,BC CALL __setflag JP M,L_21 OR A,A SBC HL,HL L_25: LD SP,IX POP IX RET ;**************************** _spawnBaddie *************************** ;Name Addr/Register Size Type ;_baddies STATIC 204 variable ;_i STATIC 3 variable ;G_12 IX-3 3 variable ;posY IX+12 4 parameter ;posX IX+6 4 parameter ; Stack Frame Size: 24 (bytes) ; Spill Code: 0 (instruction) _updateBaddie: LD HL,-30 CALL __frameset LD HL,(IX+6) LD A,17 CALL __imul_b LD (IX+-3),HL LD BC,_baddies ADD HL,BC LD (IX+-9),HL LD IY,(IX+-9) LD A,(IY+0) OR A,A JR NZ,L_32 LD IY,(IX+-9) LD BC,(IY+1) LD A,(IY+4) OR A,A SBC HL,HL LD E,194 CALL __fcmp JP P,L_30 LD BC,(IX+-3) LD (IX+-12),BC LD HL,(IX+-3) LD BC,_baddies ADD HL,BC LD (IX+-18),HL LD IY,(IX+-18) LEA BC,IY+1 LD (IX+-15),BC LD HL,(_speed) LD A,(_speed+3) LD IY,(IX+-15) LD BC,(IY+0) LD E,A LD A,(IY+3) CALL __fsub LD (IY+0),BC LD (IY+3),A LD HL,(IY+0) LD E,(IY+3) LD IY,(IX+-18) LD BC,(IY+9) LD A,(IY+12) CALL __fsub CALL __ftol PUSH BC CALL _abs POP BC LD BC,1 OR A,A SBC HL,BC JP P,L_27 LD BC,(IX+-3) LD (IX+-12),BC LD HL,(IX+-3) LD BC,_baddies ADD HL,BC LD (IX+-21),HL LD IY,(IX+-21) LD HL,(IY+5) LD E,(IY+8) LD BC,(IY+13) LD A,(IY+16) CALL __fsub CALL __ftol PUSH BC CALL _abs POP BC LD BC,1 OR A,A SBC HL,BC CALL __setflag JP M,L_28 L_27: LD BC,(IX+-12) LD (IX+-6),BC LD HL,BC LD BC,_baddies ADD HL,BC LD (IX+-27),HL LD IY,(IX+-27) LEA BC,IY+1 LD (IX+-24),BC LD IY,(IX+-24) 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,(IX+-6) LD BC,_baddies ADD HL,BC LD (IX+-30),HL LD IY,(IX+-30) LD BC,(IY+1) LD A,(IY+4) LD (IY+9),BC LD (IY+12),A LD BC,(IY+5) LD A,(IY+8) LD (IY+13),BC LD (IY+16),A L_28: LD HL,1 JR L_33 L_30: LD IY,(IX+-9) LD (IY+0),1 LD HL,1 JR L_33 L_32: OR A,A SBC HL,HL L_33: LD SP,IX POP IX RET ;**************************** _updateBaddie *************************** ;Name Addr/Register Size Type ;_baddie_data IMPORT 1026 variable ;_gfx_Sprite IMPORT ----- function ;_abs IMPORT ----- function ;_speed STATIC 4 variable ;_baddies STATIC 204 variable ;G_17 IX-12 3 variable ;G_14 IX-9 3 variable ;G_18 IX-6 3 variable ;G_15 IX-3 3 variable ;i IX+6 3 parameter ; Stack Frame Size: 39 (bytes) ; Spill Code: 0 (instruction) SEGMENT DATA _distance: DF 0.0 SEGMENT BSS _difference: DS 8 _a: DS 3 SEGMENT CODE _checkCollision: LD HL,-42 CALL __frameset LD BC,0 LD (_i),BC JR L_47 L_45: LD BC,0 LD (_a),BC JR L_41 L_39: LD HL,(_i) LD A,17 CALL __imul_b LD BC,_baddies ADD HL,BC LD (IX+-12),HL LD HL,(_a) LD A,17 CALL __imul_b LD BC,_bullets ADD HL,BC LD (IX+-9),HL LD IY,(IX+-12) LD BC,(IY+1) LD A,(IY+4) LD HL,8388608 LD E,65 CALL __fadd LD (IX+-25),BC LD IY,(IX+-9) LD BC,(IY+1) LD (IX+-26),A LD A,(IY+4) OR A,A SBC HL,HL LD E,65 CALL __fadd LD E,A LD HL,BC LD BC,(IX+-25) LD A,(IX+-26) CALL __fsub LD (_difference),BC LD (_difference+3),A LD IY,(IX+-12) LD BC,(IY+5) LD A,(IY+8) LD HL,8388608 LD E,65 CALL __fadd LD (IX+-29),BC LD IY,(IX+-9) LD BC,(IY+5) LD (IX+-30),A LD A,(IY+8) OR A,A SBC HL,HL LD E,65 CALL __fadd LD E,A LD HL,BC LD BC,(IX+-29) LD A,(IX+-30) CALL __fsub LD IY,_difference LD (IY+4),BC LD (IY+7),A LD C,64 LD B,0 PUSH BC LD A,(_difference+3) LD C,A LD DE,0 PUSH DE PUSH BC LD BC,(_difference) PUSH BC CALL _pow LD (IX+-21),HL LD H,0 POP BC POP BC POP BC POP BC LD (IX+-22),E LD C,64 LD B,0 PUSH BC LD BC,0 PUSH BC LD IY,_difference LD BC,(IY+4) LD A,(IY+7) LD L,A PUSH HL PUSH BC CALL _pow POP BC POP BC POP BC POP BC LD A,(IX+-22) LD BC,(IX+-21) CALL __fadd LD DE,BC LD C,A LD B,0 PUSH BC PUSH DE CALL _sqrt POP BC POP BC LD (_distance),HL LD A,E LD (_distance+3),A LD HL,(_i) LD A,17 CALL __imul_b LD BC,_baddies ADD HL,BC LD (IX+-3),HL LD IY,(IX+-3) LD A,(IY+0) OR A,A JR NZ,L_40 LD HL,(_a) LD A,17 CALL __imul_b LD BC,_bullets ADD HL,BC LD (IX+-6),HL LD IY,(IX+-6) LD A,(IY+0) OR A,A JR NZ,L_40 LD HL,3145728 LD E,65 LD BC,(_distance) LD A,(_distance+3) CALL __fcmp JP M,L_40 LD A,1 LD IY,(IX+-6) LD (IY+0),A LD IY,(IX+-3) LD (IY+0),A L_40: LD BC,(_a) INC BC LD (_a),BC L_41: LD BC,4 LD HL,(_a) OR A,A SBC HL,BC JP M,L_39 LD HL,(_i) LD A,17 CALL __imul_b LD BC,_baddies ADD HL,BC LD (IX+-18),HL LD BC,_player LD (IX+-15),BC LD IY,(IX+-18) LD BC,(IY+1) LD A,(IY+4) LD HL,8388608 LD E,65 CALL __fadd LD (IX+-37),BC LD IY,(IX+-15) LD BC,(IY+0) LD (IX+-38),A LD A,(IY+3) LD HL,8388608 LD E,65 CALL __fadd LD E,A LD HL,BC LD BC,(IX+-37) LD A,(IX+-38) CALL __fsub LD (_difference),BC LD (_difference+3),A LD IY,(IX+-18) LD BC,(IY+5) LD A,(IY+8) LD HL,8388608 LD E,65 CALL __fadd LD (IX+-41),BC LD IY,(IX+-15) LD BC,(IY+4) LD (IX+-42),A LD A,(IY+7) LD HL,8388608 LD E,65 CALL __fadd LD E,A LD HL,BC LD BC,(IX+-41) LD A,(IX+-42) CALL __fsub LD IY,_difference LD (IY+4),BC LD (IY+7),A LD C,64 LD B,0 PUSH BC LD A,(_difference+3) LD C,A LD DE,0 PUSH DE PUSH BC LD BC,(_difference) PUSH BC CALL _pow LD (IX+-33),HL LD H,0 POP BC POP BC POP BC POP BC LD (IX+-34),E LD C,64 LD B,0 PUSH BC LD BC,0 PUSH BC LD IY,_difference LD BC,(IY+4) LD A,(IY+7) LD L,A PUSH HL PUSH BC CALL _pow POP BC POP BC POP BC POP BC LD A,(IX+-34) LD BC,(IX+-33) CALL __fadd LD DE,BC LD C,A LD B,0 PUSH BC PUSH DE CALL _sqrt POP BC POP BC LD (_distance),HL LD A,E LD (_distance+3),A LD BC,(_i) INC BC LD (_i),BC L_47: LD BC,11 LD HL,(_i) OR A,A SBC HL,BC CALL __setflag JP M,L_45 LD SP,IX POP IX RET ;**************************** _checkCollision *************************** ;Name Addr/Register Size Type ;_player STATIC 16 variable ;_distance STATIC 4 variable ;_pow IMPORT ----- function ;_sqrt IMPORT ----- function ;_difference STATIC 8 variable ;_bullets STATIC 85 variable ;_baddies STATIC 204 variable ;_a STATIC 3 variable ;_i STATIC 3 variable ;G_21 IX-6 3 variable ;G_22 IX-3 3 variable ; Stack Frame Size: 48 (bytes) ; Spill Code: 0 (instruction) _handleInput: LD HL,-21 CALL __frameset CALL _kb_Scan LD A,(16056350) AND A,1 JR Z,L_53 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_53 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_53: LD A,(16056350) AND A,8 JR Z,L_56 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_56 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_56: LD A,(16056350) AND A,2 JR Z,L_59 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_59 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_59: LD A,(16056350) AND A,4 JR Z,L_62 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 JP P,L_62 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 L_62: LD A,(16056338) AND A,32 JR Z,L_64 LD HL,(_bulletSpawned) CALL __icmpzero JR NZ,L_64 LD BC,_player LD (IX+-15),BC LD IY,(IX+-15) LD BC,(IY+4) LD A,(IY+7) OR A,A SBC HL,HL LD E,65 CALL __fadd LD (IX+-21),BC ; spill LD C,A LD HL,8388608 LD E,65 LD B,0 PUSH BC LD (IX+-18),HL ; spill LD HL,(IX+-21) ; unspill PUSH HL LD HL,(IX+-18) ; unspill 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 L_64: LD A,(16056338) CP A,32 JR Z,L_67 LD BC,0 LD (_bulletSpawned),BC L_67: LD A,(16056338) AND A,64 JR Z,L_69 LD HL,(_baddieSpawned) CALL __icmpzero JR NZ,L_69 CALL _random LD BC,209 CALL __iremu LD BC,HL XOR A,A CALL __ultof LD DE,BC LD C,A LD B,0 PUSH BC PUSH DE LD C,67 PUSH BC LD BC,11534336 PUSH BC CALL _spawnBaddie POP BC POP BC POP BC POP BC LD BC,1 LD (_baddieSpawned),BC L_69: LD A,(16056338) CP A,64 JR Z,L_70 LD BC,0 LD (_baddieSpawned),BC ; 1 // Libraries lol ; 2 #include ; 3 #include ; 4 #include ; 5 #include ; 6 #include ; 7 #include ; 8 #include ; 9 #include ; 10 #include ; 11 #include ; 12 ; 13 // Graphics ; 14 #include "gfx/sprites.h" ; 15 ; 16 // set global vars ; 17 const int bulletAmount = 5; ; 18 const int baddieAmount = 12; ; 19 int spriteActive = 0; ; 20 int gamestate = 0; ; 21 float speed = 0.5; ; 22 int i; ; 23 float t; ; 24 float dt; ; 25 ; 26 // Include entity headers ; 27 #include "player.h" ; 28 #include "bullet.h" ; 29 #include "baddie.h" ; 30 #include "collision.h" ; 31 #include "controls.h" ; 32 ; 33 void setup() ; 34 { ; 35 boot_Set48MHzModeI(); ; 36 ; 37 /* Initialize the 8bpp graphics */ ; 38 gfx_Begin(); ; 39 ; 40 /* Set up the palette for our sprites */ ; 41 gfx_SetPalette(sprites_pal, sizeof_sprites_pal, 0); ; 42 ; 43 // Clear screen ; 44 gfx_FillScreen(01); ; 45 ; 46 // Player starting position ; 47 player.pos.x = 10; ; 48 player.pos.y = 136; ; 49 player.oldPos.x = 10; ; 50 player.oldPos.y = 10; ; 51 ; 52 // Reset all bullets ; 53 for (i = 0; i < bulletAmount; i++) ; 54 { ; 55 bullets[i].dead = true; ; 56 bullets[i].pos.x = 0; ; 57 bullets[i].pos.y = 0; ; 58 } ; 59 ; 60 // Reset all baddies ; 61 for (i = 0; i < baddieAmount; i++) ; 62 { ; 63 baddies[i].dead = true; ; 64 baddies[i].pos.x = 0; ; 65 baddies[i].pos.y = 0; ; 66 } ; 67 } ; 68 ; 69 void main(void) ; 70 { ; 71 setup(); ; 72 do ; 73 { L_70: 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_27 IX-12 3 variable ;G_26 IX-9 3 variable ;G_25 IX-6 3 variable ;G_24 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 PUSH BC LD BC,26 PUSH BC LD BC,_sprites_pal PUSH BC CALL _gfx_SetPalette POP BC POP BC POP BC LD BC,1 PUSH BC CALL _gfx_FillScreen POP BC LD BC,_player LD (IX+-6),BC LD IY,(IX+-6) LD BC,2097152 LD (IY+0),BC LD A,65 LD (IY+3),A LD BC,524288 LD (IY+4),BC LD (IY+7),67 LD BC,_player+8 LD (IX+-3),BC LD IY,(IX+-3) LD BC,2097152 LD (IY+0),BC LD (IY+3),A LD (IY+4),BC LD (IY+7),A LD BC,0 LD (_i),BC JR L_74 L_72: LD HL,(_i) LD A,17 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_74: LD BC,5 LD HL,(_i) OR A,A SBC HL,BC JP M,L_72 LD BC,0 LD (_i),BC JR L_78 L_76: LD HL,(_i) LD A,17 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_78: LD BC,12 LD HL,(_i) OR A,A SBC HL,BC CALL __setflag JP M,L_76 LD SP,IX POP IX RET ;**************************** _setup *************************** ;Name Addr/Register Size Type ;_baddies STATIC 204 variable ;_bullets STATIC 85 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_93: ; 74 ; 75 // Handle user input ; 76 handleInput(); CALL _handleInput ; 77 ; 78 // Move all alive bullets ; 79 for (i = 0; i < bulletAmount; i++) LD BC,0 LD (_i),BC JR L_85 L_83: ; 80 { ; 81 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_84 ; 82 { ; 83 spriteActive = 1; LD (_spriteActive),BC ; 84 } ; 85 } L_84: LD BC,(_i) INC BC LD (_i),BC L_85: LD BC,5 LD HL,(_i) OR A,A SBC HL,BC CALL __setflag JP M,L_83 ; 86 ; 87 // Move all alive baddies ; 88 for (i = 0; i < baddieAmount; i++) LD BC,0 LD (_i),BC JR L_90 L_88: ; 89 { ; 90 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_89 ; 91 { ; 92 spriteActive = 1; LD (_spriteActive),BC ; 93 } ; 94 ; 95 } L_89: LD BC,(_i) INC BC LD (_i),BC L_90: LD BC,12 LD HL,(_i) OR A,A SBC HL,BC CALL __setflag JP M,L_88 ; 96 ; 97 checkCollision(); CALL _checkCollision ; 98 ; 99 // Redraw player if position has changed or if a bullet has been fired ; 100 updatePlayer(spriteActive); LD BC,(_spriteActive) PUSH BC CALL _updatePlayer POP BC ; 101 ; 102 } while (kb_Data[6] != kb_Enter); LD A,(16056348) CP A,1 JR NZ,L_93 ; 103 ; 104 // Close the graphics ; 105 gfx_End(); CALL _gfx_End RET ;**************************** _main *************************** ;Name Addr/Register Size Type ;_gfx_End IMPORT ----- function ;_spriteActive STATIC 3 variable ;_i STATIC 3 variable ; Stack Frame Size: 6 (bytes) ; Spill Code: 0 (instruction) XREF _kb_Scan:ROM XREF _sprites_pal:ROM XREF _baddie_data:ROM 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 _sqrt:ROM XREF _pow:ROM XREF _boot_Set48MHzModeI:ROM XREF _random:ROM XREF __iremu:ROM XREF __fadd:ROM XREF __fsub:ROM XREF __fcmp:ROM XREF __ftol:ROM XREF __ultof:ROM XREF __frameset:ROM XREF __setflag:ROM XREF __icmpzero:ROM XREF __imul_b:ROM XDEF _main XDEF _setup XDEF _handleInput XDEF _checkCollision XDEF _a XDEF _difference XDEF _distance XDEF _updateBaddie XDEF _spawnBaddie XDEF _baddies XDEF _baddieSpawned XDEF _updateBullet XDEF _spawnBullet XDEF _bullets XDEF _bulletSpawned XDEF _updatePlayer XDEF _player XDEF _dt XDEF _t XDEF _i XDEF _speed XDEF _gamestate XDEF _spriteActive XDEF _baddieAmount XDEF _bulletAmount END