[Reduction] #441: grcg_round_boxfill

No local symbol definitions for variables here, as they are used in both the
normal function and the retfunc.
This commit is contained in:
nmlgc 2014-09-01 21:08:57 +02:00
parent 6250206235
commit b82a03c3f8
3 changed files with 211 additions and 308 deletions

View File

@ -0,0 +1,195 @@
PAGE 98,120
; graphics - grcg - round - boxfill - PC98V
;
; DESCRIPTION:
; 角の丸い四角形塗りつぶし (level 2)
;
; FUNCTION:
; void far _pascal grcg_round_boxfill( int x1, int y1, int x2, int y2, unsigned r ) ;
; PARAMETERS:
; int x1,y1 左上角の座標
; int x2,y2 右下角の座標
; unsigned r 四隅の円の半径
;
; BINDING TARGET:
; Microsoft-C / Turbo-C
;
; RUNNING TARGET:
; NEC PC-9801 Normal mode
;
; REQUIRING RESOURCES:
; CPU: V30
; GRAPHICS ACCELARATOR: GRAPHIC CHARGER
;
; COMPILER/ASSEMBLER:
; TASM 3.0
; OPTASM 1.6
;
; NOTES:
; ・描画規則はgrcg_hline, grcg_boxfillに依存しています。
; ・色をつけるには、グラフィックチャージャーを利用してください。
; ・grc_setclip()によるクリッピングに対応しています。
;
; AUTHOR:
; 恋塚昭彦
;
; 関連関数:
; grc_setclip()
; grcg_hline(), grcg_boxfill()
;
; HISTORY:
; 93/ 3/ 1 Initial
MRETURN macro
pop DI
pop SI
leave
ret 10
endm
; 引数
x1 = (RETSIZE+5)*2
y1 = (RETSIZE+4)*2
x2 = (RETSIZE+3)*2
y2 = (RETSIZE+2)*2
r = (RETSIZE+1)*2
retfunc GC_RBOXF_BOXFILL
push word ptr [BP+x1]
push word ptr [BP+y1]
push word ptr [BP+x2]
push word ptr [BP+y2]
call GRCG_BOXFILL
MRETURN
endfunc
func GRCG_ROUND_BOXFILL ; {
enter 2,0
push SI
push DI
; 変数
s = -2
mov AX,[BP+r]
mov BX,[BP+x1]
mov SI,[BP+x2]
cmp BX,SI
jle short @@SKIP1
xchg BX,SI
mov [BP+x1],BX
mov [BP+x2],SI
@@SKIP1:
sub SI,BX
shr SI,1 ; SI = abs(x2 - x1) / 2
sub AX,SI ; AX = min(AX,SI)
sbb DX,DX
and AX,DX
add AX,SI
mov CX,[BP+y1]
mov DI,[BP+y2]
cmp CX,DI
jle short @@SKIP2
xchg CX,DI
@@SKIP2:
mov BX,DI ; BX = max(y1,y2)
sub DI,CX
shr DI,1 ; DI = abs(y2 - y1) / 2
sub AX,DI ; AX = min(AX,DI)
sbb DX,DX
and AX,DX
add AX,DI
jz short GC_RBOXF_BOXFILL ; 半径が 0 になったら長方形になる
mov [BP+s],AX
add CX,AX ; y1,y2を内側へずらす
sub BX,AX
mov [BP+y1],CX
mov [BP+y2],BX
mov SI,AX ; SI = wx
inc CX
dec BX
cmp BX,CX
jl short @@SKIP_BOXFILL
push word ptr [BP+x1]
push CX
push word ptr [BP+x2]
push BX
call GRCG_BOXFILL
@@SKIP_BOXFILL:
add [BP+x1],SI
sub [BP+x2],SI
mov DI,0 ; DI = wy
@@LOOP_8:
mov AX,[BP+x1]
sub AX,SI
push AX ; x1 - wx
mov AX,[BP+x2]
add AX,SI
push AX ; x2 + wx
mov AX,[BP+y1]
sub AX,DI ; y1 - wy
push AX
call GRCG_HLINE
mov AX,[BP+x1]
sub AX,SI
push AX ; x1 - wx
mov AX,[BP+x2]
add AX,SI
push AX ; x2 + wx
mov AX,[BP+y2]
add AX,DI ; y1 + wy
push AX
call GRCG_HLINE
mov AX,DI
stc
rcl AX,1 ; (wy << 1) + 1
sub [BP+s],AX
jns short @@LOOP_8E
mov AX,[BP+x1]
sub AX,DI
push AX ; x1 - wy
mov AX,[BP+x2]
add AX,DI
push AX ; x2 + wy
mov AX,[BP+y1]
sub AX,SI ; y1 - wx
push AX
call GRCG_HLINE
mov AX,[BP+x1]
sub AX,DI
push AX ; x1 - wy
mov AX,[BP+x2]
add AX,DI
push AX ; x2 + wy
mov AX,[BP+y2]
add AX,SI ; y1 + wx
push AX
call GRCG_HLINE
dec SI ; s += --wx << 1 ;
mov AX,SI
shl AX,1
add [BP+s],AX
@@LOOP_8E:
inc DI
cmp SI,DI
jae short @@LOOP_8
MRETURN
endfunc ; }

