Merge branch 'master' into network-loopback

This commit is contained in:
チャールズ 2023-04-29 18:39:40 +09:00 committed by GitHub
commit deafd49030
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 515 additions and 163 deletions

10
.gitignore vendored
View file

@ -2,17 +2,17 @@
*.bin
*.ZXE
*.MAP
src/Boot/
/src/Boot
*.ELF
*.elf
*.sys
*.SYS
src/EFI/
build/limine
build/ovmf
/src/EFI
/build/limine
/build/ovmf
*.iso
*.raw
*.hdd
*.o
*.d
zealbooter/limine.h
/zealbooter/limine.h

View file

@ -2,15 +2,13 @@
[![Discord](https://img.shields.io/discord/934200098144022609?color=7289DA&label=Discord&logo=discord&logoColor=white)](https://discord.gg/rK6U3xdr7D) [![](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://github.com/Zeal-Operating-System/ZealOS/wiki)
The Zeal Operating System is a modernized, professional fork of the 64-bit Temple Operating System. Guiding principles of development include transparency, full user control, and adherence to public-domain/open-source implementations.
The Zeal Operating System is a modernized fork of the 64-bit Temple Operating System. Guiding principles of development include transparency, full user control, and adherence to public-domain/open-source implementations.
![](/screenshots/screenshot2.png)
ZealOS strives to be simple, documented, and require as little of a knowledge gap as possible. One person should be able to comprehend the entire system in at least a semi-detailed way within a few days of study.
Simplify, don't complicate; make accessible, don't obfuscate.
> The CIA encourages code obfuscation. They make it more complicated than necessary.\
—Terry A. Davis
**Simplify, don't complicate; make accessible, don't obfuscate.**
Features in development include:
- [32-bit color VBE graphics](https://github.com/TempleProgramming/HolyGL)

View file

@ -578,9 +578,39 @@ U0 RotateMan(F64 d)
}
}
CTask *mouse_task = NULL;
CTask *game_task = Fs;
F64 mouse_scale = 32.0;
U0 MouseHandler()
{
Bool button;
I64 x;
while (MouseRawQueueFind(game_task))
{
button = mouse_hard.raw_bttns[0];
x = mouse_hard.raw_data.x;
if (button || x != 0)
MouseRawReset; // Mark mouse data as consumed
if (button)
MessagePostWait(game_task, MESSAGE_KEY_DOWN_UP, CH_SPACE, 0);
if (x != 0)
man_é += (x / mouse_scale) / MICRO_STEPS;
Sleep(10);
}
mouse_task = NULL;
}
U0 CastleFrankenstein()
{
I64 sc;
Bool is_raw = TRUE;
MouseRaw(is_raw);
mouse_task = Spawn(&MouseHandler, NULL, "MouseHandler");
MenuPush(
"File {"
@ -594,6 +624,9 @@ U0 CastleFrankenstein()
" Left(,,SC_CURSOR_LEFT);"
" Right(,,SC_CURSOR_RIGHT);"
" Fire(,CH_SPACE);"
" MouseMode(,'m');"
" MouseScaleUp(,'+');"
" MouseScaleDown(,'-');"
"}"
);
@ -618,6 +651,30 @@ U0 CastleFrankenstein()
Fire;
break;
case 'm':
if (is_raw)
{
is_raw = FALSE;
MouseRaw(is_raw);
Kill(mouse_task);
}
else
{
is_raw = TRUE;
MouseRaw(is_raw);
mouse_task = Spawn(&MouseHandler, NULL, "MouseHandler");
}
break;
case '+':
case '=':
mouse_scale *= 0.9;
break;
case '-':
mouse_scale *= 1.1;
break;
case '\n':
Init;
break;
@ -664,6 +721,7 @@ fs_done:
}
CastleFrankenstein;
MouseRaw(FALSE);
&
 
 

View file

@ -1,94 +1,136 @@
#define VGAP_IDX 0x3C4
#define VGAP_DATA 0x3C5
#define VGAR_MAP_MASK 0x02
U8 rev[256], //The VGA bits are backward
image[640 * 480 / 8]; //We need read-modify write.
//0xA0000 alias memory can't be read.
U32 image[GR_HEIGHT * GR_WIDTH];
U0 MGInit()
{
I64 i, j;
MemSet(image, BLACK32, sizeof(image));
}
MemSet(image, 0, sizeof(image));
MemSet(rev, 0, sizeof(rev));
for (i = 0; i < 256; i++)
for (j = 0; j < 8; j++)
if (Bt(&i, j))
Bts(&rev[i], 7 - j);
}
U0 MGUpdate()
{//Copy image to VGA memory
{//Copy image to framebuffer memory
//For better performance we could only write what's changed.
//0xA0000 alias is slower than normal RAM.
OutU8(VGAP_IDX, VGAR_MAP_MASK);
OutU8(VGAP_DATA, 0xF);//All color planes at once -- Black and White
MemCopy(text.vga_alias, image,sizeof(image)); //Alias of 0xA0000
MemCopy(text.fb_alias, image, sizeof(image));
}
U0 MGPlot(I64 x,I64 y)
{
if (0 <= x < 640 && 0 <= y < 480)
Bts(image,y * 640 + x ^ 7);
if (0 <= x < GR_WIDTH && 0 <= y < GR_HEIGHT)
image[x + y * GR_WIDTH] = WHITE32;
}
U0 MGHLine(I64 x1, I64 x2, I64 y)
{//Warning! No clipping
//For performance, we do as many whole-bytes as possible.
U8 *ptr;
I64 i, w, leading, trailing, whole_bytes;
U0 MGHLine(I64 x1, I64 x2, I64 y)
{//No clipping
I64 x;
if (y >= GR_HEIGHT)
return;
if (x2 < x1)
SwapI64(&x1, &x2);
ptr = image + y * 640 / 8 + x1 >> 3;
w = x2 - x1 + 1;
leading = 8 - x1 & 7;
trailing = (x2 + 1) & 7;
if (leading + trailing > w)
*ptr |= rev[(0xFF00 >> leading & (0x00FF << trailing) >> 8)];
else
if (x1 < 0)
x1 = 0;
if (x2 < x1)
SwapI64(&x1, &x2);
x = x1;
while (x <= x2 && x < GR_WIDTH)
{
whole_bytes = (w - leading - trailing) >> 3;
if (leading)
*ptr++ |= rev[(0xFF00 >> leading) & 0xFF];
for (i = 0; i < whole_bytes; i++)
*ptr++ = 0xFF;
if (trailing)
*ptr++ |= rev[(0x00FF << trailing) >> 8];
image[x + y * GR_WIDTH] = WHITE32;
x++;
}
}
U0 MGLine(I64 x1,I64 y1,I64 x2,I64 y2)
{//Warning! No clipping
I64 dx=x2-x1,dy=y2-y1;
{//No clipping
I64 x_start, x_end, y_start, y_end, x, y, dx, dy, c;
x1 <<= 32; x2 <<= 32;
y1 <<= 32; y2 <<= 32;
if (AbsI64(dx) > AbsI64(dy))
c = 0;
x_start = MinI64(x1, x2);
if (x_start == x1)
{
dy = dy << 32 / AbsI64(dx);
dx = SignI64(dx) << 32;
while (x1 != x2)
y_start = y1;
x_end = x2;
y_end = y2;
}
else // x2
{
y_start = y2;
x_end = x1;
y_end = y1;
}
x = x_start;
y = y_start;
dx = x_end - x_start;
if (y_end < y_start)
{
dy = y_start - y_end;
if (dx >= dy)
{
MGPlot(x1.i32[1], y1.i32[1]);
x1 += dx; y1 += dy;
while (x <= x_end)
{
MGPlot(x, y);
c += dy;
if (c >= dx)
{
c -= dx;
y--;
}
x++;
}
}
else
{
while (y > y_end)
{
MGPlot(x, y);
c += dx;
if (c >= dy)
{
c -= dy;
x++;
}
y--;
}
}
}
else
{
dx = dx << 32 / AbsI64(dy);
dy = SignI64(dy) << 32;
while (y1 != y2)
dy = y_end - y_start;
if (dx >= dy)
{
MGPlot(x1.i32[1], y1.i32[1]);
x1 += dx;
y1 += dy;
while (x <= x_end)
{
MGPlot(x, y);
c += dy;
if (c >= dx)
{
c -= dx;
y++;
}
x++;
}
}
else
{
while (y <= y_end)
{
MGPlot(x, y);
c += dx;
if (c >= dy)
{
c -= dy;
x++;
}
y++;
}
}
}
MGPlot(x1.i32[1], y1.i32[1]);
}
U0 MGCircle(I64 x, I64 y, F64 r)
{
F64 s, c, x1, y1, x2, y2;
@ -118,31 +160,34 @@ U0 MGCircle(I64 x, I64 y, F64 r)
MGPlot(x+x1,y+y1);
}
}
U0 MiniGrLibDemo()
{
I64 i;
MGInit;
for (i = 0; i < 100; i++)
MGHLine(200 + i, 400 + i, 300 + i);
MGHLine(200 + i, 400 + i, 400 + i);
for (i = 0; i < 500; i += 10)
MGLine(i, 0, 0, 480 - i);
for (i = 0; i < GR_HEIGHT + 20; i += 10)
MGLine(i, 0, 0, GR_HEIGHT - i);
for (i = 0; i < 300; i += 4)
MGCircle(200, 100 + i, i);
MGCircle(400, 200 + i, i);
MGUpdate;
Busy(1500000);
/*
We are returning graphics to normal operations under ZealOS.
It is not normal to by-pass the ZealOS graphcis routines.
The ZealOS graphics don't know VGA has changed.
This bit tells ZealOS to update whole screen.
The ZealOS graphics don't know the framebuffer has changed.
This function tells ZealOS to update whole screen.
*/
//<CTRL-ALT-v> will flush screen VGA cache.
//<CTRL-ALT-v> will flush screen VGA cache and un-set framebuffer-busy bit.
LFBFlush;
}
MiniGrLibDemo;
MiniGrLibDemo;

View file

@ -1,4 +1,31 @@
$WW,1$$FG,5$$TX+CX,"ChangeLog"$$FG$
$IV,1$----03/22/23 22:27:05----$IV,0$
* Raised version number to 2.03.
* Created $LK+PU,"CMouseRawQueue",A="MN:CMouseRawQueue"$ to track tasks in raw-mouse mode, placed in $LK+PU,"CMouseHardStateGlobals mouse_hard.raw_queue",A="FF:::/Kernel/KernelA.HH,*raw_queue"$.
* Created $LK+PU,"MouseRawQueueFind",A="MN:MouseRawQueueFind"$ to check whether a given task is in raw-mouse mode, externed in $LK+PU,"KernelC.HH",A="FF:::/Kernel/KernelC.HH,MouseRawQueueFind("$.
* Created $LK+PU,"MouseRawWatcher",A="MN:MouseRawWatcher"$ and $LK+PU,"MouseRawWatcherInner",A="MN:MouseRawWatcherInner"$ to watch for killed tasks and remove them from raw_queue, spawned in $LK+PU,"KMain",A="FF:::/Kernel/KMain.ZC,&MouseRawWatcher:2"$.
* Added task parameter to $LK+PU,"MouseRaw",A="MN:MouseRaw"$, changed behaviour from a global toggle to a task-based queue of $LK+PU,"CMouseRawQueue",A="MN:CMouseRawQueue"$ entries.
* Changed $LK+PU,"MouseHardHandler",A="MN:MouseHardHandler"$ to use $LK+PU,"MouseRawQueueFind",A="MN:MouseRawQueueFind"$ with $LK+PU,"sys_focus_task",A="MN:sys_focus_task"$ to determine if currently in raw-mode or not, added $LK+PU,"clearing mouse.show, mouse.lb, mouse.rb",A="FF:::/Kernel/SerialDev/Mouse.ZC,mouse.lb = FALSE"$ to fix bug where clicking to refocus a mouse-raw application would register a repeated click on unfocus.
* Added raw_queue init to $LK+PU,"KbdMouseInit",A="FF:::/Kernel/SerialDev/Mouse.ZC,QueueInit(mouse_hard.raw_queue);"$.
* Changed $LK+PU,"CastleFrankenstein MouseHandler",A="FF:::/Demo/Games/CastleFrankenstein.ZC,MouseHandler"$ while loop condition to use $LK+PU,"MouseRawQueueFind",A="MN:MouseRawQueueFind"$ with game_task as parameter, added raw-mouse keybind descriptions to game's $LK+PU,"MenuPush",A="FF:::/Demo/Games/CastleFrankenstein.ZC,MouseMode"$.
$IV,1$----03/17/23 17:44:24----$IV,0$
* Rewrote $LK+PU,"MiniGrLib",A="FI:::/Demo/Lectures/MiniGrLib.ZC"$, replaced old VGA-specific code to work with 32-bit framebuffer.
$IV,1$----03/14/23 03:23:46----$IV,0$
* Created %o Bool $LK+PU,"StrPrint",A="FF:::/Kernel/StrPrint.ZC,'o'"$ format code, updated $LK+PU,"Print.DD",A="FI:::/Doc/Print.DD"$ with new %o code and previously undocumented format codes.
$IV,1$----03/13/23 18:06:09----$IV,0$
* Raised version number to 2.02.
$IV,1$----02/25/23 16:35:04----$IV,0$
* Created $LK+PU,"MouseRaw",A="MN:MouseRaw"$ and $LK+PU,"MouseRawReset",A="MN:MouseRawReset"$, externs added to $LK+PU,"KernelC.HH",A="FF:::/Kernel/KernelC.HH,MouseRaw("$, functions used in $MA-X+PU,"Mouse.ZC",LM="Find(\"MouseRawReset;\", \"::/Kernel/SerialDev/Mouse.ZC\");View;"$.
* Added members to $LK+PU,"CMouseHardStateGlobals",A="MN:CMouseHardStateGlobals"$ and used in $MA-X+PU,"Mouse.ZC",LM="Find(\"raw_data\", \"::/Kernel/SerialDev/Mouse.ZC\");Find(\"raw_mode\", \"::/Kernel/SerialDev/Mouse.ZC\");Find(\"raw_bttns\", \"::/Kernel/SerialDev/Mouse.ZC\");View;"$:
- CD3I64 raw_data
- Bool raw_bttns[5]
- Bool raw_mode
* $MA-X+PU,"Update CastleFrankenstein to use new MouseRaw functionality.",LM="Find(\"mouse_task\", \"::/Demo/Games/CastleFrankenstein.ZC\");Find(\"MouseHandler\", \"::/Demo/Games/CastleFrankenstein.ZC\");Find(\"MouseRaw\", \"::/Demo/Games/CastleFrankenstein.ZC\");View;"$
$IV,1$----12/21/22 03:38:35----$IV,0$
* Raised version number to 2.01.
* Created $LK+PU,"FreeAll",A="MN:FreeAll"$ method to /Kernel/Memory/MAllocFree.ZC and extern to $LK+PU,"/Kernel/KernelC.HH",A="FF:::/Kernel/KernelC.HH,FreeAll"$.

View file

@ -21,6 +21,16 @@ For $FG,2$"%c"$FG$ or $FG,2$"%C"$FG$, the <aux_format_num> repeats the char that
$ID,2$$FG,2$"%n"$FG$ floating point in engineering notation, exponents being multiples of three. If it has a <aux_format> code, it will display scientific units letters.
$FG,2$"%e"$FG$ floating point in engineering notation, exponents not restricted to multiples of three.
$FG,2$"%d"$FG$ Whole number.
$FG,2$"%u"$FG$ Unsigned whole number.
$FG,2$"%f"$FG$ Floating point number.
$FG,2$"%g"$FG$ Right-aligned rounded-up integer of floating point number.
$FG,2$"%S"$FG$ $LK,"Define",A="MN:Define"$() entry.
$FG,2$"%C"$FG$ $LK,"ToUpper",A="MN:ToUpper"$() character.
@ -52,6 +62,12 @@ $FG,2$"%Z"$FG$ $LK,"DefineListLoad",A="MN:DefineListLoad"$() subentry. Pass sub_
$FG,2$"%Q"$FG$ convert "\" to "\\" and quote to backslash quote. (For use in creating strs in strs.)
$FG,2$"%q"$FG$ rev a $FG,2$"%Q"$FG$.
$FG,2$"%x"$FG$ Hex number.
$FG,2$"%b"$FG$ Binary number$FG$.
$FG,2$"%o"$FG$ Bool$FG$.
$ID,-2$
$FG,5$$TX+CX,"Print Family"$$FG$

0
src/Home/Net/Drivers/PCNet.ZC Normal file → Executable file
View file

View file

@ -7,9 +7,8 @@
#define PCIV_E1000 0x8086
#define PCID_82545EM 0x100F
#define PCIV_VIRTIO 0x1AF4
//#define PCID_VIRTIO_NET 0x1000
#define PCID_VIRTIO_NET 0x1000
U0 NetDriverInclude(U8 *driver)
{
@ -19,42 +18,63 @@ U0 NetDriverInclude(U8 *driver)
Free(filename);
}
class CNetDriver:CQueue
{
U16 vendor_id;
U16 device_id;
U8 *filename; // relative to Drivers/ folder, not absolute
};
CQueue *net_drivers = CAlloc(sizeof(CQueue));
QueueInit(net_drivers);
U0 NetDriverRegister(U16 vendor_id=NULL, U16 device_id=NULL, U8 *filename)
{
CNetDriver *driver;
if (!vendor_id && !device_id)
return;
driver = CAlloc(sizeof(CNetDriver));
driver->vendor_id = vendor_id;
driver->device_id = device_id;
driver->filename = StrNew(filename);
QueueInsertRev(driver, net_drivers);
}
U0 NetDriverInit()
{
CPCIDev *net_driver_pci = PCIDevFind(PCIC_NETWORK);
Bool found = FALSE;
Bool found = FALSE;
CNetDriver *net_driver;
CPCIDev *net_pci;
switch (net_driver_pci->vendor_id)
// register NIC PCI details with driver (file)name
NetDriverRegister(PCIV_VIRTIO, PCID_VIRTIO_NET, "VirtIONet");
NetDriverRegister(PCIV_E1000, PCID_82545EM, "E1000");
NetDriverRegister(PCIV_PCNET, PCID_PCNET, "PCNet");
// iterate registered drivers until match is found, if any found
net_driver = net_drivers->next;
while (net_driver != net_drivers)
{
case PCIV_PCNET:
switch (net_driver_pci->device_id)
{
case PCID_PCNET:
NetDriverInclude("PCNet");
found = TRUE;
break;
}
break;
case PCIV_E1000:
switch (net_driver_pci->device_id)
{
case PCID_82545EM:
NetDriverInclude("E1000");
found = TRUE;
break;
}
break;
case PCIV_VIRTIO:
NetDriverInclude("VirtIONet");
net_pci = PCIDevFind(,, net_driver->vendor_id, net_driver->device_id);
if (net_pci)
{
found = TRUE;
NetDriverInclude(net_driver->filename);
break;
}
net_driver = net_driver->next;
}
if (!found)
{
ClassRep(net_driver_pci);
ClassRep(net_pci);
throw('NODRIVER');
}
}

View file

@ -0,0 +1,10 @@
public CBGR24 gr_palette_sandy_beach[COLORS_NUM] = {
0x000000, 0x000088, 0x008800, 0x006060, 0x002288, 0x4B0082, 0xA52A2A, 0xAAAAAA, 0x444444, 0x4169E1, 0xADFF2F, 0x00AAAA, 0xFF8888, 0x9932CC, 0xC09020, 0xFFF8DF
};
public U0 PaletteSetSandyBeach(Bool persistent=TRUE)
{
GrPaletteSet(gr_palette_sandy_beach);
LFBFlush;
if (persistent)
fp_set_std_palette = &PaletteSetSandyBeach;
}

View file

@ -13,7 +13,7 @@ CTask *sys_winmgr_task,
U8 *rev_bits_table; //Table with U8 bits reversed
CDate local_time_offset;
F64 *pow10_I64,
sys_os_version = 2.01;
sys_os_version = 2.03;
CAutoCompleteDictGlobals acd;
CAutoCompleteGlobals ac;

View file

@ -211,6 +211,8 @@ U0 KMain()
KbdInit;
"Spawn(&MouseHardDriverInstall);\n\n";
Spawn(&MouseHardDriverInstall);
"Spawn(&MouseRawWatcher,, \"MouseRawWatcher\");\n";
Spawn(&MouseRawWatcher,, "MouseRawWatcher");
"Load(\"Compiler\");\n";
Cd("/Compiler");

View file

@ -3715,17 +3715,25 @@ public class CKbdStateGlobals
};
#help_index "Mouse"
class CMouseRawQueue:CQueue
{
CTask *task;
};
public class CMouseHardStateGlobals
{
CD3I64 pos, //Position in pixels
prescale;
prescale,
raw_data;
CD3 scale;
F64 speed; //Output: How fast the user is moving it.
I64 timestamp, //Output: TSCGet when event.
install_attempts, //Private
pkt_size; //Private
CFifoU8 *fifo, *fifo2; //Private
CQueue *raw_queue;
Bool bttns[5],
raw_bttns[5],
has_wheel,
has_ext_bttns,
enabled,

View file

@ -503,6 +503,9 @@ extern I64 KbdMessagesQueue();
public extern U0 KbdTypeMatic(U8 delay);
extern Bool MouseHardDriverInstall();
public extern Bool MouseHardEnable(Bool val=TRUE);
public extern Bool MouseRaw(Bool val, CTask *task=NULL);
public extern U0 MouseRawReset(Bool val=TRUE);
extern CMouseRawQueue *MouseRawQueueFind(CTask *task);
public extern I64 PressAKey();
public extern I64 CharScan();
public extern Bool KeyScan(I64 *_ch=NULL, I64 *_scan_code=NULL, Bool echo=FALSE);

View file

@ -44,6 +44,115 @@ U0 MouseUpdate(I64 x, I64 y, I64 z, Bool l, Bool r)
LBEqual(&kbd.scan_code, SCf_MS_R_DOWN, mouse.rb);
}
public U0 MouseRawReset()
{
mouse_hard.raw_data.x = 0;
mouse_hard.raw_data.y = 0;
mouse_hard.raw_data.z = 0;
mouse_hard.raw_bttns[0] = FALSE;
mouse_hard.raw_bttns[1] = FALSE;
mouse_hard.raw_bttns[2] = FALSE;
mouse_hard.raw_bttns[3] = FALSE;
mouse_hard.raw_bttns[4] = FALSE;
}
CMouseRawQueue *MouseRawQueueFind(CTask *task)
{
CMouseRawQueue *entry = mouse_hard.raw_queue->next;
while (entry != mouse_hard.raw_queue)
{
if (entry->task == task)
return entry;
entry = entry->next;
}
return NULL;
}
U0 MouseRawWatcherInner(CTask *task, CMouseRawQueue *entry, Bool *_found)
{
CTask *task2;
if (task == entry->task)
*_found = TRUE;
task2 = task->next_child_task;
while (!*_found && task2 != (&task->next_child_task)(U8 *) - offset(CTask.next_sibling_task))
{
MouseRawWatcherInner(task2, entry, _found);
task2 = task2->next_sibling_task;
}
}
U0 MouseRawWatcher()
{
CMouseRawQueue *entry, *next_entry;
I64 i;
CCPU *c;
Bool found;
while (TRUE)
{
entry = mouse_hard.raw_queue->next;
while (entry != mouse_hard.raw_queue)
{
found = FALSE;
next_entry = entry->next;
PUSHFD
CLI
for (i = 0; i < mp_count; i++)
{
c = &cpu_structs[i];
MouseRawWatcherInner(c->executive_task, entry, &found);
}
POPFD
if (!found)
{
QueueRemove(entry);
Free(entry);
}
entry = next_entry;
}
Sleep(1000);
}
}
public Bool MouseRaw(Bool val, CTask *task=NULL)
{ // Places mouse in "raw" mode, button presses will not go to windows manager when true
CMouseRawQueue *entry;
Bool old_val;
if (!task)
task = Fs;
if (val)
{
old_val = TRUE;
if (!MouseRawQueueFind(task))
{
entry = CAlloc(sizeof(CMouseRawQueue));
entry->task = task;
QueueInsertRev(entry, mouse_hard.raw_queue);
old_val = FALSE;
}
}
else
{
old_val = FALSE;
if (entry = MouseRawQueueFind(task))
{
QueueRemove(entry);
Free(entry);
old_val = TRUE;
}
}
return old_val;
}
U0 MouseSet(I64 x=I64_MAX, I64 y=I64_MAX, I64 z=I64_MAX, I64 l=I64_MAX, I64 r=I64_MAX)
{//Note: Generates a message. See $LK,"MouseSet",A="FF:::/Demo/Games/Zing.ZC,MouseSet"$().
if (!(0 <= x < sys_framebuffer_width))
@ -78,6 +187,7 @@ U0 MouseInit()
mouse.timestamp = TSCGet;
mouse.dbl_time = 0.175;
GridInit;
MouseRawReset;
}
U0 MouseHardPacketRead()
@ -194,6 +304,7 @@ Bool MouseHardReset()
catch
Fs->catch_except = TRUE;
MouseRawReset;
return res;
}
@ -255,19 +366,22 @@ U0 MouseHardHandler()
{
I64 i, dx, dy, dz;
U8 mouse_buf[4];
Bool is_raw_mode;
if (mouse_hard.raw_queue->next == mouse_hard.raw_queue)
is_raw_mode = FALSE; // queue check branch skips func call stack push/pop, small speedup
else
is_raw_mode = MouseRawQueueFind(sys_focus_task);
if (!is_raw_mode)
MouseHardSetPre;
MouseHardSetPre;
for (i = 0; i < 4; i++)
mouse_buf[i] = 0;
for (i = 0; i < mouse_hard.pkt_size; i++)
if (!FifoU8Remove(mouse_hard.fifo2, &mouse_buf[i]))
mouse_buf[i] = 0;
mouse_hard.bttns[0] = mouse_buf[0] & 1;
mouse_hard.bttns[1] = (mouse_buf[0] & 2) >> 1;
mouse_hard.bttns[2] = (mouse_buf[0] & 4) >> 2;
mouse_hard.bttns[3] = (mouse_buf[3] & 0x10) >> 4;
mouse_hard.bttns[4] = (mouse_buf[3] & 0x20) >> 5;
if (mouse_buf[0] & 0x10)
dx = mouse_buf[1]-256;
else
@ -281,11 +395,36 @@ U0 MouseHardHandler()
else
dz = mouse_buf[3] & 7;
mouse_hard.prescale.x += dx;
mouse_hard.prescale.y += dy;
mouse_hard.prescale.z += dz;
MouseHardSetPost;
if (is_raw_mode)
{
// buttons / position data need to by consumed by app
// buttons stay down, positions keep accumulating until
// consumed by app and reset with MouseRawReset
mouse_hard.raw_bttns[0] |= mouse_buf[0] & 1;
mouse_hard.raw_bttns[1] |= (mouse_buf[0] & 2) >> 1;
mouse_hard.raw_bttns[2] |= (mouse_buf[0] & 4) >> 2;
mouse_hard.raw_bttns[3] |= (mouse_buf[3] & 0x10) >> 4;
mouse_hard.raw_bttns[4] |= (mouse_buf[3] & 0x20) >> 5;
mouse_hard.raw_data.x += dx;
mouse_hard.raw_data.y += dy;
mouse_hard.raw_data.z += dz;
mouse.show = FALSE;
mouse.lb = FALSE;
mouse.rb = FALSE;
}
else
{
mouse_hard.bttns[0] = mouse_buf[0] & 1;
mouse_hard.bttns[1] = (mouse_buf[0] & 2) >> 1;
mouse_hard.bttns[2] = (mouse_buf[0] & 4) >> 2;
mouse_hard.bttns[3] = (mouse_buf[3] & 0x10) >> 4;
mouse_hard.bttns[4] = (mouse_buf[3] & 0x20) >> 5;
mouse_hard.prescale.x += dx;
mouse_hard.prescale.y += dy;
mouse_hard.prescale.z += dz;
mouse.show = TRUE;
MouseHardSetPost;
}
}
U0 MouseHardSet(I64 x, I64 y, I64 z, I64 l, I64 r)
@ -405,5 +544,7 @@ U0 KbdMouseInit()
mouse_hard.prescale.z = 0 / mouse_hard.scale.z;
mouse_hard.pos.x = sys_framebuffer_width >> 1;
mouse_hard.pos.y = sys_framebuffer_height >> 1;
mouse_hard.raw_queue = CAlloc(sizeof(CQueue)); // head of CMouseRawQueue queue
QueueInit(mouse_hard.raw_queue);
MemCopy(&mouse_hard_last, &mouse_hard, sizeof(CMouseHardStateGlobals));
}

