~ubuntu-branches/debian/wheezy/mame/wheezy

« back to all changes in this revision

Viewing changes to src/mame/drivers/kingdrby.c

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Emmanuel Kasper, Félix Arreola Rodríguez, Jordi Mallach
  • Date: 2011-05-11 21:06:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110511210650-jizvh8a6x117y9hr
Tags: 0.142-1
[ Emmanuel Kasper ]
* New upstream release
* Set NOWERROR=1 to allow compiling with gcc-4.6
* Remove fix_powerpc_build.patch, as upstream has taken it in this release
* Add gnome-video-arcade front end as a suggested package

[ Félix Arreola Rodríguez ]
* Add kfreebsd-build.patch to quilt series, to fix build on kfreebsd

[ Jordi Mallach ]
* Remove unneeded and bogus addition of --with-quilt to the dh invocation.
* Add Cesare Falco (long time Ubuntu maintainer) to Uploaders, and wrap
  them into multiple lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
#include "sound/2203intf.h"
73
73
#include "machine/nvram.h"
74
74
 
 
75
 
 
76
class kingdrby_state : public driver_device
 
77
{
 
78
public:
 
79
        kingdrby_state(running_machine &machine, const driver_device_config_base &config)
 
80
                : driver_device(machine, config) { }
 
81
 
 
82
        UINT8 m_sound_cmd;
 
83
        UINT8 *m_vram;
 
84
        UINT8 *m_attr;
 
85
        tilemap_t *m_sc0_tilemap;
 
86
        tilemap_t *m_sc0w_tilemap;
 
87
        tilemap_t *m_sc1_tilemap;
 
88
        UINT8 m_p1_hopper;
 
89
        UINT8 m_p2_hopper;
 
90
        UINT8 m_mux_data;
 
91
        UINT8 *m_spriteram;
 
92
};
 
93
 
 
94
 
75
95
#define CLK_1   XTAL_20MHz
76
96
#define CLK_2   XTAL_3_579545MHz
77
97
 
78
 
static UINT8 sound_cmd;
79
98
 
80
99
/*************************************
81
100
 *
83
102
 *
84
103
 *************************************/
85
104
 
86
 
static UINT8 *kingdrby_vram,*kingdrby_attr;
87
 
static tilemap_t *sc0_tilemap,*sc0w_tilemap,*sc1_tilemap;
88
105
 
