fixed m68k 32 bits writes at memory boundaries

fixed UKM3 memory map being incorrectly reseted
added LFO current steps to YM2612 context
fixed IO reinitialization in controllers menu
This commit is contained in:
ekeeke31 2009-08-09 09:33:48 +00:00
parent 5d1f29637e
commit cfa4a08211
12 changed files with 65 additions and 66 deletions

View File

@ -203,7 +203,7 @@ void cart_hw_init()
}
/* ROM is mirrored each 2^k bytes */
cart.mask = size -1;
cart.mask = size - 1;
/**********************************************
DEFAULT CARTRIDGE MAPPING
@ -296,7 +296,7 @@ void cart_hw_init()
((strstr(rominfo.product,"XXXXXXXX") != NULL) && (rominfo.checksum == 0xdf39)) || /* Sampras Tennis 96 */
((strstr(rominfo.product,"T-123456") != NULL) && (rominfo.checksum == 0x1eae)) || /* Sampras Tennis 96 */
((strstr(rominfo.product,"T-120066") != NULL) && (rominfo.checksum == 0x16a4)) || /* Pete Sampras Tennis (1994)*/
(strstr(rominfo.product,"T-120096") != NULL)) /* Micro Machines 2 */
(strstr(rominfo.product,"T-120096") != NULL)) /* Micro Machines 2 */
{
if (cart.romsize <= 0x380000) /* just to be sure (checksum might not be enough) */
{
@ -532,9 +532,9 @@ static void sega_mapper_w(uint32 address, uint32 data)
/* SRAM write enabled */
for (i=0x20; i<0x40; i++)
{
m68k_memory_map[0x20].write8 = NULL;
m68k_memory_map[0x20].write16 = NULL;
zbank_memory_map[0x20].write = NULL;
m68k_memory_map[i].write8 = NULL;
m68k_memory_map[i].write16 = NULL;
zbank_memory_map[i].write = NULL;
}
}
}

View File

