1 // license:BSD-3-Clause
2 // copyright-holders:R. Belmont, Andrew Gardner
3 #ifndef MAME_INCLUDES_PLYGONET_H
4 #define MAME_INCLUDES_PLYGONET_H
5 
6 #pragma once
7 
8 #include "machine/eepromser.h"
9 #include "machine/k054321.h"
10 #include "video/k053936.h"
11 #include "cpu/dsp56156/dsp56156.h"
12 #include "emupal.h"
13 #include "tilemap.h"
14 
15 
16 static const uint16_t dsp56156_bank00_size = 0x1000;
17 static const uint16_t dsp56156_bank01_size = 0x1000;
18 static const uint16_t dsp56156_bank02_size = 0x4000;
19 static const uint16_t dsp56156_shared_ram_16_size = 0x2000;
20 static const uint16_t dsp56156_bank04_size = 0x1fc0;
21 
22 class polygonet_state : public driver_device
23 {
24 public:
polygonet_state(const machine_config & mconfig,device_type type,const char * tag)25 	polygonet_state(const machine_config &mconfig, device_type type, const char *tag) :
26 		driver_device(mconfig, type, tag),
27 		m_maincpu(*this, "maincpu"),
28 		m_audiocpu(*this, "audiocpu"),
29 		m_dsp(*this, "dsp"),
30 		m_eeprom(*this, "eeprom"),
31 		m_k053936(*this, "k053936"),
32 		m_gfxdecode(*this, "gfxdecode"),
33 		m_palette(*this, "palette"),
34 		m_k054321(*this, "k054321"),
35 		m_shared_ram(*this, "shared_ram"),
36 		m_dsp56156_p_mirror(*this, "dsp56156_p_mirror"),
37 		m_dsp56156_p_8000(*this, "dsp56156_p_8000")
38 	{ }
39 
40 	void plygonet(machine_config &config);
41 
42 	void init_polygonet();
43 
44 private:
45 	required_device<cpu_device> m_maincpu;
46 	required_device<cpu_device> m_audiocpu;
47 	required_device<dsp56156_device> m_dsp;
48 	required_device<eeprom_serial_er5911_device> m_eeprom;
49 	required_device<k053936_device> m_k053936;
50 	required_device<gfxdecode_device> m_gfxdecode;
51 	required_device<palette_device> m_palette;
52 	required_device<k054321_device> m_k054321;
53 
54 	/* 68k-side shared ram */
55 	required_shared_ptr<uint32_t> m_shared_ram;
56 
57 	required_shared_ptr<uint16_t> m_dsp56156_p_mirror;
58 	required_shared_ptr<uint16_t> m_dsp56156_p_8000;
59 
60 	ioport_port *m_inputs[4];
61 	uint8_t m_sys0;
62 	uint8_t m_sys1;
63 
64 	/* TTL text plane stuff */
65 	int m_ttl_gfx_index;
66 	tilemap_t *m_ttl_tilemap;
67 	tilemap_t *m_roz_tilemap;
68 	uint16_t m_ttl_vram[0x800];
69 	uint16_t m_roz_vram[0x800];
70 
71 	/* sound */
72 	uint8_t m_sound_ctrl;
73 	uint8_t m_sound_intck;
74 
75 	/* memory buffers */
76 	uint16_t m_dsp56156_bank00_ram[2 * 8 * dsp56156_bank00_size]; /* 2 bank sets, 8 potential banks each */
77 	uint16_t m_dsp56156_bank01_ram[2 * 8 * dsp56156_bank01_size];
78 	uint16_t m_dsp56156_bank02_ram[2 * 8 * dsp56156_bank02_size];
79 	uint16_t m_dsp56156_shared_ram_16[2 * 8 * dsp56156_shared_ram_16_size];
80 	uint16_t m_dsp56156_bank04_ram[2 * 8 * dsp56156_bank04_size];
81 
82 	void polygonet_sys_w(offs_t offset, uint8_t data);
83 	uint8_t polygonet_inputs_r(offs_t offset);
84 	void sound_irq_w(uint32_t data);
85 	uint32_t dsp_host_interface_r(offs_t offset, uint32_t mem_mask = ~0);
86 	void shared_ram_write(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
87 	void dsp_w_lines(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
88 	void dsp_host_interface_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
89 	uint32_t network_r();
90 	uint16_t dsp56156_bootload_r();
91 	uint16_t dsp56156_ram_bank00_read(offs_t offset);
92 	void dsp56156_ram_bank00_write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
93 	uint16_t dsp56156_ram_bank01_read(offs_t offset);
94 	void dsp56156_ram_bank01_write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
95 	uint16_t dsp56156_ram_bank02_read(offs_t offset);
96 	void dsp56156_ram_bank02_write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
97 	uint16_t dsp56156_shared_ram_read(offs_t offset);
98 	void dsp56156_shared_ram_write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
99 	uint16_t dsp56156_ram_bank04_read(offs_t offset);
100 	void dsp56156_ram_bank04_write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
101 	void sound_ctrl_w(uint8_t data);
102 	uint32_t polygonet_ttl_ram_r(offs_t offset);
103 	void polygonet_ttl_ram_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
104 	uint32_t polygonet_roz_ram_r(offs_t offset);
105 	void polygonet_roz_ram_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
106 
107 	TILE_GET_INFO_MEMBER(ttl_get_tile_info);
108 	TILE_GET_INFO_MEMBER(roz_get_tile_info);
109 	TILEMAP_MAPPER_MEMBER(plygonet_scan);
110 	TILEMAP_MAPPER_MEMBER(plygonet_scan_cols);
111 	virtual void machine_reset() override;
112 	virtual void machine_start() override;
113 	virtual void video_start() override;
114 	uint32_t screen_update_polygonet(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
115 	INTERRUPT_GEN_MEMBER(polygonet_interrupt);
116 	DECLARE_WRITE_LINE_MEMBER(k054539_nmi_gen);
117 
118 	void dsp_data_map(address_map &map);
119 	void dsp_program_map(address_map &map);
120 	void main_map(address_map &map);
121 	void sound_map(address_map &map);
122 };
123 
124 #endif // MAME_INCLUDES_PLYGONET_H
125