89
106
/*
90
107
tile
98
115
 
99
116
static TILE_GET_INFO( get_sc0_tile_info )
100
117
{
101
 
        int tile = kingdrby_vram[tile_index] | kingdrby_attr[tile_index]<<8;
102
 
        int color = (kingdrby_attr[tile_index] & 0x06)>>1;
 
118
        kingdrby_state *state = machine.driver_data<kingdrby_state>();
 
119
        int tile = state->m_vram[tile_index] | state->m_attr[tile_index]<<8;
 
120
        int color = (state->m_attr[tile_index] & 0x06)>>1;
103
121
 
104
122
        tile&=0x1ff;
105
123
 
112
130
 
113
131
static TILE_GET_INFO( get_sc1_tile_info )
114
132
{
115
 
        int tile = kingdrby_vram[tile_index] | kingdrby_attr[tile_index]<<8;
116
 
        int color = (kingdrby_attr[tile_index] & 0x06)>>1;
 
133
        kingdrby_state *state = machine.driver_data<kingdrby_state>();
 
134
        int tile = state->m_vram[tile_index] | state->m_attr[tile_index]<<8;
 
135
        int color = (state->m_attr[tile_index] & 0x06)>>1;
117
136
 
118
137
        tile&=0x1ff;
119
138
        //original 0xc
126
145
                        color|0x40,
127
146
                        0);
128
147
 
129
 
        tileinfo->category = (kingdrby_attr[tile_index] & 0x08)>>3;
 
148
        tileinfo->category = (state->m_attr[tile_index] & 0x08)>>3;
130
149
}
131
150
 
132
151
static VIDEO_START(kingdrby)
133
152
{
134
 
        sc0_tilemap = tilemap_create(machine, get_sc0_tile_info,tilemap_scan_rows,8,8,32,24);
135
 
        sc1_tilemap = tilemap_create(machine, get_sc1_tile_info,tilemap_scan_rows,8,8,32,24);
136
 
        sc0w_tilemap = tilemap_create(machine, get_sc0_tile_info,tilemap_scan_rows,8,8,32,32);
 
153
        kingdrby_state *state = machine.driver_data<kingdrby_state>();
 
154
        state->m_sc0_tilemap = tilemap_create(machine, get_sc0_tile_info,tilemap_scan_rows,8,8,32,24);
 
155
        state->m_sc1_tilemap = tilemap_create(machine, get_sc1_tile_info,tilemap_scan_rows,8,8,32,24);
 
156
        state->m_sc0w_tilemap = tilemap_create(machine, get_sc0_tile_info,tilemap_scan_rows,8,8,32,32);
137
157
 
138
 
        tilemap_set_transparent_pen(sc1_tilemap,0);
 
158
        tilemap_set_transparent_pen(state->m_sc1_tilemap,0);
139
159
}
140
160
 
141
 
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
 
161
static void draw_sprites(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
142
162
{
143
 
        UINT8 *spriteram = machine->generic.spriteram.u8;
 
163
        kingdrby_state *state = machine.driver_data<kingdrby_state>();
 
164
        UINT8 *spriteram = state->m_spriteram;
144
165
        int count = 0;
145
166
 
146
167
        /*sprites not fully understood.*/
171
192
                {
172
193
                        for(dy=0;dy<h;dy++)
173
194
                                for(dx=0;dx<w;dx++)
174
 
                                        drawgfx_transpen(bitmap,cliprect,machine->gfx[0],spr_offs++,colour,1,0,((x+16*w)-(dx+1)*16),(y+dy*16),0);
 
195
                                        drawgfx_transpen(bitmap,cliprect,machine.gfx[0],spr_offs++,colour,1,0,((x+16*w)-(dx+1)*16),(y+dy*16),0);
175
196
                }
176
197
                else
177
198
                {
178
199
                        for(dy=0;dy<h;dy++)
179
200
                                for(dx=0;dx<w;dx++)
180
 
                                        drawgfx_transpen(bitmap,cliprect,machine->gfx[0],spr_offs++,colour,0,0,(x+dx*16),(y+dy*16),0);
 
201
                                        drawgfx_transpen(bitmap,cliprect,machine.gfx[0],spr_offs++,colour,0,0,(x+dx*16),(y+dy*16),0);
181
202
                }
182
203
        }
183
204
}
184
205
 
185
 
static VIDEO_UPDATE(kingdrby)
 
