Skip to content

Commit

Permalink
Merge branch 'master' into telnet
Browse files Browse the repository at this point in the history
  • Loading branch information
y4my4my4m authored Feb 9, 2025
2 parents b08af23 + e225704 commit af8e036
Show file tree
Hide file tree
Showing 21 changed files with 400 additions and 138 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Features in development include:
- [32-bit color VBE graphics](https://github.com/TempleProgramming/HolyGL)
- Fully-functional AHCI support
- Network card drivers and a networking stack
- UEFI booting via [BSD2-licensed Limine bootloader](https://github.com/limine-bootloader/limine) and [Public Domain ZealBooter prekernel](/zealbooter/zealbooter.c)
- UEFI booting via [BSD2-licensed Limine bootloader](https://github.com/limine-bootloader/limine) and [Public Domain ZealBooter prekernel](/zealbooter/src/zealbooter.c)

[Changes include](https://zeal-operating-system.github.io/Doc/ChangeLog.DD.html):
- 60 FPS
Expand Down
4 changes: 2 additions & 2 deletions build/build-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ umount_tempdisk
echo "Rebuilding kernel headers, kernel, OS, and building Distro ISO ..."
$QEMU_BIN_PATH/qemu-system-x86_64 -machine q35 $KVM -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -smp 4 -device isa-debug-exit $QEMU_HEADLESS

LIMINE_BINARY_BRANCH="v6.x-branch-binary"
LIMINE_BINARY_BRANCH="v8.x-binary"

if [ -d "limine" ]
then
Expand Down Expand Up @@ -110,7 +110,7 @@ sudo cp limine/limine-uefi-cd.bin $TMPISODIR/Boot/Limine-UEFI-CD.BIN
sudo cp limine/limine-bios-cd.bin $TMPISODIR/Boot/Limine-BIOS-CD.BIN
sudo cp limine/limine-bios.sys $TMPISODIR/Boot/Limine-BIOS.SYS
sudo cp ../zealbooter/bin/kernel $TMPISODIR/Boot/ZealBooter.ELF
sudo cp ../zealbooter/Limine.CFG $TMPISODIR/Boot/Limine.CFG
sudo cp ../zealbooter/limine.conf $TMPISODIR/Boot/Limine.CONF
echo "Copying DVDKernel.ZXE over ISO Boot/Kernel.ZXE ..."
sudo mv $TMPMOUNT/Tmp/DVDKernel.ZXE $TMPISODIR/Boot/Kernel.ZXE
sudo rm $TMPISODIR/Tmp/DVDKernel.ZXE 2> /dev/null
Expand Down
15 changes: 14 additions & 1 deletion build/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ DOCS_DIR=
TMPMOUNT=/tmp/zealtmp

print_usage() {
echo "Usage: $0 ( repo | vm ) [OPTION]"
echo "Usage: $0 ( repo | vm | diff ) [OPTION]"
echo " repo Overwrites src/ with virtual disk contents."
echo " vm Overwrites virtual disk with src/ contents."
echo " diff Runs a 'diff' between src/ and virtual disk."
echo "Options:"
echo " --ignore-dots Ignore dotfiles/dotfolders during synchronize."
}
Expand All @@ -73,6 +74,18 @@ else
sudo modprobe nbd
[ ! -d $TMPMOUNT ] && mkdir $TMPMOUNT
case $1 in
flush)
mount_vdisk
sudo blockdev --flushbufs /dev/nbd0
sudo dosfsck -w -r -l -v -t /dev/nbd0
umount_vdisk
;;
diff)
mount_vdisk
diff -x *.MAP --color=always -r ../src/ $TMPMOUNT/ | less -R -p "diff -x.*|Only in.*"
umount_vdisk
echo "Finished."
;;
repo)
echo "Emptying src..."
rm -rf ../src/*
Expand Down
2 changes: 1 addition & 1 deletion src/Demo/Graphics/32BitColor.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

I0 DrawPixel(I64 x, I64 y, CBGR24 color)
{
text.fb_alias[x + y * GR_WIDTH] = color;
text.fb_alias[x + y * sys_framebuffer_width] = color;
}

I0 Color32Demo()
Expand Down
10 changes: 5 additions & 5 deletions src/Demo/Graphics/32BitPaint.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ U0 PaintGlobalsInit()

I0 DrawImagePixel(I64 x, I64 y, CBGR24 color)
{
paint.fb[x + y * GR_WIDTH] = color;
paint.fb[x + y * sys_framebuffer_width] = color;
}

I0 DrawScreenPixel(I64 x, I64 y, CBGR24 color)
{
text.fb_alias[x + y * GR_WIDTH] = color;
text.fb_alias[x + y * sys_framebuffer_width] = color;
}

I0 DrawScreenChar(I64 x, I64 y, I64 char)
Expand Down Expand Up @@ -136,7 +136,7 @@ U0 PaintLoadImage()

U32 PaintImagePeek(I64 x, I64 y)
{
return paint.fb[x + y * GR_WIDTH];
return paint.fb[x + y * sys_framebuffer_width];
}

I0 Paint32()
Expand Down Expand Up @@ -176,7 +176,7 @@ I0 Paint32()
// draw the image where the brush was last covering it
for (i = paint.last_x; i < paint.last_x + paint.last_thick; i++)
for (j = paint.last_y; j < paint.last_y + paint.last_thick; j++)
DrawScreenPixel(i, j, paint.fb[i + j * GR_WIDTH]);
DrawScreenPixel(i, j, paint.fb[i + j * sys_framebuffer_width]);

// draw the brush on the screen
DrawScreenBrush(mouse.pos.x, mouse.pos.y, paint.color, paint.thick);
Expand All @@ -193,7 +193,7 @@ I0 Paint32()
// draw the image where the color strings where covering it
for (i = 0; i < 3 * FONT_HEIGHT; i++)
for (j = 0; j < 12 * FONT_WIDTH; j++)
DrawScreenPixel(j, i, paint.fb[j + i * GR_WIDTH]);
DrawScreenPixel(j, i, paint.fb[j + i * sys_framebuffer_width]);

// draw the color strings on screen
DrawScreenStr(0, 0 * FONT_HEIGHT, str_r);
Expand Down
219 changes: 219 additions & 0 deletions src/Demo/Graphics/Mandel.ZC
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
// Mandelbrot set explorer (multi-core).
//
// - Click-and drag to move around.
// - PGUP/PGDN to zoom
// - HOME/END to increase/decrease iterations
// - ESC to exit

I64 width = GR_WIDTH;
I64 height = GR_HEIGHT;
I64 iterations = 24;
F64 xCenter = -0.5, yCenter = 0.0;
F64 xExtent = 3.0;


I64 numCores = mp_count - 1;

// -------------------

CDC* image;
I64 rowsPerCore = height / numCores;
I64 currentSequence;


U0 MandelFrame(I64 core)
{
// CDC* dc = DCAlias(image);
I64 mySequence = currentSequence;

I64 startX = 0;
I64 maxX = startX + width;
I64 startY = core * rowsPerCore;
I64 maxY = startY + rowsPerCore;

F64 xmin = xCenter - (xExtent / 2.0);
F64 xmax = xmin + xExtent;
F64 aspect = ToF64(width) / ToF64(height);
F64 ymin = yCenter - (xExtent / aspect / 2.0);
F64 ymax = ymin + (xExtent / aspect);

F64 x, y, x0, y0, x2, y2;
F64 xscale = (xmax - xmin) / ToF64(width);
F64 yscale = (ymax - ymin) / ToF64(height);
I64 iteration;
I64 px, py;

for (py = startY; py < maxY; py++) {
y0 = ymin + ToF64(py) * yscale;
if (mySequence != currentSequence)
break;

for (px = startX; px < maxX; px++) {
x = 0.0; y = 0.0;
x2 = 0.0; y2 = 0.0;
iteration = 0;
x0 = xmin + ToF64(px) * xscale;

while ((x2 + y2) < 4.0) {
y = (2.0 *x * y) + y0;
x = x2 - y2 + x0;
x2 = x * x;
y2 = y * y;
if (++iteration > iterations) {
break;
}
}

/*
if (iteration >= iterations) {
dc->color = BLACK;
} else {
dc->color = iteration & 15;
}
GrPlot0(dc, px, py);
*/

// Instead of getting a DC handle
// every time, we can just poke
// into the body of the DC.
// (is that ok?)
if (iteration >= iterations)
image->body[py*width+px] = 15;
else
image->body[py*width+px] = iteration % 15;


}
}
// DCDel(dc);
}

