Skip to content

Commit

Permalink
Aggiunto pieno supporto al Vs. System (ma non al Vs. Dual System).
Browse files Browse the repository at this point in the history
- Aggiornato il numero della versione.
- Emulato tutto quello che riguarda il Vs. System (PPU alternative,
coins, coin counter, watchdog timer e dip switches).
- Aggiunto il supporto alla mapper 151.
- Aggiunto la gestione di controlli esterni che, per comodità, rimangano
incollati alla finestra principale.
- Migliorato l'utilizzo dell'emu_pause() e della gestione del focus
della finestra principale.
  • Loading branch information
punesemu committed May 24, 2016
1 parent cd34d41 commit 8b47feb
Show file tree
Hide file tree
Showing 40 changed files with 3,531 additions and 1,997 deletions.
4 changes: 3 additions & 1 deletion src/core/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ libcore_a_SOURCES = \
miniz.h \
overscan.c \
overscan.h \
paldef.h \
palette.h \
ppu.c \
ppu.h \
Expand All @@ -64,7 +65,8 @@ libcore_a_SOURCES = \
uncompress_selection.h \
unif.c \
unif.h \
version.h
version.h\
vs_system.h

libcore_a_SOURCES += \
mappers/mapper_0.c \
Expand Down
1 change: 1 addition & 0 deletions src/core/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ enum lenght_file_name_type {
enum forced_mirroring { UNK_HORIZONTAL, UNK_VERTICAL };
enum max_chips_rom { MAX_CHIPS = 8 };
enum languages { LNG_ENGLISH, LNG_ITALIAN, LNG_RUSSIAN };
enum database_mode { NODIPSWITCH = 0xFF00, NOEXTRA = 0x0000, VSZAPPER = 0x0001 };

#define LENGTH(x) (sizeof(x)/sizeof(*(x)))

Expand Down
1 change: 1 addition & 0 deletions src/core/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ typedef struct _config {
#endif
BYTE bck_pause;
WORD language;
WORD dipswitch;

_config_input input;
_config_apu apu;
Expand Down
81 changes: 79 additions & 2 deletions src/core/cpu_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "cheat.h"
#include "info.h"
#include "conf.h"
#include "vs_system.h"
#include "qt.h"

#define mod_cycles_op(op, vl) cpu.cycles op vl
#define r2006_during_rendering()\
Expand Down Expand Up @@ -210,19 +212,50 @@ static BYTE cpu_rd_mem(WORD address, BYTE made_tick) {
if (made_tick) {
tick_hw(1);
}

/* controllo se e' consentita la lettura dalla PRG Ram */
if (cpu.prg_ram_rd_active) {
if (address < 0x6000) {
/* leggo */
cpu.openbus = prg.ram.data[address & 0x1FFF];

// Vs System
if ((vs_system.enabled) && (address >= 0x4020)) {
if ((address & 0x4020) == 0x4020) {
vs_system_r4020_clock(rd, before)
}
if (vs_system.special_mode.r5e0x) {
if (address == 0x5E00) {
vs_system.special_mode.index = 0;
} else if (address == 0x5E01) {
cpu.openbus = vs_system.special_mode.r5e0x[(vs_system.special_mode.index++) & 0x1F];
}
} else if (vs_system.special_mode.type == VS_SM_Super_Xevious) {
if (address == 0x54FF) {
cpu.openbus = 0x05;
} else if (address == 0x5678) {
cpu.openbus = vs_system.special_mode.index ? 0x00 : 0x01;
} else if (address == 0x578F) {
cpu.openbus = vs_system.special_mode.index ? 0xD1 : 0x89;
} else if (address == 0x5567) {
vs_system.special_mode.index ^= 1;
cpu.openbus = vs_system.special_mode.index ? 0x37 : 0x3E;
}
}
}
} else {
/*
* se la rom ha una PRG Ram extra allora
* la utilizzo, altrimenti leggo dalla PRG
* Ram normale.
*/
if (!prg.ram_plus) {
cpu.openbus = prg.ram.data[address & 0x1FFF];
// Vs. System
if ((vs_system.enabled == TRUE) && vs_system.shared_mem) {
cpu.openbus = prg.ram.data[address & 0x07FF];
} else {
cpu.openbus = prg.ram.data[address & 0x1FFF];
}
} else {
cpu.openbus = prg.ram_plus_8k[address & 0x1FFF];
}
Expand Down Expand Up @@ -298,6 +331,12 @@ static BYTE INLINE ppu_rd_reg(WORD address) {
ppu_openbus_wr(bit5);
ppu_openbus_wr(bit6);
ppu_openbus_wr(bit7);

// Vs. System
if (vs_system.rc2c05.enabled) {
value = (value & 0xE0) | vs_system.rc2c05.r2002;
}

return (value);
}
if (address == 0x2004) {
Expand Down Expand Up @@ -609,6 +648,16 @@ static void cpu_wr_mem(WORD address, BYTE value) {
}
if (address < 0x4000) {
address &= 0x2007;

// Vs. System
if (vs_system.rc2c05.enabled) {
if (address == 0x2000) {
address = 0x2001;
} else if (address == 0x2001) {
address = 0x2000;
}
}

/*
* per riuscire a far funzionare contemporaneamente
* Battletoads e Fighting Road (J) senza trick, devo
Expand Down Expand Up @@ -687,6 +736,12 @@ static void cpu_wr_mem(WORD address, BYTE value) {
/* controllo se e' attiva la PRG Ram */
if (cpu.prg_ram_wr_active) {
if (address < 0x6000) {
// Vs System
if (vs_system.enabled) {
if ((address >= 0x4020) && ((address & 0x4020) == 0x4020)) {
vs_system_r4020_clock(wr, value)
}
}
/* scrivo */
prg.ram.data[address & 0x1FFF] = value;
} else {
Expand All @@ -696,7 +751,12 @@ static void cpu_wr_mem(WORD address, BYTE value) {
* normale.
*/
if (!prg.ram_plus) {
prg.ram.data[address & 0x1FFF] = value;
// Vs. System
if ((vs_system.enabled == TRUE) && vs_system.shared_mem) {
prg.ram.data[address & 0x07FF] = value;
} else {
prg.ram.data[address & 0x1FFF] = value;
}
} else {
prg.ram_plus_8k[address & 0x1FFF] = value;
}
Expand Down Expand Up @@ -1816,6 +1876,23 @@ static void INLINE tick_hw(BYTE value) {
irqA12.cycles++;
irqA12.race.C001 = FALSE;
}

if (vs_system.enabled == TRUE) {
if (vs_system.coins.left) {
vs_system.coins.left--;
}
if (vs_system.coins.right) {
vs_system.coins.right--;
}
if (vs_system.coins.service) {
vs_system.coins.service--;
}
if (++vs_system.watchdog.timer == vs_system.watchdog.next) {
vs_system.watchdog.reset = TRUE;
}
vs_system_r4020_timer(rd)
vs_system_r4020_timer(wr)
}
}
}
/* --------------------------------------------------------------------------------------------- */
Expand Down
Loading

0 comments on commit 8b47feb

Please sign in to comment.