206
static SCREEN_UPDATE(kingdrby)
186
207
{
 
208
        kingdrby_state *state = screen->machine().driver_data<kingdrby_state>();
187
209
        const rectangle &visarea = screen->visible_area();
188
210
        rectangle clip;
189
 
        tilemap_set_scrollx( sc0_tilemap,0, kingdrby_vram[0x342]);
190
 
        tilemap_set_scrolly( sc0_tilemap,0, kingdrby_vram[0x341]);
191
 
        tilemap_set_scrollx( sc1_tilemap,0, kingdrby_vram[0x342]);
192
 
        tilemap_set_scrolly( sc1_tilemap,0, kingdrby_vram[0x341]);
193
 
        tilemap_set_scrolly( sc0w_tilemap,0, 32);
 
211
        tilemap_set_scrollx( state->m_sc0_tilemap,0, state->m_vram[0x342]);
 
212
        tilemap_set_scrolly( state->m_sc0_tilemap,0, state->m_vram[0x341]);
 
213
        tilemap_set_scrollx( state->m_sc1_tilemap,0, state->m_vram[0x342]);
 
214
        tilemap_set_scrolly( state->m_sc1_tilemap,0, state->m_vram[0x341]);
 
215
        tilemap_set_scrolly( state->m_sc0w_tilemap,0, 32);
194
216
 
195
217
        /* maybe it needs two window tilemaps? (one at the top, the other at the bottom)*/
196
218
        clip.min_x = visarea.min_x;
199
221
        clip.max_y = visarea.max_y;
200
222
 
201
223
        /*TILEMAP_DRAW_CATEGORY + TILEMAP_DRAW_OPAQUE doesn't suit well?*/
202
 
        tilemap_draw(bitmap,cliprect,sc0_tilemap,0,0);
203
 
        draw_sprites(screen->machine,bitmap,cliprect);
204
 
        tilemap_draw(bitmap,cliprect,sc1_tilemap,TILEMAP_DRAW_CATEGORY(1),0);
205
 
        tilemap_draw(bitmap,&clip,sc0w_tilemap,0,0);
 
224
        tilemap_draw(bitmap,cliprect,state->m_sc0_tilemap,0,0);
 
225
        draw_sprites(screen->machine(),bitmap,cliprect);
 
226
        tilemap_draw(bitmap,cliprect,state->m_sc1_tilemap,TILEMAP_DRAW_CATEGORY(1),0);
 
227
        tilemap_draw(bitmap,&clip,state->m_sc0w_tilemap,0,0);
206
228
 
207
229
        return 0;
208
230
}
209
231
 
210
232
static WRITE8_HANDLER( sc0_vram_w )
211
233
{
212
 
        kingdrby_vram[offset] = data;
213
 
        tilemap_mark_tile_dirty(sc0_tilemap,offset);
214
 
        tilemap_mark_tile_dirty(sc0w_tilemap,offset);
215
 
        tilemap_mark_tile_dirty(sc1_tilemap,offset);
 
234
        kingdrby_state *state = space->machine().driver_data<kingdrby_state>();
 
235
        state->m_vram[offset] = data;
 
236
        tilemap_mark_tile_dirty(state->m_sc0_tilemap,offset);
 
237
        tilemap_mark_tile_dirty(state->m_sc0w_tilemap,offset);
 
238
        tilemap_mark_tile_dirty(state->m_sc1_tilemap,offset);
216
239
}
217
240
 
218
241
static WRITE8_HANDLER( sc0_attr_w )
219
242
{
220
 
        kingdrby_attr[offset] = data;
221
 
        tilemap_mark_tile_dirty(sc0_tilemap,offset);
222
 
        tilemap_mark_tile_dirty(sc0w_tilemap,offset);
223
 
        tilemap_mark_tile_dirty(sc1_tilemap,offset);
 
243
        kingdrby_state *state = space->machine().driver_data<kingdrby_state>();
 
244
        state->m_attr[offset] = data;
 
245
        tilemap_mark_tile_dirty(state->m_sc0_tilemap,offset);
 
246
        tilemap_mark_tile_dirty(state->m_sc0w_tilemap,offset);
 
247
        tilemap_mark_tile_dirty(state->m_sc1_tilemap,offset);
224
248
}
225
249
 
226
250
/*************************************
230
254
 *************************************/
231
255
 
232
256
/* hopper I/O */
233
 
static UINT8 p1_hopper,p2_hopper;
234
257
 
235
258
static READ8_DEVICE_HANDLER( hopper_io_r )
236
259
{
237
 
        return (input_port_read(device->machine,"HPIO") & 0x3f) | p1_hopper | p2_hopper;
 
260
        kingdrby_state *state = device->machine().driver_data<kingdrby_state>();
 
261
        return (input_port_read(device->machine(),"HPIO") & 0x3f) | state->m_p1_hopper | state->m_p2_hopper;
238
262
}
239
263
 
