mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-05-20 05:10:30 -04:00
Compare commits
6 commits
f87bffd672
...
8c510b8b14
Author | SHA1 | Date | |
---|---|---|---|
8c510b8b14 | |||
6972a5b0d6 | |||
7f88a7c7f8 | |||
a0d68063ae | |||
a40d037d21 | |||
cd67bc5d5d |
|
@ -159,6 +159,7 @@ Genesis Plus GX 1.7.5 (xx/xx/xxxx) (Eke-Eke)
|
|||
* improved Mode 5 sprites parsing accuracy (verified on real hardware)
|
||||
* improved Mode 5 sprites rendering timings (fixes "Overdrive" demo)
|
||||
* improved FIFO timings accuracy (fixes "Overdrive" Demo)
|
||||
* improved FIFO emulation (fixes potential lockup when switching between H32 & H40 mode during active display)
|
||||
* improved H-Counter accuracy in H32 mode
|
||||
* improved VDP status timing accuracy
|
||||
* improved HBLANK flag timing accuracy (verified on real hardware by Nemesis)
|
||||
|
|
|
@ -7,7 +7,7 @@ ifeq ($(strip $(DEVKITPPC)),)
|
|||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
|
||||
endif
|
||||
|
||||
include $(DEVKITPPC)/gamecube_rules
|
||||
include $(DEVKITPRO)/libogc2/gamecube_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
|
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 3.8 MiB After Width: | Height: | Size: 3.8 MiB |
Binary file not shown.
Before Width: | Height: | Size: 4 MiB After Width: | Height: | Size: 4 MiB |
|
@ -334,8 +334,10 @@ void system_frame_gen(int do_skip)
|
|||
mcycles_vdp = 0;
|
||||
|
||||
/* reset VDP FIFO */
|
||||
fifo_write_cnt = 0;
|
||||
fifo_slots = 0;
|
||||
fifo_cycles[0] = 0;
|
||||
fifo_cycles[1] = 0;
|
||||
fifo_cycles[2] = 0;
|
||||
fifo_cycles[3] = 0;
|
||||
|
||||
/* check if display setings have changed during previous frame */
|
||||
if (bitmap.viewport.changed & 2)
|
||||
|
@ -420,8 +422,8 @@ void system_frame_gen(int do_skip)
|
|||
/* clear DMA Busy, FIFO FULL & field flags */
|
||||
status &= 0xFEED;
|
||||
|
||||
/* set VBLANK & FIFO EMPTY flags */
|
||||
status |= 0x0208;
|
||||
/* set VBLANK flag */
|
||||
status |= 0x08;
|
||||
|
||||
/* check interlaced modes */
|
||||
if (interlaced)
|
||||
|
@ -675,8 +677,10 @@ void system_frame_scd(int do_skip)
|
|||
scd.cycles = 0;
|
||||
|
||||
/* reset VDP FIFO */
|
||||
fifo_write_cnt = 0;
|
||||
fifo_slots = 0;
|
||||
fifo_cycles[0] = 0;
|
||||
fifo_cycles[1] = 0;
|
||||
fifo_cycles[2] = 0;
|
||||
fifo_cycles[3] = 0;
|
||||
|
||||
/* check if display setings have changed during previous frame */
|
||||
if (bitmap.viewport.changed & 2)
|
||||
|
@ -761,8 +765,8 @@ void system_frame_scd(int do_skip)
|
|||
/* clear DMA Busy, FIFO FULL & field flags */
|
||||
status &= 0xFEED;
|
||||
|
||||
/* set VBLANK & FIFO EMPTY flags */
|
||||
status |= 0x0208;
|
||||
/* set VBLANK flag */
|
||||
status |= 0x08;
|
||||
|
||||
/* check interlaced modes */
|
||||
if (interlaced)
|
||||
|
@ -1000,8 +1004,10 @@ void system_frame_sms(int do_skip)
|
|||
mcycles_vdp = 0;
|
||||
|
||||
/* reset VDP FIFO */
|
||||
fifo_write_cnt = 0;
|
||||
fifo_slots = 0;
|
||||
fifo_cycles[0] = 0;
|
||||
fifo_cycles[1] = 0;
|
||||
fifo_cycles[2] = 0;
|
||||
fifo_cycles[3] = 0;
|
||||
|
||||
/* check if display settings has changed during previous frame */
|
||||
if (bitmap.viewport.changed & 2)
|
||||
|
|
186
core/vdp_ctrl.c
186
core/vdp_ctrl.c
|
@ -52,6 +52,7 @@
|
|||
} \
|
||||
bg_name_dirty[name] |= (1 << ((addr >> 2) & 7)); \
|
||||
}
|
||||
|
||||
/* VINT timings */
|
||||
#define VINT_H32_MCYCLE (770)
|
||||
#define VINT_H40_MCYCLE (788)
|
||||
|
@ -98,8 +99,7 @@ uint16 v_counter; /* Vertical counter */
|
|||
uint16 vc_max; /* Vertical counter overflow value */
|
||||
uint16 lines_per_frame; /* PAL: 313 lines, NTSC: 262 lines */
|
||||
uint16 max_sprite_pixels; /* Max. sprites pixels per line (parsing & rendering) */
|
||||
int32 fifo_write_cnt; /* VDP FIFO write count */
|
||||
uint32 fifo_slots; /* VDP FIFO access slot count */
|
||||
uint32 fifo_cycles[4]; /* VDP FIFO read-out cycles */
|
||||
uint32 hvc_latch; /* latched HV counter */
|
||||
uint32 vint_cycle; /* VINT occurence cycle */
|
||||
const uint8 *hctab; /* pointer to H Counter table */
|
||||
|
@ -123,7 +123,6 @@ static void vdp_z80_data_w_ms(unsigned int data);
|
|||
static void vdp_z80_data_w_gg(unsigned int data);
|
||||
static void vdp_z80_data_w_sg(unsigned int data);
|
||||
static void vdp_bus_w(unsigned int data);
|
||||
static void vdp_fifo_update(unsigned int cycles);
|
||||
static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles);
|
||||
static void vdp_dma_68k_ext(unsigned int length);
|
||||
static void vdp_dma_68k_ram(unsigned int length);
|
||||
|
@ -150,7 +149,6 @@ static int cached_write; /* 2nd part of 32-bit CTRL port write (Genesis m
|
|||
static uint16 fifo[4]; /* FIFO ring-buffer */
|
||||
static int fifo_idx; /* FIFO write index */
|
||||
static int fifo_byte_access; /* FIFO byte access flag */
|
||||
static uint32 fifo_cycles; /* FIFO next access cycle */
|
||||
static int *fifo_timing; /* FIFO slots timing table */
|
||||
static int hblank_start_cycle; /* HBLANK flag set cycle */
|
||||
static int hblank_end_cycle; /* HBLANK flag clear cycle */
|
||||
|
@ -170,16 +168,20 @@ static const uint16 vc_table[4][2] =
|
|||
};
|
||||
|
||||
/* FIFO access slots timings */
|
||||
static const int fifo_timing_h32[16+4] =
|
||||
static const int fifo_timing_h32[] =
|
||||
{
|
||||
230, 510, 810, 970, 1130, 1450, 1610, 1770, 2090, 2250, 2410, 2730, 2890, 3050, 3350, 3370,
|
||||
MCYCLES_PER_LINE + 230, MCYCLES_PER_LINE + 510, MCYCLES_PER_LINE + 810, MCYCLES_PER_LINE + 970,
|
||||
MCYCLES_PER_LINE + 1130, MCYCLES_PER_LINE + 1450, MCYCLES_PER_LINE + 1610, MCYCLES_PER_LINE + 1770,
|
||||
MCYCLES_PER_LINE + 2090, MCYCLES_PER_LINE + 2250, MCYCLES_PER_LINE + 2410, MCYCLES_PER_LINE + 2730
|
||||
};
|
||||
|
||||
static const int fifo_timing_h40[18+4] =
|
||||
static const int fifo_timing_h40[] =
|
||||
{
|
||||
352, 820, 948, 1076, 1332, 1460, 1588, 1844, 1972, 2100, 2356, 2484, 2612, 2868, 2996, 3124, 3364, 3380,
|
||||
MCYCLES_PER_LINE + 352, MCYCLES_PER_LINE + 820, MCYCLES_PER_LINE + 948, MCYCLES_PER_LINE + 1076,
|
||||
MCYCLES_PER_LINE + 1332, MCYCLES_PER_LINE + 1460, MCYCLES_PER_LINE + 1588, MCYCLES_PER_LINE + 1844,
|
||||
MCYCLES_PER_LINE + 1972, MCYCLES_PER_LINE + 2100, MCYCLES_PER_LINE + 2356, MCYCLES_PER_LINE + 2484
|
||||
};
|
||||
|
||||
/* DMA Timings (number of access slots per line) */
|
||||
|
@ -276,9 +278,6 @@ void vdp_reset(void)
|
|||
odd_frame = 0;
|
||||
im2_flag = 0;
|
||||
interlaced = 0;
|
||||
fifo_write_cnt = 0;
|
||||
fifo_cycles = 0;
|
||||
fifo_slots = 0;
|
||||
fifo_idx = 0;
|
||||
cached_write = -1;
|
||||
fifo_byte_access = 1;
|
||||
|
@ -306,10 +305,10 @@ void vdp_reset(void)
|
|||
/* default Window clipping */
|
||||
window_clip(0,0);
|
||||
|
||||
/* reset VDP status (FIFO empty flag is set) */
|
||||
/* reset VDP status */
|
||||
if (system_hw & SYSTEM_MD)
|
||||
{
|
||||
status = vdp_pal | 0x200;
|
||||
status = vdp_pal;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1194,12 +1193,6 @@ unsigned int vdp_68k_ctrl_r(unsigned int cycles)
|
|||
/* Cycle-accurate VDP status read (adjust CPU time with current instruction execution time) */
|
||||
cycles += m68k_cycles();
|
||||
|
||||
/* Update FIFO status flags if not empty */
|
||||
if (fifo_write_cnt)
|
||||
{
|
||||
vdp_fifo_update(cycles);
|
||||
}
|
||||
|
||||
/* Check if DMA Busy flag is set */
|
||||
if (status & 2)
|
||||
{
|
||||
|
@ -1220,6 +1213,20 @@ unsigned int vdp_68k_ctrl_r(unsigned int cycles)
|
|||
/* Clear SOVR & SCOL flags */
|
||||
status &= 0xFF9F;
|
||||
|
||||
/* Check if FIFO last entry read-out cycle has been reached */
|
||||
if (cycles >= fifo_cycles[(fifo_idx + 3) & 3])
|
||||
{
|
||||
/* FIFO is empty */
|
||||
temp |= 0x200;
|
||||
}
|
||||
|
||||
/* Check if FIFO oldest entry read-out cycle is not yet reached */
|
||||
else if (cycles < fifo_cycles[fifo_idx])
|
||||
{
|
||||
/* FIFO is full */
|
||||
temp |= 0x100;
|
||||
}
|
||||
|
||||
/* VBLANK flag is set when display is disabled */
|
||||
if (!(reg[1] & 0x40))
|
||||
{
|
||||
|
@ -1991,13 +1998,6 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles)
|
|||
/* Active display width */
|
||||
if (r & 0x01)
|
||||
{
|
||||
/* FIFO access slots timings depend on active width */
|
||||
if (fifo_slots)
|
||||
{
|
||||
/* Synchronize VDP FIFO */
|
||||
vdp_fifo_update(cycles);
|
||||
}
|
||||
|
||||
if (d & 0x01)
|
||||
{
|
||||
/* Update display-dependant registers */
|
||||
|
@ -2114,68 +2114,6 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles)
|
|||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* FIFO emulation (Mega Drive VDP specific) */
|
||||
/* ---------------------------------------- */
|
||||
/* */
|
||||
/* CPU access to VRAM, CRAM & VSRAM is limited during active display: */
|
||||
/* H32 mode -> 16 access per line */
|
||||
/* H40 mode -> 18 access per line */
|
||||
/* */
|
||||
/* with fixed access slots timings detailled below. */
|
||||
/* */
|
||||
/* Each VRAM access is byte wide, so one VRAM write (word) need two slots. */
|
||||
/* */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
static void vdp_fifo_update(unsigned int cycles)
|
||||
{
|
||||
int fifo_read_cnt, line_slots = 0;
|
||||
|
||||
/* number of access slots up to current line */
|
||||
int total_slots = dma_timing[0][reg[12] & 1] * ((v_counter + 1) % lines_per_frame);
|
||||
|
||||
/* number of access slots within current line */
|
||||
cycles -= mcycles_vdp;
|
||||
while (fifo_timing[line_slots] <= cycles)
|
||||
{
|
||||
line_slots++;
|
||||
}
|
||||
|
||||
/* number of processed FIFO entries since last access (byte access needs two slots to process one FIFO word) */
|
||||
fifo_read_cnt = (total_slots + line_slots - fifo_slots) >> fifo_byte_access;
|
||||
|
||||
if (fifo_read_cnt > 0)
|
||||
{
|
||||
/* process FIFO entries */
|
||||
fifo_write_cnt -= fifo_read_cnt;
|
||||
|
||||
/* Clear FIFO full flag */
|
||||
status &= 0xFEFF;
|
||||
|
||||
if (fifo_write_cnt <= 0)
|
||||
{
|
||||
/* No more FIFO entries */
|
||||
fifo_write_cnt = 0;
|
||||
|
||||
/* Set FIFO empty flag */
|
||||
status |= 0x200;
|
||||
|
||||
/* Reinitialize FIFO access slot counter */
|
||||
fifo_slots = total_slots + line_slots;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Update FIFO access slot counter */
|
||||
fifo_slots += (fifo_read_cnt << fifo_byte_access);
|
||||
}
|
||||
}
|
||||
|
||||
/* next FIFO update cycle */
|
||||
fifo_cycles = mcycles_vdp + fifo_timing[fifo_slots - total_slots + fifo_byte_access];
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Internal 16-bit data bus access function (Mode 5 only) */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
@ -2335,29 +2273,31 @@ static void vdp_68k_data_w_m4(unsigned int data)
|
|||
/* Restricted VDP writes during active display */
|
||||
if (!(status & 8) && (reg[1] & 0x40))
|
||||
{
|
||||
/* Update VDP FIFO */
|
||||
vdp_fifo_update(m68k.cycles);
|
||||
int slot = 0;
|
||||
|
||||
/* Clear FIFO empty flag */
|
||||
status &= 0xFDFF;
|
||||
/* Cycle-accurate VDP data port access */
|
||||
int cycles = m68k.cycles;
|
||||
|
||||
/* up to 4 words can be stored */
|
||||
if (fifo_write_cnt < 4)
|
||||
/* Check against last FIFO entry read-out cycle */
|
||||
if (cycles < fifo_cycles[(fifo_idx + 3) & 3])
|
||||
{
|
||||
/* Increment FIFO counter */
|
||||
fifo_write_cnt++;
|
||||
/* Check against oldest FIFO entry read-out cycle */
|
||||
if (cycles < fifo_cycles[fifo_idx])
|
||||
{
|
||||
/* FIFO is full, 68k waits until oldest FIFO entry is processed (Chaos Engine / Soldiers of Fortune, Double Clutch, Titan Overdrive Demo) */
|
||||
m68k.cycles = (((fifo_cycles[fifo_idx] + 6) / 7) * 7);
|
||||
}
|
||||
|
||||
/* Set FIFO full flag if 4 words are stored */
|
||||
status |= ((fifo_write_cnt & 4) << 6);
|
||||
/* FIFO is not empty, next FIFO entry will be processed after last FIFO entry */
|
||||
cycles = fifo_cycles[(fifo_idx + 3) & 3];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* CPU is halted until next FIFO entry processing */
|
||||
m68k.cycles = fifo_cycles;
|
||||
|
||||
/* Update FIFO access slot counter */
|
||||
fifo_slots += (fifo_byte_access + 1);
|
||||
}
|
||||
/* Determine next FIFO entry processing slot */
|
||||
cycles -= mcycles_vdp;
|
||||
while (cycles >= fifo_timing[slot]) slot++;
|
||||
|
||||
/* Update last FIFO entry read-out cycle */
|
||||
fifo_cycles[fifo_idx] = mcycles_vdp + fifo_timing[slot + fifo_byte_access];
|
||||
}
|
||||
|
||||
/* Check destination code */
|
||||
|
@ -2427,31 +2367,33 @@ static void vdp_68k_data_w_m5(unsigned int data)
|
|||
/* Restricted VDP writes during active display */
|
||||
if (!(status & 8) && (reg[1] & 0x40))
|
||||
{
|
||||
/* Update VDP FIFO */
|
||||
vdp_fifo_update(m68k.cycles);
|
||||
int slot = 0;
|
||||
|
||||
/* Clear FIFO empty flag */
|
||||
status &= 0xFDFF;
|
||||
/* Cycle-accurate VDP data port access */
|
||||
int cycles = m68k.cycles;
|
||||
|
||||
/* up to 4 words can be stored */
|
||||
if (fifo_write_cnt < 4)
|
||||
/* Check against last FIFO entry read-out cycle */
|
||||
if (cycles < fifo_cycles[(fifo_idx + 3) & 3])
|
||||
{
|
||||
/* Increment FIFO counter */
|
||||
fifo_write_cnt++;
|
||||
/* Check against oldest FIFO entry read-out cycle */
|
||||
if (cycles < fifo_cycles[fifo_idx])
|
||||
{
|
||||
/* FIFO is full, 68k waits until oldest FIFO entry is processed (Chaos Engine / Soldiers of Fortune, Double Clutch, Titan Overdrive Demo) */
|
||||
m68k.cycles = (((fifo_cycles[fifo_idx] + 6) / 7) * 7);
|
||||
}
|
||||
|
||||
/* Set FIFO full flag if 4 words are stored */
|
||||
status |= ((fifo_write_cnt & 4) << 6);
|
||||
/* FIFO is not empty, next FIFO entry will be processed after last FIFO entry */
|
||||
cycles = fifo_cycles[(fifo_idx + 3) & 3];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* CPU is halted until next FIFO entry processing (Chaos Engine / Soldiers of Fortune, Double Clutch, Titan Overdrive Demo) */
|
||||
m68k.cycles = fifo_cycles;
|
||||
|
||||
/* Update FIFO access slot counter */
|
||||
fifo_slots += (fifo_byte_access + 1);
|
||||
}
|
||||
/* Determine next FIFO entry processing slot */
|
||||
cycles -= mcycles_vdp;
|
||||
while (cycles >= fifo_timing[slot]) slot++;
|
||||
|
||||
/* Update last FIFO entry read-out cycle */
|
||||
fifo_cycles[fifo_idx] = mcycles_vdp + fifo_timing[slot + fifo_byte_access];
|
||||
}
|
||||
|
||||
|
||||
/* Write data */
|
||||
vdp_bus_w(data);
|
||||
|
||||
|
@ -3193,7 +3135,7 @@ static void vdp_dma_fill(unsigned int length)
|
|||
{
|
||||
int name;
|
||||
|
||||
/* Get source data from last written FIFO entry */
|
||||
/* Get source data from last written FIFO entry */
|
||||
uint8 data = fifo[(fifo_idx+3)&3] >> 8;
|
||||
|
||||
do
|
||||
|
|
|
@ -78,8 +78,7 @@ extern uint16 vc_max;
|
|||
extern uint16 vscroll;
|
||||
extern uint16 lines_per_frame;
|
||||
extern uint16 max_sprite_pixels;
|
||||
extern int32 fifo_write_cnt;
|
||||
extern uint32 fifo_slots;
|
||||
extern uint32 fifo_cycles[4];
|
||||
extern uint32 hvc_latch;
|
||||
extern uint32 vint_cycle;
|
||||
extern const uint8 *hctab;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "filesel.h"
|
||||
#include "file_slot.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <iso9660.h>
|
||||
#ifdef HW_RVL
|
||||
#include <di/di.h>
|
||||
|
@ -81,8 +82,6 @@ static u8 dvdInited = 0;
|
|||
static u8 dvdMounted = 0;
|
||||
|
||||
#ifndef HW_RVL
|
||||
static u8 dvdBuffer[2048] ATTRIBUTE_ALIGN(32);
|
||||
|
||||
static bool dvdStartup()
|
||||
{
|
||||
DVD_Mount();
|
||||
|
@ -93,56 +92,6 @@ static bool dvdIsInserted()
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool dvdReadSectors(u32 offset,u32 len,void *buffer)
|
||||
{
|
||||
vu32* const dvd = (u32*)0xCC006000;
|
||||
offset = offset << 9;
|
||||
len = len << 11;
|
||||
|
||||
/* DVD transfer must be done into a 32-byte aligned buffer */
|
||||
while (len >= 2048)
|
||||
{
|
||||
DCInvalidateRange((void *)dvdBuffer, 2048);
|
||||
dvd[0] = 0x2E;
|
||||
dvd[1] = 0;
|
||||
dvd[2] = 0xA8000000;
|
||||
dvd[3] = offset;
|
||||
dvd[4] = 2048;
|
||||
dvd[5] = (u32) dvdBuffer;
|
||||
dvd[6] = 2048;
|
||||
dvd[7] = 3;
|
||||
while (dvd[7] & 1);
|
||||
if (dvd[0] & 4) return false;
|
||||
memcpy (buffer, dvdBuffer, 2048);
|
||||
len -= 2048;
|
||||
buffer += 2048;
|
||||
offset += 512;
|
||||
}
|
||||
|
||||
/* Process remaining bytes (normally not needed since libiso9960 already deals with this but you never know) */
|
||||
if (len)
|
||||
{
|
||||
/* DVD transfer length should be aligned to 32 bytes */
|
||||
u32 dmasize = (len + 0x1f) & ~0x1f;
|
||||
|
||||
DCInvalidateRange((void *)dvdBuffer, dmasize);
|
||||
dvd[0] = 0x2E;
|
||||
dvd[1] = 0;
|
||||
dvd[2] = 0xA8000000;
|
||||
dvd[3] = offset;
|
||||
dvd[4] = dmasize;
|
||||
dvd[5] = (u32) dvdBuffer;
|
||||
dvd[6] = dmasize;
|
||||
dvd[7] = 3;
|
||||
while (dvd[7] & 1);
|
||||
if (dvd[0] & 4) return false;
|
||||
|
||||
memcpy (buffer, dvdBuffer, len);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************************
|
||||
|
@ -165,7 +114,6 @@ static int MountDVD(void)
|
|||
/* patch libogc DVD interface which appears to be broken on Gamecube */
|
||||
dvd->startup = (FN_MEDIUM_STARTUP)dvdStartup;
|
||||
dvd->isInserted = (FN_MEDIUM_ISINSERTED)dvdIsInserted;
|
||||
dvd->readSectors = (FN_MEDIUM_READSECTORS)dvdReadSectors;
|
||||
#endif
|
||||
dvdInited = 1;
|
||||
}
|
||||
|
@ -284,11 +232,19 @@ int ParseDirectory(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
struct dirent *entry = readdir(dir);
|
||||
struct dirent *entry = NULL;
|
||||
|
||||
/* list entries */
|
||||
while ((entry != NULL)&& (nbfiles < MAXFILES))
|
||||
do
|
||||
{
|
||||
errno = 0;
|
||||
/* next entry */
|
||||
entry = readdir(dir);
|
||||
if (entry == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* filter entries */
|
||||
if ((entry->d_name[0] != '.')
|
||||
&& strncasecmp(".wav", &entry->d_name[strlen(entry->d_name) - 4], 4)
|
||||
|
@ -303,10 +259,8 @@ int ParseDirectory(void)
|
|||
}
|
||||
nbfiles++;
|
||||
}
|
||||
|
||||
/* next entry */
|
||||
entry = readdir(dir);
|
||||
}
|
||||
while ((entry != NULL || errno == EOVERFLOW) && (nbfiles < MAXFILES));
|
||||
|
||||
/* close directory */
|
||||
closedir(dir);
|
||||
|
|
|
@ -70,21 +70,9 @@ static u8 brm_format[0x40] =
|
|||
*****************************************************************************/
|
||||
static int CardMount(int slot)
|
||||
{
|
||||
int tries = 0;
|
||||
#ifdef HW_RVL
|
||||
*(unsigned long *) (0xCD006800) |= 1 << 13; /*** Disable Encryption ***/
|
||||
#else
|
||||
*(unsigned long *) (0xCC006800) |= 1 << 13; /*** Disable Encryption ***/
|
||||
#endif
|
||||
while (tries < 10)
|
||||
{
|
||||
VIDEO_WaitVSync ();
|
||||
if (CARD_Mount(slot, SysArea, NULL) == CARD_ERROR_READY)
|
||||
return 1;
|
||||
else
|
||||
EXI_ProbeReset ();
|
||||
tries++;
|
||||
}
|
||||
while (CARD_ProbeEx(slot, NULL, NULL) == CARD_ERROR_BUSY);
|
||||
if (CARD_Mount(slot, SysArea, NULL) == CARD_ERROR_READY)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -309,7 +297,6 @@ void slot_autodetect(int slot, int device, t_slot *ptr)
|
|||
sprintf(filename,"MD-%04X.srm", rominfo.realchecksum);
|
||||
|
||||
/* Initialise the CARD system */
|
||||
memset(&SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init("GENP", "00");
|
||||
|
||||
/* CARD slot */
|
||||
|
@ -325,7 +312,7 @@ void slot_autodetect(int slot, int device, t_slot *ptr)
|
|||
/* Retrieve date & close */
|
||||
card_stat CardStatus;
|
||||
CARD_GetStatus(device, CardFile.filenum, &CardStatus);
|
||||
time_t rawtime = CardStatus.time;
|
||||
time_t rawtime = CardStatus.time + 946684800;
|
||||
struct tm *timeinfo = localtime(&rawtime);
|
||||
ptr->year = 1900 + timeinfo->tm_year;
|
||||
ptr->month = timeinfo->tm_mon + 1;
|
||||
|
@ -373,7 +360,6 @@ int slot_delete(int slot, int device)
|
|||
sprintf(filename,"MD-%04X.srm", rominfo.realchecksum);
|
||||
|
||||
/* Initialise the CARD system */
|
||||
memset(&SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init("GENP", "00");
|
||||
|
||||
/* CARD slot */
|
||||
|
@ -477,7 +463,6 @@ int slot_load(int slot, int device)
|
|||
|
||||
/* Initialise the CARD system */
|
||||
char action[64];
|
||||
memset(&SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init("GENP", "00");
|
||||
|
||||
/* CARD slot */
|
||||
|
@ -530,12 +515,7 @@ int slot_load(int slot, int device)
|
|||
}
|
||||
|
||||
/* Read file sectors */
|
||||
while (filesize > 0)
|
||||
{
|
||||
CARD_Read(&CardFile, &in[done], SectorSize, done);
|
||||
done += SectorSize;
|
||||
filesize -= SectorSize;
|
||||
}
|
||||
CARD_Read(&CardFile, &in[done], filesize, done);
|
||||
|
||||
/* Close file */
|
||||
CARD_Close(&CardFile);
|
||||
|
@ -715,7 +695,6 @@ int slot_save(int slot, int device)
|
|||
|
||||
/* Initialise the CARD system */
|
||||
char action[64];
|
||||
memset(&SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init("GENP", "00");
|
||||
|
||||
/* CARD slot */
|
||||
|
@ -763,6 +742,7 @@ int slot_save(int slot, int device)
|
|||
|
||||
/* compress file */
|
||||
compress2 ((Bytef *)&out[2112 + 4], &filesize, (Bytef *)buffer, done, 9);
|
||||
done = 0;
|
||||
|
||||
/* Adjust file size */
|
||||
filesize = filesize + 4 + 2112;
|
||||
|
@ -820,20 +800,24 @@ int slot_save(int slot, int device)
|
|||
time(&rawtime);
|
||||
card_stat CardStatus;
|
||||
CARD_GetStatus(device, CardFile.filenum, &CardStatus);
|
||||
CardStatus.icon_addr = 0x0;
|
||||
CardStatus.icon_fmt = 2;
|
||||
CardStatus.icon_speed = 1;
|
||||
CardStatus.icon_addr = 0;
|
||||
CardStatus.icon_fmt = CARD_ICON_RGB;
|
||||
CardStatus.icon_speed = CARD_SPEED_FAST;
|
||||
CardStatus.comment_addr = 2048;
|
||||
CardStatus.time = rawtime;
|
||||
CardStatus.time = rawtime - 946684800;
|
||||
CARD_SetStatus(device, CardFile.filenum, &CardStatus);
|
||||
|
||||
/* Write file sectors */
|
||||
#ifdef HW_RVL
|
||||
while (filesize > 0)
|
||||
{
|
||||
CARD_Write(&CardFile, &out[done], SectorSize, done);
|
||||
filesize -= SectorSize;
|
||||
done += SectorSize;
|
||||
}
|
||||
#else
|
||||
CARD_Write(&CardFile, &out[done], filesize, done);
|
||||
#endif
|
||||
|
||||
/* Close file */
|
||||
CARD_Close(&CardFile);
|
||||
|
|
12
gx/gui/gui.c
12
gx/gui/gui.c
|
@ -791,7 +791,7 @@ int GUI_UpdateMenu(gui_menu *menu)
|
|||
if (button->state & BUTTON_OVER_SFX)
|
||||
{
|
||||
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,
|
||||
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
|
||||
((int)config.sfx_volume * MAX_VOLUME) / 100,((int)config.sfx_volume * MAX_VOLUME) / 100,NULL);
|
||||
}
|
||||
}
|
||||
else if (selected < (max_buttons + 2))
|
||||
|
@ -801,7 +801,7 @@ int GUI_UpdateMenu(gui_menu *menu)
|
|||
if (button->state & BUTTON_OVER_SFX)
|
||||
{
|
||||
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,
|
||||
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
|
||||
((int)config.sfx_volume * MAX_VOLUME) / 100,((int)config.sfx_volume * MAX_VOLUME) / 100,NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -832,7 +832,7 @@ int GUI_UpdateMenu(gui_menu *menu)
|
|||
if (button->state & BUTTON_SELECT_SFX)
|
||||
{
|
||||
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_select_pcm,button_select_pcm_size,
|
||||
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
|
||||
((int)config.sfx_volume * MAX_VOLUME) / 100,((int)config.sfx_volume * MAX_VOLUME) / 100,NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1183,7 +1183,7 @@ int GUI_OptionWindow(gui_menu *parent, char *title, char *infos, char *items[],
|
|||
if (selected >= 0)
|
||||
{
|
||||
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,
|
||||
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
|
||||
((int)config.sfx_volume * MAX_VOLUME) / 100,((int)config.sfx_volume * MAX_VOLUME) / 100,NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1455,7 +1455,7 @@ void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *optio
|
|||
|
||||
/* play sound effect */
|
||||
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,
|
||||
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
|
||||
((int)config.sfx_volume * MAX_VOLUME) / 100,((int)config.sfx_volume * MAX_VOLUME) / 100,NULL);
|
||||
|
||||
/* option callback */
|
||||
if (cb)
|
||||
|
@ -1700,7 +1700,7 @@ void GUI_OptionBox2(gui_menu *parent, char *text_1, char *text_2, s16 *option_1,
|
|||
modified = 0;
|
||||
/* play sound effect */
|
||||
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,
|
||||
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
|
||||
((int)config.sfx_volume * MAX_VOLUME) / 100,((int)config.sfx_volume * MAX_VOLUME) / 100,NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -702,7 +702,7 @@ static void update_screen_w(void)
|
|||
|
||||
static void update_bgm(void)
|
||||
{
|
||||
SetVolumeOgg(((int)config.bgm_volume * 255) / 100);
|
||||
SetVolumeOgg(((int)config.bgm_volume * MAX_VOLUME) / 100);
|
||||
}
|
||||
|
||||
static void prefmenu ()
|
||||
|
@ -718,10 +718,10 @@ static void prefmenu ()
|
|||
else if (config.s_auto == 1) sprintf (items[2].text, "Auto Saves: SRAM ONLY");
|
||||
else sprintf (items[2].text, "Auto Saves: NONE");
|
||||
#ifdef HW_RVL
|
||||
if (config.l_device == 1) sprintf (items[3].text, "ROM Load Device: USB");
|
||||
else if (config.l_device == 2) sprintf (items[3].text, "ROM Load Device: DVD");
|
||||
if (config.l_device == TYPE_USB) sprintf (items[3].text, "ROM Load Device: USB");
|
||||
else if (config.l_device == TYPE_DVD) sprintf (items[3].text, "ROM Load Device: DVD");
|
||||
#else
|
||||
if (config.l_device == 1) sprintf (items[3].text, "ROM Load Device: DVD");
|
||||
if (config.l_device == TYPE_DVD) sprintf (items[3].text, "ROM Load Device: DVD");
|
||||
#endif
|
||||
else sprintf (items[3].text, "ROM Load Device: SD");
|
||||
if (config.s_device == 1) sprintf (items[4].text, "Saves Device: MCARD A");
|
||||
|
@ -771,12 +771,12 @@ static void prefmenu ()
|
|||
|
||||
case 3: /*** Default ROM device ***/
|
||||
#ifdef HW_RVL
|
||||
config.l_device = (config.l_device + 1) % 3;
|
||||
if (config.l_device == 1) sprintf (items[3].text, "ROM Load Device: USB");
|
||||
else if (config.l_device == 2) sprintf (items[3].text, "ROM Load Device: DVD");
|
||||
config.l_device = (config.l_device + 1) % (TYPE_DVD + 1);
|
||||
if (config.l_device == TYPE_USB) sprintf (items[3].text, "ROM Load Device: USB");
|
||||
else if (config.l_device == TYPE_DVD) sprintf (items[3].text, "ROM Load Device: DVD");
|
||||
#else
|
||||
config.l_device ^= 1;
|
||||
if (config.l_device == 1) sprintf (items[3].text, "ROM Load Device: DVD");
|
||||
if (config.l_device == TYPE_DVD) sprintf (items[3].text, "ROM Load Device: DVD");
|
||||
#endif
|
||||
else sprintf (items[3].text, "ROM Load Device: SD");
|
||||
break;
|
||||
|
@ -871,21 +871,13 @@ static void prefmenu ()
|
|||
}
|
||||
|
||||
/* stop DVD drive when not in use */
|
||||
if (config.l_device != 2)
|
||||
if (config.l_device != TYPE_DVD)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
DI_StopMotor();
|
||||
#else
|
||||
vu32* const dvd = (u32*)0xCC006000;
|
||||
dvd[0] = 0x2e;
|
||||
dvd[1] = 0;
|
||||
dvd[2] = 0xe3000000;
|
||||
dvd[3] = 0;
|
||||
dvd[4] = 0;
|
||||
dvd[5] = 0;
|
||||
dvd[6] = 0;
|
||||
dvd[7] = 1;
|
||||
while (dvd[7] & 1);
|
||||
dvdcmdblk blk;
|
||||
DVD_StopMotor(&blk);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -218,6 +218,6 @@ void gx_audio_Stop(void)
|
|||
{
|
||||
PauseOgg(0);
|
||||
PlayOgg((char *)Bg_music_ogg, Bg_music_ogg_size, 0, OGG_INFINITE_TIME);
|
||||
SetVolumeOgg(((int)config.bgm_volume * 255) / 100);
|
||||
SetVolumeOgg(((int)config.bgm_volume * MAX_VOLUME) / 100);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -359,8 +359,7 @@ static u8 screenDisplayList[32] ATTRIBUTE_ALIGN(32) =
|
|||
static void vi_callback(u32 cnt)
|
||||
{
|
||||
/* get audio DMA remaining length */
|
||||
vu16* const _dspReg = (u16*)0xCC005000;
|
||||
u16 remain = _dspReg[29];
|
||||
u16 remain = AUDIO_GetDMABytesLeft() / 32;
|
||||
|
||||
/* adjust desired output samplerate if audio playback is not perfectly in sync with video */
|
||||
if (remain > 0)
|
||||
|
@ -1885,7 +1884,7 @@ void gx_video_Init(void)
|
|||
/* Configure VI */
|
||||
VIDEO_Configure(vmode);
|
||||
|
||||
/* Initialize font first (to ensure IPL font buffer is allocated in MEM1 as DMA from EXI bus to MEM2 is apparently not possible) */
|
||||
/* Initialize font first (to ensure IPL font buffer is allocated in MEM1 as DMA from EXI bus to MEM2 is apparently not possible with libogc) */
|
||||
FONT_Init();
|
||||
|
||||
/* Allocate framebuffers */
|
||||
|
@ -1893,7 +1892,7 @@ void gx_video_Init(void)
|
|||
xfb[1] = (u32 *) MEM_K0_TO_K1((u32 *) SYS_AllocateFramebuffer(&TV50hz_576i));
|
||||
|
||||
/* Define a console */
|
||||
console_init(xfb[0], 20, 64, 640, 574, 574 * 2);
|
||||
console_init(xfb[0], 0, 0, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * VI_DISPLAY_PIX_SZ);
|
||||
|
||||
/* Clear framebuffer to black */
|
||||
VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK);
|
||||
|
|
|
@ -452,7 +452,7 @@ int PlayOgg(char * buf, int buflen, int time_pos, int mode)
|
|||
|
||||
private_ogg.mode = mode;
|
||||
private_ogg.eof = 0;
|
||||
private_ogg.volume = 127;
|
||||
private_ogg.volume = MID_VOLUME;
|
||||
private_ogg.flag = 0;
|
||||
private_ogg.seek_time = -1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue