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 7c3bee0..0000000 Binary files a/applications/fetcher/icons/disk.png and /dev/null differ 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"