summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/jedi.h
blob: 40d5093120775825d68d2c4e59f2c0dee1717b6a (plain) (blame)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// license:BSD-3-Clause
// copyright-holders:Dan Boris, Aaron Giles
/*************************************************************************

    Atari Return of the Jedi hardware

*************************************************************************/

#include "screen.h"


/* oscillators and clocks */
#define JEDI_MAIN_CPU_OSC       (XTAL_10MHz)
#define JEDI_AUDIO_CPU_OSC      (XTAL_12_096MHz)
#define JEDI_MAIN_CPU_CLOCK     (JEDI_MAIN_CPU_OSC / 4)
#define JEDI_AUDIO_CPU_CLOCK    (JEDI_AUDIO_CPU_OSC / 8)
#define JEDI_POKEY_CLOCK        (JEDI_AUDIO_CPU_CLOCK)
#define JEDI_TMS5220_CLOCK      (JEDI_AUDIO_CPU_OSC / 2 / 9) /* div by 9 is via a binary counter that counts from 7 to 16 */


class jedi_state : public driver_device
{
public:
	jedi_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag),
		m_nvram(*this, "nvram") ,
		m_backgroundram(*this, "backgroundram"),
		m_paletteram(*this, "paletteram"),
		m_foregroundram(*this, "foregroundram"),
		m_spriteram(*this, "spriteram"),
		m_smoothing_table(*this, "smoothing_table"),
		m_audio_comm_stat(*this, "audio_comm_stat"),
		m_speech_data(*this, "speech_data"),
		m_maincpu(*this, "maincpu"),
		m_audiocpu(*this, "audiocpu"),
		m_screen(*this, "screen")
	{ }

	required_shared_ptr<uint8_t> m_nvram;

	/* machine state */
	uint8_t  m_a2d_select;
	uint8_t  m_nvram_enabled;
	emu_timer *m_interrupt_timer;

	/* video state */
	required_shared_ptr<uint8_t> m_backgroundram;
	required_shared_ptr<uint8_t> m_paletteram;
	required_shared_ptr<uint8_t> m_foregroundram;
	required_shared_ptr<uint8_t> m_spriteram;
	required_shared_ptr<uint8_t> m_smoothing_table;
	uint32_t m_vscroll;
	uint32_t m_hscroll;
	bool m_foreground_bank;
	bool m_video_off;

	/* audio state */
	uint8_t  m_audio_latch;
	uint8_t  m_audio_ack_latch;
	required_shared_ptr<uint8_t> m_audio_comm_stat;
	required_shared_ptr<uint8_t> m_speech_data;
	uint8_t  m_speech_strobe_state;
	DECLARE_WRITE8_MEMBER(main_irq_ack_w);
	DECLARE_WRITE8_MEMBER(rom_banksel_w);
	DECLARE_READ8_MEMBER(a2d_data_r);
	DECLARE_WRITE8_MEMBER(a2d_select_w);
	DECLARE_WRITE_LINE_MEMBER(coin_counter_left_w);
	DECLARE_WRITE_LINE_MEMBER(coin_counter_right_w);
	DECLARE_WRITE8_MEMBER(nvram_data_w);
	DECLARE_WRITE8_MEMBER(nvram_enable_w);
	DECLARE_WRITE8_MEMBER(jedi_vscroll_w);
	DECLARE_WRITE8_MEMBER(jedi_hscroll_w);
	DECLARE_CUSTOM_INPUT_MEMBER(jedi_audio_comm_stat_r);
	DECLARE_WRITE8_MEMBER(irq_ack_w);
	DECLARE_WRITE_LINE_MEMBER(audio_reset_w);
	DECLARE_WRITE8_MEMBER(jedi_audio_latch_w);
	DECLARE_READ8_MEMBER(audio_latch_r);
	DECLARE_READ8_MEMBER(jedi_audio_ack_latch_r);
	DECLARE_WRITE8_MEMBER(audio_ack_latch_w);
	DECLARE_WRITE8_MEMBER(speech_strobe_w);
	DECLARE_READ8_MEMBER(speech_ready_r);
	DECLARE_WRITE8_MEMBER(speech_reset_w);
	virtual void machine_start() override;
	virtual void machine_reset() override;
	virtual void sound_start() override;
	virtual void sound_reset() override;
	DECLARE_VIDEO_START(jedi);
	DECLARE_WRITE_LINE_MEMBER(foreground_bank_w);
	DECLARE_WRITE_LINE_MEMBER(video_off_w);
	uint32_t screen_update_jedi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
	TIMER_CALLBACK_MEMBER(generate_interrupt);
	TIMER_CALLBACK_MEMBER(delayed_audio_latch_w);
	void get_pens(pen_t *pens);
	void do_pen_lookup(bitmap_rgb32 &bitmap, const rectangle &cliprect);
	void draw_background_and_text(bitmap_rgb32 &bitmap, const rectangle &cliprect);
	void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect);
	required_device<cpu_device> m_maincpu;
	required_device<cpu_device> m_audiocpu;
	required_device<screen_device> m_screen;
};

/*----------- defined in audio/jedi.c -----------*/
MACHINE_CONFIG_EXTERN( jedi_audio );

/*----------- defined in video/jedi.c -----------*/
MACHINE_CONFIG_EXTERN( jedi_video );