From 9550e1945bd6fe1cb2046a2df0cac5b72aca7796 Mon Sep 17 00:00:00 2001 From: Ry Date: Fri, 2 Sep 2022 14:23:46 -0700 Subject: [PATCH] Add `get_tilemap` and `get_unused_overlay` --- draw_tile.asm | 16 ++++++++++++++++ fox32rom.def | 2 ++ main.asm | 2 ++ overlay.asm | 29 +++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/draw_tile.asm b/draw_tile.asm index c617fab..4e4d19d 100644 --- a/draw_tile.asm +++ b/draw_tile.asm @@ -9,6 +9,8 @@ const TILEMAP_HEIGHT: 0x01FFFFF8 ; r0: pointer to tilemap data ; r1: tile width ; r2: tile height +; outputs: +; none set_tilemap: mov [TILEMAP_POINTER], r0 mov [TILEMAP_WIDTH], r1 @@ -16,6 +18,20 @@ set_tilemap: 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 ; inputs: ; r0: tile number diff --git a/fox32rom.def b/fox32rom.def index 218aadb..44b0319 100644 --- a/fox32rom.def +++ b/fox32rom.def @@ -19,6 +19,7 @@ draw_tile_generic: jmp [0xF0041014] set_tilemap: jmp [0xF0041018] draw_pixel_generic: jmp [0xF004101C] draw_filled_rectangle_generic: jmp [0xF0041020] +get_tilemap: jmp [0xF0041024] ; background jump table fill_background: jmp [0xF0042000] @@ -48,6 +49,7 @@ disable_overlay: jmp [0xF0043030] move_overlay: jmp [0xF0043034] resize_overlay: jmp [0xF0043038] set_overlay_framebuffer_pointer: jmp [0xF004303C] +get_unused_overlay: jmp [0xF0043040] ; menu bar jump table enable_menu_bar: jmp [0xF0044000] diff --git a/main.asm b/main.asm index bff913a..deea550 100644 --- a/main.asm +++ b/main.asm @@ -189,6 +189,7 @@ get_rom_version: data.32 set_tilemap data.32 draw_pixel_generic data.32 draw_filled_rectangle_generic + data.32 get_tilemap ; background jump table org.pad 0xF0042000 @@ -220,6 +221,7 @@ get_rom_version: data.32 move_overlay data.32 resize_overlay data.32 set_overlay_framebuffer_pointer + data.32 get_unused_overlay ; menu bar jump table org.pad 0xF0044000 diff --git a/overlay.asm b/overlay.asm index a70ee35..b24cb0b 100644 --- a/overlay.asm +++ b/overlay.asm @@ -505,3 +505,32 @@ make_coordinates_relative_to_overlay: pop r3 pop r2 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