Skip to content

Commit 6a18cb2

Browse files
authored
Add AltirraOS 3.41 ROMs and disable legacy config (#109)
- Add AltirraOS 3.41 open-source ROMs from the upstream emulator - Disable legacy configuration (.atari800.cfg). - Add SIO patches from the upstream emulator. - Mark all ROMs as optional in libretro.info
1 parent cf1df09 commit 6a18cb2

22 files changed

+5113
-104
lines changed

Makefile.common

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ SOURCES_C += \
9090
# $(CORE_DIR)/atari800/src/videomode.c\
9191
# $(CORE_DIR)/atari800/src/pal_blending.c \
9292

93+
SOURCES_C += \
94+
$(CORE_DIR)/atari800/src/roms/altirraos_xl.c \
95+
$(CORE_DIR)/atari800/src/roms/altirraos_800.c \
96+
$(CORE_DIR)/atari800/src/roms/altirra_basic.c \
97+
$(CORE_DIR)/atari800/src/roms/altirra_5200_os.c
98+
9399
ZLIB_INCFLAGS = -I$(DEPS_DIR)/zlib
94100
ZLIB_SOURCES_C = \
95101
$(DEPS_DIR)/zlib/adler32.c \

atari800/src/atari.c

+24-8
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
#endif
148148
#if defined(__LIBRETRO__)
149149
extern const char *retro_system_directory;
150+
extern int legacy_configuration_file;
150151
#endif /* __LIBRETRO__ */
151152

152153
int Atari800_machine_type = Atari800_MACHINE_XLXE;
@@ -308,7 +309,7 @@ static int load_roms(void)
308309
int basic_ver, xegame_ver;
309310
SYSROM_ChooseROMs(Atari800_machine_type, MEMORY_ram_size, Atari800_tv_mode, &Atari800_os_version, &basic_ver, &xegame_ver);
310311
if (Atari800_os_version == -1
311-
|| !Atari800_LoadImage(SYSROM_roms[Atari800_os_version].filename, MEMORY_os, SYSROM_roms[Atari800_os_version].size)) {
312+
|| !SYSROM_LoadImage(Atari800_os_version, MEMORY_os)) {
312313
/* Missing OS ROM. */
313314
Atari800_os_version = -1;
314315
if (Atari800_machine_type != Atari800_MACHINE_5200 && emuos_mode == 1)
@@ -319,15 +320,15 @@ static int load_roms(void)
319320
}
320321
else if (Atari800_machine_type != Atari800_MACHINE_5200) {
321322
/* OS ROM found, try loading BASIC. */
322-
MEMORY_have_basic = basic_ver != -1 && Atari800_LoadImage(SYSROM_roms[basic_ver].filename, MEMORY_basic, SYSROM_roms[basic_ver].size);
323+
MEMORY_have_basic = basic_ver != -1 && SYSROM_LoadImage(basic_ver, MEMORY_basic);
323324
if (!MEMORY_have_basic)
324325
/* Missing BASIC ROM. Don't fail when it happens. */
325326
Atari800_builtin_basic = FALSE;
326327

327328
if (Atari800_builtin_game) {
328329
/* Try loading built-in XEGS game. */
329330
if (xegame_ver == -1
330-
|| !Atari800_LoadImage(SYSROM_roms[xegame_ver].filename, MEMORY_xegame, SYSROM_roms[xegame_ver].size))
331+
|| !SYSROM_LoadImage(xegame_ver, MEMORY_xegame))
331332
/* Missing XEGS game ROM. */
332333
Atari800_builtin_game = FALSE;
333334
}
@@ -427,18 +428,25 @@ int Atari800_Initialise(int *argc, char *argv[])
427428
}
428429
*argc = j;
429430
}
431+
430432
//LIBRETRO HACK
431-
//#ifndef ANDROID
432-
#if !defined(ANDROID) || defined(__LIBRETRO__)
433+
#if !defined(ANDROID) || defined(__LIBRETRO__)
434+
#if defined(__LIBRETRO__)
435+
if (legacy_configuration_file)
436+
got_config = CFG_LoadConfig(rtconfig_filename);
437+
else
438+
got_config = FALSE;
439+
#else
433440
got_config = CFG_LoadConfig(rtconfig_filename);
441+
#endif // __LIBRETRO__
434442
#else
435443
got_config = TRUE; /* pretend we got a config file -- not needed in Android */
436444
#endif
437-
445+
//LIBRETRO HACK
438446
/* try to find ROM images if the configuration file is not found
439447
or it does not specify some ROM paths (blank paths count as specified) */
440-
//LIBRETRO HACK
441-
//#ifndef ANDROID
448+
449+
442450
#if !defined(ANDROID) || defined(__LIBRETRO__)
443451
#if defined(__LIBRETRO__)
444452
SYSROM_FindInDir(retro_system_directory, TRUE);
@@ -476,7 +484,11 @@ SYSROM_FindInDir("fs:/vol/external01/retroarch/cores/system/atari800", TRUE);
476484
SYSROM_SetDefaults();
477485

