Author Topic: Accessing 64k + 192k CD ram  (Read 326 times)

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Accessing 64k + 192k CD ram
« on: January 22, 2014, 08:18:45 PM »
Is there any standard mechanism of detecting (and accessing) the extra 64k and 192k ram as available with the CD and System Card 3 models from within HuC?

I know assembly would give me more options and direct access, but unfortunately C is what I know and I can't imagine I'd have gotten even half as far if I was trying to do this in assembler.

I'd like to be able to (optionally, at compile time - based on whoever is using the library) use CD ram (if available on the system at run-time) as a cache for file and directory lookups for my Turbo Everdrive FAT filesystem library - even 1 or 2kb would be useful to store FAT table cluster entries for the last 'N' directory/file accesses, but I don't want to eat into precious base ram - I've already got 544 bytes allocated for the selected partition record and volume sector entries as well as the main read buffer for the SD card and I'd like to keep my useage of the base 32k as small as possible.

touko

  • Hero Member
  • *****
  • Posts: 953
Re: Accessing 64k + 192k CD ram
« Reply #1 on: January 23, 2014, 12:24:30 AM »
Yes you must create an intermediate overlay (like a menu, logo screen), and start your game at next overlay ,and you can have the entire 256 ko available .

In the first overlay, 64 ko are reserved for system cd error .
« Last Edit: January 23, 2014, 12:26:53 AM by touko »

nodtveidt

  • Guest
Re: Accessing 64k + 192k CD ram
« Reply #2 on: January 23, 2014, 01:37:41 AM »
Normally, you can use the cd_getver() function call to determine the current system in use. 0x300 or 0x301 means you're dealing with a 256KB system; anything less than that is a 64KB system. However, this only has an effect if you're using the system card itself. What you're obviously trying to do is check the available RAM without using the system card, since you're already going to be using the hucard port. One thing to keep in mind that the Duo is always going to have the full 256KB. As far as I know, the 64KB RAM of the original hardware is in the IFU, and the 2.0 system card is just software to run the machine... the 3.0 card contains RAM of its own and you're not going to be able to utilize it if you're already using the hucard port.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Accessing 64k + 192k CD ram
« Reply #3 on: January 23, 2014, 04:38:57 AM »
Supposedly, Turbo Everdrive allows you to access the 192k in the Duo and SuperCDROM addon units.

 But even if you detect it (banks $80-87 are CD base ram and are always available, banks $68-7f are the additional 192k), how are you going to access it in HuC without some assembly? You can't create an extra large rom project that overlaps the ram area, and then treat it like far mem. That won't work with the TE card (the upper 4megabit region of the lower 1Mbyte address range, needs to be unmapped/unused). HuC doesn't, IIRC, give you direct access over the banking mechanism. That said, there are a few undocumented internal functions of HuC that you might be able to use. It's gonna be slow.

 How much ram do you need? I can write a few pragma fastcall routines for you, to access it, if you need.

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Re: Accessing 64k + 192k CD ram
« Reply #4 on: January 23, 2014, 08:06:47 AM »
In all probability I won't need any of the extra ram over the base 32k, but reading from SD card will be slow compared to any of the ram areas or rom banks. Directory access will require multiple reads from FAT in order to traverse the tree down to the starting cluster of the file. Caching even a small number of directory entries would cut down on the number of reads substantially.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Accessing 64k + 192k CD ram
« Reply #5 on: January 27, 2014, 07:34:17 AM »
I just checked. Turbo Everdrive card has full access to 64k+192k of CD ram. As long as the rom is 4megabits or smaller (Duo and SuperCDROM units only).

 That's a nice option for making custom SuperCDROM cards (good for translating games).
« Last Edit: January 27, 2014, 07:35:48 AM by Bonknuts »

megatron-uk

  • Full Member
  • ***
  • Posts: 219
Re: Accessing 64k + 192k CD ram
« Reply #6 on: January 27, 2014, 09:08:47 PM »
That's very interesting - I'm guessing you're thinking along the lines of having the font routines, fonts themselves and perhaps even the script stored in SuperCD ram with just some stubs in the original (base/cd ram) locations that then call out?

I wonder if it would ever be feasible to disassemble the US 3.01 bios to patch in support for the everdrive, variable width font routines etc and have the everdrive load that (on a Duo/SuperCDROM of course) so that you could boot from a custom bios with the extra bios routines that would be useful on a translated/hacked/custom cd game? SO rather than adding the additional functions into the game itself, you call them from 'rom' - I guess not being involved in any translation projects I don't know if there would be anything consistent across projects that would make it worthwhile.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Accessing 64k + 192k CD ram
« Reply #7 on: January 28, 2014, 08:59:26 AM »
Yup. There are lot a functions in bank $00 (always kept at mpr7), that you could replace with your own - bios calls.

 The only down side, is that original CDROM (TGCD and white brief case models) users won't be able to use TE for this.

spenoza

  • Hero Member
  • *****
  • Posts: 2751
Re: Accessing 64k + 192k CD ram
« Reply #8 on: January 28, 2014, 11:32:50 AM »
Can GameOfYou's flashcard also access that memory? Is some extra discreet logic the everdrive has necessary for this?
<a href="http://www.pcedaisakusen.net/2/34/103/show-collection.htm" class="bbc_link" target="_blank">My meager PC Engine Collection so far.</a><br><a href="https://www.pcenginefx.com/forums/" class="bbc_link" target="_blank">PC Engine Software Bible</a><br><a href="http://www.racketboy.com/forum/" c

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Accessing 64k + 192k CD ram
« Reply #9 on: January 28, 2014, 12:46:01 PM »
I doubt it. You would need to alter the hucard detect pin for address range access of 512k-1024k range, so that the internal memory mapped stuff of the system becomes available.