1 // license:BSD-3-Clause
2 // copyright-holders:Pierpaolo Prazzoli
3 /*
4 
5 Guru-Readme for Jolly Jogger (Taito, 1982)
6 
7 PCB Layout
8 ----------
9 
10 FGO70007
11 KDN00004
12 KDK00502
13 |----------------------------------------------------------|
14 |             TMM416  TMM416  TMM416  TMM416               |
15 |             TMM416  TMM416  TMM416  TMM416              |-|
16 |             TMM416  TMM416  TMM416  TMM416              | |
17 |             TMM416  TMM416  TMM416  TMM416              | |
18 |                                                         | |
19 |                                                         | |
20 |                                                         | |
21 |                                                         | |
22 |2                                                        |-|
23 |2                                                         |
24 |W   DSW1(8)                                     KD13.1F   |
25 |A                                                         |
26 |Y                                                         |
27 |                                                         |-|
28 |                                                         | |
29 |                                                         | |
30 |                                                         | |
31 |                MB14241                                  | |
32 |    DSW2(8)                                              | |
33 |                                                         | |
34 |                                                         |-|
35 |    VOL         AY3-8910     3.579545MHz                  |
36 |----------------------------------------------------------|
37 Notes:
38       AY3-8910 - Clock 1.7897725MHz [3.579545/2]
39       KD13.1F  - 82S123 Bipolar PROM
40       TMM416   - Toshiba TMM416 16k x1-bit Page Mode DRAM
41       MB14241  - Fujitsu MB14241 Video Shifter
42       VSync    - 59.1864Hz
43       HSync    - 15.0835kHz
44 
45 
46 FGO70008
47 KDN00007
48 |----------------------------------------------------------|
49 |                                                          |
50 |                                            6116         |-|
51 |                                                         | |
52 |                                            KD21.8J      | |
53 |   D2125          D2125                                  | |
54 |                                            KD20.8H      | |
55 |   D2125          D2125                                  | |
56 |                                            KD19.8F      | |
57 |   D2125          D2125                                  |-|
58 |                                            KD18.8E       |
59 |   D2125          D2125                                   |
60 |                                            KD17.8D       |
61 |   D2125          D2125        Z80                        |
62 |                                            KD16.8C      |-|
63 |                                                         | |
64 |                                            KD15.8B      | |
65 |                                                         | |
66 |                                8216  8216  KD14.8A      | |
67 |                                                         | |
68 |                                                         | |
69 |                                                         |-|
70 |                                                          |
71 |----------------------------------------------------------|
72 Notes:
73       Z80   - Clock 3.000MHz [18/6]
74       D2125 - Intel D2125 1k x1-bit SRAM
75       8216  - 4 Bit Parallel Bi-directional Bus Driver
76       6116  - 2k x8-bit SRAM
77       KD*   - 2732 EPROM
78 
79 
80 FGO70009
81 KDN00006
82 |----------------------------------------------------------|
83 |                                                18MHz     |
84 |                                                         |-|
85 |                                                         | |
86 |                                                         | |
87 |                                                      [E]| |
88 |                                                         | |
89 |                                                         | |
90 |                         KD11.5H   KD12.7H               | |
91 |                                                         |-|
92 |1                                                         |
93 |8                                                         |
94 |W [T]                                                     |
95 |A                                                         |
96 |Y                                                        |-|
97 |                                                         | |
98 |                                                         | |
99 |                                                         | |
100 |   KD09.1C  KD10.2C  8216 8216 8216 8216 8216 8216    [F]| |
101 |                                                         | |
102 |                                                         | |
103 |               2114  2114     2114  2114  2114  2114     |-|
104 |                                                          |
105 |----------------------------------------------------------|
106 Notes:
107       KD*  - 2716 EPROM
108       2114 - 1k x4-bit SRAM
109       8216 - 4 Bit Parallel Bi-directional Bus Driver
110 
111 
112   driver by Pierpaolo Prazzoli
113 
114 Notes:
115   The hardware is very similar to Galaxian but has some differencies, like the 3bpp bitmap addition
116   To advance input tests, press Tilt button
117 
118 */
119 
120 #include "emu.h"
121 #include "cpu/z80/z80.h"
122 #include "sound/ay8910.h"
123 #include "emupal.h"
124 #include "screen.h"
125 #include "speaker.h"
126 #include "tilemap.h"
127 
128 
129 class jollyjgr_state : public driver_device
130 {
131 public:
jollyjgr_state(const machine_config & mconfig,device_type type,const char * tag)132 	jollyjgr_state(const machine_config &mconfig, device_type type, const char *tag) :
133 		driver_device(mconfig, type, tag),
134 		m_videoram(*this, "videoram"),
135 		m_colorram(*this, "colorram"),
136 		m_spriteram(*this, "spriteram"),
137 		m_bitmap(*this, "bitmap"),
138 		m_bulletram(*this, "bulletram"),
139 		m_maincpu(*this, "maincpu"),
140 		m_gfxdecode(*this, "gfxdecode"),
141 		m_palette(*this, "palette"),
142 		m_bm_palette(*this, "bm_palette")
143 	{ }
144 
145 	void fspider(machine_config &config);
146 	void jollyjgr(machine_config &config);
147 
148 private:
149 	/* memory pointers */
150 	required_shared_ptr<uint8_t> m_videoram;
151 	required_shared_ptr<uint8_t> m_colorram;
152 	required_shared_ptr<uint8_t> m_spriteram;
153 	required_shared_ptr<uint8_t> m_bitmap;
154 	optional_shared_ptr<uint8_t> m_bulletram;
155 
156 	/* video-related */
157 	tilemap_t  *m_bg_tilemap;
158 
159 	/* misc */
160 	uint8_t      m_nmi_enable;
161 	uint8_t      m_flip_x;
162 	uint8_t      m_flip_y;
163 	uint8_t      m_bitmap_disable;
164 	uint8_t      m_tilemap_bank;
165 	uint8_t      m_pri;
166 	void jollyjgr_videoram_w(offs_t offset, uint8_t data);
167 	void jollyjgr_attrram_w(offs_t offset, uint8_t data);
168 	void jollyjgr_misc_w(uint8_t data);
169 	void jollyjgr_coin_lookout_w(uint8_t data);
170 	TILE_GET_INFO_MEMBER(get_bg_tile_info);
171 	virtual void machine_start() override;
172 	virtual void machine_reset() override;
173 	virtual void video_start() override;
174 	void jollyjgr_palette(palette_device &palette) const;
175 	uint32_t screen_update_jollyjgr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
176 	uint32_t screen_update_fspider(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
177 	DECLARE_WRITE_LINE_MEMBER(vblank_irq);
178 	void draw_bitmap( bitmap_rgb32 &bitmap );
179 	required_device<cpu_device> m_maincpu;
180 	required_device<gfxdecode_device> m_gfxdecode;
181 	required_device<palette_device> m_palette;
182 	required_device<palette_device> m_bm_palette;
183 	void fspider_map(address_map &map);
184 	void jollyjgr_map(address_map &map);
185 };
186 
187 
188 /*************************************
189  *
190  *  Memory handlers
191  *
192  *************************************/
193 
jollyjgr_videoram_w(offs_t offset,uint8_t data)194 void jollyjgr_state::jollyjgr_videoram_w(offs_t offset, uint8_t data)
195 {
196 	m_videoram[offset] = data;
197 	m_bg_tilemap->mark_tile_dirty(offset);
198 }
199 
jollyjgr_attrram_w(offs_t offset,uint8_t data)200 void jollyjgr_state::jollyjgr_attrram_w(offs_t offset, uint8_t data)
201 {
202 	if (offset & 1)
203 	{
204 		/* color change */
205 		int i;
206 
207 		for (i = offset >> 1; i < 0x0400; i += 32)
208 			m_bg_tilemap->mark_tile_dirty(i);
209 	}
210 	else
211 	{
212 		m_bg_tilemap->set_scrolly(offset >> 1, data);
213 	}
214 
215 	m_colorram[offset] = data;
216 }
217 
jollyjgr_misc_w(uint8_t data)218 void jollyjgr_state::jollyjgr_misc_w(uint8_t data)
219 {
220 	// they could be swapped, because it always set "data & 3"
221 	m_flip_x = data & 1;
222 	m_flip_y = data & 2;
223 
224 	// same for these two (used by Frog & Spiders)
225 	m_bitmap_disable = data & 0x40;
226 	m_tilemap_bank = data & 0x20;
227 
228 	m_pri = data & 4;
229 
230 	m_bg_tilemap->set_flip((m_flip_x ? TILEMAP_FLIPX : 0) | (m_flip_y ? TILEMAP_FLIPY : 0));
231 
232 	m_nmi_enable = data & 0x80;
233 	if (!m_nmi_enable)
234 		m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
235 }
236 
jollyjgr_coin_lookout_w(uint8_t data)237 void jollyjgr_state::jollyjgr_coin_lookout_w(uint8_t data)
238 {
239 	machine().bookkeeping().coin_lockout_global_w(data & 1);
240 
241 	/* bits 4, 5, 6 and 7 are used too */
242 }
243 
244 /*************************************
245  *
246  *  Address maps
247  *
248  *************************************/
249 
jollyjgr_map(address_map & map)250 void jollyjgr_state::jollyjgr_map(address_map &map)
251 {
252 	map(0x0000, 0x7fff).rom();
253 	map(0x8000, 0x87ff).ram();
254 	map(0x8ff8, 0x8ff8).portr("DSW1");
255 	map(0x8ff9, 0x8ff9).portr("INPUTS");
256 	map(0x8ff8, 0x8ff8).w("aysnd", FUNC(ay8910_device::address_w));
257 	map(0x8ffa, 0x8ffa).portr("SYSTEM").w("aysnd", FUNC(ay8910_device::data_w));
258 	map(0x8ffc, 0x8ffc).w(FUNC(jollyjgr_state::jollyjgr_misc_w));
259 	map(0x8ffd, 0x8ffd).w(FUNC(jollyjgr_state::jollyjgr_coin_lookout_w));
260 	map(0x8fff, 0x8fff).portr("DSW2");
261 	map(0x9000, 0x93ff).ram().w(FUNC(jollyjgr_state::jollyjgr_videoram_w)).share("videoram");
262 	map(0x9800, 0x983f).ram().w(FUNC(jollyjgr_state::jollyjgr_attrram_w)).share("colorram");
263 	map(0x9840, 0x987f).ram().share("spriteram");
264 	map(0x9880, 0x9bff).ram();
265 	map(0xa000, 0xffff).ram().share("bitmap");
266 }
267 
fspider_map(address_map & map)268 void jollyjgr_state::fspider_map(address_map &map)
269 {
270 	map(0x0000, 0x7fff).rom();
271 	map(0x8000, 0x87ff).ram();
272 	map(0x8ff8, 0x8ff8).portr("DSW1");
273 	map(0x8ff9, 0x8ff9).portr("INPUTS");
274 	map(0x8ff8, 0x8ff8).w("aysnd", FUNC(ay8910_device::address_w));
275 	map(0x8ffa, 0x8ffa).portr("SYSTEM").w("aysnd", FUNC(ay8910_device::data_w));
276 	map(0x8ffc, 0x8ffc).w(FUNC(jollyjgr_state::jollyjgr_misc_w));
277 	map(0x8ffd, 0x8ffd).w(FUNC(jollyjgr_state::jollyjgr_coin_lookout_w));
278 	map(0x8fff, 0x8fff).portr("DSW2");
279 	map(0x9000, 0x93ff).ram().w(FUNC(jollyjgr_state::jollyjgr_videoram_w)).share("videoram");
280 	map(0x9800, 0x983f).ram().w(FUNC(jollyjgr_state::jollyjgr_attrram_w)).share("colorram");
281 	map(0x9840, 0x987f).ram().share("spriteram");
282 	map(0x9880, 0x989f).ram(); // ?
283 	map(0x98a0, 0x98af).ram().share("bulletram");
284 	map(0x98b0, 0x9bff).ram(); // ?
285 	map(0xa000, 0xffff).ram().share("bitmap");
286 }
287 
288 
289 
290 /*************************************
291  *
292  *  Input ports
293  *
294  *************************************/
295 
296 static INPUT_PORTS_START( jollyjgr )
297 	PORT_START("DSW1")
DEF_STR(Bonus_Life)298 	PORT_DIPNAME( 0x03, 0x02, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SW1:!1,!2")
299 	PORT_DIPSETTING(    0x03, "10000" )
300 	PORT_DIPSETTING(    0x02, "20000" )
301 	PORT_DIPSETTING(    0x01, "30000" )
302 	PORT_DIPSETTING(    0x00, "40000" )
303 	PORT_DIPNAME( 0x04, 0x00, DEF_STR( Free_Play ) )    PORT_DIPLOCATION("SW1:!3")
304 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
305 	PORT_DIPSETTING(    0x04, DEF_STR( On ) )
306 	PORT_DIPNAME( 0x18, 0x10, "Timer" )         PORT_DIPLOCATION("SW1:!4,!5")
307 	PORT_DIPSETTING(    0x18, "2 min 20 sec" )
308 	PORT_DIPSETTING(    0x10, "2 min 40 sec" )
309 	PORT_DIPSETTING(    0x08, "3 min" )
310 	PORT_DIPSETTING(    0x00, "3 min 20 sec" )
311 	PORT_SERVICE( 0x20, IP_ACTIVE_HIGH )            PORT_DIPLOCATION("SW1:!6")
312 	PORT_DIPNAME( 0x40, 0x00, DEF_STR( Flip_Screen ) )  PORT_DIPLOCATION("SW1:!7") // it works only when Cabinet is set to Upright
313 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
314 	PORT_DIPSETTING(    0x40, DEF_STR( On ) )
315 	PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) )      PORT_DIPLOCATION("SW1:!8")
316 	PORT_DIPSETTING(    0x80, DEF_STR( Upright ) )
317 	PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
318 
319 	PORT_START("DSW2")
320 	PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )      PORT_DIPLOCATION("SW2:!1,!2")
321 	PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
322 	PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
323 	PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
324 	PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
325 	PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) )        PORT_DIPLOCATION("SW2:!3,!4")
326 	PORT_DIPSETTING(    0x0c, "3" )
327 	PORT_DIPSETTING(    0x08, "4" )
328 	PORT_DIPSETTING(    0x04, "5" )
329 	PORT_DIPSETTING(    0x00, "6" )
330 	PORT_DIPNAME( 0x10, 0x00, "Display Coinage" )       PORT_DIPLOCATION("SW2:!5")
331 	PORT_DIPSETTING(    0x10, DEF_STR( No ) )
332 	PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
333 	PORT_DIPNAME( 0x20, 0x00, "Display Year" )      PORT_DIPLOCATION("SW2:!6")
334 	PORT_DIPSETTING(    0x20, DEF_STR( No ) )
335 	PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
336 	PORT_DIPNAME( 0x40, 0x00, "No Hit" )            PORT_DIPLOCATION("SW2:!7")
337 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
338 	PORT_DIPSETTING(    0x40, DEF_STR( On ) )
339 	PORT_DIPNAME( 0x80, 0x00, "Number of Coin Switches" )   PORT_DIPLOCATION("SW2:!8")
340 	PORT_DIPSETTING(    0x80, "1" )
341 	PORT_DIPSETTING(    0x00, "2" )
342 
343 	PORT_START("INPUTS")
344 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY
345 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY
346 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_4WAY
347 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_4WAY
348 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL
349 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL
350 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_COCKTAIL
351 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL
352 
353 	PORT_START("SYSTEM")
354 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 )
355 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
356 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_COIN1 )
357 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN2 )
358 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 )
359 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START2 )
360 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
361 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_TILT )
362 INPUT_PORTS_END
363 
364 static INPUT_PORTS_START( fspider )
365 	PORT_START("DSW1")
366 	PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )       PORT_DIPLOCATION("SW1:!1,!2,!3,!4")
367 	PORT_DIPSETTING(    0x00, DEF_STR( 9C_1C ) )
368 	PORT_DIPSETTING(    0x01, DEF_STR( 8C_1C ) )
369 	PORT_DIPSETTING(    0x02, DEF_STR( 7C_1C ) )
370 	PORT_DIPSETTING(    0x03, DEF_STR( 6C_1C ) )
371 	PORT_DIPSETTING(    0x04, DEF_STR( 5C_1C ) )
372 	PORT_DIPSETTING(    0x05, DEF_STR( 4C_1C ) )
373 	PORT_DIPSETTING(    0x06, DEF_STR( 3C_1C ) )
374 	PORT_DIPSETTING(    0x07, DEF_STR( 2C_1C ) )
375 	PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
376 	PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
377 	PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
378 	PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
379 	PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
380 	PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
381 	PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
382 	PORT_DIPSETTING(    0x08, DEF_STR( 1C_8C ) )
383 
384 	PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )       PORT_DIPLOCATION("SW1:!5,!6,!7,!8")
385 	PORT_DIPSETTING(    0x00, DEF_STR( 9C_1C ) )
386 	PORT_DIPSETTING(    0x10, DEF_STR( 8C_1C ) )
387 	PORT_DIPSETTING(    0x20, DEF_STR( 7C_1C ) )
388 	PORT_DIPSETTING(    0x30, DEF_STR( 6C_1C ) )
389 	PORT_DIPSETTING(    0x40, DEF_STR( 5C_1C ) )
390 	PORT_DIPSETTING(    0x50, DEF_STR( 4C_1C ) )
391 	PORT_DIPSETTING(    0x60, DEF_STR( 3C_1C ) )
392 	PORT_DIPSETTING(    0x70, DEF_STR( 2C_1C ) )
393 	PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
394 	PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
395 	PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
396 	PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
397 	PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
398 	PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
399 	PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
400 	PORT_DIPSETTING(    0x80, DEF_STR( 1C_8C ) )
401 
402 	PORT_START("DSW2")
403 	PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )        PORT_DIPLOCATION("SW2:!1,!2")
404 	PORT_DIPSETTING(    0x00, "3" )
405 	PORT_DIPSETTING(    0x01, "4" )
406 	PORT_DIPSETTING(    0x02, "5" )
407 	PORT_DIPSETTING(    0x03, "6" )
408 	PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SW2:!3,!4")
409 	PORT_DIPSETTING(    0x00, "10000" )
410 	PORT_DIPSETTING(    0x04, "20000" )
411 	PORT_DIPSETTING(    0x08, "30000" )
412 	PORT_DIPSETTING(    0x0c, "40000" )
413 	PORT_DIPNAME( 0x10, 0x10, "Display Coinage Settings" )  PORT_DIPLOCATION("SW2:!5")
414 	PORT_DIPSETTING(    0x00, DEF_STR( No ) )
415 	PORT_DIPSETTING(    0x10, DEF_STR( Yes ) )
416 	PORT_DIPNAME( 0x20, 0x20, "Show only 1P Coinage" )  PORT_DIPLOCATION("SW2:!6")
417 	PORT_DIPSETTING(    0x20, DEF_STR( No ) )
418 	PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
419 	PORT_DIPNAME( 0x40, 0x00, DEF_STR( Cabinet ) )      PORT_DIPLOCATION("SW2:!7")
420 	PORT_DIPSETTING(    0x40, DEF_STR( Upright ) )
421 	PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
422 	PORT_DIPNAME( 0x80, 0x00, DEF_STR( Free_Play ) )    PORT_DIPLOCATION("SW2:!8")
423 	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
424 	PORT_DIPSETTING(    0x80, DEF_STR( On ) )
425 
426 	PORT_START("INPUTS")
427 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY
428 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY
429 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1 )
430 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON2 )
431 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
432 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL
433 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
434 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_COCKTAIL
435 
436 	PORT_START("SYSTEM")
437 	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 )
438 	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
439 	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_COIN1 )
440 	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN2 )
441 	PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 )
442 	PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START2 )
443 	PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
444 	PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_TILT )
445 INPUT_PORTS_END
446 
447 /*************************************
448  *
449  *  Video emulation
450  *
451  *************************************/
452 
453 /* tilemap / sprites palette */
454 void jollyjgr_state::jollyjgr_palette(palette_device &palette) const
455 {
456 	const uint8_t *color_prom = memregion("proms")->base();
457 
458 	for (int i = 0; i < 32; i++)
459 	{
460 		int bit0, bit1, bit2;
461 
462 		// red component
463 		bit0 = BIT(*color_prom, 0);
464 		bit1 = BIT(*color_prom, 1);
465 		bit2 = BIT(*color_prom, 2);
466 		int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
467 
468 		// green component
469 		bit0 = BIT(*color_prom, 3);
470 		bit1 = BIT(*color_prom, 4);
471 		bit2 = BIT(*color_prom, 5);
472 		int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
473 
474 		// blue component
475 		bit0 = BIT(*color_prom, 6);
476 		bit1 = BIT(*color_prom, 7);
477 		int const b = 0x4f * bit0 + 0xa8 * bit1;
478 
479 		palette.set_pen_color(i, rgb_t(r,g,b));
480 		color_prom++;
481 	}
482 }
483 
484 /* Tilemap is the same as in Galaxian */
TILE_GET_INFO_MEMBER(jollyjgr_state::get_bg_tile_info)485 TILE_GET_INFO_MEMBER(jollyjgr_state::get_bg_tile_info)
486 {
487 	int color = m_colorram[((tile_index & 0x1f) << 1) | 1] & 7;
488 	int region = (m_tilemap_bank & 0x20) ? 2 : 0;
489 	tileinfo.set(region, m_videoram[tile_index], color, 0);
490 }
491 
video_start()492 void jollyjgr_state::video_start()
493 {
494 	m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(jollyjgr_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
495 
496 	m_bg_tilemap->set_transparent_pen(0);
497 	m_bg_tilemap->set_scroll_cols(32);
498 }
499 
draw_bitmap(bitmap_rgb32 & bitmap)500 void jollyjgr_state::draw_bitmap(bitmap_rgb32 &bitmap)
501 {
502 	int count = 0;
503 	for (int y = 0; y < 256; y++)
504 	{
505 		for (int x = 0; x < 256 / 8; x++)
506 		{
507 			for (int i = 0; i < 8; i++)
508 			{
509 				int const bit0 = BIT(m_bitmap[count], i);
510 				int const bit1 = BIT(m_bitmap[count + 0x2000], i);
511 				int const bit2 = BIT(m_bitmap[count + 0x4000], i);
512 				int const color = bit0 | (bit1 << 1) | (bit2 << 2);
513 
514 				if (color)
515 				{
516 					if (m_flip_x && m_flip_y)
517 						bitmap.pix(y, x * 8 + i) = m_bm_palette->pen_color(color);
518 					else if (m_flip_x && !m_flip_y)
519 						bitmap.pix(255 - y, x * 8 + i) = m_bm_palette->pen_color(color);
520 					else if (!m_flip_x && m_flip_y)
521 						bitmap.pix(y, 255 - x * 8 - i) = m_bm_palette->pen_color(color);
522 					else
523 						bitmap.pix(255 - y, 255 - x * 8 - i) = m_bm_palette->pen_color(color);
524 				}
525 			}
526 
527 			count++;
528 		}
529 	}
530 }
531 
screen_update_jollyjgr(screen_device & screen,bitmap_rgb32 & bitmap,const rectangle & cliprect)532 uint32_t jollyjgr_state::screen_update_jollyjgr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
533 {
534 	bitmap.fill(m_bm_palette->pen_color(0), cliprect);
535 
536 	if (m_pri) //used in Frog & Spiders level 3
537 	{
538 		if (!(m_bitmap_disable))
539 			draw_bitmap(bitmap);
540 
541 		m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
542 	}
543 	else
544 	{
545 		m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
546 
547 		if(!(m_bitmap_disable))
548 			draw_bitmap(bitmap);
549 	}
550 
551 	// Sprites are the same as in Galaxian
552 	for (int offs = 0; offs < 0x40; offs += 4)
553 	{
554 		int sx = m_spriteram[offs + 3] + 1;
555 		int sy = m_spriteram[offs];
556 		int flipx = m_spriteram[offs + 1] & 0x40;
557 		int flipy = m_spriteram[offs + 1] & 0x80;
558 		int code = m_spriteram[offs + 1] & 0x3f;
559 		int color = m_spriteram[offs + 2] & 7;
560 
561 		if (m_flip_x)
562 		{
563 			sx = 240 - sx;
564 			flipx = !flipx;
565 		}
566 
567 		if (m_flip_y)
568 			flipy = !flipy;
569 		else
570 			sy = 240 - sy;
571 
572 		if (offs < 3 * 4)
573 			sy++;
574 
575 		m_gfxdecode->gfx(1)->transpen(bitmap,cliprect,
576 				code,color,
577 				flipx,flipy,
578 				sx,sy,0);
579 	}
580 	return 0;
581 }
582 
screen_update_fspider(screen_device & screen,bitmap_rgb32 & bitmap,const rectangle & cliprect)583 uint32_t jollyjgr_state::screen_update_fspider(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
584 {
585 	// Draw bg and sprites
586 	screen_update_jollyjgr(screen, bitmap, cliprect);
587 
588 	/* Draw bullets
589 	16 bytes, 2 bytes per bullet (y,x). 2 player bullets, 6 enemy bullets.
590 	Assume bullets to look the same as on Galaxian hw,
591 	that is, simply 4 pixels. Colours are unknown. */
592 	for (int offs=0;offs<0x10;offs+=2) {
593 		uint8_t sy=~m_bulletram[offs];
594 		uint8_t sx=~m_bulletram[offs|1];
595 		uint16_t bc=(offs<4)?
596 			7: // player, white
597 			3; // enemy, yellow
598 
599 		if (m_flip_y) sy^=0xff;
600 		if (m_flip_x) sx+=8;
601 
602 		if (sy>=cliprect.min_y && sy<=cliprect.max_y)
603 			for (int x=sx-4;x<sx;x++)
604 				if (x>=cliprect.min_x && x<=cliprect.max_x)
605 					bitmap.pix(sy, x) = m_bm_palette->pen_color(bc);
606 	}
607 
608 	return 0;
609 }
610 
611 /*************************************
612  *
613  *  Graphics definitions
614  *
615  *************************************/
616 
617 static const gfx_layout jollyjgr_charlayout =
618 {
619 	8,8,
620 	RGN_FRAC(1,2),
621 	2,
622 	{ RGN_FRAC(0,2), RGN_FRAC(1,2) },
623 	{ 0, 1, 2, 3, 4, 5, 6, 7 },
624 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
625 	8*8
626 };
627 
628 static const gfx_layout jollyjgr_spritelayout =
629 {
630 	16,16,
631 	RGN_FRAC(1,2),
632 	2,
633 	{ RGN_FRAC(0,2), RGN_FRAC(1,2) },
634 	{ 0, 1, 2, 3, 4, 5, 6, 7,
635 		8*8+0, 8*8+1, 8*8+2, 8*8+3, 8*8+4, 8*8+5, 8*8+6, 8*8+7 },
636 	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
637 		16*8, 17*8, 18*8, 19*8, 20*8, 21*8, 22*8, 23*8 },
638 	32*8
639 };
640 
641 static GFXDECODE_START( gfx_jollyjgr )
642 	GFXDECODE_ENTRY( "gfx1", 0, jollyjgr_charlayout,   0, 8 )
643 	GFXDECODE_ENTRY( "gfx2", 0, jollyjgr_spritelayout, 0, 8 )
644 	GFXDECODE_ENTRY( "gfx3", 0, jollyjgr_charlayout,   0, 8 )
645 GFXDECODE_END
646 
647 
648 /*************************************
649  *
650  *  Machine driver
651  *
652  *************************************/
653 
WRITE_LINE_MEMBER(jollyjgr_state::vblank_irq)654 WRITE_LINE_MEMBER(jollyjgr_state::vblank_irq)
655 {
656 	if (state && m_nmi_enable)
657 		m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
658 }
659 
660 
machine_start()661 void jollyjgr_state::machine_start()
662 {
663 	save_item(NAME(m_nmi_enable));
664 	save_item(NAME(m_flip_x));
665 	save_item(NAME(m_flip_y));
666 	save_item(NAME(m_bitmap_disable));
667 	save_item(NAME(m_tilemap_bank));
668 }
669 
machine_reset()670 void jollyjgr_state::machine_reset()
671 {
672 	m_nmi_enable = 0;
673 	m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
674 	m_flip_x = 0;
675 	m_flip_y = 0;
676 	m_bitmap_disable = 0;
677 	m_tilemap_bank = 0;
678 }
679 
jollyjgr(machine_config & config)680 void jollyjgr_state::jollyjgr(machine_config &config)
681 {
682 	/* basic machine hardware */
683 	Z80(config, m_maincpu, XTAL(18'000'000)/6);  /* 3MHz verified */
684 	m_maincpu->set_addrmap(AS_PROGRAM, &jollyjgr_state::jollyjgr_map);
685 
686 	/* video hardware */
687 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
688 	screen.set_refresh_hz(59.18);     /* 59.1864Hz measured */
689 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
690 	screen.set_size(256, 256);
691 	screen.set_visarea(0*8, 32*8-1, 2*8, 30*8-1);
692 	screen.set_screen_update(FUNC(jollyjgr_state::screen_update_jollyjgr));
693 	screen.screen_vblank().set(FUNC(jollyjgr_state::vblank_irq));
694 
695 	GFXDECODE(config, m_gfxdecode, m_palette, gfx_jollyjgr);
696 	PALETTE(config, m_palette, FUNC(jollyjgr_state::jollyjgr_palette), 32); // tilemap and sprites
697 	PALETTE(config, m_bm_palette, palette_device::RGB_3BIT); // bitmap
698 
699 	/* sound hardware */
700 	SPEAKER(config, "mono").front_center();
701 
702 	AY8910(config, "aysnd", XTAL(3'579'545)/2).add_route(ALL_OUTPUTS, "mono", 0.45); /* 1.7897725MHz verified */
703 }
704 
fspider(machine_config & config)705 void jollyjgr_state::fspider(machine_config &config)
706 {
707 	jollyjgr(config);
708 	m_maincpu->set_addrmap(AS_PROGRAM, &jollyjgr_state::fspider_map);
709 
710 	subdevice<screen_device>("screen")->set_screen_update(FUNC(jollyjgr_state::screen_update_fspider));
711 }
712 
713 /*************************************
714  *
715  *  ROM definition(s)
716  *
717  *************************************/
718 
719 ROM_START( jollyjgr )
720 	ROM_REGION( 0x10000, "maincpu", 0 )
721 	ROM_LOAD( "kd14.8a",      0x0000, 0x1000, CRC(404cfa2b) SHA1(023abecbc614d1deb6a239906f62e25bb688ac14) )
722 	ROM_LOAD( "kd15.8b",      0x1000, 0x1000, CRC(4cdc4c8b) SHA1(07257863a2de3a0e6bc1b41b8dcaae8c89bc4720) )
723 	ROM_LOAD( "kd16.8c",      0x2000, 0x1000, CRC(a2fa3500) SHA1(b85439e43a31c3445420896c231ac59f95331226) )
724 	ROM_LOAD( "kd17.8d",      0x3000, 0x1000, CRC(a5ab8c89) SHA1(b5a41581bba1c26ac3819aded29aeb48a5de64f8) )
725 	ROM_LOAD( "kd18.8e",      0x4000, 0x1000, CRC(8547c9a7) SHA1(43319a2271a294c2876e87a30bb7667b67582b76) )
726 	ROM_LOAD( "kd19.8f",      0x5000, 0x1000, CRC(2d0ed544) SHA1(547bcecd7d97f343de721d6af5f13ae6f787d838) )
727 	ROM_LOAD( "kd20.8h",      0x6000, 0x1000, CRC(017a0e5a) SHA1(23e066fea44690279ff7b3b65b03e4096e4d2984) )
728 	ROM_LOAD( "kd21.8j",      0x7000, 0x1000, CRC(e4faed01) SHA1(9b9afaff6cc4addfed7c1929a0d845bfbe9d18cc) )
729 
730 	ROM_REGION( 0x1000, "gfx1", 0 )
731 	ROM_LOAD( "kd09.1c",      0x0000, 0x0800, CRC(ecafd535) SHA1(a1f0bee247e6ab4f9fc3578560b62f5913b4ece2) )
732 	ROM_LOAD( "kd10.2c",      0x0800, 0x0800, CRC(e40fc594) SHA1(1a9bd670dda0405600e4c4d0107b881906969991) )
733 
734 	ROM_REGION( 0x1000, "gfx2", 0 )
735 	ROM_LOAD( "kd11.5h",      0x0000, 0x0800, CRC(d686245c) SHA1(73567b15d9399e450121ad01ad2dcb91bedc1099) )
736 	ROM_LOAD( "kd12.7h",      0x0800, 0x0800, CRC(d69cbb4e) SHA1(f33cc161f93cae9cc314067fa2453838fa8ac3ba) )
737 
738 	ROM_REGION( 0x2000, "gfx3", ROMREGION_ERASE00 )
739 
740 	/* it's identical to kd14.8a, except for the first 32 bytes which are palette bytes */
741 	ROM_REGION( 0x1000, "proms", 0 )
742 	ROM_LOAD( "kd13.1f",      0x0000, 0x1000, CRC(4f4e4e13) SHA1(a8fe0e1fd354e6cc2cf65eab66882c3b98c82100) )
743 ROM_END
744 
745 ROM_START( fspiderb )
746 	ROM_REGION( 0x10000, "maincpu", 0 )
747 	ROM_LOAD( "1.5l",   0x0000, 0x1000, CRC(3679cab1) SHA1(21c055a1e6e42dda7070452a5de9bce01fa256b1) )
748 	ROM_LOAD( "2.8b",   0x7000, 0x1000, CRC(6e543acf) SHA1(45b66068654aabfe9745c8c893424a6d360a1748) )
749 	ROM_LOAD( "3.8c",   0x6000, 0x1000, CRC(f74f83d9) SHA1(18fdd7ebf5096b022207de4504e254860428f469) )
750 	ROM_LOAD( "4.8e",   0x5000, 0x1000, CRC(26add629) SHA1(96a2691f81ea7d0215d99c45f7f6dad4a4a6844e) )
751 	ROM_LOAD( "5.8f",   0x4000, 0x1000, CRC(0457de7b) SHA1(e7a7765d971d328333e8784178762c6fe4e2d783) )
752 	ROM_LOAD( "6.8h",   0x2000, 0x1000, CRC(329d4716) SHA1(898d0f3d053a8ac90c731f39c1d05769882cdcf6) )
753 	ROM_LOAD( "7.8j",   0x3000, 0x1000, CRC(a7d8fc3c) SHA1(3b39155001d21e75f16196bf3c11b34fb6d5fa0b) )
754 	ROM_RELOAD(         0x1000, 0x1000 )
755 
756 	ROM_REGION( 0x4000, "gfx_bank", 0 )
757 	ROM_LOAD(  "8.1c",   0x0000, 0x1000, CRC(4e39abad) SHA1(225a2a08a7afe404e6b74789aab8c97a39a21214) )
758 	ROM_LOAD(  "9.2c",   0x1000, 0x1000, CRC(04dd1604) SHA1(9e686b09e2fc59fa879fd62982adb1c681f3eb73) )
759 	ROM_LOAD( "10.5h",   0x2000, 0x1000, CRC(d4bce323) SHA1(f49df8318aa9e8bd49fad1931480dfd483a0248a) )
760 	ROM_LOAD( "11.7h",   0x3000, 0x1000, CRC(7ab56309) SHA1(b43f542a7359c3a4ccf6f116e3a84bd13af6876f) )
761 
762 	ROM_REGION( 0x1000, "gfx1", 0 )
763 	ROM_COPY( "gfx_bank", 0x0000, 0x0000, 0x800)
764 	ROM_COPY( "gfx_bank", 0x1000, 0x0800, 0x800)
765 
766 	ROM_REGION( 0x1000, "gfx2", 0 )
767 	ROM_COPY( "gfx_bank", 0x2000, 0x0000, 0x800)
768 	ROM_COPY( "gfx_bank", 0x3000, 0x0800, 0x800)
769 
770 	ROM_REGION( 0x1000, "gfx3", ROMREGION_ERASE00 )
771 	ROM_COPY( "gfx_bank", 0x0800, 0x0400, 0x400)
772 	ROM_COPY( "gfx_bank", 0x1800, 0x0c00, 0x400)
773 //  ROM_COPY( "gfx_bank", 0x2800, 0x1000, 0x800)
774 //  ROM_COPY( "gfx_bank", 0x3800, 0x1800, 0x800)
775 
776 	ROM_REGION( 0x1000, "proms", 0 )
777 	ROM_LOAD( "82s123.1f", 0x0000, 0x0020, CRC(cda6001a) SHA1(e10fe848e8123e53bd2db8a14cfa2d8c6621d6aa) )
778 ROM_END
779 
780 
781 
782 /*************************************
783  *
784  *  Game driver(s)
785  *
786  *************************************/
787 
788 GAME( 1981, fspiderb, 0, fspider,  fspider,  jollyjgr_state, empty_init, ROT90, "Taito Corporation", "Frog & Spiders (bootleg?)", MACHINE_SUPPORTS_SAVE ) // comes from a Fawaz Group bootleg(?) board
789 GAME( 1982, jollyjgr, 0, jollyjgr, jollyjgr, jollyjgr_state, empty_init, ROT90, "Taito Corporation", "Jolly Jogger",              MACHINE_SUPPORTS_SAVE )
790