Add get_tilemap and get_unused_overlay

This commit is contained in:
Ry 2022-09-02 14:23:46 -07:00
parent f31a722e4f
commit 9550e1945b
4 changed files with 49 additions and 0 deletions

View File

@ -9,6 +9,8 @@ const TILEMAP_HEIGHT: 0x01FFFFF8
; r0: pointer to tilemap data ; r0: pointer to tilemap data
; r1: tile width ; r1: tile width
; r2: tile height ; r2: tile height
; outputs:
; none
set_tilemap: set_tilemap:
mov [TILEMAP_POINTER], r0 mov [TILEMAP_POINTER], r0
mov [TILEMAP_WIDTH], r1 mov [TILEMAP_WIDTH], r1
@ -16,6 +18,20 @@ set_tilemap:
ret ret
; get the current tilemap
; inputs:
; none
; outputs:
; r0: pointer to tilemap data
; r1: tile width
; r2: tile height
get_tilemap:
mov r0, [TILEMAP_POINTER]
mov r1, [TILEMAP_WIDTH]
mov r2, [TILEMAP_HEIGHT]
ret
; draw a single tile to a framebuffer ; draw a single tile to a framebuffer
; inputs: ; inputs:
; r0: tile number ; r0: tile number

View File

@ -19,6 +19,7 @@ draw_tile_generic: jmp [0xF0041014]
set_tilemap: jmp [0xF0041018] set_tilemap: jmp [0xF0041018]
draw_pixel_generic: jmp [0xF004101C] draw_pixel_generic: jmp [0xF004101C]
draw_filled_rectangle_generic: jmp [0xF0041020] draw_filled_rectangle_generic: jmp [0xF0041020]
get_tilemap: jmp [0xF0041024]
; background jump table ; background jump table
fill_background: jmp [0xF0042000] fill_background: jmp [0xF0042000]
@ -48,6 +49,7 @@ disable_overlay: jmp [0xF0043030]
move_overlay: jmp [0xF0043034] move_overlay: jmp [0xF0043034]
resize_overlay: jmp [0xF0043038] resize_overlay: jmp [0xF0043038]
set_overlay_framebuffer_pointer: jmp [0xF004303C] set_overlay_framebuffer_pointer: jmp [0xF004303C]
get_unused_overlay: jmp [0xF0043040]
; menu bar jump table ; menu bar jump table
enable_menu_bar: jmp [0xF0044000] enable_menu_bar: jmp [0xF0044000]

View File

@ -189,6 +189,7 @@ get_rom_version:
data.32 set_tilemap data.32 set_tilemap
data.32 draw_pixel_generic data.32 draw_pixel_generic
data.32 draw_filled_rectangle_generic data.32 draw_filled_rectangle_generic
data.32 get_tilemap
; background jump table ; background jump table
org.pad 0xF0042000 org.pad 0xF0042000
@ -220,6 +221,7 @@ get_rom_version:
data.32 move_overlay data.32 move_overlay
data.32 resize_overlay data.32 resize_overlay
data.32 set_overlay_framebuffer_pointer data.32 set_overlay_framebuffer_pointer
data.32 get_unused_overlay
; menu bar jump table ; menu bar jump table
org.pad 0xF0044000 org.pad 0xF0044000

View File

@ -505,3 +505,32 @@ make_coordinates_relative_to_overlay:
pop r3 pop r3
pop r2 pop r2
ret ret
; find the first disabled overlay, starting from 0
; inputs:
; none
; outputs:
; r0: overlay number, or 0xFF if all overlays are enabled
get_unused_overlay:
push r1
push r31
mov r0, 0x80000000
mov r31, 31
get_unused_overlay_loop:
in r1, r0
cmp r1, 0
ifz jmp get_unused_overlay_found
inc r0
loop get_unused_overlay_loop
mov r0, 0xFF
pop r31
pop r1
ret
get_unused_overlay_found:
and r0, 0x000000FF
pop r31
pop r1
ret