Author Topic: User Library work in progress, specification stabilizing  (Read 3835 times)


  • Global Moderator
  • Newbie
  • *****
  • Posts: 36
    • View Profile
    • Jubatian's blog
User Library work in progress, specification stabilizing
« on: November 29, 2014, 07:04:39 PM »
Just some work-in-progress reports.

The RRPGE system's core is stabilizing, changes there are very unlikely. So 13 turned out not to be some unlucky number, actually so far this revision of the specification endured the most torture as I am developing the User Library. However soon an increment will happen as changing the Accelerator's register layout is on my TODO list since a while.

Developing the User Library going well, I have some definite image where it should eventually arrive. To summarize it the shortest possible way: to be able to say something like printf("Hello World!") in a sensible manner. Under the hood this implies developing a properly working tile system (backed by the Accelerator), useful for most old-style games as playfield. Basic text output could then use this tile system like an old character mode display. The "printf" part would be accomplished to be able to target arbitrary buffers (not just a tile map), and would work in a similar manner to the C language's printf function (format strings, variable number of arguments). In this form it can be very useful for any type of text generation.

Recently an interesting pass was developing a 32 bit divider for the User Library. This is not an easy task with a 16 bit processor! I did some research on the matter, going into Newton-Raphson division and likes until building up a very complex, but quite fast (within the constraints of RRPGE) divider. This was also about the first thing which received some systematic in-depth testing, also exercising lots of components in the RRPGE CPU's ALU. No bugs found in there, though!

A screenshot not showing too much is below:

What is going on on that nice green field? It is a test of the 32 bit reciprocal function, it's source can be found within the User Library (GitHub). It simply outputs a green dot for a successful calculation, a red dot for a failed calculation, and a white dot every second. Since obviously there are no errors here (I fixed those before taking shots), let's see the white dots.

This test ran with the source used as-is, so testing the first 256K values for their reciprocals, where the most expensive Newton-Raphson searches occur. The pixel distances between the green dots tell how many calculations could be performed in every second, the image above shows two of these. Since there are about 10M cycles useful for the application (20% is taken by the kernel which the emulator faithfully emulates in randomized batches), this indicates that at about 590 cycles are taken for one calculation. Of course this is not just the reciprocal, but also the check (several multiplies), and the glue logic to run the test. Anyway, in short, this reinforces that neither the cycle budget of the reciprocal search was miscalculated.

But when will I pack new binaries?

On the main RRPGE site still only the old binaries from August may be accessed. Why I apparently don't care is that the example pack is still not complete, and as those are also used for testing, this means that the missing examples also indicate some serious holes in there: particularly too little of the Accelerator, and nothing of the Mixer (or even sound output) was tested this far. Of course even completing those are very far from adequate tests, but if I wrote tests, just nothing would ever be completed... Eh, famous last words: "I will test it when it is complete!". But honestly, my case this approach usually does not end in a disaster! :)