back to the schematics and description

RAVEN

Program Archiving System

Technical Reference Manual

August 20, 1994

Revision 1 : September 4, 1994

Revision 2 : December 14, 1994

Revision 3 : January 15, 1995

US Patent Pending

Michael-Mathies Incorporated

Tallahassee, Florida

Contents:

1.0 Overview
1.0.1 Introduction
1.0.2 Game Cartridges
1.0.3 Gaming Systems\Software
1.0.4 Sega System\Port
1.0.5 Cartridge diagram
1.0.6 New Developments
1.0.6.1 Sega's 32X/DSP Cartridges
1.0.6.2 Piggyback Games
1.0.6.3 Sega's Saturn System
1.0.6.4 Nintendo's U64 System/Other Contenders
2.0 Raven Design Options
2.0.1 Multiple Flash/Ram cartridges
2.0.2 Disk Drive Unit
2.0.3 Computer Based Backup
3.0 Raven Circuit Designs
3.0.1 8088 Basic Design Characteristics
3.0.2 68000 Basic Design Characteristics
4.0 8088 System Internal Programming: Basic Overview
4.0.1 Control Register 00
4.0.2 Status Register 00
4.0.3 Control Register 01
4.0.4 Status Register 01
4.0.5 I/O port Designations

1.0.1 Introduction

Today, there are a number of electronically based home video game systems that a consumer may purchase and install in their home for use. Some system brands include the SEGA Genesis, the Nintendo and Super Nintendo(Super NES) systems, the Atari Jaguar system, and many others. Under most circumstances the companies in this market have more than one system available, each varying from the other in terms of size and capability. In each case, the consumer is required to purchase the initial system, and then subsequently purchase or rent the game programs for that system separately. This makes good sense in that it allows software developers to continually create and sell newer, more intricate game programs. These programs are typically stored on either a 'game cartridge'- a plastic box containing a number of program memory chips, or on a Compact Disc. Which of the two a specific system uses depends on its capabilities. Currently the Compact Disc systems have been hindered by the high prices involved in producing such a setup- hence most of today's prevailing systems are cartridge based.

Personal computer software manufacturers sell software in a form which facilitates the purchaser's ability to create a backup copy of the purchased software program. This is required in that programs on a computer's disk drive or in it's memory are not permanent- software stored in a medium can become corrupt through various means such as static electricity or stray magnetic fields. It is therefore necessary to permit the consumer the legal right to own and/or make back up copies of software he or she has purchased. It is interesting to note then that although this is a widely accepted practice in the computer system software business, it is not in the game computer system software business- Today, there is no reliable method of game cartridge backup available to the consumer. We at Michael-Mathies Incorporated would like to see this change.

1.0.2 Game cartridges

The Raven is a digitally based electronic device which enables the user to place mirror copies of home video games onto blank, erasable-reusable game cartridges. If it were possible to erase and re-write the software on the original game cartridge, the re-usable cartridge would not be necessary. Unfortunately, these cartridges contain ROM (Read Only Memories) chips within them which hold the software and who's memory cannot be erased or the contents thereof altered in any way once assembled and programmed by the chip manufacturer. They are however, susceptible to other content degrading effects such as static electricity, stray magnetic fields, water contamination, etc.. The Raven allows the user to make a backup copy of the game software contained on any ROM cartridge for use when and if the original ROM cartridge becomes corrupt. In fact, it would be beneficial for the avid game user to make copies of all his or her games, playing those games off a Raven cartridge while storing the originals. If the data on a Raven cartridge became corrupt, it could be erased and re-used. If the Raven cartridge was accidentally destroyed, a new copy could be made from the original game cartridge onto a new Raven cartridge.

1.0.3 Game Systems\Software

The software on these cartridges is specific to the game playing device that the cartridge is used in. Some are based on 8-bit (1 byte) coding and some on 16 bit (2 byte) data. A bit is a single binary number, either a 1 or a 0. Combining 4 bits makes a 1/2 byte, and the pattern of these 4 bits represents a number between 0 and 15. By placing two of these together you get a byte representing a number between 0 and 255. Game machines use a number of different microprocessors to operate, each of which has its own specific data coding method. These different methods must be taken under consideration by Michael-Mathies in that each game system will require a version of Raven specially wired to conform to it's coding scheme. Although it is comforting to note that these variations among game systems are usually small. Of these systems, the designs depicted within this text are specific to the Sega Genesis Game System. It uses a 16 bit (2 byte) data coding scheme on it's cartridges which is facilitated by the game software interpreting microprocessor- a Motorola 68000 CPU. This CPU operates at 7.6 MHz and works in conjunction with a Zilog Z80 CPU for sound and backwards compatibility with the precursors of the Genesis system, as well as a number of graphics co-processors used in placing images on the TV screen and generating sound. There are currently two different Genesis systems circulating in the U.S., both of which are basically the same system. The first, and older of the two is the system that was originally released by Sega of America, Inc. The second is an updates version of the first. Major differences include a slightly different chip set within the system and an updated software package which includes a simple illegal cartridge testing scheme. This software based algorithm looks to the memory locations 100hex-103hex in the cartridge memory for the word 'SEGA' and if found continues playing. If however it is not found, the system halts and will not continue with game play. The following listing contains the first 780 bytes of program data from the Genesis game 'Smash TV',

