Skip to content

Commit

Permalink
Fix first run crashing on Xbox One. Added savestate support. Rewind … (
Browse files Browse the repository at this point in the history
…#87)

* Fix first run crashing on Xbox One.
* Added savestate support.
* Rewind works.  Fixes issue #83 and possibly #49.
* Added Disc Control menu.  Supports Disks, Tapes and M3U files (issue #66).
* Added in support for 5200 Super Carts.
* Better support for 5200 controller.
* Added Paddle support.
* Converted Core Options menu to v2.
* Moved some core options into submenus.
* Added controller mappings for Ports 2-4.
* Added options for Dual Stick and Swap Ports.  Fixes issue #76.
* Joystick/Console now controlled more easily with device type Atari Keyboard.
* Added 4 Hi-Res Artifacting modes.  Restart does something now.
* When core option changed only reboot if necessary.  Removed several hardcoded controller binds.  Fixed issue #29.  Joypad input ignored when virtual keyboard active.
* SIO Acceleration now defaults to enabled.  Fix for Bounty Bob (5200 & lift fix A800).
* Added Atari 800 carts to autodetect DB.
* Added more Carts to DB.
* Fixed Drive Index not being reset on 'restart'.
* Changed Atari Joystick default mappings to something more reasonable.
  • Loading branch information
greenchili2 authored Jul 31, 2023
1 parent 86be15d commit 20d59af
Show file tree
Hide file tree
Showing 50 changed files with 8,233 additions and 2,139 deletions.
6 changes: 5 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SOURCES_C := \
$(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c \
$(LIBRETRO_COMM_DIR)/file/file_path.c \
$(LIBRETRO_COMM_DIR)/file/file_path_io.c \
$(LIBRETRO_COMM_DIR)/streams/memory_stream.c \
$(LIBRETRO_COMM_DIR)/string/stdstring.c \
$(LIBRETRO_COMM_DIR)/time/rtime.c \
$(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.c
Expand All @@ -27,7 +28,10 @@ SOURCES_C += \
$(CORE_DIR)/libretro/libretro-core.c \
$(CORE_DIR)/libretro/core-mapper.c \
$(CORE_DIR)/libretro/graph.c \
$(CORE_DIR)/libretro/vkbd.c
$(CORE_DIR)/libretro/vkbd.c \
$(CORE_DIR)/libretro/retro_strings.c \
$(CORE_DIR)/libretro/retro_utils.c \
$(CORE_DIR)/libretro/retro_disk_control.c

SOURCES_C += \
$(CORE_DIR)/atari800/src/afile.c \
Expand Down
7 changes: 6 additions & 1 deletion atari800/src/android/jni/jni.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ static jint JNICALL NativeRunAtariProgram(JNIEnv *env, jobject this,
CARTRIDGE_MEGA_2048_DESC,
CARTRIDGE_THECART_32M_DESC,
CARTRIDGE_THECART_64M_DESC,
CARTRIDGE_XEGS_8F_64_DESC
CARTRIDGE_XEGS_8F_64_DESC,
CARTRIDGE_5200_SUPER_64_DESC,
CARTRIDGE_5200_SUPER_128_DESC,
CARTRIDGE_5200_SUPER_256_DESC,
CARTRIDGE_5200_SUPER_512_DESC,
CARTRIDGE_ATMAX_NEW_1024_DESC
};

const jbyte *img_utf = NULL;
Expand Down
57 changes: 57 additions & 0 deletions atari800/src/antic.c
Original file line number Diff line number Diff line change
Expand Up @@ -4085,6 +4085,63 @@ case we have ANTIC_cpu2antic_ptr[ANTIC_WSYNC_C+1]-1 = 8 and in the 2nd =12 */

#ifndef BASIC

#if defined(__LIBRETRO__)
void Retro_ANTIC_StateSave(void)
{
Retro_SaveUBYTE(&ANTIC_DMACTL, 1);
Retro_SaveUBYTE(&ANTIC_CHACTL, 1);
Retro_SaveUBYTE(&ANTIC_HSCROL, 1);
Retro_SaveUBYTE(&ANTIC_VSCROL, 1);
Retro_SaveUBYTE(&ANTIC_PMBASE, 1);
Retro_SaveUBYTE(&ANTIC_CHBASE, 1);
Retro_SaveUBYTE(&ANTIC_NMIEN, 1);
Retro_SaveUBYTE(&ANTIC_NMIST, 1);
Retro_SaveUBYTE(&IR, 1);
Retro_SaveUBYTE(&anticmode, 1);
Retro_SaveUBYTE(&dctr, 1);
Retro_SaveUBYTE(&lastline, 1);
Retro_SaveUBYTE(&need_dl, 1);
Retro_SaveUBYTE(&vscrol_off, 1);

Retro_SaveUWORD(&ANTIC_dlist, 1);
Retro_SaveUWORD(&screenaddr, 1);

Retro_SaveINT(&ANTIC_xpos, 1);
Retro_SaveINT(&ANTIC_xpos_limit, 1);
Retro_SaveINT(&ANTIC_ypos, 1);
}

void Retro_ANTIC_StateRead(void)
{
Retro_ReadUBYTE(&ANTIC_DMACTL, 1);
Retro_ReadUBYTE(&ANTIC_CHACTL, 1);
Retro_ReadUBYTE(&ANTIC_HSCROL, 1);
Retro_ReadUBYTE(&ANTIC_VSCROL, 1);
Retro_ReadUBYTE(&ANTIC_PMBASE, 1);
Retro_ReadUBYTE(&ANTIC_CHBASE, 1);
Retro_ReadUBYTE(&ANTIC_NMIEN, 1);
Retro_ReadUBYTE(&ANTIC_NMIST, 1);
Retro_ReadUBYTE(&IR, 1);
Retro_ReadUBYTE(&anticmode, 1);
Retro_ReadUBYTE(&dctr, 1);
Retro_ReadUBYTE(&lastline, 1);
Retro_ReadUBYTE(&need_dl, 1);
Retro_ReadUBYTE(&vscrol_off, 1);

Retro_ReadUWORD(&ANTIC_dlist, 1);
Retro_ReadUWORD(&screenaddr, 1);

Retro_ReadINT(&ANTIC_xpos, 1);
Retro_ReadINT(&ANTIC_xpos_limit, 1);
Retro_ReadINT(&ANTIC_ypos, 1);

ANTIC_PutByte(ANTIC_OFFSET_DMACTL, ANTIC_DMACTL);
ANTIC_PutByte(ANTIC_OFFSET_CHACTL, ANTIC_CHACTL);
ANTIC_PutByte(ANTIC_OFFSET_PMBASE, ANTIC_PMBASE);
ANTIC_PutByte(ANTIC_OFFSET_CHBASE, ANTIC_CHBASE);
}
#endif /* __LIBRETRO__ */

void ANTIC_StateSave(void)
{
StateSav_SaveUBYTE(&ANTIC_DMACTL, 1);
Expand Down
5 changes: 5 additions & 0 deletions atari800/src/antic.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ void ANTIC_SetPrior(UBYTE prior);
void ANTIC_StateSave(void);
void ANTIC_StateRead(void);

#if defined(__LIBRETRO__)
void Retro_ANTIC_StateSave(void);
void Retro_ANTIC_StateRead(void);
#endif

/* Pointer to 16 KB seen by ANTIC in 0x4000-0x7fff.
If it's the same what the CPU sees (and what's in memory[0x4000..0x7fff],
then NULL. */
Expand Down
127 changes: 126 additions & 1 deletion atari800/src/atari.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
#endif
#if defined(__LIBRETRO__)
extern const char *retro_system_directory;
#endif
#endif /* __LIBRETRO__ */

int Atari800_machine_type = Atari800_MACHINE_XLXE;

Expand Down Expand Up @@ -1377,6 +1377,131 @@ void Atari800_Frame(void)

#ifndef BASIC

#if defined(__LIBRETRO__)
void Retro_Atari800_StateSave(void)
{
UBYTE temp = Atari800_tv_mode == Atari800_TV_PAL;
Retro_SaveUBYTE(&temp, 1);
temp = Atari800_machine_type;
Retro_SaveUBYTE(&temp, 1);
if (Atari800_machine_type == Atari800_MACHINE_XLXE) {
temp = Atari800_builtin_basic;
Retro_SaveUBYTE(&temp, 1);
temp = Atari800_keyboard_leds;
Retro_SaveUBYTE(&temp, 1);
temp = Atari800_f_keys;
Retro_SaveUBYTE(&temp, 1);
temp = Atari800_jumper;
Retro_SaveUBYTE(&temp, 1);
temp = Atari800_builtin_game;
Retro_SaveUBYTE(&temp, 1);
temp = Atari800_keyboard_detached;
Retro_SaveUBYTE(&temp, 1);
}
}

void Retro_Atari800_StateRead(UBYTE version)
{
if (version >= 7) {
UBYTE temp;
Retro_ReadUBYTE(&temp, 1);
Atari800_SetTVMode(temp ? Atari800_TV_PAL : Atari800_TV_NTSC);
Retro_ReadUBYTE(&temp, 1);
if (temp < 0 || temp >= Atari800_MACHINE_SIZE) {
temp = Atari800_MACHINE_XLXE;
Log_print("Warning: Bad machine type read in from state save, defaulting to XL/XE");
}
Atari800_SetMachineType(temp);
if (Atari800_machine_type == Atari800_MACHINE_XLXE) {
Retro_ReadUBYTE(&temp, 1);
Atari800_builtin_basic = temp != 0;
Retro_ReadUBYTE(&temp, 1);
Atari800_keyboard_leds = temp != 0;
Retro_ReadUBYTE(&temp, 1);
Atari800_f_keys = temp != 0;
Retro_ReadUBYTE(&temp, 1);
Atari800_jumper = temp != 0;
Atari800_UpdateJumper();
Retro_ReadUBYTE(&temp, 1);
Atari800_builtin_game = temp != 0;
Retro_ReadUBYTE(&temp, 1);
Atari800_keyboard_detached = temp != 0;
Atari800_UpdateKeyboardDetached();
}
}
else { /* savestate from version 2.2.1 or earlier */
int new_tv_mode;
/* these are all for compatibility with previous versions */
UBYTE temp;
int default_tv_mode;
int os;
int default_system;
int pil_on;

Retro_ReadUBYTE(&temp, 1);
new_tv_mode = (temp == 0) ? Atari800_TV_PAL : Atari800_TV_NTSC;
Atari800_SetTVMode(new_tv_mode);

Retro_ReadUBYTE(&temp, 1);
Retro_ReadINT(&os, 1);
switch (temp) {
case 0:
Atari800_machine_type = Atari800_MACHINE_800;
MEMORY_ram_size = 48;
break;
case 1:
Atari800_machine_type = Atari800_MACHINE_XLXE;
MEMORY_ram_size = 64;
break;
case 2:
Atari800_machine_type = Atari800_MACHINE_XLXE;
MEMORY_ram_size = 128;
break;
case 3:
Atari800_machine_type = Atari800_MACHINE_XLXE;
MEMORY_ram_size = MEMORY_RAM_320_COMPY_SHOP;
break;
case 4:
Atari800_machine_type = Atari800_MACHINE_5200;
MEMORY_ram_size = 16;
break;
case 5:
Atari800_machine_type = Atari800_MACHINE_800;
MEMORY_ram_size = 16;
break;
case 6:
Atari800_machine_type = Atari800_MACHINE_XLXE;
MEMORY_ram_size = 16;
break;
case 7:
Atari800_machine_type = Atari800_MACHINE_XLXE;
MEMORY_ram_size = 576;
break;
case 8:
Atari800_machine_type = Atari800_MACHINE_XLXE;
MEMORY_ram_size = 1088;
break;
case 9:
Atari800_machine_type = Atari800_MACHINE_XLXE;
MEMORY_ram_size = 192;
break;
default:
Atari800_machine_type = Atari800_MACHINE_XLXE;
MEMORY_ram_size = 64;
Log_print("Warning: Bad machine type read in from state save, defaulting to 800 XL");
break;
}

Retro_ReadINT(&pil_on, 1);
Retro_ReadINT(&default_tv_mode, 1);
Retro_ReadINT(&default_system, 1);
Atari800_SetMachineType(Atari800_machine_type);
}
load_roms();
/* XXX: what about patches? */
}
#endif /* __LIBRETRO__ */

void Atari800_StateSave(void)
{
UBYTE temp = Atari800_tv_mode == Atari800_TV_PAL;
Expand Down
6 changes: 6 additions & 0 deletions atari800/src/atari.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,10 @@ void Atari800_StateRead(UBYTE version);
/* Change TV mode. */
void Atari800_SetTVMode(int mode);

#if defined(__LIBRETRO__)
/* Save State */
void Retro_Atari800_StateSave(void);
void Retro_Atari800_StateRead(UBYTE version);
#endif

#endif /* ATARI_H_ */
Loading

0 comments on commit 20d59af

Please sign in to comment.