From 519d80a0c6cee9a87e82d2051ea95f46f2f57683 Mon Sep 17 00:00:00 2001 From: ry755 Date: Fri, 11 Feb 2022 20:44:11 -0800 Subject: [PATCH] fox32rom: Make all consts uppercase --- background.asm | 8 ++++---- event.asm | 54 +++++++++++++++++++++++++------------------------- fox32rom.def | 10 +++++----- main.asm | 28 +++++++++++++------------- menu.asm | 2 +- mouse.asm | 4 ++-- submenu.asm | 24 +++++++++++----------- 7 files changed, 65 insertions(+), 65 deletions(-) diff --git a/background.asm b/background.asm index f21137e..434816b 100644 --- a/background.asm +++ b/background.asm @@ -1,6 +1,6 @@ ; background routines -const background: 0x80000000 ; pointer to background framebuffer +const BACKGROUND_FRAMEBUFFER: 0x80000000 ; pointer to background framebuffer ; fill the whole background with a color ; inputs: @@ -11,7 +11,7 @@ fill_background: push r1 push r31 - mov r1, background + mov r1, BACKGROUND_FRAMEBUFFER mov r31, 0x0004B000 ; 640*480 fill_background_loop: mov [r1], r0 @@ -44,7 +44,7 @@ draw_filled_rectangle_to_background: mul r1, 2560 ; y * 2560 (640 * 4 = 2560) mul r0, 4 ; x * 4 add r0, r1 ; y * 2560 + (x * 4) - add r0, background ; r0: pointer to framebuffer + add r0, BACKGROUND_FRAMEBUFFER ; r0: pointer to framebuffer mov r6, r2 mul r6, 4 ; multiply the X size by 4, since 4 bytes per pixel @@ -105,7 +105,7 @@ draw_font_tile_to_background: mul r2, 2560 ; y * 2560 (640 * 4 = 2560) mul r1, 4 ; x * 4 add r1, r2 ; y * 2560 + (x * 4) - add r1, background ; r1: pointer to framebuffer + add r1, BACKGROUND_FRAMEBUFFER ; r1: pointer to framebuffer mov r6, 16 ; y counter draw_font_tile_to_background_y_loop: diff --git a/event.asm b/event.asm index 41466b9..0633034 100644 --- a/event.asm +++ b/event.asm @@ -1,18 +1,18 @@ ; event system routines -const event_queue_top: 0x01FFFFFE -const event_queue_bottom: 0x01FFFBFE ; top - 0x400 (32 events * (4 bytes * (1 type + 7 parameters))) -const event_queue_index: 0x01FFFFFF ; byte -const event_queue_size: 32 ; 32 events -const event_size_bytes: 32 ; 32 bytes per event -const event_size_words: 8 ; 8 words per event +const EVENT_QUEUE_TOP: 0x01FFFFFE +const EVENT_QUEUE_BOTTOM: 0x01FFFBFE ; top - 0x400 (32 events * (4 bytes * (1 type + 7 parameters))) +const EVENT_QUEUE_INDEX: 0x01FFFFFF ; byte +const EVENT_QUEUE_SIZE: 32 ; 32 events +const EVENT_SIZE_BYTES: 32 ; 32 bytes per event +const EVENT_SIZE_WORDS: 8 ; 8 words per event ; event types -const mouse_click_event_type: 0x00000000 -const menu_bar_click_event_type: 0x00000001 -const submenu_update_event_type: 0x00000002 -const submenu_click_event_type: 0x00000003 -const empty_event_type: 0xFFFFFFFF +const MOUSE_CLICK_EVENT_TYPE: 0x00000000 +const MENU_BAR_CLICK_EVENT_TYPE: 0x00000001 +const SUBMENU_UPDATE_EVENT_TYPE: 0x00000002 +const SUBMENU_CLICK_EVENT_TYPE: 0x00000003 +const EMPTY_EVENT_TYPE: 0xFFFFFFFF ; block until an event is available ; inputs: @@ -25,7 +25,7 @@ wait_for_event: halt ; if the event queue index doesn't equal zero, then at least one event is available - cmp.8 [event_queue_index], 0 + cmp.8 [EVENT_QUEUE_INDEX], 0 ifz jmp wait_for_event ; an event is available in the event queue, remove it from the queue and return it @@ -41,16 +41,16 @@ wait_for_event: ; none new_event: ; ensure there is enough space left for another event - cmp.8 [event_queue_index], event_queue_size + cmp.8 [EVENT_QUEUE_INDEX], EVENT_QUEUE_SIZE ifz ret push r8 push r9 ; point to the current event queue index - mov r8, event_queue_bottom - movz.8 r9, [event_queue_index] - mul r9, event_size_bytes + mov r8, EVENT_QUEUE_BOTTOM + movz.8 r9, [EVENT_QUEUE_INDEX] + mul r9, EVENT_SIZE_BYTES add r8, r9 ; copy the event type @@ -74,7 +74,7 @@ new_event: add r8, 4 ; increment the index - inc.8 [event_queue_index] + inc.8 [EVENT_QUEUE_INDEX] pop r9 pop r8 @@ -88,14 +88,14 @@ new_event: ; r1-r7: event parameters get_next_event: ; if the event queue index equals zero, then the queue is empty - cmp.8 [event_queue_index], 0 + cmp.8 [EVENT_QUEUE_INDEX], 0 ifz jmp get_next_event_empty icl push r8 ; point to the bottom of the event queue - mov r8, event_queue_bottom + mov r8, EVENT_QUEUE_BOTTOM ; copy the event type mov r0, [r8] @@ -120,13 +120,13 @@ get_next_event: call shift_events ; decrement the index - dec.8 [event_queue_index] + dec.8 [EVENT_QUEUE_INDEX] pop r8 ise ret get_next_event_empty: - mov r0, empty_event_type + mov r0, EMPTY_EVENT_TYPE mov r1, 0 mov r2, 0 mov r3, 0 @@ -153,24 +153,24 @@ shift_events: ; event_queue[i] = event_queue[i + 1]; ; } - movz.8 r31, [event_queue_index] + movz.8 r31, [EVENT_QUEUE_INDEX] mov r3, 0 ; i ; source pointer: event_queue[i + 1] - mov r0, event_queue_bottom + mov r0, EVENT_QUEUE_BOTTOM mov r4, r3 inc r4 - mul r4, event_size_words + mul r4, EVENT_SIZE_WORDS add r0, r4 ; destination pointer: event_queue[i] - mov r1, event_queue_bottom + mov r1, EVENT_QUEUE_BOTTOM mov r4, r3 - mul r4, event_size_words + mul r4, EVENT_SIZE_WORDS add r1, r4 ; size: event_size_words - mov r2, event_size_words + mov r2, EVENT_SIZE_WORDS call copy_memory_words diff --git a/fox32rom.def b/fox32rom.def index 481c830..6256b03 100644 --- a/fox32rom.def +++ b/fox32rom.def @@ -28,8 +28,8 @@ draw_submenu_items: jmp [0xF100300C] close_submenu: jmp [0xF1003010] ; event types -const mouse_click_event_type: 0x00000000 -const menu_bar_click_event_type: 0x00000001 -const submenu_update_event_type: 0x00000002 -const submenu_click_event_type: 0x00000003 -const empty_event_type: 0xFFFFFFFF \ No newline at end of file +const MOUSE_CLICK_EVENT_TYPE: 0x00000000 +const MENU_BAR_CLICK_EVENT_TYPE: 0x00000001 +const SUBMENU_UPDATE_EVENT_TYPE: 0x00000002 +const SUBMENU_CLICK_EVENT_TYPE: 0x00000003 +const EMPTY_EVENT_TYPE: 0xFFFFFFFF \ No newline at end of file diff --git a/main.asm b/main.asm index 7604e36..ff98f65 100644 --- a/main.asm +++ b/main.asm @@ -2,12 +2,12 @@ ; fox32 starts here on reset org 0xF0000000 -const system_stack: 0x01FFF800 -const background_color: 0xFF414C50 +const SYSTEM_STACK: 0x01FFF800 +const BACKGROUND_COLOR: 0xFF414C50 ; initialization code entry: - mov rsp, system_stack + mov rsp, SYSTEM_STACK mov [0x000003FC], system_vsync_handler @@ -44,7 +44,7 @@ cursor_enable: mov r0, 0x8000031F out r0, 1 - mov r0, background_color + mov r0, BACKGROUND_COLOR call fill_background menu_bar_enable: @@ -112,20 +112,20 @@ event_loop: call get_next_event ; was the mouse clicked? - cmp r0, mouse_click_event_type + cmp r0, MOUSE_CLICK_EVENT_TYPE ;ifz call mouse_click_event ; did the user click the menu bar? - cmp r0, menu_bar_click_event_type + cmp r0, MENU_BAR_CLICK_EVENT_TYPE ifz mov r0, menu_items_root ifz call menu_bar_click_event ; is the user in a submenu? - cmp r0, submenu_update_event_type + cmp r0, SUBMENU_UPDATE_EVENT_TYPE ifz call submenu_update_event ; did the user click a submenu item? - cmp r0, submenu_click_event_type + cmp r0, SUBMENU_CLICK_EVENT_TYPE ifz call submenu_click_event ; check if a disk is mounted as disk 0 @@ -231,12 +231,12 @@ overlay_30_framebuffer_ptr: data.32 0x8012D180 ; submenu overlay struct: ; this struct must be writable, so these are hard-coded addresses in shared memory -const overlay_29_width: 0x80137180 ; 2 bytes -const overlay_29_height: 0x80137182 ; 2 bytes -const overlay_29_position_x: 0x80137184 ; 2 bytes -const overlay_29_position_y: 0x80137186 ; 2 bytes -const overlay_29_framebuffer_ptr: 0x8013718A ; 4 bytes -const overlay_29_framebuffer: 0x8013718E +const OVERLAY_29_WIDTH: 0x80137180 ; 2 bytes +const OVERLAY_29_HEIGHT: 0x80137182 ; 2 bytes +const OVERLAY_29_POSITION_X: 0x80137184 ; 2 bytes +const OVERLAY_29_POSITION_Y: 0x80137186 ; 2 bytes +const OVERLAY_29_FRAMEBUFFER_PTR: 0x8013718A ; 4 bytes +const OVERLAY_29_FRAMEBUFFER: 0x8013718E startup_str_1: data.str "Welcome to fox32" data.8 0 startup_str_2: data.str "Insert boot disk" data.8 0 diff --git a/menu.asm b/menu.asm index e4aa548..00001ee 100644 --- a/menu.asm +++ b/menu.asm @@ -175,7 +175,7 @@ menu_bar_click_event_found_item: mov r5, 0 mov r6, 0 mov r7, 0 - mov r0, submenu_update_event_type + mov r0, SUBMENU_UPDATE_EVENT_TYPE call new_event menu_bar_click_event_end: pop r31 diff --git a/mouse.asm b/mouse.asm index 6e50d0b..9e564bf 100644 --- a/mouse.asm +++ b/mouse.asm @@ -79,7 +79,7 @@ mouse_update: mov r5, 0 mov r6, 0 mov r7, 0 - mov r0, mouse_click_event_type ; set event type to mouse type + mov r0, MOUSE_CLICK_EVENT_TYPE ; set event type to mouse type call new_event jmp mouse_update_end mouse_update_menu_was_clicked: @@ -90,7 +90,7 @@ mouse_update_menu_was_clicked: mov r5, 0 mov r6, 0 mov r7, 0 - mov r0, menu_bar_click_event_type ; set event type to menu bar click type + mov r0, MENU_BAR_CLICK_EVENT_TYPE ; set event type to menu bar click type call new_event mouse_update_end: pop r7 diff --git a/submenu.asm b/submenu.asm index 3745a74..f017e79 100644 --- a/submenu.asm +++ b/submenu.asm @@ -38,7 +38,7 @@ draw_submenu_items_calculate_x_loop: loop draw_submenu_items_calculate_x_loop draw_submenu_items_calculate_x_skip: sub r30, 8 ; move the submenu to the left by 8 pixels - mov.16 [overlay_29_position_x], r30 + mov.16 [OVERLAY_29_POSITION_X], r30 mov r31, r0 inc r31 ; point to submenu list pointer @@ -53,7 +53,7 @@ draw_submenu_items_calculate_x_skip: ; multiply the number of submenu items by 16 (the font is 16 pixels tall) mov r1, r31 mul r1, 16 - mov.16 [overlay_29_height], r1 + mov.16 [OVERLAY_29_HEIGHT], r1 ; calculate the required width for the submenu overlay ; multiply the width by 8 (the font is 8 pixels wide) @@ -62,25 +62,25 @@ draw_submenu_items_calculate_x_skip: movz.8 r1, [r1] ; load width of submenu mov r8, r1 ; save the width in characters in r8 for later mul r1, 8 - mov.16 [overlay_29_width], r1 + mov.16 [OVERLAY_29_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 [OVERLAY_29_POSITION_Y], 16 + mov [OVERLAY_29_FRAMEBUFFER_PTR], OVERLAY_29_FRAMEBUFFER mov r0, 0x8000001D ; overlay 29: position - mov.16 r1, [overlay_29_position_y] + mov.16 r1, [OVERLAY_29_POSITION_Y] sla r1, 16 - mov.16 r1, [overlay_29_position_x] + mov.16 r1, [OVERLAY_29_POSITION_X] out r0, r1 mov r0, 0x8000011D ; overlay 29: size - mov.16 r1, [overlay_29_height] + mov.16 r1, [OVERLAY_29_HEIGHT] sla r1, 16 - mov.16 r1, [overlay_29_width] + mov.16 r1, [OVERLAY_29_WIDTH] out r0, r1 mov r0, 0x8000021D ; overlay 29: framebuffer pointer - mov r1, [overlay_29_framebuffer_ptr] + mov r1, [OVERLAY_29_FRAMEBUFFER_PTR] out r0, r1 mov r0, 0x8000031D out r0, 1 @@ -239,7 +239,7 @@ submenu_update_event_clicked: mov r5, 0 mov r6, 0 mov r7, 0 - mov r0, submenu_click_event_type + mov r0, SUBMENU_CLICK_EVENT_TYPE call new_event mov r0, r1 call close_submenu @@ -253,7 +253,7 @@ submenu_update_event_end_push: mov r5, 0 mov r6, 0 mov r7, 0 - mov r0, submenu_update_event_type + mov r0, SUBMENU_UPDATE_EVENT_TYPE call new_event submenu_update_event_end_no_push: pop r9