naomi: auto configure eeprom and bbsram for network

This commit is contained in:
Flyinghead 2020-04-19 21:45:15 +02:00
parent 98b2a32eae
commit 06313dd540
15 changed files with 380 additions and 61 deletions

View File

@ -1418,9 +1418,33 @@ struct atomiswave_lightgun : maple_lightgun
}
};
char EEPROM[0x100];
u8 EEPROM[0x100];
bool EEPROM_loaded = false;
void load_naomi_eeprom()
{
if (!EEPROM_loaded)
{
EEPROM_loaded = true;
std::string nvmemSuffix = cfgLoadStr("net", "nvmem", "");
std::string eeprom_file = get_game_save_prefix() + nvmemSuffix + ".eeprom";
FILE* f = fopen(eeprom_file.c_str(), "rb");
if (f)
{
fread(EEPROM, 1, 0x80, f);
fclose(f);
DEBUG_LOG(MAPLE, "Loaded EEPROM from %s", eeprom_file.c_str());
}
else if (naomi_default_eeprom != NULL)
{
DEBUG_LOG(MAPLE, "Using default EEPROM file");
memcpy(EEPROM, naomi_default_eeprom, 0x80);
}
else
DEBUG_LOG(MAPLE, "EEPROM file not found at %s and no default found", eeprom_file.c_str());
}
}
u32 naomi_button_mapping[] = {
NAOMI_SERVICE_KEY, // DC_BTN_C
NAOMI_BTN1_KEY, // DC_BTN_B
@ -2153,6 +2177,7 @@ struct maple_naomi_jamma : maple_sega_controller
case 0x0B: //EEPROM write
{
load_naomi_eeprom();
int address = dma_buffer_in[1];
int size = dma_buffer_in[2];
DEBUG_LOG(MAPLE, "EEprom write %08X %08X\n", address, size);
@ -2183,26 +2208,7 @@ struct maple_naomi_jamma : maple_sega_controller
case 0x3: //EEPROM read
{
if (!EEPROM_loaded)
{
EEPROM_loaded = true;
std::string nvmemSuffix = cfgLoadStr("net", "nvmem", "");
std::string eeprom_file = get_game_save_prefix() + nvmemSuffix + ".eeprom";
FILE* f = fopen(eeprom_file.c_str(), "rb");
if (f)
{
fread(EEPROM, 1, 0x80, f);
fclose(f);
DEBUG_LOG(MAPLE, "Loaded EEPROM from %s", eeprom_file.c_str());
}
else if (naomi_default_eeprom != NULL)
{
DEBUG_LOG(MAPLE, "Using default EEPROM file");
memcpy(EEPROM, naomi_default_eeprom, 0x80);
}
else
DEBUG_LOG(MAPLE, "EEPROM file not found at %s and no default found", eeprom_file.c_str());
}
load_naomi_eeprom();
//printf("EEprom READ\n");
int address = dma_buffer_in[1];
//printState(Command,buffer_in,buffer_in_len);

View File

@ -133,6 +133,9 @@ void limit_joystick_magnitude(s8& joyx, s8& joyy)
}
}
extern u8 EEPROM[0x100];
void load_naomi_eeprom();
// Mouse position and buttons
extern u32 mo_buttons;
extern s32 mo_x_abs;

View File

@ -1,11 +1,6 @@
#include "maple_helper.h"
#include "maple_if.h"
u32 maple_GetBusId(u32 addr)
{
return addr>>6;
}
u32 maple_GetPort(u32 addr)
{
for (int i=0;i<6;i++)
@ -26,12 +21,3 @@ u32 maple_GetAttachedDevices(u32 bus)
return rv;
}
//device : 0 .. 4 -> subdevice , 5 -> main device :)
u32 maple_GetAddress(u32 bus,u32 port)
{
u32 rv=bus<<6;
rv|=1<<port;
return rv;
}

View File

@ -1,7 +1,19 @@
#pragma once
#include "types.h"
u32 maple_GetBusId(u32 addr);
static inline u32 maple_GetBusId(u32 addr)
{
return addr >> 6;
}
u32 maple_GetPort(u32 addr);
u32 maple_GetAttachedDevices(u32 bus);
u32 maple_GetAddress(u32 bus,u32 port);
//device : 0 .. 4 -> subdevice , 5 -> main device :)
static inline u32 maple_GetAddress(u32 bus, u32 port)
{
u32 rv = bus << 6;
rv |= 1 << port;
return rv;
}

View File

@ -0,0 +1,124 @@
/*
Created on: Apr 19, 2020
Copyright 2020 flyinghead
This file is part of flycast.
flycast is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
flycast 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with flycast. If not, see <https://www.gnu.org/licenses/>.
*/
#include "naomi_flashrom.h"
#include "hw/flashrom/flashrom.h"
#include "hw/holly/sb_mem.h"
#include "hw/maple/maple_devs.h"
extern MemChip *sys_nvmem;
static u16 eeprom_crc(const u8 *buf, int size)
{
int n = 0xdebdeb00;
for (int i = 0; i < size; i++)
{
n &= 0xffffff00;
n += buf[i];
for (int c = 0; c < 8; c++)
{
if (n & 0x80000000)
n = (n << 1) + 0x10210000;
else
n <<= 1;
}
}
for (int c = 0; c < 8; c++)
{
if (n & 0x80000000)
n = (n << 1) + 0x10210000;
else
n <<= 1;
}
return n >> 16;
}
//
// bbsram layout:
// not totally reveng'ed but there's one fixed-size record,
// followed by a variable-size record starting at 1F8
// where the interesting stuff is.
// Offset Size
// 0x1f8 2 CRC of bytes [218,218+size[
// 0x1fa 2 0
// 0x1fc 4 record size
// 0x200 4 record padded size (crc is done on this)
// 0x204 4 0
// 0x208 16 Same header repeated
// 0x218 size*2 Record data, repeated twice
//
void write_naomi_flash(u32 addr, u8 value)
{
addr &= sys_nvmem->mask;
verify(addr >= 0x218);
u32 block_size = sys_nvmem->Read(0x200, 4);
if (addr >= 0x218 + block_size || 0x218 + block_size * 2 > sys_nvmem->size)
{
WARN_LOG(NAOMI, "NVMEM record doesn't exist or is too short");
return;
}
sys_nvmem->data[addr] = value;
sys_nvmem->data[addr + block_size] = value;
u16 crc = eeprom_crc(&sys_nvmem->data[0x218], block_size);
*(u16 *)&sys_nvmem->data[0x1f8] = crc;
*(u16 *)&sys_nvmem->data[0x208] = crc;
}
//
// eeprom layout:
// Offset Size
// 0 2 CRC of bytes [2,17]
// 2 1 size of record (16, sometimes 1, ignored)
// 3 15 data
// 18 18 same record repeated
// 36 2 CRC of bytes [44,44+size[
// 38 1 record size
// 39 1 record padded size (crc is done on this)
// 40 4 Same header repeated
// 44 size*2 Record data, repeated twice
//
// The first record contains naomi bios settings, and the second one game-specific settings
//
void write_naomi_eeprom(u32 offset, u8 value)
{
load_naomi_eeprom();
if (offset >= 3 && offset < 20)
{
EEPROM[offset] = value;
EEPROM[offset + 18] = value;
u16 crc = eeprom_crc((u8 *)EEPROM + 2, 16);
*(u16 *)&EEPROM[0] = crc;
*(u16 *)&EEPROM[18] = crc;
}
else if (offset >= 44 && (int)offset - 44 < EEPROM[39])
{
EEPROM[offset] = value;
EEPROM[offset + EEPROM[39]] = value;
u16 crc = eeprom_crc((u8 *)EEPROM + 44, EEPROM[39]);
*(u16 *)&EEPROM[36] = crc;
*(u16 *)&EEPROM[40] = crc;
}
else
die("Invalid offset");
}

View File

@ -0,0 +1,25 @@
/*
Created on: Apr 19, 2020
Copyright 2020 flyinghead
This file is part of flycast.
flycast is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
flycast 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with flycast. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "types.h"
void write_naomi_flash(u32 addr, u8 value);
void write_naomi_eeprom(u32 offset, u8 value);

View File

@ -3291,7 +3291,10 @@ Games[] =
{ "mpr-23339.ic16s",0x8000000, 0x0800000 },
{ "mpr-23340.ic17s",0x8800000, 0x0800000 },
{ NULL, 0, 0 },
}
},
NULL,
NULL,
slashout_eeprom_dump
},
// Sega Marine Fishing
{
@ -3828,7 +3831,8 @@ Games[] =
{ NULL, 0, 0 },
},
NULL,
&vonot_inputs
&vonot_inputs,
vonot_eeprom_dump
},
// Virtua Striker 2 Ver. 2000 (JPN, USA, EXP, KOR, AUS) (Rev C)
{
@ -3942,6 +3946,7 @@ Games[] =
},
NULL,
&wrungp_inputs,
wrungp_eeprom_dump
},
// Wave Runner GP (USA, Rev A)
{
@ -3972,6 +3977,7 @@ Games[] =
},
NULL,
&wrungp_inputs,
wrungp_eeprom_dump
},
// World Kicks (WK2 Ver. A)
{
@ -4938,10 +4944,12 @@ Games[] =
ROT0,
{
{ "317-5069-com.pic", 0, 0x4000 },
{ "gundmgd-default-eeprom.bin", 0, 0x80, 0x0000000, Eeprom },
//{ "gundmgd-default-eeprom.bin", 0, 0x80, 0x0000000, Eeprom },
{ NULL, 0, 0 },
},
"gdl-0001",
NULL,
gundmct_eeprom_dump
},
// Mobile Suit Gundam: Federation Vs. Zeon DX (USA, Japan) (GDL-0006)
{
@ -4956,10 +4964,12 @@ Games[] =
ROT0,
{
{ "317-5079-com.pic", 0, 0x4000 },
{ "gundmxgd-default-eeprom.bin", 0, 0x80, 0x0000000, Eeprom },
//{ "gundmxgd-default-eeprom.bin", 0, 0x80, 0x0000000, Eeprom },
{ NULL, 0, 0 },
},
"gdl-0006",
NULL,
gundmxgd_eeprom_dump
},
// Ikaruga (GDL-0010)
{
@ -5485,6 +5495,8 @@ Games[] =
{ NULL, 0, 0 },
},
"gds-0004",
NULL,
slashout_eeprom_dump
},
// Spikers Battle (GDS-0005)
{
@ -5502,6 +5514,8 @@ Games[] =
{ NULL, 0, 0 },
},
"gds-0005",
NULL,
spkrbtl_eeprom_dump
},
// Sports Jam (GDS-0003)
{

View File

@ -89,12 +89,23 @@ static u8 alienfnt_eeprom_dump[] = {
};
static u8 gundmct_eeprom_dump[] = {
0xC1, 0xC1, 0x10, 0x42, 0x43, 0x56, 0x30, 0x09, 0x00, 0x0B, 0x02, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0xC1, 0xC1, 0x10, 0x42, 0x43, 0x56, 0x30, 0x09, 0x00, 0x0B, 0x02, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xbe, 0x46, 0x10, 0x42, 0x43, 0x56, 0x30, 0x18, 0x00, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0xbe, 0x46, 0x10, 0x42, 0x43, 0x56, 0x30, 0x18, 0x00, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x78, 0x1e, 0x10, 0x10, 0x78, 0x1e, 0x10, 0x10, 0x30, 0x56, 0x43, 0x42, 0x01, 0x05, 0x01, 0x01, 0x01, 0x00,
0x02, 0x00, 0x02, 0x02, 0x00, 0x03, 0x30, 0x56, 0x43, 0x42, 0x01, 0x05, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00,
0x02, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
static u8 gundmxgd_eeprom_dump[] = {
0xd9, 0xd2, 0x10, 0x42, 0x44, 0x55, 0x30, 0x18, 0x00, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0xd9, 0xd2, 0x10, 0x42, 0x44, 0x55, 0x30, 0x18, 0x00, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x65, 0x4b, 0x20, 0x20, 0x65, 0x4b, 0x20, 0x20, 0x30, 0x55, 0x44, 0x42, 0x01, 0x05, 0x01, 0x01, 0x01, 0x00,
0x02, 0x00, 0x02, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x55, 0x44, 0x42, 0x01, 0x05, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x02, 0x02,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
@ -111,11 +122,11 @@ static u8 kick4csh_eeprom_dump[] = {
};
static u8 hmgeo_eeprom_dump[] = {
0xCA, 0xFB, 0x10, 0x42, 0x43, 0x57, 0x30, 0x09, 0x10, 0x00, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0xCA, 0xFB, 0x10, 0x42, 0x43, 0x57, 0x30, 0x09, 0x10, 0x00, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0xED, 0x2A, 0x20, 0x20, 0xED, 0x2A, 0x20, 0x20, 0x06, 0x06, 0x01, 0x20, 0x03, 0x00, 0x00, 0x01, 0x00, 0x01,
0x6d, 0x46, 0x10, 0x42, 0x43, 0x57, 0x30, 0x18, 0x10, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x6d, 0x46, 0x10, 0x42, 0x43, 0x57, 0x30, 0x18, 0x10, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x69, 0x61, 0x20, 0x20, 0x69, 0x61, 0x20, 0x20, 0x06, 0x06, 0x01, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01,
0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x01, 0x20, 0x03, 0x00, 0x00, 0x01, 0x00, 0x01, 0x03, 0x03, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x01, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x03, 0x03, 0x01, 0x01,
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
@ -143,4 +154,48 @@ static u8 ringout_eeprom_dump[] = {
0x00, 0x00
};
static u8 slashout_eeprom_dump[] = {
0x7f, 0x5d, 0x10, 0x42, 0x43, 0x45, 0x30, 0x18, 0x10, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x7f, 0x5d, 0x10, 0x42, 0x43, 0x45, 0x30, 0x18, 0x10, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0xc6, 0xa4, 0x08, 0x08, 0xc6, 0xa4, 0x08, 0x08, 0x42, 0x43, 0x45, 0x30, 0x00, 0x02, 0x00, 0x00, 0x42, 0x43,
0x45, 0x30, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
static u8 spkrbtl_eeprom_dump[] = {
0x42, 0xec, 0x10, 0x42, 0x43, 0x5a, 0x30, 0x18, 0x10, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x42, 0xec, 0x10, 0x42, 0x43, 0x5a, 0x30, 0x18, 0x10, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0xd5, 0x9f, 0x10, 0x10, 0xd5, 0x9f, 0x10, 0x10, 0x42, 0x43, 0x5a, 0x30, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,
0xc0, 0x12, 0x2c, 0x01, 0x01, 0x00, 0x42, 0x43, 0x5a, 0x30, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0xc0, 0x12,
0x2c, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
static u8 vonot_eeprom_dump[] = {
0x93, 0xac, 0x10, 0x42, 0x42, 0x56, 0x30, 0x18, 0x10, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x93, 0xac, 0x10, 0x42, 0x42, 0x56, 0x30, 0x18, 0x10, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0xb7, 0x0a, 0x1c, 0x1c, 0xb7, 0x0a, 0x1c, 0x1c, 0x66, 0x05, 0x4f, 0x56, 0x06, 0x00, 0x08, 0x00, 0x02, 0x02,
0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01,
0x66, 0x05, 0x4f, 0x56, 0x06, 0x00, 0x08, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
static u8 wrungp_eeprom_dump[] = {
0x53, 0x45, 0x10, 0x42, 0x44, 0x44, 0x34, 0x18, 0x10, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x53, 0x45, 0x10, 0x42, 0x44, 0x44, 0x34, 0x18, 0x10, 0x1a, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x89, 0x55, 0x22, 0x24, 0x89, 0x55, 0x22, 0x24, 0x42, 0x44, 0x44, 0x34, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02,
0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
0x81, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x44, 0x44, 0x34, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02,
0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
0x81, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00
};
#endif /* CORE_HW_NAOMI_NAOMI_ROMS_EEPROM_H_ */

View File

@ -24,6 +24,8 @@
#include <chrono>
#include <thread>
#include "rend/gui.h"
#include "hw/naomi/naomi_cart.h"
#include "hw/naomi/naomi_flashrom.h"
sock_t NaomiNetwork::createAndBind(int protocol)
{
@ -55,6 +57,8 @@ sock_t NaomiNetwork::createAndBind(int protocol)
bool NaomiNetwork::init()
{
if (!settings.network.Enable)
return false;
#ifdef _WIN32
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0)
@ -474,3 +478,70 @@ void NaomiNetwork::terminate()
server_sock = INVALID_SOCKET;
}
}
// Sets the game network config using MIE eeprom or bbsram:
// Node -1 disables network
// Node 0 is master, nodes 1+ are slave
void SetNaomiNetworkConfig(int node)
{
if (!strcmp("ALIEN FRONT", naomi_game_id))
{
// no way to disable the network
write_naomi_eeprom(0x3f, node == 0 ? 0 : 1);
}
else if (!strcmp("MOBILE SUIT GUNDAM JAPAN", naomi_game_id) // gundmct
|| !strcmp("MOBILE SUIT GUNDAM DELUXE JAPAN", naomi_game_id)) // gundmxgd
{
write_naomi_eeprom(0x38, node == -1 ? 2
: node == 0 ? 0 : 1);
}
else if (!strcmp(" BIOHAZARD GUN SURVIVOR2", naomi_game_id))
{
// FIXME need default flash
write_naomi_flash(0x21c, node == 0 ? 0 : 1); // CPU ID - 1
write_naomi_flash(0x22a, node == -1 ? 0 : 1); // comm link on
}
else if (!strcmp("HEAVY METAL JAPAN", naomi_game_id))
{
write_naomi_eeprom(0x31, node == -1 ? 0 : node == 0 ? 1 : 2);
}
else if (!strcmp("OUTTRIGGER JAPAN", naomi_game_id))
{
// FIXME need default flash
write_naomi_flash(0x21a, node == -1 ? 0 : 1); // network on
write_naomi_flash(0x21b, node); // node id
}
else if (!strcmp("SLASHOUT JAPAN VERSION", naomi_game_id))
{
write_naomi_eeprom(0x30, node == -1 ? 0
: node == 0 ? 1 : 2);
}
else if (!strcmp("SPAWN JAPAN", naomi_game_id))
{
write_naomi_eeprom(0x44, node == -1 ? 0 : 1); // network on
write_naomi_eeprom(0x30, node <= 0 ? 1 : 2); // node id
}
else if (!strcmp("SPIKERS BATTLE JAPAN VERSION", naomi_game_id))
{
write_naomi_eeprom(0x30, node == -1 ? 0
: node == 0 ? 1 : 2);
}
else if (!strcmp("VIRTUAL-ON ORATORIO TANGRAM", naomi_game_id))
{
write_naomi_eeprom(0x45, node == -1 ? 3
: node == 0 ? 0 : 1);
write_naomi_eeprom(0x47, node == 0 ? 0 : 1);
}
else if (!strcmp("WAVE RUNNER GP", naomi_game_id))
{
write_naomi_eeprom(0x33, node);
write_naomi_eeprom(0x35, node == -1 ? 2
: node == 0 ? 0 : 1);
}
else if (!strcmp("WORLD KICKS", naomi_game_id))
{
// FIXME need default flash
write_naomi_flash(0x224, node == -1 ? 0 : 1); // network on
write_naomi_flash(0x220, node == 0 ? 0 : 1); // node id
}
}

