Access the "hidden" RAM from BASIC?

Par skumlerud

Resident (58)

Portrait de skumlerud

09-03-2023, 20:12

I'm writing a game in a combination of BASIC, C and assembler. It's written for MSX1 with disk, but should of course work with MSX2/2+ as well. Is there a clean way of using the "unused" RAM from my C/assembler routines? I understand that I can't use this RAM from BASIC, but it would be great if I could store some compressed data there.

Since I'm targeting 64Kb machines - is it safe to assume that page 2 and 3 is set to RAM, and that I can set page 0 and 1 to the same slot as page 2 and 3 to access the lower 32Kb of RAM? With interrupt disabled of course. Or could there be situations where the machine has 64Kb RAM but in different slots?

!login ou Inscrivez-vous pour poster

Par Briqunullus

Paladin (765)

Portrait de Briqunullus

09-03-2023, 20:26

With so many different MSX's around, you bet there are some with funky memory layouts. Like Sony's HB-F500 for example.

Par sd_snatcher

Prophet (3675)

Portrait de sd_snatcher

09-03-2023, 20:54

@skumlerud

Since you’re targeting machines with a disk drive, the MSX-DOS kernel embedded in their ROM searches for the RAM on the MSX boot and places it’s location conveniently in the system variables RAMAD0 to RAMAD3.

No need to worry about complicated memory layouts or RAM expansions then. :)

Par zeilemaker54

Champion (355)

Portrait de zeilemaker54

09-03-2023, 23:07

Bare in mind when using RAMAD0 and RAMAD1, the slotid is only RAM if 64 Kb is found. When running MSXDOS this is a fact, but when running DiskBASIC is not. So the correct way to validate RAMAD0 or RAMAD1 is to compare the content with the content of EXPTBL+0 (MAIN ROM slotid), which should be different.

Par gdx

Enlighted (6429)

Portrait de gdx

10-03-2023, 00:47

If you’re targeting machines with a disk drive only:
https://www.msx.org/wiki/How_to_detect_the_RAM

Otherwise, there are ready-made routines here that work on all MSXs with or without a disk. You just need to add a condition for the turbo R if you need its internal RAM to be selected.

Par skumlerud

Resident (58)

Portrait de skumlerud

10-03-2023, 10:47

Thanks guys, but I'm not quite sure what I'm looking at. 0xf341-0xf344 all contains the same values on the machines (emulated and real) I've tested. Different values on different machines, e.g. on my SVI738 with MSX2+ ROMs f341-f344 all has the value 1, while all the different machines in WebMSX has the value 83h here and OpenMSX has 8Bh. How do I interpret these results?

Par gdx

Enlighted (6429)

Portrait de gdx

10-03-2023, 12:01

As Briquullus says, some MSXs don't have the same values. (Sony's HB-F500 for example.)
Note that 0xf341-0xf344 are not available when the MSX boots from a ROM, even if it has a disk drive.

Click on "Slot ID" at the first link I gave to know the format.

Par Briqunullus

Paladin (765)

Portrait de Briqunullus

10-03-2023, 14:02

skumlerud wrote:

Different values on different machines, e.g. on my SVI738 with MSX2+ ROMs f341-f344 all has the value 1, while all the different machines in WebMSX has the value 83h here and OpenMSX has 8Bh. How do I interpret these results?

Primary slot value will always be in bits 0 and 1.
If the slot is expanded, bit 7 will be set and secondary slot value will be in bits 2 and 3.

SVI738 has ram in slot 1 (not expanded)
WebMSX has ram in slot 3-0
OpenMSX will have different values, depending on the machine selected. The machine you have examined has ram in slot 3-2

Par skumlerud

Resident (58)

Portrait de skumlerud

11-03-2023, 21:44

Thanks guys, I believe I got it working now Smile Sorry for the newbie-questions, I have never programmed the MSX except for some BASIC-programming in my early teens.