diff options
Diffstat (limited to 'Public/Developer')
| -rw-r--r-- | Public/Developer/FragLib/Sources/RuntimeFrag.c (renamed from Public/Developer/SystemLib/Sources/ApplicationStart.c) | 12 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/AMD64/CoreAssembly.s | 10 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Headers/Defines.h | 6 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Headers/Dialog.h | 26 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Headers/Draw.h | 20 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Headers/TrueType.h | 10 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Headers/Window.h | 31 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/PowerPC/CoreAssembly.s | 25 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Sources/Application.c | 4 | ||||
| -rw-r--r-- | Public/Developer/SystemLib/Sources/Window.c | 28 |
10 files changed, 116 insertions, 56 deletions
diff --git a/Public/Developer/SystemLib/Sources/ApplicationStart.c b/Public/Developer/FragLib/Sources/RuntimeFrag.c index 0960388e..f9e7c442 100644 --- a/Public/Developer/SystemLib/Sources/ApplicationStart.c +++ b/Public/Developer/FragLib/Sources/RuntimeFrag.c @@ -6,9 +6,17 @@ #include <Headers/Defines.h> -/// @brief Inits the system library. -/// @return if it was succesful or not. +/// @brief Main application entrypoint. +/// @param +/// @return +CA_EXTERN_C VoidType AppMain(VoidType); + +/// @brief Pre-entrypoint intiialization. +/// @param +/// @return CA_EXTERN_C VoidType __start(VoidType) { kSharedApplication = RtGetApp(); CA_MUST_PASS(kSharedApplication); + + AppMain(); } diff --git a/Public/Developer/SystemLib/AMD64/CoreAssembly.s b/Public/Developer/SystemLib/AMD64/CoreAssembly.s index 1d361621..5c398e94 100644 --- a/Public/Developer/SystemLib/AMD64/CoreAssembly.s +++ b/Public/Developer/SystemLib/AMD64/CoreAssembly.s @@ -1,6 +1,10 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + Purpose: AMD64 low level I/O + +------------------------------------------- */ .section .text diff --git a/Public/Developer/SystemLib/Headers/Defines.h b/Public/Developer/SystemLib/Headers/Defines.h index d3b6b793..7bd40c76 100644 --- a/Public/Developer/SystemLib/Headers/Defines.h +++ b/Public/Developer/SystemLib/Headers/Defines.h @@ -51,6 +51,12 @@ typedef CharacterTypeUTF8* PtrCharacterType; typedef void* PtrVoidType; typedef void VoidType; +#ifdef __SINGLE_PRECISION__ +typedef float PositionType; +#else +typedef double PositionType; +#endif + typedef __UINTPTR_TYPE__ UIntPtrType; typedef __INTPTR_TYPE__ IntPtrType; typedef __UINT64_TYPE__ UInt64Type; diff --git a/Public/Developer/SystemLib/Headers/Dialog.h b/Public/Developer/SystemLib/Headers/Dialog.h index b2bc93a1..0c0e4dbc 100644 --- a/Public/Developer/SystemLib/Headers/Dialog.h +++ b/Public/Developer/SystemLib/Headers/Dialog.h @@ -8,6 +8,32 @@ #include <Headers/Window.h> +struct _DialogPort; +struct _DialogPoint; + +/// @brief Dialog procedure type. +typedef VoidType(*WmDialogProc)(struct _DialogPort* port, UInt32Type msg, UIntPtrType pParam, UIntPtrType iParam); + +/// @brief A point, can represent the size, position of a window. +typedef struct _DialogPoint { + PositionType X, Y; +} DialogPoint; + +typedef struct _DialogPort { + WordType dlgPort; + WordType dlgKind; + BooleanType dlgVisible; + BooleanType dlgMoving; + DialogPoint dlgPosition; + WmDialogProc dlgProc; + struct _WindowPort* parentPort; +} DialogPort; + +/// @brief Creates a new dialog from a rsrc fork id. +/// @param rsrcId the resource id. +/// @return the dialog port. +CA_EXTERN_C DialogPort* DlgCreateFromRsrc(QWordType rsrcId); + /// @brief Shows an message box according to format. /// @param title the message box title /// @param format the format diff --git a/Public/Developer/SystemLib/Headers/Draw.h b/Public/Developer/SystemLib/Headers/Draw.h new file mode 100644 index 00000000..3060db9d --- /dev/null +++ b/Public/Developer/SystemLib/Headers/Draw.h @@ -0,0 +1,20 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include <Headers/Window.h> + +/************************************************************* + * + * File: Draw.h + * Purpose: Draw Manager API for NewOS. + * Date: 3/26/24 + * + * Copyright Mahrouss Logic, all rights reserved. + * + *************************************************************/ + diff --git a/Public/Developer/SystemLib/Headers/TrueType.h b/Public/Developer/SystemLib/Headers/TrueType.h index fb68298a..7f1bed86 100644 --- a/Public/Developer/SystemLib/Headers/TrueType.h +++ b/Public/Developer/SystemLib/Headers/TrueType.h @@ -10,7 +10,7 @@ /************************************************************* * - * File: TrueType.hxx + * File: TrueType.h * Purpose: TrueType font implementation for NewOS. * Date: 3/26/24 * @@ -35,10 +35,4 @@ CA_EXTERN_C VoidType FnDisposeFont(TTFFontRef fon); /// @return CA_EXTERN_C PtrVoidType FnGetGlyph(TTFFontRef fon, UInt32Type utfCh); -/// @brief Write a character to the window. -/// @param fon the font. -/// @param port the window port. -/// @param pos the position of where to put the character. -/// @return -CA_EXTERN_C VoidType FnWriteCharacter(TTFFontRef fon, WindowPort* port, PositionType pos); - +/// TODO: Get font metadata.
\ No newline at end of file diff --git a/Public/Developer/SystemLib/Headers/Window.h b/Public/Developer/SystemLib/Headers/Window.h index 1fd9e9e3..58b10d8e 100644 --- a/Public/Developer/SystemLib/Headers/Window.h +++ b/Public/Developer/SystemLib/Headers/Window.h @@ -10,7 +10,7 @@ /************************************************************* * - * File: Window.hxx + * File: Window.h * Purpose: Window Manager API for NewOS. * Date: 3/26/24 * @@ -21,18 +21,14 @@ struct _WmPoint; struct _WindowPort; -#ifdef __SINGLE_PRECISION__ -typedef float PositionType; -#else -typedef double PositionType; -#endif - struct _ControlPort; struct _WmPoint; -struct _WindowPort; typedef QWordType DCRef; +/// @brief Window procedure type. +typedef VoidType(*WmWindowProc)(struct _WindowPort* port, UInt32Type msg, UIntPtrType pParam, UIntPtrType iParam); + /// @brief A point, can represent the size, position of a window. typedef struct _WmPoint { PositionType X, Y; @@ -52,6 +48,7 @@ typedef struct _WindowPort { WmPoint windowSize; BooleanType windowInvalidate; DWordType windowClearColor; + WmWindowProc windowProc; struct _WindowPort* windowMenuPort; ///! Attached menu to it. struct _WindowPort* windowParentPort; } WindowPort; @@ -63,9 +60,17 @@ typedef struct _ControlPort { BooleanType controlVisible; BooleanType controlMoving; WmPoint controlPosition; + WmWindowProc controlProc; WindowPort* parentPort; } ControlPort; +enum { + kWmErrIncompatible = 0x74, + kWmErrOutOfMemory, + kWmErrInvalidArg, + kWmErrNotImplemented, +}; + /// @brief Color reference. typedef UInt32Type ColorRef; @@ -94,6 +99,7 @@ CA_EXTERN_C const ColorRef kRgbWhite; #define kControlKindIcon 6 #define kControlKindRadioBox 7 #define kControlKindCheckBox 8 +#define kControlKindUserDefined 9 /// @brief Creates a new control /// @param id the control rsrc fork. @@ -121,7 +127,7 @@ CA_EXTERN_C Int32Type WmSetControlEnabled(ControlPort* id, BooleanType enabl /// @param id /// @param visible /// @return -CA_EXTERN_C Int32Type WmMakeControlVisible(ControlPort* id, BooleanType visible); +CA_EXTERN_C Int32Type WmSetControlVisible(ControlPort* id, BooleanType visible); /// @brief Creates a new window. /// @param name the window name @@ -164,10 +170,3 @@ CA_EXTERN_C VoidType WmTranslateMessage(WindowPort* port, Int64Type msg); /// @param id /// @return CA_EXTERN_C Int32Type WmDispatchMessage(WindowPort* id); - -enum { - kWmErrIncompatible = 0x74, - kWmErrOutOfMemory, - kWmErrInvalidArg, - kWmErrNotImplemented, -}; diff --git a/Public/Developer/SystemLib/PowerPC/CoreAssembly.s b/Public/Developer/SystemLib/PowerPC/CoreAssembly.s index 7fef98e3..98fbcca9 100644 --- a/Public/Developer/SystemLib/PowerPC/CoreAssembly.s +++ b/Public/Developer/SystemLib/PowerPC/CoreAssembly.s @@ -1,25 +1,22 @@ -/** =========================================== - (C) Mahrouss Logic - Purpose: PowerPC low-level routines. - ===========================================*/ +; /* ------------------------------------------- +; +; Copyright Mahrouss Logic +; +; Purpose: PowerPC low level I/O +; +; ------------------------------------------- */ -.section .text - -.globl RtGetApp -.globl RtAssertTriggerInterrupt -.balign 4 /* @brief Application getter */ /* @throws: ApptError: appartement error. */ -RtGetApp: - stw 0x10, 0(3) /* sysGetProcessObject */ +export .code64 RtGetApp: + stw 0x10, 0(r3) /* sysGetProcessObject */ sc blr -RtAssertTriggerInterrupt: - stw 0x11, 0(3) /* sysTerminateCurrentProcess */ - stw 0x3, 0(4) +export .code64 RtAssertTriggerInterrupt: + stw 0x11, 0(r3) /* sysTerminateCurrentProcess */ sc blr diff --git a/Public/Developer/SystemLib/Sources/Application.c b/Public/Developer/SystemLib/Sources/Application.c index f1391975..69f178af 100644 --- a/Public/Developer/SystemLib/Sources/Application.c +++ b/Public/Developer/SystemLib/Sources/Application.c @@ -21,5 +21,5 @@ CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) { /// @return CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType) { return (CharacterTypeUTF8**)kSharedApplication->Invoke(kSharedApplication, - kCallGetArgsPtr); -}
\ No newline at end of file + kCallGetArgsPtr); +} diff --git a/Public/Developer/SystemLib/Sources/Window.c b/Public/Developer/SystemLib/Sources/Window.c index 2527e041..196ac537 100644 --- a/Public/Developer/SystemLib/Sources/Window.c +++ b/Public/Developer/SystemLib/Sources/Window.c @@ -9,6 +9,14 @@ /// invalid resource handle, they always start from 1. #define kInvalidRsrc (0U) +/// @brief Color refs. + +const ColorRef kRgbRed = 0x000000FF; +const ColorRef kRgbGreen = 0x0000FF00; +const ColorRef kRgbBlue = 0x00FF0000; +const ColorRef kRgbBlack = 0x00000000; +const ColorRef kRgbWhite = 0xFFFFFFFF; + ///////////////////////////////////////////////////////////////////////// CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name, @@ -16,6 +24,9 @@ CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name, CA_MUST_PASS(name); CA_MUST_PASS(rsrcId != kInvalidRsrc); + if (!name) return NullPtr; + if (rsrcId == kInvalidRsrc) return NullPtr; + return (WindowPort*)kSharedApplication->Invoke( kSharedApplication, kCallCreateWindow, name, rsrcId); } @@ -24,6 +35,7 @@ CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name, CA_EXTERN_C VoidType WmReleaseWindow(WindowPort* winPort) { CA_MUST_PASS(winPort); + if (!winPort) return; kSharedApplication->Invoke(kSharedApplication, kCallCloseWindow, winPort); } @@ -35,6 +47,9 @@ CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name, CA_MUST_PASS(name); CA_MUST_PASS(rsrcId != kInvalidRsrc); + if (!name) return NullPtr; + if (rsrcId == kInvalidRsrc) return NullPtr; + return (WindowPort*)kSharedApplication->Invoke(kSharedApplication, kCallCreateMenu, name, rsrcId); } @@ -44,15 +59,14 @@ CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name, CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* winPort) { CA_MUST_PASS(winPort); + if (!winPort) return; kSharedApplication->Invoke(kSharedApplication, kCallCloseMenu, winPort); } ///////////////////////////////////////////////////////////////////////// CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where) { - if (!id) { - return kWmErrInvalidArg; - } + if (!id) return kWmErrInvalidArg; id->windowPosition.X = where.X; id->windowPosition.Y = where.Y; @@ -60,11 +74,3 @@ CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where) { return 0; } - -/// @brief Color refs. - -const ColorRef kRgbRed = 0x000000FF; -const ColorRef kRgbGreen = 0x0000FF00; -const ColorRef kRgbBlue = 0x00FF0000; -const ColorRef kRgbBlack = 0x00000000; -const ColorRef kRgbWhite = 0xFFFFFFFF; |
