Theory of rom chips and idea for a tool similar to swapbin

A place that you can discuss reproduction of classic titles or "licensed-for-reproduction" homebrew for personal use.

Moderators: B00daW, Moderators

Forum rules
1. NO BLATANT PIRACY. This includes reproducing homebrew less than 10 years old, with the exception of free software.
2. No advertising your reproductions, with the exception of free software.
3. Be nice. See RFC 1855 if you aren't sure what this means.
Post Reply
darknezz19
Posts: 71
Joined: Wed Aug 26, 2009 8:28 am

Theory of rom chips and idea for a tool similar to swapbin

Post by darknezz19 » Thu Aug 20, 2015 9:19 pm

When a rom is burned is the data carried into the D0-D7 lines and broken up into 8 parts? I want to get a better idea of how the data is arranged and try to write a tool similar to what swapbin does. It would swap the data of a hirom game(that doesn't use sram) into a rom that could be programed onto a tsop adapter and soldered into a lorom donor to make it work properly. Lorom donors without sram are obviously more common than the hirom ones.

lidnariq
Posts: 10241
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Theory of rom chips and idea for a tool similar to swapb

Post by lidnariq » Thu Aug 20, 2015 10:54 pm

You can basically think of a ROM as basically a big lookup table, F(A)→D. Using swapbin, any address line can be exchanged with any address line, and any data line can exchanged with any data line.

As far as what the physical ROM does "under the hood", it's usually one or two square dice, each containing exactly 4ⁿ bits, and demultiplexer hardware on one axis and multiplexer hardware on the other. For example, an 8KiB ROM is usually arranged as 256×256 grid of bits, where A5..A12 ask for the data from one "row", and a set of multiplexers select eight "columns" to emit on the data pins. As to whether each bitplane is physically adjacent (all 1s bits together), or is instead sorted by byte, is an implementation detail that probably varies.

As an (amazing, insane) example, someone built a ROM by hand, from multiplexers and demultiplexers, and put a tiny (64 byte) Atari 2600 program into it: http://atariage.com/forums/topic/226940 ... tari-2600/ – here he didn't bother with the "multiplexer" stage; it's just a 64x8 bit array.

darknezz19
Posts: 71
Joined: Wed Aug 26, 2009 8:28 am

Re: Theory of rom chips and idea for a tool similar to swapb

Post by darknezz19 » Fri Aug 21, 2015 8:01 pm

Thanks for the details lidnariq, that home made rom that was built was interesting.

I tried to use a pin swap program for nes roms, made by FARID, and used a 512kb test file then did a file compare of the two. Thought there would be like chunks that are just swapped in a different order for each pin that was swapped but there was literally not one line that was the same. I guess it's more in depth than that and over my head for the time.

Just going to try to swap the pins on a new programming adapter instead of the rom rearrangement idea, seems easier.

tepples
Posts: 22278
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Theory of rom chips and idea for a tool similar to swapb

Post by tepples » Sat Aug 22, 2015 5:21 am

If a swap affects D0-D7 or A0-A3, it'll be harder to see correlation by looking for "lines" in common.

qwertymodo
Posts: 775
Joined: Mon Jul 02, 2012 7:46 am

Re: Theory of rom chips and idea for a tool similar to swapb

Post by qwertymodo » Tue Aug 25, 2015 10:08 am

Swapping address lines would rearrange the data. For example, take the original data:

Code: Select all

00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
Now, if you swap A0 and A1, you would get the following:

Code: Select all

00 02 01 04 03 07 06 09 08 0B 0A 0D 0C 0F 0E
If you were to instead swap A1 and A2, you would get:

Code: Select all

00 01 04 05 02 03 06 07 08 09 0C 0D 0A 0B 0E 0F
Now, if you were to swap the data lines instead, what you're actually doing is swapping bits within each individual byte of data, for instance, if you swap D0 and D1, then the byte 0x0A becomes 0x09. To see why, take a look at the binary representation of each:

0x09: 0b00001001
0x0A: 0b00001010

See how the two right-most bits are swapped? It's easy to see in binary, but it's very difficult to see visually in hex, so if you did a data-line swap and then compared, you probably wouldn't see any kind of discernible pattern viewing it in hex.

zzo38
Posts: 1077
Joined: Mon Feb 07, 2011 12:46 pm

Re: Theory of rom chips and idea for a tool similar to swapb

Post by zzo38 » Tue Aug 25, 2015 3:25 pm

I did once write a program that would exchange the address lines and/or data lines of a ROM image (as well as the ability to invert any of the address/data lines, and maybe even the ability to use 16-bit memory cells if I remember it properly); you may find it if you search these forums. But if you just want to swap A0 with A1 you could use "dd conv=swab". There may be many other programs too that can do such thing in certain cases, maybe even SoX or ImageMagick or sed or whatever
[url=gopher://zzo38computer.org/].[/url]

User avatar
FARID
Posts: 499
Joined: Wed Apr 07, 2010 1:14 am
Location: Iran
Contact:

Re: Theory of rom chips and idea for a tool similar to swapb

Post by FARID » Sat Aug 29, 2015 1:41 am

Code: Select all

Now, if you swap A0 and A1, you would get the following:

[code]00 02 01 04 03 07 06 09 08 0B 0A 0D 0C 0F 0E
[/code]

You messed it up by missing 05!
This should be correct :

Code: Select all

x00	x02	x01	x03	x04	x06	x05	x07	x08	x0A	x09	x0B	x0C	x0E	x0D	x0F

Here is a simple Excel file which can calculate it automatically.
But you have to fill the bits manually, copy and pate won't work because it mess up the Function :

Code: Select all

= "x" & "0" & BIN2HEX(CELL("contents";B1) & CELL("contents";B2) & CELL("contents";B3) & CELL("contents";B4))
Attachments
Swap_address_lines_calculator.zip
(7.1 KiB) Downloaded 161 times

Post Reply