478486
/* if no configuration file read, try to save one with the defaults */
487+
#if defined(__LIBRETRO__)
488+
if (!got_config && legacy_configuration_file)
489+
#else
479490
if (!got_config)
491+
#endif /* __LIBRETRO__*/
480492
CFG_WriteConfig();
481493

482494
#endif /* __PLUS */
@@ -974,7 +986,11 @@ int Atari800_Exit(int run_monitor)
974986
if (!restart) {
975987
/* We'd better save the configuration before calling the *_Exit() functions -
976988
there's a danger that they might change some emulator settings. */
989+
#if defined(__LIBRETRO__)
990+
if (CFG_save_on_exit && legacy_configuration_file)
991+
#else
977992
if (CFG_save_on_exit)
993+
#endif
978994
CFG_WriteConfig();
979995

980996
/* Cleanup functions, in reverse order as the init functions in

atari800/src/cassette.c

-8
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,6 @@ void CASSETTE_LeaderLoad(void)
412412
CASSETTE_ToggleRecord();
413413
CASSETTE_TapeMotor(TRUE);
414414
cassette_gapdelay = 9600;
415-
/* registers for SETVBV: third system timer, ~0.1 sec */
416-
CPU_regA = 3;
417-
CPU_regX = 0;
418-
CPU_regY = 5;
419415
}
420416

421417
/* indicates that a save leader is written by the OS */
@@ -425,10 +421,6 @@ void CASSETTE_LeaderSave(void)
425421
CASSETTE_ToggleRecord();
426422
CASSETTE_TapeMotor(TRUE);
427423
cassette_gapdelay = 19200;
428-
/* registers for SETVBV: third system timer, ~0.1 sec */
429-
CPU_regA = 3;
430-
CPU_regX = 0;
431-
CPU_regY = 5;
432424
}
433425

434426
int CASSETTE_ReadToMemory(UWORD dest_addr, int length)

atari800/src/devices.c

+6
Original file line numberDiff line numberDiff line change
@@ -2440,6 +2440,12 @@ int Devices_PatchOS(void)
24402440
case SYSROM_CC01R4:
24412441
addr = 0xc3eb;
24422442
break;
2443+
case SYSROM_ALTIRRA_800:
2444+
addr = 0xefd4; /* labeled InitHandlerTable in OS sources */
2445+
break;
2446+
case SYSROM_ALTIRRA_XL:
2447+
addr = 0xee90; /* labeled InitHandlerTable in OS sources */
2448+
break;
24432449
default:
24442450
return FALSE;
24452451
}

atari800/src/esc.c

+60-10
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,42 @@ int ESC_enable_sio_patch = TRUE;
4949
static UWORD esc_address[256];
5050
static ESC_FunctionType esc_function[256];
5151

