; --------------------------------------- ;
; EQUIP.ASM                               ;
;                                         ;
; Version 1.0                             ;
;                                         ;
; IC v2.0+ Installable Command            ;
;                                         ;
; Display equipment settings.             ;
;                                         ;
; Copyright (C) 1992, Geoff Friesen B.Sc. ;
; All rights reserved.                    ;
;                                         ;
; Developed with: Borland TASM 2.5        ;
; --------------------------------------- ;

_TEXT           SEGMENT BYTE PUBLIC 'CODE'
		ASSUME  cs:_TEXT, ds:_TEXT, es:_TEXT, ss:_TEXT
		ORG     100h

CR              EQU     13
LF              EQU     10

CLINE		EQU	10ah
HEXW		EQU	10ch
STDINIT		EQU	10eh

_equip:
		lea     dx, msg
		mov     ah, 9
		int     21h
		int     20h

msg             DB      "NONCOM$"

code_entry      DW      _code
help_entry      DW      _help
byline_entry    DW      _byline
setup_entry     DW      _setup
cleanup_entry   DW      _cleanup

msg1		DB	CR, LF
		DB	"syntax: EQUIP"
		DB	CR, LF
		DB	'$'

msg2		DB	CR, LF
		DB	"Equipment List:"
		DB	CR, LF
		DB	CR, LF
		DB	"Number of parallel ports: "
_pcount		DB	?
		DB	CR, LF
		DB	"Game Port: "
_gport		DB	?
		DB	CR, LF
		DB	"Number of serial ports: "
_scount		DB	?
		DB	CR, LF
		DB	"Number of floppy disk drives: "
_pddcount	DB	?
		DB	CR, LF
		DB	"Math coprocessor: "
_coproc		DB	?
		DB	CR, LF
		DB	"Boot from floppy disk drive: "
_boot		DB	?
		DB	CR, LF
		DB	"Active video adaptor: "
		DB	'$'

msg3		DB	"unused"
		DB	CR, LF
		DB	'$'

msg4		DB	"40x25 color"
		DB	CR, LF
		DB	'$'

msg5		DB	"80x25 color"
		DB	CR, LF
		DB	'$'

msg6		DB	"80x25 mono"
		DB	CR, LF
		DB	'$'

_code		PROC	NEAR
		push	cs
		pop	ds

		call	ds:[STDINIT]	; Initialize.

		cmp	al, CR		; Argument specified?
		jz	_code0		; No, branch.

		lea	dx, msg1	; Display error message.
		mov	ah, 9
		int	21h

		ret
_code0:
		int	11h		; Get equipment settings bits.

		push	ax

		and	ax, 1100000000000000B
		mov	cl, 14
		shr	ax, cl
		or	al, '0'
		mov	_pcount, al

		pop	ax
		push	ax

		mov	al, 'Y'
		test	ah, 00010000B
		jnz	_code1
		mov	al, 'N'
_code1:
		mov	_gport, al

		pop	ax
		push	ax

		and	ax, 0000111000000000B
		mov	cl, 9
		shr	ax, cl
		or	al, '0'
		mov	_scount, al

		pop	ax
		push	ax

		and	ax, 0000000011000000B
		mov	cl, 6
		shr	ax, cl
		inc	ax
		or	al, '0'
		mov	_pddcount, al

		pop	ax
		push	ax

		mov	ah, 'Y'
		test	al, 2
		jnz	_code2
		mov	ah, 'N'
_code2:
		mov	_coproc, ah

		pop	ax
		push	ax

		mov	ah, 'Y'
		test	al, 1
		jnz	_code3
		mov	ah, 'N'
_code3:
		mov	_boot, ah

		lea	dx, msg2	; Display equipment settings.
		mov	ah, 9
		int	21h

		pop	ax

		and	ax, 0000000000110000B ; Handle video last.

		lea	dx, msg3
		cmp	al, 0
		jz	_code4

		lea	dx, msg4
		cmp	al, 16
		jz	_code4

		lea	dx, msg5
		cmp	al, 32
		jz	_code4

		lea	dx, msg6
_code4:
		mov	ah, 9
		int	21h

		ret
_code		ENDP

_help		DB	CR, LF
		DB	"EQUIP: display equipment settings"
		DB	CR, LF
		DB	CR, LF
		DB	"Syntax: EQUIP"
		DB	CR, LF
		DB	CR, LF
		DB	"The EQUIP command examines the BIOS to determine"
		DB	CR, LF
		DB	"the equipment state of the computer.  The infor-"
		DB	CR, LF
		DB	"mation regarding the game port state is not rel-"
		DB	CR, LF
		DB	"evant to AT, 386, or 486 computers.  Y indicates"
		DB	CR, LF
		DB	"YES and N indicates NO."
		DB	CR, LF
		DB	'$'

_byline         DB      "EQUIP    - display equipment settings"
		DB      CR, LF
		DB      '$'

smsg		DB	CR, LF
		DB	"equip: setting up"
		DB	CR, LF
		DB	'$'

_setup          PROC    NEAR
		lea	dx, smsg
		mov	ah, 9
		int	21h

		ret
_setup          ENDP

cmsg		DB	CR, LF
		DB	"equip: cleaning up"
		DB	CR, LF
		DB	'$'

_cleanup        PROC    NEAR
		lea	dx, cmsg
		mov	ah, 9
		int	21h

		ret
_cleanup        ENDP

_TEXT		ENDS
		END	_equip