| 1 | SCULPTRIX |
| 2 | ~~~~~~~~~ |
| 3 | |
| 4 | |
| 5 | There's some Real documentation for Sculptrix, so I'll just say some |
| 6 | words about the internals, and some historical ramblings. |
| 7 | |
| 8 | |
| 9 | Wy does the world need another 3D button module? Quite honestly, it |
| 10 | doesn't. |
| 11 | |
| 12 | I was preparing to release the first version of SDLS when I realised |
| 13 | that there was a complication. Up until that point, we'd always used |
| 14 | Simon Huntingdon's Interface module for our 3D bits. SDLS only needed |
| 15 | Interface for one component, the DLLMerge tool, but I wanted the world's |
| 16 | first view of a Straylight Wimp program to be positive, and I wanted a |
| 17 | sexy looking 3D interface. |
| 18 | |
| 19 | The problem was that SDLS had extremely permissive licensing. We |
| 20 | allowed SDLS to be included free of charge with any software, whether |
| 21 | free or proprietary. And I didn't think Mr Huntingdon was going to like |
| 22 | that happening to his module. I couldn't find the documentation for |
| 23 | Interface, and Simon didn't appear to be a comp.sys.acorn regular, so I |
| 24 | decided that the quickest way to resolve the problem was to write a 3D |
| 25 | border module of my own. |
| 26 | |
| 27 | Some quick prototyping in BASIC (now lost forever) provided me with a |
| 28 | good way of drawing corners in a mode-independent way. The border |
| 29 | plotting primitives were the first bits of Sculptrix 1. I then wrote |
| 30 | the code to fit these together, a bit of validation string parsing, and |
| 31 | the module header, all in a fairly adhoc sort of way. The result was |
| 32 | Sculptrix 1.00. It took a couple of days to get this far. I'd not paid |
| 33 | much attention to making the code tidy or readable. |
| 34 | |
| 35 | Sculptrix isn't the name I originally chose for the module. I'd seen 3D |
| 36 | boxes being called `sculpted' before, and I thought that sounded fairly |
| 37 | reasonable. I originally came up with the name `Skulptor', which I |
| 38 | wasn't really happy with for two reasons; partly because it looked |
| 39 | slightly too `k00l', but mainly because it was really difficult to type |
| 40 | quickly. For the curious, I intended the name `Sculptrix' as a fake |
| 41 | feminine form of `Sculptor'. |
| 42 | |
| 43 | A major headache I was having at the time involved positioning group box |
| 44 | titles. I knew that everyone else was having this problem too, but I'm |
| 45 | a bit perfectionist about my templates, and this problem vexed me |
| 46 | greatly. I decided that adding group box borders as a Sculptrix |
| 47 | operation was an obvious solution. |
| 48 | |
| 49 | Other changes followed. After fourteen revisions, the Sculptrix source |
| 50 | code had stopped looking a mess and was approaching a disaster. I |
| 51 | decided that something drastic had to be done. |
| 52 | |
| 53 | There were two big sources of mess in the original Sculptrix: |
| 54 | |
| 55 | * The border drawing routines were horrible. Manipulating several |
| 56 | boxes, each using four registers, makes for some horrific ARM code. |
| 57 | The group box drawing code was particularly nasty. |
| 58 | |
| 59 | * The validation string parsing was a total loss. It was mostly adhoc |
| 60 | stuff. Dispatching to the border operations was done in the code, |
| 61 | which became a royal pain. |
| 62 | |
| 63 | I dealt with the first problem by using a simple `border description |
| 64 | language'. By writing a pile of macros, I persuaded objasm to assemble |
| 65 | a simple bytecode language which would draw borders. The language |
| 66 | called ARM routines to draw the sides of the border, but did all the |
| 67 | necessary arithmetic using the bytecodes, which I'd designed fairly |
| 68 | carefully to be able to do the jobs which needed to be done with minimum |
| 69 | of fuss. This made the job of writing borders easier; it made the code |
| 70 | more readable; and it reduced the code size. (Remarkably, Sculptrix 2 |
| 71 | is smaller than Sculptrix 1.) |
| 72 | |
| 73 | The border machine has a single register, a rectangle store, and a |
| 74 | (read-only) icon rectangle store. It can load values from either |
| 75 | store, perform simple arithmetic (adding and subtracting immediate |
| 76 | constants) and write back to the rectangle store. The machine can also |
| 77 | perform operations like selecting colours, finding the centre of an |
| 78 | icon, and calling another piece of border code as a subroutine. |
| 79 | |
| 80 | The problems with validation string parsing were solved by introducing a |
| 81 | concept of a `border type', which is a bitfield identifying the basic |
| 82 | border shape and various optional flags to be applied to it. Validation |
| 83 | string parsing was centralised, and made table driven; I took the |
| 84 | opportunity to rationalise the syntax at the same time. The rest of the |
| 85 | code happily passes border type codes around. |
| 86 | |
| 87 | Another major change with version 2 was the user configuration. The |
| 88 | initial version didn't have any configuration at all. A later |
| 89 | modification added some star-commands, which required understanding of |
| 90 | hex notation and a strong stomach. It was all most unsatisfactory. The |
| 91 | new version lost the star-commands, and provided a (binary) |
| 92 | configuration file which could be edited using a natty GUI application. |
| 93 | This made me feel much happier. |
| 94 | |
| 95 | |
| 96 | Setrix is the first Sapphire application in the source release. |
| 97 | Interested people should be able to learn a lot from its source code. |
| 98 | Of particular interest are: |
| 99 | |
| 100 | * The colour buttons in the dialogue box are all custom controls |
| 101 | handled entirely by Sapphire. |
| 102 | |
| 103 | * The data transfer code, and how easy the ram transfer stuff is. |
| 104 | (It still amazes me that a RAM save routine is often three lines of |
| 105 | assembler, and that a RAM load is handled more-or-less entirely by |
| 106 | Sapphire.) |
| 107 | |
| 108 | I also like the way that the `load-from-file' routine used during Wimp |
| 109 | loading of a file is just as useful for loading the initial config file. |
| 110 | |
| 111 | |
| 112 | I'm rather proud of the job I made of Sculptrix in the end. I hope you |
| 113 | agree that my time was well spent. |
| 114 | -- |
| 115 | [mdw] |