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