summaryrefslogtreecommitdiffstats
path: root/src/mame/includes/vip.h
blob: b0ab562ef3fbc21e0559d32d20b6d5175dcc5c48 (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
130
131
132
133
134
135
136
// license:BSD-3-Clause
// copyright-holders:Curt Coder
#pragma once

#ifndef MAME_INCLUDES_VIP_H
#define MAME_INCLUDES_VIP_H

#include "bus/vip/byteio.h"
#include "bus/vip/exp.h"
#include "cpu/cosmac/cosmac.h"
#include "imagedev/cassette.h"
#include "imagedev/snapquik.h"
#include "machine/ram.h"
#include "sound/discrete.h"
#include "video/cdp1861.h"

#define SCREEN_TAG      "screen"
#define CDP1802_TAG     "u1"
#define CDP1861_TAG     "u2"
#define DISCRETE_TAG    "discrete"


class vip_state : public driver_device
{
public:
	vip_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_maincpu(*this, CDP1802_TAG)
		, m_vdc(*this, CDP1861_TAG)
		, m_cassette(*this, "cassette")
		, m_beeper(*this, DISCRETE_TAG)
		, m_byteio(*this, VIP_BYTEIO_PORT_TAG)
		, m_exp(*this, VIP_EXPANSION_SLOT_TAG)
		, m_ram(*this, RAM_TAG)
		, m_rom(*this, CDP1802_TAG)
		, m_chip8(*this, "chip8")
		, m_chip8x(*this, "chip8x")
		, m_run(*this, "RUN")
		, m_keypad(*this, "KEYPAD")
		, m_io_beeper(*this, "BEEPER")
		, m_8000(1)
		, m_vdc_int(CLEAR_LINE)
		, m_vdc_dma_out(CLEAR_LINE)
		, m_vdc_ef1(CLEAR_LINE)
		, m_exp_int(CLEAR_LINE)
		, m_exp_dma_out(CLEAR_LINE)
		, m_exp_dma_in(CLEAR_LINE)
		, m_byteio_ef3(CLEAR_LINE)
		, m_byteio_ef4(CLEAR_LINE)
		, m_exp_ef1(CLEAR_LINE)
		, m_exp_ef3(CLEAR_LINE)
		, m_exp_ef4(CLEAR_LINE)
		, m_leds(*this, "led%u", 0U)
	{ }

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

	void update_interrupts();

	DECLARE_READ8_MEMBER( read );
	DECLARE_WRITE8_MEMBER( write );
	DECLARE_READ8_MEMBER( io_r );
	DECLARE_WRITE8_MEMBER( io_w );

	DECLARE_READ_LINE_MEMBER( clear_r );
	DECLARE_READ_LINE_MEMBER( ef1_r );
	DECLARE_READ_LINE_MEMBER( ef2_r );
	DECLARE_READ_LINE_MEMBER( ef3_r );
	DECLARE_READ_LINE_MEMBER( ef4_r );
	DECLARE_WRITE_LINE_MEMBER( q_w );
	DECLARE_READ8_MEMBER( dma_r );
	DECLARE_WRITE8_MEMBER( dma_w );
	DECLARE_WRITE8_MEMBER( sc_w );

	DECLARE_WRITE_LINE_MEMBER( vdc_int_w );
	DECLARE_WRITE_LINE_MEMBER( vdc_dma_out_w );
	DECLARE_WRITE_LINE_MEMBER( vdc_ef1_w );

	DECLARE_WRITE_LINE_MEMBER( byteio_inst_w );

	DECLARE_WRITE_LINE_MEMBER( exp_int_w );
	DECLARE_WRITE_LINE_MEMBER( exp_dma_out_w );
	DECLARE_WRITE_LINE_MEMBER( exp_dma_in_w );

	DECLARE_INPUT_CHANGED_MEMBER( reset_w );
	DECLARE_INPUT_CHANGED_MEMBER( beeper_w );

	DECLARE_QUICKLOAD_LOAD_MEMBER( vip );
	void vp111(machine_config &config);
	void vip(machine_config &config);
	void vip_io(address_map &map);
	void vip_mem(address_map &map);

protected:
	virtual void machine_start() override;
	virtual void machine_reset() override;

	required_device<cosmac_device> m_maincpu;
	required_device<cdp1861_device> m_vdc;
	required_device<cassette_image_device> m_cassette;
	required_device<discrete_sound_device> m_beeper;
	required_device<vip_byteio_port_device> m_byteio;
	required_device<vip_expansion_slot_device> m_exp;
	required_device<ram_device> m_ram;
	required_memory_region m_rom;
	required_memory_region m_chip8;
	required_memory_region m_chip8x;
	required_ioport m_run;
	required_ioport m_keypad;
	required_ioport m_io_beeper;

	// memory state
	int m_8000;

	// interrupt state
	int m_vdc_int;
	int m_vdc_dma_out;
	int m_vdc_ef1;
	int m_exp_int;
	int m_exp_dma_out;
	int m_exp_dma_in;
	int m_byteio_ef3;
	int m_byteio_ef4;
	int m_exp_ef1;
	int m_exp_ef3;
	int m_exp_ef4;

	// keyboard state
	int m_keylatch;

	// expansion state
	uint8_t m_byteio_data;
	output_finder<3> m_leds;
};

#endif