~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/emu/video/bufsprite.h

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Emmanuel Kasper, Jordi Mallach
  • Date: 2012-06-05 20:02:23 UTC
  • mfrom: (0.3.1) (0.1.4)
  • Revision ID: package-import@ubuntu.com-20120605200223-gnlpogjrg6oqe9md
Tags: 0.146-1
[ Emmanuel Kasper ]
* New upstream release
* Drop patch to fix man pages section and patches to link with flac 
  and jpeg system lib: all this has been pushed upstream by Cesare Falco
* Add DM-Upload-Allowed: yes field.

[ Jordi Mallach ]
* Create a "gnu" TARGETOS stanza that defines NO_AFFINITY_NP.
* Stop setting TARGETOS to "unix" in d/rules. It should be autodetected,
  and set to the appropriate value.
* mame_manpage_section.patch: Change mame's manpage section to 6 (games),
  in the TH declaration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********************************************************************
 
2
 
 
3
    bufsprite.h
 
4
 
 
5
    Buffered Sprite RAM device.
 
6
 
 
7
****************************************************************************
 
8
 
 
9
    Copyright Aaron Giles
 
10
    All rights reserved.
 
11
 
 
12
    Redistribution and use in source and binary forms, with or without
 
13
    modification, are permitted provided that the following conditions are
 
14
    met:
 
15
 
 
16
        * Redistributions of source code must retain the above copyright
 
17
          notice, this list of conditions and the following disclaimer.
 
18
        * Redistributions in binary form must reproduce the above copyright
 
19
          notice, this list of conditions and the following disclaimer in
 
20
          the documentation and/or other materials provided with the
 
21
          distribution.
 
22
        * Neither the name 'MAME' nor the names of its contributors may be
 
23
          used to endorse or promote products derived from this software
 
24
          without specific prior written permission.
 
25
 
 
26
    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
 
27
    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
28
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
29
    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
 
30
    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
31
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
32
    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
33
    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 
34
    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 
35
    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
36
    POSSIBILITY OF SUCH DAMAGE.
 
37
 
 
38
*********************************************************************/
 
39
 
 
40
#pragma once
 
41
 
 
42
#ifndef __BUFSPRITE_H__
 
43
#define __BUFSPRITE_H__
 
44
 
 
45
 
 
46
 
 
47
//**************************************************************************
 
48
//  GLOBAL VARIABLES
 
49
//**************************************************************************
 
50
 
 
51
// device type definition
 
52
extern const device_type BUFFERED_SPRITERAM8;
 
53
extern const device_type BUFFERED_SPRITERAM16;
 
54
extern const device_type BUFFERED_SPRITERAM32;
 
55
extern const device_type BUFFERED_SPRITERAM64;
 
56
 
 
57
 
 
58
 
 
59
//**************************************************************************
 
60
//  DEVICE CONFIGURATION MACROS
 
61
//**************************************************************************
 
62
 
 
63
#define MCFG_BUFFERED_SPRITERAM8_ADD(_tag) \
 
64
        MCFG_DEVICE_ADD(_tag, BUFFERED_SPRITERAM8, 0) \
 
65
 
 
66
#define MCFG_BUFFERED_SPRITERAM16_ADD(_tag) \
 
67
        MCFG_DEVICE_ADD(_tag, BUFFERED_SPRITERAM16, 0) \
 
68
 
 
69
#define MCFG_BUFFERED_SPRITERAM32_ADD(_tag) \
 
70
        MCFG_DEVICE_ADD(_tag, BUFFERED_SPRITERAM32, 0) \
 
71
 
 
72
#define MCFG_BUFFERED_SPRITERAM64_ADD(_tag) \
 
73
        MCFG_DEVICE_ADD(_tag, BUFFERED_SPRITERAM64, 0) \
 
74
 
 
75
 
 
76
 
 
77
//**************************************************************************
 
78
//  TYPE DEFINITIONS
 
79
//**************************************************************************
 
80
 
 
81
// ======================> buffered_spriteram_device
 
