Archival snapshot of the Virtual World Entertainment Tesla cockpit software, 1994-1996: MUNGA engine and L4 pod layer source (Borland C++ 5.0), BT/RP game code, and game content (models, audio, maps, gauges, Division renderer data). Includes third-party libraries: Division dVS/DPL graphics, HMI SOS audio, WATTCP networking. Files are preserved byte-for-byte (.gitattributes disables all line-ending conversion). README.md documents the layout, target hardware, and toolchain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
148 lines
5.7 KiB
NASM
148 lines
5.7 KiB
NASM
.list
|
|
;===========================================================================
|
|
; File: PCjoystk.asm
|
|
; Project: MUNGA
|
|
; Contents: PC joystick interface
|
|
;---------------------------------------------------------------------------
|
|
; Date Who Modification
|
|
; -------- --- -----------------------------------------------------------
|
|
; ??/??/?? JMA Initial coding
|
|
; 12/01/95 CPB Made pretty, expanded to four analog inputs (2 sticks).
|
|
; 01/20/95 CPB Added PC_Joystick_Mask
|
|
;---------------------------------------------------------------------------
|
|
; Copyright (C) 1995, Virtual World Entertainment, Inc. All rights reserved
|
|
; PROPRIETARY and CONFIDENTIAL
|
|
;===========================================================================
|
|
include l4asm.inc
|
|
include pcdpmi.inc
|
|
|
|
;===========================================================================
|
|
; Equates
|
|
;===========================================================================
|
|
|
|
JOYPORT EQU 0201h
|
|
XBIT1 EQU 00000001b
|
|
YBIT1 EQU 00000010b
|
|
XBIT2 EQU 00000100b
|
|
YBIT2 EQU 00001000b
|
|
BTTNA1 EQU 00010000b
|
|
BTTNB1 EQU 00100000b
|
|
BTTNA2 EQU 01000000b
|
|
BTTNB2 EQU 10000000b
|
|
|
|
ANALOGBITS EQU XBIT1+YBIT1+XBIT2+YBIT2
|
|
BUTTONBITS EQU BTTNA1+BTTNB1+BTTNA2+BTTNB2
|
|
|
|
;===========================================================================
|
|
; Data segment
|
|
;===========================================================================
|
|
BEGIN_DATA
|
|
|
|
PUBLIC PC_Joystick1_Raw_X,PC_Joystick1_Raw_Y
|
|
PUBLIC PC_Joystick2_Raw_X,PC_Joystick2_Raw_Y
|
|
PUBLIC PC_Joystick_Mask,PC_Joystick_Buttons
|
|
PC_Joystick1_Raw_X dw 0
|
|
PC_Joystick1_Raw_Y dw 0
|
|
PC_Joystick2_Raw_X dw 0
|
|
PC_Joystick2_Raw_Y dw 0
|
|
PC_Joystick_Mask db ANALOGBITS
|
|
PC_Joystick_Buttons db 0
|
|
|
|
END_DATA
|
|
|
|
;===========================================================================
|
|
; Code segment
|
|
;===========================================================================
|
|
BEGIN_CODE
|
|
|
|
;-------------------------------------------------------------------------
|
|
; PC_Joystick_Poll(void)
|
|
; Reads joystick values, places values into public memory locations
|
|
;-------------------------------------------------------------------------
|
|
; Enter:
|
|
; (void)
|
|
;-------------------------------------------------------------------------
|
|
; Returns:
|
|
; (void)
|
|
;-------------------------------------------------------------------------
|
|
BEGIN_C_PROC PC_Joystick_Update <eax,ebx,ecx,edx>
|
|
|
|
BUILD_STACK_FRAME
|
|
|
|
;--------------------------------------------------------------
|
|
; Disable interrupts, saving the old state of interrupts
|
|
;--------------------------------------------------------------
|
|
DPMI_DISABLE_SAVE_INT ;pushes ax!
|
|
;--------------------------------------------------------------
|
|
; Set up for timing loop
|
|
;--------------------------------------------------------------
|
|
mov dx,JOYPORT
|
|
xor cx,cx
|
|
;--------------------------------------------------------------
|
|
; Clear the port and start reading
|
|
;--------------------------------------------------------------
|
|
mov ah,PC_Joystick_Mask ;load AH with all bits set, clear al
|
|
xor al,al
|
|
out dx,al ;trigger the timers
|
|
|
|
check_again:
|
|
;--------------------------------------------------------------
|
|
; Read the port, check for changes
|
|
;--------------------------------------------------------------
|
|
in al,dx ;read the status bits
|
|
and al,PC_Joystick_Mask ;remove non-analog bits
|
|
|
|
xor al,ah ;check for a change
|
|
jz short no_change ;no change, hang out
|
|
;--------------------------------------------------------------
|
|
; See what changed
|
|
;--------------------------------------------------------------
|
|
test al,XBIT1
|
|
jz short no_x1_change
|
|
mov PC_Joystick1_Raw_X,cx
|
|
no_x1_change:
|
|
test al,YBIT1
|
|
jz short no_y1_change
|
|
mov PC_Joystick1_Raw_Y,cx
|
|
no_y1_change:
|
|
test al,XBIT2
|
|
jz short no_x2_change
|
|
mov PC_Joystick2_Raw_X,cx
|
|
no_x2_change:
|
|
test al,YBIT2
|
|
jz short no_y2_change
|
|
mov PC_Joystick2_Raw_Y,cx
|
|
no_y2_change:
|
|
;--------------------------------------------------------------
|
|
; See if we have read all the bits
|
|
;--------------------------------------------------------------
|
|
xor ah,al
|
|
jz short read_done
|
|
;--------------------------------------------------------------
|
|
; Increment the count and check again
|
|
;--------------------------------------------------------------
|
|
no_change:
|
|
inc cx
|
|
cmp cx,2048 ;arbitrary limit
|
|
jnz check_again
|
|
;--------------------------------------------------------------
|
|
; All done with analog values. Re-enable interrupts
|
|
;--------------------------------------------------------------
|
|
read_done:
|
|
DPMI_RESTORE_PREV_INT ;pops ax!
|
|
;--------------------------------------------------------------
|
|
; Read the buttons
|
|
;--------------------------------------------------------------
|
|
in al,dx ;read the status bits
|
|
not al ;invert the bits (so 1=closed)
|
|
and al,BUTTONBITS ;remove extraneous bits
|
|
mov PC_Joystick_Buttons,al ;save the result
|
|
;--------------------------------------------------------------
|
|
; Return
|
|
;--------------------------------------------------------------
|
|
END_C_PROC
|
|
|
|
END_CODE
|
|
|
|
END
|