Dumped via the Raven - 
Tuesday, August 23, 1994 12:12 am ******************************* C:\FORTRAN\SEGAGAME\smashtv.bin ******************************* 00000000: 00 00 00 00 00 00 02 00 - 00 00 26 A4 00 00 26 A4 ..........&...&. 00000010: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 00000020: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 00000030: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 00000040: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 00000050: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 00000060: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 00000070: 00 00 26 92 00 00 26 A4 - 00 00 26 9A 00 00 26 A4 ..&...&...&...&. 00000080: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 00000090: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 000000A0: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 000000B0: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 000000C0: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 000000D0: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 000000E0: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 000000F0: 00 00 26 A4 00 00 26 A4 - 00 00 26 A4 00 00 26 A4 ..&...&...&...&. 00000100: 53 45 47 41 20 47 45 4E - 45 53 49 53 20 20 20 20 SEGA GENESIS 00000110: 28 43 29 54 2D 38 31 20 - 31 39 39 32 2E 4D 41 59 (C)T-81 1992.MAY 00000120: 53 4D 41 53 48 20 54 2E - 56 2E 20 20 20 20 20 20 SMASH T.V. 00000130: 20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20 00000140: 20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20 00000150: 53 4D 41 53 48 20 54 2E - 56 2E 20 20 20 20 20 20 SMASH T.V. 00000160: 20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20 00000170: 20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20 00000180: 47 4D 20 54 2D 30 38 31 - 30 36 36 20 30 30 A2 88 GM T-081066 00.. 00000190: 4A 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20 J 000001A0: 00 00 00 00 00 07 FF FF - 00 FF 00 00 00 FF FF FF ................ 000001B0: 20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20 000001C0: 20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20 000001D0: 20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20 000001E0: 20 20 20 20 20 20 20 20 - 20 20 20 20 20 20 20 20 000001F0: 4A 55 45 20 20 20 20 20 - 20 20 20 20 20 20 20 20 JUE 00000200: 4A B9 00 A1 00 08 66 06 - 4A 79 00 A1 00 0C 66 7C J.....f.Jy....f| 00000210: 4B FA 00 7C 4C 9D 00 E0 - 4C DD 1F 00 10 29 EF 01 K..|L...L. ..).. 00000220: 02 00 00 0F 67 08 23 7C - 53 45 47 41 2F 00 30 14 ....g.#|SEGA/.0. 00000230: 70 00 2C 40 4E 66 72 17 - 1A 1D 38 85 DA 47 51 C9 p.,@Nfr...8..GQ. 00000240: FF F8 28 9D 36 80 32 87 - 34 87 01 11 66 FC 74 25 ..(.6.2.4...f.t% 00000250: 10 DD 51 CA FF FC 34 80 - 32 80 34 87 2D 00 51 CE ..Q...4.2.4.-.Q. 00000260: FF FC 28 9D 28 9D 76 1F - 26 80 51 CB FF FC 28 9D ..(.(.v &.Q...(. 00000270: 78 13 26 80 51 CC FF FC - 7A 03 17 5D 00 11 51 CD x.&.Q...z..]..Q. 00000280: FF FA 34 80 4C D6 7F FF - 46 FC 27 00 60 6C 80 00 ..4.L._.F.'.`l.. 00000290: 3F FF 01 00 00 A0 00 00 - 00 A1 11 00 00 A1 12 00 ?............... 000002A0: 00 C0 00 00 00 C0 00 04 - 04 14 30 3C 07 6C 00 00 ..........0<.l.. 000002B0: 00 00 FF 00 81 37 00 01 - 01 00 00 FF FF 00 00 80 .....7.......... 000002C0: 40 00 00 80 AF 01 D9 1F - 11 27 00 21 26 00 F9 77 @...... .'.!&..w 000002D0: ED B0 DD E1 FD E1 ED 47 - ED 4F D1 E1 F1 08 D9 C1 .......G.O...... 000002E0: D1 E1 F1 F9 F3 ED 56 36 - E9 E9 81 04 8F 02 C0 00 ......V6........ 000002F0: 00 00 40 00 00 10 9F BF - DF FF 4A 79 00 C0 00 04 ..@.......Jy.... 00000300: 60 00 23 06 00 08 00 0C - 00 12 00 1A 01 02 03 03 `.#............. 00000310: 04 00 01 02 01 02 03 04 - 03 00 01 04 02 03 01 02 ................ 00000320: 03 04 01 00 02 02 03 04 - 01 01 04 03 02 01 02 00 ................ 00000330: 01 90 17 10 14 50 52 45 - 53 45 4E 54 53 00 01 90 .....PRESENTS... 00000340: 17 13 04 41 17 0F 0F 50 - 52 4F 44 55 43 54 49 4F ...A...PRODUCTIO 00000350: 4E 00 01 17 06 16 4F 50 - 54 49 4F 4E 53 17 06 12 N.....OPTIONS... 00000360: 43 4F 4E 54 52 4F 4C 20 - 3D 20 02 00 00 06 00 1D CONTROL = ...... 00000370: 00 35 80 31 20 50 4C 41 - 59 45 52 20 31 20 43 4F .5.1 PLAYER 1 CO 00000380: 4E 54 52 4F 4C 4C 45 52 - 00 A0 31 20 50 4C 41 59 NTROLLER..1 PLAY 00000390: 45 52 20 32 20 43 4F 4E - 54 52 4F 4C 4C 45 52 53 ER 2 CONTROLLERS 000003A0: 00 90 32 20 50 4C 41 59 - 45 52 53 00 01 17 08 11 ..2 PLAYERS..... 000003B0: 43 4F 4E 54 52 4F 4C 4C - 45 52 20 46 49 52 45 20 CONTROLLER FIRE 000003C0: 42 55 54 54 4F 4E 53 02 - 17 00 14 50 4C 41 59 45 BUTTONS....PLAYE 000003D0: 52 20 31 20 3D 90 17 00 - 17 50 4C 41 59 45 52 20 R 1 =....PLAYER 000003E0: 32 20 3D 00 01 41 3D 00 - 01 20 42 3D 00 01 20 43 2 =..A=.. B=.. C 000003F0: 3D 00 04 02 00 04 00 02 - 02 04 00 00 04 02 02 00 =............... 00000400: 04 00 02 04 00 06 00 0F - 00 19 02 4E 4F 52 4D 41 ...........NORMA 00000410: 4C 20 00 02 90 52 45 56 - 45 52 53 45 00 02 A0 4C L ...REVERSE...L 00000420: 4F 43 4B 20 20 20 00 00 - 00 04 00 08 00 14 00 28 OCK .........( 00000430: 00 00 00 42 00 58 00 42 - 00 00 01 50 01 80 00 64 ...B.X.B...P...d 00000440: 01 2C 00 80 00 00 17 11 - 0B C0 20 47 41 4D 45 0D .,........ GAME. 00000450: 50 41 55 53 45 44 00 17 - 10 08 C0 43 52 45 44 49 PAUSED.....CREDI 00000460: 54 53 20 00 17 0F 0B D0 - 50 52 45 53 53 20 53 54 TS .....PRESS ST 00000470: 41 52 54 0D 54 4F 20 43 - 4F 4E 54 49 4E 55 45 17 ART.TO CONTINUE. 00000480: 10 10 43 52 45 44 49 54 - 53 20 00 17 12 0B D0 47 ..CREDITS .....G 00000490: 41 4D 45 0D 4F 56 45 52 - 00 54 4F 54 41 4C 00 42 AME.OVER.TOTAL.B 000004A0: 4F 4E 55 53 00 00 00 14 - 00 19 00 21 00 2C 00 36 ONUS.......!.,.6 000004B0: 00 41 00 49 00 52 00 5C - 00 67 43 41 53 48 00 54 .A.I.R.\.gCASH.T 000004C0: 4F 41 53 54 45 52 00 41 - 55 54 4F 4D 4F 42 49 4C OASTER.AUTOMOBIL 000004D0: 45 00 53 55 50 45 52 20 - 56 43 52 00 54 45 4C 45 E.SUPER VCR.TELE 000004E0: 56 49 53 49 4F 4E 00 4C - 55 47 47 41 47 45 00 56 VISION.LUGGAGE.V 000004F0: 41 43 41 54 49 4F 4E 00 - 48 4F 4D 45 20 47 41 4D ACATION.HOME GAM 00000500: 45 00 4C 41 57 4E 20 4D - 4F 57 45 52 00 47 4F 4F E.LAWN MOWER.GOO 00000510: 44 20 4D 45 41 54 00 00 - 05 00 00 00 5A 5A 4B 4A D MEAT......ZZKJ 00000520: 10 00 00 00 4C 4F 4D 4B - 09 00 00 00 4B 52 49 53 ....LOMK....KRIS 00000530: 08 00 00 00 4E 45 49 4C - 07 00 00 00 3A 3A 3A 3A ....NEIL....:::: 00000540: 06 00 00 00 46 45 52 47 - 05 00 00 00 41 47 45 43 ....FERG....AGEC 00000550: 04 00 00 00 44 41 4E 46 - 03 00 00 00 54 4F 4D 47 ....DANF....TOMG 00000560: 02 00 00 00 48 4D 4F 20 - 01 00 00 00 17 04 02 22 ....HMO ......." 00000570: 45 4E 54 45 52 20 4E 41 - 4D 45 01 17 03 05 41 20 ENTER NAME....A 00000580: 42 20 43 20 44 20 45 20 - 46 17 03 08 47 20 48 20 B C D E F...G H 00000590: 49 20 4A 20 4B 20 4C 17 - 03 0B 4D 20 4E 20 4F 20 I J K L...M N O 000005A0: 50 20 51 20 52 17 03 0E - 53 20 54 20 55 20 56 20 P Q R...S T U V 000005B0: 57 20 58 17 03 11 59 20 - 5A 20 3E 20 40 20 3F 20 W X...Y Z > @ ? 000005C0: 5B 00 17 08 13 02 00 3E - 40 3F FF 00 00 00 00 A4 [......>@?...... 000005D0: 17 05 02 01 53 4D 41 53 - 48 20 54 3A 56 3A 5D 17 ....SMASH T:V:]. 000005E0: 01 06 01 20 43 4F 50 59 - 52 49 47 48 54 20 31 39 ... COPYRIGHT 19 000005F0: 39 32 0D 02 90 20 20 20 - 20 20 41 43 43 4C 41 49 92... ACCLAI 00000600: 4D 0D 45 4E 54 45 52 54 - 41 49 4E 4D 45 4E 54 3B M.ENTERTAINMENT; 00000610: 20 49 4E 43 17 01 10 01 - 20 20 44 45 56 45 4C 4F INC.... DEVELO 00000620: 50 45 44 20 42 59 0D 02 - A0 50 52 4F 42 45 20 53 PED BY...PROBE S 00000630: 4F 46 54 57 41 52 45 20 - 4C 54 44 00 17 05 02 01 OFTWARE LTD..... 00000640: 53 4D 41 53 48 20 54 3A - 56 3A 5D 17 02 09 01 20 SMASH T:V:].... 00000650: 20 4C 49 43 45 4E 53 45 - 44 20 46 52 4F 4D 0D 02 LICENSED FROM.. 00000660: 80 41 4E 44 20 54 52 41 - 44 45 4D 41 52 4B 20 4F .AND TRADEMARK O 00000670: 46 0D 90 20 20 20 20 57 - 49 4C 4C 49 41 4D 53 01 F.. WILLIAMS. 00000680: 5D 0D 02 90 45 4C 45 43 - 54 52 4F 4E 49 43 20 47 ]...ELECTRONIC G 00000690: 41 4D 45 53 3B 0D 20 20 - 20 20 20 20 49 4E 43 3A AMES;. INC: 000006A0: 00 17 05 02 01 53 4D 41 - 53 48 20 54 3A 56 3A 5D .....SMASH T:V:] 000006B0: 17 02 06 01 20 20 4C 49 - 43 45 4E 53 45 44 20 42 .... LICENSED B 000006C0: 59 0D 02 53 45 47 41 20 - 45 4E 54 45 52 50 52 49 Y..SEGA ENTERPRI 000006D0: 53 45 53 3B 0D 4C 54 44 - 3A 17 01 0D 02 A0 20 20 SES;.LTD:..... 000006E0: 20 46 4C 59 49 4E 47 20 - 45 44 47 45 0D 01 20 49 FLYING EDGE.. I 000006F0: 53 20 41 20 44 49 56 49 - 53 49 4F 4E 20 4F 46 0D S A DIVISION OF. 00000700: 02 90 20 20 20 20 20 41 - 43 43 4C 41 49 4D 0D 45 .. ACCLAIM.E 00000710: 4E 54 45 52 54 41 49 4E - 4D 45 4E 54 3B 20 49 4E NTERTAINMENT; IN 00000720: 43 00 17 01 02 01 50 52 - 4F 47 52 41 4D 4D 45 44 C.....PROGRAMMED 00000730: 20 42 59 0D 02 90 20 20 - 20 20 5A 5A 4B 4A 17 01 BY... ZZKJ.. 00000740: 07 01 47 52 41 50 48 49 - 43 53 20 42 59 0D 02 A0 ..GRAPHICS BY... 00000750: 20 20 20 20 4D 41 52 4B - 20 4B 4E 4F 57 4C 45 53 MARK KNOWLES 00000760: 17 01 0C 01 41 55 44 49 - 4F 20 42 59 0D 02 20 20 ....AUDIO BY.. 00000770: 20 20 4B 52 49 53 41 4C - 49 53 17 01 11 01 50 52 KRISALIS....PR 00000780: 4F 44 55 43 45 44 20 42 - 59 0D 02 90 20 20 20 20 ODUCED BY...

