Converting 2 Mask ROM board to 1 with LS139 on board

Discussion in 'Modding and Hacking - Consoles and Electronics' started by jaskamakkara, Oct 29, 2017.

  1. jaskamakkara

    jaskamakkara Tinkering in the dark

    Joined:
    Aug 22, 2013
    Messages:
    140
    Likes Received:
    5
    Hi,

    I am trying to make a Breath of Fire repro using a single 29F033 chip on an adapter board, the board would therefore be converted from 2x8Mb ROMs to a single 32Mb ROM arrangement. The board is an SHVC-2A3B-01.

    I am using rear mounted adapters and therefore don't need to remove the old Mask ROMs, I have instead snipped off the /OE lines (pin 31 / 33, depending on how you look at it) on both chips and tied them to 5V to disable them both, I then have soldered my adapter onto the back of the P0 chip.

    I have not done this kind of mod with an LS139 on the PCB before, I have done many with the MAD-1 and they always work fine (using this method). I found a pinout for the LS139 and checked it with my meter and it seems accurate, so I thought that it would be a simple case of connecting the A21 pin of the '033 to pin 3 of the 139, the A20 pin of the '033 to pin 2 of the 139, and the /OE of the '033 to pin 1 of the 139. This is what I did (the A21, A20 and /OE pins of the '033 are obviously not also connected to the pcb in any other way, only by wires to the 139 - I created jumpers in the adapters for this purpose), but the game behaves weirdly.

    The game seems to boot up fine with the title and everything, but when I get to the point where I have to start a New Game and it asks for a name entry, the characters of the name entry are populated with nonsense and entering characters does not cause anything to show on the screen. I am also unable to get past the screen that asks you to set your control scheme, pressing Start does nothing and I have to cancel out of it and the other options that would let me begin the game stay greyed out.

    The ROM I am using is just the USA version of the game that has been mirrored to fill 32Mb, and it runs fine in Higan. I am pretty sure that the ROM was burned correctly since I checked it before installation. When I use my home-made cart dumper, however, the ROM file is completely wrong, without even the header information being present.

    Any ideas? I have probably misunderstood how to wire up the LS139, but I'm not sure in what way - any help would be greatly appreciated!

    If you want pics/vids just ask.
     
  2. jaskamakkara

    jaskamakkara Tinkering in the dark

    Joined:
    Aug 22, 2013
    Messages:
    140
    Likes Received:
    5
    OK, figured it out. I'll supply an explanation here for reference purposes. This might be a bit basic for some of you, but it's so any beginner finding this with Google will hopefully be able to make the same mod I have done here.

    Note that a lot of this information is similar to that found in this article, I recommend checking it out.

    Just to reiterate the problem: I want to convert my Jap Breath of Fire cartridge into an English one. I wish to do this by soldering in a new m29f033 EEPROM on an adapter board. The problem is rewiring the decoder to allow the cart to work with one big ROM rather than two smaller ones. The decoder on my BoF cart is not the MAD-1 (there is info on how to make this mod with that decoder here) but the 74LS139. I couldn't find a definitive guide on how to do this, so I thought I'd share my findings.

    The 139 is a dual 2 to 4 line decoder (datasheet). A 2 to 4 line decoder takes 2 addresses as inputs and selects 1 of 4 outputs based on the 'value' of the inputs (taken as a binary number). The 'G' pins are output enable pins, when they are pulled high then none of the 4 outputs on that decoder are activated (activated means pulled low in this instance).

    First off, let's examine the pinout of the LS139 that's found in the BoF cartridge. Note that it's different to that found in the SMW cart examined in the article I linked.
    Code:
    /CART-------|1 {1G}     {+5V} 16|---------+5V
    A21---------|2 {1A}     {2G}  15|---------[7]
    A22---------|3 {1B}     {2A}  14|---------A15
    ROM 1 /OE---|4 {1Y0}    {2B}  13|---------A20
    ROM 2 /OE---|5 {1Y1}    {2Y0} 12|-----------X
    X-----------|6 {1Y2}    {2Y1} 11|-----------X
    [15]--------|7 {1Y3}    {2Y2} 10|-----RAM /CE
    GND---------|8 {GND}    {2Y3}  9|-----------X
    So what's going on here?

    Both decoders of the LS139 are being utilised. Hopefully you can see that the first one is connected to the ROMs and the second is connected to the RAM. This chip is deciding when the SNES gets to see the ROM or RAM, and if it's the ROM then it also decides which of the 2 Mask ROM chips is selected. Since BoF is a 12Mb ROM, the first Mask ROM will contain the first 8Mb and the second the other 4Mb. If the SNES comes looking for ROM data in the first 8Mb of the ROM then P0 (ROM 1) should be selected, and if the SNES is looking in the top 4Mb then the other one should be selected instead.

    Let's look at the truth table of our first decoder for more information:
    Code:
      1G  | 1A  | 1B  | 1Y0  | 1Y1  | 1Y2 | 1Y3
    /CART | A21 | A22 | 1/OE | 2/OE |  X  | [15]
    --------------------------------------------
      H   |  X  |  X  |  H   |  H   |  H  |  H
      L   |  L  |  L  |  L   |  H   |  H  |  H
      L   |  H  |  L  |  H   |  L   |  H  |  H
      L   |  L  |  H  |  H   |  H   |  L  |  H
      L   |  H  |  H  |  H   |  H   |  H  |  L
    So, what we can see is that when the /CART line is high, the ROMs are disabled. This makes sense when you know that the /CART line is pulled low when the SNES is looking for something on the cartridge (ROM or RAM). We can also see that the A21 line is choosing between the two ROMs (when A22 is low, anyway). A21 would normally select between data chunks of size 2^21 = 2MB (16Mb), but in the LoROM memory map all the address lines after A15 are shifted forward by one, so this in fact only selects between 1MB (8Mb) chunks. This agrees with what we said before. Finally, we can see that when A21 & A22 are both high, then pin [15] of the LS139 (the output enable for the other decoder) is pulled low, thereby activating our RAM select circuitry. Let's look at that now:
    Code:
     2G  | 2A  | 2B  | 2Y0  | 2Y1  | 2Y2    | 2Y3
     [7] | A15 | A20 |  X   |  X   | RAM/OE |  X
    ----------------------------------------------
      H  |  X  |  X  |  H   |  H   |   H    |  H
      L  |  L  |  L  |  L   |  H   |   H    |  H
      L  |  H  |  L  |  H   |  L   |   H    |  H
      L  |  L  |  H  |  H   |  H   |   L    |  H
      L  |  H  |  H  |  H   |  H   |   H    |  L
    
    From this, we can determine that the RAM is only activated when A20 is high (and A21 and A22 from the first decoder are also high, of course). To see why this is the case, consider the SNES address when A20-22 are high:
    Code:
    Binary: 11100000000000000000000
    Hex:    $70:0000
    From this helpful article, we can see that this agrees with the location of the SRAM in the SNES LoROM memory map. But why would we want the RAM deactivated when A15 is pulled high? Again, let's consider the address generated by A20-22 & A15 high:
    Code:
    Binary: 11100001000000000000000
    Hex:    $70:8000
    From the same article, we can see that the upper halves of banks $70-$7D are reserved for ROM. This agrees with our decoding scheme.

    Anyway, hopefully that helped you understand how the LS139 decodes the memory on a SNES cartridge, now to mod our BoF cartridge to use a single 32Mb or 16Mb EEPROM instead of the 2 onboard Mask ROMs:

    What we want to do is connect A22 & A21 from the 139 back to A21 & A20, respectively, of our new ROM (as it would be normally in a LoROM cart with a 36 pin Mask ROM). We also need the new chip's /OE line pulled low whenever EITHER pin 4 OR 5 of the LS139 is low. We cannot simply connect the /OE of our ROM to /CART or even /A22, as in that case our ROM and RAM would sometimes both be active which may create bus conflicts. Instead, the easiest way is to AND pins 4 and 5 of the 139 together and have the output of that operation connected to our ROM's /OE line. The truth table would be as follows:
    Code:
    [4] of | [5] of | /OE of
      139  |   139  | new ROM
    -------------------------
       L   |    L   |    L     <- This case doesn't actually exist
       L   |    H   |    L        since [4] and [5] of the 139 are
       H   |    L   |    L        never simultaneously low
       H   |    H   |    H
    Hopefully you can see that this gives us exactly what we want. If /CART goes high so does our new /OE, and if at least one or the other of the old /OE lines is low, so is our new /OE. Also, when the SNES is looking at the SRAM, our new /OE will be pulled high. You can implement this easily using a 7408 logic IC, that's what I did, anyway.

    Remember when burning your BoF ROM file you will want to mirror it to fill the chip (since the file is only 12Mb) - copy that last 4Mb of the file onto the back to make it 16Mb, then double it up to 32Mb and burn the resulting file. If you are not removing the second original Mask ROM then you must permanently deactivate it to ensure there are no bus conflicts. I do this by snipping the /OE pin (pin 31 on a 32-pin Mask ROM), bending it across to the +5V pin next door, and soldering it in place. Since I use rear mounting adapters for my EEPROMs and don't have to remove either Mask ROM, I also do this to the first one. Make sure that you don't connect the /OE pin of your new EEPROM to it's usual place on the PCB as well as to your AND logic gate. My adapters have a jumper for the /OE line for this purpose.

    Here's a pic of the back of my cart:

    [​IMG]

    Hope this helps someone.
     
    Last edited: Oct 31, 2017
sonicdude10
Draft saved Draft deleted
Insert every image as a...
  1.  0%

Share This Page