home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / d86bios4.zip / ZBIOS2.8 < prev   
Text File  |  1988-07-11  |  8KB  |  239 lines

  1. ;---------------------------
  2. ;  ZENITH Z-100 INTERFACE
  3. ;---------------------------
  4.  
  5. ; BIOS interface routines for the Zenith Z-100 series.    Thanks to Patrick
  6. ;   Swayne for writing much of this interface.
  7.  
  8. Z100_KEYS:        ; Key definition for Zenith Z-100
  9.   DB 095        ; Key code for Help key
  10.   DB 096-FUNC        ; F1 code is 097 (use instead of F1)
  11.  
  12. L1:
  13.   DB 0A6        ; Down Arrow key
  14.   DB 0A2        ; Next Screen key (F12)
  15.   DB 0A5        ; Up Arrow key
  16.   DB 0A1        ; Prev Screen key (F11)
  17.   DB 0A9        ; Find key (Home)
  18.   DB 0DD        ; Select key (Shift-F7)
  19.   DB 0A0        ; F10 ==> Print Screen key (Alt-F9)
  20.   N_CONTROL_KEYS EQU $-L1
  21.  
  22.   DW HELP_HELP          ; Pointer to "HELP" message
  23.  
  24. L2:
  25.   DW Z100_COPY        ; VID_COPY routine
  26.   DW Z100_ATTR        ; VID_ATTR routine
  27.   DW RET        ; VID_FIX routine
  28.   DW Z100_BELL        ; BIOS_BELL routine
  29.   DW Z100_KEY        ; BIOS_KEY routine
  30.   DW RET        ; BIOS_SAVE routine
  31.   DW RET        ; BIOS_RESTORE routine
  32.   DW 0E000        ; VIDEO_SEG
  33.   Z100_NV_ATTR DB 07    ; Normal-video attribute
  34.   Z100_RV_ATTR DB 070    ; Reverse-video attribute
  35.   N_BIOS_CALLS EQU ($-L2)/2
  36.  
  37.  
  38. ; LOCAL DATA CELLS
  39.  
  40.   CUR_ADR DW 0291    ; Z-100 CURSOR ADDRESS
  41.   ROM_SEG DW 0        ; Z-100 ROM DATA SEGMENT
  42.  
  43.  
  44. Z100_INIT:          ; initial Z100 console sequence
  45.   DB 27,'m'
  46. Z100_SET_ATTR DB '70'   ; ** default normal colors
  47.   DB 27,'E'               ; clear screen
  48.   DB 27,'y?'              ; set keyboard to 8-bit mode
  49.   DB 27,'Y7 '             ; ** put cursor at the 24th line
  50.   DB 0FF          ; terminator
  51.  
  52. Z100_REV_VID:
  53.   DB 27,'m'
  54. RV_TEXT DB '07'         ; string to set reverse video
  55.   DB 0FF        ; terminator
  56.  
  57. Z100_NOR_VID:
  58.   DB 27,'m'
  59. NV_TEXT DB '70'         ; string to set normal video
  60.   DB 0FF        ; terminator
  61.  
  62.  
  63. ; Z100_CONFIG is the BIOS initialization routine for the Zenith Z100
  64.  
  65. Z100_CONFIG:
  66.   SS DEC B[LAST_LINE+1]   ; 24-line screen: move D86 command line up
  67.   MOV SI,Z100_KEYS        ; point to Z100's table of keycodes
  68.   CALL NEW_KEYS       ; plug these values into D86
  69. L1:              ; loop here to wait until keyboard is ready to receive
  70.   IN AL,0F5          ; fetch the keyboard status byte
  71.   TEST AL,2          ; is the keyboard ready to receive?
  72.   JNZ L1          ; loop if not
  73.   MOV AL,0B          ; load NORMAL KEY MODE control code
  74.   OUT 0F5,AL          ; output the code to the keyboard
  75.   SUB AX,AX          ; load zero
  76.   MOV ES,AX          ; point ES to interrupt vector
  77.   ES MOV AX,W[03FE]      ; fetch the high word of INT 255
  78.   MOV ROM_SEG,AX      ; this word is the MONITOR DATA segment of the Z100
  79.   MOV ES,AX          ; point to the data segment
  80.   ES MOV AL,B[5]      ; get ROM version
  81.   AND AL,0F0          ; isolate major version no.
  82.   CMP AL,010          ; is this version 1?
  83.   IF E MOV W CUR_ADR,028F ; if so then fix cursor address
  84.   MOV AL,Z100_NV_ATTR      ; get Z-100 normal video attributes
  85.   CALL CONASC          ; convert to ASCII
  86.   MOV W Z100_SET_ATTR,AX  ; set up init string
  87.   MOV W NV_TEXT,AX      ; set up Z100_ATTR string, also
  88.   MOV AL,Z100_RV_ATTR      ; get Z-100 reverse video attributes
  89.   CALL CONASC          ; make it ASCII
  90.   MOV W RV_TEXT,AX      ; set up Z100_ATTR string
  91.   MOV SI,Z100_INIT      ; load initialization sequence
  92.   JMP SHORT Z100_STRING   ; output the initialization sequence
  93.  
  94.  
  95. ; Z100_STRING outputs the SI-pointed, 0FF-terminated string to the Z100
  96. ;   console.
  97.  
  98. L1:              ; loop here to output each byte of the sequence
  99.   CALL Z100_CONOUT      ; output AL to the Z100 console
  100. Z100_STRING:
  101.   CS LODSB          ; fetch the next byte
  102.   CMP AL,0FF
  103.   JNE L1          ; loop until done
  104.   RET
  105.  
  106.  
  107. ; CONASC converts the nibbles of AL into ASCII digits AH and AL.
  108.  
  109. CONASC:
  110.   MOV AH,AL        ; copy to AH
  111.   AND AL,7        ; isolate foreground
  112.   MOV CL,4          ; shift count 4 for divide-by-16
  113.   SHR AH,CL        ; move background down
  114.   OR AX,'00'        ; make result ASCII
  115.   RET
  116.  
  117.  
  118. ; Z100_KEY is the Zenith Z100 version of the BIOS_KEY routine.
  119.  
  120. Z100_KEY:
  121.   CALL 040:6        ; wait for a key
  122.   RET
  123.  
  124.  
  125. Z100_BELL:        ; ring the bell on a Zenith Z100
  126.   MOV AL,7        ; code 7 is BELL
  127. Z100_CONOUT:
  128.   PUSH BX,CX,DX,SI,DI,ES  ; preserve registers across call
  129.   CLD              ; must be cleared!
  130.   CALL 0FE01:019      ; write character to screen
  131.   POP ES,DI,SI,DX,CX,BX   ; restore clobbered registers
  132.   RET
  133.  
  134.  
  135. ; Z100_COPY is the Zenith Z100 version of BIOS_COPY routine
  136.  
  137. Z100_COPY:
  138.   PUSH AX,BX,ES         ; preserve registers across call
  139.   CALL Z100_ROWCOL    ; get row and column
  140.   ADD DI,CX
  141.   ADD DI,CX             ; point past "memory"
  142.   PUSH DI        ; save pointer
  143.   PUSH CX,SI,DS         ; save registers while we read the actual bytes
  144.   MOV ES,DS             ; we will output the bytes to our source buffer
  145.   LEA DI,[SI+80]        ; point DI to the actual-bytes area
  146.   IN AL,0D8        ; read video port
  147.   MOV AH,AL        ; save value
  148.   MOV AL,078            ; load value that will enable the video memory
  149.   OUT 0D8,AL        ; enable video RAM
  150.   MOV DS,BX,0E000    ; point to video memory
  151.   MOV BX,DX        ; fetch the row and column
  152.   SHL BH,1        ; multiply row by 8 to get the base address
  153.   SHL BH,1
  154.   SHL BH,1
  155.   LEA SI,[BX+0480]    ; fetch the character
  156. L7:                     ; loop here to read each character from the BIOS
  157.   LODSB                 ; fetch the character from the BIOS-maintained buffer
  158.   ADD AL,' '            ; convert the character to ASCII
  159.   STOSB                 ; output the ASCII character to our buffer
  160.   LOOP L7               ; loop to read another character
  161.   MOV AL,AH        ; get video port value
  162.   OUT 0D8,AL        ; restore it
  163.   POP DS,SI,CX          ; restore source and count pointers
  164.   CS LES DI,D[CUR_ADR]    ; get cursor address
  165.   ES PUSH [DI]          ; save the user's cursor position
  166. L1:
  167.   ES MOV [DI],DX    ; set cursor
  168.   LODSB         ; get the new character
  169.   CMP AL,[SI+79]        ; is this character already on the screen?
  170.   IF NE CALL Z100_CONOUT; if not then output it
  171.   INC DL        ; increment column
  172.   LOOP L1        ; loop until done
  173.   POP AX                ; get user's cursor
  174.   INC AL        ; go to next column
  175.   ES MOV [DI],AX    ; restore cursor
  176.   MOV AL,8              ; load backspace
  177.   CALL Z100_CONOUT    ; fix cursor by backspacing back to the position
  178.   POP DI,ES,BX,AX       ; restore clobbered registers
  179.   RET
  180.  
  181.  
  182. ; Z100_ATTR copies the single attribute AL to screen at ES:DI
  183.  
  184. Z100_ATTR:
  185.   PUSH AX          ; save attribute
  186.   CS CMP AL,Z100_RV_ATTR  ; are we setting reverse video?
  187.   PUSHF                   ; save falgs setting tellling if we are
  188.   CALL Z100_ROWCOL      ; get cursor position in memory
  189.   POPF                    ; restore flags telling if it is reverse video
  190.   JNZ >L6          ; skip if not: we will remain with a normal attribute
  191.   MOV SI,Z100_REV_VID      ; it is reverse: point to reverse-attribute string
  192.   CALL Z100_STRING        ; output the sequence, converting to reverse
  193. L6:
  194.   CS LES DI,D[CUR_ADR]      ; get cursor address
  195.   ES MOV CX,[DI]          ; get users's cursor position
  196.   ES MOV [DI],DX      ; set to character to fix
  197.   CALL Z100_GETCH      ; get character there
  198.   CALL Z100_CONOUT      ; send with new attribute
  199.   ES MOV [DI],CX      ; restore old cursor
  200.   MOV SI,Z100_NOR_VID      ; point to normal attribute string
  201.   CALL Z100_STRING        ; restore normal attribute
  202.   POP AX                  ; restore clobbered register
  203.   RET
  204.  
  205.  
  206. ; Z100_ROWCOL converts the address in DI to the Z-100 row and column in DX.
  207.  
  208. Z100_ROWCOL:
  209.   MOV AX,DI        ; pointer to AX
  210.   SHR AX,1        ; AX = byte position
  211.   SUB DX,DX        ; form dword accumulator
  212.   PUSH BX           ; preserve register across call
  213.   MOV BX,80        ; 80 characters/line
  214.   DIV BX        ; get row and column
  215.   POP BX            ; restore clobbered register
  216.   MOV DH,AL        ; DX = row and column
  217.   RET
  218.  
  219.  
  220. ; Z100_GETCH sets AL to the screen character at cursor position DX.  We
  221. ;   directly access the video memory maintained by the Z100 BIOS.
  222.  
  223. Z100_GETCH:
  224.   PUSH BX,CX,DS     ; save registers across call
  225.   IN AL,0D8        ; read video port
  226.   MOV CH,AL        ; save value
  227.   MOV AL,078        ; load value that enables video RAM
  228.   OUT 0D8,AL        ; enable video RAM
  229.   MOV DS,AX,0E000   ; point to video memory
  230.   MOV BX,DX        ; fetch the row and column
  231.   SHL BH,CL,3        ; multiply row by 8 to get the base address
  232.   MOV BL,[BX+0480]  ; fetch the character
  233.   MOV AL,CH        ; get video port value
  234.   OUT 0D8,AL        ; restore it
  235.   MOV AL,BL        ; move character to AL
  236.   ADD AL,' '        ; make character ASCII
  237.   POP DS,CX,BX        ; restore clobbered registers
  238.   RET
  239.