~ubuntu-branches/ubuntu/precise/mame/precise-proposed

« back to all changes in this revision

Viewing changes to src/mame/machine/naomig1.c

  • Committer: Package Import Robot
  • Author(s): Cesare Falco
  • Date: 2011-11-30 18:50:10 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111130185010-02hcxybht1mn082w
Tags: 0.144-0ubuntu1
* New upstream release (LP: #913550)
* mame.install:
  - Added artwork/ images to be used with -effect switch
  - Be more selective with hash/ contents
* contrib/mame.ini: added /usr/share/games/mame/artwork/ to artpath

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#define ADDRESS_MAP_MODERN
 
2
 
 
3
#include "emu.h"
 
4
#include "naomig1.h"
 
5
 
 
6
DEVICE_ADDRESS_MAP_START(amap, 32, naomi_g1_device)
 
7
        AM_RANGE(0x04, 0x07) AM_READWRITE(sb_gdstar_r, sb_gdstar_w)
 
8
        AM_RANGE(0x08, 0x0b) AM_READWRITE(sb_gdlen_r, sb_gdlen_w)
 
9
        AM_RANGE(0x0c, 0x0f) AM_READWRITE(sb_gddir_r, sb_gddir_w)
 
10
        AM_RANGE(0x14, 0x17) AM_READWRITE(sb_gden_r, sb_gden_w)
 
11
        AM_RANGE(0x18, 0x1b) AM_READWRITE(sb_gdst_r, sb_gdst_w)
 
12
        AM_RANGE(0x80, 0x83) AM_WRITE(sb_g1rrc_w)
 
13
        AM_RANGE(0x84, 0x87) AM_WRITE(sb_g1rwc_w)
 
14
        AM_RANGE(0x88, 0x8b) AM_WRITE(sb_g1frc_w)
 
15
        AM_RANGE(0x8c, 0x8f) AM_WRITE(sb_g1fwc_w)
 
16
        AM_RANGE(0x90, 0x93) AM_WRITE(sb_g1crc_w)
 
17
        AM_RANGE(0x94, 0x97) AM_WRITE(sb_g1cwc_w)
 
18
        AM_RANGE(0xa0, 0xa3) AM_WRITE(sb_g1gdrc_w)
 
19
        AM_RANGE(0xa4, 0xa7) AM_WRITE(sb_g1gdwc_w)
 
20
        AM_RANGE(0xb0, 0xb3) AM_READ(sb_g1sysm_r)
 
21
        AM_RANGE(0xb4, 0xb7) AM_WRITE(sb_g1crdyc_w)
 
22
        AM_RANGE(0xb8, 0xbb) AM_WRITE(sb_gdapro_w)
 
23
        AM_RANGE(0xf4, 0xf7) AM_READ(sb_gdstard_r)
 
24
        AM_RANGE(0xf8, 0xfb) AM_READ(sb_gdlend_r)
 
25
ADDRESS_MAP_END
 
26
 
 
27
naomi_g1_device::naomi_g1_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
 
28
        : device_t(mconfig, type, name, tag, owner, clock)
 
29
{
 
30
        cpu = 0;
 
31
}
 
32
 
 
33
void naomi_g1_device::static_set_maincpu_tag(device_t &device, const char *maincpu_tag)
 
34
{
 
35
        naomi_g1_device &naomi_g1 = downcast<naomi_g1_device &>(device);
 
36
        naomi_g1.maincpu_tag = maincpu_tag;
 
37
}
 
38
 
 
39
void naomi_g1_device::static_set_irq_cb(device_t &device, void (*irq_cb)(running_machine &))
 
40
{
 
41
        naomi_g1_device &naomi_g1 = downcast<naomi_g1_device &>(device);
 
42
        naomi_g1.irq_cb = irq_cb;
 
43
}
 
44
 
 
45
void naomi_g1_device::device_start()
 
46
{
 
47
        cpu = machine().device<sh4_device>(maincpu_tag);
 
48
        timer = timer_alloc(G1_TIMER_ID);
 
49
 
 
50
        save_item(NAME(gdstar));
 
51
        save_item(NAME(gdlen));
 
52
        save_item(NAME(gddir));
 
53
        save_item(NAME(gden));
 
54
        save_item(NAME(gdst));
 
55
}
 
56
 
 
57
void naomi_g1_device::device_reset()
 
58
{
 
59
        gdstar = 0;
 
60
        gdlen = 0;
 
61
        gddir = 0;
 
62
        gden = 0;
 
63
        gdst = 0;
 
64
}
 
65
 
 
66
void naomi_g1_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
 
67
{
 
68
        timer.adjust(attotime::never);
 
69
        if(!gdst)
 
70
                return;
 
71
        gdst = 0;
 
72
        if(irq_cb)
 
73
                irq_cb(machine());
 
74
}
 
75
 
 
76
READ32_MEMBER(naomi_g1_device::sb_gdstar_r)
 
77
{
 
78
        return gdstar;
 
79
}
 
80
 
 
81
WRITE32_MEMBER(naomi_g1_device::sb_gdstar_w)
 
82
{
 
83
        COMBINE_DATA(&gdstar);
 
84
        logerror("G1: gdstar_w %08x @ %08x\n", data, mem_mask);
 
85
}
 
86
 
 
87
READ32_MEMBER(naomi_g1_device::sb_gdlen_r)
 
88
{
 
89
        return gdlen;
 
90
}
 
91
 
 
92
WRITE32_MEMBER(naomi_g1_device::sb_gdlen_w)
 
93
{
 
94
        COMBINE_DATA(&gdlen);
 
95
        logerror("G1: gdlen_w %08x @ %08x\n", data, mem_mask);
 
96
}
 
97
 
 
98
READ32_MEMBER(naomi_g1_device::sb_gddir_r)
 
99
{
 
100
        return gddir;
 
101
}
 
102
 
 
103
WRITE32_MEMBER(naomi_g1_device::sb_gddir_w)
 
104
{
 
105
        COMBINE_DATA(&gddir);
 
106
        gddir &= 1;
 
107
        logerror("G1: gddir_w %08x @ %08x\n", data, mem_mask);
 
108
}
 
109
 
 
110
READ32_MEMBER(naomi_g1_device::sb_gden_r)
 
111
{
 
112
        return gden;
 
113
}
 
114
 
 
115
WRITE32_MEMBER(naomi_g1_device::sb_gden_w)
 
116
{
 
117
        COMBINE_DATA(&gden);
 
118
        gden &= 1;
 
119
        logerror("G1: gden_w %08x @ %08x\n", data, mem_mask);
 
120
}
 
121
 
 
122
READ32_MEMBER(naomi_g1_device::sb_gdst_r)
 
123
{
 
124
        return gdst;
 
125
}
 
126
 
 
127
WRITE32_MEMBER(naomi_g1_device::sb_gdst_w)
 
128
{
 
129
        UINT32 old = gdst;
 
130
        COMBINE_DATA(&gdst);
 
131
        gdst &= 1;
 
132
        logerror("G1: gdst_w %08x @ %08x\n", data, mem_mask);
 
133
        if(!old && gdst && gden) {
 
134
                // DMA starts
 
135
 
 
136
                UINT32 adr = gdstar;
 
137
                UINT32 len = gdlen;
 
138
 
 
139
                // Deunan says round up to 32, doc says complete with zeroes.
 
140
                // Virtua Tennis requires one of the two to boot
 
141
                // We'll go with DK for now.
 
142
                //
 
143
                // In any case, low bit is ignored
 
144
                len = (len + 30) & ~30;
 
145
 
 
146
                bool to_mainram = true;
 
147
                while(len) {
 
148
                        UINT8 *base;
 
149
                        UINT32 limit = len;
 
150
                        dma_get_position(base, limit, to_mainram);
 
151
 
 
152
                        if(!limit)
 
153
                                break;
 
154
                        UINT32 tlen = limit > len ? len : limit;
 
155
                        dma(base, adr, tlen, to_mainram);
 
156
                        adr += tlen;
 
157
                        len -= tlen;
 
158
                        dma_advance(tlen);
 
159
                }
 
160
 
 
161
                while(len && to_mainram) {
 
162
                        unsigned char zero[32];
 
163
                        memset(zero, 0, sizeof(zero));
 
164
                        UINT32 tlen = len > 32 ? 32 : len;
 
165
                        dma(zero, adr, tlen, to_mainram);
 
166
                        adr += tlen;
 
167
                        len -= tlen;
 
168
                }
 
169
 
 
170
                timer->adjust(attotime::from_usec(500));
 
171
        }
 
172
}
 
173
 
 
174
WRITE32_MEMBER(naomi_g1_device::sb_g1rrc_w)
 
175
{
 
176
        logerror("G1: g1rrc_w %08x @ %08x\n", data, mem_mask);
 
177
}
 
178
 
 
179
WRITE32_MEMBER(naomi_g1_device::sb_g1rwc_w)
 
180
{
 
181
        logerror("G1: g1rwc_w %08x @ %08x\n", data, mem_mask);
 
182
}
 
183
 
 
184
WRITE32_MEMBER(naomi_g1_device::sb_g1crc_w)
 
185
{
 
186
        logerror("G1: g1crc_w %08x @ %08x\n", data, mem_mask);
 
187
}
 
188
 
 
189
WRITE32_MEMBER(naomi_g1_device::sb_g1cwc_w)
 
190
{
 
191
        logerror("G1: g1cwc_w %08x @ %08x\n", data, mem_mask);
 
192
}
 
193
 
 
194
WRITE32_MEMBER(naomi_g1_device::sb_g1frc_w)
 
195
{
 
196
        logerror("G1: g1frc_w %08x @ %08x\n", data, mem_mask);
 
197
}
 
198
 
 
199
WRITE32_MEMBER(naomi_g1_device::sb_g1fwc_w)
 
200
{
 
201
        logerror("G1: g1fwc_w %08x @ %08x\n", data, mem_mask);
 
202
}
 
203
 
 
204
WRITE32_MEMBER(naomi_g1_device::sb_g1gdrc_w)
 
205
{
 
206
        logerror("G1: g1gdrc_w %08x @ %08x\n", data, mem_mask);
 
207
}
 
208
 
 
209
WRITE32_MEMBER(naomi_g1_device::sb_g1gdwc_w)
 
210
{
 
211
        logerror("G1: g1gdwc_w %08x @ %08x\n", data, mem_mask);
 
212
}
 
213
 
 
214
READ32_MEMBER(naomi_g1_device::sb_g1sysm_r)
 
215
{
 
216
        logerror("G1: g1sysm_r @ %08x\n", mem_mask);
 
217
        return 0;
 
218
}
 
219
 
 
220
WRITE32_MEMBER(naomi_g1_device::sb_g1crdyc_w)
 
221
{
 
222
        logerror("G1: g1crdyc_w %08x @ %08x\n", data, mem_mask);
 
223
}
 
224
 
 
225
WRITE32_MEMBER(naomi_g1_device::sb_gdapro_w)
 
226
{
 
227
        logerror("G1: gdapro_w %08x @ %08x\n", data, mem_mask);
 
228
}
 
229
 
 
230
READ32_MEMBER(naomi_g1_device::sb_gdstard_r)
 
231
{
 
232
        logerror("G1: gdstard_r @ %08x\n", mem_mask);
 
233
        return 0;
 
234
}
 
235
 
 
236
READ32_MEMBER(naomi_g1_device::sb_gdlend_r)
 
237
{
 
238
        logerror("G1: gdlend_r @ %08x\n", mem_mask);
 
239
        return 0;
 
240
}
 
241
 
 
242
void naomi_g1_device::dma(void *dma_ptr, UINT32 main_adr, UINT32 size, bool to_mainram)
 
243
{
 
244
        sh4_ddt_dma ddt;
 
245
        if(to_mainram)
 
246
                ddt.destination = main_adr;
 
247
        else
 
248
                ddt.source = main_adr;
 
249
        ddt.buffer = dma_ptr;
 
250
        ddt.length = size >> 5;
 
251
        ddt.size = 32;
 
252
        ddt.direction = to_mainram;
 
253
        ddt.channel = -1;
 
254
        ddt.mode = -1;
 
255
        sh4_dma_ddt(cpu, &ddt);
 
256
}
 
257