The word 'SEGA' starting at address 100hex is present. This algorithm is of no major concern in the designing of Raven or the re-usable cartridges so long as the backup copy is a 'mirror' copy- where each byte/address matches perfectly.

It is not necessary to know the internal structure of the entire Genesis system in order to make copies of the game cartridges. What must be understood is the pin representations on the cartridge slot, the cartridge wiring itself and any internal structure associated with the slot which would facilitate the offloading of game software. Although most of this hardware is used in downloading game software, some of the capabilities open to the perspective game cartridge manufacturer have yet to be used. Any final design of the Raven should take all of this hardware into account in an effort to prevent future game manufacturers from interfering with the Raven's operations.

1.0.4 Sega Cartridge Port

The following is a pinout of the Genesis game port including all valid information we have found to be true:

A32: ground             B32: CPL
A31: +5 volts DC        B31: unknown
A30: data 11		B30: soft RESET Genesis input
A29: data 3		B29: UDSW 68000 control signal
A28: data 4		B28: LDSW 68000 control signal
A27: data 10		B27: RESET 68000 control signal
A26: data 2		B26: LO_MEM
A25: data 5		B25: data 12
A24: data 9		B24: data 13
A23: data 1		B23: data 14
A22: data 6		B22: data 15
A21: data 8		B21: unknown clock
A20: data 0		B20: DTACK 68000 control signal
A19: data 7		B19: CLK 68000 control signal
A18: ground		B18: AS 68000 control signal
A17: address 0		B17: CE ROM control signal
A16: address 16		B16: OE ROM control signal
A15: address 1		B15: 13.188MHz clock (HS_CLK)
A14: address 15		B14: 16.240KHz clock (HSYNC)
A13: address 3		B13: 60Hz out (VSYNC)
A12: address 14		B12: video signal
A11: address 3		B11: address 22
A10: address 13		B10: address 21
A09: address 4		B09: address 20
A08: address 12		B08: address 19
A07: address 5		B07: address 18
A06: address 11		B06: address 17
A05: address 6		B05: address 9
A04: address 10		B04: address 8
A03: address 7		B03: unknown
A02: + 5 volts DC	B02: hard RESET Genesis input
A01: ground		B01: unknown

SEGA GENESIS CARTRIDGE PORT 

An engineer familiar with the Motorola 68000 would recognize a number of these signals as ones belonging to the 68000. All software on Genesis cartridges is downloaded and interpreted by the 68000. The address lines (address 0-22) are attached directly to the 68000's address bus lines A01-A23. This effectively allows a cartridge size of 223 16-bit words of unique addressing. According to our research, the largest game cartridge out on the market is approx 32 Megbits in size or ranging an address space from 000000hex-1FFFFFhex. (Eternal Champions) A cartridge of this size would require eight 4 Meg flash memories to facilitate a complete copy.

Cartridge data lines are attached directly to the 68000's data bus D0-D15.

Both CE ROM and OE ROM (both inverse logic) connect directly to the ROM chips CE and OE respectively or to other circiutry used in asserting these lines. These lines do not go to the 68000 and are attached to one of the other processors in the Genesis.

Other pins on this port include 3 clock pins, one resonating at 13.188MHz, One at 16.240KHz and pin B19 which feeds the 68000 standard 7.67MHz operating clock. The 13.188MHz is not used by the standard ROM cartridge but has been fed there for use in future applications. It is possibly the operation clock for one of the other co-processors contained within the Genesis. These co-processors are all self contained and unfortunately, labeled only with SEGA designation numbers. Our research has not completely reverse engineered these chips. The 16.240KHz clock signal is most likely associated with video, as is the 60 Hz output.

Also included are the 68000 control signals UDSW, LDSW, RESET, DTACK, and AS. These signals have no use with the standard ROM cartridge but are again accessible for future use. It is possible that some of these signals, such as UDSW, LDSW or DTACK are used in memory selection circuitry in some cartridges, specifically with those that contain RAM(Random Access Memory) for saving game information. Although there are very few of these (approx. 2 or 3) on the market today. These RAM using games will under most circumstances copy and run perfectly well on Raven cartridges but saving game information will not be possible unless a special RAM containing Raven cartridge is developed. It is also possible that each of the few RAM bearing cartridges places it's RAM at different address locations within the 68000's address space. Therefore, a separate cartridge would have to be developed for each game. This is not confirmed however, as we have only found and reverse engineered one of these cartridges. These possibilities should be researched further.

The pin LO_MEM is a simple memory addressing pin. It goes low during addressing operations below 7FFFFFhex.

The hard RESET line can cause a hard reset of the system. This occurs at power up and during, disables the cartridge ROM from the 68000's address space. The internal Genesis ROM contains the Genesis BIOS software. This is responsible for checking for a valid (i.e., does it say 'SEGA' at location 000100hex?) cartridge, presenting the initial onscreen licensing message, enabling the cartridge ROM, and then jumping to the cartridge's entry point. The pin Cartridge Present Low is also used to insure a cartridge is present. If this pin is high, both the cartridge and BIOS ROMs are disabled, leaving the 68000 seeing invalid instructions. Within most cartridges, this line is simply tied to ground.

The soft RESET line will cause a soft reset of the system. This occurs when the reset button is pushed and causes the processor to fetch an initial stack pointer from location 0000000hex-0000003hex, and jumps to the initial IP specified by locations 000004hex-000007hex.

Most of these pins are not used by most of the game cartridges out on the market today. They could, however, be used and controlled by future game programmers and could possibly be used to prevent the use of the Raven for backing up software. It is therefore important to include the capability of upgrading internal Raven software through the use of the external expansion port, and initially giving Raven internal access to all of these pins on the Sega cartridge connector. (possibly through the use of read/write latches tied in as memory registers or I/O ports) This will insure we will have the ability to contend with anything the game manufacturers 'throw at us'. Through software and re-usable cartridge upgrades, we will be able to deal with any future incompatibilities.

The following is an estimate of the memory map of the Genesis system:

$000000 $3FFFFF Cartridge ROM, when enabled by the CPL line.
$000000 $0007FF Internal BIOS ROM, when enabled by the CPL line.
$FF0000 $FFFFFF 64Kbytes scratchpad RAM

$A14101 Cartridge control register-
bit 0 = 0:BIOS enabled
bit 0 = 1:cartridge ROM enabled

Other differences between the first Genesis system and the later updated version are:

- Possibly no cartridge control register
- 'SEGA' at address 100hex-103hex not checked
- Soft and hard RESET lines same

1.0.5 Cartridge diagram

Depending on the size of the cartridge, different wiring schemes will be used by the cartridge manufacturer. The actual internal wiring of the basic lines is of no importance, since all cartridges have to conform to and work with, the Sega Genesis. By conforming in the same fashion in the design of the Raven's ports, we can simply read the data off any cartridge linearly. Depending on the type of chips used in the re-usable cartridges, specific chip selection circuitry will have to be implemented to enable each successive chip in a chain. Fig. 1.0 depicts circuitry which could possibly be used to select between 8-4Megbit flash memories, necessary in the backup of the largest (32Megbit) ROM cartridge. All chips, except the memories, are common inexpensive units.

