Skip to content

Commit 683a37f

Browse files
authored
Enhanced cart auto-detection and more (#106)
- Enhance cart dump (.rom, .bin) type and machine detection. - Set Atari 5200 joystick mapping when an Atari 5200 cart is detected. - Add cart mapper for Bounty Bob Strikes Back (alternative mapping). - Set Atari 800XL as the default machine instead of Atari 400/800 for better compatibility. - Sync partially cartridge types with the Atari800 emulator. - Merge hash lists (A5200 and A800). - Add TOSEC bin Atari 5200 dumps (169 new files). - Add Turbosoft multicart Atari 800 dumps (16 new files). - Add TOSEC bin Atari 800 dumps (118 new files). - Update atari800_libretro.info. - Add configurable palette (tint, saturation, contrast, brightness, gamma). - Add configure key for the Atari800 menu (F1 or F10). - Remove some options from the legacy menu.
1 parent 39380a6 commit 683a37f

14 files changed

+1996
-60
lines changed

Makefile.common

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ SOURCES_C := \
2525
$(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.c
2626

2727
SOURCES_C += \
28+
$(CORE_DIR)/libretro/carts_hash.c \
2829
$(CORE_DIR)/libretro/libretro-core.c \
2930
$(CORE_DIR)/libretro/core-mapper.c \
3031
$(CORE_DIR)/libretro/graph.c \

atari800/src/afile.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <stdio.h>
4242
#ifdef __LIBRETRO__
4343
#include "crc32.h"
44+
#include "carts_hash.h"
4445
#endif
4546

4647
int AFILE_DetectFileType(const char *filename)
@@ -50,16 +51,18 @@ int AFILE_DetectFileType(const char *filename)
5051
FILE *fp = fopen(filename, "rb");
5152
if (fp == NULL)
5253
return AFILE_ERROR;
53-
// Commando CART hack
54+
5455
#ifdef __LIBRETRO__
56+
// False positives - hack for raw images
5557
ULONG crc;
5658
CRC32_FromFile(fp, &crc);
5759
Util_rewind(fp);
58-
if (crc == 0x28288df4) { // Commando cart CRC
60+
if (is_cart(crc)) {
5961
fclose(fp);
60-
return AFILE_CART;
62+
return AFILE_ROM;
6163
}
62-
#endif
64+
#endif // __LIBRETRO__
65+
6366
if (fread(header, 1, 4, fp) != 4) {
6467
fclose(fp);
6568
return AFILE_ERROR;

atari800/src/android/jni/jni.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,15 @@ static jint JNICALL NativeRunAtariProgram(JNIEnv *env, jobject this,
255255
CARTRIDGE_THECART_32M_DESC,
256256
CARTRIDGE_THECART_64M_DESC,
257257
CARTRIDGE_XEGS_8F_64_DESC,
258+
CARTRIDGE_ATRAX_128_DESC,
259+
CARTRIDGE_ADAWLIAH_32_DESC,
260+
CARTRIDGE_ADAWLIAH_64_DESC,
258261
CARTRIDGE_5200_SUPER_64_DESC,
259262
CARTRIDGE_5200_SUPER_128_DESC,
260263
CARTRIDGE_5200_SUPER_256_DESC,
261264
CARTRIDGE_5200_SUPER_512_DESC,
262-
CARTRIDGE_ATMAX_NEW_1024_DESC
265+
CARTRIDGE_ATMAX_NEW_1024_DESC,
266+
CARTRIDGE_5200_40_ALT_DESC
263267
};
264268

265269
const jbyte *img_utf = NULL;

atari800/src/cartridge.c

+112-16
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,15 @@ int const CARTRIDGE_kb[CARTRIDGE_LAST_SUPPORTED + 1] = {
120120
32*1024, /* CARTRIDGE_THECART_32M */
121121
64*1024, /* CARTRIDGE_THECART_64M */
122122
64, /* CARTRIDGE_XEGS_64_8F */
123+
128, /* CARTRIDGE_ATRAX_128_RAW */
124+
32, /* CARTRIDGE_ADAWLIAH_32 */
125+
64, /* CARTRIDGE_ADAWLIAH_64 */
123126
64, /* CARTRIDGE_5200_SUPER_64 */
124127
128, /* CARTRIDGE_5200_SUPER_128 */
125128
256, /* CARTRIDGE_5200_SUPER_256 */
126129
512, /* CARTRIDGE_5200_SUPER_512 */
127130
1024, /* CARTRIDGE_ATMAX_NEW_1024 */
131+
40, /* CARTRIDGE_5200_40_ALT */
128132
};
129133

130134
int CARTRIDGE_autoreboot = TRUE;
@@ -135,6 +139,7 @@ static int CartIsFor5200(int type)
135139
case CARTRIDGE_5200_32:
136140
case CARTRIDGE_5200_EE_16:
137141
case CARTRIDGE_5200_40:
142+
case CARTRIDGE_5200_40_ALT:
138143
case CARTRIDGE_5200_NS_16:
139144
case CARTRIDGE_5200_8:
140145
case CARTRIDGE_5200_4:
@@ -451,6 +456,21 @@ static void MapActiveCart(void)
451456
MEMORY_readmap[0x5f] = CARTRIDGE_BountyBob2GetByte;
452457
MEMORY_writemap[0x4f] = CARTRIDGE_BountyBob1PutByte;
453458
MEMORY_writemap[0x5f] = CARTRIDGE_BountyBob2PutByte;
459+
#endif
460+
break;
461+
case CARTRIDGE_5200_40_ALT:
462+
MEMORY_CopyROM(0x4000, 0x4fff, active_cart->image + 0x2000 + (active_cart->state & 0x03) * 0x1000);
463+
MEMORY_CopyROM(0x5000, 0x5fff, active_cart->image + 0x6000 + ((active_cart->state & 0x0c) >> 2) * 0x1000);
464+
MEMORY_CopyROM(0x8000, 0x9fff, active_cart->image);
465+
MEMORY_CopyROM(0xa000, 0xbfff, active_cart->image);
466+
#ifndef PAGED_ATTRIB
467+
MEMORY_SetHARDWARE(0x4ff6, 0x4ff9);
468+
MEMORY_SetHARDWARE(0x5ff6, 0x5ff9);
469+
#else
470+
MEMORY_readmap[0x4f] = CARTRIDGE_BountyBob1GetByte;
471+
MEMORY_readmap[0x5f] = CARTRIDGE_BountyBob2GetByte;
472+
MEMORY_writemap[0x4f] = CARTRIDGE_BountyBob1PutByte;
473+
MEMORY_writemap[0x5f] = CARTRIDGE_BountyBob2PutByte;
454474
#endif
455475
break;
456476
case CARTRIDGE_5200_NS_16:
@@ -1123,7 +1143,10 @@ void CARTRIDGE_BountyBob1(UWORD addr)
11231143
if (Atari800_machine_type == Atari800_MACHINE_5200) {
11241144
if (addr >= 0x4ff6 && addr <= 0x4ff9) {
11251145
addr -= 0x4ff6;
1126-
MEMORY_CopyROM(0x4000, 0x4fff, active_cart->image + addr * 0x1000);
1146+
if (active_cart->type == CARTRIDGE_5200_40_ALT)
1147+
MEMORY_CopyROM(0x4000, 0x4fff, active_cart->image + 0x2000 + addr * 0x1000);
1148+
else
1149+
MEMORY_CopyROM(0x4000, 0x4fff, active_cart->image + addr * 0x1000);
11271150
active_cart->state = (active_cart->state & 0x0c) | addr;
11281151
}
11291152
} else {
@@ -1140,7 +1163,10 @@ void CARTRIDGE_BountyBob2(UWORD addr)
11401163
if (Atari800_machine_type == Atari800_MACHINE_5200) {
11411164
if (addr >= 0x5ff6 && addr <= 0x5ff9) {
11421165
addr -= 0x5ff6;
1143-
MEMORY_CopyROM(0x5000, 0x5fff, active_cart->image + 0x4000 + addr * 0x1000);
1166+
if (active_cart->type == CARTRIDGE_5200_40_ALT)
1167+
MEMORY_CopyROM(0x5000, 0x5fff, active_cart->image + 0x6000 + addr * 0x1000);
1168+
else
1169+
MEMORY_CopyROM(0x5000, 0x5fff, active_cart->image + 0x4000 + addr * 0x1000);
11441170
active_cart->state = (active_cart->state & 0x03) | (addr << 2);
11451171
}
11461172
}
@@ -1437,8 +1463,7 @@ void CARTRIDGE_ColdStart(void) {
14371463
}
14381464

14391465
#ifdef __LIBRETRO__
1440-
#include "atari5200_hash.h"
1441-
#include "atari800_hash.h"
1466+
#include "carts_hash.h"
14421467
#include "esc.h"
14431468
#include "pokeysnd.h"
14441469
extern int autorunCartridge;
@@ -1489,7 +1514,7 @@ static int InsertCartridge(const char *filename, CARTRIDGE_image_t *cart)
14891514
len >>= 10; /* number of kilobytes */
14901515
cart->size = len;
14911516
#ifdef __LIBRETRO__
1492-
if (autorunCartridge == 1) {
1517+
if (autorunCartridge == A5200_CART) {
14931518
int match = 0, i = 0;
14941519
printf("Hack Libretro:crc A5200 ON sz:%d crc:%x\n", cart->size, crc);
14951520
while (a5200_game[i].type != -1) {
@@ -1515,6 +1540,11 @@ static int InsertCartridge(const char *filename, CARTRIDGE_image_t *cart)
15151540
cart->type = CARTRIDGE_5200_40;
15161541
POKEYSND_stereo_enabled = FALSE;
15171542
}
1543+
else if (a5200_game[i].type == a5200_40_ALT) {
1544+
/* Bounty Bob don't like stereo pokey (game locks) */
1545+
cart->type = CARTRIDGE_5200_40_ALT;
1546+
POKEYSND_stereo_enabled = FALSE;
1547+
}
15181548
else if (a5200_game[i].type == a5200_ee_16)
15191549
cart->type = CARTRIDGE_5200_EE_16;
15201550
else if (a5200_game[i].type == a5200_64)
@@ -1525,21 +1555,47 @@ static int InsertCartridge(const char *filename, CARTRIDGE_image_t *cart)
15251555
cart->type = CARTRIDGE_5200_SUPER_256; // I've yet to see this type
15261556
else if (a5200_game[i].type == a5200_512)
15271557
cart->type = CARTRIDGE_5200_SUPER_512;
1558+
else if (a5200_game[i].type == a5200_unsupported) {
1559+
match = 3;
1560+
cart->type = CARTRIDGE_NONE;
1561+
}
1562+
else if (a5200_game[i].type == a5200_incomplete) {
1563+
match = 4;
1564+
cart->type = CARTRIDGE_NONE;
1565+
}
1566+
else if (a5200_game[i].type == a5200_bad_dump) {
1567+
match = 5;
1568+
cart->type = CARTRIDGE_NONE;
1569+
}
15281570

1529-
printf("Hack Libretro:A5200 cart->type:%d %x\n", cart->type, crc);
1571+
printf("Hack Libretro:A5200 cart name:%s type:%d crc32:%x\n", a5200_game[i].name,cart->type, crc);
15301572
break;
15311573
}
15321574
i++;
15331575
}
15341576

15351577
if (match == 1) {
15361578
if (!RetroMsgShown)
1537-
retro_message("5200 Cart found in DB.", 1000, 0);
1538-
1579+
retro_message("Atari 5200 cart detected.", 1000, 0);
1580+
goto label_fin;
1581+
}
1582+
else if (match == 3) {
1583+
if (!RetroMsgShown)
1584+
retro_message("Atari 5200 unsupported cart detected.", 1000, 0);
1585+
goto label_fin;
1586+
}
1587+
else if (match == 4) {
1588+
if (!RetroMsgShown)
1589+
retro_message("Atari 5200 incomplete cart detected.", 1000, 0);
1590+
goto label_fin;
1591+
}
1592+
else if (match == 5) {
1593+
if (!RetroMsgShown)
1594+
retro_message("Atari 5200 bad dump detected.", 1000, 0);
15391595
goto label_fin;
15401596
}
15411597
}
1542-
else if (autorunCartridge == 2) {
1598+
else if (autorunCartridge == A800_CART) {
15431599
int match = 0, i = 0;
15441600
printf("Hack Libretro:crc A800 ON sz:%d crc:%x\n", cart->size, crc);
15451601
while (a800_game[i].type != -1) {
@@ -1578,27 +1634,67 @@ static int InsertCartridge(const char *filename, CARTRIDGE_image_t *cart)
15781634
match = 2;
15791635
cart->type = CARTRIDGE_ATMAX_1024;
15801636
}
1637+
else if (a800_game[i].type == a800_TURBOSOFT_64) {
1638+
match = 2;
1639+
cart->type = CARTRIDGE_TURBOSOFT_64;
1640+
}
1641+
else if (a800_game[i].type == a800_TURBOSOFT_128) {
1642+
match = 2;
1643+
cart->type = CARTRIDGE_TURBOSOFT_128;
1644+
}
1645+
else if (a800_game[i].type == a800_TURBOSOFT_64_WILL) {
1646+
match = 2;
1647+
cart->type = CARTRIDGE_WILL_64;
1648+
}
1649+
else if (a800_game[i].type == a800_OSS_M091_16) {
1650+
cart->type = CARTRIDGE_OSS_M091_16;
1651+
}
1652+
else if (a800_game[i].type == a800_unsupported) {
1653+
match = 3;
1654+
cart->type = CARTRIDGE_NONE;
1655+
}
1656+
else if (a800_game[i].type == a800_incomplete) {
1657+
match = 4;
1658+
cart->type = CARTRIDGE_NONE;
1659+
}
1660+
else if (a800_game[i].type == a800_bad_dump) {
1661+
match = 5;
1662+
cart->type = CARTRIDGE_NONE;
1663+
}
15811664

1582-
printf("Hack Libretro:A800 cart->type:%d %x\n", cart->type, crc);
1665+
printf("Hack Libretro:A800 cart name:%s type:%d crc32:%x\n", a800_game[i].name, cart->type, crc);
15831666
break;
15841667
}
15851668
i++;
15861669
}
15871670

15881671
if (match == 1) {
15891672
if (!RetroMsgShown)
1590-
retro_message("800 Cart found in DB.", 1000, 0);
1591-
1673+
retro_message("Atari 800 cart detected.", 1000, 0);
15921674
goto label_fin;
15931675
}
15941676
else if (match == 2) {
15951677
if (!RetroMsgShown)
1596-
retro_message("800 Cart found in DB. Some ATMAX carts need SIO Accleration disabled.", 1000, 0);
1597-
1678+
retro_message("Atari 800 cart detected. This cart may need SIO Acceleration disabled.", 1000, 0);
1679+
goto label_fin;
1680+
}
1681+
else if (match == 3) {
1682+
if (!RetroMsgShown)
1683+
retro_message("Atari 800 unsupported cart detected.", 1000, 0);
1684+
goto label_fin;
1685+
}
1686+
else if (match == 4) {
1687+
if (!RetroMsgShown)
1688+
retro_message("Atari 800 incomplete cart detected.", 1000, 0);
1689+
goto label_fin;
1690+
}
1691+
else if (match == 5) {
1692+
if (!RetroMsgShown)
1693+
retro_message("Atari 800 bad dump detected.", 1000, 0);
15981694
goto label_fin;
15991695
}
16001696
else if (!RetroMsgShown)
1601-
retro_message("800 Cart NOT found in DB.", 6000, 0);
1697+
retro_message("Atari 800 unknown cart (not in DB).", 6000, 0);
16021698
}
16031699

16041700
RetroMsgShown = TRUE;
@@ -1615,8 +1711,8 @@ static int InsertCartridge(const char *filename, CARTRIDGE_image_t *cart)
16151711
}
16161712
#ifdef __LIBRETRO__
16171713
label_fin:
1618-
#endif
16191714
RetroMsgShown = TRUE;
1715+
#endif
16201716

16211717
if (cart->type != CARTRIDGE_NONE) {
16221718
InitCartridge(cart);

atari800/src/cartridge.h

+16-7
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@ enum {
7575
CARTRIDGE_THECART_64M = 66,
7676
CARTRIDGE_XEGS_8F_64 = 67,
7777

78-
CARTRIDGE_5200_SUPER_64 = 68, // 71
79-
CARTRIDGE_5200_SUPER_128 = 69, // 72
80-
CARTRIDGE_5200_SUPER_256 = 70, // 73
81-
CARTRIDGE_5200_SUPER_512 = 71, // 74
82-
CARTRIDGE_ATMAX_NEW_1024 = 72, // 75
83-
84-
CARTRIDGE_LAST_SUPPORTED = 72
78+
CARTRIDGE_ATRAX_128_RAW = 68,
79+
CARTRIDGE_ADAWLIAH_32 = 69,
80+
CARTRIDGE_ADAWLIAH_64 = 70,
81+
CARTRIDGE_5200_SUPER_64 = 71,
82+
CARTRIDGE_5200_SUPER_128 = 72,
83+
CARTRIDGE_5200_SUPER_256 = 73,
84+
CARTRIDGE_5200_SUPER_512 = 74,
85+
CARTRIDGE_ATMAX_NEW_1024 = 75,
86+
87+
CARTRIDGE_5200_40_ALT = 76, // Bounty Bob (5200) - Alternate layout
88+
89+
CARTRIDGE_LAST_SUPPORTED = 76
8590
};
8691

8792
#define CARTRIDGE_MAX_SIZE (128 * 1024 * 1024)
@@ -154,11 +159,15 @@ extern int const CARTRIDGE_kb[CARTRIDGE_LAST_SUPPORTED + 1];
154159
#define CARTRIDGE_THECART_32M_DESC "The!Cart 32 MB cartridge"
155160
#define CARTRIDGE_THECART_64M_DESC "The!Cart 64 MB cartridge"
156161
#define CARTRIDGE_XEGS_8F_64_DESC "XEGS 64 KB cartridge (banks 8-15)"
162+
#define CARTRIDGE_ATRAX_128_RAW_DESC "Atrax 128 KB cartridge"
163+
#define CARTRIDGE_ADAWLIAH_32_DESC "aDawliah 32 KB cartridge"
164+
#define CARTRIDGE_ADAWLIAH_64_DESC "aDawliah 64 KB cartridge"
157165
#define CARTRIDGE_5200_SUPER_64_DESC "64 KB Atari 5200 Super Cart"
158166
#define CARTRIDGE_5200_SUPER_128_DESC "128 KB Atari 5200 Super Cart"
159167
#define CARTRIDGE_5200_SUPER_256_DESC "256 KB Atari 5200 Super Cart"
160168
#define CARTRIDGE_5200_SUPER_512_DESC "512 KB Atari 5200 Super Cart"
161169
#define CARTRIDGE_ATMAX_NEW_1024_DESC "Atarimax 1 MB Flash cartridge"
170+
#define CARTRIDGE_5200_40_ALT_DESC "Bounty Bob (5200) - Alternate layout"
162171

163172
/* Indicates whether the emulator should automatically reboot (coldstart)
164173
after inserting/removing a cartridge. (Doesn't affect the piggyback

atari800/src/ui.c

+12
Original file line numberDiff line numberDiff line change
@@ -1048,11 +1048,15 @@ int UI_SelectCartType(int k)
10481048
UI_MENU_ACTION(CARTRIDGE_THECART_32M, CARTRIDGE_THECART_32M_DESC),
10491049
UI_MENU_ACTION(CARTRIDGE_THECART_64M, CARTRIDGE_THECART_64M_DESC),
10501050
UI_MENU_ACTION(CARTRIDGE_XEGS_8F_64, CARTRIDGE_XEGS_8F_64_DESC),
1051+
UI_MENU_ACTION(CARTRIDGE_ATRAX_128_RAW, CARTRIDGE_ATRAX_128_RAW_DESC),
1052+
UI_MENU_ACTION(CARTRIDGE_ADAWLIAH_32, CARTRIDGE_ADAWLIAH_32_DESC),
1053+
UI_MENU_ACTION(CARTRIDGE_ADAWLIAH_64, CARTRIDGE_ADAWLIAH_64_DESC),
10511054
UI_MENU_ACTION(CARTRIDGE_5200_SUPER_64, CARTRIDGE_5200_SUPER_64_DESC),
10521055
UI_MENU_ACTION(CARTRIDGE_5200_SUPER_128, CARTRIDGE_5200_SUPER_128_DESC),
10531056
UI_MENU_ACTION(CARTRIDGE_5200_SUPER_256, CARTRIDGE_5200_SUPER_256_DESC),
10541057
UI_MENU_ACTION(CARTRIDGE_5200_SUPER_512, CARTRIDGE_5200_SUPER_512_DESC),
10551058
UI_MENU_ACTION(CARTRIDGE_ATMAX_NEW_1024, CARTRIDGE_ATMAX_NEW_1024_DESC),
1059+
UI_MENU_ACTION(CARTRIDGE_5200_40_ALT, CARTRIDGE_5200_40_ALT_DESC),
10561060
UI_MENU_END
10571061
};
10581062

@@ -4048,12 +4052,16 @@ void UI_Run(void)
40484052
UI_MENU_FILESEL_ACCEL(UI_MENU_LOADSTATE, "Load State", "Alt+L"),
40494053
#if !defined(CURSES_BASIC) && !defined(DREAMCAST)
40504054
#ifdef HAVE_LIBPNG
4055+
#ifndef __LIBRETRO__
40514056
UI_MENU_FILESEL_ACCEL(UI_MENU_PCX, "Save Screenshot", "F10"),
40524057
/* there isn't enough space for "PNG/PCX Interlaced Screenshot Shift+F10" */
40534058
UI_MENU_FILESEL_ACCEL(UI_MENU_PCXI, "Save Interlaced Screenshot", "Shift+F10"),
4059+
#endif // __LIBRETRO__
40544060
#else
4061+
#ifndef __LIBRETRO__
40554062
UI_MENU_FILESEL_ACCEL(UI_MENU_PCX, "PCX Screenshot", "F10"),
40564063
UI_MENU_FILESEL_ACCEL(UI_MENU_PCXI, "PCX Interlaced Screenshot", "Shift+F10"),
4064+
#endif // __LIBRETRO__
40574065
#endif
40584066
#endif
40594067
UI_MENU_ACTION_ACCEL(UI_MENU_BACK, "Back to Emulated Atari", "Esc"),
@@ -4066,10 +4074,14 @@ void UI_Run(void)
40664074
#elif defined(DIRECTX)
40674075
UI_MENU_ACTION_ACCEL(UI_MENU_MONITOR, monitor_label, "F8"),
40684076
#else
4077+
#ifndef __LIBRETRO__
40694078
UI_MENU_ACTION_ACCEL(UI_MENU_MONITOR, "Enter Monitor", "F8"),
4079+
#endif // __LIBRETRO__
40704080
#endif
40714081
UI_MENU_ACTION_ACCEL(UI_MENU_ABOUT, "About the Emulator", "Alt+A"),
4082+
#ifndef __LIBRETRO__
40724083
UI_MENU_ACTION_ACCEL(UI_MENU_EXIT, "Exit Emulator", "F9"),
4084+
#endif // __LIBRETRO__
40734085
UI_MENU_END
40744086
};
40754087

0 commit comments

Comments
 (0)