U0 DrawIt(CTask *task, CDC *dc) {
image->flags |= DCF_NO_TRANSPARENTS;
GrBlot(dc, 0, 0, image);
}

U0 Mandel() {
SettingsPush;
AutoComplete;
WinBorder;
WinMax;

DocClear;
DCFill;

Fs->win_inhibit = WIG_TASK_DEFAULT-WIF_SELF_FOCUS-WIF_SELF_BORDER;

I64 msg_code, arg1, arg2;
I64 i, j, lastx, lasty;
F64 aspect;
Bool moving = FALSE;
Bool renderFrame = TRUE;


// Make our own palette, if we like.
CBGR48 bgr;
for (i=0; i<COLORS_NUM; i++) {
j = 0xFFFF * i / (COLORS_NUM-1);
bgr.b = j;
bgr.g = j;
bgr.r = j;
// GrPaletteColorSet(i,bgr);
}


image = DCNew(width, height);

Fs->draw_it = &DrawIt;

while(TRUE) {

if (renderFrame) {
renderFrame = FALSE;

currentSequence++;
for (i=0; i<numCores; i++) {
JobQueue(&MandelFrame, i, i+1);
}
}

msg_code = MessageGet(&arg1, &arg2,
1<<MESSAGE_KEY_DOWN + 1<<MESSAGE_MS_L_DOWN
+ 1<<MESSAGE_MS_L_UP + 1<<MESSAGE_MS_MOVE);

switch(msg_code) {
case MESSAGE_MS_MOVE:
if (moving) {
renderFrame = TRUE;
xCenter += (xExtent / ToF64(width) * ToF64(lastx - arg1));
aspect = ToF64(width) / ToF64(height);
yCenter += (xExtent / aspect / ToF64(height) * (lasty - arg2));
}
lastx = arg1;
lasty = arg2;
break;
case MESSAGE_MS_L_DOWN:
moving = TRUE;
break;
case MESSAGE_MS_L_UP:
moving = FALSE;
break;


case MESSAGE_KEY_DOWN:
switch(arg1) {
case 0:
U8 code = arg2.u8[0];
if (code == SC_PAGE_UP ||code == SC_PAGE_DOWN) {
F64 factor = 0.6666666;
if (code == SC_PAGE_DOWN) {
factor = 1.5;
}
aspect = ToF64(width) / ToF64(height);
F64 xmin = xCenter - (xExtent / 2.0);
F64 xmax = xmin + xExtent;
F64 xpos = xmin + (ToF64(lastx)*xExtent / ToF64(width));
F64 ymin = yCenter - (xExtent / aspect / 2.0);
F64 ymax = ymin + (xExtent / aspect);
F64 ypos = ymin + (ToF64(lasty) * xExtent / aspect / ToF64(height));

xmin = xpos - (xpos - xmin)*factor;
xmax = xpos + (xmax - xpos)*factor;
ymin = ypos - (ypos - ymin)*factor;
ymax = ypos = (ymax - ypos)*factor;

xExtent = xmax - xmin;
xCenter = xmin + xExtent/2.0;
yCenter = ymin + xExtent/aspect/2.0;
renderFrame = TRUE;
}
else if(code == SC_HOME) {
iterations++;
renderFrame = TRUE;
}
else if(code == SC_END) {
iterations--;
if (iterations < 2)
iterations = 2;
renderFrame = TRUE;
}
break;
case CH_ESC:
case CH_SHIFT_ESC:
goto m_done;
default:
break;
}
break;
default:
break;
}
}

m_done:
DCDel(image);
DCFill;
SettingsPop;
}