82
 
 
83
// base class to manage buffered spriteram
 
84
template<typename _Type>
 
85
class buffered_spriteram_device : public device_t
 
86
{
 
87
public:
 
88
        // construction
 
89
        buffered_spriteram_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock)
 
90
                : device_t(mconfig, type, "Buffered Sprite RAM", tag, owner, clock),
 
91
                  m_spriteram(*owner, tag) { }
 
92
 
 
93
        // getters
 
94
        _Type *live() const { return m_spriteram; }
 
95
        _Type *buffer() { return m_buffered; }
 
96
        UINT32 bytes() const { return m_spriteram.bytes(); }
 
97
 
 
98
        // operations
 
99
        _Type *copy(UINT32 srcoffset = 0, UINT32 srclength = 0x7fffffff)
 
100
        {
 
101
                assert(m_spriteram != NULL);
 
102
                if (m_spriteram != NULL)
 
103
                        memcpy(m_buffered, m_spriteram + srcoffset, MIN(srclength, m_spriteram.bytes() / sizeof(_Type) - srcoffset) * sizeof(_Type));
 
104
                return m_buffered;
 
105
        }
 
106
 
 
107
        // read/write handlers
 
108
        void write(address_space &space, offs_t offset, _Type data, _Type mem_mask = ~_Type(0)) { copy(); }
 
109
 
 
110
        // VBLANK handlers
 
111
        void vblank_copy_rising(screen_device &screen, bool state) { if (state) copy(); }
 
112
        void vblank_copy_falling(screen_device &screen, bool state) { if (!state) copy(); }
 
113
 
 
114
protected:
 
115
        // first-time setup
 
116
        virtual void device_start()
 
117
        {
 
118
                if (m_spriteram != NULL)
 
119
                {
 
120
                        m_buffered.resize(m_spriteram.bytes() / sizeof(_Type));
 
121
                        save_item(NAME(m_buffered));
 
122
                }
 
123
        }
 
124
 
 
125
private:
 
126
        // internal state
 
127
        required_shared_ptr<_Type>      m_spriteram;
 
128
        dynamic_array<_Type>            m_buffered;
 
129
};
 
130
 
 
131
 
 
132
// ======================> buffered_spriteram8_device
 
133
 
 
134
class buffered_spriteram8_device : public buffered_spriteram_device<UINT8>
 
135
{
 
136
public:
 
137
        // construction
 
138
        buffered_spriteram8_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
 
139
                : buffered_spriteram_device<UINT8>(mconfig, BUFFERED_SPRITERAM8, tag, owner, clock) { }
 
140
};
 
141
 
 
142
 
 
143
// ======================> buffered_spriteram16_device
 
144
 
 
145
class buffered_spriteram16_device : public buffered_spriteram_device<UINT16>
 
146
{
 
147
public:
 
148
        // construction
 
149
        buffered_spriteram16_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
 
150
                : buffered_spriteram_device<UINT16>(mconfig, BUFFERED_SPRITERAM16, tag, owner, clock) { }
 
151
};
 
152
 
 
153
 
 
154
// ======================> buffered_spriteram32_device
 
155
 
 
156
class buffered_spriteram32_device : public buffered_spriteram_device<UINT32>
 
157
{
 
158
public:
 
159
        // construction
 
160
        buffered_spriteram32_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
 
161
                : buffered_spriteram_device<UINT32>(mconfig, BUFFERED_SPRITERAM32, tag, owner, clock) { }
 
162
};
 
163
 
 
164
 
 
165
// ======================> buffered_spriteram64_device
 
166
 
 
167
class buffered_spriteram64_device : public buffered_spriteram_device<UINT64>
 
168
{
 
169
public:
 
170
        // construction
 
171
        buffered_spriteram64_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
 
172
                : buffered_spriteram_device<UINT64>(mconfig, BUFFERED_SPRITERAM64, tag, owner, clock) { }
 
173
};
 
174
 
 
175
 
 
176
#endif  /* __BUFSPRITE_H__ */