home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
m
/
mask
/
!Mask
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1993-09-11
|
96KB
|
4,370 lines
>Mask
Michel Grimminck
"Hourglass_Smash":
" at line ";
'Version$="1.10":version=
(Version$)
init:
main:
lastmove=
( A$=
A$<>""
key:lastmove=
X,Y,B:
B<>0
lastmove=
-lastmove)>6*60*100
joke:B=0:lastmove=
B<>0
B>0
testbutton:
A$<>"none"
key:B=0
B>0
X>XS/2-32
X<(XS/2-32+MX)
selectmask:B=0
B>0
X>=PX+16
X<=PX+32
Y>=Yd0
Y<=Yd1
B>1
X>=PX
X<=PX+48
Y<Yd0
M0+=1:
changeM0:B=0
B>1
X>=PX
X<=PX+48
Y>Yd1
M0-=1:
changeM0:B=0
B=1
X>=PX
X<=PX+48
Y<Yd0
M0-=1:
changeM0:B=0
B=1
X>=PX
X<=PX+48
Y>Yd1
M0+=1:
changeM0:B=0
B=1
X<PX
Y>YS/2
makesection:B=0
B=4
X<PX
Y<PY
makelocal:B=0
(B=1
B=2)
X<PX
Y<PY
editpixel:B=0
B=4
X<PX
Y>YS/2
(-1)
gsline:B=0
B=4
X<PX
Y>YS/2
setxy
B=2
makeMask(Type,Mcurrent):
update(Mcurrent)
( Dcurrent=(Y-Yd0)/(Yd1-Yd0):
printD
B=2
makeMask(Type,Mcurrent):
update(Mcurrent)
Y0=Y:
X,Y,B:
B>0
PX+24,Y
Y<>Y0
inversegetbxy(X,Y,
((X-ZOOM!0)/Xc*SFX)+SFX
Yt=(ZOOM!12-Y)/Yc*SFY+SFY
getxy(X,Y,
.2Xt=
((X-SFX)/SFX)*Xc+ZOOM!0:
Xt<0
Xt=ZOOM!0
/6Yt=ZOOM!12+1-
((Y-YS/2)/SFY)*Yc:
Yt<0
Yt=ZOOM!4
getbxy(X,Y,
32Xt=
((X-SFX)/SFX)*Xc+ZOOM!0:
Xt<0
Xt=ZOOM!0
42Yt=
(ZOOM!12+1-
(Y/SFY)*Yc):
Yt<0
Yt=ZOOM!4
setxy
getxy(X,Y,Xt,Yt)
Xt>=0
Xt<!MainX
Yt>=0
Yt<!MainY
Xcurrent=Xt:Ycurrent=Yt:
printXY
gsline
!Main24=
"Not implemented for <=8 bpp files":
"Making line, release shift to abort"
X0=X:Y0=Y
Xold=X0:Yold=Y0:
X,Y,X,Y
X,Y,B
X>=PX
X=PX-1
Y>=PY+YS/2
Y=PY+YS/2-1
Y<=YS/2
Y=YS/2+1
X<>Xold
Y<>Yold
X0,Y0,Xold,Yold:
X,Y,X0,Y0:Xold=X:Yold=Y
(-1) =
"Shift was released, operation aborted":
X,Y,X0,Y0:
X,Y,X0,Y0
getxy(X0,Y0,Xt0,Yt0)
getxy(X,Y,Xt,Yt)
O1A%=Xt:B%=Yt:
ReadRGB:
2:L%(R%)=RGB?R%:
P3A%=Xt0:B%=Yt0:
ReadRGB:
2:M%(R%)=RGB?R%:
M%()=M%()-L%()
((Xt0-Xt)^2+(Yt0-Yt)^2)+1
DX=(Xt0-Xt)/L:DY=(Yt0-Yt)/L
L:X%=Xt+T%*DX:Y%=Yt+T%*DY
U, AD%=MASK(Mcurrent)+!MainX*Y%+X%:?AD%=0
V$ A%=!MainData+!MainLine*Y%+3*X%
R%=0
2:A%?R%=L%(R%)+T%*M%(R%)/L:
displayMainOrig(1):
update(Mcurrent)
makesection
X0=X:Y0=Y
Xold=X0:Yold=Y0:
X,Y,0,0
X,Y,B
X>=PX
X=PX-1
Y>=PY+YS/2
Y=PY+YS/2-1
Y<=YS/2
Y=YS/2+1
X<>Xold
Y<>Yold
X0,Y0,Xold-X0,Yold-Y0:
X0,Y0,X-X0,Y-Y0:Xold=X:Yold=Y
X0,Y0,X-X0,Y-Y0
X<X0
X,X0
Y<Y0
Y,Y0
getxy(X0,Y0,Xt0,Yt0)
getxy(X,Y,Xt,Yt)
do0:AD%=MASK(Mcurrent)
Y%=Yt
Yt0:AD%=MASK(Mcurrent)+!MainX*Y%:A%=AD%+Xt0:B%=AD%+Xt:C%=1:
VULMEM:
update(Mcurrent)
makelocal
getbxy(X,Y,Xt,Yt):
Xt<0
Xt=0
Yt<0
Yt=0
AD%=MASK(Mcurrent)
C%=?(AD%+!MainX*Yt+Xt)
fill(Xt,Yt,1500,2)
IK%
C%=1
A%=AD%:
Swap12
IK%
C%=0
A%=AD%:
Filter2
A%=AD%:
Filter
update(Mcurrent)
line(X0,Y0,X1,Y1)
L,DX,T%,X%,Y%
X0+=.5:Y0+=.5:X1+=.5:Y1+=.5
((X1-X0)^2+(Y1-Y0)^2)+1
DX=(X1-X0)/L:DY=(Y1-Y0)/L
L:X%=X0+T%*DX:Y%=Y0+T%*DY
-AD%=MASK(Mcurrent)+!MainX*Y%+X%:?AD%=COL%
editpixel
getbxy(X,Y,Xt0,Yt0)
B=1
COL%=0
B=2
COL%=1
X0=X:Y0=Y:
X,Y,B0
getbxy(X,Y,Xt,Yt)
line(Xt0,Yt0,Xt,Yt)
Xt0=Xt:Yt0=Yt
update(Mcurrent)
B0=0
"Seed: Please select a mask":M1%=
input
seedintern
M1%=Mcurrent
"Seed on itself has no effect":
"Selecting seeds"
Max%=12000
mc_maxblock:
error$:
mc_assign(M%):
error$:
Max%>= M%/8/4
Max%=M%/8/4-1
T%=L%:H%=1
AD%=MASK(M1%):P%=0
!MainY-1:AD%=MASK(M1%)+!MainX*Y%
!MainX-1
AD%?X%=1
T%!(4*P%)=X%+65536*Y%:
P%<(Max%-1)
P%+=1
DX%=!MainX
P%=Max%-1
"Not all seeds are used"
;P%; " seeds used"
8C%=1:COL%=2:AD%=MASK(Mcurrent):DPT%=1400:
seededfill
A%=AD%:
Filter
update(Mcurrent)
fill(X%,Y%,DPT%,COL%)
P%,DX%,T%,H%,A%,B%,L%,M%,TN%
C%=COLOR
P%=1:DX%=!MainX
mc_maxblock:
error$:
mc_assign(M%):
error$:
T%=L%:H%=1
1T%!0=X%+65536*Y%:A%=AD%+!MainX*Y%+X%:?A%=COL%
seededfill
!FillAD=AD%:!FillKL=COL%
P%*4*5 >=M%
mc_release(L%):
"Operation failed due to memory problems":
H%=0
TN%=L%
TN%=L%+M%-P%*4*4
!FillStoreAD=TN%:A%=T%
!FillNP=0:B%=P%:
Fill
T%=TN%:P%=!FillNP
DPT%-=1:H%=1-H%
P%=0
DPT%<0
mc_release(L%):
error$:
"V","v" :
version
"D","d" :
zoomtoc
"C","c" :
unzoomtoc
"Z","z" :
"X","x" :
unzoom
"0" :
printbutton("0",
"1" :
printbutton("1",
"andnot" :
andnot:
printbutton("andnot",
"=","copy" :
copy:
printbutton("copy",
"A","a","and" :
printbutton("and",
"O","o","or" :
printbutton("or",
"E","e","eor" :
printbutton("eor",
"N","n","not" :
printbutton("not",
"S","s","save":
save:
printbutton("save",
"1","grey" :
cleartypes:
printbutton("grey",
):Type=0:
makeMask(Type,Mcurrent):
update(Mcurrent)
"2","rgb" :
cleartypes:
printbutton("rgb",
):Type=1:
makeMask(Type,Mcurrent):
update(Mcurrent)
"3","color" :
cleartypes:
printbutton("color",
):Type=2:
makeMask(Type,Mcurrent):
update(Mcurrent)
"edge:grey" :
cleartypes:
printbutton("edge:grey",
):Type=3:
makeMask(Type,Mcurrent):
update(Mcurrent)
"hue" :
cleartypes:
printbutton("hue",
):Type=4:
makeMask(Type,Mcurrent):
update(Mcurrent)
"save:pic" :
clearsave:SaveType$="save:pic":
printbutton("save:pic",
X,Y,B:
"save:smpic" :
clearsave:SaveType$="save:smpic":
printbutton("save:smpic",
X,Y,B:
"save:mask" :
clearsave:SaveType$="save:mask":
printbutton("save:mask",
X,Y,B:
"black","white","red","green","blue","purple","cyan","yellow","cgrey","darkred","darkblue":
setmaskcolor(A$):
displayMain(Mcurrent)
"noise" :
noise(noise):
printbutton("noise",
"noise:1","noise:2","noise:3","noise:4","noise:5","noise:6","noise:8" :noise=
A$,1)):
clearnoise:
printbutton(A$,
X,Y,B:
"dilation" :
dilation:
printbutton("dilation",
"dilation:1","dilation:3","dilation:5","dilation:6","dilation:8" :dilation=
A$,1)):
cleardilation:
printbutton(A$,
X,Y,B:
"load","l","L":
load:
printbutton("load",
"load:mask","load:pic","load:back" :
printbutton(LoadType$,
printbutton(A$,
):LoadType$=A$:
X,Y,B:
mc_showmap
"T":
tidymem
"seed" :
seed:
printbutton("seed",
"large" :
large:
printbutton("large",
"invall" :
inverse("all"):
printbutton(A$,
"invmask" :
inverse("mask"):
printbutton(A$,
" :
speedtest
"erase" :
erase:
printbutton(A$,
"24bit" :
24bit:
printbutton(A$,
"changecolor" :
changecolor:
printbutton(A$,
"changegrey" :
changegrey:
printbutton(A$,
"correctcol" :
correctcol:
printbutton(A$,
"gamma" :
gamma:
printbutton(A$,
"sceleton" :
sceleton(1):
update(Mcurrent):
printbutton(A$,
"pal" :!pal=1-!pal:
setuppal(
displayMainOrig(1):
update(Mcurrent):
printbutton("pal",-!pal)
"=":T%=
checkpal:
;Colors?T%;:
"morph","m","M":
transform:
printbutton("morph",
"dma" :dma=1-dma:
printbutton("dma",dma-1):
X,Y,B:
"fastdisplay" :FD=1-FD:
printbutton("fastdisplay",-FD):
displayMainOrig(1):
X,Y,B:
"flipy" :
flipy:
printbutton(A$,
displayMainOrig(1)
"flipx" :
flipx:
printbutton(A$,
displayMainOrig(1)
"contrast" :
contrast:
printbutton(A$,
displayMainOrig(1)
"sharp" :
sharp:
printbutton(A$,
displayMainOrig(1)
"loadmap" :
loadmap:
printbutton(A$,
"\" :
compress
"|" :
testmem
"J" :
"K" :
lines
"tundo" :undo=
undo:
printbutton("tundo",undo):
X,Y,B:
"undo" :
undo:
printbutton(A$,
dmaon
U%,F%,L%
"OS_File",5,"<Wimp$ScrapDir>.MaskBackup"
U%,,F%,,L%:F%=(F% >>8)
L%<>!MainL
"Unable to undo":
printDiskAccess(
"OS_File",255,"<Wimp$ScrapDir>.MaskBackup",MAIN
printDiskAccess(
displayMainOrig(1)
backup
undo
printDiskAccess(
'CH%=
("<Wimp$ScrapDir>.MaskBackup")
"OS_GBPB",&02,CH%,MAIN,!MainL
"SetType <Wimp$ScrapDir>.MaskBackup 690"
printDiskAccess(
OX,OY,X0,Y0,B0,X,Y,B,R,S,ROT,XL,YL,DX,DY
RECTANGLEFILL SFX,YS/2+SFY,PX-SFX*2,PY-SFY*2
"Let's not waste those ";
(12*index+.5);" mips...."
(1)<.45
lines:
OX=PX/2:OY=PY/2+YS/2
R=0:S=0.003:ROT=.015
(1)<.3
ROT=ROT*1.5:S=S*1.5
X0,Y0,B0
(50)+120
(50)+120
(1)*(PX-SFX-XL)+SFX -OX
(1)*(PY-SFY-YL)+SFY+YS/2 -OY
%%DX=(
(1)-.5)*R-S*(X+XL/2)-Y*ROT-1
&#DY=(
(1)-.5)*R-S*(Y+YL/2)+X*ROT
X+=OX:Y+=OY
(X+DX)>SFX
(Y+DY)>(YS/2+SFY)
(X+DX+XL+SFX)<PX
(Y+DY+YL+SFY)<(PY+YS/2)
X,Y,XL,YL
X+DX,Y+DY
(1)<1.5E-4
(255):
X,Y,XL,YL
X,Y,B
(0)<>""
X<>X0
Y<>Y0
B<>0
displayMainOrig(1)
lines
T%,L,K,G,M,M2,OX,OY,B,X0,X1,Y0,Y1,VX0,VY0,VX1,VY1,C,CO
T%=0
9:X0(T%)=PX/2:Y0(T%)=YS/2+PY/2:K(T%)=
L=1.8:
INVLOED X,Y
K=.5:
VERKLEINING
G=.99:
AFREMMING
M=.01:M2=.2:
OX,OY,B
CO=C:C=(C+1)
K(C):
X0(C),Y0(C),X1(C),Y1(C)
:5X0(C)=(X0(C)+X0*L)/(1+L):Y0(C)=(Y0(C)+Y0*L)/(1+L)
;5X1(C)=(X0(C)+X1*L)/(1+L):Y1(C)=(Y0(C)+Y1*L)/(1+L)
X0(C),Y0(C),X1(C),Y1(C):K(C)=
=GVX0=G*(VX0+
rnd):VX1=G*(VX1+
rnd):VY0=G*(VY0+
rnd):VY1=G*(VY1+
>)X1=(X1+M*X0)/(1+M):Y1=(Y1+M*Y0)/(1+M)
?'X0+=VX0:Y0+=VY0:X1+=VX1:Y1+=VY1:U=
X0<4
X0>=1276:VX0=-VX0:X0+=VX0:U=
Y0<4
Y0>=956:VY0=-VY0:Y0+=VY0:U=
X1<4
X1>=1276:VX1=-VX1:X1+=VX1:U=
Y1<4
Y1>=956:VY1=-VY1:Y1+=VY1:U=
X,Y,B
(0)<>""
X<>OX
Y<>OY
B<>0
K(C)
X0(C),Y0(C),X1(C),Y1(C)
=(6+2*4)*(
(1)-.5)
testmem
mc_showmap
P.R%=
ensuremem(
mc_free+150*1024,
,2,0,0,0)
"Result:";R%
mc_showmap
restoremem
mc_showmap
compress
A%=MASK(Mcurrent)
CompressBitfield
update(Mcurrent)
CALL DeCompressBitfield
PROCupdate(Mcurrent)
sharp
!Main24=
"Operation not implemented for <24 bit files":
b,T%=
ensuremem(!MainN+4,
,Mcurrent,0,0,0)
"Not enough memory for operation":
restoremem:
d5MAD=
mc_assign(!MainN+4):
MAD=
error$:
MTEMP=MAD
"Strength (def.=0.5)";S
S=0
S=.5
(S)>5
i)
"illegal strength. Aborted"
j3 T%=
mc_release(MAD):
error$:
restoremem
l
m
backup
M=1+4*S
p6MX%=!MainLine:!sharpS=S*1024:!sharpM=M*1024:B%=MX%
C%=0
"Processing colour:";C%
Y%=1
!MainY-2:!sharpMask=MASK(Mcurrent)+Y%*!MainX:A%=!MainData+!MainLine*Y%+C%:!sharpStore=MAD+Y%*!MainX
sharpen
Y%=1
!MainY-2:!sharpMask=MASK(Mcurrent)+Y%*!MainX:A%=!MainData+!MainLine*Y%+C%:!sharpStore=MAD+Y%*!MainX
sharpback
"Memory stuff"
{/T%=
mc_release(MAD):
error$:
restoremem
"Ready":
printtime
transform
T$=""
ensuremem(!MainL+256 + MaskAmount+16,
,0,0,0,0)
tridata=
:OldMask=Mcurrent
restoremem:
"Not enough memory available for operation":
DSEC=
mc_assign(!MainL +256):
SEC=
restoremem:
error$:
"Secondary picture (RETURN for none)";S$
S$<>""
7
"OS_File",5,S$
U%,,F%,,L%:F%=(F% >>8)
M
F%<>&690
"Not a clear file. Transforming aborted":
relsec:
X
L%>(!MainL+40)
"Second picture has an unequal size. Aborted":
relsec:
printDiskAccess(
"OS_File",255,S$,SEC
printDiskAccess(
hB$="":
S$<>""
!Main24=
"Interpolate with secondary picture? (Yes/No/Abort)";B$:B$=
B$,1)
B$="A"
B$="a"
"Operation aborted.":
relsec:
B$="Y"
B$="y"
int=
int=
"Number of steps (default=1)";:
Step
Step=0
Step=1
Step<0
Step<>
(Step)
Step>500
"Illegal number of steps. Transforming aborted":
relsec:
F$="":
Step>1
int
"Filename";
.
int=
" (or RETURN not to save)";
F$=""
int
"Aborted:Must have a filename to interpolate":
relsec:
F$<>""
6
"OS_File",5,F$
U%,,F%,,L%:F%=(F% >>8)
L
U%=1
"'"F$"' already exists as a file. Aborted.":
relsec:
"Cdir "+F$
"Cdir "+F$+".spr"
F$<>""
;
"Load point file (or RETURN not to load):";T$
T$<>""
:
"OS_File",5,T$
U%,,F%,,L%:F%=(F% >>8)
Z
F%<>&FFD
U%<>1
"illegal file, ignored. (press key)",~F%:B$=
:T$=""
%
T$<>""
loadtrans(T$)
Ktridata=
mc_assign(MaskAmount+16):
tridata=
relsec:
error$:
/MASK(0)=tridata:OldMask=Mcurrent:Mcurrent=0
$templ=!MainData+!MainLine*!MainY
X=!MainX:Y=!MainY
S$<>""
initmain(SEC)
`
!MainX<>X
!MainY<>Y
"The secondary image has wrong size. Aborted.":
relsec:
\
!Main24=
int=
"Secondary image must be 24bpp to interpolate":
relsec:
H temp=MAIN:MAIN=SEC:
displayMainOrig(0):MAIN=temp:
initmain(MAIN)
"Please select points with the mouse, menu to end"
T$=""
T$<>""
U%=5
draw(U%):
S$=""
A%=MAIN:B%=templ:C%=SEC:
COPYMEM
X,Y,B:
X<PX
:S%=1
X0,Y0,B:B$=
B<>0
B$<>""
"\ZXDCzxdc
",B$)<=1
X=X0:Y=Y0+4000*(X>PX):B$=
testbutton
B$<>"none"
(X<PX
B=0)
handlezoom:B=0
Y>PY
Y<YS/2
Y0>=YS/2
Y0-=YS/2
getbxy(X0,Y0,X0,Y0)
B=1
{ D=4000:
((X(T%,S%)-X0)^2+(Y(T%,S%)-Y0)^2)<D
((X(T%,S%)-X0)^2+(Y(T%,S%)-Y0)^2):Q%=T%:Q2%=S%
5 X0=X(Q%,0):Y0=Y(Q%,0):X1=X(Q%,1):Y1=Y(Q%,1)
L N-=1:
T%=Q%
N:X(T%,S%)=X(T%+1,S%):Y(T%,S%)=Y(T%+1,S%):
< B=8:S%=Q2%:X(N,0)=X0:Y(N,0)=Y0:X(N,1)=X1:Y(N,1)=Y1
B=4
B=8
Xold=X0:Yold=Y0
J
B=4
X(N,1-S%)=X0:Y(N,1-S%)=Y0:X(N,S%)=X0:Y(N,S%)=Y0:
draw(N)
X,Y,B
X>=PX
X=PX-1
Y>=YS/2
Y-=YS/2
Y>=PY
Y=PY-1
getbxy(X,Y,X,Y)
V
X<>Xold
Y<>Yold
draw(N):X(N,S%)=X:Y(N,S%)=Y:
draw(N):Xold=X:Yold=Y
8 N+=1:S%=1:
N>50
N=50:
"No more points"
N=5
"Too little points. Aborted.":
relsec::
S$<>""
A%=MAIN:B%=templ:C%=SEC:
COPYMEM
F$<>""
savetrans(F$+".Points")
N-=1:
"Sorting points"
6 X(1,R%)=0:Y(1,R%)=0:X(2,R%)=!MainX-.5:Y(2,R%)=0
F X(3,R%)=!MainX-.5:Y(3,R%)=!MainY-.5:X(4,R%)=0:Y(4,R%)=!MainY-.5
I A=X(T,S%)*X(T,S%)+Y(T,S%)*Y(T,S%):
A<D
D=A:X0=X(T,S%):Y0=Y(T,S%)
MIN=-1
N:MAX=1E9:V=-1
N:C=(X(B,S%)-X0)*(X(B,S%)-X0)+(Y(B,S%)-Y0)*(Y(B,S%)-Y0)
C>MIN
C<MAX
MAX=C:V=B
I(A)=V:MIN=MAX
backup
"Making triangulation"
-T(1,0)=I(1):T(1,1)=I(2):T(1,2)=I(3):TRI=1
3:HULL(T)=I(T):
orient(HULL(1),HULL(2),HULL(3))=
HULL(1),HULL(2)
* L0=0:L1=0:P0=-1:P1=-1:P2=-1:USED()=
% O=
orient(HULL(1),I(K),HULL(2))
JN=2
J=JN:
JN>H
J-=H
J1=J+1:
J1>H
J1-=H
' NO=
orient(HULL(J),I(K),HULL(J1))
USED(J)=
USED(J)=
J
TRI+=1:T(TRI,0)=HULL(J):T(TRI,1)=I(K):T(TRI,2)=HULL(J1)
L0=J:P0=HULL(J)
L1=J:P1=HULL(J1)
JN+=1:O=NO
L0>0
L1>0
(L1<L0
J1<>L0)
1 H+=1:
L1+1
-1:HULL(T)=HULL(T-1):
HULL(L1)=I(K)
L1>(L0+1)
< H-=L1-L0-1:
T=L0+1
H:HULL(T)=HULL(T+L1-L0-1):
L0>L1
L1=1
H=L0+1
<
L1>1
H=L0-L1+2:
H:HULL(T)=HULL(T+L1-1):
K+=1
"Optimizing triangulation: pass=";P
F%=
H1=1
TRI:
H2=1
TRI:
optimize(H1,H2):
P+=1
P>20
TRI:
showline(T(T,0),T(T,1)):
showline(T(T,1),T(T,2)):
showline(T(T,2),T(T,0))
Init triangle table
inittridata
dotransformation(0)
int=
F$<>""
CH%=
(F$+".000")
.
writestring(CH%,"Run "+CurrentFile$)
#CH%,0
"
"SetType "+F$+".000 FEB"
int
MAIN,SEC
S%=1-S%
inittridata
printDiskAccess(
"Cdir "+F$+".sec"
"Cdir "+F$+".mix"
&
"OS_File",255,S$,MAIN
printDiskAccess(
(? A%=MAIN:B%=!MainData+!MainLine*!MainY:C%=SEC:
COPYMEM
dotransformation(1)
MAIN,SEC
CH%=
(F$+".mix.000")
,0
writestring(CH%,"Run "+CurrentFile$)
#CH%,0
/(
"SetType "+F$+".mix.000 FEB"
09 B$=F$+".mix."+
("0000"+
(Step+1)),3):CH%=
1&
writestring(CH%,"Run "+S$)
#CH%,0
4
"SetType "+B$+" FEB"
NR=1
Step
6"
"Mixing nr:";NR
Mu=1-NR/(Step+1)
8) C$=F$+"."+
("0000"+
(NR)),3)
9$
"OS_File",255,C$,MAIN
:4
initmain(MAIN):Da%=!MainData:N%=!MainN
;- C$=F$+".sec."+
("0000"+
(NR)),3)
<#
"OS_File",255,C$,SEC
initmain(SEC)
>: A%=Da%:B%=!MainData:C%=1024*Mu:D%=1024*(1-Mu)
@0
initmain(MAIN):
displayMainOrig(1)
A- C$=F$+".mix."+
("0000"+
(NR)),3)
CH%=
C,
"OS_GBPB",&02,CH%,MAIN,!MainL
E"
"SetType "+C$+" 690"
H)T%=
mc_release(SEC):
error$:
I-T%=
mc_release(tridata):
error$:
Mcurrent=OldMask
restoremem
initmain(MAIN):
"Ready.":
printtime
inittridata
"filling triangles"
AD%=tridata
TV COL%=T:
setline(T(T,0),T(T,1)):
setline(T(T,1),T(T,2)):
setline(T(T,2),T(T,0))
X%=0:Y%=0
V3
2:X%+=X(T(T,K),S%):Y%+=Y(T(T,K),S%):
W( X%=X%/3:Y%=Y%/3:C%=0:AD%=tridata
fill(X%,Y%,1500,T)
T%=1
!MainN-1:
AD%?T%=0
AD%?T%=AD%?(T%-1)
relsec
mc_release(SEC)
error$:
tridata<>
mc_release(tridata)
error$:
d Mcurrent=OldMask:
restoremem
savetrans(T$)
U%,CH%
#CH%,N-5
U%=5
#CH%,X(U%,0),Y(U%,0),X(U%,1),Y(U%,1)
loadtrans(T$)
U%,CH%
#CH%,N:N+=5
U%=5
#CH%,X(U%,0),Y(U%,0),X(U%,1),Y(U%,1)
dotransformation(dir)
initmain(MAIN)
{0LI%=!MainLine:X=!MainX:Y=!MainY:D%=!MainData
initmain(SEC):T%=1:To%=-1:L%=5:Da%=!MainData:ml%=!MainLine
!_DA=Da%:!_ML=ml%
!Main24=
!_bpp=3
!_bpp=1
"Hourglass_On"
NR=1
Step
int
Mu=NR/(Step+1)
Mu=NR/Step
dir
Mu=1-Mu
M1=1-Mu
!_Mu1=M1*MLacc:!_Xmax=X
"Transforming....";:
Step>1
"(Picture nr:";NR;")"
!MainN>7E4*index
dmaoff
2X%=0:
triangle=1
TRI:!_tri=triangle:
newtri
T=triangle
<TYmin=
min(Y(T(T,0),S%),
min(Y(T(T,1),S%),Y(T(T,2),S%)))
<TYmax=
max(Y(T(T,0),S%),
max(Y(T(T,1),S%),Y(T(T,2),S%)))
;!_AD=D%+LI%*TYmin:!_LI=LI%:!_Msk=MASK(Mcurrent)+TYmin*X
Y%= TYmin
TYmax
!_v2=(YY0+M1*Y%+.5) *MXacc
M VY0=Y%-Y0:!Aacc=4096*(VX0*VY2-VY0*VX2)*J:!Bacc=4096*(VY0*VX1-VX0*VY1)*J
morph:
dmaon
initmain(MAIN):
displayMainOrig(1):
initmain(SEC)
C$=F$+"."+
("0000"+
(NR)),3)
dir=1
C$=F$+".sec."+
("0000"+
(NR)),3)
F$<>""
CH%=
"OS_GBPB",&02,CH%,MAIN,LI%*Y+D%-MAIN
"SetType "+C$+" 690"
"Hourglass_Off"
gettrianglenr(X%,Y%,T%)
intri(T%)
TRI:
T%<>I%
intri(I%)
intri(T%)
'A0%=
orient2(X%,Y%,T(T%,0),T(T%,1))
'A1%=
orient2(X%,Y%,T(T%,1),T(T%,2))
A0%<>A1%
'A2%=
orient2(X%,Y%,T(T%,2),T(T%,0))
A0%<>A2%
optimize(T0,T1)
(T0)=
(T1)
TEL+=1
A0=-1:A1=-1:B0=-1:B1=-1
T(T0,I)=T(T1,J)
A0>-1
B0=-1
B0=I:A1=J
T(T0,I)=T(T1,J)
A0=-1
B0=-1
A0=I:B1=J
A0=-1
B0=-1
C0=-1:C1=-1
A0<>T
B0<>T
C0=T
A1<>T
B1<>T
C1=T
C0=-1
C1=-1
"ERROR":
orient(T(T0,C0),T(T0,A0),T(T1,C1))<>
orient(T(T1,C1),T(T1,A1),T(T0,C0))
min(
angle(T(T0,C0),T(T1,C1),T(T1,A1)) ,
angle(T(T0,C0),T(T0,A0),T(T1,C1)) )
min(
angle(T(T0,A0),T(T0,B0),T(T0,C0)) ,
angle(T(T1,A1),T(T1,B1),T(T1,C1)) )
R1<R2
'T(T0,A0)=T(T1,C1):T(T1,A1)=T(T0,C0)
newtri
T%=triangle
'T0%=T(T%,0):T1%=T(T%,1):T2%=T(T%,2)
X0=X(T0%,S%):Y0=Y(T0%,S%)
%VX1=X(T1%,S%)-X0:VY1=Y(T1%,S%)-Y0
%VX2=X(T2%,S%)-X0:VY2=Y(T2%,S%)-Y0
$J=VX1*VY2-VX2*VY1:
J<>0
J=1/J
J=J*MLacc
<XX0=X(T0%,1-S%)*Mu:XX1=X(T1%,1-S%)*Mu:XX2=X(T2%,1-S%)*Mu
<YY0=Y(T0%,1-S%)*Mu:YY1=Y(T1%,1-S%)*Mu:YY2=Y(T2%,1-S%)*Mu
#U0=XX1-XX0:U1=XX2-XX0:U2=XX0+.5
V0=YY1-YY0:V1=YY2-YY0
0!_u0=U0 *MXacc:!_u1=U1 *MXacc:!_u2=U2 *MXacc
!!_v0=V0 *MXacc:!_v1=V1 *MXacc
,VX0=X%-X0:!Da=4096*VY2*J:!Db=-4096*VY1*J
min(A,B)
A<B
max(A,B)
A>B
angle(P0,P1,P2)
A,B,C,A1,A2,A3
dist(P0,P1):B=
dist(P1,P2):C=
dist(P2,P0)
A<1
A=1:
"Warning: arcsine out of range"
B<1
B=1:
"Warning: arcsine out of range"
C<1
C=1:
"Warning: arcsine out of range"
)T=(A*A-B*B-C*C)/(2*B*C):
T<-1
T=-1
T>1
)T=(B*B-C*C-A*A)/(2*C*A):
T<-1
T=-1
T>1
)T=(C*C-A*A-B*B)/(2*A*B):
T<-1
T=-1
T>1
min(A1,
min(A2,A3))
dist(P0,P1)
((X(P0,S%)-X(P1,S%))^2+(Y(P0,S%)-Y(P1,S%))^2)
handlezoom
A$=B$:dontdismask=
Stemp=MAIN:MAIN=SEC:
initmain(SEC):
displayMainOrig(0):MAIN=temp:
initmain(MAIN)
T%=5
N-1:
draw(T%):
flipy
!Main24=
!MainX/2
E A%=!MainData+3*X%+0:B%=!MainData+!MainLine-3-3*X%:
flipy
E A%=!MainData+3*X%+1:B%=!MainData+!MainLine-2-3*X%:
flipy
E A%=!MainData+3*X%+2:B%=!MainData+!MainLine-1-3*X%:
flipy
M
!MainX/2:A%=!MainData+X%:B%=!MainData+!MainLine-1-X%:
flipy:
flipx
mc_assign(!MainLine+4)
!MainY/2:AD%=!MainData+Y*!MainLine:AD1%=!MainData+(!MainY-Y-1)*!MainLine
BU%=
0
X%=0
!MainLine-1 :
AD%?X%,AD1%?X%:
2 A%=AD%:B%=AD%+!MainLine-1:C%=BU%:
COPYMEM
4 A%=AD1%:B%=AD1%+!MainLine-1:C%=AD%:
COPYMEM
3 A%=BU%:B%=BU%+!MainLine-1:C%=AD1%:
COPYMEM
BU%<>
BU%=
mc_release(BU%):
BU%=
error$:
showline(P0,P1)
X0,Y0,X1,Y1
inversegetbxy(X(P0,1-S%),Y(P0,1-S%),X0,Y0)
inversegetbxy(X(P1,1-S%),Y(P1,1-S%),X1,Y1)
window(1)
X0,Y0+YS/2,X1,Y1+YS/2
inversegetbxy(X(P0,S%),Y(P0,S%),X0,Y0)
inversegetbxy(X(P1,S%),Y(P1,S%),X1,Y1)
window(0)
X0,Y0,X1,Y1
setline(P0,P1)
line(X(P0,S%),Y(P0,S%),X(P1,S%),Y(P1,S%))
dist(P0,P1)
((X(P0,S%)-X(P1,S%))^2+(Y(P0,S%)-Y(P1,S%))^2)
orient(T0,T1,T2)
*UO=(X(T1,S%)-X(T0,S%))*(Y(T2,S%)-Y(T0,S%))-(X(T2,S%)-X(T0,S%))*(Y(T1,S%)-Y(T0,S%))
orient2(X%,Y%,T1,T2)
/=O=(X(T1,S%)-X%)*(Y(T2,S%)-Y%)-(X(T2,S%)-X%)*(Y(T1,S%)-Y%)
0 =O>=0
draw(Q%)
X0,Y0,X1,Y1
inversegetbxy(X(Q%,0),Y(Q%,0),X0,Y0)
inversegetbxy(X(Q%,1),Y(Q%,1),X1,Y1)
window(0)
X1,Y1,10
X0,Y0,X1,Y1
window(1)
X0,Y0+YS/2,10
X0,Y0+YS/2,X1,Y1+YS/2
window(NR)
24,SFX;SFY+YS/2*NR;PX-SFX;PY+YS/2*NR-SFY;
checkpal
A%,B%,F%,T%
4:Colors!T%=0:
F.A%=MASK(Mcurrent):B%=Colors:
CheckPalette
G7double=0:Gaps=0:
Colors?T%=3
double+=1
Colors?T%=0
Gaps+=1
=double>0
sceleton(TI%)
255:Colors?T%=0:
Colors?255=1:Colors?0=1
P7T1=(T%
1)=1:T2=(T%
2)=2:T3=(T%
4)=4:T4=(T%
QAT5=(T%
16)=16:T6=(T%
32)=32:T7=(T%
64)=64:T8=(T%
128)=128
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
Colors?T%=1
(T1+T2+T3+T4+T5+T6+T7+T8)=-1
Colors?T%=1
(T1+T2+T3+T4+T5+T6+T7+T8)<-4
Colors?T%=0
:Colors?255=1:Colors?0=1
DX%=!MainX
!MainY-2:AD%=MASK(Mcurrent)+!MainX*Y%
!MainX-2:A%=AD%+X%:
?A%=1
hS C%=(A%?1>0)+2*(A%?(1-DX%)>0)+4*(A%?(-DX%)>0)+8*(A%?(-1-DX%)>0)+16*(A%?-1>0)
i? C%+=32*(A%?(-1+DX%)>0)+64*(A%?DX%>0)+128*(A%?(1+DX%)>0)
?A%=3-Colors?-C%
k
A%=MASK(Mcurrent):
Filter
changecolor
!Main24=
s[ T%=
checkpal:
"OPERATION FAILED:Not able to change palette.":fail=
t
"Use Current selected point or new point (C/N/A)"
B$<>"N"
B$<>"C"
B$<>"c"
B$<>"n"
"Operation aborted":
B$="N"
B$="n"
y,
"Please enter red value:";:
z.
"Please enter green value:";:
{-
"Please enter blue value:";:
|
}) A%=Xcurrent:B%=Ycurrent:
ReadRGB
R=RGB?0:G=RGB?1:B=RGB?2
backup
R+G+B=0
R=1:G=1:B=1
#GR=(R+G+B):R=R/GR:G=G/GR:B=B/GR
"Busy..."
!MainN>5E4*index
!Main24=
dmaoff
!Main24=
8
!MainEntry-1:
Colors?T%<>1
Colors?T%=0
A A=!MainData:N=!MainN:!MainData=!MainPal:!MainN=!MainEntry
AD%=Colors
AD%=MASK(Mcurrent)
!MainN-1
AD%?T%=1
> A%=!MainData+T%*3:R0=A%?0:G0=A%?1:B0=A%?2:GR0=R0+G0+B0
" R0=R*GR0:G0=G*GR0:B0=B*GR0
R0>255
R0=255
G0>255
G0=255
B0>255
B0=255
A%?0=R0:A%?1=G0:A%?2=B0
!Main24=
!MainData=A:!MainN=N
dmaon
"Ready"
displayMainOrig(1):
update(Mcurrent)
changegrey
testpalette:
fail :
"By which factor has the grey-value to be multiplied";
F<0
"What is a negative grey-value suppossed to mean?":
backup
F>255
"That much? Ok. but it will all turn white"
"Busy..."
!Main24=
4:Table!T%=Colors!T%:
255:G0=F*T%:
G0>255
G0=255
: maps?(4+T%)=G0:maps?(260+T%)=G0:maps?(516+T%)=G0:
generalcorrectcolor
"Ready"
displayMainOrig(1):
update(Mcurrent)
correctcol
testpalette:
fail :
"By which factor has the red-value to be multiplied";
R<0
"What is a negative red-value suppossed to mean?":
"By which factor has the green-value to be multiplied";
G<0
"What is a negative green-value suppossed to mean?":
"By which factor has the blue-value to be multiplied";
B<0
"What is a negative blue-value suppossed to mean?":
backup
"Busy..."
!Main24=
4:Table!T%=Colors!T%:
E%=0
255:R%=R*E%:G%=G*E%:B%=B*E%
R%<0
R%=0
G%<0
G%=0
B%<0
B%=0
R%>255
R%=255
G%>255
G%=255
B%>255
B%=255
6 maps?(4+E%)=R%:maps?(260+E%)=G%:maps?(516+E%)=B%
generalcorrectcolor
fail :
"Ready"
displayMainOrig(1):
update(Mcurrent)
testpalette
fail=
!Main24=
[ T%=
checkpal:
"OPERATION FAILED:Not able to change palette.":fail=
generalcorrectcolor
fail=
!Main24=
[ T%=
checkpal:
"OPERATION FAILED:Not able to change palette.":fail=
!Main24=
4:Table!T%=Colors!T%:
!Main24
F A%=maps+4:C%=MASK(Mcurrent):
TransFormColor:A%+=256:
6
!MainEntry-1:
Table?T%<>1
Table?T%=0
A A=!MainData:N=!MainN:!MainData=!MainPal:!MainN=!MainEntry
= A%=maps+4:C%=Table:
TransFormColor:A%+=256:
!MainData=A:!MainN=N
gamma
testpalette:
fail :
"gamma factor";
G<=.001
G>100
"Illegal gamma. Aborted.":
backup
!Main24=
4:Table!T%=Colors!T%:
255:G0=255*(T%/255)^(1/G)
: maps?(4+T%)=G0:maps?(260+T%)=G0:maps?(516+T%)=G0:
"maps?4=0:maps?260=0:maps?516=0
generalcorrectcolor
fail
"Ready"
-
displayMainOrig(1):
update(Mcurrent)
loadmap
testpalette:
fail :
B$=M$
"Load map:Filename ('','last','other')";M$
M$="last"
M$="LAST"
M$="Last"
M$=B$
M$=""
M$="<Mask$Dir>.Maps.MyMap":
"Default map:'"M$"' taken."
M$,1)=":"
M$="<Mask$Dir>.Maps."+
M$,2)
"OS_File",5,M$
U%,,F%,,L%:F%=(F% >>8)
U%<>1
"This file does not exist":
L%<>832
"This file is not a color-map. Its length is not 832 bytes.":
F%<>&FFD
"Warning:incorrect file-type"
"OS_File",255,M$,maps
!maps<>&BD2A275D
"Warning:incorrect indentifier"
backup
name(maps+4,60)
.A%=maps+64:B%=maps+832:C%=maps+4:
COPYMEM
generalcorrectcolor
fail
-
displayMainOrig(1):
update(Mcurrent)
24bit
!Main24=
"Picture is already in 24 bit format":
"T%=MAIN:
?T%<>0 T%+=1:
:M=T%
(M-MAIN+4*!MainX*!MainY+4+7*mc_page) >mc_amount
"Not enough memory for operation":
T%=1
T%<=MaxMask%
* A%=MASK(T%):
CompressBitfield
printDiskAccess(
3 CH%=
("<Wimp$ScrapDir>.MaskSwap"+
(T%))
1
"OS_GBPB",&02,CH%,A%,MaskAmount/8+1
printDiskAccess(
8 R%=
mc_release(MASK(T%)):
error$:
OldMask%=MaxMask%
mc_assign(M-MAIN+3*!MainX*!MainY+4):
B O=MAIN:MAIN=
mc_reallocate(MAIN):
MAIN=
error$:
#
O<>MAIN
initmain(MAIN)
/ N%=
mc_assign(M-MAIN+3*!MainX*!MainY+4)
error$:
"Converting....":
(M-MAIN)
4:N%!T%=MAIN!T%:
8O=N%+M-MAIN:O!1=M!1:O!5=M!5:O!9=M!9:O!13=24:AD%=O+17
A%=0:B%=AD%:
ConvertTo24
!Main24=
!MainData=O+17
!MainLine=3*!MainX
mc_release(MAIN)=
error$:
#2MAIN=N%:!MainL=!MainData-MAIN+!MainLine*!MainY
"reallocating..."
%8MAIN=
mc_reallocate(MAIN):
MAIN=
error$:
!MainData=MAIN+O+17-N%
T%=1
8:MASK(T%)=
mc_assign(1):
MASK(T%)=
error$:
assignmasks
T%=1
min(MaxMask%,OldMask%)
printDiskAccess(
"OS_File",255,"<Wimp$ScrapDir>.MaskSwap"+
(T%),MASK(T%)
printDiskAccess(
.& A%=MASK(T%):
DeCompressBitfield
displayMask(M%,M%-M0+1):
version
T$=" Version:"+Version$+" "+"Author:Michel Grimminck Email:grimmink@phys.uva.nl Smail:Westerstraat 155
Amsterdam "
78T$=T$+"Current image contains "+
(!MainN)+" pixels "
!Main24=
T$=T$+"of 3 bytes per pixel"
T$=T$+"of one byte/pixel"
T$=T$+" "
(T$):
T$,T%,57):
contrast
!Main24=
"Not implemented for <=8 bpp files":
getboundaries
X0=0
Y0=0
X1=!MainX-1
Y1=!MainY
"Erase/contrast cannot handle edges":
A*data=
mc_assign(3*(X1-X0+1)*(Y1-Y0+1))
data=
"not enough memory for operation":
"Contrast factor";CF
Y%=Y0
Y1:AD%=data+3*(X1-X0+1)*(Y%-Y0):ADL%=!MainData+Y%*!MainLine
X%=3*X0
3*X1+2:AD%?(X%-X0)=ADL%?X%
erase
fail=
mc_release(data):
error$:
fail=
Y%=Y0
Y1:AD%=data+3*(X1-X0+1)*(Y%-Y0):ADL%=!MainData+Y%*!MainLine
X%=3*X0
3*X1+2:N=(1-CF)*ADL%?X%+CF*AD%?(X%-X0)
N<0
N>255
N=255
ADL%?X%=N
"Ready."
S0T%=
mc_release(data):
error$:
erase
X0,Y0,X1,Y1
fail=
!Main24=
"Not implemented for <=8 bpp files":
getboundaries
X0=0
Y0=0
X1=!MainX-1
Y1=!MainY
"Erase cannot handle edges":
\9T%=
ensuremem((X1-X0+3)*(Y1-Y0+3)*4,
,Mcurrent,0,0,0)
"Erase:not enough memory for operation":
restoremem:
^UGS%=
mc_assign((X1-X0+3)*(Y1-Y0+3)*4):
GS%=
error$:fail=
restoremem:
IM%=(X1-X0+1)*(Y1-Y0+1)*.07
IM%<40
IM%=40
IM%>1500
cK
"This is going to take a very long time. Are you sure?(Y/N)"
B$=
B$<>"Y"
B$<>"y"
f9 T%=
mc_release(GS%):
error$:
g8
"Erase aborted":fail=
restoremem:
backup
"Copying color";C%;" data"
DY%=(X1-X0+3)*4
(Y1-Y0+2):B%=Y%+Y0-1:AD%=GS%+DY%*Y%:M%=MASK(Mcurrent)+!MainX*B%+X0-1
(X1-X0+2):A%=X%+X0-1:
M%?X%=0
ReadRGB:AD%!(X%*4)=256*RGB?C%
AD%!(X%*4)=0
"Doing ";IM%;" Gauss-Seidel iterations in color ";C%
IM%>150*(index^.333)
dmaoff
F%=DY%
(Y1-Y0)+1:A%=GS%+DY%*Y%:B%=MASK(Mcurrent)+!MainX*(Y%+Y0-1)+X0-1
D%=(X1-X0)+1:
GaussSeidel
{ I%+=1
dmaon
"Copying color";C%;" back to picture"
(Y1-Y0+2):B%=Y%+Y0-1:AD%=GS%+DY%*Y%:M%=MASK(Mcurrent)+!MainX*B%+X0-1:S%=!MainData+!MainLine*B%+(X0-1)*3
(X1-X0+2):A%=X%-X0-1:
M%?X%=1
S%?(X%*3+C%)=AD%!(X%*4)/256
"Ready"
mc_release(GS%):
error$:
restoremem
displayMainOrig(1)
update(Mcurrent)
speedtest
"Doing speedtests"
A%=MASK(Mcurrent)
T%=0
CompressBitfield:
DeCompressBitfield:
"Time to compress+decompress:";
/100/T%*1000;" ms"
displayMask(Mcurrent,Mcurrent-M0+1):
"Black mask:";(
-TI%)/100/(T%-1)
displayMain(Mcurrent):
"Black main:";(
-TI%)/100/(T%-1)
&P%=BinaryInstr:[OPT 0:
R3,R5,R7:]
BA%=MASK(Mcurrent):B%=MASK(Mcurrent):C%=MASK(Mcurrent):
Binary
displayMask(Mcurrent,Mcurrent-M0+1):
"White mask:";(
-TI%)/100/(T%-1)
displayMain(Mcurrent):
"White main:";(
-TI%)/100/(T%-1)
inverse(option$)
fail=
option$="all"
AD%=!MainData
!Main24=
?
255:Colors?T%=255-T%:
:A%=Colors:C%=0:
B%=0
TransFormColor:
3
T%=!MainPal
!MainData-1:?T%=255-?T%:
option$="mask"
255:maps?(4+T%)=255-T%:maps?(260+T%)=255-T%:maps?(516+T%)=255-T%:
generalcorrectcolor
fail :
displayMainOrig(1)
update(Mcurrent)
noise(D%)
DX%=!MainX
!MainY-2:A%=MASK(Mcurrent)+DX%*Y%:
Neighbours2:
A%=MASK(Mcurrent):
Filter
update(Mcurrent)
dilation
DX%=!MainX:D%=dilation
!MainY-2:A%=MASK(Mcurrent)+!MainX*Y%:
Neighbours:
A%=MASK(Mcurrent):
Filter2
Filter
update(Mcurrent)
clearnoise
printbutton("noise:1",
printbutton("noise:2",
printbutton("noise:3",
printbutton("noise:4",
printbutton("noise:5",
printbutton("noise:6",
printbutton("noise:8",
cleardilation
printbutton("dilation:1",
printbutton("dilation:3",
printbutton("dilation:5",
printbutton("dilation:6",
printbutton("dilation:8",
cleartypes
printbutton("grey",
printbutton("rgb",
printbutton("color",
printbutton("edge:grey",
printbutton("hue",
clearsave
printbutton("save:pic",
printbutton("save:smpic",
printbutton("save:mask",
update(M%)
displayMask(M%,M%-M0+1):
displayMain(M%):
printtime
printtime
40,0);" ";:
40,0)
changeM0
M0<1
M0=1
(M0+2)>MaxMask%
M0=MaxMask%-2
clearD:
printD
YY%=0
displayMask(YY%+M0,YY%+1):
showMaskRect
X,Y,B:
-T%)>12
large
ensuremem(MaskAmount,
,Mcurrent,0,0,0)
"Large: not enough memory for operation":
restoremem:
QM1%=0:MASK(0)=
mc_assign(MaskAmount):
MASK(0)=
error$:
restoremem:
"Please enter a minimal thickness (pixels)";
S%:S%=
(S%/2)
S%>200
"Don't you think that is rather big?":
restoremem:
%P%=BinaryInstr:[OPT 0:MOV R3,R5:]
;A%=MASK(0):B%=MASK(Mcurrent):C%=MASK(Mcurrent):
Binary
K=Mcurrent:Mcurrent=M1%
R%=1
noise(8):
Mcurrent=K:
seedintern
mc_release(MASK(0)):
error$:
restoremem
update(Mcurrent)
"And: Please select first mask":M1%=
input
"And: Please select second mask":M2%=
input
"Doing operation:z=x and y"
&P%=BinaryInstr:[OPT 0:
R3,R5,R6:]
8A%=MASK(Mcurrent):B%=MASK(M1%):C%=MASK(M2%):
Binary
update(Mcurrent)
andnot
"And Not: Please select first mask":M1%=
input
"And Not: Please select second mask":M2%=
input
"Doing operation:z=x andnot y"
&P%=BinaryInstr:[OPT 0:
R3,R5,R7:]
3A%=MASK(M2%):B%=MASK(M2%):C%=MASK(M2%):
Binary
&P%=BinaryInstr:[OPT 0:
R3,R5,R6:]
8A%=MASK(Mcurrent):B%=MASK(M1%):C%=MASK(M2%):
Binary
&P%=BinaryInstr:[OPT 0:
R3,R5,R7:]
3A%=MASK(M2%):B%=MASK(M2%):C%=MASK(M2%):
Binary
update(Mcurrent)
"Or: Please select first mask":M1%=
input
"Or: Please select second mask":M2%=
input
"Doing operation:z=x or y"
%'P%=BinaryInstr:[OPT 0:
R R3,R5,R6:]
&8A%=MASK(Mcurrent):B%=MASK(M1%):C%=MASK(M2%):
Binary
update(Mcurrent)
"Exclusive or: Please select first mask":M1%=
input
"Exclusive or: Please select second mask":M2%=
input
"Doing operation:z=x eor y"
.&P%=BinaryInstr:[OPT 0:
R3,R5,R6:]
/8A%=MASK(Mcurrent):B%=MASK(M1%):C%=MASK(M2%):
Binary
update(Mcurrent)
"Not:Please select a mask":M1%=
input
"Doing operation:z=not x"
6&P%=BinaryInstr:[OPT 0:
R3,R5,R7:]
78A%=MASK(Mcurrent):B%=MASK(M1%):C%=MASK(M1%):
Binary
update(Mcurrent)
"Copy: Please select a mask":M1%=
input
"Doing operation:z=x"
>%P%=BinaryInstr:[OPT 0:MOV R3,R5:]
?8A%=MASK(Mcurrent):B%=MASK(M1%):C%=MASK(M1%):
Binary
update(Mcurrent)
update(Mcurrent)
A%,B%,C%
I%P%=BinaryInstr:[OPT 0:MOV R3,#0:]
JBA%=MASK(Mcurrent):B%=MASK(Mcurrent):C%=MASK(Mcurrent):
Binary
N%P%=BinaryInstr:[OPT 0:MOV R3,R7:]
OBA%=MASK(Mcurrent):B%=MASK(Mcurrent):C%=MASK(Mcurrent):
Binary
update(Mcurrent)
input
X,Y,B:
X,Y,B:
B>1
X>=PX
X<=PX+48
Y<Yd0
M0+=1:
changeM0:B=0
B>1
X>=PX
X<=PX+48
Y>Yd1
M0-=1:
changeM0:B=0
B=1
X>=PX
X<=PX+48
Y<Yd0
M0-=1:
changeM0:B=0
B=1
X>=PX
X<=PX+48
Y>Yd1
M0+=1:
changeM0:B=0
(Y/YS*3)+(M0-1)
selectmask
c+M%=3-
(Y/YS*3)+(M0-1):
M%>MaxMask%
Mcurrent=M%
showMaskRect
displayMain(Mcurrent)
makeMask(TYPE%,NR%)
=0:A%=Xcurrent:B%=Ycurrent:
ReadRGB
"Hourglass_Start",100
TYPE%
n9 A%=MASK(NR%):B%=RGB?0+RGB?1+RGB?2:C%=768*Dcurrent
!Main24
Calc(0)
q
r_ A%=Colors:A=!MainData:!MainData=!MainPal:N=!MainN:!MainN=!MainEntry:!Main24=
Calc(0)
sB !Main24=
:!MainN=N:!MainData=A:B%=MASK(Mcurrent):
SetMask
t
v/ A%=MASK(NR%):B%=RGB?0:C%=RGB?1:D%=RGB?2
E%=Dcurrent^2*3*255*255
!Main24=
Calc(1)
z
{_ A%=Colors:A=!MainData:!MainData=!MainPal:N=!MainN:!MainN=!MainEntry:!Main24=
Calc(1)
|B !Main24=
:!MainN=N:!MainData=A:B%=MASK(Mcurrent):
SetMask
}
Z=Dcurrent^2 /3
- TR=RGB?0:TG=RGB?1:TB=RGB?2:T=TR+TG+TB
A%=T:B%=Z*65536
!Main24=
C%=MASK(NR%):
Calc(2)
_ C%=Colors:A=!MainData:!MainData=!MainPal:N=!MainN:!MainN=!MainEntry:!Main24=
Calc(2)
H !Main24=
:!MainN=N:!MainData=A:A%=C%:B%=MASK(Mcurrent):
SetMask
"Hourglass_Off"
!Main24=
"Not implemented for 24 bpp files":
C=Dcurrent*
W3=2/3*
(3):P2=
X=RGB?0-.5*RGB?1-.5*RGB?2
Y=W3*RGB?1-W3*RGB?2
Y=0
T=-
*(X<0)
T=
(X/Y):
X<0
!MainEntry-1
9 R=!MainPal+3*B%:G=!MainPal+3*B%+1:B=!MainPal+3*B%+2
X=?R-.5*?G-.5*?B
Y=W3*?G-W3*?B
Y=0
H=-
*(X<0)
H=
(X/Y):
X<0
(H-T):
H>P2
H-=P2
H=P2-H
H<C
Colors?B%=1
Colors?B%=0
)A%=Colors:B%=MASK(Mcurrent):
SetMask
!MainN>140000*index :
"This will take a long time. Are you sure?(Y/N)"
!MainN>140000*index
^ B$=
B$<>"Y"
B$<>"y"
"Edge aborted":
"Ok. busy for some time...."
!MainN>14000*index
dmaoff
#C%=(Dcurrent*600)^2:!EdgeVal=C%
!MainY-2:AD%=MASK(Mcurrent)+!MainX*B%:!EdgeAd=AD%:
Edge:
dmaon
type2
"Hourglass_On":Z=Dcurrent^2 /3
)TR=RGB?0:TG=RGB?1:TB=RGB?2:T=TR+TG+TB
<A%=T:B%=Z*65536:C%=MASK(NR%):
Calc(2):
"Hourglass_Off"
makebutton(X,Y,T$,A$)
(T$)*8*SFX:B=8*SFY
3X0=X-2*SFX:Y0=Y-2*SFY:X1=X+A+2*SFX:Y1=Y+B+2*SFY
*ButtonP$(button)=T$:Button$(button)=A$
+Button(button,0)=X0:Button(button,1)=Y0
+Button(button,2)=X1:Button(button,3)=Y1
ButtonType(button)=1
button+=1
printbutton(A$,
makebutton2(X,Y,T$,A$)
(T$)*8*SFX:B=8*SFY
#X0=X:Y0=Y:X1=X+A:Y1=Y+B-1-1*SFY
*ButtonP$(button)=T$:Button$(button)=A$
+Button(button,0)=X0:Button(button,1)=Y0
+Button(button,2)=X1:Button(button,3)=Y1
ButtonType(button)=2
X,Y,A,Y1-Y0:
X,Y+SFY*7:
button+=1
printbutton(A$,Pressed%)
A,B,X,Y,X0,X1,Y0,Y1,Q%
7T%=-1:
Q%=button-1
A$=Button$(Q%)
T%=Q%
T%=-1
"button '"A$"' not found":
ButtonType(T%)=2
-X=Button(T%,0)+2*SFX:Y=Button(T%,1)+2*SFY
(ButtonP$(T%))*8*SFX:B=8*SFY
3X0=X-2*SFX:Y0=Y-2*SFY:X1=X+A+2*SFX:Y1=Y+B+2*SFY
Pressed%
X0,Y0,X1-X0,Y1-Y0
Pressed%
X0,Y0,X1,Y0:
X1,Y1
Pressed%
X0,Y1:
X0,Y0
X,Y+B-SFY:
ButtonP$(T%)
printline(X0,Y0,X1)
X0,Y0,X1,Y0:
X0,Y0+SFY
X0,Y0+SFY,X1-SFX,Y0+SFY:
X0,Y0
testbutton
S,T%
button-1
X>=Button(T%,0)
X<=Button(T%,2)
Y>=Button(T%,1)
Y<=Button(T%,3)
S=T%
S>=0
printbutton(Button$(S),
S=-1
="none"
=Button$(S)
defaults
mode:mode=
"FX 4 1"
.mapsize=6144 :
Size of main fixed buffer
PL 16,MASK(8),OldMask(8),Button(90,3),ButtonP$(90),Button$(90)
ButtonType(90),C%(2,2,2),L%(2),M%(2),Colors 256,Table 256,R(15),G(15),B(15)
X(50,1),Y(50,1),I(50),T(100,2),USED(40),HULL(40),maps mapsize
K(10),X0(10),Y0(10),X1(10),Y1(10)
maskstatus(8),temp(8),M(3)
button=0:on=1:off=0:M$=""
FD=deffd:dontdismask=
=PL!0=149:PL!4=-1:
"OS_ReadVduVariables",PL,PL+8:EE%=PL!8
"OS_ReadModeVariable",mode,3
,,T%:
T%<>63
mode=15:
mode:
"This program must run in a 256 color mode. Change !Defaults-file":
"OS_ReadModeVariable",mode,4
,,FX
"OS_ReadModeVariable",mode,5
,,FY
"OS_ReadModeVariable",mode,7
,,ScrMem%
"OS_ReadModeVariable",mode,11
,,XW:XW+=1
"OS_ReadModeVariable",mode,12
,,YW:YW+=1
+SFX=1<<FX:SFY=1<<FY:XS=XW<<FX:YS=YW<<FY
PX=XS/2-32-64+16:PY=YS/2-36
Yd0=0:Yd1=YS-1-8*SFY
MY=YS/3-32:MX=MY:M0=1
'XMmax=(PX >>FX)-2:YMmax=(PY >>FY)-2
)XMmaxM=(MX >>FX)-2:YMmaxM=(MY >>FY)-2
Determen arm speed:
=0:T%=0:
:T%+=1:
>=10:index=T%/2100
'dma=defdma:!pal=defpal:
setuppal(
defdma=2
%
index<.6
dma=off
dma=on
0,0,PX,PY:
0,YS/2,PX,PY
.MaxMask%=3:Mcurrent=2:Type=2:
showMaskRect
7Xmenu=XS/2-32+MX+20:
Xmenu,0,1500,3000
mc_init(
-48*1024,4096):
error$
-MAIN=
mc_assign(1)::
MAIN=
error$
8:MASK(T%)=
mc_assign(1):
MASK(T%)=
error$
>SaveType$="save:smpic":Xcurrent=0:Ycurrent=0:Dcurrent=0.25
LoadType$="load:pic"
printXY:
printD
Y=YS*47/50
21+128
makebutton(Xmenu+32,Y,"Grey","grey")
makebutton(Xmenu+128,Y,"RGB","rgb")
makebutton(Xmenu+208,Y,"Color","color")
makebutton(Xmenu+32,Y-3/50*YS,"Hue","hue")
makebutton(Xmenu+128,Y-3/50*YS,"Edge","edge:grey")
printbutton("color",
printline(Xmenu+0*SFX,Y-5/50*YS+SFY*3,XS)
Xmenu+1,Y
YB=40/50*YS
makebutton(Xmenu+12,YB,"NOT","not")
makebutton(Xmenu+78,YB,"=","copy")
makebutton(Xmenu+114,YB,"AND","and")
makebutton(Xmenu+182,YB,"0","0")
makebutton(Xmenu+216,YB,"1","1")
makebutton(Xmenu+252,YB,"LARGE","large")
makebutton(Xmenu+12,YB-3/50*YS,"EOR","eor")
makebutton(Xmenu+80,YB-3/50*YS,"OR","or")
makebutton(Xmenu+132,YB-3/50*YS,"ANDNOT","andnot")
makebutton(Xmenu+248,YB-3/50*YS,"SEED","seed")
makebutton(Xmenu+12,YB-6/50*YS,"NOISE:","noise")
makebutton(Xmenu+126,YB-6/50*YS,"1","noise:1")
makebutton(Xmenu+158,YB-6/50*YS,"2","noise:2")
makebutton(Xmenu+190,YB-6/50*YS,"3","noise:3")
makebutton(Xmenu+222,YB-6/50*YS,"4","noise:4")
makebutton(Xmenu+254,YB-6/50*YS,"5","noise:5")
makebutton(Xmenu+286,YB-6/50*YS,"6","noise:6")
makebutton(Xmenu+318,YB-6/50*YS,"8","noise:8")
;%noise=1:
printbutton("noise:1",
makebutton(Xmenu+12,YB-9/50*YS,"DILATION:","dilation")
makebutton(Xmenu+176,YB-9/50*YS,"1","dilation:1")
makebutton(Xmenu+208,YB-9/50*YS,"3","dilation:3")
makebutton(Xmenu+240,YB-9/50*YS,"5","dilation:5")
makebutton(Xmenu+272,YB-9/50*YS,"6","dilation:6")
makebutton(Xmenu+272+32,YB-9/50*YS,"8","dilation:8")
B+dilation=1:
printbutton("dilation:1",
printline(Xmenu+0*SFX,YB-11/50*YS+SFY*4,XS)
Xmenu+1,YB
YF=YB-13/50*YS
makebutton(Xmenu+16,YF,"LOAD:","load")
makebutton(Xmenu+112,YF,"pic","load:pic")
makebutton(Xmenu+176,YF,"mask","load:mask")
makebutton(Xmenu+256,YF,"back","load:back")
printbutton(LoadType$,
makebutton(Xmenu+16,YF-YS*3/50,"SAVE:","save")
makebutton(Xmenu+112,YF-YS*3/50,"pic","save:pic")
makebutton(Xmenu+176,YF-YS*3/50,"smpic","save:smpic")
makebutton(Xmenu+270,YF-YS*3/50,"mask","save:mask")
printbutton(SaveType$,
printline(Xmenu+0*SFX,YF-5/50*YS+SFY*4,XS)
Xmenu+1,YF
U%=-32+16
Ypic=YF-YS*7/50
makebutton(Xmenu+16,Ypic,"map","loadmap")
makebutton(Xmenu+86,Ypic,"InvM","invmask")
makebutton(Xmenu+170,Ypic,"
","flipy")
makebutton(Xmenu+224,Ypic,"
","flipx")
makebutton(Xmenu+278,Ypic,"24b","24bit")
makebutton(Xmenu+170,Ypic-YS*3/50,"Gam","gamma")
makebutton(Xmenu+240,Ypic-YS*3/50,"Filt","correctcol")
makebutton(Xmenu+100,Ypic-YS*3/50,"Col","changecolor")
makebutton(Xmenu+16,Ypic-YS*3/50,"grey","changegrey")
makebutton(Xmenu+16,Ypic-YS*6/50,"Morph","morph")
makebutton(Xmenu+116,Ypic-YS*6/50,"Erase","erase")
makebutton(Xmenu+216,Ypic-YS*6/50,"contrast","contrast")
makebutton(Xmenu+16,Ypic-YS*9/50,"sharp","sharp")
makebutton(Xmenu+116,Ypic-YS*9/50,"undo","undo")
Y=Ypic-12/50*YS
makebutton(Xmenu+U%+32,Y,"b","black")
makebutton(Xmenu+U%+64,Y,"w","white")
makebutton(Xmenu+U%+96,Y,"r","red")
makebutton(Xmenu+U%+128,Y,"g","green")
makebutton(Xmenu+U%+160,Y,"b","blue")
makebutton(Xmenu+U%+192,Y,"p","purple")
makebutton(Xmenu+U%+224,Y,"c","cyan")
makebutton(Xmenu+U%+256,Y,"y","yellow")
makebutton(Xmenu+U%+288,Y,"g","cgrey")
makebutton(Xmenu+U%+320,Y,"R","darkred")
makebutton(Xmenu+U%+352,Y,"B","darkblue")
printline(Xmenu+0*SFX,Ypic-14/50*YS+SFY*4,XS)
Yo=Y-4/50*YS
makebutton(Xmenu+16,Yo,"DMA","dma")
printbutton("dma",dma-1)
makebutton(Xmenu+88,Yo,"FD","fastdisplay")
printbutton("fastdisplay",-FD)
makebutton(Xmenu+144,Yo,"pal","pal")
printbutton("pal",-!pal)
makebutton(Xmenu+216,Yo,"undo","tundo")
printbutton("tundo",undo)
Xmenu+1,Ypic
y(MaskColor$="":
setmaskcolor("black")
makebutton2(0,YS/2-8*SFY,"zoom","D")
makebutton2(16*5,YS/2-8*SFY,"unzoom","C")
makebutton2(16*12,YS/2-8*SFY,"mask","Z")
makebutton2(16*17,YS/2-8*SFY,"X","X")
makebutton2(16*19,YS/2-8*SFY,"
makebutton2(16*21,YS/2-8*SFY,"
makebutton2(16*23,YS/2-8*SFY,"
makebutton2(16*25,YS/2-8*SFY,"
loadClear("<Mask$Dir>.Demo2")
setmaskcolor(A$)
MaskColor$<>""
printbutton(MaskColor$,
MaskColor$=A$
"black" :?MaskColor=0
!
"white" :?MaskColor=255
"red" :?MaskColor=16
#
"darkred" :?MaskColor=4
"green" :?MaskColor=64
!
"blue" :?MaskColor=128
#
"darkblue" :?MaskColor=8
$
"purple":?MaskColor=128+16
$
"cyan" :?MaskColor=128+64
#
"yellow":?MaskColor=64+16
$
"cgrey" :?MaskColor=4+8+32
printbutton(MaskColor$,
showMaskRect
T%=0
2:M%=3-T%:
(M%+M0-1)<>Mcurrent
XS/2-32,T%*YS/3,MX,MY
(M%+M0-1)>MaxMask%
XS/2-32,T%*YS/3,MX,MY
printXY
A%,B%
%A%=Xcurrent:B%=Ycurrent:
ReadRGB
5:Y=YS*0.6/10
Xmenu,Y-16*SFY,500,16*SFY::
Xmenu+32,Y:
"Position:";
Xcurrent;",";
Ycurrent
Xmenu+32,Y-8*SFY:
"Color:";RGB?0;",";RGB?1;",";RGB?2
printDiskAccess(
clearD
PX+16,0,16,YS
showArrows
printD
Dcurrent<0
Dcurrent=0
Dcurrent>1
Dcurrent=1
PX+16,Yd0,16,Yd1-Yd0
PX+16,Yd0,16,(Yd1-Yd0)*Dcurrent
printDiskAccess(A%)
Xmenu+32,YS*0.4/10:
XS-15,15,10
dmaoff
dma=off
"OS_UpdateMEMC",0,1024
dmaon
"OS_UpdateMEMC",1024,1024
loadClear(C$)
"OS_File",5,C$
U%,,F%,,L%:F%=(F% >>8)
F%<>&690
F%<>&FF9
"Not a clear or sprite file":
%OLDMAIN=MAIN:MAINL=!MainL:FLAG%=
mc_amount< (L%*1.33+9*mc_page)
"Not enough memory for image":
%OldMask()=MASK():MAXMASK=MaxMask%
8:MASK(T%)=
mc_reassign(MASK(T%),1):
MASK(T%)=
error$:
MAIN=
mc_reassign(MAIN,L%):
MAIN=
error$="Not enough continious memory."
"Tidying memory":
tidymem:MAIN=
mc_assign(L%)
MAIN=
error$:
loadmask=
:fail=
F%=&690
loadtype690
F%=&FF9
loadtypeFF9
loadtype690
printDiskAccess(
"OS_File",255,C$,MAIN
printDiskAccess(
takecareofnew
takecareofnew
CurrentFile$=C$
(C$) +1:
T%-=1:
C$,T%,1)="."
T%=0
C$,T%,1)=":"
FileName$=
C$,T%+1)
initmain(MAIN)
6ZOOM!0=0:ZOOM!4=0:ZOOM!8=!MainX-1:ZOOM!12=!MainY-1
initzoom
MaskAmount=!MainX*!MainY
assignmasks
MaxMask%<=0
displayMainOrig(1)
loadmask=
loadmask=
loadspritemask
displayMask(M%,M%-M0+1):
displayMainOrig(1)
loadmask=
displayMain(Mcurrent)
loadtypeFF9
printDiskAccess(
readbuffer(12):
!maps<>1
"Warning: more than one sprite in this file"
readbuffer(44):S=maps
,M=S!40:
"OS_ReadModeVariable",M,3
1:BPP=1
3:BPP=2
15:BPP=4
63:BPP=8
"illegal spritefile. Loading aborted":fail=
<Y=S!20 +1:X=S!16*4*(8/BPP)+(S?28-S?24+1)/BPP:XL=S!16*4+4
Y<=0
Y>1E4
X<=0
XL>mapsize
"illegal spritefile. Loading aborted":fail=
name(S+4,12)
N%=S!36:M%=S?24/8:MO%=S?24
(N%-44-XL*Y)>=0
N%-=XL*Y:loadmask=
loadmask=
readbuffer(N%-44)
converting to clear-format:
T%=1
(S$):MAIN?(T%-1)=
S$,T%)):
:MAIN?(T%-1)=0
m=T%-1+MAIN
m!1=100*version
m!5=X
m!9=Y
m!13=8
p=m+17
Q%=0
767
4:p!Q%=0:
Taking care of the palette:
(N%-44)>0
(N%-44)<2048
Q%=0
(2^BPP-1) :
2: j=maps?(8*(Q%
63)+1+C%)
'
C%=1
(Q%
64)<>0
j+=128
(
C%=2
(Q%
128)<>0
j+=128
p?(3*Q%+C%)=j
(N%-44)=0
A%=0
255:
getRGB8
,
C%=0
2:p?(3*A%+C%)=rgb!(4*C%)
!6
Q%=0
C%=0
2:p?(3*Q%+C%)=240-32*Q%:
p!(3* 7)=&000000
p!(3* 8)=&994400
p!(3* 9)=&00EEEE
p!(3*10)=&00CC00
p!(3*11)=&0000DD
p!(3*12)=&99EEEE
p!(3*13)=&008855
p!(3*14)=&00BBFF
p!(3*15)=&FFBB00
p!(3*0)=&FFFFFF
p!(3*1)=&BBBBBB
p!(3*2)=&777777
p!(3*3)=&000000
p!(3*0)=&FFFFFF
p!(3*1)=&000000
"illegal spritefile. Loading aborted":fail=
(N%-44)=2048
Q%=0
(2^BPP-1) :
2: j=maps?(8*Q%+1+C%)
p?(3*Q%+C%)=j
:
256 palette entries
loading in the sprite:
= D=p+256*3:P%=mapsize/XL:W%=0
C=63
V%=0
@0
W%=0
readbuffer(XL*
min(P%,Y-V%))
A8 A%=maps+M%+XL*W%:B%=A%+X-1:C%=D+V%*X:
COPYMEM
W%+=1:
W%=P%
W%=0
C
D
C<63
FL MAIN=
mc_reassign(MAIN,X*Y+D-MAIN):
MAIN=
error$:fail=
B%=2^BPP-1
V%=0
I0
W%=0
readbuffer(XL*
min(P%,Y-V%))
J* S%=D+V%*X:O%=maps+XL*W%:bit%=MO%
KR
X%=0
X-1:byte%=bit%/8:S%?X%=((O%?byte%) >> (bit%
B%:bit%+=BPP:
W%+=1:
W%=P%
W%=0
M
N
loadmask=
printDiskAccess(
takecareofnew
loadspritemask
printDiskAccess(
B%=2^BPP-1:W%=0
V%=0
X0
W%=0
readbuffer(XL*
min(P%,Y-V%))
Y7 S%=MASK(Mcurrent)+V%*X:O%=maps+XL*W%:bit%=MO%
ZZ
X%=0
X-1:byte%=bit%/8:S%?X%=-((((O%?byte%) >> (bit%
B%)<>0):bit%+=BPP:
W%+=1:
W%=P%
W%=0
\
printDiskAccess(
readbuffer(AA%)
B,C%,D%,E%
AA%<=mapsize
d"
"OS_GBPB",4,CH%,maps,AA%
e
f(
"OS_GBPB",4,CH%,maps,mapsize-1
g
"OS_Args",0,CH%
,,FP
h9
"OS_GBPB",3,CH%,maps+mapsize-1,1,FP+AA%-mapsize
i
initzoom
m:X=ZOOM!8-ZOOM!0+1:Y=ZOOM!12-ZOOM!4+1:!ZOOMX=X:!ZOOMY=Y
n%Xc=X/
(PX/SFX-1):Yc=Y/
(PY/SFY-1)
o1Xcm=!MainX/
(MX/SFX-1):Ycm=!MainY/
(MY/SFY-1)
initmain(MAIN)
t"T%=MAIN:
?T%<>0 T%+=1:
:M=T%
!MainX=M!5
!MainY=M!9
!MainN=M!5*M!9
M!13<=8
!Main24=
!MainPal=M+17
!MainEntry=2^M!13
|! !MainData=M+17+3*(2^M!13)
!MainLine=!MainX
~
!Main24=
!MainData=M+17
!MainLine=3*!MainX
*!MainL=!MainData-MAIN+!MainLine*!MainY
,X0=ZOOM!0:Y0=ZOOM!4:X1=ZOOM!8:Y1=ZOOM!12
DX=X1-X0:DY=Y1-Y0:U=5
":X0-=DX/U:X1-=DX/U
":X0+=DX/U:X1+=DX/U
":Y0+=DY/U:Y1+=DY/U
":Y0-=DY/U:Y1-=DY/U
X0<0
X1-=X0:X0=0
X1>!MainX-1
X0-=X1-!MainX+1:X1=!MainX-1
Y0<0
Y1-=Y0:Y0=0
Y1>!MainY-1
Y0-=Y1-!MainY+1:Y1=!MainY-1
255:B$=
zoomtoxy
unzoomtoc
L=.2:Q=L
X0=(1+Q)*ZOOM!0-Q*ZOOM!8
Y0=(1+Q)*ZOOM!4-Q*ZOOM!12
X1=(1+Q)*ZOOM!8-Q*ZOOM!0
Y1=(1+Q)*ZOOM!12-Q*ZOOM!4
X0<0
X0=0
X1>!MainX-1
X1=!MainX-1
Y0<0
Y0=0
Y1>!MainY-1
Y1=!MainY-1
zoomtoxy
255:B$=
zoomtoc
L=.2:Q=-L
X0=(1+Q)*ZOOM!0-Q*ZOOM!8
Y0=(1+Q)*ZOOM!4-Q*ZOOM!12
X1=(1+Q)*ZOOM!8-Q*ZOOM!0
Y1=(1+Q)*ZOOM!12-Q*ZOOM!4
zoomtoxy
255:B$=
unzoom
%X0=0:Y0=0:X1=!MainX-1:Y1=!MainY-1
zoomtoxy
255:B$=
getboundaries
zoomtoxy
,ZOOM!0=X0:ZOOM!4=Y0:ZOOM!8=X1:ZOOM!12=Y1
(X=ZOOM!8-ZOOM!0+1:Y=ZOOM!12-ZOOM!4+1
!ZOOMX=X:!ZOOMY=Y
%Xc=X/
(PX/SFX-1):Yc=Y/
(PY/SFY-1)
displayMainOrig(1)
dontdismask=
displayMain(Mcurrent)
dontdismask=
assignmasks
Mcurrent<=0
Mcurrent=1
;Reserve%=
mc_assign(10*1024):
No error handling needed
T%=0:
:T%+=1
1MASK(T%)=
mc_reassign(MASK(T%),MaskAmount+16)
T%=8
MASK(T%)=
MASK(T%)=
MaxMask%=T%-1
MaxMask%=8
MASK(T%)=
MASK(T%)=
mc_assign(1):
MASK(T%)=
error$:
MaxMask%>=4
MASK(MaxMask%)=
mc_reassign(MASK(MaxMask%),1):MaxMask%-=1:
MASK(MaxMask%+1)=
error$:
MaxMask%>=5
MASK(MaxMask%)=
mc_reassign(MASK(MaxMask%),1):MaxMask%-=1:
MASK(MaxMask%+1)=
error$:
Mcurrent>MaxMask%
Mcurrent=MaxMask%
T%=MaxMask%-3:
T%<0
T%=0
!Yd0=8*SFY*T%:Yd1=YS-8*SFY-Yd0
showMaskRect:
clearD:
printD
MaxMask%<=0
"Not enough memory. Load another object to avoid crashing!"
Reserve%>0
mc_release(Reserve%):
error$:
tidymem
T%,R%,FLAG,O
T%=0:
FLAG=
@ O=MAIN:MAIN=
mc_reallocate(MAIN):
MAIN=
error$:
O<>MAIN
FLAG=
initmain(MAIN)
O=MASK(R%)
G MASK(R%)=
mc_reallocate(MASK(R%)):
MASK(R%)=
error$:
MASK(R%)<>O
FLAG=
T%+=1
T%=8
FLAG=
showArrows
(M0+3)<=MaxMask%
T%=M0+3
MaxMask%:
PX+16,(-2+8*(1+T%-M0-3))*SFY:
M0>1
M0-1:
PX+16,YS-1-8*(T%)*SFY:
(139):
0,0)" "
0,0);
LoadType$
"load:pic" :
"Load picture:filename";
"load:mask" :
"Load mask:filename";
"load:back" :
"Load background:filename";
"Bug in load procedure":
S$=""
"Loading aborted":
"OS_File",5,S$
U%,,F%,,L%:F%=(F% >>8)
U%<>1
"File not found":
F%<>&690
F%<>&FF9
"Not a clear or sprite file":
LoadType$="load:mask":
loadmask:
LoadType$="load:back":
loadback:
loadClear(S$)
loadmask
#CH%:C%+=1:
C%=500
T%=0
C%=500
"This file does not look like a clear file":
#CH%:
readnumber
readnumber
readnumber
X<>!MainX
Y<>!MainY
"The mask has not the right size":
#CH%:
readnumber:
T%<>1
"This is not a mask file ( >2 colors)":
#CH%:
6:T%=
#CH%:
printDiskAccess(
"OS_GBPB",4,CH%,MASK(Mcurrent),!MainN
printDiskAccess(
update(Mcurrent)
loadback
!Main24=
"the operation is only implemented for 24 bit files":
#CH%:C%+=1:
C%=500
T%=0
C%=500
"This file does not look like a clear file":
#CH%:
readnumber
readnumber
readnumber
X<>!MainX
Y<>!MainY
"The picture has not the right size":
#CH%:
readnumber:
T%<>24
"Operation not implemented for <24 bit files":
#CH%:
printDiskAccess(
"AD%=!MainData:
T%=0
!MainN-1
#CH%:G%=
#CH%:B%=
MASK(Mcurrent)?T%=0
AD%?(T%*3)=R%:AD%?(T%*3+1)=B%:AD%?(T%*3+2)=G%
printDiskAccess(
displayMainOrig(1)
savemask
' A$="Mask of '"+FileName$+"'"
"Saving mask of ";!MainN+24+
(A$);" bytes"
printDiskAccess(
#CH%,
A$,T%,1)):
#CH%,0:
writenumber(100*
(Version$))
writenumber(!MainX):
writenumber(!MainY)
writenumber(1)
#CH%,0:
#CH%,0:
#CH%,0
#CH%,255:
#CH%,255:
#CH%,255
"OS_GBPB",2,CH%,MASK(Mcurrent),!MainN
"SetType "+S$+" 690"
printDiskAccess(
writenumber(R%)
#CH%, R%
255:R%=R% >>8:
writestring(CH%,S$)
(S$):
#CH%,
S$,T%)):
readnumber
#CH% *256
#CH% *65536
#CH% *65536*256
okToSave(S$)
U%,F%,L%
"OS_File",5,S$
U%,,F%,,L%:F%=(F% >>8)
U%=2
S$;" is a directory, saving aborted":=
U%=1
F%<>&690
OJ
"File already exists with type &";~F%;" Are you sure (Y/N)"
P< A$=
A$<>"Y"
A$<>"y"
"Saving aborted":=
=
R
SaveType$
"save:pic" :
"Save picture:filename";
"save:smpic" :
"Save small picture:filename";
"save:mask" :
"Save mask:filename";
"Bug in save procedure":
S$=""
"Saving aborted":
okToSave(S$)=
SaveType$="save:pic"
X0=0:Y0=0:X1=!MainX-1:Y1=!MainY-1
SaveType$="save:smpic"
getboundaries:
Y0>Y1
X0>X1
SaveType$="save:mask"
savemask:
d"T%=MAIN:
?T%<>0 T%+=1:
:M=T%
M!5=X1-X0+1:M!9=Y1-Y0+1
"Saving ";M!5*M!9*!MainLine/!MainX+!MainData-MAIN;" bytes"
g3A%=?MaskColor:
getRGB8:R=rgb!0:G=rgb!4:B=rgb!8
!Main24=
i0 C%=0:U=1E6:
2^M!13-1 :AD%=M+17+3*T%
jD V=(AD%?0-R)*(AD%?0-R)+(AD%?1-G)*(AD%?1-G)+(AD%?2-B)*(AD%?2-B)
V<U
U=V:C%=T%
printDiskAccess(
o4bsize%=
mc_maxblock:
bsize%=
error$:
p<BU%=
mc_assign(bsize%):
BU%=
BU%=maps:bsize%=mapsize
!_buffer=BU%
T%=MAIN
!MainData-1:
#CH%,?T%:
!Main24=
u0 E%=CH%:B%=X0:C%=R:F%=X1:G%=G:H%=B:!_bp=0
vi
Y%=Y0
Y1:ADmain%=!MainData+!MainLine*Y%:ADmask%=MASK(Mcurrent)+!MainX*Y%:A%=ADmask%:D%=ADmain%
write3row
x&
(!_bp +!MainLine) >=bsize%
y&
"OS_GBPB",2,CH%,BU%,!_bp
!_bp=0
}!
"OS_GBPB",2,CH%,BU%,!_bp
! E%=CH%:B%=X0:F%=X1:!_bp=0
i
Y%=Y0
Y1:ADmain%=!MainData+!MainLine*Y%:ADmask%=MASK(Mcurrent)+!MainX*Y%:A%=ADmask%:D%=ADmain%
writerow
&
(!_bp +!MainLine) >=bsize%
&
"OS_GBPB",2,CH%,BU%,!_bp
!_bp=0
"
"OS_GBPB",2,CH%,BU%,!_bp
"SetType "+S$+" 690"
printDiskAccess(
BU%<>
BU%<>Colors :T%=
mc_release(BU%):
error$:
getboundaries
B%,C%,D%
Y0=-1:Y1=0:X0=-1:X1=0
!MainY-1
AD%=MASK(Mcurrent)+!MainX*Y%
(B%=AD%:C%=!MainX-1:D%=1:M%=
TestGT0
Y0=-1
Y0=Y%
Y1=Y%
!MainX-1
AD%=MASK(Mcurrent)+X%
:B%=AD%:D%=!MainX:C%=(!MainY-1)*D%:M%=
TestGT0
X0=-1
X0=X%
X1=X%
displayMainOrig(p)
L1,L2,S0%,C%,H%,T%,Y%,D%,B%
:S0%=EE%+
((YS/2-PY)/SFY)*XW+1:
p=0
S0%=S0%+
(YS/2/SFY)*XW
H%=0:C%=Xc *2^18+1
mc_assign(4*XW/2+8):
!_L1=
error$:
mc_assign(4*XW/2+8):
!_L2=
error$:
4*XW/2+4
4:T%!L1=&808080:T%!L2=&808080:
!_L1=L1+4:!_L2=L2+4
FD=off
YMmax:D%=S0%+XW*Y%+.5:B%=Y%*Yc+ZOOM!4
DisplayMain:
L1,L2:!_L1=L1+4:!_L2=L2+4:
YMmax:D%=S0%+XW*Y%+.5:B%=Y%*Yc+ZOOM!4:H%=!MainX*B%
DisplayMainFast:
L1,L2:!_L1=L1+4:!_L2=L2+4:
mc_release(L1):
error$:
mc_release(L2):
error$:
displayMain(MASK)
B%,C%,D%,H%,S0%
:S0%=EE%+
((YS-PY)/SFY)*XW+1:L0%=EE%+
((YS/2-PY)/SFY)*XW+1
4C%=Xc *2^18+1:!_MASK=MASK(MASK):!_XW=XW:!_S0=S0%
YMmax:H%=D%*Yc+ZOOM!4:B%=L0%+XW*D%:
DisplayMainMask:
displayMask(M%,NR%)
A%,B%,C%,D%,S0%
NR%<1
NR%>3
M%<1
M%>MaxMask%
@S0%=EE%+
(NR%*YS/3+.999)-MY)/SFY+.999)*XW+(XS/2-32)/SFX+1
LC%=XMmaxM:D%=Xcm*2^18+1:!_S0=S0%:!_XW=XW:!_MASK=MASK(M%):!_DY=Ycm*2^18+1
!_Y=0
"A%=YMmaxM+1:B%=0:
DisplayMask
setuppal(Q%)
!pal
0:P$="brtt"
1:P$="rrbg"
Q% :
"Palette set to:"P$
&R()=0:G()=0:B()=0:R=2:G=1:B=2:TI=1
4:M=16>>Q:A$=
P$,Q,1)
M)=M
A$="t"
U=1<<TI:R(T)+=U:G(T)+=U:B(T)+=U
A$="r"
R(T)+=1<<R
A$="g"
G(T)+=1<<G
A$="b"
B(T)+=1<<B
A$="t"
TI-=1
A$="g"
G-=1
A$="r"
R-=1
A$="b"
B-=1
T,R(T)*16,G(T)*16,B(T)*16:
CODE 9000
CalcLoop(10),Calc(10),CalcEnd(10)
PASS=0
P%=CODE
-ADmask=11:X=10:C=2:ADmain=3:X1=5:V=0:T=12
BU=4:BP=8 :ch=4
[OPT PASS
._buffer EQUD0
._bp EQUD0
.writerow
MOV ADmask,R0
MOV X,R1
(MOV R1,ch ;output channel
0LDR BU,_buffer ;address of some buffer
+LDR BP,_bp ;pointer in buffer
.writerowloop
LDRB T,[ADmask,X]
CMP T,#0
Q V,C
LDRNE V,[ADmain,X]
STRB V,[BU,BP]
ADD BP,BP,#1
ADD X,X,#1
CMP X,X1
BLE writerowloop
STR BP,_bp
MOV PC,R14
R=2:G=6:B=7:X3=9
[OPT PASS
.write3row
MOV ADmask,R0
MOV X,R1
(MOV R1,ch ;output channel
ADD X3,X,X,LSL#1 ;X3=3*X
0LDR BU,_buffer ;address of some buffer
+LDR BP,_bp ;pointer in buffer
.write3rowloop
LDRB T,[ADmask,X]
CMP T,#0
Q V,R
LDRNE V,[ADmain,X3]
STRB V,[BU,BP]
ADD BP,BP,#1
ADD X3,X3,#1
Q V,G
LDRNE V,[ADmain,X3]
STRB V,[BU,BP]
ADD BP,BP,#1
ADD X3,X3,#1
Q V,B
LDRNE V,[ADmain,X3]
STRB V,[BU,BP]
ADD BP,BP,#1
ADD X3,X3,#1
ADD X,X,#1
CMP X,X1
BLE write3rowloop
STR BP,_bp
MOV PC,R14
'MASK=0:Table=1:X=2:T=3:I=4:AD=5:P=6
[OPT PASS
;1 color is in mask
;2 color is out mask
;3 color is in and out mask
.CheckPalette
LDR AD,MainData
LDR X,MainN:SUB X,X,#1
.PalLoop
LDRB P,[AD,X]
LDRB T,[MASK,X]
LDRB I,[Table,P]
'$CMP T,#1:
REQ I,I,#1:
RNE I,I,#2
STRB I,[Table,P]
SUBS X,X,#1
BPL PalLoop
MOV PC,R14
AD=5:X=6:T=7:C=8
[OPT PASS
.ConvertTo24
MOV AD,R1:MOV R11,R14
MOV X,R0:LDR C,MainN
2!ADD AD,AD,X:ADD AD,AD,X,LSL#1
.ConvertLoop
MOV R0,X:MOV R1,#0
BL ReadRGBfast
STRB R0,[AD]
STRB R1,[AD,#1]
STRB R2,[AD,#2]
ADD AD,AD,#3
ADD X,X,#1
SUBS C,C,#1
BGT ConvertLoop
MOV PC,R11
?)Table=0:C=1:AD=2:TEMP=3:T=4:M=5:USE=6
[OPT PASS
.TransFormColor
MOV M,R2:CMP M,#0
Q USE,#1:MOVNE USE,#0
LDR AD,MainData
LDR T,MainN
ADD AD,AD,C
.TransLoop
LDRB TEMP,[M],#1
ADD TEMP,TEMP,USE
CMP TEMP,#1
LDRB TEMP,[AD]
LDRB TEMP,[Table,TEMP]
M&STRPLB TEMP,[AD],#3:ADDLT AD,AD,#3
SUBS T,T,#1
BGT TransLoop
MOV PC,R14
R!Col=0:M=1:X=2:P=4:TEMP=5:T1=6
[OPT PASS
.SetMask
LDR X,MainN:BIC X,X,#3
LDR P,MainData
.SetMaskLoop
LDRB TEMP,[P,X]
LDRB T1,[Col,TEMP]
ADD X,X,#1
LDRB TEMP,[P,X]
LDRB TEMP,[Col,TEMP]
ADD T1,T1,TEMP,LSL#8
ADD X,X,#1
LDRB TEMP,[P,X]
LDRB TEMP,[Col,TEMP]
ADD T1,T1,TEMP,LSL#16
ADD X,X,#1
LDRB TEMP,[P,X]
LDRB TEMP,[Col,TEMP]
ADD T1,T1,TEMP,LSL#24
SUB X,X,#3
STR T1,[M,X]
SUBS X,X,#4
BGE SetMaskLoop
MOV PC,R14
[OPT PASS
.TestGT0
MOV R0,#0
.TestGT0loop
LDRB R4,[R1,R2]
CMP R4,#0:MVNNE R0,#0
SUBS R2,R2,R3
BGE TestGT0loop
MOV PC,R14
v&AD=0:M=1:X=3:TEMP=4:DY=5:S=6:AD0=7
[OPT PASS
.GaussSeidel
MOV AD0,AD
.GSloop
LDRB TEMP,[M,X]
CMP TEMP,#0
BEQ GSscip
ADD AD,AD0,X,LSL#2
LDR S,[AD,#4]
"LDR TEMP,[AD,#-4]:ADD S,S,TEMP
!LDR TEMP,[AD,DY]:ADD S,S,TEMP
SUB AD,AD,DY
!LDR TEMP,[AD,#0]:ADD S,S,TEMP
ADD AD,AD,DY
LDR TEMP,[AD,#0]
SUB S,S,TEMP,ASL#2
ADD S,S,S,ASR#1 ;1.5*D
!ADD S,S,S,ASR#2 ;1.75*D
MOV S,S,ASR#2
ADD S,S,TEMP
STR S,[AD,#0]
.GSscip
SUBS X,X,#1
BGT GSloop
MOV PC,R14
<A=0:TN=1:C=2:NP=3:X=4:Y=5:DX=6:TEMP=7:T=8:J=9:P=10:KL=11
[OPT PASS
.FillStoreAD EQUD0
.FillNP EQUD0
.FillAD EQUD0
.FillKL EQUD0
.Fill
,MOV T,R0:MOV J,#0:MOV P,R1:MOV P,P,LSL#2
,LDR DX,MainX:LDR NP,FillNP:LDR KL,FillKL
.FillLoop
LDR TN,FillStoreAD
ADD TN,TN,NP,LSL#2
LDR X,[T,J]:ADD J,J,#4
#MOV Y,X,LSR#16:SUB X,X,Y,LSL#16
LDR A,FillAD
MLA A,DX,Y,A
ADD A,A,X
SUB TEMP,DX,#1
CMP X,TEMP
BGE Fill2
LDRB TEMP,[A,#1]
CMP TEMP,C
BNE Fill2
MOV TEMP,KL
STRB TEMP,[A,#1]
ADD TEMP,X,#1
ADD TEMP,TEMP,Y,LSL#16
STR TEMP,[TN],#4
ADD NP,NP,#1
.Fill2
CMP X,#0
BLE Fill3
LDRB TEMP,[A,#-1]
CMP TEMP,C
BNE Fill3
MOV TEMP,KL
STRB TEMP,[A,#-1]
SUB TEMP,X,#1
ADD TEMP,TEMP,Y,LSL#16
STR TEMP,[TN],#4
ADD NP,NP,#1
.Fill3
#LDR TEMP,MainY:SUB TEMP,TEMP,#1
CMP Y,TEMP:BGE Fill4
LDRB TEMP,[A,DX]
CMP TEMP,C
BNE Fill4
MOV TEMP,KL
STRB TEMP,[A,DX]
ADD TEMP,Y,#1
ADD TEMP,X,TEMP,LSL#16
STR TEMP,[TN],#4
ADD NP,NP,#1
.Fill4
CMP Y,#0:BLE Fill5
SUB A,A,DX
LDRB TEMP,[A]
CMP TEMP,C
BNE Fill5
MOV TEMP,KL
STRB TEMP,[A]
SUB TEMP,Y,#1
ADD TEMP,X,TEMP,LSL#16
STR TEMP,[TN],#4
ADD NP,NP,#1
.Fill5
CMP J,P
BLT FillLoop
STR NP,FillNP
MOV PC,R14
)AD=0:DX=1:S=2:T=3:DIL=4:NOI=4:B=5:X=6
[OPT PASS
.Neighbours
MOV DIL,R3:MOV B,R0
(LDR X,MainX:SUBS X,X,#2:MOVLE PC,R14
.NeighboursLoop
ADD AD,B,X
+LDRB T,[AD,#0]:CMP T,#0:BNE NeighboursC
LDR DX,MainX
MOV S,#0
SUB AD,AD,DX
)LDRB T,[AD,#-1]:CMP T,#1:ADDEQ S,S,#1
(LDRB T,[AD,#0]:CMP T,#1:ADDEQ S,S,#1
(LDRB T,[AD,#1]:CMP T,#1:ADDEQ S,S,#1
ADD AD,AD,DX
)LDRB T,[AD,#-1]:CMP T,#1:ADDEQ S,S,#1
(LDRB T,[AD,#1]:CMP T,#1:ADDEQ S,S,#1
ADD AD,AD,DX
)LDRB T,[AD,#-1]:CMP T,#1:ADDEQ S,S,#1
(LDRB T,[AD,#0]:CMP T,#1:ADDEQ S,S,#1
(LDRB T,[AD,#1]:CMP T,#1:ADDEQ S,S,#1
6CMP S,DIL:MOVPL T,#2:SUB AD,AD,DX:STRPLB T,[AD,#0]
.NeighboursC
SUBS X,X,#1
BGT NeighboursLoop
MOV PC,R14
.Neighbours2
LDR DX,MainX
MOV NOI,R3:MOV B,R0
(LDR X,MainX:SUBS X,X,#2:MOVLE PC,R14
.Neighbours2Loop
MOV S,#0:ADD AD,B,X
,LDRB T,[AD,#0]:CMP T,#1:BNE Neighbours2C
SUB AD,AD,DX
)LDRB T,[AD,#-1]:CMP T,#1:ADDGE S,S,#1
(LDRB T,[AD,#0]:CMP T,#1:ADDGE S,S,#1
(LDRB T,[AD,#1]:CMP T,#1:ADDGE S,S,#1
ADD AD,AD,DX
)LDRB T,[AD,#-1]:CMP T,#1:ADDGE S,S,#1
(LDRB T,[AD,#1]:CMP T,#1:ADDGE S,S,#1
ADD AD,AD,DX
)LDRB T,[AD,#-1]:CMP T,#1:ADDGE S,S,#1
(LDRB T,[AD,#0]:CMP T,#1:ADDGE S,S,#1
(LDRB T,[AD,#1]:CMP T,#1:ADDGE S,S,#1
6CMP S,NOI:MOVPL T,#2:SUB AD,AD,DX:STRPLB T,[AD,#0]
MOV R0,S
.Neighbours2C
SUBS X,X,#1
BGT Neighbours2Loop
MOV PC,R14
AD=0:X=1:TEMP=2
[OPT PASS
.Filter
LDR X,MainN:SUB X,X,#1
.FilterLoop
LDRB TEMP,[AD,X]
CMP TEMP,#2
Q TEMP,#1:MOVNE TEMP,#0
STRB TEMP,[AD,X]
SUBS X,X,#1
BPL FilterLoop
MOV PC,R14
.Filter2
LDR X,MainN:SUB X,X,#1
.Filter2Loop
LDRB TEMP,[AD,X]
CMP TEMP,#1
Q TEMP,#2
STREQB TEMP,[AD,X]
SUBS X,X,#1
BPL Filter2Loop
MOV PC,R14
.Swap12
LDR X,MainN:SUB X,X,#1
.SwapLoop
LDRB TEMP,[AD,X]
CMP TEMP,#2
Q R8,#1:STREQB R8,[AD,X]
CMP TEMP,#1
Q R8,#2:STREQB R8,[AD,X]
SUBS X,X,#1
BPL SwapLoop
MOV PC,R14
-%S=0:L1=1:L2=2:RES=3:X=4:V1=5:V2=6
[OPT PASS
.Binary
05MOV R7,#&1:ADD R7,R7,R7,LSL#8:ADD R7,R7,R7,LSL#16
LDR X,MainN:BIC X,X,#3
.BinaryLoop
LDR V1,[L1,X]
LDR V2,[L2,X]
.BinaryInstr
RES,V1,V2
STR RES,[S,X]
SUBS X,X,#4
BGE BinaryLoop
MOV PC,R14
X=7:MASK=8:V=9:G=10:D=11
[OPT PASS
.Calc(0)
MOV R12,R14
MOV G,R1:MOV D,R2
MOV MASK,R0
LDR X,MainN
.CalcLoop(0)
SUBS X,X,#1
MOVLT PC,R12
MOV R0,X:BL ReadRGBfast
MOV V,#0
H, ADD R0,R0,R1:ADD R0,R0,R2:SUBS R0,R0,G
RSBLT R0,R0,#0:CMP R0,D
MOVLE V,#1
STRB V,[MASK,X]
B CalcLoop(0)
N&X=7:MASK=8:V=9:R=10:G=11:B=12:D=13
[OPT PASS
.RGBopsl EQUD0:EQUD0:EQUD0
.Calc(1)
STR R13,CalcOpsl
STR R14,CalcOpsl+4
MOV MASK,R0
U'MOV R,R1:MOV G,R2:MOV B,R3:MOV D,R4
V1STR R,RGBopsl:STR G,RGBopsl+4:STR B,RGBopsl+8
LDR X,MainN
.CalcLoop(1)
SUBS X,X,#1
BLT CalcEnd(1)
MOV R0,X:BL ReadRGBfast
MOV V,#0
]4 LDR R,RGBopsl:LDR G,RGBopsl+4:LDR B,RGBopsl+8
^& SUB R,R,R0:SUB G,G,R1:SUB B,B,R2
_ MOV R0,R:MOV R1,G:MOV R2,B
`) MUL R0,R,R0:MUL R1,G,R1:MUL R2,B,R2
ADD R0,R0,R1:ADD R0,R0,R2
CMP R0,D
MOVLE V,#1
STRB V,[MASK,X]
B CalcLoop(1)
.CalcEnd(1)
LDR R13,CalcOpsl
LDR PC,CalcOpsl+4
.CalcOpsl EQUD0:EQUD0
k?Z=5:M=6:X=7:V=8:T=9:D=10:TEMP1=4:TEMP2=14:TR=13:TG=12:TB=11
[OPT PASS
.Calc(2)
STR R13,CalcOpsl
STR R14,CalcOpsl+4
p4MOV T,R0:LDRB TR,RGB:LDRB TG,RGB+1:LDRB TB,RGB+2
MOV Z,R1:MOV M,R2
LDR X,MainN
.CalcLoop(2)
SUBS X,X,#1
BLT CalcEnd(1)
MOV R0,X:BL ReadRGBfast
ADD V,R0,R1:ADD V,V,R2
MUL TEMP1,R0,T
MUL TEMP2,TR,V
zC SUB TEMP1,TEMP1,TEMP2:MOV TEMP2,TEMP1,ASR#2:MUL D,TEMP1,TEMP2
MOV D,D,LSR#8
MUL TEMP1,R1,T
MUL TEMP2,TG,V
~[ SUB TEMP1,TEMP1,TEMP2:MOV TEMP2,TEMP1,ASR#2:MUL TEMP2,TEMP1,TEMP2:ADD D,D,TEMP2,LSR#8
MUL TEMP1,R2,T
MUL TEMP2,TB,V
[ SUB TEMP1,TEMP1,TEMP2:MOV TEMP2,TEMP1,ASR#2:MUL TEMP2,TEMP1,TEMP2:ADD D,D,TEMP2,LSR#8
) MUL TEMP1,V,T:MOV TEMP1,TEMP1,LSR#4
5 MOV TEMP2,TEMP1:MUL TEMP2,TEMP1,TEMP2 ;V*V*T*T
/ MOV TEMP2,TEMP2,LSR#12:MUL TEMP2,Z,TEMP2:
MOV TEMP2,TEMP2,LSR#6
MOV R0,#0
CMP D,TEMP2
MOVLE R0,#1
STRB R0,[M,X]
B CalcLoop(2)
?L=0:S=1:Y=1:MAX=2:DX=3:Xacc=5:TEMP=6:V=7:TEL=10:YY=11:MM=12
[OPT PASS
!.ZOOM EQUD0:EQUD0:EQUD0:EQUD0
.ZOOMX EQUD0
.ZOOMY EQUD0
._S0 EQUD0
._XW EQUD0
._MASK EQUD0
._DY EQUD0
._Y EQUD0
.DisplayMask
#MOV TEL,R0:MOV YY,#0:MOV MM,MAX
.DisplayMaskLoop2
LDR L,_Y:MOV L,L,LSR#18
LDR TEMP,MainX
MUL L,TEMP,L
LDR TEMP,_MASK
ADD L,L,TEMP
LDR TEMP,_XW
MUL S,TEMP,YY
LDR TEMP,_S0
ADD S,S,TEMP
MOV Xacc,#0
MOV MAX,MM
.DisplayMaskLoop
LDRB TEMP,[L,Xacc,ASR#18]
MOV V,TEMP,LSL#2
CMP V,#4:
Q V,#255
STRB V,[S],#1
ADD Xacc,Xacc,DX
SUBS MAX,MAX,#1
BGE DisplayMaskLoop
LDR V,_Y
LDR TEMP,_DY
ADD V,V,TEMP
STR V,_Y
ADD YY,YY,#1
SUBS TEL,TEL,#1
BGT DisplayMaskLoop2
.DoNothing
MOV PC,R14
DX=0:Y=1:L=1:CM=2:MASK=7:AD=8:Xacc=9:DX=10:Xmax=11:ER=4:EG=5:EB=6
L1=12:L2=13
[OPT PASS
.MaskColor EQUD0
.DisplayMainMask
5STR R13,DisplayMainOpsl:STR R14,DisplayMainOpsl+4
MOV DX,R2:MOV R12,R1
$LDR Xmax,ZOOM+8:ADD Xmax,Xmax,#1
MOV R13,MASK:LDR MASK,_MASK
LDR R12,MainX
MLA MASK,R12,R13,MASK
LDR R13,_XW:LDR R14,_S0
MLA AD,R13,R3,R14
&LDR Xacc,ZOOM:MOV Xacc,Xacc,LSL#18
LDRB CM,MaskColor
.DisplayMainMaskLoop
LDRB R4,[MASK,Xacc,ASR#18]
#CMP R4,#0:
Q R0,CM:ADDEQ L,L,#1
LDRNEB R0,[L],#1
STRB R0,[AD],#1
ADD Xacc,Xacc,DX
CMP Xacc,Xmax,LSL#18
BLT DisplayMainMaskLoop
LDR R13,DisplayMainOpsl
LDR PC,DisplayMainOpsl+4
._L1 EQUD0
._L2 EQUD0
".DisplayData EQUD0:EQUD0:EQUD0
.DisplayMainOpsl EQUD0:EQUD0
.DisplayMain
5STR R13,DisplayMainOpsl:STR R14,DisplayMainOpsl+4
#MOV DX,R2:MOV AD,R3:MOV MASK,R1
$LDR Xmax,ZOOM+8:ADD Xmax,Xmax,#1
LDR Xacc,ZOOM
MOV Xacc,Xacc,LSL#18
LDR L1,_L1
LDR L2,_L2
.DisplayLoop
MOV Y,MASK:MOV X,Xacc,LSR#18
BL ReadRGB
;LDR R3,[L1,#-1]
";LDR R3,[L1,#-1]:;ADD R3,R3,R4
LDR R3,[L1,#0]:;ADD R3,R3,R4
LDR R4,[L2,#0]:ADD R3,R3,R4
6SUB R3,R3,#&80:SUB R3,R3,#&8000:SUB R3,R3,#&800000
R4,R3,#&FF0000:MOV R4,R4,LSR#16:SUB R4,R4,#&80
ADD R0,R0,R4
R4,R3,#&00FF00:MOV R4,R4,LSR#8:SUB R4,R4,#&80
ADD R1,R1,R4
R4,R3,#&0000FF:SUB R4,R4,#&80
ADD R2,R2,R4
CMP R0,#255:MOVPL R0,#255
CMP R1,#255:MOVPL R1,#255
CMP R2,#255:MOVPL R2,#255
CMP R0,#0:MOVLT R0,#0
CMP R1,#0:MOVLT R1,#0
CMP R2,#0:MOVLT R2,#0
ADR R4,DisplayData
STMIA R4,{R0,R1,R2}
BL RGBtoPOKE
STRB R0,[AD],#1
BL getRGB8
ADR R4,DisplayData
LDMIA R4,{ER,EG,EB}
*SUB ER,ER,R0:SUB EG,EG,R1:SUB EB,EB,R2
MOV R0,#&80
<ADD ER,R0,ER,ASR#1:ADD EG,R0,EG,ASR#1:ADD EB,R0,EB,ASR#1
ADD R0,EB,EG,LSL#8
ADD R0,R0,ER,LSL#16
STR R0,[L1,#4]
STR R0,[L2,#0]
ADD L1,L1,#4:ADD L2,L2,#4
ADD Xacc,Xacc,DX
CMP Xacc,Xmax,LSL#18
BLT DisplayLoop
LDR R13,DisplayMainOpsl
LDR PC,DisplayMainOpsl+4
.DisplayMainFast
5STR R13,DisplayMainOpsl:STR R14,DisplayMainOpsl+4
$MOV DX,R2:MOV AD,R3:;MOV MASK,R1
$LDR Xmax,ZOOM+8:ADD Xmax,Xmax,#1
LDR Xacc,ZOOM
MOV Xacc,Xacc,LSL#18
.DisplayLoopFast
ADD X,MASK,Xacc,LSR#18
BL ReadRGBfast
BL RGBtoPOKE
STRB R0,[AD],#1
ADD Xacc,Xacc,DX
CMP Xacc,Xmax,LSL#18
BLT DisplayLoopFast
LDR R13,DisplayMainOpsl
LDR PC,DisplayMainOpsl+4
#X=0:Y=1:R=0:G=1:B=2:TEMP=3:AD=4
[OPT PASS
.MainX EQUD0
.MainY EQUD0
.MainN EQUD0
.MainLine EQUD0
.MainL EQUD0
.Main24 EQUD0
.MainPal EQUD0
.MainEntry EQUD0
.MainData EQUD0
.RGB EQUD0
.ReadRGB
LDR TEMP,Main24
CMP TEMP,#0
BEQ ReadRGBpalette
LDR AD,MainData
'!ADD AD,AD,X:ADD AD,AD,X,LSL#1
LDR TEMP,MainLine
MUL TEMP,Y,TEMP
ADD AD,AD,TEMP
+0LDRB R,[AD,#0]:LDRB G,[AD,#1]:LDRB B,[AD,#2]
,(STRB R,RGB:STRB G,RGB+1:STRB B,RGB+2
MOV PC,R14
.ReadRGBpalette
LDR AD,MainData
ADD AD,AD,X
LDR TEMP,MainLine
MUL TEMP,Y,TEMP
ADD AD,AD,TEMP
LDRB TEMP,[AD]
ADD TEMP,TEMP,TEMP,LSL#1
LDR AD,MainPal
ADD AD,AD,TEMP
LDRB R,[AD,#0]
LDRB G,[AD,#1]
LDRB B,[AD,#2]
;(STRB R,RGB:STRB G,RGB+1:STRB B,RGB+2
MOV PC,R14
.ReadRGBfast
LDR TEMP,Main24
CMP TEMP,#0
BEQ ReadRGBpalettefast
LDR AD,MainData
C!ADD AD,AD,X:ADD AD,AD,X,LSL#1
D0LDRB R,[AD,#0]:LDRB G,[AD,#1]:LDRB B,[AD,#2]
MOV PC,R14
.ReadRGBpalettefast
LDR AD,MainData
LDRB TEMP,[AD,X]
ADD TEMP,TEMP,TEMP,LSL#1
LDR AD,MainPal
ADD AD,AD,TEMP
LDRB R,[AD,#0]
LDRB G,[AD,#1]
LDRB B,[AD,#2]
MOV PC,R14
.RGBtoPOKE
R'LDR R3,pal:CMP R3,#0:BNE RGBtoPOKE1
CMP R0,#0:MOVLT R0,#0
CMP R1,#0:MOVLT R1,#0
CMP R2,#0:MOVLT R2,#0
CMP R0,#255:MOVGT R0,#255
CMP R1,#255:MOVGT R1,#255
CMP R2,#255:MOVGT R2,#255
SUB R0,R0,R0,ASR#5
SUB R1,R1,R1,ASR#5
SUB R2,R2,R2,ASR#5
R3,R0,#48:
R4,R1,#48:
R5,R2,#48
])ADD R3,R3,R4:ADD R3,R3,R5:ADR R4,TTAB
LDRB R3,[R4,R3,LSR#4]
_3MOV R0,R0,LSR#6:MOV R1,R1,LSR#6:MOV R2,R2,LSR#6
ADD R3,R3,R1,LSL#5
R4,R0,#1:ADD R3,R3,R4,LSL#2
R4,R2,#1:ADD R3,R3,R4,LSL#3
R4,R0,#2:ADD R3,R3,R4,LSL#3
R4,R2,#2:ADD R0,R3,R4,LSL#6
MOV PC,R14
.RGBtoPOKE1
CMP R0,#0:MOVLT R0,#0
CMP R1,#0:MOVLT R1,#0
CMP R2,#0:MOVLT R2,#0
CMP R0,#255:MOVGT R0,#255
CMP R1,#255:MOVGT R1,#255
CMP R2,#255:MOVGT R2,#255
SUB R0,R0,R0,ASR#4
SUB R1,R1,R1,ASR#4
SUB R2,R2,R2,ASR#3
p3MOV R0,R0,LSR#5:MOV R1,R1,LSR#5:MOV R2,R2,LSR#6
MOV R3,R0,LSL#2
R4,R1,#%110:ADD R3,R3,R4,LSL#4
R4,R1,#%1:ADD R3,R3,R4
R4,R2,#%10:ADD R3,R3,R4,LSL#6
R4,R2,#%1:ADD R0,R3,R4,LSL#1
MOV PC,R14
w .TTAB
EQUB 0
EQUB 0
EQUB 1
EQUB 1
EQUB 1
EQUB 2
EQUB 2
EQUB 3
EQUB 3
EQUB 3
ALIGN
.getRGB8
.;Leest RGB waardes van r0=archimedes kleur
)STR R4,getRGB8O+12:STR R5,getRGB8O+16
%LDR R4,pal:CMP R4,#1:BEQ getRGB81
MOV R4,R0
R0,R4,#16:MOV R0,R0,LSR#1:
R5,R4,#7:ADD R0,R0,R5:MOV R0,R0,LSL#4;Rood
R1,R4,#96:MOV R1,R1,LSL#1:
R5,R4,#3:ADD R1,R1,R5,LSL#4;Groen
R2,R4,#128:
R5,R4,#8:ADD R2,R2,R5,LSL#3:
R5,R4,#3:ADD R2,R2,R5,LSL#4;Blauw
<ADD R0,R0,R0,LSR#4:ADD R1,R1,R1,LSR#4:ADD R2,R2,R2,LSR#4
)LDR R4,getRGB8O+12:LDR R5,getRGB8O+16
(STR R0,rgb:STR R1,rgb+4:STR R2,rgb+8
MOV PC,R14
.getRGB81
MOV R4,R0
R0,R4,#%11100:MOV R0,R0,LSL#3
R1,R4,#%01100000:MOV R1,R1,LSL#1:
R5,R4,#1:ADD R1,R1,R5,LSL#5
R2,R4,#%10000000:
R5,R4,#%10:ADD R2,R2,R5,LSL#5
<ADD R0,R0,R0,LSR#3:ADD R1,R1,R1,LSR#3:ADD R2,R2,R2,LSR#2
)LDR R4,getRGB8O+12:LDR R5,getRGB8O+16
(STR R0,rgb:STR R1,rgb+4:STR R2,rgb+8
MOV PC,R14
MOV R4,R0
.getRGB8O
+.rgb EQUD 0:EQUD 0:EQUD 0:EQUD 0:EQUD 0
.pal EQUD 0
(X=5:Y=6:C=7:T=8:EX=9:A=10:EY=11:E=12
[OPT PASS
.EdgeVal EQUD0
.EdgeAd EQUD0
.EdgeOpsl EQUD0:EQUD0
.Edge
'STR R13,EdgeOpsl:STR R14,EdgeOpsl+4
LDR X,MainX:SUB X,X,#2
MOV Y,R1
ADR A,RGB
.EdgeLoopX
MOV E,#0:MOV C,#2
.EdgeLoop
SUB R0,X,#1:SUB R1,Y,#1
BL ReadRGB
LDRB EX,[A,C]
LDRB EY,[A,C]
MOV R0,X:SUB R1,Y,#1
BL ReadRGB
LDRB T,[A,C]
ADD EY,EY,T,LSL#1
ADD R0,X,#1:SUB R1,Y,#1
BL ReadRGB
LDRB T,[A,C]
SUB EX,EX,T:ADD EY,EY,T
SUB R0,X,#1:MOV R1,Y
BL ReadRGB
LDRB T,[A,C]
ADD EX,EX,T,LSL#1
ADD R0,X,#1:MOV R1,Y
BL ReadRGB
LDRB T,[A,C]
SUB EX,EX,T,LSL#1
SUB R0,X,#1:ADD R1,Y,#1
BL ReadRGB
LDRB T,[A,C]
ADD EX,EX,T:SUB EY,EY,T
MOV R0,X:ADD R1,Y,#1
BL ReadRGB
LDRB T,[A,C]
SUB EY,EY,T,LSL#1
ADD R0,X,#1:ADD R1,Y,#1
BL ReadRGB
LDRB T,[A,C]
SUB EX,EX,T:SUB EY,EY,T
MOV T,EX:MUL EX,T,EX
MOV T,EY:MUL EY,T,EY
ADD E,E,EX:ADD E,E,EY
SUBS C,C,#1
BPL EdgeLoop
LDR R0,EdgeAd
LDR T,EdgeVal
CMP E,T
MOV T,#0:MOVGT T,#1
STRB T,[R0,X]
SUBS X,X,#1
BGT EdgeLoopX
LDR R13,EdgeOpsl
LDR PC,EdgeOpsl+4
'A=0:B=1:X=2:TEMP=3:S=4:L=5:T=L:TX=6
,Lacc=12:Xacc=4:MLacc=2^Lacc:MXacc=2^Xacc
[OPT PASS
._LI EQUD0
._AD EQUD0
._DA EQUD0
._ML EQUD0
._bpp EQUD0
._Mu1 EQUD0
._u0 EQUD0
._u1 EQUD0
._u2 EQUD0
._v0 EQUD0
._v1 EQUD0
._v2 EQUD0
._l1 EQUD0
._l2 EQUD0
.Aacc EQUD0
.Bacc EQUD0
.Da EQUD0
.Db EQUD0
.morphx EQUD0
._tri EQUD0
._Msk EQUD0
._Xmax EQUD0
.morph
MOV TEMP,#0
STR TEMP,morphx
.morphline
LDR A,Aacc
LDR B,Bacc
LDR TEMP,Da
ADD TEMP,TEMP,A
STR TEMP,Aacc
LDR TEMP,Db
ADD TEMP,TEMP,B
STR TEMP,Bacc
MOV A,A,ASR#12
MOV B,B,ASR#12
LDR TEMP,_Msk
LDR X,morphx
'LDRB X,[TEMP,X] ;check triangle
LDR TEMP,_tri
CMP TEMP,X
*BNE inx ;in wrong triangle
STR R0,_l1
STR R1,_l2
LDR TEMP,_v0
LDR T,_l1
!MUL B,T,TEMP ;B=L1*V0
LDR TEMP,_v1
LDR T,_l2
'MLA B,T,TEMP,B ;B=L1*V0+L2*V1
LDR TEMP,_v2
ADD B,B,TEMP,LSL#Lacc
;ADD B,B,#1<< (Lacc+Xacc-1)
MOV B,B,ASR#Lacc+Xacc
CMP B,#0:MOVMI B,#0
LDR TEMP,_u0
LDR T,_l1
!MUL A,T,TEMP ;A=L1*U0
LDR TEMP,_u1
LDR T,_l2
'MLA A,T,TEMP,A ;A=L1*U0+L2*U1
LDR TEMP,_u2
ADD A,A,TEMP,LSL#Lacc
;ADD A,A,#1<< (Lacc+Xacc-1)
LDR TEMP,_Mu1
LDR X,morphx
MUL TEMP,X,TEMP
ADD A,A,TEMP,LSL#Xacc
MOV A,A,ASR#Lacc+Xacc
ADD TX,X,#1
STR TX,morphx
LDR TEMP,_bpp
MUL A,TEMP,A ;A=3*A%
MUL X,TEMP,X ;X=3*X%
LDR TEMP,_AD
'1ADD S,X,TEMP ;Write address ;S=AD%+3*X%
LDR TEMP,_ML
)%MLA L,TEMP,B,A ;L=B%*ml%+3*A%
LDR TEMP,_DA
+)ADD L,L,TEMP ;L=Da%+B%*ml%+3*A%
LDRB TEMP,[L,#0]
STRB TEMP,[S,#0]
LDRB TEMP,[L,#1]
STRB TEMP,[S,#1]
LDRB TEMP,[L,#2]
STRB TEMP,[S,#2]
LDR X,morphx
LDR TEMP,_Xmax
CMP X,TEMP
BLT morphline
6 B iny
LDR X,morphx
ADD X,X,#1
STR X,morphx
LDR TEMP,_Xmax
CMP X,TEMP
BLT morphline
LDR A,_AD
LDR TEMP,_LI
ADD A,A,TEMP
STR A,_AD
LDR A,_Msk
LDR TEMP,_Xmax
ADD A,A,TEMP
STR A,_Msk
MOV PC,R14
I%P0=0:P1=1:M0=2:M1=3:T=4:T0=5:T1=6
[OPT PASS
LDR T,MainN
M$ADD T,T,T,LSL#2 ;3*!MainN
SUB T,T,#1
.mixloop
LDRB T0,[P0,T]
LDRB T1,[P1,T]
MUL T0,M0,T0
MLA T0,M1,T1,T0
ADD T0,T0,#512
MOV T0,T0,LSR#10
STRB T0,[P0,T]
SUBS T,T,#1
BGT mixloop
MOV PC,R14
[9LAD=0:X=1:MAX=2:SAD=3:T=4:B=5:W1=10:W2=11:W3=12:W4=13
[OPT PASS
.CompressBitfield
LDR MAX,MainN
MOV SAD,LAD
MOV X,#0
.comloop
LDMIA (LAD),{W1,W2}
ADD LAD,LAD,#8
T,W1,#1
TST W1,#1<<8:ADDNE T,T,#2
TST W1,#1<<16:ADDNE T,T,#4
TST W1,#1<<24:ADDNE T,T,#8
TST W2,#1:ADDNE T,T,#16
TST W2,#1<<8:ADDNE T,T,#32
TST W2,#1<<16:ADDNE T,T,#64
k TST W2,#1<<24:ADDNE T,T,#128
STRB T,[SAD],#1
ADD X,X,#8
CMP X,MAX
BLT comloop
MOV PC,R14
.DeCompressBitfield
LDR X,MainN
s*SUB X,X,#1:MOV X,X,LSR#3:MOV X,X,LSL#3
ADD SAD,LAD,X
ADD LAD,LAD,X,LSR#3
.decomloop
LDRB T,[LAD],#-1
W1,T,#1
TST T,#2:ADDNE W1,W1,#1<<8
TST T,#4:ADDNE W1,W1,#1<<16
TST T,#8:ADDNE W1,W1,#1<<24
MOV W2,T,LSR#4:
W2,W2,#1
TST T,#32:ADDNE W2,W2,#1<<8
~ TST T,#64:ADDNE W2,W2,#1<<16
!TST T,#128:ADDNE W2,W2,#1<<24
STMIA SAD,{W1,W2}
SUB SAD,SAD,#8
SUBS X,X,#8
BPL decomloop
MOV PC,R14
Ecentre=0:dx=1:MASK=5:XMAX=6:store=7:TEMP=8:S=9:M=10:sharp=11:X=12
[OPT PASS
.sharpS EQUD0
.sharpM EQUD0
.sharpMask EQUD0
.sharpStore EQUD0
.sharpen
MOV X,#1
LDR store,sharpStore
LDR S,sharpS
LDR M,sharpM
LDR XMAX,MainX
SUB XMAX,XMAX,#2
LDR MASK,sharpMask
.sharploop
ADD centre,centre,#3
LDRB TEMP,[MASK,X]
CMP TEMP,#0
BEQ sharpcont
LDRB sharp,[centre,#3]
LDRB TEMP,[centre,#-3]
ADD sharp,sharp,TEMP
LDRB TEMP,[centre,dx]
ADD sharp,sharp,TEMP
RSB dx,dx,#0
LDRB TEMP,[centre,dx]
ADD sharp,sharp,TEMP
MUL sharp,S,sharp
LDRB TEMP,[centre,#0]
MUL TEMP,M,TEMP
SUB sharp,TEMP,sharp
MOV sharp,sharp,ASR#10
CMP sharp,#0
MOVLT sharp,#0
CMP sharp,#255
MOVGT sharp,#255
STRB sharp,[store,X]
.sharpcont
ADD X,X,#1
CMP X,XMAX
BLE sharploop
MOV PC,R14
.sharpback
MOV X,#1
LDR store,sharpStore
LDR XMAX,MainX
SUB XMAX,XMAX,#2
LDR MASK,sharpMask
.sharpbackloop
ADD centre,centre,#3
LDRB TEMP,[MASK,X]
CMP TEMP,#0
BEQ sharpbackcont
LDRB sharp,[store,X]
STRB sharp,[centre]
.sharpbackcont
ADD X,X,#1
CMP X,XMAX
BLE sharpbackloop
MOV PC,R14
$AD1=0:AD2=1:L=9:Y=10:T1=11:T2=12
[OPT PASS
.flipy
LDR Y,MainY
LDR L,MainLine
.flipyloop
LDRB T1,[AD1]
LDRB T2,[AD2]
STRB T1,[AD2]
STRB T2,[AD1]
ADD AD1,AD1,L
ADD AD2,AD2,L
SUBS Y,Y,#1
BPL flipyloop
MOV PC,R14
name(AD%,N%)
A$,T%
<A$="":T%=0:
AD%?T%>=31
T%<N%:A$=A$+
(AD%?T%):T%+=1:
defaults
%CHANNEL=
("<Mask$Dir>.!Defaults")
T%=1
#CHANNEL):
A$=":"
A$=
#CHANNEL)
A$="="
V$="":
#CHANNEL):
A<>34
V$=V$+
C%=(A<32 )
C%=( A<=32
A=34)
A<>34
(V$)-1)
1:mode=V:
V<0
V>127
"Illegal mode":
"on":defdma=1
"off":defdma=0
"auto":defdma=2
I
"Error in !Defauls file:dma option unknown":defdma=2:B$=
"off":deffd=0
"on":deffd=1
Q
"Error in !Defaults file:FastDisplay option unknown":deffd=0:B$=
4:defpal=V:
V<>0
V<>1
"Error in !Defaults file:palette option unknown":defpal=0:B$=
"off":undo=
"on":undo=
L
"Error in !Defaults file:Undo option unknown":undo=
#CHANNEL
swap_init
Swap$(8),SwapLock(8),SwapLength(8),SwapAd(8)
Swap$()="InMemory"
SwapLock()=
swap_ensure(S%(0),S%(1),S%(2),S%(3))
S%(3)
S%(T%)>=0
SwapLock(S%(T%))=
S%(T%)>=0
Swap$(S%(T%))
"InMemory":
9
"Crunched":
swap_makefree(MaskAmount):
uncrunch
6
"OnDisc" :
swap_makefree(SwapLength(S%(T%))
swap_makefree(amount)
S%(3)
enough
*larg=
mc_maxblock:
larg=
error$:
block=
mc_usage(MASK(1))
amount<=larg
:
Memory can be assigned
amount<=free
tidymem
#. larg=
mc_maxblock:
larg=
error$:
$G
amount<=larg
:
Memory can be assigned after tidymem
%
ensuremem(amount,main,M(0),M(1),M(2),M(3))
larg,free,block
maskstatus()=0
enough=
not enough space, so make space:
T%=1
MaxMask%:maskstatus(T%)=0:
0=free to use
T%=0
3:maskstatus(M(T%))=1:
:
1=not free to use
/9left=0:
T%=1
MaxMask%:
maskstatus(T%)=0
left+=1
maxfree=free+left*block
main=
maxfree+=
mc_usage(MAIN)
amount > maxfree
:memory definitly can not be made free
maskstatus(T%)=0
7B A%=MASK(T%):
CompressBitfield:
PRINT"Compressed mask:";T%
8D MASK(T%)=
mc_reassign(A%,MaskAmount/8+16):
error$:
9G maskstatus(T%)=2 :
2=bitfield compressed.
free+=block
;
< T%+=1
T%>MaxMask%
amount<=free
>*larg=
mc_maxblock:
larg=
error$:
enough=
All masks are compressed and there is still not enough memory
restoremem
T%,FLAG%
FLAG%=
T%=1
MaxMask%
maskstatus(T%)=2
FLAG%=
I5
(MaskAmount+16) >
mc_maxblock
tidymem
J7 MASK(T%)=
mc_reassign(MASK(T%),MaskAmount+16)
K&
PRINT"Decompressing nr:";T%
MASK(T%)=
"Due to memory problems, masks are lost. (sorry).":MaxMask%=T%-1
A%=MASK(T%):
DeCompressBitfield
FLAG% :
tidymem
mc_init(amount,page)
A%,B%,C%
inits memory controller, giving it 'amount' bytes off memory.
readcopymem:mc_page=page
mc_page<16
mc_page=256
W#mc_amount=-
(-amount/page)*page
mc_memory mc_amount
YCmc_max=amount/mc_page-1:
mc_map mc_max+5:mc_map+=1:mc_map?-1=
ZEA%=mc_map:B%=mc_map+mc_max+2:C%=0:
VULMEM:?(mc_map+mc_max+1)=255
error$="No error"
mc_restore(ad,amount)
T1,T2
mc_nr(ad):
a&T2=
mc_nr(ad+amount-1):
mc_getnr:
T%=T1
mc_map?T%<>0
error$="memory is occupied":=
mc_map?T%=nr
mc_assign(amount)
A%,B%,C%,T%
amount>
mc_free
error$="Not enough memory, "+
(amount-
mc_free)+" Bytes too little.":=
mc_getnr:
m,mc_ad=
mc_bestfit(amount):
mc_ad=
mc_nr(mc_ad)=
oKA%=mc_map+
mc_nr(mc_ad):B%=mc_map+
mc_nr(mc_ad+amount-1):C%=nr:
VULMEM
=mc_ad
mc_free
T%,F%:F%=0
T%=0
mc_max:
mc_map?T%=0
F%+=1
:=F%*mc_page
mc_maxblock
T%,F%
mc_largest=-1:T%=0
{+F%=0:
mc_map?T%=0:T%+=1:F%+=1:
:T%+=1
F%>mc_largest
mc_largest=F%
T%>mc_max
=mc_largest*mc_page
mc_getnr
A%,B%,C%,D%,F%,T%,M%:M%=1
"A%=mc_max:B%=mc_map:C%=M%:D%=
mc_getnr
M%+=1
M%>=255
M%>=255
error$="Too many handles":=
=M%-1
mc_nr(ad)
nr%=(ad-mc_memory)/mc_page
nr%<0
nr%>mc_max
error$="handle is outside range":=
mc_showmap
T%,N%
T%=0
mc_max:N%=mc_map?T%
N%>0
(48+N%);
mc_bestfit(amount)
T%,best,len
mc_smallest=1E8:best=0:T%=0
mc_map?T%<>0:T%+=1:
T%<=mc_max
+ len=0:
mc_map?T%=0:len+=1:T%+=1:
S
(len*mc_page >= amount)
(len<mc_smallest)
mc_smallest=len:best=T%-len
T%>mc_max
mc_smallest=1E8
error$="Not enough continious memory.":=
=mc_memory+best*mc_page
mc_release(handle)
A%,B%,C%,T%,nr
Gnr=mc_map?
mc_nr(handle):
nr=0
error$="Handle does not exist":=
*A%=mc_map:B%=mc_max:C%=nr:
mc_release
mc_usage(handle)
T%,U%,nr
-U%=0:nr=mc_map?
mc_nr(handle):
T%=0
mc_max:
mc_map?T%=nr
U%+=1
=U%*mc_page
mc_reallocate(handle)
nr,amount,T%
,amount=
mc_usage(handle):
amount=
mc_reassign(handle,amount):
mc_reassign(handle,amount)
A%,B%,C%,T%,nr,ad,a
mc_usage(handle):
amount<a
a=amount
mc_release(handle)=
error$:
mc_assign(amount):
ad<>handle
mc_nr(handle)<>
A%=handle:B%=handle+a-1:C%=ad:
FASTCOPYMEM
readcopymem
COPYMEM 280
CALL COPYMEM (BeginLoad,EindLoad,BeginSave,-,-,0,0,0,0,0,0,0,0,0,0,0)
Verplaats een stuk geheugen. Van BeginLoad tot EindLoad naar BeginSave
CALL VULMEM (Beginadres,Eindadres,Waarde,0,0,0,0,0,0,0,0,0,0,0,0,0)
PASS=0
P%=COPYMEM
[OPT PASS
CMP R0,R2
BLS Anderevolgorde
.COPYMEMLOOP
LDRB R3,[R0],#1
STRB R3,[R2],#1
CMP R0,R1
BLE COPYMEMLOOP
MOV PC,R14
.Anderevolgorde
SUB R3,R2,R0
$ADD R3,R3,R1 ;R3=EindSave
.COPYLOOP2
LDRB R4,[R1],#-1
STRB R4,[R3],#-1
CMP R1,R0
BPL COPYLOOP2
MOV PC,R14
.FASTCOPYMEM
CMP R0,R2
BLS AnderevolgordeF
.FASTCOPYMEMLOOP
LDR R3,[R0],#4
STR R3,[R2],#4
CMP R0,R1
BLE FASTCOPYMEMLOOP
MOV PC,R14
.AnderevolgordeF
#MOV R1,R1,LSR#2:MOV R1,R1,LSL#2
SUB R3,R2,R0
$ADD R3,R3,R1 ;R3=EindSave
.FASTCOPYLOOP2
LDR R4,[R1],#-4
STR R4,[R3],#-4
CMP R1,R0
BPL FASTCOPYLOOP2
MOV PC,R14
.VULMEM
STRB R2,[R0],#1
CMP R0,R1
BLE VULMEM
MOV PC,R14
.mc_getnr
LDRB R4,[R1,R0]
CMP R4,R2:MVNEQ R3,#0
SUBS R0,R0,#1
BPL mc_getnr
MOV R0,R3
MOV PC,R14
.mc_release
MOV R4,#0
LDRB R3,[R0,R1]
CMP R3,R2
STREQB R4,[R0,R1]
SUBS R1,R1,#1
BPL mc_release
MOV PC,R14