View File

@ -73,3 +73,5 @@ private:
static const uint16_t SERVER_PORT = 37391;
};
void SetNaomiNetworkConfig(int node);

View File

@ -28,6 +28,7 @@
#include "cheats.h"
#include "rend/CustomTexture.h"
#include "hw/maple/maple_devs.h"
#include "network/naomi_network.h"
void FlushCache();
void LoadCustom();
@ -635,7 +636,11 @@ void dc_start_game(const char *path)
naomi_cart_LoadRom(path);
LoadCustom();
if (settings.platform.system == DC_PLATFORM_NAOMI)
{
mcfg_CreateNAOMIJamma();
SetNaomiNetworkConfig(settings.network.Enable ? settings.network.ActAsServer ? 0 : 1 // FIXME more than 2 nodes
: -1);
}
else if (settings.platform.system == DC_PLATFORM_ATOMISWAVE)
mcfg_CreateAtomisWaveControllers();
}
@ -798,6 +803,7 @@ void InitSettings()
settings.input.maple_expansion_devices[i][0] = i == 0 ? MDT_SegaVMU : MDT_None;
settings.input.maple_expansion_devices[i][1] = i == 0 ? MDT_SegaVMU : MDT_None;
}
settings.network.Enable = false;
settings.network.ActAsServer = false;
settings.network.dns = "46.101.91.123"; // Dreamcast Live DNS
settings.network.server = "";
@ -904,6 +910,7 @@ void LoadSettings(bool game_specific)
sprintf(device_name, "device%d.2", i + 1);
settings.input.maple_expansion_devices[i][1] = (MapleDeviceType)cfgLoadInt(input_section, device_name, settings.input.maple_expansion_devices[i][1]);
}
settings.network.Enable = cfgLoadBool("network", "Enable", settings.network.Enable);
settings.network.ActAsServer = cfgLoadBool("network", "ActAsServer", settings.network.ActAsServer);
settings.network.dns = cfgLoadStr("network", "DNS", settings.network.dns.c_str());
settings.network.server = cfgLoadStr("network", "server", settings.network.server.c_str());
@ -1064,6 +1071,7 @@ void SaveSettings()
}
cfgSaveStr("config", "Dreamcast.ContentPath", paths.c_str());
cfgSaveBool("config", "Dreamcast.HideLegacyNaomiRoms", settings.dreamcast.HideLegacyNaomiRoms);
cfgSaveBool("network", "Enable", settings.network.Enable);
cfgSaveBool("network", "ActAsServer", settings.network.ActAsServer);
cfgSaveStr("network", "DNS", settings.network.dns.c_str());
cfgSaveStr("network", "server", settings.network.server.c_str());

View File

@ -1304,15 +1304,21 @@ static void gui_display_settings()
}
if (ImGui::CollapsingHeader("Network", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::Checkbox("Act as Server", &settings.network.ActAsServer);
ImGui::SameLine();
ShowHelpMarker("Create a local server for Naomi network games");
char server_name[256];
strcpy(server_name, settings.network.server.c_str());
ImGui::InputText("Server", server_name, sizeof(server_name), ImGuiInputTextFlags_CharsNoBlank, nullptr, nullptr);
ImGui::SameLine();
ShowHelpMarker("The server to connect to. Leave blank to find a server automatically");
settings.network.server = server_name;
ImGui::Checkbox("Enable", &settings.network.Enable);
ImGui::SameLine();
ShowHelpMarker("Enable networking for supported Naomi games");
if (settings.network.Enable)
{
ImGui::Checkbox("Act as Server", &settings.network.ActAsServer);
ImGui::SameLine();
ShowHelpMarker("Create a local server for Naomi network games");
char server_name[256];
strcpy(server_name, settings.network.server.c_str());
ImGui::InputText("Server", server_name, sizeof(server_name), ImGuiInputTextFlags_CharsNoBlank, nullptr, nullptr);
ImGui::SameLine();
ShowHelpMarker("The server to connect to. Leave blank to find a server automatically");
settings.network.server = server_name;
}
}
if (ImGui::CollapsingHeader("Other", ImGuiTreeNodeFlags_DefaultOpen))
{

View File

@ -98,7 +98,7 @@ extern GD_StatusT GDStatus;
extern ByteCount_t ByteCount ;
//./core/hw/maple/maple_devs.o
extern char EEPROM[0x100];
extern u8 EEPROM[0x100];
extern bool EEPROM_loaded;
//./core/hw/maple/maple_if.o

View File

@ -534,6 +534,7 @@ struct settings_t
} input;
struct {
bool Enable;
bool ActAsServer;
std::string dns;
std::string server;

View File

@ -250,6 +250,7 @@
AE8C274321122E2500D4D8F4 /* xbrz.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE8C273D21122E2500D4D8F4 /* xbrz.cpp */; };
AE90679B235B6F6400CE473C /* gl_context.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE90679A235B6F6400CE473C /* gl_context.cpp */; };
AE90679D235DF80400CE473C /* osd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AE90679C235DF80400CE473C /* osd.cpp */; };
AEA94931244CDF50001134C7 /* naomi_flashrom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AEA9492F244CDF50001134C7 /* naomi_flashrom.cpp */; };
AED73BAE22FC0E9600ECDB64 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = AED73BAD22FC0E9600ECDB64 /* README.md */; };
AED73DC42303E19200ECDB64 /* sdl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AED73DC02303E19100ECDB64 /* sdl.cpp */; };
AED73DCC233ACC9800ECDB64 /* cheats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AED73DCB233ACC9800ECDB64 /* cheats.cpp */; };
@ -815,6 +816,8 @@
AE8C274021122E2500D4D8F4 /* xbrz_tools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xbrz_tools.h; sourceTree = "<group>"; };
AE90679A235B6F6400CE473C /* gl_context.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gl_context.cpp; sourceTree = "<group>"; };
AE90679C235DF80400CE473C /* osd.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = osd.cpp; sourceTree = "<group>"; };
AEA9492F244CDF50001134C7 /* naomi_flashrom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = naomi_flashrom.cpp; sourceTree = "<group>"; };
AEA94930244CDF50001134C7 /* naomi_roms_eeprom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = naomi_roms_eeprom.h; sourceTree = "<group>"; };
AED73BAD22FC0E9600ECDB64 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../../../core/README.md; sourceTree = "<group>"; };
AED73DC02303E19100ECDB64 /* sdl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sdl.cpp; sourceTree = "<group>"; };
AED73DC12303E19100ECDB64 /* sdl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sdl.h; sourceTree = "<group>"; };
@ -2070,8 +2073,10 @@
AE2A2D5021D6846F004B308D /* m1cartridge.h */,
AE2A2D5621D68470004B308D /* m4cartridge.cpp */,
AE2A2D5421D68470004B308D /* m4cartridge.h */,
AEA9492F244CDF50001134C7 /* naomi_flashrom.cpp */,
AE7BCB6C24460910007285F8 /* naomi_m3comm.cpp */,
AE7BCB6D24460910007285F8 /* naomi_m3comm.h */,
AEA94930244CDF50001134C7 /* naomi_roms_eeprom.h */,
AE2A2D5821D68470004B308D /* naomi_roms_input.h */,
AE2A2D5521D68470004B308D /* naomi_roms.h */,
AE80EDB92157D4E600F7800F /* naomi.cpp */,
@ -2754,6 +2759,7 @@
8491687F1B782B2D00F3F2B4 /* ini.cpp in Sources */,
84B7BF341B72720200F9733F /* maple_cfg.cpp in Sources */,
AE649C2D218C553A00EF4A81 /* LzmaDec.c in Sources */,
AEA94931244CDF50001134C7 /* naomi_flashrom.cpp in Sources */,
AE649C3D218C555600EF4A81 /* chd.c in Sources */,
AED73E762348E45000ECDB64 /* Scan.cpp in Sources */,
AE649C25218C553A00EF4A81 /* Bra.c in Sources */,
@ -2990,7 +2996,7 @@
"USE_SDL=1",
XXH_INLINE_ALL,
VK_USE_PLATFORM_MACOS_MVK,
Z_HAVE_UNISTD_H
Z_HAVE_UNISTD_H,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@ -3045,7 +3051,7 @@
"USE_SDL=1",
XXH_INLINE_ALL,
VK_USE_PLATFORM_MACOS_MVK,
Z_HAVE_UNISTD_H
Z_HAVE_UNISTD_H,
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;