View File

@ -58,153 +58,7 @@ include libs/master.lib/grc_setclip.asm
include libs/master.lib/grcg_fill.asm
include libs/master.lib/grcg_hline.asm
include libs/master.lib/grcg_polygon_c.asm
; ---------------------------------------------------------------------------
; START OF FUNCTION CHUNK FOR sub_EAA
loc_E94:
push word ptr [bp+0Eh]
push word ptr [bp+0Ch]
push word ptr [bp+0Ah]
push word ptr [bp+08h]
call grcg_boxfill
pop di
pop si
leave
retf 0Ah
; END OF FUNCTION CHUNK FOR sub_EAA
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_EAA proc far
var_2 = word ptr -2
arg_0 = word ptr 6
arg_2 = word ptr 8
arg_4 = word ptr 0Ah
arg_6 = word ptr 0Ch
arg_8 = word ptr 0Eh
; FUNCTION CHUNK AT 0E94 SIZE 00000016 BYTES
enter 2, 0
push si
push di
mov ax, [bp+arg_0]
mov bx, [bp+arg_8]
mov si, [bp+arg_4]
cmp bx, si
jle short loc_EC5
xchg bx, si
mov [bp+arg_8], bx
mov [bp+arg_4], si
loc_EC5:
sub si, bx
shr si, 1
sub ax, si
sbb dx, dx
and ax, dx
add ax, si
mov cx, [bp+arg_6]
mov di, [bp+arg_2]
cmp cx, di
jle short loc_EDD
xchg cx, di
loc_EDD:
mov bx, di
sub di, cx
shr di, 1
sub ax, di
sbb dx, dx
and ax, dx
add ax, di
jz short loc_E94
mov [bp+var_2], ax
add cx, ax
sub bx, ax
mov [bp+arg_6], cx
mov [bp+arg_2], bx
mov si, ax
inc cx
dec bx
cmp bx, cx
jl short loc_F0E
push [bp+arg_8]
push cx
push [bp+arg_4]
push bx
call grcg_boxfill
loc_F0E:
add [bp+arg_8], si
sub [bp+arg_4], si
mov di, 0
loc_F17:
mov ax, [bp+arg_8]
sub ax, si
push ax
mov ax, [bp+arg_4]
add ax, si
push ax
mov ax, [bp+arg_6]
sub ax, di
push ax
call grcg_hline
mov ax, [bp+arg_8]
sub ax, si
push ax
mov ax, [bp+arg_4]
add ax, si
push ax
mov ax, [bp+arg_2]
add ax, di
push ax
call grcg_hline
mov ax, di
stc
rcl ax, 1
sub [bp+var_2], ax
jns short loc_F81
mov ax, [bp+arg_8]
sub ax, di
push ax
mov ax, [bp+arg_4]
add ax, di
push ax
mov ax, [bp+arg_6]
sub ax, si
push ax
call grcg_hline
mov ax, [bp+arg_8]
sub ax, di
push ax
mov ax, [bp+arg_4]
add ax, di
push ax
mov ax, [bp+arg_2]
add ax, si
push ax
call grcg_hline
dec si
mov ax, si
shl ax, 1
add [bp+var_2], ax
loc_F81:
inc di
cmp si, di
jnb short loc_F17
pop di
pop si
leave
retf 0Ah
sub_EAA endp
include libs/master.lib/grcg_round_boxfill.asm
include libs/master.lib/grcg_setcolor.asm
include libs/master.lib/gaiji_backup.asm
include libs/master.lib/gaiji_entry_bfnt.asm
@ -7396,7 +7250,7 @@ loc_BA4B:
lea ax, [di+48h]
push ax
push 8
call sub_EAA
call grcg_round_boxfill
push 0C0h ; 'À'
push 0
call grcg_setcolor
@ -7407,7 +7261,7 @@ loc_BA4B:
lea ax, [di+40h]
push ax
push 8
call sub_EAA
call grcg_round_boxfill
call grcg_off
mov bx, [bp+arg_0]
imul bx, 0Ch
@ -7468,7 +7322,7 @@ sub_BAFC proc far
push 208h
push 38h ; '8'
push 8
call sub_EAA
call grcg_round_boxfill
push 0C0h ; 'À'
push 0
call grcg_setcolor
@ -7477,7 +7331,7 @@ sub_BAFC proc far
push 200h
push 30h ; '0'
push 8
call sub_EAA
call grcg_round_boxfill
call grcg_off
push word ptr off_DD46+2
push word ptr off_DD46
@ -7497,7 +7351,7 @@ sub_BAFC proc far
push 278h
push 68h ; 'h'
push 8
call sub_EAA
call grcg_round_boxfill
push 0C0h ; 'À'
push 0
call grcg_setcolor
@ -7506,7 +7360,7 @@ sub_BAFC proc far
push 270h
push 60h ; '`'
push 8
call sub_EAA
call grcg_round_boxfill
call grcg_off
push word ptr off_DD4A+2
push word ptr off_DD4A

