Skip to content

Commit

Permalink
1.32.1
Browse files Browse the repository at this point in the history
  • Loading branch information
psakhis committed Apr 28, 2024
1 parent eb86238 commit 8832c08
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 61 deletions.
14 changes: 14 additions & 0 deletions mednafen/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
-- 1.32.1: --

March 15, 2024:
Apple2: Fixed erroneous parsing of WOZ file padding bytes and unknown chunks' data as 8-byte chunk headers.

Fixed broken handling of the end-of-stream condition when reading from non-compressed files stored in ZIP archives;
fixes loading of such Apple II WOZ disk images and CloneCD CD images.

January 17, 2024:
SS: Implemented workaround for gcc bug #113255 in the VDP1 rasterization code.

January 14, 2024:
Apple2: Fixed typos/brainfart that broke language card and ROM card control accesses via $C08F.

-- 1.32.0-UNSTABLE: --

December 29, 2023:
Expand Down
2 changes: 1 addition & 1 deletion mednafen/Documentation/modules.def
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EMU4CRT-1.32.0-UNSTABLE
EMU4CRT-1.32.1
apple2
Apple II/II+/IIe/Enhanced IIe
250
Expand Down
6 changes: 3 additions & 3 deletions mednafen/src/apple2/apple2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2619,7 +2619,7 @@ static void Load(GameFile* gf)
for(unsigned A = 0xC05E; A < 0xC060; A++)
SetRWHandlers(A, RWSoftSwitch_AN3_IIE, RWSoftSwitch_AN3_IIE);

for(unsigned A = 0xC080; A < 0xC08F; A++)
for(unsigned A = 0xC080; A < 0xC090; A++)
SetRWHandlers(A, RWLangCardControl_IIE<true>, RWLangCardControl_IIE<false>);

