added support for one EEPROM game, code cleanup

This commit is contained in:
ekeeke31 2009-01-07 17:12:03 +00:00
parent e774dc03ae
commit cb7149fb6b
10 changed files with 59 additions and 60 deletions

View File

@ -26,7 +26,7 @@ INCLUDES := source source/m68k source/z80 source/sound source/sound/SRC source/n
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -O3 -mrvl -Wall $(MACHDEP) -Wno-strict-aliasing $(INCLUDE) -DWORDS_BIGENDIAN -DNGC="1" -DHW_RVL
CFLAGS = -O3 -g -mrvl -Wall $(MACHDEP) -Wno-strict-aliasing $(INCLUDE) -DWORDS_BIGENDIAN -DNGC="1" -DHW_RVL
CXXFLAGS = $(CFLAGS)
LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map

View File

@ -28,7 +28,7 @@ typedef struct
T_EEPROM_TYPE type;
} T_GAME_ENTRY;
T_GAME_ENTRY database[24] =
T_GAME_ENTRY database[25] =
{
/* ACCLAIM mappers */
/* 24C02 (old mapper) */
@ -57,6 +57,7 @@ T_GAME_ENTRY database[24] =
{{"PR-1993" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Greatest Heavyweights of the Ring (E) */
{{"G-4060" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Wonderboy in Monster World */
{{"00001211-00"}, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Sports Talk Baseball */
{{"00004076-00"}, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Honoo no Toukyuuji Dodge Danpei */
/* CODEMASTERS mapper */
/* 24C01 */

View File

@ -45,7 +45,7 @@ void sram_init()
memset (&sram.sram[0], 0xFF, 0x10000);
sram.crc = crc32 (0, &sram.sram[0], 0x10000);
if ((cart_rom[0x1b0] == 0x52) && (cart_rom[0x1b1] == 0x41))
if ((READ_BYTE(cart_rom,0x1b0) == 0x52) && (READ_BYTE(cart_rom,0x1b1) == 0x41))
{
/* retrieve informations from headezr */
sram.detected = 1;

View File

@ -1136,7 +1136,8 @@ void MainMenu ()
/* Switch to menu default rendering mode (60hz or 50hz, but always 480 lines) */
VIDEO_Configure (vmode);
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK);
VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK);
VIDEO_Flush();
VIDEO_WaitVSync();
VIDEO_WaitVSync();
@ -1221,11 +1222,11 @@ void MainMenu ()
while (WPAD_ButtonsHeld(0)) WPAD_ScanPads();
#endif
/*** Reinitialize GX ***/
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
/*** Reinitialize VIDEO ***/
VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK);
VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK);
VIDEO_Flush();
VIDEO_WaitVSync();
VIDEO_WaitVSync();
ogc_video__reset();
odd_frame = 1;

View File

@ -35,6 +35,9 @@ u8 soundbuffer[2][3840] ATTRIBUTE_ALIGN(32);
/* Current work soundbuffer */
int mixbuffer;
/* Status of Audio playback */
static int AudioStarted = 0;
/* Current DMA length (required to be a factor of 32-bytes)
length is calculated regarding current emulation timings:
PAL timings : 50 frames/sec, 48000 samples/sec = 960 samples per frame = 3840 bytes (16 bits stereo samples)
@ -97,10 +100,10 @@ void ogc_audio__update(void)
void ogc_audio__start(void)
{
dma_len = vdp_pal ? 3840 : 3200;
memset(soundbuffer[0], 0, dma_len);
AUDIO_InitDMA((u32) soundbuffer[0], dma_len);
DCFlushRange(soundbuffer[0], dma_len);
AUDIO_StartDMA();
AudioStarted = 1;
mixbuffer = 1;
}
@ -113,5 +116,10 @@ void ogc_audio__start(void)
***/
void ogc_audio__stop(void)
{
if (AudioStarted)
{
AUDIO_StopDMA ();
AudioStarted = 0;
memset(soundbuffer, 0, 2 * 3840);
}
}

View File

@ -676,8 +676,8 @@ void ogc_video__init(void)
ARAMPut ((char *) 0x80700000 + 0x20, (char *) 0x8000, genromsize);
}
/* Get the current video mode then :
- set menu video mode (480p, 480i or 576i)
/* Get the current VIDEO mode then :
- set menu VIDEO mode (480p, 480i or 576i)
- set emulator rendering TV modes (PAL/MPAL/NTSC/EURGB60)
*/
vmode = VIDEO_GetPreferredMode(NULL);
@ -729,7 +729,7 @@ void ogc_video__init(void)
}
#endif
/* Configure video mode */
/* Configure VIDEO mode */
VIDEO_Configure (vmode);
/* Configure the framebuffers (double-buffering) */
@ -746,13 +746,14 @@ void ogc_video__init(void)
/* Set the framebuffer to be displayed at next VBlank */
VIDEO_SetNextFramebuffer (xfb[0]);
/* Set Vertical Interrupt callbacks for VIDEO synchronization */
VIDEO_SetPreRetraceCallback(xfb_switch);
VIDEO_SetPostRetraceCallback(xfb_copy);
/* Enable Video Interface */
VIDEO_SetBlack (FALSE);
/* Update video settings for next VBlank */
/* Update VIDEO settings for next VBlank */
VIDEO_Flush ();
/* Wait for VBlank */

View File

@ -28,18 +28,12 @@
/* Global variables */
t_bitmap bitmap;
t_snd snd;
uint8 vdp_rate;
uint16 lines_per_frame;
uint32 aim_m68k;
uint32 count_m68k;
uint32 line_m68k;
uint32 hint_m68k;
uint32 aim_z80;
uint32 count_z80;
uint32 line_z80;
int32 current_z80;
uint8 odd_frame;
uint8 interlaced;
uint8 system_hw;
static inline void audio_update (void);
@ -49,10 +43,6 @@ static inline void audio_update (void);
****************************************************************/
void system_init (void)
{
/* PAL/NTSC timings */
vdp_rate = vdp_pal ? 50 : 60;
lines_per_frame = vdp_pal ? 313 : 262;
gen_init ();
vdp_init ();
render_init ();
@ -60,31 +50,21 @@ void system_init (void)
}
/****************************************************************
* Virtual Genesis Restart
* Virtual Genesis Hard Reset
****************************************************************/
void system_reset (void)
{
aim_m68k = 0;
count_m68k = 0;
line_m68k = 0;
aim_z80 = 0;
count_z80 = 0;
line_z80 = 0;
current_z80 = 0;
odd_frame = 0;
interlaced = 0;
/* Cart Hardware reset */
/* Cartridge Hardware */
cart_hw_reset();
/* Hard reset */
/* Genesis Hardware */
gen_reset (1);
vdp_reset ();
render_reset ();
io_reset();
SN76489_Reset(0);
/* Sound buffers reset */
/* Sound Buffers */
memset (snd.psg.buffer, 0, SND_SIZE);
memset (snd.fm.buffer[0], 0, SND_SIZE*2);
memset (snd.fm.buffer[1], 0, SND_SIZE*2);
@ -111,10 +91,11 @@ int system_frame (int do_skip)
return 0;
}
int aim_m68k = 0;
int aim_z80 = 0;
/* reset cycles counts */
count_m68k = 0;
aim_m68k = 0;
aim_z80 = 0;
count_z80 = 0;
fifo_write_cnt = 0;
fifo_lastwrite = 0;

View File

@ -79,18 +79,12 @@ typedef struct
/* Global variables */
extern t_bitmap bitmap;
extern t_snd snd;
extern uint16 lines_per_frame;
extern uint8 vdp_rate;
extern uint32 aim_m68k;
extern uint32 count_m68k;
extern uint32 line_m68k;
extern uint32 hint_m68k;
extern uint32 aim_z80;
extern uint32 count_z80;
extern uint32 line_z80;
extern int32 current_z80;
extern uint8 interlaced;
extern uint8 odd_frame;
extern uint8 system_hw;
/* Function prototypes */

View File

@ -69,13 +69,16 @@ uint16 playfield_row_mask; /* Horizontal scroll mask */
uint32 y_mask; /* Name table Y-index bits mask */
uint16 hc_latch; /* latched HCounter (INT2) */
uint16 v_counter; /* VDP scanline counter */
uint8 im2_flag; /* 1= Interlace mode 2 is being used */
uint32 dma_length; /* Current DMA remaining bytes */
int32 fifo_write_cnt; /* VDP writes fifo count */
uint32 fifo_lastwrite; /* last VDP write cycle */
uint8 fifo_latency; /* VDP write cycles latency */
uint8 vdp_pal = 0; /* 1: PAL , 0: NTSC (default) */
uint8 odd_frame; /* 1: odd field , 0: even field */
uint8 interlaced; /* 1: Interlace mode 1 or 2 */
uint8 im2_flag; /* 1= Interlace mode 2 is being used */
uint8 vdp_pal; /* 0: NTSC, 1: PAL */
uint8 vdp_rate; /* NTSC: 60hz, PAL: 50hz */
uint16 lines_per_frame; /* NTSC: 262 lines, PAL: 313 lines */
/* Tables that define the playfield layout */
static const uint8 shift_table[] = { 6, 7, 0, 8 };
@ -133,9 +136,8 @@ static inline void data_write(unsigned int data);
/*--------------------------------------------------------------------------*/
void vdp_init(void)
{
/* DMA timings */
int i;
/* reinitialize DMA timings table */
for (i=0; i<4; i++)
{
vdp_timings[0][i] = ((double)m68cycles_per_line) / ((double) dma_rates[i]);
@ -143,6 +145,10 @@ void vdp_init(void)
vdp_timings[2][i] = ((double)m68cycles_per_line) / ((double) dma_rates[i + 8]);
vdp_timings[3][i] = ((double)m68cycles_per_line) / ((double) dma_rates[i + 12]);
}
/* PAL/NTSC timings */
vdp_rate = vdp_pal ? 50 : 60;
lines_per_frame = vdp_pal ? 313 : 262;
}
void vdp_reset(void)
@ -223,6 +229,10 @@ void vdp_reset(void)
window_clip(1,0);
}
/* non-interlaced display */
odd_frame = 0;
interlaced = 0;
/* default latency */
fifo_latency = 27;
}
@ -281,7 +291,7 @@ void dma_update()
index += (reg[12] & 1); /* 32 or 40 Horizontal Cells */
/* calculate transfer quantity for the remaining 68k cycles */
left_cycles = aim_m68k - count_m68k;
left_cycles = line_m68k + m68cycles_per_line - count_m68k;
if (left_cycles < 0) left_cycles = 0;
dma_bytes = (uint32)(((double)left_cycles / vdp_timings[dma_type][index]) + 0.5);
@ -906,7 +916,6 @@ void vdp_test_w(unsigned int value)
int vdp_int_ack_callback(int int_level)
{
/* VINT triggered ? */
if (irq_status&0x20)
{

View File

@ -57,12 +57,16 @@ extern uint16 playfield_row_mask;
extern uint32 y_mask;
extern uint16 hc_latch;
extern uint16 v_counter;
extern uint8 im2_flag;
extern uint32 dma_length;
extern int32 fifo_write_cnt;
extern uint32 fifo_lastwrite;
extern uint8 fifo_latency;
extern uint8 im2_flag;
extern uint8 interlaced;
extern uint8 odd_frame;
extern uint8 vdp_pal;
extern uint8 vdp_rate;
extern uint16 lines_per_frame;
extern uint8 *vctab;
extern uint8 *hctab;