From 20e25f963ebde38515aedffd01b2cc7817c87827 Mon Sep 17 00:00:00 2001 From: Ry Date: Wed, 12 Jul 2023 16:41:39 -0700 Subject: [PATCH] Fetcher: Minor code style fixes --- applications/fetcher/Browser.okm | 12 +++++------ applications/fetcher/Desktop.okm | 35 ++++++++++---------------------- applications/fetcher/Fetcher.okm | 4 ++-- applications/fetcher/OS.okm | 19 ++++++++++++++++- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/applications/fetcher/Browser.okm b/applications/fetcher/Browser.okm index acb82f9..3eebe9b 100644 --- a/applications/fetcher/Browser.okm +++ b/applications/fetcher/Browser.okm @@ -1,5 +1,5 @@ MODULE Browser; - IMPORT OS, Desktop; + IMPORT OS; VAR browserRunning: CHAR; browserWindow: ARRAY 36 OF CHAR; @@ -24,16 +24,16 @@ MODULE Browser; destroy_window(PTROF(browserWindow)); browserRunning := 0; IF desktopWin # 0 THEN - (* Draw the retracting box animation *) + (* draw the retracting box animation *) i := 0; WHILE i < 16 DO - x := RSH(GETSHORT(PTROF(browserWindow) + 20) *| (16 - i) + iconX *| i,4); - y := RSH(GETSHORT(PTROF(browserWindow) + 22) *| (16 - i) + iconY *| i,4); + x := RSH(GETSHORT(PTROF(browserWindow) + 20) *| (16 - i) + iconX *| i, 4); + y := RSH(GETSHORT(PTROF(browserWindow) + 22) *| (16 - i) + iconY *| i, 4); w := RSH(384 *| (16 - i) + 32 *| i,4); h := RSH(192 *| (16 - i) + 32 *| i,4); - DrawWireframeBox(get_window_overlay_number(desktopWin),x,y,w,h,20F0F0F0H); + DrawWireframeBox(get_window_overlay_number(desktopWin), x, y, w, h, 020F0F0F0H); Eep(5); - draw_filled_rectangle_to_overlay(x,y,w,h,0,get_window_overlay_number(desktopWin)); + draw_filled_rectangle_to_overlay(x, y, w, h, 0, get_window_overlay_number(desktopWin)); i := i + 1; END; draw_widgets_to_window(desktopWin); diff --git a/applications/fetcher/Desktop.okm b/applications/fetcher/Desktop.okm index 2aeeab8..6822eca 100644 --- a/applications/fetcher/Desktop.okm +++ b/applications/fetcher/Desktop.okm @@ -34,41 +34,28 @@ MODULE Desktop; END; END; - PROCEDURE Eep(ms: INT;); (* the furry version of sleep :3 *) - VAR deadline: INT; - BEGIN - deadline := ms + PortIn(80000706H); - WHILE PortIn(80000706H) <| deadline DO - save_state_and_yield_task(); - END; - END; - - PROCEDURE DrawWireframeBox(overlay, x, y, w, h, color: INT;); - BEGIN - draw_filled_rectangle_to_overlay(x,y,w,1,color,overlay); - draw_filled_rectangle_to_overlay(x,y,1,h,color,overlay); - draw_filled_rectangle_to_overlay(x+w-1,y,1,h,color,overlay); - draw_filled_rectangle_to_overlay(x,y+h-1,w,1,color,overlay); - END; - PROCEDURE HandleDesktopIconClick(buttonId: INT;); VAR i, x, y, w, h: INT; icon: POINTER TO Fox32OSButtonWidget; BEGIN - (* Draw the expanding box animation *) + (* draw the expanding box animation *) i := 0; icon := PTROF(desktopIcons[buttonId]); WHILE i < 16 DO - x := RSH(icon^.x *| (16 - i) + 64 *| i,4); - y := RSH(icon^.y *| (16 - i) + 64 *| i,4); - w := RSH(32 *| (16 - i) + 384 *| i,4); - h := RSH(32 *| (16 - i) + 192 *| i,4); - DrawWireframeBox(get_window_overlay_number(PTROF(desktopWindow)),x,y,w,h,20F0F0F0H); + x := RSH(icon^.x *| (16 - i) + 64 *| i, 4); + y := RSH(icon^.y *| (16 - i) + 64 *| i, 4); + w := RSH(32 *| (16 - i) + 384 *| i, 4); + h := RSH(32 *| (16 - i) + 192 *| i, 4); + DrawWireframeBox(get_window_overlay_number(PTROF(desktopWindow)), x, y, w, h, 020F0F0F0H); Eep(5); - draw_filled_rectangle_to_overlay(x,y,w,h,0,get_window_overlay_number(PTROF(desktopWindow))); + draw_filled_rectangle_to_overlay(x, y, w, h, 0, get_window_overlay_number(PTROF(desktopWindow))); i := i + 1; END; + + (* redraw the icons *) draw_widgets_to_window(PTROF(desktopWindow)); + + (* launch a new instance of Fetcher *) IF launch_fxf_from_disk("fetcher.fxf", get_boot_disk_id(), 0FFFFFFFFH, buttonId, icon^.x, icon^.y, PTROF(desktopWindow)) = 0FFFFFFFFH THEN new_messagebox("Failed to start new", "instance of fetcher.fxf", 0, 64, 64, 200); END; diff --git a/applications/fetcher/Fetcher.okm b/applications/fetcher/Fetcher.okm index 6af62ec..a1b1d3a 100644 --- a/applications/fetcher/Fetcher.okm +++ b/applications/fetcher/Fetcher.okm @@ -14,10 +14,10 @@ MODULE Fetcher; DesktopMain(); ELSIF arg0Ptr <|= 5 THEN (* launched from an existing instance of fetcher *) - BrowserMain(arg0Ptr,arg1Ptr,arg2Ptr,arg3Ptr); + BrowserMain(arg0Ptr, arg1Ptr, arg2Ptr, arg3Ptr); ELSE (* probably launched from the terminal *) - BrowserMain(string_to_int(arg0Ptr, 10),0,0,0); + BrowserMain(string_to_int(arg0Ptr, 10), 0, 0, 0); END; END; END. diff --git a/applications/fetcher/OS.okm b/applications/fetcher/OS.okm index 3178ef8..ff1f05e 100644 --- a/applications/fetcher/OS.okm +++ b/applications/fetcher/OS.okm @@ -6,7 +6,7 @@ MODULE OS; launch_fxf_from_disk, get_boot_disk_id, string_to_int: INT; EXTERN PROCEDURE brk: INT; - + EXTERN PROCEDURE PortIn: INT; EXTERN EVENT_TYPE_MOUSE_CLICK, @@ -24,4 +24,21 @@ MODULE OS; next, id, type, text, fgColor, bgColor: INT; width, height, x, y: SHORT; END; + + PROCEDURE Eep(ms: INT;); (* the furry version of sleep :3 *) + VAR deadline: INT; + BEGIN + deadline := ms + PortIn(80000706H); + WHILE PortIn(80000706H) <| deadline DO + save_state_and_yield_task(); + END; + END; + + PROCEDURE DrawWireframeBox(overlay, x, y, w, h, color: INT;); + BEGIN + draw_filled_rectangle_to_overlay(x, y, w, 1, color, overlay); + draw_filled_rectangle_to_overlay(x, y, 1, h, color, overlay); + draw_filled_rectangle_to_overlay(x + w - 1, y, 1, h, color, overlay); + draw_filled_rectangle_to_overlay(x, y + h - 1, w, 1, color, overlay); + END; END.