Skip to content

Commit

Permalink
Merge branch 'ekeeke:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ds22x authored Nov 10, 2023
2 parents d90bd0f + 6f0ac9a commit 31add24
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 116 deletions.
2 changes: 2 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Genesis Plus GX 1.7.5 (xx/xx/xxxx) (Eke-Eke)
* fixed word access to CDD control register (fixes spurious audio track playback on startup with Mode 1 patched games using MSU-MD driver)
* fixed CD communication registers state on peripheral reset (fixes SUB-CPU side initialization in MSU-MD sample demo and some Mode 1 patched games using MSU-MD driver)
* fixed 32x32 pixels stamp index masking during GFX operation (fixes graphics rotation/scaling effects in "Chuck Rock II - Son of Chuck")
* fixed CDC DMA to PCM RAM when transfer length is not word-aligned
* optimized Sub-CPU / Main-CPU synchronization

[Core/MD]
Expand Down Expand Up @@ -132,6 +133,7 @@ Genesis Plus GX 1.7.5 (xx/xx/xxxx) (Eke-Eke)
* improved 4 Way-Play emulation (fixes multitap detection in CD games)
* increased Sega Mouse latency (fixes mouse support in Star Blade)
* fixed TeamPlayer emulation (fixes multitap detection in Gauntlet 4)
* improved Japanese Paddle emulation (fixes Paddle support on control port #2)

[Core/VDP]
---------------
Expand Down
22 changes: 21 additions & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Unless otherwise explicitly stated, all code in Genesis Plus GX is released
under the following license:

Copyright (c) 1998-2003 Charles MacDonald
Copyright (c) 2007-2017 Eke-Eke
Copyright (c) 2007-2023 Eke-Eke
Some portions copyright Nicola Salmoria and the MAME team
All rights reserved.

Expand Down Expand Up @@ -37,6 +37,26 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

----------------------------------------------------------------------------------------

Nuked OPN2 core is distributed under the following license:

/*
* Copyright (C) 2017-2022 Alexey Khokholov (Nuke.YKT)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

----------------------------------------------------------------------------------------

Expand Down
Binary file modified builds/genesis_plus_gx_libretro.dll
Binary file not shown.
Binary file modified builds/genplus_cube.dol
Binary file not shown.
Binary file modified builds/genplus_wii.dol
Binary file not shown.
19 changes: 8 additions & 11 deletions core/cd_hw/cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Genesis Plus
* CD data controller (LC8951x compatible)
*
* Copyright (C) 2012-2019 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2012-2023 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -181,17 +181,14 @@ int cdc_context_load(uint8 *state)

void cdc_dma_update(void)
{
/* maximal transfer length */
int length = DMA_BYTES_PER_LINE;

/* end of DMA transfer ? */
if (cdc.dbc.w < DMA_BYTES_PER_LINE)
{
/* transfer remaining words using 16-bit DMA */
cdc.dma_w((cdc.dbc.w + 1) >> 1);
/* transfer remaining bytes using DMA */
cdc.dma_w(cdc.dbc.w + 1);

/* reset data byte counter (DBCH bits 4-7 should be set to 1) */
cdc.dbc.w = 0xf000;
/* reset data byte counter (DBCH bits 4-7 should also be set to 1) */
cdc.dbc.w = 0xffff;

/* clear !DTEN and !DTBSY */
cdc.ifstat |= (BIT_DTBSY | BIT_DTEN);
Expand Down Expand Up @@ -234,11 +231,11 @@ void cdc_dma_update(void)
}
else
{
/* transfer all words using 16-bit DMA */
cdc.dma_w(DMA_BYTES_PER_LINE >> 1);
/* transfer limited amount of bytes using DMA */
cdc.dma_w(DMA_BYTES_PER_LINE);

/* decrement data byte counter */
cdc.dbc.w -= length;
cdc.dbc.w -= DMA_BYTES_PER_LINE;
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/cd_hw/cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Genesis Plus
* CD data controller (LC8951x compatible)
*
* Copyright (C) 2012-2019 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2012-2023 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -53,7 +53,7 @@ typedef struct
uint8 head[2][4];
uint8 stat[4];
int cycles;
void (*dma_w)(unsigned int words); /* DMA transfer callback */
void (*dma_w)(unsigned int length); /* DMA transfer callback */
uint8 ram[0x4000 + 2352]; /* 16K external RAM (with one block overhead to handle buffer overrun) */
} cdc_t;

Expand Down
17 changes: 13 additions & 4 deletions core/cd_hw/gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Genesis Plus
* CD graphics processor
*
* Copyright (C) 2012-2022 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2012-2023 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -41,10 +41,13 @@
/* WORD-RAM DMA interfaces (1M & 2M modes) */
/***************************************************************/

void word_ram_0_dma_w(unsigned int words)
void word_ram_0_dma_w(unsigned int length)
{
uint16 data;

/* 16-bit DMA only */
unsigned int words = length >> 1;

/* CDC buffer source address */
uint16 src_index = cdc.dac.w & 0x3ffe;

Expand Down Expand Up @@ -74,10 +77,13 @@ void word_ram_0_dma_w(unsigned int words)
}
}

void word_ram_1_dma_w(unsigned int words)
void word_ram_1_dma_w(unsigned int length)
{
uint16 data;

/* 16-bit DMA only */
unsigned int words = length >> 1;

/* CDC buffer source address */
uint16 src_index = cdc.dac.w & 0x3ffe;

Expand Down Expand Up @@ -107,10 +113,13 @@ void word_ram_1_dma_w(unsigned int words)
}
}

void word_ram_2M_dma_w(unsigned int words)
void word_ram_2M_dma_w(unsigned int length)
{
uint16 data;

/* 16-bit DMA only */
unsigned int words = length >> 1;

/* CDC buffer source address */
uint16 src_index = cdc.dac.w & 0x3ffe;

Expand Down
8 changes: 4 additions & 4 deletions core/cd_hw/gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Genesis Plus
* CD graphics processor
*
* Copyright (C) 2012-2022 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2012-2023 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -61,9 +61,9 @@ typedef struct
/***************************************************************/
/* WORD-RAM DMA interfaces (1M & 2M modes) */
/***************************************************************/
extern void word_ram_0_dma_w(unsigned int words);
extern void word_ram_1_dma_w(unsigned int words);
extern void word_ram_2M_dma_w(unsigned int words);
extern void word_ram_0_dma_w(unsigned int length);
extern void word_ram_1_dma_w(unsigned int length);
extern void word_ram_2M_dma_w(unsigned int length);

/***************************************************************/
/* WORD-RAM 0 & 1 CPU interfaces (1M mode) */
Expand Down
27 changes: 11 additions & 16 deletions core/cd_hw/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Genesis Plus
* PCM sound chip (315-5476A) (RF5C164 compatible)
*
* Copyright (C) 2012-2021 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2012-2023 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -450,36 +450,31 @@ unsigned char pcm_read(unsigned int address, unsigned int cycles)
return 0xff;
}

void pcm_ram_dma_w(unsigned int words)
void pcm_ram_dma_w(unsigned int length)
{
uint16 data;

/* CDC buffer source address */
uint16 src_index = cdc.dac.w & 0x3ffe;
uint16 src_index = cdc.dac.w & 0x3fff;

/* PCM-RAM destination address*/
uint16 dst_index = (scd.regs[0x0a>>1].w << 2) & 0xffe;
uint16 dst_index = (scd.regs[0x0a>>1].w << 2) & 0xfff;

/* update DMA destination address */
scd.regs[0x0a>>1].w += (words >> 1);
scd.regs[0x0a>>1].w += (length >> 2);

/* update DMA source address */
cdc.dac.w += (words << 1);
cdc.dac.w += length;

/* DMA transfer */
while (words--)
while (length--)
{
/* read 16-bit word from CDC buffer */
data = *(uint16 *)(cdc.ram + src_index);

/* write 16-bit word to PCM RAM (endianness does not matter since PCM RAM is always accessed as byte)*/
*(uint16 *)(pcm.bank + dst_index) = data ;
/* copy byte from CDC buffer to PCM RAM bank */
pcm.bank[dst_index] = cdc.ram[src_index];

/* increment CDC buffer source address */
src_index = (src_index + 2) & 0x3ffe;
src_index = (src_index + 1) & 0x3fff;

/* increment PCM-RAM destination address */
dst_index = (dst_index + 2) & 0xffe;
dst_index = (dst_index + 1) & 0xfff;
}
}

