~vdupras/collapseos

ref: ac3629b817115b1af75096856ee9499cfbbd3392 collapseos/doc/sega.txt -rw-r--r-- 1.3 KiB
ac3629b8Virgil Dupras Make BLK@* and BLK!* into ialiases 1 year, 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Sega Master System ROM signatures

When loading ROM, the SMS' BIOS checks for a special signature
at the end of that ROM. If that signature is incorrect, the ROM
doesn't load.

Collapse OS has a program to generate that signature at B165.
This document describes what it does.

At boot, the BIOS checks 0x10 bytes before the 0x8000, then
0x4000, then 0x2000 mark for a signature. This signature has
the following structure.

0x00-0x07: String constant: "TMR SEGA"
0x08-0x09: null bytes
0x0a-0x0b: checksum
0x0c-0x0e: null bytes
0x0f     : "size" flag

The checksum is a simple 16-bit sum of all bytes up to the
beginning of the signature.

The size flag can have 3 values: 0x4a for an 8K ROM, 0x4b for
16K and 0x4c for 32K. It can have other values for other kinds
of sizes, but we don't care about them in the context of
Collapse OS.

## Generating the signature

Before generating the signature, you need to have the contents
of your ROM somewhere in memory. Then, you load B165 and you
call "segasig" which has the signature "addr size". "addr" is
the adress of the beginning of the ROM and "size" is 0, 1 or 2
depending on whether your ROM is 8K, 16K or 32K.

Calling the word will write the 0x10 bytes signature at the
end of the ROM.

Note that all I/O use the "Addressed device" words (see
usage.txt), so I/O indirections will work.