Jump to content
IGNORED

C Files, D Files and Memory Layout Help


Recommended Posts

So I'm at the point in my new DS/DSi emulator for the TI99/4a that I want to load the C/D files as used by Atarisoft and a few other TI carts. 

 

My original understanding from reading piles of forum posts here on AA (thanks guys!) is that the 8K C and 8K D are both mapped to >6000 but different banks selected by writes (of any data) to >6000 and >6002. I'm further to understand that it's internally identical to the Classic99 Format '9' (inverted) - though I've tried both ways with no success. The game launches but crashes pretty fast.   I've had no problems (so far) with more traditional C/G files.

 

Okay... so my brain is not grokking this and I need a concrete layout example.

 

Let's say I have a hypothetical game with a C and a D (and no G - not important for this scenario).

 

Let's call the two 8K files GameC.bin and GameD.bin

 

For the sake of working this out visually in my head... let's assume the first 4K of GameC.bin is filled with hex C1 bytes and the last 4K of GameC.bin is filled with hex C2 bytes.

Similarly, GameD.bin has 4K of D1 bytes followed by 4K of D2 bytes.

 

Here are my assumptions - obviously I've got something wrong:

 

When the system comes up, the 8K CPU Memory at >6000 will contain 4K of C1 followed by 4K of C2 (bank 0 is installed - this is the 'C' rom)

 

If the program writes memory >6002 it will swap in the 'D' rom and we now have 4K of D1 followed by 4K of D2 (bank 1 is installed - this is the 'D' rom).

If the program writes memory >6000 it will swap in the 'C' rom and we now have 4K of C1 followed by 4K of C2 (bank 0 is installed - this is the 'C' rom again).

 

I've tried to only swap out only the 4K bank at >7000 and I've tried the inverse (i.e. bank 1 or the 'D' rom installed at startup) and I'm growing more perplexed so I thought I'd try to ask some simple questions:

 

  • In my example above, what would be the initial C1/C2/D1/D2 layout at >6000 before any banking writes take place?
  • What happens when we write >6000?  >6002?

 

Thanks much in advance!

Edited by llabnip
Fix typos...
  • Like 2
Link to comment
Share on other sites

35 minutes ago, llabnip said:

In my example above, what would be the initial C1/C2/D1/D2 layout at >6000 before any banking writes take place?

 

The ROM state of ROM-only cartridges is not guaranteed at power-up. This is why most ROM-only cartridges have startup code in all banks that switches to the correct bank.

 

35 minutes ago, llabnip said:

What happens when we write >6000?  >6002?

 

With a non-inverting latch, writing to >6000 switches to bank 0 and writing to >6002, to bank 1.

 

With an inverting latch for a 16-KiB ROM*, writing to >6000 switches to bank 1 and writing to >6002, to bank 0.

 

...lee

_________________

*The reason I qualified the inverted ROM is that, for an inverting latch, writing to the bank-changing locations switches banks from the high end, i.e., if you had a 16-KiB ROM on a 32-KiB EPROM, the code would be necessarily duplicated to fill the EPROM and writing to >6000 switches to bank 3 (the highest bank) and writing to >6002, to bank 2.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Thanks @Lee Stewart

 

Let me ask a follow-up clarifying questions so as to leave no doubts in my head:

 

  • Is the C rom 'bank 0' and the D rom 'bank 1'?
  • Are the older C/D games (e.g. DigDug, Donkey Kong, etc.) considered inverting or non-inverting?  According to one post they are type '9' which implies inverting...
  • Is the entire 8K swapped in/out on a bank swap?  i.e. the only possibilities would be C1/C2 or D1/D2 in the 8K memory region. 
Link to comment
Share on other sites

1 hour ago, llabnip said:

Is the C rom 'bank 0' and the D rom 'bank 1'?

 

Others ( @Tursi, @acadiel, @Ksarul, ... ) will know better than I, but I think that is correct for a non-inverting latch.

 

1 hour ago, llabnip said:

Are the older C/D games (e.g. DigDug, Donkey Kong, etc.) considered inverting or non-inverting?  According to one post they are type '9' which implies inverting...

 

I defer to others on this one.

 

1 hour ago, llabnip said:

Is the entire 8K swapped in/out on a bank swap?  i.e. the only possibilities would be C1/C2 or D1/D2 in the 8K memory region. 

 

When writing to >6000, >6002<, ..., swapping is, indeed, for the entire 8 KiB. I think there are other ROM-write addresses for swapping only the upper 4 KiB, but I have not used them and am unsure.

 

...lee

  • Like 1
Link to comment
Share on other sites

41 minutes ago, HOME AUTOMATION said:

DigDug, appears to be non-inverted.

Donkey Kong, is just a mess. Paging using >6020, >6022. But also non-inverted.

Holy crap! That's it... that fixes DK for my emulator!

This memory switching is nutbar :)

  • Like 2
Link to comment
Share on other sites

Most DataBiotics 16K games were 9 (inverted) because they were 16K and used 74LS379's.  The 379 paged in the D (8K bank) first then the C (8K bank) into >6000->7FFF.  This was a rudimentary form of copyright protection by DBT.  (And later forms of copyright protection for larger 32K and 64K DBT carts such as Desktop Publisher, Red Baron Flight Simulator and TI Workshop used CRU bank switching with a PAL.  These have all been converted to the "standard write to ROM" bank switching method by community members.)

 

