From 58f7436c454deb7714a39604b478835db1e9765a Mon Sep 17 00:00:00 2001 From: hkz Date: Tue, 7 Oct 2025 12:52:38 +0200 Subject: [PATCH] Add a module list with defines --- src/demo_main.c | 3 +- src/dlog_main.c | 5 +-- src/game_main.c | 5 +-- src/intro_main.c | 80 ++++++++++++++++++++++++----------------------- src/master_main.c | 6 +--- src/module_list.h | 8 +++++ 6 files changed, 58 insertions(+), 49 deletions(-) create mode 100644 src/module_list.h diff --git a/src/demo_main.c b/src/demo_main.c index 65905ee..5d9a243 100644 --- a/src/demo_main.c +++ b/src/demo_main.c @@ -15,6 +15,7 @@ #include "game_hgr_graphics.h" #include "monitor_subroutines.h" #include "sound.h" +#include "module_list.h" // External initialization requirements #pragma require __preserve_zp @@ -44,7 +45,7 @@ void main(void) { // 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 + shared_page->next_module_idx = MODULE_DLOG; // Go to the DLOG module dlog_data *dld = (dlog_data *)(shared_page->module_data); dlog_data *gad = (dlog_data *)(shared_page->module_data); diff --git a/src/dlog_main.c b/src/dlog_main.c index 98598a3..5c32d8f 100644 --- a/src/dlog_main.c +++ b/src/dlog_main.c @@ -13,6 +13,7 @@ #include "game_data.h" #include "input.h" #include "sound.h" +#include "module_list.h" // External initialization requirements #pragma require __preserve_zp @@ -54,7 +55,7 @@ void main(void) { shared_page->master_command = MASTER_COMMAND_NONE; } - shared_page->next_module_idx = 4; // Go to the GAME module + 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)) { @@ -63,7 +64,7 @@ void main(void) { } if (wait_counter == WAIT_COUNTER_END) { - shared_page->next_module_idx = 5; // Actually go to the DEMO module + shared_page->next_module_idx = MODULE_DEMO; // Actually go to the DEMO module return; } diff --git a/src/game_main.c b/src/game_main.c index 835cd0f..2ae6867 100644 --- a/src/game_main.c +++ b/src/game_main.c @@ -15,6 +15,7 @@ #include "game_hgr_graphics.h" #include "monitor_subroutines.h" #include "sound.h" +#include "module_list.h" // External initialization requirements #pragma require __preserve_zp @@ -43,7 +44,7 @@ void main(void) { // 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 + shared_page->next_module_idx = MODULE_DLOG; // Go to the DLOG module dlog_data *dld = (dlog_data *)(shared_page->module_data); dlog_data *gad = (dlog_data *)(shared_page->module_data); @@ -112,7 +113,7 @@ void main(void) { case K_CTRL_L: snd_mod_button(); sync_display1_buffer(); - shared_page->next_module_idx = 4; + shared_page->next_module_idx = MODULE_GAME; gad->mode = GAME_MODE_LOAD; return; default: diff --git a/src/intro_main.c b/src/intro_main.c index 4595ad0..4d094b9 100644 --- a/src/intro_main.c +++ b/src/intro_main.c @@ -1,39 +1,41 @@ -#include -#include - -#include - -#include "monitor_subroutines.h" -#include "utility.h" -#include "mem_map.h" -#include "shared_page.h" - -// External initialization requirements -#pragma require __preserve_zp -#pragma require __data_initialization_needed - -static shared_page_data *shared_page = (shared_page_data*)SHARED_PAGE; - -void main(void) { - uint8_t wait_count = 0x40; - - // Initialize the register for LFSR - lfsr_init(0xF00D); - - // Clear the memory used to pass parameters to the next module - memset((void*)(shared_page->module_data), 0, MODULE_DATA_SIZE); - - // TODO: Detect expansion hardware, and choose what to load according to that - - // Delay a bit - while(wait_count--) WAIT(0xFF); - - // Clear the display memory - memset((void*)DISPLAY_PAGE_2, 0, DISPLAY_PAGE_SIZE); - memset((void*)DISPLAY_PAGE_1, 0, DISPLAY_PAGE_SIZE); - - shared_page->master_command = MASTER_COMMAND_NONE; - shared_page->next_module_idx = 3; // DLOG module is next! - - return; -} +#include +#include + +#include + +#include "monitor_subroutines.h" +#include "utility.h" +#include "mem_map.h" +#include "shared_page.h" + +#include "module_list.h" + +// External initialization requirements +#pragma require __preserve_zp +#pragma require __data_initialization_needed + +static shared_page_data *shared_page = (shared_page_data*)SHARED_PAGE; + +void main(void) { + uint8_t wait_count = 0x40; + + // Initialize the register for LFSR + lfsr_init(0xF00D); + + // Clear the memory used to pass parameters to the next module + memset((void*)(shared_page->module_data), 0, MODULE_DATA_SIZE); + + // TODO: Detect expansion hardware, and choose what to load according to that + + // Delay a bit + while(wait_count--) WAIT(0xFF); + + // Clear the display memory + memset((void*)DISPLAY_PAGE_2, 0, DISPLAY_PAGE_SIZE); + memset((void*)DISPLAY_PAGE_1, 0, DISPLAY_PAGE_SIZE); + + shared_page->master_command = MASTER_COMMAND_NONE; + shared_page->next_module_idx = MODULE_DLOG; // DLOG module is next! + + return; +} diff --git a/src/master_main.c b/src/master_main.c index 029a126..b9ed9c7 100644 --- a/src/master_main.c +++ b/src/master_main.c @@ -123,17 +123,14 @@ __task int main(void) { uint8_t cur_file = 0; uint8_t keep_going = 1; - __disable_interrupts(); + __disable_interrupts(); // Keep the interrupts disabled in the master module init(); init_floppy_data(&cur_trk, &cur_file); - - __enable_interrupts(); do { if((cur_file != shared_page->next_module_idx) || (shared_page->master_command == MASTER_COMMAND_SAVE)) { - __disable_interrupts(); dii_power_on(DEFAULT_DRIVE_CONTROLLER_OFFSET, 0); // Check if we need to load another module @@ -151,7 +148,6 @@ __task int main(void) { } dii_power_off(DEFAULT_DRIVE_CONTROLLER_OFFSET); - __enable_interrupts(); } shared_page->master_command = MASTER_COMMAND_NONE; diff --git a/src/module_list.h b/src/module_list.h new file mode 100644 index 0000000..17df25e --- /dev/null +++ b/src/module_list.h @@ -0,0 +1,8 @@ +#ifndef _MODULE_LIST_HEADER_ +#define _MODULE_LIST_HEADER_ + +#define MODULE_DLOG 3 +#define MODULE_GAME 4 +#define MODULE_DEMO 5 + +#endif /* _MODULE_LIST_HEADER_ */