[C] 32K ROM limitations in openMSX

ページ 1/4
| 2 | 3 | 4

By MattyT

Rookie (26)

MattyT さんの画像

12-04-2022, 02:39

I have made Blastoid (as in MSXdev22) and am working on another game (maybe for MSXdev22). I am using sdcc with the msxbios and msxromcrt0 rel libraries. I compile and link and pad out with hex2bin to make the 32K ROM.
I got to the point with both games that they got big enough that they no longer would run in openMSX when I use Panasonic CF2700 MSX1 emulation. They work with MSX2+ CBIOS in openMSX. And both games work on my real CF2700 with a MegaFlashROM.
I thought they could be close to the 32K ROM size, but when I look at the ROM files in a hex editor there are FF's padded from 0x5220 (21,024) for one of the games and 0x4906 (18,694) for the other.
Could this be a limitation of OpenMSX? Have I hit some other limit? Any ideas?

ログイン/登録して投稿

By santiontanon

Paragon (1830)

santiontanon さんの画像

12-04-2022, 03:48

I don't know much about sdcc, but it seems to me it might be a case of not setting the ROM/RAM pages correctly at cartridge initialization. At least, in a cartridge coded in assembler, you would have to add some special initialization code if your ROM is larger than 16KB. It might work in some configurations due to the way ROM/RAM pages are set at startup.

See, for example: https://www.msx.org/wiki/Develop_a_program_in_cartridge_ROM#...

By DamnedAngel

Champion (286)

DamnedAngel さんの画像

12-04-2022, 04:02

Hi MattyT,

You seem to be using my templates in this project as well (since you mentioned msxbios and msxromcrt0, these are filenames in my templates).

As santiontanon said, there is a copy to set the pages up that have to be run on intitialization. Did you enable this on the configuration of the project/template?

As for the padding, that must be diagnosed. If you share your project with me I can try to help further. It may be some with the project's .AREAs having been impropely set.

By MattyT

Rookie (26)

MattyT さんの画像

12-04-2022, 04:15

You mean these configurations?

;----------------------------------------------------------
; ApplicationSettings.txt - by Danilo Angelo, 2020
;
; MSX ROM project general configuration.
;----------------------------------------------------------

;----------------------------------------------------------
; Project Type
PROJECT_TYPE ROM

;----------------------------------------------------------
; crt0 features
GLOBALS_INITIALIZER _ON _ON: Includes routine to initialize global variables; _OFF: Don't include
RETURN_TO_BASIC _OFF ; _ON: Returns to basic; _OFF: Don't return
STACK_HIMEM _ON ; _ON: Sets stack to HIMEM (RETURN_TO_BASIC *MUST* be _OFF); _OFF: Don't set
SET_PAGE_2 _ON ; _ON: Enables page 2 on the same slot/subslot as page 1 (useful for 32kb ROMs on pages 1 and 2); _OFF: Leaves page 2 as is

;----------------------------------------------------------
; ROM settings
ROM_SIZE 32k ; 16k/32k
FILESTART 0x4000 ; Typically, 0x4000 for 32kb ROM or 0x8000 for 16kb ROM
CALL_EXPANSION _OFF ; _ON: expands BASIC's CALL instruction; _OFF: Don't expand
DEVICE_EXPANSION _OFF ; _ON: creates BASIC's device; _OFF: Don't create
BASIC_PROGRAM 0 ; 0 -> no BASIC program; other values: BASIC program address

;----------------------------------------------------------
; BASIC CALL expansion
;
; NOT MANDATORY!
; Use this to extend the funcionality of
; BASIC's CALL command
;
; BASIC usage example (for the standard app)
; 10 CALL CMD1TongueRINT "Oi."
; 20 CALL CMD2TongueRINT "Ola."
; 30 CALL CMD1
; 40 PRINT "Hi."
; 50 CALL CMD2
; 60 PRINT "Hello."
;
CALL_STATEMENT CMD1
CALL_STATEMENT CMD2

;----------------------------------------------------------
; BASIC device expansion
;
DEVICE DEV

;----------------------------------------------------------
; Code segment (.area _CODE) start address
; If you don't know what you are doing,
; LEAVE IT COMMENTED for automatic setting.
;CODE_LOC 0x8100

