From b908d98bb63ec269fd5d6076a2de13cc4d2cde8e Mon Sep 17 00:00:00 2001 From: Ry Date: Sun, 17 Apr 2022 15:43:13 -0700 Subject: [PATCH] fox32rom: Make overlay structs const --- main.asm | 38 ++++++++++++++++++-------------------- menu.asm | 20 ++++++++++---------- menu_bar.asm | 10 +++++----- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/main.asm b/main.asm index 4f8d036..5acc2e1 100644 --- a/main.asm +++ b/main.asm @@ -35,7 +35,7 @@ disable_all_overlays_loop: out r0, 0 ; write the cursor bitmap to the overlay framebuffer - mov r0, [overlay_31_framebuffer_ptr] + mov r0, CURSOR_FRAMEBUFFER_PTR mov r1, mouse_cursor mov r31, 96 ; 8x12 cursor_overlay_loop: @@ -47,12 +47,12 @@ cursor_overlay_loop: cursor_enable: ; set properties of overlay 31 mov r0, 0x8000011F ; overlay 31: size - mov.16 r1, [overlay_31_height] + mov.16 r1, CURSOR_HEIGHT sla r1, 16 - mov.16 r1, [overlay_31_width] + mov.16 r1, CURSOR_WIDTH out r0, r1 mov r0, 0x8000021F ; overlay 31: framebuffer pointer - mov r1, [overlay_31_framebuffer_ptr] + mov r1, CURSOR_FRAMEBUFFER_PTR out r0, r1 ; enable overlay 31 (cursor) @@ -240,27 +240,25 @@ mouse_cursor: #include_bin "font/cursor2.raw" ; cursor overlay struct: -overlay_31_width: data.16 8 -overlay_31_height: data.16 12 -overlay_31_position_x: data.16 0 -overlay_31_position_y: data.16 0 -overlay_31_framebuffer_ptr: data.32 0x0212D000 +const CURSOR_WIDTH: 8 +const CURSOR_HEIGHT: 12 +const CURSOR_FRAMEBUFFER_PTR: 0x0212D000 ; menu bar overlay struct: -overlay_30_width: data.16 640 -overlay_30_height: data.16 16 -overlay_30_position_x: data.16 0 -overlay_30_position_y: data.16 0 -overlay_30_framebuffer_ptr: data.32 0x0212D180 +const MENU_BAR_WIDTH: 640 +const MENU_BAR_HEIGHT: 16 +const MENU_BAR_POSITION_X: 0 +const MENU_BAR_POSITION_Y: 0 +const MENU_BAR_FRAMEBUFFER_PTR: 0x0212D180 ; menu overlay struct: ; this struct must be writable, so these are hard-coded addresses in ram -const OVERLAY_29_WIDTH: 0x02137180 ; 2 bytes -const OVERLAY_29_HEIGHT: 0x02137182 ; 2 bytes -const OVERLAY_29_POSITION_X: 0x02137184 ; 2 bytes -const OVERLAY_29_POSITION_Y: 0x02137186 ; 2 bytes -const OVERLAY_29_FRAMEBUFFER_PTR: 0x0213718A ; 4 bytes -const OVERLAY_29_FRAMEBUFFER: 0x0213718E +const MENU_WIDTH: 0x02137180 ; 2 bytes +const MENU_HEIGHT: 0x02137182 ; 2 bytes +const MENU_POSITION_X: 0x02137184 ; 2 bytes +const MENU_POSITION_Y: 0x02137186 ; 2 bytes +const MENU_FRAMEBUFFER_PTR: 0x0213718A ; 4 bytes +const MENU_FRAMEBUFFER: 0x0213718E startup_str: data.str "fox32 - ROM version %u.%u.%u - insert boot disk" data.8 0 diff --git a/menu.asm b/menu.asm index e285cf1..baecf2b 100644 --- a/menu.asm +++ b/menu.asm @@ -43,7 +43,7 @@ draw_menu_items_calculate_x_loop: loop draw_menu_items_calculate_x_loop draw_menu_items_calculate_x_skip: sub r30, 8 ; move the menu to the left by 8 pixels - mov.16 [OVERLAY_29_POSITION_X], r30 + mov.16 [MENU_POSITION_X], r30 mov r31, r0 inc r31 ; point to menu list pointer @@ -58,7 +58,7 @@ draw_menu_items_calculate_x_skip: ; multiply the number of menu items by 16 (the font is 16 pixels tall) mov r1, r31 mul r1, 16 - mov.16 [OVERLAY_29_HEIGHT], r1 + mov.16 [MENU_HEIGHT], r1 ; calculate the required width for the menu overlay ; multiply the width by 8 (the font is 8 pixels wide) @@ -67,25 +67,25 @@ draw_menu_items_calculate_x_skip: movz.8 r1, [r1] ; load width of menu mov r8, r1 ; save the width in characters in r8 for later mul r1, 8 - mov.16 [OVERLAY_29_WIDTH], r1 + mov.16 [MENU_WIDTH], r1 push r0 ; set properties of overlay 29 - mov.16 [OVERLAY_29_POSITION_Y], 16 - mov [OVERLAY_29_FRAMEBUFFER_PTR], OVERLAY_29_FRAMEBUFFER + mov.16 [MENU_POSITION_Y], 16 + mov [MENU_FRAMEBUFFER_PTR], MENU_FRAMEBUFFER mov r0, 0x8000001D ; overlay 29: position - mov.16 r1, [OVERLAY_29_POSITION_Y] + mov.16 r1, [MENU_POSITION_Y] sla r1, 16 - mov.16 r1, [OVERLAY_29_POSITION_X] + mov.16 r1, [MENU_POSITION_X] out r0, r1 mov r0, 0x8000011D ; overlay 29: size - mov.16 r1, [OVERLAY_29_HEIGHT] + mov.16 r1, [MENU_HEIGHT] sla r1, 16 - mov.16 r1, [OVERLAY_29_WIDTH] + mov.16 r1, [MENU_WIDTH] out r0, r1 mov r0, 0x8000021D ; overlay 29: framebuffer pointer - mov r1, [OVERLAY_29_FRAMEBUFFER_PTR] + mov r1, [MENU_FRAMEBUFFER_PTR] out r0, r1 mov r0, 0x8000031D out r0, 1 diff --git a/menu_bar.asm b/menu_bar.asm index be5b501..5be926c 100644 --- a/menu_bar.asm +++ b/menu_bar.asm @@ -15,17 +15,17 @@ enable_menu_bar: ; set properties of overlay 30 mov r0, 0x8000001E ; overlay 30: position - mov.16 r1, [overlay_30_position_y] + mov.16 r1, MENU_BAR_POSITION_Y sla r1, 16 - mov.16 r1, [overlay_30_position_x] + mov.16 r1, MENU_BAR_POSITION_X out r0, r1 mov r0, 0x8000011E ; overlay 30: size - mov.16 r1, [overlay_30_height] + mov.16 r1, MENU_BAR_HEIGHT sla r1, 16 - mov.16 r1, [overlay_30_width] + mov.16 r1, MENU_BAR_WIDTH out r0, r1 mov r0, 0x8000021E ; overlay 30: framebuffer pointer - mov r1, [overlay_30_framebuffer_ptr] + mov r1, MENU_BAR_FRAMEBUFFER_PTR out r0, r1 ; enable overlay 30 (menu bar)