home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
archives
/
msvp98b1.lzh
/
MSZP98.ASM
< prev
Wrap
Assembly Source File
|
1992-07-04
|
12KB
|
549 lines
;+ This is MSZP98.ASM
;
; Utility and SetUp Package for NEC PC-9801
; Author: Hirofumi Fujii (KEK On-line group)
; Last Edited: 17-Apr-1990
; 04-Jul-1992 VTS is moved to MSYP98.ASM
; 17-Apr-1991 deleted prn_out
; 05-Apr-1991 added pcwtst
; 30-Sep-1990 added text_scrn
; 27-Sep-1990 VTS comes here !
; 13-Aug-1990 added sense_sftkey
; 24-Jul-1990 for MS-Kermit v3.02
include mssdef.h
include msxp98.h
public s2jis, jis2s, is_kanji1
public set_keydef, reset_keydef
public set_cursor
public sense_sftkey
public text_scrn
public pc98_bell
public pc98_tstrt, pc98_tend
public pcwait, pcwtst
public setnbios
data segment
;-------------------------------------------------------------------
; Data for set-up routine
;-------------------------------------------------------------------
extrn flags:byte
extrn comand:byte ; in MSSCMD.ASM
extrn denyflg:word
extrn cpu_clock:byte, vtgrph_flg:byte, vttest_flg:byte
extrn curkey_mode:byte, keypad_mode:byte
extrn display_mode:byte
extrn keyin_dos:byte
extrn kanji_rcode:byte, kanji_scode:byte
extrn vt100_flags:byte, vt100_pflag:byte
extrn vt100_lflag:byte, vt100_gflag:byte
extrn def_color:byte, scn_color:byte
pc98v8old dd 0 ; old vector 8
pc98tick_L dw 0 ; pc98 tick count (low word)
pc98tick_H dw 0 ; pc98 tick count (high word)
pc98tcnt db 0 ; counter for interval timer
pc98tmsk db 0 ; old interrupt mask
pcwcnt dw 480 ; wait count
pcwtst_vect dw 0, 0, 0, 0
pcwtst_done dw 0
param_dst dw ?
temp dw ?
;---------------------------------------------------------------------------
; Function key definition tables
ker_keydef db 0FEh,'f 01 ',0FFh,062h, 8 dup (0) ; f 1
db 0FEh,'f 02 ',0FFh,063h, 8 dup (0) ; f 2
db 0FEh,'f 03 ',0FFh,064h, 8 dup (0) ; f 3
db 0FEh,'f 04 ',0FFh,065h, 8 dup (0) ; f 4
db 0FEh,'f 05 ',0FFh,066h, 8 dup (0) ; f 5
db 0FEh,'f 06 ',0FFh,067h, 8 dup (0) ; f 6
db 0FEh,'f 07 ',0FFh,068h, 8 dup (0) ; f 7
db 0FEh,'f 08 ',0FFh,069h, 8 dup (0) ; f 8
db 0FEh,'f 09 ',0FFh,06Ah, 8 dup (0) ; f 9
db 0FEh,'f 10 ',0FFh,06Bh, 8 dup (0) ; f10
db 0FEh,'F 01 ',0FFh,082h, 8 dup (0) ; shift f 1
db 0FEh,'F 02 ',0FFh,083h, 8 dup (0) ; shift f 2
db 0FEh,'F 03 ',0FFh,084h, 8 dup (0) ; shift f 3
db 0FEh,'F 04 ',0FFh,085h, 8 dup (0) ; shift f 4
db 0FEh,'F 05 ',0FFh,086h, 8 dup (0) ; shift f 5
db 0FEh,'F 06 ',0FFh,087h, 8 dup (0) ; shift f 6
db 0FEh,'F 07 ',0FFh,088h, 8 dup (0) ; shift f 7
db 0FEh,'F 08 ',0FFh,089h, 8 dup (0) ; shift f 8
db 0FEh,'F 09 ',0FFh,08Ah, 8 dup (0) ; shift f 9
db 0FEh,'F 10 ',0FFh,08Bh, 8 dup (0) ; shift f10
db 0FFh,036h, 4 dup (0) ; ROLL UP
db 0FFh,037h, 4 dup (0) ; ROLL DOWN
db 0FFh,038h, 4 dup (0) ; INS
db 0FFh,039h, 4 dup (0) ; DEL
db 0FFh,03Ah, 4 dup (0) ; up arrow
db 0FFh,03Bh, 4 dup (0) ; left arrow
db 0FFh,03Ch, 4 dup (0) ; right arrow
db 0FFh,03Dh, 4 dup (0) ; down arrow
db 0FFh,03Eh, 4 dup (0) ; HOME CLR
db 0FFh,03Fh, 4 dup (0) ; HELP
db 0FFh,0AEh, 4 dup (0) ; shift HOME CLR
KEYDEF_SIZE = $ - ker_keydef + 2
DOS_keydef db KEYDEF_SIZE dup (?)
;
data ends
_TEXT segment
assume cs:_TEXT
public _realclock
_realclock proc near
push ds
cli
mov ax,seg data
mov ds,ax
mov ax,ds:pc98tick_L
mov dx,ds:pc98tick_H
sti
pop ds
ret
_realclock endp
_TEXT ends
code segment
assume cs:code, ds:data
;-------------------
is_kanji1 proc near
;
; Check if al is Kanji 1st byte (stc) or not (clc)
;
cmp al,81h
jb is_kanji1_no
cmp al,0FCh
ja is_kanji1_no
cmp al,9fh
jbe is_kanji1_yes
cmp al,0E0h
jae is_kanji1_yes
is_kanji1_no:
clc
ret
is_kanji1_yes:
stc
ret
is_kanji1 endp
;-------------------
jis2s proc near
;
; Convert JIS Kanji code in AX to shift-JIS Kanji code
; ah 2nd byte
; al 1st byte
;
test al,1
jz jis2s1
add ah,1Fh
jmp jis2s2
jis2s1:
add ah,7Dh
jis2s2:
cmp ah,7Fh
jb jis2s3
add ah,1
jis2s3:
sub al,21h
shr al,1
add al,81h
cmp al,9Fh
jbe jis2s4
add al,40h
jis2s4:
ret
jis2s endp
;-------------------
s2jis proc near
;
; Convert Shift JIS Kanji code in AX to JIS Kanji code
; ah 2nd byte
; al 1st byte
;
cmp al,9Fh
ja s2jis1
sub al,71h
jmp s2jis2
s2jis1:
sub al,0B1h
s2jis2:
shl al,1
inc al
cmp ah,7Fh
jbe s2jis3
dec ah
s2jis3:
cmp ah,9Eh
jb s2jis4
sub ah,7Dh
inc al
jmp s2jis5
s2jis4:
sub ah,1Fh
s2jis5:
ret
s2jis endp
set_keydef proc near
; Save MS-DOS key definition table and set new key definition table.
; This is done by calling NEC-PC98 extended bios.
push ax
push cx
push dx
mov dx,offset DOS_keydef
mov ax,0
mov cl,0Ch
int 0DCh
mov dx,offset ker_keydef
mov ax,0
mov cl,0Dh
int 0DCh
pop dx
pop cx
pop ax
ret
set_keydef endp
reset_keydef proc near
; Restore MS-DOS key definition table
push ax
push cx
push dx
mov dx,offset DOS_keydef
mov ax,0
mov cl,0Dh
int 0DCh
pop dx
pop cx
pop ax
ret
reset_keydef endp
;---------------------------
text_scrn proc near
;
; Text screen on/off control
;
; Input AL: 0 off
; others on
;
push ax
push bx
mov bl,0Ch ; assume off
cmp al,0 ; want off ?
je text_scrn_1 ; e=yes
mov bl,0Dh ; on
text_scrn_1:
in al,60h ; Read Text GDC status
test al,04h ; GDC buffer empty ?
jz text_scrn_1 ; z=no
mov al,bl
out 62h,al ; send command
pop bx
pop ax
ret
text_scrn endp
;
;---------------------------
set_cursor proc near
;
; set cursor
; Input
; AH: Lines/Row - 1 (15 or 19)
; 25 line mode = 400 / 25 - 1 = 15
; 20 line mode = 400 / 20 - 1 = 19
; AL: cursor attributes
; bit0 0:visible, 1:invisible
; bit1 0:blink, 1:noblink
; bit2 0:block, 1:underline
;
; GDC CSFORM command is
; +--+--+--+--+--+--+--+--+
; | 0| 1| 0| 0| 1| 0| 1| 1|
; +--+--+--+--+--+--+--+--+
; |CS| 0| 0| L/R | CS=cursor 0:off/1:on, L/R=(lines/row - 1)
; +--+--+--+--+--+--+--+--+
; | BLL |BD| CST | BD=blink 0:yes/1:no, CST=(start line - 1)
; +--+--+--+--+--+--+--+--+
; | CFI | BLH | CFI=(final line - 1), BLH+BLD=blink speed
; +--+--+--+--+--+--+--+--+
;
push ax
push bx
mov bx,ax
cli
set_cursor1:
in al,60h ; Read Text GDS status
test al,04h ; GDC buffer empty ?
jz set_cursor1 ; z = no
mov al,4Bh ; CSFORM command
out 62h,al ; send command
mov al,ah ; set L/R
or al,80h ; assume cursor is on
test bx,1 ; cursor off ?
jz set_cursor2 ; z = no
and al,07Fh ; cursor is off, set CS=0
set_cursor2:
out 60h,al ; send P1 parameter
mov al,0 ; set CST to zero
test bx,4 ; underline cursor ?
jz set_cursor3 ; z = yes
mov al,ah ; set CST to last line
dec al ; one line (underline) cursor
set_cursor3:
and al,1fh ; mask other bit (BD=0)
test bx,2 ; blink ?
jz set_cursor4 ; z = yes. blink cursor
or al,20h ; no blink, set BD=1
set_cursor4:
out 60h,al ; send P2 parameter
mov al,ah ; CFI is last line
shl al,1
shl al,1
shl al,1
and al,0F8h
or al,0Bh ; BL=12
out 60h,al ; send P3 parameter
sti
pop bx
pop ax
ret
set_cursor endp
;-----------------------------------------------------------------------
; Bell routine
;
pc98_bell proc near
push ax
push cx
;
mov al,06h ; bell on
out 37h,al
mov cx,0D000h ; counter
pc98_bell_loop:
loop pc98_bell_loop
mov al,07h ; bell off
out 37h,al
;
pop cx
pop ax
ret
pc98_bell endp
;-----------------------------------------------------------------------
; timer routines
;
pc98_tint proc near
push ds
push ax
mov ax,seg data ; set our data segment
mov ds,ax ; to DS
pushf
call dword ptr ds:pc98v8old ; call old interrupt routine
cli
mov ax,seg data
mov ds,ax
mov al,pc98tcnt ; get tick count (every 10msec)
inc al
and al,3 ; use only lower 2 bits
mov pc98tcnt,al ; save it
or al,al ; zero?
jnz pc98_tint_ex ; nz = no, don't do anything
add pc98tick_L,1 ; longword increment1
adc pc98tick_H,0
pc98_tint_ex:
in al,2 ; make sure timer interrupt enabled
and al,0feh
out 2,al
sti ; enable interrupt
pop ax
pop ds
iret
pc98_tint endp
pc98_tstrt proc near
; start pc98 tick timer
push ax
push bx
push dx
push ds
push es
;
xor ax,ax
mov pc98tcnt,al
mov pc98tick_L,ax
mov pc98tick_H,ax
cli ; disable interrupt
in al,2 ; read interrupt mask
mov pc98tmsk,al ; save old mask
and al,0feh ; unmask timer interrupt (#0)
out 2,al ; set mask value
mov ah,35h ; read vector
mov al,8
int DOS ; call DOS function
mov WORD PTR pc98v8old,bx ; save offset
mov WORD PTR pc98v8old+2,es ; save segment
mov dx,offset pc98_tint ; new interrupt routine
push cs
pop ds ; DS = CS
mov ah,25h ; set vector
mov al,8 ; vector number
int DOS ; call DOS function
;
sti ; enable interrupt
pop es
pop ds
pop dx
pop bx
pop ax
clc
ret
pc98_tstrt endp
pc98_tend proc near
push ax
push bx
push dx
push ds
cli
mov al,pc98tmsk ; restore old interrupt mask
out 2,al
mov ah,25h ; set vector
mov al,8 ; vector number
mov dx,WORD PTR pc98v8old
mov bx,WORD PTR pc98v8old+2
push bx
pop ds
int DOS ; call DOS function
sti
pop ds
pop dx
pop bx
pop ax
clc
ret
pc98_tend endp
;-----------------------------------------------------------------------
; set the pcwcnt used in pcwait.
;
pcwtst_int proc near
mov pcwtst_done,1
iret
pcwtst_int endp
pcwtst proc near
push ax
push bx
push cx
push si
push di
push es
;
xor ax,ax
mov es,ax ; ES = 0
cli ; disable interrupt
mov si,28 ; save vector number 7 & 8
mov di,offset pcwtst_vect
mov ax,es:[si]
mov [di],ax
mov ax,es:[si+2]
mov [di+2],ax
mov ax,es:[si+4]
mov [di+4],ax
mov ax,es:[si+6]
mov [di+6],ax
;
mov pcwcnt,0
mov pcwtst_done,0
sti ; enable interrupt
mov cx,10 ; 100msec mesurements
mov ax,cs
mov es,ax
mov bx,offset pcwtst_int
mov ah,02h ; interval timer function number
int 1Ch ; BIOS call
;
pcwtst0:
cmp pcwtst_done,0
jne pcwtst2
mov cx,100
pcwtst1:
sub cx,1
jnz pcwtst1
inc pcwcnt
jmp pcwtst0
;
pcwtst2:
inc pcwcnt ; add 1
cli
xor ax,ax
mov es,ax ; ES = 0
mov si,28 ; restore vector 7 & 8
mov di,offset pcwtst_vect
mov ax,[di]
mov es:[si],ax
mov ax,[di+2]
mov es:[si+2],ax
mov ax,[di+4]
mov es:[si+4],ax
mov ax,[di+6]
mov es:[si+6],ax
sti
pop es
pop di
pop si
pop cx
pop bx
pop ax
ret
pcwtst endp
;-----------------------------------------------------------------------
;; Wait for the # of milliseconds in ax, for non-IBM compatibles.
; inner loop counter (pcwcnt, adjusted by proc pcwtst).
pcwait proc near
push cx
pcwai0: mov cx,pcwcnt ; inner loop counter for 1 ms
pcwai1: sub cx,1 ; inner loop takes 20 clock cycles
jnz pcwai1
dec ax ; outer loop counter
jnz pcwai0 ; wait another millisecond
pop cx
ret
pcwait endp
;-----------------------------------------------------------------------
; Sense shfit-key status
;
; output
; +----+----+----+----+----+----+----+----+
; AL | -- | -- | -- |CTRL|GRPH|KANA|CAPS|SHFT|
; +----+----+----+----+----+----+----+----+
sense_sftkey proc near
mov ah,02h
int 18h
ret
sense_sftkey endp
setnbios proc near
stc ; can't do this
ret
setnbios endp
code ends
end