fox32rom: Make all consts uppercase

This commit is contained in:
ry755 2022-02-11 20:44:11 -08:00 committed by Ry
parent 041cf206ec
commit 519d80a0c6
7 changed files with 65 additions and 65 deletions

View File

@ -1,6 +1,6 @@
; background routines ; background routines
const background: 0x80000000 ; pointer to background framebuffer const BACKGROUND_FRAMEBUFFER: 0x80000000 ; pointer to background framebuffer
; fill the whole background with a color ; fill the whole background with a color
; inputs: ; inputs:
@ -11,7 +11,7 @@ fill_background:
push r1 push r1
push r31 push r31
mov r1, background mov r1, BACKGROUND_FRAMEBUFFER
mov r31, 0x0004B000 ; 640*480 mov r31, 0x0004B000 ; 640*480
fill_background_loop: fill_background_loop:
mov [r1], r0 mov [r1], r0
@ -44,7 +44,7 @@ draw_filled_rectangle_to_background:
mul r1, 2560 ; y * 2560 (640 * 4 = 2560) mul r1, 2560 ; y * 2560 (640 * 4 = 2560)
mul r0, 4 ; x * 4 mul r0, 4 ; x * 4
add r0, r1 ; y * 2560 + (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 mov r6, r2
mul r6, 4 ; multiply the X size by 4, since 4 bytes per pixel 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 r2, 2560 ; y * 2560 (640 * 4 = 2560)
mul r1, 4 ; x * 4 mul r1, 4 ; x * 4
add r1, r2 ; y * 2560 + (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 mov r6, 16 ; y counter
draw_font_tile_to_background_y_loop: draw_font_tile_to_background_y_loop:

View File

@ -1,18 +1,18 @@
; event system routines ; event system routines
const event_queue_top: 0x01FFFFFE const EVENT_QUEUE_TOP: 0x01FFFFFE
const event_queue_bottom: 0x01FFFBFE ; top - 0x400 (32 events * (4 bytes * (1 type + 7 parameters))) const EVENT_QUEUE_BOTTOM: 0x01FFFBFE ; top - 0x400 (32 events * (4 bytes * (1 type + 7 parameters)))
const event_queue_index: 0x01FFFFFF ; byte const EVENT_QUEUE_INDEX: 0x01FFFFFF ; byte
const event_queue_size: 32 ; 32 events const EVENT_QUEUE_SIZE: 32 ; 32 events
const event_size_bytes: 32 ; 32 bytes per event const EVENT_SIZE_BYTES: 32 ; 32 bytes per event
const event_size_words: 8 ; 8 words per event const EVENT_SIZE_WORDS: 8 ; 8 words per event
; event types ; event types
const mouse_click_event_type: 0x00000000 const MOUSE_CLICK_EVENT_TYPE: 0x00000000
const menu_bar_click_event_type: 0x00000001 const MENU_BAR_CLICK_EVENT_TYPE: 0x00000001
const submenu_update_event_type: 0x00000002 const SUBMENU_UPDATE_EVENT_TYPE: 0x00000002
const submenu_click_event_type: 0x00000003 const SUBMENU_CLICK_EVENT_TYPE: 0x00000003
const empty_event_type: 0xFFFFFFFF const EMPTY_EVENT_TYPE: 0xFFFFFFFF
; block until an event is available ; block until an event is available
; inputs: ; inputs:
@ -25,7 +25,7 @@ wait_for_event:
halt halt
; if the event queue index doesn't equal zero, then at least one event is available ; 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 ifz jmp wait_for_event
; an event is available in the event queue, remove it from the queue and return it ; an event is available in the event queue, remove it from the queue and return it
@ -41,16 +41,16 @@ wait_for_event:
; none ; none
new_event: new_event:
; ensure there is enough space left for another 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 ifz ret
push r8 push r8
push r9 push r9
; point to the current event queue index ; point to the current event queue index
mov r8, event_queue_bottom mov r8, EVENT_QUEUE_BOTTOM
movz.8 r9, [event_queue_index] movz.8 r9, [EVENT_QUEUE_INDEX]
mul r9, event_size_bytes mul r9, EVENT_SIZE_BYTES
add r8, r9 add r8, r9
; copy the event type ; copy the event type
@ -74,7 +74,7 @@ new_event:
add r8, 4 add r8, 4
; increment the index ; increment the index
inc.8 [event_queue_index] inc.8 [EVENT_QUEUE_INDEX]
pop r9 pop r9
pop r8 pop r8
@ -88,14 +88,14 @@ new_event:
; r1-r7: event parameters ; r1-r7: event parameters
get_next_event: get_next_event:
; if the event queue index equals zero, then the queue is empty ; 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 ifz jmp get_next_event_empty
icl icl
push r8 push r8
; point to the bottom of the event queue ; point to the bottom of the event queue
mov r8, event_queue_bottom mov r8, EVENT_QUEUE_BOTTOM
; copy the event type ; copy the event type
mov r0, [r8] mov r0, [r8]
@ -120,13 +120,13 @@ get_next_event:
call shift_events call shift_events
; decrement the index ; decrement the index
dec.8 [event_queue_index] dec.8 [EVENT_QUEUE_INDEX]
pop r8 pop r8
ise ise
ret ret
get_next_event_empty: get_next_event_empty:
mov r0, empty_event_type mov r0, EMPTY_EVENT_TYPE
mov r1, 0 mov r1, 0
mov r2, 0 mov r2, 0
mov r3, 0 mov r3, 0
@ -153,24 +153,24 @@ shift_events:
; event_queue[i] = event_queue[i + 1]; ; event_queue[i] = event_queue[i + 1];
; } ; }
movz.8 r31, [event_queue_index] movz.8 r31, [EVENT_QUEUE_INDEX]
mov r3, 0 ; i mov r3, 0 ; i
; source pointer: event_queue[i + 1] ; source pointer: event_queue[i + 1]
mov r0, event_queue_bottom mov r0, EVENT_QUEUE_BOTTOM
mov r4, r3 mov r4, r3
inc r4 inc r4
mul r4, event_size_words mul r4, EVENT_SIZE_WORDS
add r0, r4 add r0, r4
; destination pointer: event_queue[i] ; destination pointer: event_queue[i]
mov r1, event_queue_bottom mov r1, EVENT_QUEUE_BOTTOM
mov r4, r3 mov r4, r3
mul r4, event_size_words mul r4, EVENT_SIZE_WORDS
add r1, r4 add r1, r4
; size: event_size_words ; size: event_size_words
mov r2, event_size_words mov r2, EVENT_SIZE_WORDS
call copy_memory_words call copy_memory_words