View File

@ -63,153 +63,7 @@ include libs/master.lib/grcg_boxfill.asm
include libs/master.lib/grcg_byteboxfill_x.asm
include libs/master.lib/grcg_hline.asm
include libs/master.lib/grcg_polygon_c.asm
; ---------------------------------------------------------------------------
; START OF FUNCTION CHUNK FOR sub_FF0
loc_FDA:
push word ptr [bp+0eh]
push word ptr [bp+0ch]
push word ptr [bp+0ah]
push word ptr [bp+08h]
call grcg_boxfill
pop di
pop si
leave
retf 0Ah
; END OF FUNCTION CHUNK FOR sub_FF0
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_FF0 proc far
var_2 = word ptr -2
arg_0 = word ptr 6
arg_2 = word ptr 8
arg_4 = word ptr 0Ah
arg_6 = word ptr 0Ch
arg_8 = word ptr 0Eh
; FUNCTION CHUNK AT 0FDA SIZE 00000016 BYTES
enter 2, 0
push si
push di
mov ax, [bp+arg_0]
mov bx, [bp+arg_8]
mov si, [bp+arg_4]
cmp bx, si
jle short loc_100B
xchg bx, si
mov [bp+arg_8], bx
mov [bp+arg_4], si
loc_100B:
sub si, bx
shr si, 1
sub ax, si
sbb dx, dx
and ax, dx
add ax, si
mov cx, [bp+arg_6]
mov di, [bp+arg_2]
cmp cx, di
jle short loc_1023
xchg cx, di
loc_1023:
mov bx, di
sub di, cx
shr di, 1
sub ax, di
sbb dx, dx
and ax, dx
add ax, di
jz short loc_FDA
mov [bp+var_2], ax
add cx, ax
sub bx, ax
mov [bp+arg_6], cx
mov [bp+arg_2], bx
mov si, ax
inc cx
dec bx
cmp bx, cx
jl short loc_1054
push [bp+arg_8]
push cx
push [bp+arg_4]
push bx
call grcg_boxfill
loc_1054:
add [bp+arg_8], si
sub [bp+arg_4], si
mov di, 0
loc_105D:
mov ax, [bp+arg_8]
sub ax, si
push ax
mov ax, [bp+arg_4]
add ax, si
push ax
mov ax, [bp+arg_6]
sub ax, di
push ax
call grcg_hline
mov ax, [bp+arg_8]
sub ax, si
push ax
mov ax, [bp+arg_4]
add ax, si
push ax
mov ax, [bp+arg_2]
add ax, di
push ax
call grcg_hline
mov ax, di
stc
rcl ax, 1
sub [bp+var_2], ax
jns short loc_10C7
mov ax, [bp+arg_8]
sub ax, di
push ax
mov ax, [bp+arg_4]
add ax, di
push ax
mov ax, [bp+arg_6]
sub ax, si
push ax
call grcg_hline
mov ax, [bp+arg_8]
sub ax, di
push ax
mov ax, [bp+arg_4]
add ax, di
push ax
mov ax, [bp+arg_2]
add ax, si
push ax
call grcg_hline
dec si
mov ax, si
shl ax, 1
add [bp+var_2], ax
loc_10C7:
inc di
cmp si, di
jnb short loc_105D
pop di
pop si
leave
retf 0Ah
sub_FF0 endp
include libs/master.lib/grcg_round_boxfill.asm
include libs/master.lib/grcg_setcolor.asm
include libs/master.lib/get_machine_98.asm
include libs/master.lib/get_machine_at.asm
@ -8801,7 +8655,7 @@ loc_D353:
lea ax, [di+48h]
push ax
push 8
call sub_FF0
call grcg_round_boxfill
push large 0C00002h
call grcg_setcolor
push si
@ -8811,7 +8665,7 @@ loc_D353:
lea ax, [di+40h]
push ax
push 8
call sub_FF0
call grcg_round_boxfill
mov dx, 7Ch ; '|'
mov al, 0
out dx, al
@ -9060,7 +8914,7 @@ sub_D595 proc near
lea ax, [si+1Fh]
push ax
push 8
call sub_FF0
call grcg_round_boxfill
lea ax, [di+8]
push ax
lea ax, [si+20h]
@ -9070,7 +8924,7 @@ sub_D595 proc near
lea ax, [si+37h]
push ax
push 8
call sub_FF0
call grcg_round_boxfill
push 88h ; 'ˆ'
lea ax, [si+8]
push ax
@ -9078,7 +8932,7 @@ sub_D595 proc near
lea ax, [si+1Fh]
push ax
push 8
call sub_FF0
call grcg_round_boxfill
push large 0C00002h
call grcg_setcolor
push di
@ -9088,7 +8942,7 @@ sub_D595 proc near
lea ax, [si+17h]
push ax
push 8
call sub_FF0
call grcg_round_boxfill
push di
lea ax, [si+18h]
push ax
@ -9097,14 +8951,14 @@ sub_D595 proc near
lea ax, [si+2Fh]
push ax
push 8
call sub_FF0
call grcg_round_boxfill
push 80h ; '€'
push si
push 13Fh
lea ax, [si+17h]
push ax
push 8
call sub_FF0
call grcg_round_boxfill
mov dx, 7Ch ; '|'
mov al, 0
out dx, al