page ,132 ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 1987-07-13 by まさとい $$$ ; ; PC−88VA ; ; 「「Fancy Font BIOS Sample Program「「 ; ; 漢字ROMからGETしたフォントに対してFancyFontBIOSで ; 装飾をかけ、それをマウスフォントとしてセットする。 ; ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ title FancyFont Sample code segment assume cs:code, ds:code, ss:code, es:code org 100h ;=============================================== ; Constants ;=============================================== $NULL equ 0 $Bell equ 07h $Lf equ 0ah $Cr equ 0dh $Dos equ 21h ; PC-Engine File System $EndProc equ 4ch ; End of Process $MBios equ 33h ; Mouse BIOS $InitMous equ 00h ; Initiaize Mouse $OnMcsr equ 01h ; Turn On Mouse Cursor $OffMcsr equ 02h ; Turn Off Mouse Cursor $Mstyle equ 09h ; Set Mouse Cursor Font $KeyBios equ 82h ; KeyBoard BIOS $GetChar equ 00h ; Get Character $SnsChar equ 01h ; Sense Character $TxBios equ 83h ; Text BIOS $ChPut equ 00h ; Put a Char to Console $PutStr equ 02h ; Put String to Console $GetFont equ 23h ; Get Font Pattern $SprBios equ 84h ; Sprite BIOS $InitSpr equ 00h ; Initialize Sprite BIOS $JfpBios equ 8dh ; JFP(Japanese Front Processor) BIOS $GetJfp equ 00h ; Get JFP current status $SetJfp equ 01h ; Set new JFP status $FancyBios equ 92h ; fancy Font BIOS StFancy: jmp Fancy ;=============================================== ; Message and data area ;=============================================== greeting_mes db $Cr, $Lf db "PC−88VA サンプルプログラム " db "「「ファンシーフォント「「" db $Cr, $Lf, $Lf, $NULL prompt1_mes db "漢字を1文字入力してください〉", $NULL Notkan_mes db $Bell, $Cr, $Lf db " これは漢字ではありません。", $Cr, $Lf, $NULL FancyMode_mes db $Cr, $Lf db "装飾モードを選んでください(複数可)", $Cr, $Lf db " 1.白抜き", $Cr, $Lf db " 2.斜 体", $Cr, $Lf db " 3.太 字", $Cr, $Lf db " 4.影つき", $Cr, $Lf db " 5.終 了", $NULL prompt2_mes db $Cr, $Lf, "〉", $NULL OutKanji_mes db " ", $Cr, $Lf, $NULL color_mes db "カラーを指定してください(1〜9,A〜F)〉", $NULL FancyBitTbl db 10000000b ; Outline font db 01000000b ; Italic font db 00100000b ; Bold font db 00010000b ; Shadow font Savekanji dw ? SaveFancyBit db ? even src_buf db 3*24 dup (0) ; 24*24 sized buffer dst_buf db 3*24 dup (0) ; ditto len_buf equ $-dst_buf mfont dw 32 ; mouse font X-size dw 24 ; mouse font Y-size dw 1 ; monochorome mode m_color dw 4 ; mouse color m_buf db 4*32 dup (0) ; 32*24 sized buffer len_m_buf equ $-m_buf ;=============================================== ; Main Routine ;=============================================== Fancy: mov si, offset greeting_mes ; print greeing message call PutString ;----------------------------------------------- ; Get Kanji Char ; GetKanji: mov si, offset prompt1_mes ; print Kanji input prompt call PutString mov ax, 1 ; JFP Zenkaku call SetJFP call GetChar ; get a Zenkaku Char call ChkKanji ; see if it's Kanji char. jc YesKan ; branch it's kanji char. mov si, offset Notkan_mes call PutString jmp GetKanji ; retry to get Kanji char Yeskan: mov SaveKanji, ax ; save kanji char mov si, offset OutKanji_mes xchg al, ah ; exchange AL with AH mov [si], ax ; set Kanji code in put string call PutString xor ax, ax ; JFP Hankaku call SetJFP call FlushKey ; flush key queue ;----------------------------------------------- ; Get fancy Font Style mode ; mov si, offset FancyMode_mes call PutString mov si, offset prompt2_mes call PutString mov cl, 00000000b ; set default FancyFont parameter ; Bit0=0 : Zenkaku ; Bit1=0 : 16*16 dot ; Bit2=0 : mode size is 24 dot ; Bit4-7=0 : not chnge style now GetNum: push cx call GetChar ; get a char pop cx sub al, "0" ; to digit from ASCII code cmp al, 1 ; 1 <= AL <= 5 ? jl GetNum cmp al, 5 jg GetNum cmp al, 5 ; end of setting font style ? je OkStyle push ax mov dx, "0" add dl, al ; to Zenkaku number mov ah, $ChPut int $TxBios ; put a char to console pop ax dec al ; to 0 relative cbw ; to word mov bx, offset FancyBitTbl ; set font style bit table pointer add bx, ax ; move specified font style pointer mov al, [bx] ; get font style bit or cl, al ; append font style bit jmp GetNum OkStyle: mov SaveFancyBit, cl mov si, offset OutKanji_mes mov word ptr [si], 2020h call PutString ;----------------------------------------------- ; Get Mouse Color ; mov si, offset color_mes call PutString GetMCol: call GetChar sub al, "0" ; to digit from ASCII code cmp al, 1 ; "1" - "9" ? jl GetMCol cmp al, 9 jle SetMCol sub al, 7 ; to digit from "A"-"F" cmp al, 10 ; "A" - "F" ? jl GetMCol cmp al, 15 jle SetMCol sub al, 20h ; to digit from "a"-"f" cmp al, 10 ; "a" - "f" ? jl GetMCol cmp al, 15 jg GetMCol SetMCol: xor ah, ah ; to word color code(1 to 15) mov word ptr m_color, ax cmp al, 10 ; "A"-"F" ? jge ToAlphZen mov dx, "0" add dl, al ; to Zenkaku "0" - "9" jmp short DispNum ToAlphZen: sub al, 10 mov dx, "A" add dl, al ; to Zenkaku "A" - "F" DispNum: xchg dl, dh ; exchange Low with High mov si, offset OutKanji_mes mov [si], dx call PutString ;----------------------------------------------- ; Get Kanji Font from Kanji-ROM ; cld xor ax, ax mov di, offset src_buf ; set src_buf pointer mov cx, len_buf/2 ; buffer size(word) rep stosw ; clear src_buf mov di, offset dst_buf ; set dst_buf pointer mov cx, len_buf/2 ; buffer size(word) rep stosw ; clear dst_buf mov dx, SaveKanji ; reget Kanji char mov bp, offset src_buf ; set font stored buffer pointer call GetFont ; read font data in src_buff ;----------------------------------------------- ; Exec Fancy Font ; mov cl, SaveFancyBit ; set attribute mov si, offset src_buf ; original font buffer pointer mov di, offset dst_buf ; change style font buffer int $FancyBios call xchg_font ; exchange font stored pattern call SetMousFnt ; Set Mouse Font and display mov ah, $EndProc ; End of Process int $Dos ; return to Shell ;=============================================== ; Get a Zenkaku Character ; ; Exit AX=chracter(Hankau/Zenkaku) ;=============================================== GetChar: mov ah, $GetChar int $KeyBios ret ;=============================================== ; Flush Key Queue ;=============================================== FlushKey: mov ah, $SnsChar ; see if any char in queue int $KeyBios jc NoMoreKey ; Branch if no key in queue mov ah, $GetChar ; eat key char from queue int $KeyBios jmp FlushKey NoMoreKey: ret ;=============================================== ; SetUp JFP On/Off ; ; Entry AX=0 : Hankaku mode ; =1 : Zenkaku mode ;=============================================== SetJFP: push ax ; save switch mode mov cl, $GetJFP ; get current status int $JfpBios and al, 0fch ; clear Bit1(Kana/ANK) ; and Bit0(Zenkaku/Hankaku) pop bx ; reget switch mode mov cl, 03h ; assume that Zenkaku mode ; Bit1=1:Kana / Bit0=1:Zenkaku and bl, 1 ; Zenkaku ? jnz SetZen ; yes mov cl, 0 ; Hankaku mode ; Bit1=0:ANK / Bit0=0:Hankaku SetZen: or al, cl ; set new mode mov cl, $SetJFP ; set new status int $JfpBios ret ;=============================================== ; Display String on Screen ; ; Entry DS:SI NULL terminated string ;=============================================== PutString: mov ah, $PutStr ; set function mov dx, -1 ; attribute is current int $TxBios ret ;=============================================== ; Check if Kanji code is in Shift-JIS range ; ; Entry AX=Shift-JIS Kanji char ; Exit Cy=0 : Not Kanji ; =1 : kanji ;=============================================== ChkKanji: cmp ah, 81h ; 81h <= AL <= 9Fh ? jb NotKanji cmp ah, 0a0h jb YesKanji cmp ah, 0e0h ; E0h <= AH <= FCh ? jb NotKanji cmp ah, 0fdh jb YesKanji NotKanji: clc ret YesKanji: cmp al, 40h ; 40h <= AL <= FCh (except 7Fh) ? jb NotKanji cmp al, 7fh je NotKanji cmp al, 0fdh jnb NotKanji stc ret ;=============================================== ; Get font data from Kanji-ROM ; ; Entry DX=Shift-JIS Kanji code ; ES:BP=Buffer Pointer ;=============================================== GetFont: mov ah, $GetFont int $TxBios ret ;=============================================== ; Exchange font stored patern ;=============================================== xchg_font: call CnvtFnt ; convert data array for printer(FancyFont ; result) to data array for mouse(sprite) mov di, offset m_buf mov cx, len_m_buf/2 xor ax, ax rep stosw ; clear mouse font buffer mov si, offset src_buf mov di, offset m_buf mov cx, 24 lp_xchg: mov dx, cx mov cx, 3 rep movsb xor al, al stosb mov cx, dx loop lp_xchg ret ;=============================================== ; Convert Printer data to Mouse data ;=============================================== ; Result of Fancy Font BIOS is for Printer BIOS. ; So, we must convert its data array to mouse's. ;----------------------------------------------- CnvtFnt: xor ax, ax mov di, offset src_buf mov cx, len_buf/2 rep stosw ; clear buffer mov si, offset dst_buf ; FancyFont result data buffer mov di, offset src_buf mov cx, 3 CnvtFnt0: push cx xor cl, cl mov bx, 8 CnvtFnt1: push bx push si xor bx, bx mov dx, 16 mov ch, 15 CnvtFnt2: lodsb shr al, cl and al, 00000001b xchg cl, ch xor ah, ah shl ax, cl xchg cl, ch or bx, ax inc si inc si dec ch dec dx jnz CnvtFnt2 xor dl, dl mov dh, 8 mov ch, 7 CnvtFnt3: lodsb shr al, cl and al, 00000001b xchg cl, ch shl al, cl xchg cl, ch or dl, al inc si inc si dec ch dec dh jnz CnvtFnt3 pop si inc cl mov al, bh stosb mov al, bl stosb mov al, dl stosb pop bx dec bx jnz CnvtFnt1 pop cx inc si loop CnvtFnt0 ret ;=============================================== ; Set Mouse Font and Display ;=============================================== SetMousFnt: mov ah, $InitSpr ; initialize sprite BIOS mov al, 1 ; 640*400 dot mdoe mov dx, 2000h int $SprBios mov ax, $InitMous ; initialize mouse int $MBios mov ax, $MStyle ; set mouse font mov bx, 0 ; mouse X click position mov cx, 0 ; mouse Y click position mov dx, offset mfont; mouse font parameter and data buffer pointer int $MBios mov ax, $OnMcsr ; turn on mouse int $MBios ret code ends end StFancy