52+
/* Esc function that removes the wait loop when reading the tape leader. For
53+
use with standard Atari OSes only. */
54+
static void CassetteLeaderLoad(void)
55+
{
56+
CASSETTE_LeaderLoad();
57+
58+
/* registers for SETVBV: third system timer, ~0.1 sec */
59+
CPU_regA = 3;
60+
CPU_regX = 0;
61+
CPU_regY = 5;
62+
}
63+
64+
/* Esc function that removes the wait loop when writing the tape leader. For
65+
use with standard Atari OSes only. */
66+
static void CassetteLeaderSave(void)
67+
{
68+
CASSETTE_LeaderSave();
69+
70+
/* registers for SETVBV: third system timer, ~0.1 sec */
71+
CPU_regA = 3;
72+
CPU_regX = 0;
73+
CPU_regY = 5;
74+
}
75+
76+
/* Esc function that removes the wait loop in AltirraOS's "CassetteWait"
77+
routine when reading or writing the tape leader. */
78+
static void CassetteLeaderAltirra(void)
79+
{
80+
if (CPU_regX == 1)
81+
CASSETTE_LeaderLoad();
82+
else
83+
CASSETTE_LeaderSave();
84+
/* Routine expects Y = 1 on exit. */
85+
CPU_regY = 1;
86+
}
87+
5288
void ESC_ClearAll(void)
5389
{
5490
int i;
@@ -124,6 +160,7 @@ void ESC_PatchOS(void)
124160
UWORD addr_s;
125161
UBYTE check_s_0;
126162
UBYTE check_s_1;
163+
int altirra = FALSE;
127164
/* patch Open() of C: so we know when a leader is processed */
128165
switch (Atari800_os_version) {
129166
case SYSROM_A_NTSC:
@@ -167,19 +204,32 @@ void ESC_PatchOS(void)
167204
check_s_0 = 0xa9;
168205
check_s_1 = 0x03;
169206
break;
207+
case SYSROM_ALTIRRA_800:
208+
altirra = TRUE;
209+
addr_l = 0xef91; /* points to CassetteWait */
210+
/* Fall through. */
211+
case SYSROM_ALTIRRA_XL:
212+
altirra = TRUE;
213+
addr_l = 0xee4a; /* points to CassetteWait */
214+
break;
170215
default:
171216
return;
172217
}
173-
/* don't hurt non-standard OSes that may not support cassette at all */
174-
if (MEMORY_dGetByte(addr_l) == 0xa9 && MEMORY_dGetByte(addr_l + 1) == 0x03
175-
&& MEMORY_dGetByte(addr_l + 2) == 0x8d && MEMORY_dGetByte(addr_l + 3) == 0x2a
176-
&& MEMORY_dGetByte(addr_l + 4) == 0x02
177-
&& MEMORY_dGetByte(addr_s) == check_s_0
178-
&& MEMORY_dGetByte(addr_s + 1) == check_s_1
179-
&& MEMORY_dGetByte(addr_s + 2) == 0x20 && MEMORY_dGetByte(addr_s + 3) == 0x5c
180-
&& MEMORY_dGetByte(addr_s + 4) == 0xe4) {
181-
ESC_Add(addr_l, ESC_COPENLOAD, CASSETTE_LeaderLoad);
182-
ESC_Add(addr_s, ESC_COPENSAVE, CASSETTE_LeaderSave);
218+
if (altirra)
219+
ESC_AddEscRts(addr_l, ESC_COPENLOAD, CassetteLeaderAltirra);
220+
else
221+
{
222+
/* don't hurt non-standard OSes that may not support cassette at all */
223+
if (MEMORY_dGetByte(addr_l) == 0xa9 && MEMORY_dGetByte(addr_l + 1) == 0x03
224+
&& MEMORY_dGetByte(addr_l + 2) == 0x8d && MEMORY_dGetByte(addr_l + 3) == 0x2a
225+
&& MEMORY_dGetByte(addr_l + 4) == 0x02
226+
&& MEMORY_dGetByte(addr_s) == check_s_0
227+
&& MEMORY_dGetByte(addr_s + 1) == check_s_1
228+
&& MEMORY_dGetByte(addr_s + 2) == 0x20 && MEMORY_dGetByte(addr_s + 3) == 0x5c
229+
&& MEMORY_dGetByte(addr_s + 4) == 0xe4) {
230+
ESC_Add(addr_l, ESC_COPENLOAD, CassetteLeaderLoad);
231+
ESC_Add(addr_s, ESC_COPENSAVE, CassetteLeaderSave);
232+
}
183233
}
184234
ESC_AddEscRts(0xe459, ESC_SIOV, SIO_Handler);
185235
patched = TRUE;

atari800/src/memory.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "antic.h"
3232
#include "cpu.h"
3333
#include "cartridge.h"
34-
#include "emuos.h"
34+
#include "roms/altirra_5200_os.h"
3535
#include "esc.h"
3636
#include "gtia.h"
3737
#include "log.h"
@@ -1403,9 +1403,9 @@ void MEMORY_CartA0bfEnable(void)
14031403
void MEMORY_GetCharset(UBYTE *cs)
14041404
{
14051405
/* copy font, but change screencode order to ATASCII order */
1406-
memcpy(cs, emuos_h + 0x200, 0x100); /* control chars */
1407-
memcpy(cs + 0x100, emuos_h, 0x200); /* !"#$..., uppercase letters */
1408-
memcpy(cs + 0x300, emuos_h + 0x300, 0x100); /* lowercase letters */
1406+
memcpy(cs, ROM_altirra_5200_os + 0x200, 0x100); /* control chars */
1407+
memcpy(cs + 0x100, ROM_altirra_5200_os, 0x200); /* !"#$..., uppercase letters */
1408+
memcpy(cs + 0x300, ROM_altirra_5200_os + 0x300, 0x100); /* lowercase letters */
14091409
}
14101410

14111411
#ifndef PAGED_MEM

atari800/src/roms/LICENSE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Altirra - Atari 800/800XL emulator
2+
Kernel ROM replacement
3+
Copyright (C) 2008-2020 Avery Lee
4+
5+
Copying and distribution of this file, with or without modification,
6+
are permitted in any medium without royalty provided the copyright
7+
notice and this notice are preserved. This file is offered as-is,
8+
without any warranty.

0 commit comments

Comments
 (0)