Mandel;
14 changes: 7 additions & 7 deletions src/Kernel/Display.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
}
if (ch == '\t')
{
RawPutChar(CH_SPACE);
while (text.raw_col & 3)
do
RawPutChar(CH_SPACE);
while (text.raw_col & 3);
}
else if (ch == CH_BACKSPACE)
{
Expand All @@ -60,17 +60,17 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
{//Scroll screen down

MemCopy(text.fb_alias,
text.fb_alias + sys_framebuffer_width * FONT_HEIGHT,
(text.screen_size - sys_framebuffer_width * FONT_HEIGHT) * sizeof(U32));
text.fb_alias + sys_framebuffer_pidth * FONT_HEIGHT,
(text.screen_size - sys_framebuffer_pidth * FONT_HEIGHT) * sizeof(U32));

MemSetU32(text.fb_alias + text.screen_size - sys_framebuffer_width * FONT_HEIGHT, BLACK32, sys_framebuffer_width * FONT_HEIGHT);
MemSetU32(text.fb_alias + text.screen_size - sys_framebuffer_pidth * FONT_HEIGHT, BLACK32, sys_framebuffer_pidth * FONT_HEIGHT);
text.raw_col -= text.cols ;
row = text.rows - 1;
}
x = col * FONT_WIDTH;
y = row * FONT_HEIGHT;
ch_bitmap = text.font[ch & 0xFF];
framebuffer = text.fb_alias + sys_framebuffer_width * y + x;
framebuffer = text.fb_alias + sys_framebuffer_pidth * y + x;

PUSHFD
CLI
Expand All @@ -81,7 +81,7 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
else
*framebuffer++ = BLACK32;
if (i & (FONT_WIDTH - 1) == FONT_WIDTH - 1)
framebuffer += sys_framebuffer_width - FONT_WIDTH;
framebuffer += sys_framebuffer_pidth - FONT_WIDTH;
ch_bitmap >>= 1;
}
POPFD
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/KGlobals.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ U8 *rev_bits_table; //Table with U8 bits reversed
CDate local_time_offset;
F64 *pow10_I64,
sys_os_version = 2.03;
U64 sys_os_version_sub = 117;
U64 sys_os_version_sub = 120;
U8 *sys_os_version_str;
U8 *sys_os_version_full;
U8 *sys_os_version_nice;
Expand Down
3 changes: 2 additions & 1 deletion src/Kernel/KMain.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ U0 SysGrInit()
text.cols = sys_framebuffer_width / FONT_WIDTH;
text.rows = sys_framebuffer_height / FONT_HEIGHT;

text.screen_size = sys_framebuffer_width * sys_framebuffer_height;
sys_framebuffer_pidth = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8);
text.screen_size = sys_framebuffer_pidth * sys_framebuffer_height;
text.buffer_size = text.screen_size * 4; //buffer for 32-bit, but only 16 colors now.
text.raw_screen = CAlloc(text.buffer_size);
text.fb_alias = sys_framebuffer_addr;
Expand Down
Loading

0 comments on commit af8e036

Please sign in to comment.