11 September to 14 September 2025
Here's my disassembly diary for this part of my project to document The Sentinel on the BBC Micro. You can click on the following links to jump to a specific day in the diary:
- 11 September 2025 - Document GetAngleFromCoords, GetHypotenuse, tanHalfAngle and MultiplyCoords, lay out zero page and workspace variables, identify GetNextSeedNumber
- 14 September 2025 - Document GetNextSeedNumber, identify PrintTextToken, insert text token labels, reach 10% progress
Please note that this diary is a dump of my thoughts as I disassembled and documented The Sentinel, and as such it contains lots of mistakes and dead ends and misinterpretations. This diary is all about the journey, rather than the destination; for the latter, see the finished product.
11 September 2025
=================
See all the GitHub commits and diffs for 11 September 2025.
sub_C0D4A contains a lot more code than the simple division part we copied from Revs yesterday, so document it as GetAngleFromCoords.
So it looks like the weird tan/sin/cos lookup table at L3D02 is used in sub_C565F to calculate a hypotenuse.
I worked out the maths last night on the sofa by drawing it out on my iPad:
and here are my notes:
|`. (1) |`. (2)
|t `. |t `.
| `. a | `. a h
a | `. a | `. ,´
| p `. | `.´
| p ___--´ | ___--´`. c
+--´ +--´---------`+
b
__+
__--´ \ (3)
__--´ | c
__--´ \
__--´ 90-p 90 |
+´------------------------+
b
t = theta, our triangle's angle
p = phi
a, b = sides of the triangle (e.g. coordinates)
We want to find h
Extend circle arc (1) into a triangle (2), and for small angles we get
h =~ a + c
So what is c?
Focus in on right-angled triangle (3)
For small theta, the angle in the bottom-right tends towards a right angle
180 - theta
phi = ----------- = 90 - theta/2
2
So:
90 - phi = 90 - (90 - theta/2)
= theta/2
From (3):
tan(90 - phi) = c / b
So
c = b * tan(90 - phi)
= b * tan(theta / 2)
So
h =~ a + c
=~ a + b * tan(theta / 2)
So the table contains the hypotenuse for angle theta
and triangle sides a and b
This looks pretty good, so document all this as GetHypotenuse and rename L3D02 to tanHalfAngle.
sub_C1C6C is close to MultiplyCoords in Revs, so copy over the relevant commentary.
Go through and document all JSR calls to the Revs-based routines above.
Lay out zero page and workspaces so each variable has its own comment.
Identified GetRandomNumber routine - it appears to be a linear feedback shift register with EOR feedback, see NES Dev.
Really starting to feel like I'm unpeeling a Geoff Crammond game now, with such a clear development path from Revs.
14 September 2025
=================
See all the GitHub commits and diffs for 14 September 2025.
Documented GetRandomNumber.
sub_C36AD prints text on-screen, takes a token argument in X -> PrintTextToken.
There's a token lookup table at L5784.
Tokens end in &FF, so insert token0, token1 labels after each &FF and replace lookups with calculated offsets to tokens.
Turns out tokens are recursive, with characters 200+token expanding into recursive tokens.
>>> I have now broken through the 10% barrier <<<