summaryrefslogtreecommitdiffhomepage
path: root/Public/Developer/SystemLib
diff options
context:
space:
mode:
Diffstat (limited to 'Public/Developer/SystemLib')
-rw-r--r--Public/Developer/SystemLib/AMD64/CoreAssembly.s10
-rw-r--r--Public/Developer/SystemLib/Headers/Defines.h2
-rw-r--r--Public/Developer/SystemLib/Headers/Dialog.h7
-rw-r--r--Public/Developer/SystemLib/Headers/Draw.h2
-rw-r--r--Public/Developer/SystemLib/Headers/File.h13
-rw-r--r--Public/Developer/SystemLib/Headers/Math.h11
-rw-r--r--Public/Developer/SystemLib/Headers/TrueType.h2
-rw-r--r--Public/Developer/SystemLib/Headers/Wm.h (renamed from Public/Developer/SystemLib/Headers/Window.h)61
-rw-r--r--Public/Developer/SystemLib/PowerPC/CoreAssembly.s5
-rw-r--r--Public/Developer/SystemLib/Sources/App.c (renamed from Public/Developer/SystemLib/Sources/Application.c)6
-rw-r--r--Public/Developer/SystemLib/Sources/File.c35
-rw-r--r--Public/Developer/SystemLib/Sources/Heap.c7
-rw-r--r--Public/Developer/SystemLib/Sources/Math.c7
-rw-r--r--Public/Developer/SystemLib/Sources/Wm.c (renamed from Public/Developer/SystemLib/Sources/Window.c)39
-rw-r--r--Public/Developer/SystemLib/compile_flags.txt2
15 files changed, 142 insertions, 67 deletions
diff --git a/Public/Developer/SystemLib/AMD64/CoreAssembly.s b/Public/Developer/SystemLib/AMD64/CoreAssembly.s
index 5c398e94..58fa3c28 100644
--- a/Public/Developer/SystemLib/AMD64/CoreAssembly.s
+++ b/Public/Developer/SystemLib/AMD64/CoreAssembly.s
@@ -6,23 +6,23 @@
------------------------------------------- */
-.section .text
+.text
-.globl RtGetApp
+.globl RtGetAppPointer
.globl RtAssertTriggerInterrupt
/* @brief Application getter */
/* @throws: ApptError: appartement error. */
-RtGetApp:
+RtGetAppPointer:
mov $0x10, %rcx /* sysGetProcessObject */
- int $0x21
+ int $0x32
/* rax gets saved and returned. */
ret
RtAssertTriggerInterrupt:
mov $0x11, %rcx /* sysTerminateCurrentProcess */
- int $0x21
+ int $0x32
ret
diff --git a/Public/Developer/SystemLib/Headers/Defines.h b/Public/Developer/SystemLib/Headers/Defines.h
index 7bd40c76..3be7552f 100644
--- a/Public/Developer/SystemLib/Headers/Defines.h
+++ b/Public/Developer/SystemLib/Headers/Defines.h
@@ -193,7 +193,7 @@ using StrType = CharacterTypeUTF8[N];
/// @brief Get app singleton.
/// @param
/// @return
-CA_EXTERN_C ApplicationRef RtGetApp(VoidType);
+CA_EXTERN_C ApplicationRef RtGetAppPointer(VoidType);
/// @brief Get argument count
/// @param
diff --git a/Public/Developer/SystemLib/Headers/Dialog.h b/Public/Developer/SystemLib/Headers/Dialog.h
index 872eae5d..800f56db 100644
--- a/Public/Developer/SystemLib/Headers/Dialog.h
+++ b/Public/Developer/SystemLib/Headers/Dialog.h
@@ -6,7 +6,7 @@
#pragma once
-#include <Headers/Window.h>
+#include <Headers/Wm.h>
struct _DialogPort;
struct _DialogPoint;
@@ -22,10 +22,11 @@ typedef struct _DialogPoint {
typedef struct _DialogPort {
WordType dlgPort;
WordType dlgKind;
- BooleanType dlgVisible;
- BooleanType dlgMoving;
+ BooleanType dlgVisible : 1;
+ BooleanType dlgMoving : 1;
DialogPoint dlgPosition;
WmDialogFn dlgProc;
+ struct _WmGFX* dlgGfx;
struct _WindowPort* parentPort;
} DialogPort;
diff --git a/Public/Developer/SystemLib/Headers/Draw.h b/Public/Developer/SystemLib/Headers/Draw.h
index 3060db9d..38f99e7d 100644
--- a/Public/Developer/SystemLib/Headers/Draw.h
+++ b/Public/Developer/SystemLib/Headers/Draw.h
@@ -6,7 +6,7 @@
#pragma once
-#include <Headers/Window.h>
+#include <Headers/Wm.h>
/*************************************************************
*
diff --git a/Public/Developer/SystemLib/Headers/File.h b/Public/Developer/SystemLib/Headers/File.h
index 5e58d104..234c33da 100644
--- a/Public/Developer/SystemLib/Headers/File.h
+++ b/Public/Developer/SystemLib/Headers/File.h
@@ -14,8 +14,8 @@ typedef QWordType FSRef;
/// @brief Opens a new file.
/// @param path where to find it.
-/// @param r the restrict (rw, rwe, r+, w+, r, w)
-/// @return
+/// @param rest the restrict (rw, rwe, r+, w+, r, w)
+/// @return FSRef the file.
CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r);
/// @brief Closes the file and flushes it to the said file.
@@ -23,13 +23,15 @@ CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeU
/// @return
CA_EXTERN_C VoidType FsCloseFile(FSRef refFs);
+#define kMaxForkNameLength 256 /* long fork names. */
+
/// @brief A fork information header.
typedef struct _Fork {
PtrVoidType forkData;
SizeType forkSize;
Int32Type forkFlags;
Int32Type forkKind;
- CharacterTypeUTF8 forkName[256];
+ CharacterTypeUTF8 forkName[kMaxForkNameLength];
} ForkType;
typedef ForkType* FSForkRef;
@@ -40,5 +42,10 @@ typedef ForkType* FSForkRef;
/// @return the fork data.
CA_EXTERN_C FSForkRef FsGetFork(FSRef refFs, const CharacterTypeUTF8* forkName);
+/// @brief Check if the filesystem path is valid.
+/// @return if not return false, or true.
+CA_EXTERN_C BooleanType FsIsValidPath(const CharacterTypeUTF8* path);
+
+/// @note not only limited to, there is code forks, icon forks...
#define FsGetDataFork(refFs) FsGetFork(refFs, "data")
#define FsGetRsrcFork(refFs) FsGetFork(refFs, "rsrc")
diff --git a/Public/Developer/SystemLib/Headers/Math.h b/Public/Developer/SystemLib/Headers/Math.h
new file mode 100644
index 00000000..f6c8f216
--- /dev/null
+++ b/Public/Developer/SystemLib/Headers/Math.h
@@ -0,0 +1,11 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#include <Headers/Defines.h>
+
+CA_EXTERN_C SizeType MathRand(VoidType);
diff --git a/Public/Developer/SystemLib/Headers/TrueType.h b/Public/Developer/SystemLib/Headers/TrueType.h
index 7f1bed86..6387e58f 100644
--- a/Public/Developer/SystemLib/Headers/TrueType.h
+++ b/Public/Developer/SystemLib/Headers/TrueType.h
@@ -6,7 +6,7 @@
#pragma once
-#include <Headers/Window.h>
+#include <Headers/Wm.h>
/*************************************************************
*
diff --git a/Public/Developer/SystemLib/Headers/Window.h b/Public/Developer/SystemLib/Headers/Wm.h
index ca0b942e..66ed96a3 100644
--- a/Public/Developer/SystemLib/Headers/Window.h
+++ b/Public/Developer/SystemLib/Headers/Wm.h
@@ -10,7 +10,7 @@
/*************************************************************
*
- * File: Window.h
+ * File: Wm.h
* Purpose: Window Manager API for NewOS.
* Date: 3/26/24
*
@@ -24,7 +24,13 @@ struct _WindowPort;
struct _ControlPort;
struct _WmPoint;
-typedef QWordType DCRef;
+/// @brief Window Graphics type.
+typedef struct _WmGFX {
+ UInt32Type Depth;
+ UInt32Type* DataFrame;
+ SizeType DataFrameWidth;
+ SizeType DataFrameHeight;
+} WmGFX, *WmGFXRef;
/// @brief Window procedure type.
typedef VoidType(*WmWindowFn)(struct _WindowPort* port, UInt32Type msg, UIntPtrType pParam, UIntPtrType iParam);
@@ -34,20 +40,21 @@ typedef struct _WmPoint {
PositionType X, Y;
} WmPoint;
+
/// @brief Window port type, can be used to control the window.
typedef struct _WindowPort {
WordType windowPort;
WordType windowKind;
- BooleanType windowVisible;
- BooleanType windowMaximized;
- BooleanType windowMinimized;
- BooleanType windowMoving;
- BooleanType windowDisableClose;
- BooleanType windowDisableMinimize;
+ BooleanType windowVisible : 1;
+ BooleanType windowMaximized : 1;
+ BooleanType windowMinimized : 1;
+ BooleanType windowMoving : 1;
+ BooleanType windowDisableClose : 1;
+ BooleanType windowDisableMinimize : 1;
+ BooleanType windowInvalidate : 1;
WmPoint windowPosition;
WmPoint windowSize;
- BooleanType windowInvalidate;
- DWordType windowClearColor;
+ WmGFXRef windowGfx;
WmWindowFn windowProc;
struct _WindowPort* windowMenuPort; ///! Attached menu to it.
struct _WindowPort* windowParentPort;
@@ -57,10 +64,11 @@ typedef struct _WindowPort {
typedef struct _ControlPort {
WordType controlPort;
WordType controlKind;
- BooleanType controlVisible;
- BooleanType controlMoving;
+ BooleanType controlVisible : 1;
+ BooleanType controlMoving : 1;
WmPoint controlPosition;
WmWindowFn controlProc;
+ WmGFXRef controlGfx;
WindowPort* parentPort;
} ControlPort;
@@ -107,37 +115,37 @@ CA_EXTERN_C const ColorRef kRgbWhite;
CA_EXTERN_C ControlPort* WmCreateControl(DWordType id);
/// @brief Releases the control
-/// @param id the control ref.
+/// @param ctrlPort the control ref.
/// @return
-CA_EXTERN_C VoidType WmReleaseControl(ControlPort* id);
+CA_EXTERN_C VoidType WmReleaseControl(ControlPort* ctrlPort);
/// @brief Moves a control inside a ControlPort.
-/// @param id the control ref.
+/// @param ctrlPort the control ref.
/// @param where where to move at.
/// @return
-CA_EXTERN_C Int32Type WmSetControlPosition(ControlPort* id, WmPoint where);
+CA_EXTERN_C Int32Type WmSetControlPosition(ControlPort* ctrlPort, WmPoint where);
/// @brief Enable control.
-/// @param id
+/// @param ctrlPort
/// @param enabled
/// @return
-CA_EXTERN_C Int32Type WmSetControlEnabled(ControlPort* id, BooleanType enabled);
+CA_EXTERN_C Int32Type WmSetControlEnabled(ControlPort* ctrlPort, BooleanType enabled);
/// @brief Make control visible.
-/// @param id
+/// @param ctrlPort
/// @param visible
/// @return
-CA_EXTERN_C Int32Type WmSetControlVisible(ControlPort* id, BooleanType visible);
+CA_EXTERN_C Int32Type WmSetControlVisible(ControlPort* ctrlPort, BooleanType visible);
/// @brief Creates a new window.
/// @param name the window name
-/// @param rsrcId the window fork rsrc id.
+/// @param rsrcId the window fork rsrc ctrlPort.
/// @return the window graphics port.
CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name, const DWordType rsrcId);
/// @brief Creates a new menu
/// @param name the menu's name
-/// @param rsrcId the menu fork rsrc id.
+/// @param rsrcId the menu fork rsrc ctrlPort.
/// @return the menu graphics port.
CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name, const DWordType rsrcId);
@@ -151,14 +159,17 @@ CA_EXTERN_C VoidType WmReleaseWindow(WindowPort* port);
/// @return void
CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* port);
-/// @brief Moves a window on the desktop. (menu arent movable, will return kErrIncompatible is menu is provided.)
-/// @param id the gfx port.
+/// @brief Moves a window on the desktop. (menu arent movable, will return kErrIncompatible if menu is provided.)
+/// @param wndPort the gfx port.
/// @param where to move.
/// @return error code.
-CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where);
+CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* wndPort, WmPoint where);
/// @brief Get the NewOS about window.
/// @return The window port of it.
/// @note The reason that this is not a window is for it to run without blocking the UI.
CA_EXTERN_C WindowPort* WmGetOSDlg(void);
+/// @brief Draws a blur effect on the window.
+/// @param wndPort the window port.
+CA_EXTERN_C VoidType WmBlur(WindowPort* wndPort); \ No newline at end of file
diff --git a/Public/Developer/SystemLib/PowerPC/CoreAssembly.s b/Public/Developer/SystemLib/PowerPC/CoreAssembly.s
index 98fbcca9..7078774e 100644
--- a/Public/Developer/SystemLib/PowerPC/CoreAssembly.s
+++ b/Public/Developer/SystemLib/PowerPC/CoreAssembly.s
@@ -2,14 +2,13 @@
;
; Copyright Mahrouss Logic
;
-; Purpose: PowerPC low level I/O
+; Purpose: PowerPC Core assembly routines.
;
; ------------------------------------------- */
-
/* @brief Application getter */
/* @throws: ApptError: appartement error. */
-export .code64 RtGetApp:
+export .code64 RtGetAppPointer:
stw 0x10, 0(r3) /* sysGetProcessObject */
sc
diff --git a/Public/Developer/SystemLib/Sources/Application.c b/Public/Developer/SystemLib/Sources/App.c
index 69f178af..9d390795 100644
--- a/Public/Developer/SystemLib/Sources/Application.c
+++ b/Public/Developer/SystemLib/Sources/App.c
@@ -6,13 +6,15 @@
#include <Headers/Defines.h>
-/// @brief Main Application object, retrieved from the RtGetApp symbol.
+/// @brief Main Application object, retrieved from the RtGetAppPointer symbol.
ApplicationRef kSharedApplication = NullPtr;
/// @brief Gets the app arguments count.
/// @param void no arguments.
/// @return
CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) {
+ CA_MUST_PASS(kSharedApplication);
+
return kSharedApplication->Invoke(kSharedApplication, kCallGetArgsCount);
}
@@ -20,6 +22,8 @@ CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) {
/// @param void no arguments.
/// @return
CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType) {
+ CA_MUST_PASS(kSharedApplication);
+
return (CharacterTypeUTF8**)kSharedApplication->Invoke(kSharedApplication,
kCallGetArgsPtr);
}
diff --git a/Public/Developer/SystemLib/Sources/File.c b/Public/Developer/SystemLib/Sources/File.c
index ca23d9f7..39a4aff0 100644
--- a/Public/Developer/SystemLib/Sources/File.c
+++ b/Public/Developer/SystemLib/Sources/File.c
@@ -8,31 +8,32 @@
#include <Headers/File.h>
enum FileOp {
- kFlushFile,
- kReadFork,
- kWriteFork,
- kOpenFork,
- kCloseFork,
+ kFlushFile,
+ kReadFork,
+ kWriteFork,
+ kOpenFork,
+ kCloseFork,
};
/// @brief Opens a new file.
/// @param path where to find it.
-/// @param r the restrict (rw, rwe, r+, w+, r, w)
-/// @return
-CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, const CharacterTypeUTF8* r) {
- CA_MUST_PASS(kSharedApplication);
- CA_MUST_PASS(path);
- CA_MUST_PASS(r);
-
- return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path, r);
+/// @param rest the restrict (rw, rwe, r+, w+, r, w)
+/// @return FSRef the file.
+CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path,
+ const CharacterTypeUTF8* rest) {
+ CA_MUST_PASS(kSharedApplication);
+ CA_MUST_PASS(path && FsIsValidPath(path) == Yes);
+ CA_MUST_PASS(rest);
+
+ return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path, rest);
}
/// @brief Closes the file and flushes it to the said file.
/// @param refFs the filesystem reference.
-/// @return
+/// @return
CA_EXTERN_C VoidType FsCloseFile(FSRef refFs) {
- CA_MUST_PASS(kSharedApplication);
+ CA_MUST_PASS(kSharedApplication);
- kSharedApplication->Invoke(kSharedApplication, refFs, kFlushFile);
- kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refFs);
+ kSharedApplication->Invoke(kSharedApplication, refFs, kFlushFile);
+ kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refFs);
}
diff --git a/Public/Developer/SystemLib/Sources/Heap.c b/Public/Developer/SystemLib/Sources/Heap.c
index 041c5764..3db7a374 100644
--- a/Public/Developer/SystemLib/Sources/Heap.c
+++ b/Public/Developer/SystemLib/Sources/Heap.c
@@ -12,6 +12,7 @@
/// @param flags flags.
/// @return
CA_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, DWordType flags) {
+ CA_MUST_PASS(kSharedApplication);
CA_MUST_PASS(sz);
CA_MUST_PASS(flags);
@@ -22,7 +23,9 @@ CA_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, DWordType flags) {
/// @brief Free pointer from the user's heap.
/// @param ptr the pointer to free.
CA_EXTERN_C VoidType RtTlsFree(PtrVoidType ptr) {
+ CA_MUST_PASS(kSharedApplication);
CA_MUST_PASS(ptr);
+
CA_UNREFERENCED_PARAMETER(
kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr));
}
@@ -31,6 +34,8 @@ CA_EXTERN_C VoidType RtTlsFree(PtrVoidType ptr) {
/// @param ptr the pointer to find.
/// @return the size.
CA_EXTERN_C QWordType RtTlsGetSize(PtrVoidType ptr) {
+ CA_MUST_PASS(kSharedApplication);
+
CA_MUST_PASS(ptr);
return kSharedApplication->Invoke(kSharedApplication, kCallSizePtr, ptr);
}
@@ -39,6 +44,8 @@ CA_EXTERN_C QWordType RtTlsGetSize(PtrVoidType ptr) {
/// @param ptr the pointer to check.
/// @return if it exists
CA_EXTERN_C BooleanType RtTlsPtrExists(PtrVoidType ptr) {
+ CA_MUST_PASS(kSharedApplication);
+
CA_MUST_PASS(ptr);
return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr);
}
diff --git a/Public/Developer/SystemLib/Sources/Math.c b/Public/Developer/SystemLib/Sources/Math.c
new file mode 100644
index 00000000..20919711
--- /dev/null
+++ b/Public/Developer/SystemLib/Sources/Math.c
@@ -0,0 +1,7 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <Headers/Math.h>
diff --git a/Public/Developer/SystemLib/Sources/Window.c b/Public/Developer/SystemLib/Sources/Wm.c
index 196ac537..79eda22a 100644
--- a/Public/Developer/SystemLib/Sources/Window.c
+++ b/Public/Developer/SystemLib/Sources/Wm.c
@@ -4,7 +4,8 @@
------------------------------------------- */
-#include <Headers/Window.h>
+#include <Headers/Wm.h>
+#include <Headers/Math.h>
/// invalid resource handle, they always start from 1.
#define kInvalidRsrc (0U)
@@ -65,12 +66,38 @@ CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* winPort) {
/////////////////////////////////////////////////////////////////////////
-CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where) {
- if (!id) return kWmErrInvalidArg;
+CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* wndPort, WmPoint where) {
+ if (!wndPort) return kWmErrInvalidArg;
- id->windowPosition.X = where.X;
- id->windowPosition.Y = where.Y;
- id->windowMoving = True;
+ wndPort->windowPosition.X = where.X;
+ wndPort->windowPosition.Y = where.Y;
+ wndPort->windowMoving = True;
return 0;
}
+
+/// @brief Draws a blur effect on the window.
+/// @param wndPort the window port.
+CA_EXTERN_C VoidType WmBlur(WindowPort* wndPort) {
+ if (wndPort != NullPtr) {
+ WmGFXRef refGfx = wndPort->windowGfx;
+
+ UInt32Type lookupTbl[4] = {0.21336, 0.41336, 0.61336, 0.81336};
+
+ for (SizeType width = 0; width < refGfx->DataFrameWidth; ++width) {
+ for (SizeType height = 0; height < refGfx->DataFrameHeight; ++height) {
+ refGfx->DataFrame[width * height] =
+ refGfx->DataFrame[width * height] * lookupTbl[MathRand() % 4];
+ }
+ }
+ }
+}
+
+/// @brief Causes the window to invalidate and redraw.
+/// @param wndPort The Window port.
+/// @return nothing.
+CA_EXTERN_C VoidType WmInvalidateGfx(WindowPort* wndPort) {
+ if (wndPort) {
+ wndPort->windowInvalidate = Yes;
+ }
+} \ No newline at end of file
diff --git a/Public/Developer/SystemLib/compile_flags.txt b/Public/Developer/SystemLib/compile_flags.txt
index 6e721e73..3be985d1 100644
--- a/Public/Developer/SystemLib/compile_flags.txt
+++ b/Public/Developer/SystemLib/compile_flags.txt
@@ -1,4 +1,4 @@
-I./
-I../
-I../../../Private
--std=c++20
+-std=c17