Thursday, 19 August 2010

Deep Thought

I've decided to leave CHARPLOT alone after having a good think about whether to tweak it so that the structures use absolute addresses instead of the base+offset model it currently supports. Weighing-up the pros and cons, I couldn't see any absolute advantage in making the change, and in fact there were one or two things that I had a feeling might be less useful - for example, CHARPLOT figures-out where the screen is when it plots a character rather than having to do that work every time a structure is initialised. This makes the whole thing very adaptable to varying configurations of the system, as well as opening the door to double-buffering if I ever need it (by changing the SCREEN base address before calling a bunch of CHARPLOT updates). As a consequence I've decided to write a general-purpose structure update routine that manages the adjustments needed whenever a mobile object changes position.

The other problem, where CHARPLOT structures have no concept of a 'last' position, isn't actually that big a deal; I was playing with the idea of creating clone structures so that I could calculate the new position (of a Meanie, for example) but still have the old structure lurking around so that the screen-update routine could erase the character at the old position before drawing the new. In fact, I only really need to hold the Control Byte and Offset Byte of a character to be erased, and just drop those two bytes into a table which I can run through to zap whatever was at that position. So I can write a routine to step through the CHARPLOT objects, pick the first two bytes out of each and stash them somewhere, recompute the location of the object and update the structure, and then have a small loop zip through the 'old' positions table to clear those locations on screen.

I'll write these two routines this evening, and test them out with the one Meanie I currently have instantiated. Once they're working, I'll write some collision-tester code to detect when a Meanie hits something and goes out of play - and then I'll bring Meanie #2 online and have both wibbling around on the screen blowing stuff up. At that point, I might post a demo, even though it'll be fairly dull, just to prove to myself that progress has been made. ;)

0 comments:

Post a Comment