1 // license:BSD-3-Clause
2 // copyright-holders:Hau
3 #ifndef MAME_INCLUDES_GALASTRM_H
4 #define MAME_INCLUDES_GALASTRM_H
5 
6 #pragma once
7 
8 #include "machine/eepromser.h"
9 
10 #include "video/poly.h"
11 #include "video/tc0100scn.h"
12 #include "video/tc0110pcr.h"
13 #include "video/tc0480scp.h"
14 
15 #include "emupal.h"
16 #include "screen.h"
17 
18 
19 class galastrm_state;
20 
21 struct gs_poly_data
22 {
23 	bitmap_ind16* texbase;
24 };
25 
26 class galastrm_renderer : public poly_manager<float, gs_poly_data, 2, 10000>
27 {
28 public:
29 	galastrm_renderer(galastrm_state &state);
30 
31 	void tc0610_draw_scanline(s32 scanline, const extent_t& extent, const gs_poly_data& object, int threadid);
32 	void tc0610_rotate_draw(bitmap_ind16 &srcbitmap, const rectangle &clip);
33 
screenbits()34 	bitmap_ind16 &screenbits() { return m_screenbits; }
35 
36 private:
37 	galastrm_state& m_state;
38 	bitmap_ind16 m_screenbits;
39 };
40 
41 
42 class galastrm_state : public driver_device
43 {
44 	friend class galastrm_renderer;
45 public:
galastrm_state(const machine_config & mconfig,device_type type,const char * tag)46 	galastrm_state(const machine_config &mconfig, device_type type, const char *tag) :
47 		driver_device(mconfig, type, tag),
48 		m_spriteram(*this,"spriteram"),
49 		m_spritemap_rom(*this, "sprmaprom"),
50 		m_maincpu(*this, "maincpu"),
51 		m_eeprom(*this, "eeprom"),
52 		m_tc0100scn(*this, "tc0100scn"),
53 		m_tc0110pcr(*this, "tc0110pcr"),
54 		m_tc0480scp(*this, "tc0480scp"),
55 		m_gfxdecode(*this, "gfxdecode"),
56 		m_screen(*this, "screen")
57 	{ }
58 
59 	void galastrm(machine_config &config);
60 	DECLARE_READ_LINE_MEMBER(frame_counter_r);
61 
62 protected:
63 	virtual void video_start() override;
64 
65 private:
66 	required_shared_ptr<u32> m_spriteram;
67 
68 	required_region_ptr<u16> m_spritemap_rom;
69 
70 	required_device<cpu_device> m_maincpu;
71 	required_device<eeprom_serial_93cxx_device> m_eeprom;
72 	required_device<tc0100scn_device> m_tc0100scn;
73 	required_device<tc0110pcr_device> m_tc0110pcr;
74 	required_device<tc0480scp_device> m_tc0480scp;
75 	required_device<gfxdecode_device> m_gfxdecode;
76 	required_device<screen_device> m_screen;
77 
78 	struct gs_tempsprite
79 	{
80 		u8 gfx;
81 		u32 code,color;
82 		bool flipx,flipy;
83 		int x,y;
84 		int zoomx,zoomy;
85 		u32 primask;
86 	};
87 
88 	u16 m_frame_counter;
89 	int m_tc0610_addr[2];
90 	s16 m_tc0610_ctrl_reg[2][8];
91 	std::unique_ptr<gs_tempsprite[]> m_spritelist;
92 	struct gs_tempsprite *m_sprite_ptr_pre;
93 	bitmap_ind16 m_tmpbitmaps;
94 	std::unique_ptr<galastrm_renderer> m_poly;
95 
96 	int m_rsxb;
97 	int m_rsyb;
98 	int m_rsxoffs;
99 	int m_rsyoffs;
100 
101 	template<int Chip> void tc0610_w(offs_t offset, u16 data);
102 	void coin_word_w(u8 data);
103 	u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
104 	INTERRUPT_GEN_MEMBER(interrupt);
105 	void draw_sprites_pre(int x_offs, int y_offs);
106 	void draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, const u32 *primasks, int priority);
107 
108 	void main_map(address_map &map);
109 };
110 
111 #endif // MAME_INCLUDES_GALASTRM_H
112