A course for the Dragon 32 · Chapters 0 to 15
You have seen $0400 dozens of times by now, always with a translation next to it: 1024. Time to understand it.
We count with ten digits, 0 to 9. The computer likes to count with 16 signs: 0 to 9, and after them A, B, C, D, E, F. The $ in front says: “this number is written in counting by 16”.
Why is this handy? Because everything fits exactly: a number in one house is always two digits ($00 to $FF), a house number is always four digits, and a row on the screen is exactly $20.
Remember the old odometer in a car? Wheels with digits. The right wheel turns, and when it passes 9 it goes back to 0 and moves the wheel next to it on by one.
The computer’s odometer is exactly the same, except that each wheel goes up to F before it goes back to 0.
The odometer starts at $0400, the first house of the screen. Under it, the same number in ordinary counting. Press the buttons and watch the wheels.
Look at the +$20 button: it always takes you one row down on the screen. $20 is 32, and a row has 32 squares.
In ordinary counting, in 254 the digit 2 is worth two hundred, because each place to the left is worth 10 times more. On the computer’s odometer each place to the left is worth 16 times more: 1, 16, 256, 4096.
You don’t need to work this out in your head every time. What matters is to remember a few numbers that come up all the time:
Now the numbers at the side of the screen make sense. Each row starts $20 after the one before. After 8 rows the wheel rolls over, and the 4 becomes 5: halfway down the screen we reach $0500.
And inside the row? Add the column number, also in the computer’s way of writing. Column 15 is $0F, and column 16 is $10. So the square in row 8, column 16, is $0500 plus $10: $0510.
The same two commands from Chapter 2. Only the houses start speaking the computer’s language. Guess first, then Step.
We wanted A, with B under it. One line is missing. Which one?
Translate into ordinary counting. You can use the odometer above to help.
$0420 = $05FF = $FF = And now code puzzles. The houses are given only in the computer’s way of writing.
In DREAM you can write numbers both ways. STA $0400 and STA 1024 are exactly the same line: a number without $ counts as ordinary.
And BASIC has its own sign for the computer’s way of writing: &H. Try:
PRINT &H0400
And the computer will answer 1024.
PRINT &H0400 answered 1024, and PRINT &H05FF,&HFF answered 1535 and 255. In DREAM, the lines LDA #88 and STA 1056 were translated into exactly the same numbers as LDA #$58 and STA $0420, and the X appeared in square $0420. ✓ Checked on our Dragon machineA hobbyist tribute project, not affiliated with or endorsed by Dragon Data. The course, drawings and text are our own. Every program in the course was checked on the site's Dragon machine (XRoar running the BASIC we wrote).