View file

@ -439,6 +439,12 @@ to avoid this.
ptr = argv[cur_arg++];
break;
case 'o': // Bool
if (cur_arg >= argc)
throw('StrPrint');
ptr = DefineSub(ToBool(argv[cur_arg++]), "ST_FALSE_TRUE");
break;
case 'S':
if (cur_arg >= argc)
throw('StrPrint');
@ -656,7 +662,7 @@ sp_out_inf:
break;
}
sp_out_f:
sp_out_f:
if (dec_len < 0)
dec_len = 0;
n = Log10(d);

View file

@ -15,7 +15,7 @@ U0 LoadDocDefines()
//$LK,"DD_BOOT_HIGH_LOC_DVD",A="FF:::/System/Boot/BootDVD.ZC,DD_BOOT_HIGH_LOC_DVD"$
$TR,"LineRep"$
$ID,2$DefinePrint("DD_ZEALOS_LOC","98,709");
$ID,2$DefinePrint("DD_ZEALOS_LOC","98,756");
$ID,-2$
DefinePrint("DD_MP_VECT", "%08X", MP_VECT_ADDR);
DefinePrint("DD_MP_VECT_END", "%08X", MP_VECT_ADDR + COREAP_16BIT_INIT_END - COREAP_16BIT_INIT - 1);