240
264
static WRITE8_DEVICE_HANDLER( hopper_io_w )
241
265
{
242
 
        p1_hopper = (data & 0x8)<<3;
243
 
        p2_hopper = (data & 0x4)<<5;
 
266
        kingdrby_state *state = device->machine().driver_data<kingdrby_state>();
 
267
        state->m_p1_hopper = (data & 0x8)<<3;
 
268
        state->m_p2_hopper = (data & 0x4)<<5;
244
269
//  printf("%02x\n",data);
245
270
}
246
271
 
247
272
static WRITE8_DEVICE_HANDLER( sound_cmd_w )
248
273
{
249
 
        cputag_set_input_line(device->machine, "soundcpu", INPUT_LINE_NMI, PULSE_LINE);
250
 
        sound_cmd = data;
 
274
        kingdrby_state *state = device->machine().driver_data<kingdrby_state>();
 
275
        cputag_set_input_line(device->machine(), "soundcpu", INPUT_LINE_NMI, PULSE_LINE);
 
276
        state->m_sound_cmd = data;
251
277
        /* soundlatch is unneeded since we are already using perfect interleave. */
252
278
        // soundlatch_w(space,0, data);
253
279
}
254
280
 
255
 
static UINT8 mux_data;
256
281
 
257
282
/* No idea about what's this (if it's really a mux etc.)*/
258
283
static WRITE8_DEVICE_HANDLER( outport2_w )
259
284
{
 
285
        kingdrby_state *state = device->machine().driver_data<kingdrby_state>();
260
286
//  popmessage("PPI1 port C(upper) out: %02X", data);
261
 
        mux_data = data & 0x80;
 
287
        state->m_mux_data = data & 0x80;
262
288
}
263
289
 
264
290
static READ8_DEVICE_HANDLER( input_mux_r )
265
291
{
266
 
        if(mux_data & 0x80)
267
 
                return input_port_read(device->machine,"MUX0");
 
292
        kingdrby_state *state = device->machine().driver_data<kingdrby_state>();
 
293
        if(state->m_mux_data & 0x80)
 
294
                return input_port_read(device->machine(),"MUX0");
268
295
        else
269
 
                return input_port_read(device->machine,"MUX1");
 
296
                return input_port_read(device->machine(),"MUX1");
270
297
}
271
298
 
272
299
static READ8_DEVICE_HANDLER( key_matrix_r )
273
300
{
274
 
        static UINT16 p1_val,p2_val;
275
 
        static UINT8 p1_res,p2_res;
 
301
        UINT16 p1_val,p2_val;
 
302
        UINT8 p1_res,p2_res;
276
303
 
277
 
        p1_val = input_port_read(device->machine,"KEY_1P");
278
 
        p2_val = input_port_read(device->machine,"KEY_2P");
 
304
        p1_val = input_port_read(device->machine(),"KEY_1P");
 
305
        p2_val = input_port_read(device->machine(),"KEY_2P");
279
306
 
280
307
        p1_res = 0;
281
308
        p2_res = 0;
323
350
 
324
351
static READ8_DEVICE_HANDLER( sound_cmd_r )
325
352
{
326
 
        return sound_cmd;
 
353
        kingdrby_state *state = device->machine().driver_data<kingdrby_state>();
 
354
        return state->m_sound_cmd;
327
355
}
328
356
 
329
357
static WRITE8_HANDLER( led_array_w )
343
371
 *
344
372
 *************************************/
345
373
 
346
 
static ADDRESS_MAP_START( master_map, ADDRESS_SPACE_PROGRAM, 8 )
 
374
static ADDRESS_MAP_START( master_map, AS_PROGRAM, 8 )
347
375
        AM_RANGE(0x0000, 0x2fff) AM_ROM
348
376
        AM_RANGE(0x3000, 0x33ff) AM_RAM AM_MIRROR(0xc00) AM_SHARE("share1")
349
 
        AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(sc0_vram_w) AM_BASE(&kingdrby_vram)
350
 
        AM_RANGE(0x5000, 0x53ff) AM_RAM_WRITE(sc0_attr_w) AM_BASE(&kingdrby_attr)
 
377
        AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(sc0_vram_w) AM_BASE_MEMBER(kingdrby_state, m_vram)
 
378
        AM_RANGE(0x5000, 0x53ff) AM_RAM_WRITE(sc0_attr_w) AM_BASE_MEMBER(kingdrby_state, m_attr)
351
379
ADDRESS_MAP_END
352
380
 
353
 
static ADDRESS_MAP_START( master_io_map, ADDRESS_SPACE_IO, 8 )
 
381
static ADDRESS_MAP_START( master_io_map, AS_IO, 8 )
354
382
        ADDRESS_MAP_GLOBAL_MASK(0xff)
355
383
        AM_RANGE(0x00, 0x00) AM_NOP //interrupt ack
356
384
ADDRESS_MAP_END
357
385
 
358
 
static ADDRESS_MAP_START( slave_map, ADDRESS_SPACE_PROGRAM, 8 )
 
386
static ADDRESS_MAP_START( slave_map, AS_PROGRAM, 8 )
359
387
        AM_RANGE(0x0000, 0x2fff) AM_ROM
360
388
        AM_RANGE(0x3000, 0x3fff) AM_ROM //sound rom tested for the post check
361
389
        AM_RANGE(0x4000, 0x43ff) AM_RAM AM_SHARE("nvram") //backup ram
362
390
        AM_RANGE(0x5000, 0x5003) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w)     /* I/O Ports */
363
391
        AM_RANGE(0x6000, 0x6003) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w)     /* I/O Ports */
364
392
        AM_RANGE(0x7000, 0x73ff) AM_RAM AM_SHARE("share1")
365
 
        AM_RANGE(0x7400, 0x74ff) AM_RAM AM_BASE_GENERIC(spriteram)
 
393
        AM_RANGE(0x7400, 0x74ff) AM_RAM AM_BASE_MEMBER(kingdrby_state, m_spriteram)
366
394
        AM_RANGE(0x7600, 0x7600) AM_DEVWRITE("crtc", mc6845_address_w)
367
395
        AM_RANGE(0x7601, 0x7601) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
368
396
        AM_RANGE(0x7801, 0x780f) AM_WRITE(led_array_w)
375
403
        // (same as the inputs but active high)
376
404
}
377
405
 
378
 
static ADDRESS_MAP_START( slave_1986_map, ADDRESS_SPACE_PROGRAM, 8 )
 
406
static ADDRESS_MAP_START( slave_1986_map, AS_PROGRAM, 8 )
379
407
        AM_RANGE(0x0000, 0x2fff) AM_ROM
380
408
        AM_RANGE(0x3000, 0x3fff) AM_ROM //sound rom tested for the post check
381
409
        AM_RANGE(0x4000, 0x47ff) AM_RAM AM_SHARE("nvram") //backup ram
382
410
        AM_RANGE(0x5000, 0x5003) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w)     /* I/O Ports */
383
411
//  AM_RANGE(0x6000, 0x6003) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w) /* I/O Ports */
384
412
        AM_RANGE(0x7000, 0x73ff) AM_RAM AM_SHARE("share1")
385
 
        AM_RANGE(0x7400, 0x74ff) AM_RAM AM_BASE_GENERIC(spriteram)
 
413
        AM_RANGE(0x7400, 0x74ff) AM_RAM AM_BASE_MEMBER(kingdrby_state, m_spriteram)
386
414
        AM_RANGE(0x7600, 0x7600) AM_DEVWRITE("crtc", mc6845_address_w)
387
415
        AM_RANGE(0x7601, 0x7601) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
388
416
        AM_RANGE(0x7800, 0x7800) AM_READ_PORT("KEY0")