4 changes: 2 additions & 2 deletions core/cd_hw/pcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Genesis Plus
* PCM sound chip (315-5476A) (RF5C164 compatible)
*
* Copyright (C) 2012-2021 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2012-2023 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -72,6 +72,6 @@ extern int pcm_context_load(uint8 *state);
extern void pcm_update(unsigned int samples);
extern void pcm_write(unsigned int address, unsigned char data, unsigned int cycles);
extern unsigned char pcm_read(unsigned int address, unsigned int cycles);
extern void pcm_ram_dma_w(unsigned int words);
extern void pcm_ram_dma_w(unsigned int length);

#endif
7 changes: 5 additions & 2 deletions core/cd_hw/scd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Genesis Plus
* Mega CD / Sega CD hardware
*
* Copyright (C) 2012-2022 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2012-2023 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -78,10 +78,13 @@ static void s68k_unused_16_w(unsigned int address, unsigned int data)
/*--------------------------------------------------------------------------*/
/* PRG-RAM DMA access */
/*--------------------------------------------------------------------------*/
void prg_ram_dma_w(unsigned int words)
void prg_ram_dma_w(unsigned int length)
{
uint16 data;

/* 16-bit DMA only */
unsigned int words = length >> 1;

/* CDC buffer source address */
uint16 src_index = cdc.dac.w & 0x3ffe;

Expand Down
4 changes: 2 additions & 2 deletions core/cd_hw/scd.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Genesis Plus
* Mega CD / Sega CD hardware
*
* Copyright (C) 2012-2022 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2012-2023 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -90,6 +90,6 @@ extern void scd_end_frame(unsigned int cycles);
extern int scd_context_load(uint8 *state, char *version);
extern int scd_context_save(uint8 *state);
extern int scd_68k_irq_ack(int level);
extern void prg_ram_dma_w(unsigned int words);
extern void prg_ram_dma_w(unsigned int length);

#endif
18 changes: 13 additions & 5 deletions core/input_hw/paddle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Genesis Plus
* Sega Paddle Control support
*
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2023 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -41,12 +41,14 @@
static struct
{
uint8 State;
uint8 Counter;
} paddle[2];

void paddle_reset(int index)
void paddle_reset(int port)
{
input.analog[index][0] = 128;
paddle[index>>2].State = 0x40;
input.analog[port][0] = 128;
paddle[port>>2].State = 0x40;
paddle[port>>2].Counter = 0;
}

INLINE unsigned char paddle_read(int port)
Expand All @@ -63,7 +65,13 @@ INLINE unsigned char paddle_read(int port)
/* Japanese model: automatic flip-flop */
if (region_code < REGION_USA)
{
paddle[index].State ^= 0x40;
/* two I/O port reads are required to fully read paddles state on control ports 1 & 2 so using two read access latency for switching should be safe */
/* note: real paddle switching time is approx. 62.5 us period according to https://www.raphnet.net/electronique/sms_paddle/index_en.php#4 */
if (++paddle[index].Counter > 2)
{
paddle[index].Counter = 0;
paddle[index].State ^= 0x40;
}
}

if (paddle[index].State & 0x40)
Expand Down
4 changes: 2 additions & 2 deletions core/input_hw/paddle.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Genesis Plus
* Sega Paddle Control support
*
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
* Copyright (C) 2007-2023 Eke-Eke (Genesis Plus GX)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
Expand Down Expand Up @@ -40,7 +40,7 @@
#define _PADDLE_H_

/* Function prototypes */
extern void paddle_reset(int index);
extern void paddle_reset(int port);
extern unsigned char paddle_1_read(void);
extern unsigned char paddle_2_read(void);
extern void paddle_1_write(unsigned char data, unsigned char mask);
Expand Down
Loading

0 comments on commit 31add24

Please sign in to comment.