Author Topic: BRAM Library  (Read 1533 times)

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: BRAM Library
« Reply #30 on: May 29, 2016, 11:10:55 AM »
Quote
It's definitely an emulator thing with mednafen. I switched over to using the sys card bram routines instead,...

That sounds so damn familiar...I wish I could remember what we did to fix it...

First, check your mednafen.cfg file, and make sure its set up for bram saves; I vaguely recall if you don't specify a path for something, it won't actually save to a file.
Second, delete any old bram files you find. I do remember everytime I changed the cd image, mednafen created a new bram file (empty of course) with a different name. I believe the name was based on a hash of the code, and if things in the iso changed, you got a new save file.
Other than that ask the mednafen author what's going on / if he has any ideas. He's a pretty ok guy explaining why things do what they do. And if it's really an emulation problems, he does get it fixed.

Quote
Also, the CDREAD routine is annoying. I can only read in as many free banks as I have logical address range for (32k at a time)

The syscard 3.0 (?) CD_READ uses DH as a read type; the nice (or not) thing is you can specify an MPR bank to use for the read, and it is capable of filling consecutive banks for you.
And I -think- it may even load partial banks if the length isn't a multiple of 4 sectors.

Somewhere around there there used to be a HuCD7_final.pdf file that had the details on how the bios did things; not sure if it was 2.0 or 3.0, but the things it says do work on a 3.0 card.

That's how we figured out how to do MML :)

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: BRAM Library
« Reply #31 on: May 29, 2016, 11:19:44 AM »
Yeah, I set _DH to the MPR page and put the starting bank in _BL. Maybe I missed something. I'll give it another try. It seems weird that they wouldn't allow all 256k to be loaded in a single pass (#$80 sectors).

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: BRAM Library
« Reply #32 on: May 29, 2016, 11:25:32 AM »
Somewhere around there there used to be a HuCD7_final.pdf file that had the details on how the bios did things; not sure if it was 2.0 or 3.0, but the things it says do work on a 3.0 card.

 I have it. It's listed as CD-ROM BIOS ver 1.00

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: BRAM Library
« Reply #33 on: May 29, 2016, 11:55:59 AM »
Ok. I tracked down the problem with BRAM code. For some reason, mednafen won't unlock BRAM if you write "Hu",$80 to port $1807 if the emulator is in CD mode. It only works if you write only $80 to the port. So definitely an emulator thing. And the other thing that I noted; you can't see the contents of BRAM while you're stepping through the routine in the debugger if the emulator is in CD mode. For hucard mode, this isn't an issue.

 So it was a two fold problem. I was able to mix and match sys card and my own routines now, in a CD project.

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: BRAM Library
« Reply #34 on: May 29, 2016, 12:42:12 PM »
Quote
Ok. I tracked down the problem with BRAM code.

Good to hear. Now, when can we expect Dragon Warrior?

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: BRAM Library
« Reply #35 on: May 29, 2016, 01:18:23 PM »
Quote
Yeah, I set _DH to the MPR page and put the starting bank in _BL.

lda    #4    ; $8000 range / sta    _DH  /  lda  #80    /sta BL    kinda thing?

As I found out, there's a gap in page numbers...so it probably can only load 64K at a time.


[Syscard 3.0 banks are at $60-$6F, iirc. Then you jump to $80-$8F for 'stock' pages.
 I could be wrong though, with the ranges. I just remember they aren't consecutive.]


elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: BRAM Library
« Reply #36 on: May 30, 2016, 04:11:20 AM »
Ok. I tracked down the problem with BRAM code. For some reason, mednafen won't unlock BRAM if you write "Hu",$80 to port $1807 if the emulator is in CD mode. It only works if you write only $80 to the port. So definitely an emulator thing.

Do you have a Mednafen patch for that, or are you working around it in your PCE test-code?

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: BRAM Library
« Reply #37 on: May 30, 2016, 08:16:57 AM »
I ended up using an .ifndef for an assembler variable/argument. Declaring _CDPROJ switches to the different unlock code.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: BRAM Library
« Reply #38 on: June 02, 2016, 09:12:40 AM »
Just wanted to say that I started real system tests, since ironing out the problems with the emulator, and everything seems to work as it should (the custom bram lib). And as expected, the real CD unit doesn't care what's written to port $1807; only the last byte being $80. So that's totally a mednafen thing.

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: BRAM Library
« Reply #39 on: June 02, 2016, 11:23:53 AM »
[Syscard 3.0 banks are at $60-$6F, iirc. Then you jump to $80-$8F for 'stock' pages.
 I could be wrong though, with the ranges. I just remember they aren't consecutive.]

Are you sure about this?  Isn't (S)CD RAM consecutive from bank $68-$87, with $80-$87 being standard CD RAM?

dshadoff

  • Full Member
  • ***
  • Posts: 175
Re: BRAM Library
« Reply #40 on: June 02, 2016, 11:40:18 AM »
[Syscard 3.0 banks are at $60-$6F, iirc. Then you jump to $80-$8F for 'stock' pages.
 I could be wrong though, with the ranges. I just remember they aren't consecutive.]

Are you sure about this?  Isn't (S)CD RAM consecutive from bank $68-$87, with $80-$87 being standard CD RAM?

I'm with Chris on this... I'm certain that the "additional" memory goes to $7F, to make memory contiguous.

Dave

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: BRAM Library
« Reply #41 on: June 02, 2016, 04:41:05 PM »
Quote
I'm certain that the "additional" memory goes to $7F, to make memory contiguous.

Okay. Being wrong is part of learning.
I have a hard enough time remembering things, anyway. (At least since I turned XX)

So, to do this the card either has a 128K RAM + 64 K RAM + 64K ROM and a decoder sith some glue chips, or 3 * 64K RAM + 64K ROM + decoder....
Hmm. must have been a pain to get wired.

And the bios converts number-of-sectors to read to number-of-bytes to read, which is where the 64K limit comes in. Got it.
<Now, can it be fixed.....>

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: BRAM Library
« Reply #42 on: June 02, 2016, 04:44:33 PM »
<edit>
256 K ROM
(16+15 = 31 * 8 = 256K)

Mednafen

  • Full Member
  • ***
  • Posts: 140
Re: BRAM Library
« Reply #43 on: June 08, 2016, 02:41:13 PM »
Just wanted to say that I started real system tests, since ironing out the problems with the emulator, and everything seems to work as it should (the custom bram lib). And as expected, the real CD unit doesn't care what's written to port $1807; only the last byte being $80. So that's totally a mednafen thing.

I can fix a bug if you provide a test program with accompanying source code.