📄 asm_colorx.asm
字号:
GetAddrxxyy: ; In esi-> PalBGR(1,1,1,2),ixx,iyy Out: new esi->B
;B = esi + (4 * (iy-1) * PICW + 4 * (ix-1))
;B = esi + 4 * [(iy-1) * PICW + (ix-1))]
mov eax,iyy
dec eax
mov ebx,PICW
mul ebx
mov ebx,ixx
dec ebx
add eax,ebx
shl eax,2 ; x4
add esi,eax
RET
;============================================================
DiffuseColorXUp: ; 5
;%define zN [ebp-40] ; zN = .9 for Diffuse REDEFINED OK
;%define zN2 [ebp-44] ; zN2 = 0.1
;%define ix [ebp-48]
;%define iy [ebp-52]
;%define culB [ebp-56]
;%define culG [ebp-60]
;%define culR [ebp-64]
;%define offset [ebp-68]
;%define ABSY [ebp-72]
;%define ABSX [ebp-76]
;%define A [ebp-80]
;%define numbr [ebp-84]
;%define ixx [ebp-88]
;%define iyy [ebp-92]
;%define cul [ebp-96]
;%define zNV [ebp-100] ; varying zN
mov esi,PtrPalBGR ; pts to PalBGR(1,1,1,1)
mov eax,PalSize
shl eax,2 ; x4
add esi,eax ; pts to PalBGR(1,1,1,2) Blue
push esi
pop edi ; copy
mov eax,Increment
add eax,2
shr eax,1 ;(Increment+2)\2
cmp eax,5
jne i5
mov eax,4
i5:
mov offset,eax
;-----------------------------------
mov ecx,1 ; iy = 1 to PICH - offset
IY5:
mov iy,ecx
push ecx
mov ecx,1 ; ix = 1 to PICW
IX5:
mov ix,ecx
mov ixx,ecx
push ecx
; Get LongCul @ ix,iy
Call near GetAddr
xor eax,eax
mov aL,byte[esi] ; B
shl eax,8
mov aL,byte[esi+1] ; G
shl eax,8
mov aL,byte[esi+2] ; R
push edi
pop esi
cmp eax,QBLongColor
jne near nex5
;=======================
mov eax,zN
mov zNV,eax ; zN = 0.9
mov eax,offset
mov ecx,eax ; OFFY = offset to 0
iyoff5:
mov eax,iy
add eax,ecx
mov iyy,eax ; iyy=iy+OFFY
;------------------------------
fld dword zNV
fld dword zN2 ; 0.1,zNV
fsubp st1 ; zNV-0.1
fstp dword zNV
Call near GetAddrxxyy
Call near FillPalBGR
push edi
pop esi
;------------------------------
dec ecx ; OFFY=OFFY-1
jnz near iyoff5
;=======================
nex5:
pop ecx
inc ecx ; ix+1
cmp ecx,PICW ; ix - PICW
jle near IX5
ney5:
pop ecx
inc ecx ; iy+1
mov eax,PICH
sub eax,offset
cmp ecx,eax ; iy-(PICH-offset)
jle near IY5
RET
;============================================================
DiffuseColorXDown: ; 6
mov esi,PtrPalBGR ; pts to PalBGR(1,1,1,1)
mov eax,PalSize
shl eax,2 ; x4
add esi,eax ; pts to PalBGR(1,1,1,2) Blue
push esi
pop edi ; copy
mov eax,Increment
add eax,2
shr eax,1 ;(Increment+2)\2
cmp eax,5
jne i6
mov eax,4
i6:
mov offset,eax
;-----------------------------------
mov ecx,1
add ecx,eax ; iy = 1+offset to PICH
IY6:
mov iy,ecx
push ecx
mov ecx,1 ; ix = 1 to PICW
IX6:
mov ix,ecx
mov ixx,ecx
push ecx
; Get LongCul @ ix,iy
Call near GetAddr
xor eax,eax
mov aL,byte[esi] ; B
shl eax,8
mov aL,byte[esi+1] ; G
shl eax,8
mov aL,byte[esi+2] ; R
push edi
pop esi
cmp eax,QBLongColor
jne near nex6
;=======================
mov eax,zN
mov zNV,eax ; zN = 0.9
mov eax,offset
neg eax
mov ecx,eax ; OFFY = -offset to 0
iyoff6:
mov eax,iy
add eax,ecx
mov iyy,eax ; iyy=iy+OFFY
;------------------------------
fld dword zNV
fld dword zN2 ; 0.1,zNV
fsubp st1 ; zNV-0.1
fstp dword zNV
Call near GetAddrxxyy
Call near FillPalBGR
push edi
pop esi
;------------------------------
inc ecx ; OFFY=OFFY+1
jnz near iyoff6
;=======================
nex6:
pop ecx
inc ecx ; ix+1
cmp ecx,PICW ; ix - PICW
jle near IX6
pop ecx
inc ecx ; iy+1
cmp ecx,PICH ; iy-PICH
jle near IY6
RET
;============================================================
DiffuseColorXLeft: ; 7
mov esi,PtrPalBGR ; pts to PalBGR(1,1,1,1)
mov eax,PalSize
shl eax,2 ; x4
add esi,eax ; pts to PalBGR(1,1,1,2) Blue
push esi
pop edi ; copy
mov eax,Increment
add eax,2
shr eax,1 ;(Increment+2)\2
cmp eax,5
jne i7
mov eax,4
i7:
mov offset,eax
;-----------------------------------
mov ecx,1 ; iy = 1 to PICH
IY7:
mov iy,ecx
mov iyy,ecx
push ecx
mov ecx,1
mov eax,offset
add ecx,eax ; ix = 1+offset to PICW
IX7:
mov ix,ecx
push ecx
; Get LongCul @ ix,iy
Call near GetAddr
xor eax,eax
mov aL,byte[esi] ; B
shl eax,8
mov aL,byte[esi+1] ; G
shl eax,8
mov aL,byte[esi+2] ; R
push edi
pop esi
cmp eax,QBLongColor
jne near nex7
;=======================
mov eax,zN
mov zNV,eax ; zN = 0.9
mov eax,offset
neg eax
mov ecx,eax ; OFFX = -offset to 0
ixoff7:
mov eax,ix
add eax,ecx
mov ixx,eax ; ixx=ix+OFFX
;------------------------------
fld dword zNV
fld dword zN2 ; 0.1,zNV
fsubp st1 ; zNV-0.1
fstp dword zNV
Call near GetAddrxxyy
Call near FillPalBGR
push edi
pop esi
;------------------------------
inc ecx ; OFFX=OFFX+1
jnz near ixoff7
;=======================
nex7:
pop ecx
inc ecx ; ix+1
cmp ecx,PICW ; ix - PICW
jle near IX7
pop ecx
inc ecx ; iy+1
cmp ecx,PICH ; iy-PICH
jle near IY7
RET
;============================================================
DiffuseColorXRight: ; 8
mov esi,PtrPalBGR ; pts to PalBGR(1,1,1,1)
mov eax,PalSize
shl eax,2 ; x4
add esi,eax ; pts to PalBGR(1,1,1,2) Blue
push esi
pop edi ; copy
mov eax,Increment
add eax,2
shr eax,1 ;(Increment+2)\2
cmp eax,5
jne i8
mov eax,4
i8:
mov offset,eax
;-----------------------------------
mov ecx,1 ; iy = 1 to PICH
IY8:
mov iy,ecx
mov iyy,ecx
push ecx
mov ecx,1 ; ix = 1 to PICW-offset
IX8:
mov ix,ecx
push ecx
; Get LongCul @ ix,iy
Call near GetAddr
xor eax,eax
mov aL,byte[esi] ; B
shl eax,8
mov aL,byte[esi+1] ; G
shl eax,8
mov aL,byte[esi+2] ; R
push edi
pop esi
cmp eax,QBLongColor
jne near nex8
;=======================
mov eax,zN
mov zNV,eax ; zN = 0.9
mov eax,offset
mov ecx,eax ; OFFX = offset to 0
ixoff8:
mov eax,ix
add eax,ecx
mov ixx,eax ; ixx=ix+OFFX
;------------------------------
fld dword zNV
fld dword zN2 ; 0.1,zNV
fsubp st1 ; zNV-0.1
fstp dword zNV
Call near GetAddrxxyy
Call near FillPalBGR
push edi
pop esi
;------------------------------
dec ecx ; OFFX=OFFX-1
jnz near ixoff8
;=======================
nex8:
pop ecx
inc ecx ; ix+1
mov eax,PICW
sub eax,offset ; PICW-offset
cmp ecx,PICW ; ix - (PICW-offset)
jle near IX8
pop ecx
inc ecx ; iy+1
cmp ecx,PICH ; iy-PICH
jle near IY8
RET
;============================================================
BrightSpotXpYp: ;9
;%define zN [ebp-40] ; zN = .9 for Diffuse REDEFINED OK
;%define zN2 [ebp-44] ; zN2 = 0.1
;%define ix [ebp-48]
;%define iy [ebp-52]
;%define culB [ebp-56]
;%define culG [ebp-60]
;%define culR [ebp-64]
;%define offset [ebp-68]
;%define ABSY [ebp-72]
;%define ABSX [ebp-76]
;%define A [ebp-80]
;%define numbr [ebp-84]
;%define ixx [ebp-88]
;%define iyy [ebp-92]
;%define cul [ebp-96]
;%define zNV [ebp-100] ; varying zN
%define Xp [ebp-40] ; iXp from VB
%define Yp [ebp-44] ; iYp from VB
%define rad [ebp-68]
%define theta [ebp-72]
%define zFrac [ebp-76]
%define d2r [ebp-80] ; pi/180, deg to rads
mov esi,PtrPalBGR ; pts to PalBGR(1,1,1,1)
mov eax,PalSize
shl eax,2 ; x4
add esi,eax ; pts to PalBGR(1,1,1,2) Blue
push esi
pop edi ; copy
mov eax,24
mov numbr,eax
mov eax,180
mov d2r,eax
fldpi
fild dword d2r ;180, pi
fdivp st1 ;pi/180
fstp dword d2r
mov ecx,1 ; rad=1 to 24*Increment
rad9:
push ecx
mov rad,ecx
;====================
; Calc 1+zFrac
fld1 ; 1
fild dword rad ; rad, 1
fild dword Increment
fild dword numbr
fmulp st1 ; (24*Increment), rad, 1
fdivp st1 ; rad/(24*Increment), 1
fsubp st1 ; zFrac = 1 - rad/(24*Increment)
fld1
faddp st1
fstp dword zFrac ; 1+zFrac
mov ecx,359 ; theta = 359 to 0
theta9:
mov theta,ecx
;-----------
; Calc ix
fild dword theta
fld dword d2r
fmulp st1
fsin
fild dword rad
fmulp st1 ; rad*sin(theta*d2r)
fld dword Xp
faddp st1 ; iXp+rad*sin(theta*d2r)
fistp dword ix
; Calc iy
fild dword theta
fld dword d2r
fmulp st1
fcos
fild dword rad
fmulp st1 ; rad*cos(theta*d2r)
fild dword PICH
fld dword Yp ; Yp, PICH
fsubp st1 ; PICH-Yp
faddp st1 ; (PICh-iYp)+rad*cos(theta*d2r)
fistp dword iy
; Ensure ix,iy in-range
mov eax,ix
cmp eax,1
jl nextheta9
cmp eax,PICW
jg nextheta9
mov eax,iy
cmp eax,1
jl nextheta9
cmp eax,PICH
jg nextheta9
; Modify BGR
Call near GetAddr
Call near FillModTestBGR
push edi
pop esi
nextheta9:
;-----------
dec ecx
jnz theta9
;====================
pop ecx
inc ecx ; rad=rad+1
mov eax,Increment
mov ebx,24
mul ebx
cmp ecx,eax ;rad-(24*Increment)
jle near rad9
RET
;============================================================
FillModTestBGR: ;In: esi, (1+zFrac) in zFrac
; Calc culBGR = PalBGR()*(1+zFrac)
movzx eax,byte[esi] ; B
mov cul,eax
fild dword cul
fld dword zFrac
fmulp st1
fistp dword cul
mov eax,cul
cmp eax,255
jbe BT0
mov eax,culB
jmp BOK
BT0:
cmp eax,0
jae BOK
xor eax,eax
BOK:
mov byte[esi],aL
;-----------------
movzx eax,byte[esi+1] ; G
mov cul,eax
fild dword cul
fld dword zFrac
fmulp st1
fistp dword cul
mov eax,cul
cmp eax,255
jbe GT0
mov eax,culG
jmp GOK
GT0:
cmp eax,0
jae GOK
xor eax,eax
GOK:
mov byte[esi+1],aL
;-----------------
movzx eax,byte[esi+2] ; R
mov cul,eax
fild dword cul
fld dword zFrac
fmulp st1
fistp dword cul
mov eax,cul
cmp eax,255
jbe RT0
mov eax,culR
jmp ROK
RT0:
cmp eax,0
jae ROK
xor eax,eax
ROK:
mov byte[esi+2],aL
;-----------------
RET
;============================================================
;============================================================
;mov ebx,[ebp+20]
;mov [ebx],eax
;ret
;jmp GETOUT
;mov eax,ecx
;mov ebx,[ebp+20]
;mov [ebx],eax
;============================================================
;RANDNOISE: ; Out: aL & Seed = rand(0-255)
; mov eax,011813h ; 71699 prime
; imul DWORD Seed
; add eax, 0AB209h ; 700937 prime
;
;
; rcr eax,1 ; leaving out gives vertical lines plus
; ; faint horizontal ones, tartan
;
; ;----------------------------------------
; jc ok ; these 2 have little effect
; rol eax,1 ;
;ok: ;
; ;----------------------------------------
;
; ;----------------------------------------
; ;dec eax ; these produce vert lines
; ;inc eax ; & with fsin marble arches
; ;----------------------------------------
;
; mov Seed,eax ; save seed
; and eax,255
; mov aran,eax ; aran = rnd(0-255)
;RET
;============================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -