How to handle the Rom/Ram memory slots? (Development MSX Fora)MSX Resource Center MSXdev 2008 - MSX1 development bonanza!           
            
English Nederlands Español Português Russian         
 Nieuws
   Voorpagina
  Nieuws archief
  Nieuws onderwerpen

 Informatie
   MSX Fora
  Artikelen
  Recensies
  Beursverslagen
  Fotoreportages
  Beurzen en meetings
  Enquêtes
  Links
  Zoek

 Software
   Downloads
  Webshop

 MRC
   Wie we zijn
  Kom bij ons team
  Doneren
  Policies
  Contact met het MRC
  Link naar Ons
  Statistieken

 Zoek
 
  

  

 Login
 

Gebruikersnaam

Wachtwoord




Ben je nog niet lid? Klik hier en word MSX vriend!


 Statistieken
 

Er zijn 116 gasten en 1 MSX vriend online

Je bent een anonieme bezoeker.
 

MSX Fora


MSX Fora

Development - How to handle the Rom/Ram memory slots?

Ga naar pagina ( 1 | 2 Volgende pagina )
Schrijver

How to handle the Rom/Ram memory slots?

Prodatron
msx master
Berichten: 1088
Geplaatst: 07 Mei 2006, 12:10   
Hi,

I played around a little bit with the ram and rom banking of the MSX2.
As an information source I used this document:
http://www.work.de/nocash/portar.txt

In section "Memory" I found the description of the slot register and the memory mapper.

