home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 3
/
FREEWARE.BIN
/
towns_os
/
tvi
/
tvi_src.lzh
/
ASM
/
PALCALC.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-11-01
|
4KB
|
142 lines
PAGE 255,132
;*****************************************************************************
;$Header: palcalc.asv 1.8 90/11/01 16:30:28 Nam Rel $
;*****************************************************************************
extrn tbl_expand:word
extrn tbl_compless:byte
.386p
code segment dword public use32 'code'
assume cs:code
;************************************************************
; palet 最適化
;************************************************************
;*** get min-distination ***
; void calc_palet(int dword)
; ↑テーブルオフセットadd(dword)
public calc_palet
db 'calc_palet',10
align 4
calc_palet proc near
cli ;割り込み禁止
mov eax,dword ptr [esp+4] ;eax=(short *)tbl_col_dist
push ebx
push ebp
push esi
push edi
push es
mov edi,eax ;edi=(short *)tbl_col_dist
mov ebp,dword ptr ds:[tbl_compless] ;ebp=(char *)tbl_compless
xor ecx,ecx ;ecx=0 ※'90.10.27
mov eax,dword ptr ds:[tbl_expand] ;(short *)tbl_expand
push eax ;[esp]=(short *)tbl_expand
mov ax,ds
mov es,ax ;es=ds
cld ;loopはincで
align 4 ;高速化のため境界整合
calc_palet_loop_1:
mov esi,[esp] ;esi=(short *)tbl_expand
xor dx,dx ;(※'90.10.27)
dec dx ;dx=0ffffh(※c_value_min初期化)
mov ax,cx
and ax,7c00h ;'90.10.26(shift桁合わせ省略)
push ax ;col_green
mov ax,cx
and ax,03e0h
push ax ;col_red
mov ax,cx
and ax,001fh
push ax ;col_blue
shl ecx,16 ;上位16bitへ / cx=0
align 4 ;高速化のため境界整合
calc_palet_loop_2:
mov ax,word ptr ds:[esi] ;***green
and ax,7c00h ;'90.10.26
sub ax,word ptr [esp+4] ;col_g (※'90.10.27)
jnc short set_green
neg ax ;結果が負なら反転
set_green:
movzx ebx,ax ;bx上位16bit=0
mov ax,word ptr ds:[esi] ;***red
and ax,03e0h
sub ax,word ptr [esp+2] ;col_r (※'90.10.27)
jnc short set_red
neg ax ;結果が負なら反転
set_red:
or bx,ax
lodsw ;ax=blue/esi+=2 (10/27)
and ax,001fh
sub ax,word ptr [esp] ;col_b (※'90.10.27)
jnc short set_blue
neg ax ;結果が負なら反転
set_blue:
or bx,ax
mov ax,word ptr es:[edi+ebx*2] ;'90.10.26
;≒shl ebx,1 / mov ax,word ptr es:[edi+ebx]
cmp ax,dx ;c_value_minと比較
jae short set_min_color ;上位or等しければjmp
mov dx,ax ;save min_color_value
mov byte ptr ds:[ebp],cl ;color[ebp]=min_colorNo
set_min_color:
inc cx ;color[k++]
cmp cx,255 ;0~255までのループ
jna short calc_palet_loop_2
add esp,6 ;≒(pop ax)*3
inc ebp ;ebp++
shr ecx,16 ;上位16bit取り出し
inc cx ;i++
cmp cx,32768 ;※0~32767までのループ
jna calc_palet_loop_1
pop esi ;esi=(short*)tbl_expand
pop es
pop edi
pop esi
pop ebp
pop ebx
sti ;割り込み許可
ret
calc_palet endp
code ends
data segment dword public use32 'data'
assume ds:data
min_colNo dw 0
data ends
end
;*****************************************************************************
;$Log: RCS/palcalc.asv $
; Revision 1.8 90/11/01 16:30:28 Nam
; Release at V0.0 L18d
;
; Revision 1.7 90/11/01 16:30:28 Nam
; Rel V0.0L17 at '90.11.2 for FPICS.
;
; Revision 1.6 90/11/01 16:30:28 Nam
; '1-32766' -> '0-32767'
;
; Revision 1.5 90/10/27 22:51:06 Nam
; faster 1:30->1:15 (data area cut)
;
; Revision 1.4 90/10/27 17:26:52 Nam
; a littele faster
;
; Revision 1.3 90/10/26 19:44:44 Nam
; a little faster
;
; Revision 1.2 90/10/24 20:02:04 Nam
; separate a vector-table-object from main routine
;
; Revision 1.1 90/10/10 18:37:28 Nam
; Initial revision
;
;*****************************************************************************