Tuesday, January 31, 2006

Tuesday 31st

Despite a severe storm taking out power for the best part of the night, I managed to chip another task off the To-Do list; tonight it was the turn of the Info panel to get a much-needed nip 'n' tuck, as there was plenty of information which a) wasn't needed on the panel in the first place, b) badly laid out and taking up too much space, or c) not included at all.

After much tweaking, testing, and recompiling, the panel now displays the following information:

1. The current Drawing Mode (eg. Pen Mode).

2. The Currently-selected Layer, along with (L) if the Layer is locked, (D) if being viewed as Decimal, and (H) if being viewed as hex.

3. The cursor's X position, followed by the Map Width (e.g. 5/120).

4. The cursor's Y position, followed by the Map Height (e.g. 6/120).

5. The current Left tile, followed by the number of occurrences of that tile in the current Layer.

6. The current Right tile, followed by the number of occurrences of that tile in the current Layer.

7. The currently-selected Tileset, followed by the Tileset assigned to the current Layer.

8. The Mask status (Off or On).

9. The Grid Status (Off, Normal, or Brush, followed by (S) if grid scrolling is activated).

10. The current Grid X and Y sizes (eg. 5/12).

11. The current Shape X and Y sizes (shapes being any line, box, or circle being drawn by the player, or the current Brush).

12. The Parallax X and Y speeds (eg. 3/3).

13. The current Animation status (On or Off).

14. The current Zoom Level (25%, 50%, 75%, or 100%).

15. The Symmetry status (X, Y, or X+Y).

16. The current Symmetry X and Y values (eg. 5/5).

With that task out of the way, I made a couple of tweaks to the main window layout, adding checkboxes to control the looping for the Static and Parallax Layers (this had previously been tucked away in the Layer menu and wasn't nearly as accessible as it should have been). This tweak also required a minor modification to the Project I/O.

At last, the light at the end of the tunnel seems to be in sight; I have but four tasks left on my Pre-Beta list (Undo/Redo, Circle Mode, Documentation, plus a bug fix in the MiniMap routine), and thankfully most of the items on the Post-Beta list are really just features which I'd like to include but won't really be missed if I run out of time. I won't curse the project by mentioning a release date - but it'll be soon :)

Monday, January 30, 2006

Monday 30th

I'm now getting down to the final few tasks before beta, two of which - Map Rotation and Undo/Redo - are old friends as far as the development process goes. After trying, without success, to write a fast and shorthand map rotation algorithm, I settled with slower/reliable (after all, it works for Brush rotation, so why reinvent the wheel?).

After toiling for a couple of hours, I managed to get the arrays and buffers talking to each other, but during the debugging process I encountered a bug when small maps (ie. smaller in width/height than the screen) are loaded back into the Editor. This then led me to discover a teensy bug in the Project I/O routine, and for a moment I felt a very overwhelming sense of foreboding.

However, patience was the key, and after fixing the Project I/O (which, thankfully, didn't have an adverse effect on existing project files), I tracked down the map problem to a couple of calls within an existing routine which were resetting variables I was trying to change.

With that out of the way, and after putting in some failsafe checks to ensure that all routines that read the map data are reset properly, the rotation code was in and working. As an afterthought, I added the option to rotate the tiles along with the map - thanks to the way I'd structured my code, this took just a couple of minutes to add, and in the space of a day the Editor has become even more feature-packed and powerful.

Friday, January 27, 2006

Friday 27th

Brute force urged me to make progress today, so after preparing Non-Disclosure Agreements for my team of Beta Testers, I ploughed ahead with the INI routines and completed the save portion of the routine. This took a while to debug, and on closer investigation it appeared that the file wasn't being touched by the Editor at all.

This led me to realise that some of my string values weren't enclosed in quotes, causing the routine to find a null value and exit; a few little tweaks later, everything was working perfectly. I finished up by adding the save function call at each of the three program exit points (clicking close, choosing Quit, or tapping Esc). I may choose to add a "Save Preferences" option later, but for now the system is complete.

The final task of the night was the Tile Duplicate system; I'd written the bare bones of this with some help from my chum Muttley, but for some reason the routine failed to work properly. Additionally, I'd also had issues with how the data is presented to the user (and over my dead body would I dump the data to an external TXT file).

A couple of days ago I hit upon the idea of using a similar system to that of my Unused Tiles system; basically, if a tile is being used in the current map, it is overlaid with a tick (and if not, overlaid with a cross). This system could also work for duplicates - click on a Tile, and any duplicates are overlaid with a tick.

After setting up the core variables and logic for this, I could then use it to debug the checking routine - after all, I would know what the duplicate tiles were and thus, be able to see precisely when the routine failed to work.

I finally managed to track down the source of the problem mere minutes before going to bed (I usually load my brain with code before I got to sleep in the hope that my subconscious will solve them overnight). The problem stemmed from the way the buffers were being set up and locked for pixel-reading operations. After a bit of tinkering, the routine is now slightly slower at checking, but works 100%. Result :)

