1 // license:BSD-3-Clause
2 // copyright-holders:Zsolt Vasvari, Couriersud
3 /***************************************************************************
4 
5     Burger Time hardware
6 
7 ***************************************************************************/
8 #ifndef MAME_INCLUDES_BTIME_H
9 #define MAME_INCLUDES_BTIME_H
10 
11 #pragma once
12 
13 #include "machine/gen_latch.h"
14 #include "machine/input_merger.h"
15 #include "machine/timer.h"
16 #include "emupal.h"
17 #include "screen.h"
18 
19 class btime_state : public driver_device
20 {
21 public:
btime_state(const machine_config & mconfig,device_type type,const char * tag)22 	btime_state(const machine_config &mconfig, device_type type, const char *tag)
23 		: driver_device(mconfig, type, tag)
24 		, m_rambase(*this, "rambase")
25 		, m_videoram(*this, "videoram")
26 		, m_colorram(*this, "colorram")
27 		, m_bnj_backgroundram(*this, "bnj_bgram")
28 		, m_zoar_scrollram(*this, "zoar_scrollram")
29 		, m_lnc_charbank(*this, "lnc_charbank")
30 		, m_deco_charram(*this, "deco_charram")
31 		, m_spriteram(*this, "spriteram")
32 		, m_audio_rambase(*this, "audio_rambase")
33 		, m_maincpu(*this, "maincpu")
34 		, m_audiocpu(*this, "audiocpu")
35 		, m_audionmi(*this, "audionmi")
36 		, m_gfxdecode(*this, "gfxdecode")
37 		, m_screen(*this, "screen")
38 		, m_palette(*this, "palette")
39 		, m_soundlatch(*this, "soundlatch")
40 		, m_prom_region(*this, "proms")
41 	{
42 	}
43 
44 	/* memory pointers */
45 	optional_shared_ptr<uint8_t> m_rambase;
46 	required_shared_ptr<uint8_t> m_videoram;
47 	required_shared_ptr<uint8_t> m_colorram;
48 	optional_shared_ptr<uint8_t> m_bnj_backgroundram;
49 	optional_shared_ptr<uint8_t> m_zoar_scrollram;
50 	optional_shared_ptr<uint8_t> m_lnc_charbank;
51 	optional_shared_ptr<uint8_t> m_deco_charram;
52 	optional_shared_ptr<uint8_t> m_spriteram;     // used by disco
53 //  uint8_t *  m_decrypted;
54 	optional_shared_ptr<uint8_t> m_audio_rambase;
55 
56 	/* video-related */
57 	std::unique_ptr<bitmap_ind16> m_background_bitmap;
58 	uint8_t    m_btime_palette;
59 	uint8_t    m_bnj_scroll1;
60 	uint8_t    m_bnj_scroll2;
61 	uint8_t    m_btime_tilemap[4];
62 
63 	/* audio-related */
64 	uint8_t    m_audio_nmi_enable_type;
65 
66 	/* protection-related (for mmonkey) */
67 	int      m_protection_command;
68 	int      m_protection_status;
69 	int      m_protection_value;
70 	int      m_protection_ret;
71 
72 	/* devices */
73 	required_device<cpu_device> m_maincpu;
74 	optional_device<cpu_device> m_audiocpu;
75 	optional_device<input_merger_device> m_audionmi;
76 	required_device<gfxdecode_device> m_gfxdecode;
77 	required_device<screen_device> m_screen;
78 	required_device<palette_device> m_palette;
79 	optional_device<generic_latch_8_device> m_soundlatch;
80 	optional_memory_region m_prom_region;
81 
82 	void audio_nmi_enable_w(uint8_t data);
83 	uint8_t zoar_dsw1_read();
84 	uint8_t wtennis_reset_hack_r();
85 	uint8_t mmonkey_protection_r(offs_t offset);
86 	void mmonkey_protection_w(offs_t offset, uint8_t data);
87 	void lnc_videoram_w(offs_t offset, uint8_t data);
88 	uint8_t btime_mirrorvideoram_r(offs_t offset);
89 	uint8_t btime_mirrorcolorram_r(offs_t offset);
90 	void btime_mirrorvideoram_w(offs_t offset, uint8_t data);
91 	void lnc_mirrorvideoram_w(offs_t offset, uint8_t data);
92 	void btime_mirrorcolorram_w(offs_t offset, uint8_t data);
93 	void deco_charram_w(offs_t offset, uint8_t data);
94 	void bnj_background_w(offs_t offset, uint8_t data);
95 	void bnj_scroll1_w(uint8_t data);
96 	void bnj_scroll2_w(uint8_t data);
97 	void btime_video_control_w(uint8_t data);
98 	void bnj_video_control_w(uint8_t data);
99 	void zoar_video_control_w(uint8_t data);
100 	void disco_video_control_w(uint8_t data);
101 	DECLARE_INPUT_CHANGED_MEMBER(coin_inserted_irq_hi);
102 	DECLARE_INPUT_CHANGED_MEMBER(coin_inserted_irq_lo);
103 	DECLARE_INPUT_CHANGED_MEMBER(coin_inserted_nmi_lo);
104 	void ay_audio_nmi_enable_w(uint8_t data);
105 
106 	void init_btime();
107 	void init_tisland();
108 	void init_cookrace();
109 	void init_zoar();
110 	void init_sdtennis();
111 	void init_wtennis();
112 	void init_bnj();
113 	void init_protennb();
114 	void init_disco();
115 	void init_lnc();
116 	DECLARE_MACHINE_START(btime);
117 	DECLARE_MACHINE_RESET(btime);
118 	void btime_palette(palette_device &palette) const;
119 	DECLARE_MACHINE_RESET(lnc);
120 	void lnc_palette(palette_device &palette) const;
121 	DECLARE_MACHINE_START(mmonkey);
122 	DECLARE_MACHINE_RESET(mmonkey);
123 	DECLARE_VIDEO_START(bnj);
124 	DECLARE_VIDEO_START(disco);
125 	uint32_t screen_update_btime(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
126 	uint32_t screen_update_cookrace(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
127 	uint32_t screen_update_lnc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
128 	uint32_t screen_update_eggs(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
129 	uint32_t screen_update_bnj(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
130 	uint32_t screen_update_zoar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
131 	uint32_t screen_update_disco(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
132 	TIMER_DEVICE_CALLBACK_MEMBER(audio_nmi_gen);
133 	void draw_chars( bitmap_ind16 &bitmap, const rectangle &cliprect, uint8_t transparency, uint8_t color, int priority );
134 	void draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect, uint8_t* tmap, uint8_t color );
135 	void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, uint8_t color,
136 							uint8_t sprite_y_adjust, uint8_t sprite_y_adjust_flip_screen,
137 							uint8_t *sprite_ram, offs_t interleave );
138 
139 	void lnc(machine_config &config);
140 	void disco(machine_config &config);
141 	void mmonkey(machine_config &config);
142 	void bnj(machine_config &config);
143 	void cookrace(machine_config &config);
144 	void protenn(machine_config &config);
145 	void wtennis(machine_config &config);
146 	void sdtennis(machine_config &config);
147 	void tisland(machine_config &config);
148 	void zoar(machine_config &config);
149 	void btime(machine_config &config);
150 	void audio_map(address_map &map);
151 	void bnj_map(address_map &map);
152 	void btime_map(address_map &map);
153 	void cookrace_map(address_map &map);
154 	void disco_audio_map(address_map &map);
155 	void disco_map(address_map &map);
156 	void lnc_map(address_map &map);
157 	void mmonkey_map(address_map &map);
158 	void protenn_map(address_map &map);
159 	void tisland_map(address_map &map);
160 	void zoar_map(address_map &map);
161 };
162 
163 #endif // MAME_INCLUDES_BTIME_H
164