Skip to content

Commit

Permalink
NEO.emu and Z80 CPU updates
Browse files Browse the repository at this point in the history
* MD.emu: Refactor Z80 code as a class instead of using global variables
* MD.emu: Allow configuring memory access functions of the Z80 class at compile time
* MD.emu: Generate the Z80 flag lookup tables at compile time
* NEO.emu: Attempt to keep the 68K/Z80 in sync when the 68K reads/writes to the sound register, fixes missing intro audio in Blazing Star in console mode
* NEO.emu: Fix CMC50 M1 decryption issue causing missing audio in games like KOF2000 and SS5
* NEO.emu: Update ADPCM-B step value in YM2610ChangeSamplerate(), fixes audio from that channel changing pitch on sample rate change
* NEO.emu: When emulating the timer interrupt, guard the loop by the current line count
* NEO.emu: Remove a lot of unused code including old CPU cores
* NEO.emu: Remove current Z80 code and share code with MD.emu
  • Loading branch information
Robert Broglia committed Mar 20, 2024
1 parent 29b266a commit e4b141e
Show file tree
Hide file tree
Showing 114 changed files with 1,042 additions and 84,749 deletions.
5 changes: 5 additions & 0 deletions MD.emu/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ CPPFLAGS += -DLSB_FIRST \

CFLAGS_WARN += -Wno-missing-field-initializers

ifeq ($(config_compiler),clang)
# needed for Z80CPU::makeFlagTables()
CFLAGS_CODEGEN += -fconstexpr-steps=10000000
endif

# Genesis Plus includes
CPPFLAGS += -I$(projectPath)/src \
-I$(projectPath)/src/$(gplusPath) \
Expand Down
12 changes: 0 additions & 12 deletions MD.emu/src/fileio/fileio.cc

This file was deleted.

5 changes: 0 additions & 5 deletions MD.emu/src/fileio/fileio.h

This file was deleted.

6 changes: 6 additions & 0 deletions MD.emu/src/genplus-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ using int32 = int32_t;
using uint8 = uint8_t;
using uint16 = uint16_t;
using uint32 = uint32_t;
using INT8 = int8_t;
using INT16 = int16_t;
using INT32 = int32_t;
using UINT8 = uint8_t;
using UINT16 = uint16_t;
using UINT32 = uint32_t;
typedef int16 FMSampleType;
typedef int16 PCMSampleType;
static const uint8 config_dac_bits = 14;
Expand Down
10 changes: 5 additions & 5 deletions MD.emu/src/genplus-gx/cart_hw/sms_cart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,23 @@ void sms_cart_init(void)
switch(slot.mapper)
{
case MAPPER_NONE:
z80_writemem = write_mapper_none;
Z80.onWriteMem = write_mapper_none;
break;

case MAPPER_CODIES:
z80_writemem = write_mapper_codies;
Z80.onWriteMem = write_mapper_codies;
break;

case MAPPER_KOREA:
z80_writemem = write_mapper_korea;
Z80.onWriteMem = write_mapper_korea;
break;

case MAPPER_MSX:
z80_writemem = write_mapper_msx;
Z80.onWriteMem = write_mapper_msx;
break;

default:
z80_writemem = write_mapper_sega;
Z80.onWriteMem = write_mapper_sega;
break;
}

Expand Down
14 changes: 7 additions & 7 deletions MD.emu/src/genplus-gx/genesis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ void gen_init(void)
{
/* initialize Z80 read handler */
/* NB: memory map & write handler are defined by cartridge hardware */
z80_readmem = z80_sms_memory_r;
Z80.onReadMem = z80_sms_memory_r;

/* initialize Z80 ports handlers */
z80_writeport = z80_sms_port_w;
z80_readport = z80_sms_port_r;
Z80.onWritePort = z80_sms_port_w;
Z80.onReadPort = z80_sms_port_r;

/* initialize MS cartridge hardware */
sms_cart_init();
Expand Down Expand Up @@ -162,12 +162,12 @@ void gen_init(void)
}

/* initialize Z80 memory handlers */
z80_writemem = z80_md_memory_w;
z80_readmem = z80_md_memory_r;
Z80.onWriteMem = z80_md_memory_w;
Z80.onReadMem = z80_md_memory_r;

/* initialize Z80 port handlers */
z80_writeport = z80_unused_port_w;
z80_readport = z80_unused_port_r;
Z80.onWritePort = z80_unused_port_w;
Z80.onReadPort = z80_unused_port_r;

/* initialize MD cartridge hardware */
md_cart_init();
Expand Down
1 change: 0 additions & 1 deletion MD.emu/src/genplus-gx/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "genplus-config.h"
#include "macros.h"
#include "m68k.h"
#include "z80.h"
#include "system.h"
#include "genesis.h"
#include "vdp_ctrl.h"
Expand Down
2 changes: 2 additions & 0 deletions MD.emu/src/genplus-gx/sound/sn76489.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef _SN76489_H_
#define _SN76489_H_

#include <genplus-config.h>

/* Function prototypes */

extern void SN76489_Init(double PSGClockValue, int SamplingRate);
Expand Down
3 changes: 1 addition & 2 deletions MD.emu/src/genplus-gx/sound/ym2413.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ to do:

/** EkeEke (2011): removed multiple chips support and cleaned code for Genesis Plus GX **/

#include <math.h>

#include "shared.h"
#include <cmath>

/* compiler dependence */
#define INLINE static __inline__
Expand Down
1 change: 1 addition & 0 deletions MD.emu/src/genplus-gx/system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ uint32 mcycles_vdp;
uint8 system_hw;
void (*system_frame)(EmuEx::EmuSystemTaskContext, EmuEx::EmuVideo *);
int (*audioUpdateFunc)(int16 *sb);
Z80CPU<z80Desc> Z80;

template <bool hasSegaCD = 0>
static void system_frame_md(EmuEx::EmuSystemTaskContext, EmuEx::EmuVideo *);
Expand Down
18 changes: 15 additions & 3 deletions MD.emu/src/genplus-gx/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
*
****************************************************************************************/

#ifndef _SYSTEM_H_
#define _SYSTEM_H_
#pragma once

#include "genplus-config.h"
#include <z80conf.hh>

namespace EmuEx
{
Expand Down Expand Up @@ -103,5 +103,17 @@ static bool emuSystemIs16Bit()
return system_hw != SYSTEM_PBC;
}

#endif /* _SYSTEM_H_ */
extern Z80CPU<z80Desc> Z80;

#define z80_readmap Z80.readMap()
#define z80_writemap Z80.writeMap()
#define z80_readmem Z80.readMem
#define z80_writemem Z80.writeMem
#define z80_readport Z80.readPort
#define z80_writeport Z80.writePort

static void z80_init() { Z80.init(); }
static void z80_reset() { Z80.reset(); }
static void z80_exit () {}
static void z80_run(unsigned cycles) { Z80.run(cycles); }
static void z80_set_nmi_line(unsigned state) { Z80.setNmiLine(state); }
66 changes: 0 additions & 66 deletions MD.emu/src/genplus-gx/z80/osd_cpu.h

This file was deleted.

Loading

0 comments on commit e4b141e

Please sign in to comment.