View file

@ -54,6 +54,7 @@ public U0 PaletteSetDark(Bool persistent=TRUE)
//*(drv_text_attr(U8 *) + 1) = BROWN;
}
//********************************************************************************
public CBGR24 gr_palette_light[COLORS_NUM] = {
0x000000, 0x0148A4, 0x3B7901, 0x057C7E, 0xBB2020, 0x9E42AE, 0xB57901, 0xB2B6AF,
0x555753, 0x678FBB, 0x82BC49, 0x0097A2, 0xE26A6A, 0xC671BC, 0xC7AB00, 0xFEF1F0

View file

@ -395,6 +395,7 @@ U0 GrUpdateScreen32()
while (src < size) //draw 2 pixels at a time
*dst++ = gr_palette[*src++ & 0xFF] | gr_palette[*src++ & 0xFF] << 32;
GrCalcScreenUpdates;
if (LBtr(&sys_semas[SEMA_FLUSH_VBE_IMAGE], 0))

View file

@ -41,7 +41,7 @@ U0 Cvt(U8 *ff_mask="*", U8 *fu_flags="+r+l-i+S")
Find("ExtDft", ff_mask, fu_flags, "ExtDefault");
Find("ExtChg", ff_mask, fu_flags, "ExtChange");
Find("RegDft", ff_mask, fu_flags, "RegDefault");
Find("\"HC\"", ff_mask, fu_flags, "\"CC\"");
Find("\"HC\"", ff_mask, fu_flags, "\"ZC\"");
Find("CDrv", ff_mask, fu_flags, "CDrive");
Find("CDbgInfo", ff_mask, fu_flags, "CDebugInfo");
Find("dbg_info", ff_mask, fu_flags, "debug_info");

Binary file not shown.

View file

@ -1,8 +1,11 @@
# Nuke built-in rules and variables.
override MAKEFLAGS += -rR
# This is the name that our final kernel executable will have.
# Change as needed.
override KERNEL := zealbooter.elf
# Convenience macro to reliably declare overridable command variables.
# Convenience macro to reliably declare user overridable variables.
define DEFAULT_VAR =
ifeq ($(origin $1),default)
override $(1) := $(2)
@ -20,61 +23,70 @@ $(eval $(call DEFAULT_VAR,CC,cc))
# Same thing for "ld" (the linker).
$(eval $(call DEFAULT_VAR,LD,ld))
# User controllable CFLAGS.
CFLAGS ?= -g -O2 -pipe -Wall -Wextra
# User controllable C flags.
$(eval $(call DEFAULT_VAR,CFLAGS,-g -O2 -pipe))
# User controllable preprocessor flags. We set none by default.
CPPFLAGS ?=
# User controllable C preprocessor flags. We set none by default.
$(eval $(call DEFAULT_VAR,CPPFLAGS,))
# User controllable nasm flags.
NASMFLAGS ?= -F dwarf -g
$(eval $(call DEFAULT_VAR,NASMFLAGS,-F dwarf -g))
# User controllable linker flags. We set none by default.
LDFLAGS ?=
$(eval $(call DEFAULT_VAR,LDFLAGS,))
# Internal C flags that should not be changed by the user.
override CFLAGS += \
-std=gnu11 \
-ffreestanding \
override CFLAGS += \
-Wall \
-Wextra \
-std=gnu11 \
-ffreestanding \
-fno-stack-protector \
-fno-stack-check \
-fno-lto \
-fno-pie \
-fno-pic \
-m64 \
-march=x86-64 \
-mabi=sysv \
-mno-80387 \
-mno-mmx \
-mno-sse \
-mno-sse2 \
-mno-red-zone \
-mcmodel=kernel \
-MMD \
-I. \
-I./lib
-fno-stack-check \
-fno-lto \
-fno-PIE \
-fno-PIC \
-m64 \
-march=x86-64 \
-mabi=sysv \
-mno-80387 \
-mno-mmx \
-mno-sse \
-mno-sse2 \
-mno-red-zone \
-mcmodel=kernel
# Internal C preprocessor flags that should not be changed by the user.
override CPPFLAGS := \
-I. \
-I./lib \
$(CPPFLAGS) \
-MMD \
-MP
# Internal linker flags that should not be changed by the user.
override LDFLAGS += \
-nostdlib \
-static \
-m elf_x86_64 \
override LDFLAGS += \
-nostdlib \
-static \
-m elf_x86_64 \
-z max-page-size=0x1000 \
-T linker.ld
# Check if the linker supports -no-pie and enable it if it does
# Check if the linker supports -no-pie and enable it if it does.
ifeq ($(shell $(LD) --help 2>&1 | grep 'no-pie' >/dev/null 2>&1; echo $$?),0)
override LDFLAGS += -no-pie
endif
# Internal nasm flags that should not be changed by the user.
override NASMFLAGS += \
-Wall \
-f elf64
# Use find to glob all *.c, *.S, and *.asm files in the directory and extract the object names.
override CFILES := $(shell find . -type f -name '*.c')
override ASFILES := $(shell find . -type f -name '*.S')
override NASMFILES := $(shell find . -type f -name '*.asm')
# Use "find" to glob all *.c, *.S, and *.asm files in the tree and obtain the
# object and header dependency file names.
override CFILES := $(shell find -L . -type f -name '*.c')
override ASFILES := $(shell find -L . -type f -name '*.S')
override NASMFILES := $(shell find -L . -type f -name '*.asm')
override OBJ := $(CFILES:.c=.o) $(ASFILES:.S=.o) $(NASMFILES:.asm=.o)
override HEADER_DEPS := $(CFILES:.c=.d) $(ASFILES:.S=.d)
@ -83,7 +95,7 @@ override HEADER_DEPS := $(CFILES:.c=.d) $(ASFILES:.S=.d)
all: $(KERNEL)
limine.h:
curl https://raw.githubusercontent.com/limine-bootloader/limine/trunk/limine.h -o $@ || cp ../build/limine/limine.h limine.h || echo "ERROR"
curl -Lo $@ https://github.com/limine-bootloader/limine/raw/trunk/limine.h || cp ../build/limine/limine.h limine.h || echo "ERROR"
# Link rules for the final kernel executable.
$(KERNEL): $(OBJ)
@ -94,11 +106,11 @@ $(KERNEL): $(OBJ)
# Compilation rules for *.c files.
%.o: %.c limine.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
# Compilation rules for *.S files.
%.o: %.S limine.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
# Compilation rules for *.asm (nasm) files.
%.o: %.asm

View file

@ -40,6 +40,10 @@ SECTIONS
*(.data .data.*)
} :data
/* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */
/* unnecessary zeros will be written to the binary. */
/* If you need, for example, .init_array and .fini_array, those should be placed */
/* above this. */
.bss : {
*(COMMON)
*(.bss .bss.*)