home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / d86bios4.zip / ZBIOS1.8 < prev    next >
Text File  |  1989-07-07  |  35KB  |  960 lines

  1. ;------------------
  2. ;  WANG INTERFACE
  3. ;------------------
  4.  
  5. ; Thanks to Alan Tschetter for providing the information necessary for me
  6. ;   to program this interface.
  7.  
  8. WANG_KEYS:
  9.   DB 0E1           ; HELP key value
  10.   DB 07F-FUNC           ; add-quantity for FUNC
  11. L1:
  12.   DB 0C2,0C9,0C0,0C8,0C4 ; DOWN, NEXT, UP, PREV, HOME
  13.   DB 097,097           ; shift-F7 key, disabled Alt-F9 key
  14. N_CONTROL_KEYS EQU $-L1
  15.  
  16.   DW HELP_HELP      ; pointer to "HELP" message, the name of Wang's HELP key
  17.  
  18. L2:
  19.   DW WANG_COPY        ; VID_COPY routine
  20.   DW WANG_ATTR        ; VID_ATTR routine
  21.   DW RET        ; there is no VID_FIX necessary on the Wang
  22.   DW WANG_BELL        ; BIOS_BELL routine
  23.   DW WANG_KEY        ; BIOS_KEY routine
  24.   DW RET
  25.   DW RET
  26.   DW 0F000        ; new value for VIDEO_SEG
  27.   DB 0            ; normal-video attribute for the Wang PC
  28.   DB 2            ; reverse-video attribute for the Wang PC
  29. N_BIOS_CALLS EQU ($-L2)/2
  30.  
  31.  
  32. ; Other Wang keycodes:    F1--F16  80--8F
  33. ;            Prev     C8      Erase   CB
  34. ;            Insert     C6      Delete  C7
  35. ;            <---     C3      --->      C1
  36. ;            EXEC     C5
  37. ;   All the above codes add 010 for SHIFT versions.
  38. ;   NO ALT KEY!!!
  39. ;            Print     E3      Back Tab     CD
  40. ;            Cancel     E0      Shift Cancel 03
  41.  
  42.  
  43. ; WANG_CONFIG is the BIOS initialization routine for a Wang PC.  We copy the
  44. ;   values of WANG_KEYS to various locations, then we fetch the value of
  45. ;   ENABLE_PORT, that lets us access Wang's video memory, then we move the
  46. ;   user's cursor to the lower left corner.
  47.  
  48. L1:            ; console codes to move cursor to lower left corner
  49.   DB 01B,'[25;1H'       ; row 25, column 1
  50. L2 EQU $-L1        ; L2 is the count of bytes
  51.  
  52. WANG_CONFIG:
  53.   MOV SI,WANG_KEYS      ; point to Wang's table of key codes and other values
  54.   CALL NEW_KEYS         ; plug the new values into our program's data structures
  55.   MOV AL,1        ; function code for GET BIOS ENVIRONMENT
  56.   INT 088               ; sets ES to a segment where we'll find port #
  57.   ES MOV BX,[BX+10]    ; fetch a pointer
  58.   ES MOV AH,[BX+19]    ; use the pointer to fetch the high of the port #
  59.   MOV AL,010        ; low of the port # is always 010
  60.   MOV ENABLE_PORT,AX    ; store the port number
  61.   MOV DS,CS        ; point DS to our program, for console sequence
  62.   MOV DX,L1             ; point DX to the "go to lower left" console sequence
  63.   MOV CX,L2        ; load the number of bytes in the sequence
  64.   MOV BH,0              ; device number, maybe?  I don't know for sure
  65.   MOV AL,0D             ; function number, maybe?  I don't know for sure
  66.   INT 088               ; output escape string, user's cursor goes to lower left
  67.   RET
  68.  
  69.  
  70. ; WANG_COPY is the Wang-PC version of the VID_COPY routine.  The character
  71. ;   and attribute bytes are reversed from what they are on the IBM-PC, so
  72. ;   AH and AL are swapped before and after every word output.  There are no
  73. ;   snow problems; so we can get away with copying everything every time.
  74. ;   We do need to enable the video memory, though.
  75.  
  76. WANG_COPY:
  77.   MOV DX,ENABLE_PORT  ; fetch the port number for enabling video memory
  78.   MOV AL,1          ; value 1 causes memory to be enabled
  79.   OUT DX,AL          ; we can now access the video memory
  80. L1:              ; loop here for each character to be copied
  81.   LODSB           ; fetch the next character
  82.   XCHG AH,AL          ; swap character into AH, attribute byte into AL
  83.   STOSW           ; output the word to video memory
  84.   MOV AH,AL          ; copy the attribute byte back to AH, for next char
  85.   LOOP L1          ; loop to copy the next character
  86. L2:              ; common exit with WANG_ATTR
  87.   MOV AL,0          ; value 0 shuts off access to video memory
  88.   OUT DX,AL          ; video access is now disabled
  89.   RET
  90.  
  91.  
  92. ; WANG_ATTR is the Wang-PC version of the VID_ATTR routine.  The attribute
  93. ;    byte is the low byte of the DI-pointed video memory.  Also, to access it,
  94. ;    we must send the code that enables Wang video memory.
  95.  
  96. WANG_ATTR:
  97.   PUSH AX          ; preserve the attribute code
  98.   MOV DX,ENABLE_PORT  ; fetch the port number for enabling video memory
  99.   MOV AL,1          ; value 1 causes memory to be enabled
  100.   OUT DX,AL          ; we can now access the video memory
  101.   POP AX          ; restore the attribute code
  102.   STOSB           ; output the attribute byte to the LOW byte of video word
  103.   JMP L2          ; join common code to disable video access
  104.  
  105.  
  106. ; WANG_KEY is the Wang-PC version of the BIOS_KEY routine.
  107.  
  108. WANG_KEY:
  109.   PUSH BX          ; preserve register across call
  110. L1:              ; loop here to wait for a key to become ready
  111.   MOV AL,15          ; Wang BIOS function code for GET KEY STATUS
  112.   MOV BL,2            ; another parameter for Wang BIOS - I'm not sure which
  113.   INT 088          ; call Wang BIOS to get the status and maybe the key
  114.   TEST AL          ; do we have a key?
  115.   JNZ L1          ; loop if not, to try again
  116.   XCHG AX,BX          ; we do: swap the key code into AL for return
  117.   POP BX          ; restore clobbered register
  118.   RET
  119.  
  120.  
  121. ; WANG_BELL is the Wang-PC version of the BIOS_BELL routine.
  122.  
  123. WANG_BELL:
  124.   MOV BX,7          ; BL=7 is the BELL code; the BIOS also wants BH=0
  125.   MOV AL,6          ; Wang BIOS function code for CONSOLE OUTPUT
  126.   INT 088          ; output the BELL control code to the Wang console
  127.   RET
  128.  
  129.  
  130. ;------------------
  131. ;  TI-PC INTERFACE
  132. ;------------------
  133.  
  134. ; Thanks to David R. Cook for writing the following code.  I have reformatted
  135. ; it to look like the rest of my code, and made optimizations.
  136.  
  137. TIPC_KEYS:
  138.   DB 0B5       ; key code for F11 - the help key
  139.   DB 0AA-FUNC       ; F1 is code 0AB on the TI-PC
  140. L1:
  141.   DB 0C0       ; down-arrow key
  142.   DB 0C1       ; no PgDn key on the TI-PC, so we use alt-down-arrow code
  143.   DB 0B8       ; up-arrow key
  144.   DB 0B9       ; no PgUp key on the TI-PC, so we use alt-up-arrow code
  145.   DB 0B7       ; HOME key
  146.   DB 0CA       ; shift-F7 key
  147.   DB 0E0       ; alt-F9 key
  148. N_CONTROL_KEYS equ $-L1
  149.  
  150.   DW F11_HELP       ; pointer to help message
  151.  
  152. L2:
  153.   DW TIPC_COPY        ; VID_COPY routine
  154.   DW TIPC_ATTR        ; VID_ATTR routine
  155.   DW TIPC_FIX        ; VID_FIX routine
  156.   DW TIPC_BELL        ; BIOS_BELL routine
  157.   DW TIPC_KEY        ; BIOS_KEY routine
  158.   DW RET
  159.   DW RET
  160.   DW 0DE00        ; new value for VIDEO_SEG
  161.   DB 0F         ; normal-video attribute for the TI-PC
  162.   DB 01F        ; reverse-video attribute for the TI-PC
  163. N_BIOS_CALLS equ ($-L2)/2
  164.  
  165. ; Other TI keycodes:
  166.  
  167. ;   key   +shift  +alt      +ctrl  plain
  168. ;   ----------------------------------
  169. ;   F1      0C4      0D8      0CE     0AB
  170. ;   ...
  171. ;   F10   0CD      0E1      0D7     0B4
  172. ;   F11   "x"     "|"     "z"    0B5
  173. ;   F12   "y"     "}"     "{"    0B6
  174. ;
  175. ;   PRNT             0E2
  176. ;   INS   098      09A      099     0C2
  177. ;   DEL   0A8      0AA      0A9     0C3
  178. ;   UP AR 0F8      0B9      0F4
  179. ;   DN AR 0F9      0C1      0E6
  180. ;   LT AR 0FB      0BC      0E3     0BB
  181. ;   RT AR 0FA      0BE      0E4     0BD
  182. ;   HOME  0F6      0F5      0E7
  183. ;   TAB   07F    ignored ignored   09
  184.  
  185.  
  186.  
  187. ; TIPC_CONFIG is the BIOS initialization routine for the TI-PC.  We copy the
  188. ;   values in TIPC_KEYS to various locations, then we drop into TIPC_FIX,
  189. ;   to reset the cursor.
  190.  
  191. TIPC_CONFIG:
  192.   MOV SI,TIPC_KEYS      ; point to configuration-table for TI-PC's BIOS
  193.   CALL NEW_KEYS     ; copy the values to our tables
  194. TIPC_FIX:
  195.   MOV AH,014            ; BIOS function code for "clear graphics screen"
  196.   INT 049        ; clear the graphics screen
  197.   MOV AH,013            ; BIOS function code for "clear text screen"
  198.   INT 049        ; clear the text screen
  199.   MOV AH,2              ; BIOS function code for "position the cursor"
  200.   MOV DX,1 BY 24    ; first column, 24th row
  201.   INT 049               ; move the user's cursor to the bottom left corner
  202.   RET
  203.  
  204.  
  205. ; TIPC_COPY is the VID_COPY routine for the TIPC video board.  The attribute
  206. ;   AH is written to a single memory-mapped latch in the video segment.
  207. ;   Then the text bytes can be copied as-is.
  208.  
  209. TIPC_COPY:
  210.   ES MOV B[01801],AH    ; set the attribute latch
  211.   SHR DI,1        ; adjust the video address for bytes, not words
  212.   REP MOVSB        ; copy the text as-is
  213.   SHL DI,1        ; restore the video address to words, not bytes
  214.   RET
  215.  
  216.  
  217. ; TIPC_ATTR is the VID_ATTR routine for TI-PC computer.  We change the
  218. ;   attribute latch to the one provided in AL, then we add 0 to the video
  219. ;   character in memory, causing the new latch value to take effect.
  220.  
  221. TIPC_ATTR:
  222.   SHR DI,1        ; adjust video address for bytes, not words
  223.   ES MOV AH,B[DI]    ; fetch the character
  224.   ES MOV B[01801],AL    ; rewrite the latch with the caller's value
  225.   ES MOV B[DI],AH    ; re-write the value already there, to effect the latch
  226.   SHL DI,1        ; restore DI
  227.   RET
  228.  
  229.  
  230. ; TIPC_KEY is the BIOS_KEY routine for TI_PC computer.    We must transform the
  231. ;   two-byte code returned by the TIPC BIOS into the single code AL expected by
  232. ;   the rest of the debugger. The only differences to IBM_KEY are the interrupt
  233. ;   number, and the mapping of the codes received and returned.
  234.  
  235. TIPC_KEY:
  236.   MOV AH,0        ; function code for GET KEY
  237.   INT 04A        ; get the keystroke from the TIPC BIOS
  238.   TEST AL        ; is the return AL nonzero?
  239.   JNZ RET        ; if yes then AL is our return code
  240.   MOV AL,AH        ; AL is zero, so AH determines the return code
  241.   ADD AL,080-16     ; shift the values into a range not seen directly in AL
  242.   RET
  243.  
  244.  
  245. ; TIPC_BELL is the BIOS_BELL routine for TIPC-PC computer.  We output the code
  246. ;   07 to the BIOS's console output routine. The only difference to IBM_KEY is
  247. ;   the interrupt number.
  248.  
  249. TIPC_BELL:
  250.   MOV AX,0E07       ; AH= console out function number; AL="BELL" control code
  251.   INT 049        ; output BELL to the console
  252.   RET
  253.  
  254.  
  255. ;------------------
  256. ; SANYO INTERFACE
  257. ;------------------
  258.  
  259. ; Thanks to Jerry Farnsworth for providing the information necessary for me
  260. ;   to program this interface.
  261.  
  262. SANYO_KEYS:
  263.   DB 0DC       ; key code for Ctrl-PF5 -- the help key
  264.   DB 0           ; same function codes as IBM-PC
  265. L1:
  266.   DB 0C0       ; down-arrow key
  267.   DB 0C1       ; PgDn key
  268.   DB 0B8       ; up-arrow key
  269.   DB 0B9       ; PgUp key
  270.   DB 0B7       ; HOME key
  271.   DB 0CA       ; shift-F7 key is Ctrl 7 on the Sanyo
  272.   DB ALT_F 9       ; Ctrl-Shift-PF4 will restore a trashed screen
  273. N_CONTROL_KEYS equ $-L1
  274.  
  275.   DW PF5_HELP       ; pointer to help message
  276.  
  277. L2:
  278.   DW SANYO_COPY     ; VID_COPY routine
  279.   DW SANYO_ATTR     ; VID_ATTR routine
  280.   DW NO_ACTUAL        ; VID_FIX routine
  281.   DW IBM_BELL        ; BIOS_BELL routine
  282.   DW IBM_KEY        ; BIOS_KEY routine
  283.   DW SANYO_SAVE     ; we must save the BIOS cursor position
  284.   DW SANYO_RESTORE  ; we must restore the BIOS cursor position
  285.   DW 07C00        ; new value for VIDEO_SEG
  286.   DB 07         ; normal-video attribute for the Sanyo-PC
  287.   DB 0F0        ; reverse-video attribute for the Sanyo-PC
  288. N_BIOS_CALLS equ ($-L2)/2
  289.  
  290.  
  291. ; Other Sanyo keycodes:
  292.  
  293. ; IBM         Sanyo           IBM          Sanyo
  294.  
  295. ; Alt         Ctrl Shift        DOWN       numeric pad 5
  296. ; Alt Fn     Ctrl Fn           END          numeric pad 2
  297. ; Shift Fn   Ctrl n
  298. ; Ctrl 2     Ctrl `                Ctrl F12345    Ctrl ={}:"
  299. ; Ctrl 6     Ctrl tilde            Ctrl F678910   Ctrl ;',./
  300.  
  301.  
  302.  
  303. ; SANYO_CONFIG is the BIOS initialization routine for a Sanyo 55x.  We copy the
  304. ;   values of SANYO_KEYS to various locations, fetch and store the current
  305. ;   video page, and set the user cursor to the lower left of the screen.
  306.  
  307. ; SANYO_FIX insures a screen refresh by filling the "actual" buffers of SCREEN_P
  308. ;   with impossible FF-values.
  309.  
  310. SANYO_CONFIG:
  311.   MOV SI,SANYO_KEYS     ; point to configuration-table for SANYO's BIOS
  312.   CALL NEW_KEYS     ; copy the values to our tables
  313.   MOV AH,15        ; function number for fetching the video page
  314.   INT 010        ; set BH to the current video page
  315.   MOV SANYO_PAGE,BH    ; store the page throughout the debugging session
  316.   MOV DX,24 BY 0    ; load coordinates for the lower left corner
  317.   CALL SET_SANYO_POS    ; store this position
  318.   CALL SANYO_RESTORE    ; this call causes the user cursor to move there
  319. NO_ACTUAL:
  320.   MOV AX,0FFFF        ; load AH and AL with the 0FF impossible-value
  321. FILL_ACTUAL:
  322.   MOV ES,SS        ; destination segment is our stack, for buffer-fill
  323.   XCHG DI,AX            ; save fill-value in DI
  324.   SS MOV AX,SCREEN_P    ; point to the screen buffer
  325.   MOV AL,80             ; advance AX to the actual buffer for the first line
  326.   XCHG AX,DI            ; swap actual pointer to DI, restore fill value to AX
  327.   MOV DL,24        ; load the count of actual lines to fill
  328. L2:
  329.   MOV CX,40        ; number of words in the actual buffer
  330.   REP STOSW        ; fill the buffer with the words
  331.   ADD DI,256-80         ; advance output pointer to the next line's actual buff.
  332.   DEC DL        ; count down lines
  333.   JNZ L2        ; loop to fill the next line
  334.   RET
  335.  
  336.  
  337. ; SANYO_COPY is the VID_COPY routine for the Sanyo.  The Sanyo does not have
  338. ;   a hardware character generator, so we call the BIOS to copy bit-patterns
  339. ;   to the screen.
  340.  
  341. SANYO_COPY:
  342.   PUSH BX,BP            ; preserve caller's BX and return DI value
  343.   MOV BP,>L3
  344.   MOV BH,0        ; load the page number
  345. SANYO_PAGE EQU B[$-1]    ; previous immediate value is plugged in
  346. BP_VID_COPY:
  347.   MOV AX,DI        ; fetch the output character number
  348.   ADD DI,CX        ; add the character count
  349.   ADD DI,CX        ; add it twice, to advance by words not bytes
  350.   PUSH DI
  351.   CALL GET_ROWCOL    ; convert character number AX into row-and-column DX
  352.   DEC DX        ; cancel the following first INC DX
  353. L1:            ; loop here for every character already out there
  354.   INC DX        ; advance the column number DL to the next position
  355.   LODSB         ; fetch the next character
  356.   MOV BL,AL        ; save the character in BL
  357.   XCHG AL,[SI+79]    ; swap it with the already-out-there value
  358.   CMP AL,BL        ; is the character already out there?
  359.   LOOPE L1        ; loop if it is
  360.   JE >L2        ; jump if the characters are exhausted
  361.   INC CX                ; undo the previous LOOPE's decrement of CX
  362.   CALL BP
  363.   LOOP L1        ; loop to check for another output character
  364. L2:
  365.   POP DI,BP,BX        ; restore clobbered registers
  366.   RET
  367.  
  368. L3:
  369.   CALL SET_IBM_CURSOR    ; move the cursor to the indicated position
  370.   MOV AL,BL        ; fetch the character to be output
  371.   MOV BL,7              ; load the attribute code, always 7 in Sanyo's case
  372.   PUSH CX        ; save the character count
  373.   MOV CX,1        ; we are outputting 1 character in this call
  374.   MOV AH,9        ; BIOS function number for WRITE_CHAR
  375.   INT 010        ; write the character to the screen
  376.   POP CX        ; restore the character count
  377.   RET
  378.  
  379.  
  380. ; SANYO_ATTR is the VID_ATTR routine for the Sanyo.  We use the BIOS to
  381. ;   move the cursor to the current position, read the character that is
  382. ;   already there, and rewrite the character with the new attribute.
  383.  
  384. SANYO_ATTR:
  385.   PUSH BX,CX,DX,DI    ; save registers across call
  386.   PUSH AX        ; save the attribute across the repositioning
  387.   MOV AX,DI        ; fetch the character number
  388.   CALL GET_ROWCOL    ; convert the character number AX to row-and-column DX
  389.   CS MOV BH,SANYO_PAGE    ; load the current page number
  390.   CALL SET_IBM_CURSOR    ; move the cursor to the required location
  391.   MOV AH,8        ; function number for READ_CHARACTER
  392.   INT 010        ; set AL to the character already there
  393.   POP DX        ; restore DL = new attribute byte
  394.   MOV BL,DL        ; copy the attribute to BL where the BIOS expects it
  395.   MOV CX,1        ; we are writing one character only
  396.   MOV AH,9        ; BIOS function number for WRITE_CHAR
  397.   INT 010        ; write the character to the screen
  398.   POP DI,DX,CX,BX    ; restore clobbered registers
  399.   RET
  400.  
  401.  
  402. ; GET_ROWCOL an address AX into a row number DH and column number DL.  The input
  403. ;   AX address is twice the number of characters from the start of the screen
  404. ;   to the current cursor position.
  405.  
  406. GET_ROWCOL:
  407.   SHR AX,1          ; convert the word index into a byte index
  408.   MOV DL,80         ; there are 80 characters in a line
  409.   DIV DL            ; compute the column number AH, row number AL
  410.   XCHG AL,AH        ; swap so AH is row, AL is column
  411.   XCHG DX,AX        ; swap so DH is row, DL is column
  412.   RET
  413.  
  414.  
  415. ; SANYO_SAVE is the BIOS_SAVE routine for the Sanyo.  We record the user's
  416. ;   cursor position, so that it can be restored by BIOS_RESTORE.
  417.  
  418. SANYO_SAVE:
  419.   MOV AH,3        ; BIOS function number for READ_CURSOR_POSITION
  420.   INT 010        ; set DX to the current user cursor position
  421. SET_SANYO_POS:
  422.   CS MOV SANYO_POS,DX    ; store the cursor position DX
  423.   RET
  424.  
  425.  
  426. ; SANYO_RESTORE is the BIOS_RESTORE routine for the Sanyo.  We set the
  427. ;   user's sursor position to the place previously stored.
  428.  
  429. SANYO_RESTORE:
  430.   MOV DX,0        ; fetch the cursor position
  431. SANYO_POS EQU W[$-2]    ; the above immedaite operand has been plugged
  432.   JMP SET_IBM_CURSOR    ; jump to set the user's cursor
  433.  
  434.  
  435. ;------------------------
  436. ;  TANDY 2000 INTERFACE
  437. ;------------------------
  438.  
  439. ; Thanks to John B. Harrell, Contributing Editor PC Resuorce, for writing
  440. ;    the following code.  I have made minor code optimizations.
  441.  
  442. TANDY_KEYS:
  443.   DB ALT_F 10        ; code for Alt-F10 -- the HELP key
  444.   DB 0            ; F1 code same as on IBM-PC
  445. L1:
  446.   DB 0C0        ; Down Arrow
  447.   DB 0C1        ; PgDn
  448.   DB 0B8        ; Up Arrow
  449.   DB 0B9        ; PgUp
  450.   DB 0B7        ; Home
  451.   DB 0CA        ; Shift F7
  452.   DB ALT_F 9        ; Alt-F9 fixes a trashed screen
  453. N_CONTROL_KEYS EQU $-L1
  454.  
  455.   DW ALTF10_HELP    ; pointer to help message
  456.  
  457. L2:
  458.   DW MONO_COPY        ; VID_COPY routine
  459.   DW IBM_ATTR        ; VID_ATTR routine
  460.   DW TANDY_FIX        ; VID_FIX routine
  461.   DW IBM_BELL        ; BIOS_BELL routine
  462.   DW IBM_KEY        ; BIOS_KEY routine
  463.   DW RET        ; BIOS_SAVE routine needed for Sanyo only
  464.   DW RET        ; BIOS_RESTORE routine needed for Sanyo only
  465. TANDY_VSEG  DW ?    ; Tandy 2000 floating video segment address = VIDEO_SEG
  466.   DB 0A         ; normal video attribute on Tandy 2000
  467.   DB 0CA        ; reverse video attribute on Tandy 2000
  468. N_BIOS_CALLS EQU ($-L2)/2
  469.  
  470. ; Other Tandy 2000 keycodes:
  471.  
  472. ;   key   +shift  +alt      +ctrl  plain
  473. ;   ----------------------------------
  474. ;   F1      0C4      0D8      0CE     0AB
  475. ;   ...
  476. ;   F10   0CD      0E1      0D7     0B4
  477. ;   F11   012     "&"     01C    008
  478. ;   F12   013     "`"     01D    009
  479. ;
  480. ;   PRNT  ---      0B6      0E2     010
  481. ;   INS   0F9      010      00F     0C2
  482. ;   DEL   0FA      00E      00D     0C3
  483. ;   UP AR 0F5      001      000
  484. ;   DN AR 0F6      007      006
  485. ;   LT AR 0F7      002      0E3     0BB
  486. ;   RT AR 0F8      ---      0E4     0BD
  487. ;   HOME  0BA      016      0E7
  488. ;   TAB   07F      0FE      0FD     009
  489. ;   BKSP  008      0FC      07F     008
  490. ;   TAB   07F      0FE      0FD     009
  491. ;   ESC   01B      0FB      01B     01B
  492. ;   END   ---      ---      0E5     0BF
  493. ;   PGUP  ---      ---      0F4     0B9
  494. ;   PGDN  ---      ---      0E6
  495.  
  496. TANDY_CONFIG:
  497.   INT 012           ; get reported memory size in KBytes
  498.   MOV CL,6           ; shift count = * 64 for Kbytes to paragraphs
  499.   SHL AX,CL           ; convert to paragraphs
  500.   ADD AX,0080           ; point to starting location of monochrome video buffer
  501.   CS MOV TANDY_VSEG,AX ; save in data structure
  502.   MOV SI,TANDY_KEYS    ; point to configuration table for Tandy 2000
  503.   CALL NEW_KEYS        ; copy the value into BIOS tables
  504. TANDY_FIX:
  505.   MOV AX,0 BY 2        ; AH= BIOS function code for SET_VIDEO_MODE; AL = mode 0
  506.   INT 16           ; force a monochrome video mode
  507.   JMP SET_IBM_LOW_LEFT ; move the cursor to the lower left corner
  508.  
  509.  
  510. ;-----------------------
  511. ;   SIRIUS INTERFACE
  512. ;-----------------------
  513.  
  514. ; BIOS interface routines for the ACT Sirius/DRG Victor 9000.  Thanks to
  515. ;    Frank Peelo, Dublin, Rep. of Ireland, for writing this code.  I
  516. ;    have made format changes and minor optimizations.
  517.  
  518. SIRIUS_KEYS:
  519.   DB 0A          ; ALT-J for help, to duplicate Wordstar
  520.   DB 0F0-FUNC    ; The function keys return F0 to F8 - I don't have 9 or 10!
  521.  
  522. L1:
  523.   DB 0A1        ; Down Arrow
  524.   DB 03         ; PgDn -- must use Ctrl-C as there's no PgDn
  525.   DB 0A0        ; Up Arrow
  526.   DB 012         ; PgUp -- must use Ctrl-R as there's no PgUp
  527.   DB 0B         ; Home -- Ctrl-K
  528.   DB 01A        ; Shift F7
  529.   DB 0              ; no fixup needed on Sirius
  530. N_CONTROL_KEYS EQU $-L1
  531.  
  532.   DW ALTJ_HELP
  533.  
  534. L2:
  535.   DW SIRIUS_COPY    ; Offsets of subroutines.
  536.   DW SIRIUS_ATTR    ; For the do-nothing routines, I'll let you put in
  537.   DW RET            ; no SIRIUS_FIX needed
  538.   DW SIRIUS_BELL
  539.   DW SIRIUS_KEY
  540.   DW RET            ; no SIRIUS_SAVE needed
  541.   DW RET            ; no SIRIUS_RESTORE needed
  542.  
  543.   DW 0F000          ; segment address of the Video RAM.
  544.   DB 040            ; attribute for normal-intensity, positive video.
  545.   DB 060            ; attribute for normal-intensity, underlined video
  546.                     ;    (reverse video is 0C0)
  547. N_BIOS_CALLS EQU ($-L2)/2
  548.  
  549. T1: DB 01B,'Y',' '+23,' '   ; ≈ Text of VT52 escape code to move
  550. T2 EQU $-T1                        ; ≈ cursor to row 23, col 0.
  551.  
  552.  
  553. ; SIRIUS_BLOCK is a control block passed to INT 0DF, to get the pointer
  554. ;   to the console handler routine.
  555.  
  556. SIRIUS_BLOCK:
  557.                 DW 1   ; first parameter - device number (1=CON device)
  558. SIRIUS_BIOS     DD ?   ; second parameter - the vector is returned here
  559.  
  560.  
  561. SIRIUS_CONFIG:
  562.   MOV SI,SIRIUS_KEYS   ; Point to configuration table for the Sirius
  563.   CALL NEW_KEYS        ; Copy the data into D86's tables
  564.   MOV BX,SIRIUS_BLOCK
  565.   MOV AX,14            ; BIOS function 14 = Get Device Vector
  566.   INT 0DF              ; The variable Sirius_BIOS_Vector is now set
  567.   MOV BX,T1            ; There is only one screen, so move the cursor
  568.   MOV CX,T2            ; I use an escape code, through Int 29h, to skip
  569. L1:                    ;   redirection, if it's in use
  570.   MOV AL,[BX]
  571.   PUSH BX,CX           ; preserve registers across interrupt
  572.   INT 029
  573.   POP CX,BX            ; restore clobbered registers
  574.   INC BX
  575.   LOOP L1
  576.   RET
  577.  
  578.  
  579. ; SIRIUS_COPY is the VID_COPY routine for the Sirius.  On the Sirius,
  580. ;   video memory consists of 2k of 16-bit words, wherein the top 5 bits
  581. ;   are the attributes, and the bottom 11 a pointer to the font cell. The
  582. ;   11 bits are multiplied by 2 to give the paragraph address, since each
  583. ;   character definition takes 32 bytes (16x16 pixels); the font is
  584. ;   therefore in the bottom 128k of RAM. To arrive at the standard video
  585. ;   font address, 100xd is added to the ASCII code using 16-bit
  586. ;   arithmetic.  Note that the low 3 bits of the attribute byte are 0, so
  587. ;   this can occupy the high byte throughout the addition without any
  588. ;   Carry-through problems.
  589.  
  590. SIRIUS_COPY:
  591.   CALL SIRIUS_ADDR    ; fix ES:DI for the Sirius
  592.   MOV BH,AH           ; store the attribute - calculating font addr clobbers AH
  593. L1:
  594.   LODSB
  595.   MOV AH,BH           ; the addition of 100 can't carry into the attributes
  596.   ADD AX,100          ; calculate the font address
  597.   STOSW               ; save the character to the screen
  598.   LOOP L1
  599.   SUB DI,DX           ; convert DI back from memory to virtual screen offset
  600.   RET
  601.  
  602.  
  603. SIRIUS_ATTR:          ; VID_ATTR for the Sirius
  604.   CALL SIRIUS_ADDR    ; fix ES:DI for the Sirius
  605.   ES MOV BX,W[DI]     ; get the character
  606.   AND BX,07FF         ; mask off the attribute bits
  607.   OR BH,AL            ; and put in the new value
  608.   ES MOV W[DI],BX     ; put the character back
  609.   SUB DI,DX           ; restore DI
  610.   RET
  611.  
  612.  
  613. SIRIUS_BELL:          ; BIOS_BELL for the Sirius
  614.   PUSH ES,SI,DI
  615.   MOV CL,7            ; BIOS outputs the character in CL
  616.   MOV AX,1            ; BIOS call 1 = output char
  617.   CS CALL SIRIUS_BIOS
  618.   POP DI,SI,ES
  619.   RET
  620.  
  621.  
  622. ; SIRIUS_KEY is the BIOS_KEY routine for the Sirius.  We find the next key
  623. ;   pressed, and we translate F8 into F10, and the arrow keys into single
  624. ;   codes.
  625.  
  626. SIRIUS_KEY:
  627.   PUSH ES,SI,DI       ; registers might be clobbered by the BIOS
  628.   SUB AX,AX           ; BIOS call 0 = Console Input
  629.   CS CALL SIRIUS_BIOS
  630.   CMP AL,0F8          ; is it Fn key 8?
  631.   JNZ >L1
  632.   MOV AL,0FA          ; if so, pretend it was F10
  633.   JMP >L0             ; L0 pops registers & returns
  634.  
  635. ; Escape codes. The Arrow keys return <ESC>A-up, B-down, C-right & D-left
  636. ; I will use Right & Left as Page Up & Page Down, respectively.
  637.  
  638. C1:
  639.  DB 0A0,0A1,0A2,0A3   ; Codes that up, down, right & left get translated to.
  640.  
  641. L1:
  642.   CMP AL,01B          ; if not escape then we don't have this problem
  643.   JNZ >L0             ; L0 pops registers returns
  644.   MOV AX,2            ; BIOS call 2: is there any keyboard data pending?
  645.   CS CALL SIRIUS_BIOS
  646.   OR AL,AL            ; AL=0 if no data pending, else AL=FF & AH=next char
  647.   JZ >L2              ; If no data pending, then it was the ESC key
  648.   CMP AH,'A'          ; else check for valid code
  649.   JB >L2              ; If <'A' or >'D', then it was the ESC key
  650.   CMP AH,'D'
  651.   JA >L2
  652.   XOR AX,AX           ; If we are to interpret the next key, we mustn't leave
  653.   CS CALL SIRIUS_BIOS ; it hanging. (It's returned in AL)
  654.   MOV BX,C1-'A'       ; BX = offset of the Code table, with A=lower bound of AL
  655.   CS XLATB
  656.   JMP >L0
  657.  
  658. L2:                   ; It was only an ESC after all
  659.   MOV AL,01B
  660. L0:
  661.   POP DI,SI,ES
  662.   RET
  663.  
  664.  
  665. ; SIRIUS_ADDR converts ES:DI from an offset that the caller recognizes,
  666. ;   into an offset that the Sirius video recognizes.  The mapping is
  667. ;   variable to allow fast scrolling.  Since the buffer repeats once
  668. ;   in the memory map, the screen occupies contiguous memory, starting
  669. ;   at an address 2047 or less.  We also return DX set to the amount
  670. ;   DI was changed, so that SUB DI,DX will restore DI.
  671.  
  672. SIRIUS_ADDR:
  673.   PUSH DS           ; We have to ask the CRTC chip for the address
  674.   MOV DS,DX,0E800   ;   of the first char on the screen
  675.   MOV B[0],12       ; Register 12 = high byte
  676.   MOV DH,B[1]
  677.   MOV B[0],13       ; Register 13 = low byte
  678.   MOV DL,B[1]       ; Now ax = offset of line 0, col 0, in 16-bit words
  679.   AND DX,2047       ; It must be modulo-2048. This will always be the
  680.        ; case anyway, unless the user's programme has screwed up the CRTC
  681.   SHL DX,1          ; now the offset is in bytes in DX
  682.   ADD DI,DX         ; Now ES:DI points to the right address
  683.   POP DS            ; DS is preserved
  684.   RET
  685.  
  686.  
  687. ;--------------------------
  688. ;   DEC RAINBOW INTERFACE
  689. ;--------------------------
  690.  
  691. FUNC EQU 59+111
  692.  
  693. ; BIOS interface routines for the DEC Rainbow A and B.  Thanks to
  694. ;     Vinzenz Esser, Moosburg, West Germany for writing this code.
  695. ;     I have made format changes and minor optimizations.
  696.  
  697. DEC_KEYS:               ; Key definition for DEC_RAINBOW_100
  698.   DB 0                  ; Key code for Help key
  699. #if IBMSIM
  700.   DB 0
  701. #else
  702.   DB 097-FUNC           ; Keypad_0 code is 097 (use instead of F1)
  703. #endif
  704.  
  705. L1:
  706.   DB 094                ; Down Arrow key
  707.   DB 092                ; Next Screen key
  708.   DB 093                ; Up Arrow key
  709.   DB 091                ; Prev Screen key
  710.   DB 08D                ; Find key (Home)
  711.   DB 090                ; Select key (Shift-F7)
  712.   DB 081                ; F2 Print Screen key (Alt-F9)
  713.   N_CONTROL_KEYS EQU $-L1
  714.  
  715.   DW HELP_HELP          ; Pointer to "HELP" message
  716.  
  717. L2:
  718.     DW DEC_COPY   ; VID_COPY routine
  719.     DW DEC_ATTR   ; VID_ATTR routine
  720.     DW RET        ; VID_FIX not needed
  721. #if IBMSIM
  722.     DW IBM_BELL,IBM_KEY
  723. #else
  724.     DW DEC_BELL   ; BIOS_BELL routine
  725.     DW DEC_KEY    ; BIOS_KEY routine
  726. #endif
  727.     DW RET        ; BIOS_SAVE not needed
  728.     DW RET        ; BIOS_RESTORE not needed
  729.     DW 0B800      ; VIDEO_SEG not needed but included for IBMSIM
  730.     DB 0E         ; Normal-video attribute
  731.     DB 0F         ; Reverse-video attribute
  732. N_BIOS_CALLS EQU ($-L2)/2
  733.  
  734.  
  735. ; DEC_CONFIG is the BIOS initialization routine for the DEC RAINBOW 100
  736.  
  737. DEC_CONFIG:
  738.   SS DEC B[LAST_LINE+1] ; 24-line screen: move D86 command line up
  739.   CS DEC B[D86_LINES]   ; also reduce the refresh lines count
  740.   MOV SI,DEC_KEYS       ; Point to DEC's table of keycodes
  741.   CALL NEW_KEYS         ;    and plug these values into D86
  742.   MOV DX,DEC_INIT       ; Clear screen
  743.   MOV AH,9
  744.   INT 021
  745.   RET
  746.  
  747.  
  748. DEC_INIT:
  749.   DB 27,'[?3l'     ; clear screen, reset all attributes, select 80 column mode
  750.   DB 27,'[24;1H$'  ; position cursor to line 24, column 1
  751.  
  752.  
  753. ; DEC_KEY is the DEC RAINBOW 100 version of the BIOS_KEY routine.
  754. ;
  755. ; The BIOS call we use returns a character code in AL, and flag bits in AH:
  756. ; 01 for function key, 02 shift, 04 control key, 08 caps lock in effect.  
  757. ;
  758. ; We remap the keys so that function keys return consecutive codes above 80H,
  759. ; according to the following chart:
  760. ;
  761. ;                      BIOS   D86                              Bios   D86
  762. ;         Key          Code  Code                Key           Code  Code
  763. ; -------------------  ----  ----        -------------------   ----  ----
  764. ; F1   Hold Screen      XXx   n/a        Prev Screen            23    91
  765. ; F2   Print Screen     03    81         Next Screen            25    92
  766. ; F3   Set-Up           XXx   n/a        Up Arrow               27    93
  767. ; F4                    05    82         Down Arrow             29    94
  768. ; F5   Break            65    A9         Right Arrow            2B    95
  769. ; F6   Interrupt        07    83         Left Arrow             2D    96
  770. ; F7   Resume           09    84         Keypad 0               2F    97
  771. ; F8   Cancel           0B    85         Keypad 1               32    98
  772. ; F9   Main Screen      0D    86         Keypad 2               35    99
  773. ; F10  Exit             0F    87         Keypad 3               38    9A
  774. ; F11  (ESC)            XXx   n/a        Keypad 4               3B    9B
  775. ; F12  (BS)             XXx   n/a        Keypad 5               3E    9C
  776. ; F13  (LF)             XXx   n/a        Keypad 6               41    9D
  777. ; Addt'l Options        11    88         Keypad 7               44    9E
  778. ; Help                  00    FF         Keypad 8               47    9F
  779. ; Do                    01    80         Keypad 9               4A    A0
  780. ; F17                   13    89         Keypad Dash            4D    A1
  781. ; F18                   15    8A         Keypad Comma           50    A2
  782. ; F19                   17    8B         Keypad Period          53    A3
  783. ; F20                   19    8C         Keypad Enter           56    A4
  784. ; Find                  1B    8D         Keypad PF1             59    A5
  785. ; Insert Here           1D    8E         Keypad PF2             5C    A6
  786. ; Remove                1F    8F         Keypad PF3             5F    A7
  787. ; Select                21    90         Keypad PF4             62    A8
  788. ; Compose Character     XXx   n/a
  789. ;
  790. ;  XXx   These keys are trapped out for special processing by firmware:
  791. ;          F1  Hold Screen      Scroll lock toggle
  792. ;          F3  Set-Up           Enter SET-UP mode to change system parameters
  793. ;          F11 (ESC)            Always generates ESC character 1Bh
  794. ;          F12 (BS)             Always generates BS character 08
  795. ;          F13 (LF)             Always generates LF character 0Ah
  796. ;          Compose Character    Introduction key to a compose character
  797. ;                                  sequence to generate characters from the
  798. ;                                  DEC 8-bit multinational character set
  799.  
  800. ; The code assigned to each function key is presented in the column 'D86' of
  801. ; the function key table above.  Since on the DEC RAINBOW only 8 of the
  802. ; function keys F1-F10 are available to an application I had to remap the
  803. ; keys somewhat:
  804. ;    IBM Key         DEC Key
  805. ;    F1              Keypad 0
  806. ;    ..              ..
  807. ;    F10             Keypad 9
  808. ;    Alt-F9          F2  Print Screen
  809. ;    Shift-F7        Select
  810. ;    Home            Find
  811. ;    Alt-F10         Help
  812.  
  813. ; Since the following 3 'function keys' do not set the function key flag,
  814. ; they end up here too:
  815. ;    F11 (ESC)   Always generates ESC character 1Bh
  816. ;    F12 (BS)    Always generates BS character 08
  817. ;    F13 (LF)    Always generates LF character 0Ah
  818. ;
  819.  
  820.  
  821. L0:
  822.   TEST AL       ; Is this an 8-bit character?
  823.   JNS RET       ; drop through if it is: we don't want it
  824. DEC_KEY:        
  825.   PUSH DI,ES    ; save some registers
  826. L1:
  827.   MOV DI,6      ; DEC BIOS function for GET KEY IF AVAILABLE
  828.   INT 24        ; do it
  829.   INC CL        ; is a character available?
  830.   JNZ L1        ; keep looking, if not
  831.   POP ES,DI     ; restore clobbered registers
  832.   TEST AH,1     ; Check function key flag
  833.   JZ L0         ; Go, if not a function key
  834.   TEST AL       ; Check for help key
  835.   JZ RET        ; Go, if help key
  836.   CMP AL,02F    ; is the key in the divide-by-2 range?
  837.   JB >L2        ; jump if it is
  838.   MOV CL,3      ; key is in the divide-by-3 range: load divisor 3
  839.   MOV AH,0      ; extend keycode AL to AX
  840.   DIV CL        ; divide by 3
  841.   ADD AL,088    ; add offset so that 2F,32,35,... becomes 97,98,99,...
  842.   CMP AL,097
  843.   IF E MOV AL,0A1
  844.   RET
  845.  
  846. L2:             ; key code is in the divide-by-2 range
  847.   SHR AX,1      ; shift in low bit of AH: now 13,15,17... becomes 89,8A,8B...
  848.   RET
  849.  
  850.  
  851. DEC_BELL:               ; ring the bell on a DEC RAINBOW
  852.   PUSH DI,ES            ; save registers
  853.   MOV AL,7              ; code 7 is BELL
  854.   MOV DI,0              ; function code for OUTPUT_AL
  855.   INT 24                ; output the bell code, to ring the bell
  856.   POP ES,DI             ; restore trashed registers
  857.   RET
  858.  
  859.  
  860. DEC_COPY:               ; DEC RAINBOW 100 version of BIOS_COPY routine
  861.   PUSH BX,CX,SI,BP      ; save registers across call
  862.   MOV AX,DI             ; fetch starting output pointer
  863.   ADD AX,CX             ; add in the number of characters
  864.   ADD AX,CX             ; add twice, to reflect the output of words not bytes
  865.   PUSH AX               ; simulated beyond-output is saved for return
  866.   MOV BP,DS             ; Segment address in BP for function 14
  867.   CALL DEC_CONV_VIDEO   ; convert DI from D86 value to line BL column BH
  868.   MOV AX,2              ; Set transfer type 2 = characters only
  869.   CALL DATA_TO_SCREEN   ; Send data to screen
  870.   POP DI,BP,SI,CX,BX    ; Restore registers
  871.   RET
  872.  
  873.  
  874. DEC_ATTR:             ; copy single attribute AL to screen at ES:DI
  875.   PUSH AX             ; push the attribute byte AL onto the stack
  876.   CALL DEC_CONV_VIDEO ; Convert DI to line/column
  877.   MOV AX,1            ; Set transfer type 1 = attrib only
  878.   MOV CX,AX           ; Transfer 1 character
  879.   MOV DX,SP           ; Point to attribute byte
  880.   MOV BP,SS           ; Segment address in BP
  881.   CALL DATA_TO_SCREEN ; send the attribute to the screen
  882.   POP AX              ; pop attribute byte back off of stack
  883.   RET
  884.  
  885.  
  886. ; DATA_TO_SCREEN copies CX characters (no more than 80) from memory to the
  887. ;   screen at column BH (1--80) line BL (1--24).  Input AX tells whether to
  888. ;   copy attributes from BP=DS:DX (AX=1), characters from DS:SI (AX=2) or both
  889. ;   (AX=0).
  890.  
  891. DATA_TO_SCREEN:
  892. #if IBMSIM
  893.   PUSH ES,DX,SI
  894.   CS MOV ES,VIDEO_SEG
  895.   ADD AX,AX
  896.   PUSH AX
  897.   MOV AL,BL
  898.   DEC AX
  899.   MOV AH,80
  900.   MUL AH
  901.   MOV BL,BH
  902.   DEC BX
  903.   MOV BH,0
  904.   ADD BX,AX
  905.   ADD BX,BX
  906.   MOV DI,BX
  907.   POP BX
  908.   CS CALL >L4[BX]
  909.   POP SI,DX,ES
  910.   RET
  911.  
  912. L4:
  913.   DW >L0,>L1,>L2
  914.  
  915. L0:
  916.   PUSH DI
  917.   CALL >L2
  918.   POP DI
  919. L1:
  920.   XCHG SI,DX
  921. L5:
  922.   INC DI
  923.   MOVSB
  924.   LOOP L5
  925.   XCHG DX,SI
  926.   RET
  927.  
  928. L2:
  929.   MOVSB
  930.   INC DI
  931.   LOOP L2
  932.   RET
  933.  
  934. #else
  935.   MOV DI,8        ; function number for DISABLE CURSOR
  936.   INT 24          ; call the DEC BIOS to disable the cursor
  937.   MOV DI,014      ; function number for WRITE TO SCREEN
  938.   INT 24          ; call the DEC BIOS to write to the screen
  939.   MOV DI,0A       ; function number for ENABLE CURSOR
  940.   INT 24          ; call the DEC BIOS to enable the cursor
  941.   RET
  942. #endif
  943.  
  944.  
  945.  
  946. ; DEC_CONV_VIDEO converts the D86 video memory address in DI to line BL (1-24)
  947. ;    and column BH (1-80)
  948.  
  949. DEC_CONV_VIDEO:
  950.   XCHG AX,DI        ; swap the D86 address in AX
  951.   SHR AX,1          ; convert words to bytes
  952.   MOV BL,80         ; load the number of characters in a line
  953.   DIV BL            ; compute column number AH, line number AL
  954.   MOV BX,0101       ; load offsets to convert first numbers from 0 to 1
  955.   ADD BX,AX         ; add in the coordinates, for return in BH and BL
  956.   RET
  957.  
  958.  
  959.  
  960.