What is the difference of mega ram and memory mapped ram ? (Hardware MSX Forum)MSX Resource Center               
              
English Nederlands Espa�ol Portugu�s Russian         
 News
   Frontpage
  News archive
  News topics

 Resources
   MSX Forum
  Articles
  Reviews
  Fair reports
  Photo shoots
  Fairs and meetings
  Polls
  Links
  Search

 Software
   Downloads
  Webshop

 MRC
   Who we are
  Join our team
  Donate
  Policies
  Contact us
  Link to Us
  Statistics

 Search
 
  

  

 Login
 

Username

Password




Don't you have an account yet? Become an MSX-friend and register an account now!.


 Statistics
 

There are 36 guests and 2 MSX friends online

You are an anonymous user.
 

MSX Forum


MSX Forum

Hardware - What is the difference of mega ram and memory mapped ram ?

Author

What is the difference of mega ram and memory mapped ram ?

nikodr
msx addict
Posts: 491
Posted: July 26 2007, 12:28   
I would like to ask you some information regarding megaram.What is it really?How does it work and what is the difference between memory mapped ram and megaram.I have a 4mbyte ram expansion (not megaram).When loading games i suspect there must be something different happening with the paging than megaram.Can somebody explain me the difference of those 2?

Guillian
msx professional
Posts: 647
Posted: July 26 2007, 15:41   
Memory mapped RAM uses ports #FC-#FF to change memory banks.
MegaRAM uses address (i.e.: #5000, #7000, #9000, #B000). So you can't use MegaRAM as memory expansion, but you can use it to load ROMs or MegaROMs to it.
nikodr
msx addict
Posts: 491
Posted: July 26 2007, 17:55   
Since a z80 can only access 64kbyte at once how can we go ahead of address #FFFF ? ( the limit of what z80 can access because of 16 bit address range).Or in that sense megaram is actually a cartridge emulator in the sense that acts like the cartridges ? (eg a game of 512kbytes could run on a 64kbyte machine).
Guillian
msx professional
Posts: 647
Posted: July 26 2007, 18:36   
Yep, Z80 can only address 64k so you need to use a mapper to access the whole memory. I.e:

This will select the first 64k of the memory mapper (banks 0-3)
out (#fc),0 ; 0000-3FFF
out (#fd),1 ; 4000-7FFF
out (#fe),2 ; 8000-BFFF
out (#ff),3 ; C000-FFFF

This would select the last 16k bank of a 512k memory mapper in #8000-#BFFF
out (#fe),31

As you said MegaRAM is a "cartridge emulator" since it uses common address as mapper registers. So writing:
ld a, 15
ld (#4000),a
would select the last 8k bank of a 128k ROM in #4000-#5FFF. It works quite similar to Konami mappers.
SLotman
msx professional
Posts: 544
Posted: July 27 2007, 03:15   
And precisely because MegaRAM uses 8kb pages like cartridges, you can play all megarom games on MegaRAM without any speed loss - and you can load almost all ROMs with Execrom from Adriano
nikodr
msx addict
Posts: 491
Posted: July 27 2007, 05:04   
so ld instructions like:
ld a,number of bank
ld (#address),a

is faster than

out (#fc), number of 16kbyte bank

What causes the slowdown in the memory mapped versions of games ?They are indeed a little slower than the rom ones.

Another question i have has to do with the code of a game.As i am trying to learn asm code and i am a complete beginer,can i write an asm code game in such a way that for example,screen draw and setup of sprites is in different bank than the sound of the game?

If game is only 64kbyte rom then there is no speed loss i can assume even if i use the out instructions to select 16kbyte banks?.

Now i am a little confused,since z80 can access 64kbytes do i really need to do this trick of selecting 16kbyte banks in a game that is 64kbytes?Is there any article or book that could help me understand the way memory mappers work and how they can be utilized when creating games?

Right now i am going to debug some memory mapped version of konami games and also debug with bluemsx debugger the rom version in order to understand how this works.

By the way would megaram work on msx1 ?I found a cheap msx1 for sale somewhere and i thought that since the model only has 64kbytes i could use megaram to play on it some msx1 rom games.

Sorry about all these questions,i am just discovering the art of asm programing and questions seem to pop up all the time in my head.

Guillian
msx professional
Posts: 647
Posted: July 27 2007, 15:44   
It is not a matter of speed of LD vs OUT instructions. The main problem is that a memory mapper uses 16k banks and most of the MegaROMS uses 8k banks. So if a game ROM change one of its pages like:

ld a, 5
ld (#7000),a
it changes only #6000-#7FFF memory range

but if you do a:

ld a, 2
out (#fd), a
you change #4000-#7FFF

So some disk conversion need to do LDIRs (a other tricks) to solve that problem, and this is one of the causes of the slowdowns.


About using different memory banks in a game. As you know Z80 can only address 64k. Usually #C000-#FFFF is set as RAM used for system and game variables. Also in #0000-#3FFF is usually selected the BIOS. So most MegaROM uses only #4000-#BFFF for game ROM. That 32k are not enough for all the game code, music, graphics, etc. That's why they use a mapper and different banks.
In example they can have the main code in #4000-#7FFF and use #8000-#BFFF to select different banks depeding on the music they want to play, the actual stage map and/or the graphics data they need to uncompress and/or copy to VRAM.

nikodr
msx addict
Posts: 491
Posted: July 30 2007, 15:01   
I found Nyyrikki's super-x program and tried to load a disk cracked version of a konami megarom game.I noticed that when i use the LD file it gives me the start address the end address and the execution address.
The game has 8 files that have to be bloaded.So i did 8 ld instructions.
The following are the Start Address:End address:execution Addresses of each file.
____Start_End__Exec
File1 8000:C020:C000
File2 8000:C020:C000
File3 8000:C060:C000
File4 8000:C020:C000
File5 8000:C060:C000
File6 8000:C004:C000
File7 8000:C004:C000
File8 8000:C100:C000

Game starts after loading of file 8 so i assume that C000-C100 contains the start of the game.

Game is a konami megarom 128kbytes (no scc) of a game made in 1987.Can somebody explain the use of banks here?Since each file is about 16kbytes,how can the msx now when to switch to other bank to load the data since all files have start address of $8000.Is this provided in machine code in each file?
mohai
msx freak
Posts: 129
Posted: July 30 2007, 17:25   
As Guillian said (look above), standard MSX mapper, uses ports #FC - #FF to set memory bank at an address rank. You can set anyone you want and you can repeat them also.
The "BLOADable" files you have, do all the switching and patching for you. You should have another BASIC program to make them load and execute. Only thing you have to make sure is that you are loading suitable version for your MSX, that is, if you only have 128 K, you have to load a 128 K version. Never mind what long is original game, as some big games are patched to (even) load into 128 K.
 
 







(c) 1994 - 2008 MSX Resource Center Foundation. MSX is a trademark of MSX Licensing Corporation.