summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/includes/rm380z.h
blob: add77a280a0d12e0c07f3e57a701873feedf8ad2 (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
/*

Research Machines RM 380Z

*/

#ifndef RM380Z_H_
#define RM380Z_H_

#include "emu.h"
#include "cpu/z80/z80.h"
#include "machine/ram.h"
#include "imagedev/flopdrv.h"
#include "machine/wd17xx.h"
#include "machine/keyboard.h"

//
//
//

#define RM380Z_MAINCPU_TAG		"maincpu"
#define RM380Z_PORTS_ENABLED_HIGH	( m_port0 & 0x80 )
#define RM380Z_PORTS_ENABLED_LOW	( ( m_port0 & 0x80 ) == 0x00 )

#define RM380Z_VIDEOMODE_40COL	0x01
#define RM380Z_VIDEOMODE_80COL	0x02

#define RM380Z_CHDIMX 5
#define RM380Z_CHDIMY 9
#define RM380Z_NCX 8
#define RM380Z_NCY 16
#define RM380Z_SCREENCOLS 80
#define RM380Z_SCREENROWS 24

#define RM380Z_VIDEORAM_SIZE 0x600
#define RM380Z_SCREENSIZE 0x1200


//
//
//


class rm380z_state : public driver_device
{
private:

	void put_point(int charnum,int x,int y,int col);
	void init_graphic_chars();

	void putChar(int charnum,int attribs,int x,int y,bitmap_ind16 &bitmap,unsigned char* chsb,int vmode);
	void decode_videoram_char(int pos,UINT8& chr,UINT8& attrib);
	void scroll_videoram();
	void config_videomode();
	void check_scroll_register();

	int writenum;

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

public:

	UINT8 m_port0;
	UINT8 m_port0_kbd;
	UINT8 m_port1;
	UINT8 m_fbfd;
	UINT8 m_fbfe;

	UINT8 m_graphic_chars[0x80][(RM380Z_CHDIMX+1)*(RM380Z_CHDIMY+1)];

	UINT8	m_mainVideoram[RM380Z_VIDEORAM_SIZE];
	UINT8	m_vramchars[RM380Z_SCREENSIZE];
	UINT8	m_vramattribs[RM380Z_SCREENSIZE];
	UINT8	m_vram[RM380Z_SCREENSIZE];

	int m_rasterlineCtr;
	emu_timer* m_vblankTimer;

	int m_old_fbfd;
	int m_old_old_fbfd;

	int m_videomode;
	int m_old_videomode;

	required_device<cpu_device> m_maincpu;
	required_device<ram_device> m_messram;
	optional_device<device_t> m_fdc;

	rm380z_state(const machine_config &mconfig, device_type type, const char *tag)
	  : driver_device(mconfig, type, tag),
		m_maincpu(*this, RM380Z_MAINCPU_TAG),
		m_messram(*this, RAM_TAG),
		m_fdc(*this, "wd1771")
	{
	}

	DECLARE_WRITE8_MEMBER( port_write );
	DECLARE_READ8_MEMBER( port_read );
	DECLARE_WRITE8_MEMBER( port_write_1b00 );
	DECLARE_READ8_MEMBER( port_read_1b00 );

	DECLARE_READ8_MEMBER( main_read );
	DECLARE_WRITE8_MEMBER( main_write );

	DECLARE_READ8_MEMBER( videoram_read );
	DECLARE_WRITE8_MEMBER( videoram_write );

	UINT8 hiram[0x1000];
	DECLARE_READ8_MEMBER( hiram_read );
	DECLARE_WRITE8_MEMBER( hiram_write );

	DECLARE_READ8_MEMBER( rm380z_portlow_r );
	DECLARE_WRITE8_MEMBER( rm380z_portlow_w );
	DECLARE_READ8_MEMBER( rm380z_porthi_r );
	DECLARE_WRITE8_MEMBER( rm380z_porthi_w );

	DECLARE_WRITE8_MEMBER(disk_0_control);

	DECLARE_WRITE8_MEMBER( keyboard_put );

	void config_memory_map();
	int keyboard_decode();
	void update_screen(bitmap_ind16 &bitmap);
};


#endif