[Reduction] #428: text_puts

This commit is contained in:
nmlgc 2014-09-01 08:58:15 +02:00
parent ce245eae9f
commit b4dd0d452d
2 changed files with 116 additions and 77 deletions

View File

@ -0,0 +1,113 @@
; master library - PC98
;
; Description:
; テキスト画面への文字列の書き込み
; 幅指定なし・属性なし
;
; Function/Procedures:
; void text_puts( unsigned x, unsigned y, char *strp ) ;
;
; Parameters:
; unsigned x 左端の座標 ( 0 〜 79 )
; unsigned y 上端の座標 ( 0 〜 24 )
; char * strp 文字列の先頭アドレス ( NULLは禁止 )
;
; Returns:
; none
;
; Binding Target:
; Microsoft-C / Turbo-C / Turbo Pascal
;
; Running Target:
; PC-9801
;
; Requiring Resources:
; CPU: 8086
;
; Notes:
;
;
; Compiler/Assembler:
; TASM 3.0
; OPTASM 1.6
;
; Author:
; 恋塚昭彦
;
; Revision History:
; 92/11/15 Initial
func TEXT_PUTS
mov DX,BP ; push BP
mov BP,SP
push SI
push DI
; 引数
@@x = (RETSIZE+1+DATASIZE)*2
@@y = (RETSIZE+0+DATASIZE)*2
@@strp = (RETSIZE+0)*2
mov AX,[BP + @@y] ; アドレス計算
mov DI,AX
shl AX,1
shl AX,1
add DI,AX
shl DI,1 ; DI = y * 10
add DI,TextVramSeg
mov ES,DI
mov DI,[BP + @@x]
shl DI,1
_push DS
_lds SI,[BP+@@strp]
mov BP,DX ; pop BP
mov BX,0fedfh ; -2,-(20h + 1)
mov CX,7f7fh
mov DX,9f80h
lodsb
or AL,AL
je short @@EXITLOOP
EVEN
@@SLOOP: xor AH,AH
cmp AL,DL ; 80h 81-9f e0-fd ?
jbe short @@ANK_OR_RIGHT
cmp AL,DH ; 9fh
jbe short @@KANJI
cmp AL,BL ; 0dfh
jbe short @@ANK_OR_RIGHT
; cmp AL,0fdh
; jnb short ANK_OR_RIGHT
@@KANJI: mov AH,AL
lodsb ; 2文字目: 40-7e,80-fc
shl AH,1 ; e0..fc->60..98->40..78 または
; 81..9f->22..5e->02..3e にする
; 9f-fc -> 21-7e
cmp AL,DH ; 40-7e -> 21-5f,--ah
jnb short @@SKIP ; 80-9e -> 60-7e,--ah
cmp AL,DL
adc AX,BX ; (stc)
@@SKIP: sbb AL,BH ; 0feh
and AX,CX
xchg AH,AL
stosw
or AH,DL
@@ANK_OR_RIGHT: stosw
lodsb
or AL,AL
jne short @@SLOOP
@@EXITLOOP:
_pop DS
pop DI
pop SI
ret (2+datasize)*2
endfunc

View File

@ -172,81 +172,7 @@ include libs/master.lib/soundio.asm
include libs/master.lib/text_boxfilla.asm
include libs/BorlandC/text_clear.asm
include libs/master.lib/text_fillca.asm
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_2024 proc far
; sub_15D53+126P
arg_0 = dword ptr 4
arg_4 = word ptr 8
arg_6 = word ptr 0Ah
mov dx, bp
mov bp, sp
push si
push di
mov ax, [bp+arg_4]
mov di, ax
shl ax, 1
shl ax, 1
add di, ax
shl di, 1
add di, TextVramSeg
mov es, di
assume es:nothing
mov di, [bp+arg_6]
shl di, 1
push ds
lds si, [bp+arg_0]
mov bp, dx
mov bx, 0FEDFh
mov cx, 7F7Fh
mov dx, 9F80h
lodsb
or al, al
jz short loc_2080
loc_2056:
xor ah, ah
cmp al, dl
jbe short loc_207A
cmp al, dh
jbe short loc_2064
cmp al, bl
jbe short loc_207A
loc_2064:
mov ah, al
lodsb
shl ah, 1
cmp al, dh
jnb short loc_2071
cmp al, dl
adc ax, bx
loc_2071:
sbb al, bh
and ax, cx
xchg ah, al
stosw
or ah, dl
loc_207A:
stosw
lodsb
or al, al
jnz short loc_2056
loc_2080:
pop ds
pop di
pop si
retf 8
sub_2024 endp
include libs/master.lib/text_puts.asm
include libs/master.lib/text_putsa.asm
include libs/master.lib/vsync.asm
include libs/master.lib/vsync_wait.asm
@ -27818,13 +27744,13 @@ loc_15E45:
push 2
push ds
push offset asc_1DD84 ; " "
call sub_2024
call text_puts
lea ax, [di+4]
push ax
push 3
push ds
push offset asc_1DD84 ; " "
call sub_2024
call text_puts
mov byte ptr [si+1], 0
push word ptr [si+2]
push [bp+var_3+1]