mirror of
https://codeberg.org/hkzlab/TK2048.git
synced 2025-12-25 14:22:16 +11:00
Integrate the new dialog module for the VDP
This commit is contained in:
parent
b4469d514c
commit
dd0e5ce53d
4 changed files with 73 additions and 42 deletions
4
Makefile
4
Makefile
|
|
@ -36,8 +36,8 @@ DEMO_C_SRCS = demo_main.c input.c utility.c game_hgr_graphics_demo.c hgr_line_da
|
|||
VDPIN_ASM_SRCS = tk2k_startup_module.s preserve_zero_pages.s vdp.s vdp_utils.s vdp_init.s
|
||||
VDPIN_C_SRCS = vdpin_main.c utility.c
|
||||
|
||||
VDDLG_ASM_SRCS = tk2k_startup_module.s preserve_zero_pages.s sound.s
|
||||
VDDLG_C_SRCS = vddlg_main.c input.c utility.c game_hgr_graphics.c hgr_line_data.c
|
||||
VDDLG_ASM_SRCS = tk2k_startup_module.s preserve_zero_pages.s sound.s vdp.s vdp_utils.s game_vdp_graphics.s
|
||||
VDDLG_C_SRCS = vddlg_main.c input.c utility.c
|
||||
|
||||
# Object files
|
||||
MASTER_OBJS = $(MASTER_ASM_SRCS:%.s=%.o) $(MASTER_C_SRCS:%.c=%.o)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,20 @@
|
|||
#include "mem_registers.h"
|
||||
#include "monitor_subroutines.h"
|
||||
|
||||
void decbuf_to_ascii(uint8_t len, uint8_t *buf) {
|
||||
for(uint8_t idx = 0; idx < len; idx++) {
|
||||
buf[idx] += 0x30;
|
||||
}
|
||||
|
||||
// Swap the order in the array
|
||||
uint8_t tmp;
|
||||
for(uint8_t idx = 0; idx < len/2; idx++) {
|
||||
tmp = buf[idx];
|
||||
buf[idx] = buf[(len - 1) - idx];
|
||||
buf[(len - 1) - idx] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void num_to_decbuf(uint16_t n, uint8_t len, uint8_t *buf) {
|
||||
for(uint8_t idx = 0; idx < len; idx++) {
|
||||
buf[idx] = n % 10;
|
||||
|
|
|
|||
|
|
@ -1,34 +1,35 @@
|
|||
#ifndef _UTILITY_HEADER_
|
||||
#define _UTILITY_HEADER_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define SCREEN_HEIGHT 192
|
||||
#define SCREEN_WIDTH_BYTES 128
|
||||
#define BYTES_PER_LINE 40
|
||||
|
||||
#define PEEKZ(a) (*(volatile uint8_t* __attribute__((zpage)))(a))
|
||||
#define POKEZ(a, b) ((*(volatile uint8_t* __attribute__((zpage)))(a)) = b)
|
||||
|
||||
#define PEEK(a) (*(volatile uint8_t*)(a))
|
||||
#define POKE(a, b) ((*(volatile uint8_t*)(a)) = b)
|
||||
|
||||
#define PEEKW(a) (*(volatile uint16_t*)(a))
|
||||
#define POKEW(a, b) ((*(volatile uint16_t*)(a)) = b)
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
|
||||
|
||||
// 0x356 - 0x357 actually fall inside the
|
||||
// decoding table for DISK II sector reading,
|
||||
// but they're unused bytes! So we can use them
|
||||
// to store the lfsr_update
|
||||
#define LFSR_REGISTER_ADDRESS 0x0356
|
||||
|
||||
void num_to_decbuf(uint16_t n, uint8_t len, uint8_t *buf);
|
||||
uint8_t bit_reverse(uint8_t b);
|
||||
uint8_t bit_count(uint8_t b);
|
||||
void lfsr_init(uint16_t reg);
|
||||
uint16_t lfsr_update(void);
|
||||
uint8_t calculate_crc8(uint8_t* data, uint8_t len);
|
||||
|
||||
#endif /* _UTILITY_HEADER_ */
|
||||
#ifndef _UTILITY_HEADER_
|
||||
#define _UTILITY_HEADER_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define SCREEN_HEIGHT 192
|
||||
#define SCREEN_WIDTH_BYTES 128
|
||||
#define BYTES_PER_LINE 40
|
||||
|
||||
#define PEEKZ(a) (*(volatile uint8_t* __attribute__((zpage)))(a))
|
||||
#define POKEZ(a, b) ((*(volatile uint8_t* __attribute__((zpage)))(a)) = b)
|
||||
|
||||
#define PEEK(a) (*(volatile uint8_t*)(a))
|
||||
#define POKE(a, b) ((*(volatile uint8_t*)(a)) = b)
|
||||
|
||||
#define PEEKW(a) (*(volatile uint16_t*)(a))
|
||||
#define POKEW(a, b) ((*(volatile uint16_t*)(a)) = b)
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
|
||||
|
||||
// 0x356 - 0x357 actually fall inside the
|
||||
// decoding table for DISK II sector reading,
|
||||
// but they're unused bytes! So we can use them
|
||||
// to store the lfsr_update
|
||||
#define LFSR_REGISTER_ADDRESS 0x0356
|
||||
|
||||
void decbuf_to_ascii(uint8_t len, uint8_t *buf);
|
||||
void num_to_decbuf(uint16_t n, uint8_t len, uint8_t *buf);
|
||||
uint8_t bit_reverse(uint8_t b);
|
||||
uint8_t bit_count(uint8_t b);
|
||||
void lfsr_init(uint16_t reg);
|
||||
uint16_t lfsr_update(void);
|
||||
uint8_t calculate_crc8(uint8_t* data, uint8_t len);
|
||||
|
||||
#endif /* _UTILITY_HEADER_ */
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
#include <calypsi/intrinsics6502.h>
|
||||
|
||||
#include "game_hgr_graphics.h"
|
||||
#include "vdp_utils.h"
|
||||
#include "game_vdp_graphics.h"
|
||||
#include "monitor_subroutines.h"
|
||||
#include "utility.h"
|
||||
#include "mem_map.h"
|
||||
|
|
@ -21,6 +22,7 @@
|
|||
|
||||
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 score_buf[7] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
#define WAIT_COUNTER_END 0xFFFF
|
||||
|
||||
|
|
@ -29,21 +31,35 @@ void main(void) {
|
|||
dlog_data *dld = (dlog_data *)(shared_page->module_data);
|
||||
game_data *gad = (game_data *)(shared_page->module_data);
|
||||
|
||||
// Make sure the buffers are pointing to the correct memory
|
||||
initialize_display_buffers();
|
||||
__disable_interrupts(); // Make sure the interrupts are disabled
|
||||
|
||||
num_to_decbuf(state_page->hi_score, 6, score_buf);
|
||||
decbuf_to_ascii(6, score_buf);
|
||||
|
||||
vdp_clear_dialog();
|
||||
vdp_switch_nt(1); // Make sure VDP shows the correct dialog nametable
|
||||
|
||||
vdp_print_string(1, 6, 10, "Current High-Score :");
|
||||
vdp_print_string(1, 13, 12, (char*)score_buf);
|
||||
vdp_print_string(1, 5, 15, "Press any key to START");
|
||||
vdp_print_string(1, 1, 23, "hkz@social.chinwag.org");
|
||||
vdp_print_string(1, 27, 23, "2025");
|
||||
|
||||
switch(dld->mode) {
|
||||
case DLOG_MODE_WIN:
|
||||
snd_festive();
|
||||
ddraw_endgame_box(1, dld->score, state_page->hi_score);
|
||||
//ddraw_endgame_box(1, dld->score, state_page->hi_score);
|
||||
vdp_print_string(1, 11, 8, "YOU WIN!!!");
|
||||
break;
|
||||
case DLOG_MODE_LOSE:
|
||||
snd_sad_scale();
|
||||
ddraw_endgame_box(-1, dld->score, state_page->hi_score);
|
||||
//ddraw_endgame_box(-1, dld->score, state_page->hi_score);
|
||||
vdp_print_string(1, 11, 8, "GAME OVER!");
|
||||
break;
|
||||
default:
|
||||
case DLOG_MODE_START:
|
||||
ddraw_endgame_box(0, dld->score, state_page->hi_score);
|
||||
//ddraw_endgame_box(0, dld->score, state_page->hi_score);
|
||||
vdp_print_string(1, 7, 8, "WELCOME TO TK2048!");
|
||||
snd_start();
|
||||
break;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue