home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR4 / SNES_GEN.ZIP / GAMEMEDC.TXT < prev    next >
Text File  |  1994-01-24  |  14KB  |  335 lines

  1. GAME MEDIC
  2. by Mr. Turbo of the Silicon Valley Swappe Shoppe
  3.   Read and playback Sega Genesis and Super Nintendo cartridges
  4. --------------------------------------------------------------
  5.  
  6.  
  7. 1. Introduction
  8.  
  9. This information was gleaned from disassembling the Sega Genesis and
  10. the Super Nintendo and their cartridges.  The contents of this file
  11. does not come from confidential sources.
  12.  
  13. The average Sega Genesis/Megadrive cartridge consists of a ROM chip and 
  14. sometimes a battery backed up static ram chip.  The signals to and from
  15. the cartridge are all CMOS level (rail to rail voltage swings) and therefore
  16. all chips which interface to a cartridge or the Genesis/Megadrive should
  17. be CMOS compatible parts.  When using the 74 series chips, be sure
  18. to use either 74HC or 74HCT family.  When using EPROMS, be sure they are
  19. CMOS compatible.  The Sega Genesis uses a CMOS variant of the Motorola
  20. 68000.  Therefore, there are 16 data lines and 23 address lines at the 
  21. cartridge slot.
  22.  
  23. Sega cartridges almost exclusively use a single mask programmed 16 bit 
  24. wide ROM chip in their cartridges, but third party manufacturers sometimes 
  25. use multiple (sometimes 8 bit wide) ROM chips.  Therefore, reading a
  26. Genesis cartridge consists of asserting the address and chip select
  27. lines low, setting the address lines to the address you want to read
  28. and reading the data of the data lines.  Playing back a game read from
  29. a cartridge consists of writing the data to an EPROM or equivalent and
  30. connecting it to the Genesis.
  31.  
  32. The pinouts for the cartridge port is as follows:
  33.  
  34. When standing in front of the Genesis, b is frontward, a is rearward,
  35. 1 is to the left and 32 is to the right.
  36.  
  37. *=active low
  38.  
  39. a1  - gnd    b1  -
  40. a2  - +5v    b2  -
  41. a3  - A8     b3  -
  42. a4  - A11    b4  - A9
  43. a5  - A7     b5  - A10
  44. a6  - A12    b6  - A18
  45. a7  - A6     b7  - A19
  46. a8  - A13    b8  - A20
  47. a9  - A5     b9  - A21
  48. a10 - A14    b10 - A22
  49. a11 - A4     b11 - A23
  50. a12 - A15    b12 -
  51. a13 - A3     b13 -
  52. a14 - A16    b14 -
  53. a15 - A2     b15 -
  54. a16 - A17    b16 - *OE
  55. a17 - A1     b17 - *CS
  56. a18 - gnd    b18 - *AS
  57. a19 - D7     b19 -
  58. a20 - D0     b20 -
  59. a21 - D8     b21 -
  60. a22 - D6     b22 - D15
  61. a23 - D1     b23 - D14
  62. a24 - D9     b24 - D13
  63. a25 - D5     b25 - D12
  64. a26 - D2     b26 -
  65. a27 - D10    b27 - *RESET
  66. a28 - D4     b28 - *WE
  67. a29 - D3     b29 -
  68. a30 - D11    b30 -
  69. a31 - +5v    b31 -
  70. a32 - gnd    b32 - gnd
  71.  
  72.  
  73. 2. The Cartridge Reader
  74.  
  75. 2.1 About the IBM PC Parallel Port and the Cartridge Reader
  76.  
  77. The cartridge reader is designed to interface with the IBM PC (and
  78. compatibles) parallel printer port.  Although I could have used one of
  79. the backplane slots to read the cartridge, the parallel port was
  80. selected because it is easier to construct a device that physically
  81. plugs into it and they are cheap to replace in case you fry your parallel
  82. port.  The disadvantage (from the designer's standpoint) is that you
  83. only have 12 bits of data coming out of it (8 parallel port data and 4
  84. control) and you can only feed in 4 bits of data into the parallel port.
  85.  
  86. The solution to this is to use registers/octal latches (the 74HCT374).
  87. What we do is feed the address we want to read into the latches and
  88. then read the data off the data lines.  Two of the parallel port
  89. handshake lines are used to select between the three 8 bit
  90. registers/latches.  Since the Genesis ROM has a 16 bit datapath, we
  91. add an extra address line (A0) to select between the upper and lower 8
  92. bits.  We still have to feed this 8 bit data into a 4 bit port so we
  93. use a 74HCT244 as a data selector to select between the upper and
  94. lower 4 bits of data.  Another control line is used to make the
  95. selection.  Note that because of the way IBM designed their parallel
  96. prot, the highest bit of this 4 bit input is inverted.
  97.  
  98. 2.2 Building the Cartridge Reader
  99.  
  100. Be sure to use the 74HCT family or equivalent when purchasing the parts.
  101. The HCT family means that the chips are "high speed", CMOS level outputs
  102. and TTL level inputs.
  103.  
  104. You can either print out the PCB pattern I provided or wire wrap the
  105. circuit.  Another option is to use a breadboard but you must be
  106. careful because breadboard projects tend to loosen their wires over a
  107. period of time. The filename for the schematic is READ-SCH and the
  108. filename for the pattern is READ-PAT.
  109.  
  110. If you want to etch your own PCB, one thing you can try is the laser
  111. printer direct method.  Print the pattern on a plastic sheet and iron
  112. the sheet to a clean copperclad board.  The laser printer toner will
  113. transfer from the plastic to the copperclad and act as a resist.  You
  114. then toss the copperclad into some etchant and clean it off when you
  115. are done.
  116.  
  117. To build the cartridge reader, you will need the following parts:
  118. 2 - 74HCT139
  119. 3 - 74HCT374
  120. 2 - 74HCT244
  121. 7 - .1 microFarad capacitors
  122. 1 - male DB25 connector
  123. 1 - 64 pin card edge connector with .100 inch contact centers
  124. 1 - 5 volt power source (you can use a 5 volt source from inside your PC)
  125.  
  126. The first 5 parts are fairly easily obtainable.  If you don't have a
  127. good electronics store in your area, you can mail order the parts from
  128. Digikey (call 1 800 344 4539 and ask for a catalog).  The 64 pin card
  129. edge connector is fairly hard to find.  3M makes such an item but only
  130. in the ribbon cable variant.  What I did was to use the 3M connector
  131. with a ribbon cable and put DIP plugs on the other end of the ribbon.
  132. If you decide to do this, be sure to keep the ribbon cable short (i.e.
  133. 4 inches or less) to cut down on the noise.  When using the 3M connector,
  134. you have to shave off the edges in order to get it to fit in a Genesis
  135. cartridge.  If you can't find a 64 pin connector, you can get a 72 pin
  136. connector, insert a barrier key to separate off 64 pins and cut off
  137. the extra 8 pins.
  138.  
  139. The capacitors go between +5 and ground.  Put one as near as possible
  140. to each chip.
  141.  
  142. Keep the connection between the IBM PC parallel port and the cartridge
  143. reader as short as possible to reduce the noise factor.
  144.  
  145. 2.3 Software
  146.  
  147. All programs are written in C and were compiled using Borland C/C++.
  148. All you need to do to convert them to Microcrud C or Zortech or whatever
  149. else, just change the outport() and inport() function calls to whatever
  150. your compiler uses.
  151.  
  152. The software is provided as READCART.C,  TESTCART.C and SIZETEST.C.
  153.  
  154. READCART.C reads the data from the cartridge and writes to the
  155. specified file.  If no file specification is given, it will write it
  156. to game.dat.  You must also specify the size of the file in megabits.
  157. The program is hard coded to read data from LPT1:.  If you use another
  158. parallel port, be sure to change the address macro definitions.
  159.  
  160. TESTCART.C is a program to test the cartridge reader.  Feed the lower
  161. 16 bits of the address back into the data lines and this program will
  162. verify correct operation of the cartridge reader.
  163.  
  164. SIZETEST.C is a program to automatically determine the size (in
  165. megabits) of a cartridge plugged into the cartridge reader.
  166.  
  167. 2.4 Testing and Debugging
  168.  
  169. Hook up the address lines to the data lines (A1 goes to D0, A2 goes to
  170. D1, etc) and run the TESTCART.C program.  If you get consistent
  171. errors, then you have a wiring problem or you forgot to hook up the +5
  172. volt power source.  If you get random errors, you have a noise
  173. problem.  Shorten the cables between the cartridge and the reader and
  174. the compuer and the reader.  Add more capacitors to your power source.
  175. If you still get noise errors, play with the delay factor on line 25
  176. of TESTCART.C and/or add pullup or pulldown resistors or both to the
  177. lines going to and from the parallel port.
  178.  
  179. When you feel confident that everything is working, plug in a
  180. cartridge and read it in two or three times.  Do a compare of the
  181. files you get to make sure there are no noise problems.  Offset
  182. 100-19f hex should contain ASCII info on whatever cartridge you have
  183. plugged in.  If it doesn't, try another cartridge.  It should say
  184. something like:
  185.  
  186. SEGA GENESIS (C) SEGA 1992.FEB SONIC THE HEDGEHOG
  187. etc.
  188.  
  189. Almost all Sega produced games say SEGA GENESIS at offset 100 hex.
  190.  
  191. If it appears that the byte order is switched (i.e. it comes
  192. out ESAGG NESESI or something like that), then the four wires from the 
  193. 74HCT139 to the 74HCT244's are switched around.  If you can't find
  194. the text at offset 100 hex, try looking at 1 hex and 10000 hex. If
  195. you find it at one of those locations, then the 3 wires going from
  196. the 74HCT139 to the 74HCT374's are switched around.
  197.  
  198.  
  199. 3. Playing Back What You Read.
  200.  
  201. In order to play back what you read out of the cartridge, you will
  202. need to store it in either static RAM, EPROM or flash memory.  If you
  203. are going to store it in EPROM or flash memory, you will need an EPROM
  204. programmer.  Needham Electronics (916 924 8037) sells a nice one for very cheap.
  205. Flash memory is especially nice since you erase it electronically like
  206. static RAM, it is non-volatile like an EPROM and programs very fast.
  207. Unfortunately, they are hard to find.  Microprocessors Unlimited
  208. (918 267 6961; ask for a price sheet) sells the Intel 28F020 flash
  209. memory as well as EPROMs and static RAM.  The 28F020 is a 2 megabit
  210. chip and is 8 bits wide so you will need two of them.  EPROMS have
  211. the highest density but they are the hardest to program and are a pain
  212. to erase (you have to put them under a ultra-violet lamp).  The last
  213. time I checked, static RAM only comes in 1 megabit configurations and
  214. you have to provide some sort of battery backup when transferring
  215. programs from the IBM PC to the Genesis.
  216.  
  217. The easiest way to make a carrier for your memory chips is to get a
  218. cartridge that already has two 8 bit wide chips on it and hack it
  219. apart.  Early Electronics Arts games use such an arrangement.  Clip
  220. off all the legs of each of the chips and desolder each of them one by
  221. one.  Replace each of the chips with a ZIF (Zero Insertion Force)
  222. socket.  Some of the larger ZIF sockets may not fit in your cartridge.
  223. Aries Electronics has a small low profile ZIF socket you can buy from
  224. Digikey (see above).
  225.  
  226. If you want to make your own, I have provided a PCB pattern called
  227. CART-PAT.
  228.  
  229. When you program your memory, if you are using 8 bit wide memory, you
  230. will need to program one chip with the even addresses and one chip
  231. with the odd addresses. 
  232.  
  233. 4. Battery Backed up RAM Games
  234.  
  235. When A21 goes high, then the chip select (*CS) of the battery backed
  236. up RAM is active (low).  Just connect *CS, *OE, *WE and the rest of
  237. the address and data lines to the SRAM.
  238.  
  239. 5. Using the Cartridge Reader with the Super Nintendo
  240.  
  241. The Super Nintendo cartridge is very similar to the Sega Genesis
  242. arrangement.  The two main differences are that the Sega has 16 data
  243. lines while the Super Nintendo has 8 and the Super Nintendo has a
  244. lockout chip.
  245.  
  246. To adapt the Sega cartridge reader to the Super Nintendo, just wire
  247. the address lines on the cartridge reader to the proper lines on the
  248. Super Nintendo (i.e. A1 on the Sega goes to A0 on the SNES, A2-Sega
  249. goes to A1-SNES, etc) and the D0-D8 lines on the SNES go to the D0-D8
  250. lines on the cartridge reader.  Line 85 of of READCART.C contains the
  251. code you need to modify in order to convert it to reading Super
  252. Nintendo cartridges.
  253.  
  254. The lockout chip really doesn't do much of anything.  All the Super
  255. Nintendo does is detect its presence.  If the lockout chip is properly
  256. connected, the Super Nintendo will read the cartridge.  If not, it
  257. won't.  You may want to use pullup resistors to tie the inputs/outputs
  258. to the lockout chip high so you don't leave anything floating when you
  259. read the cartridge.
  260.  
  261. The cartridge connector inside the Super Nintendo console consists of
  262. a connector 3 13/16 inches wide using .100 inch contact centers.
  263. There are 62 pins total, but there are 8 pins on either side which are
  264. separated from the 46 pins in the center.  The width of the connector
  265. is roughly the same as a 70 pin solder tail connector so you can use
  266. one of those with a pair of barrier keys to center the cartridge
  267. fingers.
  268.  
  269. If you are looking at the Super Nintendo from the front of the
  270. console, the connector pins towards the front are numbered from
  271. 1 to 31 from left to right and the connector pins towards the rear are
  272. numbered from 32 to 62 from left to right.  Remember that for most
  273. cartridges, only the center 46 pins are used so that the fingers on
  274. the cartridge are numbered from 5 to 27 and from 36 to 58.
  275.  
  276. The pinouts are as follows:
  277.  
  278. 5  - gnd                   36 - gnd
  279. 6  - A11                   37 - A12
  280. 7  - A10                   38 - A13
  281. 8  - A9                    39 - A14
  282. 9  - A8                    40 -
  283. 10 - A7                    41 - A15
  284. 11 - A6                    42 - *OE
  285. 12 - A5                    43 - A19
  286. 13 - A4                    44 - A16
  287. 14 - A3                    45 - A17
  288. 15 - A2                    46 -
  289. 16 - A1                    47 -
  290. 17 - A0                    48 -
  291. 18 -                       49 - *CS
  292. 19 - D0                    50 - D4
  293. 20 - D1                    51 - D5
  294. 21 - D2                    52 - D6
  295. 22 - D3                    53 - D7
  296. 23 - A18                   54 - *WE
  297. 24 - Lockout chip pin 1    55 - Lockout Chip pin 2
  298. 25 - Lockout chip pin 7    56 - Lockout chip pin 6
  299. 26 -                       57 -
  300. 27 - +5                    58 - +5
  301.  
  302. The *CS line of the battery backed up RAM goes active (low) when A18 is
  303. low, A17 is high and pins 26, 46 and 47 of the cartridge connector are high.
  304.  
  305. The best way to make a playback cartridge is to scavange an existing
  306. Super Nintendo cartridge and wiring an adapter to that.  Just desolder
  307. the existing mask ROM and wire in an adapter from the Sega Genesis
  308. playback cartridge.  This way, you already have a lockout chip and
  309. battery backed up RAM already in place.  The schematic is SNES-SCH.
  310.  
  311. The pinouts for the mask ROM are as follows:
  312.  
  313. 1  A19  32 +5
  314. 2  A16  31 *CE
  315. 3  A15  30 A17
  316. 4  A12  29 A14
  317. 5  A7   28 A13
  318. 6  A6   27 A8
  319. 7  A5   26 A9
  320. 8  A4   25 A11
  321. 9  A3   24 *OE
  322. 10 A2   23 A10
  323. 11 A1   22 A18
  324. 12 A0   21 D7
  325. 13 D0   20 D6
  326. 14 D1   19 D5
  327. 15 D2   18 D4
  328. 16 gnd  17 D3
  329.  
  330.  
  331. 6. Conclusion
  332.  
  333. Good luck hacking your Game Medic!
  334. <-> Mr. Turbo '92
  335.