The selection circuity for multiple chip ROM cartridges is similar. They require multiple chips(i.e., usually 2) simply because producing large memory ROMs is not cost effective. Using smaller ROMs and designing circuitry that can effectively page through the different areas of memory is less expensive. Fig. 2.0 depicts the selection circuitry for the Eternal Champions game cartridge, which makes use of two 16Megbit* ROM chips designated for address spaces 000000-0FFFFFhex and 100000-1FFFFFhex.

* it was unknown at the time of printing whether this cartridge contained 2-16 Megbit ROMs = 32 Megbit / 2-8 Megbit ROMs = 16 Megbit or one of each making it a 24 Megbit card.

1.0.6 New Developments

As of December of 94, there have been a number new releases in terms of add-on hardware for the SEGA Genesis system. As new enhancements arrive on the market it will be the responsibility of Michael-Mathies to insure compatibility between the Raven and these add-ons. Some the of the most important and widely advertised are mention here.

1.0.6.1 Sega's 32X/DSP Cartridges

One of the most significant developments for the Genesis has been the release of the new game cartridges containing the 'FX Chip set'. This new chip set comprises the standard Read Only Memory for containing program data, and a 68000 compatible math co-processing chip contained within the cartridge. A second version of this is the new 32X insert, which attaches to the SEGA Genesis and contains the math co-processor. New game cartridges which make use of this co-processor can then be sold, without the added cost of including the processor in the cartridge.

1.0.6.2 Piggyback Games

Another new development for the SEGA Genesis is the piggyback game cartridge, known as Lockon Technology. In this case, a new game cartridge is purchased that interfaces both with the Genesis and a previously released game cartridge. The new cartridge has two connectors, one for inserting into the Genesis and the other for the older game cartridge. When the game is played, a new character or background is added to the older game. It is interesting to note that like the Game Genie this new cartridge alters and adds to the older program code. Because of the method used, this will most likely allow Raven to detect the new size of the game program, and create a new one cartridge game from the original two. In the case of the Game Genie, changes in the program code would be made permanent on the Raven cartridge also, thereby allowing the consumer to create new games from old.

1.0.6.3 Sega's Saturn System

This new system, recently released in Japan is SEGA's new game machine. Little is known about it's setup as of yet however some key facts have come to light. The Japanese system is CD based with a cartridge peripheral slot. This slot is rumored to be simply an expansion port, and not a game cartridge receptacle. It will allow the Saturn to interface to new adapters which will be developed and released on later dates. Saturn will most likely debut in the US sometime in May, 95 or in Nov./Dec. 95 if software development is lacking by the initial release date.

1.0.6.4 Nintendo's U64 System/Other Contenders

Little is known about the U64 other than it will most likely be cartridge based rather than CD. Sony has come out with a new system called the PS-X, which is CD based. Initial reviews indicate that it is an extremely nice machine.

2.0 Raven Design Options

Depending on the availability and pricing of certain key components, different versions of the basic unit will need to be considered in deciding which will be used as the model for mass production.

2.0.1 Multiple Flash/Ram cartridges

Depending on price and availability, the most appealing design would incorporate a base unit with the capability to make direct, exact copies of game cartridges onto blank, reusable Raven cartridges. The Raven cartridge would make use of a re-programmable memory in storing the game data. In the current prototype an Intel Flash Memory is used as the game data storage medium. The Flash Memory is a relatively new device contained within an integrated circuit package that combines inherent non-volatility with ease of use. These memory chips employ advanced technology and are capable of over one hundred thousand write/erase cycles without any degradation of the data medium. Data storage is permanent after being written and the chips do not require power in order to retain information. The erase process is electrical in comparison to the Electronically Programmable Read Only Memory (EPROM) which requires ultra-violet light to remove data stored in the medium. These characteristics lend themselves to keeping the Raven base unit and it's cartridges simple in design and reliable over extended use.

As an alternative to the Flash Memory, a static or dynamic Random Access Memory (SRAM/DRAM) could be used. These chips come in similar packages to the Flash Memories, have equally reliable performance over extended use, are physically interchangeable with their Flash Memory counterparts, (although cartridges would have to indicate which type of chip was present to the base unit software) and make use of the same read/write/erase interfacing. However these chips would require a battery backup to prevent the loss of data after being disconnected from the base unit. This could easily be accomplished through the use a coin sized battery compartment integrated into the cartridge. For a 4 megabit, SRAM cartridge, the battery lifetime would be approximately 3.0 years*. A small, inexpensive, integral charging capacitor would be used to prevent data loss when the battery was changed. It is interesting to note that in a recent survey of Game Fan Magazine- the publication dedicated to reporting on new game developments, eight out of the thirteen new games reviewed were 16 megabit in size with one 8 megabit and four 32 megabit. Quite obviously larger cartridge sizes are the trend as game manufacturers continue to improve game play by pressing more data onto cartridges.

