;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;;    GLOBALS
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;    GLOBAL CONSTANT EQUATES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ifdef PROM
PROM_STACKSEG	equ 01000h		; PROM USE ONLY: ram segment for stack
PROM_DATASEG	equ 02000h		; PROM USE ONLY: segment for data
SCRBUF_LINES	equ 24d*16		; PROM: 16 pages of screen buffer
else
SCRBUF_LINES	equ 24d*4		; TESTING: 4 pages of screen buffer
endif

SCRBUF_SIZE	equ SCRBUF_LINES*80d*2	; #bytes in scroll buffer
COMBUF_SIZE	equ 01000h		; #bytes for comrings
ESCBUF_SIZE	equ 40d			; escape sequence buffer size
TABSTOP_SIZE	equ 132d		; # tab stop positions


;;; VIDEO EQUATES (vidflags)
NO_WRAP		equ 0001h		; 'no auto wrap' flag
NO_FLASH	equ 0002h		; 'no flash' (use bell) NOT USED YET
HEX_DEBUG	equ 0004h		; 'hex debug' mode
RELATIVE_MODE	equ 0008h		; 'relative cursor positioning' mode
CLEAR_SCRN_WORD	equ 0720h		; word used for clearing screen


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;    GLOBAL MACROS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; GENERIC RING BUFFER ADVANCE INDEX
;	index and end are variables names, start is a buffer name
;	all registers preserved.
;
RING_ADVANCE macro index,end,start
	local nope
	push ax
	mov ax,[index]
	add ax,1
	cmp ax,[end]
	jl nope
	mov ax,offset start
nope:	mov [ds:index],ax
	pop ax
	endm

; JUMP IF TRUE
;	(for use in context with TEST ops)
;
jt	macro addr
	jnz addr
	endm

; JUMP IF FALSE
;	(for use in context with TEST ops)
jf	macro addr
	jz addr
	endm

; HACK FOR DEBUGGING
WAITKEY	macro
	local wait1,wait2
wait1:	in al,60h
	cmp al,1
	jne wait1
wait2:	in al,60h
	cmp al,1
	je wait2
	endm