summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/liberatr.h
blob: 43139771e2d525e6ea64730e667227899f067dab (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// license:BSD-3-Clause
// copyright-holders:Stefan Jokisch
/*************************************************************************

    Atari Liberator hardware

*************************************************************************/
#ifndef MAME_INCLUDES_LIBERATR_H
#define MAME_INCLUDES_LIBERATR_H

#pragma once

#include "cpu/m6502/m6502.h"
#include "machine/74259.h"
#include "machine/er2055.h"
#include "machine/watchdog.h"
#include "sound/pokey.h"
#include "screen.h"

class liberatr_state : public driver_device
{
public:
	liberatr_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_earom(*this, "earom")
		, m_earom_data(0)
		, m_earom_control(0)
		, m_outlatch(*this, "outlatch")
		, m_screen(*this, "screen")
		, m_base_ram(*this, "base_ram")
		, m_planet_frame(*this, "planet_frame")
		, m_xcoord(*this, "xcoord")
		, m_ycoord(*this, "ycoord")
		, m_bitmapram(*this, "bitmapram")
		, m_colorram(*this, "colorram")
	{ }

	void liberat2(machine_config &config);
	void liberatr(machine_config &config);

private:
	virtual void machine_start() override;
	virtual void machine_reset() override;
	virtual void video_start() override;

	DECLARE_WRITE8_MEMBER(output_latch_w);
	DECLARE_WRITE_LINE_MEMBER(coin_counter_left_w);
	DECLARE_WRITE_LINE_MEMBER(coin_counter_right_w);

	DECLARE_WRITE_LINE_MEMBER(trackball_reset_w);
	DECLARE_READ8_MEMBER(port0_r);

	DECLARE_WRITE8_MEMBER( bitmap_w );
	DECLARE_READ8_MEMBER( bitmap_xy_r );
	DECLARE_WRITE8_MEMBER( bitmap_xy_w );

	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);

	// early raster EAROM interface
	DECLARE_READ8_MEMBER( earom_r );
	DECLARE_WRITE8_MEMBER( earom_w );
	DECLARE_WRITE8_MEMBER( earom_control_w );

	void liberat2_map(address_map &map);
	void liberatr_map(address_map &map);

	// The following structure describes the (up to 32) line segments
	// that make up one horizontal line (latitude) for one display frame of the planet.
	// Note: this and the following structure is only used to collect the
	// data before it is packed for actual use.
	struct planet_frame_line
	{
		uint8_t segment_count;    // the number of segments on this line
		uint8_t max_x;            // the maximum value of x_array for this line
		uint8_t color_array[32];  // the color values
		uint8_t x_array[32];      // and maximum x values for each segment
	};

	// The following structure describes the lines (latitudes)
	// that make up one complete display frame of the planet.
	// Note: this and the previous structure is only used to collect the
	// data before it is packed for actual use.
	struct planet_frame
	{
		planet_frame_line lines[0x80];
	};

	// The following structure collects the 256 frames of the
	// planet (one per value of longitude).
	// The data is packed segment_count,segment_start,color,length,color,length,...  then
	//                    segment_count,segment_start,color,length,color,length...  for the next line, etc
	// for the 128 lines.
	struct planet
	{
		uint8_t *frames[256];
	};

	void init_planet(planet &liberatr_planet, uint8_t *planet_rom);
	void get_pens(pen_t *pens);
	void draw_planet(bitmap_rgb32 &bitmap, pen_t *pens);
	void draw_bitmap(bitmap_rgb32 &bitmap, pen_t *pens);

	// vector and early raster EAROM interface
	required_device<er2055_device> m_earom;
	uint8_t               m_earom_data;
	uint8_t               m_earom_control;

	required_device<ls259_device> m_outlatch;

	required_device<screen_device> m_screen;
	required_shared_ptr<uint8_t> m_base_ram;
	required_shared_ptr<uint8_t> m_planet_frame;
	required_shared_ptr<uint8_t> m_xcoord;
	required_shared_ptr<uint8_t> m_ycoord;
	required_shared_ptr<uint8_t> m_bitmapram;
	required_shared_ptr<uint8_t> m_colorram;

	uint8_t       m_trackball_offset;
	uint8_t       m_ctrld;
	uint8_t       m_videoram[0x10000];

	bool m_planet_select;

	// The following array collects the 2 different planet
	// descriptions, which are selected by planetbit
	planet m_planets[2];
};

#endif // MAME_INCLUDES_LIBERATR_H