Difference between revisions of "Create a plain ROM"
From MSX Game Library
(→Page specific data and code) |
|||
Line 26: | Line 26: | ||
== Page specific data and code == | == Page specific data and code == | ||
+ | The build tool allows you to add data and code to a given page of a plain ROM. | ||
+ | To do this, you just need to add at the root of your project, a file with a postfix <tt>_px</tt> where <tt>x</tt> is the number of the page where to place this code (0 to 3). | ||
+ | And that's all. :) | ||
+ | |||
+ | The page file can be either in C (<tt>.c</tt>) or in assembler (<tt>.asm</tt>). | ||
+ | Data and code are accumulated from the following addresses: | ||
+ | * Page 0: | ||
+ | ** <tt>0000h</tt> (for targets without ISR) | ||
+ | ** <tt>0100h</tt> (for targets with ISR) | ||
+ | * Page 1: <tt>4000h</tt> | ||
+ | * Page 2: <tt>8000h</tt> | ||
+ | * Page 3: <tt>C000h</tt> |
Revision as of 22:10, 2 May 2023
A plain ROM is a format of binary application to be write into a ROM. The most common use case is the creation of game cartridges. The build tool will generate a .ROM file that can be written to an EPROM (like with a Mega Flash ROM cartridge).
Principles
A plain ROM, unlike a mapped ROM, is constructed from a single block whose parts will always be seen by the Z80 at the same address. Therefore, they cannot be more than 64 KB in size (the maximum size visible to the Z80). A program in ROM is detected by the MSX system thanks to a header located at addresses 4000h or 8000h but can in theory use any space between 0000h and FFFFh. Generally, a ROM uses one or more 16 KB pages (numbered from 0 to 3). Pages 1 and 2 can be used freely, but the system expects to have special content in pages 0 and 3:
- Page 0:
- The MSX BIOS with all standard functions.
- The interrupt handling code (ISR) at address 0038h.
- Page 3:
- RAM with call stack and BIOS variables area.
- Secondary slot register at address FFFFh.
MSXgl was designed to easily override the limitations of page 0 by providing BIOS-independent functionality and by providing ISR code that can install automatically in 0038h. On the other hand, it is not easy to use page 3, especially because the call stack is located there. However, it is possible to write code that will copy the contents of page 3 to VRAM (or to RAM in another page for MSX2 or above).
Targets
To create an plain ROM you just have to choice one of the following targets format:
Target | Description |
---|---|
ROM_8K | 8 KB ROM in page 1 (4000h ~ 5FFFh) |
ROM_8K_P2 | 8 KB ROM in page 2 (8000h ~ 9FFFh) |
ROM_16K | 16 KB ROM in page 1 (4000h ~ 7FFFh) |
ROM_16K_P2 | 16 KB ROM in page 2 (8000h ~ BFFFh) |
ROM_32K | 32 KB ROM in page 1&2 (4000h ~ BFFFh) |
ROM_48K | 48 KB ROM in page 0-2 (0000h ~ BFFFh) |
ROM_48K_ISR | 48 KB ROM in page 0-2 (0000h ~ BFFFh) with ISR replacement |
ROM_64K | 64 KB ROM in page 0-3 (0000h ~ FFFFh) |
ROM_64K_ISR | 64 KB ROM in page 0-3 (0000h ~ FFFFh) with ISR replacement |
ROM | Alias for ROM_32K |
For more detail, see Target article.
Page specific data and code
The build tool allows you to add data and code to a given page of a plain ROM. To do this, you just need to add at the root of your project, a file with a postfix _px where x is the number of the page where to place this code (0 to 3). And that's all. :)
The page file can be either in C (.c) or in assembler (.asm). Data and code are accumulated from the following addresses:
- Page 0:
- 0000h (for targets without ISR)
- 0100h (for targets with ISR)
- Page 1: 4000h
- Page 2: 8000h
- Page 3: C000h