From 16399b2f2797d8aa1c80d09bf61a7209f9c380e4 Mon Sep 17 00:00:00 2001 From: Ry Date: Fri, 1 Apr 2022 16:05:59 -0700 Subject: [PATCH] fox32rom: Add draw_hex routines --- background.asm | 32 +++++++++++++++++++++++++++++++- draw_text.asm | 40 ++++++++++++++++++++++++++++++++++++++++ fox32rom.def | 21 ++++++++++++--------- overlay.asm | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 10 deletions(-) diff --git a/background.asm b/background.asm index f5822b0..129a089 100644 --- a/background.asm +++ b/background.asm @@ -156,4 +156,34 @@ draw_decimal_to_background: pop r7 pop r6 pop r5 - ret \ No newline at end of file + 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 diff --git a/draw_text.asm b/draw_text.asm index 92f7955..f988ea8 100644 --- a/draw_text.asm +++ b/draw_text.asm @@ -288,3 +288,43 @@ draw_decimal_generic_print: pop r10 pop r0 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" diff --git a/fox32rom.def b/fox32rom.def index 3e24ebb..488583c 100644 --- a/fox32rom.def +++ b/fox32rom.def @@ -13,27 +13,30 @@ panic: jmp [0xF0040018] draw_str_generic: jmp [0xF0041000] draw_format_str_generic: jmp [0xF0041004] draw_decimal_generic: jmp [0xF0041008] -draw_font_tile_generic: jmp [0xF004100C] -draw_filled_rectangle_generic: jmp [0xF0041010] +draw_hex_generic: jmp [0xF004100C] +draw_font_tile_generic: jmp [0xF0041010] +draw_filled_rectangle_generic: jmp [0xF0041014] ; background jump table entries fill_background: jmp [0xF0042000] draw_str_to_background: jmp [0xF0042004] draw_format_str_to_background: jmp [0xF0042008] draw_decimal_to_background: jmp [0xF004200C] -draw_font_tile_to_background: jmp [0xF0042010] -draw_filled_rectangle_to_background: jmp [0xF0042014] +draw_hex_to_background: jmp [0xF0042010] +draw_font_tile_to_background: jmp [0xF0042014] +draw_filled_rectangle_to_background: jmp [0xF0042018] ; overlay jump table entries fill_overlay: jmp [0xF0043000] draw_str_to_overlay: jmp [0xF0043004] draw_format_str_to_overlay: jmp [0xF0043008] draw_decimal_to_overlay: jmp [0xF004300C] -draw_font_tile_to_overlay: jmp [0xF0043010] -draw_filled_rectangle_to_overlay: jmp [0xF0043014] -find_overlay_covering_position: jmp [0xF0043018] -check_if_overlay_covers_position: jmp [0xF004301C] -check_if_enabled_overlay_covers_position: jmp [0xF0043020] +draw_hex_to_overlay: jmp [0xF0043010] +draw_font_tile_to_overlay: jmp [0xF0043014] +draw_filled_rectangle_to_overlay: jmp [0xF0043018] +find_overlay_covering_position: jmp [0xF004301C] +check_if_overlay_covers_position: jmp [0xF0043020] +check_if_enabled_overlay_covers_position: jmp [0xF0043024] ; menu bar jump table entries enable_menu_bar: jmp [0xF0044000] diff --git a/overlay.asm b/overlay.asm index c382ab0..c5c4875 100644 --- a/overlay.asm +++ b/overlay.asm @@ -193,6 +193,41 @@ draw_decimal_to_overlay: pop r5 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 ; does not check overlay 31, which is always the mouse pointer ; inputs: