From a033fae4aeb3468ef93213ba36c6608bfc198fe8 Mon Sep 17 00:00:00 2001 From: Ry Date: Thu, 12 Oct 2023 16:20:12 -0700 Subject: [PATCH] Fetcher: Use the global icons.res resource for the desktop icons --- applications/fetcher/Browser.okm | 12 +++++++++++- applications/fetcher/Desktop.okm | 17 +++++++++++++---- applications/fetcher/Fetcher.okm | 24 +++++++++++++++++++++--- applications/fetcher/OS.okm | 4 +++- applications/fetcher/icons/.gitignore | 1 - applications/fetcher/icons/disk.png | Bin 4464 -> 0 bytes applications/fetcher/start.asm | 3 --- 7 files changed, 48 insertions(+), 13 deletions(-) delete mode 100644 applications/fetcher/icons/.gitignore delete mode 100644 applications/fetcher/icons/disk.png diff --git a/applications/fetcher/Browser.okm b/applications/fetcher/Browser.okm index d22bbca..4d76cba 100644 --- a/applications/fetcher/Browser.okm +++ b/applications/fetcher/Browser.okm @@ -14,7 +14,8 @@ MODULE Browser; EXTERN browserMenuItemsRoot: POINTER TO CHAR; EXTERN browserFileListFriendly: ARRAY 12 OF POINTER TO CHAR; - PROCEDURE BrowserMain(diskId, iconX, iconY: INT; desktopWin: PTR;); + PROCEDURE BrowserMain(diskId, iconX, iconY: INT; desktopWin: PTR; hasIcons: CHAR; iconsResPtr: PTR;); + VAR tempDskIconResPtr: PTR; BEGIN (* first, before we do anything, check to make sure the selected disk is available *) IF diskId >| 4 THEN @@ -36,6 +37,15 @@ MODULE Browser; browserPage := 0; browserDiskId := diskId; + (* if icons.res was loaded, then pull the `dsk` resource from it *) + IF hasIcons THEN + tempDskIconResPtr := get_resource(iconsResPtr, "dsk", 4096); + IF tempDskIconResPtr THEN + copy_memory_bytes(tempDskIconResPtr, PTROF(desktopDiskIcon), 4096); + free_memory(tempDskIconResPtr); + END; + END; + (* create the window and draw its initial contents *) new_window(PTROF(browserWindow), "Fetcher", 384, 192, 64, 64, PTROF(browserMenuItemsRoot), PTROF(browserIcons)); DrawBrowserWindow(); diff --git a/applications/fetcher/Desktop.okm b/applications/fetcher/Desktop.okm index 50fc832..08dca45 100644 --- a/applications/fetcher/Desktop.okm +++ b/applications/fetcher/Desktop.okm @@ -4,13 +4,22 @@ MODULE Desktop; VAR desktopRunning: CHAR; desktopWindow: ARRAY WINDOW_STRUCT_SIZE OF CHAR; desktopIcons: ARRAY 5 OF Fox32OSButtonWidget; + desktopDiskIcon: ARRAY 4096 OF CHAR; - EXTERN diskIcon: ARRAY 1024 OF INT; - - PROCEDURE DesktopMain(); + PROCEDURE DesktopMain(hasIcons: CHAR; iconsResPtr: PTR;); + VAR tempDskIconResPtr: PTR; BEGIN desktopRunning := 1; + (* if icons.res was loaded, then pull the `dsk` resource from it *) + IF hasIcons THEN + tempDskIconResPtr := get_resource(iconsResPtr, "dsk", 4096); + IF tempDskIconResPtr THEN + copy_memory_bytes(tempDskIconResPtr, PTROF(desktopDiskIcon), 4096); + free_memory(tempDskIconResPtr); + END; + END; + (* set up the desktop icon widgets *) SetupDesktopIconStructs(); @@ -72,7 +81,7 @@ MODULE Desktop; draw_widgets_to_window(desktopWin); (* set the tilemap and draw the icons! *) - set_tilemap(PTROF(diskIcon), 32, 32); + set_tilemap(PTROF(desktopDiskIcon), 32, 32); overlay := get_window_overlay_number(desktopWin); i := 5; y := 16; diff --git a/applications/fetcher/Fetcher.okm b/applications/fetcher/Fetcher.okm index a1b1d3a..fdbf884 100644 --- a/applications/fetcher/Fetcher.okm +++ b/applications/fetcher/Fetcher.okm @@ -7,17 +7,35 @@ MODULE Fetcher; EXTERN arg2Ptr: POINTER TO CHAR; EXTERN arg3Ptr: POINTER TO CHAR; + VAR iconsResFile: ARRAY FILE_STRUCT_SIZE OF CHAR; + iconsRes: POINTER TO CHAR; + iconsResSize: INT; + hasIcons: CHAR; + PROCEDURE Main(); BEGIN + (* open icons.res from the boot disk and read its contents into `iconsRes` *) + hasIcons := 0; + IF open("icons.res", get_boot_disk_id(), PTROF(iconsResFile)) THEN + iconsResSize := get_size(PTROF(iconsResFile)); + iconsRes := allocate_memory(iconsResSize); + read(iconsResSize, PTROF(iconsResFile), iconsRes); + hasIcons := 1; + END; + IF (terminalStreamPtr = 0) & (arg0Ptr = 0) THEN (* probably launched from startup.cfg *) - DesktopMain(); + DesktopMain(hasIcons, iconsRes); ELSIF arg0Ptr <|= 5 THEN (* launched from an existing instance of fetcher *) - BrowserMain(arg0Ptr, arg1Ptr, arg2Ptr, arg3Ptr); + BrowserMain(arg0Ptr, arg1Ptr, arg2Ptr, arg3Ptr, hasIcons, iconsRes); ELSE (* probably launched from the terminal *) - BrowserMain(string_to_int(arg0Ptr, 10), 0, 0, 0); + BrowserMain(string_to_int(arg0Ptr, 10), 0, 0, 0, hasIcons, iconsRes); + END; + + IF hasIcons THEN + free_memory(iconsRes); END; END; END. diff --git a/applications/fetcher/OS.okm b/applications/fetcher/OS.okm index 63b9b9c..0539818 100644 --- a/applications/fetcher/OS.okm +++ b/applications/fetcher/OS.okm @@ -2,13 +2,15 @@ MODULE OS; CONST WINDOW_STRUCT_SIZE = 36; + CONST FILE_STRUCT_SIZE = 32; EXTERN PROCEDURE new_window, destroy_window, draw_str_to_overlay, get_window_overlay_number, draw_widgets_to_window, draw_filled_rectangle_to_overlay, GetNextWindowEvent, DrawPixel, save_state_and_yield_task, start_dragging_window, handle_widget_click, fill_window, fill_overlay, set_window_flags, menu_update_event, menu_bar_click_event, close_menu, new_messagebox, launch_fxf_from_disk, get_boot_disk_id, string_to_int, set_tilemap, draw_tile_to_overlay, - ryfs_get_file_list, copy_memory_bytes, IsRomDiskAvailable, end_current_task, sleep_task: INT; + ryfs_get_file_list, copy_memory_bytes, IsRomDiskAvailable, end_current_task, sleep_task, + open, read, get_size, get_boot_disk_id, get_resource, allocate_memory, free_memory: INT; EXTERN PROCEDURE brk: INT; diff --git a/applications/fetcher/icons/.gitignore b/applications/fetcher/icons/.gitignore deleted file mode 100644 index 2a06e93..0000000 --- a/applications/fetcher/icons/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.inc diff --git a/applications/fetcher/icons/disk.png b/applications/fetcher/icons/disk.png deleted file mode 100644 index 7c3bee062cab340f8ded323282ff53567b308922..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4464 zcmeHLdsGuw8V^1IkyZ+#D2PL_isEE4dCwdoAc+t)$jc1{ZJA_l!Wi-(8At>l;A<_4 zSaz+}TD2lrE444X>+>kP3hWljanZKx+RCnV=_<-%wOYlxcM@Kn_M9Hh+5SgzGBfwP zzwdXy?{~j@&z-!QmYV!rz|;U9kN2D=MU?^X2>0_J1+Tqfw`<_-PDxfan?bn{yTfK= z3IM{cv;zdV86%J9zEYW)~ck)*!#Yvy>FFib}!tqVqAP<-lnK& z-QBuJWM%BE<@J-Wjd?e3UfrHG^$*4SG^e^7FV25*uKjXe!n&B6dw*AyMYpAwF01bR zk;tEUA}aUJ0(1HMOIB5uFIzhyz_+@o^;lDR*o=s+?4?}coR@F+99vy;=yK`du${GZ zrW=T2x1AOpPHcNJumkIB_bfUXHFedbO<($t-B{sj zZv3JnHqoa=DOkb2`a|ZMxi#@!@ofvIM_w!bqkC)p$2^|TdL}6;O_P+=pE=BT&+6Bd zDSu9gxbRA5EkD$6e1(F3C-w70b%Z&zA}#7tzIp} zbbh+Tpk7{KQDFxATJY1I6LZeH?N_T@4w6V%>ox>6 zA~TWZ7SX?F%pQBKr>KheO1D1l)2CPW)hubv4fNl9zR+Ly!nFOFLqkX!ny@<+K8pnx9)DNZ<^DIewI_) znDgKpEU@$b4sf(RA~ASN_PQ}I1gwau85NG_6lKgk$i)Bi`t;%_!6zm+2koQ2T~oNHDjhjCUUF;OcdNS;ts%(6z-9ljto_8NWli{hm*An(lCTM@LXt zY{vH|+fJ2|rH>yhK5};Ys#M3j$cp$7<$___Jv)HxT0eY*mPX(w4=BDfzE)ZfC3pUil$*PMXNnb!e>*36T>lw=c zPFs<~0My06%0>^RpbZ25_991tCmq^=fdXKGP$wJ}e`d&JjW%t-gOk9-SnM7zDE2c* zmN5>B^-OGBk0+g>fk5{G-e=JLxqHA6rPY!uo1uscPoq-ux$#NbW?*R2^JtV)G=)i5aDtPGX&NP8BoGc-(h4Zn2pyFC#f-JcJ=l@O zSU@IAacbf+1tAhjrf>+}Ml;5h zzl7!%4-)5{@)X7i$6x6&c~?{>DD<|x%>u@=ln}(TC`iiSO~FYO1Fyo6%iCqhr>rIb zcaOeu?YA>OQwmbOTr8#KVpL&}i{Sjp<**d=B9t&l6cQm#%V^-uYJlBoGqNtq0TNA6 zN2nDnPmfkejAx=|do&wByYc}y3s5kq5c*TWu)c&bZqMk?I1c-XCUG9XkWB{qd2Mj> zf_ou0uo?Dg1|#@2KYerYYYu@RBZCY}-x0Y+~*N9xhQear%k?Q)t$rUj8 zIt8ro6y$<0OQ8A1!|+ARSHCD(#e2$q_n$fRJ7^haPkG77;|Zd8H*(95VJC*Z1hebdmE{4rVxWl5Z{Q1cc^r=Rbn3dAh`no1~ z0}`kXxwF<(QZBO~A)0rK%5z?P`hzqC{xfm!>!`;Gs)tK=>h1&;FAv{xY1Z{EbM(Fc zXz2ZYAo9&Q|Lvhyj?Y(pbdv8lBK*^_%CgFL#%~=Tr0Wa|_iN}{e(nCe8~Em&*rkV_ zufMQpQNrit>8sD&_;F0-f%EgvR2`UmE_Pbb=^PMpH^HrlnlPq)A$qs&Zzt97*O}C< zH<9KKzF$Au_Y2+bt5sd&ZrsWjY}%idLoELj;?&{*3(a}em9!xN`$84C~ SRw;sM@igjG)zSHR>;4BIIa-te diff --git a/applications/fetcher/start.asm b/applications/fetcher/start.asm index 1b61059..c4fc1e7 100644 --- a/applications/fetcher/start.asm +++ b/applications/fetcher/start.asm @@ -82,8 +82,5 @@ menu_items_system_list: data.8 7 ; menu width (usually longest item + 2) data.8 5 data.strz "About" ; text length, text, null-terminator -diskIcon: - #include "icons/disk.inc" - #include "../../../fox32rom/fox32rom.def" #include "../../fox32os.def"