Friday, 10 January 2014

Sometimes real code works .......

BlockBuster working
So, following the last post, I decided to see if it worked.

I removed the test mentioned in the TMS1100 data sheet - only updating the R-Latches if the X Index register was less than four.

It partly worked - except it came out back to front and upside down. Turns out that the LCD input was reversed, which I fixed by reversing the bits on the LCD driver (equivalent to reprogramming the Parallel Output ROM to do it), and as you can see it works well enough.

Hitting a few keys at random it appears to do what the BlockBuster Cartridge does (haven't checked this properly yet), and it also starts up the game and displays the initial wall.

I wasn't, originally, going to emulate the Rotary Hardware, but perhaps I will now, just to see how it works.

Running real code is usually asking for trouble.

Self Portrait
Thanks to Sean, Kevin and the MESS team I've got some real code running. It's quite interesting.

One of the big issues with the TMS1000 is the instruction set is mask programmable. It's not like a 6502 when you know what you are getting or like a Pentium when you know 2 + 2 = 7, you can (I think !) order it with a reorganised instruction set. I kind of reckoned nobody ever bothered, I mean if you did that the development tools wouldn't work.

I've been running BlockBuster on the emulator (It's one of those knock the bricks out of the wall games) . One of the first things it does is display something like 7 ST (a bit like this

It sort of works. It displays something, but not what it should.

Looking at the code, I find this (note for people even more pedantic than me - code has been remapped from the LFSR PC to a standard counter PC. If you don't comprehend this this means you are a normal human being).

796   ldx 4          // set X index to 4
797   tma            // Load Memory(4,Y) to accumulator
798   tdo            // put A (pixel data) on output lines to LCD
799   tya            // save Y in A (this is the ptr to the data)
79A   tcy 7          // set Y to 7 (the data clock latch)
79B   rstr           // set data clock (latch 7) to 0
7BC   setr           // set data clock (latch 7) to 1
7BD   tay            // restore the pointer.

which is all very sensible. This should load a nibble into the accumulator (Y points to the pixel data at the start), put it on the LCD data bus and put a pulse on the data clock line to load it into the latches, it preserves the pixel data pointer whilst it does this).

However ....... it doesn't work.  Single stepping this code, it doesn't output the data to the LCD.

Because ... it shouldn't work

The reason it shouldn't work is in the TMS1x00 Programmer Guide.

It says (page 8-12) "The operation of the SETR and RSTR commands is possible for 0<=Y<=15 and 0<=X<=3. And it explicitly says - the X register must be <= 3.

(I note that the Microvision emulation for the TMS1x00 doesn't test this. This might be because they know more than I do, or because they are working from the TMS1000 which doesn't do this test, because X is always 0,1,2 or 3)

A brief perusal of the code above shows X isn't in the range 0-3. It's 4. So , according to the book - it shouldn't work.

Now the code is obviously - to me anyway - doing what it should. It makes logical sense, and it may well work without this test.

Whether the book is wrong (other lists don't mention this X requirement and it does seem a bit pointless !), or the chip is a special one, I don't know. The problem is, of course, if the chip is a special this is an entirely new issue. It doesn't seem to be, what I see of this code makes sense. So I'm going to fix it so it works irrespective of X is and see what happens.

From the challenge view point it doesn't matter as I'm writing a new game not an old one, but if I can get it working reasonably I know my emulation is okay. (If you do nothing it beeps three times to warn you which kinda makes sense). I do have a Microvision so I must see if it actually does this.

The display, we shall see.