for(unsigned A = 0xD000; A < 0xE000; A++)
Expand All @@ -2632,7 +2632,7 @@ static void Load(GameFile* gf)
{
assert(!EnableROMCard);

for(unsigned A = 0xC080; A < 0xC08F; A++)
for(unsigned A = 0xC080; A < 0xC090; A++)
SetRWHandlers(A, RWLangCardControl<true>, RWLangCardControl<false>);

for(unsigned A = 0xD000; A < 0xE000; A++)
Expand All @@ -2645,7 +2645,7 @@ static void Load(GameFile* gf)
{
if(EnableROMCard)
{
for(unsigned A = 0xC080; A < 0xC08F; A++)
for(unsigned A = 0xC080; A < 0xC090; A++)
SetRWHandlers(A, RWROMCardControl, RWROMCardControl);
}

Expand Down
8 changes: 5 additions & 3 deletions mednafen/src/apple2/disk2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,10 +918,11 @@ static void LoadWOZ(Stream* sp, FloppyDisk* disk)
{
const uint32 chunk_id = MDFN_de32lsb(&chunk_header[0]);
const uint32 chunk_size = MDFN_de32lsb(&chunk_header[4]);
const uint64 chunk_data_pos = sp->tell();

if(chunk_id == 0x4F464E49) // INFO
{
if(sp->tell() != 20)
if(chunk_data_pos != 20)
throw MDFN_Error(0, _("Required chunk \"%s\" is at the wrong offset."), "INFO");

if(chunk_size != 60)
Expand Down Expand Up @@ -1006,7 +1007,7 @@ static void LoadWOZ(Stream* sp, FloppyDisk* disk)
}
else if(chunk_id == 0x50414D54) // TMAP
{
if(sp->tell() != 88)
if(chunk_data_pos != 88)
throw MDFN_Error(0, _("Required chunk \"%s\" is at the wrong offset."), "TMAP");

if(chunk_size != 160)
Expand All @@ -1024,7 +1025,7 @@ static void LoadWOZ(Stream* sp, FloppyDisk* disk)
}
else if(chunk_id == 0x534B5254) // TRKS
{
if(sp->tell() != 256)
if(chunk_data_pos != 256)
throw MDFN_Error(0, _("Required chunk \"%s\" is at the wrong offset."), "TRKS");

src_tracks.reset(new FloppyDisk::Track[num_src_tracks]);
Expand Down Expand Up @@ -1139,6 +1140,7 @@ static void LoadWOZ(Stream* sp, FloppyDisk* disk)
printf("%c", sp->get_u8());
}
*/
sp->seek(chunk_data_pos + chunk_size, SEEK_SET);
}

if(!(required_chunks & 1))
Expand Down
6 changes: 3 additions & 3 deletions mednafen/src/compress/ZIPReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* Mednafen - Multi-system Emulator */
/******************************************************************************/
/* ZIPReader.cpp:
** Copyright (C) 2018-2021 Mednafen Team
** Copyright (C) 2018-2024 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -81,11 +81,11 @@ StreamViewFilter::~StreamViewFilter()

uint64 StreamViewFilter::read(void *data, uint64 count, bool error_on_eos)
{
const uint64 size_ = ss_bound_pos - ss_start_pos;
uint64 cc = count;
uint64 ret;

cc = std::min<uint64>(cc, ss_bound_pos - ss_start_pos);
cc = std::min<uint64>(cc, ss_bound_pos - std::min<uint64>(ss_bound_pos, pos));
cc = std::min<uint64>(cc, size_ - std::min<uint64>(size_, pos));

if(cc < count && error_on_eos)
throw MDFN_Error(0, _("Error reading from %s: %s"), vfcontext.c_str(), _("Unexpected EOF"));
Expand Down
65 changes: 61 additions & 4 deletions mednafen/src/drivers/Joystick_SDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* Mednafen - Multi-system Emulator */
/******************************************************************************/
/* Joystick_SDL.cpp:
** Copyright (C) 2012-2018 Mednafen Team
** Copyright (C) 2012-2023 Mednafen Team
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -36,22 +36,29 @@ class Joystick_SDL : public Joystick

void UpdateInternal(void);

virtual unsigned HatToButtonCompat(unsigned hat);
virtual void SetRumble(uint8 weak_intensity, uint8 strong_intensity) override;

virtual unsigned HatToButtonCompat(unsigned hat) override;

private:
SDL_Joystick *sdl_joy;
SDL_Joystick* sdl_joy;
unsigned sdl_num_axes;
unsigned sdl_num_hats;
unsigned sdl_num_balls;
unsigned sdl_num_buttons;
//
SDL_Haptic* sdl_haptic;

SDL_HapticEffect effect;
int effect_id;
};

unsigned Joystick_SDL::HatToButtonCompat(unsigned hat)
{
return(sdl_num_buttons + (hat * 4));
}

Joystick_SDL::Joystick_SDL(unsigned index) : sdl_joy(NULL)
Joystick_SDL::Joystick_SDL(unsigned index) : sdl_joy(NULL), sdl_haptic(NULL), effect_id(-1)
{
sdl_joy = SDL_JoystickOpen(index);
if(sdl_joy == NULL)
Expand Down Expand Up @@ -95,9 +102,39 @@ Joystick_SDL::Joystick_SDL(unsigned index) : sdl_joy(NULL)
axis_state.resize(num_axes);
rel_axis_state.resize(num_rel_axes);
button_state.resize(num_buttons);
//
//
#if 0
if(SDL_JoystickIsHaptic(sdl_joy) > 0)
{
if(!(sdl_haptic = SDL_HapticOpenFromJoystick(sdl_joy)))
throw MDFN_Error(0, _("SDL_HapticOpenFromJoystick() failed: %s"), SDL_GetError());

memset(&effect, 0, sizeof(effect));

effect.type = SDL_HAPTIC_LEFTRIGHT;
effect.leftright.small_magnitude = 0;
effect.leftright.large_magnitude = 0;
effect.leftright.length = 3000;

if(SDL_HapticEffectSupported(sdl_haptic, &effect) > 0)
{
if((effect_id = SDL_HapticNewEffect(sdl_haptic, &effect)) == -1)
throw MDFN_Error(0, _("SDL_HapticNewEffect() failed: %s"), SDL_GetError());
}
else
{
SDL_HapticClose(sdl_haptic);
sdl_haptic = NULL;
}
}
#endif
}
catch(...)
{
if(sdl_haptic)
SDL_HapticClose(sdl_haptic);

if(sdl_joy)
SDL_JoystickClose(sdl_joy);

Expand All @@ -107,13 +144,31 @@ Joystick_SDL::Joystick_SDL(unsigned index) : sdl_joy(NULL)

Joystick_SDL::~Joystick_SDL()
{
if(sdl_haptic)
{
SDL_HapticClose(sdl_haptic);
sdl_haptic = NULL;
}

if(sdl_joy)
{
SDL_JoystickClose(sdl_joy);
sdl_joy = NULL;
}
}

void Joystick_SDL::SetRumble(uint8 weak_intensity, uint8 strong_intensity)
{
if(!sdl_haptic || effect_id == -1)
return;
//
effect.leftright.small_magnitude = weak_intensity * (65535 / 255) / 2;
effect.leftright.large_magnitude = strong_intensity * (65535 / 255) / 2;

SDL_HapticUpdateEffect(sdl_haptic, effect_id, &effect);
SDL_HapticRunEffect(sdl_haptic, effect_id, 1);
}

void Joystick_SDL::UpdateInternal(void)
{
for(unsigned i = 0; i < sdl_num_axes; i++)
Expand Down Expand Up @@ -168,6 +223,7 @@ class JoystickDriver_SDL : public JoystickDriver
JoystickDriver_SDL::JoystickDriver_SDL()
{
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
SDL_InitSubSystem(SDL_INIT_HAPTIC);

for(int n = 0; n < SDL_NumJoysticks(); n++)
{
Expand All @@ -190,6 +246,7 @@ JoystickDriver_SDL::~JoystickDriver_SDL()
delete joys[n];
}

SDL_QuitSubSystem(SDL_INIT_HAPTIC);
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}

Expand Down
75 changes: 46 additions & 29 deletions mednafen/src/drivers/logdebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,43 +214,60 @@ int LogDebugger_Event(const SDL_Event *event)
{
default: break;

case SDLK_MINUS: Debugger_GT_ModOpacity(-8);
break;
case SDLK_EQUALS: Debugger_GT_ModOpacity(8);
break;
case SDLK_MINUS:
Debugger_GT_ModOpacity(-8);
break;

case SDLK_EQUALS:
Debugger_GT_ModOpacity(8);
break;

case SDLK_HOME: WhichLog->LogScroll = 0;
break;
case SDLK_HOME:
WhichLog->LogScroll = 0;
break;

case SDLK_END: ChangePos(1 << 30);
break;
case SDLK_END:
ChangePos(1 << 30);
break;

case SDLK_LEFT:
case SDLK_COMMA:
LogGroupSelect(-1);
break;
LogGroupSelect(-1);
break;

case SDLK_RIGHT:
case SDLK_PERIOD: LogGroupSelect(1);
break;

case SDLK_UP: ChangePos(-1);
break;

case SDLK_DOWN: ChangePos(1);
break;

case SDLK_PAGEUP: ChangePos(-32);
break;

case SDLK_PAGEDOWN: ChangePos(32);
break;

case SDLK_t:LoggingActive = !LoggingActive;
if(CurGame->Debugger->SetLogFunc)
CurGame->Debugger->SetLogFunc(LoggingActive ? TheLogger : NULL);
break;
case SDLK_PERIOD:
LogGroupSelect(1);
break;

case SDLK_UP:
if(event->key.keysym.mod & KMOD_CTRL)
Debugger_GT_ModOpacity(8);
else
ChangePos(-1);
break;

case SDLK_DOWN:
if(event->key.keysym.mod & KMOD_CTRL)
Debugger_GT_ModOpacity(-8);
else
ChangePos(1);
break;

case SDLK_PAGEUP:
ChangePos(-32);
break;

case SDLK_PAGEDOWN:
ChangePos(32);
break;

case SDLK_t:
LoggingActive = !LoggingActive;

if(CurGame->Debugger->SetLogFunc)
CurGame->Debugger->SetLogFunc(LoggingActive ? TheLogger : NULL);
break;
}
break;

Expand Down
9 changes: 7 additions & 2 deletions mednafen/src/psx/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,10 @@ static INLINE uint32 MDFN_NOWARN_UNUSED ShiftHelper(uint32 val, int shamt, uint3
}
#endif

#pragma GCC push_options
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC push_options
#pragma GCC optimize("no-unroll-loops,no-peel-loops,no-crossjumping")
#endif
#pragma GCC optimize("no-unroll-loops,no-peel-loops,no-crossjumping")
static INLINE void ReorderRGB_Var(uint32 out_Rshift, uint32 out_Gshift, uint32 out_Bshift, bool bpp24, const uint16 *src, uint32 *dest, const int32 dx_start, const int32 dx_end, int32 fb_x)
{
Expand Down Expand Up @@ -1241,7 +1244,9 @@ static NO_INLINE void ReorderRGB(bool bpp24, const uint16 *src, uint32 *dest, co
{
ReorderRGB_Var(out_Rshift, out_Gshift, out_Bshift, bpp24, src, dest, dx_start, dx_end, fb_x);
}
#pragma GCC pop_options
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC pop_options
#endif

MDFN_FASTCALL pscpu_timestamp_t GPU_Update(const pscpu_timestamp_t sys_timestamp)
{
Expand Down
17 changes: 9 additions & 8 deletions mednafen/src/ss/vdp1_poly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ static int32 PolygonResumeBase(const uint16* cmd_data)
const bool SPD_Opaque = (((mode >> 3) & 0x7) < 0x6) ? ((int32)(TexFetchTab[(mode >> 3) & 0x1F](0xFFFFFFFF)) >= 0) : true;
auto* const fnptr = LineFuncTab[(bool)(FBCR & FBCR_DIE)][(TVMR & TVMR_8BPP) ? ((TVMR & TVMR_ROTATE) ? 2 : 1) : 0][((mode >> 6) & 0x1E) | SPD_Opaque /*(mode >> 6) & 0x1F*/][(mode & 0x8000) ? 8 : (mode & 0x7)];
//
// Don't merge e0 and e1 into a single array, keeping them separate is a workaround for gcc bug #113255
//
//
EdgeStepper e[2] = { PrimData.e[0], PrimData.e[1] };
EdgeStepper e0 = PrimData.e[0];
EdgeStepper e1 = PrimData.e[1];
int32 iter = PrimData.iter;
int32 ret = 0;
//
Expand All @@ -97,8 +98,8 @@ static int32 PolygonResumeBase(const uint16* cmd_data)
{
//printf("x=0x%03x y=0x%03x x_error=0x%04x y_error=0x%04x --- x_error_inc=0x%04x, x_error_adj=0x%04x --- y_error_inc=0x%04x, y_error_adj=0x%04x\n", e[0].x & 0x7FF, e[0].y & 0x7FF, (uint32)e[0].x_error >> (32 - 13), (uint32)e[0].y_error >> (32 - 13), (uint32)e[0].x_error_inc >> (32 - 13), (uint32)e[0].x_error_adj >> (32 - 13), (uint32)e[0].y_error_inc >> (32 - 13), (uint32)e[0].y_error_adj >> (32 - 13));

e[0].GetVertex<gourauden>(&LineData.p[0]);
e[1].GetVertex<gourauden>(&LineData.p[1]);
e0.GetVertex<gourauden>(&LineData.p[0]);
e1.GetVertex<gourauden>(&LineData.p[1]);

#if 0
printf("(Edge0: x=%u y=%u, d_error=0x%04x x_error=0x%04x y_error=0x%04x) ", LineData.p[0].x, LineData.p[0].y, (e[0].d_error + e[0].d_error_inc) >> (32 - 13), (e[0].x_error + e[0].x_error_inc) >> (32 - 13), (e[0].y_error + e[0].y_error_inc) >> (32 - 13));
Expand All @@ -116,14 +117,14 @@ static int32 PolygonResumeBase(const uint16* cmd_data)
break;
}

e[0].Step<gourauden>();
e[1].Step<gourauden>();
e0.Step<gourauden>();
e1.Step<gourauden>();
} while(MDFN_LIKELY(--iter >= 0 && ret < VDP1_SuspendResumeThreshold));
}
//
//
PrimData.e[0] = e[0];
PrimData.e[1] = e[1];
PrimData.e[0] = e0;
PrimData.e[1] = e1;
PrimData.iter = iter;

return ret;
Expand Down
Loading

0 comments on commit 8832c08

Please sign in to comment.