@ -93,7 +93,7 @@ static inline void lightgun_update(int num)
}
/* Sega Menacer specific */
uint32 menacer_read()
uint32 menacer_read(void)
{
/* pins should return 0 by default (fix Body Count when mouse is enabled) */
int retval = 0x00;
@ -106,7 +106,7 @@ uint32 menacer_read()
}
/* Konami Justifier specific */
uint32 justifier_read()
uint32 justifier_read(void)
{
/* TL & TR pins should always return 1 (write only) */
/* LEFT & RIGHT pins should always return 0 (needed during gun detection) */
@ -144,7 +144,7 @@ static struct mega_mouse
uint8 Port;
} mouse;
static inline void mouse_reset()
static inline void mouse_reset(void)
{
mouse.State = 0x60;
mouse.Counter = 0;
@ -620,7 +620,7 @@ void jcart_write(uint32 address, uint32 data)
* Generic INPUTS Control
*
*****************************************************************************/
void input_init ()
void input_init(void)
{
int i,j;

View File

@ -118,6 +118,6 @@ void config_default(void)
/* restore saved configuration */
config_load();
io_reset();
io_init();
}

View File

@ -1304,6 +1304,9 @@ static void ctrlmenu(void)
input.system[0] = NO_SYSTEM;
input.system[1] = SYSTEM_GAMEPAD;
}
old_system[0] = -1;
old_system[1] = -1;
io_init();
io_reset();
old_system[0] = input.system[0];
old_system[1] = input.system[1];
@ -1351,6 +1354,9 @@ static void ctrlmenu(void)
input.system[1] = NO_SYSTEM;
input.system[0] = SYSTEM_GAMEPAD;
}
old_system[0] = -1;
old_system[1] = -1;
io_init();
io_reset();
old_system[0] = input.system[0];
old_system[1] = input.system[1];
@ -1480,7 +1486,8 @@ static void ctrlmenu(void)
{
if (config.input[player].device == 1) break;
config.input[player].padtype ^= 1;
io_reset();
input_init();
input_reset();
}
else
{

View File

@ -1073,6 +1073,7 @@ INLINE uint m68ki_read_imm_16(void)
return m68k_read_immediate_16(REG_PC-2);
#endif /* M68K_EMULATE_PREFETCH */
}
INLINE uint m68ki_read_imm_32(void)
{
#if M68K_EMULATE_PREFETCH
@ -1123,6 +1124,7 @@ INLINE uint m68ki_read_8_fc(uint address, uint fc)
if (temp->read8) return (*temp->read8)(ADDRESS_68K(address));
else return READ_BYTE(temp->base, (address) & 0xffff);
}
INLINE uint m68ki_read_16_fc(uint address, uint fc)
{
m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */
@ -1132,6 +1134,7 @@ INLINE uint m68ki_read_16_fc(uint address, uint fc)
if (temp->read16) return (*temp->read16)(ADDRESS_68K(address));
else return *(uint16 *)(temp->base + ((address) & 0xffff));
}
INLINE uint m68ki_read_32_fc(uint address, uint fc)
{
m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */
@ -1149,6 +1152,7 @@ INLINE void m68ki_write_8_fc(uint address, uint fc, uint value)
if (temp->write8) (*temp->write8)(ADDRESS_68K(address),value);
else WRITE_BYTE(temp->base, (address) & 0xffff, value);
}
INLINE void m68ki_write_16_fc(uint address, uint fc, uint value)
{
m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */
@ -1157,22 +1161,17 @@ INLINE void m68ki_write_16_fc(uint address, uint fc, uint value)
if (temp->write16) (*temp->write16)(ADDRESS_68K(address),value);
else *(uint16 *)(temp->base + ((address) & 0xffff)) = value;
}
INLINE void m68ki_write_32_fc(uint address, uint fc, uint value)
{
m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */
m68ki_check_address_error_010_less(address, MODE_WRITE, fc); /* auto-disable (see m68kcpu.h) */
_m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff];
if (temp->write16)
{
(*temp->write16)(ADDRESS_68K(address),value>>16);
(*temp->write16)(ADDRESS_68K(address+2),value&0xffff);
}
else
{
*(uint16 *)(temp->base + ((address) & 0xffff)) = value >> 16;
temp = &m68k_memory_map[((address + 2)>>16)&0xff];
*(uint16 *)(temp->base + ((address + 2) & 0xffff)) = value;
}
if (temp->write16) (*temp->write16)(ADDRESS_68K(address),value>>16);
else *(uint16 *)(temp->base + ((address) & 0xffff)) = value >> 16;
temp = &m68k_memory_map[((address + 2)>>16)&0xff];
if (temp->write16) (*temp->write16)(ADDRESS_68K(address+2),value&0xffff);
else *(uint16 *)(temp->base + ((address + 2) & 0xffff)) = value;
}
#if M68K_SIMULATE_PD_WRITES

View File

@ -597,6 +597,9 @@ typedef struct
UINT32 lfo_cnt; /* current LFO phase */
UINT32 lfo_inc; /* step of LFO counter */
UINT32 lfo_freq[8]; /* LFO FREQ table */
UINT32 LFO_AM; /* current LFO AM step */
INT32 LFO_PM; /* current LFO PM step */
} FM_OPN;
/***********************************************************/
@ -617,9 +620,6 @@ static YM2612 ym2612;
static INT32 m2,c1,c2; /* Phase Modulation input for operators 2,3,4 */
static INT32 mem; /* one sample delay memory */
static INT32 out_fm[8]; /* outputs of working channels */
static UINT32 LFO_AM; /* runtime LFO calculations helper */
static INT32 LFO_PM; /* runtime LFO calculations helper */
/* limitter */
#define Limit(val, max,min) { \
@ -1009,12 +1009,12 @@ INLINE void advance_lfo()
/* triangle */
/* AM: 0 to 126 step +2, 126 to 0 step -2 */
if (pos<64)
LFO_AM = pos * 2;
ym2612.OPN.LFO_AM = pos * 2;
else
LFO_AM = 126 - ((pos&63) * 2);
ym2612.OPN.LFO_AM = 126 - ((pos&63) * 2);
/* PM works with 4 times slower clock */
LFO_PM = pos >> 2;
ym2612.OPN.LFO_PM = pos >> 2;
}
/* when LFO is disabled, current level is held (fix Spider-Man & Venom : Separation Anxiety) */
/*else
@ -1229,7 +1229,7 @@ INLINE void update_ssg_eg_channel(FM_SLOT *SLOT)
INLINE void update_phase_lfo_slot(FM_SLOT *SLOT , INT32 pms, UINT32 block_fnum)
{
UINT32 fnum_lfo = ((block_fnum & 0x7f0) >> 4) * 32 * 8;
INT32 lfo_fn_table_index_offset = lfo_pm_table[ fnum_lfo + pms + LFO_PM ];
INT32 lfo_fn_table_index_offset = lfo_pm_table[ fnum_lfo + pms + ym2612.OPN.LFO_PM ];
if (lfo_fn_table_index_offset) /* LFO phase modulation active */
{
@ -1261,7 +1261,7 @@ INLINE void update_phase_lfo_channel(FM_CH *CH)
UINT32 block_fnum = CH->block_fnum;
UINT32 fnum_lfo = ((block_fnum & 0x7f0) >> 4) * 32 * 8;
INT32 lfo_fn_table_index_offset = lfo_pm_table[ fnum_lfo + CH->pms + LFO_PM ];
INT32 lfo_fn_table_index_offset = lfo_pm_table[ fnum_lfo + CH->pms + ym2612.OPN.LFO_PM ];
if (lfo_fn_table_index_offset) /* LFO phase modulation active */
{
@ -1305,16 +1305,13 @@ INLINE void update_phase_lfo_channel(FM_CH *CH)
INLINE void chan_calc(FM_CH *CH)
{
unsigned int eg_out;
UINT32 AM = LFO_AM >> CH->ams;
UINT32 AM = ym2612.OPN.LFO_AM >> CH->ams;
m2 = c1 = c2 = mem = 0;
*CH->mem_connect = CH->mem_value; /* restore delayed sample (MEM) value to m2 or c2 */
eg_out = volume_calc(&CH->SLOT[SLOT1]);
unsigned int eg_out = volume_calc(&CH->SLOT[SLOT1]);
{
INT32 out = CH->op1_out[0] + CH->op1_out[1];
CH->op1_out[0] = CH->op1_out[1];
@ -1459,11 +1456,11 @@ static void reset_channels(FM_CH *CH , int num )
CH[c].fc = 0;
for(s = 0 ; s < 4 ; s++ )
{
CH[c].SLOT[s].ssg = 0;
CH[c].SLOT[s].ssgn = 0;
CH[c].SLOT[s].state= EG_OFF;
CH[c].SLOT[s].volume = MAX_ATT_INDEX;
CH[c].SLOT[s].vol_out= MAX_ATT_INDEX;
CH[c].SLOT[s].ssg = 0;
CH[c].SLOT[s].ssgn = 0;
CH[c].SLOT[s].state = EG_OFF;
CH[c].SLOT[s].volume = MAX_ATT_INDEX;
CH[c].SLOT[s].vol_out = MAX_ATT_INDEX;
}
}
}
@ -1668,9 +1665,9 @@ INLINE void OPNWriteMode(int r, int v)
if (!ym2612.OPN.lfo_inc)
{
/* restart LFO */
ym2612.OPN.lfo_cnt = 0;
LFO_AM = 0;
LFO_PM = 0;
ym2612.OPN.lfo_cnt = 0;
ym2612.OPN.LFO_AM = 0;
ym2612.OPN.LFO_PM = 0;
}
ym2612.OPN.lfo_inc = ym2612.OPN.lfo_freq[v&7];
@ -2071,9 +2068,9 @@ int YM2612ResetChip(void)
ym2612.OPN.eg_timer = 0;
ym2612.OPN.eg_cnt = 0;
LFO_AM = 0;
LFO_PM = 0;
ym2612.OPN.lfo_cnt = 0;
ym2612.OPN.LFO_AM = 0;
ym2612.OPN.LFO_PM = 0;
ym2612.OPN.ST.TAC = 0;
ym2612.OPN.ST.TBC = 0;

View File

@ -24,7 +24,7 @@
#define _STATE_H_
#define STATE_SIZE 0x28000
#define STATE_VERSION "GENPLUS-GX 1.4.0"
#define STATE_VERSION "GENPLUS-GX 1.4.x"
/* Function prototypes */
extern int state_load(unsigned char *buffer);

View File

@ -141,12 +141,9 @@ int audio_init (int rate)
snd.sample_rate = rate;
/* Calculate the sound buffer size (for one frame) */
#ifdef NGC
snd.buffer_size = (rate / vdp_rate) + 8;
#else
snd.buffer_size = (rate / vdp_rate);
#ifndef NGC
/* Output buffers */
snd.buffer[0] = (int16 *) malloc(SND_SIZE);
snd.buffer[1] = (int16 *) malloc(SND_SIZE);
@ -204,14 +201,14 @@ void audio_shutdown(void)
****************************************************************/
void system_init (void)
{
/* Cartridge hardware (should be done first !) */
cart_hw_init();
/* Genesis hardware */
gen_init ();
vdp_init ();
render_init ();
io_init();
/* Cartridge hardware */
cart_hw_init();
}
/****************************************************************
@ -219,7 +216,7 @@ void system_init (void)
****************************************************************/
void system_reset (void)
{
/* Cartridge hardware (should be done first !) */
/* Cartridge Hardware */
cart_hw_reset();
/* Genesis hardware */

View File

@ -101,6 +101,8 @@ void set_config_defaults(void)
config.hq_fm = 1;
config.psgBoostNoise = 0;
config.filter = 1;
config.low_freq = 200;
config.high_freq = 20000;
config.lg = 1.0;
config.mg = 1.0;
config.hg = 1.0;

View File

@ -64,6 +64,8 @@ typedef struct
int32 psg_preamp;
int32 fm_preamp;
uint8 filter;
uint16 low_freq;
uint16 high_freq;
float lg;
float mg;
float hg;

View File

@ -13,7 +13,7 @@ NAME = ../gen_sdl.exe
CC = gcc
CFLAGS = `sdl-config --cflags` -O6 -march=i686 -fomit-frame-pointer
DEFINES = -DLSB_FIRST -DX86_ASM -DLOGERROR=1
INCLUDES = -I. -I.. -I../z80 -I../m68k -I../dos -I../sound -I../sound/SRC -I../cart_hw -I../cart_hw/svp -I../ntsc
INCLUDES = -I. -I.. -I../z80 -I../m68k -I../sound -I../cart_hw -I../cart_hw/svp -I../ntsc
LIBS = `sdl-config --libs` -lz -lm
OBJECTS = obj/z80.o
@ -37,19 +37,19 @@ OBJECTS += obj/sound.o \
obj/sn76489.o \
obj/ym2612.o
OBJECTS += obj/samplerate.o \
obj/src_linear.o \
obj/src_sinc.o \
obj/src_zoh.o \
OBJECTS += obj/blip.o \
obj/Fir_Resampler.o
OBJECTS += obj/eq.o \
OBJECTS += obj/filters.o \
OBJECTS += obj/sram.o \
obj/eeprom.o \
obj/svp.o \
obj/ssp16.o \
obj/ggenie.o \
obj/datel.o \
obj/cart_hw.o
OBJECTS += obj/main.o \
@ -80,11 +80,6 @@ obj/%.o : ../sound/%.c ../sound/%.h
obj/%.o : ../sound/%.c
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../sound/SRC/%.c ../sound/SRC/%.h
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../sound/SRC/%.c
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../cart_hw/%.c ../cart_hw/%.h
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@

View File

@ -23,7 +23,7 @@ void set_config_defaults(void)
/* system options */
config.region_detect = 0;
config.force_dtack = 0;
config.addr_error = 0;
config.addr_error = 1;
config.bios_enabled = 0;
config.lock_on = 0;
config.romtype = 0;