From 85ca4f19a232775105a1373622e0638fb09d0495 Mon Sep 17 00:00:00 2001 From: hkz Date: Tue, 15 Jul 2025 21:14:14 +0200 Subject: [PATCH] Begin with basic init --- Makefile | 3 ++- src/game_graphics.c | 7 +++++++ src/game_graphics.h | 8 ++++++++ src/main.c | 15 ++++++++++++++- src/tk2k_startup.s | 10 +++++----- 5 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 src/game_graphics.c create mode 100644 src/game_graphics.h diff --git a/Makefile b/Makefile index 6fcf927..7fb5ea8 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,8 @@ LIBS=clib-6502.a # Common source files ASM_SRCS = tk2k_startup.s -C_SRCS = main.c monitor_subroutines.c utility.c +C_SRCS = main.c monitor_subroutines.c utility.c \ + game_graphics.c # Object files OBJS = $(ASM_SRCS:%.s=%.o) $(C_SRCS:%.c=%.o) diff --git a/src/game_graphics.c b/src/game_graphics.c new file mode 100644 index 0000000..eeed217 --- /dev/null +++ b/src/game_graphics.c @@ -0,0 +1,7 @@ +#include "game_graphics.h" + +#include "mem_map.h" + +void draw_game_background(void) { + +} diff --git a/src/game_graphics.h b/src/game_graphics.h new file mode 100644 index 0000000..f51a35e --- /dev/null +++ b/src/game_graphics.h @@ -0,0 +1,8 @@ +#ifndef _GAME_GRAPHICS_HEADER_ +#define _GAME_GRAPHICS_HEADER_ + +#include + +void draw_game_background(void); + +#endif /* _GAME_GRAPHICS_HEADER_ */ diff --git a/src/main.c b/src/main.c index 81535d7..0d5ea5e 100644 --- a/src/main.c +++ b/src/main.c @@ -9,9 +9,22 @@ #include "monitor_subroutines.h" -__task int main () { + +// Low level initialization +void __low_level_init(void) { POKE(P3_PWRDUP, 0); // Dirty the value checked by the reset vector PEEK(IO_ROMSEL); // Make sure the ROM is selected + + PEEK(IO_DISPLAY_BW); // Disable colors + PEEK(IO_DISPLAY_PAGE1); // Select the first display page + + // Clear display memory + memset((void*)DISPLAY_PAGE_1, 0, DISPLAY_PAGE_SIZE); + memset((void*)DISPLAY_PAGE_2, 0, DISPLAY_PAGE_SIZE); +} + +__task int main(void) { + while(1){ diff --git a/src/tk2k_startup.s b/src/tk2k_startup.s index 146a92a..0092cfa 100644 --- a/src/tk2k_startup.s +++ b/src/tk2k_startup.s @@ -8,7 +8,7 @@ .section data_init_table .section registers ; pseudo registers in zero page - .extern main, exit + .extern main, exit, __low_level_init .extern _Zp, _Vsp, _Vfp .pubweak __program_root_section, __program_start @@ -87,10 +87,10 @@ __call_heap_initialize: ;;; ;;; *************************************************************************** - .section code - .pubweak __low_level_init -__low_level_init: - rts +;;; .section code +;;; .pubweak __low_level_init +;;;__low_level_init: +;;; rts ;;; *************************************************************************** ;;;