Fetcher: Use the global icons.res resource for the desktop icons

This commit is contained in:
Ry 2023-10-12 16:20:12 -07:00
parent 19f5996855
commit a033fae4ae
7 changed files with 48 additions and 13 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -1 +0,0 @@
*.inc

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -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"