launcher: Initial commit
This commit is contained in:
parent
2a4b5bef9b
commit
c3b68946f5
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,5 +5,6 @@
|
|||
**/*.fxf
|
||||
**/bg.inc
|
||||
**/bg.raw
|
||||
**/icons.inc
|
||||
**/fox32os.img
|
||||
**/fox32os.img.tmp
|
||||
|
|
9
Makefile
9
Makefile
|
@ -35,6 +35,12 @@ base_image/bg.raw: applications/bg/bg.inc
|
|||
applications/bg/bg.inc: applications/bg/bg.png
|
||||
$(GFX2INC) 640 480 $< $@
|
||||
|
||||
base_image/launcher.fxf: applications/launcher/main.asm $(wildcard applications/launcher/*.asm) applications/launcher/icons.inc
|
||||
$(FOX32ASM) $< $@
|
||||
|
||||
applications/launcher/icons.inc: applications/launcher/icons.png
|
||||
$(GFX2INC) 16 16 $< $@
|
||||
|
||||
bootloader/bootloader.bin: bootloader/main.asm $(wildcard bootloader/*.asm)
|
||||
$(FOX32ASM) $< $@
|
||||
|
||||
|
@ -45,7 +51,8 @@ FILES = \
|
|||
base_image/terminal.fxf \
|
||||
base_image/foxpaint.fxf \
|
||||
base_image/bg.fxf \
|
||||
base_image/bg.raw
|
||||
base_image/bg.raw \
|
||||
base_image/launcher.fxf
|
||||
|
||||
fox32os.img: $(BOOTLOADER) $(FILES)
|
||||
$(RYFS) -s $(IMAGE_SIZE) -l fox32os -b $(BOOTLOADER) create fox32os.img.tmp
|
||||
|
|
BIN
applications/launcher/icons.png
Normal file
BIN
applications/launcher/icons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 639 B |
64
applications/launcher/launch.asm
Normal file
64
applications/launcher/launch.asm
Normal file
|
@ -0,0 +1,64 @@
|
|||
; FXF launcher helper routines
|
||||
|
||||
; launch an FXF binary from a file name
|
||||
; inputs:
|
||||
; r0: pointer to FXF binary name
|
||||
; outputs:
|
||||
; none
|
||||
launch_fxf:
|
||||
push r0
|
||||
push r1
|
||||
push r2
|
||||
push r3
|
||||
push r4
|
||||
|
||||
; open the file
|
||||
mov r1, 0
|
||||
mov r2, launch_fxf_struct
|
||||
call open
|
||||
cmp r0, 0
|
||||
ifz jmp allocate_error
|
||||
|
||||
; allocate memory for the binary
|
||||
mov r0, launch_fxf_struct
|
||||
call ryfs_get_size
|
||||
call allocate_memory
|
||||
cmp r0, 0
|
||||
ifz jmp allocate_error
|
||||
mov [launch_fxf_binary_ptr], r0
|
||||
|
||||
; read the file into memory
|
||||
mov r0, launch_fxf_struct
|
||||
mov r1, [launch_fxf_binary_ptr]
|
||||
call ryfs_read_whole_file
|
||||
|
||||
; allocate a 64KiB stack
|
||||
mov r0, 65536
|
||||
call allocate_memory
|
||||
cmp r0, 0
|
||||
ifz jmp allocate_error
|
||||
mov [launch_fxf_stack_ptr], r0
|
||||
|
||||
; relocate the binary
|
||||
mov r0, [launch_fxf_binary_ptr]
|
||||
call parse_fxf_binary
|
||||
|
||||
; create a new task
|
||||
mov r1, r0
|
||||
call get_unused_task_id
|
||||
mov r2, [launch_fxf_stack_ptr]
|
||||
add r2, 65516 ; point to the end of the stack (stack grows down!!)
|
||||
mov r3, [launch_fxf_binary_ptr]
|
||||
mov r4, [launch_fxf_stack_ptr]
|
||||
call new_task
|
||||
allocate_error:
|
||||
pop r4
|
||||
pop r3
|
||||
pop r2
|
||||
pop r1
|
||||
pop r0
|
||||
ret
|
||||
|
||||
launch_fxf_struct: data.fill 0, 8
|
||||
launch_fxf_binary_ptr: data.32 0
|
||||
launch_fxf_stack_ptr: data.32 0
|
107
applications/launcher/main.asm
Normal file
107
applications/launcher/main.asm
Normal file
|
@ -0,0 +1,107 @@
|
|||
; simple application launcher
|
||||
|
||||
; create the window
|
||||
mov r0, window_struct
|
||||
mov r1, window_title
|
||||
mov r2, 88
|
||||
mov r3, 0
|
||||
mov r4, 0
|
||||
mov r5, 464
|
||||
mov r6, 0
|
||||
mov r7, terminal_button_widget
|
||||
call new_window
|
||||
|
||||
; draw the buttons
|
||||
mov r0, window_struct
|
||||
call draw_widgets_to_window
|
||||
|
||||
; set the tilemap
|
||||
mov r0, icons
|
||||
mov r1, 16
|
||||
mov r2, 16
|
||||
call set_tilemap
|
||||
|
||||
; draw the icons
|
||||
mov r0, window_struct
|
||||
call get_window_overlay_number
|
||||
mov r3, r0
|
||||
mov r0, 0
|
||||
mov r1, 72
|
||||
mov r2, 0
|
||||
call draw_tile_to_overlay
|
||||
|
||||
event_loop:
|
||||
mov r0, window_struct
|
||||
call get_next_window_event
|
||||
|
||||
; was the mouse clicked?
|
||||
cmp r0, EVENT_TYPE_MOUSE_CLICK
|
||||
ifz call mouse_click_event
|
||||
|
||||
; did the user click a button?
|
||||
cmp r0, EVENT_TYPE_BUTTON_CLICK
|
||||
ifz call button_click_event
|
||||
|
||||
call yield_task
|
||||
jmp event_loop
|
||||
|
||||
mouse_click_event:
|
||||
push r0
|
||||
|
||||
; first, check if we are attempting to drag or close the window
|
||||
cmp r1, 72
|
||||
iflteq jmp drag_or_close_window
|
||||
|
||||
; then, handle widget clicks
|
||||
mov r0, window_struct
|
||||
call handle_widget_click
|
||||
|
||||
pop r0
|
||||
ret
|
||||
|
||||
button_click_event:
|
||||
; r1 contains the ID of the clicked button
|
||||
|
||||
; terminal
|
||||
cmp r1, 0
|
||||
ifz mov r0, terminal_button_fxf
|
||||
ifz call launch_fxf
|
||||
|
||||
ret
|
||||
|
||||
drag_or_close_window:
|
||||
cmp r1, 8
|
||||
iflteq jmp close_window
|
||||
mov r0, window_struct
|
||||
call start_dragging_window
|
||||
pop r0
|
||||
ret
|
||||
close_window:
|
||||
mov r0, window_struct
|
||||
call destroy_window
|
||||
call end_current_task
|
||||
|
||||
window_title: data.str "Launcher" data.8 0
|
||||
window_struct: data.fill 0, 36
|
||||
|
||||
terminal_button_fxf: data.str "terminalfxf" data.8 0
|
||||
terminal_button_widget:
|
||||
data.32 0 ; next_ptr
|
||||
data.32 0 ; id
|
||||
data.32 WIDGET_TYPE_BUTTON ; type
|
||||
data.32 button_text ; text_ptr
|
||||
data.32 0xFFFFFFFF ; foreground_color
|
||||
data.32 0xFF000000 ; background_color
|
||||
data.16 16 ; width
|
||||
data.16 0 ; reserved
|
||||
data.16 72 ; x_pos
|
||||
data.16 0 ; y_pos
|
||||
button_text: data.str " " data.8 0
|
||||
|
||||
icons:
|
||||
#include "icons.inc"
|
||||
|
||||
#include "launch.asm"
|
||||
|
||||
#include "../../../fox32rom/fox32rom.def"
|
||||
#include "../../fox32os.def"
|
|
@ -1 +1,3 @@
|
|||
bg fxf
|
||||
launcherfxf
|
||||
terminalfxf
|
||||
|
|
Loading…
Reference in New Issue
Block a user