From 19f5996855973136650a5f09a615248cca08b573 Mon Sep 17 00:00:00 2001 From: Ry Date: Thu, 12 Oct 2023 16:17:08 -0700 Subject: [PATCH] kernel/res + base: Add `get_resource` and an icons.res file --- Makefile | 12 ++++++++ applications/icons/.gitignore | 1 + applications/icons/cfg_icon.png | Bin 0 -> 4831 bytes applications/icons/dsk_icon.png | Bin 0 -> 4464 bytes applications/icons/fxf_icon.png | Bin 0 -> 4829 bytes applications/icons/icons.res.asm | 16 +++++++++++ fox32os.def | 3 ++ kernel/main.asm | 5 ++++ kernel/res.asm | 48 +++++++++++++++++++++++++++++++ 9 files changed, 85 insertions(+) create mode 100644 applications/icons/.gitignore create mode 100644 applications/icons/cfg_icon.png create mode 100644 applications/icons/dsk_icon.png create mode 100644 applications/icons/fxf_icon.png create mode 100644 applications/icons/icons.res.asm create mode 100644 kernel/res.asm diff --git a/Makefile b/Makefile index 7764c41..3e564c2 100644 --- a/Makefile +++ b/Makefile @@ -67,8 +67,19 @@ bootloader/bootloader.bin: bootloader/main.asm $(wildcard bootloader/*.asm) base_image/startup.cfg: base_image/startup.cfg.default 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 = \ base_image/startup.cfg \ + base_image/icons.res \ base_image/kernel.fxf \ base_image/sh.fxf \ base_image/barclock.fxf \ @@ -83,6 +94,7 @@ FILES = \ ROM_FILES = \ base_image/startup.cfg \ + base_image/icons.res \ base_image/kernel.fxf \ base_image/sh.fxf \ base_image/barclock.fxf \ diff --git a/applications/icons/.gitignore b/applications/icons/.gitignore new file mode 100644 index 0000000..2a06e93 --- /dev/null +++ b/applications/icons/.gitignore @@ -0,0 +1 @@ +*.inc diff --git a/applications/icons/cfg_icon.png b/applications/icons/cfg_icon.png new file mode 100644 index 0000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LoELj;?&{*3(a}em9!xN`$84C~ SRw;sM@igjG)zSHR>;4BIIa-te literal 0 HcmV?d00001 diff --git a/applications/icons/fxf_icon.png b/applications/icons/fxf_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..918a70cdc86de21cb9d5333bb491931f06f90172 GIT binary patch literal 4829 zcmeHKeNYtV8DGSTqTpx}k%+oEX(uRqw|lquwc$XyJLF={P`Civ$(VO{-#fN&x5wVX z9cUt=v~i3OLm(#NS1PTRpv`C?>QLhZKc|^kjj38|31bq{1TE22JCWFT@A#Z#rbAo% z7k9H?&-*;T_j!KL@7<4$Im?&E#XcH~VOX3a+m?%txUx;2g!X~T%G>DBTj?s4b3qXI zOQKsSfw)}Zhd2xgZVU@u+5FR=)lPhD^1V9`ubwz@jX&wzhOgp2yPMZ~sl#$6dD(=_ z-Gz-{ZU4MaKBxC5(G719p6Y%3O0BuVrSn{J@7r@$PyHr(dcpdrDfx-bADoO&s+~nB=caD`=IYt5&ZD-+Y%}JjekyM%@3v?=Prj0q zeCW}%%?FMbR8QEtZPiCTGjAO*v}djQD&xagG2w9ezJ*U%V=ydggJ8AhIIPye!cn2}4(^68|DKl-47wxKEnA%x%(Lrt5-M{CTYd`8+c0Kp>Gf@jp zP5Aja{D~L-o^kgttt*;#NcEYHUH4D4Wt?31p8A~c%0KSB?QMS=yRY*%2m9ZdMSkn3 zJlJBdt2*xO>ORtvviiMGj?m`T{?Ad0q zYQ6QjH*J@{oOg3xPjByEb=$vt0c&|j>e&1IC)Y4+db)swSm=C;;Y6<*@FEMsxU5t&K0vpg@;|_VvDNKnS)zJ3F5SxR+EH1B$R7a>9Kg4#JibX zTh;&sy0WN>WZBPXG{Im{9n`5s$)lmnX0wLWYP4Dcc@TjLpA15TFR(y?h+x=YfRhBj zEQmf_!33;WCR#AE=k+_CL-4-901Jo@O$hikl$z9dy_%5`0oh)TKn4=}!H9qh zt!GUx42WeC2kqt1CodQY!E;0L{xYc~Tn^7^UUoh zMD{38S#S@NH7Yk{BwWtOL{Rt;?kMlU+QZJs%jslnB3GuQ=df8+%KQv3astnUPu)hq z0}23wVkw@Wb#6caEw3dYFzYE&XVwAAFapZq3&_C7K?Mqds|AGPrZ@vf>M6nqc?6+% zQwW0A5zuX1PGFci-*S)$|xsGWirc%a7b^MnT!!kHyG4vR{wCWkFKB|vtg0E_A=!B-X<9&ia> zm?r~;P0C<4QhJJ_QQ-!iQ9taI52XN7qJl}0Y8@ROQQE?wVi2)F(J2B5+fglyRf0ek zC6_3cSX4?%xDq)u>_p3n2Qsh$86r?pt79mVp|mba&*-&`R!@*dh8*E9@`AhK-+3#G z2TzN%JX;8$`76Sv$coB?rID-1Wr+}8N;n=~6b#@ZB?Le@j4+I_B12pe@OdD*dkn~R z&@TLd6!ff7r{|42!o(T1sDDNy0eDtRm^s=+lRR(WVWg@d^nmD=gFu2yJcvic6_RI| zEBx_rqf)}04S5HPpwb0I7-EP}2s1FWnW2mWglQgpiL6me>D)#|lN2CmUTYu#3wR`c z9W)!vv{7%?jZXSME|DU`CF&WHLgM&8mZ;a06sv~>3phy7W|k#bmNpSI)bl2T7VrjL zMCwC*`R_{{Df@vgrfHNr|DbNuG~ZKp#9_pv0(C!PLysWzMAHmC(gtLK@_mrMffe;2 zr@-;?NyfzQI9=m(jfsIVIghJroUSo3Fec}5b^XuiiXHwahCcKz8$_SH8-7we8+|TM zVwWwoVfU5)u8!Z-Bg+(j_KE<8sTU|)RH!+l92sL|htnSOdF-@VbRw4creaEz?S-;c z^eW$0SooD6@_0~?i*V(YzhGT_0&Ztp+4?++Va)ojE(%?)gPR z|N6yAf2e!r-Iw>Yk!@`zOqnR~jX zc~R$V;Rr0Pp literal 0 HcmV?d00001 diff --git a/applications/icons/icons.res.asm b/applications/icons/icons.res.asm new file mode 100644 index 0000000..74f9a3f --- /dev/null +++ b/applications/icons/icons.res.asm @@ -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" diff --git a/fox32os.def b/fox32os.def index 28828a0..6cd68da 100644 --- a/fox32os.def +++ b/fox32os.def @@ -52,6 +52,9 @@ get_size: jmp [0x00000D24] draw_widgets_to_window: jmp [0x00000E10] handle_widget_click: jmp [0x00000E14] +; resource jump table +get_resource: jmp [0x00000F10] + ; event types const EVENT_TYPE_BUTTON_CLICK: 0x80000000 diff --git a/kernel/main.asm b/kernel/main.asm index 7aa2dd0..927deea 100644 --- a/kernel/main.asm +++ b/kernel/main.asm @@ -77,6 +77,10 @@ jump_table: org.pad 0x00000610 data.32 draw_widgets_to_window data.32 handle_widget_click + + ; resource jump table + org.pad 0x00000710 + data.32 get_resource jump_table_end: ; initialization code @@ -374,6 +378,7 @@ get_os_api_version: #include "allocator.asm" #include "fxf/fxf.asm" + #include "res.asm" #include "task.asm" #include "vfs/vfs.asm" #include "widget/widget.asm" diff --git a/kernel/res.asm b/kernel/res.asm new file mode 100644 index 0000000..bc370e4 --- /dev/null +++ b/kernel/res.asm @@ -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"