Most other 16K ROM games (Atari, etc.) were non inverted; C then D.

 

If you find an inverted Atari game, for example, it was likely made for my first 16K cart board with the 74LS379 (there's about 750 of them out in the wild.)  The image can be fixed by putting the 8192 bytes at the beginning of the file at the end of the file with a hex editor (for binary 16K files) or just renaming the .C and .D files (for 8K files).

 

My and @Ksarul's later boards (64K, 512K, 2MB) with the 74LS378 and 74LS377 were not inverted.  C then D.  We didn't come up with a naming scheme for more than two banks.  (You'd eventually run into .G which is a legacy GROM extension.)

 

Hope this helps!

  • Like 2
Link to comment
Share on other sites

Posted (edited)

Thanks guys! Immensely helpful - and now Donkey Kong and Dig Dug and a few others are working great... Moon Patrol starts up.. music plays and then crashes using both inverted and non-inverted. I'll debug that one more.

 

Is there something easy I can scan for in the actual ROMs themselves to determine if inverted/non?

Edited by llabnip
  • Like 2
Link to comment
Share on other sites

If it's using the C/D scheme, then they should all be the same order, but damned if I can ever remember which is which.

 

The cartridges bank using the second-to-least significant address bit, so make sure you are treating /all/ ROM writes as bank switches and just masking out the bit(s) you need.

 

If you don't know whether a particular set of ROMs are inverted or not, there is no way to tell. You have to just try it. That's why the metadata is important. But many modern carts have discarded it - you can usually assume modern files that don't otherwise say are non-inverted.

 

 

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

6 hours ago, acadiel said:

If you find an inverted Atari game, for example, it was likely made for my first 16K cart board with the 74LS379 (there's about 750 of them out in the wild.) 

 

My and @Ksarul's later boards (64K, 512K, 2MB) with the 74LS378 and 74LS377 were not inverted.  C then D.  We didn't come up with a naming scheme for more than two banks.  (You'd eventually run into .G which is a legacy GROM extension.)

One general note on the 16K Inverted Bank boards--these boards were extended to 64K and later to 128K, and remain as 74LS379 Inverted boards with a lot more banks. The Black Boards are the latest iteration of these, and there are about 800 of the Black boards in the wild now, in addition to the 16K and 64K boards mentioned by @acadiel.

 

The 512K Red Boards use the non-inverted 74LS378 (I've built close to 1,000 of these) and the 2M Yellow Boards use the non-inverted 74LS377 (about 300 of these are in the wild). There is also a nice bank inversion tool from @Asmusr that lets you switch your files between the two formats (the tool works to switch files in either direction, and I've attached it here).

bankinvert.zip

  • Like 3
Link to comment
Share on other sites

Thanks guys - I've got most of it working now thanks to your insights!  Moon Patrol ended up being an illegal opcode which I just vectored off into space rather than handle as a delay.

 

So I next wanted to try some of the bigger bankswitching carts... and found out that many of them require the 32K RAM expansion. That seemed simple enough - so I marked off 8K at >2000 and 24K at >A000 as 8-bit RAM and cleared RAM to start (0x00 values in all RAM locations) and still the games say 'Requires 32K' (or similar... some just crash). 

 

So there must be something more than just providing the RAM as writable? Is there some memory location or other setup that I need to perform so that the carts detect the 32K RAM? I had mostly assumed that a cart would just try writing/reading to some expansion address to see if it responds.

Link to comment
Share on other sites

2 hours ago, llabnip said:

So there must be something more than just providing the RAM as writable? Is there some memory location or other setup that I need to perform so that the carts detect the 32K RAM? I had mostly assumed that a cart would just try writing/reading to some expansion address to see if it responds.

There is nothing more to it than that.

  • Like 2
Link to comment
Share on other sites

6 hours ago, llabnip said:

Thanks guys - I've got most of it working now thanks to your insights!  Moon Patrol ended up being an illegal opcode which I just vectored off into space rather than handle as a delay.

Ah, yes, I can confirm that Moon Patrol does indeed have that. Slymoids also uses the "illegal" IDLE instruction in its main loop. Off the top of my head those are the main two commercial ROM weirdies. ;)

 

  • Like 4
Link to comment
Share on other sites

Posted (edited)

Holy crap... Slymoids is the OTHER file I'm having trouble with.  I was afraid to keep going back to the well asking for help.  I'll add you to my credits of thanks :)

 

I did find my 32K bug... that's all working.

Edited by llabnip
  • Like 2
Link to comment
Share on other sites

18 hours ago, Tursi said:

I hadn't even heard of Guardian before. :)
Ah, Rip-off clone. Nice ;)

It's quite a while ago, but I proposed it in the High Score competition:

Guardian means a lot of fun, especially in higher rounds, where you feel like on a special sale day in your discounter shop.

  • Like 1
Link to comment
Share on other sites

On 1/6/2023 at 2:01 PM, mizapf said:

It's quite a while ago, but I proposed it in the High Score competition:

Guardian means a lot of fun, especially in higher rounds, where you feel like on a special sale day in your discounter shop.

Hehe, I can't keep up with that contest, you guys are all way too good. ;)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...