View File

@ -28,8 +28,8 @@ draw_submenu_items: jmp [0xF100300C]
close_submenu: jmp [0xF1003010] close_submenu: jmp [0xF1003010]
; event types ; event types
const mouse_click_event_type: 0x00000000 const MOUSE_CLICK_EVENT_TYPE: 0x00000000
const menu_bar_click_event_type: 0x00000001 const MENU_BAR_CLICK_EVENT_TYPE: 0x00000001
const submenu_update_event_type: 0x00000002 const SUBMENU_UPDATE_EVENT_TYPE: 0x00000002
const submenu_click_event_type: 0x00000003 const SUBMENU_CLICK_EVENT_TYPE: 0x00000003
const empty_event_type: 0xFFFFFFFF const EMPTY_EVENT_TYPE: 0xFFFFFFFF

View File

@ -2,12 +2,12 @@
; fox32 starts here on reset ; fox32 starts here on reset
org 0xF0000000 org 0xF0000000
const system_stack: 0x01FFF800 const SYSTEM_STACK: 0x01FFF800
const background_color: 0xFF414C50 const BACKGROUND_COLOR: 0xFF414C50
; initialization code ; initialization code
entry: entry:
mov rsp, system_stack mov rsp, SYSTEM_STACK
mov [0x000003FC], system_vsync_handler mov [0x000003FC], system_vsync_handler
@ -44,7 +44,7 @@ cursor_enable:
mov r0, 0x8000031F mov r0, 0x8000031F
out r0, 1 out r0, 1
mov r0, background_color mov r0, BACKGROUND_COLOR
call fill_background call fill_background
menu_bar_enable: menu_bar_enable:
@ -112,20 +112,20 @@ event_loop:
call get_next_event call get_next_event
; was the mouse clicked? ; was the mouse clicked?
cmp r0, mouse_click_event_type cmp r0, MOUSE_CLICK_EVENT_TYPE
;ifz call mouse_click_event ;ifz call mouse_click_event
; did the user click the menu bar? ; 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 mov r0, menu_items_root
ifz call menu_bar_click_event ifz call menu_bar_click_event
; is the user in a submenu? ; is the user in a submenu?
cmp r0, submenu_update_event_type cmp r0, SUBMENU_UPDATE_EVENT_TYPE
ifz call submenu_update_event ifz call submenu_update_event
; did the user click a submenu item? ; did the user click a submenu item?
cmp r0, submenu_click_event_type cmp r0, SUBMENU_CLICK_EVENT_TYPE
ifz call submenu_click_event ifz call submenu_click_event
; check if a disk is mounted as disk 0 ; check if a disk is mounted as disk 0
@ -231,12 +231,12 @@ overlay_30_framebuffer_ptr: data.32 0x8012D180
; submenu overlay struct: ; submenu overlay struct:
; this struct must be writable, so these are hard-coded addresses in shared memory ; this struct must be writable, so these are hard-coded addresses in shared memory
const overlay_29_width: 0x80137180 ; 2 bytes const OVERLAY_29_WIDTH: 0x80137180 ; 2 bytes
const overlay_29_height: 0x80137182 ; 2 bytes const OVERLAY_29_HEIGHT: 0x80137182 ; 2 bytes
const overlay_29_position_x: 0x80137184 ; 2 bytes const OVERLAY_29_POSITION_X: 0x80137184 ; 2 bytes
const overlay_29_position_y: 0x80137186 ; 2 bytes const OVERLAY_29_POSITION_Y: 0x80137186 ; 2 bytes
const overlay_29_framebuffer_ptr: 0x8013718A ; 4 bytes const OVERLAY_29_FRAMEBUFFER_PTR: 0x8013718A ; 4 bytes
const overlay_29_framebuffer: 0x8013718E const OVERLAY_29_FRAMEBUFFER: 0x8013718E
startup_str_1: data.str "Welcome to fox32" data.8 0 startup_str_1: data.str "Welcome to fox32" data.8 0
startup_str_2: data.str "Insert boot disk" data.8 0 startup_str_2: data.str "Insert boot disk" data.8 0