;----------------------------------------------------------
; Data segment (.area _DATA) start address
; 0 -> data segment immediately after code
; other value -> data segment address
; If you don't know what you are doing,
; LEAVE IT AT 0xC000 (page 3)
DATA_LOC 0xC000

By Manuel

Ascended (19676)

Manuel さんの画像

12-04-2022, 07:41

You may also want to specify how openMSX maps this ROM into memory. I think by default it is mirrored all over the slot. That's probably different than with the MFR.

By Timmy

Master (200)

Timmy さんの画像

12-04-2022, 13:21

In z88dk, the default settings will create a 32K ROM. I don't know much about sdcc, but it should be just as easy as z88dk in making 32k rom files too.

You probably have a wrong setting somewhere.

Also, a correct 32K ROM should be able to work on most MSX configurations, with or without mirroring.

By aoineko

Paragon (1132)

aoineko さんの画像

12-04-2022, 16:57

I don't know the tools you use to generate your ROM, but I don't see any reason for your problems to come from SDCC, and even less from OpenMSX. Smile

If your ROM works on some systems and not on others it may be a problem in the initialization code you are using. For a 32 KB cartridge that starts at 4000h (page #1), you have to initialize the slot on page #2 to the same value as the slot on page #1 (your cartridge one).

In MSXgl (my MSX game library) it is the INIT_P1_TO_P2 macro that handle this.

By DamnedAngel

Champion (286)

DamnedAngel さんの画像

12-04-2022, 21:07

MattyT wrote:

You mean these configurations?
(...)
;----------------------------------------------------------
; crt0 features
SET_PAGE_2 _ON ; _ON: Enables page 2 on the same slot/subslot as page 1 (useful for 32kb ROMs on pages 1 and 2); _OFF: Leaves page 2 as is
(...)
;----------------------------------------------------------
; ROM settings
ROM_SIZE 32k ; 16k/32k
FILESTART 0x4000 ; Typically, 0x4000 for 32kb ROM or 0x8000 for 16kb ROM

;----------------------------------------------------------
; Code segment (.area _CODE) start address
; If you don't know what you are doing,
; LEAVE IT COMMENTED for automatic setting.
;CODE_LOC 0x8100

;----------------------------------------------------------
; Data segment (.area _DATA) start address
; 0 -> data segment immediately after code
; other value -> data segment address
; If you don't know what you are doing,
; LEAVE IT AT 0xC000 (page 3)
DATA_LOC 0xC000

This seems to be right.

In your [DEBUG/RELEASE]\obj folder, there's, a *.MAP file (after compiling the project). You can inspect it to check where the compiler put the several segments of your project, and where each and every symbol is. That can give some insight of what's happening. Please check this file and see if it makes sense.

By DamnedAngel

Champion (286)

DamnedAngel さんの画像

12-04-2022, 21:09

aoineko wrote:

I don't know the tools you use to generate your ROM, but I don't see any reason for your problems to come from SDCC, and even less from OpenMSX. Smile

If your ROM works on some systems and not on others it may be a problem in the initialization code you are using. For a 32 KB cartridge that starts at 4000h (page #1), you have to initialize the slot on page #2 to the same value as the slot on page #1 (your cartridge one).

In MSXgl (my MSX game library) it is the INIT_P1_TO_P2 macro that handle this.

He's using my template which, in principle, handles this. The configuration is correct for the automatic inclusion of the page setup code.
Hope it is working :).

By aoineko

Paragon (1132)

aoineko さんの画像

12-04-2022, 22:57

Are you sure your template handle the case where the cartridge is in a secondary slot? I'm asking this because the first version of my crt0 for 32 KB cartridge didn't handle this case well. ^^
You have to switch the page 3's slot to cartridge slot before changing the secondary slot register in FFFFh (SLTSL), then reset the page 3's slot to its initial value (and of course do not use the call-stack or system variables in the meantime).
See the INIT_P1_TO_P2 macro for an exemple.

By DamnedAngel

Champion (286)

DamnedAngel さんの画像

12-04-2022, 23:21

aoineko wrote:

Are you sure your template handle the case where the cartridge is in a secondary slot?

Oh, that is a very good point. I am 99% sure it DOESN'T!
I'll take a look.

ページ 1/4
| 2 | 3 | 4