⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 woarlm.asm

📁 Dos6.0
💻 ASM
📖 第 1 页 / 共 5 页
字号:
WoaSwitchOutESP         dd      ?               ;value of esp at switch out time
DosAppPSP               dw      ?               ;PSP of the DOS APP.
DosAppDMA               dd      ?               ;DMA address of dos app
MasterPICMask           db      ?               ;value of 21h (master PIC) port
PreExecSLavePICMask     db      ?               ;the preexec value of the mask
GlobalSlavePICMask      db      ?               ;value of slave PIC for windows
AppSlavePICMask         db      ?               ;value of slave PIC for app
AppUsesIRQ9             db      0               ;app uses IRQ 9 or not.
DosAppDisk              db      ?               ;current disk of dos app
DosPreExecDisk          db      ?               ;windows current disk
DosPreExecCD            db      '\'             ;specify the root
			db      79 dup (?)      ;rest of the name
DosAppCD                db      '\'             ;specify the root
			db      79 dup (?)      ;rest of the name
lpInDosFlag             dd      ?               ;long pointer to InDos flag
lpErrModeFlag           dd      ?               ;long pointer to err mode flag
AsyncNetPending         db      0               ;async net request done or not
PendingTime             dw      0               ;num ticks after switch req set
ActualInt1C             dd      ?               ;previous INT 1C ISR
ActualInt09             dd      ?               ;previous INT 09 ISR
ActualInt0A             dd      ?               ;pre-exec INT 0AH
ActualInt21             dd      ?               ;previous INT 21 ISR
ActualInt15             dd      ?               ;previous INT 15 ISR
ActualInt16             dd      ?               ;previous INT 16 ISR
ActualInt24             dd      ?               ;original INT 24 ISR
ActualInt27             dd      ?               ;original INT 27 ISR
ActualInt2A             dd      ?               ;original INT 2A ISR
ActualInt5C             dd      ?               ;original INT 5C ISR
ActualInt71             dd      ?               ;pre-exec INT 71H ISR
OtherActualInt2f        dd      ?               ;original INT 2f ISR
WoaHotkeyState          db      ?               ;state of hot keys
WoaNodeToSwitchTo       db      ?               ;node # to switch to
lpGlobalSwtchStr        dd      ?               ;pointer to global switch str.
LastScanCode            db      0               ;last scan code read
TsrActive               db      0               ;TSR activated or not
TestWoaInt16InChain     db      0               ;are we in INT 16 chain ?


SwitchInProgress        db      0               ;switch in progress or not

  SIP_SWITCHING         equ     01h             ;actually switching

WOAsInt16               db      0               ;INT 16 call from WOA code
PopRet                  dw      ?               ;variable to pop ret address
lpDosData               dd      ?               ;lptr to DOS data block
ConsoleRawMode          db      0               ;console in raw mode or not.
OriginalInt15MemSize    dw      ?               ;original int 15 memory size
OurInt15OffChain        db      ?               ;can we reach INT 15 isr ?
AppEmsSaveArea          db      256 dup (?)     ;EMS save area
WinIoctlData            db      5 dup (?)       ;win IOCTL data for shrd handles
AppIoctlData            db      5 dup (?)       ;app IOCTL data for shrd handles
WinPrinterPorts         dw      3 dup (?)       ;win printer port addresses
AppPrinterPorts         dw      3 dup (?)       ;app printer port addresses 
DevHeaderChain          db      26 dup (0)      ;device header pointers
GrabberParaSize         dw      ?               ;grabber context para size
PrtScInProgress         db      0               ;print screen in progress or not
TempStack               dw      ?               ;save temp stack segment
lpXmsEntry              dd      ?               ;entry to xms initializer
XMsFlag                 db      0               ;XMS installed or not.
ActualXms               dd      ?               ;HIMEM entry point
DosAllocationStrategy   db      ?               ;allocation strategy for app
DosLinkState            db      ?               ;link state
AppsLogicalNodeNum      db      0               ;node number of app
Woa4BSP                 dw      ?               ;saved value of SP of PSP
Woa4BSS                 dw      ?               ;saved value of SS of PSP

;----------------------------------------------------------------------------;
; reserve space for saving some old app state related variables.             ;
;----------------------------------------------------------------------------;

Buf8087                 db      98 dup (?)      ;8087 state saved here
Speaker                 db      0               ;speaker value,init to 0
ControlCFlag            db      ?               ;state of control c flag

;----------------------------------------------------------------------------;
; Miscellaneous flags.                                                       ;
;----------------------------------------------------------------------------;

