fox32rom: Add draw_hex routines

This commit is contained in:
Ry 2022-04-01 16:05:59 -07:00
parent 8cb29104bb
commit 16399b2f27
4 changed files with 118 additions and 10 deletions

View File

@ -157,3 +157,33 @@ draw_decimal_to_background:
pop r6 pop r6
pop r5 pop r5
ret ret
; draw a hex value to the background
; inputs:
; r0: value
; r1: X coordinate
; r2: Y coordinate
; r3: foreground color
; r4: background color
; outputs:
; r1: X coordinate of end of text
draw_hex_to_background:
push r5
push r6
push r7
push r8
push r9
mov r5, standard_font_data
movz.16 r6, [standard_font_width]
movz.16 r7, [standard_font_height]
mov r8, BACKGROUND_FRAMEBUFFER
mov r9, 640
call draw_hex_generic
pop r9
pop r8
pop r7
pop r6
pop r5
ret

View File

@ -288,3 +288,43 @@ draw_decimal_generic_print:
pop r10 pop r10
pop r0 pop r0
ret ret
; draw a hex value to a framebuffer
; inputs:
; r0: value
; r1: X coordinate
; r2: Y coordinate
; r3: foreground color
; r4: background color
; r5: pointer to font graphics
; r6: font width
; r7: font height
; r8: pointer to framebuffer
; r9: framebuffer width
; outputs:
; r1: X coordinate of end of text
draw_hex_generic:
push r10
push r11
push r12
push r31
mov r10, r0
mov r31, 8
draw_hex_generic_loop:
rol r10, 4
movz.16 r11, r10
and r11, 0x0F
mov r12, draw_hex_generic_characters
add r12, r11
movz.8 r0, [r12]
call draw_font_tile_generic
add r1, r6
loop draw_hex_generic_loop
pop r31
pop r12
pop r11
pop r10
ret
draw_hex_generic_characters: data.str "0123456789ABCDEF"

View File

@ -13,27 +13,30 @@ panic: jmp [0xF0040018]
draw_str_generic: jmp [0xF0041000] draw_str_generic: jmp [0xF0041000]
draw_format_str_generic: jmp [0xF0041004] draw_format_str_generic: jmp [0xF0041004]
draw_decimal_generic: jmp [0xF0041008] draw_decimal_generic: jmp [0xF0041008]
draw_font_tile_generic: jmp [0xF004100C] draw_hex_generic: jmp [0xF004100C]
draw_filled_rectangle_generic: jmp [0xF0041010] draw_font_tile_generic: jmp [0xF0041010]
draw_filled_rectangle_generic: jmp [0xF0041014]
; background jump table entries ; background jump table entries
fill_background: jmp [0xF0042000] fill_background: jmp [0xF0042000]
draw_str_to_background: jmp [0xF0042004] draw_str_to_background: jmp [0xF0042004]
draw_format_str_to_background: jmp [0xF0042008] draw_format_str_to_background: jmp [0xF0042008]
draw_decimal_to_background: jmp [0xF004200C] draw_decimal_to_background: jmp [0xF004200C]
draw_font_tile_to_background: jmp [0xF0042010] draw_hex_to_background: jmp [0xF0042010]
draw_filled_rectangle_to_background: jmp [0xF0042014] draw_font_tile_to_background: jmp [0xF0042014]
draw_filled_rectangle_to_background: jmp [0xF0042018]
; overlay jump table entries ; overlay jump table entries
fill_overlay: jmp [0xF0043000] fill_overlay: jmp [0xF0043000]
draw_str_to_overlay: jmp [0xF0043004] draw_str_to_overlay: jmp [0xF0043004]
draw_format_str_to_overlay: jmp [0xF0043008] draw_format_str_to_overlay: jmp [0xF0043008]
draw_decimal_to_overlay: jmp [0xF004300C] draw_decimal_to_overlay: jmp [0xF004300C]
draw_font_tile_to_overlay: jmp [0xF0043010] draw_hex_to_overlay: jmp [0xF0043010]
draw_filled_rectangle_to_overlay: jmp [0xF0043014] draw_font_tile_to_overlay: jmp [0xF0043014]
find_overlay_covering_position: jmp [0xF0043018] draw_filled_rectangle_to_overlay: jmp [0xF0043018]
check_if_overlay_covers_position: jmp [0xF004301C] find_overlay_covering_position: jmp [0xF004301C]
check_if_enabled_overlay_covers_position: jmp [0xF0043020] check_if_overlay_covers_position: jmp [0xF0043020]
check_if_enabled_overlay_covers_position: jmp [0xF0043024]
; menu bar jump table entries ; menu bar jump table entries
enable_menu_bar: jmp [0xF0044000] enable_menu_bar: jmp [0xF0044000]

View File

@ -193,6 +193,41 @@ draw_decimal_to_overlay:
pop r5 pop r5
ret ret
; draw a hex value to an overlay
; inputs:
; r0: value
; r1: X coordinate
; r2: Y coordinate
; r3: foreground color
; r4: background color
; outputs:
; r1: X coordinate of end of text
draw_hex_to_overlay:
push r5
push r6
push r7
push r8
push r9
mov r6, r5
or r6, 0x80000100 ; bitwise or the overlay number with the command to get the overlay size
or r5, 0x80000200 ; bitwise or the overlay number with the command to get the framebuffer pointer
in r8, r5 ; r8: overlay framebuffer poiner
in r9, r6
and r9, 0x0000FFFF ; r9: overlay width
mov r5, standard_font_data
movz.16 r6, [standard_font_width]
movz.16 r7, [standard_font_height]
call draw_hex_generic
pop r9
pop r8
pop r7
pop r6
pop r5
ret
; finds the overlay with the highest priority covering the specified position ; finds the overlay with the highest priority covering the specified position
; does not check overlay 31, which is always the mouse pointer ; does not check overlay 31, which is always the mouse pointer
; inputs: ; inputs: