1 // license:BSD-3-Clause
2 // copyright-holders:Takahiro Nogi
3 #include "machine/nb1413m3.h"
4 #include "emupal.h"
5 #include "screen.h"
6 
7 class nbmj8900_state : public driver_device
8 {
9 public:
10 
11 
nbmj8900_state(const machine_config & mconfig,device_type type,const char * tag)12 	nbmj8900_state(const machine_config &mconfig, device_type type, const char *tag)
13 		: driver_device(mconfig, type, tag) ,
14 		m_maincpu(*this, "maincpu"),
15 		m_nb1413m3(*this, "nb1413m3"),
16 		m_screen(*this, "screen"),
17 		m_palette(*this, "palette")   { }
18 
19 	void ohpaipee(machine_config &config);
20 	void togenkyo(machine_config &config);
21 
22 	void init_togenkyo();
23 	void init_ohpaipee();
24 
25 private:
26 	enum
27 	{
28 		TIMER_BLITTER
29 	};
30 
31 	required_device<cpu_device> m_maincpu;
32 	required_device<nb1413m3_device> m_nb1413m3;
33 	required_device<screen_device> m_screen;
34 	required_device<palette_device> m_palette;
35 
36 	int m_scrolly;
37 	int m_blitter_destx;
38 	int m_blitter_desty;
39 	int m_blitter_sizex;
40 	int m_blitter_sizey;
41 	int m_blitter_src_addr;
42 	int m_blitter_direction_x;
43 	int m_blitter_direction_y;
44 	int m_vram;
45 	int m_gfxrom;
46 	int m_dispflag;
47 	int m_flipscreen;
48 	int m_clutsel;
49 	int m_screen_refresh;
50 	int m_gfxdraw_mode;
51 	int m_screen_height;
52 	int m_screen_width;
53 	bitmap_ind16 m_tmpbitmap0;
54 	bitmap_ind16 m_tmpbitmap1;
55 	std::unique_ptr<uint8_t[]> m_videoram0;
56 	std::unique_ptr<uint8_t[]> m_videoram1;
57 	std::unique_ptr<uint8_t[]> m_palette_ptr;
58 	std::unique_ptr<uint8_t[]> m_clut;
59 	int m_flipscreen_old;
60 	emu_timer *m_blitter_timer;
61 
62 	uint8_t palette_type1_r(offs_t offset);
63 	void palette_type1_w(offs_t offset, uint8_t data);
64 	void clutsel_w(uint8_t data);
65 	uint8_t clut_r(offs_t offset);
66 	void clut_w(offs_t offset, uint8_t data);
67 	void blitter_w(offs_t offset, uint8_t data);
68 	void scrolly_w(uint8_t data);
69 	void vramsel_w(uint8_t data);
70 	void romsel_w(uint8_t data);
71 
72 	virtual void video_start() override;
73 
74 	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
75 	void vramflip(int vram);
76 	void update_pixel0(int x, int y);
77 	void update_pixel1(int x, int y);
78 	void gfxdraw();
79 	void postload();
80 
81 	void ohpaipee_io_map(address_map &map);
82 	void ohpaipee_map(address_map &map);
83 	void togenkyo_map(address_map &map);
84 
85 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
86 };
87