No work tonight (grin), so I tucked straight into Mask mode once again; started off by tidying up the Tabbers which display the Tiles and the Mask - tiles are displayed as normal in the Tile tabber, and you now click on the Mask tabber to display the Tiles with Mask information overlaid. This was also combined with a key to turn the Mask on and off, which makes it much easier to use.
Next I set to work on integrating the Mask into the various drawing tools (Pen, Line, Box, Box Fill, Box Continuous, and Brush mode). Again this was relatively straightforward, and I finished up by adding a small function which will invert the current mask on the press of a key.
The next task was something of a biggie, a task I'd been pushing to the back for quite some time; I could have tackled another small job, but my brain was itching to get started on the dreaded Brush library. As mentioned in previous instalments, once you've grabbed a brush from the current map, you can "store" this in a Brush library and bring it back with the prod of a key (this library is saved as part of the current project). Well, that's the plan anyway.
As each Brush is an array, and I need an array of Brushes, the situation calls for an array of arrays; this is possible in Blitz only if the arrays are all the same size, and has the downside that when one array is resized, all the arrays are wiped. The solution, therefore, is to use a DataBank, which is more or less a "home made" array, is dynamic, and slightly more flexible.
After delving in at the deep end, I wrote a routine to firstly save the current brush to a DataBank, and then retrieve it. The save code seemed to work, but the load code continually crashed the program. After over an hour of trying different combinations and permutations, I tracked the problem down to a single variable that needed to be declared as "Global". Frustrating, but I'm glad I had the perseverance to, well, persevere. :)
Once the basics were working, I added the code to dynamically store brush dimensions in the DataBank too (until now I'd been using Brushes of a fixed size), but this kept resulting in an intermittent crash. "A memory leak!" I hear you cry.
In actual fact, the DataBank wasn't big enough - usually, you can define a properly-sized array by multiplying two variables together; with DataBanks, you have to add 1 to the variables, otherwise you're DataBank is too small. Not particularly consistent (excuse me while I have another grumble about the Blitz documentation!), but it was good not to end the day with more bugs on my list.
