2022-01-27 07:21:21 +01:00
|
|
|
; entry point
|
|
|
|
; fox32 starts here on reset
|
|
|
|
org 0xF0000000
|
|
|
|
|
2022-02-12 06:12:18 +01:00
|
|
|
const FOX32ROM_VERSION_MAJOR: 0
|
|
|
|
const FOX32ROM_VERSION_MINOR: 1
|
|
|
|
const FOX32ROM_VERSION_PATCH: 0
|
|
|
|
|
2022-02-12 05:44:11 +01:00
|
|
|
const SYSTEM_STACK: 0x01FFF800
|
2022-02-23 00:01:58 +01:00
|
|
|
const BACKGROUND_COLOR: 0xFF674764
|
|
|
|
const TEXT_COLOR: 0xFFFFFFFF
|
2022-01-27 07:21:21 +01:00
|
|
|
|
|
|
|
; initialization code
|
|
|
|
entry:
|
2022-02-12 05:44:11 +01:00
|
|
|
mov rsp, SYSTEM_STACK
|
2022-01-27 07:21:21 +01:00
|
|
|
|
|
|
|
mov [0x000003FC], system_vsync_handler
|
|
|
|
|
|
|
|
; disable all overlays
|
|
|
|
mov r31, 0x1F
|
2022-01-28 03:11:54 +01:00
|
|
|
mov r0, 0x80000300
|
2022-01-27 07:21:21 +01:00
|
|
|
disable_all_overlays_loop:
|
|
|
|
out r0, 0
|
|
|
|
inc r0
|
|
|
|
loop disable_all_overlays_loop
|
|
|
|
|
|
|
|
; write the cursor bitmap to the overlay framebuffer
|
|
|
|
mov r0, [overlay_31_framebuffer_ptr]
|
|
|
|
mov r1, mouse_cursor
|
|
|
|
mov r31, 96 ; 8x12
|
|
|
|
cursor_overlay_loop:
|
|
|
|
mov [r0], [r1]
|
|
|
|
add r0, 4
|
|
|
|
add r1, 4
|
|
|
|
loop cursor_overlay_loop
|
|
|
|
|
|
|
|
cursor_enable:
|
|
|
|
; set properties of overlay 31
|
2022-01-28 03:11:54 +01:00
|
|
|
mov r0, 0x8000011F ; overlay 31: size
|
2022-01-27 07:21:21 +01:00
|
|
|
mov.16 r1, [overlay_31_height]
|
|
|
|
sla r1, 16
|
|
|
|
mov.16 r1, [overlay_31_width]
|
|
|
|
out r0, r1
|
2022-01-28 03:11:54 +01:00
|
|
|
mov r0, 0x8000021F ; overlay 31: framebuffer pointer
|
2022-01-27 07:21:21 +01:00
|
|
|
mov r1, [overlay_31_framebuffer_ptr]
|
|
|
|
out r0, r1
|
|
|
|
|
|
|
|
; enable overlay 31 (cursor)
|
2022-01-28 03:11:54 +01:00
|
|
|
mov r0, 0x8000031F
|
2022-01-27 07:21:21 +01:00
|
|
|
out r0, 1
|
|
|
|
|
2022-02-12 05:44:11 +01:00
|
|
|
mov r0, BACKGROUND_COLOR
|
2022-01-27 07:21:21 +01:00
|
|
|
call fill_background
|
|
|
|
|
2022-03-23 19:24:01 +01:00
|
|
|
call enable_menu_bar
|
2022-01-27 07:21:21 +01:00
|
|
|
call clear_menu_bar
|
|
|
|
mov r0, menu_items_root
|
|
|
|
mov r1, 0xFFFFFFFF
|
|
|
|
call draw_menu_bar_root_items
|
|
|
|
|
|
|
|
draw_startup_text:
|
2022-02-22 22:47:20 +01:00
|
|
|
mov r0, startup_str
|
|
|
|
mov r1, 16
|
|
|
|
mov r2, 464
|
2022-02-23 00:01:58 +01:00
|
|
|
mov r3, TEXT_COLOR
|
2022-01-27 07:21:21 +01:00
|
|
|
mov r4, 0x00000000
|
2022-02-22 22:47:20 +01:00
|
|
|
mov r10, FOX32ROM_VERSION_MAJOR
|
|
|
|
mov r11, FOX32ROM_VERSION_MINOR
|
|
|
|
mov r12, FOX32ROM_VERSION_PATCH
|
|
|
|
call draw_format_str_to_background
|
2022-01-27 07:21:21 +01:00
|
|
|
|
|
|
|
ise
|
|
|
|
event_loop:
|
2022-02-12 05:27:23 +01:00
|
|
|
call get_next_event
|
2022-01-27 07:21:21 +01:00
|
|
|
|
|
|
|
; was the mouse clicked?
|
2022-02-12 05:44:11 +01:00
|
|
|
cmp r0, MOUSE_CLICK_EVENT_TYPE
|
2022-01-27 07:21:21 +01:00
|
|
|
;ifz call mouse_click_event
|
|
|
|
|
|
|
|
; did the user click the menu bar?
|
2022-02-12 05:44:11 +01:00
|
|
|
cmp r0, MENU_BAR_CLICK_EVENT_TYPE
|
2022-01-27 07:21:21 +01:00
|
|
|
ifz mov r0, menu_items_root
|
|
|
|
ifz call menu_bar_click_event
|
|
|
|
|
2022-02-22 06:26:30 +01:00
|
|
|
; is the user in a menu?
|
|
|
|
cmp r0, MENU_UPDATE_EVENT_TYPE
|
|
|
|
ifz call menu_update_event
|
2022-01-27 07:21:21 +01:00
|
|
|
|
2022-02-22 06:26:30 +01:00
|
|
|
; did the user click a menu item?
|
|
|
|
cmp r0, MENU_CLICK_EVENT_TYPE
|
|
|
|
ifz call menu_click_event
|
2022-01-27 07:21:21 +01:00
|
|
|
|
2022-02-22 23:05:39 +01:00
|
|
|
; check if a disk is inserted as disk 0
|
|
|
|
; if port 0x8000100n returns a non-zero value, then a disk is inserted as disk n
|
2022-01-30 09:57:54 +01:00
|
|
|
in r0, 0x80001000
|
|
|
|
cmp r0, 0
|
2022-01-31 12:37:49 +01:00
|
|
|
ifnz call start_boot_process
|
2022-01-30 09:57:54 +01:00
|
|
|
|
2022-01-27 07:21:21 +01:00
|
|
|
jmp event_loop
|
|
|
|
|
2022-02-22 06:26:30 +01:00
|
|
|
menu_click_event:
|
|
|
|
; r3 contains the clicked menu item
|
2022-01-27 07:21:21 +01:00
|
|
|
|
2022-02-22 23:05:39 +01:00
|
|
|
; insert disk
|
2022-03-11 20:48:27 +01:00
|
|
|
cmp r3, 0
|
2022-02-22 23:05:39 +01:00
|
|
|
ifz jmp insert_boot_disk
|
2022-01-30 09:57:54 +01:00
|
|
|
|
2022-03-12 02:39:41 +01:00
|
|
|
; shutdown
|
2022-03-11 20:48:27 +01:00
|
|
|
cmp r3, 1
|
2022-01-27 07:21:21 +01:00
|
|
|
ifz icl
|
|
|
|
ifz halt
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2022-02-22 23:05:39 +01:00
|
|
|
insert_boot_disk:
|
2022-01-30 09:57:54 +01:00
|
|
|
mov r0, 0x80001000
|
|
|
|
out r0, 0
|
|
|
|
ret
|
|
|
|
|
2022-02-12 06:12:18 +01:00
|
|
|
get_rom_version:
|
|
|
|
mov r0, FOX32ROM_VERSION_MAJOR
|
|
|
|
mov r1, FOX32ROM_VERSION_MINOR
|
|
|
|
mov r2, FOX32ROM_VERSION_PATCH
|
|
|
|
ret
|
|
|
|
|
2022-01-27 07:21:21 +01:00
|
|
|
; code
|
|
|
|
#include "background.asm"
|
2022-02-12 06:31:41 +01:00
|
|
|
#include "boot.asm"
|
2022-02-12 04:41:58 +01:00
|
|
|
#include "debug.asm"
|
2022-02-22 06:15:16 +01:00
|
|
|
#include "draw_rectangle.asm"
|
2022-02-13 05:42:37 +01:00
|
|
|
#include "draw_text.asm"
|
2022-02-12 06:31:41 +01:00
|
|
|
#include "event.asm"
|
2022-02-12 04:39:33 +01:00
|
|
|
#include "memory.asm"
|
2022-01-27 07:21:21 +01:00
|
|
|
#include "menu.asm"
|
2022-02-22 06:26:30 +01:00
|
|
|
#include "menu_bar.asm"
|
2022-01-27 07:21:21 +01:00
|
|
|
#include "mouse.asm"
|
2022-02-12 06:31:41 +01:00
|
|
|
#include "overlay.asm"
|
2022-03-19 05:59:51 +01:00
|
|
|
#include "panic.asm"
|
2022-01-27 07:21:21 +01:00
|
|
|
#include "vsync.asm"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; data
|
|
|
|
|
|
|
|
; system jump table
|
2022-02-12 05:57:37 +01:00
|
|
|
org.pad 0xF0040000
|
2022-02-12 06:12:18 +01:00
|
|
|
data.32 get_rom_version
|
2022-01-28 01:33:50 +01:00
|
|
|
data.32 system_vsync_handler
|
|
|
|
data.32 get_mouse_position
|
2022-02-12 05:27:23 +01:00
|
|
|
data.32 new_event
|
2022-01-28 01:33:50 +01:00
|
|
|
data.32 wait_for_event
|
2022-02-12 05:27:23 +01:00
|
|
|
data.32 get_next_event
|
2022-03-19 05:59:51 +01:00
|
|
|
data.32 panic
|
2022-01-27 07:21:21 +01:00
|
|
|
|
2022-02-22 06:15:16 +01:00
|
|
|
; generic drawing jump table
|
2022-02-12 05:57:37 +01:00
|
|
|
org.pad 0xF0041000
|
2022-02-13 05:42:37 +01:00
|
|
|
data.32 draw_str_generic
|
2022-02-22 22:45:54 +01:00
|
|
|
data.32 draw_format_str_generic
|
2022-02-22 07:07:02 +01:00
|
|
|
data.32 draw_decimal_generic
|
2022-02-13 05:42:37 +01:00
|
|
|
data.32 draw_font_tile_generic
|
2022-02-22 06:15:16 +01:00
|
|
|
data.32 draw_filled_rectangle_generic
|
2022-02-13 05:42:37 +01:00
|
|
|
|
|
|
|
; background jump table
|
|
|
|
org.pad 0xF0042000
|
|
|
|
data.32 fill_background
|
2022-01-28 01:33:50 +01:00
|
|
|
data.32 draw_str_to_background
|
2022-02-22 22:45:54 +01:00
|
|
|
data.32 draw_format_str_to_background
|
2022-02-22 07:07:02 +01:00
|
|
|
data.32 draw_decimal_to_background
|
2022-01-28 01:33:50 +01:00
|
|
|
data.32 draw_font_tile_to_background
|
2022-02-22 06:15:16 +01:00
|
|
|
data.32 draw_filled_rectangle_to_background
|
2022-01-27 07:21:21 +01:00
|
|
|
|
|
|
|
; overlay jump table
|
2022-02-13 05:42:37 +01:00
|
|
|
org.pad 0xF0043000
|
|
|
|
data.32 fill_overlay
|
2022-01-28 01:33:50 +01:00
|
|
|
data.32 draw_str_to_overlay
|
2022-02-22 22:45:54 +01:00
|
|
|
data.32 draw_format_str_to_overlay
|
2022-02-22 07:07:02 +01:00
|
|
|
data.32 draw_decimal_to_overlay
|
2022-01-28 01:33:50 +01:00
|
|
|
data.32 draw_font_tile_to_overlay
|
2022-02-22 06:15:16 +01:00
|
|
|
data.32 draw_filled_rectangle_to_overlay
|
2022-01-28 01:33:50 +01:00
|
|
|
data.32 find_overlay_covering_position
|
|
|
|
data.32 check_if_overlay_covers_position
|
|
|
|
data.32 check_if_enabled_overlay_covers_position
|
2022-01-27 07:21:21 +01:00
|
|
|
|
|
|
|
; menu bar jump table
|
2022-02-13 05:42:37 +01:00
|
|
|
org.pad 0xF0044000
|
2022-03-23 19:24:01 +01:00
|
|
|
data.32 enable_menu_bar
|
|
|
|
data.32 disable_menu_bar
|
2022-01-28 01:33:50 +01:00
|
|
|
data.32 menu_bar_click_event
|
|
|
|
data.32 clear_menu_bar
|
|
|
|
data.32 draw_menu_bar_root_items
|
2022-02-22 06:26:30 +01:00
|
|
|
data.32 draw_menu_items
|
|
|
|
data.32 close_menu
|
2022-03-23 19:30:17 +01:00
|
|
|
data.32 menu_update_event
|
2022-01-27 07:21:21 +01:00
|
|
|
|
2022-02-12 05:57:37 +01:00
|
|
|
org.pad 0xF004F000
|
2022-02-13 05:42:37 +01:00
|
|
|
standard_font_width:
|
|
|
|
data.16 8
|
|
|
|
standard_font_height:
|
|
|
|
data.16 16
|
|
|
|
standard_font_data:
|
2022-01-28 01:35:25 +01:00
|
|
|
#include_bin "font/unifont-thin.raw"
|
2022-01-27 07:21:21 +01:00
|
|
|
|
|
|
|
mouse_cursor:
|
2022-01-28 01:35:25 +01:00
|
|
|
#include_bin "font/cursor2.raw"
|
2022-01-27 07:21:21 +01:00
|
|
|
|
|
|
|
; cursor overlay struct:
|
2022-01-28 01:33:50 +01:00
|
|
|
overlay_31_width: data.16 8
|
|
|
|
overlay_31_height: data.16 12
|
|
|
|
overlay_31_position_x: data.16 0
|
|
|
|
overlay_31_position_y: data.16 0
|
2022-03-12 02:13:18 +01:00
|
|
|
overlay_31_framebuffer_ptr: data.32 0x0212D000
|
2022-01-27 07:21:21 +01:00
|
|
|
|
|
|
|
; menu bar overlay struct:
|
2022-01-28 01:33:50 +01:00
|
|
|
overlay_30_width: data.16 640
|
|
|
|
overlay_30_height: data.16 16
|
|
|
|
overlay_30_position_x: data.16 0
|
|
|
|
overlay_30_position_y: data.16 0
|
2022-03-12 02:13:18 +01:00
|
|
|
overlay_30_framebuffer_ptr: data.32 0x0212D180
|
2022-01-27 07:21:21 +01:00
|
|
|
|
2022-02-22 06:26:30 +01:00
|
|
|
; menu overlay struct:
|
2022-03-12 02:13:18 +01:00
|
|
|
; this struct must be writable, so these are hard-coded addresses in ram
|
|
|
|
const OVERLAY_29_WIDTH: 0x02137180 ; 2 bytes
|
|
|
|
const OVERLAY_29_HEIGHT: 0x02137182 ; 2 bytes
|
|
|
|
const OVERLAY_29_POSITION_X: 0x02137184 ; 2 bytes
|
|
|
|
const OVERLAY_29_POSITION_Y: 0x02137186 ; 2 bytes
|
|
|
|
const OVERLAY_29_FRAMEBUFFER_PTR: 0x0213718A ; 4 bytes
|
|
|
|
const OVERLAY_29_FRAMEBUFFER: 0x0213718E
|
2022-01-27 07:21:21 +01:00
|
|
|
|
2022-02-22 22:52:29 +01:00
|
|
|
startup_str: data.str "fox32 - ROM version %u.%u.%u - insert boot disk" data.8 0
|
2022-01-27 07:21:21 +01:00
|
|
|
|
|
|
|
menu_items_root:
|
2022-02-22 06:26:30 +01:00
|
|
|
data.8 1 ; number of menus
|
|
|
|
data.32 menu_items_system_list data.32 menu_items_system_name ; pointer to menu list, pointer to menu name
|
2022-01-27 07:21:21 +01:00
|
|
|
menu_items_system_name:
|
2022-03-11 20:48:27 +01:00
|
|
|
data.8 6 data.str "System" data.8 0x00 ; text length, text, null-terminator
|
2022-01-27 07:21:21 +01:00
|
|
|
menu_items_system_list:
|
2022-03-11 20:48:27 +01:00
|
|
|
data.8 2 ; number of items
|
|
|
|
data.8 13 ; menu width (usually longest item + 2)
|
2022-02-22 23:05:39 +01:00
|
|
|
data.8 11 data.str "Insert Disk" data.8 0x00 ; text length, text, null-terminator
|
2022-03-12 02:39:41 +01:00
|
|
|
data.8 9 data.str "Shut Down" data.8 0x00 ; text length, text, null-terminator
|
2022-01-27 07:21:21 +01:00
|
|
|
|
2022-02-12 05:57:37 +01:00
|
|
|
; pad out to 512 KiB
|
|
|
|
org.pad 0xF0080000
|