Category : Assembly Language Source Code
Archive   : D86BIOS4.ZIP
Filename : ZBIOS2.8

 
Output of file : ZBIOS2.8 contained in archive : D86BIOS4.ZIP
;---------------------------
; ZENITH Z-100 INTERFACE
;---------------------------

; BIOS interface routines for the Zenith Z-100 series. Thanks to Patrick
; Swayne for writing much of this interface.

Z100_KEYS: ; Key definition for Zenith Z-100
DB 095 ; Key code for Help key
DB 096-FUNC ; F1 code is 097 (use instead of F1)

L1:
DB 0A6 ; Down Arrow key
DB 0A2 ; Next Screen key (F12)
DB 0A5 ; Up Arrow key
DB 0A1 ; Prev Screen key (F11)
DB 0A9 ; Find key (Home)
DB 0DD ; Select key (Shift-F7)
DB 0A0 ; F10 ==> Print Screen key (Alt-F9)
N_CONTROL_KEYS EQU $-L1

DW HELP_HELP ; Pointer to "HELP" message

L2:
DW Z100_COPY ; VID_COPY routine
DW Z100_ATTR ; VID_ATTR routine
DW RET ; VID_FIX routine
DW Z100_BELL ; BIOS_BELL routine
DW Z100_KEY ; BIOS_KEY routine
DW RET ; BIOS_SAVE routine
DW RET ; BIOS_RESTORE routine
DW 0E000 ; VIDEO_SEG
Z100_NV_ATTR DB 07 ; Normal-video attribute
Z100_RV_ATTR DB 070 ; Reverse-video attribute
N_BIOS_CALLS EQU ($-L2)/2


; LOCAL DATA CELLS

CUR_ADR DW 0291 ; Z-100 CURSOR ADDRESS
ROM_SEG DW 0 ; Z-100 ROM DATA SEGMENT


Z100_INIT: ; initial Z100 console sequence
DB 27,'m'
Z100_SET_ATTR DB '70' ; ** default normal colors
DB 27,'E' ; clear screen
DB 27,'y?' ; set keyboard to 8-bit mode
DB 27,'Y7 ' ; ** put cursor at the 24th line
DB 0FF ; terminator

Z100_REV_VID:
DB 27,'m'
RV_TEXT DB '07' ; string to set reverse video
DB 0FF ; terminator

Z100_NOR_VID:
DB 27,'m'
NV_TEXT DB '70' ; string to set normal video
DB 0FF ; terminator


; Z100_CONFIG is the BIOS initialization routine for the Zenith Z100

Z100_CONFIG:
SS DEC B[LAST_LINE+1] ; 24-line screen: move D86 command line up
MOV SI,Z100_KEYS ; point to Z100's table of keycodes
CALL NEW_KEYS ; plug these values into D86
L1: ; loop here to wait until keyboard is ready to receive
IN AL,0F5 ; fetch the keyboard status byte
TEST AL,2 ; is the keyboard ready to receive?
JNZ L1 ; loop if not
MOV AL,0B ; load NORMAL KEY MODE control code
OUT 0F5,AL ; output the code to the keyboard
SUB AX,AX ; load zero
MOV ES,AX ; point ES to interrupt vector
ES MOV AX,W[03FE] ; fetch the high word of INT 255
MOV ROM_SEG,AX ; this word is the MONITOR DATA segment of the Z100
MOV ES,AX ; point to the data segment
ES MOV AL,B[5] ; get ROM version
AND AL,0F0 ; isolate major version no.
CMP AL,010 ; is this version 1?
IF E MOV W CUR_ADR,028F ; if so then fix cursor address
MOV AL,Z100_NV_ATTR ; get Z-100 normal video attributes
CALL CONASC ; convert to ASCII
MOV W Z100_SET_ATTR,AX ; set up init string
MOV W NV_TEXT,AX ; set up Z100_ATTR string, also
MOV AL,Z100_RV_ATTR ; get Z-100 reverse video attributes
CALL CONASC ; make it ASCII
MOV W RV_TEXT,AX ; set up Z100_ATTR string
MOV SI,Z100_INIT ; load initialization sequence
JMP SHORT Z100_STRING ; output the initialization sequence


; Z100_STRING outputs the SI-pointed, 0FF-terminated string to the Z100
; console.

L1: ; loop here to output each byte of the sequence
CALL Z100_CONOUT ; output AL to the Z100 console
Z100_STRING:
CS LODSB ; fetch the next byte
CMP AL,0FF
JNE L1 ; loop until done
RET


; CONASC converts the nibbles of AL into ASCII digits AH and AL.

CONASC:
MOV AH,AL ; copy to AH
AND AL,7 ; isolate foreground
MOV CL,4 ; shift count 4 for divide-by-16
SHR AH,CL ; move background down
OR AX,'00' ; make result ASCII
RET


; Z100_KEY is the Zenith Z100 version of the BIOS_KEY routine.

