Begin renaming graphic files to mention they're for HGR

This commit is contained in:
hkz 2025-10-07 11:59:16 +02:00
commit dbc1bebf9f
9 changed files with 209 additions and 209 deletions

View file

@ -23,13 +23,13 @@ INTRO_ASM_SRCS = tk2k_startup_module.s preserve_zero_pages.s
INTRO_C_SRCS = intro_main.c utility.c
DLOG_ASM_SRCS = tk2k_startup_module.s preserve_zero_pages.s sound.s
DLOG_C_SRCS = dlog_main.c input.c utility.c game_graphics.c line_data.c
DLOG_C_SRCS = dlog_main.c input.c utility.c game_hgr_graphics.c line_data.c
GAME_ASM_SRCS = tk2k_startup_module.s preserve_zero_pages.s input_asm.s sound.s
GAME_C_SRCS = game_main.c input.c utility.c game_graphics.c line_data.c game_logic.c arrows_pic.c tiles.c graph_misc_data.c
GAME_C_SRCS = game_main.c input.c utility.c game_hgr_graphics.c line_data.c game_logic.c arrows_pic.c tiles.c graph_misc_data.c
DEMO_ASM_SRCS = tk2k_startup_module.s preserve_zero_pages.s input_asm.s sound.s
DEMO_C_SRCS = demo_main.c input.c utility.c game_graphics_demo.c line_data.c game_logic.c arrows_pic.c tiles.c graph_misc_data.c
DEMO_C_SRCS = demo_main.c input.c utility.c game_hgr_graphics_demo.c line_data.c game_logic.c arrows_pic.c tiles.c graph_misc_data.c
# Object files
MASTER_OBJS = $(MASTER_ASM_SRCS:%.s=%.o) $(MASTER_C_SRCS:%.c=%.o)

View file

@ -12,7 +12,7 @@
#include "game_data.h"
#include "input.h"
#include "game_logic.h"
#include "game_graphics.h"
#include "game_hgr_graphics.h"
#include "monitor_subroutines.h"
#include "sound.h"

View file

@ -3,7 +3,7 @@
#include <calypsi/intrinsics6502.h>
#include "game_graphics.h"
#include "game_hgr_graphics.h"
#include "monitor_subroutines.h"
#include "utility.h"
#include "mem_map.h"

View file

@ -1,3 +0,0 @@
#define _DEMO_MODE_ 1
#include "game_graphics.c"

View file

@ -1,4 +1,4 @@
#include "game_graphics.h"
#include "game_hgr_graphics.h"
#include <string.h>

View file

@ -1,34 +1,34 @@
#ifndef _GAME_GRAPHICS_HEADER_
#define _GAME_GRAPHICS_HEADER_
#include <stdint.h>
#define BRD_DOUBLING_UP(a) (a & 0x01)
#define BRD_DOUBLING_DOWN(a) (a & 0x02)
#define BRD_DOUBLING_LEFT(a) (a & 0x04)
#define BRD_DOUBLING_RIGHT(a) (a & 0x08)
#define BRD_SKIP_UP(a) (a & 0x10)
#define BRD_SKIP_DOWN(a) (a & 0x20)
#define BRD_SKIP_LEFT(a) (a & 0x40)
#define BRD_SKIP_RIGHT(a) (a & 0x80)
#define GRAPH_ARROW_UP 0
#define GRAPH_ARROW_DOWN 1
#define GRAPH_ARROW_LEFT 2
#define GRAPH_ARROW_RIGHT 3
void initialize_display_buffers(void);
void ddraw_field_borders_on_buffer(uint8_t brd);
void draw_game_background(uint16_t hi_score);
void draw_number(uint16_t n, uint8_t len, uint8_t x, uint8_t y);
void draw_tiles(void);
void ddraw_single_tile(uint8_t offset);
void swap_display_buffers(void);
void clear_display_buffers(void);
void clear_box(uint8_t w, uint8_t h, uint8_t off_x, uint8_t off_y, uint8_t *disp_buf);
void ddraw_direction_arrows(uint8_t dir);
void ddraw_endgame_box(int8_t done, uint16_t score, uint16_t hi_score);
void sync_display1_buffer(void);
#endif /* _GAME_GRAPHICS_HEADER_ */
#ifndef _GAME_HGR_GRAPHICS_HEADER_
#define _GAME_HGR_GRAPHICS_HEADER_
#include <stdint.h>
#define BRD_DOUBLING_UP(a) (a & 0x01)
#define BRD_DOUBLING_DOWN(a) (a & 0x02)
#define BRD_DOUBLING_LEFT(a) (a & 0x04)
#define BRD_DOUBLING_RIGHT(a) (a & 0x08)
#define BRD_SKIP_UP(a) (a & 0x10)
#define BRD_SKIP_DOWN(a) (a & 0x20)
#define BRD_SKIP_LEFT(a) (a & 0x40)
#define BRD_SKIP_RIGHT(a) (a & 0x80)
#define GRAPH_ARROW_UP 0
#define GRAPH_ARROW_DOWN 1
#define GRAPH_ARROW_LEFT 2
#define GRAPH_ARROW_RIGHT 3
void initialize_display_buffers(void);
void ddraw_field_borders_on_buffer(uint8_t brd);
void draw_game_background(uint16_t hi_score);
void draw_number(uint16_t n, uint8_t len, uint8_t x, uint8_t y);
void draw_tiles(void);
void ddraw_single_tile(uint8_t offset);
void swap_display_buffers(void);
void clear_display_buffers(void);
void clear_box(uint8_t w, uint8_t h, uint8_t off_x, uint8_t off_y, uint8_t *disp_buf);
void ddraw_direction_arrows(uint8_t dir);
void ddraw_endgame_box(int8_t done, uint16_t score, uint16_t hi_score);
void sync_display1_buffer(void);
#endif /* _GAME_HGR_GRAPHICS_HEADER_ */

View file

@ -0,0 +1,3 @@
#define _DEMO_MODE_ 1
#include "game_hgr_graphics.c"

View file

@ -1,165 +1,165 @@
#include <stubs.h>
#include <string.h>
#include <calypsi/intrinsics6502.h>
#include "monitor_subroutines.h"
#include "utility.h"
#include "mem_map.h"
#include "shared_page.h"
#include "state_page.h"
#include "dlog_data.h"
#include "game_data.h"
#include "input.h"
#include "game_logic.h"
#include "game_graphics.h"
#include "monitor_subroutines.h"
#include "sound.h"
// External initialization requirements
#pragma require __preserve_zp
#pragma require __data_initialization_needed
#define MOVES_TEXT_X 32
#define MOVES_TEXT_Y 61
#define MOVES_TEXT_WIDTH 5
#define SCORE_TEXT_X 32
#define SCORE_TEXT_Y 29
#define SCORE_TEXT_WIDTH 5
#define HIGH_TEXT_X 32
#define HIGH_TEXT_Y 107
#define WIN_SCORE_BONUS 10000
static state_page_data* state_page = (state_page_data*)STATE_PAGE;
static shared_page_data *shared_page = (shared_page_data*)SHARED_PAGE;
void main(void) {
uint16_t moves_count = 0;
uint16_t score = 0;
int8_t done = 0;
// By default, once we return from this, return to the DLOG module and give the master no command to execute
shared_page->master_command = MASTER_COMMAND_NONE;
shared_page->next_module_idx = 3; // Go to the DLOG module
dlog_data *dld = (dlog_data *)(shared_page->module_data);
dlog_data *gad = (dlog_data *)(shared_page->module_data);
// Make sure the buffers are pointing to the correct memory and are clear
clear_display_buffers();
// Reset the game, calculate the initial score depending on which tiles we randomly get
score = reset_game();
// Load the game
if(gad->mode == GAME_MODE_LOAD) {
gad->mode = GAME_MODE_NORMAL;
memcpy(get_front_grid(), (void*)(state_page->save_grid), GRID_SIDE * GRID_SIDE);
moves_count = state_page->saved_moves_count;
score = calculate_score();
// We loaded an empty save, just restart the game
if (!score) score = reset_game();
}
// Draw the initial state of the game
draw_game_background(state_page->hi_score);
draw_number(moves_count, MOVES_TEXT_WIDTH, MOVES_TEXT_X, MOVES_TEXT_Y);
draw_number(score, SCORE_TEXT_WIDTH, SCORE_TEXT_X, SCORE_TEXT_Y);
draw_tiles();
// Swap graphical buffers
swap_display_buffers();
while(1) { // Game loop
lfsr_update();
switch(read_kb()) {
case K_UP:
SND_TAP();
done = step_game(GAME_STEP_UP);
ddraw_direction_arrows(GRAPH_ARROW_UP);
break;
case K_DOWN:
SND_TAP();
done = step_game(GAME_STEP_DOWN);
ddraw_direction_arrows(GRAPH_ARROW_DOWN);
break;
case K_LEFT:
SND_TAP();
done = step_game(GAME_STEP_LEFT);
ddraw_direction_arrows(GRAPH_ARROW_LEFT);
break;
case K_RIGHT:
SND_TAP();
done = step_game(GAME_STEP_RIGHT);
ddraw_direction_arrows(GRAPH_ARROW_RIGHT);
break;
case K_CTRL_R:
snd_mod_button();
score = 0; // We'll reset the score
done = -1;
break;
case K_CTRL_S: // The following two will return early
snd_mod_button();
memcpy((void*)(state_page->save_grid), get_front_grid(), GRID_SIDE * GRID_SIDE);
state_page->saved_moves_count = moves_count;
shared_page->master_command = MASTER_COMMAND_SAVE;
case K_CTRL_L:
snd_mod_button();
sync_display1_buffer();
shared_page->next_module_idx = 4;
gad->mode = GAME_MODE_LOAD;
return;
default:
continue; // Do nothing, loop again
}
// Increase the count of moves we made (unless we lost or reset the game)
if(done >= 0) moves_count++;
// Draw the number of moves
draw_number(moves_count, MOVES_TEXT_WIDTH, MOVES_TEXT_X, MOVES_TEXT_Y);
// Draw the moved tiles
draw_tiles();
// If we have won, or we got a reset request, break out of this loop
if(done) {
score += (done > 0) ? WIN_SCORE_BONUS : 0;
draw_number(score, SCORE_TEXT_WIDTH, SCORE_TEXT_X, SCORE_TEXT_Y);
swap_display_buffers(); // Make sure we show the latest changes
break;
}
// Unable to add a tile: we ran out of space and lost!!!
uint8_t random_tile_off = add_random_tile();
if(!random_tile_off) {
done = -1; // Lost the game
break;
}
score = calculate_score();
// Draw the score
draw_number(score, SCORE_TEXT_WIDTH, SCORE_TEXT_X, SCORE_TEXT_Y);
swap_display_buffers();
// Draw the new tile directly on the front buffer, this way we make it appear with an "animation"
ddraw_single_tile(random_tile_off - 1);
}
// Sync the display buffers
sync_display1_buffer();
dld->mode = (done > 0) ? DLOG_MODE_WIN : DLOG_MODE_LOSE;
dld->score = score;
return;
}
#include <stubs.h>
#include <string.h>
#include <calypsi/intrinsics6502.h>
#include "monitor_subroutines.h"
#include "utility.h"
#include "mem_map.h"
#include "shared_page.h"
#include "state_page.h"
#include "dlog_data.h"
#include "game_data.h"
#include "input.h"
#include "game_logic.h"
#include "game_hgr_graphics.h"
#include "monitor_subroutines.h"
#include "sound.h"
// External initialization requirements
#pragma require __preserve_zp
#pragma require __data_initialization_needed
#define MOVES_TEXT_X 32
#define MOVES_TEXT_Y 61
#define MOVES_TEXT_WIDTH 5
#define SCORE_TEXT_X 32
#define SCORE_TEXT_Y 29
#define SCORE_TEXT_WIDTH 5
#define HIGH_TEXT_X 32
#define HIGH_TEXT_Y 107
#define WIN_SCORE_BONUS 10000
static state_page_data* state_page = (state_page_data*)STATE_PAGE;
static shared_page_data *shared_page = (shared_page_data*)SHARED_PAGE;
void main(void) {
uint16_t moves_count = 0;
uint16_t score = 0;
int8_t done = 0;
// By default, once we return from this, return to the DLOG module and give the master no command to execute
shared_page->master_command = MASTER_COMMAND_NONE;
shared_page->next_module_idx = 3; // Go to the DLOG module
dlog_data *dld = (dlog_data *)(shared_page->module_data);
dlog_data *gad = (dlog_data *)(shared_page->module_data);
// Make sure the buffers are pointing to the correct memory and are clear
clear_display_buffers();
// Reset the game, calculate the initial score depending on which tiles we randomly get
score = reset_game();
// Load the game
if(gad->mode == GAME_MODE_LOAD) {
gad->mode = GAME_MODE_NORMAL;
memcpy(get_front_grid(), (void*)(state_page->save_grid), GRID_SIDE * GRID_SIDE);
moves_count = state_page->saved_moves_count;
score = calculate_score();
// We loaded an empty save, just restart the game
if (!score) score = reset_game();
}
// Draw the initial state of the game
draw_game_background(state_page->hi_score);
draw_number(moves_count, MOVES_TEXT_WIDTH, MOVES_TEXT_X, MOVES_TEXT_Y);
draw_number(score, SCORE_TEXT_WIDTH, SCORE_TEXT_X, SCORE_TEXT_Y);
draw_tiles();
// Swap graphical buffers
swap_display_buffers();
while(1) { // Game loop
lfsr_update();
switch(read_kb()) {
case K_UP:
SND_TAP();
done = step_game(GAME_STEP_UP);
ddraw_direction_arrows(GRAPH_ARROW_UP);
break;
case K_DOWN:
SND_TAP();
done = step_game(GAME_STEP_DOWN);
ddraw_direction_arrows(GRAPH_ARROW_DOWN);
break;
case K_LEFT:
SND_TAP();
done = step_game(GAME_STEP_LEFT);
ddraw_direction_arrows(GRAPH_ARROW_LEFT);
break;
case K_RIGHT:
SND_TAP();
done = step_game(GAME_STEP_RIGHT);
ddraw_direction_arrows(GRAPH_ARROW_RIGHT);
break;
case K_CTRL_R:
snd_mod_button();
score = 0; // We'll reset the score
done = -1;
break;
case K_CTRL_S: // The following two will return early
snd_mod_button();
memcpy((void*)(state_page->save_grid), get_front_grid(), GRID_SIDE * GRID_SIDE);
state_page->saved_moves_count = moves_count;
shared_page->master_command = MASTER_COMMAND_SAVE;
case K_CTRL_L:
snd_mod_button();
sync_display1_buffer();
shared_page->next_module_idx = 4;
gad->mode = GAME_MODE_LOAD;
return;
default:
continue; // Do nothing, loop again
}
// Increase the count of moves we made (unless we lost or reset the game)
if(done >= 0) moves_count++;
// Draw the number of moves
draw_number(moves_count, MOVES_TEXT_WIDTH, MOVES_TEXT_X, MOVES_TEXT_Y);
// Draw the moved tiles
draw_tiles();
// If we have won, or we got a reset request, break out of this loop
if(done) {
score += (done > 0) ? WIN_SCORE_BONUS : 0;
draw_number(score, SCORE_TEXT_WIDTH, SCORE_TEXT_X, SCORE_TEXT_Y);
swap_display_buffers(); // Make sure we show the latest changes
break;
}
// Unable to add a tile: we ran out of space and lost!!!
uint8_t random_tile_off = add_random_tile();
if(!random_tile_off) {
done = -1; // Lost the game
break;
}
score = calculate_score();
// Draw the score
draw_number(score, SCORE_TEXT_WIDTH, SCORE_TEXT_X, SCORE_TEXT_Y);
swap_display_buffers();
// Draw the new tile directly on the front buffer, this way we make it appear with an "animation"
ddraw_single_tile(random_tile_off - 1);
}
// Sync the display buffers
sync_display1_buffer();
dld->mode = (done > 0) ? DLOG_MODE_WIN : DLOG_MODE_LOSE;
dld->score = score;
return;
}

View file

@ -34,7 +34,7 @@ static shared_page_data * shared_page = (shared_page_data*)SHARED_PAGE;
static const uint8_t file_table[FILE_LIST_LEN][FNAME_LEN] = {
{ 0x80 | 'L', 0x80 | 'O', 0x80 | 'A', 0x80 | 'D', 0x80 | 'S', 0x00}, // LOADS (this is not an executable, but will be used to show the loading screen).
{ 0x80 | 'S', 0x80 | 'T', 0x80 | 'A', 0x80 | 'T', 0x80 | 'E', 0x00}, // STATE (this is not an executable, but will be used to save/load the game and scores).
{ 0x80 | 'I', 0x80 | 'N', 0x80 | 'T', 0x80 | 'R', 0x80 | 'O', 0x00}, // INTRO (this executable will show the initial presentation picture)
{ 0x80 | 'I', 0x80 | 'N', 0x80 | 'T', 0x80 | 'R', 0x80 | 'O', 0x00}, // INTRO (this executable will detect hardware and load the appropriate followup module)
{ 0x80 | 'D', 0x80 | 'L', 0x80 | 'O', 0x80 | 'G', 0xA0, 0x00}, // DLOG (startup, win, lose dialogs)
{ 0x80 | 'G', 0x80 | 'A', 0x80 | 'M', 0x80 | 'E', 0xA0, 0x00}, // GAME (the actual game)
{ 0x80 | 'D', 0x80 | 'E', 0x80 | 'M', 0x80 | 'O', 0xA0, 0x00}, // DEMO (automatic demo)