Add dummy module for VDP dialog

This commit is contained in:
hkz 2025-10-12 15:25:31 +02:00
commit b4469d514c
6 changed files with 123 additions and 3 deletions

View file

@ -12,6 +12,8 @@ INTRO_PRG=intro
DLOG_PRG=dlog
GAME_PRG=game
DEMO_PRG=demo
VDPIN_PRG=vdpin
VDDLG_PRG=vddlg
# Libraries
LIBS=clib-6502.a
@ -34,6 +36,9 @@ 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
# Object files
MASTER_OBJS = $(MASTER_ASM_SRCS:%.s=%.o) $(MASTER_C_SRCS:%.c=%.o)
INTRO_OBJS = $(INTRO_ASM_SRCS:%.s=%.o) $(INTRO_C_SRCS:%.c=%.o)
@ -41,6 +46,7 @@ DLOG_OBJS = $(DLOG_ASM_SRCS:%.s=%.o) $(DLOG_C_SRCS:%.c=%.o)
GAME_OBJS = $(GAME_ASM_SRCS:%.s=%.o) $(GAME_C_SRCS:%.c=%.o)
DEMO_OBJS = $(DEMO_ASM_SRCS:%.s=%.o) $(DEMO_C_SRCS:%.c=%.o)
VDPIN_OBJS = $(VDPIN_ASM_SRCS:%.s=%.o) $(VDPIN_C_SRCS:%.c=%.o)
VDDLG_OBJS = $(VDDLG_ASM_SRCS:%.s=%.o) $(VDDLG_C_SRCS:%.c=%.o)
all: $(SW_NAME).woz
@ -69,6 +75,9 @@ $(DEMO_PRG).hex: $(DEMO_OBJS)
$(VDPIN_PRG).hex: $(VDPIN_OBJS)
(cd obj ; ln6502 -g ../linker-files/vdpin_module.scm $^ -o ../out/$@ $(LIBS) -l --cross-reference --cstartup=tk2k --no-automatic-placement-rules --output-format intel-hex --rom-code)
$(VDDLG_PRG).hex: $(VDDLG_OBJS)
(cd obj ; ln6502 -g ../linker-files/module.scm $^ -o ../out/$@ $(LIBS) -l --cross-reference --cstartup=tk2k --no-automatic-placement-rules --output-format intel-hex --rom-code)
$(MASTER_PRG).bin: $(MASTER_PRG).hex
(cd out ; objcopy -I ihex -O binary $(MASTER_PRG).hex $(MASTER_PRG).bin)
@ -86,8 +95,11 @@ $(DEMO_PRG).bin: $(DEMO_PRG).hex
$(VDPIN_PRG).bin: $(VDPIN_PRG).hex
(cd out ; objcopy -I ihex -O binary $(VDPIN_PRG).hex $(VDPIN_PRG).bin)
$(VDDLG_PRG).bin: $(VDDLG_PRG).hex
(cd out ; objcopy -I ihex -O binary $(VDDLG_PRG).hex $(VDDLG_PRG).bin)
$(SW_NAME).dsk: $(MASTER_PRG).bin $(INTRO_PRG).bin $(DLOG_PRG).bin $(GAME_PRG).bin $(DEMO_PRG).bin $(VDPIN_PRG).bin
$(SW_NAME).dsk: $(MASTER_PRG).bin $(INTRO_PRG).bin $(DLOG_PRG).bin $(GAME_PRG).bin $(DEMO_PRG).bin $(VDPIN_PRG).bin $(VDDLG_PRG).bin
(cd out ; cp ../dsk/TK2048_AUTO_BRUN.dsk ./$(SW_NAME).dsk; \
cat $(MASTER_PRG).bin | $(JAVA) -jar $(ACMD) -p $(SW_NAME).dsk HELLO B 0x800; \
cat $(INTRO_PRG).bin | $(JAVA) -jar $(ACMD) -p $(SW_NAME).dsk INTRO b; \
@ -95,6 +107,7 @@ $(SW_NAME).dsk: $(MASTER_PRG).bin $(INTRO_PRG).bin $(DLOG_PRG).bin $(GAME_PRG).b
cat $(GAME_PRG).bin | $(JAVA) -jar $(ACMD) -p $(SW_NAME).dsk GAME b; \
cat $(DEMO_PRG).bin | $(JAVA) -jar $(ACMD) -p $(SW_NAME).dsk DEMO b; \
cat $(VDPIN_PRG).bin | $(JAVA) -jar $(ACMD) -p $(SW_NAME).dsk VDPIN b; \
cat $(VDDLG_PRG).bin | $(JAVA) -jar $(ACMD) -p $(SW_NAME).dsk VDDLG b; \
cat ../data/LOADS.bin | $(JAVA) -jar $(ACMD) -p $(SW_NAME).dsk LOADS b; \
cat ../data/STATE.bin | $(JAVA) -jar $(ACMD) -p $(SW_NAME).dsk STATE b;)

