Fetcher: Minor code style fixes

This commit is contained in:
Ry 2023-07-12 16:41:39 -07:00
parent 924ada984a
commit 20e25f963e
4 changed files with 37 additions and 33 deletions

View File

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

View File

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

View File

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

View File

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