Thursday, January 26, 2006

Thursday 26th

Started on the INI file system, as it was top of my (reformatted!) To-Do list. This was a fairly lengthy task, mainly because I needed to sift through all of the variables and work out which ones should be stored and loaded automatically with the program.

After quite a lot of intensive copying and pasting, I had a structure for the INI file established, and managed to complete the foundations of the initialisation routine (though at present, a number of variables aren't being set properly - one of the joys of using someone else's code, I imagine).

Wednesday, January 25, 2006

Wednesday 25th

Bit the bullet today and decided to finish off the Tile Resize system I'd had trouble with a week ago. The plan was reasonably simple - create executables on the main PC and test them on the laptop, which wasn't too much of an ordeal as the pair are already networked.

Within an hour or so I'd managed to get the routines working properly, and the system required just a few more tweaks and checks to ensure that everything else worked properly (buffers being reset and variables restored, the kind of boring housework that often gets overlooked until someone finds a bug).

The next task was a small tweak to the Zoom routine, as I realised that the Zoom tileset is calculated by loading in the current tileset from disk - this meant that newly-created tilesets which hadn't yet been saved (and thus, had no file or filename) wouldn't be displayed. A few frantic finger flourishes later, the Zoom routine was working perfectly (and as an added bonus, I also tracked down a small bug in my buffer plot routine).

The remainder of today's session was spent adding code to handle INI files, so that preferences can be saved and loaded as required (some of the default settings are beginning to annoy even me!). Managed to find a suitable routine in the Blitz Code Archives, so I'll probably chop this down to the bare minimum for my requirements.

Rounded off by having a think about a Guides system for the Editor; while testing the Brush and Symmetry functions, it became apparent that some artists might need a guide or two, particularly if their maps are very long or tall. However, I've a strict list of things I really have to be getting on with, so the Guides will have to wait :)

Tuesday, January 24, 2006

Tuesday 24th

Finally managed to get the Decimal/Hex display routines finished, along with the tileset for use in 16x16 mode; the feature is reasonably useful if you're working on collision maps and so forth, and also if you're animating a lot of tiles (the decimal/hex numbers also animate accordingly). All that remained was to add the relevant keypresses and menu commands, and I'm one step closer to wrapping this editor up before 2007. :)

Monday, January 23, 2006

Monday 23rd

Started tackling a routine which I'd been meaning to finish for quite some time: the ability to view a layer as decimal or hex (as opposed to tiles). The main reason this was put on hold was due to processing power - Blitz seems to stumble when a huge amount of text is being printed on screen (which is often the case when in 16x16 tile mode), or when drawing a lot of rectangles.

I decided to get around this by a) not drawing a rectangle around each tile, instead just drawing a grid over the entire screen, and b) only printing text in 32x32 tile mode or greater - 16x16 tile mode would use a specially created tileset.

With the core of the routine written, all that remains is to finish the special 16x16 tileset. The final task of the night involved tracking down a bug which meant that the editor wasn't starting up properly when New Project was selected; after nearly an hour of tweaking and bypassing code, I found the culprit: a Return command in the wrong place. Gah!

Sunday, January 22, 2006

Sunday 22nd

Limited time to tackle any serious coding today, so I took the liberty of adding some simple functions I'd been thinking of for a while. The first of these was the Project stats, essentially a list of all the files currently in memory, along with their relevant paths. It's a fairly simple addition, but enables the user to see at a glance which elements have been saved, and also keep a handle on larger projects.

The final task involved adding inertia controls for the parallax scrolling when using the Test Map module; this enables the user to essentially control how closely the scroll follows the mouse pointer, and basically adds a little more precision if so desired.

Monday, January 16, 2006

Monday 16th

A glimmer of hope came in the form of some updated graphics drivers for my video card; it transpires that the bugs I've been wrestling with are due to an obscure video card problem (which wasn't an issue with my previous video card, which I swapped out only recently). A quick build transferred to the trusty laptop confirmed that it was indeed a hardware issue. After updating the video drivers, however, my code only worked once before hopping back on the bus to Bug City.

Although this isn't a significant problem (I can now just switch over to the laptop to finish key routines), it did reinstate my faith in the project and drove me to make some progress.

First up was a tweak to the New Project dialogue box - I'd neglected to include a Cancel button (which is something of a problem if you accidentally select the New Project option). A few minutes later, I'd inserted the relevant code and balance was restored.

Next came a tweak to the Tile clear functions, which weren't generating their thumbnails properly (and, thanks to my video card problem, I can't actually test the results!). However, the code uses an existing routine that I know is rock solid, so for now I'll have to work blind.

Next I tackled the Grab function; I'd inserted code a while back to allow lines to be constrained to vertical, horizontal, or diagonal, and similarly, constrained boxes to true squares. This code had never worked properly in Grab Mode when the constrained square went off the edge of the map, mainly because I'd been too elaborate with my checks - after inserting just a couple of tweaks at the start of the routine, everything was working as it should.

The final task of the night involved getting my symmetry code working wish Brushes; this is a lot trickier than it seems, mainly because the brush width has to be taken into account when you're generating the symmetry values. Additionally, the sophisticated clipping also caused chunks of the reflected brush to disappear if the equivalent chunk was off the edge of the screen.

Brute force was the order of the day, however, and after much head scratching and more than a little persistence, the basic code was in and working - now all I need to do is add the plotting code and masking code without breaking the already complex routines.

Sunday, January 15, 2006

Sunday 15th

Something of a red-letter day in the development of FishEd; after trying for two days to get my Tile Purge / Resize routines finished, it transpires that certain video cards - such as mine - cannot cope with images over a certain size. Not only does this mess up the routines I'm working on, it also means that other functions (such as copying/pasting Tile ranges, dumping the map to a BMP, etc.) also won't function properly.

With this in mind, FishEd is on temporary hold until I can find a way around the problem; there are simply too many changes - and too many compromises - to make to the Editor, given my limited time, and so, gracefully, I may have to hang up my coding hat until further notice.

Friday, January 13, 2006

Friday 13th

Spent the last couple of days making a few modifications to the Test Map system; instead of launching in its own window, the Test Map system now displays in the main window - this keeps everything centralised in one window and minimises confusion.

This also has the knock-on effect of rendering my additional buttons and checkboxes redundant, and also allows me to share parallax scrolling values between the Editor and the Test Map system. To get the system finished, today's tasks involved adding the relevant keyboard controls and adding some checks to ensure that the map cannot be scrolled off the bottom-right of the screen.

Tuesday, January 10, 2006

Tuesday 10th

Best laid plans being what they are, FishEd didn't reach Beta at the end of December; however, work has continued and good progress has been made over the last couple of days.

The main task in hand has involved finishing the Test Map module, which allows the user to see how their map will look when scrolled smoothly at varying speeds. I'd managed to find some code with a fairly simple scroller, so yesterday I took this code, rewrote it, then tweaked it to mimick how I wanted the Test Map system to operate.

After getting nowhere, I posted a message on the YakYak programming forum - after further investigation today, it transpired that I couldn't manipulate the MouseX and MouseY variables without first assigning them to another variable. These kinds of bugs are painful, mainly because you begin to question your programming ability when it's actually the compiler's fault. Grrr.

With this problem out of the way, today I began integrating the testbed code into the Editor; though this process took a while to debug (mainly due to the fact that the map display routine and logic routine all had to be tweaked to suit), results came thick and fast. I had to change the size of the visible area a couple of times, in order to make sure that all tile sizes can be displayed properly, so I resorted to using the current window size used by the Editor.

After a little more tinkering and debugging, the code was in and working; while holding the mouse button, tracking the cursor across the window will cause the map to scroll proportionally in the same direction (so clicking at the far right/left of the window takes the user to the far left/right of the map). This allows maximum control over the map scrolling, and feels extremely comfortable in practise.

This new system means that I'll no longer need a system for changing the scrolling speed; instead these will be applied to the Parallax layer, so that it scrolls at the correct ratio.