Rom of 48Kb for MSX

Post Reply
eldeljar
Member
Posts: 33
Joined: Sun Feb 12, 2017 6:04 pm

Rom of 48Kb for MSX

Post by eldeljar »

Hello, I would like to know if it is possible to generate a 48Kb Rom.

The goal is to generate a rom with data at address 0000h-03FFFh (page 0). How can I do it? Do I have to create a new crt file?

I am aware that the BIOS is in that direction, so in the program I will have to change the BIOS for my data page, but that will be solved later.

Can you help me?

Thank you
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

It can be done but I'm not sure how classic is handling org 0 code - it might not so you may have to provide a new crt if so.
But otherwise it should be fairly straightforward by setting CRT_ORG_CODE to 0 and CRT_ORG_BSS or CRT_ORG_DATA to the location of your ram.

It's fairly late here to delve into for me now but if someone else does not answer I will have a look tomorrow.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

In theory it's possible just be defining CRT_ORG_CODE and CRT_ORG_BSS as Alvin said. The default values for these are $4000 and $c000.

However, the MSX -startup=3 ROM crt0 doesn't have any interrupt handling so it will fall over pretty quickly if the bottom bank is changed.

You'll need to make a few tweaks (I'm assuming you want BSS and DATA at 0x000-0x3fff) to copy in the lower memory space requirements (i.e. interrupt handlers).

I'm guessing that in this model you won't be able to call any msxbios routines so if you want to use graphics/text from the library you'll need to provide an msxbios replacement.
eldeljar
Member
Posts: 33
Joined: Sun Feb 12, 2017 6:04 pm

Post by eldeljar »

Sorry, I have not been able to answer before.

I am testing what you have indicated, but at the moment it does not work for me.

I do not want the functions to be on page 0, only constant data.

Since I'm not sure how to make a crt file, I'm currently testing with:

Code: Select all

zcc +msx -Cs -no-cleanup -v -m -g -s -subtype=rom -compiler=sdcc -SO3 --max-allocs-per-node10000 --reserve-regs -i and -create-app -pragma- define: CRT_MODEL=2 -o test.bin @zproject.lst --fsigned-char -pragma-include: zpragma.inc
, and the file "zpragma.inc" contains:

Code: Select all

#pragma output CRT_ORG_BSS = 0x0000
#pragma output CRT_ORG_CODE = 0x4000
#pragma output CRT_ORG_DATA = 0xc000
It is right?

I'm reviewing the .map file but I think it does not position the data on page 0.

The rom I want to start at address 0x4000 (page 1) as it is done in 32Kb roms, but then read data (tiles, sprites, etc.) from page 0 at the right time.

Any help will be welcome.

Thank you.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I think I understand what you want to do now:

- rodata goes to low memory
- code starts at 0x4000 as usual
- BSS (uninitialised static/global variables) into RAM at 0xc000

The following will move compiler generated rodata (so your sprites/tiles etc) section down to 0x0000:

main.c:

Code: Select all

#pragma constseg page0

static char data_str[] = "Hello World";

static const char rodata_str[] = "Good bye";

static int bss_int = 0;

int main() {

}
page0.asm:

Code: Select all

        SECTION page0
        org     $0000
Compile with:

Code: Select all

zcc +msx main.c page0.asm -subtype=rom -lndos -create-app
From the .map file:

Code: Select all

_rodata_str                     = $0000 ; addr, local, , main_c, page0, main.c:23
_data_str                       = $C075 ; addr, local, , main_c, data_compiler, main.c:17
_bss_int                        = $C081 ; addr, local, , main_c, data_compiler, main.c:29
There will be two output files:

a.rom - The usual rom file
a_page0.bin - The contents of the lower memory

You'll have to stitch them together yourself into a usable file.
Timmy
Well known member
Posts: 392
Joined: Sat Mar 10, 2012 4:18 pm

Post by Timmy »

Somehow I missed this thread... I can ask around how they do bank switching, but it can take a couple of days to get an answer. (This is a very busy week for me.)
eldeljar
Member
Posts: 33
Joined: Sun Feb 12, 2017 6:04 pm

Post by eldeljar »

Thank you very much, that's what I was trying to do.

I have tried to join the bin file from page 0 (filling it up to 16Kb) and the rom file, and the rom seems to work correctly:

Code: Select all

FillFile.exe test_page0.bin 16384
copy /b test_page0.bin + /b test.rom /b test48Kb.rom
I still have to add the code to change the BIOS on page 0, recover the data and put the BIOS back. In the following url there is assembler code to do it:

http://www.msxblog.es/tutorial-ensambla ... om-de-48k/

, but at the moment I have not achieved anything.

Thank you.
eldeljar
Member
Posts: 33
Joined: Sun Feb 12, 2017 6:04 pm

Post by eldeljar »

Hello, after several days of testing, the code does not work for me. I have adapted part of the assembler code of the url that I indicated in the previous comment, but the rom does not work for me.

I have uploaded the code to github:

https://github.com/eldeljar/MSX_z88dk_48K

I do not know if the problem is that I am not generating the rom file correctly, or that the code is not correct.

If in the file test.c the functions changeBIOStoPage0 and changePage0toBIOS are together, the rom works, but I do not get the expected result. If I read the variables rodata_int in the middle of the 2 functions, loading the rom in an emulator gives an error.

Can someone help me to see what I'm doing wrong?

Thank you
Timmy
Well known member
Posts: 392
Joined: Sat Mar 10, 2012 4:18 pm

Post by Timmy »

It took me a long while to create the rom (it would be really quicker if you also include the rom file somewhere :) )

And it seems that reading the rodata_int works.

The problem is msx_color. After you swap out the BIOS from page 0, then you can't use any BIOS calls.

What do you think msx_color is doing? Yes, it's a BIOS call.

To solve this, either you can swap the page back before you do BIOS calls, or you write your own code for setting colours.
eldeljar
Member
Posts: 33
Joined: Sun Feb 12, 2017 6:04 pm

Post by eldeljar »

Thank you very much Timmy.

I know that the msx_color function uses the BIOS, but I did not notice that I was using the msx_color function when changing the BIOS on page 0.

I have corrected the code and it works. I have uploaded the code to github and left the rom in the "bin" folder.

The next test I'm going to do is with screen 2, tiles and sprites.

Thank you very much everyone for the help.
Post Reply