ASCII-EX mapper

From MSX Game Library

Revision as of 23:18, 23 November 2023 by Aoineko (talk | contribs)

Here's a proposal for a mapper format operating with a 16-bit segment register and allowing ROMs larger than the 2/4 MB limit of classic mappers.

Principales

The idea is to use the ASCII8/16 mapper format for the low byte of the segment register and to use the 8000h~9FFFh memory space unused by ASCII to manage the high byte. This way, we could build hardware capable of running standard ASCII8/16 ROMs in addition to the new 16-bit format.

For the time being, we propose to reserve the 4 most significant bits for future extensions for the format (such as SRAM or sound chips support for example). This leaves 12 bits to select which segment is visible in each bank, for a maximum of 4096 segments.

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved Segment MSB Segment LSB

The maximum ROM size is therefore 32 MB (for 8 KB segments) or 64 MB (for 16 KB segments).

Detection by emulators should be fairly easy (counting ROM write accesses).

Below, the parts in blue are the only additions to the standard ASCII8/16 format.

ASCII-EX16 mapper

Bank (16kB) Switching address Initial segment
0: 4000h~7FFFh (mirror: C000h~FFFFh) Lower byte: 6000h (mirror: even address to 67FEh)
Higher byte: 6001h (mirror: odd address to 67FFh)
0000h
1: 8000h~BFFFh (mirror: 0000h~3FFFh) Lower byte: 7000h (mirror: even address to 77FEh)
Higher byte: 7001h (mirror: odd address to 77FFh)
0000h
  • Maximum number of segments: 4096
  • Maximum ROM size: 64 MB (1024 MB)

ASCII-EX8 mapper

Bank (8kB) Switching address Initial segment
0: 4000h~5FFFh (mirror: C000h~DFFFh) Lower byte: 6000h (mirror: 6001h~67FFh)
Higher byte: 8000h (mirror: 8001h~87FFh)
0000h
1: 6000h~7FFFh (mirror: E000h~FFFFh) Lower byte: 6800h (mirror: 6801h~6FFFh)
Higher byte: 8800h (mirror: 8801h~8FFFh)
0000h
2: 8000h~9FFFh (mirror: 0000h~1FFFh) Lower byte: 7000h (mirror: 7001h~77FFh)
Higher byte: 9000h (mirror: 9001h~97FFh)
0000h
3: A000h~BFFFh (mirror: 2000h~3FFFh) Lower byte: 7800h (mirror: 7801h~7FFFh)
Higher byte: 9800h (mirror: 9801h~9FFFh)
0000h
  • Maximum number of segments: 4096
  • Maximum ROM size: 32 MB

Misc

Naming

If the ASCII-EX (extended ASCII) name poses any legal issue, we could simply called those mappers EX8 and EX16.

Bank switching cost

The cost of switching only the lower or higher byte of the 16-bit segment register is the same that switching segment for standard ASCII mappers.

; Direct access
LD (nn),A   ; 14 t-states

; Indirect access
LD HL,nn    ; 11 t-states
LD (HL),A   ;  8 t-states

Although a program can avoid having to change the 2 bytes of the segment register at once, there are cases where this may be necessary. In such cases, the cost is doubled, but remains reasonable.

Alternative

If the impact of a segment change in a bank is critical, an alternative would be to use the odd and even addresses of mapper to access the 2 bytes of the register. In this way, it would be sufficient, for example, to write a 16-bit value to address 6000h, to change the 2 bytes of the segment register of the first bank at once.

The minimum cost with direct access would then be 17 t-states instead of 28 with the proposed configuration. On the other hand, we risk losing compatibility with games that use odd addresses for segment changes (if any). The benefit-risk ratio is questionable.

; Direct access
LD (nn),HL  ; 17 t-states

; Indirect access
LD HL,nn    ; 11 t-states
LD (HL),E   ;  8 t-states
INC HL      ;  7 t-states
LD (HL),D   ;  8 t-states

MSXgl

MSXgl uses macros to encapsulate bank switching mechanisms. It would therefore be totally transparent for a user to switch from an ASCII8 or even Konami-SCC mapper, to an ASCII-EX8 mapper.

#define SET_BANK_SEGMENT(bank, segment) /* ... */

// Make segment #12 visible through bank #1
SET_BANK_SEGMENT(1, 12);