Atari 5200 Updates

1. Added CRC database lookup for ROM dump validation and file renaming
2. Added delays to improve successful ROM dumping. Especially helps with
   2-chip ROMs
3. Fixed database mapper config for Star Trek (not a 2-chip ROM)
This commit is contained in:
Andy Miles 2024-08-01 11:45:44 -07:00
parent ecbdcbda44
commit a81fbd2df6
No known key found for this signature in database
GPG Key ID: 4F416ABAAC32750B
3 changed files with 246 additions and 181 deletions

View File

@ -54,6 +54,12 @@
#define DISABLE_8000 PORTH |= (1 << 6) // ROM SELECT 8000-BFFF #define DISABLE_8000 PORTH |= (1 << 6) // ROM SELECT 8000-BFFF
#define ENABLE_8000 PORTH &= ~(1 << 6) #define ENABLE_8000 PORTH &= ~(1 << 6)
struct a5200_DB_entry {
char crc32[9];
byte gameMapper;
byte gameSize;
};
//****************************************** //******************************************
// Supported Mappers // Supported Mappers
//****************************************** //******************************************
@ -166,37 +172,14 @@ uint8_t readData_5200(uint16_t addr) // Add Input Pullup
{ {
PORTF = addr & 0xFF; // A0-A7 PORTF = addr & 0xFF; // A0-A7
PORTK = (addr >> 8) & 0xFF; // A8-A13 PORTK = (addr >> 8) & 0xFF; // A8-A13
NOP; cycleDelay(5);
NOP;
NOP;
NOP;
NOP;
// DDRC = 0x00; // Set to Input // DDRC = 0x00; // Set to Input
PORTC = 0xFF; // Input Pullup PORTC = 0xFF; // Input Pullup
NOP; cycleDelay(15); // Standard + extended delay for Vanguard
NOP;
NOP;
NOP;
NOP;
// Extended Delay for Vanguard
NOP;
NOP;
NOP;
NOP;
NOP;
NOP;
NOP;
NOP;
NOP;
NOP;
uint8_t ret = PINC; uint8_t ret = PINC;
NOP; cycleDelay(5);
NOP;
NOP;
NOP;
NOP;
return ret; return ret;
} }
@ -249,11 +232,14 @@ void readROM_5200() {
// Lower Half of 32K is at 0x4000 // Lower Half of 32K is at 0x4000
if (a5200size == 3) { // 32K if (a5200size == 3) { // 32K
ENABLE_4000; ENABLE_4000;
cycleDelay(15);
readSegment_5200(0x4000, 0x8000); // +16K = 32K readSegment_5200(0x4000, 0x8000); // +16K = 32K
DISABLE_4000; DISABLE_4000;
cycleDelay(15);
} }
// 4K/8K/16K + Upper Half of 32K // 4K/8K/16K + Upper Half of 32K
ENABLE_8000; ENABLE_8000;
cycleDelay(15);
if (a5200size > 1) if (a5200size > 1)
readSegment_5200(0x8000, 0xA000); // +8K = 16K readSegment_5200(0x8000, 0xA000); // +8K = 16K
if (a5200size > 0) if (a5200size > 0)
@ -261,32 +247,41 @@ void readROM_5200() {
// Base 4K // Base 4K
readSegment_5200(0xB000, 0xC000); // 4K readSegment_5200(0xB000, 0xC000); // 4K
DISABLE_8000; DISABLE_8000;
cycleDelay(15);
break; break;
case 1: // Two Chip 16KB case 1: // Two Chip 16KB
ENABLE_4000; ENABLE_4000;
cycleDelay(15);
readSegment_5200(0x4000, 0x6000); // 8K readSegment_5200(0x4000, 0x6000); // 8K
DISABLE_4000; DISABLE_4000;
cycleDelay(15);
ENABLE_8000; ENABLE_8000;
cycleDelay(15);
readSegment_5200(0x8000, 0xA000); // +8K = 16K readSegment_5200(0x8000, 0xA000); // +8K = 16K
DISABLE_8000; DISABLE_8000;
cycleDelay(15);
break; break;
case 2: // Bounty Bob Strikes Back 40KB [UNTESTED] case 2: // Bounty Bob Strikes Back 40KB [UNTESTED]
ENABLE_4000; ENABLE_4000;
cycleDelay(15);
// First 16KB (4KB x 4) // First 16KB (4KB x 4)
readBankBountyBob_5200(0x4000); readBankBountyBob_5200(0x4000);
// Second 16KB (4KB x 4) // Second 16KB (4KB x 4)
readBankBountyBob_5200(0x5000); readBankBountyBob_5200(0x5000);
DISABLE_4000; DISABLE_4000;
cycleDelay(15);
ENABLE_8000; ENABLE_8000;
cycleDelay(15);
readSegment_5200(0x8000, 0xA000); // +8K = 40K readSegment_5200(0x8000, 0xA000); // +8K = 40K
DISABLE_8000; DISABLE_8000;
cycleDelay(15);
break; break;
} }
myFile.close(); myFile.close();
printCRC(fileName, NULL, 0); compareCRC("5200.txt", 0, 1, 0);
println_Msg(FS(FSTRING_EMPTY)); println_Msg(FS(FSTRING_EMPTY));
// Prints string out of the common strings array either with or without newline // Prints string out of the common strings array either with or without newline
@ -421,6 +416,35 @@ void checkStatus_5200() {
#endif #endif
} }
//******************************************
// READ MAPPER
//******************************************
void readDbEntry(FsFile& database, void* entry) {
struct a5200_DB_entry* castEntry = (a5200_DB_entry*)entry;
// Read expected CRC32 as a string
for (int i = 0; i < 8; ++i) {
castEntry->crc32[i] = database.read();
}
castEntry->crc32[8] = '\0';
database.seekCur(1); // Skip comma delimiter
// Read mapper
castEntry->gameMapper = database.read() - 48;
// if next char is not a comma, expect an additional digit
char temp = database.read();
if (temp != ',') {
castEntry->gameMapper = (castEntry->gameMapper * 10) + (temp - 48);
database.seekCur(1); // Skip over comma
}
// Read rom size
castEntry->gameSize = database.read() - 48;
database.seekCur(2); // Skip rest of line
}
//****************************************** //******************************************
// SET MAPPER // SET MAPPER
//****************************************** //******************************************
@ -473,7 +497,7 @@ void setCart_5200() {
//go to root //go to root
sd.chdir(); sd.chdir();
struct database_entry_mapper_size entry; struct a5200_DB_entry entry;
// Select starting letter // Select starting letter
byte myLetter = starting_letter(); byte myLetter = starting_letter();
@ -482,7 +506,7 @@ void setCart_5200() {
if (myFile.open("5200.txt", O_READ)) { if (myFile.open("5200.txt", O_READ)) {
seek_first_letter_in_database(myFile, myLetter); seek_first_letter_in_database(myFile, myLetter);
if(checkCartSelection(myFile, &readDataLineMapperSize, &entry)) { if(checkCartSelection(myFile, &readDbEntry, &entry)) {
EEPROM_writeAnything(7, entry.gameMapper); EEPROM_writeAnything(7, entry.gameMapper);
EEPROM_writeAnything(8, entry.gameSize); EEPROM_writeAnything(8, entry.gameSize);
} }
@ -490,4 +514,12 @@ void setCart_5200() {
print_FatalError(FS(FSTRING_DATABASE_FILE_NOT_FOUND)); print_FatalError(FS(FSTRING_DATABASE_FILE_NOT_FOUND));
} }
} }
// While not precise in terms of exact cycles for NOP due to the for-loop
// overhead, it simplifies the code while still achieving a similar result.
void cycleDelay(byte cycleCount) {
for (byte i = 0; i < cycleCount; ++i) {
NOP;
}
}
#endif #endif

View File

@ -459,7 +459,7 @@ uint32_t calculateCRC(char* fileName, char* folder, unsigned long offset) {
/****************************************** /******************************************
CRC Functions for Atari, Fairchild, Ody2, Arc, etc. modules CRC Functions for Atari, Fairchild, Ody2, Arc, etc. modules
*****************************************/ *****************************************/
#if (defined(ENABLE_ODY2) || defined(ENABLE_ARC) || defined(ENABLE_FAIRCHILD) || defined(ENABLE_MSX) || defined(ENABLE_POKE) || defined(ENABLE_2600) || defined(ENABLE_5200) || defined(ENABLE_7800) || defined(ENABLE_C64) || defined(ENABLE_VECTREX) || defined(ENABLE_NES) || defined(ENABLE_LYNX) || defined(ENABLE_ATARI8) || defined(ENABLE_BALLY) || defined(ENABLE_LEAP) || defined(ENABLE_LJ) || defined(ENABLE_LJPRO) || defined(ENABLE_PV1000) || defined(ENABLE_PYUUTA) || defined(ENABLE_RCA) || defined(ENABLE_TI99) || defined(ENABLE_TRS80) || defined(ENABLE_VIC20) || defined(ENABLE_VSMILE)) #if (defined(ENABLE_ODY2) || defined(ENABLE_ARC) || defined(ENABLE_FAIRCHILD) || defined(ENABLE_MSX) || defined(ENABLE_POKE) || defined(ENABLE_2600) || defined(ENABLE_7800) || defined(ENABLE_C64) || defined(ENABLE_VECTREX) || defined(ENABLE_NES) || defined(ENABLE_LYNX) || defined(ENABLE_ATARI8) || defined(ENABLE_BALLY) || defined(ENABLE_LEAP) || defined(ENABLE_LJ) || defined(ENABLE_LJPRO) || defined(ENABLE_PV1000) || defined(ENABLE_PYUUTA) || defined(ENABLE_RCA) || defined(ENABLE_TI99) || defined(ENABLE_TRS80) || defined(ENABLE_VIC20) || defined(ENABLE_VSMILE))
void printCRC(char* checkFile, uint32_t* crcCopy, unsigned long offset) { void printCRC(char* checkFile, uint32_t* crcCopy, unsigned long offset) {
uint32_t crc = calculateCRC(checkFile, folder, offset); uint32_t crc = calculateCRC(checkFile, folder, offset);
@ -751,7 +751,7 @@ void readDataLineSingleDigit(FsFile& database, void* byteData) {
#endif #endif
#if ( \ #if ( \
defined(ENABLE_ODY2) || defined(ENABLE_5200) || defined(ENABLE_7800) || defined(ENABLE_C64) || defined(ENABLE_JAGUAR) || \ defined(ENABLE_ODY2) || defined(ENABLE_7800) || defined(ENABLE_C64) || defined(ENABLE_JAGUAR) || \
defined(ENABLE_VIC20)|| defined(ENABLE_ATARI8)\ defined(ENABLE_VIC20)|| defined(ENABLE_ATARI8)\
) )
struct database_entry_mapper_size { struct database_entry_mapper_size {

View File

@ -1,225 +1,258 @@
Activision Decathlon Activision Decathlon, The (USA).a52
0,2 F43E7CD0,0,2
Astro Chase Astro Chase (USA).a52
1,2 4019ECEC,1,2
Atari PAM - Pete's Test Atari PAM - Pete's Test (USA).a52
0,1 28278CD6,0,1
Atari PAM Diagnostics Atari PAM Diagnostics (USA) (v2.0).a52
1,2 E8B130C4,1,2
Atari PAM System Test Atari PAM Diagnostics (USA) (v2.3).a52
0,1 CE07D9AD,1,2
Ballblazer Atari PAM System Test (USA) (v1.02).a52
0,3 7EA86E87,0,1
Beamrider Ballblazer (USA).a52
0,2 DEF2A207,0,3
BerZerk Beamrider (USA).a52
0,2 9BAE58DC,0,2
Blue Print BerZerk (USA).a52
0,2 BE3CD348,0,2
Boogie Blue Print (USA).a52
0,0 0624E6E7,0,2
Bounty Bob Strikes Back! Boogie (USA) (Demo).a52
2,4 3BD5FDD6,0,0
Buck Rogers Bounty Bob Strikes Back! (USA).a52
1,2 7873C6DD,2,4
Centipede Buck Rogers - Planet of Zoom (USA) (Alt).a52
1,2 20DF4927,1,2
Choplifter! Buck Rogers - Planet of Zoom (USA).a52
0,2 04807705,1,2
Congo Bongo Carol Shaw's River Raid (USA).a52
1,2 09FC7648,0,1
Countermeasure Castle Blast (USA) (Unl).a52
1,2 7C988054,0,3
Defender Castle Crisis (USA) (Unl).a52
1,2 D50E4061,0,3
Dig Dug Centipede (USA).a52
1,2 536A70FE,1,2
Dreadnaught Factor Choplifter! (USA).a52
0,1 9AD53BBC,0,2
Frogger Congo Bongo (USA).a52
0,1 F1F42BBD,1,2
Frogger II Countermeasure (USA).a52
1,2 FD541C80,1,2
Galaxian David Crane's Pitfall II - Lost Caverns (USA).a52
0,1 4B910461,0,2
Gorf Defender (USA).a52
0,1 BD52623B,1,2
Gremlins Dig Dug (USA).a52
0,3 6A687F9C,1,2
Gyruss Dreadnaught Factor, The (USA).a52
1,2 460DEF2D,0,1
H.E.R.O. Frogger (USA).a52
0,2 AE7E3444,0,1
James Bond 007 Frogger II - Threeedeep! (USA).a52
1,2 0AF19345,1,2
Joust Galaxian (USA) (Alt).a52
1,2 3A6E6133,0,1
Jungle Hunt Galaxian (USA).a52
1,2 3EF4A23F,0,1
Kaboom! Gorf (USA).a52
0,0 E955DB74,0,1
Kangaroo Gremlins (USA).a52
1,2 063EC2C4,0,3
Keystone Kapers Gyruss (USA) (Alt).a52
0,1 4241582D,1,2
K-Razy Shoot-Out Gyruss.a52
0,1 CFD4A7F9,1,2
Mario Bros. H.E.R.O. (USA).a52
0,3 18A73AF3,0,2
MegaMania James Bond 007 (USA).a52
0,1 D9AE4518,1,2
Meteorites Joust (USA).a52
0,2 BFD30C01,1,2
Miner 2049er Jungle Hunt (USA).a52
0,2 2C676662,1,2
Missile Command Kaboom! (USA).a52
0,1 420F5D0B,0,0
Montezuma's Revenge Kangaroo (USA).a52
1,2 ECFA624F,1,2
Moon Patrol Keystone Kapers (USA).a52
0,2 8FE3BB2C,0,1
Mountain King Koffi - Yellow Kopter (USA) (Unl).a52
0,1 917BE656,0,3
Mr. Do!'s Castle K-Razy Shoot-Out (USA).a52
0,1 EE702214,0,1
Ms. Pac-Man Mario Bros. (USA) (Alt).a52
1,2 6B3F1179,0,3
Pac-Man Mario Bros. (USA).a52
1,2 873742F1,0,3
Pengo MegaMania (USA).a52
0,3 240A1E1A,0,1
Pitfall II Meteorites (USA).a52
0,2 AB8E035B,0,2
Pitfall! Miner 2049er Starring Bounty Bob (USA).a52
0,1 7DF1ADFB,0,2
Pole Position Missile Command (USA).a52
1,2 44D3FF6F,0,1
Popeye Montezuma's Revenge - Featuring Panama Joe (USA).a52
1,2 2A640143,1,2
Q-bert Moon Patrol (USA).a52
0,1 D0B2F285,0,2
QIX Mountain King (USA).a52
1,2 0F24243C,0,1
Quest for Quintana Roo Mr. Do!'s Castle (USA).a52
0,2 AA55F9BE,0,1
RealSports Baseball Ms. Pac-Man (USA).a52
0,3 752F5EFD,1,2
RealSports Basketball Pac-Man (USA).a52
0,3 8873EF51,1,2
RealSports Football Pengo (USA).a52
1,2 E4F8BA8C,0,3
RealSports Soccer Pitfall! (USA).a52
1,2 B2887833,0,1
RealSports Tennis Pole Position (USA).a52
1,2 ABC2D1E4,1,2
Rescue on Fractalus! Popeye (USA).a52
0,3 A18A9A40,1,2
River Raid Q-bert (USA).a52
0,1 3FE4A401,0,1
Robotron 2084 QIX (USA).a52
0,2 AEA6D2C2,1,2
Space Dungeon Quest for Quintana Roo (USA).a52
1,2 B5F3402B,0,2
Space Invaders RealSports Baseball (USA).a52
0,1 44166592,0,3
Space Shuttle RealSports Basketball (USA).a52
0,2 DD217276,0,3
Star Raiders RealSports Football (USA).a52
1,2 4336C2CC,1,2
Star Trek RealSports Soccer (USA).a52
1,2 ECBD1853,1,2
Star Wars - Return of the Jedi RealSports Tennis (USA).a52
0,1 10F33C90,1,2
Star Wars - The Arcade Game Rescue on Fractalus! (USA).a52
1,2 762C591B,0,3
Super Breakout Robotron 2084 (USA).a52
0,0 4252ABD9,0,2
Super Cobra Space Dungeon (USA).a52
0,1 B68D61E8,1,2
Vanguard Space Invaders (USA).a52
0,3 DE5C354A,0,1
Wizard of Wor Space Shuttle - A Journey Into Space (USA).a52
0,2 387365DC,0,2
Yellow Submarine Star Raiders (USA) (Alt).a52
0,0 4BAC5DD9,1,2
Zaxxon Star Raiders (USA).a52
0,3 7D819A9F,1,2
Zenji Star Trek - Strategic Operations Simulator (USA) (Alt).a52
0,1 33B70206,0,2
Zone Ranger Star Trek - Strategic Operations Simulator (USA).a52
0,2 69F23548,0,2
Star Wars - Return of the Jedi - Death Star Battle (USA).a52
0675F0A5,0,1
Star Wars - The Arcade Game (USA).a52
75F566DF,1,2
Super Breakout (USA).a52
A0642110,0,0
Super Cobra (USA).a52
97DEBCD2,0,1
Tempest (USA) (AtariAge).a52
A6400E17,0,3
Vanguard (USA).a52
CAAEA0A4,0,3
Wizard of Wor (USA).a52
D6F7DDFD,0,2
Yellow Submarine (USA) (Demo).a52
F47BC091,0,0
Zaxxon (USA).a52
741746D1,0,3
Zenji (USA).a52
DA228530,0,1
Zone Ranger (USA).a52
2959D827,0,2