MiscFlags               dw      0               ;random flags defined below

	TIMER_HOOKED    equ     1h              ;timer has been hooked.

;----------------------------------------------------------------------------;
; define the HOT KEY related structures and definitions.                     ;
;----------------------------------------------------------------------------;


MAX_FIXED_HOT_KEYS      equ     5               ;no of predefined hot keys.

		EVEN
ScanCodeTable   label word

		db      0fh             ;scan code for TAB (ALT-TAB)
		db      00001000b       ;shift state for ALT
		db      01h             ;scan code for ESC (ALT-ESC)
		db      00001000b       ;shift state for ALT
		db      01h             ;scan code for ESC (CTRL-ESC)
		db      00000100b       ;shift state for CTRL
		db      0fh             ;scan code for TAB (SHIFT-ALT-TAB)
		db      00001011b       ;shift state for ALT+SHIFT
		db      01h             ;scan code for ESC (SHIFT-ALT-ESC)
		db      00001011b       ;shift state for ALT+SHIFT

; now have the app specific scan code table

AppsScanCodeTable  db   MAX_NUM_PROGRAMS * SIZE ScanCodeStruc dup (0)

		EVEN

HotKeyInfoTable label byte

 WoaAltTabDisabled      db      0               ;ALT+TAB not disabled
			db      0               ;the extra scan code (none)
			db      WOA_ALT_TAB     ;type of switch.
			db      -1              ;logical node number

  WoaAltEscDisabled     db      0               ;ALT+ESC not disabled
			db      0               ;the extra scan code (none)
			db      WOA_ALT_ESC     ;type of switch.
			db      -1              ;logical node number

  WoaCtrlEscDisabled    db      0               ;ALT+ESC not disabled
			db      0               ;the extra scan code (none)
			db      WOA_CTRL_ESC    ;type of switch.
			db      -1              ;logical node number

  WoaShftALtTabDisabled db      0               ;SHIFT+ALT+TAB not disabled
			db      0               ;the extra scan code (none)
			db      WOA_SHIFT_ALT_TAB;type of switch.
			db      -1              ;logical node number

  WoaShftAltEscDisabled db      0               ;ALT+ESC not disabled
			db      0               ;the extra scan code (none)
			db      WOA_SHIFT_ALT_ESC;type of switch.
			db      -1              ;logical node number

; now have the app specific hot key info table

AppsHotKeyInfoTable  db MAX_NUM_PROGRAMS * SIZE HotKeyInfoStruc dup (0)

;----------------------------------------------------------------------------;
; define a 400 byte of stack frame for the real mode stack which will be     ;
; used while switching out                                                   ;
;----------------------------------------------------------------------------;

			db      400 dup (99h)   ;switch out stack

WoaSwitchOutStackTop    dw      99h             ;the top of temp stack

;----------------------------------------------------------------------------;
; define another 128 byte stack on which we will do the EXEC call to start the
; app. Some INT 21H handler may trap the 4BH call and chain down by calling  ;
; the previous handler. In this case they would have valid data on the stack ;
; that would be needed when the app exits.                                   ;
;----------------------------------------------------------------------------;

			db      128 dup (55h)   ;exec stack

WoaExecStackTop         dw      55h             ;top of exec time stack

;----------------------------------------------------------------------------;

WoaAppsSS               dw      ?               ;app's SS
WoaAppsSP               dw      ?               ;app's SP
WoaAppsESP              dd      ?               ;app's ESP

;----------------------------------------------------------------------------;
; define external constants.                                                 ;
;----------------------------------------------------------------------------;

externA PromptStringLength                      ;(WOAMSG2.INC,WOATSR.ASM)

;----------------------------------------------------------------------------;
; define equates for some hardware ports.                                    ;
;----------------------------------------------------------------------------;

timer0                  equ     40H             ;Timer port 0
SpeakerCtl              equ     61H             ; Speaker port
CoProcPort              equ    0F0H             ; 8087/80287 ports
mskreg                  equ     21H             ; IRQ int mask register
BEEP_ON                 equ     03h             ; beeping...

;----------------------------------------------------------------------------;
; define other needed constants.                                             ;
;----------------------------------------------------------------------------;

TIMEOUT_TICK_COUNT      equ     18*2+1          ;2 seconds timeout value


IS_WINOLDAP_ACTIVE      equ     4680h           ;woa's INT 2f hook
WIN_P_START_UP          equ     1605h           ;PMODE Windows start up
WIN_P_EXIT              equ     1606h           ;PMODE Windows exits
WOA_MIN_FILEHANDLES     equ     2               ;min free handles for WOA

