Hello,
I was working on a project with raw files.
The idea was to hide graphics in easier manner.
The source code below is my result.
What do you think, it's usefull?
include "asm.inc"
window 640,512,1
SetFrames (60)
sys rawM[32],rawZ[32]
Sub StoreRaw(sys m,z)
for i=1 to 32
if rawM[i]=0
rawM[i]=m
rawZ[i]=z
Return i
end if
next
End Sub
Sub LoadRaw(string rawFile,sys size)
sys adr
hnd = OpenFile rawFile
adr = GetMemory(size*size*3)
ReadByte(hnd,*adr,size*size*3)
CloseFile(hnd)
Return StoreRaw(adr,size)
End Sub
Sub DrawRaw(sys id,x0,y0) as sys
for y=0 to <rawZ[id]
for x=0 to <rawZ[id]
z=(y*rawZ[id]+x)*3
p1=Peek rawM[id],z+0
p2=Peek rawM[id],z+1
p3=Peek rawM[id],z+2
if p1>0 and p2>0 and p3>0
Color p1,p2,p3
SetPixel x+x0,y+y0
end if
next
next
End Sub
Sub ScaleRaw(sys id,single x0,y0, xz,yz) as sys
for y=0 to <rawZ[id]
for x=0 to <rawZ[id]
z=(y*rawZ[id]+x)*3
p1=Peek rawM[id],z+0
p2=Peek rawM[id],z+1
p3=Peek rawM[id],z+2
if p1>0 and p2>0 and p3>0
Color p1,p2,p3
DrawPoint((x+x0)*xz,(y+y0)*yz,xz)
end if
next
next
End Sub
Sub BlendRaw(sys id,x0,y0, float alpha) as sys
for y=0 to <rawZ[id]
for x=0 to <rawZ[id]
z=(y*rawZ[id]+x)*3
p1=Peek rawM[id],z+0
p2=Peek rawM[id],z+1
p3=Peek rawM[id],z+2
if p1>0 and p2>0 and p3>0
Color p1,p2,p3
aPixel x+x0,y+y0,alpha
end if
next
next
End Sub
Sub FreeRaw()
for i=1 to 32
if rawM[i]>0
FreeMemory rawM[i]
rawM[i]=0
rawZ[i]=0
end if
next
End Sub
float a
tex1=LoadRaw ("raw/ball_64.raw",64)
tex2=LoadRaw ("raw/boll_64.raw",64)
tex5=LoadRaw ("raw/texture01_128.raw",128)
while Keydown(27)=0
cls 0,0,0
ScaleRaw tex5, 0, 0, 5,5
for i=0 to <640 step 64
DrawRaw tex1,i,100+sin(i+a)*60
DrawRaw tex2,i,200+sin(i+a)*60
next
Flip()
Wait(20)
a +=1
wend
FreeRaw()
WinEnd