Skip to content

Commit 39380a6

Browse files
authored
Add XEGS emulation and Start Core without content (#105)
- Add emulation for the Atari XE Game System console. - Add support for starting the core without content.
1 parent 173edee commit 39380a6

File tree

3 files changed

+94
-56
lines changed

3 files changed

+94
-56
lines changed

atari800/src/atari.c

+2
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,8 @@ SYSROM_FindInDir("fs:/vol/external01/retroarch/cores/system/atari800", TRUE);
824824
/* Auto-start files left on the command line */
825825
j = 1; /* diskno */
826826
for (i = 1; i < *argc; i++) {
827+
if (strcmp(argv[i], "") == 0) // Core started with no content
828+
break;
827829
if (j > 8) {
828830
/* The remaining arguments are not necessary disk images, but ignore them... */
829831
Log_print("Too many disk image filenames on the command line (max. 8).");

libretro/libretro-core.c

+76-55
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ int autorunCartridge = 0;
111111
int atari_joyhack = 0;
112112
int paddle_mode = 0;
113113
int paddle_speed = 3;
114+
int atarixegs_keyboard_detached = 0;
114115

115116
extern int INPUT_joy_5200_center;
116117
extern int INPUT_joy_5200_min;
@@ -514,6 +515,9 @@ void retro_set_environment(retro_environment_t cb)
514515
libretro_set_core_options(environ_cb, &option_cats_supported);
515516

516517
cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
518+
519+
bool no_content = true;
520+
cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_content);
517521
}
518522

519523
static void update_variables(void)
@@ -525,7 +529,9 @@ static void update_variables(void)
525529
var.value = NULL;
526530

527531
/* Moved here for better consistency and when system options that require EMU reset to occur */
528-
if (HandleExtension((char*)RPATH, "a52") || HandleExtension((char*)RPATH, "A52"))
532+
if (strcmp(RPATH, "") == 0) // Start core with no content
533+
autorunCartridge = 0;
534+
else if (HandleExtension((char*)RPATH, "a52") || HandleExtension((char*)RPATH, "A52"))
529535
autorunCartridge = 1;
530536
else if (HandleExtension((char*)RPATH, "bin") || HandleExtension((char*)RPATH, "BIN")
531537
|| HandleExtension((char*)RPATH, "rom") || HandleExtension((char*)RPATH, "ROM"))
@@ -665,6 +671,17 @@ static void update_variables(void)
665671
Atari800_builtin_game = FALSE;
666672
Atari800_keyboard_detached = FALSE;
667673
}
674+
else if (strcmp(var.value, "XEGS") == 0)
675+
{
676+
Atari800_machine_type = Atari800_MACHINE_XLXE;
677+
MEMORY_ram_size = 64;
678+
Atari800_builtin_basic = TRUE;
679+
Atari800_keyboard_leds = FALSE;
680+
Atari800_f_keys = FALSE;
681+
Atari800_jumper = FALSE;
682+
Atari800_builtin_game = TRUE;
683+
Atari800_keyboard_detached = atarixegs_keyboard_detached;
684+
}
668685

669686
if (!libretro_runloop_active || (strcmp(var.value, old_Atari800_machine_type) != 0 ))
670687
{
@@ -845,6 +862,21 @@ static void update_variables(void)
845862
}
846863
}
847864