What I want is to hide all roms, so that I see the full 64K ram (which I may swap with the ports #FC-#FF).

So I did the following:
ld bc,#ffa8
out (c),b
ld a,#aa
ld (#ffff),a

This seems to work. I just wonder if this is the best way to hide all roms/catridges/mapped IOs, or do I need to consider something else?

CU,
Prodatron

Edwin
msx professional
Berichten: 591
Geplaatst: 07 Mei 2006, 12:36   
That is a rather static solution. It will not work on all machines. While I think every MSX2 and higher has its internal memory in slot 3, it's certainly not always in subslot 2. Also, there could be a larger memory mapper in one of the expansion slots, which you may want to use as primary or extra memory. Except for turbo R machines where internal memory is a great deal faster than memory in expansions.
Basically you will have to figure out what is where first. This stuff has all been done before though. So code or methods may be readily available.

If you need to discuss some topics you can find quite a few people on IRC (#msx, #msxdev, #msxdev). I can usually be found in #msxdev @ Rizon.
Sonic_aka_T

msx guru
Berichten: 2260
Geplaatst: 07 Mei 2006, 14:38   
Personally I'd start developing by loading SymbOS from MSX-DOS. You'll already have RAM present at all pages, and there's no need to phase out MSX-BASIC. If you want, you could later always make a loader that also works from BASIC, but I doubt many people will have a particular need for that.

By the time you're ready to fire up SymbOS the MSX BIOS will already be installed. This means that most of the slot-info is already available. You can check EXPTBL to see if each of the primary slots is expanded or not. EXPTBL is located at address $FCC1 - $FCC4. If bit 7 of the byte is set, then the slot it expanded.

When in DOS, you can check RAMAD0 to find the slot address of the primary mapper. Again, bit 7 indicates if it's an expanded slot, the lowest 4 bits indicate the primary and secondary slot number. On $F348 you can find the slot address of the primary disk ROM, this is only set if there is a disk ROM, but DOS requires one to boot anyways. $FB22, $FB24, $FB26 and $FB28 contain the slot-addresses of the first 4 disk ROMs. The byte that follows the slot-address contains the amount of drives found.

Check http://map.tni.nl/ for some more system variables. They can be very handy and save you a few checks. The mapper system is pretty straight forward, just do an OUT to ports $FC - $FF to change a bank in the ranges $0000, $4000, $8000 and $C000. Remember the MSX does an RST $38 each time the VDP (or anything else) generates an interrupt, so if you're paging something out, you'll want to be sure you do this with interrupts disabled, or a proper interrupt handler present at $0038.
Edwin
msx professional
Berichten: 591
Geplaatst: 07 Mei 2006, 15:00   
What you're suggesting may seem easy, but I doubt it really is. MSX-DOS has a lot of quirks you will have to live with if you're trying to run something under that. And the variables you mention are set even if DOS isn't started. Plus, IIRC, SymbOS was designed with the system running in the high memory range, which you can't touch if you allow things to run through the BIOS. All in all, it may require a lot of patching to the system to make it run. Which is all wasted effort in the end.

BTW, Prodatron, which interrupt mode do you use in SymbOS?
Prodatron
msx master
Berichten: 1088
Geplaatst: 07 Mei 2006, 15:41   
Regarding the starting point: Currently I start my code from basic, as I use the "autoexec.bas" like described in the "cross compiler" thread. Btw, how do I switch from Basic to MSX-DOS? If I type "call system" I get an "illegal function call". Currently I am using the startard MSX2 configuration in BlueMSX.
Regarding the methode, how to hide all ROMs/catridges/etc: Ok, so I will need a better function here or I could use Tobis hints. This small code I posted seems to work so far with my config, so I could do the improvement later. Now the most important thing is, that I can always use the #FC-#FF ports for changing the memory banking.
@Edwin: You spoke about primary/extra/internal/external memory. Can it all be addressed via these four ports?
@Sonic_aka_T: Yes, on the CPC I need a handler at #38 in every ram bank, too.
I use IM 1 in SymbOS, so I also can use the I-register. In SymbOS it's used to store the current RAM memory configuration.

Thanx a lot for your help! It's very exciting to start coding on the MSX
Prodatron
msx master
Berichten: 1088
Geplaatst: 07 Mei 2006, 15:51   
Another question: Is it possible in Basic to load a binary into the extended memory (>64K) or in the RAM blocks 2 and 3 (#0000-#7ffff)?
manuel
msx guru
Berichten: 3350
Geplaatst: 07 Mei 2006, 15:57   
Some short hints and comments:
- MSX-DOS 1 can only be started from basic if you already booted the system with DOS. Unless you do a POKE &HF346,1 to fake this
- Use I/O port 0xA8 to select the primary slot for each 16k page, use address 0xFFFF of those slots to select the secondary slot. See: http://map.tni.nl/resources/msx_io_ports.php#ppi
Edwin
msx professional
Berichten: 591
Geplaatst: 07 Mei 2006, 17:09   
Quote:

@Edwin: You spoke about primary/extra/internal/external memory. Can it all be addressed via these four ports?



Internal/external is just the physical location. It only matters on turbo R machines because external access gets delayed when in R800 mode. Primary is what the system selects ase the base mapper (that could be either the internal memory or a cartrigdge). It is possible to use multiple mappers as well, although it is a bit slower due to the slot switching that must be done.
Basically, at startup you need to find it all by looping through all (sub)slots and then through the mapper segments (through one of the ports $FC..FF) and find out if there is memory. You can use $FCC1..4 to find out if a slot is subslotted or not since those values are set at startup anyway.

Quote:

I use IM 1 in SymbOS, so I also can use the I-register. In SymbOS it's used to store the current RAM memory configuration.



Good. I was worried for a bit that you could be using IM2, which won't work on MSX.

I don't know what you want to do with basic and how much space you need. But, IIRC, you can set the start address of where basic programs are stored (here). If you set it above $C000, you have page 2 ($8000-$BFFF) free for switching, even from basic.
norakomi
msx professional
Berichten: 861
Geplaatst: 07 Mei 2006, 18:18   
Quote:

Btw, how do I switch from Basic to MSX-DOS? If I type "call system" I get an "illegal function call".

start with putting a dos disk in the drive (doh), then type poke&hf346,1:_system
msd
msx professional
Berichten: 600
Geplaatst: 07 Mei 2006, 19:23   
Quote:

MSX-DOS has a lot of quirks you will have to live with if you're trying to run something under that

. Like what?
Prodatron
msx master
Berichten: 1088
Geplaatst: 07 Mei 2006, 19:54   
Another question:
Currently I am trying to get the kernel up and running on the MSX2. I use BlueMSX for testing. As I said, SymbOS is running in IM1 and I have the interrupt handler installed at #38. While the interrupt routine works (maybe about 100-150 instructions), the interrupts of course are disabled.
In the blueMSX debugger I see, that everytime when it should leave the interrupt routine with EI:RET a new interrupt is triggered directly after the EI command?! So I am sticked in the interrupt routine. Why could this happen? I thought, only the VDP generates an interrupt 50times/second?
Sonic_aka_T

msx guru
Berichten: 2260
Geplaatst: 07 Mei 2006, 20:14   
Yes, but you need to clear the interrupt flag by reading the status register. If you don't clear the interrupt flag, the VDP will continue generating interrupts.
BiFi
msx guru
Berichten: 3142
Geplaatst: 07 Mei 2006, 20:15   
The Z80 reacts to every interrupt. It's true a plain MSX only has the VDP which generates interrupts. There are more devices (like MSX-AUDIO, MoonSound / OPL4, RS-232 interface, MIDI interface, GFX9000 / V9990) capable of generating interrupts. What the interrupt routine should do is find out which device caused the interrupt and handle it.

I think your handler is called at interrupt, but it doesn't find out which device caused it. In many of those devices the interrupt will only occur again once the status register with the flag that caused it before is reset (which is automatically done after the status register is read). Not doing that will cause the interrupt to be handled once and never again.

The MSX will seem to hang when the keyboard is scanned and the buffer is filled at the interrupt handler and your program waits for the buffer to contain contents and reads from it. For example, the MSX standard interrupt routine is bigger than your 100 to 150 instructions one and still has time to spare for things like BASIC... or even add more to it like complete music replayers for 24 channels.
Sonic_aka_T

msx guru
Berichten: 2260
Geplaatst: 07 Mei 2006, 20:15   
Quote:

What you're suggesting may seem easy, but I doubt it really is. MSX-DOS has a lot of quirks you will have to live with if you're trying to run something under that. And the variables you mention are set even if DOS isn't started. Plus, IIRC, SymbOS was designed with the system running in the high memory range, which you can't touch if you allow things to run through the BIOS. All in all, it may require a lot of patching to the system to make it run. Which is all wasted effort in the end.

BTW, Prodatron, which interrupt mode do you use in SymbOS?

I suggested loading from DOS, not running it in DOS.
Prodatron
msx master
Berichten: 1088
Geplaatst: 07 Mei 2006, 20:22   
Sorry for stupid question, seems, that I need to read port #99...
 
Ga naar pagina ( 1 | 2 Volgende pagina )
 







(c) 1994 - 2008 Stichting MSX Resource Center. MSX is een trademark van MSX Licensing Corporation.