1 // license:BSD-3-Clause
2 // copyright-holders:Angelo Salese, Nicola Salmoria
3 /*******************************************************************************************
4 
5 Fever Soccer (c) 2004 Seibu Kaihatsu
6 
7 A down-grade of the Seibu SPI Hardware with SH-2 as main cpu.
8 
9 driver by Angelo Salese & Nicola Salmoria
10 
11 The input routines are very convoluted in comparison to previous Seibu games,
12 looping over a complex control structure. Could these be derived from the
13 "Touch Panel System" DVD mahjong games Seibu released under the CATS label?
14 
15 TODO:
16 - Layout including lamps
17 - Hopper only works in "COIN HOPPER" mode
18 - Do button 5 or remaining DIPs actually do anything outside service mode?
19 
20 ============================================================================
21 
22 Fever Soccer (JAMMA based Gambling Game)
23 
24 Seibu Kaihatsu Inc.
25 
26 PCB (c) 2004 SYS_SH2B + SYS_SH2B Rom Board
27 
28 Very simple PCB contains:
29 
30      CPU: Hitachi SH-2 (HD6417604F28)
31    Audio: OKI 6295 (rebadged as AD-65)
32 GFX CHIP: RISE11 (custom graphics chip with programmable decryption)
33   EEPROM: ST93C56A
34      OSC: 28.63636MHz
35      DSW: Single 4 switch
36 
37 Other: Battery (CR2032)
38        Sigma XLINX 9572
39        JRC 6355E Serial Real Time Clock (connected to a 32.768KHz OSC)
40 
41 RAM: BSI BS62LV1024SC-70 (x2)
42      EtronTech EM51256C-15J (x4)
43 
44 
45 PRG0.U0139 ST M27C1001 (PCB can handle up to 27C080)
46 PRG1.U0140 ST M27C1001
47 
48 PCM.U0743 ST M27C4001
49 
50 On the SYS_SH2B ROM BOARD:
51 OBJ1.U011 ST M27C160
52 OBJ2.U012 ST M27C160
53 OBJ3.U013 ST M27C160
54 
55 Not used / unpopulated:
56 
57 U0145 LH28F800SU (Alt program ROM near SH-2)
58 
59 U0744 LH28F800SU (Alt PCM ROM near AD-65)
60 
61 U0561 LH28F800SU OBJ1-1 (near ROM BOARD connector & RISE11 chip)
62 U0562 LH28F800SU OBJ2-1
63 U0563 LH28F800SU OBJ3-1
64 U0564 LH28F800SU OBJ4-1
65 
66 *******************************************************************************************/
67 
68 #include "emu.h"
69 #include "cpu/sh/sh2.h"
70 #include "machine/seibuspi.h"
71 #include "sound/okim6295.h"
72 #include "machine/eepromser.h"
73 #include "machine/rtc4543.h"
74 #include "machine/nvram.h"
75 #include "machine/ticket.h"
76 #include "emupal.h"
77 #include "screen.h"
78 #include "speaker.h"
79 
80 
81 class feversoc_state : public driver_device
82 {
83 public:
feversoc_state(const machine_config & mconfig,device_type type,const char * tag)84 	feversoc_state(const machine_config &mconfig, device_type type, const char *tag) :
85 		driver_device(mconfig, type, tag),
86 		m_mainram1(*this, "workram1"),
87 		m_mainram2(*this, "workram2"),
88 		m_nvram(*this, "nvram"),
89 		m_spriteram(*this, "spriteram"),
90 		m_in(*this, {"IN1", "IN0"}),
91 		m_lamps(*this, "lamp%u", 1U),
92 		m_maincpu(*this, "maincpu"),
93 		m_oki(*this, "oki"),
94 		m_eeprom(*this, "eeprom"),
95 		m_rtc(*this, "rtc"),
96 		m_hopper(*this, "hopper"),
97 		m_gfxdecode(*this, "gfxdecode"),
98 		m_palette(*this, "palette")
99 	{ }
100 
101 	void init_feversoc();
102 	void feversoc(machine_config &config);
103 
104 private:
105 	uint16_t in_r(offs_t offset);
106 	void output_w(uint16_t data);
107 	void output2_w(uint16_t data);
108 	void feversoc_map(address_map &map);
109 	uint32_t screen_update_feversoc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
110 	DECLARE_WRITE_LINE_MEMBER(feversoc_irq);
111 	void feversoc_irq_ack(uint16_t data);
112 	virtual void machine_start() override;
113 
114 	required_shared_ptr<uint32_t> m_mainram1;
115 	required_shared_ptr<uint32_t> m_mainram2;
116 	required_shared_ptr<uint32_t> m_nvram;
117 	required_shared_ptr<uint32_t> m_spriteram;
118 	required_ioport_array<2> m_in;
119 	output_finder<7> m_lamps;
120 
121 	required_device<sh2_device> m_maincpu;
122 	required_device<okim6295_device> m_oki;
123 	required_device<eeprom_serial_93cxx_device> m_eeprom;
124 	required_device<jrc6355e_device> m_rtc;
125 	required_device<ticket_dispenser_device> m_hopper;
126 	required_device<gfxdecode_device> m_gfxdecode;
127 	required_device<palette_device> m_palette;
128 };
129 
130 
131 #define MASTER_CLOCK XTAL(28'636'363)
132 
133 
screen_update_feversoc(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)134 uint32_t feversoc_state::screen_update_feversoc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
135 {
136 	uint32_t *spriteram32 = m_spriteram;
137 	int offs,spr_offs,colour,sx,sy,h,w,dx,dy;
138 
139 	bitmap.fill(m_palette->pen(0), cliprect); //black pen
140 
141 	for(offs=(0x2000/4)-2;offs>-1;offs-=2)
142 	{
143 		spr_offs = (spriteram32[offs+0] & 0x3fff);
144 		if(spr_offs == 0)
145 			continue;
146 		sy = (spriteram32[offs+1] & 0x01ff);
147 		sx = (spriteram32[offs+1] & 0x01ff0000)>>16;
148 		colour = (spriteram32[offs+0] & 0x003f0000)>>16;
149 		w = ((spriteram32[offs+0] & 0x07000000)>>24)+1;
150 		h = ((spriteram32[offs+0] & 0x70000000)>>28)+1;
151 
152 		if( sy & 0x100)
153 			sy-=0x200;
154 
155 		for(dx=0;dx<w;dx++)
156 			for(dy=0;dy<h;dy++)
157 				m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,spr_offs++,colour,0,0,(sx+dx*16),(sy+dy*16),0x3f);
158 	}
159 
160 	return 0;
161 }
162 
163 
164 
in_r(offs_t offset)165 uint16_t feversoc_state::in_r(offs_t offset)
166 {
167 	return m_in[offset]->read() & 0xffff;
168 }
169 
output_w(uint16_t data)170 void feversoc_state::output_w(uint16_t data)
171 {
172 	machine().bookkeeping().coin_lockout_w(0, ~data & 0x40);
173 	machine().bookkeeping().coin_lockout_w(1, ~data & 0x40);
174 	machine().bookkeeping().coin_counter_w(0, data & 1);
175 	// data & 2 coin out counter
176 	machine().bookkeeping().coin_counter_w(1, data & 4);
177 	m_hopper->motor_w((data & 0x08) >> 3); // coin hopper or prize hopper
178 	m_oki->set_rom_bank((data & 0x20) >> 5);
179 
180 	m_eeprom->di_write((data & 0x8000) ? 1 : 0);
181 	m_eeprom->clk_write((data & 0x4000) ? ASSERT_LINE : CLEAR_LINE);
182 	m_eeprom->cs_write((data & 0x2000) ? ASSERT_LINE : CLEAR_LINE);
183 
184 	m_rtc->data_w((data & 0x0800) ? 1 : 0);
185 	m_rtc->wr_w((data & 0x0400) ? ASSERT_LINE : CLEAR_LINE);
186 	m_rtc->clk_w((data & 0x0200) ? ASSERT_LINE : CLEAR_LINE);
187 	m_rtc->ce_w((data & 0x0100) ? ASSERT_LINE : CLEAR_LINE);
188 }
189 
output2_w(uint16_t data)190 void feversoc_state::output2_w(uint16_t data)
191 {
192 	for (int n = 0; n < 7; n++)
193 		m_lamps[n] = BIT(data, n); // LAMP1-LAMP7
194 
195 	machine().bookkeeping().coin_counter_w(2, data & 0x2000); // key in
196 	//data & 0x4000 key out
197 }
198 
199 
feversoc_map(address_map & map)200 void feversoc_state::feversoc_map(address_map &map)
201 {
202 	map(0x00000000, 0x0003ffff).rom();
203 	map(0x02000000, 0x0202ffff).ram().share("workram1"); //work ram
204 	map(0x02030000, 0x02033fff).ram().share("nvram");
205 	map(0x02034000, 0x0203dfff).ram().share("workram2"); //work ram
206 	map(0x0203e000, 0x0203ffff).ram().share("spriteram");
207 	map(0x06000000, 0x06000001).w(FUNC(feversoc_state::output_w));
208 	map(0x06000002, 0x06000003).w(FUNC(feversoc_state::output2_w));
209 	map(0x06000006, 0x06000007).w(FUNC(feversoc_state::feversoc_irq_ack));
210 	map(0x06000008, 0x0600000b).r(FUNC(feversoc_state::in_r));
211 	map(0x0600000d, 0x0600000d).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write));
212 	//map(0x06010000, 0x0601007f).rw("obj", FUNC(seibu_encrypted_sprite_device::read), FUNC(seibu_encrypted_sprite_device::write));
213 	map(0x06010060, 0x06010063).nopw(); // sprite buffering
214 	map(0x06018000, 0x06019fff).ram().w(m_palette, FUNC(palette_device::write32)).share("palette");
215 }
216 
217 static const gfx_layout spi_spritelayout =
218 {
219 	16,16,
220 	RGN_FRAC(1,3),
221 	6,
222 	{ RGN_FRAC(0,3)+0,RGN_FRAC(0,3)+8,RGN_FRAC(1,3)+0,RGN_FRAC(1,3)+8,RGN_FRAC(2,3)+0,RGN_FRAC(2,3)+8 },
223 	{
224 		7,6,5,4,3,2,1,0,23,22,21,20,19,18,17,16
225 	},
226 	{
227 		0*32,1*32,2*32,3*32,4*32,5*32,6*32,7*32,8*32,9*32,10*32,11*32,12*32,13*32,14*32,15*32
228 	},
229 	16*32
230 };
231 
232 
233 static GFXDECODE_START( gfx_feversoc )
234 	GFXDECODE_ENTRY( "gfx1", 0, spi_spritelayout,   0, 0x40 )
235 GFXDECODE_END
236 
INPUT_PORTS_START(feversoc)237 static INPUT_PORTS_START( feversoc )
238 	// The "ANALIZE" input shown in test mode does not exist on this hardware.
239 	PORT_START("IN0")
240 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 )
241 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
242 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE )
243 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_GAMBLE_KEYIN ) PORT_NAME("Key In (Service)")
244 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_COIN1 )
245 	PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_DEVICE_MEMBER("hopper", ticket_dispenser_device, line_r)
246 	PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, do_read)
247 	PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_DEVICE_MEMBER("rtc", rtc4543_device, data_r)
248 	PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Service_Mode ) ) PORT_DIPLOCATION( "DIP1:1" )
249 	PORT_DIPSETTING(    0x0100, DEF_STR( Off ) )
250 	PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
251 	PORT_DIPUNKNOWN_DIPLOC( 0x0200, 0x0200, "DIP1:2" )
252 	PORT_DIPNAME( 0x0400, 0x0400, "Backup Memory" ) PORT_DIPLOCATION( "DIP1:3" )
253 	PORT_DIPSETTING(    0x0400, "Use" )
254 	PORT_DIPSETTING(    0x0000, "Reset" )
255 	PORT_DIPUNKNOWN_DIPLOC( 0x0800, 0x0800, "DIP1:4" )
256 	PORT_DIPUNKNOWN_DIPLOC( 0x1000, 0x1000, "DIP1:5" )
257 	PORT_DIPUNKNOWN_DIPLOC( 0x2000, 0x2000, "DIP1:6" )
258 	PORT_DIPUNKNOWN_DIPLOC( 0x4000, 0x4000, "DIP1:7" )
259 	PORT_DIPUNKNOWN_DIPLOC( 0x8000, 0x8000, "DIP1:8" )
260 
261 	PORT_START("IN1")
262 	PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SLOT_STOP1 ) PORT_NAME("Stop 1 (BTN1)")
263 	PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_SLOT_STOP2 ) PORT_NAME("Stop 2 (BTN2)")
264 	PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SLOT_STOP3 ) PORT_NAME("Stop 3 (BTN3)")
265 	PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_GAMBLE_BET ) PORT_NAME("Bet (BTN4)")
266 	PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Unknown (BTN5)") PORT_CODE(KEYCODE_J)
267 	PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_GAMBLE_KEYOUT ) PORT_NAME("Key Out (BTN6)")
268 	PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT ) PORT_NAME("Coin Out (BTN7)")
269 	PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_MEMORY_RESET )
270 	PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
271 INPUT_PORTS_END
272 
273 WRITE_LINE_MEMBER(feversoc_state::feversoc_irq)
274 {
275 	if (state)
276 		m_maincpu->set_input_line(8, ASSERT_LINE);
277 }
278 
feversoc_irq_ack(uint16_t data)279 void feversoc_state::feversoc_irq_ack(uint16_t data)
280 {
281 	m_maincpu->set_input_line(8, CLEAR_LINE);
282 }
283 
machine_start()284 void feversoc_state::machine_start()
285 {
286 	m_lamps.resolve();
287 }
288 
feversoc(machine_config & config)289 void feversoc_state::feversoc(machine_config &config)
290 {
291 	/* basic machine hardware */
292 	SH2(config, m_maincpu, MASTER_CLOCK);
293 	m_maincpu->set_addrmap(AS_PROGRAM, &feversoc_state::feversoc_map);
294 
295 	/* video hardware */
296 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
297 	screen.set_refresh_hz(60);
298 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
299 	screen.set_size(40*8, 32*8);
300 	screen.set_visarea(0*8, 40*8-1, 0*8, 30*8-1); //dynamic resolution?
301 	screen.set_screen_update(FUNC(feversoc_state::screen_update_feversoc));
302 	screen.set_palette(m_palette);
303 	screen.screen_vblank().set(FUNC(feversoc_state::feversoc_irq));
304 
305 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_feversoc);
306 	PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x1000);
307 
308 	/* sound hardware */
309 	SPEAKER(config, "mono").front_center();
310 	OKIM6295(config, m_oki, MASTER_CLOCK/16, okim6295_device::PIN7_LOW).add_route(ALL_OUTPUTS, "mono", 0.6); //pin 7 & frequency not verified (clock should be 28,6363 / n)
311 
312 	EEPROM_93C56_16BIT(config, "eeprom");
313 
314 	JRC6355E(config, m_rtc, XTAL(32'768));
315 
316 	NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);
317 
318 	TICKET_DISPENSER(config, m_hopper, attotime::from_msec(60), TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH);
319 }
320 
321 /***************************************************************************
322 
323   Game driver(s)
324 
325 ***************************************************************************/
326 
327 // Date of build, as displayed in service mode, is Apr 30 2004/22:44:21.
328 // Program ROMs also contain leftover strings and tables from a previous build dated Apr 26 2004/20:25:31.
329 ROM_START( feversoc )
330 	ROM_REGION32_BE( 0x40000, "maincpu", 0 )
CRC(fa699503)331 	ROM_LOAD16_BYTE( "prog0.u0139",   0x00001, 0x20000, CRC(fa699503) SHA1(96a834d4f7d5b764aa51db745afc2cd9a7c9783d) )
332 	ROM_LOAD16_BYTE( "prog1.u0140",   0x00000, 0x20000, CRC(fd4d7943) SHA1(d7d782f878656bc79d70589f9df2cbcfff0adb5e) )
333 
334 	ROM_REGION( 0x600000, "gfx1", 0)    /* text */
335 	ROM_LOAD("obj1.u011", 0x000000, 0x200000, CRC(d8c8dde7) SHA1(3ef815fb1e21a0bd907ee835bc7a32d80f6a9d28) )
336 	ROM_LOAD("obj2.u012", 0x200000, 0x200000, CRC(8e93bfda) SHA1(3b4740cefb164efc320fb69f58e8800d2646fea6) )
337 	ROM_LOAD("obj3.u013", 0x400000, 0x200000, CRC(8c8c6e8b) SHA1(bed4990d6eebb7aefa200ad2bed9b7e71e6bd064) )
338 
339 	ROM_REGION( 0x80000, "oki", 0 )
340 	ROM_LOAD( "pcm.u0743", 0x00000, 0x80000, CRC(20b0c0e3) SHA1(dcf2f620a8fe695688057dbaf5c431a32a832440) )
341 ROM_END
342 
343 void feversoc_state::init_feversoc()
344 {
345 	uint32_t *rom = (uint32_t *)memregion("maincpu")->base();
346 
347 	seibuspi_rise11_sprite_decrypt_feversoc(memregion("gfx1")->base(), 0x200000);
348 
349 	m_maincpu->sh2drc_set_options(SH2DRC_FASTEST_OPTIONS);
350 	m_maincpu->sh2drc_add_fastram(0x00000000, 0x0003ffff, 1, rom);
351 	m_maincpu->sh2drc_add_fastram(0x02000000, 0x0202ffff, 0, &m_mainram1[0]);
352 	m_maincpu->sh2drc_add_fastram(0x02030000, 0x02033fff, 0, &m_nvram[0]);
353 	m_maincpu->sh2drc_add_fastram(0x02034000, 0x0203dfff, 0, &m_mainram2[0]);
354 	m_maincpu->sh2drc_add_fastram(0x0203e000, 0x0203ffff, 0, &m_spriteram[0]);
355 }
356 
357 GAME( 2004, feversoc, 0, feversoc, feversoc, feversoc_state, init_feversoc, ROT0, "Seibu Kaihatsu", "Fever Soccer", 0 )
358