summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2019-04-14 20:10:23 -0400
committerAndrew Opalach <andrew@akon.city> 2019-04-14 20:10:23 -0400
commit4477c1db42b579a441bf0a62bed2f627176f1c76 (patch)
treee6960d29717ddecd45c88fa7ec510e644eecfda8
parent2e59a5b0a8e8b70f30d44de7d14e53c800e19914 (diff)
downloadcetris-4477c1db42b579a441bf0a62bed2f627176f1c76.tar.gz
cetris-4477c1db42b579a441bf0a62bed2f627176f1c76.tar.bz2
cetris-4477c1db42b579a441bf0a62bed2f627176f1c76.zip
add next piece delay for when a line is cleared + cleanup
-rw-r--r--core/include/cetris.h35
-rw-r--r--core/include/input.h6
-rw-r--r--core/include/matrix.h10
-rw-r--r--core/include/test.h8
-rw-r--r--core/src/cetris.c105
-rw-r--r--core/src/input.c2
-rw-r--r--core/src/matrix.c31
-rw-r--r--core/src/test.c2
-rw-r--r--frontends/calculator/Makefile8
-rw-r--r--frontends/calculator/obj/gfx/block_1.src98
-rw-r--r--frontends/calculator/obj/gfx/block_2.src98
-rw-r--r--frontends/calculator/obj/gfx/block_3.src98
-rw-r--r--frontends/calculator/obj/gfx/block_4.src98
-rw-r--r--frontends/calculator/obj/gfx/block_5.src98
-rw-r--r--frontends/calculator/obj/gfx/block_6.src98
-rw-r--r--frontends/calculator/obj/gfx/block_7.src98
-rw-r--r--frontends/calculator/obj/gfx/logo_gfx.src22
-rw-r--r--frontends/calculator/obj/main.src172
l---------frontends/calculator/src/cetris.c1
l---------frontends/calculator/src/cetris.h1
-rw-r--r--frontends/calculator/src/gfx/block_1.c17
-rw-r--r--frontends/calculator/src/gfx/block_1.pngbin0 -> 127 bytes
-rw-r--r--frontends/calculator/src/gfx/block_2.c17
-rw-r--r--frontends/calculator/src/gfx/block_2.pngbin0 -> 129 bytes
-rw-r--r--frontends/calculator/src/gfx/block_3.c17
-rw-r--r--frontends/calculator/src/gfx/block_3.pngbin0 -> 129 bytes
-rw-r--r--frontends/calculator/src/gfx/block_4.c17
-rw-r--r--frontends/calculator/src/gfx/block_4.pngbin0 -> 129 bytes
-rw-r--r--frontends/calculator/src/gfx/block_5.c17
-rw-r--r--frontends/calculator/src/gfx/block_5.pngbin0 -> 126 bytes
-rw-r--r--frontends/calculator/src/gfx/block_6.c17
-rw-r--r--frontends/calculator/src/gfx/block_6.pngbin0 -> 129 bytes
-rw-r--r--frontends/calculator/src/gfx/block_7.c17
-rw-r--r--frontends/calculator/src/gfx/block_7.pngbin0 -> 129 bytes
-rw-r--r--frontends/calculator/src/gfx/convpng.ini10
-rw-r--r--frontends/calculator/src/gfx/convpng.log20
-rw-r--r--frontends/calculator/src/gfx/logo_gfx.c14
-rw-r--r--frontends/calculator/src/gfx/logo_gfx.h47
l---------frontends/calculator/src/input.c1
l---------frontends/calculator/src/input.h1
-rw-r--r--frontends/calculator/src/main.c41
l---------frontends/calculator/src/matrix.c1
l---------frontends/calculator/src/matrix.h1
l---------frontends/calculator/src/types.h1
-rw-r--r--frontends/curses/curses_ui.c6
-rw-r--r--frontends/gl/main.c2
46 files changed, 1261 insertions, 92 deletions
diff --git a/core/include/cetris.h b/core/include/cetris.h
index 9e3cf83..1606f2a 100644
--- a/core/include/cetris.h
+++ b/core/include/cetris.h
@@ -10,16 +10,18 @@
#define CETRIS_INITIAL_X 3
#define CETRIS_INITIAL_Y 0
#define CETRIS_INITIAL_Y_OFFSET 2
-//#define CETRIS_BOARD_VISABLE 21
#define CETRIS_HZ 60
#define CETRIS_DAS_DELAY 11
#define CETRIS_DAS_PERIOD 3
#define CETRIS_DROP_PERIOD 2
+#define CETRIS_NEXT_PIECE_DELAY 40
#define CETRIS_LINE_CLEAR_DELAY 40
#define CETRIS_LOCK_DELAY 40
#define CETRIS_WAIT_ON_CLEAR 0
+#define CETRIS_STARTING_LEVEL 1
+
typedef enum {
O, I, S, Z, L, J, T
} type;
@@ -42,15 +44,16 @@ typedef enum {
TWICE
} rstate;
-struct tetrimino {
+typedef struct {
type t;
rstate r;
color c;
piece_matrix m;
- u8 ghost_y;
+ i8 ghost_y;
vec2 pos;
u32 lock_tick;
-};
+ bool locked;
+} tetrimino;
typedef struct {
bool occupied;
@@ -60,15 +63,15 @@ typedef struct {
color c;
} slot;
-struct cetris_game {
+typedef struct {
/* playfield represented by a 2d array */
slot board[CETRIS_BOARD_X][CETRIS_BOARD_Y];
/* constant queue of all 7 possible tetrimino */
- struct tetrimino piece_queue[7];
+ tetrimino piece_queue[7];
/* current tetrimino */
- struct tetrimino current;
+ tetrimino current;
u8 current_index;
/* input_manager */
@@ -81,6 +84,7 @@ struct cetris_game {
/* internal game tick */
u32 tick;
u32 next_drop_tick;
+ u32 next_piece_tick;
/* progress trackers */
u32 lines;
@@ -92,15 +96,16 @@ struct cetris_game {
bool mini_tspin;
/* score counter */
- u64 score;
-};
+ u32 score;
+} cetris_game;
-void next_piece(struct cetris_game* g);
-void update_board(struct cetris_game* g);
+void next_piece(cetris_game* g);
+void update_board(cetris_game* g);
+void lock_current(cetris_game* g);
/* API PROTOTYPES FUNCTIONS */
-void init_game(struct cetris_game* g);
-void update_game_tick(struct cetris_game* g);
-void move_piece(struct cetris_game* g, input_t move);
-void stop_holding(struct cetris_game* g, input_t move);
+void init_game(cetris_game* g);
+void update_game_tick(cetris_game* g);
+void move_piece(cetris_game* g, input_t move);
+void stop_holding(cetris_game* g, input_t move);
diff --git a/core/include/input.h b/core/include/input.h
index 3cfa947..95cb2aa 100644
--- a/core/include/input.h
+++ b/core/include/input.h
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <stdbool.h>
-struct cetris_game;
+#include "cetris.h"
-bool handle_inputs(struct cetris_game* g);
-void clear_held_key(struct cetris_game* g);
+bool handle_inputs(cetris_game *g);
+void clear_held_key(cetris_game *g);
diff --git a/core/include/matrix.h b/core/include/matrix.h
index 050a32e..eb9e272 100644
--- a/core/include/matrix.h
+++ b/core/include/matrix.h
@@ -7,8 +7,8 @@
extern const piece_matrix default_matrices[7];
-void move_current(struct cetris_game* g, input_t move);
-void hard_drop(struct cetris_game* g);
-void rotate_matrix(struct cetris_game* g, bool clockwise);
-void set_matrix(struct cetris_game* g, piece_matrix *m);
-i8 check_matrix(struct cetris_game* g, piece_matrix *m);
+void move_current(cetris_game* g, input_t move);
+void hard_drop(cetris_game* g);
+void rotate_matrix(cetris_game* g, bool clockwise);
+void set_matrix(cetris_game* g, piece_matrix* m);
+i8 check_matrix(cetris_game* g, piece_matrix* m);
diff --git a/core/include/test.h b/core/include/test.h
index d700627..4b8622e 100644
--- a/core/include/test.h
+++ b/core/include/test.h
@@ -1,8 +1,8 @@
-struct cetris_game;
+#include "cetris.h"
-enum tests {
+typedef enum {
TSPIN,
TSPIN_NO_LINES
-};
+} test;
-void apply_test_board(struct cetris_game* g, enum tests t);
+void apply_test_board( cetris_game* g, test t);
diff --git a/core/src/cetris.c b/core/src/cetris.c
index a3f2ded..4e404d6 100644
--- a/core/src/cetris.c
+++ b/core/src/cetris.c
@@ -1,4 +1,3 @@
-#include <locale.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
@@ -16,10 +15,9 @@
/* FUNCTION PROTOTYPES */
-static void init_piece_queue(struct cetris_game* g);
-static void shuffle_queue(struct cetris_game* g);
-static void set_constants(struct cetris_game* g);
-static void add_score(struct cetris_game* g, u8 lines);
+static void init_piece_queue(cetris_game* g);
+static void shuffle_queue(cetris_game* g);
+static void add_score(cetris_game* g, u8 lines);
/* LEVEL DROP SPEED VALUES */
@@ -29,34 +27,20 @@ static const u32 level_drop_delay[20] = {
/* GAME FUNCTIONS */
-void init_game(struct cetris_game* g) {
- srand(time(NULL));
+void init_game(cetris_game* g) {
+
+ /* check for config errors */
+ assert(CETRIS_NEXT_PIECE_DELAY >= CETRIS_LINE_CLEAR_DELAY);
- memset(g->board, 0, sizeof(slot) * CETRIS_BOARD_X * CETRIS_BOARD_Y);
+ srand(time(NULL));
#ifdef BUILD_TESTS
apply_test_board(g, TSPIN_NO_LINES);
#endif
- g->tick = 0;
- g->next_drop_tick = level_drop_delay[0];
-
- g->current_index = 0;
+ memset(g, 0, sizeof(cetris_game));
- memset(g->held_moves, 0, sizeof(bool) * 7);
- g->das_repeat = 0;
- g->prev_das_move = 0;
- g->das_move_tick = 0;
- g->down_move_tick = 0;
-
- g->lines = 0;
- g->level = 1;
- g->game_over = false;
-
- g->tspin = false;
- g->mini_tspin = false;
-
- g->score = 0;
+ g->level = CETRIS_STARTING_LEVEL;
init_piece_queue(g);
shuffle_queue(g);
@@ -64,34 +48,46 @@ void init_game(struct cetris_game* g) {
next_piece(g);
}
-void init_piece_queue(struct cetris_game* g) {
+void init_piece_queue(cetris_game* g) {
for (u8 i = 0; i < 7; i++) {
g->piece_queue[i].t = i;
g->piece_queue[i].c = i + 1;
memcpy(g->piece_queue[i].m, default_matrices[i], sizeof(piece_matrix));
g->piece_queue[i].r = INIT;
g->piece_queue[i].lock_tick = 0;
- g->piece_queue[i].pos = (vec2){CETRIS_INITIAL_X, CETRIS_INITIAL_Y - CETRIS_INITIAL_Y_OFFSET};
+ g->piece_queue[i].locked = false;
g->piece_queue[i].ghost_y = 0;
+ g->piece_queue[i].pos = (vec2){CETRIS_INITIAL_X, CETRIS_INITIAL_Y - CETRIS_INITIAL_Y_OFFSET};
}
}
-void shuffle_queue(struct cetris_game* g) {
+void shuffle_queue(cetris_game* g) {
for (u8 i = 0; i < 7; i++) {
- struct tetrimino t = g->piece_queue[i];
+ tetrimino t = g->piece_queue[i];
u8 rand_index = rand() % 7;
g->piece_queue[i] = g->piece_queue[rand_index];
g->piece_queue[rand_index] = t;
}
}
-void update_game_tick(struct cetris_game* g) {
+void update_game_tick(cetris_game* g) {
if (g->game_over) return;
+ g->tick++;
+
+ if (g->next_piece_tick && g->tick >= g->next_piece_tick) {
+ next_piece(g);
+ }
+
+ if (g->next_piece_tick) return;
+
bool did_move = false;
if (g->tick >= g->next_drop_tick || !g->next_drop_tick) {
- if (g->next_drop_tick) move_current(g, DOWN);
- did_move = true;
+ if (g->next_drop_tick) {
+ move_current(g, DOWN);
+ did_move = true;
+ }
+
if (g->level <= 20) {
g->next_drop_tick = g->tick + level_drop_delay[g->level - 1];
} else {
@@ -100,10 +96,11 @@ void update_game_tick(struct cetris_game* g) {
}
/* lock piece if it was hovering for CETRIS_LOCK_DELAY */
- if (g->current.lock_tick && g->current.lock_tick <= g->tick) {
+ if (!g->next_piece_tick && g->current.lock_tick && g->current.lock_tick <= g->tick) {
g->current.pos.y++;
if (check_matrix(g, &g->current.m) <= 0) {
- next_piece(g);
+ lock_current(g);
+ did_move = true;
}
g->current.pos.y--;
g->current.lock_tick = 0;
@@ -114,14 +111,11 @@ void update_game_tick(struct cetris_game* g) {
}
if (did_move) update_board(g);
-
- g->tick++;
}
-void next_piece(struct cetris_game* g) {
- set_constants(g);
-
+void next_piece(cetris_game* g) {
g->next_drop_tick = 0;
+ g->next_piece_tick = 0;
g->current = g->piece_queue[g->current_index];
if (check_matrix(g, &g->current.m) <= 0) {
@@ -133,17 +127,21 @@ void next_piece(struct cetris_game* g) {
g->current_index = 0;
shuffle_queue(g);
}
+
+ update_board(g);
}
-void set_constants(struct cetris_game* g) {
+void lock_current(cetris_game* g) {
+ g->current.locked = true;
for (u8 x = 0; x < CETRIS_BOARD_X; x++) {
for (u8 y = 0; y < CETRIS_BOARD_Y; y++) {
if (g->board[x][y].occupied) g->board[x][y].constant = 1;
}
}
+ update_board(g);
}
-void make_ghosts(struct cetris_game* g) {
+void make_ghosts(cetris_game* g) {
u8 orig_y = g->current.pos.y;
while (true) {
g->current.pos.y++;
@@ -155,7 +153,9 @@ void make_ghosts(struct cetris_game* g) {
}
}
-void update_board(struct cetris_game* g) {
+void update_board(cetris_game* g) {
+ if (g->game_over) return;
+
u8 lines_cleared = 0;
for (u8 y = 0; y < CETRIS_BOARD_Y; y++) {
bool clear_line = true;
@@ -175,15 +175,26 @@ void update_board(struct cetris_game* g) {
g->board[x][s + 1] = g->board[x][s];
}
}
+ }
+ if (clear_line) {
+ g->board[0][y].remove_tick = g->tick + CETRIS_LINE_CLEAR_DELAY;
lines_cleared++;
}
- if (clear_line) g->board[0][y].remove_tick = g->tick + CETRIS_LINE_CLEAR_DELAY;
}
make_ghosts(g);
set_matrix(g, &g->current.m);
assert(lines_cleared <= 4);
+
+ if (g->current.locked && !g->next_piece_tick) {
+ if (lines_cleared > 0) {
+ g->next_piece_tick = g->tick + CETRIS_NEXT_PIECE_DELAY;
+ } else {
+ next_piece(g);
+ }
+ }
+
if (lines_cleared > 0 || g->tspin || g->mini_tspin) {
add_score(g, lines_cleared);
if (lines_cleared > 0) {
@@ -195,7 +206,7 @@ void update_board(struct cetris_game* g) {
/* SCORE FUNCTIONS */
-void add_score(struct cetris_game* g, u8 lines) {
+void add_score(cetris_game* g, u8 lines) {
if (!g->tspin && !g->mini_tspin) {
switch (lines) {
case 1: g->score += 100 * g->level; break;
@@ -223,7 +234,7 @@ void add_score(struct cetris_game* g, u8 lines) {
/* MOVEMENT FUNCTIONS */
-void move_piece(struct cetris_game* g, input_t move) {
+void move_piece(cetris_game* g, input_t move) {
if (!g->held_moves[move]) {
switch (move) {
case LEFT:
@@ -246,7 +257,7 @@ void move_piece(struct cetris_game* g, input_t move) {
g->held_moves[move] = true;
}
-void stop_holding(struct cetris_game* g, input_t move) {
+void stop_holding(cetris_game* g, input_t move) {
g->held_moves[move] = false;
if (move == RIGHT || move == LEFT) {
g->das_move_tick = 0;
diff --git a/core/src/input.c b/core/src/input.c
index 2904158..65dead1 100644
--- a/core/src/input.c
+++ b/core/src/input.c
@@ -6,7 +6,7 @@
#include "matrix.h"
#include "cetris.h"
-bool handle_inputs(struct cetris_game* g) {
+bool handle_inputs(cetris_game* g) {
if ((g->held_moves[RIGHT] || g->held_moves[LEFT]) && !g->das_move_tick) {
if (g->das_repeat == 0) {
g->das_move_tick = g->tick + CETRIS_DAS_DELAY;
diff --git a/core/src/matrix.c b/core/src/matrix.c
index 86e9ad2..caae107 100644
--- a/core/src/matrix.c
+++ b/core/src/matrix.c
@@ -88,8 +88,8 @@ const vec2 basic_movements[5] = {
{0, 0}, {0, 1}, {0, 1}, {1, 0}, {-1, 0} // NONE, DOWN, USER_DOWN, RIGHT, LEFT
};
-void move_current(struct cetris_game* g, input_t move) {
- if (g->game_over) return;
+void move_current(cetris_game* g, input_t move) {
+ if (g->game_over || g->next_piece_tick) return;
g->current.pos.y += basic_movements[move].y;
g->current.pos.x += basic_movements[move].x;
@@ -108,7 +108,7 @@ void move_current(struct cetris_game* g, input_t move) {
update_board(g);
}
-i8 check_matrix(struct cetris_game* g, piece_matrix *m) {
+i8 check_matrix(cetris_game* g, piece_matrix* m) {
for (i8 y = 0; y < 4; y++) {
for (i8 x = 0; x < 4; x++) {
vec2 r = (vec2){x + g->current.pos.x, y + g->current.pos.y};
@@ -124,7 +124,7 @@ i8 check_matrix(struct cetris_game* g, piece_matrix *m) {
return 1;
}
-void set_matrix(struct cetris_game *g, piece_matrix *m) {
+void set_matrix(cetris_game* g, piece_matrix* m) {
for (i8 y = 0; y < 4; y++) {
for (i8 x = 0; x < 4; x++) {
vec2 r = (vec2){x + g->current.pos.x, y + g->current.pos.y};
@@ -134,15 +134,17 @@ void set_matrix(struct cetris_game *g, piece_matrix *m) {
g->board[r.x][r.y].c = g->current.c;
}
if (g->current.ghost_y + y >= 0) {
- g->board[r.x][g->current.ghost_y + y].ghost = true;
+ if (r.y != (g->current.ghost_y + y)) {
+ g->board[r.x][g->current.ghost_y + y].ghost = true;
+ }
}
}
}
}
}
-void hard_drop(struct cetris_game* g) {
- if (g->game_over) return;
+void hard_drop(cetris_game* g) {
+ if (g->game_over || g->next_piece_tick) return;
bool drop = false;
u8 drop_count = 0;
@@ -159,11 +161,11 @@ void hard_drop(struct cetris_game* g) {
g->score += 2 * drop_count; // 2 score for each hard-drop'd cell
update_board(g);
- next_piece(g);
+ lock_current(g);
}
-void rotate_matrix(struct cetris_game* g, bool clockwise) {
- if (g->game_over) return;
+void rotate_matrix(cetris_game* g, bool clockwise) {
+ if (g->game_over || g->next_piece_tick) return;
if (g->current.t == O) return;
rstate next = 0;
@@ -213,8 +215,11 @@ void rotate_matrix(struct cetris_game* g, bool clockwise) {
u8 new_y = (clockwise) ? 2 + (x - 1) : 2 - (x - 1);
if (g->current.t == I) {
- if (clockwise) new_y--;
- else new_x++;
+ if (clockwise) {
+ new_y--;
+ } else {
+ new_x++;
+ }
}
m[new_y][new_x] = 1;
@@ -231,8 +236,10 @@ void rotate_matrix(struct cetris_game* g, bool clockwise) {
} else {
kick = srs_wall_kicks[wall_kick][i];
}
+
g->current.pos.x += kick.x;
g->current.pos.y += kick.y;
+
if (check_matrix(g, &m) > 0) {
set_current = true;
if (i > 0) did_kick = true;
diff --git a/core/src/test.c b/core/src/test.c
index 7db2fe5..bad50d8 100644
--- a/core/src/test.c
+++ b/core/src/test.c
@@ -47,7 +47,7 @@ u8 tspin_no_lines_board[20][10] = {
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }
};
-void apply_test_board(struct cetris_game* g, enum tests t) {
+void apply_test_board(cetris_game* g, test t) {
u8 (*board)[20][10];
switch (t) {
case TSPIN:
diff --git a/frontends/calculator/Makefile b/frontends/calculator/Makefile
new file mode 100644
index 0000000..505d4bf
--- /dev/null
+++ b/frontends/calculator/Makefile
@@ -0,0 +1,8 @@
+NAME ?= Cetris
+COMPRESSED ?= NO
+ICON ?= iconc.png
+DESCRIPTION ?= "Cetris for calculator"
+
+# ----------------------------
+
+include $(CEDEV)/include/.makefile
diff --git a/frontends/calculator/obj/gfx/block_1.src b/frontends/calculator/obj/gfx/block_1.src
new file mode 100644
index 0000000..19a50e7
--- /dev/null
+++ b/frontends/calculator/obj/gfx/block_1.src
@@ -0,0 +1,98 @@
+; Zilog eZ80 ANSI C Compiler Release 3.4
+; -optsize -noreduceopt -nomodsect -peephole -globalopt
+; -localcse -const=ROM
+ FILE "SRC\GFX\BLOCK_1.C"
+ .assume ADL=1
+ SEGMENT DATA
+_block_1_data:
+ DB 9
+ DB 9
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 0
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 2
+ DB 2
+ DB 5
+ DB 0
+ DB 0
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 2
+ DB 2
+ DB 5
+ DB 0
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 2
+ DB 2
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 2
+ DB 2
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 2
+ DB 2
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 2
+ DB 2
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 5
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ XDEF _block_1_data
+; 1 // convpng v7.0
+; 2 #include <stdint.h>
+; 3 #include "logo_gfx.h"
+; 4
+; 5 // 8 bpp image
+; 6 uint8_t block_1_data[83] = {
+ END
diff --git a/frontends/calculator/obj/gfx/block_2.src b/frontends/calculator/obj/gfx/block_2.src
new file mode 100644
index 0000000..200b19f
--- /dev/null
+++ b/frontends/calculator/obj/gfx/block_2.src
@@ -0,0 +1,98 @@
+; Zilog eZ80 ANSI C Compiler Release 3.4
+; -optsize -noreduceopt -nomodsect -peephole -globalopt
+; -localcse -const=ROM
+ FILE "SRC\GFX\BLOCK_2.C"
+ .assume ADL=1
+ SEGMENT DATA
+_block_2_data:
+ DB 9
+ DB 9
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 0
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 2
+ DB 2
+ DB 7
+ DB 0
+ DB 0
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 2
+ DB 2
+ DB 7
+ DB 0
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 2
+ DB 2
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 2
+ DB 2
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 2
+ DB 2
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 2
+ DB 2
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 7
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ XDEF _block_2_data
+; 1 // convpng v7.0
+; 2 #include <stdint.h>
+; 3 #include "logo_gfx.h"
+; 4
+; 5 // 8 bpp image
+; 6 uint8_t block_2_data[83] = {
+ END
diff --git a/frontends/calculator/obj/gfx/block_3.src b/frontends/calculator/obj/gfx/block_3.src
new file mode 100644
index 0000000..5126067
--- /dev/null
+++ b/frontends/calculator/obj/gfx/block_3.src
@@ -0,0 +1,98 @@
+; Zilog eZ80 ANSI C Compiler Release 3.4
+; -optsize -noreduceopt -nomodsect -peephole -globalopt
+; -localcse -const=ROM
+ FILE "SRC\GFX\BLOCK_3.C"
+ .assume ADL=1
+ SEGMENT DATA
+_block_3_data:
+ DB 9
+ DB 9
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 0
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 0
+ DB 0
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 0
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ XDEF _block_3_data
+; 1 // convpng v7.0
+; 2 #include <stdint.h>
+; 3 #include "logo_gfx.h"
+; 4
+; 5 // 8 bpp image
+; 6 uint8_t block_3_data[83] = {
+ END
diff --git a/frontends/calculator/obj/gfx/block_4.src b/frontends/calculator/obj/gfx/block_4.src
new file mode 100644
index 0000000..bc9ad7d
--- /dev/null
+++ b/frontends/calculator/obj/gfx/block_4.src
@@ -0,0 +1,98 @@
+; Zilog eZ80 ANSI C Compiler Release 3.4
+; -optsize -noreduceopt -nomodsect -peephole -globalopt
+; -localcse -const=ROM
+ FILE "SRC\GFX\BLOCK_4.C"
+ .assume ADL=1
+ SEGMENT DATA
+_block_4_data:
+ DB 9
+ DB 9
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 0
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 2
+ DB 2
+ DB 3
+ DB 0
+ DB 0
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 2
+ DB 2
+ DB 3
+ DB 0
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 2
+ DB 2
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 2
+ DB 2
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 2
+ DB 2
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 2
+ DB 2
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 3
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ XDEF _block_4_data
+; 1 // convpng v7.0
+; 2 #include <stdint.h>
+; 3 #include "logo_gfx.h"
+; 4
+; 5 // 8 bpp image
+; 6 uint8_t block_4_data[83] = {
+ END
diff --git a/frontends/calculator/obj/gfx/block_5.src b/frontends/calculator/obj/gfx/block_5.src
new file mode 100644
index 0000000..ec02546
--- /dev/null
+++ b/frontends/calculator/obj/gfx/block_5.src
@@ -0,0 +1,98 @@
+; Zilog eZ80 ANSI C Compiler Release 3.4
+; -optsize -noreduceopt -nomodsect -peephole -globalopt
+; -localcse -const=ROM
+ FILE "SRC\GFX\BLOCK_5.C"
+ .assume ADL=1
+ SEGMENT DATA
+_block_5_data:
+ DB 9
+ DB 9
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 0
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 2
+ DB 2
+ DB 4
+ DB 0
+ DB 0
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 2
+ DB 2
+ DB 4
+ DB 0
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 2
+ DB 2
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 2
+ DB 2
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 2
+ DB 2
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 2
+ DB 2
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 4
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ XDEF _block_5_data
+; 1 // convpng v7.0
+; 2 #include <stdint.h>
+; 3 #include "logo_gfx.h"
+; 4
+; 5 // 8 bpp image
+; 6 uint8_t block_5_data[83] = {
+ END
diff --git a/frontends/calculator/obj/gfx/block_6.src b/frontends/calculator/obj/gfx/block_6.src
new file mode 100644
index 0000000..7ae3009
--- /dev/null
+++ b/frontends/calculator/obj/gfx/block_6.src
@@ -0,0 +1,98 @@
+; Zilog eZ80 ANSI C Compiler Release 3.4
+; -optsize -noreduceopt -nomodsect -peephole -globalopt
+; -localcse -const=ROM
+ FILE "SRC\GFX\BLOCK_6.C"
+ .assume ADL=1
+ SEGMENT DATA
+_block_6_data:
+ DB 9
+ DB 9
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 0
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 0
+ DB 0
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 0
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 6
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ XDEF _block_6_data
+; 1 // convpng v7.0
+; 2 #include <stdint.h>
+; 3 #include "logo_gfx.h"
+; 4
+; 5 // 8 bpp image
+; 6 uint8_t block_6_data[83] = {
+ END
diff --git a/frontends/calculator/obj/gfx/block_7.src b/frontends/calculator/obj/gfx/block_7.src
new file mode 100644
index 0000000..fc945cd
--- /dev/null
+++ b/frontends/calculator/obj/gfx/block_7.src
@@ -0,0 +1,98 @@
+; Zilog eZ80 ANSI C Compiler Release 3.4
+; -optsize -noreduceopt -nomodsect -peephole -globalopt
+; -localcse -const=ROM
+ FILE "SRC\GFX\BLOCK_7.C"
+ .assume ADL=1
+ SEGMENT DATA
+_block_7_data:
+ DB 9
+ DB 9
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 0
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 2
+ DB 2
+ DB 1
+ DB 0
+ DB 0
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 2
+ DB 2
+ DB 1
+ DB 0
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 2
+ DB 2
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 2
+ DB 2
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 2
+ DB 2
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 2
+ DB 2
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 1
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ DB 2
+ XDEF _block_7_data
+; 1 // convpng v7.0
+; 2 #include <stdint.h>
+; 3 #include "logo_gfx.h"
+; 4
+; 5 // 8 bpp image
+; 6 uint8_t block_7_data[83] = {
+ END
diff --git a/frontends/calculator/obj/gfx/logo_gfx.src b/frontends/calculator/obj/gfx/logo_gfx.src
new file mode 100644
index 0000000..673beca
--- /dev/null
+++ b/frontends/calculator/obj/gfx/logo_gfx.src
@@ -0,0 +1,22 @@
+; 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 62052
+ DW 0
+ DW 52356
+ DW 14527
+ DW 8479
+ DW 41840
+ DW 22671
+ XDEF _logo_gfx_pal
+; 1 // convpng v7.0
+; 2 #include <stdint.h>
+; 3 #include "logo_gfx.h"
+; 4
+; 5 uint16_t logo_gfx_pal[8] = {
+ END
diff --git a/frontends/calculator/obj/main.src b/frontends/calculator/obj/main.src
new file mode 100644
index 0000000..8897b9b
--- /dev/null
+++ b/frontends/calculator/obj/main.src
@@ -0,0 +1,172 @@
+; Zilog eZ80 ANSI C Compiler Release 3.4
+; -optsize -noreduceopt -nomodsect -peephole -globalopt
+; -localcse -const=ROM
+ FILE "SRC\MAIN.C"
+ .assume ADL=1
+ SEGMENT CODE
+; 1 #include <stdbool.h>
+; 2 #include <stddef.h>
+; 3 #include <stdint.h>
+; 4 #include <tice.h>
+; 5
+; 6 #include <math.h>
+; 7 #include <stdio.h>
+; 8 #include <stdlib.h>
+; 9 #include <string.h>
+; 10
+; 11 #include <graphx.h>
+; 12
+; 13 #include "cetris.h"
+; 14
+; 15 /* Include the sprite data */
+; 16 #include "gfx/logo_gfx.h"
+; 17
+; 18 void main(void) {
+_main:
+; 19 /* Initialize the 8bpp graphics */
+; 20 gfx_Begin();
+ CALL _gfx_Begin
+; 21
+; 22 /* Set up the palette for our sprites */
+; 23 gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0);
+ LD BC,0
+ PUSH BC
+ LD BC,16
+ PUSH BC
+ LD BC,_logo_gfx_pal
+ PUSH BC
+ CALL _gfx_SetPalette
+ POP BC
+ POP BC
+ POP BC
+; 24
+; 25 /* Fill the screen with color index 0 */
+; 26 gfx_FillScreen(0);
+ LD BC,0
+ PUSH BC
+ CALL _gfx_FillScreen
+ POP BC
+; 27
+; 28 /* Draw a bunch of different styled sprites on the screen */
+; 29 gfx_Sprite(block_1, 0, 0);
+ LD BC,0
+ PUSH BC
+ PUSH BC
+ LD BC,_block_1_data
+ PUSH BC
+ CALL _gfx_Sprite
+ POP BC
+ POP BC
+ POP BC
+; 30 gfx_Sprite_NoClip(block_1, 32, 32);
+ LD BC,32
+ PUSH BC
+ PUSH BC
+ LD BC,_block_1_data
+ PUSH BC
+ CALL _gfx_Sprite_NoClip
+ POP BC
+ POP BC
+ POP BC
+; 31 gfx_TransparentSprite(block_1, 64, 64);
+ LD BC,64
+ PUSH BC
+ PUSH BC
+ LD BC,_block_1_data
+ PUSH BC
+ CALL _gfx_TransparentSprite
+ POP BC
+ POP BC
+ POP BC
+; 32 gfx_TransparentSprite_NoClip(block_1, 96, 96);
+ LD BC,96
+ PUSH BC
+ PUSH BC
+ LD BC,_block_1_data
+ PUSH BC
+ CALL _gfx_TransparentSprite_NoClip
+ POP BC
+ POP BC
+ POP BC
+; 33 gfx_ScaledSprite_NoClip(block_1, 128, 128, 2, 2);
+ LD BC,2
+ PUSH BC
+ PUSH BC
+ LD BC,128
+ PUSH BC
+ PUSH BC
+ LD BC,_block_1_data
+ PUSH BC
+ CALL _gfx_ScaledSprite_NoClip
+ POP BC
+ POP BC
+ POP BC
+ POP BC
+ POP BC
+; 34 gfx_ScaledTransparentSprite_NoClip(block_1, 128, 0, 3, 3);
+ LD BC,3
+ PUSH BC
+ PUSH BC
+ LD BC,0
+ PUSH BC
+ LD BC,128
+ PUSH BC
+ LD BC,_block_1_data
+ PUSH BC
+ CALL _gfx_ScaledTransparentSprite_NoClip
+ POP BC
+ POP BC
+ POP BC
+ POP BC
+ POP BC
+; 35
+; 36 /* Wait for a key to be pressed */
+; 37 while (!os_GetCSC());
+L_1:
+ CALL _os_GetCSC
+ OR A,A
+ JR Z,L_1
+; 38
+; 39 /* Close the graphics */
+; 40 gfx_End();
+ CALL _gfx_End
+; 41 }
+ RET
+
+
+;**************************** _main ***************************
+;Name Addr/Register Size Type
+;_gfx_End IMPORT ----- function
+;_os_GetCSC IMPORT ----- function
+;_gfx_ScaledTransparentSprite_NoClip IMPORT ----- function
+;_gfx_ScaledSprite_NoClip IMPORT ----- function
+;_gfx_TransparentSprite_NoClip IMPORT ----- function
+;_gfx_TransparentSprite IMPORT ----- function
+;_gfx_Sprite_NoClip IMPORT ----- function
+;_block_1_data IMPORT 83 variable
+;_gfx_Sprite IMPORT ----- function
+;_gfx_FillScreen IMPORT ----- function
+;_logo_gfx_pal IMPORT 16 variable
+;_gfx_SetPalette IMPORT ----- function
+;_gfx_Begin IMPORT ----- function
+
+
+; Stack Frame Size: 6 (bytes)
+; Spill Code: 0 (instruction)
+
+
+ XREF _logo_gfx_pal:ROM
+ XREF _block_1_data:ROM
+ XREF _gfx_ScaledTransparentSprite_NoClip:ROM
+ XREF _gfx_ScaledSprite_NoClip:ROM
+ XREF _gfx_TransparentSprite_NoClip:ROM
+ XREF _gfx_TransparentSprite:ROM
+ XREF _gfx_Sprite_NoClip:ROM
+ XREF _gfx_Sprite:ROM
+ XREF _gfx_FillScreen:ROM
+ XREF _gfx_SetPalette:ROM
+ XREF _gfx_End:ROM
+ XREF _gfx_Begin:ROM
+ XREF _os_GetCSC:ROM
+ XDEF _main
+ END
diff --git a/frontends/calculator/src/cetris.c b/frontends/calculator/src/cetris.c
new file mode 120000
index 0000000..ecbdb48
--- /dev/null
+++ b/frontends/calculator/src/cetris.c
@@ -0,0 +1 @@
+../../../core/src/cetris.c \ No newline at end of file
diff --git a/frontends/calculator/src/cetris.h b/frontends/calculator/src/cetris.h
new file mode 120000
index 0000000..37329b2
--- /dev/null
+++ b/frontends/calculator/src/cetris.h
@@ -0,0 +1 @@
+../../../core/include/cetris.h \ No newline at end of file
diff --git a/frontends/calculator/src/gfx/block_1.c b/frontends/calculator/src/gfx/block_1.c
new file mode 100644
index 0000000..58d58d3
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_1.c
@@ -0,0 +1,17 @@
+// convpng v7.0
+#include <stdint.h>
+#include "logo_gfx.h"
+
+// 8 bpp image
+uint8_t block_1_data[83] = {
+ 9,9, // width,height
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x00,0x05,0x05,0x05,0x05,0x05,0x05,0x02,
+ 0x02,0x05,0x00,0x00,0x05,0x05,0x05,0x05,0x02,
+ 0x02,0x05,0x00,0x05,0x05,0x05,0x05,0x05,0x02,
+ 0x02,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,
+ 0x02,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,
+ 0x02,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,
+ 0x02,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+};
diff --git a/frontends/calculator/src/gfx/block_1.png b/frontends/calculator/src/gfx/block_1.png
new file mode 100644
index 0000000..295821e
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_1.png
Binary files differ
diff --git a/frontends/calculator/src/gfx/block_2.c b/frontends/calculator/src/gfx/block_2.c
new file mode 100644
index 0000000..47c16cb
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_2.c
@@ -0,0 +1,17 @@
+// convpng v7.0
+#include <stdint.h>
+#include "logo_gfx.h"
+
+// 8 bpp image
+uint8_t block_2_data[83] = {
+ 9,9, // width,height
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x02,
+ 0x02,0x07,0x00,0x00,0x07,0x07,0x07,0x07,0x02,
+ 0x02,0x07,0x00,0x07,0x07,0x07,0x07,0x07,0x02,
+ 0x02,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x02,
+ 0x02,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x02,
+ 0x02,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x02,
+ 0x02,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+};
diff --git a/frontends/calculator/src/gfx/block_2.png b/frontends/calculator/src/gfx/block_2.png
new file mode 100644
index 0000000..29443db
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_2.png
Binary files differ
diff --git a/frontends/calculator/src/gfx/block_3.c b/frontends/calculator/src/gfx/block_3.c
new file mode 100644
index 0000000..798215c
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_3.c
@@ -0,0 +1,17 @@
+// convpng v7.0
+#include <stdint.h>
+#include "logo_gfx.h"
+
+// 8 bpp image
+uint8_t block_3_data[83] = {
+ 9,9, // width,height
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x00,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+};
diff --git a/frontends/calculator/src/gfx/block_3.png b/frontends/calculator/src/gfx/block_3.png
new file mode 100644
index 0000000..a4b6dfd
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_3.png
Binary files differ
diff --git a/frontends/calculator/src/gfx/block_4.c b/frontends/calculator/src/gfx/block_4.c
new file mode 100644
index 0000000..517aff2
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_4.c
@@ -0,0 +1,17 @@
+// convpng v7.0
+#include <stdint.h>
+#include "logo_gfx.h"
+
+// 8 bpp image
+uint8_t block_4_data[83] = {
+ 9,9, // width,height
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x02,
+ 0x02,0x03,0x00,0x00,0x03,0x03,0x03,0x03,0x02,
+ 0x02,0x03,0x00,0x03,0x03,0x03,0x03,0x03,0x02,
+ 0x02,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02,
+ 0x02,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02,
+ 0x02,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02,
+ 0x02,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+};
diff --git a/frontends/calculator/src/gfx/block_4.png b/frontends/calculator/src/gfx/block_4.png
new file mode 100644
index 0000000..e5b977e
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_4.png
Binary files differ
diff --git a/frontends/calculator/src/gfx/block_5.c b/frontends/calculator/src/gfx/block_5.c
new file mode 100644
index 0000000..073b138
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_5.c
@@ -0,0 +1,17 @@
+// convpng v7.0
+#include <stdint.h>
+#include "logo_gfx.h"
+
+// 8 bpp image
+uint8_t block_5_data[83] = {
+ 9,9, // width,height
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x02,
+ 0x02,0x04,0x00,0x00,0x04,0x04,0x04,0x04,0x02,
+ 0x02,0x04,0x00,0x04,0x04,0x04,0x04,0x04,0x02,
+ 0x02,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x02,
+ 0x02,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x02,
+ 0x02,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x02,
+ 0x02,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+};
diff --git a/frontends/calculator/src/gfx/block_5.png b/frontends/calculator/src/gfx/block_5.png
new file mode 100644
index 0000000..a63802c
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_5.png
Binary files differ
diff --git a/frontends/calculator/src/gfx/block_6.c b/frontends/calculator/src/gfx/block_6.c
new file mode 100644
index 0000000..4decd9b
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_6.c
@@ -0,0 +1,17 @@
+// convpng v7.0
+#include <stdint.h>
+#include "logo_gfx.h"
+
+// 8 bpp image
+uint8_t block_6_data[83] = {
+ 9,9, // width,height
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x00,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+};
diff --git a/frontends/calculator/src/gfx/block_6.png b/frontends/calculator/src/gfx/block_6.png
new file mode 100644
index 0000000..a4b6dfd
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_6.png
Binary files differ
diff --git a/frontends/calculator/src/gfx/block_7.c b/frontends/calculator/src/gfx/block_7.c
new file mode 100644
index 0000000..67122d1
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_7.c
@@ -0,0 +1,17 @@
+// convpng v7.0
+#include <stdint.h>
+#include "logo_gfx.h"
+
+// 8 bpp image
+uint8_t block_7_data[83] = {
+ 9,9, // width,height
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x02,
+ 0x02,0x01,0x00,0x00,0x01,0x01,0x01,0x01,0x02,
+ 0x02,0x01,0x00,0x01,0x01,0x01,0x01,0x01,0x02,
+ 0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,
+ 0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,
+ 0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,
+ 0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+};
diff --git a/frontends/calculator/src/gfx/block_7.png b/frontends/calculator/src/gfx/block_7.png
new file mode 100644
index 0000000..8cb6da8
--- /dev/null
+++ b/frontends/calculator/src/gfx/block_7.png
Binary files differ
diff --git a/frontends/calculator/src/gfx/convpng.ini b/frontends/calculator/src/gfx/convpng.ini
new file mode 100644
index 0000000..fcf7193
--- /dev/null
+++ b/frontends/calculator/src/gfx/convpng.ini
@@ -0,0 +1,10 @@
+#GroupC : logo_gfx
+#TransparentColor : 255,255,255
+#PNGImages :
+ block_1
+ block_2
+ block_3
+ block_4
+ block_5
+ block_6
+ block_7
diff --git a/frontends/calculator/src/gfx/convpng.log b/frontends/calculator/src/gfx/convpng.log
new file mode 100644
index 0000000..538c0d0
--- /dev/null
+++ b/frontends/calculator/src/gfx/convpng.log
@@ -0,0 +1,20 @@
+opened convpng.ini
+
+--- logo_gfx (C) ---
+building palette with [256] available indices ...
+built palette with [8] indices.
+palette quality : 100.00%
+transparent color index : 0
+transparent color : 0xFFFF
+7:
+ block_1 : 100.00%
+ block_2 : 100.00%
+ block_3 : 100.00%
+ block_4 : 100.00%
+ block_5 : 100.00%
+ block_6 : 100.00%
+ block_7 : 100.00%
+
+converted in 0 s
+
+finished!
diff --git a/frontends/calculator/src/gfx/logo_gfx.c b/frontends/calculator/src/gfx/logo_gfx.c
new file mode 100644
index 0000000..3509c0e
--- /dev/null
+++ b/frontends/calculator/src/gfx/logo_gfx.c
@@ -0,0 +1,14 @@
+// convpng v7.0
+#include <stdint.h>
+#include "logo_gfx.h"
+
+uint16_t logo_gfx_pal[8] = {
+ 0xFFFF, // 00 :: rgb(255,255,255)
+ 0xF264, // 01 :: rgb(231,156,33)
+ 0x0000, // 02 :: rgb(0,0,0)
+ 0xCC84, // 03 :: rgb(160,35,30)
+ 0x38BF, // 04 :: rgb(115,41,255)
+ 0x211F, // 05 :: rgb(66,66,255)
+ 0xA370, // 06 :: rgb(66,222,132)
+ 0x588F, // 07 :: rgb(181,33,123)
+}; \ No newline at end of file
diff --git a/frontends/calculator/src/gfx/logo_gfx.h b/frontends/calculator/src/gfx/logo_gfx.h
new file mode 100644
index 0000000..02714e5
--- /dev/null
+++ b/frontends/calculator/src/gfx/logo_gfx.h
@@ -0,0 +1,47 @@
+// convpng v7.0
+// this file contains all the graphics sources for easy inclusion in a project
+#ifndef __logo_gfx__
+#define __logo_gfx__
+#include <stdint.h>
+
+#define logo_gfx_transparent_color_index 0
+
+#define block_1_width 9
+#define block_1_height 9
+#define block_1_size 83
+extern uint8_t block_1_data[83];
+#define block_1 ((gfx_sprite_t*)block_1_data)
+#define block_2_width 9
+#define block_2_height 9
+#define block_2_size 83
+extern uint8_t block_2_data[83];
+#define block_2 ((gfx_sprite_t*)block_2_data)
+#define block_3_width 9
+#define block_3_height 9
+#define block_3_size 83
+extern uint8_t block_3_data[83];
+#define block_3 ((gfx_sprite_t*)block_3_data)
+#define block_4_width 9
+#define block_4_height 9
+#define block_4_size 83
+extern uint8_t block_4_data[83];
+#define block_4 ((gfx_sprite_t*)block_4_data)
+#define block_5_width 9
+#define block_5_height 9
+#define block_5_size 83
+extern uint8_t block_5_data[83];
+#define block_5 ((gfx_sprite_t*)block_5_data)
+#define block_6_width 9
+#define block_6_height 9
+#define block_6_size 83
+extern uint8_t block_6_data[83];
+#define block_6 ((gfx_sprite_t*)block_6_data)
+#define block_7_width 9
+#define block_7_height 9
+#define block_7_size 83
+extern uint8_t block_7_data[83];
+#define block_7 ((gfx_sprite_t*)block_7_data)
+#define sizeof_logo_gfx_pal 16
+extern uint16_t logo_gfx_pal[8];
+
+#endif
diff --git a/frontends/calculator/src/input.c b/frontends/calculator/src/input.c
new file mode 120000
index 0000000..5b377ca
--- /dev/null
+++ b/frontends/calculator/src/input.c
@@ -0,0 +1 @@
+../../../core/src/input.c \ No newline at end of file
diff --git a/frontends/calculator/src/input.h b/frontends/calculator/src/input.h
new file mode 120000
index 0000000..d569ad2
--- /dev/null
+++ b/frontends/calculator/src/input.h
@@ -0,0 +1 @@
+../../../core/include/input.h \ No newline at end of file
diff --git a/frontends/calculator/src/main.c b/frontends/calculator/src/main.c
new file mode 100644
index 0000000..535f431
--- /dev/null
+++ b/frontends/calculator/src/main.c
@@ -0,0 +1,41 @@
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <tice.h>
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <graphx.h>
+
+#include "cetris.h"
+
+/* Include the sprite data */
+#include "gfx/logo_gfx.h"
+
+void main(void) {
+ /* Initialize the 8bpp graphics */
+ gfx_Begin();
+
+ /* Set up the palette for our sprites */
+ gfx_SetPalette(logo_gfx_pal, sizeof_logo_gfx_pal, 0);
+
+ /* Fill the screen with color index 0 */
+ gfx_FillScreen(0);
+
+ /* Draw a bunch of different styled sprites on the screen */
+ gfx_Sprite(block_1, 0, 0);
+ gfx_Sprite_NoClip(block_1, 32, 32);
+ gfx_TransparentSprite(block_1, 64, 64);
+ gfx_TransparentSprite_NoClip(block_1, 96, 96);
+ gfx_ScaledSprite_NoClip(block_1, 128, 128, 2, 2);
+ gfx_ScaledTransparentSprite_NoClip(block_1, 128, 0, 3, 3);
+
+ /* Wait for a key to be pressed */
+ while (!os_GetCSC());
+
+ /* Close the graphics */
+ gfx_End();
+}
diff --git a/frontends/calculator/src/matrix.c b/frontends/calculator/src/matrix.c
new file mode 120000
index 0000000..9a72a36
--- /dev/null
+++ b/frontends/calculator/src/matrix.c
@@ -0,0 +1 @@
+../../../core/src/matrix.c \ No newline at end of file
diff --git a/frontends/calculator/src/matrix.h b/frontends/calculator/src/matrix.h
new file mode 120000
index 0000000..0b441d9
--- /dev/null
+++ b/frontends/calculator/src/matrix.h
@@ -0,0 +1 @@
+../../../core/include/matrix.h \ No newline at end of file
diff --git a/frontends/calculator/src/types.h b/frontends/calculator/src/types.h
new file mode 120000
index 0000000..65216e0
--- /dev/null
+++ b/frontends/calculator/src/types.h
@@ -0,0 +1 @@
+../../../core/include/types.h \ No newline at end of file
diff --git a/frontends/curses/curses_ui.c b/frontends/curses/curses_ui.c
index 1f1440c..5557ed9 100644
--- a/frontends/curses/curses_ui.c
+++ b/frontends/curses/curses_ui.c
@@ -66,7 +66,7 @@
#define X_OFFSET 8
#define Y_OFFSET 0
-struct cetris_game game;
+cetris_game game;
void curses_init() {
setlocale(LC_CTYPE, "");
@@ -119,7 +119,7 @@ void draw_board() {
}
if (game.board[x][y].occupied) {
attron(COLOR_PAIR(game.board[x][y].c) | A_BOLD);
- if (game.board[0][y].remove_tick > 0) {
+ if (game.board[0][y].remove_tick) {
if (game.tick % 2 == 0) {
mvaddstr((y) + 1, x * 2 + X_OFFSET, BLOCK);
}
@@ -148,7 +148,7 @@ void draw_board() {
attron(A_BOLD);
char score[50];
- sprintf(score, "%li", game.score);
+ sprintf(score, "%i", game.score);
mvaddstr(1, (39 + X_OFFSET) - strlen(score), score);
char level[20];
diff --git a/frontends/gl/main.c b/frontends/gl/main.c
index a105290..1cab197 100644
--- a/frontends/gl/main.c
+++ b/frontends/gl/main.c
@@ -188,7 +188,7 @@ int main(void) {
struct block_drawable block;
create_block(&block);
- struct cetris_game cetris;
+ cetris_game cetris;
init_game(&cetris);
double prev_time = glfwGetTime();