First commit

This commit is contained in:
Arne van Iterson 2019-12-17 22:50:36 +01:00
commit ee0c04706a
26 changed files with 4566 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.vscode/*
bin/*
src/gfx/convpng.*
screenshot.png

31
autotester.json Normal file
View File

@ -0,0 +1,31 @@
{
"rom": "84pce_515.rom",
"transfer_files": [
"bin/DEMO.8xp"
],
"target": {
"name": "DEMO",
"isASM": true
},
"sequence": [
"action|launch",
"hashWait|1",
"key|enter",
"hashWait|2"
],
"hashes": {
"1": {
"description": "Make sure the sprites are displayed properly",
"start": "vram_start",
"size": "vram_8_size",
"expected_CRCs": [ "DF7FD32" ]
},
"2": {
"description": "Back to the home screen (exit check)",
"start": "vram_start",
"size": "vram_16_size",
"expected_CRCs": [ "FFAF89BA", "101734A5", "9DA19F44" ]
}
}
}

15
makefile Normal file
View File

@ -0,0 +1,15 @@
# ----------------------------
# Set NAME to the program name
# Set ICON to the png icon file name
# Set DESCRIPTION to display within a compatible shell
# Set COMPRESSED to "YES" to create a compressed program
# ----------------------------
NAME ?= DEMO
COMPRESSED ?= NO
ICON ?= iconc.png
DESCRIPTION ?= "C SDK Demo"
# ----------------------------
include $(CEDEV)/include/.makefile

6
obj/baddie.src Normal file
View File

@ -0,0 +1,6 @@
; Zilog eZ80 ANSI C Compiler Release 3.4
; -optsize -noreduceopt -nomodsect -peephole -globalopt
; -localcse -const=ROM
FILE "SRC\BADDIE.C"
.assume ADL=1
END

6
obj/bullet.src Normal file
View File

@ -0,0 +1,6 @@
; Zilog eZ80 ANSI C Compiler Release 3.4
; -optsize -noreduceopt -nomodsect -peephole -globalopt
; -localcse -const=ROM
FILE "SRC\BULLET.C"
.assume ADL=1
END

1041
obj/gfx/baddie.src Normal file

File diff suppressed because it is too large Load Diff

273
obj/gfx/bullet.src Normal file
View File

@ -0,0 +1,273 @@
; Zilog eZ80 ANSI C Compiler Release 3.4
; -optsize -noreduceopt -nomodsect -peephole -globalopt
; -localcse -const=ROM
FILE "SRC\GFX\BULLET.C"
.assume ADL=1
SEGMENT DATA
_bullet_data:
DB 16
DB 16
DB 8
DB 8
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 8
DB 8
DB 8
DB 8
DB 8
DB 8
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 8
DB 8
DB 8
DB 8
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 5
DB 5
DB 5
DB 5
DB 2
DB 2
DB 8
DB 8
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 5
DB 5
DB 5
DB 5
DB 2
DB 2
DB 8
DB 8
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 5
DB 5
DB 2
DB 2
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 5
DB 5
DB 2
DB 2
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 2
DB 2
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 2
DB 2
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 2
DB 2
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 2
DB 2
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 5
DB 5
DB 2
DB 2
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 5
DB 5
DB 2
DB 2
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 5
DB 5
DB 5
DB 5
DB 2
DB 2
DB 8
DB 8
DB 2
DB 2
DB 0
DB 0
DB 0
DB 0
DB 0
DB 0
DB 5
DB 5
DB 5
DB 5
DB 2
DB 2
DB 8
DB 8
DB 8
DB 8
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 8
DB 8
DB 8
DB 8
DB 8
DB 8
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 2
DB 8
DB 8
DB 8
DB 8
XDEF _bullet_data
; 1 // convpng v7.2
; 2 #include <stdint.h>
; 3 #include "sprites.h"
; 4
; 5 // 8 bpp image
; 6 uint8_t bullet_data[258] = {
END

21
obj/gfx/logo_gfx.src Normal file
View File

@ -0,0 +1,21 @@
; Zilog eZ80 ANSI C Compiler Release 3.4
; -optsize -noreduceopt -nomodsect -peephole -globalopt
; -localcse -const=ROM
FILE "SRC\GFX\LOGO_GFX.C"
.assume ADL=1
SEGMENT DATA
_logo_gfx_pal:
DW 65535
DW 63421
DW 0
DW 23254
DW 46509
DW 19026
DW 0
XDEF _logo_gfx_pal
; 1 // convpng v7.2
; 2 #include <stdint.h>
; 3 #include "logo_gfx.h"
; 4
; 5 uint16_t logo_gfx_pal[7] = {
END

1041
obj/gfx/spaceship.src Normal file

File diff suppressed because it is too large Load Diff

23
obj/gfx/sprites.src Normal file
View File

@ -0,0 +1,23 @@
; Zilog eZ80 ANSI C Compiler Release 3.4
; -optsize -noreduceopt -nomodsect -peephole -globalopt
; -localcse -const=ROM
FILE "SRC\GFX\SPRITES.C"
.assume ADL=1
SEGMENT DATA
_sprites_pal:
DW 65535
DW 63421
DW 0
DW 46509
DW 23254
DW 23254
DW 61307
DW 19026
DW 0
XDEF _sprites_pal
; 1 // convpng v7.2
; 2 #include <stdint.h>
; 3 #include "sprites.h"
; 4
; 5 uint16_t sprites_pal[9] = {
END

1041
obj/gfx/ubuntu.src Normal file

File diff suppressed because it is too large Load Diff

733
obj/main.src Normal file
View File

@ -0,0 +1,733 @@
; Zilog eZ80 ANSI C Compiler Release 3.4
; -optsize -noreduceopt -nomodsect -peephole -globalopt
; -localcse -const=ROM
FILE "SRC\MAIN.C"
.assume ADL=1
SEGMENT BSS
_key:
DS 1
SEGMENT DATA
_speed:
DF 0.5
SEGMENT BSS
_i:
DS 3
_bulletSpawned:
DS 3
_baddieSpawned:
DS 3
SEGMENT DATA
_gameloop:
DW 0
DB 0
SEGMENT BSS
_player:
DS 16
SEGMENT CODE
_updatePlayer:
LD HL,-3
CALL __frameset
LD BC,_player
LD (IX+-3),BC
LD HL,(IX+6)
LD E,(IX+9)
LD IY,(IX+-3)
LD BC,(IY+0)
LD A,(IY+3)
CALL __fadd
LD (IY+0),BC
LD (IY+3),A
LD HL,(IX+12)
LD E,(IX+15)
LD BC,(IY+4)
LD A,(IY+7)
CALL __fadd
LD (IY+4),BC
LD (IY+7),A
LD SP,IX
POP IX
RET
;**************************** _updatePlayer ***************************
;Name Addr/Register Size Type
;_player STATIC 16 variable
;dy IX+12 4 parameter
;dx IX+6 4 parameter
; Stack Frame Size: 21 (bytes)
; Spill Code: 0 (instruction)
SEGMENT BSS
_bullets:
DS 45
SEGMENT CODE
_spawnBullet:
LD HL,-6
CALL __frameset
LD BC,1
LD HL,(_gameloop)
OR A,A
SBC HL,BC
JR NZ,L_8
LD BC,0
LD (_i),BC
JR L_5
L_3:
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_4
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_9
L_4:
LD BC,(_i)
INC BC
LD (_i),BC
L_5:
LD BC,5
LD HL,(_i)
OR A,A
SBC HL,BC
CALL __setflag
JP M,L_3
LD HL,1
JR L_9
L_8:
OR A,A
SBC HL,HL
L_9:
LD SP,IX
POP IX
RET
;**************************** _spawnBullet ***************************
;Name Addr/Register Size Type
;_bullets STATIC 45 variable
;_i STATIC 3 variable
;_gameloop STATIC 3 variable
;G_0 IX-3 3 variable
;posY IX+12 4 parameter
;posX IX+6 4 parameter
; Stack Frame Size: 24 (bytes)
; Spill Code: 0 (instruction)
_updateBullets:
LD HL,-12
CALL __frameset
LD BC,0
LD (_i),BC
JR L_16
L_14:
LD HL,(_i)
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_15
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
JR L_15
L_12:
LD IY,(IX+-6)
LD (IY+0),1
L_15:
LD BC,(_i)
INC BC
LD (_i),BC
L_16:
LD BC,45
LD HL,(_i)
OR A,A
SBC HL,BC
JR C,L_14
LD SP,IX
POP IX
RET
;**************************** _updateBullets ***************************
;Name Addr/Register Size Type
;_bullet_data IMPORT 258 variable
;_gfx_Sprite IMPORT ----- function
;_speed STATIC 4 variable
;_bullets STATIC 45 variable
;_i STATIC 3 variable
;G_1 IX-6 3 variable
;G_2 IX-3 3 variable
; Stack Frame Size: 18 (bytes)
; Spill Code: 0 (instruction)
SEGMENT BSS
_baddies:
DS 288
SEGMENT CODE
; 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 #include <keypadc.h>
; 13
; 14 // Graphics
; 15 #include "gfx/sprites.h"
; 16
; 17 // set global vars
; 18 kb_key_t key;
; 19 float speed = 0.5;
; 20 int i;
; 21 int bulletSpawned;
; 22 int baddieSpawned;
; 23 int gameloop = 0;
; 24
; 25 // Include entity headers
; 26 #include "player.h"
; 27 #include "bullet.h"
; 28 #include "baddie.h"
; 29
; 30 void setup() {
_setup:
LD HL,-9
CALL __frameset
; 31 boot_Set48MHzModeI();
CALL _boot_Set48MHzModeI
; 32
; 33 /* Initialize the 8bpp graphics */
; 34 gfx_Begin();
CALL _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);
LD BC,0
PUSH BC
LD BC,18
PUSH BC
LD BC,_sprites_pal
PUSH BC
CALL _gfx_SetPalette
POP BC
POP BC
POP BC
; 40
; 41 // Clear screen
; 42 gfx_FillScreen(02);
LD BC,2
PUSH BC
CALL _gfx_FillScreen
POP BC
; 43
; 44 // Player starting position
; 45 player.pos.x = 10;
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
; 46 player.pos.y = 136;
LD BC,524288
LD (IY+4),BC
LD (IY+7),67
; 47 player.oldPos.x = 10;
LD BC,_player+8
LD (IX+-3),BC
LD IY,(IX+-3)
LD BC,2097152
LD (IY+0),BC
LD (IY+3),A
; 48 player.oldPos.y = 10;
LD (IY+4),BC
LD (IY+7),A
; 49
; 50 // Reset all bullets
; 51 for (i = 0; i < 5; i++)
LD BC,0
LD (_i),BC
JR L_23
L_21:
; 52 {
; 53 bullets[i].dead = true;
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
; 54 bullets[i].pos.x = 0;
LD BC,0
LD (IY+1),BC
LD (IY+4),0
; 55 bullets[i].pos.y = 0;
LD (IY+5),BC
LD (IY+8),0
LD BC,(_i)
INC BC
LD (_i),BC
; 56 }
L_23:
LD BC,5
LD HL,(_i)
OR A,A
SBC HL,BC
JP M,L_21
; 57 }
LD SP,IX
POP IX
RET
;**************************** _setup ***************************
;Name Addr/Register Size Type
;_bullets STATIC 45 variable
;_i STATIC 3 variable
;_player STATIC 16 variable
;_gfx_FillScreen IMPORT ----- function
;_sprites_pal IMPORT 18 variable
;_gfx_SetPalette IMPORT ----- function
;_gfx_Begin IMPORT ----- function
;_boot_Set48MHzModeI IMPORT ----- function
; Stack Frame Size: 15 (bytes)
; Spill Code: 0 (instruction)
; 58
; 59 void main(void) {
_main:
LD HL,-39
CALL __frameset
; 60 setup();
CALL _setup
; 61 gameloop = 1;
LD BC,1
LD (_gameloop),BC
; 62 do {
L_45:
; 63 // Scan keyboard for button presses
; 64 kb_Scan();
CALL _kb_Scan
; 65
; 66 // Move all alive bullets
; 67 updateBullets();
CALL _updateBullets
; 68
; 69 // set key to keyboard memory adress row 7
; 70 key = kb_Data[7];
LD A,(16056350)
LD (_key),A
; 71
; 72 // Move player
; 73 //// Down
; 74 if (key & kb_Down) {
AND A,1
JR Z,L_29
; 75 if (!(player.pos.y >= (LCD_HEIGHT - 32))) {
LD BC,_player
LD (IX+-21),BC
LD IY,(IX+-21)
LD HL,(IY+4)
LD E,(IY+7)
LD BC,5242880
LD A,67
CALL __fcmp
JP P,L_29
; 76 player.pos.y += speed;
LD HL,(_speed)
LD A,(_speed+3)
LD IY,(IX+-21)
LD BC,(IY+4)
LD E,A
LD A,(IY+7)
CALL __fadd
LD (IY+4),BC
LD (IY+7),A
; 77 }
; 78 }
L_29:
; 79 //// Up
; 80 if (key & kb_Up) {
LD A,(_key)
AND A,8
JR Z,L_32
; 81 if (!(player.pos.y <= 0)) {
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_32
; 82 player.pos.y -= speed;
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
; 83 }
; 84 }
L_32:
; 85 //// Left
; 86 if (key & kb_Left) {
LD A,(_key)
AND A,2
JR Z,L_35
; 87 if (!(player.pos.x <= 0)) {
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_35
; 88 player.pos.x -= speed;
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
; 89 }
; 90 }
L_35:
; 91 //// Right
; 92 if (key & kb_Right) {
LD A,(_key)
AND A,4
JR Z,L_38
; 93 if (!(player.pos.x >= (LCD_WIDTH - 32))) {
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_38
; 94 player.pos.x += speed;
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
; 95 }
; 96 }
L_38:
; 97
; 98 // Spawn bullet on 2nd press
; 99 if (kb_Data[1] & kb_2nd) {
LD A,(16056338)
AND A,32
JR Z,L_40
; 100 // If bullet has already been spawned (You cannot hold the button)
; 101 if (bulletSpawned == 0){
LD HL,(_bulletSpawned)
CALL __icmpzero
JR NZ,L_40
; 102 spawnBullet((player.pos.x + 16), (player.pos.y + 8));
LD BC,_player
LD (IX+-30),BC
LD IY,(IX+-30)
LD BC,(IY+4)
LD A,(IY+7)
OR A,A
SBC HL,HL
LD E,65
CALL __fadd
LD (IX+-39),BC ; spill
LD C,A
LD HL,8388608
LD E,65
LD B,0
PUSH BC
LD (IX+-36),HL ; spill
LD HL,(IX+-39) ; unspill
PUSH HL
LD HL,(IX+-36) ; 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
; 103 bulletSpawned = 1;
LD BC,1
LD (_bulletSpawned),BC
; 104 }
; 105 }
L_40:
; 106
; 107 // Set bulletSpawned to false if button is let loose
; 108 if (kb_Data[1] != kb_2nd){
LD A,(16056338)
CP A,32
JR Z,L_44
; 109 bulletSpawned = 0;
LD BC,0
LD (_bulletSpawned),BC
; 110 }
L_44:
; 111
; 112 // Redraw all sprites if player pos has changed or a bullet has been spawned
; 113 if ( (abs(player.oldPos.x - player.pos.x) >= 1) || (abs(player.oldPos.y - player.pos.y) >= 1) || bulletSpawned == 1) {
LD BC,_player+8
LD (IX+-18),BC
LD BC,_player
LD (IX+-15),BC
LD (IX+-24),BC
LD BC,(IX+-18)
LD (IX+-27),BC
LD IY,(IX+-15)
LD HL,(IY+0)
LD E,(IY+3)
LD IY,(IX+-18)
LD BC,(IY+0)
LD A,(IY+3)
CALL __fsub
CALL __ftol
PUSH BC
CALL _abs
POP BC
LD BC,1
OR A,A
SBC HL,BC
JP P,L_43
LD BC,(IX+-15)
LD (IX+-24),BC
LD BC,(IX+-18)
LD (IX+-27),BC
LD IY,(IX+-15)
LD HL,(IY+4)
LD E,(IY+7)
LD IY,(IX+-18)
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_43
LD HL,(_bulletSpawned)
OR A,A
SBC HL,BC
JR NZ,L_46
L_43:
; 114 gfx_Sprite(spaceship, player.pos.x, player.pos.y);
LD BC,(IX+-24)
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
; 115 player.oldPos.x = player.pos.x;
LD BC,(IX+-27)
LD (IX+-33),BC
LD IY,(IX+-3)
LD BC,(IY+0)
LD A,(IY+3)
LD IY,(IX+-33)
LD (IY+0),BC
LD (IY+3),A
; 116 player.oldPos.y = player.pos.y;
LD IY,(IX+-3)
LD BC,(IY+4)
LD A,(IY+7)
LD IY,(IX+-33)
LD (IY+4),BC
LD (IY+7),A
; 117 }
; 118 } while (kb_Data[6] != kb_Enter);
L_46:
LD A,(16056348)
CP A,1
JR NZ,L_45
; 119
; 120 // Close the graphics
; 121 gfx_End();
CALL _gfx_End
LD SP,IX
POP IX
RET
;**************************** _main ***************************
;Name Addr/Register Size Type
;_gfx_End IMPORT ----- function
;_spaceship_data IMPORT 1026 variable
;_gfx_Sprite IMPORT ----- function
;_abs IMPORT ----- function
;_bulletSpawned STATIC 3 variable
;_speed STATIC 4 variable
;_player STATIC 16 variable
;_key STATIC 1 variable
;_kb_Scan IMPORT ----- function
;_gameloop STATIC 3 variable
;G_12 IX-27 3 variable
;G_10 IX-24 3 variable
;G_4 IX-21 3 variable
;G_8 IX-18 3 variable
;G_9 IX-15 3 variable
;G_7 IX-12 3 variable
;G_6 IX-9 3 variable
;G_5 IX-6 3 variable
;G_11 IX-3 3 variable
; Stack Frame Size: 45 (bytes)
; Spill Code: 0 (instruction)
XREF _sprites_pal:ROM
XREF _bullet_data:ROM
XREF _spaceship_data:ROM
XREF _kb_Scan: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 __fadd:ROM
XREF __fsub:ROM
XREF __fcmp:ROM
XREF __ftol:ROM
XREF __frameset:ROM
XREF __setflag:ROM
XREF __icmpzero:ROM
XREF __imul_b:ROM
XDEF _main
XDEF _setup
XDEF _baddies
XDEF _updateBullets
XDEF _spawnBullet
XDEF _bullets
XDEF _updatePlayer
XDEF _player
XDEF _gameloop
XDEF _baddieSpawned
XDEF _bulletSpawned
XDEF _i
XDEF _speed
XDEF _key
END

5
readme.md Normal file
View File

@ -0,0 +1,5 @@
## Spacemania TI-84 CE Edition
### Now almost working!
Will post a release later, for now, you can compile it for yourself with the tools from [CE-Programming](https://github.com/CE-Programming/)

8
src/baddie.h Normal file
View File

@ -0,0 +1,8 @@
// baddie.h
struct Baddie {
bool dead;
struct pos {
float x;
float y;
} pos;
} baddies[32];

41
src/bullet.h Normal file
View File

@ -0,0 +1,41 @@
// bullet.h
struct Bullet {
bool dead;
struct pos {
float x;
float y;
} pos;
} bullets[5];
// Reset all bullets
for (i = 0; i < sizeof(bullets); i++)
{
bullets[i].dead = true;
bullets[i].pos.x = 0;
bullets[i].pos.y = 0;
}
int spawnBullet(float posX, float posY) {
for (i = 0; i < sizeof(bullets); i++) {
if (bullets[i].dead == true) {
bullets[i].pos.x = posX;
bullets[i].pos.y = posY;
bullets[i].dead = false;
return 1;
}
}
}
void updateBullets() {
for (i = 0; i < sizeof(bullets); i++) {
if (bullets[i].dead == false) {
if (!(bullets[i].pos.x >= (LCD_WIDTH + 16)))
{
bullets[i].pos.x += speed;
gfx_Sprite(bullet, bullets[i].pos.x, bullets[i].pos.y);
} else {
bullets[i].dead = true;
}
}
}
}

3
src/controls.h Normal file
View File

@ -0,0 +1,3 @@
// controls.h
// Scan keyboard for button presses
kb_Scan();

40
src/gfx/baddie.c Normal file
View File

@ -0,0 +1,40 @@
// convpng v7.2
#include <stdint.h>
#include "sprites.h"
// 8 bpp image
uint8_t baddie_data[1026] = {
32,32, // width,height
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,
0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x06,0x06,0x02,0x02,0x06,0x06,0x02,0x02,0x06,0x06,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x06,0x06,0x02,0x02,0x06,0x06,0x02,0x02,0x06,0x06,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x08,0x08,0x02,0x02,0x03,0x03,0x02,0x02,0x06,0x06,0x02,0x02,0x06,0x06,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x02,0x02,0x03,0x03,0x02,0x02,0x06,0x06,0x02,0x02,0x06,0x06,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x03,0x02,0x02,0x06,0x06,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x03,0x02,0x02,0x06,0x06,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x03,0x03,0x02,0x02,0x03,0x03,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x03,0x03,0x02,0x02,0x03,0x03,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x03,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x03,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x02,0x02,0x02,0x02,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,
};

BIN
src/gfx/baddie.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

24
src/gfx/bullet.c Normal file
View File

@ -0,0 +1,24 @@
// convpng v7.2
#include <stdint.h>
#include "sprites.h"
// 8 bpp image
uint8_t bullet_data[258] = {
16,16, // width,height
0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,
0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x02,0x02,0x08,0x08,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x02,0x02,0x08,0x08,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x02,0x02,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x02,0x02,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x02,0x02,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x02,0x02,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x02,0x02,0x08,0x08,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x05,0x02,0x02,0x08,0x08,
0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,
0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,
};

BIN
src/gfx/bullet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

40
src/gfx/spaceship.c Normal file
View File

@ -0,0 +1,40 @@
// convpng v7.2
#include <stdint.h>
#include "sprites.h"
// 8 bpp image
uint8_t spaceship_data[1026] = {
32,32, // width,height
0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x02,0x02,0x01,0x01,0x02,0x02,0x08,0x08,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x02,0x02,0x01,0x01,0x02,0x02,0x08,0x08,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x02,0x02,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,
0x02,0x02,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,
0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x04,0x04,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,
0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x04,0x04,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,
0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x04,0x04,0x02,0x02,0x03,0x03,0x02,0x02,0x01,0x01,0x02,0x02,0x08,0x08,
0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x04,0x04,0x02,0x02,0x03,0x03,0x02,0x02,0x01,0x01,0x02,0x02,0x08,0x08,
0x02,0x02,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x02,0x02,0x03,0x03,0x02,0x02,0x03,0x03,0x02,0x02,0x08,0x08,
0x02,0x02,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x02,0x02,0x03,0x03,0x02,0x02,0x03,0x03,0x02,0x02,0x08,0x08,
0x02,0x02,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x02,0x02,
0x02,0x02,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x01,0x01,0x02,0x02,0x02,0x02,
0x02,0x02,0x07,0x07,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,
0x02,0x02,0x07,0x07,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,
0x02,0x02,0x07,0x07,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,
0x02,0x02,0x07,0x07,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,
0x02,0x02,0x07,0x07,0x04,0x04,0x04,0x04,0x01,0x01,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,
0x02,0x02,0x07,0x07,0x04,0x04,0x04,0x04,0x01,0x01,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,
0x08,0x08,0x02,0x02,0x07,0x07,0x04,0x04,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x08,0x08,
0x08,0x08,0x02,0x02,0x07,0x07,0x04,0x04,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x08,0x08,
0x08,0x08,0x02,0x02,0x07,0x07,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x08,0x08,
0x08,0x08,0x02,0x02,0x07,0x07,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x08,0x08,
0x08,0x08,0x08,0x08,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x08,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x08,0x08,0x08,0x08,
0x08,0x08,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,
0x08,0x08,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,
0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
};

BIN
src/gfx/spaceship.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

15
src/gfx/sprites.c Normal file
View File

@ -0,0 +1,15 @@
// convpng v7.2
#include <stdint.h>
#include "sprites.h"
uint16_t sprites_pal[9] = {
0xFFFF, // 00 :: rgb(255,255,255)
0xF7BD, // 01 :: rgb(238,238,238)
0x0000, // 02 :: rgb(0,0,0)
0xB5AD, // 03 :: rgb(108,108,108)
0x5AD6, // 04 :: rgb(178,178,178)
0x5AD6, // 05 :: rgb(179,179,179)
0xEF7B, // 06 :: rgb(222,222,222)
0x4A52, // 07 :: rgb(146,146,146)
0x0000, // 08 :: rgb(0,0,0)
};

27
src/gfx/sprites.h Normal file
View File

@ -0,0 +1,27 @@
// convpng v7.2
// this file contains all the graphics sources for easy inclusion in a project
#ifndef __sprites__
#define __sprites__
#include <stdint.h>
#define sprites_transparent_color_index 0
#define spaceship_width 32
#define spaceship_height 32
#define spaceship_size 1026
extern uint8_t spaceship_data[1026];
#define spaceship ((gfx_sprite_t*)spaceship_data)
#define bullet_width 16
#define bullet_height 16
#define bullet_size 258
extern uint8_t bullet_data[258];
#define bullet ((gfx_sprite_t*)bullet_data)
#define baddie_width 32
#define baddie_height 32
#define baddie_size 1026
extern uint8_t baddie_data[1026];
#define baddie ((gfx_sprite_t*)baddie_data)
#define sizeof_sprites_pal 18
extern uint16_t sprites_pal[9];
#endif

106
src/main.c Normal file
View File

@ -0,0 +1,106 @@
// Libraries lol
#include <stddef.h>
#include <stdint.h>
#include <tice.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <debug.h>
#include <graphx.h>
#include <keypadc.h>
// Graphics
#include "gfx/sprites.h"
// set global vars
kb_key_t key;
float speed = 0.5;
int i;
int bulletSpawned;
int baddieSpawned;
// Include entity headers
#include "player.h"
#include "bullet.h"
#include "baddie.h"
void setup() {
boot_Set48MHzModeI();
/* Initialize the 8bpp graphics */
gfx_Begin();
dbg_sprintf(dbgout, "This is the start of a CEmu debugging test\n");
dbg_Debugger();
/* Set up the palette for our sprites */
gfx_SetPalette(sprites_pal, sizeof_sprites_pal, 0);
// Clear screen
gfx_FillScreen(02);
}
void main(void) {
setup();
do {
// Scan keyboard for button presses
kb_Scan();
// Move all alive bullets
updateBullets();
// set key to keyboard memory adress row 7
key = kb_Data[7];
// Move player
//// Down
if (key & kb_Down) {
if (!(player.pos.y >= (LCD_HEIGHT - 32))) {
player.pos.y += speed;
}
}
//// Up
if (key & kb_Up) {
if (!(player.pos.y <= 0)) {
player.pos.y -= speed;
}
}
//// Left
if (key & kb_Left) {
if (!(player.pos.x <= 0)) {
player.pos.x -= speed;
}
}
//// Right
if (key & kb_Right) {
if (!(player.pos.x >= (LCD_WIDTH - 32))) {
player.pos.x += speed;
}
}
// Spawn bullet on 2nd press
if (kb_Data[1] & kb_2nd) {
// If bullet has already been spawned (You cannot hold the button)
if (bulletSpawned == 0){
spawnBullet((player.pos.x + 16), (player.pos.y + 8));
bulletSpawned = 1;
}
}
// Set bulletSpawned to false if button is let loose
if (kb_Data[1] != kb_2nd){
bulletSpawned = 0;
}
// Redraw all sprites if player pos has changed or a bullet has been spawned
if ( (abs(player.oldPos.x - player.pos.x) >= 1) || (abs(player.oldPos.y - player.pos.y) >= 1) || bulletSpawned == 1) {
gfx_Sprite(spaceship, player.pos.x, player.pos.y);
player.oldPos.x = player.pos.x;
player.oldPos.y = player.pos.y;
}
} while (kb_Data[6] != kb_Enter);
// Close the graphics
gfx_End();
}

22
src/player.h Normal file
View File

@ -0,0 +1,22 @@
// player.h
struct Player {
struct pos {
float x;
float y;
} pos;
struct oldPos {
float x;
float y;
} oldPos;
} player;
// Player starting position
player.pos.x = 10;
player.pos.y = 136;
player.oldPos.x = 10;
player.oldPos.y = 10;
void updatePlayer(float dx, float dy) {
player.pos.x = player.pos.x + dx;
player.pos.y = player.pos.y + dy;
}