TI-84/obj/main.src

962 lines
16 KiB
Plaintext

; 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 32
DB 0
SEGMENT DATA
_spriteActive:
DW 0
DB 0
_speed:
DF 0.5
SEGMENT BSS
_i:
DS 3
_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
;bulletsAlive IX+6 3 parameter
; Stack Frame Size: 27 (bytes)
; Spill Code: 0 (instruction)
SEGMENT BSS
_bulletSpawned:
DS 3
_bullets:
DS 45
SEGMENT CODE
_spawnBullet:
LD HL,-6
CALL __frameset
LD BC,0
LD (_i),BC
JR L_8
L_6:
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
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 45 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,-12
CALL __frameset
LD HL,(IX+6)
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
JR NZ,L_14
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
LD HL,1
JR L_15
L_12:
LD IY,(IX+-6)
LD (IY+0),1
LD HL,1
JR L_15
L_14:
OR A,A
SBC HL,HL
L_15:
LD SP,IX
POP IX
RET
;**************************** _updateBullet ***************************
;Name Addr/Register Size Type
;_bullet_data IMPORT 258 variable
;_gfx_Sprite IMPORT ----- function
;_speed STATIC 4 variable
;_bullets STATIC 45 variable
;G_6 IX-6 3 variable
;G_7 IX-3 3 variable
;i IX+6 3 parameter
; Stack Frame Size: 21 (bytes)
; Spill Code: 0 (instruction)
SEGMENT BSS
_baddieSpawned:
DS 3
_baddies:
DS 288
SEGMENT CODE
_spawnBaddie:
LD HL,-6
CALL __frameset
LD BC,0
LD (_i),BC
JR L_20
L_18:
LD HL,(_i)
LD A,9
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_19
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_22
L_19:
LD BC,(_i)
INC BC
LD (_i),BC
L_20:
LD BC,32
LD HL,(_i)
OR A,A
SBC HL,BC
JP M,L_18
OR A,A
SBC HL,HL
L_22:
LD SP,IX
POP IX
RET
;**************************** _spawnBaddie ***************************
;Name Addr/Register Size Type
;_baddies STATIC 288 variable
;_i STATIC 3 variable
;G_9 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,-12
CALL __frameset
LD HL,(IX+6)
LD A,9
CALL __imul_b
LD (IX+-3),HL
LD BC,_baddies
ADD HL,BC
LD (IX+-6),HL
LD IY,(IX+-6)
LD A,(IY+0)
OR A,A
JR NZ,L_26
LD IY,(IX+-6)
LD BC,(IY+1)
LD A,(IY+4)
OR A,A
SBC HL,HL
LD E,194
CALL __fcmp
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
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
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
JR Z,L_38
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
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_41
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_41:
LD A,(16056338)
AND A,32
JR Z,L_43
LD HL,(_bulletSpawned)
CALL __icmpzero
JR NZ,L_43
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_43:
LD A,(16056338)
CP A,32
JR Z,L_46
LD BC,0
LD (_bulletSpawned),BC
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
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_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
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_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);
LD A,(16056348)
CP A,1
JR NZ,L_74
; 99
; 100 // Close the graphics
; 101 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 _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 _updateBaddie
XDEF _spawnBaddie
XDEF _baddies
XDEF _baddieSpawned
XDEF _updateBullet
XDEF _spawnBullet
XDEF _bullets
XDEF _bulletSpawned
XDEF _updatePlayer
XDEF _player
XDEF _i
XDEF _speed
XDEF _spriteActive
XDEF _baddieAmount
XDEF _bulletAmount
END