NextProse (part 3)

NextProse (part 3)

So last time we’d gotten to the point of having the screen set up right, and drawing things in.

Then came the moment of truth: I wanted to write a routine to draw arbitrary pixel pairs. Just to understand that I had the maths right about getting from an arbitrary position to a given memory location and that things worked right.

I’d had to walk away from it for a couple of days because of work commitments but that had left me time to stew. I’d written a routine that accepted params, passed them in, did some funky maths and should have worked.

See, I’d figured out that if I was writing to x coordinates 0 to 127, I needed bank 0; 128-255 = bank 1 and so on. If I had the x position in a 16 bit number, I could take the bits that corresponded to 512, 256 and 128, shift them appropriately and that’s my bank number – and the remainder is the position within the bank.

I arranged a routine to send in a 16 bit unsigned integer from ZX Basic, which accepted the two halves of this 16 bit number, transferred the top byte (=the 512 and 256 bits), cleared the rest, shifted it up one, then pulled the top-most bit from the other byte and slid it in appropriately.

And ran it. Nothing happened.

The rest of the code worked as it should – I had the status bar as is. Just not that.

Time to break out the debugger. CSpect has a really nice debugger. Unfortunately for me, the way the ZX Basic compiler works, it doesn’t natively line up the list of ‘this location has this tag’ with what CSpect wants, but that was a swift Python script later.

OK, so let’s get this show on the road. I have my little BASIC function that just wraps my assembly, PlotPixelPair(), and we’ve set a breakpoint on it, now we wait for it to get to that point.

We can see that as we hit PlotPixelPair, the screen is what we expect it to be. Let’s step through the instructions one at a time with the F7 key and see what results.

Uh, that’s not right. DETERMINEBANK is the maths to work out which bank we wanted, EVENBANK is the bit of ‘getting the top bit of the bottom byte and moving it across’ and OUT (C), A is bank switching… and the screen went black.

It would take several days of not staring at this for it to dawn on me what the problem was. It’s not evident from the code but what I’m pushing out to (C) in A is missing a particular bit being set.

That at least meant the banking was being set up appropriately, but there was something else still wrong – apparently no matter what was being pushed where, nothing changed…


Your Header Sidebar area is currently empty. Hurry up and add some widgets.