TempleOSCD_150720.ISO
This commit is contained in:
1 parent
401601816c
commit
f8c05f98f4
554 files changed
+26046
-24853
No files matched your search
@@ -1,5 +1,5 @@
|
||||
U0 GridInit()
|
||||
{//Init input pointer grid struct.
|
||||
{//Init input pointer grid struct. See $LK,"::/Demo/Graphics/Grid.CPP.Z"$.
|
||||
ip_grid.x=ip_grid.y=ip_grid.z=8;
|
||||
ip_grid.x_offset=ip_grid.y_offset=ip_grid.z_offset=0;
|
||||
ip_grid.x_speed =ip_grid.y_speed =ip_grid.z_speed =1;
|
||||
@@ -41,8 +41,8 @@ U0 IPVarsUpdate(I64 x,I64 y,I64 z,Bool l,Bool r)
|
||||
}
|
||||
|
||||
U0 IPSet(I64 x=MAX_I64,I64 y=MAX_I64,I64 z=MAX_I64,I64 l=MAX_I64,I64 r=MAX_I64)
|
||||
{//Note: Generates a message.
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
{//Note: Generates a message. See $LK,"IPSet",A="FF:::/Demo/Games/Zing.CPP.Z,IPSet"$().
|
||||
Bool old_preempt=Preempt;
|
||||
if (!(0<=x<GR_WIDTH))
|
||||
x=ip.pos.x;
|
||||
if (!(0<=y<GR_HEIGHT))
|
||||
|
||||
@@ -13,8 +13,10 @@ SHIFT_KEY_SCAN_DECODE_TABLE::
|
||||
DU8 0,0,0,0,0,0,0,0,0,0,'-',0,0,0,'+',0;
|
||||
CTRL_KEY_SCAN_DECODE_TABLE::
|
||||
DU8 0,CH_ESC,"1234567890-=",CH_BACKSPACE,'\t';
|
||||
DU8 CH_CTRLQ,CH_CTRLW,CH_CTRLE,CH_CTRLR,CH_CTRLT,CH_CTRLY,CH_CTRLU,CH_CTRLI,CH_CTRLO,CH_CTRLP,"[]",'\n',0,CH_CTRLA,CH_CTRLS;
|
||||
DU8 CH_CTRLD,CH_CTRLF,CH_CTRLG,CH_CTRLH,CH_CTRLJ,CH_CTRLK,CH_CTRLL,";'\`",0,"\\",CH_CTRLZ,CH_CTRLX,CH_CTRLC,CH_CTRLV;
|
||||
DU8 CH_CTRLQ,CH_CTRLW,CH_CTRLE,CH_CTRLR,CH_CTRLT,CH_CTRLY,CH_CTRLU,
|
||||
CH_CTRLI,CH_CTRLO,CH_CTRLP,"[]",'\n',0,CH_CTRLA,CH_CTRLS;
|
||||
DU8 CH_CTRLD,CH_CTRLF,CH_CTRLG,CH_CTRLH,CH_CTRLJ,CH_CTRLK,CH_CTRLL,
|
||||
";'\`",0,"\\",CH_CTRLZ,CH_CTRLX,CH_CTRLC,CH_CTRLV;
|
||||
DU8 CH_CTRLB,CH_CTRLN,CH_CTRLM,",./",0,'*',0,CH_SPACE,0,0,0,0,0,0;
|
||||
DU8 0,0,0,0,0,0,0,0,0,0,'-',0,0,0,'+',0;
|
||||
}
|
||||
@@ -49,7 +51,7 @@ U0 KbdCmdFlush()
|
||||
|
||||
U0 KbdSetLEDs(I64 sc)
|
||||
{
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
U8 v=0;
|
||||
BEqu(&v,0,Bt(&sc,SCf_SCROLL));
|
||||
BEqu(&v,1,Bt(&sc,SCf_NUM));
|
||||
@@ -165,8 +167,10 @@ U8 scan_code_map[0x100]={
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,SC_ENTER,SC_CTRL,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0x35,0,0,SC_ALT,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,SC_HOME,SC_CURSOR_UP,SC_PAGE_UP,0,SC_CURSOR_LEFT,0,SC_CURSOR_RIGHT,0,SC_END,
|
||||
SC_CURSOR_DOWN,SC_PAGE_DOWN,SC_INS,SC_DELETE,0,0,0,0,0,0,0,0,SC_GUI,0,0,0,
|
||||
0,0,0,0,0,0,0,SC_HOME,
|
||||
SC_CURSOR_UP,SC_PAGE_UP,0,SC_CURSOR_LEFT,0,SC_CURSOR_RIGHT,0,SC_END,
|
||||
SC_CURSOR_DOWN,SC_PAGE_DOWN,SC_INS,SC_DELETE,0,0,0,0,
|
||||
0,0,0,0,SC_GUI,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
@@ -185,8 +189,10 @@ U8 num_lock_map[0x100]={
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,SC_ENTER,SC_CTRL,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0x35,0,0,SC_ALT,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,SC_HOME,SC_CURSOR_UP,SC_PAGE_UP,0,SC_CURSOR_LEFT,0,SC_CURSOR_RIGHT,0,SC_END,
|
||||
SC_CURSOR_DOWN,SC_PAGE_DOWN,SC_INS,SC_DELETE,0,0,0,0,0,0,0,0,SC_GUI,0,0,0,
|
||||
0,0,0,0,0,0,0,SC_HOME,
|
||||
SC_CURSOR_UP,SC_PAGE_UP,0,SC_CURSOR_LEFT,0,SC_CURSOR_RIGHT,0,SC_END,
|
||||
SC_CURSOR_DOWN,SC_PAGE_DOWN,SC_INS,SC_DELETE,0,0,0,0,
|
||||
0,0,0,0,SC_GUI,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
@@ -194,7 +200,7 @@ U8 num_lock_map[0x100]={
|
||||
U8 *Char2KeyName(I64 ch,Bool include_ctrl=TRUE)
|
||||
{//ASCII val to key name.
|
||||
I64 i;
|
||||
U8 buf[136];
|
||||
U8 buf[STR_LEN];
|
||||
if (ch<=CH_SPACE) {
|
||||
nobound_switch (ch) {
|
||||
case '\n':
|
||||
@@ -230,7 +236,7 @@ U8 *Char2KeyName(I64 ch,Bool include_ctrl=TRUE)
|
||||
buf[i+1]=0;
|
||||
break;
|
||||
}
|
||||
} else if (Bt(chars_bitmap_printable,ch)) {
|
||||
} else if (Bt(chars_bmp_printable,ch)) {
|
||||
*buf=ch;
|
||||
buf[1]=0;
|
||||
} else
|
||||
@@ -241,7 +247,7 @@ U8 *Char2KeyName(I64 ch,Bool include_ctrl=TRUE)
|
||||
U8 *ScanCode2KeyName(I64 sc)
|
||||
{//Scan code to key name.
|
||||
I64 ch;
|
||||
U8 buf[136],*st;
|
||||
U8 buf[STR_LEN],*st;
|
||||
*buf=0;
|
||||
if (sc&SCF_CTRL)
|
||||
CatPrint(buf,"CTRL ");
|
||||
@@ -262,8 +268,8 @@ U8 *ScanCode2KeyName(I64 sc)
|
||||
case SC_CURSOR_UP:CatPrint(buf,"UP"); break;
|
||||
case SC_CURSOR_DOWN:CatPrint(buf,"DOWN"); break;
|
||||
case SC_CURSOR_LEFT:CatPrint(buf,"LEFT"); break;
|
||||
case SC_CURSOR_RIGHT:CatPrint(buf,"RIGHT"); break;
|
||||
case SC_PAGE_UP: CatPrint(buf,"PAGE_UP"); break;
|
||||
case SC_CURSOR_RIGHT:CatPrint(buf,"RIGHT"); break;
|
||||
case SC_PAGE_UP: CatPrint(buf,"PAGE_UP"); break;
|
||||
case SC_PAGE_DOWN:CatPrint(buf,"PAGE_DOWN");break;
|
||||
case SC_HOME: CatPrint(buf,"HOME"); break;
|
||||
case SC_END: CatPrint(buf,"END"); break;
|
||||
@@ -281,9 +287,9 @@ U8 *ScanCode2KeyName(I64 sc)
|
||||
case SC_F10: CatPrint(buf,"F10"); break;
|
||||
case SC_F11: CatPrint(buf,"F11"); break;
|
||||
case SC_F12: CatPrint(buf,"F12"); break;
|
||||
case SC_GUI: CatPrint(buf,"WINDOWS"); break;
|
||||
case SC_PRTSCRN1: CatPrint(buf,"PRTSCRN1"); break;
|
||||
case SC_PRTSCRN2: CatPrint(buf,"PRTSCRN2"); break;
|
||||
case SC_GUI: CatPrint(buf,"WINDOWS"); break;
|
||||
case SC_PRTSCRN1: CatPrint(buf,"PRTSCRN1"); break;
|
||||
case SC_PRTSCRN2: CatPrint(buf,"PRTSCRN2"); break;
|
||||
}
|
||||
}
|
||||
return StrNew(buf);
|
||||
@@ -398,17 +404,6 @@ interrupt U0 KbdIntHandler()
|
||||
KbdPktRead;
|
||||
}
|
||||
|
||||
U0 CtrlAltLetCBSet(U8 ch,U0 (*fp_handler)(I64 sc),U8 *desc,Bool in_irq=FALSE)
|
||||
{//Set callback for <CTRL-ALT-letter>.
|
||||
ch=ToUpper(ch)-'A';
|
||||
if (ch<26) {
|
||||
keydev.fp_ctrl_alt_let_cbs[ch]=fp_handler;
|
||||
Free(keydev.ctrl_alt_let_descs[ch]);
|
||||
keydev.ctrl_alt_let_descs[ch]=AStrNew(desc);
|
||||
BEqu(&keydev.ctrl_alt_let_in_irq_flags,ch,in_irq);
|
||||
}
|
||||
}
|
||||
|
||||
U0 KbdInit()
|
||||
{
|
||||
try {
|
||||
@@ -424,14 +419,6 @@ U0 KbdInit()
|
||||
}
|
||||
IntEntrySet(0x21,&KbdIntHandler);
|
||||
OutU8(0x21,InU8(0x21)&~2);
|
||||
|
||||
CtrlAltLetCBSet('C',&CtrlAltC,"Sys/Break Execution",TRUE);
|
||||
CtrlAltLetCBSet('D',&CtrlAltD,"Sys/Enter Debugger",TRUE);
|
||||
CtrlAltLetCBSet('E',&CtrlAltE,"Sys/Spawn New User Task");
|
||||
CtrlAltLetCBSet('F',&CtrlAltF,"Sys/VGA Flush",TRUE);
|
||||
CtrlAltLetCBSet('M',&CtrlAltM,"Sys/Toggle Mute");
|
||||
CtrlAltLetCBSet('T',&CtrlAltT,"Sys/Switch Focus to Next Task",TRUE);
|
||||
CtrlAltLetCBSet('X',&CtrlAltX,"Sys/Kill Focused Task",TRUE);
|
||||
}
|
||||
|
||||
U0 KbdHandler()
|
||||
|
||||
+12
-12
@@ -20,10 +20,10 @@ U0 InputFilterTask()
|
||||
SetRFlags(old_flags);
|
||||
Preempt(ON);
|
||||
try
|
||||
ExePrint("%s",tempc->aux_str);
|
||||
ExePrint("%s",tempc->aux_str);
|
||||
catch
|
||||
Fs->catch_except=TRUE;
|
||||
Preempt(OFF);
|
||||
Preempt;
|
||||
SrvCmdDel(tempc);
|
||||
} else
|
||||
break;
|
||||
@@ -66,8 +66,8 @@ Note: This delivers messages from parent down to pop-up.
|
||||
*_a2=tempc->aux2;
|
||||
SrvCmdDel(tempc);
|
||||
if ((result!=MSG_KEY_DOWN || !(tempc->aux2&SCF_KEY_DESC) ||
|
||||
Bt(&mask,MSGF_ALLOW_KEY_DESC)) && Bt(&mask,result))
|
||||
goto sm_done;
|
||||
Bt(&mask,MSGF_ALLOW_KEY_DESC)) && Bt(&mask,result))
|
||||
goto sm_done;
|
||||
}
|
||||
}
|
||||
SetRFlags(old_flags);
|
||||
@@ -97,9 +97,9 @@ I64 FlushMsgs(CTask *task=NULL)
|
||||
I64 GetMsg(I64 *_a1=NULL,I64 *_a2=NULL,I64 mask=~1,CTask *task=NULL)
|
||||
{//Wait for a message of type specified by a one in the mask.
|
||||
//Throw-out all messages not in mask.
|
||||
//Returns $LK,"msg_code",A="MN:MSG_CMD"$. See $LK,"::/Demo/MsgLoop.CPP"$.
|
||||
//Returns $LK,"msg_code",A="MN:MSG_CMD"$. See $LK,"::/Demo/MsgLoop.CPP"$.
|
||||
I64 result;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
if (!task) task=Fs;
|
||||
LBtr(&task->task_flags,TASKf_IDLE);
|
||||
while (!(result=ScanMsg(_a1,_a2,mask,task))) {
|
||||
@@ -114,7 +114,7 @@ I64 GetMsg(I64 *_a1=NULL,I64 *_a2=NULL,I64 mask=~1,CTask *task=NULL)
|
||||
I64 ScanChar()
|
||||
{//Checks for $LK,"MSG_KEY_DOWN",A="MN:MSG_KEY_DOWN"$ and returns 0 immediately if no key.
|
||||
//Waits for $LK,"MSG_KEY_UP",A="MN:MSG_KEY_UP"$ of non-zero $LK,"ASCII",A="MN:CH_CTRLA"$ key and returns $LK,"ASCII",A="MN:CH_CTRLA"$ if key.
|
||||
//$LK,"ScanMsg",A="MN:ScanMsg"$() throws away other message types.
|
||||
//$LK,"ScanMsg",A="MN:ScanMsg"$() throws away other message types.
|
||||
I64 a1a,a2a,a1b,a2b;
|
||||
if (!ScanMsg(&a1a,&a2a,1<<MSG_KEY_DOWN)||!a1a)
|
||||
return 0;
|
||||
@@ -127,8 +127,8 @@ I64 ScanChar()
|
||||
Bool ScanKey(I64 *_ch=NULL,I64 *_scan_code=NULL,Bool echo=FALSE)
|
||||
{//Checks for $LK,"MSG_KEY_DOWN",A="MN:MSG_KEY_DOWN"$ and returns FALSE immediately if no key.
|
||||
//Sets $LK,"ASCII",A="MN:CH_CTRLA"$ and $LK,"scan_code",A="FI:::/Doc/CharOverview.TXT"$.
|
||||
//Removes key message and returns TRUE.
|
||||
//$LK,"ScanMsg",A="MN:ScanMsg"$() throws away other message types.
|
||||
//Removes key message and returns TRUE.
|
||||
//$LK,"ScanMsg",A="MN:ScanMsg"$() throws away other message types.
|
||||
I64 ch=0,sc=0;
|
||||
if (ScanMsg(&ch,&sc,1<<MSG_KEY_DOWN)) {
|
||||
if (_ch) *_ch=ch;
|
||||
@@ -146,9 +146,9 @@ Bool ScanKey(I64 *_ch=NULL,I64 *_scan_code=NULL,Bool echo=FALSE)
|
||||
I64 GetKey(I64 *_scan_code=NULL,Bool echo=FALSE,Bool raw_cursor=FALSE)
|
||||
{//Waits for $LK,"MSG_KEY_DOWN",A="MN:MSG_KEY_DOWN"$ message and returns $LK,"ASCII",A="MN:CH_CTRLA"$.
|
||||
//Sets $LK,"scan_code",A="FI:::/Doc/CharOverview.TXT"$.
|
||||
//$LK,"ScanKey",A="MN:ScanKey"$() throws away other message types.
|
||||
//$LK,"ScanKey",A="MN:ScanKey"$() throws away other message types.
|
||||
I64 ch,sc;
|
||||
Bool old_preempt=Preempt(OFF),cursor_on=FALSE;
|
||||
Bool old_preempt=Preempt,cursor_on=FALSE;
|
||||
while (!ScanKey(&ch,&sc,FALSE)) {
|
||||
if (IsRaw && raw_cursor) {
|
||||
if (!cursor_on && ToI64(GetTSC*5/cnts.time_stamp_freq)&1) {
|
||||
@@ -161,7 +161,7 @@ I64 GetKey(I64 *_scan_code=NULL,Bool echo=FALSE,Bool raw_cursor=FALSE)
|
||||
}
|
||||
LBts(&Fs->task_flags,TASKf_IDLE);
|
||||
if (IsDbg) {
|
||||
//We don't want interrupt-driven keyboard when in debugger
|
||||
//We don't want interrupt-driven keyboard when in debugger
|
||||
//because that could have side-effects or crash, so we poll
|
||||
//keyboard when in debugger with interrupts off.
|
||||
PUSHFD
|
||||
|
||||
+17
-14
@@ -49,7 +49,7 @@ Bool MouseRst()
|
||||
if (*_w==0x9FC0) {
|
||||
_b=0x9FC00+0x30;
|
||||
*_b=1; //This enables my mouse. It might be for one machine.
|
||||
//USB DMA packets, set-up by BIOS to make legacy PS/2?
|
||||
//USB DMA packets, set-up by BIOS to make legacy PS/2?
|
||||
}
|
||||
if (!present)
|
||||
MemPagePresentMark(_w,FALSE);
|
||||
@@ -71,7 +71,7 @@ Bool MouseRst()
|
||||
while (tS<timeout);
|
||||
|
||||
try
|
||||
KbdCmdRead;
|
||||
KbdCmdRead;
|
||||
catch
|
||||
Fs->catch_except=TRUE;
|
||||
|
||||
@@ -98,7 +98,7 @@ Bool MouseRst()
|
||||
KbdMouseCmdAck(0xF4); // enable Mouse
|
||||
result=TRUE;
|
||||
|
||||
//Enable IRQ 12
|
||||
//Enable IRQ 12
|
||||
KbdCmdSend(KBD_CTRL,0x20);
|
||||
b=KbdCmdRead;
|
||||
KbdCmdSend(KBD_CTRL,0x60);
|
||||
@@ -107,12 +107,12 @@ Bool MouseRst()
|
||||
} catch
|
||||
Fs->catch_except=TRUE;
|
||||
|
||||
//This is been added to override failure
|
||||
//because the mouse sometimes still works.
|
||||
result=TRUE;
|
||||
//This is been added to override failure
|
||||
//because the mouse sometimes still works.
|
||||
result=TRUE;
|
||||
|
||||
try
|
||||
KbdCmdSend(KBD_CTRL,0xAE); //Enable Keyboard
|
||||
KbdCmdSend(KBD_CTRL,0xAE); //Enable Keyboard
|
||||
catch
|
||||
Fs->catch_except=TRUE;
|
||||
if (mouse.has_wheel || mouse.has_ext_buttons)
|
||||
@@ -121,7 +121,7 @@ Bool MouseRst()
|
||||
mouse.pkt_size=3;
|
||||
if (!result)
|
||||
try
|
||||
KbdCmdSend(KBD_CTRL,0xA7); //Disable Mouse
|
||||
KbdCmdSend(KBD_CTRL,0xA7); //Disable Mouse
|
||||
catch
|
||||
Fs->catch_except=TRUE;
|
||||
return result;
|
||||
@@ -130,8 +130,9 @@ Bool MouseRst()
|
||||
U0 MouseSpeedSet()
|
||||
{
|
||||
I64 dd,temp;
|
||||
if ((dd=SqrI64(mouse_last.pos.x-mouse.pos.x)+SqrI64(mouse_last.pos.y-mouse.pos.y)) &&
|
||||
(temp=mouse.timestamp-mouse_last.timestamp))
|
||||
if ((dd=SqrI64(mouse_last.pos.x-mouse.pos.x)
|
||||
+SqrI64(mouse_last.pos.y-mouse.pos.y)) &&
|
||||
(temp=mouse.timestamp-mouse_last.timestamp))
|
||||
mouse.speed=Sqrt(dd)*cnts.time_stamp_freq/temp;
|
||||
mouse_last.timestamp=mouse.timestamp;
|
||||
}
|
||||
@@ -150,7 +151,8 @@ U0 MouseUpdatePost()
|
||||
mouse.pos.y=mouse.prescale.y*mouse.scale.y*ip_grid.y_speed;
|
||||
mouse.pos.z=mouse.prescale.z*mouse.scale.z*ip_grid.z_speed;
|
||||
|
||||
i=Trunc(ip.scale.x*mouse.pos.x/ip_grid.x)*ip_grid.x+ip.offset.x; //TODO ip_grid.x_offset?
|
||||
i=Trunc(ip.scale.x*mouse.pos.x/ip_grid.x)*ip_grid.x+ip.offset.x;
|
||||
//TODO ip_grid.x_offset?
|
||||
if (i<0)
|
||||
ip.offset.x-=i;
|
||||
else if (i>=GR_WIDTH)
|
||||
@@ -162,7 +164,8 @@ U0 MouseUpdatePost()
|
||||
else if (i>=GR_HEIGHT)
|
||||
ip.offset.y+=GR_HEIGHT-1-i;
|
||||
|
||||
if (mouse.pos.x!=mouse_last.pos.x || mouse.pos.y!=mouse_last.pos.y || mouse.pos.z!=mouse_last.pos.z) {
|
||||
if (mouse.pos.x!=mouse_last.pos.x || mouse.pos.y!=mouse_last.pos.y ||
|
||||
mouse.pos.z!=mouse_last.pos.z) {
|
||||
mouse.evt=TRUE;
|
||||
MouseSpeedSet;
|
||||
} else
|
||||
@@ -264,8 +267,8 @@ U0 KbdMouseHandler(Bool poll_kbd,Bool poll_mouse)
|
||||
KbdMouseRst;
|
||||
else {
|
||||
if (poll_mouse &&
|
||||
mouse.installed &&
|
||||
!mouse.irqs_working) {
|
||||
mouse.installed &&
|
||||
!mouse.irqs_working) {
|
||||
PUSHFD
|
||||
CLI
|
||||
while (InU8(KBD_CTRL)&1)
|
||||
|
||||
Reference in new issue
Block a user