865+
var.key = "atarixegs_keyboard_detached";
866+
var.value = NULL;
867+
868+
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
869+
{
870+
if (strcmp(var.value, "attached") == 0)
871+
{
872+
atarixegs_keyboard_detached = 0;
873+
}
874+
else if (strcmp(var.value, "detached") == 0)
875+
{
876+
atarixegs_keyboard_detached = 1;
877+
}
878+
}
879+
848880
/* Digital Joystick/Paddle Sensitivity */
849881
var.key = "pot_digital_sensitivity";
850882
var.value = NULL;
@@ -1232,54 +1264,55 @@ static void keyboard_cb(bool down, unsigned keycode,
12321264

12331265
bool retro_load_game(const struct retro_game_info* info)
12341266
{
1235-
const char* full_path;
1236-
bool media_is_disk_tape = TRUE;
1237-
1238-
(void)info;
1239-
12401267
struct retro_keyboard_callback cb = { keyboard_cb };
1268+
environ_cb(RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK, &cb);
12411269

1242-
environ_cb(RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK, &cb);
1270+
if (info!=NULL) {
1271+
const char* full_path;
1272+
bool media_is_disk_tape = TRUE;
12431273

1244-
full_path = info->path;
1274+
(void)info;
12451275

1246-
// If it's a m3u file
1247-
if (strendswith(full_path, "M3U"))
1248-
{
1249-
// Parse the m3u file
1250-
dc_parse_m3u(dc, full_path);
1251-
1252-
// Some debugging
1253-
//log_cb(RETRO_LOG_INFO, "m3u file parsed, %d file(s) found\n", dc->count);
1254-
//for (unsigned i = 0; i < dc->count; i++)
1255-
//{
1256-
// fprintf(fp, "file %d: %s\n", i + 1, dc->files[i]);
1257-
// log_cb(RETRO_LOG_INFO, "file %d: %s\n", i + 1, dc->files[i]);
1258-
//}
1259-
}
1260-
else if (strendswith(full_path, "XFD") ||
1261-
strendswith(full_path, "ATR") ||
1262-
strendswith(full_path, "DCM") ||
1263-
strendswith(full_path, "ATX") ||
1264-
strendswith(full_path, "CAS"))
1265-
{
1266-
// Add the file to disk control context
1267-
// Maybe, in a later version of retroarch, we could add disk on the fly (didn't find how to do this)
1268-
dc_add_file(dc, full_path);
1269-
}
1270-
else
1271-
media_is_disk_tape = FALSE;
1276+
full_path = info->path;
12721277

1273-
if (media_is_disk_tape)
1274-
{
1275-
// Init first disk
1276-
dc->index = 0;
1277-
dc->eject_state = false;
1278-
log_cb(RETRO_LOG_INFO, "Disk/Cassette (%d) inserted into drive 1 : %s\n", dc->index + 1, dc->files[dc->index]);
1279-
strcpy(RPATH, dc->files[0]);
1278+
// If it's a m3u file
1279+
if (strendswith(full_path, "M3U"))
1280+
{
1281+
// Parse the m3u file
1282+
dc_parse_m3u(dc, full_path);
1283+
1284+
// Some debugging
1285+
//log_cb(RETRO_LOG_INFO, "m3u file parsed, %d file(s) found\n", dc->count);
1286+
//for (unsigned i = 0; i < dc->count; i++)
1287+
//{
1288+
// fprintf(fp, "file %d: %s\n", i + 1, dc->files[i]);
1289+
// log_cb(RETRO_LOG_INFO, "file %d: %s\n", i + 1, dc->files[i]);
1290+
//}
1291+
}
1292+
else if (strendswith(full_path, "XFD") ||
1293+
strendswith(full_path, "ATR") ||
1294+
strendswith(full_path, "DCM") ||
1295+
strendswith(full_path, "ATX") ||
1296+
strendswith(full_path, "CAS"))
1297+
{
1298+
// Add the file to disk control context
1299+
// Maybe, in a later version of retroarch, we could add disk on the fly (didn't find how to do this)
1300+
dc_add_file(dc, full_path);
1301+
}
1302+
else
1303+
media_is_disk_tape = FALSE;
1304+
1305+
if (media_is_disk_tape)
1306+
{
1307+
// Init first disk
1308+
dc->index = 0;
1309+
dc->eject_state = false;
1310+
log_cb(RETRO_LOG_INFO, "Disk/Cassette (%d) inserted into drive 1 : %s\n", dc->index + 1, dc->files[dc->index]);
1311+
strcpy(RPATH, dc->files[0]);
1312+
}
1313+
else
1314+
strcpy(RPATH, full_path);
12801315
}
1281-
else
1282-
strcpy(RPATH, full_path);
12831316

12841317
update_variables();
12851318

@@ -1333,10 +1366,6 @@ size_t retro_serialize_size(void)
13331366
size = Retro_SaveAtariState(data_, A800_SAVE_STATE_SIZE, 1);
13341367
free(data_);
13351368

1336-
//FILE* fp1 = fopen("E:\\debugme.txt", "a");
1337-
//fprintf(fp1, "Estimated savestate size %i\n", size);
1338-
//fclose(fp1);
1339-
13401369
return size;
13411370
}
13421371

@@ -1346,10 +1375,6 @@ bool retro_serialize(void* data_, size_t size)
13461375

13471376
returned_size = Retro_SaveAtariState(data_, size, 1);
13481377

1349-
//FILE* fp1 = fopen("E:\\debugme.txt", "a");
1350-
//fprintf(fp1, "Actual savestate size %i\n", returned_size);
1351-
//fclose(fp1);
1352-
13531378
return returned_size;
13541379
}
13551380

@@ -1359,10 +1384,6 @@ bool retro_unserialize(const void* data_, size_t size)
13591384

13601385
returned_size = Retro_ReadAtariState(data_, size);
13611386

1362-
//FILE* fp1 = fopen("E:\\debugme.txt", "a");
1363-
//fprintf(fp1, "Savestate size read in %i\nFor game %s\n", returned_size,RPATH);
1364-
//fclose(fp1);
1365-
13661387
return returned_size;
13671388
}
13681389

libretro/libretro_core_options.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,20 @@ struct retro_core_option_v2_definition option_defs_us[] = {
269269
},
270270
"poll"
271271
},
272+
{
273+
"atarixegs_keyboard_detached",
274+
"Atari XEGS keyboard",
275+
NULL,
276+
"Set whether the Atari XEGS keyboard is attached or detached. If 'Internal BASIC' is enabled and the keyboard is attached, it will boot to BASIC. If 'Internal BASIC' is enabled and the keyboard is detached it will boot to the in-built game (Missile Command). If 'Internal BASIC' is disabled, it will boot to the Self Test screen",
277+
NULL,
278+
"input",
279+
{
280+
{ "attached", NULL },
281+
{ "detached", NULL },
282+
{ NULL, NULL },
283+
},
284+
"attached"
285+
},
272286
{
273287
"keyboard_defines",
274288
"Atari Keyboard Defines",
@@ -286,7 +300,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
286300
"atari800_system",
287301
"Atari System",
288302
NULL,
289-
"Select system emulated. Atari 5200 for Atari 5200 console games. 400/800 (OS B) for <48K games or ones that require OS/B. 800XL (64K) works for most content. 130XE (128K), Modern XL/XE(320K Compy Shop), Modern XL/XE(576K), Modern XL/XE(1088K) for content that needs more than 64K.",
303+
"Select system emulated. Atari 5200 for Atari 5200 console games. 400/800 (OS B) for <48K games or ones that require OS/B. 800XL (64K) works for most content. 130XE (128K), Modern XL/XE(320K Compy Shop), Modern XL/XE(576K), Modern XL/XE(1088K) for content that needs more than 64K. Atari XE Game System for the Atari XE Game System or XEGS console games.",
290304
NULL,
291305
NULL,
292306
{
@@ -296,6 +310,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
296310
{ "Modern XL/XE(320K CS)", "Modern Atari XL/XE(320K Compy Shop)" },
297311
{ "Modern XL/XE(576K)", "Modern Atari XL/XE(576K)" },
298312
{ "Modern XL/XE(1088K)", "Modern Atari XL/XE(1088K)" },
313+
{ "XEGS", "Atari XE Game System"},
299314
{ "5200", "Atari 5200 Super System" },
300315
{ NULL, NULL },
301316
},

0 commit comments

Comments
 (0)