Autor
| Universal RAM allocator
|
pitpan msx master Mensajes: 1418 | Publicado: Julio 12 2005, 22:39   |
Hi everyone.
I'm really frustated because apparently I cannot produce a routine able to locate RAM in pages 0 and 1 of ANY MSX computer with at least 64 KB of RAM installed. Could you please give me a clue? I'm asuming that there's already RAM allocated in pages 2 and 3 (BIOS does it).
For MSX computers without memory mapper, I explore every slot and subslot looking for RAM.
For MSX computers with a mapper, I don't exactly know what to do.
How can I prevent other types of RAM of being located? (for example, SCC/SCC-I memory or memory for other devices).
I'm sorry to ask here such a n00b question, but I cannot find a right answer. I've tried different techniques, and every time that I publish a new WAV file, someone reports an error related to RAM allocation. Damn!
|
|
Sonic_aka_T
 msx guru Mensajes: 2269 | Publicado: Julio 12 2005, 23:14   |
Like you said, it boots with RAM present on page 3, rite? Just use whatever slot is located there. Any mapper will have at least 64kB, so there shouldn't be a problem. I don't fiddle around with RAM too much, (other than banking) but I remember doing a LD A,($F341) LD H,$40 CALL $0024 whenever I needed some extra RAM in the BASIC environment. It might not be pretty, but it should be pretty much compatible on most (all?) machines that have a mapper.
|
|
pitpan msx master Mensajes: 1418 | Publicado: Julio 12 2005, 23:59   |
But there are a lot of MSX2/2+ without mapper and MSX1 with mapper as well. What should I do?
|
|
Sonic_aka_T
 msx guru Mensajes: 2269 | Publicado: Julio 13 2005, 02:19   |
Quote:
| But there are a lot of MSX2/2+ without mapper and MSX1 with mapper as well. What should I do?
|
I don't know, can't you just use whatever slot is being used on page 3? |
|
pitpan msx master Mensajes: 1418 | Publicado: Julio 13 2005, 06:46   |
No. It would be too easy! That was my first approach, but there are some strange machines around. For example, the Toshiba HX-20 or the SONY HB-900, with RAM divided in different slots. Any clues?
|
|
BiFi msx guru Mensajes: 3142 | Publicado: Julio 13 2005, 07:01   |
Quote:
| I don't fiddle around with RAM too much, (other than banking) but I remember doing a LD A,($F341) LD H,$40 CALL $0024 whenever I needed some extra RAM in the BASIC environment. It might not be pretty, but it should be pretty much compatible on most (all?) machines that have a mapper.
|
Yes... (yes, here it is  ) but, what if it's not a mapper? Memory can be in a different slot for every Z80 page... and $F341 is set by the DiskROM... and...
$F341 = $0000-$3FFF = page0 RAM slot
$F342 = $4000-$7FFF = page1 RAM slot
$F343 = $8000-$BFFF = page2 RAM slot
$F344 = $C000-$FFFF = page3 RAM slot
Only on MSX computers with a memory mapper and an initialized DiskROM your asm will work.. |
|
BiFi msx guru Mensajes: 3142 | Publicado: Julio 13 2005, 07:07   |
Quote:
| But there are a lot of MSX2/2+ without mapper and MSX1 with mapper as well. What should I do?
|
You need to parse each slot for a page (or each page) to look for RAM. You can use $000C (RDSLT) and $0014 (WRSLT) to hunt for memory without having to set the slot yourself first. SCC-I RAM is detected in a different way. The cartridge is set in ReadOnly mode and you need to set it to RAM mode yourself. SCC is usually ROM anyway and if you write to a switch address in a slot where a MegaROM is detected the ROM area will change in a whole, not change just one byte.
Detecting RAM in general is like this:
Read current value, write test value, read test value, restore old value... if writing and reading the test value succeeds it's most likely RAM, and if the current value is read after writing the test value, it's most likely ROM. |
|
BiFi msx guru Mensajes: 3142 | Publicado: Julio 13 2005, 07:17   |
oh yeah, you need to use $FCC1 (EXPTBL) to determine if the slot is expanded and you need to parse secundary slots as well.
|
|
ro msx guru Mensajes: 2353 | Publicado: Julio 13 2005, 07:27   |
Like the beefman said.
;Set primairy page in slot
ld a,($F341+slotnr)
ld h,slotnr*16
call $24
And don't forget to (re)set subslots (the famous poke-1,x) Subslot info can be found in #FFFF (value=neg). Use some fiddling to get all slot correct. Gotta check my source again, I'm sure the beefmaster can explain in detail without 'aving to scroll through manuals of sources (bifi's the real online library here)
AFTER that, you might even set mapper values if ya want (and if present)
slots/pages/maps have always been kinda confusing to newbies. don't worry, you're here to lear.
good luck.
|
|
NYYRIKKI msx master Mensajes: 1533 | Publicado: Julio 13 2005, 07:44   |
If you can expect, that user has DISKDRIVE, then you can use #F341 for page 0 slotID and #F342 for page 1 slotID.
If there is no DISK ROM, then things get quite a bit harder... My suggestion is to search every primary & subslot for RAM and test RAM for types, you want to exclude. You need to repeat this for both pages separately. Mapper does not really make any difference. To avoid possible RAM conflict, do OUT (#FC),0 and OUT (#FD),1 before detection.
In theory the 64KB RAM can be divided to 4 different slots. and to make things even more ugly, some memorymappers don't work at all on pages 0 and 3. Remember, that correct slot needs to be selected to page 3 in order to select subslots... Aargh!
|
|
BiFi msx guru Mensajes: 3142 | Publicado: Julio 13 2005, 08:48   |
Quote:
|
If you can expect, that user has DISKDRIVE, then you can use #F341 for page 0 slotID and #F342 for page 1 slotID.
If there is no DISK ROM, then things get quite a bit harder... My suggestion is to search every primary & subslot for RAM and test RAM for types, you want to exclude.
|
I can be wrong, but didn't I say that already?  |
|
AuroraMSX
 msx master Mensajes: 1278 | Publicado: Julio 13 2005, 09:32   |
[/quote]I can be wrong, but didn't I say that already?  [/quote]
You did, but NYYRIKKI's answer is less obscure  |
|
BiFi msx guru Mensajes: 3142 | Publicado: Julio 13 2005, 13:51   |
thanks  |
|
pitpan msx master Mensajes: 1418 | Publicado: Julio 13 2005, 19:56   |
Thanks for the explanations. But once again: there is no SIMPLE method to do it!
Scanning slots and subslots for RAM is booooring! But if there is no other solution, then I'll have to do it.
|
|
Arjan msx addict Mensajes: 479 | Publicado: Julio 13 2005, 21:23   |
If you want to prevent other types of ram being allocated, you should test the memory at several addresses (like at $0000, $1000, $2000, ...) AND also make sure the ram is not being mirrored.
|
|
|
|
|