*(Based on power consumption values for NEC uPD434000G5-10L 524x8 SRAM: Istandby=0.015mA x 12hrs/day x 365 days/year =65.7mAH/year Battery@0-40deg.cel.. Panasonic CR-2032 coin cell lithium battery's capacity=190mAH. (190mAH)/(65.7.0mAH/year) =2.89 years. 8megs would require 1 battery, 16meg - 2, 24meg w/2=approx. 1yr., 24meg w/3=approx. 1.5yrs..)

2.0.2 Disk Drive Unit

As an alternative to the multiple cartridge design, a 3&1/4 inch floppy disk based system could be used. This system would make use of a single Flash Memory or RAM based cartridge with a disk drive integrated into the base unit for storing data. Advantages include the ability to compress and store multiple game data on a single disk. It would also eliminate the need for the consumer to purchase multiple cartridges to store games.

2.0.3 Computer Based Backup

Regardless of the method used to store game data, a home computer can always be used to backup game data. In all the previous designs, a port for communicating with a PC through the parallel printer port would be implemented. This method could also be used as the only method of saving games data, like that of the disk in the disk based system. However, sales would be limited to those with access to a PC.

3.0 Raven Circuit Designs

The initial design of the Raven made use of the Intel 8088 CPU for controlling purposes. The reason for this was it's ease of use/interfacing, versatile support component line of products, and it's ability to withstand the experimentation processes involved in testing a new idea. Future base systems will most likely not be based on the Intel 8088. A more suitable CPU must be used which will interface more accurately with the data contained on most game cartridges. Michael-Mathies is therefore working with the Motorola 68000 CPU in designing a circuit to be used in the commercially produced system. The advantages of this processor over the 8088 based prototype include reduced component numbers, increased speed, readily available stock of the 68000, interface compatibility with the SEGA Genesis and Atari Jaguar systems, and the use of a gaming industry standard CPU. A 68000 prototype circuit is included with this manual.

3.0.1 8088 Basic Design Characteristics

The 8088 system is based on the idea that the cartridges should be completely isolated from the CPU of the system and that all data during a copy process will pass between the carts and not through the CPU. Since the 8088 does not have the proper number of address pins to facilitate accessing a game cartridge, a set of Binary up/down counters(IC18-23) are used to create the address values present at the two cart ports. Data can then be transferred directly from one cartridge to another, without the 8088 having to read from one and transfer to another. The process is controlled and monitored through a set of registers(IC8-11, IC15-16), written to as I/O ports in the 8088 address space. All control registers are written to using byte wide data which is held in 8 bit latches. The status of some of these lines as well as those involved in the PC interface can also be read, through the use of 8 bit buffers(IC8-11, IC15-16) tied into the appropriate lines. The buffers are also accessed through I/O routines in the 8088 programming.

The 8088 can however access the data on the cartridges through 8 bit buffers/latches(IC26-29) which monitor the data lines between the two cartridges. Such a process is used when data is either read off a cartridge and transferred to the PC interface, or vice versa. Care must be taken to insure that the address counters are currently outputing the wanted address location within the cartridge address space. To insure that this is so, the counter generated address bus is also monitored through 8 bit buffers(IC30-32) tied to the appropriate lines. These and the data read buffers/data write latches are accessed through I/O locations.

PC communication with the 8088 is made possible through a complex set of handshaking signals and 8 bit data transfer. Current software makes use of checksum error checking after a predetermined block of data has been transferred. Both devices generates checksums and parity which are compared at specific block lengths to insure uncorrupted data transfer.

3.0.2 68000 Basic Design Characteristics

The 68000 system is much like that of the 8088 in that the CPU is isolated from the cartridge memories through a set of latches/buffers. Since the cartridges address space can be equal to or less than that of the 68000 there is no assured safe area of memory to place the 68000 RAM and programming. Therefore, the cartridge's address bus is created by having the 68000 write data to a specific memory location. This address data is then loaded into a set of 8 bit latches(IC11-13). Cartridge data is transferred first to the 68000 through 8 bit buffers(IC18-21), then loaded into 8 bit latches(IC14-17) that have they're output connected to the opposite cartridges data bus lines. Since the 68000 based system works entirely with data that is 16 bits in length, as opposed to 8 bits as in the 8088 system, the circuit is more streamline. This configuration also allows for a lower number of parts. Control is again maintained through a set of registers/latches(IC22-23,IC26) and status buffers(IC24-25).

4.0 8088 Programming: Basic Overview

The internal programming held on the internal memory fills the address space of 00000hex-1FFFFhex. The NEC uPD4368 static RAM fills the address space of 20000hex-27FFFhex and is used primarily for stack memory and scratchpad RAM. The placing of the program memory starting at base address zero facilitates the use of the artificially created jump statements through jump chips. The Initial jump statement, hardwired into memory locations FFFF0hex-FFFF5hex initiates a jump to 0C000hex. At this point, the stack pointer is set to 20100hex so that stack listings will be built in addresses ascending from that point. Memory areas 20000hex-200FFhex are designated as scratchpad RAM for use in storing data and variables. Registers are cleared as well as the interrupt flag, and then a jump is executed to the entry point of the Raven software- 00400hex. An interrupt vector table has also been set up and stored in memory locations 00000hex-0003FFhex. Depending on whether the auxiliary port is installed these addresses point to either the interrupt interpreter or location 00400hex. Upon entry at 00400hex, the software begins polling the various input sources for a change and upon detecting a key press, auxiliary port cartridge or printer port connection, jumps to the appropriate software routine.

4.0.1 Control Register 00

Control Register 00 bit representation

Bit 7 6 5 4 3 2 1 0
Description rom port output enable rom port CE & OE pins raven port OE pin raven port CE pint raven port WR pin raven port DATA07 counter reset clock pulse
Active low low low low low low low lowhigh trans.

Description: This control regaister controls most of the input and output of the two cartridge ports. It also contains the counter control bits which control the address bus generation counters for both cartridges. The data bus lines between the two cartridges are buffered with two SN74LS245N 3-state octal transceivers whose output must be enabled for the rom port data to reach the raven port pins. This output is controlled with bit 7. The entire port may be written to by an out 00,AL, byte wide output instruction.

rom port output enable: this input controls the two 74LS245 transceivers that buffer the cartridge data lines 0-16. must be active for valid ROM data at raven port data bus. Active low.

rom port CE and OE: This bit controls the output line leading to the Chip Enable and Output Enable lines of the rom cartridge port. Active low for most ROM cartridges.

raven port CE: this bit controls the output line leading to the Chip Enable of raven cartridge port. Active low.

raven port OE: same as above except connection is made to Output Enable. Active low.

raven port WR: This bit controls the output line leading to the WRite line leading through the auxiliary cartridge connector, along with the 12volt programming line. For Intel's 28F400BX 4 MBit flash memory- addresses are latched on falling edge and data is latched on rising edge. For more information and Flash memory timing specifics see the Intel Memory Products catalog.

raven port DATA07: This bit controls the Output Enable of the command latch written to through I/O port 02. This line must be toggled low after a command is written to the Intel Flash memory Command User Interface(CUI) at port 02 and before the WR line is toggled. Otherwise the data lines 0-7 connected to the raven port will not be valid. For more information on writing to the Intel CUI see the Intel Memory Products catalog.

counter reset: This bit controls the line connected to the MR (active low) line of the address bus counters. All counters are SN74LS161AN counters and the timing of this and CP follow there specifications.

clock pulse: This bit controls the line connected to the CP line of the 161 counters.(see above) Active low.

4.0.2 Status Register 00

Status Register 00 bit representation

Bit 7 6 5 4 3 2 1 0
Description rom port output enable rom port CE & OE pins raven port OE pin raven port CE pint raven port WR pin raven port DATA07 counter reset clock pulse

The status register 00 emulates that of it's corresponding control register. All bit values of the control register can be read by inputing the same I/O address. A suitable command would be to use the IN AL,00 I/O command. This register is primarily used by the Slave Command Interpreter when writing to control register 00. All bit changes within each command are masked with existing, un-used bit values.

4.0.3 Control Register 01

Control Register 01 bit representation

Bit 7 6 5 4 3 2 1 0
Description OE out RS data815 OE busy ack select oop error
Cabl. Pin n/a n/a n/a 11 10 13 12 15

Description: The control register 01 is the primary printer control register. It's contents can be written to to control the states of the different control lines of the Centronics 36 pin male connector. The pin designations on this connector are listed for reference. This register is primarily used in the control of data transfers between PC computers and and the Raven. Note: not all signals are associated with the printer interface, data815 OE is associated with the data latches connected to the raven port data lines 8-15.

OE out: This line controls the Output Enable of the printer port data latch written to at I/O location 0C. This line must be toggle low making the data valid on the printer interface data bus lines 0-7.

RS: Register Select is used in controlling the input/output of the LCD display.

data815OE: This line controls the Output Enable line of the data815W latch. (seebelow) It must be inactive (high) during ROM port to raven portprogramming operations and active during write operations involving the printer interface.

busy: controls the state of the BUSY interface line.

ack: controls the state of the Printer ready (ACKnowledge) line.

select: controls the state of the Device Selected (SELECT) line.

oop: controls the state of the device Out Of Paper interface line.

error: controls the state of the device ERROR interface line.

4.0.4 Status Register 01

Status Register 01 bit representation

Bit 7 6 5 4 3 2 1 0
Description n/a n/a n/a n/a ATTention INPut INITialize Autofd
cabl pin.         1 17 16 14
Logic         inverse inverse normal inverse

Description: Status register 01 is the primary printer status register. Lines on the printer port, controlled by the host PC can be checked through reading this register. This register is used primarily for data transfer between PC computers and the Raven.

ATT: reflects the status of the STROBE interface line.

INP: reflects the status of the SELect input interface line.

INIT: reflects the status of the INITialize interface line.

autofd: reflects the status of the autofd interface line. This pin is the main control line of the interface. It is forcibly held high with a 20K Ohm pullup resistor. This line is continually polled for a low state by the BIOS software and when active, causes the raven to enter the slave mode. The Slave Command Interpreter (SLC) interprets and executes commands handed down from the host PC.

4.0.5 I/O Port Designation

I/O port designations and names

address read/write? name:
00 read:

write:

status resister 00

control register 00

01 write: latched display
02 write:

read:

CUI latch

CUI buffer

03 read: address bus-middle
04 read: address bus-high
05 n/a n/a
06 read: keyboard
07 read: address bus-low
08 read:

write:

data815R

data815W

09 write: control register 01
0A read: status register 01
0B read: printer port data0-7 buffer(PPDB07)
0C write: printer port data0-7 data latch(PPDL07)

status register 00: see above section on this topic

control register 00: see above section on this topic

latched display: This port can be written to with byte wide data. The display is a self contained, LCD display with LED backlighting built in.

CUI latch: The CUI latch is written to with byte wide data. It's Output Enable line is tied to the control register 00 bit # 2. Care must be taken that no two data line output devices are enabled at one time. The OE line (control register 00 bit#5) for the raven port must be at a high state as well as the OE line (control register bit#7) of the data bus 74LS245 buffers before enabling this output. Once enabled, the Flash memory CUI command byte can be read by the raven cartridge on data lines 0-7. !IMPORTANT: the OE bit must be set high prior to reading the output valuesof the CUI buffer. These two work independently and one does not effect thestate of the other. This latch is also used to hold the lower 7 bits of data during upload+write procedures involving a personal computer attached to the printer interface.

CUI buffer: The CUI buffer is a general purpose buffer attached to data lines 0-7. Not only can this buffer be used to read status bytes during program/erase procedures involving the Intel Flash memory, it is also used to read the lower 7 data bits of ROM data during software downloads through the printer interface. Note that during this procedure, the OE of the 74LS245 data bus buffers must be active(low) since the input lines of the CUI buffer are attached to the Raven port side of data bus.

address bus-middle: This read only buffer allows access to the middle (hex (x-5)xFFxx) address byte of the full cartridge address bus. This bus, which is generated by the 74LS161 counter chips, is 23 bits wide. the address bus-middle buffer reads the states of bits 09-16. address bus-high: This read only buffer allows access to the high (hex 3Fxxxx) address byte of the full cartridge address bus. This bus, which is generated by the 74LS161 counter chips, is 23 bits wide. the address bus-high buffer reads the states of bits 17-23.

keyboard: This read only buffer allows access to the states of the keypads on the keyboard input. 3 possible keys can be pressed on this prototype.

address bus-low: This read only buffer allows access to the low (hex (x-5)xxxFF) address byte of the full cartridge address bus. This bus, which is generated by the 74LS161 counter chips, is 23 bits wide. the address bus-low buffer reads the states of bits 01-08.

data815R: The data815R buffer is a general purpose buffer attached to data lines 8-15. It is used to read the upper 7 data bits of ROM data during software downloads through the printer interface. Note that during this procedure, the OE of the 74LS245 data bus buffers must be active(low) since the input lines of the data815 buffer are attached to the Raven port side of data bus.

data815W: the data815W latch is a general purpose latch used in write operations to the raven port during printer interface software downloads. During write operations, the upper 8 data bits of the data bus must be loaded into this latch. Care must be taken to insure no two devices have valid data on the data lines at any particular time. This latch is independent of the 74LS245 data bus buffers placed between the two ports. These buffers must be inactive to insure proper data line states during write operations involving the data815W latch.

control register 01: see above section on this topic.

status register 01: see above section on this topic.

PPDB07: This 8 bit buffer allows access to the data held on the 8 bit data bus of the printer interface. The buffer is actually an SN74LS373N 3-state octal transparent latch with it's Enable line help low with a 20K pull down resistor. This E line is connected to the STROBE input line and data is automatically latched through PC software control. The latch's bit status can then be read at any time using this register, which controls the Output Enable line of the 373. Note: this buffer is only 1 byte deep, and subsequent writes from the PC via the STROBE line will erase and replace existing data.

PPDL07: This 8 bit write only latch is loaded with any write operation to it's address. The data is not placed on the printer interface data lines 0-7 until bit 7 of the control register 01 is asserted. (active low) This bit controls the Output Enable line of the PPDL07 latch. Care must be taken to insure that data is not placed on the printer interface data lines by both the PC and Raven. Possible future implementations would change this output control to the PC.

Bios Listing

(No listing available. I could download it off the chip. But that would be alot of work. Email me if your interested.)

Fortran code used in downloading cartridge ROM's to PC through printer port

C	Compiled with Microsoft Fortran 5.1
C	with the use of NOLIMIT's extension NOLIMIT4.0 Extension Library	
C	Written by:	Jim Mathies
C	Platform: IBM 486DX2
C	Operating env.:	DOS.exe executable






include 'fgraph.fi'
integer*4	low,high,error,addrl,addrm,addrh
integer*4	command,myaddr
integer*4	a,b,x,i,size,err
integer*4	chkflagt,chksuml,chkcount,chkflago,chksumh
character*10	name
character*30	buffer
character*2	meg
character*9	count
character*1	inpt
character*80	hold
real*4	calc
call clsatt(30)
44	call portot(888,0,0)
call portot(890,0,2#0000000)
call screen(inpt)
if(inpt.eq.'1') goto 99
if(inpt.eq.'2') goto 999
if(inpt.eq.'3'.or.inpt.eq.'0') then
call portot(888,0,0)
call portot(890,0,2#0000000)
return
endif



99	b=0
c	call clsatt(30)
do a=12,16
call putcur(a,5,0,error)
call wchars(0,
&	' '
&	// ' '
&	,70,15,3,0,error)
enddo
!---------shadow-----------
call putcur(13,75,0,error)
call wchars(0,
&	hold,2,0,0,0,error)
call putcur(14,75,0,error)
call wchars(0,
&	hold,2,0,0,0,error)
call putcur(15,75,0,error)
call wchars(0,
&	hold,2,0,0,0,error)
call putcur(16,75,0,error)
call wchars(0,
&	hold,2,0,0,0,error)
call putcur(17,6,0,error)
call wchars(0,
&	hold,71,0,0,0,error)
call putcur(13,6,0,error)
call wchars(0,
&	'Enter full name of game: ' ,
&	25,15,3,0,error)
call putcur(13,31,0,error)
call lnebuf(name,error,10,30,1)
call putcur(14,6,0,error)
call wchars(0,
&	'Length in Meg(4,8,16,24,(R)ead from raven): ' ,
&	44,15,3,0,error)
call putcur(14,50,0,error)
call lnebuf(meg,error,2,30,1)
c	if(meg.eq.'4') then
size=(16#3FFFF)*2
c	endif
call settextwindow(12,5,14,75)
call filstg(hold,80,' ',1)
call putcur(12,5,0,error)
call wchars(0,
&	' Program: Length: Transt: Messages: '
&	// ' '
&	,70,15,3,0,error)
call putcur(13,5,0,error)
call wchars(0,
&	' '
&	// ' '
&	,70,15,3,0,error)
call putcur(14,5,0,error)
call wchars(0,
&	' '
&	// ' '
&	,70,15,3,0,error)
call putcur(14,36,0,error)
call wchars(0,
&'chksums:'
&	,8,15,3,0,error)
call putcur(15,5,0,error)
call wchars(0,
&	' computer: raven: blocks'
&	// 'ize: '
&	,70,15,3,0,error)
call putcur(16,5,0,error)
call wchars(0,
&	' '
&	// ' '
&	,70,15,3,0,error)
!boxes
call settextwindow(13,6,13,26)
call wchars(0,
&	hold,21,0,0,0,error)
call settextwindow(13,28,13,34)
call wchars(0,
&	hold,7,0,0,0,error)
call settextwindow(13,36,13,42)
call wchars(0,
&	hold,7,0,0,0,error)
call settextwindow(13,44,13,74)
call wchars(0,
&	hold,30,0,0,0,error)
call settextwindow(15,15,15,26)
call wchars(0,
&	hold,13,0,0,0,error)
call settextwindow(15,39,15,50)
call wchars(0,
&	hold,13,0,0,0,error)
call settextwindow(15,70,36,74)
call wchars(0,
&	hold,4,0,0,0,error)


c----------control section---------------c

call portot(890,0,2#0000010)
! Taking control
1	call portin(889,0,x)
! look for Acknoledge (looking for error transition H-L)
y=2#00001000
x=iand(x,y)
call settextwindow(13,44,13,74)
call wchars(0,
&	'L o o king for error low '
&	,30,7,0,0,error)
if (x.ne.0) goto1
call settextwindow(13,44,13,74)
call wchars(0,
&	'Acknowledged '
&	,30,15,0,0,error)
call waster (1.0)
!erase memories
call settextwindow(13,44,13,74)
call wchars(0,
&	'clearing memory '
&	,30,7,0,0,error)
call internal(09,err)
if(err.ne.0) goto 672
call waster (.5)
!clear stack pointer
call settextwindow(13,44,13,74)
call wchars(0,
&	'clearing stack pointer '
&	,30,7,0,0,error)
call internal(08,err)
if(err.ne.0)goto 673
call waster ( .5)
!reset counters
call settextwindow(13,44,13,74)
call wchars(0,
&	'reseting counters '
&	,30,7,0,0,error)
call internal(01,err)
if(err.ne.0)goto 674
call waster( .5)



c	call sendword(10,255,04)
c	call waster(1)
c	!set checksum to 10 bytes
21	call portin(889,0,x)

! look for Acknoledge (looking for error transition H-L)

y=2#00001000
x=iand(x,y)
call settextwindow(13,44,13,74)
call wchars(0,
&	'L o o king for error low '
&	,30,7,0,0,error)
if (x.ne.0) goto21
call settextwindow(13,44,13,74)
call wchars(0,
&	'Acknowledged first error check '
&	,30,15,0,0,error)
open (2,file=name//'.bin',status='unknown',form='binary',
&	access='direct',recl=1)
buffer=name // '.bin '
call justl(buffer,30,error)
call settextwindow(13,6,13,26)
call wchars(0,
&	buffer
&	,20,7,0,0,error)
write(buffer,'(i7)')size
call settextwindow(13,28,13,34)
call wchars(0,
&	buffer,7,7,0,0,error)
call settextwindow(15,70,36,74)
call wchars(0,
&	'1275',4,7,0,0,error)
call settextwindow(13,44,13,74)
call wchars(0,
&	'Checking address values... '
&	,30,15,0,0,error)
call waster(.3)
call readbyte(06,addrm,a,err)
call readbyte(05,addrl,a,err)
call readbyte(07,addrh,a,err)
write(buffer,'(a5,z7,a1)')'high:',addrh,'?'
call settextwindow(13,44,13,74)
call wchars(0,
&	buffer
&	,30,15,0,0,error)
call waster(0.3)
if(addrh.ne.0)goto 666
write(buffer,'(a5,z7,a1)')'mid :',addrm,'?'
call settextwindow(13,44,13,74)
call wchars(0,
&	buffer
&	,30,15,0,0,error)
call waster(0.3)
if(addrm.ne.0)goto666
write(buffer,'(a5,z7,a1)')'low :',addrl,'?'
call settextwindow(13,44,13,74)
call wchars(0,
&	buffer
&	,30,15,0,0,error)
call waster(0.3)
if(addrl.ne.0)goto 666

myaddr=0
a=1
c---------------Main Loop----------------------c
call settextwindow(13,44,13,74)
call wchars(0,
&	'Uploading... '
&	,30,15,0,0,error)
call waster(1.0)
chksum=0
chkcount=0
10	call readbyte(03,low,chkflago,err)
if(err.ne.0)goto 676
call readbyte(04,high,chkflagt,err)
if(err.ne.0)goto 677
c-------------Check sum routines------------------c
if(chkflago.ne.chkflagt) goto 668
if(chkflago.eq.1) then
chkflago=0
chkflagt=0
if(chkcount.ne.16#4ff)	goto 667
chkcount=0
chksuml=iand(chksuml,2#11111111)
chksumh=iand(chksumh,2#11111111)
write(buffer,'(a1,i4)')'>',(chksuml+chksumh)
call settextwindow(15,23,15,26)
call wchars(0,
&	buffer,5,15,0,0,error)
write(buffer,'(i13)')(low+high)
call settextwindow(15,39,15,50)
call wchars(0,
amp;	buffer,13,7,0,0,error)
if(low.ne.chksuml)goto669
if(high.ne.chksumh) goto670
chksuml=0
chksumh=0
goto 10
else
chksuml=chksuml+low
chksumh=chksumh+high
endif
chkcount=chkcount+1
c--------writing bin file two bytes---------------c
write(2,rec=(a))high
write(2,rec=(a+1))low

c----------check for address corelation----------------------c
call readbyte(05,addrl,x,err)
if(err.ne.0)goto 678
if(iand(myaddr,16#0000FF).ne.addrl)goto 671
if(addrl.eq.255)then
call readbyte(07,addrh,x,err)
if(err.ne.0)goto 679
call readbyte(06,addrm,x,err)
if(err.ne.0)goto 680
if(ishl(iand(myaddr,16#FF0000),-16).ne.addrh)goto 6712
if(ishl(iand(myaddr,16#00FF00),-8).ne.addrm)goto 6711
write(buffer,'(i7)')(chksuml+chksumh)
call settextwindow(15,15,15,22)
call wchars(0,
&	buffer,7,7,0,0,error)

calc=real(addrm)/4
if (calc.eq.int(calc)) then
call settextwindow(13,36,13,42)
write(count,'(i7)')a
call wchars(0,
&	count,7,15,0,0,error)
endif
if(addrh.eq.16#03.and.addrm.eq.16#FF.and.
&	addrl.eq.16#FF)then
call settextwindow(13,44,13,74)
call wchars(0,
&	'upload complete '
&	,30,15,0,0,error)
call settextwindow(13,36,13,42)
write(count,'(i7)')a
call wchars(0,
&	count,7,15,0,0,error)
call portot(888,0,0)
call portot(890,0,2#0000000)
write(2,rec=(a+2))
&	'(C)1994Raven Patent Pending(Aug 1994) '
&	//'Michael-Mathies Incorporated '
&	//'Backup v1.0 '
close(2,status='keep')
goto 44
endif

c-------all finished now displaying---------------c
call settextwindow(13,44,13,74)
call wchars(0,
&	'no errors acknowledged '
&	,30,7,0,0,error)
endif
! 02=inc counter
call internal(02,err)
if(err.ne.0)goto 675
a=a+2
myaddr=myaddr+1
goto 10
666	call settextwindow(13,44,13,74)
call wchars(0,
&	'Error- address fail to match '
&	,30,15,0,0,error)
goto 690
667	call settextwindow(13,44,13,74)
call wchars(0,
&	'Error- checksum framing '
&	,30,15,0,0,error)
write(*,'(z6)')chkcount
goto 690
668	call settextwindow(13,44,13,74)
call wchars(0,
&	'Error-low/high byte frame size'
&	,30,15,0,0,error)
write(*,*)' '
write(*,'(i2,i2,z4)') chkflago,chkflagt,chkcount
goto 690
669	call settextwindow(13,44,13,74)
call wchars(0,
&	'Error-low chksum unequal '
&	,30,15,0,0,error)
goto 690
670	call settextwindow(13,44,13,74)
call wchars(0,
&	'Error-high chksum unequal '
&	,30,15,0,0,error)
goto 690
671	call settextwindow(13,44,13,74)
call wchars(0,
&	'Error-address match failure L '
&	,30,15,0,0,error)
write(*,'(a1,z6,a1,z2,z2,z2)')'|'
&	,myaddr,'|',addrh,addrm,addrl
goto 690
6711	call settextwindow(13,44,13,74)
call wchars(0,
&	'Error-address match failure M '
&	,30,15,0,0,error)
write(*,'(a1,z6,a1,z2,z2,z2)')'|'
&	,myaddr,'|',addrh,addrm,addrl
write(*,*) ' '
write(*,'(a1,z6,a1,z6,a1,z6)')'|',(ishl(iand(myaddr,16#FF00),
&	-8)),'|',addrm,'|',iand(myaddr,16#FF00)
goto 690
6712	call settextwindow(13,44,13,74)
call wchars(0,
&	'Error-address match failure F '
&	,30,15,0,0,error)
write(*,'(a1,z6,a1,z2,z2,z2)')'|'
&	,myaddr,'|',addrh,addrm,addrl
goto 690
672	write(buffer(1:),'(a21,i1)')'timeout errcd-int09.0',err
call wchars(0,buffer,30,15,0,0,error)
goto 690
673	write(buffer(1:),'(a21,i1)')'timeout errcd-int08.0',err
call wchars(0,buffer,30,15,0,0,error)
goto 690
674	write(buffer(1:),'(a21,i1)')'timeout errcd-int01.1',err
call wchars(0,buffer,30,15,0,0,error)
goto 690
675	write(buffer(1:),'(a21,i1)')'timeout errcd-int01.2',err
call wchars(0,buffer,30,15,0,0,error)
goto 690
676	write(buffer(1:),'(a21,i1)')'timeout errcd-int0b.L',err
call wchars(0,buffer,30,15,0,0,error)
goto 690
677	write(buffer(1:),'(a21,i1)')'timeout errcd-int0b.H',err
call wchars(0,buffer,30,15,0,0,error)
goto 690
678	write(buffer(1:),'(a21,i1)')'timeout errcd-int0L.0',err
call wchars(0,buffer,30,15,0,0,error)
goto 690
679	write(buffer(1:),'(a21,i1)')'timeout errcd-int0H.0',err
call wchars(0,buffer,30,15,0,0,error)
goto 690
680	write(buffer(1:),'(a21,i1)')'timeout errcd-int0M.0',err
call wchars(0,buffer,30,15,0,0,error)
goto 690
690	call waster(1.0)
call portot(888,0,0)
call portot(890,0,2#0000000)
close (2,status='delete')
goto 44

999 end


subroutine screen(inpt)
integer*4 error,x,Q,W,E,R,cha,keycde,nchr
character*1 inpt
Q=4
W=3
E=3
R=3
dox=5,10
call putcur(x,20,0,error)
call wchars(0,
&	' '
&	,37,15,3,0,error)
enddo
call putcur(11,21,0,error)
call wchars(0,
&	' '
&	,37,0,0,0,error)
call putcur(6,57,0,error)
call wchars(0,' ',1,0,0,0,error)
call putcur(7,57,0,error)
call wchars(0,' ',1,0,0,0,error)
call putcur(8,57,0,error)
call wchars(0,' ',1,0,0,0,error)
call putcur(9,57,0,error)
call wchars(0,' ',1,0,0,0,error)
call putcur(10,57,0,error)
call wchars(0,' ',1,0,0,0,error)

10	call putcur(6,25,0,error)
call wchars(0,
&	'1: Upload a file from Raven',
&	27,15,Q,0,error)
call putcur(7,25,0,error)
call wchars(0,
&	'2: Download a file to Raven',
&	27,15,W,0,error)
call putcur(8,25,0,error)
call wchars(0,
&	'3: Exit program ',
&	27,15,E,0,error)
call putcur(9,25,0,error)
call wchars(0,
&	'4: Size cartridge ',
&	27,15,R,0,error)

11	call putcur(10,37,0,error)
call inkey(cha,keycde,nchr)
if(nchr.gt.0)then
if(cha.eq.13)then
if(q.eq.4)then
inpt='1'
elseif(w.eq.4)then
inpt='2'
elseif(e.eq.4)then
inpt='3'
elseif(r.eq.4)then
inpt='4'
endif
return
endif
if(char(cha).eq.(char(27))) then
inpt='0'
return
endif
if(keycde.gt.0.and.keycde.lt.5)then
inpt=char(cha)
return
endif
if(keycde.eq.80)then
if(q.eq.4)then
w=4
q=3
elseif(w.eq.4)then
e=4
w=3
elseif(e.eq.4)then
r=4
e=3
elseif(r.eq.4)then
q=4
r=3
endif
endif
if(keycde.eq.72)then
if(q.eq.4)then
r=4
q=3
elseif(w.eq.4)then
q=4
w=3
elseif(e.eq.4)then
w=4
e=3
elseif(r.eq.4)then
e=4
r=3
endif
endif
goto 10
endif
goto 11
return
end


subroutine sendword(command,wordl,wordh)

integer*4 command,wordl,wordh,x,y



call portot(890,0,2#00000010)

! direction out

call portot(888,0,command)

call portot(890,0,2#00000011)

! Strobe (latch line) high = E pin on 74LS373

c	write(*,*) 'command should be latched now, strobe high'

call portot(890,0,2#00000110)

! Direction out, Strobe low, init high

! error will go high on reciept, command will be interpreted and

! raven will jump to required subroutine. command loop will

! initiate.

c Status register bit information c

c of the raven port address 0Ah

c

c	7 6	5 4	3 2	1 0

c	O -	- b	A s	o e

c	E	u	C e	o r

c	s	K l	p r

c	y	e	o

c	c	r

c	t

c

c

c Status register bit information c

c of the parallel printer port c

c 379h, 889 Decimal address

c

c	7 6	5 4	3 2	1 0

c	B A	o s	e -	- -

c	u C	o e	r

c	s K	p l	r

c	y	e	o

c	c	r

c	t

c

10	call portin(889,0,x)

! look for Acknoledge error =H

y=2#00001000

x=iand(x,y)

c	write(*,'(a1,i4,\)') '=',x

if (x.eq.2#00001000) goto20

goto 10

c command is loaded off of port before error goes high so,

c raven is waiting for init low to read low byte

20	call portot(888,0,wordl)

call portot(890,0,2#00001010)

! select = h,init = l

c raven reads data nd stores, then sends oop and error and busy high

c and waits for init H

call portin(889,0,x)

! look for Acknoledge error =H and oop =h busy =h

y=2#00101000

x=iand(x,y)

c	write(*,'(i4,\)') x

if (x.eq.2#00101000) then

goto 30

endif

goto 20

30	call portot(888,0,wordh)

call portot(890,0,2#00001110)

!init =h, selectin=high





768	call portin(889,0,x)

! look for Acknoledge (looking for error transition H-L)

y=2#00001000

x=iand(x,y)

c	write(*,*) 'l o o king for error low'

if (x.ne.0) goto768

! Command executed... go on to next

call portot(890,0,2#00001010)

! Selectin high, Direction out, init =low

! raven is looking at select in for low transition

call portot(890,0,2#00000010)

!select in low

return

end



subroutine internal(command,err)

integer*4 x,y,command,err

real*4 diff

integer*2 ih,im,is,ihs,ih1,im1,is1,ihs1

err=0



call portot(890,0,2#00000010)

! direction out

call portot(888,0,command)

call portot(890,0,2#00000011)

! Strobe (latch line) high = E pin on 74LS373

call portot(890,0,2#00000110)

! Direction in, Strobe low, init high

call portot(890,0,2#00001110)

call portot(890,0,2#00001110)

! select high

call gettim (ih,im,is,ihs)

7	call gettim (ih1,im1,is1,ihs1)

if ( ih1 .lt. ih ) ih1 = ih1 + 24

diff=(ih1-ih)*3600.+(im1-im)*60.

& + float((is1-is)) + float((ihs1-ihs))/100.

if(diff.ge.3.0) then

err=1

return

endif

call portin(889,0,x)

! look for Acknoledge (looking for error l)

y=2#00001000

x=iand(x,y)

if (x.ne.0) goto7

! Command executed... go on to next

call portot(890,0,2#00001010)

! Init low

call portot(890,0,2#00000010)

! Selectin low, Direction out

call gettim (ih,im,is,ihs)

767	call gettim (ih1,im1,is1,ihs1)

if ( ih1 .lt. ih ) ih1 = ih1 + 24

diff=(ih1-ih)*3600.+(im1-im)*60.

& + float((is1-is)) + float((ihs1-ihs))/100.

if(diff.ge.3.0) then

err=2

return

endif

call portin(889,0,x)

! look for Acknoledge (looking for error transition H-L)

y=2#00001000

x=iand(x,y)

if (x.ne.0) goto767

return

end











subroutine readbyte(command,byte,flag,err)

integer*4 x,y,i,command,err

real*4 diff

integer*2 ih,im,is,ihs,ih1,im1,is1,ihs1

integer*4 byte,flag

flag=0

err=0

call portot(890,0,2#00000010)

! direction out

call portot(888,0,command)

call portot(890,0,2#00000011)

! Strobe (latch line) high = E pin on 74LS373

c	write(*,*) 'command should be latched now, strobe high'

call portot(890,0,2#00000010)

call portot(890,0,2#00000010)

! Strobe low

call portot(890,0,2#00100010)

! direction in, init high

call portot(890,0,2#00100110)

call portot(890,0,2#00100110)

call portot(890,0,2#00100110)

!error will go high on reciept

c	write(*,*) 'looking for error=h oop=H'

c Status register bit information c

c of the raven port address 0Ah

c

c	7 6	5 4	3 2	1 0

c	O -	- b	A s	o e

c	E	u	C e	o r

c	s	K l	p r

c	y	e	o

c	c	r

c	t

c

c

c Status register bit information c

c of the parallel printer port c

c 379h, 889 Decimal address

c

c	7 6	5 4	3 2	1 0

c	B A	o s	e -	- -

c	u C	o e	r

c	s K	p l	r

c	y	e	o

c	c	r

c	t

c

call gettim (ih,im,is,ihs)

7	call gettim (ih1,im1,is1,ihs1)

if ( ih1 .lt. ih ) ih1 = ih1 + 24

diff=(ih1-ih)*3600.+(im1-im)*60.

& + float((is1-is)) + float((ihs1-ihs))/100.

if(diff.ge.3.0) then

err=3

return

endif

call portin(889,0,x)

! look for Acknoledge error =H and oop =h

y=2#01101000

x=iand(x,y)

C	write(*,'(i4,\)') x

if (x.eq.2#00101000) goto5

!	10101000

if (x.eq.2#01101000) then

! Checksum coming through instead of data

flag=1

goto 5

endif

goto 7

!get byte of data

5	call portin(888,0,byte)

call portot(890,0,2#00101110)

! select = h

call portot(890,0,2#00101010)

! init = L (got byte)

call gettim (ih,im,is,ihs)

8	call gettim (ih1,im1,is1,ihs1)

if ( ih1 .lt. ih ) ih1 = ih1 + 24

diff=(ih1-ih)*3600.+(im1-im)*60.

& + float((is1-is)) + float((ihs1-ihs))/100.

if(diff.ge.3.0) then

err=1

return

endif

call portin(889,0,x)

! look for Acknoledge (looking for error transition H-L)

y=2#00001000

x=iand(x,y)

if (x.ne.0) goto8



! Command executed... go on to next

call portot(890,0,2#00000010)

! Selectin low, Direction out, init =l

c	write(*,*) 'finished, waiting for next'

call gettim (ih,im,is,ihs)

768	call gettim (ih1,im1,is1,ihs1)

if ( ih1 .lt. ih ) ih1 = ih1 + 24

diff=(ih1-ih)*3600.+(im1-im)*60.

& + float((is1-is)) + float((ihs1-ihs))/100.

if(diff.ge.3.0) then

err= 2

return

endif

call portin(889,0,x)

! look for Acknoledge (looking for error transition H-L)

y=2#00001000

x=iand(x,y)

if (x.ne.0) goto768

return

end







subroutine waster ( times )

c	----------------------------

real*4 diff

integer*2 ih,im,is,ihs,ih1,im1,is1,ihs1

if ( times .eq. 0.0 .or. times .gt. 1000. ) return

call gettim (ih,im,is,ihs)

1 call gettim (ih1,im1,is1,ihs1)

if ( ih1 .lt. ih ) ih1 = ih1 + 24

diff=(ih1-ih)*3600.+(im1-im)*60.

& + float((is1-is)) + float((ihs1-ihs))/100.

if ( diff .ge. times ) return

goto 1

end