; Define IBM PC port locations for the Intel 8243 Programmable Interval Timer
; chip

PIT_PORTA       =       040h
PIT_PORTB       =       041h
PIT_PORTC       =       042h
PIT_PORTD       =       043h

; Define IBM PC port locations for the Intel 8255 Programmable Peripheral
; Interface chip

PPI_PORTA       =       060h
PPI_PORTB       =       061h
PPI_PORTC       =       062h
PPI_PORTD       =       063h

; Define timimgs and divisors to make sounds via the PIT, PPI chips and the
; PC's speaker circuitry.

BEEP_TIME1      =       02400h
BEEP_TIME2      =       03400h
BEEP_TONE1      =       00533h
BEEP_TONE2      =       00633h


WF_CPU086088    =    0000h
WF_CPU186       =    0001h
WF_CPU286       =    0002h
WF_CPU386       =    0004h
WF_CPU486ORABV  =    0008h

;----------------------------------------------------------------------------;
; we need to save about 50 bytes from 0:4f0 for comm related stuff. Also,    ;
; Basic uses some of these areas to save some stuff, but then we will not be ;
; able to switch out from basic any way.                                     ;
;----------------------------------------------------------------------------;

CommSaveArea            db      50 dup (?)

;----------------------------------------------------------------------------;
; define the dispatch table for the INT 21 calls that we trap.               ;
;----------------------------------------------------------------------------;

DosTraps        label byte

		db      01h             ;conin with echo
		dw      DosFuncGetKey   ;routine which handles it
		db      07h             ;unfiltered input with echo
		dw      DosFuncGetKey   ;routine which handles it
		db      08h             ;conin without echo
		dw      DosFuncGetKey   ;routine which handles it
		db      0ah             ;buffered-keyboard-input
		dw      DosFunc0A       ;routine which handles that
		db      0ch             ;flush buffer, read keyboard
		dw      DosFunc0C       ;routine which handles it
		db      31h             ;terminate and stay resident
		dw      DosFunc31       ;routine which handles it
		db      3fh             ;read file or device
		dw      DosFunc3f       ;routine which handles it
		db      44h             ;IOCTL function
		dw      DosFunc44       ;routine which handles it
DosDefaultCode  db      ?               ;put AH here on entry to trap default
		dw      DosDefaultFunc  ;pass on to original handler
			
;----------------------------------------------------------------------------;

RealModeWoa proc far

	smov    ds,cs                   ;set up proper data segment

;----------------------------------------------------------------------------;
; save the current values of stack segment and stack pointer so that we can  ;
; return back to protected mode from one of the interrupt handlers in case of;
; a context switch.                                                          ;
;----------------------------------------------------------------------------;

	mov     WoaRlmEntrySS,ss        ;save stack segment
	mov     WoaRlmEntrySP,sp        ;save stack pointer

;----------------------------------------------------------------------------;
; Get the amount of extende memory available via the INT 15 call             ;
;----------------------------------------------------------------------------;

	mov     ah,88h                  ;get extended memory size call ?
	int     15h                     ;ax returns the available size
	mov     OriginalInt15MemSize,ax ;save it.

;----------------------------------------------------------------------------;
; First try to load in grabber and initialize it also reserving and marking  ;
; the loaction of the buffer needed for saving the screen.                   ;
;----------------------------------------------------------------------------;

	cCall   LoadGrabberAndInit      ;load and initialize grabber
	jnc     @f                      ;loading went off smoothly

; the grabber load has failed. Retuen back to real mode with proper error
; code.

	mov     ah,ER_GRABBER_LOAD      ;grabber load failure
	stc                             ;error indication
	ret                             ;go back to protected mode

@@:

; get and save a pointer to the global switch structure.

	mov     ax,4a05h                ;INT 2F code for the shell interface
	mov     si,CGET_GLOBAL_SWITCH_DATA
	int     2fh                     ;dx:ax has the long pointer
	mov     wptr [lpGlobalSwtchStr],ax;save offset
	mov     wptr [lpGlobalSwtchStr+2],dx;save segment

; prepare the table of hotkey information.

	call    PrepareAppHotKeyList

;----------------------------------------------------------------------------;
; We will now shrink the block size to just hold the stubs.                  ;
;                                                                            ;
; Also we must mark this block as the last dos block, so that dos does not   ;
; allocate any memory past the end of the block.                             ;
;----------------------------------------------------------------------------;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -