This'll be my last new plug-in for the year - want to start designing my new game soon... Anyway, this plug-is a lot more complicated than these previous versions as there can be more than 1 tile in a matrix.
The maximum number of matricies allowed is 8, and up to 65535 tiles in each of these.
In order to pass all the tile information, you need to allocate memory and fill this information with the following structure, which is 20 bytes in size :
+0 - Tile X Number
+4 - Tile Y Number
+8 - Tile Start Image Number
+12 - Tile End Image Number
+16-+19 - Timer
And then call the MatrixIRQSetup command with the address of this memory location, and the number of tiles, and the initial setup will be completed. Then its just a matter of starting the IRQ with the MatrixStartPause command.
There is one problem with this plug-in at the moment - the constant use of Update Matrix() has an adverse effect on your program, by slowing everything down. I think I can fix this in the future by making sure the update is only done when all tiles for a matrix have been updated. Therefore the maximum number tiles per matrix may be modified to a power of 2 later on (either increased or decreased).
Example code :
/Rem Project: TestMatrix
Rem Created: 24/12/2003 14:45:16
Rem ***** Main Source File *****
sync on
sync rate 0
#constant MAX 5
ptr=make memory(1024)
fill memory ptr,0,1024
remstart
+0 - X Tile
+4 - Y Tile
+8 - Start image index
+12 - End image index
+16 - Time
remend
restore
for z=0 to MAX-1
read x,y,time
pokeL ptr,(z*20)+0,x
pokeL ptr,(z*20)+4,y
pokeL ptr,(z*20)+8,2
pokeL ptr,(z*20)+12,XSIZE/16
pokeL ptr,(z*20)+16,time
next z
#constant XSIZE 128
#constant YSIZE 128
make matrix 1,XSIZE*8,YSIZE*12,XSIZE,YSIZE
position matrix 1,0.0,0.0,0.0
create bitmap 1,XSIZE*16,16
set current bitmap 1
cls 0
p=128
for x=1 to XSIZE/16
box (x*16),0,(x*16)+15,16,rgb(rnd(255),p,0),rgb(p,rnd(255),p),rgb(p,p,p+10),rgb(rnd(255),p,p)
inc p,5
next x
get image 1,0,0,XSIZE,16,1
set current bitmap 0
prepare matrix texture 1,1,XSIZE/16,1
position camera -10,50.0,-30.0
g=2
x=MatrixIRQSetup(1,1,MAX,ptr)
x=MatrixStartPause(1,0)
h#=0.0
pause=1
do
text 0,0,str$(screen fps())
`sprite 1,0,0,1
`set matrix height 1,1,2,h#
`set matrix height 1,2,2,h#
`set matrix height 1,1,3,h#
`set matrix height 1,2,3,h#
`update matrix 1
`ghost matrix on 1,1
inc h#,0.005
if spacekey()=1 then x=matrixStartPause(1,pause):pause=1-pause
if returnkey()=1 then matrixStopAll
if leftkey() then position camera 0,camera position x(0)-2.0,camera position y(0),camera position z(0)
if rightkey() then position camera 0,camera position x(0)+2.0,camera position y(0),camera position z(0)
if downkey() then position camera 0,camera position x(0),camera position y(0)-2.0,camera position z(0)
if upkey() then position camera 0,camera position x(0),camera position y(0)+2.0,camera position z(0)
` set matrix tile 1,0,0,g
` update matrix 1
` inc g
` if g>XSIZE/16 then g=1
sync
loop
data 1,2,20
data 5,5,120
data 7,8,50
data 8,8,51
data 12,12,40
The place for all
great plug-ins