Skip to content

Commit

Permalink
Merge pull request #52 from retro-wertz/master
Browse files Browse the repository at this point in the history
selected bug fixes from 0.9.39.2
  • Loading branch information
hizzlekizzle committed Feb 1, 2019
2 parents 555e292 + aa42215 commit c3b269c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -602,15 +602,14 @@ else
endif

$(TARGET): $(OBJECTS)
@echo "** BUILDING $(TARGET) FOR PLATFORM $(platform) **"

ifeq ($(platform), emscripten)
$(CXX) $(CXXFLAGS) $(OBJOUT)$@ $^
else ifeq ($(STATIC_LINKING), 1)
$(AR) rcs $@ $(OBJECTS)
else
$(LD) $(LINKOUT)$@ $^ $(LDFLAGS) $(LIBS)
endif
@echo "** BUILD SUCCESSFUL! GG NO RE **"

%.o: %.cpp
$(CXX) -c $(OBJOUT)$@ $< $(CPPFLAGS) $(CXXFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion mednafen/hw_cpu/z80-fuse/z80.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void z80_reset( void )
IFF1=IFF2=IM=0;
z80.halted=0;

z80.interrupts_enabled_at = -1;
z80.interrupts_enabled_at = 0;
z80_tstates = last_z80_tstates = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion mednafen/hw_cpu/z80-fuse/z80_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef struct processor {

/* Interrupts were enabled at this time; do not accept any interrupts
until z80_tstates > this value */
int32_t interrupts_enabled_at;
uint64_t interrupts_enabled_at;

} processor;

Expand Down
16 changes: 13 additions & 3 deletions mednafen/ngp/T6W28_Apu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ T6W28_ApuState *T6W28_Apu::save_state(void)

for(x = 0; x < 4; x++)
{
ret->delay[x] = oscs[x]->delay;
ret->volume_left[x] = oscs[x]->volume_left;
ret->volume_right[x] = oscs[x]->volume_right;
}
Expand All @@ -377,6 +378,7 @@ T6W28_ApuState *T6W28_Apu::save_state(void)
}
ret->noise_shifter = noise.shifter;
ret->noise_tap = noise.tap;
ret->noise_period_extra = noise.period_extra;

if(noise.period == &noise_periods[0])
ret->noise_period = 0;
Expand All @@ -386,30 +388,38 @@ T6W28_ApuState *T6W28_Apu::save_state(void)
ret->noise_period = 2;
else ret->noise_period = 3;

ret->latch_left = latch_left;
ret->latch_right = latch_right;

return(ret);
}

void T6W28_Apu::load_state(T6W28_ApuState *state)
{
int x, select;
unsigned x, select;
for(x = 0; x < 4; x++)
{
oscs[x]->delay = state->delay[x];
oscs[x]->volume_left = state->volume_left[x];
oscs[x]->volume_right = state->volume_right[x];
}
for(x = 0; x < 3; x++)
{
squares[x].period = state->sq_period[x];
squares[x].period = state->sq_period[x] & 0x3FFF;
squares[x].phase = state->sq_phase[x];
}
noise.shifter = state->noise_shifter;
noise.tap = state->noise_tap = noise.tap;
noise.tap = state->noise_tap;
noise.period_extra = state->noise_period_extra & 0x3FFF;

select = state->noise_period;

if ( select < 3 )
noise.period = &noise_periods [select];
else
noise.period = &noise.period_extra;

latch_left = state->latch_left;
latch_right = state->latch_right;
}

4 changes: 3 additions & 1 deletion mednafen/ngp/T6W28_Apu.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ typedef struct
{
int32_t sq_period[3];
int32_t sq_phase[3];
int32_t noise_period;
uint32_t noise_period;
uint32_t noise_period_extra;
uint32_t noise_shifter;
uint32_t noise_tap;

int32_t delay[4];
int32_t volume_left[4];
int32_t volume_right[4];
uint8_t latch_left, latch_right;
Expand Down
10 changes: 5 additions & 5 deletions mednafen/ngp/mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ static void* translate_address_read(uint32 address)
if (address >= ROM_START && address <= ROM_END)
{
/* ROM (LOW) */
if (address <= ROM_START + ngpc_rom.length)
if (address < ROM_START + ngpc_rom.length)
return ngpc_rom.data + (address - ROM_START);
return NULL;
}

if (address >= HIROM_START && address <= HIROM_END)
{
/* ROM (HIGH) */
if (address <= HIROM_START + (ngpc_rom.length - 0x200000))
if (address < HIROM_START + (ngpc_rom.length - 0x200000))
return ngpc_rom.data + 0x200000 + (address - HIROM_START);
return NULL;
}
Expand All @@ -134,15 +134,15 @@ static void *translate_address_write(uint32 address)
/* ROM (LOW) */
if (address >= ROM_START && address <= ROM_END)
{
if (address <= ROM_START + ngpc_rom.length)
if (address < ROM_START + ngpc_rom.length)
return ngpc_rom.data + (address - ROM_START);
return NULL;
}

/* ROM (HIGH) */
if (address >= HIROM_START && address <= HIROM_END)
{
if (address <= HIROM_START + (ngpc_rom.length - 0x200000))
if (address < HIROM_START + (ngpc_rom.length - 0x200000))
return ngpc_rom.data + 0x200000 + (address - HIROM_START);
return NULL;
}
Expand Down Expand Up @@ -182,7 +182,7 @@ static void *translate_address_write(uint32 address)
// system_debug_stop();

//Write to the rom itself.
if (address <= ROM_START + ngpc_rom.length)
if (address < ROM_START + ngpc_rom.length)
return ngpc_rom.data + (address - ROM_START);
}
}
Expand Down
2 changes: 2 additions & 0 deletions mednafen/ngp/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,15 @@ int MDFNNGPCSOUND_StateAction(void *data, int load, int data_only)

SFVAR(schipenable),

SFARRAY32N(sn_state->delay, 4, "Delay"),
SFARRAY32N(sn_state->volume_left, 4, "VolumeLeft"),
SFARRAY32N(sn_state->volume_right, 4, "VolumeRight"),
SFARRAY32N(sn_state->sq_period, 3, "SQPeriod"),
SFARRAY32N(sn_state->sq_phase, 3, "SQPhase"),
SFVARN(sn_state->noise_period, "NPeriod"),
SFVARN(sn_state->noise_shifter, "NShifter"),
SFVARN(sn_state->noise_tap, "NTap"),
SFVARN(sn_state->noise_period_extra, "NPeriodExtra"),
SFVARN(sn_state->latch_left, "LatchLeft"),
SFVARN(sn_state->latch_right, "LatchRight"),
SFEND
Expand Down

0 comments on commit c3b269c

Please sign in to comment.