1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// license:BSD-3-Clause
// copyright-holders:S. Smith,David Haywood,Fabio Priuli
/***********************************************************************************************************
Neo Geo cart emulation
Super Bubble Pop cart type
Note: since protection here involves accesses to ROM, we include the scrambling in this
file rather than in a separate prot_* source
***********************************************************************************************************/
#include "emu.h"
#include "sbp.h"
DEFINE_DEVICE_TYPE(NEOGEO_SBP_CART, neogeo_sbp_cart_device, "neocart_sbp", "Neo Geo Super Bubble Pop Cart")
neogeo_sbp_cart_device::neogeo_sbp_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
neogeo_rom_device(mconfig, NEOGEO_SBP_CART, tag, owner, clock)
{
}
void neogeo_sbp_cart_device::device_start()
{
}
void neogeo_sbp_cart_device::device_reset()
{
}
uint16_t neogeo_sbp_cart_device::protection_r(address_space &space, offs_t offset)
{
uint16_t* rom = (get_rom_size()) ? get_rom_base() : get_region_rom_base();
uint16_t origdata = rom[offset + (0x200/2)];
uint16_t data = bitswap<16>(origdata, 11,10,9,8,15,14,13,12,3,2,1,0,7,6,5,4);
int realoffset = 0x200 + (offset * 2);
logerror("sbp_lowerrom_r offset %08x data %04x\n", realoffset, data);
// there is actually data in the rom here already, maybe we should just return it 'as is'
if (realoffset == 0xd5e)
return origdata;
return data;
}
void neogeo_sbp_cart_device::protection_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
int realoffset = 0x200 + (offset * 2);
// the actual data written is just pulled from the end of the rom, and unused space
// maybe this is just some kind of watchdog for the protection device and it doesn't
// matter?
if (realoffset == 0x1080)
{
if (data == 0x4e75)
{
return;
}
else if (data == 0xffff)
{
return;
}
}
printf("sbp_lowerrom_w offset %08x data %04x\n", realoffset, data);
}
void neogeo_sbp_cart_device::patch(uint8_t* cpurom, uint32_t cpurom_size)
{
/* the game code clears the text overlay used ingame immediately after writing it.. why? protection? sloppy code that the hw ignores? imperfect emulation? */
uint16_t* rom = (uint16_t*)cpurom;
rom[0x2a6f8/2] = 0x4e71;
rom[0x2a6fa/2] = 0x4e71;
rom[0x2a6fc/2] = 0x4e71;
}
void neogeo_sbp_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)
{
patch(cpuregion, cpuregion_size);
}
|