fox32rom: Add draw_pixel routines
This commit is contained in:
parent
7f830cdceb
commit
8b2df35475
|
@ -22,6 +22,25 @@ fill_background_loop:
|
||||||
pop r1
|
pop r1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; draw a pixel to the background
|
||||||
|
; inputs:
|
||||||
|
; r0: X coordinate
|
||||||
|
; r1: Y coordinate
|
||||||
|
; r2: color
|
||||||
|
; outputs:
|
||||||
|
; none
|
||||||
|
draw_pixel_to_background:
|
||||||
|
push r5
|
||||||
|
push r6
|
||||||
|
|
||||||
|
mov r3, BACKGROUND_FRAMEBUFFER
|
||||||
|
mov r4, 640
|
||||||
|
call draw_pixel_generic
|
||||||
|
|
||||||
|
pop r6
|
||||||
|
pop r5
|
||||||
|
ret
|
||||||
|
|
||||||
; draw a filled rectangle to the background
|
; draw a filled rectangle to the background
|
||||||
; inputs:
|
; inputs:
|
||||||
; r0: X coordinate of top-left
|
; r0: X coordinate of top-left
|
||||||
|
|
32
draw_pixel.asm
Normal file
32
draw_pixel.asm
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
; generic pixel drawing routines
|
||||||
|
|
||||||
|
; draw a pixel to a framebuffer
|
||||||
|
; inputs:
|
||||||
|
; r0: X coordinate
|
||||||
|
; r1: Y coordinate
|
||||||
|
; r2: color
|
||||||
|
; r3: pointer to framebuffer
|
||||||
|
; r4: framebuffer width (pixels)
|
||||||
|
; outputs:
|
||||||
|
; none
|
||||||
|
draw_pixel_generic:
|
||||||
|
push r0
|
||||||
|
push r1
|
||||||
|
push r3
|
||||||
|
push r4
|
||||||
|
|
||||||
|
; calculate pointer to the framebuffer
|
||||||
|
mul r4, 4 ; 4 bytes per pixel
|
||||||
|
mul r1, r4 ; y * width * 4
|
||||||
|
mul r0, 4 ; x * 4
|
||||||
|
add r0, r1 ; y * width * 4 + (x * 4)
|
||||||
|
add r3, r0
|
||||||
|
mov r0, r3 ; r0: pointer to framebuffer
|
||||||
|
|
||||||
|
mov [r0], r2
|
||||||
|
|
||||||
|
pop r4
|
||||||
|
pop r3
|
||||||
|
pop r1
|
||||||
|
pop r0
|
||||||
|
ret
|
15
fox32rom.def
15
fox32rom.def
|
@ -15,7 +15,8 @@ draw_format_str_generic: jmp [0xF0041004]
|
||||||
draw_decimal_generic: jmp [0xF0041008]
|
draw_decimal_generic: jmp [0xF0041008]
|
||||||
draw_hex_generic: jmp [0xF004100C]
|
draw_hex_generic: jmp [0xF004100C]
|
||||||
draw_font_tile_generic: jmp [0xF0041010]
|
draw_font_tile_generic: jmp [0xF0041010]
|
||||||
draw_filled_rectangle_generic: jmp [0xF0041014]
|
draw_pixel_generic: jmp [0xF0041014]
|
||||||
|
draw_filled_rectangle_generic: jmp [0xF0041018]
|
||||||
|
|
||||||
; background jump table entries
|
; background jump table entries
|
||||||
fill_background: jmp [0xF0042000]
|
fill_background: jmp [0xF0042000]
|
||||||
|
@ -24,7 +25,8 @@ draw_format_str_to_background: jmp [0xF0042008]
|
||||||
draw_decimal_to_background: jmp [0xF004200C]
|
draw_decimal_to_background: jmp [0xF004200C]
|
||||||
draw_hex_to_background: jmp [0xF0042010]
|
draw_hex_to_background: jmp [0xF0042010]
|
||||||
draw_font_tile_to_background: jmp [0xF0042014]
|
draw_font_tile_to_background: jmp [0xF0042014]
|
||||||
draw_filled_rectangle_to_background: jmp [0xF0042018]
|
draw_pixel_to_background: jmp [0xF0042018]
|
||||||
|
draw_filled_rectangle_to_background: jmp [0xF004201C]
|
||||||
|
|
||||||
; overlay jump table entries
|
; overlay jump table entries
|
||||||
fill_overlay: jmp [0xF0043000]
|
fill_overlay: jmp [0xF0043000]
|
||||||
|
@ -33,10 +35,11 @@ draw_format_str_to_overlay: jmp [0xF0043008]
|
||||||
draw_decimal_to_overlay: jmp [0xF004300C]
|
draw_decimal_to_overlay: jmp [0xF004300C]
|
||||||
draw_hex_to_overlay: jmp [0xF0043010]
|
draw_hex_to_overlay: jmp [0xF0043010]
|
||||||
draw_font_tile_to_overlay: jmp [0xF0043014]
|
draw_font_tile_to_overlay: jmp [0xF0043014]
|
||||||
draw_filled_rectangle_to_overlay: jmp [0xF0043018]
|
draw_pixel_to_overlay: jmp [0xF0043018]
|
||||||
find_overlay_covering_position: jmp [0xF004301C]
|
draw_filled_rectangle_to_overlay: jmp [0xF004301C]
|
||||||
check_if_overlay_covers_position: jmp [0xF0043020]
|
find_overlay_covering_position: jmp [0xF0043020]
|
||||||
check_if_enabled_overlay_covers_position: jmp [0xF0043024]
|
check_if_overlay_covers_position: jmp [0xF0043024]
|
||||||
|
check_if_enabled_overlay_covers_position: jmp [0xF0043028]
|
||||||
|
|
||||||
; menu bar jump table entries
|
; menu bar jump table entries
|
||||||
enable_menu_bar: jmp [0xF0044000]
|
enable_menu_bar: jmp [0xF0044000]
|
||||||
|
|
4
main.asm
4
main.asm
|
@ -132,6 +132,7 @@ get_rom_version:
|
||||||
#include "boot.asm"
|
#include "boot.asm"
|
||||||
#include "debug.asm"
|
#include "debug.asm"
|
||||||
#include "disk.asm"
|
#include "disk.asm"
|
||||||
|
#include "draw_pixel.asm"
|
||||||
#include "draw_rectangle.asm"
|
#include "draw_rectangle.asm"
|
||||||
#include "draw_text.asm"
|
#include "draw_text.asm"
|
||||||
#include "event.asm"
|
#include "event.asm"
|
||||||
|
@ -165,6 +166,7 @@ get_rom_version:
|
||||||
data.32 draw_format_str_generic
|
data.32 draw_format_str_generic
|
||||||
data.32 draw_decimal_generic
|
data.32 draw_decimal_generic
|
||||||
data.32 draw_font_tile_generic
|
data.32 draw_font_tile_generic
|
||||||
|
data.32 draw_pixel_generic
|
||||||
data.32 draw_filled_rectangle_generic
|
data.32 draw_filled_rectangle_generic
|
||||||
|
|
||||||
; background jump table
|
; background jump table
|
||||||
|
@ -174,6 +176,7 @@ get_rom_version:
|
||||||
data.32 draw_format_str_to_background
|
data.32 draw_format_str_to_background
|
||||||
data.32 draw_decimal_to_background
|
data.32 draw_decimal_to_background
|
||||||
data.32 draw_font_tile_to_background
|
data.32 draw_font_tile_to_background
|
||||||
|
data.32 draw_pixel_to_background
|
||||||
data.32 draw_filled_rectangle_to_background
|
data.32 draw_filled_rectangle_to_background
|
||||||
|
|
||||||
; overlay jump table
|
; overlay jump table
|
||||||
|
@ -183,6 +186,7 @@ get_rom_version:
|
||||||
data.32 draw_format_str_to_overlay
|
data.32 draw_format_str_to_overlay
|
||||||
data.32 draw_decimal_to_overlay
|
data.32 draw_decimal_to_overlay
|
||||||
data.32 draw_font_tile_to_overlay
|
data.32 draw_font_tile_to_overlay
|
||||||
|
data.32 draw_pixel_to_overlay
|
||||||
data.32 draw_filled_rectangle_to_overlay
|
data.32 draw_filled_rectangle_to_overlay
|
||||||
data.32 find_overlay_covering_position
|
data.32 find_overlay_covering_position
|
||||||
data.32 check_if_overlay_covers_position
|
data.32 check_if_overlay_covers_position
|
||||||
|
|
25
overlay.asm
25
overlay.asm
|
@ -33,6 +33,31 @@ fill_overlay_loop:
|
||||||
pop r1
|
pop r1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; draw a pixel to an overlay
|
||||||
|
; inputs:
|
||||||
|
; r0: X coordinate
|
||||||
|
; r1: Y coordinate
|
||||||
|
; r2: color
|
||||||
|
; r3: overlay number
|
||||||
|
; outputs:
|
||||||
|
; none
|
||||||
|
draw_pixel_to_overlay:
|
||||||
|
push r3
|
||||||
|
push r4
|
||||||
|
|
||||||
|
mov r4, r3
|
||||||
|
or r4, 0x80000100 ; bitwise or the overlay number with the command to get the overlay size
|
||||||
|
or r3, 0x80000200 ; bitwise or the overlay number with the command to get the framebuffer pointer
|
||||||
|
in r3, r3 ; r3: overlay framebuffer poiner
|
||||||
|
in r4, r4
|
||||||
|
and r4, 0x0000FFFF ; r4: overlay width
|
||||||
|
|
||||||
|
call draw_pixel_generic
|
||||||
|
|
||||||
|
pop r4
|
||||||
|
pop r3
|
||||||
|
ret
|
||||||
|
|
||||||
; draw a filled rectangle to an overlay
|
; draw a filled rectangle to an overlay
|
||||||
; inputs:
|
; inputs:
|
||||||
; r0: X coordinate of top-left
|
; r0: X coordinate of top-left
|
||||||
|
|
Loading…
Reference in New Issue
Block a user