394
422
        AM_RANGE(0x7c00, 0x7c00) AM_READ_PORT("DSW")
395
423
ADDRESS_MAP_END
396
424
 
397
 
static ADDRESS_MAP_START( slave_io_map, ADDRESS_SPACE_IO, 8 )
 
425
static ADDRESS_MAP_START( slave_io_map, AS_IO, 8 )
398
426
        ADDRESS_MAP_GLOBAL_MASK(0xff)
399
427
        AM_RANGE(0x00, 0x00) AM_NOP //interrupt ack
400
428
ADDRESS_MAP_END
401
429
 
402
 
static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
 
430
static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8 )
403
431
        AM_RANGE(0x0000, 0x0fff) AM_ROM
404
432
        AM_RANGE(0x2000, 0x23ff) AM_RAM
405
433
ADDRESS_MAP_END
406
434
 
407
 
static ADDRESS_MAP_START( sound_io_map, ADDRESS_SPACE_IO, 8 )
 
435
static ADDRESS_MAP_START( sound_io_map, AS_IO, 8 )
408
436
        ADDRESS_MAP_GLOBAL_MASK(0xff)
409
437
        AM_RANGE(0x40, 0x40) AM_DEVREAD("aysnd", ay8910_r)
410
438
        AM_RANGE(0x40, 0x41) AM_DEVWRITE("aysnd", ay8910_data_address_w)
411
439
ADDRESS_MAP_END
412
440
 
413
 
static ADDRESS_MAP_START( cowrace_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
 
441
static ADDRESS_MAP_START( cowrace_sound_map, AS_PROGRAM, 8 )
414
442
        AM_RANGE(0x0000, 0x1fff) AM_ROM
415
443
        AM_RANGE(0x2000, 0x23ff) AM_RAM
416
444
ADDRESS_MAP_END
417
445
 
418
 
static ADDRESS_MAP_START( cowrace_sound_io, ADDRESS_SPACE_IO, 8 )
 
446
static ADDRESS_MAP_START( cowrace_sound_io, AS_IO, 8 )
419
447
        ADDRESS_MAP_GLOBAL_MASK(0xff)
420
448
        AM_RANGE(0x40, 0x41) AM_DEVWRITE("aysnd", ym2203_w)
421
449
ADDRESS_MAP_END
936
964
 
937
965
static PALETTE_INIT(kingdrbb)
938
966
{
939
 
        UINT8 *raw_prom = machine->region("raw_prom")->base();
940
 
        UINT8 *prom = machine->region("proms")->base();
 
967
        UINT8 *raw_prom = machine.region("raw_prom")->base();
 
968
        UINT8 *prom = machine.region("proms")->base();
941
969
        int     bit0, bit1, bit2 , r, g, b;
942
970
        int     i;
943
971
 
966
994
        }
967
995
}
968
996
 
969
 
static MACHINE_CONFIG_START( kingdrby, driver_device )
 
997
static MACHINE_CONFIG_START( kingdrby, kingdrby_state )
970
998
        MCFG_CPU_ADD("master", Z80, CLK_2)
971
999
        MCFG_CPU_PROGRAM_MAP(master_map)
972
1000
        MCFG_CPU_IO_MAP(master_io_map)
999
1027
        MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1000
1028
        MCFG_SCREEN_SIZE(256, 256)
1001
1029
        MCFG_SCREEN_VISIBLE_AREA(0, 256-1, 0, 224-1)    /* controlled by CRTC */
 
1030
        MCFG_SCREEN_UPDATE(kingdrby)
1002
1031
 
1003
1032
        MCFG_VIDEO_START(kingdrby)
1004
 
        MCFG_VIDEO_UPDATE(kingdrby)
1005
1033
 
1006
1034
        MCFG_MC6845_ADD("crtc", MC6845, CLK_1/32, mc6845_intf)  /* 53.333 Hz. guess */
1007
1035