This repository does not carry the game. It carries the commented disassembly of El Descubrimiento de America (Gema Software / OMK Software, 1987) and the tools that reproduce it.
descubrimiento.cas. Its
sha256 is
ac7b780000c2b92f0cbbd89f9ee36e741beb88a41261920680235e84b1c53077.pasmo on the PATH.make.make # extract, trace, build, reassemble, verify, test
It ends with this, and it is the only thing you have to look at:
OK: la cinta entera se reproduce byte a byte
It means the five listings in src/, assembled and wrapped back up with the
headers and sentinels of the .cas format, give back the same 66,371 bytes. If
that fails, nothing else matters.
Because the tape does not carry one program, it carries two, and both occupy the same addresses. There is no single memory map to disassemble: there are three.
| listing | addresses | bytes | what it is |
|---|---|---|---|
carga |
0xC000-0xD3DF | 5,088 | the loader, which survives both programs |
p1bajo |
0x4000-0x63FF | 9,216 | first half, the program |
p1alto |
0x8000-0xD2FF | 21,248 | first half, the graphics |
p2bajo |
0x4000-0x63FF | 9,216 | second half, the program |
p2alto |
0x8000-0xD2FF | 21,248 | second half, the graphics |
The two alto listings do not hold a single instruction: they are data end
to end.
| command | what it does |
|---|---|
make extract |
splits the .cas on the sentinel and pulls out the four files |
make cuerpos |
builds the 64 KB image as it stands once each half is loaded |
make trazado |
follows the flow from the entry points in src/*.entries |
make listados |
writes the five .asm files, joining the trace and the notes |
make verify |
assembles, wraps back up and compares the sha256 with the original |
make sanity |
what reassembly does NOT cover (see below) |
make test |
the tests |
make densidad |
how much of the listings is commented |
make sin_leer |
the bytes nobody reads, counted from the notes themselves |
make imagenes |
draws the screens and maps from the tape |
make emulador |
loads the tape in openMSX and cross-checks RAM and VRAM |
make web |
generates these pages |
verify is not enoughverify proves the bytes come back out, not that they have been understood.
A listing where everything was a db would reassemble just as well. So there
are four more checks, and all four have to pass:
check_entradas: no tracer entry point falls inside a range declared as
data.check_trace: no .nocode region -what the tape never loads- comes back
marked as code. Without that barrier a single wrongly deduced destination
sends the tracer into a sea of zeros and it "traces" the lot as nop: false
coverage.check_datos: the 103 data regions declared in the .notes,
cross-checked one by one against the trace.presupuesto: not one byte without an owner. Right now, 66,016 of
66,016.The 355 bytes between that figure and the tape's total are the .cas wrapper:
six eight-byte sentinels, two sixteen-byte file headers, the six of the BIN
header, the 256 of the BASIC loader, the two sync triplets and the alignment
padding. A test checks that split too.
make emulador loads the tape for real in openMSX -a Philips VG-8020, needed
because the loader calls the real BIOS TAPION and TAPIN- and dumps RAM and VRAM
with the game running. tools/coteja.py compares that with what the listings
say. The results are in In the emulator.
66,371 bytes, sha256 ac7b7800.... Inside there is not one program: there are
four files, and two of them are whole programs that occupy the same addresses.
tools/cas_parse.py splits the .cas on the eight-byte sentinel and finds
this:
| # | type | name | contents |
|---|---|---|---|
| 00 | ASCII | DSCRMT |
256 bytes: one line of BASIC |
| 02 | BIN | CARGA |
5,088 bytes, 0xC000-0xD3DF, runs from 0xD302 |
| 04 | headerless | — | 30,472 bytes: the FIRST half |
| 05 | headerless | — | 30,467 bytes: the SECOND half |
The ASCII file is literally one line:
1 CLEAR 0,57107!:POKE 65535!,168:BLOAD "CAS:",R
CLEAR 0,57107 puts HIMEM at 0xDF13, and the POKE 65535,168 writes 0xA8 into
the page 3 subslot register, which only has any effect on machines with an
expanded slot.
Files 04 and 05 have no header, so BLOAD would not know what to do with
them. The loader's loop at 0xD369 reads them by hand, with TAPION and TAPIN,
byte by byte, and splits each into three pieces:
03 02 01;3 + 9,216 + 21,248 = 30,467, which is exactly block 05. Block 04 is five
bytes longer, and they are .cas alignment padding: zeros, checked.
0x0000-0x3FFF BASIC ROM (the font comes from here, CGTABL 0x1BBF)
0x4000-0x63FF the program of whichever half is loaded
0x6400-0x7FFF not used by the tape
0x8000-0xD2FF the graphics of whichever half is loaded
0xD300-0xD3DF the loader, which survives both halves
0xD3E0-0xFFFF game and system variables
That no tape block reaches past 0xD2FF is what makes the whole arrangement possible: the loader stays alive at 0xD300-0xD3DF from beginning to end, and above it there is room for the six bytes the two halves hand over.
Since the program loads at 0x4000, the machine needs RAM in page 1, that is, 64 KB.
That split is where the project's five listings come from:
| listing | org | bytes | code | data |
|---|---|---|---|---|
carga |
0xC000 | 5,088 | 210 | 4,878 |
p1bajo |
0x4000 | 9,216 | 8,079 | 1,137 |
p1alto |
0x8000 | 21,248 | 0 | 21,248 |
p2bajo |
0x4000 | 9,216 | 7,215 | 2,001 |
p2alto |
0x8000 | 21,248 | 0 | 21,248 |
| total | 66,016 | 15,504 | 50,512 |
Three quarters of the tape is data. The two alto listings have not a single
instruction.
The 103 declared data ranges are not eyeballed. In the first half they come out of the game's own three upload routines, which say how many bytes of tape each block consumes:
| routine | consumes |
|---|---|
vuelca_patrones (0x4497) |
BC bytes |
vuelca_comprimido (0x44CB) |
BC of artwork + BC/8 of colour, one byte per tile stretched over its eight rows with FILVRM |
vuelca_con_color (0x446D) |
2*BC |
Chaining those sums, the end of each block falls exactly on the start of the next, from 0xAB60 to 0xC012, with not one gap. A test checks the whole chain.
The tape records 0x2400 and 0x5300 bytes no matter what, but the first half's program ends at 0x5F9F and the second's at 0x5C3F. Whatever was in memory got recorded behind them.
Altogether that is 7,564 bytes out of 66,016 (11.5%) that are identified and
accounted for but that no instruction reads. make sin_leer counts them from
the notes themselves:
| listing | region | range | bytes |
|---|---|---|---|
carga |
assembly leftover | D3D8-D3DF | 8 |
p1bajo |
assembly leftovers | 5F9F-5FF7 | 89 |
p1bajo |
block filler | 5FF8-63FF | 1,032 |
p1alto |
sprite gap | A66D-AAFC | 1,168 |
p1alto |
loading-screen colour tail | CC56-CFFF | 938 |
p1alto |
copy of the loading screen | D000-D2FF | 768 |
p2bajo |
assembly leftovers | 5C3F-5C79 | 59 |
p2bajo |
block filler | 5C7A-63FF | 1,926 |
p2alto |
block filler | CCD8-D2FF | 1,576 |
| TOTAL | 7,564 |
The three "assembly leftovers" -one per program, loader included- are a truncated copy of the program's own code, always cut mid-instruction:
| program | leftover | copy of |
|---|---|---|
carga |
0xD3D8-0xD3DF | 0xD358-0xD35F |
| first half | 0x5F9F-0x5FF7 | 0x5F1F-0x5F77, 0x80 higher up |
| second half | 0x5C42-0x5C79 | 0x5BC2-0x5BF9 |
All three checked byte for byte. Nobody executes them, and they look like a slip of whatever tool the blocks were built with.
What is in the fillers, and what is not known about them, is in Open questions.
15,504 bytes of code spread over 733 named routines, none of them below the comment bar. But the code sits in three places, not one, and the three are independent.
| listing | instructions | routines | commented |
|---|---|---|---|
carga |
88 | 9 | 26.1% |
p1bajo |
3,451 | 371 | 27.2% |
p2bajo |
3,126 | 353 | 26.3% |
| total | 6,665 | 733 | 26.7% |
The two alto listings do not appear because they have not a single
instruction.
carga is the smallest program and the most important one. Of its 5,088 bytes
only 210 are code; the rest is the loading screen and its font.
Its job is the loop at 0xD369: it starts the motor with TAPION, takes the sync, and then reads byte by byte with TAPIN, with no header and no file BIOS, splitting what arrives between 0x4000 and 0x8000. When it is done it jumps into the code it has just loaded.
It lives at 0xD300-0xD3DF, which is above anything a tape block reaches, and that is why it is still standing once the game is running. The two bytes at 0xD300 are not code but the address of that loop, and the first half uses them to come back:
5CC2 ld hl,(0xD300)
5CC5 push hl
5CC6 ret
Everything you see goes through one of these three, and each consumes tape at a different rate:
| routine | consumes | what it does |
|---|---|---|
vuelca_patrones (0x4497) |
BC | uploads artwork, leaving colour alone |
vuelca_comprimido (0x44CB) |
BC + BC/8 | uploads artwork and then one colour byte per tile, stretched over its eight rows with FILVRM |
vuelca_con_color (0x446D) |
2*BC | uploads artwork and the full colour table |
That BC/8 in the middle one is the game's colour compression: one byte per
tile instead of eight. It is also what makes it possible to close the data
boundaries without eyeballing them — see The tape.
The first half installs a JP at H.KEYI (0xFD9F) pointing to 0x4046: the music
plays on every scan interrupt, before the BIOS reads the keyboard.
The state is fourteen consecutive bytes, 0xF8CB-0xF8D8, with three bytes per channel -score pointer and duration-. That is why the cursor at 0x4181 steps by three and the same routine serves all three channels without a single table. There are sixteen tunes indexed at 0xCB95.
The second half installs nothing: it writes the PSG straight from the main loop, at 0x5213. Checked by searching for writes to 0xFD9A and 0xFD9F across all traced code: there are none.
The first half's start-up does:
420A ld a,(0xC103)
420D cp 8
420F call nz, voltea_los_patrones
0xC103 is not a variable: it is a byte of the pattern table, used as a flag so the same artwork is not flipped twice. The routine at 0x561D reverses the bit order of every byte between 0xC102 and 0xC138, which is how the game gets its mirrored artwork without spending any more tape.
The same trick is in the sprites: the routine at 0x4B1E flips them in memory to draw the figure facing the other way. You can see it on the machine: of the 21,248 bytes of the first half's high block, openMSX finds only 45 written over, and they are exactly those sprites (0x9E05-0x9E53) plus one tile the start-up touches up (0x915B).
Screen 7 of the first half and the whole ship of the second come out of the same kind of loop: a map wider than the screen, out of which a window is cut.
What says how wide it is is not a constant in any table: it is the loop's own step between rows. In the ship map, the loop at 0x4285 adds 0x80 per row, and that is what fixes the width at 128 tiles. If it had been misread, cross-checking the window against the emulator's VRAM would come out at hundreds of differences; it comes out at zero across all 768 tiles.
There are three blocks of strings, and only three:
| where | what |
|---|---|
| 0x8200 | the opening text, nine lines already broken to nineteen columns |
| 0xC28A | eleven on-screen labels |
| 0xCBF2 | five crossing disasters, 22 characters each and no terminator |
All of them are drawn with the BASIC ROM font (CGTABL, 0x1BBF), copied tile by tile into the pattern table: the tape does not spend one byte on an alphabet of its own for the game.
The only text that does not use that font is the loading screen's, which uses its own tiles and is not even ASCII. That is covered in Findings.
Reading the binary is not enough. This game has been actually loaded in openMSX, and the RAM and VRAM with the game running have been compared byte for byte with what the listings say.
make emulador
tools/omsx_carga.tcl and tools/omsx_parte2.tcl load the tape on a Philips
VG-8020, which is an MSX1 with real ROM. The real machine is needed: the
loader calls the BIOS TAPION and TAPIN, so without ROM there is no load. The
scripts leave RAM and VRAM dumps in work/omsx, and tools/coteja.py compares
them with the listings.
It takes a few minutes: 36 and 66 KB of tape at 1200 baud, even emulated at full speed.
OK 0x4000-0x63FF = low part of the block 9216 bytes, 0 different
OK 0x8000-0xD2FF = high part (45 bytes the game writes over) 21248 bytes
OK 0xD300-0xD3DF = the loader (2 working bytes) 224 bytes
OK and the ones written over are the expected ones 45 addresses
OK name table, minus the wave band 704 bytes, 0 different
OK patterns of the tiles that are visible 0 different
OK colours of the tiles that are visible 0 different
OK 0x4000-0x63FF = low part of the block 9216 bytes, 0 different
OK 0x8000-0xD2FF: what is written over falls in the two work areas 743 bytes
OK patterns of the ship font, all three thirds 6144 bytes, 0 different
OK the window of the 128x52 map 768 tiles, 0 different
OK: the machine says the same as the disassembly
The split of the tape comes out at zero differences across 0x4000-0x63FF, in both halves. Which means the carving up of the headerless block -three sync bytes, 0x2400 low, 0x5300 high- is exactly what the machine does.
Of the 21,248 bytes of the first half's high block, the machine writes over only 45, and they are exactly the ones the listing says get written over: 0x915B, a tile the start-up touches up, and 0x9E05-0x9E53, the sprites the routine at 0x4B1E flips in memory to draw the figure facing the other way.
In the second half the 743 bytes written over all fall inside the two declared work areas: the ship's record (0xB000) and the copy of the screen (0xB058-0xB357).
Screen 0, built by hand from the tape by repeating the game's three upload routines, matches the real VRAM byte for byte across every tile that is visible. That is what settles that the three upload routines — and with them the boundaries of the 103 data blocks — are read correctly.
And the 32x24 window of the ship map matches across all 768 tiles with the cut of the 128x52 map at column 50 and row 16, which are the first two bytes of 0xCBC6. If the width of 128 were wrong, this would come out at hundreds of differences.
They are listed one by one inside coteja.py itself, not hidden:
The second half cannot be reached without playing the first all the way
through. To dump it, omsx_parte2.tcl forces the jump the game itself makes on
finishing:
ld hl,(0xD300) / push hl / ret
which is what hands control back to the loader so it asks for the next block.
That a full game has been played. It has not. The screen names come from looking at the artwork, and the mechanics -what each object does, how you move between screens, what each setback counts- come from reading the code. Playing it properly would probably correct one or two. That is said in Open questions too.