fox32rom: Add routines for drawing decimal values
This commit is contained in:
parent
a7ccb2167e
commit
f17a15b14a
|
@ -96,3 +96,33 @@ draw_str_to_background_loop:
|
|||
pop r5
|
||||
pop r0
|
||||
ret
|
||||
|
||||
; draw a decimal 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_decimal_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_decimal_generic
|
||||
|
||||
pop r9
|
||||
pop r8
|
||||
pop r7
|
||||
pop r6
|
||||
pop r5
|
||||
ret
|
|
@ -109,3 +109,49 @@ draw_str_generic_loop:
|
|||
pop r10
|
||||
pop r0
|
||||
ret
|
||||
|
||||
; draw a decimal 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_decimal_generic:
|
||||
push r0
|
||||
push r10 ; r10: original stack pointer
|
||||
push r11 ; temp 1
|
||||
push r12 ; temp 2
|
||||
push r13 ; temp 3
|
||||
mov r10, rsp
|
||||
mov r12, r0
|
||||
|
||||
push.8 0x00 ; end the string with a terminator
|
||||
draw_decimal_generic_find_loop:
|
||||
push r12
|
||||
div r12, 10 ; quotient goes into r12
|
||||
pop r13
|
||||
rem r13, 10 ; remainder goes into r13
|
||||
mov r11, r13
|
||||
add r11, '0'
|
||||
push.8 r11
|
||||
cmp r12, 0
|
||||
ifnz jmp draw_decimal_generic_find_loop
|
||||
draw_decimal_generic_print:
|
||||
mov r0, rsp ; point to start of string in the stack
|
||||
call draw_str_generic
|
||||
|
||||
mov rsp, r10
|
||||
pop r13
|
||||
pop r12
|
||||
pop r11
|
||||
pop r10
|
||||
pop r0
|
||||
ret
|
||||
|
|
21
fox32rom.def
21
fox32rom.def
|
@ -10,23 +10,26 @@ get_next_event: jmp [0xF0040014]
|
|||
|
||||
; generic drawing jump table
|
||||
draw_str_generic: jmp [0xF0041000]
|
||||
draw_font_tile_generic: jmp [0xF0041004]
|
||||
draw_filled_rectangle_generic: jmp [0xF0041008]
|
||||
draw_decimal_generic: jmp [0xF0041004]
|
||||
draw_font_tile_generic: jmp [0xF0041008]
|
||||
draw_filled_rectangle_generic: jmp [0xF004100C]
|
||||
|
||||
; background jump table entries
|
||||
fill_background: jmp [0xF0042000]
|
||||
draw_str_to_background: jmp [0xF0042004]
|
||||
draw_font_tile_to_background: jmp [0xF0042008]
|
||||
draw_filled_rectangle_to_background: jmp [0xF004200C]
|
||||
draw_decimal_to_background: jmp [0xF0042008]
|
||||
draw_font_tile_to_background: jmp [0xF004200C]
|
||||
draw_filled_rectangle_to_background: jmp [0xF0042010]
|
||||
|
||||
; overlay jump table entries
|
||||
fill_overlay: jmp [0xF0043000]
|
||||
draw_str_to_overlay: jmp [0xF0043004]
|
||||
draw_font_tile_to_overlay: jmp [0xF0043008]
|
||||
draw_filled_rectangle_to_overlay: jmp [0xF004300C]
|
||||
find_overlay_covering_position: jmp [0xF0043010]
|
||||
check_if_overlay_covers_position: jmp [0xF0043014]
|
||||
check_if_enabled_overlay_covers_position: jmp [0xF0043018]
|
||||
draw_decimal_to_overlay: jmp [0xF0043008]
|
||||
draw_font_tile_to_overlay: jmp [0xF004300C]
|
||||
draw_filled_rectangle_to_overlay: jmp [0xF0043010]
|
||||
find_overlay_covering_position: jmp [0xF0043014]
|
||||
check_if_overlay_covers_position: jmp [0xF0043018]
|
||||
check_if_enabled_overlay_covers_position: jmp [0xF004301C]
|
||||
|
||||
; menu bar jump table entries
|
||||
menu_bar_click_event: jmp [0xF0044000]
|
||||
|
|
3
main.asm
3
main.asm
|
@ -201,6 +201,7 @@ get_rom_version:
|
|||
; generic drawing jump table
|
||||
org.pad 0xF0041000
|
||||
data.32 draw_str_generic
|
||||
data.32 draw_decimal_generic
|
||||
data.32 draw_font_tile_generic
|
||||
data.32 draw_filled_rectangle_generic
|
||||
|
||||
|
@ -208,6 +209,7 @@ get_rom_version:
|
|||
org.pad 0xF0042000
|
||||
data.32 fill_background
|
||||
data.32 draw_str_to_background
|
||||
data.32 draw_decimal_to_background
|
||||
data.32 draw_font_tile_to_background
|
||||
data.32 draw_filled_rectangle_to_background
|
||||
|
||||
|
@ -215,6 +217,7 @@ get_rom_version:
|
|||
org.pad 0xF0043000
|
||||
data.32 fill_overlay
|
||||
data.32 draw_str_to_overlay
|
||||
data.32 draw_decimal_to_overlay
|
||||
data.32 draw_font_tile_to_overlay
|
||||
data.32 draw_filled_rectangle_to_overlay
|
||||
data.32 find_overlay_covering_position
|
||||
|
|
35
overlay.asm
35
overlay.asm
|
@ -121,6 +121,41 @@ draw_str_to_overlay_loop:
|
|||
pop r0
|
||||
ret
|
||||
|
||||
; draw a decimal 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_decimal_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_decimal_generic
|
||||
|
||||
pop r9
|
||||
pop r8
|
||||
pop r7
|
||||
pop r6
|
||||
pop r5
|
||||
ret
|
||||
|
||||
; finds the overlay with the highest priority covering the specified position
|
||||
; does not check overlay 31, which is always the mouse pointer
|
||||
; inputs:
|
||||
|
|
Loading…
Reference in New Issue
Block a user