Saturday, 23 February 2013

In Which We Divide And Conquer


You'd be forgiven for thinking that I'd forgotten about, or abandoned, the promise I made a while back to ship a demo. Rest assured I haven't, but as you'll have noticed things got a bit wild there for a couple of weeks and kind of knocked me way off the pace in terms of getting something worthwhile out there. However, I think we're back in the zone, and I'm still ticking-off items from that to-do list that I decided would constitute the features that should be present in the release.

So this week I didn't have a lot of time to commit to the project, but nevertheless I have made progress; the first thing I did was incorporate the cursor countdown timer into the same logic that handles the time-of-day countdown clock. However, the clock is driven by the system jiffy interval which is determined by the video mode (PAL or NTSC) and is called from the IRQ handler, so it counts one jiffy every frame and ticks the 'second' counter of the clock over every 50 or 60 jiffys accordingly. Which is perfect for a clock, but no good for a cursor-blink effect in which the duty-cycle (from on, to off, and on again) is measured in half-seconds - the clock logic is built to count seconds, not half-seconds.

But this is actually quite trivial to adjust - I added a half-second counter to the clock storage, tweaked the jiffy interval to half the video frequency (i.e. 25 for PAL, 30 for NTSC) and added a couple of lines to the clock logic so that instead of counting to 50 or 60 and then tickling the seconds value, it now counts to 25 or 30 and hits the half-second value. Then, every 2 half-seconds, we hit the seconds value as before - so we now have a clock with hours, minutes, seconds, and half-seconds. This new half-second counter is exactly what the IRQ routine needs to blink the cursor, which therefore allowed me to junk the old - and now redundant - cursor-timer storage and its' associated management code.

I'll be plugging the much-simplified blink trigger into the IRQ routine in a day or so, but first I'm doing the next item on the list, which is to re-integrate the whole cursor-handling subsystem; this is essentially a re-write of pretty-much all that code, mainly because the first version didn't work the way I wanted, and also because stuff like the basic cursor-draw logic will benefit greatly from the reworked glyph renderer code. Now that I have massively re-vamped that whole mechanism with lookup tables, faster code and less ZP storage, I can re-use a significant chunk of it to make the process of drawing and undrawing the cursor much more elegant and efficient than it was before.

Work continues...

No comments:

Post a Comment