kernel/res + base: Add get_resource
and an icons.res file
This commit is contained in:
parent
a1a8e9f7f9
commit
19f5996855
12
Makefile
12
Makefile
|
@ -67,8 +67,19 @@ bootloader/bootloader.bin: bootloader/main.asm $(wildcard bootloader/*.asm)
|
||||||
base_image/startup.cfg: base_image/startup.cfg.default
|
base_image/startup.cfg: base_image/startup.cfg.default
|
||||||
cp $< $@
|
cp $< $@
|
||||||
|
|
||||||
|
ICONS := \
|
||||||
|
applications/icons/cfg_icon.inc \
|
||||||
|
applications/icons/dsk_icon.inc \
|
||||||
|
applications/icons/fxf_icon.inc
|
||||||
|
|
||||||
|
applications/icons/%.inc: applications/icons/%.png
|
||||||
|
$(GFX2INC) 32 32 $< $@
|
||||||
|
base_image/icons.res: applications/icons/icons.res.asm $(ICONS)
|
||||||
|
$(FOX32ASM) $< $@
|
||||||
|
|
||||||
FILES = \
|
FILES = \
|
||||||
base_image/startup.cfg \
|
base_image/startup.cfg \
|
||||||
|
base_image/icons.res \
|
||||||
base_image/kernel.fxf \
|
base_image/kernel.fxf \
|
||||||
base_image/sh.fxf \
|
base_image/sh.fxf \
|
||||||
base_image/barclock.fxf \
|
base_image/barclock.fxf \
|
||||||
|
@ -83,6 +94,7 @@ FILES = \
|
||||||
|
|
||||||
ROM_FILES = \
|
ROM_FILES = \
|
||||||
base_image/startup.cfg \
|
base_image/startup.cfg \
|
||||||
|
base_image/icons.res \
|
||||||
base_image/kernel.fxf \
|
base_image/kernel.fxf \
|
||||||
base_image/sh.fxf \
|
base_image/sh.fxf \
|
||||||
base_image/barclock.fxf \
|
base_image/barclock.fxf \
|
||||||
|
|
1
applications/icons/.gitignore
vendored
Normal file
1
applications/icons/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.inc
|
BIN
applications/icons/cfg_icon.png
Normal file
BIN
applications/icons/cfg_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
applications/icons/dsk_icon.png
Normal file
BIN
applications/icons/dsk_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
BIN
applications/icons/fxf_icon.png
Normal file
BIN
applications/icons/fxf_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
16
applications/icons/icons.res.asm
Normal file
16
applications/icons/icons.res.asm
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
const ICON_SIZE: 4096
|
||||||
|
|
||||||
|
; format: "RES" magic bytes, version, number of resource IDs
|
||||||
|
data.str "RES" data.8 0 data.8 3
|
||||||
|
|
||||||
|
; format: 3 character null-terminated ID, pointer to data, size
|
||||||
|
data.strz "cfg" data.32 cfg_icon data.32 ICON_SIZE
|
||||||
|
data.strz "dsk" data.32 dsk_icon data.32 ICON_SIZE
|
||||||
|
data.strz "fxf" data.32 fxf_icon data.32 ICON_SIZE
|
||||||
|
|
||||||
|
cfg_icon:
|
||||||
|
#include "cfg_icon.inc"
|
||||||
|
dsk_icon:
|
||||||
|
#include "dsk_icon.inc"
|
||||||
|
fxf_icon:
|
||||||
|
#include "fxf_icon.inc"
|
|
@ -52,6 +52,9 @@ get_size: jmp [0x00000D24]
|
||||||
draw_widgets_to_window: jmp [0x00000E10]
|
draw_widgets_to_window: jmp [0x00000E10]
|
||||||
handle_widget_click: jmp [0x00000E14]
|
handle_widget_click: jmp [0x00000E14]
|
||||||
|
|
||||||
|
; resource jump table
|
||||||
|
get_resource: jmp [0x00000F10]
|
||||||
|
|
||||||
; event types
|
; event types
|
||||||
const EVENT_TYPE_BUTTON_CLICK: 0x80000000
|
const EVENT_TYPE_BUTTON_CLICK: 0x80000000
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,10 @@ jump_table:
|
||||||
org.pad 0x00000610
|
org.pad 0x00000610
|
||||||
data.32 draw_widgets_to_window
|
data.32 draw_widgets_to_window
|
||||||
data.32 handle_widget_click
|
data.32 handle_widget_click
|
||||||
|
|
||||||
|
; resource jump table
|
||||||
|
org.pad 0x00000710
|
||||||
|
data.32 get_resource
|
||||||
jump_table_end:
|
jump_table_end:
|
||||||
|
|
||||||
; initialization code
|
; initialization code
|
||||||
|
@ -374,6 +378,7 @@ get_os_api_version:
|
||||||
|
|
||||||
#include "allocator.asm"
|
#include "allocator.asm"
|
||||||
#include "fxf/fxf.asm"
|
#include "fxf/fxf.asm"
|
||||||
|
#include "res.asm"
|
||||||
#include "task.asm"
|
#include "task.asm"
|
||||||
#include "vfs/vfs.asm"
|
#include "vfs/vfs.asm"
|
||||||
#include "widget/widget.asm"
|
#include "widget/widget.asm"
|
||||||
|
|
48
kernel/res.asm
Normal file
48
kernel/res.asm
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
; RES resource routines
|
||||||
|
|
||||||
|
; extract resource data from a RES binary loaded in memory
|
||||||
|
; inputs:
|
||||||
|
; r0: pointer to memory buffer containing a RES binary
|
||||||
|
; r1: pointer to 3 character null-terminated resource ID string
|
||||||
|
; r2: size of resource data to be extracted
|
||||||
|
; outputs:
|
||||||
|
; r0: pointer to newly-allocated memory buffer containing the requested resource data
|
||||||
|
; this buffer must be freed by the caller!
|
||||||
|
; returns zero if resource ID not found, not enough memory, or invalid magic bytes
|
||||||
|
get_resource:
|
||||||
|
cmp [r0], [res_magic]
|
||||||
|
ifnz mov r0, 0
|
||||||
|
ifnz ret
|
||||||
|
|
||||||
|
push r3
|
||||||
|
push r31
|
||||||
|
|
||||||
|
mov r3, r0
|
||||||
|
movz.8 r31, [r0+4]
|
||||||
|
add r0, 5
|
||||||
|
get_resource_find_loop:
|
||||||
|
cmp [r0], [r1]
|
||||||
|
ifz jmp get_resource_found
|
||||||
|
add r0, 12
|
||||||
|
loop get_resource_find_loop
|
||||||
|
mov r0, 0
|
||||||
|
jmp get_resource_end
|
||||||
|
get_resource_found:
|
||||||
|
cmp r2, [r0+8]
|
||||||
|
ifgt mov r2, [r0+8]
|
||||||
|
mov r31, [r0+4]
|
||||||
|
add r31, r3
|
||||||
|
mov r0, r2
|
||||||
|
call allocate_memory
|
||||||
|
cmp r0, 0
|
||||||
|
ifz jmp get_resource_end
|
||||||
|
mov r1, r0
|
||||||
|
mov r0, r31
|
||||||
|
call copy_memory_bytes
|
||||||
|
mov r0, r1
|
||||||
|
get_resource_end:
|
||||||
|
pop r31
|
||||||
|
pop r3
|
||||||
|
ret
|
||||||
|
|
||||||
|
res_magic: data.strz "RES"
|
Loading…
Reference in New Issue
Block a user