diff --git a/README.md b/README.md index e19308f5..96326874 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/Demo/Games/CastleFrankenstein.ZC b/src/Demo/Games/CastleFrankenstein.ZC index c5eed11b..306a912c 100755 --- a/src/Demo/Games/CastleFrankenstein.ZC +++ b/src/Demo/Games/CastleFrankenstein.ZC @@ -578,6 +578,29 @@ U0 RotateMan(F64 d) } } +CTask *mouse_task = NULL; +CTask *game_task = Fs; +F64 mouse_scale = 32.0; + +U0 MouseHandler() +{ + Bool button; + I64 x; + while (TRUE) + { + 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); + } +} + U0 CastleFrankenstein() { I64 sc; @@ -618,6 +641,26 @@ U0 CastleFrankenstein() Fire; break; + case 'm': + if (!mouse_task) { + MouseRaw(TRUE); + mouse_task=Spawn(&MouseHandler,NULL); + } + else { + Kill(mouse_task); + mouse_task=NULL; + MouseRaw(FALSE); + } + break; + + case '+': + mouse_scale *= 0.9; + break; + + case '-': + mouse_scale *= 1.1; + break; + case '\n': Init; break; @@ -663,7 +706,11 @@ fs_done: RegWrite("ZealOS/CastleFrankenstein", "F64 best_score=%5.4f;\n", best_score); } +MouseRaw(TRUE); +mouse_task=Spawn(&MouseHandler,NULL); CastleFrankenstein; +if (mouse_task) Kill(mouse_task); +MouseRaw(FALSE); &     diff --git a/src/Doc/ChangeLog.DD b/src/Doc/ChangeLog.DD index 4c92ea5d..d8b899d3 100755 --- a/src/Doc/ChangeLog.DD +++ b/src/Doc/ChangeLog.DD @@ -1,4 +1,19 @@ $WW,1$$FG,5$$TX+CX,"ChangeLog"$$FG$ +$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"$. + $IV,1$----11/02/22 20:26:55----$IV,0$ * Raised version number to 2.00. * Updated the $LK,"Charter",A="FI:::/Doc/Charter.DD"$ to allow non-Public-Domain MBR/UEFI bootloaders, as long as the Public Domain ZealOS HDD/DVD Boot Loaders are included, offered, and functional. The Charter upholds that all operating system code must still be 100% public domain. Updated $LK+PU,"Credits",A="FI:::/Doc/Credits.DD"$, $LK+PU,"FAQ",A="FI:::/Doc/FAQ.DD"$, $LK+PU,"Features.DD",A="FI:::/Doc/Features.DD"$, $LK+PU,"Welcome.DD",A="FI:::/Doc/Welcome.DD"$. diff --git a/src/Home/Net/Drivers/PCNet.ZC b/src/Home/Net/Drivers/PCNet.ZC old mode 100644 new mode 100755 index 65acfb7a..26b09f1d --- a/src/Home/Net/Drivers/PCNet.ZC +++ b/src/Home/Net/Drivers/PCNet.ZC @@ -23,8 +23,12 @@ #define PCNET_DW_RDP 0x10 #define PCNET_DW_RAP 0x14 +#define PCNET_DW_BDP 0x1C #define PCNET_DW_RESET 0x18 // reset reg location when card is in 32-bit mode +#define PCNET_BCR_MISC_CONFIG 2 +#define PCNET_BCR_FULL_DUPLEX_CTRL 9 + #define PCNET_CSR_CTRLSTATUS 0 #define PCNET_CSR_INTERRUPTS 3 #define PCNET_CSR_FEATURECTRL 4 @@ -57,6 +61,11 @@ #define PCNET_FEATURE_APADXMT 11 +#define PCNET_BCR_MISC_CONFIG_ASEL 1 + +#define PCNET_BCR_FULL_DUPLEX_CTRL_FDEN 0 +#define PCNET_BCR_FULL_DUPLEX_CTRL_AUIFD 1 + #define PCNET_CTRL_INIT 0 #define PCNET_CTRL_STRT 1 #define PCNET_CTRL_STOP 2 @@ -159,6 +168,28 @@ U0 PCNetRAPWrite(U32 value) OutU32(PCNetIOBaseGet + PCNET_DW_RAP, value); } +U0 PCNetBCRWrite(U32 bcr, U32 value) +{/* AMD PCNet datasheet p. 1-952 + Summary: Bus Control Registers are + accessed via the BDP (Bus Data Port). + Which BCR is selected is based on the value + in the RAP. */ + + PCNetRAPWrite(bcr); + OutU32(PCNetIOBaseGet + PCNET_DW_BDP, value); +} + +U32 PCNetBCRRead(U32 bcr) +{/* AMD PCNet datasheet p. 1-952 + Summary: Bus Control Registers are + accessed via the BDP (Bus Data Port). + Which BCR is selected is based on the value + in the RAP. */ + + PCNetRAPWrite(bcr); + return InU32(PCNetIOBaseGet + PCNET_DW_BDP); +} + U0 PCNetCSRWrite(U32 csr, U32 value) {/* AMD PCNet datasheet p. 1-952 Summary: Control and Status Registers are @@ -181,6 +212,26 @@ U32 PCNetCSRRead(U32 csr) return InU32(PCNetIOBaseGet + PCNET_DW_RDP); } +U0 PCNetAutoLinkSelect() +{ + U32 bcr = PCNetCSRRead(PCNET_BCR_FULL_DUPLEX_CTRL); + + Bts(&bcr, PCNET_BCR_FULL_DUPLEX_CTRL_FDEN); + Bts(&bcr, PCNET_BCR_FULL_DUPLEX_CTRL_AUIFD); + + PCNetBCRWrite(PCNET_BCR_FULL_DUPLEX_CTRL, bcr); +} + +U0 PCNetEnableFullDuplex() +{ + U32 bcr = PCNetCSRRead(PCNET_BCR_MISC_CONFIG); + + Bts(&bcr, PCNET_BCR_MISC_CONFIG_ASEL); + + PCNetBCRWrite(PCNET_BCR_MISC_CONFIG, bcr); +} + + U0 PCNetSWStyleSet() {/* AMD PCNet datasheet p. 1-968 In CSR58 (Software Style), the 8-bit @@ -260,9 +311,9 @@ U0 PCNetBuffersAllocate() pcnet.rx_de_buffer = dev.uncached_alias + pcnet.rx_de_buffer_phys; // we want uncached pcnet.tx_de_buffer = dev.uncached_alias + pcnet.tx_de_buffer_phys; // access to these. - pcnet.rx_buffer_addr_phys = CAlloc(ETHERNET_FRAME_SIZE * PCNET_RX_BUFF_COUNT, Fs->code_heap); + pcnet.rx_buffer_addr_phys = CAllocAligned(ETHERNET_FRAME_SIZE * PCNET_RX_BUFF_COUNT, 16, Fs->code_heap); - pcnet.tx_buffer_addr_phys = CAlloc(ETHERNET_FRAME_SIZE * PCNET_TX_BUFF_COUNT, Fs->code_heap); + pcnet.tx_buffer_addr_phys = CAllocAligned(ETHERNET_FRAME_SIZE * PCNET_TX_BUFF_COUNT, 16, Fs->code_heap); //Shrine does a check and returns -1 here, if the end of either buffer exceeds 0x100000000 @@ -361,7 +412,7 @@ U0 PCNetDirectInit() U8 *PCNetInitBlockSetup() { - U8 *setup = CAlloc(sizeof(CPCNetBufferSetup), Fs->code_heap); + U8 *setup = CAllocAligned(sizeof(CPCNetBufferSetup), 16, Fs->code_heap); CPCNetBufferSetup *u_setup = setup + dev.uncached_alias; U32 p_setup; @@ -426,6 +477,7 @@ U0 PCNetConfigModeExit() Btr(&csr, PCNET_CTRL_INIT); Btr(&csr, PCNET_CTRL_STOP); + Bts(&csr, PCNET_CTRL_IENA); Bts(&csr, PCNET_CTRL_STRT); PCNetCSRWrite(PCNET_CSR_CTRLSTATUS, csr); @@ -433,10 +485,9 @@ U0 PCNetConfigModeExit() U0 PCNetUploadConfig() {/* Upload new config and wait for card to acknowlege */ - U32 csr = PCNetCSRRead(PCNET_CSR_CTRLSTATUS); + U32 csr = 0; Bts(&csr, PCNET_CTRL_INIT); - Bts(&csr, PCNET_CTRL_IENA); PCNetCSRWrite(PCNET_CSR_CTRLSTATUS, csr); @@ -449,7 +500,6 @@ U0 PCNetUploadConfig() } } - I64 PCNetDriverOwns(CPCNetDescriptorEntry* entry) {/* Returns whether the value of the OWN bit of the Descriptor Entry is zero. If 0, driver owns, @@ -681,6 +731,10 @@ U0 PCNetInit() PCNetTXAutoPadEnable; + PCNetAutoLinkSelect; + + PCNetEnableFullDuplex; + PCNetUploadConfig; csr = PCNetCSRRead(PCNET_CSR_CTRLSTATUS); diff --git a/src/Kernel/KGlobals.ZC b/src/Kernel/KGlobals.ZC index 17c3558d..d240802b 100755 --- a/src/Kernel/KGlobals.ZC +++ b/src/Kernel/KGlobals.ZC @@ -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.00; + sys_os_version = 2.02; CAutoCompleteDictGlobals acd; CAutoCompleteGlobals ac; diff --git a/src/Kernel/KernelA.HH b/src/Kernel/KernelA.HH index 2f22b54f..15bc09fb 100755 --- a/src/Kernel/KernelA.HH +++ b/src/Kernel/KernelA.HH @@ -3718,7 +3718,8 @@ public class CKbdStateGlobals 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. @@ -3726,6 +3727,8 @@ public class CMouseHardStateGlobals pkt_size; //Private CFifoU8 *fifo, *fifo2; //Private Bool bttns[5], + raw_bttns[5], + raw_mode, has_wheel, has_ext_bttns, enabled, diff --git a/src/Kernel/KernelC.HH b/src/Kernel/KernelC.HH index 9bd4886a..72a04628 100755 --- a/src/Kernel/KernelC.HH +++ b/src/Kernel/KernelC.HH @@ -503,6 +503,8 @@ 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); +public extern U0 MouseRawReset(Bool val=TRUE); public extern I64 PressAKey(); public extern I64 CharScan(); public extern Bool KeyScan(I64 *_ch=NULL, I64 *_scan_code=NULL, Bool echo=FALSE); @@ -555,6 +557,7 @@ public extern U8 *ReAlloc( U8 *src, U64 size, CTask *mem_task=NU public _extern _MHEAP_CTRL CHeapCtrl *MHeapCtrl( U8 *src); public _extern _MSIZE I64 MSize( U8 *src); //size of heap object public _extern _MSIZE2 I64 MSize2( U8 *src); //Internal size +public extern U0 FreeAll(...); //Free all pointers passed #help_index "Memory/HeapCtrl" public extern U0 HeapCtrlDel( CHeapCtrl *hc); @@ -735,4 +738,4 @@ public extern F64 tS(); //From SysTimerFreq. #help_index "Windows" public extern Bool WinInside(I64 x, I64 y, CTask *task=NULL, I64 border=0); -#help_index "" \ No newline at end of file +#help_index "" diff --git a/src/Kernel/Memory/MAllocFree.ZC b/src/Kernel/Memory/MAllocFree.ZC index 92912b7d..a72c0565 100755 --- a/src/Kernel/Memory/MAllocFree.ZC +++ b/src/Kernel/Memory/MAllocFree.ZC @@ -504,3 +504,11 @@ U8 *SysStrNew(U8 *buf) {//Alloc copy of string in System task's heap. return StrNew(buf, sys_task); } + +U0 FreeAll(...) +{// Free all pointers passed + U64 cur_arg = 0; + + while (argc--) + Free(argv[cur_arg++]); +} diff --git a/src/Kernel/SerialDev/Mouse.ZC b/src/Kernel/SerialDev/Mouse.ZC index 756aaedf..be578c4c 100755 --- a/src/Kernel/SerialDev/Mouse.ZC +++ b/src/Kernel/SerialDev/Mouse.ZC @@ -44,6 +44,28 @@ 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; +} + +public Bool MouseRaw(Bool val) +{ // Places mouse in "raw" mode, button presses will not go to windows manager when true + Bool old_val = mouse_hard.raw_mode; + + mouse_hard.raw_mode = val; + mouse.show = !val; + + 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 +100,7 @@ U0 MouseInit() mouse.timestamp = TSCGet; mouse.dbl_time = 0.175; GridInit; + MouseRawReset; } U0 MouseHardPacketRead() @@ -194,6 +217,7 @@ Bool MouseHardReset() catch Fs->catch_except = TRUE; + MouseRawReset; return res; } @@ -256,18 +280,15 @@ U0 MouseHardHandler() I64 i, dx, dy, dz; U8 mouse_buf[4]; - MouseHardSetPre; + if (!mouse_hard.raw_mode) + 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 +302,32 @@ 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 (mouse_hard.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; + } + 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; + MouseHardSetPost; + } } U0 MouseHardSet(I64 x, I64 y, I64 z, I64 l, I64 r) diff --git a/src/System/Define.ZC b/src/System/Define.ZC index 3130a724..707e21d0 100755 --- a/src/System/Define.ZC +++ b/src/System/Define.ZC @@ -15,8 +15,8 @@ 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,675"); -$ID,-2$ +$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); diff --git a/src/System/Gr/GrScreen.ZC b/src/System/Gr/GrScreen.ZC index dcfd93a9..1c8e64e6 100755 --- a/src/System/Gr/GrScreen.ZC +++ b/src/System/Gr/GrScreen.ZC @@ -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)) diff --git a/src/System/Utils/ConversionScript.ZC b/src/System/Utils/ConversionScript.ZC index e3436b86..8289fea9 100755 --- a/src/System/Utils/ConversionScript.ZC +++ b/src/System/Utils/ConversionScript.ZC @@ -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");