📄 applicat.cpp
字号:
( ( da.year - 1980 )<<9 ) + ( (unsigned) da.month<<5) +
(unsigned) da.day;
if (( stream = fopen(swpfile, "w+b")) == NULL ) return (-1);
if (( count = fwrite(tmpstr,32 , 1, stream)) != 1 ) return (-1);
// if ( ( _currentGrafPort->device == VGA ) // IS VGAHI
// && ( _currentGrafPort->mode == VGAHI ) )
if ( ( 1 )
&& ( 1 ) )
{
for ( i = 0; i < 4; i ++ )
{
// enable VGA bit-plane read
_selectVGABitPlane ( i, 0 );
fseek ( stream,i* 38400L+32, SEEK_SET );
if ((count =fwrite((void far*)0xa0000000L,
(unsigned)38400, 1, stream) ) != 1 ) return (-1);
}
}
else return (-1);
if ( ( fclose ( stream ) ) != 0 ) return -1;
return 0;
}
int application_class::_disk2Screen ( const char * swpfile )
{
int result = 0, i;
FILE *stream;
size_t count;
char tmpstr [ 32 ];
if (( stream = fopen(swpfile, "r+b")) == NULL ) return (-1);
if (( count = fread (tmpstr,32 , 1, stream)) != 1 ) return (-1);
if ( ( strcmp ( tmpstr, "ADFFT(c)LDh1994" ) != 0 ) || ( tmpstr [ 24 ] != 0x05 ) )
return dosFileNotFound;
// if ( ( _currentGrafPort->device == VGA ) // OK VGAHI
// && ( _currentGrafPort->mode == VGAHI ) )
if ( ( 1 )
&& ( 1 ) )
{
for ( i = 0; i < 4; i ++ )
{
// enable VGA bit-plane write
_selectVGABitPlane ( i, 1 );
fseek ( stream,i* 38400L+32, SEEK_SET );
if ((count =fread ((void far*)0xa0000000L,
(unsigned)38400, 1, stream) ) != 1 ) return (-1);
}
}
else return (-1);
if ( ( fclose ( stream ) ) != 0 ) return -1;
return 0;
}
/////////////////////////////////////////////////////////////////////////
////////////////////////// exec a dialog //////////////////////////////
/////////////////////////////////////////////////////////////////////////
int application_class::exec_dialog(Tdialog *pdialog_handled)
{ int ret_value;
int keynum;
class MSGQueue savqueue;
MSG savmsg;
savqueue =thequeue;
savmsg =sysmsg;
thequeue.Reset();
pdialog_handled->open_one_win ();
do {
ret_value=main_message_loop();
} while ( ( (ret_value != Dlg_OK)&&(ret_value!=Dlg_CANCEL) ) || //Dlg_OK or Dlg_CANCEL
(pdialog_handled ==pcurrent_selected_win ) );
// similar to run
// others no need to delete now
// No need to delete pdialog_handled;--->deleted as it is closed
asm cli;
sysmsg =savmsg;
thequeue =savqueue;
asm sti;
return ret_value;
}
///////////////////////////////////////////////////////////////////////////
void interrupt application_class::timer(...)
{
// disable();
// mouse still makes the program crash////////////////// WHY
if (!timer_active){
timer_active =TRUE;
(*old_timer)(...);
if (thequeue.QueueFull()) goto Ret;
///Prevent more queue
if ( thequeue.first !=thequeue.last ) {
if (( thequeue.msg_array[thequeue.oldfirst].Action==TimerMSG)
|| (thequeue.msg_array[thequeue.oldfirst].Action==SlowTimerMSG))
goto Ret;
}
time_counter++;
slow_time_counter ++;
if ( time_counter > TIMER_COUNT ){
time_counter =0;
thequeue.SendMessage(0,TimerMSG,NULL);
}
if (slow_time_counter > SLOW_TIMER_COUNT ) {
slow_time_counter =0 ;
thequeue.SendMessage(0,SlowTimerMSG,NULL);
}
Ret: timer_active =FALSE;
}
// enable();
}
void interrupt (* application_class::old_timer) (...)=getvect(0x19);
void interrupt (* application_class::old_key ) (...)=getvect(0x19);
void interrupt (* application_class::old_mouse) (...)=getvect(0x19);
void interrupt (* application_class::old_dos_error) (...)=getvect(0x19);
/*
#define MYBIOSKEY \
switch (key_code) { \
case 0x48e0: \
key_code=UPKEY; \
break; \
case 0x4be0: \
key_code=LEFTKEY; \
break; \
case 0x4de0: \
key_code=RIGHTKEY; \
break; \
case 0x50e0: \
key_code=DOWNKEY; \
break; \
\
case 0x8de0: \
key_code=CTRL_UP; \
break; \
case 0x73e0: \
key_code=CTRL_LEFT; \
break; \
case 0x74e0: \
key_code=CTRL_RIGHT; \
break; \
case 0x91e0: \
key_code=CTRL_DOWN; \
break; \
case SPACEKEY: \
if ( bioskey (0x12) & 0x08 ) \
key_code =ALT_SPACE; \
break; \
case ALT_LEFT: \
if ( bioskey (0x12) & 0x04 ) \
key_code =CTRL_ALT_LEFT; \
break; \
case ALT_RIGHT: \
if ( bioskey (0x12) & 0x04 ) \
key_code =CTRL_ALT_RIGHT; \
break; \
};
*/
#define MYBIOSKEY \
switch (tmp) { \
case 0x53e0: \
tmp=DELKEY; \
break; \
case 0x52e0: \
tmp=INSKEY; \
break; \
case 0x49e0: \
tmp=PGUPKEY; \
break; \
case 0x47e0: \
tmp=HOMEKEY; \
break; \
case 0x4fe0: \
tmp=ENDKEY; \
break; \
case 0x51e0: \
tmp=PGDNKEY; \
break; \
case 0x4be0: \
tmp=LEFTKEY; \
break; \
case 0x4de0: \
tmp=RIGHTKEY; \
break; \
case 0x48e0: \
tmp=UPKEY; \
break; \
case 0x50e0: \
tmp=DOWNKEY; \
break; \
\
case 0x8de0: \
tmp=CTRL_UP; \
break; \
case 0x73e0: \
tmp=CTRL_LEFT; \
break; \
case 0x74e0: \
tmp=CTRL_RIGHT; \
break; \
case 0x91e0: \
tmp=CTRL_DOWN; \
break; \
case SPACEKEY: \
if ( bioskey (0x12) & 0x08 ) \
tmp =ALT_SPACE; \
break; \
case ALT_LEFT: \
if ( bioskey (0x12) & 0x04 ) \
tmp =CTRL_ALT_LEFT; \
break; \
case ALT_RIGHT: \
if ( bioskey (0x12) & 0x04 ) \
tmp =CTRL_ALT_RIGHT; \
break; \
};
void interrupt application_class::key (...)
{ register int tmp;
MSG tmpmsg;
// disable();
(*old_key)(...);
if (!kb_active ){
kb_active =TRUE;
//~//~ (*old_key)(...); // put here may cause CAPSLOCK Unable
//~ switch (bioskey(1)) {
switch (bioskey(0x11)) {
case -1:
thequeue.SendMessage(0,CtrlBreakMSG,NULL );
break;
case 0:break;
default :
//~ key_code=bioskey(0);
// tmp =key_code;
//~ key_code=bioskey(0x10);
tmp=bioskey(0x10);
if (thequeue.QueueFull()) goto Ret;
MYBIOSKEY;
if ( thequeue.first !=thequeue.last ) {
if (( thequeue.msg_array[thequeue.oldfirst].Action
==KeyPressedMSG) && (tmp==key_code))
goto Ret;
}
// if ( thequeue.PeekMessage (tmpmsg) !=FALSE ){
// if ((tmpmsg.Action==KeyPressedMSG) && (tmp==key_code))
// goto Ret;
// }
key_code =tmp;
thequeue.SendMessage(0, KeyPressedMSG,NULL);
}
Ret: kb_active =FALSE;
}
// enable();
}
void interrupt application_class::mouse(...)
{
// disable();
(*old_mouse)(...);
if (!mouse_active ){
mouse_active =TRUE;
if (in_win_moving) {
if (sysmouse->get_release_count(LEFT_BUTTON) >0 ) {
thequeue.SendMessage(pcurrent_selected_win->ID
,WinMovedSizedMSG,pcurrent_selected_win );
in_win_moving =FALSE;
mouse_active =FALSE;
return ;
}
sysmouse->get_posn ();
if ( (abs(old_mouse_x-mouse_x )<10) && (abs(old_mouse_y-mouse_y)<10) ){
mouse_active =FALSE;
return ;
}
thequeue.SendMessage(0,WinMovingSizingMSG,pcurrent_selected_win);
mouse_active =FALSE;
return;
}
if (sysmouse->get_press_count(LEFT_BUTTON) >0 )
thequeue.SendMessage(0,MouseLButtonDownMSG,NULL );
mouse_active =FALSE;
}
// enable();
}
void interrupt application_class::dos_error(...)
{ int i,j;
i=_AX;
j=_DI;
if (dos_error_active ) return ;
dos_error_active =TRUE;
// enable();
if ( i & 0x8000 ); // AH bit7 is set ; means not disk error
else {
switch (j & 0xff ) {
case 0x00:strcpy (msgbuf,"Write Protected");break;
case 0x01:strcpy (msgbuf,"Invalid Drive Number");break;
case 0x02:strcpy (msgbuf,"Drive not ready");break;
default :strcpy (msgbuf,"Drive error");break;
}
diskerrorno = j & 0xff ;
putch('\007');
// To let the owner do next && retry,etc
// if (theprogram->exec_dialog(new Tmsgbox("Message",msgbuf,MB_RETRYCANCEL))
// == Dlg_OK ) _AL=0x01;
// else _AL =0x02;
dos_error_active =FALSE;
// _AL =0x00; cannot be touched by the caller
// asm {
// mov bp,sp
// mov ax,[bp+22]
// mov al,0
// mov [bp+22],ax
// }
return;
}
(*old_dos_error );
dos_error_active =FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -