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

📄 fspxw.asm

📁 汇编编程艺术
💻 ASM
📖 第 1 页 / 共 2 页
字号:
		mov	dx, 900h	;Read the 8 switches.
		mov	ah, 84h
		int	15h

		mov	CurSw, al
		xor	al, LastSw	;See if any changes
		jz	NoChanges
		and	al, CurSw	;See if sw just went down.
		jz	NoChanges


; If a switch has just gone down, output an appropriate set of scan codes
; for it, if that key is active.  Note that pressing *any* key will reset
; all the other key indexes.

		test	al, 1		;See if Sw0 (trigger) was pulled.
		jz	NoSw0
		cmp	Sw0.Pgmd, 0
		je	NoChanges
		mov	ax, 0
		mov	Left.Index, ax	;Reset the key indexes for all keys
		mov	Right.Index, ax	; except SW0.
		mov	Up.Index, ax
		mov	Down.Index, ax
		mov	Sw1.Index, ax
		mov	Sw2.Index, ax
		mov	Sw3.Index, ax
		mov	bx, Sw0.Index
		mov	ax, Sw0.Index
		mov	bx, Sw0.Ptrs[bx]
		add	ax, 2
		cmp	ax, Sw0.Cnt
		jb	SetSw0
		mov	ax, 0
SetSw0:		mov	Sw0.Index, ax
		call	PutStrInBuf
		jmp	NoChanges



NoSw0:		test	al, 2		;See if Sw1 (left sw) was pressed.
		jz	NoSw1
		cmp	Sw1.Pgmd, 0
		je	NoChanges
		mov	ax, 0
		mov	Left.Index, ax	;Reset the key indexes for all keys
		mov	Right.Index, ax	; except Sw1.
		mov	Up.Index, ax
		mov	Down.Index, ax
		mov	Sw0.Index, ax
		mov	Sw2.Index, ax
		mov	Sw3.Index, ax
		mov	bx, Sw1.Index
		mov	ax, Sw1.Index
		mov	bx, Sw1.Ptrs[bx]
		add	ax, 2
		cmp	ax, Sw1.Cnt
		jb	SetSw1
		mov	ax, 0
SetSw1:		mov	Sw1.Index, ax
		call	PutStrInBuf
		jmp	NoChanges


NoSw1:		test	al, 4		;See if Sw2 (middle sw) was pressed.
		jz	NoSw2
		cmp	Sw2.Pgmd, 0
		je	NoChanges
		mov	ax, 0
		mov	Left.Index, ax	;Reset the key indexes for all keys
		mov	Right.Index, ax	; except Sw2.
		mov	Up.Index, ax
		mov	Down.Index, ax
		mov	Sw0.Index, ax
		mov	Sw1.Index, ax
		mov	Sw3.Index, ax
		mov	bx, Sw2.Index
		mov	ax, Sw2.Index
		mov	bx, Sw2.Ptrs[bx]
		add	ax, 2
		cmp	ax, Sw2.Cnt
		jb	SetSw2
		mov	ax, 0
SetSw2:		mov	Sw2.Index, ax
		call	PutStrInBuf
		jmp	NoChanges


NoSw2:		test	al, 8		;See if Sw3 (right sw) was pressed.
		jz	NoSw3
		cmp	Sw3.Pgmd, 0
		je	NoChanges
		mov	ax, 0
		mov	Left.Index, ax	;Reset the key indexes for all keys
		mov	Right.Index, ax	; except Sw3.
		mov	Up.Index, ax
		mov	Down.Index, ax
		mov	Sw0.Index, ax
		mov	Sw1.Index, ax
		mov	Sw2.Index, ax
		mov	bx, Sw3.Index
		mov	ax, Sw3.Index
		mov	bx, Sw3.Ptrs[bx]
		add	ax, 2
		cmp	ax, Sw3.Cnt
		jb	SetSw3
		mov	ax, 0
SetSw3:		mov	Sw3.Index, ax
		call	PutStrInBuf
		jmp	NoChanges


NoSw3:		test	al, 10h		;See if Cooly was pressed upwards.
		jz	NoUp
		cmp	Up.Pgmd, 0
		je	NoChanges
		mov	ax, 0
		mov	Right.Index, ax	;Reset all but Up.
		mov	Left.Index, ax
		mov	Down.Index, ax
		mov	Sw0.Index, ax
		mov	Sw1.Index, ax
		mov	Sw2.Index, ax
		mov	Sw3.Index, ax
		mov	bx, Up.Index
		mov	ax, Up.Index
		mov	bx, Up.Ptrs[bx]
		add	ax, 2
		cmp	ax, Up.Cnt
		jb	SetUp
		mov	ax, 0
SetUp:		mov	Up.Index, ax
		call	PutStrInBuf
		jmp	NoChanges


NoUp:		test	al, 20h		;See if Cooly was pressed to the left.
		jz	NoLeft
		cmp	Left.Pgmd, 0
		je	NoChanges
		mov	ax, 0
		mov	Right.Index, ax	;Reset all but Left.
		mov	Up.Index, ax
		mov	Down.Index, ax
		mov	Sw0.Index, ax
		mov	Sw1.Index, ax
		mov	Sw2.Index, ax
		mov	Sw3.Index, ax
		mov	bx, Left.Index
		mov	ax, Left.Index
		mov	bx, Left.Ptrs[bx]
		add	ax, 2
		cmp	ax, Left.Cnt
		jb	SetLeft
		mov	ax, 0
SetLeft:	mov	Left.Index, ax
		call	PutStrInBuf
		jmp	NoChanges


NoLeft:		test	al, 40h		;See if Cooly was pressed to Right
		jz	NoRight
		cmp	Right.Pgmd, 0
		je	NoChanges
		mov	ax, 0
		mov	Left.Index, ax	;Reset all but Right.
		mov	Up.Index, ax
		mov	Down.Index, ax
		mov	Sw0.Index, ax
		mov	Sw1.Index, ax
		mov	Sw2.Index, ax
		mov	Sw3.Index, ax
		mov	bx, Right.Index
		mov	ax, Right.Index
		mov	bx, Right.Ptrs[bx]
		add	ax, 2
		cmp	ax, Right.Cnt
		jb	SetRight
		mov	ax, 0
SetRight:	mov	Right.Index, ax
		call	PutStrInBuf
		jmp	NoChanges


NoRight:	test	al, 80h		;See if Cooly was pressed Downward.
		jz	NoChanges
		cmp	Down.Pgmd, 0
		je	NoChanges
		mov	ax, 0
		mov	Left.Index, ax	;Reset all but Down.
		mov	Up.Index, ax
		mov	Right.Index, ax
		mov	Sw0.Index, ax
		mov	Sw1.Index, ax
		mov	Sw2.Index, ax
		mov	Sw3.Index, ax
		mov	bx, Down.Index
		mov	ax, Down.Index
		mov	bx, Down.Ptrs[bx]
		add	ax, 2
		cmp	ax, Down.Cnt
		jb	SetDown
		mov	ax, 0
SetDown:	mov	Down.Index, ax
		call	PutStrInBuf

NoChanges:	pop	dx
		pop	bx
		pop	ax
		pop	ds
		jmp	cs:Int1CVect
MyInt1c		endp
		assume	ds:nothing

; PutStrInBuf-  BX points at a zero terminated string of words.
;		Output each word by calling PutInBuffer.

PutStrInBuf	proc	near
		push	ax
		push	bx
PutLoop:	mov	ax, [bx]
		test	ax, ax
		jz	PutDone
		call	PutInBuffer
		add	bx, 2
		jmp	PutLoop

PutDone:	pop	bx
		pop	ax
		ret
PutStrInBuf	endp

; PutInBuffer- Outputs character and scan code in AX to the type ahead
; buffer.

		assume	ds:nothing
KbdHead		equ	word ptr ds:[1ah]
KbdTail		equ	word ptr ds:[1ch]
KbdBuffer	equ	word ptr ds:[1eh]
EndKbd		equ	3eh
Buffer		equ	1eh

PutInBuffer	proc	near
		push	ds
		push	bx
		mov	bx, 40h
		mov	ds, bx
		pushf
		cli				;This is a critical region!
		mov     bx, KbdTail             ;Get ptr to end of type
		inc     bx                      ; ahead buffer and make room
		inc     bx                      ; for this character.
		cmp     bx, buffer+32           ;At physical end of buffer?
		jb      NoWrap
		mov     bx, buffer              ;Wrap back to 1eH if at end.
;
NoWrap:         cmp     bx, KbdHead             ;Buffer overrun?
		je      PIBDone
		xchg    KbdTail, bx             ;Set new, get old, ptrs.
		mov     ds:[bx], ax             ;Output AX to old location.
PIBDone:	popf				;Restore interrupts
		pop	bx
		pop	ds
		ret
PutInBuffer	endp



;****************************************************************************
;
; FindCode: On entry, ES:DI points at some code in *this* program which
;	    appears in the ATP game.  DS:SI points at a block of memory
;	    in the ATP game.  FindCode searches through memory to find the
;	    suspect piece of code and returns DS:SI pointing at the start of
;	    that code.  This code assumes that it *will* find the code!
;	    It returns the carry clear if it finds it, set if it doesn't.

FindCode	proc	near
		push	ax
		push	bx
		push	dx

DoCmp:		mov	dx, 1000h
CmpLoop:  	push	di			;Save ptr to compare code.
		push	si			;Save ptr to start of string.
		push	cx			;Save count.
	repe	cmpsb
		pop	cx
		pop	si
		pop	di
		je	FoundCode
		inc	si
		dec	dx
		jne	CmpLoop
		sub	si, 1000h
		mov	ax, ds
		inc	ah
		mov	ds, ax
		cmp	ax, 9000h
		jb	DoCmp

		pop	dx
		pop	bx
		pop	ax
		stc
		ret

FoundCode:	pop	dx
		pop	bx
		pop	ax
		clc
		ret
FindCode	endp


;****************************************************************************
;
; Joystick and button routines which appear in application code.  This code is
; really data as the INT 21h patch code searches through memory for this code
; after loading a file from disk.



JoyStickCode	proc	near
		sti
		neg	bx
		neg	di
		pop	bp
		pop	dx
		pop	cx
		ret
		mov	bp, bx
		in	al, dx
		mov	bl, al
		not	al
		and	al, ah
		jnz	$+11h
		in	al, dx
JoyStickCode	endp
EndJSC:

JoyLength	=	EndJSC-JoyStickCode

ReadSwCode	proc
		mov	dx, 201h
		in	al, dx
		xor	al, 0ffh
		and	ax, 0f0h
ReadSwCode	endp
EndRSC:

ButtonLength	=	EndRSC-ReadSwCode

cseg		ends


Installation	segment

; Move these things here so they do not consume too much space in the
; resident part of the patch.

DfltFCB		db	3,"           ",0,0,0,0,0
CmdLine		db	2, "  ", 0dh, 126 dup (" ")	;Cmd line for program
Pgm		db	"XWING.EXE",0
		db	128 dup (?)			;For user supplied name


; ChkBIOS15- Checks to see if the INT 15 driver for FSPro is present in memory.

ChkBIOS15	proc	far
		mov	ah, 84h
		mov	dx, 8100h
		int	15h
		mov	di, bx
		strcmpl
		db	"CH Products:Flightstick Pro",0
		jne	NoDriverLoaded
		ret

NoDriverLoaded:	print
		byte	"CH Products SGDI driver for Flightstick Pro is not "
		byte	"loaded into memory.",cr,lf
		byte	"Please run FSPSGDI before running this program."
		byte	cr,lf,0
		exitpgm

ChkBIOS15	endp


;****************************************************************************
;
; Identify-	Prints a sign-on message.

		assume	ds:nothing
Identify	proc	far

; Print a welcome string.  Note that the string "VersionStr" will be
; modified by the "version.exe" program each time you assemble this code.

		print
		db	cr,lf,lf
		byte	"帜哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪

⌨️ 快捷键说明

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