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

« back to all changes in this revision

Viewing changes to src/mame/video/tx1.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:
27
27
 
28
28
    TODO: Calc TX-1 values...
29
29
*/
30
 
static emu_timer *interrupt_timer;
31
30
 
32
31
/*
33
32
    TODO: Check interrupt timing from CRT config. Probably different between games.
34
33
*/
35
34
static TIMER_CALLBACK( interrupt_callback )
36
35
{
 
36
        tx1_state *state = machine.driver_data<tx1_state>();
37
37
        cputag_set_input_line_and_vector(machine, "main_cpu", 0, HOLD_LINE, 0xff);
38
 
        timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0);
 
38
        state->m_interrupt_timer->adjust(machine.primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS));
39
39
}
40
40
 
41
41
 
97
97
        TX1_RDFLAG_SCCHGF
98
98
};
99
99
 
100
 
static struct
101
 
{
102
 
        UINT16  scol;           /* Road colours */
103
 
        UINT32  slock;          /* Scroll lock */
104
 
        UINT8   flags;          /* Road flags */
105
 
 
106
 
        UINT32  ba_val;         /* Accumulator */
107
 
        UINT32  ba_inc;
108
 
        UINT32  bank_mode;
109
 
 
110
 
        UINT16  h_val;          /* Accumulator */
111
 
        UINT16  h_inc;
112
 
 
113
 
        UINT8   slin_val;       /* Accumulator */
114
 
        UINT8   slin_inc;
115
 
} tx1_vregs;
116
 
 
117
 
UINT16 *tx1_vram;
118
 
UINT16 *tx1_objram;
119
 
UINT16 *tx1_rcram;
120
 
size_t tx1_objram_size;
121
 
 
122
 
static UINT8 *tx1_chr_bmp;
123
 
static UINT8 *tx1_obj_bmp;
124
 
static UINT8 *tx1_rod_bmp;
125
 
 
126
 
static bitmap_t *tx1_bitmap;
127
100
 
128
101
 
129
102
/***************************************************************************
172
145
 
173
146
WRITE16_HANDLER( tx1_bankcs_w )
174
147
{
 
148
        tx1_state *state = space->machine().driver_data<tx1_state>();
 
149
        vregs_t &tx1_vregs = state->m_vregs;
 
150
 
175
151
        // AAB2 = /BASET0
176
152
        // AAB3 = /BASET
177
153
        // AAB4 = /BSET
223
199
 
224
200
WRITE16_HANDLER( tx1_slincs_w )
225
201
{
 
202
        tx1_state *state = space->machine().driver_data<tx1_state>();
226
203
        if (offset == 1)
227
 
                tx1_vregs.slin_inc = data;
 
204
                state->m_vregs.slin_inc = data;
228
205
        else
229
 
                tx1_vregs.slin_inc = tx1_vregs.slin_val = 0;
 
206
                state->m_vregs.slin_inc = state->m_vregs.slin_val = 0;
230
207
}
231
208
 
232
209
WRITE16_HANDLER( tx1_slock_w )
233
210
{
234
 
        tx1_vregs.slock = data & 1;
 
211
        tx1_state *state = space->machine().driver_data<tx1_state>();
 
212
        state->m_vregs.slock = data & 1;
235
213
}
236
214
 
237
215
WRITE16_HANDLER( tx1_scolst_w )
238
216
{
239
 
        tx1_vregs.scol = data & 0x0707;
 
217
        tx1_state *state = space->machine().driver_data<tx1_state>();
 
218
        state->m_vregs.scol = data & 0x0707;
240
219
}
241
220
 
242
221
WRITE16_HANDLER( tx1_flgcs_w )
243
222
{
244
 
        tx1_vregs.flags = data & 0xff;
 
223
        tx1_state *state = space->machine().driver_data<tx1_state>();
 
224
        state->m_vregs.flags = data & 0xff;
245
225
}
246
226
 
247
227
 
251
231
 *
252
232
 *************************************/
253
233
 
254
 
static void tx1_draw_char(running_machine *machine, UINT8 *bitmap)
 
234
static void tx1_draw_char(running_machine &machine, UINT8 *bitmap)
255
235
{
 
236
        tx1_state *state = machine.driver_data<tx1_state>();
 
237
        UINT16 *tx1_vram = state->m_vram;
256
238
        INT32 x, y;
257
239
        UINT32 scroll_x;
258
240
        UINT8 *chars, *gfx2;
259
241
 
260
242
        /* 2bpp characters */
261
 
        chars = machine->region("char_tiles")->base();
 
243
        chars = machine.region("char_tiles")->base();
262
244
        gfx2 = chars + 0x4000;
263
245
 
264
246
        /* X scroll value is the last word in char RAM */
276
258
                y_offs = y;
277
259
 
278
260
                if ((y_offs >= 64) && (y_offs < 128))
279
 
                        x_offs = tx1_vregs.slock ? scroll_x : 0;
 
261
                        x_offs = state->m_vregs.slock ? scroll_x : 0;
280
262
                else
281
263
                        x_offs = 0;
282
264
 
337
319
        pix[NUM][3][0] = prom_a[0];                     pix[NUM][3][1] = prom_b[0];                     pix[NUM][3][2] = prom_c[0]; \
338
320
}
339
321
 
340
 
INLINE void tx1_draw_road_pixel(running_machine *machine, int screen, UINT8 *bmpaddr,
 
322
INLINE void tx1_draw_road_pixel(running_machine &machine, int screen, UINT8 *bmpaddr,
341
323
                                                                UINT8 apix[3], UINT8 bpix[3], UINT32 pixnuma, UINT32 pixnumb,
342
324
                                                                UINT8 stl, UINT8 sld, UINT8 selb,
343
325
                                                                UINT8 bnk, UINT8 rorev, UINT8 eb, UINT8 r, UINT8 delr)
344
326
{
 
327
        tx1_state *state = machine.driver_data<tx1_state>();
 
328
        vregs_t &tx1_vregs = state->m_vregs;
345
329
        UINT8 a0 = BIT(apix[0], pixnuma);
346
330
        UINT8 a1 = BIT(apix[1], pixnuma);
347
331
        UINT8 a2 = BIT(apix[2], pixnuma);
415
399
}
416
400
 
417
401
/* This could do with a tidy up and more comments... */
418
 
static void tx1_draw_road(running_machine *machine, UINT8 *bitmap)
 
402
static void tx1_draw_road(running_machine &machine, UINT8 *bitmap)
419
403
{
 
404
        tx1_state *state = machine.driver_data<tx1_state>();
 
405
        UINT16 *tx1_rcram = state->m_rcram;
 
406
        vregs_t &tx1_vregs = state->m_vregs;
420
407
        INT32   y;
421
408
        UINT32  rva9_8;
422
409
        UINT32  rva7;
433
420
        UINT8   pix[2][4][3];
434
421
 
435
422
        /* Road slice map ROMs */
436
 
        const UINT8 *const gfx3 = machine->region("gfx3")->base();
 
423
        const UINT8 *const gfx3 = machine.region("gfx3")->base();
437
424
        const UINT8 *const rom_a = gfx3;
438
425
        const UINT8 *const rom_b = gfx3 + 0x2000;
439
426
        const UINT8 *const rom_c = gfx3 + 0x4000;
440
427
 
441
428
        /* Pixel data */
442
 
        const UINT8 *const proms = machine->region("proms")->base();
 
429
        const UINT8 *const proms = machine.region("proms")->base();
443
430
        const UINT8 *const prom_a = proms + 0x1100;
444
431
        const UINT8 *const prom_b = proms + 0x1300;
445
432
        const UINT8 *const prom_c = proms + 0x1500;
867
854
 *
868
855
 *************************************/
869
856
 
870
 
static void tx1_draw_objects(running_machine *machine, UINT8 *bitmap)
 
857
static void tx1_draw_objects(running_machine &machine, UINT8 *bitmap)
871
858
{
 
859
        tx1_state *state = machine.driver_data<tx1_state>();
 
860
        UINT16 *tx1_objram = state->m_objram;
872
861
#define FRAC    16
873
862
 
874
863
        UINT32 offs;
875
864
 
876
865
        /* The many lookup table ROMs */
877
 
        const UINT8 *const ic48 = machine->region("user3")->base();
 
866
        const UINT8 *const ic48 = machine.region("user3")->base();
878
867
        const UINT8 *const ic281 = ic48 + 0x2000;
879
868
 
880
 
        const UINT8 *const proms = machine->region("proms")->base();
 
869
        const UINT8 *const proms = machine.region("proms")->base();
881
870
        const UINT8 *const ic190 = proms + 0xc00;
882
871
        const UINT8 *const ic162 = proms + 0xe00;
883
872
        const UINT8 *const ic25  = proms + 0x1000;
884
873
 
885
 
        const UINT8 *const ic106 = machine->region("obj_map")->base();
 
874
        const UINT8 *const ic106 = machine.region("obj_map")->base();
886
875
        const UINT8 *const ic73  = ic106 + 0x4000;
887
876
 
888
 
        const UINT8 *const pixdata_rgn = machine->region("obj_tiles")->base();
 
877
        const UINT8 *const pixdata_rgn = machine.region("obj_tiles")->base();
889
878
 
890
 
        for (offs = 0x0; offs <= tx1_objram_size; offs += 8)
 
879
        for (offs = 0x0; offs <= 0x300; offs += 8)
891
880
        {
892
881
                UINT32  x;
893
882
                UINT32  y;
1119
1108
 
1120
1109
VIDEO_START( tx1 )
1121
1110
{
 
1111
        tx1_state *state = machine.driver_data<tx1_state>();
1122
1112
        /* Allocate a large bitmap that covers the three screens */
1123
 
        tx1_bitmap = auto_bitmap_alloc(machine, 768, 256, BITMAP_FORMAT_INDEXED16);
 
1113
        state->m_bitmap = auto_bitmap_alloc(machine, 768, 256, BITMAP_FORMAT_INDEXED16);
1124
1114
 
1125
1115
        /* Allocate some bitmaps */
1126
 
        tx1_chr_bmp = auto_alloc_array(machine, UINT8, 256 * 3 * 240);
1127
 
        tx1_obj_bmp = auto_alloc_array(machine, UINT8, 256 * 3 * 240);
1128
 
        tx1_rod_bmp = auto_alloc_array(machine, UINT8, 256 * 3 * 240);
 
1116
        state->m_chr_bmp = auto_alloc_array(machine, UINT8, 256 * 3 * 240);
 
1117
        state->m_obj_bmp = auto_alloc_array(machine, UINT8, 256 * 3 * 240);
 
1118
        state->m_rod_bmp = auto_alloc_array(machine, UINT8, 256 * 3 * 240);
1129
1119
 
1130
1120
        /* Set a timer to run the interrupts */
1131
 
        interrupt_timer = timer_alloc(machine, interrupt_callback, NULL);
 
1121
        state->m_interrupt_timer = machine.scheduler().timer_alloc(FUNC(interrupt_callback));
1132
1122
 
1133
1123
        /* /CUDISP CRTC interrupt */
1134
 
        timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0);
 
1124
        state->m_interrupt_timer->adjust(machine.primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS));
1135
1125
}
1136
1126
 
1137
 
VIDEO_EOF( tx1 )
 
1127
SCREEN_EOF( tx1 )
1138
1128
{
 
1129
        tx1_state *state = machine.driver_data<tx1_state>();
1139
1130
        /* /VSYNC: Update TZ113 */
1140
 
        tx1_vregs.slin_val += tx1_vregs.slin_inc;
 
1131
        state->m_vregs.slin_val += state->m_vregs.slin_inc;
1141
1132
}
1142
1133
 
1143
 
static void tx1_combine_layers(running_machine *machine, bitmap_t *bitmap, int screen)
 
1134
static void tx1_combine_layers(running_machine &machine, bitmap_t *bitmap, int screen)
1144
1135
{
 
1136
        tx1_state *state = machine.driver_data<tx1_state>();
1145
1137
        int x, y;
1146
 
        UINT8 *chr_pal = machine->region("proms")->base() + 0x900;
 
1138
        UINT8 *chr_pal = machine.region("proms")->base() + 0x900;
1147
1139
 
1148
1140
        int x_offset = screen * 256;
1149
1141
 
1153
1145
 
1154
1146
                UINT32 bmp_offset = y * 768 + x_offset;
1155
1147
 
1156
 
                UINT8 *chr_addr = tx1_chr_bmp + bmp_offset;
1157
 
                UINT8 *rod_addr = tx1_rod_bmp + bmp_offset;
1158
 
                UINT8 *obj_addr = tx1_obj_bmp + bmp_offset;
 
1148
                UINT8 *chr_addr = state->m_chr_bmp + bmp_offset;
 
1149
                UINT8 *rod_addr = state->m_rod_bmp + bmp_offset;
 
1150
                UINT8 *obj_addr = state->m_obj_bmp + bmp_offset;
1159
1151
 
1160
1152
                for (x = 0; x < 256; ++x)
1161
1153
                {
1190
1182
        }
1191
1183
}
1192
1184
 
1193
 
VIDEO_UPDATE( tx1 )
 
1185
SCREEN_UPDATE( tx1 )
1194
1186
{
1195
 
        device_t *left_screen   = screen->machine->device("lscreen");
1196
 
        device_t *centre_screen = screen->machine->device("cscreen");
1197
 
        device_t *right_screen  = screen->machine->device("rscreen");
 
1187
        tx1_state *state = screen->machine().driver_data<tx1_state>();
 
1188
        device_t *left_screen   = screen->machine().device("lscreen");
 
1189
        device_t *centre_screen = screen->machine().device("cscreen");
 
1190
        device_t *right_screen  = screen->machine().device("rscreen");
1198
1191
 
1199
1192
        if (screen == left_screen)
1200
1193
        {
1201
 
                memset(tx1_obj_bmp, 0, 768*240);
1202
 
 
1203
 
                tx1_draw_char(screen->machine, tx1_chr_bmp);
1204
 
                tx1_draw_road(screen->machine, tx1_rod_bmp);
1205
 
                tx1_draw_objects(screen->machine, tx1_obj_bmp);
1206
 
 
1207
 
                tx1_combine_layers(screen->machine, bitmap, 0);
 
1194
                memset(state->m_obj_bmp, 0, 768*240);
 
1195
 
 
1196
                tx1_draw_char(screen->machine(), state->m_chr_bmp);
 
1197
                tx1_draw_road(screen->machine(), state->m_rod_bmp);
 
1198
                tx1_draw_objects(screen->machine(), state->m_obj_bmp);
 
1199
 
 
1200
                tx1_combine_layers(screen->machine(), bitmap, 0);
1208
1201
        }
1209
1202
        else if (screen == centre_screen)
1210
1203
        {
1211
 
                tx1_combine_layers(screen->machine, bitmap, 1);
 
1204
                tx1_combine_layers(screen->machine(), bitmap, 1);
1212
1205
        }
1213
1206
        else if (screen == right_screen)
1214
1207
        {
1215
 
                tx1_combine_layers(screen->machine, bitmap, 2);
 
1208
                tx1_combine_layers(screen->machine(), bitmap, 2);
1216
1209
        }
1217
1210
 
1218
1211
        return 0;
1235
1228
#define BB_RDFLAG_RVA7          1
1236
1229
#define BB_RDFLAG_WANGL         0
1237
1230
 
1238
 
/* Video registers */
1239
 
static struct
1240
 
{
1241
 
        UINT32  ba_val;
1242
 
        UINT32  ba_inc;
1243
 
 
1244
 
        UINT32  bank_mode;
1245
 
 
1246
 
        UINT16  h_val;
1247
 
        UINT16  h_inc;
1248
 
        UINT16  h_init;
1249
 
 
1250
 
        UINT8   wa8;
1251
 
        UINT8   wa4;
1252
 
 
1253
 
        UINT8   slin;
1254
 
        UINT8   slin_inc;
1255
 
 
1256
 
        UINT16  wave_lfsr;
1257
 
        UINT16  scol;
1258
 
        UINT8   sky;
1259
 
        UINT16  gas;
1260
 
        UINT8   flags;
1261
 
        UINT8   shift;
1262
 
} vregs;
1263
 
 
1264
 
 
1265
 
UINT16 *buggyboy_objram;
1266
 
UINT16 *buggyboy_rcram;
1267
 
UINT16 *buggyboy_vram;
1268
 
size_t buggyboy_objram_size;
1269
 
size_t buggyboy_rcram_size;
1270
 
 
1271
 
static UINT8 *bb_chr_bmp;
1272
 
static UINT8 *bb_obj_bmp;
1273
 
static UINT8 *bb_rod_bmp;
1274
 
 
1275
 
 
1276
1231
/***************************************************************************
1277
1232
 
1278
1233
  Convert the color PROMs into a more useable format.
1335
1290
 *
1336
1291
 *************************************/
1337
1292
 
1338
 
static void buggyboy_draw_char(running_machine *machine, UINT8 *bitmap, int wide)
 
1293
static void buggyboy_draw_char(running_machine &machine, UINT8 *bitmap, int wide)
1339
1294
{
 
1295
        tx1_state *state = machine.driver_data<tx1_state>();
 
1296
        UINT16 *buggyboy_vram = state->m_vram;
1340
1297
        INT32 x, y;
1341
1298
        UINT32 scroll_x, scroll_y;
1342
1299
        UINT8 *chars, *gfx2;
1344
1301
        UINT32 x_mask;
1345
1302
 
1346
1303
        /* 2bpp characters */
1347
 
        chars = machine->region("char_tiles")->base();
1348
 
        gfx2 = machine->region("char_tiles")->base() + 0x4000;
 
1304
        chars = machine.region("char_tiles")->base();
 
1305
        gfx2 = machine.region("char_tiles")->base() + 0x4000;
1349
1306
 
1350
1307
        /* X/Y scroll values are the last word in char RAM */
1351
1308
        if (wide)
1560
1517
                        hp##NUM = hp##NUM + 1;          \
1561
1518
        }                                                                       \
1562
1519
 
1563
 
static void buggyboy_draw_road(running_machine *machine, UINT8 *bitmap)
 
1520
static void buggyboy_draw_road(running_machine &machine, UINT8 *bitmap)
1564
1521
{
 
1522
        tx1_state *state = machine.driver_data<tx1_state>();
 
1523
        UINT16 *buggyboy_rcram = state->m_rcram;
 
1524
        vregs_t &vregs = state->m_vregs;
1565
1525
        INT32 x;
1566
1526
        UINT32 y;
1567
1527
        UINT16 rva_offs;
1576
1536
        UINT32 rva20_6;
1577
1537
 
1578
1538
        /* ROM/PROM lookup tables */
1579
 
        const UINT8 *rcols = (UINT8*)(machine->region("proms")->base() + 0x1500);
1580
 
        const UINT8 *rom   = machine->region("road")->base();
 
1539
        const UINT8 *rcols = (UINT8*)(machine.region("proms")->base() + 0x1500);
 
1540
        const UINT8 *rom   = machine.region("road")->base();
1581
1541
        const UINT8 *prom0 = rom + 0x4000;
1582
1542
        const UINT8 *prom1 = rom + 0x4200;
1583
1543
        const UINT8 *prom2 = rom + 0x4400;
1671
1631
                ls161 =  ((rcrdb0_15 & 0x8000) >> 1) | ls161_156_a | rcrs10 | (rcrdb0_15 & 0x03ff);
1672
1632
 
1673
1633
                /* SLD */
1674
 
                sld = (vprom[rva0_6] + vregs.slin) & 0x38;
 
1634
                sld = (vprom[rva0_6] + vregs.slin_val) & 0x38;
1675
1635
 
1676
1636
                /* Determine the x-offset */
1677
1637
                x_offs = ls161 & 7;
2189
2149
        }
2190
2150
}
2191
2151
 
2192
 
static void buggybjr_draw_road(running_machine *machine, UINT8 *bitmap, int wide)
 
2152
static void buggybjr_draw_road(running_machine &machine, UINT8 *bitmap, int wide)
2193
2153
{
 
2154
        tx1_state *state = machine.driver_data<tx1_state>();
 
2155
        UINT16 *buggyboy_rcram = state->m_rcram;
 
2156
        vregs_t &vregs = state->m_vregs;
2194
2157
        INT32 x;
2195
2158
        UINT32 y;
2196
2159
        UINT16 rva_offs;
2205
2168
        UINT32 rva20_6;
2206
2169
 
2207
2170
        /* ROM/PROM lookup tables */
2208
 
        const UINT8 *rcols = (UINT8*)(machine->region("proms")->base() + 0x1500);
2209
 
        const UINT8 *rom   = machine->region("road")->base();
 
2171
        const UINT8 *rcols = (UINT8*)(machine.region("proms")->base() + 0x1500);
 
2172
        const UINT8 *rom   = machine.region("road")->base();
2210
2173
        const UINT8 *prom0 = rom + 0x4000;
2211
2174
        const UINT8 *prom1 = rom + 0x4200;
2212
2175
        const UINT8 *prom2 = rom + 0x4400;
2293
2256
                ls161 =  ((rcrdb0_15 & 0x8000) >> 1) | ls161_156_a | rcrs10 | (rcrdb0_15 & 0x03ff);
2294
2257
 
2295
2258
                /* SLD */
2296
 
                sld = (vprom[rva0_6] + vregs.slin) & 0x38;
 
2259
                sld = (vprom[rva0_6] + vregs.slin_val) & 0x38;
2297
2260
 
2298
2261
                /* Determine the x-offset */
2299
2262
                x_offs = ls161 & 7;
2606
2569
 
2607
2570
**************************************************************************/
2608
2571
 
2609
 
static void buggyboy_draw_objs(running_machine *machine, UINT8 *bitmap, int wide)
 
2572
static void buggyboy_draw_objs(running_machine &machine, UINT8 *bitmap, int wide)
2610
2573
{
 
2574
        tx1_state *state = machine.driver_data<tx1_state>();
 
2575
        UINT16 *buggyboy_objram = state->m_objram;
2611
2576
#define FRAC    16
2612
2577
 
2613
2578
        UINT32 offs;
2616
2581
        UINT32 x_stride;
2617
2582
 
2618
2583
        /* The many lookup table ROMs */
2619
 
        const UINT8 *const bug13  = (UINT8*)machine->region("obj_luts")->base();
 
2584
        const UINT8 *const bug13  = (UINT8*)machine.region("obj_luts")->base();
2620
2585
        const UINT8 *const bug18s = bug13 + 0x2000;
2621
 
        const UINT8 *const bb8    = (UINT8*)machine->region("proms")->base() + 0x1600;
 
2586
        const UINT8 *const bb8    = (UINT8*)machine.region("proms")->base() + 0x1600;
2622
2587
 
2623
 
        const UINT8 *const bug16s = (UINT8*)machine->region("obj_map")->base();
 
2588
        const UINT8 *const bug16s = (UINT8*)machine.region("obj_map")->base();
2624
2589
        const UINT8 *const bug17s = bug16s + 0x8000;
2625
2590
 
2626
 
        const UINT8 *const bb9o = (UINT8*)machine->region("proms")->base() + 0x500;
 
2591
        const UINT8 *const bb9o = (UINT8*)machine.region("proms")->base() + 0x500;
2627
2592
        const UINT8 *const bb9e = bb9o + 0x800;
2628
2593
 
2629
 
        const UINT8 *const pixdata_rgn = (UINT8*)machine->region("obj_tiles")->base();
 
2594
        const UINT8 *const pixdata_rgn = (UINT8*)machine.region("obj_tiles")->base();
2630
2595
 
2631
2596
        if (wide)
2632
2597
        {
2639
2604
                x_stride = 256;
2640
2605
        }
2641
2606
 
2642
 
        for (offs = 0; offs <= buggyboy_objram_size; offs += 8)
 
2607
        for (offs = 0; offs <= 0x300; offs += 8)
2643
2608
        {
2644
2609
                UINT32  x;
2645
2610
                UINT32  y;
2876
2841
*/
2877
2842
WRITE16_HANDLER( buggyboy_gas_w )
2878
2843
{
 
2844
        tx1_state *state = space->machine().driver_data<tx1_state>();
 
2845
        vregs_t &vregs = state->m_vregs;
2879
2846
        offset <<= 1;
2880
2847
 
2881
2848
        switch (offset & 0xe0)
2936
2903
                }
2937
2904
                case 0xe0:
2938
2905
                {
2939
 
                        cputag_set_input_line(space->machine, "math_cpu", INPUT_LINE_TEST, CLEAR_LINE);
 
2906
                        cputag_set_input_line(space->machine(), "math_cpu", INPUT_LINE_TEST, CLEAR_LINE);
2940
2907
                        vregs.flags = data;
2941
2908
                        break;
2942
2909
                }
2949
2916
 
2950
2917
WRITE16_HANDLER( buggyboy_sky_w )
2951
2918
{
2952
 
        vregs.sky = data;
2953
 
}
2954
 
 
2955
 
WRITE16_HANDLER( buggyboy_slincs_w )
2956
 
{
2957
 
        if (offset == 1)
2958
 
                vregs.slin_inc = data;
2959
 
        else
2960
 
                vregs.slin_inc = vregs.slin = 0;
2961
 
}
2962
 
 
2963
 
WRITE16_HANDLER( buggyboy_scolst_w )
2964
 
{
2965
 
        vregs.scol = data;
 
2919
        tx1_state *state = space->machine().driver_data<tx1_state>();
 
2920
        state->m_vregs.sky = data;
2966
2921
}
2967
2922
 
2968
2923
 
2972
2927
 *
2973
2928
 *************************************/
2974
2929
 
2975
 
static void bb_combine_layers(running_machine *machine, bitmap_t *bitmap, int screen)
 
2930
static void bb_combine_layers(running_machine &machine, bitmap_t *bitmap, int screen)
2976
2931
{
2977
 
        UINT8 *chr_pal = machine->region("proms")->base() + 0x400;
 
2932
        tx1_state *state = machine.driver_data<tx1_state>();
 
2933
        UINT8 *chr_pal = machine.region("proms")->base() + 0x400;
2978
2934
        UINT32 bmp_stride;
2979
2935
        UINT32 x_offset;
2980
2936
        UINT32 y;
2996
2952
 
2997
2953
                UINT32 bmp_offset = y * bmp_stride + x_offset;
2998
2954
 
2999
 
                UINT8 *chr_addr = bb_chr_bmp + bmp_offset;
3000
 
                UINT8 *rod_addr = bb_rod_bmp + bmp_offset;
3001
 
                UINT8 *obj_addr = bb_obj_bmp + bmp_offset;
 
2955
                UINT8 *chr_addr = state->m_chr_bmp + bmp_offset;
 
2956
                UINT8 *rod_addr = state->m_rod_bmp + bmp_offset;
 
2957
                UINT8 *obj_addr = state->m_obj_bmp + bmp_offset;
3002
2958
 
3003
 
                UINT32 sky_en = BIT(vregs.sky, 7);
3004
 
                UINT32 sky_val = (((vregs.sky & 0x7f) + y) >> 2) & 0x3f;
 
2959
                UINT32 sky_en = BIT(state->m_vregs.sky, 7);
 
2960
                UINT32 sky_val = (((state->m_vregs.sky & 0x7f) + y) >> 2) & 0x3f;
3005
2961
 
3006
2962
                UINT16 *bmp_addr = BITMAP_ADDR16(bitmap, y, 0);
3007
2963
 
3041
2997
 
3042
2998
VIDEO_START( buggyboy )
3043
2999
{
 
3000
        tx1_state *state = machine.driver_data<tx1_state>();
3044
3001
        /* Allocate some bitmaps */
3045
 
        bb_chr_bmp = auto_alloc_array(machine, UINT8, 3 * 256 * 240);
3046
 
        bb_obj_bmp = auto_alloc_array(machine, UINT8, 3 * 256 * 240);
3047
 
        bb_rod_bmp = auto_alloc_array(machine, UINT8, 3 * 256 * 240);
 
3002
        state->m_chr_bmp = auto_alloc_array(machine, UINT8, 3 * 256 * 240);
 
3003
        state->m_obj_bmp = auto_alloc_array(machine, UINT8, 3 * 256 * 240);
 
3004
        state->m_rod_bmp = auto_alloc_array(machine, UINT8, 3 * 256 * 240);
3048
3005
 
3049
3006
        /* Set a timer to run the interrupts */
3050
 
        interrupt_timer = timer_alloc(machine, interrupt_callback, NULL);
 
3007
        state->m_interrupt_timer = machine.scheduler().timer_alloc(FUNC(interrupt_callback));
3051
3008
 
3052
3009
        /* /CUDISP CRTC interrupt */
3053
 
        timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0);
 
3010
        state->m_interrupt_timer->adjust(machine.primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS));
3054
3011
}
3055
3012
 
3056
3013
VIDEO_START( buggybjr )
3057
3014
{
 
3015
        tx1_state *state = machine.driver_data<tx1_state>();
3058
3016
        /* Allocate some bitmaps */
3059
 
        bb_chr_bmp = auto_alloc_array(machine, UINT8, 256 * 240);
3060
 
        bb_obj_bmp = auto_alloc_array(machine, UINT8, 256 * 240);
3061
 
        bb_rod_bmp = auto_alloc_array(machine, UINT8, 256 * 240);
 
3017
        state->m_chr_bmp = auto_alloc_array(machine, UINT8, 256 * 240);
 
3018
        state->m_obj_bmp = auto_alloc_array(machine, UINT8, 256 * 240);
 
3019
        state->m_rod_bmp = auto_alloc_array(machine, UINT8, 256 * 240);
3062
3020
 
3063
3021
        /* Set a timer to run the interrupts */
3064
 
        interrupt_timer = timer_alloc(machine, interrupt_callback, NULL);
 
3022
        state->m_interrupt_timer = machine.scheduler().timer_alloc(FUNC(interrupt_callback));
3065
3023
 
3066
3024
        /* /CUDISP CRTC interrupt */
3067
 
        timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0);
 
3025
        state->m_interrupt_timer->adjust(machine.primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS));
3068
3026
}
3069
3027
 
3070
 
VIDEO_EOF( buggyboy )
 
3028
SCREEN_EOF( buggyboy )
3071
3029
{
 
3030
        tx1_state *state = machine.driver_data<tx1_state>();
 
3031
 
3072
3032
        /* /VSYNC: Update TZ113 @ 219 */
3073
 
        vregs.slin += vregs.slin_inc;
 
3033
        state->m_vregs.slin_val += state->m_vregs.slin_inc;
3074
3034
 
3075
3035
        /* /VSYNC: Clear wave LFSR */
3076
 
        vregs.wave_lfsr = 0;
 
3036
        state->m_vregs.wave_lfsr = 0;
3077
3037
}
3078
3038
 
3079
3039
 
3080
 
VIDEO_UPDATE( buggyboy )
 
3040
SCREEN_UPDATE( buggyboy )
3081
3041
{
3082
 
        device_t *left_screen = screen->machine->device("lscreen");
3083
 
        device_t *center_screen = screen->machine->device("cscreen");
3084
 
        device_t *right_screen = screen->machine->device("rscreen");
 
3042
        tx1_state *state = screen->machine().driver_data<tx1_state>();
 
3043
        device_t *left_screen = screen->machine().device("lscreen");
 
3044
        device_t *center_screen = screen->machine().device("cscreen");
 
3045
        device_t *right_screen = screen->machine().device("rscreen");
3085
3046
 
3086
3047
        if (screen == left_screen)
3087
3048
        {
3088
 
                memset(bb_obj_bmp, 0, 768*240);
3089
 
                memset(bb_rod_bmp, 0, 768*240);
3090
 
 
3091
 
                buggyboy_draw_char(screen->machine, bb_chr_bmp, 1);
3092
 
                buggyboy_draw_road(screen->machine, bb_rod_bmp);
3093
 
                buggyboy_draw_objs(screen->machine, bb_obj_bmp, 1);
3094
 
 
3095
 
                bb_combine_layers(screen->machine, bitmap, 0);
 
3049
                memset(state->m_obj_bmp, 0, 768*240);
 
3050
                memset(state->m_rod_bmp, 0, 768*240);
 
3051
 
 
3052
                buggyboy_draw_char(screen->machine(), state->m_chr_bmp, 1);
 
3053
                buggyboy_draw_road(screen->machine(), state->m_rod_bmp);
 
3054
                buggyboy_draw_objs(screen->machine(), state->m_obj_bmp, 1);
 
3055
 
 
3056
                bb_combine_layers(screen->machine(), bitmap, 0);
3096
3057
        }
3097
3058
        else if (screen == center_screen)
3098
3059
        {
3099
 
                bb_combine_layers(screen->machine, bitmap, 1);
 
3060
                bb_combine_layers(screen->machine(), bitmap, 1);
3100
3061
        }
3101
3062
        else if (screen == right_screen)
3102
3063
        {
3103
 
                bb_combine_layers(screen->machine, bitmap, 2);
 
3064
                bb_combine_layers(screen->machine(), bitmap, 2);
3104
3065
        }
3105
3066
 
3106
3067
        return 0;
3107
3068
 
3108
3069
}
3109
3070
 
3110
 
VIDEO_UPDATE( buggybjr )
 
3071
SCREEN_UPDATE( buggybjr )
3111
3072
{
3112
 
        memset(bb_obj_bmp, 0, 256*240);
3113
 
 
3114
 
        buggyboy_draw_char(screen->machine, bb_chr_bmp, 0);
3115
 
        buggybjr_draw_road(screen->machine, bb_rod_bmp, 0);
3116
 
        buggyboy_draw_objs(screen->machine, bb_obj_bmp, 0);
3117
 
 
3118
 
        bb_combine_layers(screen->machine, bitmap, -1);
 
3073
        tx1_state *state = screen->machine().driver_data<tx1_state>();
 
3074
        memset(state->m_obj_bmp, 0, 256*240);
 
3075
 
 
3076
        buggyboy_draw_char(screen->machine(), state->m_chr_bmp, 0);
 
3077
        buggybjr_draw_road(screen->machine(), state->m_rod_bmp, 0);
 
3078
        buggyboy_draw_objs(screen->machine(), state->m_obj_bmp, 0);
 
3079
 
 
3080
        bb_combine_layers(screen->machine(), bitmap, -1);
3119
3081
        return 0;
3120
3082
}