View File

@ -175,7 +175,7 @@ menu_bar_click_event_found_item:
mov r5, 0 mov r5, 0
mov r6, 0 mov r6, 0
mov r7, 0 mov r7, 0
mov r0, submenu_update_event_type mov r0, SUBMENU_UPDATE_EVENT_TYPE
call new_event call new_event
menu_bar_click_event_end: menu_bar_click_event_end:
pop r31 pop r31

View File

@ -79,7 +79,7 @@ mouse_update:
mov r5, 0 mov r5, 0
mov r6, 0 mov r6, 0
mov r7, 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 call new_event
jmp mouse_update_end jmp mouse_update_end
mouse_update_menu_was_clicked: mouse_update_menu_was_clicked:
@ -90,7 +90,7 @@ mouse_update_menu_was_clicked:
mov r5, 0 mov r5, 0
mov r6, 0 mov r6, 0
mov r7, 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 call new_event
mouse_update_end: mouse_update_end:
pop r7 pop r7

View File

@ -38,7 +38,7 @@ draw_submenu_items_calculate_x_loop:
loop draw_submenu_items_calculate_x_loop loop draw_submenu_items_calculate_x_loop
draw_submenu_items_calculate_x_skip: draw_submenu_items_calculate_x_skip:
sub r30, 8 ; move the submenu to the left by 8 pixels 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 mov r31, r0
inc r31 ; point to submenu list pointer 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) ; multiply the number of submenu items by 16 (the font is 16 pixels tall)
mov r1, r31 mov r1, r31
mul r1, 16 mul r1, 16
mov.16 [overlay_29_height], r1 mov.16 [OVERLAY_29_HEIGHT], r1
; calculate the required width for the submenu overlay ; calculate the required width for the submenu overlay
; multiply the width by 8 (the font is 8 pixels wide) ; 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 movz.8 r1, [r1] ; load width of submenu
mov r8, r1 ; save the width in characters in r8 for later mov r8, r1 ; save the width in characters in r8 for later
mul r1, 8 mul r1, 8
mov.16 [overlay_29_width], r1 mov.16 [OVERLAY_29_WIDTH], r1
push r0 push r0
; set properties of overlay 29 ; set properties of overlay 29
mov.16 [overlay_29_position_y], 16 mov.16 [OVERLAY_29_POSITION_Y], 16
mov [overlay_29_framebuffer_ptr], overlay_29_framebuffer mov [OVERLAY_29_FRAMEBUFFER_PTR], OVERLAY_29_FRAMEBUFFER
mov r0, 0x8000001D ; overlay 29: position mov r0, 0x8000001D ; overlay 29: position
mov.16 r1, [overlay_29_position_y] mov.16 r1, [OVERLAY_29_POSITION_Y]
sla r1, 16 sla r1, 16
mov.16 r1, [overlay_29_position_x] mov.16 r1, [OVERLAY_29_POSITION_X]
out r0, r1 out r0, r1
mov r0, 0x8000011D ; overlay 29: size mov r0, 0x8000011D ; overlay 29: size
mov.16 r1, [overlay_29_height] mov.16 r1, [OVERLAY_29_HEIGHT]
sla r1, 16 sla r1, 16
mov.16 r1, [overlay_29_width] mov.16 r1, [OVERLAY_29_WIDTH]
out r0, r1 out r0, r1
mov r0, 0x8000021D ; overlay 29: framebuffer pointer mov r0, 0x8000021D ; overlay 29: framebuffer pointer
mov r1, [overlay_29_framebuffer_ptr] mov r1, [OVERLAY_29_FRAMEBUFFER_PTR]
out r0, r1 out r0, r1
mov r0, 0x8000031D mov r0, 0x8000031D
out r0, 1 out r0, 1
@ -239,7 +239,7 @@ submenu_update_event_clicked:
mov r5, 0 mov r5, 0
mov r6, 0 mov r6, 0
mov r7, 0 mov r7, 0
mov r0, submenu_click_event_type mov r0, SUBMENU_CLICK_EVENT_TYPE
call new_event call new_event
mov r0, r1 mov r0, r1
call close_submenu call close_submenu
@ -253,7 +253,7 @@ submenu_update_event_end_push:
mov r5, 0 mov r5, 0
mov r6, 0 mov r6, 0
mov r7, 0 mov r7, 0
mov r0, submenu_update_event_type mov r0, SUBMENU_UPDATE_EVENT_TYPE
call new_event call new_event
submenu_update_event_end_no_push: submenu_update_event_end_no_push:
pop r9 pop r9