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
|
// license:BSD-3-Clause
// copyright-holders:Wilbert Pol
/******************************************************************************
K1GE/K2GE graphics emulation
******************************************************************************/
#ifndef MAME_VIDEO_K1GE_H
#define MAME_VIDEO_K1GE_H
#pragma once
#define MCFG_K1GE_ADD(_tag, _clock, _screen, _vblank, _hblank ) \
MCFG_DEVICE_ADD( _tag, K1GE, _clock ) \
MCFG_VIDEO_SET_SCREEN( _screen ) \
devcb = &downcast<k1ge_device &>(*device).set_vblank_callback(DEVCB_##_vblank ); \
devcb = &downcast<k1ge_device &>(*device).set_hblank_callback(DEVCB_##_hblank );
#define MCFG_K2GE_ADD(_tag, _clock, _screen, _vblank, _hblank ) \
MCFG_DEVICE_ADD( _tag, K2GE, _clock ) \
MCFG_VIDEO_SET_SCREEN( _screen ) \
devcb = &downcast<k1ge_device &>(*device).set_vblank_callback(DEVCB_##_vblank ); \
devcb = &downcast<k1ge_device &>(*device).set_hblank_callback(DEVCB_##_hblank );
class k1ge_device : public device_t, public device_video_interface
{
public:
k1ge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
void update( bitmap_ind16 &bitmap, const rectangle &cliprect );
// Static methods
template <class Object> devcb_base &set_vblank_callback(Object &&cb) { return m_vblank_pin_w.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_hblank_callback(Object &&cb) { return m_hblank_pin_w.set_callback(std::forward<Object>(cb)); }
static const int K1GE_SCREEN_HEIGHT = 199;
protected:
k1ge_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override;
devcb_write_line m_vblank_pin_w;
devcb_write_line m_hblank_pin_w;
std::unique_ptr<uint8_t[]> m_vram;
uint8_t m_wba_h, m_wba_v, m_wsi_h, m_wsi_v;
emu_timer *m_timer;
emu_timer *m_hblank_on_timer;
std::unique_ptr<bitmap_ind16> m_bitmap;
virtual void draw(int line);
void draw_scroll_plane( uint16_t *p, uint16_t base, int line, int scroll_x, int scroll_y, int pal_base );
void draw_sprite_plane( uint16_t *p, uint16_t priority, int line, int scroll_x, int scroll_y );
TIMER_CALLBACK_MEMBER( hblank_on_timer_callback );
TIMER_CALLBACK_MEMBER( timer_callback );
private:
DECLARE_PALETTE_INIT(k1ge);
};
class k2ge_device : public k1ge_device
{
public:
k2ge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
protected:
virtual void device_add_mconfig(machine_config &config) override;
virtual void draw(int line) override;
void draw_scroll_plane( uint16_t *p, uint16_t base, int line, int scroll_x, int scroll_y, uint16_t pal_base );
void draw_sprite_plane( uint16_t *p, uint16_t priority, int line, int scroll_x, int scroll_y );
void k1ge_draw_scroll_plane( uint16_t *p, uint16_t base, int line, int scroll_x, int scroll_y, uint16_t pal_lut_base, uint16_t k2ge_lut_base );
void k1ge_draw_sprite_plane( uint16_t *p, uint16_t priority, int line, int scroll_x, int scroll_y );
private:
DECLARE_PALETTE_INIT(k2ge);
};
DECLARE_DEVICE_TYPE(K1GE, k1ge_device)
DECLARE_DEVICE_TYPE(K2GE, k2ge_device)
#endif // MAME_VIDEO_K1GE_H
|