Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mac-style disk icon to Fox32ROM #6

Merged
merged 1 commit into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added font/disk1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added font/disk1.raw
Binary file not shown.
Binary file added font/disk2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added font/disk2.raw
Binary file not shown.
75 changes: 75 additions & 0 deletions icon.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
; status icon routines
; created by TalonFox for Ry :3

; note to self: icon overlay is overlay 28 (0x1c)

; changes the 32x32 pixel icon to the given icon pointed at the given address
; inputs:
; r0: Pointer to icon data
; outputs:
; none
change_icon:
push r0
push r1
push r31

; write the cursor bitmap to the overlay framebuffer
movz.32 r1, r0
mov r0, ICON_FRAMEBUFFER_PTR
mov r31, 1024 ; 32x32
change_icon_loop:
mov [r0], [r1]
add r0, 4
add r1, 4
loop change_icon_loop
pop r31
pop r1
pop r0
ret

setup_icon:
push r0
push r1
movz r0, 0x8000001c
movz r1, ICON_POSITION_Y
sla r1, 16
or r1, ICON_POSITION_X
out r0, r1
add r0, 0x100
movz r1, ICON_HEIGHT
sla r1, 16
or r1, ICON_WIDTH
out r0, r1
add r0, 0x100
movz r1, ICON_FRAMEBUFFER_PTR
out r0, r1
add r0, 0x100
movz r1, 1
out r0, r1
pop r1
pop r0
ret

const ICON_TICK: 0x03FFFFFC

icon_update:
push r0
mov.32 r0, [ICON_TICK]
add r0, 1
rem r0, 60
mov.32 [ICON_TICK], r0
cmp r0, 0
ifz jmp icon_update1
cmp r0, 30
ifz jmp icon_update2
jmp icon_update_ret
icon_update1:
movz r0, disk_icon_q
call change_icon
jmp icon_update_ret
icon_update2:
movz r0, disk_icon
call change_icon
icon_update_ret:
pop r0
ret
86 changes: 56 additions & 30 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -121,36 +121,42 @@ draw_bottom_bar_loop:
call draw_format_str_to_background

; draw the box in the middle of the screen
mov r0, 242
mov r1, 203
mov r2, 156
mov r3, 60
mov r4, 0xFFFFFFFF
call draw_filled_rectangle_to_background
mov r0, 243
mov r1, 204
mov r2, 154
mov r3, 58
mov r4, 0xFF000000
call draw_filled_rectangle_to_background
mov r0, 244
mov r1, 205
mov r2, 152
mov r3, 56
mov r4, 0xFFFFFFFF
call draw_filled_rectangle_to_background
;mov r0, 242
;mov r1, 203
;mov r2, 156
;mov r3, 60
;mov r4, 0xFFFFFFFF
;call draw_filled_rectangle_to_background
;mov r0, 243
;mov r1, 204
;mov r2, 154
;mov r3, 58
;mov r4, 0xFF000000
;call draw_filled_rectangle_to_background
;mov r0, 244
;mov r1, 205
;mov r2, 152
;mov r3, 56
;mov r4, 0xFFFFFFFF
;call draw_filled_rectangle_to_background

; draw the text inside the box
mov r0, startup_str_0
mov r1, 256
mov r2, 216
mov r3, 0xFF000000
mov r4, 0x00000000
call draw_str_to_background
mov r0, startup_str_1
mov r1, 256
mov r2, 232
call draw_str_to_background
; mov r0, startup_str_0
; mov r1, 256
; mov r2, 216
; mov r3, 0xFF000000
; mov r4, 0x00000000
; call draw_str_to_background
; mov r0, startup_str_1
; mov r1, 256
; mov r2, 232
; call draw_str_to_background

mov r0, disk_icon_q
call change_icon
call setup_icon

mov r0, bottom_bar_patterns

event_loop:
call get_next_event
Expand Down Expand Up @@ -198,6 +204,7 @@ poweroff_wait:
#include "draw_tile.asm"
#include "event.asm"
#include "exception.asm"
#include "icon.asm"
#include "integer.asm"
#include "keyboard.asm"
#include "memory.asm"
Expand Down Expand Up @@ -341,6 +348,18 @@ standard_font_data:
mouse_cursor:
#include_bin "font/cursor2.raw"

disk_icon:
#include_bin "font/disk1.raw"
disk_icon_q:
#include_bin "font/disk2.raw"

; icon overlay struct:
const ICON_WIDTH: 32
const ICON_HEIGHT: 32
const ICON_POSITION_X: 304
const ICON_POSITION_Y: 224
const ICON_FRAMEBUFFER_PTR: 0x0212C000

; cursor overlay struct:
const CURSOR_WIDTH: 8
const CURSOR_HEIGHT: 12
Expand All @@ -353,6 +372,13 @@ const MENU_BAR_POSITION_X: 0
const MENU_BAR_POSITION_Y: 0
const MENU_BAR_FRAMEBUFFER_PTR: 0x0214C180

; menu bar overlay struct:
const MENU_BAR_WIDTH: 640
const MENU_BAR_HEIGHT: 16
const MENU_BAR_POSITION_X: 0
const MENU_BAR_POSITION_Y: 0
const MENU_BAR_FRAMEBUFFER_PTR: 0x0214D180

; menu overlay struct:
; this struct must be writable, so these are hard-coded addresses in ram
const MENU_WIDTH: 0x02156180 ; 2 bytes
Expand All @@ -362,8 +388,8 @@ const MENU_POSITION_Y: 0x02156186 ; 2 bytes
const MENU_FRAMEBUFFER_PTR: 0x0215618A ; 4 bytes
const MENU_FRAMEBUFFER: 0x0215618E ; max 640x480x4 = end address at 0x0228218E

startup_str_0: data.strz "Welcome to fox32"
startup_str_1: data.strz "Insert boot disk"
; startup_str_0: data.strz "Welcome to fox32"
; startup_str_1: data.strz "Insert boot disk"

bottom_bar_str_0: data.strz "FOX"
bottom_bar_str_1: data.strz "32"
Expand Down
1 change: 1 addition & 0 deletions vsync.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ system_vsync_handler:

call mouse_update
call keyboard_update
call icon_update

pop r7
pop r6
Expand Down