Z100_KEY:
CALL 040:6 ; wait for a key
RET


Z100_BELL: ; ring the bell on a Zenith Z100
MOV AL,7 ; code 7 is BELL
Z100_CONOUT:
PUSH BX,CX,DX,SI,DI,ES ; preserve registers across call
CLD ; must be cleared!
CALL 0FE01:019 ; write character to screen
POP ES,DI,SI,DX,CX,BX ; restore clobbered registers
RET


; Z100_COPY is the Zenith Z100 version of BIOS_COPY routine

Z100_COPY:
PUSH AX,BX,ES ; preserve registers across call
CALL Z100_ROWCOL ; get row and column
ADD DI,CX
ADD DI,CX ; point past "memory"
PUSH DI ; save pointer
PUSH CX,SI,DS ; save registers while we read the actual bytes
MOV ES,DS ; we will output the bytes to our source buffer
LEA DI,[SI+80] ; point DI to the actual-bytes area
IN AL,0D8 ; read video port
MOV AH,AL ; save value
MOV AL,078 ; load value that will enable the video memory
OUT 0D8,AL ; enable video RAM
MOV DS,BX,0E000 ; point to video memory
MOV BX,DX ; fetch the row and column
SHL BH,1 ; multiply row by 8 to get the base address
SHL BH,1
SHL BH,1
LEA SI,[BX+0480] ; fetch the character
L7: ; loop here to read each character from the BIOS
LODSB ; fetch the character from the BIOS-maintained buffer
ADD AL,' ' ; convert the character to ASCII
STOSB ; output the ASCII character to our buffer
LOOP L7 ; loop to read another character
MOV AL,AH ; get video port value
OUT 0D8,AL ; restore it
POP DS,SI,CX ; restore source and count pointers
CS LES DI,D[CUR_ADR] ; get cursor address
ES PUSH [DI] ; save the user's cursor position
L1:
ES MOV [DI],DX ; set cursor
LODSB ; get the new character
CMP AL,[SI+79] ; is this character already on the screen?
IF NE CALL Z100_CONOUT; if not then output it
INC DL ; increment column
LOOP L1 ; loop until done
POP AX ; get user's cursor
INC AL ; go to next column
ES MOV [DI],AX ; restore cursor
MOV AL,8 ; load backspace
CALL Z100_CONOUT ; fix cursor by backspacing back to the position
POP DI,ES,BX,AX ; restore clobbered registers
RET


; Z100_ATTR copies the single attribute AL to screen at ES:DI

Z100_ATTR:
PUSH AX ; save attribute
CS CMP AL,Z100_RV_ATTR ; are we setting reverse video?
PUSHF ; save falgs setting tellling if we are
CALL Z100_ROWCOL ; get cursor position in memory
POPF ; restore flags telling if it is reverse video
JNZ >L6 ; skip if not: we will remain with a normal attribute
MOV SI,Z100_REV_VID ; it is reverse: point to reverse-attribute string
CALL Z100_STRING ; output the sequence, converting to reverse
L6:
CS LES DI,D[CUR_ADR] ; get cursor address
ES MOV CX,[DI] ; get users's cursor position
ES MOV [DI],DX ; set to character to fix
CALL Z100_GETCH ; get character there
CALL Z100_CONOUT ; send with new attribute
ES MOV [DI],CX ; restore old cursor
MOV SI,Z100_NOR_VID ; point to normal attribute string
CALL Z100_STRING ; restore normal attribute
POP AX ; restore clobbered register
RET


; Z100_ROWCOL converts the address in DI to the Z-100 row and column in DX.

Z100_ROWCOL:
MOV AX,DI ; pointer to AX
SHR AX,1 ; AX = byte position
SUB DX,DX ; form dword accumulator
PUSH BX ; preserve register across call
MOV BX,80 ; 80 characters/line
DIV BX ; get row and column
POP BX ; restore clobbered register
MOV DH,AL ; DX = row and column
RET


; Z100_GETCH sets AL to the screen character at cursor position DX. We
; directly access the video memory maintained by the Z100 BIOS.

Z100_GETCH:
PUSH BX,CX,DS ; save registers across call
IN AL,0D8 ; read video port
MOV CH,AL ; save value
MOV AL,078 ; load value that enables video RAM
OUT 0D8,AL ; enable video RAM
MOV DS,AX,0E000 ; point to video memory
MOV BX,DX ; fetch the row and column
SHL BH,CL,3 ; multiply row by 8 to get the base address
MOV BL,[BX+0480] ; fetch the character
MOV AL,CH ; get video port value
OUT 0D8,AL ; restore it
MOV AL,BL ; move character to AL
ADD AL,' ' ; make character ASCII
POP DS,CX,BX ; restore clobbered registers
RET


  3 Responses to “Category : Assembly Language Source Code
Archive   : D86BIOS4.ZIP
Filename : ZBIOS2.8

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/