View file

@ -4,6 +4,7 @@
#include <stdint.h>
void vdp_clear_gamegrid(void);
void vdp_clear_dialog(void);
uint8_t vdp_draw_numtile(uint8_t type, uint8_t x, uint8_t y);
#endif /* _GAME_VDP_GRAPHICS_HEADER_ */

View file

@ -37,6 +37,35 @@ ClearTile$:
bne ClearLine$
rts
vdp_clear_dialog:
T_NT_IDX$: .equ _Zp+4
T_Y$: .equ _Zp+1
T_X$: .equ _Zp+0
lda #0x01
sta zp:T_NT_IDX$
lda #0x04
sta zp:T_X$
lda #15
sta zp:T_Y$
ldy #9
ClearLine$:
jsr vdp_point_to_vram_xy
lda #0x00
ldx #24
ClearTile$:
sta VDP_MEM
dex
bne ClearTile$
dec zp:T_Y$
dey
bne ClearLine$
rts
;;; vdp_draw_numtile:
;;; Draws the 2048 tile at specified coordinates
@ -124,4 +153,5 @@ TileNum_Y_Map:
;;;;;;;;;;;;;;;;;;
.public vdp_draw_numtile
.public vdp_clear_gamegrid
.public vdp_clear_dialog

View file

@ -24,7 +24,7 @@
static uint8_t *module_page = (uint8_t*)MODULE_PAGE;
static shared_page_data * shared_page = (shared_page_data*)SHARED_PAGE;
#define FILE_LIST_LEN 7
#define FILE_LIST_LEN 8
#define FNAME_LEN 6
#define STATE_FILE_IDX 1
@ -39,6 +39,7 @@ static const uint8_t file_table[FILE_LIST_LEN][FNAME_LEN] = {
{ 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),
{ 0x80 | 'V', 0x80 | 'D', 0x80 | 'P', 0x80 | 'I', 0x80 | 'N', 0x00}, // VDPIN (Loads VDP resources),
{ 0x80 | 'V', 0x80 | 'D', 0x80 | 'D', 0x80 | 'L', 0x80 | 'G', 0x00}, // VDDLG (VDP startup, win, lose dialogs),
};
static uint8_t file_trksec[FILE_LIST_LEN][2]; // This will hold track/sector for initial ts list sector for every one of the listed files. Populated at startup.
@ -50,6 +51,7 @@ static uint16_t file_load_address[FILE_LIST_LEN] = { // This will hold the load
MODULE_PAGE,
MODULE_PAGE,
MODULE_PAGE,
MODULE_PAGE,
};
static void init(void);

74
src/vddlg_main.c Normal file
View file

@ -0,0 +1,74 @@
#include <stubs.h>
#include <string.h>
#include <calypsi/intrinsics6502.h>
#include "game_hgr_graphics.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 "sound.h"
#include "module_list.h"
// External initialization requirements
#pragma require __preserve_zp
#pragma require __data_initialization_needed
static state_page_data* state_page = (state_page_data*)STATE_PAGE;
static shared_page_data *shared_page = (shared_page_data*)SHARED_PAGE;
#define WAIT_COUNTER_END 0xFFFF
void main(void) {
uint16_t wait_counter = 0;
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();
switch(dld->mode) {
case DLOG_MODE_WIN:
snd_festive();
ddraw_endgame_box(1, dld->score, state_page->hi_score);
break;
case DLOG_MODE_LOSE:
snd_sad_scale();
ddraw_endgame_box(-1, dld->score, state_page->hi_score);
break;
default:
case DLOG_MODE_START:
ddraw_endgame_box(0, dld->score, state_page->hi_score);
snd_start();
break;
};
if(dld->score > state_page->hi_score) { // New high-score. We need to save it.
state_page->hi_score = dld->score;
shared_page->master_command = MASTER_COMMAND_SAVE;
} else {
shared_page->master_command = MASTER_COMMAND_NONE;
}
shared_page->next_module_idx = MODULE_GAME; // Go to the GAME module
gad->mode = GAME_MODE_NORMAL; // Set the proper start mode for the game
while(!read_any_key() && (wait_counter != WAIT_COUNTER_END)) {
wait_counter++;
lfsr_update();
}
if (wait_counter == WAIT_COUNTER_END) {
shared_page->next_module_idx = MODULE_DEMO; // Actually go to the DEMO module
return;
}
snd_mod_button();
return;
}

View file

@ -28,7 +28,7 @@ void main(void) {
vdp_print_string(1, 6, 10, "Loading...");
shared_page->master_command = MASTER_COMMAND_NONE;
shared_page->next_module_idx = MODULE_DLOG;
shared_page->next_module_idx = MODULE_DLOG_VDP;
return;
}