mirror of
https://codeberg.org/hkzlab/TK2048.git
synced 2026-01-10 23:03:04 +11:00
Begin fixing game code
This commit is contained in:
parent
78604e6f7d
commit
7c4385972d
2 changed files with 57 additions and 26 deletions
|
|
@ -28,16 +28,16 @@
|
|||
#define HSCORE_TEXT_Y 13
|
||||
|
||||
#define SCORE_TEXT_X 27
|
||||
#define SCORE_TEXT_Y 8
|
||||
#define SCORE_TEXT_Y 4
|
||||
|
||||
#define MOVES_TEXT_X 27
|
||||
#define MOVES_TEXT_Y 4
|
||||
#define MOVES_TEXT_Y 8
|
||||
|
||||
#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;
|
||||
static uint8_t text_buf[7] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
static uint8_t text_buf[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
void main(void) {
|
||||
uint16_t moves_count = 0;
|
||||
|
|
@ -77,21 +77,22 @@ void main(void) {
|
|||
}
|
||||
|
||||
// Draw the initial state of the game
|
||||
num_to_decbuf(state_page->hi_score, 6, text_buf); // High score
|
||||
decbuf_to_ascii(6, text_buf);
|
||||
num_to_decbuf(state_page->hi_score, 5, text_buf); // High score
|
||||
decbuf_to_ascii(5, text_buf);
|
||||
vdp_print_string(0, HSCORE_TEXT_X, HSCORE_TEXT_Y, (char*)text_buf);
|
||||
|
||||
num_to_decbuf(moves_count, 6, text_buf); // Moves count
|
||||
decbuf_to_ascii(6, text_buf);
|
||||
num_to_decbuf(moves_count, 5, text_buf); // Moves count
|
||||
decbuf_to_ascii(5, text_buf);
|
||||
vdp_print_string(0, MOVES_TEXT_X, MOVES_TEXT_Y, (char*)text_buf);
|
||||
|
||||
num_to_decbuf(score, 6, text_buf); // Score
|
||||
decbuf_to_ascii(6, text_buf);
|
||||
num_to_decbuf(score, 5, text_buf); // Score
|
||||
decbuf_to_ascii(5, text_buf);
|
||||
vdp_print_string(0, SCORE_TEXT_X, SCORE_TEXT_Y, (char*)text_buf);
|
||||
|
||||
vdp_draw_joystick(JS_POS_CENTER); // Center the joystick
|
||||
//vdp_draw_joystick(JS_POS_CENTER); // Center the joystick
|
||||
|
||||
vdp_redraw_tiles(get_front_grid());
|
||||
//vdp_redraw_tiles(get_front_grid());
|
||||
while(1);
|
||||
|
||||
__enable_interrupts();
|
||||
|
||||
|
|
@ -99,7 +100,7 @@ void main(void) {
|
|||
lfsr_update();
|
||||
|
||||
__disable_interrupts();
|
||||
vdp_draw_joystick(JS_POS_CENTER);
|
||||
//vdp_draw_joystick(JS_POS_CENTER);
|
||||
__enable_interrupts();
|
||||
|
||||
switch(read_kb()) {
|
||||
|
|
@ -107,28 +108,28 @@ void main(void) {
|
|||
SND_TAP();
|
||||
done = step_game(GAME_STEP_UP);
|
||||
__disable_interrupts();
|
||||
vdp_draw_joystick(JS_POS_UP);
|
||||
//vdp_draw_joystick(JS_POS_UP);
|
||||
__enable_interrupts();
|
||||
break;
|
||||
case K_DOWN:
|
||||
SND_TAP();
|
||||
done = step_game(GAME_STEP_DOWN);
|
||||
__disable_interrupts();
|
||||
vdp_draw_joystick(JS_POS_DOWN);
|
||||
//vdp_draw_joystick(JS_POS_DOWN);
|
||||
__enable_interrupts();
|
||||
break;
|
||||
case K_LEFT:
|
||||
SND_TAP();
|
||||
done = step_game(GAME_STEP_LEFT);
|
||||
__disable_interrupts();
|
||||
vdp_draw_joystick(JS_POS_LEFT);
|
||||
//vdp_draw_joystick(JS_POS_LEFT);
|
||||
__enable_interrupts();
|
||||
break;
|
||||
case K_RIGHT:
|
||||
SND_TAP();
|
||||
done = step_game(GAME_STEP_RIGHT);
|
||||
__disable_interrupts();
|
||||
vdp_draw_joystick(JS_POS_RIGHT);
|
||||
//vdp_draw_joystick(JS_POS_RIGHT);
|
||||
__enable_interrupts();
|
||||
break;
|
||||
case K_CTRL_R:
|
||||
|
|
@ -186,14 +187,14 @@ void main(void) {
|
|||
decbuf_to_ascii(6, text_buf);
|
||||
__disable_interrupts();
|
||||
vdp_print_string(0, SCORE_TEXT_X, SCORE_TEXT_Y, (char*)text_buf);
|
||||
vdp_redraw_tiles(get_front_grid());
|
||||
//vdp_redraw_tiles(get_front_grid());
|
||||
__enable_interrupts();
|
||||
}
|
||||
|
||||
dld->mode = (done > 0) ? DLOG_MODE_WIN : DLOG_MODE_LOSE;
|
||||
dld->score = score;
|
||||
|
||||
vdp_redraw_tiles(get_front_grid());
|
||||
//vdp_redraw_tiles(get_front_grid());
|
||||
|
||||
WAIT(0xFF);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue