summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/vtech2.h
blob: 8c221b4be9c3d2d7e2660837bc53813d09384857 (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
// license:GPL-2.0+
// copyright-holders:Juergen Buchmueller
/*****************************************************************************
 *
 * includes/vtech2.h
 *
 ****************************************************************************/
#ifndef MAME_INCLUDES_VTECH2_H
#define MAME_INCLUDES_VTECH2_H

#pragma once

#include "machine/bankdev.h"
#include "bus/generic/carts.h"
#include "bus/generic/slot.h"
#include "bus/vtech/ioexp/ioexp.h"
#include "imagedev/cassette.h"
#include "imagedev/flopdrv.h"
#include "sound/spkrdev.h"
#include "emupal.h"

#define TRKSIZE_FM  3172    /* size of a standard FM mode track */

class vtech2_state : public driver_device
{
public:
	vtech2_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_maincpu(*this, "maincpu")
		, m_speaker(*this, "speaker")
		, m_cassette(*this, "cassette")
		, m_cart(*this, "cartslot")
		, m_laser_file(*this, "floppy%u", 0U)
		, m_gfxdecode(*this, "gfxdecode")
		, m_palette(*this, "palette")
		, m_videoram(*this, "videoram")
		, m_io_keyboard(*this, {"ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROWD", "ROWC", "ROWB", "ROWA"})
		, m_banka(*this, "banka")
		, m_bankb(*this, "bankb")
		, m_bankc(*this, "bankc")
		, m_bankd(*this, "bankd")
		, m_ioexp(*this, "io")
	{ }

	void laser350(machine_config &config);
	void laser700(machine_config &config);
	void laser500(machine_config &config);

	void init_laser();

	DECLARE_INPUT_CHANGED_MEMBER(reset_button);

protected:
	virtual void machine_reset() override;

private:
	DECLARE_WRITE8_MEMBER(laser_bank_select_w);
	DECLARE_WRITE8_MEMBER(laser_fdc_w);
	DECLARE_WRITE8_MEMBER(laser_bg_mode_w);
	DECLARE_WRITE8_MEMBER(laser_two_color_w);
	DECLARE_READ8_MEMBER(laser_fdc_r);
	void vtech2_palette(palette_device &palette) const;
	uint32_t screen_update_laser(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	INTERRUPT_GEN_MEMBER(vtech2_interrupt);
	DECLARE_WRITE8_MEMBER(mmio_w);
	DECLARE_READ8_MEMBER(mmio_r);
	DECLARE_READ8_MEMBER(cart_r);
	DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart_load);

	void laser_get_track();
	void laser_put_track();

	void io_map(address_map &map);
	void mem_map(address_map &map);
	void m_map350(address_map &map);
	void m_map500(address_map &map);
	void m_map700(address_map &map);

	required_device<cpu_device> m_maincpu;
	required_device<speaker_sound_device> m_speaker;
	required_device<cassette_image_device> m_cassette;
	required_device<generic_slot_device> m_cart;
	optional_device_array<legacy_floppy_image_device, 2> m_laser_file;
	required_device<gfxdecode_device> m_gfxdecode;
	required_device<palette_device> m_palette;
	optional_shared_ptr<u8> m_videoram;
	required_ioport_array<12> m_io_keyboard;
	required_device<address_map_bank_device> m_banka;
	required_device<address_map_bank_device> m_bankb;
	required_device<address_map_bank_device> m_bankc;
	required_device<address_map_bank_device> m_bankd;
	required_device<vtech_ioexp_slot_device> m_ioexp;

	char m_laser_frame_message[64+1];
	int m_laser_frame_time;
	u8 m_laser_latch;
	uint8_t m_laser_track_x2[2];
	uint8_t m_laser_fdc_status;
	uint8_t m_laser_fdc_data[TRKSIZE_FM];
	int m_laser_data;
	int m_laser_fdc_edge;
	int m_laser_fdc_bits;
	int m_laser_drive;
	int m_laser_fdc_start;
	int m_laser_fdc_write;
	int m_laser_fdc_offs;
	int m_laser_fdc_latch;
	int m_level_old;
	int m_cassette_bit;
	int m_laser_bg_mode;
	int m_laser_two_color;
	u8 m_language;
	u32 m_cart_size;

	memory_region *m_cart_rom;
};

#endif // MAME_INCLUDES_VTECH2_H