summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-26 21:01:10 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-26 21:01:10 +0200
commitd5b7989351bc16e6acb436e54298dedba1551223 (patch)
tree39ca6b7804804d44d839aebc54ebc61fe8d26e2b /dev
parent60cc51ae3bc8de2276a7c7a5f3e7117dc0473c98 (diff)
[IMP] New Loading console when loading kernel and it's drivers.
[IMP] Concept of parents and children inside a CG window. Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev')
-rw-r--r--dev/ZGM/.keep0
-rw-r--r--dev/ZGM/build.json21
-rw-r--r--dev/ZKA/KernelKit/User.hxx2
-rw-r--r--dev/ZKA/Modules/CoreCG/FbRenderer.hxx124
-rw-r--r--dev/ZKA/Modules/CoreCG/WindowRenderer.hxx79
-rw-r--r--dev/ZKA/Sources/DLLMain.cxx14
6 files changed, 179 insertions, 61 deletions
diff --git a/dev/ZGM/.keep b/dev/ZGM/.keep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/dev/ZGM/.keep
diff --git a/dev/ZGM/build.json b/dev/ZGM/build.json
new file mode 100644
index 00000000..cd8fbe63
--- /dev/null
+++ b/dev/ZGM/build.json
@@ -0,0 +1,21 @@
+{
+ "compiler_path": "x86_64-w64-mingw32-g++",
+ "compiler_std": "c++20",
+ "headers_path": ["../"],
+ "sources_path": ["Sources/*.cxx"],
+ "output_name": "sgm.sys",
+ "compiler_flags": [
+ "-fPIC",
+ "-ffreestanding",
+ "-shared",
+ "-fno-rtti",
+ "-fno-exceptions",
+ "-Wl,--subsystem=17"
+ ],
+ "cpp_macros": [
+ "__SGM_IMPL__",
+ "cSGMVersion=0x0100",
+ "cSGMVersionHighest=0x0100",
+ "cSGMVersionLowest=0x0100"
+ ]
+}
diff --git a/dev/ZKA/KernelKit/User.hxx b/dev/ZKA/KernelKit/User.hxx
index d8f81fd7..39d9f5ba 100644
--- a/dev/ZKA/KernelKit/User.hxx
+++ b/dev/ZKA/KernelKit/User.hxx
@@ -13,7 +13,7 @@
#include <NewKit/Defines.hxx>
// user mode users.
-#define kSuperUser "ZKA USER\\SYSTEM"
+#define kSuperUser "ZKA USER\\SUPER"
#define kGuestUser "ZKA USER\\GUEST"
#define kUsersFile "\\Users\\$UsrRcrd"
diff --git a/dev/ZKA/Modules/CoreCG/FbRenderer.hxx b/dev/ZKA/Modules/CoreCG/FbRenderer.hxx
index e53d4a90..08bf9f6a 100644
--- a/dev/ZKA/Modules/CoreCG/FbRenderer.hxx
+++ b/dev/ZKA/Modules/CoreCG/FbRenderer.hxx
@@ -17,72 +17,134 @@
#define CGFini() __GXCursor = 0
/// @brief Performs OR drawing on the framebuffer.
-#define CGDrawBitMapInRegionA(ImgPtr, _Height, _Width, BaseX, BaseY) \
- __GXCursor = 0; \
+#define CGDrawBitMapInRegionA(_BitMp, _Height, _Width, _BaseX, _BaseY) \
+ __GXCursor = 0; \
+ \
+ for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \
+ { \
+ for (Kernel::SizeT u = _BaseY; u < (_Width + _BaseY); ++u) \
+ { \
+ *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \
+ 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
+ i + \
+ 4 * u))) |= (_BitMp)[__GXCursor]; \
+ \
+ ++__GXCursor; \
+ } \
+ }
+
+/// @brief Draws a resource.
+#define CGDrawBitMapInRegion(_BitMp, _Height, _Width, _BaseX, _BaseY) \
+ __GXCursor = 0; \
+ \
+ for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \
+ { \
+ for (Kernel::SizeT u = _BaseY; u < (_Width + _BaseY); ++u) \
+ { \
+ *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \
+ 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
+ i + \
+ 4 * u))) = (_BitMp)[__GXCursor]; \
+ \
+ ++__GXCursor; \
+ } \
+ }
+
+#define CGDrawBitMapInRegionToRgn(_Rgn, _BitMp, _Height, _Width, _BaseX, _BaseY) \
+ __GXCursor = 0; \
+ \
+ for (Kernel::SizeT i = _BaseX; i < (_Height + _BaseX); ++i) \
+ { \
+ for (Kernel::SizeT u = _BaseY; u < (_Width + _BaseY); ++u) \
+ { \
+ *(((Kernel::UInt32*)(_Rgn + \
+ 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
+ i + \
+ 4 * u))) = (_BitMp)[__GXCursor]; \
+ \
+ ++__GXCursor; \
+ } \
+ }
+
+/// @brief Cleans a resource.
+#define CGClearRegion(_Height, _Width, _BaseX, _BaseY) \
\
- for (Kernel::SizeT i = BaseX; i < (_Height + BaseX); ++i) \
+ for (Kernel::SizeT i = _BaseX; i < _Height + _BaseX; ++i) \
{ \
- for (Kernel::SizeT u = BaseY; u < (_Width + BaseY); ++u) \
+ for (Kernel::SizeT u = _BaseY; u < _Width + _BaseY; ++u) \
{ \
- *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \
+ *(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \
4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
i + \
- 4 * u))) |= (ImgPtr)[__GXCursor]; \
+ 4 * u))) = cCGClearClr; \
+ } \
+ }
+
+/// @brief Draws inside a zone.
+#define CGDrawInRegion(_Clr, _Height, _Width, _BaseX, _BaseY) \
\
- ++__GXCursor; \
+ for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \
+ { \
+ for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \
+ { \
+ *(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \
+ 4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
+ x_base + \
+ 4 * y_base))) = _Clr; \
} \
}
-/// @brief Draws a resource.
-#define CGDrawBitMapInRegion(ImgPtr, _Height, _Width, BaseX, BaseY) \
+/// @brief Draws inside a zone.
+#define CGDrawInRegionToRgn(_Rgn, _Clr, _Height, _Width, _BaseX, _BaseY) \
__GXCursor = 0; \
\
- for (Kernel::SizeT i = BaseX; i < (_Height + BaseX); ++i) \
+ for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \
{ \
- for (Kernel::SizeT u = BaseY; u < (_Width + BaseY); ++u) \
+ for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \
{ \
- *(((Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \
+ *(((volatile Kernel::UInt32*)(_Rgn + \
4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
- i + \
- 4 * u))) = (ImgPtr)[__GXCursor]; \
- \
+ x_base + \
+ 4 * y_base))) = _Clr[__GXCursor]; \
++__GXCursor; \
} \
}
-/// @brief Cleans a resource.
-#define CGClearRegion(_Height, _Width, BaseX, BaseY) \
+#define CGDrawInRegionToVideoRgn(_VideoRgn, _Clr, _Height, _Width, _BaseX, _BaseY) \
+ __GXCursor = 0; \
\
- for (Kernel::SizeT i = BaseX; i < _Height + BaseX; ++i) \
+ for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \
{ \
- for (Kernel::SizeT u = BaseY; u < _Width + BaseY; ++u) \
+ for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \
{ \
- *(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \
+ *(((volatile Kernel::UInt32*)(_VideoRgn + \
4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
- i + \
- 4 * u))) = cCGClearClr; \
+ x_base + \
+ 4 * y_base))) = _Clr; \
+ ++__GXCursor; \
} \
}
-/// @brief Draws inside a zone.
-#define CGDrawInRegion(_Clr, _Height, _Width, BaseX, BaseY) \
+#define CGDrawInRegionToVideoRgnA(_VideoRgn, _Clr, _Height, _Width, _BaseX, _BaseY) \
+ __GXCursor = 0; \
\
- for (Kernel::SizeT x_base = BaseX; x_base < (_Width + BaseX); ++x_base) \
+ for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \
{ \
- for (Kernel::SizeT y_base = BaseY; y_base < (_Height + BaseY); ++y_base) \
+ for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \
{ \
- *(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \
+ *(((volatile Kernel::UInt32*)(_VideoRgn + \
4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
x_base + \
- 4 * y_base))) = _Clr; \
+ 4 * y_base))) |= _Clr; \
+ ++__GXCursor; \
} \
}
-#define CGDrawInRegionA(_Clr, _Height, _Width, BaseX, BaseY) \
+#define CGDrawInRegionA(_Clr, _Height, _Width, _BaseX, _BaseY) \
\
- for (Kernel::SizeT x_base = BaseX; x_base < (_Width + BaseX); ++x_base) \
+ for (Kernel::SizeT x_base = _BaseX; x_base < (_Width + _BaseX); ++x_base) \
{ \
- for (Kernel::SizeT y_base = BaseY; y_base < (_Height + BaseY); ++y_base) \
+ for (Kernel::SizeT y_base = _BaseY; y_base < (_Height + _BaseY); ++y_base) \
{ \
*(((volatile Kernel::UInt32*)(kHandoverHeader->f_GOP.f_The + \
4 * kHandoverHeader->f_GOP.f_PixelPerLine * \
diff --git a/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx b/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx
index 79208c47..b377d7d0 100644
--- a/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx
+++ b/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx
@@ -34,21 +34,24 @@ namespace CG
struct UI_WINDOW_STRUCT final
{
- Char w_window_name[255]{0};
- Char w_class_name[255]{0};
- Int32 w_type{0};
- Int32 w_sub_type{0};
- Int32 w_x{0};
- Int32 w_y{0};
- Int32 w_w{0};
- Int32 w_h{0};
- UInt32* display_ptr{nullptr};
- Bool w_needs_repaint{false};
+ Char w_window_name[255]{0};
+ Char w_class_name[255]{0};
+ Int32 w_type{0};
+ Int32 w_sub_type{0};
+ Int32 w_x{0};
+ Int32 w_y{0};
+ Int32 w_w{0};
+ Int32 w_h{0};
+ Size w_child_count{0};
+ struct UI_WINDOW_STRUCT* w_child_elements[255]{0};
+ struct UI_WINDOW_STRUCT* w_parent{nullptr};
+ UInt32* display_ptr{nullptr};
+ Bool w_needs_repaint{false};
};
typedef struct UI_WINDOW_STRUCT UI_WINDOW_STRUCT;
- inline struct UI_WINDOW_STRUCT* CGCreateWindow(Int32 kind, const Char* window_name, const Char* class_name, Int32 x, Int32 y, Int32 width, Int32 height)
+ inline struct UI_WINDOW_STRUCT* CGCreateWindow(Int32 kind, const Char* window_name, const Char* class_name, Int32 x, Int32 y, Int32 width, Int32 height, UI_WINDOW_STRUCT* parent = nullptr)
{
UI_WINDOW_STRUCT* wnd = new UI_WINDOW_STRUCT();
@@ -61,6 +64,14 @@ namespace CG
rt_copy_memory((VoidPtr)window_name, wnd->w_window_name, rt_string_len(window_name));
rt_copy_memory((VoidPtr)class_name, wnd->w_class_name, rt_string_len(class_name));
+ if (parent)
+ {
+ wnd->w_parent = parent;
+
+ ++wnd->w_parent->w_child_count;
+ wnd->w_parent->w_child_elements[wnd->w_parent->w_child_count - 1] = wnd;
+ }
+
wnd->w_sub_type = 0;
wnd->w_type = kind;
wnd->w_x = x;
@@ -93,6 +104,18 @@ namespace CG
return false;
}
+ inline Kernel::Void CGDrawStringToWnd(UI_WINDOW_STRUCT* wnd, const Kernel::Char* text, Kernel::Int32 y_dst, Kernel::Int32 x_dst, Kernel::Int32 color)
+ {
+ for (Kernel::SizeT i = 0; text[i] != 0; ++i)
+ {
+ if (x_dst > wnd->w_w)
+ break;
+
+ CGRenderStringFromBitMap(&cFontBitmap[text[i]][0], FONT_SIZE_X, FONT_SIZE_Y, y_dst, x_dst, color);
+ x_dst += FONT_SIZE_Y;
+ }
+ }
+
inline SizeT CGDrawWindowList(UI_WINDOW_STRUCT** wnd, SizeT wnd_cnt)
{
if (wnd_cnt == 0 ||
@@ -108,6 +131,8 @@ namespace CG
!wnd[index]->w_needs_repaint)
continue;
+ CGInit();
+
wnd[index]->w_needs_repaint = false;
if (UIAccessibilty::The().Width() < wnd[index]->w_x)
@@ -136,8 +161,6 @@ namespace CG
++cnt;
- CGInit();
-
// Draw fake controls, just for the looks of it (WINDOW ONLY)
if (wnd[index]->w_type == cWndFlagWindow)
{
@@ -165,21 +188,41 @@ namespace CG
auto x_center = wnd[index]->w_x + 6;
auto y_center = wnd[index]->w_y + 7;
- CGDrawInRegion(CGColor(0xD3, 0x74, 0x00), wnd[index]->w_w + 1 - rt_string_len(wnd[index]->w_window_name), wnd[index]->w_h + 1 - rt_string_len(wnd[index]->w_window_name), wnd[index]->w_y, wnd[index]->w_x);
- CGDrawInRegion(CGColor(0xFF, 0xFF, 0xFF), wnd[index]->w_w - 1 - rt_string_len(wnd[index]->w_window_name), wnd[index]->w_h - 1 - rt_string_len(wnd[index]->w_window_name), wnd[index]->w_y + 1, wnd[index]->w_x + 1);
- CGDrawString(wnd[index]->w_window_name, y_center, x_center, CGColor(0x00, 0x00, 0x00));
+ CGDrawInRegion(CGColor(0xD3, 0x74, 0x00), wnd[index]->w_w + 1, wnd[index]->w_h + 1, wnd[index]->w_y, wnd[index]->w_x);
+ CGDrawInRegion(CGColor(0xFF, 0xFF, 0xFF), wnd[index]->w_w - 1, wnd[index]->w_h - 1, wnd[index]->w_y + 1, wnd[index]->w_x + 1);
+ CGDrawStringToWnd(wnd[index], wnd[index]->w_window_name, y_center, x_center, CGColor(0x00, 0x00, 0x00));
}
else if (wnd[index]->w_type == cWndFlagButton)
{
auto x_center = wnd[index]->w_x + 6;
auto y_center = wnd[index]->w_y + 7;
- CGDrawInRegion(CGColor(0xDC, 0xDC, 0xDC), wnd[index]->w_w + 1 - rt_string_len(wnd[index]->w_window_name), wnd[index]->w_h + 1 - rt_string_len(wnd[index]->w_window_name), wnd[index]->w_y, wnd[index]->w_x);
- CGDrawInRegion(CGColor(0xFF, 0xFF, 0xFF), wnd[index]->w_w - 1 - rt_string_len(wnd[index]->w_window_name), wnd[index]->w_h - 1 - rt_string_len(wnd[index]->w_window_name), wnd[index]->w_y + 1, wnd[index]->w_x + 1);
+ CGDrawInRegion(CGColor(0xDC, 0xDC, 0xDC), wnd[index]->w_w + 1, wnd[index]->w_h + 1, wnd[index]->w_y, wnd[index]->w_x);
+ CGDrawInRegion(CGColor(0xFF, 0xFF, 0xFF), wnd[index]->w_w - 1, wnd[index]->w_h - 1, wnd[index]->w_y + 1, wnd[index]->w_x + 1);
CGDrawString(wnd[index]->w_window_name, y_center, x_center, CGColor(0x00, 0x00, 0x00));
}
CGFini();
+
+ // draw child windows and controls.
+ // doesn't have to be a window, enabling then windows in windows.
+
+ for (SizeT child = 0; child < wnd[index]->w_child_count; ++child)
+ {
+ if (wnd[index]->w_child_elements[child]->w_x < wnd[index]->w_x + FLATCONTROLS_WIDTH)
+ wnd[index]->w_child_elements[child]->w_x += wnd[index]->w_x + FLATCONTROLS_WIDTH;
+
+ if (wnd[index]->w_child_elements[child]->w_y < (wnd[index]->w_y + FLATCONTROLS_HEIGHT))
+ wnd[index]->w_child_elements[child]->w_y += wnd[index]->w_y + FLATCONTROLS_HEIGHT;
+
+ if ((wnd[index]->w_child_elements[child]->w_w + wnd[index]->w_child_elements[child]->w_x) > (wnd[index]->w_x + wnd[index]->w_w) ||
+ (wnd[index]->w_child_elements[child]->w_h + wnd[index]->w_child_elements[child]->w_y) > (wnd[index]->w_y + wnd[index]->w_h))
+ continue;
+
+ CGDrawWindowList(&wnd[index]->w_child_elements[child], 1);
+ }
+
+ CGFini();
}
return cnt;
diff --git a/dev/ZKA/Sources/DLLMain.cxx b/dev/ZKA/Sources/DLLMain.cxx
index bfa206a5..54254f73 100644
--- a/dev/ZKA/Sources/DLLMain.cxx
+++ b/dev/ZKA/Sources/DLLMain.cxx
@@ -194,7 +194,7 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
CGFini();
- auto root_zka_wnd = CG::CGCreateWindow(CG::cWndFlagWindow, "ZKA Setup", "Window", 0, 0, 512, 256);
+ auto root_zka_wnd = CG::CGCreateWindow(CG::cWndFlagWindow, "ZKA Operating System", "Window", 20, 20, CG::UIAccessibilty::The().Height() - 20, CG::UIAccessibilty::The().Width() - 20);
root_zka_wnd->w_sub_type = CG::cWndFlagCloseControlSelect;
root_zka_wnd->w_x = 10;
@@ -202,19 +202,11 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
root_zka_wnd->w_needs_repaint = Yes;
+ CG::CGDrawWindowList(&root_zka_wnd, 1);
+
/// Now run kernel loop, until no process are running.
Kernel::Detail::FilesystemInstaller(); // automatic filesystem creation.
- auto root_install_wnd = CG::CGCreateWindow(CG::cWndFlagButtonSelect, "Install Now.", "Button", 0, 0, 128, 32);
-
- root_install_wnd->w_x = 512 - 128;
- root_install_wnd->w_y = 256 - 32;
-
- root_install_wnd->w_needs_repaint = Yes;
-
- CG::CGDrawWindowList(&root_zka_wnd, 1);
- CG::CGDrawWindowList(&root_install_wnd, 1);
-
/// @note BThread doesn't parse the symbols so doesn't nullify them, .bss is though.
Kernel::cProcessScheduler = nullptr;