Previous 15994 Revisions Next

r3334 Saturday 27th September, 2008 at 03:25:52 UTC by Nathan Woods
Updated to MAME 0.127u5 core
[docs]messnew.txt
[src/emu]cheat.c clifront.c debugger.h emu.mak timer.c timer.h ui.c uimenu.c
[src/emu/cpu/arm7]arm7core.c arm7core.h
[src/emu/cpu/cubeqcpu]cubeqcpu.c
[src/emu/cpu/dsp56k]dsp56dsm.c
[src/emu/cpu/g65816]g65816ds.c
[src/emu/cpu/i8085]i8085.c
[src/emu/cpu/m37710]m7700ds.c
[src/emu/cpu/mcs48]mcs48.c
[src/emu/debug]debugcpu.c debugcpu.h debugvw.c
[src/emu/machine]laserdsc.h ldcore.c ldcore.h ldpr8210.c ldvp931.c*
[src/emu/sound]multipcm.c
[src/lib/util]bitmap.c png.c
[src/mame]mame.mak mamedriv.c
[src/mame/audio]dkong.c irem.c tx1.c
[src/mame/drivers]chanbara.c* cubeqst.c firefox.c galaxi.c gamecstl.c goal92.c gticlub.c guab.c hikaru.c igs009.c itgambl3.c leland.c namcoic.c namcona1.c namconb1.c namcond1.c namcos23.c naomi.c neodrvr.c niyanpai.c paradise.c peplus.c plygonet.c quizpun2.c senjyo.c shanghai.c snesb.c snk.c srmp6.c subsino.c system1.c tx1.c videopkr.c warpwarp.c zn.c
[src/mame/includes]dc.h dkong.h neogeo.h
[src/mame/machine]cubocd32.c dc.c namcos1.c nb1413m3.c neocrypt.c neoprot.c psx.c
[src/mame/video]atarirle.c avgdvg.c dc.c dkong.c esd16.c hd63484.c hyprduel.c leland.c midzeus.c midzeus2.c model3.c namcofl.c naughtyb.c neogeo.c system1.c taito_f3.c tx1.c
[src/mess/osd/windows]menu.c
[src/osd/windows]debugwin.c
[src/tools]chdcd.c

src/mame/audio/tx1.c
r3333r3334
33    Tatsumi TX-1/Buggy Boy sound hardware
44
55***************************************************************************/
6
67#include "driver.h"
78#include "streams.h"
89#include "deprecat.h"
r3333r3334
1011#include "video/resnet.h"
1112#include "sound/custom.h"
1213
14
1315/*************************************
1416 *
1517 *  Common
r3333r3334
2224static UINT32 step1;
2325static UINT32 step2;
2426
27
2528/*************************************
2629 *
2730 *  8253 Programmable Interval Timer
r3333r3334
166169   sndti_set_output_gain(SOUND_AY8910, 0, 0, gain);
167170   sndti_set_output_gain(SOUND_AY8910, 0, 1, gain);
168171   sndti_set_output_gain(SOUND_AY8910, 0, 2, gain);
169
170   if (!BIT(ay_outputb, 6))
171      popmessage("Skid!");
172
173   if (!BIT(ay_outputb, 7))
174      popmessage("Screech!");
175172}
176173
177174/***************************************************************************
r3333r3334
200197
201198 ***************************************************************************/
202199
203
204200INLINE void update_engine (int eng[4])
205201{
206202   int p0 = eng[0];
r3333r3334
231227   memset(buffer[0], 0, length * sizeof(*buffer[0]));
232228   memset(buffer[1], 0, length * sizeof(*buffer[1]));
233229
234   /* 8253 outputs for the player/opponent buggy engine sounds. */
230   /* 8253 outputs for the player/opponent engine sounds. */
235231   step_0 = pit8253.counts[0].val ? (TX1_PIT_CLOCK / pit8253.counts[0].val) * freq_to_step : 0;
236232   step_1 = pit8253.counts[1].val ? (TX1_PIT_CLOCK / pit8253.counts[1].val) * freq_to_step : 0;
237233   step_2 = pit8253.counts[2].val ? (TX1_PIT_CLOCK / pit8253.counts[2].val) * freq_to_step : 0;
src/mame/audio/irem.c
r3333r3334
194194 *************************************/
195195
196196/* All 6 (3*2) AY-3-8910 outputs are tied together
197 * and put with 470 KOhm to gnd.
198 * The following is a approximation */
197 * and put with 470 Ohm to gnd.
198 * The following is a approximation, since
199 * it does not take cross-chip mixing effects into account.
200 */
199201
200202static const ay8910_interface irem_ay8910_interface_1 =
201203{
src/mame/audio/dkong.c
r3333r3334
872872 *
873873 ****************************************************************/
874874
875SOUND_START( dkong)
876{
877   dkong_state *state = machine->driver_data;
875878
879   state->snd_rom = memory_region(machine, "sound");
880   state->dev_vp2 = devtag_get_device(machine, LATCH8, "virtual_p2");
881}
876882
883
877884/****************************************************************
878885 *
879886 * M58817 Speech
r3333r3334
9981005
9991006static READ8_DEVICE_HANDLER( dkong_tune_r )
10001007{
1001   const device_config *devvp2 = devtag_get_device(device->machine, LATCH8, "virtual_p2");
1002   UINT8 *snd_rom = memory_region(device->machine, "sound");
1003   UINT8 page = latch8_r(devvp2,0) & 0x47;
1008   dkong_state *state = device->machine->driver_data;
1009   UINT8 page = latch8_r(state->dev_vp2,0) & 0x47;
10041010
10051011   if ( page & 0x40 )
10061012   {
r3333r3334
10091015   else
10101016   {
10111017      /* printf("rom access at pc = %4x\n",activecpu_get_pc()); */
1012      return (snd_rom[0x1000+(page & 7)*256+offset]);
1018      return (state->snd_rom[0x1000+(page & 7)*256+offset]);
10131019   }
10141020}
10151021
r3333r3334
10991105static const nes_interface nes_interface_1 = { "n2a03a" };
11001106static const nes_interface nes_interface_2 = { "n2a03b" };
11011107
1108
11021109/*************************************
11031110 *
11041111 *  Machine driver
r3333r3334
11071114
11081115MACHINE_DRIVER_START( dkong2b_audio )
11091116
1117   MDRV_SOUND_START( dkong )
1118
11101119   /* sound latches */
11111120
11121121   MDRV_LATCH8_ADD("ls175.3d") /* sound cmd latch */
src/mame/machine/cubocd32.c
r3333r3334
260260   /*E*/   "C2P"
261261};
262262
263const char* get_akiko_reg_name(int reg)
263static const char* get_akiko_reg_name(int reg)
264264{
265265   if (reg < 0xf )
266266   {
src/mame/machine/dc.c
r3333r3334
1616
1717#define DEBUG_SYSCTRL   (0)
1818#define DEBUG_MAPLE   (0)
19#define DEBUG_MAPLE_REGS   (0)
1920
2021#if DEBUG_SYSCTRL
2122static const char *const sysctrl_names[] =
r3333r3334
289290
290291   reg = decode_reg_64(offset, mem_mask, &shift);
291292
292   #if DEBUG_MAPLE
293   #if DEBUG_MAPLE_REGS
293294   mame_printf_verbose("MAPLE:  Unmapped read %08x\n", 0x5f6c00+reg*4);
294295   #endif
295296   return (UINT64)maple_regs[reg] << shift;
r3333r3334
313314   dat = (UINT32)(data >> shift);
314315   old = maple_regs[reg];
315316
316   #if DEBUG_MAPLE
317   #if DEBUG_MAPLE_REGS
317318   mame_printf_verbose("MAPLE: [%08x=%x] write %llx to %x (reg %x: %s), mask %llx\n", 0x5f6c00+reg*4, dat, data >> shift, offset, reg, maple_names[reg], mem_mask);
318319   #endif
319320
r3333r3334
353354
354355               if (pattern == 0)
355356               {
357                  if (port > 0)
358                     buff[0]=0xffffffff;
356359                  switch (command)
357360                  {
358361                     case 1:
r3333r3334
398401                        cpunum_set_info_ptr(0,CPUINFO_PTR_SH4_EXTERNAL_DDT_DMA,&ddtdata);
399402
400403                        subcommand = buff[0] & 0xff;
404                        #if DEBUG_MAPLE
405                        mame_printf_verbose("MAPLE: transfer command %d port %d subcommand %d\n", command, port, subcommand);
406                        #endif
401407                        if (subcommand == 3) // read data
402408                        {
403409                           for (a=0;a < 0x80;a+=4)
r3333r3334
594600                        #if DEBUG_MAPLE
595601                        mame_printf_verbose("MAPLE: unknown transfer command %d port %d\n", command, port);
596602                        #endif
603                        ddtdata.length=1;
604                        buff[0]=0xffffffff;
597605                        break;
598606                  }
599607               }
r3333r3334
609617               // skip fixed packet header
610618               dat += 8;
611619               // skip transfer data
612               dat += ((command & 0xff) + 1) * 4;
620               dat += (length + 1) * 4;
613621            } // do transfers
614622            maple_regs[reg] = 0;
615623         }
624         else
625         {
626            #if DEBUG_MAPLE
627            mame_printf_verbose("MAPLE: hardware trigger not supported yet\n");
628            #endif
629         }
616630      }
617631      break;
618632   }
src/mame/machine/namcos1.c
r3333r3334
12111211}
12121212
12131213// Inputs are multiplexed, somehow
1214READ8_HANDLER( tankfrc4_input_r )
1214static READ8_HANDLER( tankfrc4_input_r )
12151215{
12161216
12171217   switch (offset)
src/mame/machine/neoprot.c
r3333r3334
33    Neo-Geo hardware protection devices
44
55    unknown devices
6        ssideki, fatfury2, fatfury3, kof98, mslugx
6        ssideki, fatfury2, kof98 (some versions), mslugx
77
88    SMA chip
99        kof99, garou, garouo, mslug3, kof2002
src/mame/machine/neocrypt.c
r3333r3334
1313    NeoGeo 'C' (Graphics) Rom encryption
1414      CMC42 and CMC50 protection chips
1515      Also contains 'S' (Text Layer) data on these games
16      M1 (Z80) rom is also encrypted for CMC50: NOT DECRYPTED
16      M1 (Z80) rom is also encrypted for CMC50
1717
18     the M1 roms contain some additional data at 0xf800.  Some of this
19     is said to be related to the C rom encryption.
20
1821      Later games use additional basic scrambling on top of the standard
1922      CMC scramble.
2023
r3333r3334
631634   address_0_7_xor =    kof2000_address_0_7_xor;
632635   neogeo_gfx_decrypt(machine, extra_xor);
633636   neogeo_sfix_decrypt(machine);
634
635   /* here I should also decrypt the sound ROM */
636637}
637638
638639
r3333r3334
665666   address_16_23_xor2 = kof2000_address_16_23_xor2;
666667   address_0_7_xor =    kof2000_address_0_7_xor;
667668   neogeo_gfx_decrypt(machine, extra_xor);
668
669   /* here I should also decrypt the sound ROM */
670669}
671670
672671
r3333r3334
13631362   }
13641363   free(buf);
13651364}
1365
1366
1367static const UINT8 m1_address_8_15_xor[256] =
1368{
1369        0x0a, 0x72, 0xb7, 0xaf, 0x67, 0xde, 0x1d, 0xb1, 0x78, 0xc4, 0x4f, 0xb5, 0x4b, 0x18, 0x76, 0xdd,
1370        0x11, 0xe2, 0x36, 0xa1, 0x82, 0x03, 0x98, 0xa0, 0x10, 0x5f, 0x3f, 0xd6, 0x1f, 0x90, 0x6a, 0x0b,
1371        0x70, 0xe0, 0x64, 0xcb, 0x9f, 0x38, 0x8b, 0x53, 0x04, 0xca, 0xf8, 0xd0, 0x07, 0x68, 0x56, 0x32,
1372        0xae, 0x1c, 0x2e, 0x48, 0x63, 0x92, 0x9a, 0x9c, 0x44, 0x85, 0x41, 0x40, 0x09, 0xc0, 0xc8, 0xbf,
1373        0xea, 0xbb, 0xf7, 0x2d, 0x99, 0x21, 0xf6, 0xba, 0x15, 0xce, 0xab, 0xb0, 0x2a, 0x60, 0xbc, 0xf1,
1374        0xf0, 0x9e, 0xd5, 0x97, 0xd8, 0x4e, 0x14, 0x9d, 0x42, 0x4d, 0x2c, 0x5c, 0x2b, 0xa6, 0xe1, 0xa7,
1375        0xef, 0x25, 0x33, 0x7a, 0xeb, 0xe7, 0x1b, 0x6d, 0x4c, 0x52, 0x26, 0x62, 0xb6, 0x35, 0xbe, 0x80,
1376        0x01, 0xbd, 0xfd, 0x37, 0xf9, 0x47, 0x55, 0x71, 0xb4, 0xf2, 0xff, 0x27, 0xfa, 0x23, 0xc9, 0x83,
1377        0x17, 0x39, 0x13, 0x0d, 0xc7, 0x86, 0x16, 0xec, 0x49, 0x6f, 0xfe, 0x34, 0x05, 0x8f, 0x00, 0xe6,
1378        0xa4, 0xda, 0x7b, 0xc1, 0xf3, 0xf4, 0xd9, 0x75, 0x28, 0x66, 0x87, 0xa8, 0x45, 0x6c, 0x20, 0xe9,
1379        0x77, 0x93, 0x7e, 0x3c, 0x1e, 0x74, 0xf5, 0x8c, 0x3e, 0x94, 0xd4, 0xc2, 0x5a, 0x06, 0x0e, 0xe8,
1380        0x3d, 0xa9, 0xb2, 0xe3, 0xe4, 0x22, 0xcf, 0x24, 0x8e, 0x6b, 0x8a, 0x8d, 0x84, 0x4a, 0xd2, 0x91,
1381        0x88, 0x79, 0x57, 0xa5, 0x0f, 0xcd, 0xb9, 0xac, 0x3b, 0xaa, 0xb3, 0xd1, 0xee, 0x31, 0x81, 0x7c,
1382        0xd7, 0x89, 0xd3, 0x96, 0x43, 0xc5, 0xc6, 0xc3, 0x69, 0x7f, 0x46, 0xdf, 0x30, 0x5b, 0x6e, 0xe5,
1383        0x08, 0x95, 0x9b, 0xfb, 0xb8, 0x58, 0x0c, 0x61, 0x50, 0x5d, 0x3a, 0xa2, 0x29, 0x12, 0xfc, 0x51,
1384        0x7d, 0x1a, 0x02, 0x65, 0x54, 0x5e, 0x19, 0xcc, 0xdc, 0xdb, 0x73, 0xed, 0xad, 0x59, 0x2f, 0xa3,
1385};
1386
1387static const UINT8 m1_address_0_7_xor[256] =
1388{
1389        0xf4, 0xbc, 0x02, 0xf7, 0x2c, 0x3d, 0xe8, 0xd9, 0x50, 0x62, 0xec, 0xbd, 0x53, 0x73, 0x79, 0x61,
1390        0x00, 0x34, 0xcf, 0xa2, 0x63, 0x28, 0x90, 0xaf, 0x44, 0x3b, 0xc5, 0x8d, 0x3a, 0x46, 0x07, 0x70,
1391        0x66, 0xbe, 0xd8, 0x8b, 0xe9, 0xa0, 0x4b, 0x98, 0xdc, 0xdf, 0xe2, 0x16, 0x74, 0xf1, 0x37, 0xf5,
1392        0xb7, 0x21, 0x81, 0x01, 0x1c, 0x1b, 0x94, 0x36, 0x09, 0xa1, 0x4a, 0x91, 0x30, 0x92, 0x9b, 0x9a,
1393        0x29, 0xb1, 0x38, 0x4d, 0x55, 0xf2, 0x56, 0x18, 0x24, 0x47, 0x9d, 0x3f, 0x80, 0x1f, 0x22, 0xa4,
1394        0x11, 0x54, 0x84, 0x0d, 0x25, 0x48, 0xee, 0xc6, 0x59, 0x15, 0x03, 0x7a, 0xfd, 0x6c, 0xc3, 0x33,
1395        0x5b, 0xc4, 0x7b, 0x5a, 0x05, 0x7f, 0xa6, 0x40, 0xa9, 0x5d, 0x41, 0x8a, 0x96, 0x52, 0xd3, 0xf0,
1396        0xab, 0x72, 0x10, 0x88, 0x6f, 0x95, 0x7c, 0xa8, 0xcd, 0x9c, 0x5f, 0x32, 0xae, 0x85, 0x39, 0xac,
1397        0xe5, 0xd7, 0xfb, 0xd4, 0x08, 0x23, 0x19, 0x65, 0x6b, 0xa7, 0x93, 0xbb, 0x2b, 0xbf, 0xb8, 0x35,
1398        0xd0, 0x06, 0x26, 0x68, 0x3e, 0xdd, 0xb9, 0x69, 0x2a, 0xb2, 0xde, 0x87, 0x45, 0x58, 0xff, 0x3c,
1399        0x9e, 0x7d, 0xda, 0xed, 0x49, 0x8c, 0x14, 0x8e, 0x75, 0x2f, 0xe0, 0x6e, 0x78, 0x6d, 0x20, 0xd2,
1400        0xfa, 0x2d, 0x51, 0xcc, 0xc7, 0xe7, 0x1d, 0x27, 0x97, 0xfc, 0x31, 0xdb, 0xf8, 0x42, 0xe3, 0x99,
1401        0x5e, 0x83, 0x0e, 0xb4, 0x2e, 0xf6, 0xc0, 0x0c, 0x4c, 0x57, 0xb6, 0x64, 0x0a, 0x17, 0xa3, 0xc1,
1402        0x77, 0x12, 0xfe, 0xe6, 0x8f, 0x13, 0x71, 0xe4, 0xf9, 0xad, 0x9f, 0xce, 0xd5, 0x89, 0x7e, 0x0f,
1403        0xc2, 0x86, 0xf3, 0x67, 0xba, 0x60, 0x43, 0xc9, 0x04, 0xb3, 0xb0, 0x1e, 0xb5, 0xc8, 0xeb, 0xa5,
1404        0x76, 0xea, 0x5c, 0x82, 0x1a, 0x4f, 0xaa, 0xca, 0xe1, 0x0b, 0x4e, 0xcb, 0x6a, 0xef, 0xd1, 0xd6,
1405};
1406
1407
1408int m1_address_scramble_inv(int address, UINT16 key)
1409{
1410   int block;
1411   int aux;
1412
1413   const int p1[8][16] = {
1414      {8,4,5,6,15,14,12,3,7,13,2,10,9,11,1,0},
1415      {13,1,6,7,10,8,14,0,2,5,12,3,15,9,11,4},
1416      {9,7,10,3,8,11,1,5,0,15,4,13,14,12,2,6},
1417      {10,12,0,4,5,15,9,7,1,3,11,6,13,8,14,2},
1418      {14,0,13,5,9,12,2,10,6,8,7,15,11,1,4,3},
1419      {5,11,7,2,3,13,8,4,12,6,14,0,10,15,9,1},
1420      {11,6,15,10,14,1,4,13,3,9,0,8,12,2,7,5},
1421      {3,14,4,1,6,10,15,2,11,0,9,7,5,13,8,12},
1422   };
1423
1424   block = (address>>16)&7;
1425   aux = address&0xffff;
1426
1427   aux = BITSWAP16(aux, 14,13,10,9,7,5,3,1,15,12,11,8,6,4,2,0);
1428   aux ^= m1_address_8_15_xor[aux&0xff]<<8;
1429   aux ^= m1_address_0_7_xor[(aux>>8)&0xff];
1430   aux = BITSWAP16(aux,
1431      p1[block][15],p1[block][14],p1[block][13],p1[block][12],
1432      p1[block][11],p1[block][10],p1[block][9],p1[block][8],
1433      p1[block][7],p1[block][6],p1[block][5],p1[block][4],
1434      p1[block][3],p1[block][2],p1[block][1],p1[block][0]);
1435   aux ^= key;
1436
1437   return (block<<16)|aux;
1438}
1439
1440
1441/* The CMC50 hardware does a checksum of the first 64kb of the M1 rom,
1442   ,and uses this checksum as the basis of the key with which to decrypt
1443   the rom */
1444
1445static UINT16 generate_cs16(UINT8 *rom, int size)
1446{
1447    UINT16 cs16;
1448    int i;
1449    cs16 = 0x0000;
1450    for (i=0;i<size;i++ )
1451    {
1452        cs16 += rom[i];
1453    }
1454    return cs16&0xFFFF;
1455}
1456
1457
1458int m1_address_scramble(int address, UINT16 key)
1459{
1460   int block;
1461   int aux;
1462
1463   const int p1[8][16] = {
1464      {15,14,10,7,1,2,3,8,0,12,11,13,6,9,5,4},
1465      {7,1,8,11,15,9,2,3,5,13,4,14,10,0,6,12},
1466      {8,6,14,3,10,7,15,1,4,0,2,5,13,11,12,9},
1467      {2,8,15,9,3,4,11,7,13,6,0,10,1,12,14,5},
1468      {1,13,6,15,14,3,8,10,9,4,7,12,5,2,0,11},
1469      {11,15,3,4,7,0,9,2,6,14,12,1,8,5,10,13},
1470      {10,5,13,8,6,15,1,14,11,9,3,0,12,7,4,2},
1471      {9,3,7,0,2,12,4,11,14,10,5,8,15,13,1,6},
1472   };
1473
1474   block = (address>>16)&7;
1475   aux = address&0xffff;
1476
1477        aux ^= BITSWAP16(key,12,0,2,4,8,15,7,13,10,1,3,6,11,9,14,5);
1478   aux = BITSWAP16(aux,
1479      p1[block][15],p1[block][14],p1[block][13],p1[block][12],
1480      p1[block][11],p1[block][10],p1[block][9],p1[block][8],
1481      p1[block][7],p1[block][6],p1[block][5],p1[block][4],
1482      p1[block][3],p1[block][2],p1[block][1],p1[block][0]);
1483        aux ^= m1_address_0_7_xor[(aux>>8)&0xff];
1484   aux ^= m1_address_8_15_xor[aux&0xff]<<8;
1485   aux = BITSWAP16(aux, 7,15,14,6,5,13,12,4,11,3,10,2,9,1,8,0);
1486
1487   return (block<<16)|aux;
1488}
1489
1490
1491void neogeo_cmc50_m1_decrypt(running_machine *machine)
1492{
1493   UINT8* rom = memory_region(machine, "audiocrypt");
1494   size_t rom_size = 0x80000;
1495   UINT8* rom2 = memory_region(machine, "audio");
1496
1497   UINT8* buffer = malloc_or_die(rom_size);
1498
1499   UINT32 i;
1500
1501   UINT16 key=generate_cs16(rom,0x10000);
1502
1503   //printf("key %04x\n",key);
1504
1505   for (i=0; i<rom_size; i++)
1506   {
1507      buffer[i] = rom[m1_address_scramble(i,key)];
1508   }
1509
1510   memcpy(rom,buffer,rom_size);
1511
1512   memcpy(rom2,rom,0x10000);
1513   memcpy(rom2+0x10000,rom,0x80000);
1514
1515   #if 0
1516   {
1517      FILE *fp;
1518      const char *gamename = machine->gamedrv->name;
1519      char filename[256];
1520      sprintf(filename, "%s_m1.dump", gamename);
1521
1522      fp=fopen(filename, "w+b");
1523      if (fp)
1524      {
1525         fwrite(rom, rom_size, 1, fp);
1526         fclose(fp);
1527      }
1528   }
1529   #endif
1530
1531
1532   #if 0
1533   {
1534      FILE *fp;
1535      const char *gamename = machine->gamedrv->name;
1536      char filename[256];
1537      sprintf(filename, "%s_m1extra.dump", gamename);
1538
1539      fp=fopen(filename, "w+b");
1540      if (fp)
1541      {
1542         fwrite(&rom[0xf800], 0x800, 1, fp);
1543         fclose(fp);
1544      }
1545   }
1546   #endif
1547
1548}
src/mame/machine/psx.c
r3333r3334
3535UINT32 *g_p_n_psxram;
3636size_t g_n_psxramsize;
3737
38#ifdef UNUSED_FUNCTON
38#ifdef UNUSED_FUNCTION
3939INLINE void psxwriteword( UINT32 n_address, UINT16 n_data )
4040{
4141   *( (UINT16 *)( (UINT8 *)g_p_n_psxram + WORD_XOR_LE( n_address ) ) ) = n_data;
src/mame/machine/nb1413m3.c
r3333r3334
2020
2121
2222int nb1413m3_type;
23int nb1413m3_sndromregion;
23//int nb1413m3_sndromregion;
2424const char * nb1413m3_sndromrgntag;
2525int nb1413m3_sndrombank1;
2626int nb1413m3_sndrombank2;
src/mame/mamedriv.c
r3333r3334
861861   DRIVER( propcycl )   /* (c) 1996 */
862862
863863   /* Namco System 23 */
864   DRIVER( rapidrvr )   /* (c) 1997 */
864865   DRIVER( timecrs2 )   /* (c) 1997 */
865   DRIVER( gp500 )      /* (c) 1999 */
866   DRIVER( timcrs2b )   /* (c) 1997 */
867   DRIVER( 500gp )      /* (c) 1999 */
866868   DRIVER( finfurl2 )   /* (c) 1999 */
867869   DRIVER( finfrl2j )   /* (c) 1999 */
868870
r3333r3334
42254227   DRIVER( firetrap )   /* (c) 1986 Data East USA (US) */
42264228   DRIVER( firetpbl )   /* bootleg */
42274229   DRIVER( metlclsh )   /* (c) 1985 Data East */
4230   DRIVER( chanbara )   /* (c) 1985 Data East */
42284231   DRIVER( brkthru )   /* (c) 1986 Data East USA (US) */
42294232   DRIVER( brkthruj )   /* (c) 1986 Data East Corporation (Japan) */
42304233   DRIVER( forcebrk )   /* (c) 1986 Data East Corporation (Japan) */
r3333r3334
71427145   /* Yun Sung games */
71437146   DRIVER( paradise )   /* (c) >1994 Yun Sung */
71447147   DRIVER( paradlx )   /* (c) >1994 Yun Sung */
7148   DRIVER( para2dx )   /* (c) >1994 Yun Sung */
71457149   DRIVER( tgtball )   /* (c) 1995 Yun Sung */
71467150   DRIVER( tgtballa )   /* (c) 1995 Yun Sung */
71477151   DRIVER( torus )      /* (c) 1996 Yun Sung */
r3333r3334
82298233   DRIVER( jongkyo )   /* (c) 1985 Kiwako */
82308234   DRIVER( gtipoker )   /* (c) 1983 GTI Inc */
82318235   DRIVER( gamecstl )   /* MAME based bootleg */
8236   DRIVER( gamecst2 )   /* MAME based bootleg, version 2.613 */
82328237   DRIVER( drw80pkr )   /* (c) 1983 IGT */
82338238   DRIVER( blazlaz )   /* (c) 1989 Hudson Soft */
82348239   DRIVER( paranoia )   /* (c) 1990 Naxat Soft */
src/mame/includes/dkong.h
r3333r3334
7878   UINT8   hardware_type;
7979
8080   /* sound state */
81   const UINT8 *         snd_rom;
82   const device_config *   dev_vp2;      /* virtual port 2 */
8183
8284   /* video state */
8385   tilemap *bg_tilemap;
r3333r3334
9193   size_t          sprite_ram_size;
9294
9395   /* radar scope */
96
97   UINT8 *         gfx4;
98   UINT8 *         gfx3;
99   int            gfx3_len;
100
94101   UINT8   sig30Hz;
95102   UINT8   grid_sig;
96103   UINT8   rflip_sig;
src/mame/includes/neogeo.h
r3333r3334
6767void neo_pcm2_snk_1999(running_machine *machine, int value);
6868void neo_pcm2_swap(running_machine *machine, int value);
6969
70void neogeo_cmc50_m1_decrypt(running_machine *machine);
7071
7172/*----------- defined in machine/neoprot.c -----------*/
7273
src/mame/includes/dc.h
r3333r3334
113113#define REVISION      ((0x005F8004-0x005F8000)/4)
114114#define SOFTRESET      ((0x005F8008-0x005F8000)/4)
115115#define STARTRENDER      ((0x005F8014-0x005F8000)/4)
116#define PARAM_BASE      ((0x005F8020-0x005F8000)/4)
116117#define VO_BORDER_COL   ((0x005F8040-0x005F8000)/4)
118#define FB_W_CTRL      ((0x005F8048-0x005F8000)/4)
119#define FB_W_LINESTRIDE   ((0x005F804c-0x005F8000)/4)
120#define FB_R_SOF1      ((0x005F8050-0x005F8000)/4)
121#define FB_R_SOF2      ((0x005F8054-0x005F8000)/4)
122#define FB_R_SIZE      ((0x005F805c-0x005F8000)/4)
123#define FB_W_SOF1      ((0x005F8060-0x005F8000)/4)
124#define FB_W_SOF2      ((0x005F8064-0x005F8000)/4)
117125#define VO_CONTROL      ((0x005F80E8-0x005F8000)/4)
118126#define PAL_RAM_CTRL   ((0x005F8108-0x005F8000)/4)
119127#define ISP_BACKGND_T   ((0x005F808C-0x005F8000)/4)
r3333r3334
131139#define TA_NEXT_OPB      ((0x005F8134-0x005F8000)/4)
132140#define TA_ITP_CURRENT   ((0x005F8138-0x005F8000)/4)
133141
142/* ------------- normal interrupts ------------- */
134143#define IST_EOR_VIDEO   0x00000001
135144#define IST_EOR_ISP   0x00000002
136145#define IST_EOR_TSP   0x00000004
r3333r3334
154163#define IST_DMA_SORT   0x00100000
155164#define IST_G1G2EXTSTAT 0x40000000
156165#define IST_ERROR   0x80000000
166/* ------------ external interrupts ------------ */
167#define IST_EXT_EXTERNAL   0x00000008
168#define IST_EXT_MODEM   0x00000004
169#define IST_EXT_AICA   0x00000002
170#define IST_EXT_GDROM   0x00000001
157171
158172#endif
src/mame/mame.mak
r3333r3334
628628   $(DRIVERS)/boogwing.o $(VIDEO)/boogwing.o \
629629   $(DRIVERS)/brkthru.o $(VIDEO)/brkthru.o \
630630   $(DRIVERS)/btime.o $(MACHINE)/btime.o $(VIDEO)/btime.o \
631   $(DRIVERS)/chanbara.o \
631632   $(DRIVERS)/bwing.o $(VIDEO)/bwing.o \
632633   $(DRIVERS)/cbuster.o $(VIDEO)/cbuster.o \
633634   $(DRIVERS)/cninja.o $(VIDEO)/cninja.o \
src/mame/video/hd63484.c
r3333r3334
2424static UINT16 readfifo;
2525UINT16 *HD63484_ram;
2626UINT16 HD63484_reg[256/2];
27UINT16 pattern[16];
27static UINT16 pattern[16];
2828static int org,org_dpd,rwp;
2929static UINT16 cl0,cl1,ccmp,edg,mask,ppy,pzcy,ppx,pzcx,psy,psx,pey,pzy,pex,pzx,xmin,ymin,xmax,ymax,rwp_dn;
3030static INT16 cpx,cpy;
r3333r3334
790790   }
791791}
792792
793void line(INT16 sx, INT16 sy, INT16 ex, INT16 ey, INT16 col)
793static void line(INT16 sx, INT16 sy, INT16 ex, INT16 ey, INT16 col)
794794{
795795         INT16 ax,ay;
796796
r3333r3334
841841
842842}
843843
844void paint(int sx, int sy, int col)
844static void paint(int sx, int sy, int col)
845845{
846846   int getpixel;
847847   dot(sx,sy,0,col);
src/mame/video/system1.c
r3333r3334
178178}
179179
180180
181#ifdef UNUSED_FUNCTON
181#ifdef UNUSED_FUNCTION
182182INLINE int get_sprite_bottom_y(int spr_number)
183183{
184184   return  spriteram[0x10 * spr_number + SPR_Y_BOTTOM];
src/mame/video/namcofl.c
r3333r3334
1414/* nth_word32 is a general-purpose utility function, which allows us to
1515 * read from 32-bit aligned memory as if it were an array of 16 bit words.
1616 */
17#ifdef UNUSED_FUNCTON
17#ifdef UNUSED_FUNCTION
1818INLINE UINT16
1919nth_word32( const UINT32 *source, int which )
2020{
r3333r3334
3434/* nth_byte32 is a general-purpose utility function, which allows us to
3535 * read from 32-bit aligned memory as if it were an array of bytes.
3636 */
37#ifdef UNUSED_FUNCTON
37#ifdef UNUSED_FUNCTION
3838INLINE UINT8
3939nth_byte32( const UINT32 *pSource, int which )
4040{
src/mame/video/midzeus.c
r3333r3334
202202   }
203203}
204204
205#ifdef UNUSED_FUNCTON
205#ifdef UNUSED_FUNCTION
206206INLINE void waveram_plot_check_depth_nowrite(int y, int x, UINT16 color, UINT16 depth)
207207{
208208   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
src/mame/video/dkong.c
r3333r3334
817817   UINT16          *pixel;
818818
819819   if (state->hardware_type == HARDWARE_TRS01)
820      htable = memory_region(machine, "gfx4");
820      htable = state->gfx4;
821821
822822   y = cliprect->min_y;
823823   while (y <= cliprect->max_y)
r3333r3334
840840static void radarscp_scanline(running_machine *machine, int scanline)
841841{
842842   dkong_state *state = machine->driver_data;
843   const UINT8 *table = memory_region(machine, "gfx3");
844   int       table_len = memory_region_length(machine, "gfx3");
843   const UINT8 *table = state->gfx3;
844   int       table_len = state->gfx3_len;
845845   int          x,y,offset;
846846   UINT16          *pixel;
847847   static int      counter=0;
r3333r3334
950950   {
951951      case HARDWARE_TRS02:
952952         state->bg_bits = video_screen_auto_bitmap_alloc(machine->primary_screen);
953         state->gfx3 = memory_region(machine, "gfx3");
954         state->gfx3_len = memory_region_length(machine, "gfx3");
953955          /* fall through */
954956      case HARDWARE_TKG04:
955957      case HARDWARE_TKG02:
r3333r3334
961963         tilemap_set_scrolldx(state->bg_tilemap, 0, 128);
962964
963965         state->bg_bits = video_screen_auto_bitmap_alloc(machine->primary_screen);
966         state->gfx4 = memory_region(machine, "gfx4");
967         state->gfx3 = memory_region(machine, "gfx3");
968         state->gfx3_len = memory_region_length(machine, "gfx3");
969
964970         break;
965971      default:
966972         fatalerror("Invalid hardware type in dkong_video_start");
src/mame/video/hyprduel.c
r3333r3334
126126
127127
128128/* 8x8x4 tiles only */
129#ifdef UNUSED_FUNCTON
129#ifdef UNUSED_FUNCTION
130130INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,int layer,UINT16 *vram)
131131{
132132   UINT16 code;
r3333r3334
204204
205205/* 16x16x4 or 16x16x8 tiles. It's the tile's color that decides: if its low 4
206206   bits are high ($f,$1f,$2f etc) the tile is 8bpp, otherwise it's 4bpp */
207#ifdef UNUSED_FUNCTON
207#ifdef UNUSED_FUNCTION
208208INLINE void get_tile_info_16x16_8bit(running_machine *machine,tile_data *tileinfo,int tile_index,int layer,UINT16 *vram)
209209{
210210   UINT16 code;
src/mame/video/leland.c
r3333r3334
4040static UINT16 xscroll;
4141static UINT16 yscroll;
4242static UINT8 gfxbank;
43static UINT16 last_scanline;
4344
45static emu_timer *scanline_timer;
4446
47/*************************************
48 *
49 *  Scanline callback
50 *
51 *************************************/
4552
53static TIMER_CALLBACK( scanline_callback )
54{
55   int scanline = param;
56
57   /* update the DACs */
58
59   if (!(leland_dac_control & 0x01))
60      leland_dac_update(0, leland_video_ram[(last_scanline) * 256 + 160]);
61
62   if (!(leland_dac_control & 0x02))
63      leland_dac_update(1, leland_video_ram[(last_scanline) * 256 + 161]);
64
65   last_scanline = scanline;
66
67   scanline = (scanline+1) % 256;
68
69   if (scanline == 0)
70   {
71      /* turn off the DACs at the start of the frame */
72      leland_dac_control = 3;
73   }
74
75   /* come back at the next appropriate scanline */
76   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline);
77}
78
79
4680/*************************************
4781 *
4882 *  Start video hardware
r3333r3334
5690
5791   /* reset videoram */
5892   memset(leland_video_ram, 0, VRAM_SIZE);
93
94   /* scanline timer */
95   scanline_timer = timer_alloc(scanline_callback, NULL);
96   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
97
5998}
6099
61100
r3333r3334
369408
370409/*************************************
371410 *
372 *  Resets the DAC
373 *
374 *************************************/
375
376static TIMER_CALLBACK( dac_reset )
377{
378   /* turn off the DACs at the start of the frame */
379   leland_dac_control = 3;
380}
381
382
383
384/*************************************
385 *
386411 *  ROM-based refresh routine
387412 *
388413 *************************************/
r3333r3334
442467         *dst++ = pen;
443468      }
444469
445      /* also update the DACs */
446      if (!(leland_dac_control & 0x01))
447         leland_dac_update(0, leland_video_ram[y * 256 + 160]);
448
449      if (!(leland_dac_control & 0x02))
450         leland_dac_update(1, leland_video_ram[y * 256 + 161]);
451470   }
452471
453   /* set a timer to go off at the top of the frame */
454   if (cliprect->max_y == video_screen_get_visible_area(screen)->max_y)
455      timer_set(video_screen_get_time_until_pos(screen, 0, 0), NULL, 0, dac_reset);
456
457472   return 0;
458473}
459474
r3333r3334
517532
518533         *dst++ = pen;
519534      }
520
521      /* also update the DACs */
522      if (!(leland_dac_control & 0x01))
523         leland_dac_update(0, leland_video_ram[y * 256 + 160]);
524
525      if (!(leland_dac_control & 0x02))
526         leland_dac_update(1, leland_video_ram[y * 256 + 161]);
527535   }
528536
529   /* set a timer to go off at the top of the frame */
530   if (cliprect->max_y == video_screen_get_visible_area(screen)->max_y)
531      timer_set(video_screen_get_time_until_pos(screen, 0, 0), NULL, 0, dac_reset);
532
533537   return 0;
534538}
535539
src/mame/video/dc.c
r3333r3334
3030static emu_timer *vbout_timer;
3131
3232typedef struct {
33   int tafifo_pos, tafifo_mask, tafifo_vertexwords, tafifo_listtype;
34   int start_render_received;
35   int listtype_used;
36   int alloc_ctrl_OPB_Mode, alloc_ctrl_PT_OPB, alloc_ctrl_TM_OPB, alloc_ctrl_T_OPB, alloc_ctrl_OM_OPB, alloc_ctrl_O_OPB;
3733   struct testsprites
3834   {
3935      int positionx, positiony;
r3333r3334
5147      int endofstrip;
5248   } showvertices[65536];
5349#endif
54   int testsprites_size, toerasesprites, testvertices_size;
50   int testsprites_size, testsprites_toerase, testvertices_size;
51   UINT32 ispbase;
52   UINT32 fbwsof1;
53   UINT32 fbwsof2;
54   int busy;
55   int valid;
56} receiveddata;
57
58typedef struct {
59   int tafifo_pos, tafifo_mask, tafifo_vertexwords, tafifo_listtype;
60   int start_render_received;
61   int renderselect;
62   int listtype_used;
63   int alloc_ctrl_OPB_Mode, alloc_ctrl_PT_OPB, alloc_ctrl_TM_OPB, alloc_ctrl_T_OPB, alloc_ctrl_OM_OPB, alloc_ctrl_O_OPB;
64   receiveddata grab[4];
65   int grabsel;
66   int grabsellast;
5567   UINT32 paracontrol,paratype,endofstrip,listtype,global_paratype,parameterconfig;
5668   UINT32 groupcontrol,groupen,striplen,userclip;
5769   UINT32 objcontrol,shadow,volume,coltype,texture,offfset,gouraud,uv16bit;
r3333r3334
6173   UINT32 depthcomparemode,cullingmode,zwritedisable,cachebypass,dcalcctrl,volumeinstruction,mipmapped,vqcompressed,strideselect,paletteselector;
6274} pvrta_state;
6375
64pvrta_state state_ta;
76static pvrta_state state_ta;
6577
6678// register decode helper
6779INLINE int decode_reg_64(UINT32 offset, UINT64 mem_mask, UINT64 *shift)
r3333r3334
130142   }
131143
132144   #if DEBUG_PVRTA_REGS
133   mame_printf_verbose("PVRTA: [%08x] read %x @ %x (reg %x), mask %llx (PC=%x)\n", 0x5f8000+reg*4, pvrta_regs[reg], offset, reg, mem_mask, activecpu_get_pc());
145   if (reg != 0x43)
146      mame_printf_verbose("PVRTA: [%08x] read %x @ %x (reg %x), mask %llx (PC=%x)\n", 0x5f8000+reg*4, pvrta_regs[reg], offset, reg, mem_mask, activecpu_get_pc());
134147   #endif
135148   return (UINT64)pvrta_regs[reg] << shift;
136149}
r3333r3334
140153   int reg;
141154   UINT64 shift;
142155   UINT32 old,dat;
156   int a;
143157
144158   reg = decode_reg_64(offset, mem_mask, &shift);
145159   dat = (UINT32)(data >> shift);
r3333r3334
161175         mame_printf_verbose("pvr_ta_w:  Core Pipeline soft reset\n");
162176         #endif
163177         if (state_ta.start_render_received == 1)
178         {
179            for (a=0;a < 4;a++)
180               if (state_ta.grab[a].busy == 1)
181                  state_ta.grab[a].busy = 0;
164182            state_ta.start_render_received = 0;
183         }
165184      }
166185      if (dat & 4)
167186      {
r3333r3334
176195      mame_printf_verbose("  Region Array at %08x\n",pvrta_regs[REGION_BASE]);
177196      mame_printf_verbose("  ISP/TSP Parameters at %08x\n",pvrta_regs[PARAM_BASE]);
178197      #endif
179      state_ta.start_render_received=1;
198      // select buffer to draw using PARAM_BASE
199      for (a=0;a < 4;a++)
200      {
201         if ((state_ta.grab[a].ispbase == pvrta_regs[PARAM_BASE]) && (state_ta.grab[a].valid == 1) && (state_ta.grab[a].busy == 0))
202         {
203            state_ta.grab[a].busy = 1;
204            state_ta.renderselect = a;
205            state_ta.start_render_received=1;
206            state_ta.grab[a].fbwsof1=pvrta_regs[FB_W_SOF1];
207            state_ta.grab[a].fbwsof2=pvrta_regs[FB_W_SOF2];
208            break;
209         }
210      }
211      if (a != 4)
212         break;
213      assert_always(0, "TA grabber error!\n");
180214      break;
181215   case TA_LIST_INIT:
182216      state_ta.tafifo_pos=0;
183217      state_ta.tafifo_mask=7;
184218      state_ta.tafifo_vertexwords=8;
185219      state_ta.tafifo_listtype= -1;
186      state_ta.toerasesprites=1;
187220   #if DEBUG_PVRTA
188221      mame_printf_verbose("TA_OL_BASE       %08x TA_OL_LIMIT  %08x\n", pvrta_regs[TA_OL_BASE], pvrta_regs[TA_OL_LIMIT]);
189222      mame_printf_verbose("TA_ISP_BASE      %08x TA_ISP_LIMIT %08x\n", pvrta_regs[TA_ISP_BASE], pvrta_regs[TA_ISP_LIMIT]);
r3333r3334
199232      state_ta.alloc_ctrl_OM_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 4) & 3)) & 0x38;
200233      state_ta.alloc_ctrl_O_OPB = (4 << ((pvrta_regs[TA_ALLOC_CTRL] >> 0) & 3)) & 0x38;
201234      state_ta.listtype_used |= (1+4);
235      // use TA_ISP_BASE and select buffer for grab data
236      state_ta.grabsel = -1;
237      // try to find already used buffer but not busy
238      for (a=0;a < 4;a++)
239      {
240         if ((state_ta.grab[a].ispbase == pvrta_regs[TA_ISP_BASE]) && (state_ta.grab[a].busy == 0) && (state_ta.grab[a].valid == 1))
241         {
242            state_ta.grabsel=a;
243            break;
244         }
245      }
246      // try a buffer not used yet
247      if (state_ta.grabsel < 0)
248      {
249         for (a=0;a < 4;a++)
250         {
251            if (state_ta.grab[a].valid == 0)
252            {
253               state_ta.grabsel=a;
254               break;
255            }
256         }
257      }
258      // find a non busy buffer starting from the last one used
259      if (state_ta.grabsel < 0)
260      {
261         for (a=0;a < 3;a++)
262         {
263            if (state_ta.grab[(state_ta.grabsellast+1+a) & 3].busy == 0)
264            {
265               state_ta.grabsel=a;
266               break;
267            }
268         }
269      }
270      if (state_ta.grabsel < 0)
271         assert_always(0, "TA grabber error!\n");
272      state_ta.grabsellast=state_ta.grabsel;
273      state_ta.grab[state_ta.grabsel].ispbase=pvrta_regs[TA_ISP_BASE];
274      state_ta.grab[state_ta.grabsel].busy=0;
275      state_ta.grab[state_ta.grabsel].valid=1;
276      state_ta.grab[state_ta.grabsel].testsprites_size=0;
277      state_ta.grab[state_ta.grabsel].testvertices_size=0;
202278      break;
203279   case TA_LIST_CONT:
204280   #if DEBUG_PVRTA
r3333r3334
210286   }
211287
212288   #if DEBUG_PVRTA_REGS
213   mame_printf_verbose("PVRTA: [%08x=%x] write %llx to %x (reg %x %x), mask %llx\n", 0x5f8000+reg*4, dat, data>>shift, offset, reg, (reg*4)+0x8000, mem_mask);
289   if ((reg != 0x14) && (reg != 0x15))
290      mame_printf_verbose("PVRTA: [%08x=%x] write %llx to %x (reg %x %x), mask %llx\n", 0x5f8000+reg*4, dat, data>>shift, offset, reg, (reg*4)+0x8000, mem_mask);
214291   #endif
215292}
216293
r3333r3334
223300      tafifo_buff[state_ta.tafifo_pos]=(UINT32)data;
224301      tafifo_buff[state_ta.tafifo_pos+1]=(UINT32)(data >> 32);
225302      #if DEBUG_FIFO_POLY
226      mame_printf_debug("ta_fifo_poly_w:  Unmapped write64 %08x = %llx -> %08x %08x\n", 0x10000000+offset*8, data, tafifo_buff[tafifo_pos], tafifo_buff[tafifo_pos+1]);
303      mame_printf_debug("ta_fifo_poly_w:  Unmapped write64 %08x = %llx -> %08x %08x\n", 0x10000000+offset*8, data, tafifo_buff[state_ta.tafifo_pos], tafifo_buff[state_ta.tafifo_pos+1]);
227304      #endif
228305      state_ta.tafifo_pos += 2;
229306   }
r3333r3334
264341         state_ta.uv16bit=(state_ta.objcontrol >> 0) & 1;
265342      }
266343
267      if (state_ta.toerasesprites == 1)
268      {
269         state_ta.toerasesprites=0;
270         state_ta.testsprites_size=0;
271#if DEBUG_VERTICES
272         state_ta.testvertices_size=0;
273#endif
274      }
275
276344      // check if we need 8 words more
277345      if (state_ta.tafifo_mask == 7)
278346      {
r3333r3334
304372      }
305373
306374      // now we heve all the needed words
307      // interpret their meaning
375      // here we should generate the data for the various tiles
376      // for now, just interpret their meaning
308377      if (state_ta.paratype == 0)
309378      { // end of list
310379         #if DEBUG_PVRDLIST
r3333r3334
461530                  mame_printf_verbose(" A(%f,%f) B(%f,%f) C(%f,%f)\n",u2f(tafifo_buff[13] & 0xffff0000),u2f((tafifo_buff[13] & 0xffff) << 16),u2f(tafifo_buff[14] & 0xffff0000),u2f((tafifo_buff[14] & 0xffff) << 16),u2f(tafifo_buff[15] & 0xffff0000),u2f((tafifo_buff[15] & 0xffff) << 16));
462531                  #endif
463532/* test video start */
464                  state_ta.showsprites[state_ta.testsprites_size].positionx=u2f(tafifo_buff[1]);
465                  state_ta.showsprites[state_ta.testsprites_size].positiony=u2f(tafifo_buff[2]);
466                  state_ta.showsprites[state_ta.testsprites_size].sizex=u2f(tafifo_buff[4])-u2f(tafifo_buff[1]);
467                  state_ta.showsprites[state_ta.testsprites_size].sizey=u2f(tafifo_buff[8])-u2f(tafifo_buff[2]);
468                  state_ta.showsprites[state_ta.testsprites_size].u=u2f(tafifo_buff[13] & 0xffff0000);
469                  state_ta.showsprites[state_ta.testsprites_size].v=u2f((tafifo_buff[13] & 0xffff) << 16);
470                  state_ta.showsprites[state_ta.testsprites_size].du=u2f(tafifo_buff[14] & 0xffff0000)-state_ta.showsprites[state_ta.testsprites_size].u;
471                  state_ta.showsprites[state_ta.testsprites_size].dv=u2f((tafifo_buff[15] & 0xffff) << 16)-state_ta.showsprites[state_ta.testsprites_size].v;
472                  state_ta.showsprites[state_ta.testsprites_size].textureaddress=state_ta.textureaddress;
473                  state_ta.showsprites[state_ta.testsprites_size].texturesizex=state_ta.textureusize;
474                  state_ta.showsprites[state_ta.testsprites_size].texturesizey=state_ta.texturevsize;
475                  state_ta.showsprites[state_ta.testsprites_size].texturemode=state_ta.scanorder+state_ta.vqcompressed*2;
476                  state_ta.showsprites[state_ta.testsprites_size].texturesizes=state_ta.texturesizes;
477                  state_ta.showsprites[state_ta.testsprites_size].texturepf=state_ta.pixelformat;
478                  state_ta.showsprites[state_ta.testsprites_size].texturepalette=state_ta.paletteselector;
479                  state_ta.testsprites_size=state_ta.testsprites_size+1;
533                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].positionx=u2f(tafifo_buff[1]);
534                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].positiony=u2f(tafifo_buff[2]);
535                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].sizex=u2f(tafifo_buff[4])-u2f(tafifo_buff[1]);
536                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].sizey=u2f(tafifo_buff[8])-u2f(tafifo_buff[2]);
537                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].u=u2f(tafifo_buff[13] & 0xffff0000);
538                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].v=u2f((tafifo_buff[13] & 0xffff) << 16);
539                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].du=u2f(tafifo_buff[14] & 0xffff0000)-state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].u;
540                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].dv=u2f((tafifo_buff[15] & 0xffff) << 16)-state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].v;
541                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].textureaddress=state_ta.textureaddress;
542                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].texturesizex=state_ta.textureusize;
543                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].texturesizey=state_ta.texturevsize;
544                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].texturemode=state_ta.scanorder+state_ta.vqcompressed*2;
545                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].texturesizes=state_ta.texturesizes;
546                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].texturepf=state_ta.pixelformat;
547                  state_ta.grab[state_ta.grabsel].showsprites[state_ta.grab[state_ta.grabsel].testsprites_size].texturepalette=state_ta.paletteselector;
548                  state_ta.grab[state_ta.grabsel].testsprites_size=state_ta.grab[state_ta.grabsel].testsprites_size+1;
480549/* test video end */
481550               }
482551            }
r3333r3334
488557               mame_printf_verbose("\n");
489558               #endif
490559#if DEBUG_VERTICES
491               if (state_ta.testvertices_size < 65530)
560               if (state_ta.grab[state_ta.grabsel].testvertices_size <= 65530)
492561               {
493                  state_ta.showvertices[state_ta.testvertices_size].x=u2f(tafifo_buff[1]);
494                  state_ta.showvertices[state_ta.testvertices_size].y=u2f(tafifo_buff[2]);
495                  state_ta.showvertices[state_ta.testvertices_size].endofstrip=state_ta.endofstrip;
562                  state_ta.grab[state_ta.grabsel].showvertices[state_ta.grab[state_ta.grabsel].testvertices_size].x=u2f(tafifo_buff[1]);
563                  state_ta.grab[state_ta.grabsel].showvertices[state_ta.grab[state_ta.grabsel].testvertices_size].y=u2f(tafifo_buff[2]);
564                  state_ta.grab[state_ta.grabsel].showvertices[state_ta.grab[state_ta.grabsel].testvertices_size].endofstrip=state_ta.endofstrip;
496565               }
497               state_ta.testvertices_size=state_ta.testvertices_size+1;
566               state_ta.grab[state_ta.grabsel].testvertices_size=state_ta.grab[state_ta.grabsel].testvertices_size+1;
498567#endif
499568            }
500569         }
r3333r3334
562631}
563632
564633#if DEBUG_VERTICES
565static void testdrawline(bitmap_t *bitmap,int from,int to)
634static void testdrawline(bitmap_t *bitmap, int index, int from, int to)
566635{
636UINT32 *bmpaddr;
637int ix, iy, i, inc, x, y, dx, dy, plotx, ploty;
638
639   if ((state_ta.grab[index].showvertices[to].x < 0) || (state_ta.grab[index].showvertices[to].x > 639))
640      return;
641   if ((state_ta.grab[index].showvertices[from].x < 0) || (state_ta.grab[index].showvertices[from].x > 639))
642      return;
643   if ((state_ta.grab[index].showvertices[to].y < 0) || (state_ta.grab[index].showvertices[to].y > 479))
644      return;
645   if ((state_ta.grab[index].showvertices[from].y < 0) || (state_ta.grab[index].showvertices[from].y > 479))
646      return;
647    dx = state_ta.grab[index].showvertices[to].x - state_ta.grab[index].showvertices[from].x;
648   dy = state_ta.grab[index].showvertices[to].y - state_ta.grab[index].showvertices[from].y;
649    plotx = state_ta.grab[index].showvertices[from].x;
650   ploty = state_ta.grab[index].showvertices[from].y;
651    ix = abs(dx);
652   iy = abs(dy);
653   inc = max(ix,iy);
654   x = y = 0;
655
656    for (i=0; i <= inc; ++i)
657    {
658      x += ix;  y += iy;
659
660      if (x > inc)
661      {
662         x -= inc;
663         plotx += (dx ? dx/ix : 0);
664         bmpaddr = BITMAP_ADDR32(bitmap,ploty,plotx);
665         *bmpaddr = MAKE_RGB(0, 0, 255);
666      }
667      if (y > inc)
668      {
669         y -= inc;
670         ploty += (dy ? dy/iy : 0);
671         bmpaddr = BITMAP_ADDR32(bitmap,ploty,plotx);
672         *bmpaddr = MAKE_RGB(0, 0, 255);
673      }
674   }
567675}
568676#endif
569677
678#if 0
679INLINE UINT32 alpha_blend_r16_565(UINT32 d, UINT32 s, UINT8 level)
680{
681   int alphad = 256 - level;
682   return ((((s & 0x001f) * level + (d & 0x001f) * alphad) >> 8)) |
683         ((((s & 0x07e0) * level + (d & 0x07e0) * alphad) >> 8) & 0x07e0) |
684         ((((s & 0xf800) * level + (d & 0xf800) * alphad) >> 8) & 0xf800);
685}
686#endif
687
570688static void testdrawscreen(bitmap_t *bitmap,const rectangle *cliprect)
571689{
572   int cs,x,y,dx,dy,xi,yi,a;
690   int cs,x,y,dx,dy,xi,yi,a,rs,ns;
573691   float iu,iv,u,v;
574692   UINT32 addrp;
575693   UINT32 *bmpaddr;
576694   int xt,yt,cd;
577695   UINT32 c;
696#if 0
697   int stride;
698   UINT16 *bmpaddr16;
699   UINT32 k;
700#endif
578701
702   if (state_ta.renderselect < 0)
703      return;
704   rs=state_ta.renderselect;
579705   c=pvrta_regs[ISP_BACKGND_T];
580   fillbitmap(bitmap,program_read_dword_64le(0x05000000+((c&0xfffff8)>>1)+(3+3)*4),cliprect);
706   c=program_read_dword_64le(0x05000000+((c&0xfffff8)>>1)+(3+3)*4);
707   fillbitmap(bitmap,c,cliprect);
708#if 0
709   stride=pvrta_regs[FB_W_LINESTRIDE] << 3;
710   c=pvrta_regs[ISP_BACKGND_T];
711   a=(c & 0xfffff8) >> 1;
712   cs=(c >> 24) & 7;
713   cs=cs+3; // cs*2+3
714   c=program_read_dword_64le(0x05000000+a+3*4+(cs-1)*4);
715   dx=(int)u2f(program_read_dword_64le(0x05000000+a+3*4+cs*4+0));
716   dy=(int)u2f(program_read_dword_64le(0x05000000+a+3*4+2*cs*4+4));
717   for (y=0;y < dy;y++)
718   {
719      addrp=state_ta.grab[rs].fbwsof1+y*stride;
720      for (x=0;x < dx;x++)
721      {
722         bmpaddr16=((UINT16 *)dc_texture_ram) + (WORD2_XOR_LE(addrp) >> 1);
723         *bmpaddr16=((c & 0xf80000) >> 8) | ((c & 0xfc00) >> 5) | ((c & 0xf8) >> 3);
724         addrp+=2;
725      }
726   }
727#endif
581728
582   for (cs=0;cs < state_ta.testsprites_size;cs++)
729   ns=state_ta.grab[rs].testsprites_size;
730   for (cs=0;cs < ns;cs++)
583731   {
584      dx=state_ta.showsprites[cs].sizex;
585      dy=state_ta.showsprites[cs].sizey;
586      iu=state_ta.showsprites[cs].du/dx;
587      iv=state_ta.showsprites[cs].dv/dy;
588      cd=dilatechose[state_ta.showsprites[cs].texturesizes];
732      dx=state_ta.grab[rs].showsprites[cs].sizex;
733      dy=state_ta.grab[rs].showsprites[cs].sizey;
734      iu=state_ta.grab[rs].showsprites[cs].du/dx;
735      iv=state_ta.grab[rs].showsprites[cs].dv/dy;
736      cd=dilatechose[state_ta.grab[rs].showsprites[cs].texturesizes];
589737
590      if ((state_ta.showsprites[cs].positionx+dx) > 640)
591         dx=640-state_ta.showsprites[cs].positionx;
592      if ((state_ta.showsprites[cs].positiony+dy) > 480)
593         dy=480-state_ta.showsprites[cs].positiony;
738      if ((state_ta.grab[rs].showsprites[cs].positionx+dx) > 640)
739         dx=640-state_ta.grab[rs].showsprites[cs].positionx;
740      if ((state_ta.grab[rs].showsprites[cs].positiony+dy) > 480)
741         dy=480-state_ta.grab[rs].showsprites[cs].positiony;
594742      xi=0;
595743      yi=0;
596744
597      if (state_ta.showsprites[cs].positionx < 0)
598         xi=-state_ta.showsprites[cs].positionx;
599      if (state_ta.showsprites[cs].positiony < 0)
600         yi=-state_ta.showsprites[cs].positiony;
745      if (state_ta.grab[rs].showsprites[cs].positionx < 0)
746         xi=-state_ta.grab[rs].showsprites[cs].positionx;
747      if (state_ta.grab[rs].showsprites[cs].positiony < 0)
748         yi=-state_ta.grab[rs].showsprites[cs].positiony;
601749
602750      for (y = yi;y < dy;y++)
603751      {
604752         for (x = xi;x < dx;x++)
605753         {
606754            // find the coordinates
607            u=state_ta.showsprites[cs].u+iu*x;
608            v=state_ta.showsprites[cs].v+iv*y;
609            yt=v*(state_ta.showsprites[cs].texturesizey-1);
610            xt=u*(state_ta.showsprites[cs].texturesizex-1);
755            u=state_ta.grab[rs].showsprites[cs].u+iu*x;
756            v=state_ta.grab[rs].showsprites[cs].v+iv*y;
757            yt=v*(state_ta.grab[rs].showsprites[cs].texturesizey-1);
758            xt=u*(state_ta.grab[rs].showsprites[cs].texturesizex-1);
611759
612            switch (state_ta.showsprites[cs].texturepf)
760            a=255;
761            switch (state_ta.grab[rs].showsprites[cs].texturepf)
613762            {
614763            case 0: // 1555
615764               // find the address
616               if (state_ta.showsprites[cs].texturemode == 1)
617                  addrp=state_ta.showsprites[cs].textureaddress+(state_ta.showsprites[cs].texturesizex*yt+xt)*2;
618               else if (state_ta.showsprites[cs].texturemode == 0) // twiddled
619                  addrp=state_ta.showsprites[cs].textureaddress+(dilated1[cd][xt] + dilated0[cd][yt])*2;
765               if (state_ta.grab[rs].showsprites[cs].texturemode == 1)
766                  addrp=state_ta.grab[rs].showsprites[cs].textureaddress+(state_ta.grab[rs].showsprites[cs].texturesizex*yt+xt)*2;
767               else if (state_ta.grab[rs].showsprites[cs].texturemode == 0) // twiddled
768                  addrp=state_ta.grab[rs].showsprites[cs].textureaddress+(dilated1[cd][xt] + dilated0[cd][yt])*2;
620769               else // vq-compressed
621770               {
622771                  c=0x800+(dilated1[cd][xt >> 1] + dilated0[cd][yt >> 1]);
623                  c=*(((UINT8 *)dc_texture_ram) + BYTE_XOR_LE(state_ta.showsprites[cs].textureaddress+c));
624                  addrp=state_ta.showsprites[cs].textureaddress+c*8+(dilated1[cd][xt & 1] + dilated0[cd][yt & 1])*2;
772                  c=*(((UINT8 *)dc_texture_ram) + BYTE_XOR_LE(state_ta.grab[rs].showsprites[cs].textureaddress+c));
773                  addrp=state_ta.grab[rs].showsprites[cs].textureaddress+c*8+(dilated1[cd][xt & 1] + dilated0[cd][yt & 1])*2;
625774               }
626775               // read datum
627776               c=*(((UINT16 *)dc_texture_ram) + (WORD2_XOR_LE(addrp) >> 1));
628777               // find the color and draw
629778               a=(((c & 0x8000) >> 8)*255)/0x80;
630               bmpaddr=BITMAP_ADDR32(bitmap,state_ta.showsprites[cs].positiony+y,state_ta.showsprites[cs].positionx+x);
631               *bmpaddr = alpha_blend_r32(*bmpaddr, MAKE_RGB((c&0x7c00) >> 7, (c&0x3e0) >> 2, (c&0x1f) << 3), a);
779               c=MAKE_RGB((c&0x7c00) >> 7, (c&0x3e0) >> 2, (c&0x1f) << 3);
632780               break;
633781            case 1: // 565
634782               // find the address
635               if (state_ta.showsprites[cs].texturemode == 1)
636                  addrp=state_ta.showsprites[cs].textureaddress+(state_ta.showsprites[cs].texturesizex*yt+xt)*2;
637               else if (state_ta.showsprites[cs].texturemode == 0) // twiddled
638                  addrp=state_ta.showsprites[cs].textureaddress+(dilated1[cd][xt] + dilated0[cd][yt])*2;
783               if (state_ta.grab[rs].showsprites[cs].texturemode == 1)
784                  addrp=state_ta.grab[rs].showsprites[cs].textureaddress+(state_ta.grab[rs].showsprites[cs].texturesizex*yt+xt)*2;
785               else if (state_ta.grab[rs].showsprites[cs].texturemode == 0) // twiddled
786                  addrp=state_ta.grab[rs].showsprites[cs].textureaddress+(dilated1[cd][xt] + dilated0[cd][yt])*2;
639787               else // vq-compressed
640788               {
641789                  c=0x800+(dilated1[cd][xt >> 1] + dilated0[cd][yt >> 1]);
642                  c=*(((UINT8 *)dc_texture_ram) + BYTE_XOR_LE(state_ta.showsprites[cs].textureaddress+c));
643                  addrp=state_ta.showsprites[cs].textureaddress+c*8+(dilated1[cd][xt & 1] + dilated0[cd][yt & 1])*2;
790                  c=*(((UINT8 *)dc_texture_ram) + BYTE_XOR_LE(state_ta.grab[rs].showsprites[cs].textureaddress+c));
791                  addrp=state_ta.grab[rs].showsprites[cs].textureaddress+c*8+(dilated1[cd][xt & 1] + dilated0[cd][yt & 1])*2;
644792               }
645793               // read datum
646794               c=*(((UINT16 *)dc_texture_ram) + (WORD2_XOR_LE(addrp) >> 1));
647795               // find the color and draw
648               bmpaddr=BITMAP_ADDR32(bitmap,state_ta.showsprites[cs].positiony+y,state_ta.showsprites[cs].positionx+x);
649               *bmpaddr = alpha_blend_r32(*bmpaddr, MAKE_RGB((c&0xf800) >> 8, (c&0x7e0) >> 3, (c&0x1f) << 3), 255);
796               a=255;
797               c=MAKE_RGB((c&0xf800) >> 8, (c&0x7e0) >> 3, (c&0x1f) << 3);
650798               break;
651799            case 2: // 4444
652800               // find the address
653               if (state_ta.showsprites[cs].texturemode == 1)
654                  addrp=state_ta.showsprites[cs].textureaddress+(state_ta.showsprites[cs].texturesizex*yt+xt)*2;
655               else if (state_ta.showsprites[cs].texturemode == 0) // twiddled
656                  addrp=state_ta.showsprites[cs].textureaddress+(dilated1[cd][xt] + dilated0[cd][yt])*2;
801               if (state_ta.grab[rs].showsprites[cs].texturemode == 1)
802                  addrp=state_ta.grab[rs].showsprites[cs].textureaddress+(state_ta.grab[rs].showsprites[cs].texturesizex*yt+xt)*2;
803               else if (state_ta.grab[rs].showsprites[cs].texturemode == 0) // twiddled
804                  addrp=state_ta.grab[rs].showsprites[cs].textureaddress+(dilated1[cd][xt] + dilated0[cd][yt])*2;
657805               else // vq-compressed
658806               {
659807                  c=0x800+(dilated1[cd][xt >> 1] + dilated0[cd][yt >> 1]);
660                  c=*(((UINT8 *)dc_texture_ram) + BYTE_XOR_LE(state_ta.showsprites[cs].textureaddress+c));
661                  addrp=state_ta.showsprites[cs].textureaddress+c*8+(dilated1[cd][xt & 1] + dilated0[cd][yt & 1])*2;
808                  c=*(((UINT8 *)dc_texture_ram) + BYTE_XOR_LE(state_ta.grab[rs].showsprites[cs].textureaddress+c));
809                  addrp=state_ta.grab[rs].showsprites[cs].textureaddress+c*8+(dilated1[cd][xt & 1] + dilated0[cd][yt & 1])*2;
662810               }
663811               // read datum
664812               c=*(((UINT16 *)dc_texture_ram) + (WORD2_XOR_LE(addrp) >> 1));
665813               // find the color and draw
666814               a=(((c & 0xf000) >> 8)*255)/0xf0;
667               bmpaddr=BITMAP_ADDR32(bitmap,state_ta.showsprites[cs].positiony+y,state_ta.showsprites[cs].positionx+x);
668               *bmpaddr = alpha_blend_r32(*bmpaddr, MAKE_RGB((c&0xf00) >> 4, c&0xf0, (c&0xf) << 4), a);
815               c=MAKE_RGB((c&0xf00) >> 4, c&0xf0, (c&0xf) << 4);
669816               break;
670817            case 3: // yuv422
671818               break;
r3333r3334
674821            case 5: // 4 bpp palette
675822               break;
676823            case 6: // 8 bpp palette
677               if (state_ta.showsprites[cs].texturemode & 2) // vq-compressed
824               if (state_ta.grab[rs].showsprites[cs].texturemode & 2) // vq-compressed
678825               {
679826                  c=0x800+(dilated1[cd][xt >> 1] + dilated0[cd][yt >> 2]);
680                  c=*(((UINT8 *)dc_texture_ram) + BYTE_XOR_LE(state_ta.showsprites[cs].textureaddress+c));
681                  addrp=state_ta.showsprites[cs].textureaddress+c*8+(dilated1[cd][xt & 1] + dilated0[cd][yt & 3]);
827                  c=*(((UINT8 *)dc_texture_ram) + BYTE_XOR_LE(state_ta.grab[rs].showsprites[cs].textureaddress+c));
828                  addrp=state_ta.grab[rs].showsprites[cs].textureaddress+c*8+(dilated1[cd][xt & 1] + dilated0[cd][yt & 3]);
682829               }
683830               else
684831               {
685                  addrp=state_ta.showsprites[cs].textureaddress+(dilated1[cd][xt] + dilated0[cd][yt]);
832                  addrp=state_ta.grab[rs].showsprites[cs].textureaddress+(dilated1[cd][xt] + dilated0[cd][yt]);
686833               }
687834               c=*(((UINT8 *)dc_texture_ram) + BYTE_XOR_LE(addrp));
688               c=((state_ta.showsprites[cs].texturepalette & 0x30) << 4) | c;
835               c=((state_ta.grab[rs].showsprites[cs].texturepalette & 0x30) << 4) | c;
689836               c=pvrta_regs[0x1000/4+c];
690837               switch (pvrta_regs[PAL_RAM_CTRL])
691838               {
692839               case 0: // argb1555
693840                  a=(((c & 0x8000) >> 8)*255)/0x80;
694                  bmpaddr=BITMAP_ADDR32(bitmap,state_ta.showsprites[cs].positiony+y,state_ta.showsprites[cs].positionx+x);
695                  *bmpaddr = alpha_blend_r32(*bmpaddr, MAKE_RGB((c&0x7c00) >> 7, (c&0x3e0) >> 2, (c&0x1f) << 3), a);
841                  c=MAKE_RGB((c&0x7c00) >> 7, (c&0x3e0) >> 2, (c&0x1f) << 3);
696842                  break;
697843               case 1: // rgb565
698                  bmpaddr=BITMAP_ADDR32(bitmap,state_ta.showsprites[cs].positiony+y,state_ta.showsprites[cs].positionx+x);
699                  *bmpaddr = alpha_blend_r32(*bmpaddr, MAKE_RGB((c&0xf800) >> 8, (c&0x7e0) >> 3, (c&0x1f) << 3), 255);
844                  a=255;
845                  c=MAKE_RGB((c&0xf800) >> 8, (c&0x7e0) >> 3, (c&0x1f) << 3);
700846                  break;
701847               case 2: // argb4444
702848                  a=(((c & 0xf000) >> 8)*255)/0xf0;
703                  bmpaddr=BITMAP_ADDR32(bitmap,state_ta.showsprites[cs].positiony+y,state_ta.showsprites[cs].positionx+x);
704                  *bmpaddr = alpha_blend_r32(*bmpaddr, MAKE_RGB((c&0xf00) >> 4, c&0xf0, (c&0xf) << 4), a);
849                  c=MAKE_RGB((c&0xf00) >> 4, c&0xf0, (c&0xf) << 4);
705850                  break;
706851               case 3: // argb8888
707852                  a=(c & 0xff000000) >> 24;
708                  bmpaddr=BITMAP_ADDR32(bitmap,state_ta.showsprites[cs].positiony+y,state_ta.showsprites[cs].positionx+x);
709                  *bmpaddr = alpha_blend_r32(*bmpaddr, MAKE_RGB((c&0xff0000) >> 16, (c&0xff00) >> 8, c&0xff), a);
853                  c=MAKE_RGB((c&0xff0000) >> 16, (c&0xff00) >> 8, c&0xff);
710854                  break;
711855               }
712856               break;
713857            case 7: // reserved
714858               break;
715            }
859            } // switch
860            bmpaddr=BITMAP_ADDR32(bitmap,state_ta.grab[rs].showsprites[cs].positiony+y,state_ta.grab[rs].showsprites[cs].positionx+x);
861            *bmpaddr = alpha_blend_r32(*bmpaddr, c, a);
862#if 0
863            // write into framebuffer
864            switch (pvrta_regs[FB_W_CTRL] & 7)
865            {
866            case 0: // 0555 KRGB 16 bit
867               k=pvrta_regs[FB_W_CTRL] & 0x8000;
868               addrp=state_ta.grab[s].fbwsof1+(state_ta.grab[s].showsprites[cs].positiony+y)*stride+(state_ta.grab[s].showsprites[cs].positionx+x)*2;
869               bmpaddr16=((UINT16 *)dc_texture_ram) + (WORD2_XOR_LE(addrp) >> 1);
870               *bmpaddr16=k | alpha_blend_r16(*bmpaddr16,((c & 0xf80000) >> 9) | ((c & 0xf800) >> 6) | ((c & 0xf8) >> 3),a);
871               break;
872            case 1: // 565 RGB 16 bit
873               addrp=state_ta.grab[rs].fbwsof1+(state_ta.grab[rs].showsprites[cs].positiony+y)*stride+(state_ta.grab[rs].showsprites[cs].positionx+x)*2;
874               bmpaddr16=((UINT16 *)dc_texture_ram) + (WORD2_XOR_LE(addrp) >> 1);
875               //*bmpaddr16=alpha_blend_r16_565(*bmpaddr16,((c & 0xf80000) >> 8) | ((c & 0xfc00) >> 5) | ((c & 0xf8) >> 3),a);
876               *bmpaddr16=((c & 0xf80000) >> 8) | ((c & 0xfc00) >> 5) | ((c & 0xf8) >> 3);
877               break;
878            case 2: // 4444 ARGB 16 bit
879               break;
880            case 3: // 1555 ARGB 16 bit
881               break;
882            case 4: // 888 RGB 24 bit packed
883               break;
884            case 5: // 0888 KRGB 32 bit
885               break;
886            case 6: // 8888 ARGB 32 bit
887               break;
888            case 7: // reserved
889               break;
890            } // switch
891#endif
716892         }
717893      }
718894   }
895   state_ta.grab[rs].busy=0;
719896#if DEBUG_VERTICES
720   xi = yi = -1;
721   a = state_ta.testvertices_size;
722   if (a > 65535)
723      a = 65535;
724   for (cs=0;cs < a;cs++)
897   a = state_ta.grab[rs].testvertices_size;
898   if (a > 65530)
899      a = 65530;
900   for (cs=1;cs < a;cs++)
725901   {
726      xi=yi;
727      yi=cs;
728      if (xi >= 0)
729         testdrawline(bitmap,xi,yi);  // draw a segment from vertex xi to vertex yi
730      if (state_ta.showvertices[cs].endofstrip == 1)
731         xi = yi = -1;
902      testdrawline(bitmap,rs,cs-1,cs);  // draw a segment from vertex xi to vertex yi
903      if ((cs > 1) && (state_ta.grab[rs].showvertices[cs-2].endofstrip == 0))
904         testdrawline(bitmap,rs,cs-2,cs);
905      if (state_ta.grab[rs].showvertices[cs].endofstrip == 1)
906         cs++;
732907   }
733908#endif
734909}
910
911static void testdrawscreenframebuffer(bitmap_t *bitmap,const rectangle *cliprect)
912{
913   int x,y,dy,xi;
914   UINT32 addrp;
915   UINT16 *fbaddr;
916   UINT32 c;
917
918   // only for rgb565 framebuffer
919   xi=((pvrta_regs[FB_R_SIZE] & 0x3ff)+1) << 1;
920   dy=((pvrta_regs[FB_R_SIZE] >> 10) & 0x3ff)+1;
921   for (y=0;y < dy;y++)
922   {
923      addrp=pvrta_regs[FB_R_SOF1]+y*xi*2;
924      for (x=0;x < xi;x++)
925      {
926         fbaddr=BITMAP_ADDR16(bitmap,y,x);
927         c=*(((UINT16 *)dc_texture_ram) + (WORD2_XOR_LE(addrp) >> 1));
928         *fbaddr = (UINT16)c;
929         addrp+=2;
930      }
931   }
932}
735933/* test video end */
736934
737935static void pvr_build_parameterconfig(void)
r3333r3334
776974{
777975   memset(pvrctrl_regs, 0, sizeof(pvrctrl_regs));
778976   memset(pvrta_regs, 0, sizeof(pvrta_regs));
977   memset(state_ta.grab, 0, sizeof(state_ta.grab));
779978   pvr_build_parameterconfig();
780979
781980   // if the next 2 registers do not have the correct values, the naomi bios will hang
r3333r3334
788987   state_ta.tafifo_vertexwords=8;
789988   state_ta.tafifo_listtype= -1;
790989   state_ta.start_render_received=0;
990   state_ta.renderselect= -1;
991   state_ta.grabsel=0;
791992
792   state_ta.testsprites_size=0;
793   state_ta.toerasesprites=0;
794   state_ta.testvertices_size=0;
795993   computedilated();
796994
797995   vbout_timer = timer_alloc(vbout, 0);
r3333r3334
800998
801999VIDEO_UPDATE(dc)
8021000{
1001static int useframebuffer=1;
1002
8031003   if (pvrta_regs[VO_CONTROL] & (1 << 3))
8041004   {
8051005      fillbitmap(bitmap,pvrta_regs[VO_BORDER_COL] & 0xFFFFFF,cliprect);
8061006      return 0;
8071007   }
8081008
809   testdrawscreen(bitmap,cliprect);
1009   if ((useframebuffer) && !state_ta.start_render_received)
1010   {
1011      testdrawscreenframebuffer(bitmap,cliprect);
1012      return 0;
1013   }
8101014
8111015   if (state_ta.start_render_received)
8121016   {
1017      useframebuffer=0;
1018      testdrawscreen(bitmap,cliprect);
8131019      state_ta.start_render_received=0;
1020      state_ta.renderselect= -1;
8141021      dc_sysctrl_regs[SB_ISTNRM] |= IST_EOR_TSP;   // TSP end of render
8151022      update_interrupt_status();
1023      return 0;
8161024   }
817   return 0;
1025   else
1026      return 1;
8181027}
8191028
8201029void dc_vblank(running_machine *machine)
src/mame/video/midzeus2.c
r3333r3334
169169   return WAVERAM_BLOCK1(blocknum);
170170}
171171
172#ifdef UNUSED_FUNCTON
172#ifdef UNUSED_FUNCTION
173173INLINE void *waveram0_ptr_from_texture_addr(UINT32 addr, int width)
174174{
175175   UINT32 blocknum = ((addr & ~1) * width) / 8;
r3333r3334
184184 *
185185 *************************************/
186186
187#ifdef UNUSED_FUNCTON
187#ifdef UNUSED_FUNCTION
188188INLINE void waveram_plot(int y, int x, UINT32 color)
189189{
190190   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
r3333r3334
201201   }
202202}
203203
204#ifdef UNUSED_FUNCTON
204#ifdef UNUSED_FUNCTION
205205INLINE void waveram_plot_check_depth(int y, int x, UINT32 color, UINT16 depth)
206206{
207207   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
r3333r3334
216216}
217217#endif
218218
219#ifdef UNUSED_FUNCTON
219#ifdef UNUSED_FUNCTION
220220INLINE void waveram_plot_check_depth_nowrite(int y, int x, UINT32 color, UINT16 depth)
221221{
222222   if (x >= 0 && x <= zeus_cliprect.max_x && y >= 0 && y < zeus_cliprect.max_y)
r3333r3334
242242}
243243
244244
245#ifdef UNUSED_FUNCTON
245#ifdef UNUSED_FUNCTION
246246INLINE UINT8 get_texel_4bit(const void *base, int y, int x, int width)
247247{
248248   UINT32 byteoffs = (y / 2) * (width * 2) + ((x / 8) << 3) + ((y & 1) << 2) + ((x / 2) & 3);
src/mame/video/esd16.c
r3333r3334
6868static tilemap *esdtilemap_0;
6969static tilemap *esdtilemap_1;
7070tilemap *esdtilemap_1_16x16;
71tilemap *esdtilemap_0_16x16;
71static tilemap *esdtilemap_0_16x16;
7272
7373static TILE_GET_INFO( get_tile_info_0 )
7474{
src/mame/video/model3.c
r3333r3334
739739   }
740740}
741741
742#ifdef UNUSED_FUNCTON
742#ifdef UNUSED_FUNCTION
743743INLINE void write_texture8(int xpos, int ypos, int width, int height, int page, UINT16 *data)
744744{
745745   int x,y,i,j;
r3333r3334
916916/*****************************************************************************/
917917/* matrix and vector operations */
918918
919#ifdef UNUSED_FUNCTON
919#ifdef UNUSED_FUNCTION
920920INLINE float dot_product(VECTOR a, VECTOR b)
921921{
922922   return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]) + (a[3] * b[3]);
src/mame/video/atarirle.c
r3333r3334
162162    two.
163163---------------------------------------------------------------*/
164164
165#ifdef UNUSED_FUNCTON
165#ifdef UNUSED_FUNCTION
166166INLINE int compute_log(int value)
167167{
168168   int log = 0;
r3333r3334
201201    value into the result, packing the bits along the way.
202202---------------------------------------------------------------*/
203203
204#ifdef UNUSED_FUNCTON
204#ifdef UNUSED_FUNCTION
205205INLINE int collapse_bits(int value, int mask)
206206{
207207   int testmask, ormask;
src/mame/video/avgdvg.c
r3333r3334
12171217 *
12181218 ************************************/
12191219
1220#ifdef UNUSED_FUNCTION
12201221int avgdvg_done(void)
12211222{
12221223   return vg->sync_halt;
12231224}
1225#endif
12241226
12251227CUSTOM_INPUT( avgdvg_done_r )
12261228{
src/mame/video/tx1.c
r3333r3334
33    Tatsumi TX-1/Buggy Boy video hardware
44
55****************************************************************************/
6
67#include "driver.h"
78#include "profiler.h"
89#include "render.h"
910#include "cpu/i86/i86.h"
11#include "video/resnet.h"
1012#include "tx1.h"
1113
12#define PRINT_CRTC_DATA 1
1314
14/*
15    HD46505S-2 CRT Controller
16*/
15/*************************************
16 *
17 *  HD46505S-2 CRT Controller
18 *
19 *************************************/
20
21#define PRINT_CRTC_DATA 0
22
1723READ16_HANDLER( tx1_crtc_r )
1824{
1925   return 0xffff;
r3333r3334
3541         case 0x04: mame_printf_debug("Vertical total           "); break;
3642         case 0x05: mame_printf_debug("Vertical total adjust    "); break;
3743         case 0x06: mame_printf_debug("Vertical displayed       "); break;
38           case 0x07: mame_printf_debug("Vertical sync position   "); break;
39           case 0x08: mame_printf_debug("Interlace mode           "); break;
40           case 0x09: mame_printf_debug("Max. scan line address   "); break;
41           case 0x0a: mame_printf_debug("Cursror start            "); break;
42           case 0x0b: mame_printf_debug("Cursor end               "); break;
43           case 0x0c: mame_printf_debug("Start address (h)        "); break;
44           case 0x0d: mame_printf_debug("Start address (l)        "); break;
45           case 0x0e: mame_printf_debug("Cursor (h)               "); break;
46           case 0x0f: mame_printf_debug("Cursor (l)               "); break;
47           case 0x10: mame_printf_debug("Light pen (h))           "); break;
48           case 0x11: mame_printf_debug("Light pen (l)            "); break;
44         case 0x07: mame_printf_debug("Vertical sync position   "); break;
45         case 0x08: mame_printf_debug("Interlace mode           "); break;
46         case 0x09: mame_printf_debug("Max. scan line address   "); break;
47         case 0x0a: mame_printf_debug("Cursror start            "); break;
48         case 0x0b: mame_printf_debug("Cursor end               "); break;
49         case 0x0c: mame_printf_debug("Start address (h)        "); break;
50         case 0x0d: mame_printf_debug("Start address (l)        "); break;
51         case 0x0e: mame_printf_debug("Cursor (h)               "); break;
52         case 0x0f: mame_printf_debug("Cursor (l)               "); break;
53         case 0x10: mame_printf_debug("Light pen (h))           "); break;
54         case 0x11: mame_printf_debug("Light pen (l)            "); break;
4955      }
5056   }
5157   else if (offset == 1)
r3333r3334
6167  TX-1
6268
6369***************************************************************************/
70
71enum
72{
73   TX1_RDFLAG_RVA8 = 0,
74   TX1_RDFLAG_RVA9,
75   TX1_RDFLAG_RVA7,
76   TX1_RDFLAG_TNLF,
77   TX1_RDFLAG_STLF,
78   TX1_RDFLAG_SCCHGF
79} tx1_roadreg;
80
6481static struct
6582{
6683   UINT16   scol;      /* Road colours */
r3333r3334
6986
7087   UINT32   ba_val;      /* Accumulator */
7188   UINT32   ba_inc;
89   UINT32   bank_mode;
7290
7391   UINT16   h_val;      /* Accumulator */
7492   UINT16   h_inc;
r3333r3334
7795   UINT8   slin_inc;
7896} tx1_vregs;
7997
80/* Offsets into the palette PROMs */
81#define TX1_COLORS_CHAR   0x00
82#define TX1_COLORS_OBJ   0x80
83#define TX1_COLORS_ROAD   0xC0
84
8598UINT16 *tx1_vram;
8699UINT16 *tx1_objram;
87100UINT16 *tx1_rcram;
88101size_t tx1_objram_size;
89102
90static tilemap *tx1_tilemap;
103static UINT8 *tx1_chr_bmp;
104static UINT8 *tx1_obj_bmp;
105static UINT8 *tx1_rod_bmp;
106
91107static bitmap_t *tx1_bitmap;
92108static render_texture *tx1_texture;
93109
94WRITE16_HANDLER( tx1_vram_w )
95{
96   COMBINE_DATA(&tx1_vram[offset]);
97   tilemap_mark_tile_dirty(tx1_tilemap, offset);
98}
99110
100static TILE_GET_INFO( get_tx1_tile_info )
101{
102   int tilenum, color;
103
104   color = (tx1_vram[tile_index] >> 10) & 0x3f;
105   tilenum = (tx1_vram[tile_index]&0x03ff) | ((tx1_vram[tile_index] & 0x8000) >> 5);
106
107   SET_TILE_INFO(0, tilenum, color, 0);
108}
109
110111/***************************************************************************
111112
112113  Palette initialisation
113114
114  TODO: Add some notes
115
116115  bit 3 -- 220 ohm resistor  -- RED/GREEN/BLUE
117116        -- 470 ohm resistor  -- RED/GREEN/BLUE
118117        -- 1.0kohm resistor  -- RED/GREEN/BLUE
119118  bit 0 -- 2.2kohm resistor  -- RED/GREEN/BLUE
120119
121120***************************************************************************/
121
122122PALETTE_INIT( tx1 )
123123{
124124   int i;
125125
126   /* allocate the colortable */
127   machine->colortable = colortable_alloc(machine, 0x100);
126   static const res_net_info tx1_net_info =
127   {
128      RES_NET_VCC_5V | RES_NET_VIN_TTL_OUT,
129      {
130         { RES_NET_AMP_NONE, 0, 0, 4, { 2200, 1000, 470, 220 } },
131         { RES_NET_AMP_NONE, 0, 0, 4, { 2200, 1000, 470, 220 } },
132         { RES_NET_AMP_NONE, 0, 0, 4, { 2200, 1000, 470, 220 } }
133      }
134   };
128135
129   /* create a lookup table for the palette */
130   for (i = 0; i < 0x100; i++)
136   for (i = 0; i < 256; ++i)
131137   {
132      int r = pal4bit(color_prom[i + 0x000]);
133      int g = pal4bit(color_prom[i + 0x100]);
134      int b = pal4bit(color_prom[i + 0x200]);
138      int r, g, b;
135139
136      colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
137   }
140      r = compute_res_net(color_prom[i + 0x300] & 0xf, 0, &tx1_net_info);
141      g = compute_res_net(color_prom[i + 0x400] & 0xf, 1, &tx1_net_info);
142      b = compute_res_net(color_prom[i + 0x500] & 0xf, 2, &tx1_net_info);
138143
139   /* color_prom now points to the beginning of the lookup table */
140   color_prom += 0x300;
141
142   /* TODO */
143   for (i = 0; i < 0x100; i++)
144   {
145      UINT8 ctabentry = (color_prom[i + 0x600] & 0x0f) | 0x00;
146      colortable_entry_set_value(machine->colortable, i, ctabentry);
144      palette_set_color(machine, i, MAKE_RGB(r, g, b));
147145   }
148146}
149147
148
149/*************************************
150 *
151 *  Video Control Registers
152 *
153 *************************************/
154
150155WRITE16_HANDLER( tx1_bankcs_w )
151156{
152157   // AAB2 = /BASET0
r3333r3334
171176      tx1_vregs.ba_inc &= ~0xffff0000;
172177      tx1_vregs.ba_inc |= data << 16;
173178
179      // TODO: Schems say D15.
180      tx1_vregs.bank_mode = BIT(data, 1);
181
174182      if ( !(offset & 2)  )
175183         tx1_vregs.ba_val &= ~0xffff0000;
176184   }
177   if ( offset & 0x10 )
185   if ( !(offset & 0x10) )
178186   {
179187      /* Ignore data */
180188      if ( offset & 2 )
181      {
182189         tx1_vregs.ba_val = (tx1_vregs.ba_inc + tx1_vregs.ba_val) & 0x00ffffff;
183      }
184190   }
185191   if ( offset & 0x20 )
186192   {
r3333r3334
191197   }
192198   if ( !(offset & 0x40) )
193199   {
194      /* Ignore data? */
195      if ( offset & 2 )
200      /* TODO: Looks safe to remove this */
201//      if ( offset & 2 )
196202         tx1_vregs.h_val += tx1_vregs.h_inc;
197203   }
198204}
r3333r3334
221227}
222228
223229
224/* Preliminary */
225static void tx1_draw_objects(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
230/*************************************
231 *
232 *  Characters
233 *
234 *************************************/
235
236static void tx1_draw_char(running_machine *machine, UINT8 *bitmap)
226237{
238   INT32 x, y;
239   UINT32 scroll_x;
240   UINT8 *gfx1, *gfx2;
241
242   /* 2bpp characters */
243   gfx1 = memory_region(machine, "gfx1");
244   gfx2 = gfx1 + 0x4000;
245
246   /* X scroll value is the last word in char RAM */
247   scroll_x = tx1_vram[0xfff] & 0x3ff;
248
249   for (y = 0; y < 240; ++y)
250   {
251      UINT32 d0 = 0, d1 = 0;
252      UINT32 colour = 0;
253      UINT32 y_offs;
254      UINT32 x_offs;
255      UINT32 y_gran;
256
257      /* No y-scrolling? */
258      y_offs = y;
259
260      if ( (y_offs >= 64) && (y_offs < 128) )
261         x_offs = tx1_vregs.slock ? scroll_x : 0;
262      else
263         x_offs = 0;
264
265      y_gran = y_offs & 7;
266
267      if (x_offs & 7)
268      {
269         UINT32 tilenum;
270         UINT16 ram_val = tx1_vram[((y_offs << 4) & 0xf80) + ((x_offs >> 3) & 0x7f)];
271
272         tilenum = (ram_val & 0x03ff) | ((ram_val & 0x8000) >> 5);
273         colour = (ram_val & 0xfc00) >> 8;
274         d0 = *(gfx2 + (tilenum << 3) + y_gran);
275         d1 = *(gfx1 + (tilenum << 3) + y_gran);
276      }
277
278      for (x = 0; x < 256 * 3; ++x)
279      {
280         UINT32 x_gran = x_offs & 7;
281
282         if (!x_gran)
283         {
284            UINT32 tilenum;
285            UINT16 ram_val = tx1_vram[((y_offs << 4) & 0xf80) + ((x_offs >> 3) & 0x7f)];
286
287            tilenum = (ram_val & 0x03ff) | ((ram_val & 0x8000) >> 5);
288            colour = (ram_val & 0xfc00) >> 8;
289            d0 = *(gfx2 + (tilenum << 3) + y_gran);
290            d1 = *(gfx1 + (tilenum << 3) + y_gran);
291         }
292
293         *bitmap++ = colour |
294                  (((d1 >> (7 ^ x_gran)) & 1) << 1) |
295                  ((d0 >> (7 ^ x_gran)) & 1);
296
297         x_offs = (x_offs + 1) & 0x3ff;
298      }
299   }
300}
301
302
303/*************************************
304 *
305 *  Road
306 *
307 *************************************/
308
309#define TX1_GET_ROADPIX(NUM) \
310{ \
311   UINT32 addr = (rva6_0 << 5) | (road##NUM##_hcnt & 0x1f); \
312   UINT8 promaddr1, promaddr2, promaddr3; \
313   promaddr1 = rom_a[addr]; \
314   promaddr2 = rom_b[addr]; \
315   promaddr3 = rom_c[addr]; \
316   pix[NUM][0][0] = prom_a[promaddr1]; pix[NUM][0][1] = prom_b[promaddr1]; pix[NUM][0][2] = prom_c[promaddr1]; \
317   pix[NUM][1][0] = prom_a[promaddr2]; pix[NUM][1][1] = prom_b[promaddr2]; pix[NUM][1][2] = prom_c[promaddr2]; \
318   pix[NUM][2][0] = prom_a[promaddr3]; pix[NUM][2][1] = prom_b[promaddr3]; pix[NUM][2][2] = prom_c[promaddr3]; \
319   pix[NUM][3][0] = prom_a[0];         pix[NUM][3][1] = prom_b[0];         pix[NUM][3][2] = prom_c[0]; \
320}
321
322INLINE void tx1_draw_road_pixel(int screen, UINT8 *bmpaddr,
323                   UINT8 apix[3], UINT8 bpix[3], UINT32 pixnuma, UINT32 pixnumb,
324                   UINT8 stl, UINT8 sld, UINT8 selb,
325                   UINT8 bnk, UINT8 rorev, UINT8 eb, UINT8 r, UINT8 delr,
326                   running_machine *machine)
327{
328   UINT8 a0 = BIT(apix[0], pixnuma);
329   UINT8 a1 = BIT(apix[1], pixnuma);
330   UINT8 a2 = BIT(apix[2], pixnuma);
331
332   UINT8 b0 = BIT(bpix[0], pixnumb);
333   UINT8 b1 = BIT(bpix[1], pixnumb);
334   UINT8 b2 = BIT(bpix[2], pixnumb);
335
336   UINT8 d3;
337   UINT8 d2;
338   UINT8 d1;
339   UINT8 d0;
340   UINT8 sel;
341   UINT8 c6 = BIT(sld, 6);
342   UINT8 c5 = BIT(sld, 5);
343   UINT8 c4 = BIT(sld, 4);
344   UINT8 c3 = BIT(sld, 2);
345
346   UINT32 addr_offset = screen * 256;
347
348   sel = !bnk && ( (a2 && !b0) || (!a0 && b2) || !a1 || !a2 || !b1 || !b2 );
349
350   d3 =
351      (a2 && a1 && a0 && b2 && b1 && b0 && !rorev)
352      || (a1 && b1 && !b0 && stl && !bnk && !c6)
353      || (a1 && !a0 && b1 && stl && !bnk && !c6)
354      || (a1 && !b2 && b1 && stl && !bnk && !c6)
355      || (a2 && b2 && !b1 && stl && !bnk && !c4)
356      || (a2 && !a1 && b2 && stl && !bnk && !c4)
357      || (!a2 && a1 && b2 && stl && !bnk && !c6)
358      || (a2 && !b2 && b1 && stl && !bnk && !c6)
359      || (!a2 && !a1 && stl && !bnk && !c5)
360      || (!b2 && !b1 && stl && !bnk && !c5)
361      || (!b0 && !stl && !bnk && !c3)
362      || (!b1 && !stl && !bnk && !c3)
363      || (!a0 && !stl && !bnk && !c3)
364      || (!a1 && !stl && !bnk && !c3)
365      || (!a2 && !stl && !bnk && !c3)
366      || (!b2 && !stl && !bnk && !c3)
367      || (bnk && !rorev);
368
369   if (eb == 0)
370   {
371      if (sel == 1)
372      {
373         d2 = stl && (!a2 || !b2);
374         d1 = !stl || (!a2 && !a1) || (!b1 && !b2) || (a2 && !b1) || (b2 && !a1);
375         d0 = !stl
376            || (!a2 && !a0 && b1)
377            || (a1 && !b2 && !b0)
378            || (!a2 && !a1 && !a0)
379            || (!b2 && !b1 && !b0)
380            || (a2 && a1 && !b0)
381            || (!a0 && b2 && b1)
382            || (a2 && !b1 && !b0)
383            || (!a1 && !a0 && b2)
384            || (!a2 && !a0 && b2)
385            || (a2 && !b2 && !b0);
386      }
387      else
388      {
389         d2 = BIT(tx1_vregs.scol, selb ? 2 : 10);
390         d1 = BIT(tx1_vregs.scol, selb ? 1 : 9);
391         d0 = BIT(tx1_vregs.scol, selb ? 0 : 8);
392      }
393   }
394   else
395      d2 = d1 = d0 = 0;
396
397   *(bmpaddr + addr_offset) = (bnk << 6) | (r << 5) | (!(sel && delr) << 4 ) | (d3 << 3) | (d2 << 2) | (d1 << 1) | d0;
398}
399
400/* This could do with a tidy up and more comments... */
401static void tx1_draw_road(running_machine *machine, UINT8 *bitmap)
402{
403   INT32   y;
404   UINT32   rva9_8;
405   UINT32   rva7;
406   UINT32   tnlf;
407   UINT32   stlf;
408   UINT32   scchgf;
409
410   UINT32   vc = 0;
411
412   UINT16   road0_hcnt;
413   UINT8   road0_pcnt;
414   UINT16   road1_hcnt;
415   UINT8   road1_pcnt;
416   UINT8   pix[2][4][3];
417
418   /* Road slice map ROMs */
419   const UINT8 *const gfx3 = memory_region(machine, "gfx3");
420   const UINT8 *const rom_a = gfx3;
421   const UINT8 *const rom_b = gfx3 + 0x2000;
422   const UINT8 *const rom_c = gfx3 + 0x4000;
423
424   /* Pixel data */
425   const UINT8 *const proms = memory_region(machine, "proms");
426   const UINT8 *const prom_a = proms + 0x1100;
427   const UINT8 *const prom_b = proms + 0x1300;
428   const UINT8 *const prom_c = proms + 0x1500;
429   const UINT8 *const vprom  = proms + 0x1700;
430
431   rva9_8   = (tx1_vregs.flags & 3) << 8;
432   rva7   = !BIT(tx1_vregs.flags, TX1_RDFLAG_RVA7) << 7;
433   tnlf   = BIT(tx1_vregs.flags, TX1_RDFLAG_TNLF);
434   scchgf   = BIT(tx1_vregs.flags, TX1_RDFLAG_SCCHGF);
435   stlf   = BIT(tx1_vregs.flags, TX1_RDFLAG_STLF);
436
437   for (y = 0; y < 240; ++y)
438   {
439      UINT32   x;
440      UINT8   sld;
441      UINT8   rva6_0;
442      UINT16   rcrdb15_0;
443      UINT16   rva_addr;
444      UINT32   bank_cnt;
445
446      UINT16   vat;
447      UINT16   vp0;
448      UINT16   vp1;
449      UINT16   vp2;
450      UINT16   vp3;
451      UINT16   vp4;
452
453      UINT32   va8, va9, va10, va11, va12, va13, va14, va15;
454      UINT32   v0, v1, v2;
455
456      UINT8   hc1_u, hc1_l;
457      UINT8   hc0_u, hc0_l;
458
459      UINT32   bnkls, bnkcs, bnkrs;
460      UINT32   rl, rc, rr;
461
462      UINT32   stl;
463      UINT32   selb;
464      UINT32   ebls, ebcs, ebrs;
465
466      UINT8 *bmpaddr = bitmap + (y * 768);
467
468      UINT32 rltmp, rctmp, rrtmp;
469      UINT32 eltmp, ectmp, ertmp;
470
471      UINT32 tmpm;
472      UINT32 tmpn;
473      UINT32 tmpc;
474      UINT32 tmpd;
475
476      UINT8 scrcnt0;
477      UINT8 scrcnt1;
478
479      UINT8 rorevls = 0;
480      UINT8 rorevcs = 0;
481      UINT8 rorevrs = 0;
482
483      int febl[2] = { 0, 0 };
484      int febr[2] = { 0, 0 };
485      int febc[2] = { 0, 0 };
486
487      /* Road vertical address */
488      if ( BIT(tx1_vregs.h_val, 15) )
489         rva6_0 = 0x7f;
490      else
491         rva6_0 = (~tx1_vregs.h_val >> 7) & 0x7f;
492
493      rva_addr = rva9_8 | rva6_0;
494
495      /* Get the stripe data also */
496      sld = vprom[rva6_0] + tx1_vregs.slin_val;
497
498      /* Load the left road h-counter */
499      rcrdb15_0 = tx1_rcram[(0x80 + rva_addr) ^ 0x7ff];
500      road0_pcnt = rcrdb15_0 & 0x7;
501      road0_hcnt = (rcrdb15_0 >> 3) & 0x7f;
502      road0_hcnt |= rcrdb15_0 & 0xfc00 ? 0x80 : 0;
503      road0_hcnt |= (rcrdb15_0 & 0xfc00) == 0xfc00 ? 0x100 : 0x000;
504
505      /* Load the second road h-counter */
506      rcrdb15_0 = tx1_rcram[(rva7 + rva_addr) ^ 0x7ff];
507      road1_pcnt = rcrdb15_0 & 0x7;
508      road1_hcnt = (rcrdb15_0 >> 3) & 0x7f;
509      road1_hcnt |= rcrdb15_0 & 0xfc00 ? 0x80 : 0;
510      road1_hcnt |= (rcrdb15_0 & 0xfc00) == 0xfc00 ? 0x100 : 0x000;
511      road1_hcnt |= (rcrdb15_0 & 0x800);
512
513      scrcnt0 = (road0_hcnt >> 5) & 0xf;
514      scrcnt1 = (road1_hcnt >> 5) & 0xf;
515
516      if (road0_pcnt & 7)
517      {
518         TX1_GET_ROADPIX(0);
519
520         febl[0] = (scrcnt0 + 0) & 0xc;
521         febc[0] = (scrcnt0 + 1) & 0xc;
522         febr[0] = (scrcnt0 + 2) & 0xc;
523      }
524
525      if (road1_pcnt & 7)
526      {
527         UINT32 y4 = (road1_hcnt >> 4) & 1;
528         UINT32 temp = (road1_hcnt >> 5) & 0xf;
529         UINT32 x, u;
530         UINT32 fl11 = BIT(road1_hcnt, 15);
531
532         TX1_GET_ROADPIX(1);
533
534         x = (temp & 0xc);
535         u = !(((temp & 1) && y4) || (temp & 2));
536         rorevls = ((fl11 && !x) || (fl11 && x && u));
537         febl[1] = x;
538
539         temp += 1;
540         x = (temp & 0xc);
541         u = !(((temp & 1) && y4) || (temp & 2));
542         rorevcs = ((fl11 && !x) || (fl11 && x && u));
543         febc[1] = x;
544
545         temp += 1;
546         x = (temp & 0xc);
547         u = !(((temp & 1) && y4) || (temp & 2));
548         rorevrs = ((fl11 && !x) || (fl11 && x && u));
549         febr[1] = x;
550      }
551
552      /* Load the bank counter with accumulator bits 14-5 */
553      bank_cnt = (tx1_vregs.ba_val >> 5) & 0x3ff;
554
555      /* Load vertical position data */
556      vat = tx1_rcram[(rva9_8 + 7) ^ 0x7f8];
557      vp0 = tx1_rcram[(rva9_8 + 6) ^ 0x7f8];
558      vp1 = tx1_rcram[(rva9_8 + 5) ^ 0x7f8];
559      vp2 = tx1_rcram[(rva9_8 + 4) ^ 0x7f8];
560      vp3 = tx1_rcram[(rva9_8 + 3) ^ 0x7f8];
561      vp4 = tx1_rcram[(rva9_8 + 2) ^ 0x7f8];
562
563      /*  */
564      if (y-1 == vp0) vc++;
565      if (y-1 == vp1) vc++;
566      if (y-1 == vp2) vc++;
567      if (y-1 == vp3) vc++;
568      if (y-1 == vp4) vc++;
569
570      /* */
571      va8 = BIT(vat, 8);
572      va9 = BIT(vat, 9);
573      va10 = BIT(vat, 10);
574      va11 = BIT(vat, 11);
575      va12 = BIT(vat, 12);
576      va13 = BIT(vat, 13);
577      va14 = BIT(vat, 14);
578      va15 = BIT(vat, 15);
579
580      v0 = BIT(vc, 0);
581      v1 = BIT(vc, 1);
582      v2 = BIT(vc, 2);
583
584      /* Load the horizontal tunnel position counters */
585      hc1_u = tx1_rcram[(rva9_8 + 1) ^ 0x7f8] >> 8;
586      hc1_l = tx1_rcram[(rva9_8 + 1) ^ 0x7f8] & 0xff;
587      hc0_u = tx1_rcram[(rva9_8 + 0) ^ 0x7f8] >> 8;
588      hc0_l = tx1_rcram[(rva9_8 + 0) ^ 0x7f8] & 0xff;
589
590      stl = !stlf || v0 || (!v2 && !scchgf) || scchgf;
591      selb = (!v2 && !scchgf) || v2;
592
593      rltmp =
594      (v2 && !v0 && !va10)
595      || (!v2 && v0 && !va10)
596      || (v2 && !v0 && !va11)
597      || (v2 && !v1 && !v0)
598      || (!v2 && v0 && !va11)
599      || (!v2 && v1 && !v0)
600      || (!v2 && !v1 && v0);
601
602      rctmp =
603      (v2 && !v0 && va9 && va8)
604      || (!v2 && v0 && va9 && va8)
605      || (v2 && !v0 && !va11)
606      || (v2 && !v1 && !v0)
607      || (!v2 &&  v0 && !va11)
608      || (!v2 &&  v1 && !v0)
609      || (!v2 && !v1 &&  v0);
610
611      rrtmp =
612      (v2 && !v0 && !va11 && !va10)
613      || (!v2 && v0 && !va11 && !va10)
614      || (v2 && !v0 && va9)
615      || (!v2 && v0 && va9)
616      || (v2 && !v1 && !v0)
617      || (!v2 && v1 && !v0)
618      || (!v2 && !v1 && v0);
619
620      ectmp =
621      (v2 && !v0 && va13 && va12)
622      || (!v2 && v1 && va13 && va12)
623      || (!v2 && !v1 && v0)
624      || (v2 && !v0 && !va15)
625      || (!v2 && v1 && !va15);
626
627      eltmp =
628      (v2 && !v0 && !va14)
629      || (!v2 && v1 && !va14)
630      || (!v2 && !v1 && v0)
631      || (v2 && !v0 && !va15)
632      || (!v2 && v1 && !va15);
633
634      ertmp =
635      (v2 && !v0 && !va15 && !va14)
636      || (!v2 && v1 && !va15 && !va14)
637      || (v2 && !v0 && va13)
638      || (!v2 && v1 && va13)
639      || (!v2 && !v1 && v0);
640
641      tmpn = (v2 && !v0) || (!v2 && v0);
642      tmpm = (v2 && !v0) || (!v2 && v1);
643      tmpc = (!v1 && !v0) || (v2);
644      tmpd = v1 && v0 && va11;
645
646      for (x = 0; x < 256; x++)
647      {
648         UINT32 pixnum0 = (road0_pcnt & 7) ^ 7;
649         UINT32 pixnum1 = (road1_pcnt & 7) ^ 7;
650
651         UINT32 cyu, cyl;
652         UINT32 delrl, delrc, delrr;
653
654         /* */
655         scrcnt0 = (road0_hcnt >> 5) & 0xf;
656         scrcnt1 = (road1_hcnt >> 5) & 0xf;
657
658         /* Get new pixel data? */
659         if ( !(road0_pcnt & 7) )
660         {
661            TX1_GET_ROADPIX(0);
662
663            /* Road 0 enables */
664            febl[0] = (scrcnt0 + 0) & 0xc;
665            febc[0] = (scrcnt0 + 1) & 0xc;
666            febr[0] = (scrcnt0 + 2) & 0xc;
667         }
668
669         if ( !(road1_pcnt & 7) )
670         {
671            UINT32 y4 = (road1_hcnt >> 4) & 1;
672            UINT32 temp = (road1_hcnt >> 5) & 0xf;
673            UINT32 x, u;
674            UINT32 fl11 = BIT(road1_hcnt, 15);
675
676            TX1_GET_ROADPIX(1);
677
678            x = (temp & 0xc);
679            u = !(((temp & 1) && y4) || (temp & 2));
680            rorevls = ((fl11 && !x) || (fl11 && x && u));
681            febl[1] = x;
682
683            temp += 1;
684            x = (temp & 0xc);
685            u = !(((temp & 1) && y4) || (temp & 2));
686            rorevcs = ((fl11 && !x) || (fl11 && x && u));
687            febc[1] = x;
688
689            temp += 1;
690            x = (temp & 0xc);
691            u = !(((temp & 1) && y4) || (temp & 2));
692            rorevrs = ((fl11 && !x) || (fl11 && x && u));
693            febr[1] = x;
694         }
695
696         /* Road camber/banking */
697         if ( BIT(tx1_vregs.ba_val, 23) )
698         {
699            bnkls = 1;
700            bnkcs = 1;
701            bnkrs = 1;
702         }
703         else if (tx1_vregs.ba_val & 0x007f8000)
704         {
705            bnkls = 0;
706            bnkcs = 0;
707            bnkrs = 0;
708         }
709         else
710         {
711            bnkls = bank_cnt < 0x400;
712            bnkcs = bank_cnt < 0x300;
713            bnkrs = bank_cnt < 0x200;
714         }
715
716         if (tx1_vregs.bank_mode)
717         {
718            bnkls ^= 1;
719            bnkcs ^= 1;
720            bnkrs ^= 1;
721         }
722
723         cyu = hc1_u == 0xff;
724         cyl = hc1_l == 0xff;
725
726         rl = tnlf && ( rltmp || (tmpn && (!cyl || (va8 && va9 && cyu))) );
727         rc = tnlf && ( rctmp || (tmpn && ((!va10 && !cyl) || (va9 && cyu))) );
728         rr = tnlf && ( rrtmp || (tmpn && ((!va11 && !cyl) || (va8 && cyu))) );
729
730         /* Evaluates to 0 for tunnels */
731         delrl = !tnlf || tmpc || ((tmpd && va10) && ((!va8 && cyl) || (!va9 && cyl) || (!cyu && !cyl)));
732
733         delrr =
734            !tnlf
735            || tmpc
736            || (v1 && v0 && va10 && !va9 && !va8 && cyl)
737            || (v1 && v0 && va10 && !va9 && cyl && !cyu)
738            || (tmpd && !va9 && !cyu)
739            || (tmpd && !va9 && !va8);
740
741         delrc = !tnlf || tmpc || (tmpd && ((!va8 && cyl && !cyu) || (!va8 && va10 && !cyu) || (!va9 && cyl) || (va10 && !va9)));
742
743         cyu = hc0_u == 0xff;
744         cyl = hc0_l == 0xff;
745
746         ebls = tnlf && ( eltmp || (tmpm && (!cyl || (va12 && va13 && cyu))));
747         ebcs = tnlf && ( ectmp || (tmpm && ((!va14 && !cyl) || (va13 && cyu))));
748         ebrs = tnlf && ( ertmp || (tmpm && ((!va15 && !cyl) || (va12 && cyu))));
749
750         /* Carry for horizontal position counters */
751         cyu = hc0_u == 0xff;
752         cyl = hc0_l == 0xff;
753
754         if (!(bnkls && !rl))
755         {
756            int a, b;
757
758            if (!febl[0])
759               a = (scrcnt0) & 3;
760            else
761               a = 3;
762
763            if (!febl[1])
764               b = (scrcnt1) & 3;
765            else
766               b = 3;
767
768            tx1_draw_road_pixel(0, bmpaddr,
769                   &pix[0][a][0], &pix[1][b][0],
770                   pixnum0, pixnum1,
771                   stl, sld, selb, bnkls, rorevls, ebls, rl, delrl, machine);
772         }
773         else
774            *(bmpaddr) = (bnkls << 6) | (rl << 5);
775
776         if (!(bnkcs && !rc))
777         {
778            int a, b;
779
780            if (!febc[0])
781               a = (scrcnt0 + 1) & 3;
782            else
783               a = 3;
784
785            if (!febc[1])
786               b = (scrcnt1 + 1) & 3;
787            else
788               b = 3;
789
790            tx1_draw_road_pixel(1, bmpaddr,
791                   &pix[0][a][0], &pix[1][b][0],
792                   pixnum0, pixnum1,
793                   stl, sld, selb, bnkcs, rorevcs, ebcs, rc, delrc, machine);
794         }
795         else
796            *(bmpaddr + 256) = (bnkcs << 6) | (rc << 5);
797
798         if (!(bnkrs && !rr))
799         {
800            int a, b;
801
802            if (!febr[0])
803               a = (scrcnt0 + 2) & 3;
804            else
805               a = 3;
806
807            if (!febr[1])
808               b = (scrcnt1 + 2) & 3;
809            else
810               b = 3;
811
812            tx1_draw_road_pixel(2, bmpaddr,
813                   &pix[0][a][0], &pix[1][b][0],
814                   pixnum0, pixnum1,
815                   stl, sld, selb, bnkrs, rorevrs, ebrs, rr, delrr, machine);
816         }
817         else
818            *(bmpaddr + 512) = (bnkrs << 6) | (rr << 5);
819
820         ++bmpaddr;
821
822         /* Update road counters */
823         if (!(++road0_pcnt & 7))
824            ++road0_hcnt;
825
826         if (!(++road1_pcnt & 7))
827            ++road1_hcnt;
828
829         /* Increment horizontal counters (stop at 0xff) */
830         if (hc0_u != 0xff) ++hc0_u;
831         if (hc0_l != 0xff) ++hc0_l;
832         if (hc1_u != 0xff) ++hc1_u;
833         if (hc1_l != 0xff) ++hc1_l;
834
835         /* Update bank counter */
836         bank_cnt = (bank_cnt + 1) & 0x7ff;
837      }
838
839      tx1_vregs.h_val += tx1_vregs.h_inc;
840
841      /* Finally, increment the bank accumulator */
842      tx1_vregs.ba_val = (tx1_vregs.ba_val + tx1_vregs.ba_inc) & 0x00ffffff;
843   }
844
845}
846
847/*************************************
848 *
849 *  Objects
850 *
851 *************************************/
852
853static void tx1_draw_objects(running_machine *machine, UINT8 *bitmap)
854{
227855#define FRAC   16
228856
229857   UINT32 offs;
230858
231859   /* The many lookup table ROMs */
232   const UINT8 *const ic48  = (UINT8*)memory_region(machine, "user3");
233   const UINT8 *const ic281 = (UINT8*)memory_region(machine, "user3") + 0x2000;
234   const UINT8 *const ic25  = (UINT8*)memory_region(machine, "proms") + 0x1000;
860   const UINT8 *const user3 = memory_region(machine, "user3");
861   const UINT8 *const ic48  = user3;
862   const UINT8 *const ic281 = user3 + 0x2000;
235863
236   const UINT8 *const ic106 = (UINT8*)memory_region(machine, "user2");
237   const UINT8 *const ic73  = (UINT8*)memory_region(machine, "user2") + 0x4000;
864   const UINT8 *const proms = memory_region(machine, "proms");
865   const UINT8 *const ic25  = proms + 0x1000;
238866
239   const UINT8 *const ic190 = (UINT8*)memory_region(machine, "proms") + 0xc00;
240   const UINT8 *const ic162 = (UINT8*)memory_region(machine, "proms") + 0xe00;
867   const UINT8 *const user2 = memory_region(machine, "user2");
868   const UINT8 *const ic106 = user2;
869   const UINT8 *const ic73  = user2 + 0x4000;
241870
242   const UINT8 *const pixdata_rgn = (UINT8*)memory_region(machine, "gfx2");
871   const UINT8 *const ic190 = proms + 0xc00;
872   const UINT8 *const ic162 = proms + 0xe00;
243873
874   const UINT8 *const pixdata_rgn = memory_region(machine, "gfx2");
875
244876   for (offs = 0x0; offs <= tx1_objram_size; offs += 8)
245877   {
246878      UINT32   x;
r3333r3334
282914      /* Add 1 to account for line buffering */
283915      y = (tx1_objram[offs] >> 8) + 1;
284916
285      for (; y <= cliprect->max_y; ++y)
917      for (; y < 240; ++y)
286918      {
287919         UINT32   rom_addr2   = 0;
288920         UINT8   ic106_data   = 0;
r3333r3334
3741006                  lut_data = (ic106_data << 8) | ic73_data;
3751007                  psbb0_12 = lut_data & 0x1fff;
3761008
377                  // 0000 1100 0011 1111
3781009                  pscb0_14 = (psbb0_12 & 0xc3f);
3791010
3801011                  /* Bits 9_6 are from PCTMP11-8 or PSBB9-6 */
r3333r3334
4161047               }
4171048
4181049               /* Draw a pixel? */
419               if ( x <= cliprect->max_x )
1050               if ( x < 768 )
4201051               {
4211052                  UINT8   pix;
4221053                  UINT8   bit;
r3333r3334
4421073                     else
4431074                        color = ~ic162[prom_addr] & 0x3f;
4441075
445                     *BITMAP_ADDR16(bitmap, y, x) = TX1_COLORS_OBJ + color;
1076//                          *BITMAP_ADDR16(bitmap, y, x) = machine->pens[TX1_COLORS_OBJ + color];
1077                     *(bitmap + 768*y + x) = 0x40 | color;
4461078                  }
4471079               }
4481080
r3333r3334
4661098}
4671099
4681100
1101/*************************************
1102 *
1103 *  Core Functions
1104 *
1105 *************************************/
1106
4691107VIDEO_START( tx1 )
4701108{
471   tx1_tilemap = tilemap_create(get_tx1_tile_info, tilemap_scan_rows,  8, 8, 128, 64);
472   tilemap_set_transparent_pen(tx1_tilemap, 0xff);
473
4741109   /* Allocate a large bitmap that covers the three screens */
4751110   tx1_bitmap = auto_bitmap_alloc(768, 256, BITMAP_FORMAT_INDEXED16);
4761111   tx1_texture = render_texture_alloc(NULL, NULL);
1112
1113   /* Allocate some bitmaps */
1114   tx1_chr_bmp = auto_malloc(sizeof(UINT8) * 256 * 3 * 240);
1115   tx1_obj_bmp = auto_malloc(sizeof(UINT8) * 256 * 3 * 240);
1116   tx1_rod_bmp = auto_malloc(sizeof(UINT8) * 256 * 3 * 240);
4771117}
4781118
4791119VIDEO_EOF( tx1 )
r3333r3334
4821122   tx1_vregs.slin_val += tx1_vregs.slin_inc;
4831123}
4841124
1125static void tx1_combine_layers(running_machine *machine, bitmap_t *bitmap, int screen)
1126{
1127   int x, y;
1128   UINT8 *chr_pal = memory_region(machine, "proms") + 0x900;
4851129
486/* Experimental :) */
1130   int x_offset = screen * 256;
1131
1132   for (y = 0; y < 240; ++y)
1133   {
1134      UINT16 *bmp_addr = BITMAP_ADDR16(bitmap, y, 0);
1135
1136      UINT32 bmp_offset = y * 768 + x_offset;
1137
1138      UINT8 *chr_addr = tx1_chr_bmp + bmp_offset;
1139      UINT8 *rod_addr = tx1_rod_bmp + bmp_offset;
1140      UINT8 *obj_addr = tx1_obj_bmp + bmp_offset;
1141
1142      for (x = 0; x < 256; ++x)
1143      {
1144         UINT8 out_val;
1145         UINT32 char_val = chr_addr[x];
1146         UINT32 c7 = BIT(char_val, 7);
1147         UINT32 c1 = BIT(char_val, 1);
1148         UINT32 c0 = BIT(char_val, 0);
1149
1150         UINT32 road_val = rod_addr[x];
1151         UINT32 r6 = BIT(road_val, 6);
1152         UINT32 r5 = BIT(road_val, 5);
1153
1154         UINT32 obj_val = obj_addr[x];
1155         UINT32 obj6 = BIT(obj_val, 6);
1156
1157         UINT32 term1 = !(c7 && c1);
1158         UINT32 term2 = !(c7 && c0);
1159         UINT32 term3 = r5 || !r6;
1160         UINT32 p12 = !(term1 && term2 && term3);
1161         UINT32 p6 = !(obj6 && term1 && term2);
1162         UINT32 sel =  p12 | (p6 << 1);
1163
1164         UINT32 psel =  (!(p6 && p12) << 1) | p6;
1165
1166         if      (sel == 3)   out_val = ((char_val & 0xc0) >> 2) | (chr_pal[char_val] & 0xf);
1167         else if (sel == 2)   out_val = road_val & 0x3f;
1168         else            out_val = obj_val & 0x3f;
1169
1170         *bmp_addr++ = (psel << 6) | out_val;
1171      }
1172   }
1173}
1174
4871175VIDEO_UPDATE( tx1 )
4881176{
489   int y;
1177   const device_config *left_screen   = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "left");
1178   const device_config *centre_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "center");
1179   const device_config *right_screen  = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "right");
4901180
491   const device_config *left_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "left");
492   const device_config *center_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "center");
493   const device_config *right_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "right");
494
4951181   if ( screen == left_screen )
4961182   {
497      rectangle rect = { 0, 768 - 1, 0, 240 - 1 };
1183      memset(tx1_obj_bmp, 0, 768*240);
4981184
499//      tilemap_set_scrollx(tx1_tilemap, 0, scroll);
500      tilemap_draw(tx1_bitmap, &rect, tx1_tilemap, 0, 0);
501//      tx1_draw_road(tx1_bitmap, &rect);
502      tx1_draw_objects(screen->machine, tx1_bitmap, &rect);
1185      tx1_draw_char(screen->machine, tx1_chr_bmp);
1186      tx1_draw_road(screen->machine, tx1_rod_bmp);
1187      tx1_draw_objects(screen->machine, tx1_obj_bmp);
5031188
504      for (y = 0; y < 240; ++y)
505         memcpy(BITMAP_ADDR16(bitmap, y, 0), BITMAP_ADDR16(tx1_bitmap, y, 0 * 256), sizeof(UINT16) * 256);
1189      tx1_combine_layers(screen->machine, bitmap, 0);
5061190   }
507   else if ( screen == center_screen )
508      for (y = 0; y < 240; ++y)
509         memcpy(BITMAP_ADDR16(bitmap, y, 0), BITMAP_ADDR16(tx1_bitmap, y, 1 * 256), sizeof(UINT16) * 256);
510   else if ( screen == right_screen )
511      for (y = 0; y < 240; ++y)
512         memcpy(BITMAP_ADDR16(bitmap, y, 0), BITMAP_ADDR16(tx1_bitmap, y, 2 * 256), sizeof(UINT16) * 256);
1191   else if (screen == centre_screen)
1192   {
1193      tx1_combine_layers(screen->machine, bitmap, 1);
1194   }
1195   else if (screen == right_screen)
1196   {
1197      tx1_combine_layers(screen->machine, bitmap, 2);
1198   }
5131199
514
5151200   return 0;
5161201}
5171202
r3333r3334
5661251size_t buggyboy_objram_size;
5671252size_t buggyboy_rcram_size;
5681253
569static tilemap *buggyboy_tilemap;
1254static UINT8 *bb_chr_bmp;
1255static UINT8 *bb_obj_bmp;
1256static UINT8 *bb_rod_bmp;
5701257
571static UINT8 *chr_bmp;
572static UINT8 *obj_bmp;
573static UINT8 *rod_bmp;
5741258
5751259/***************************************************************************
5761260
r3333r3334
5921276  bit 2 -- 4.7kohm resistor  -- RED
5931277
5941278***************************************************************************/
595PALETTE_INIT( buggybjr )
1279
1280PALETTE_INIT( buggyboy )
5961281{
5971282   int i;
5981283
r3333r3334
6261311   }
6271312}
6281313
629PALETTE_INIT( buggyboy )
1314
1315/*************************************
1316 *
1317 *  Characters
1318 *
1319 *************************************/
1320
1321static void buggyboy_draw_char(running_machine *machine, UINT8 *bitmap, int wide)
6301322{
631   int i;
1323   INT32 x, y;
1324   UINT32 scroll_x, scroll_y;
1325   UINT8 *gfx1, *gfx2;
1326   UINT32 total_width;
1327   UINT32 x_mask;
6321328
633   /* allocate the colortable */
634   machine->colortable = colortable_alloc(machine, 0x100);
1329   /* 2bpp characters */
1330   gfx1 = memory_region(machine, "gfx1");
1331   gfx2 = memory_region(machine, "gfx1") + 0x4000;
6351332
636   /* create a lookup table for the palette */
637   for (i = 0; i < 0x100; i++)
1333   /* X/Y scroll values are the last word in char RAM */
1334   if (wide)
6381335   {
639      int bit0, bit1, bit2, bit3, bit4;
640      int r, g, b;
1336      scroll_y = (buggyboy_vram[0xfff] >> 10) & 0x3f;
1337      scroll_x = buggyboy_vram[0xfff] & 0x1ff;
1338      total_width = 768;
1339      x_mask = 0x3ff;
1340   }
1341   else
1342   {
1343      scroll_y = (buggyboy_vram[0x7ff] >> 10) & 0x3f;
1344      scroll_x = buggyboy_vram[0x7ff] & 0x1ff;
1345      total_width = 256;
1346      x_mask = 0x1ff;
1347   }
6411348
642      bit0 = BIT(color_prom[i + 0x000], 0);
643      bit1 = BIT(color_prom[i + 0x000], 1);
644      bit2 = BIT(color_prom[i + 0x000], 2);
645      bit3 = BIT(color_prom[i + 0x000], 3);
646      bit4 = BIT(color_prom[i + 0x300], 2);
647      r = 0x06 * bit4 + 0x0d * bit0 + 0x1e * bit1 + 0x41 * bit2 + 0x8a * bit3;
1349   for (y = 0; y < 240; ++y)
1350   {
1351      UINT32 d0 = 0, d1 = 0;
1352      UINT32 colour = 0;
1353      UINT32 y_offs;
1354      UINT32 x_offs;
1355      UINT32 y_gran;
6481356
649      bit0 = BIT(color_prom[i + 0x100], 0);
650      bit1 = BIT(color_prom[i + 0x100], 1);
651      bit2 = BIT(color_prom[i + 0x100], 2);
652      bit3 = BIT(color_prom[i + 0x100], 3);
653      bit4 = BIT(color_prom[i + 0x300], 1);
654      g = 0x06 * bit4 + 0x0d * bit0 + 0x1e * bit1 + 0x41 * bit2 + 0x8a * bit3;
1357      /* There's no y-scrolling between scanlines 0 and 63 */
1358      if (y < 64)
1359         y_offs = y;
1360      else
1361      {
1362         y_offs = (y + (scroll_y | 0xc0) + 1) & 0xff;
6551363
656      bit0 = BIT(color_prom[i + 0x200], 0);
657      bit1 = BIT(color_prom[i + 0x200], 1);
658      bit2 = BIT(color_prom[i + 0x200], 2);
659      bit3 = BIT(color_prom[i + 0x200], 3);
660      bit4 = BIT(color_prom[i + 0x300], 0);
661      b = 0x06 * bit4 + 0x0d * bit0 + 0x1e * bit1 + 0x41 * bit2 + 0x8a * bit3;
1364         /* Clamp */
1365         if (y_offs < 64)
1366            y_offs |= 0xc0;
1367      }
6621368
663      colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
664   }
1369      if ( (y_offs >= 64) && (y_offs < 128) )
1370         x_offs = scroll_x;
1371      else
1372         x_offs = 0;
6651373
666   /* color_prom now points to the beginning of the lookup table */
667   color_prom += 0x400;
6681374
669   /* Characters use colours 192-255 */
670   for (i = 0; i < 0x100; i++)
671   {
672      UINT8 ctabentry = 0xc0 | (((i & 0xc0) >> 2)) | (color_prom[i] & 0x0f);
673      colortable_entry_set_value(machine->colortable, i, ctabentry);
674   }
675}
1375      y_gran = y_offs & 7;
6761376
677WRITE16_HANDLER( buggyboy_vram_w )
678{
679   COMBINE_DATA(&buggyboy_vram[offset]);
680   tilemap_mark_tile_dirty(buggyboy_tilemap, offset);
681}
1377      if (x_offs & 7)
1378      {
1379         UINT32 tilenum;
1380         UINT16 ram_val;
6821381
683WRITE16_HANDLER( buggybjr_vram_w )
684{
685   COMBINE_DATA(&buggybjr_vram[offset]);
686}
1382         if (wide)
1383            ram_val = buggyboy_vram[((y_offs << 4) & 0xf80) + ((x_offs >> 3) & 0x7f)];
1384         else
1385            ram_val = buggyboy_vram[((y_offs << 3) & 0x7c0) + ((x_offs >> 3) & 0x3f)];
6871386
688static TILE_GET_INFO( get_buggyboy_tile_info )
689{
690   int color, tilenum;
1387         tilenum = (ram_val & 0x03ff) | ((ram_val & 0x8000) >> 5);
1388         colour = (ram_val & 0xfc00) >> 8;
1389         d0 = *(gfx2 + (tilenum << 3) + y_gran);
1390         d1 = *(gfx1 + (tilenum << 3) + y_gran);
1391      }
6911392
692   color = (buggyboy_vram[tile_index] >> 10) & 0x3f;
693   tilenum = (buggyboy_vram[tile_index]&0x03ff) | ((buggyboy_vram[tile_index] & 0x8000) >> 5);
1393      for (x = 0; x < total_width; ++x)
1394      {
1395         UINT32 x_gran = x_offs & 7;
6941396
695   SET_TILE_INFO(0, tilenum, color, 0);
1397         if (!x_gran)
1398         {
1399            UINT32 tilenum;
1400            UINT16 ram_val;
1401
1402            if (wide)
1403               ram_val = buggyboy_vram[((y_offs << 4) & 0xf80) + ((x_offs >> 3) & 0x7f)];
1404            else
1405               ram_val = buggyboy_vram[((y_offs << 3) & 0x7c0) + ((x_offs >> 3) & 0x3f)];
1406
1407            tilenum = (ram_val & 0x03ff) | ((ram_val & 0x8000) >> 5);
1408            colour = (ram_val & 0xfc00) >> 8;
1409            d0 = *(gfx2 + (tilenum << 3) + y_gran);
1410            d1 = *(gfx1 + (tilenum << 3) + y_gran);
1411         }
1412
1413         *bitmap++ = colour |
1414                  (((d1 >> (7 ^ x_gran)) & 1) << 1) |
1415                  ((d0 >> (7 ^ x_gran)) & 1);
1416
1417         x_offs = (x_offs + 1) & x_mask;
1418      }
1419   }
6961420}
6971421
1422
6981423/***************************************************************************
6991424
7001425  Buggy Boy Road Hardware
r3333r3334
7321457  http://philwip.mameworld.info/buggyboy/PAL16L8.150.htm
7331458
7341459***************************************************************************/
735static void buggybjr_draw_road(running_machine *machine, UINT8 *bitmap)
1460
1461static void buggybjr_draw_road(running_machine *machine, UINT8 *bitmap, int wide)
7361462{
7371463#define X_ADJUST 384
7381464#define LOAD_HPOS_COUNTER( NUM )                                    \
r3333r3334
8331559
8341560      UINT32   bank_cnt;
8351561      UINT8   roadpix;
1562      UINT32   _rorevcs = 0;
8361563
8371564      rva8 = (vregs.h_val & 0x8000) || !(vregs.shift & 0x80);
8381565
r3333r3334
9071634         UINT32   rom_en;
9081635         UINT32   pix;
9091636         UINT32   hp0_en, hp1_en, hp2_en, hp3_en;
910         UINT32   _rorevcs = 0;
9111637
9121638         /* The many PALs */
9131639
r3333r3334
9481674         hp2_en = !(hp2_cy || hps22);
9491675         hp3_en = !(hp3_cy || hps32);
9501676
951         _rorevcs = !( (rom_en && rom_flip) || (!rom_en && (ls161 & 0x4000)) );
952
9531677         /* Load in a new road gfx strip */
9541678         if ( (ls161 & 7) == 0 )
9551679         {
9561680            UINT8 d0 = 0;
9571681            UINT8 d1 = 0;
9581682
1683            /* I think it's correct to latch it here */
1684            _rorevcs = !( (rom_en && rom_flip) || (!rom_en && (ls161 & 0x4000)) );
1685
9591686            /* TODO: ROM data is 0xff if not enabled. */
9601687            if (rom_en)
9611688            {
r3333r3334
12281955      /* Finally, increment the banking accumulator */
12291956      vregs.ba_val = (vregs.ba_val + vregs.ba_inc) & 0x00ffffff;
12301957      }
1231
1232   profiler_mark(PROFILER_END);
12331958}
12341959
12351960
r3333r3334
12551980    ------xx xxxxxxxx       X position
12561981
12571982**************************************************************************/
1258static void buggyboy_draw_objs(running_machine *machine, UINT8 *bitmap)
1983
1984static void buggyboy_draw_objs(running_machine *machine, UINT8 *bitmap, int wide)
12591985{
12601986#define FRAC   16
12611987
12621988   UINT32 offs;
12631989
1990   UINT32 x_mask;
1991   UINT32 x_stride;
1992
12641993   /* The many lookup table ROMs */
12651994   const UINT8 *const bug13  = (UINT8*)memory_region(machine, "user3");
12661995   const UINT8 *const bug18s = (UINT8*)memory_region(machine, "user3") + 0x2000;
r3333r3334
12742003
12752004   const UINT8 *const pixdata_rgn = (UINT8*)memory_region(machine, "gfx2");
12762005
1277   profiler_mark(PROFILER_USER2);
2006   if (wide)
2007   {
2008      x_mask = 0x7ff; // ???????
2009      x_stride = 768;
2010   }
2011   else
2012   {
2013      x_mask = 0x3ff;
2014      x_stride = 256;
2015   }
12782016
12792017   for (offs = 0; offs <= buggyboy_objram_size; offs += 8)
12802018   {
r3333r3334
13682106            x_acc = (psa0_12 & 0xff) << (FRAC + 5);
13692107
13702108            /* TODO Add note */
1371            x = buggyboy_objram[offs + 4] & 0x3ff;
2109            x = buggyboy_objram[offs + 4] & x_mask;
13722110
13732111            for (;;)
13742112            {
1375               #define MASK   0x3ff
1376
13772113               /* Get data and attributes for an 8x8 tile */
13782114               if (newtile)
13792115               {
r3333r3334
13832119                  UINT32   rombank;
13842120                  UINT8   *romptr;
13852121                  UINT32   bug18s_data;
1386                  UINT32   low_addr = ((x_acc >> (FRAC + 3)) & MASK);
2122                  UINT32   low_addr = ((x_acc >> (FRAC + 3)) & x_mask);
13872123
13882124                  /*
13892125                            Objects are grouped by width (either 16, 8 or 4 tiles) in
r3333r3334
14492185               }
14502186
14512187               /* Draw a pixel? */
1452               if (x < 256)
2188               if (x < x_stride)
14532189               {
14542190                  UINT8   pix;
14552191                  UINT8   bit;
r3333r3334
14762212                     else
14772213                        color = ~(color | bb9e[bb9_addr]) & 0x3f;
14782214
1479                     *(bitmap + 256*y + x) = 0x40 | color;
2215                     *(bitmap + x_stride*y + x) = 0x40 | color;
14802216                  }
14812217               }
14822218
14832219               /* Check if we've stepped into a new 8x8 tile */
1484               if ( (((x_acc + x_step) >> (FRAC + 3)) & MASK) != ((x_acc >> (FRAC + 3)) & MASK) )
2220               if ( (((x_acc + x_step) >> (FRAC + 3)) & x_mask) != ((x_acc >> (FRAC + 3)) & x_mask) )
14852221               {
14862222                  if (lasttile)
14872223                     break;
r3333r3334
14892225                  newtile = 1;
14902226               }
14912227
1492                 x = (x + 1) & 0x3ff;
2228               x = (x + 1) & x_mask;
14932229               x_acc += x_step;
14942230            }
14952231         }// if (yscale)
14962232         y_scale += y_step;
14972233      } /* for (y) */
14982234   }/* for (offs) */
1499
1500   profiler_mark(PROFILER_END);
15012235}
15022236
15032237
2238/*************************************
2239 *
2240 *  Video Control Registers
2241 *
2242 *************************************/
2243
15042244/*
15052245    2400-24FF is road control (R/W)
15062246
r3333r3334
15242264         vregs.ba_inc &= ~0x0000ffff;
15252265         vregs.ba_inc |= data;
15262266
1527         if ( !(offset & 2)  )
2267         if (!(offset & 2))
15282268            vregs.ba_val &= ~0x0000ffff;
15292269
15302270         break;
r3333r3334
15372277
15382278         vregs.bank_mode = data & 1;
15392279
1540         if ( !(offset & 2)  )
2280         if (!(offset & 2))
15412281            vregs.ba_val &= ~0xffff0000;
15422282
15432283         break;
r3333r3334
15452285      case 0x40:
15462286      {
15472287         /* Ignore data? */
1548         if ( offset & 2 )
1549         {
2288         if (offset & 2)
15502289            vregs.ba_val = (vregs.ba_inc + vregs.ba_val) & 0x00ffffff;
1551         }
15522290
15532291         break;
15542292      }
r3333r3334
15572295         vregs.h_inc = data;
15582296         vregs.shift = 0;
15592297
1560         if ( !(offset & 2)  )
2298         if (!(offset & 2))
15612299            vregs.h_val = 0;
15622300
15632301         break;
r3333r3334
15652303      case 0x80:
15662304      {
15672305         /* Ignore data? */
1568         if ( offset & 2 )
2306         if (offset & 2)
15692307            vregs.h_val += vregs.h_inc;
15702308         break;
15712309      }
r3333r3334
16072345}
16082346
16092347
2348/*************************************
2349 *
2350 *  Core Functions
2351 *
2352 *************************************/
16102353
1611VIDEO_START( buggyboy )
2354static void bb_combine_layers(running_machine *machine, bitmap_t *bitmap, int screen)
16122355{
1613   buggyboy_tilemap = tilemap_create(get_buggyboy_tile_info, tilemap_scan_rows,  8, 8, 128, 64);
1614   tilemap_set_transparent_pen(buggyboy_tilemap, 0);
1615}
2356   UINT8 *chr_pal = memory_region(machine, "proms") + 0x400;
2357   UINT32 bmp_stride;
2358   UINT32 x_offset;
2359   UINT32 y;
16162360
1617
1618
1619VIDEO_UPDATE( buggyboy )
1620{
1621   int xscrollamount = 0;
1622
1623   const device_config *left_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "left");
1624   const device_config *center_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "center");
1625   const device_config *right_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "right");
1626
1627   /* The video hardware seems to use one large tilemap, scroll it to the right position for each screen */
1628   if ( screen == left_screen )
1629      xscrollamount = 0 * 256;
1630   else if ( screen == center_screen )
1631      xscrollamount = 1 * 256;
1632   else if ( screen == right_screen )
1633      xscrollamount = 2 * 256;
1634
1635   tilemap_set_scrollx(buggyboy_tilemap, 0, xscrollamount);
1636   tilemap_draw(bitmap, cliprect, buggyboy_tilemap, TILEMAP_DRAW_OPAQUE, 0);
1637   return 0;
1638}
1639
1640
1641VIDEO_EOF( buggyboy )
1642{
1643   /* /VSYNC: Update TZ113 @ 219 */
1644   vregs.slin += vregs.slin_inc;
1645
1646   /* /VSYNC: Clear wave LFSR */
1647   vregs.wave_lfsr = 0;
1648}
1649
1650
1651VIDEO_START( buggybjr )
1652{
1653   /* Allocate some bitmaps */
1654   chr_bmp = auto_malloc(sizeof(UINT8) * 256 * 240);
1655   obj_bmp = auto_malloc(sizeof(UINT8) * 256 * 240);
1656   rod_bmp = auto_malloc(sizeof(UINT8) * 256 * 240);
1657}
1658
1659/*
1660    Draw the tilemap with scrolling
1661*/
1662static void buggyboy_draw_char(running_machine *machine, UINT8 *bitmap)
1663{
1664   INT32 x, y;
1665   UINT32 scroll_x, scroll_y;
1666   UINT8 *gfx1, *gfx2;
1667
1668   profiler_mark(PROFILER_USER3);
1669
1670   /* 2bpp characters */
1671   gfx1 = memory_region(machine, "gfx1");
1672   gfx2 = memory_region(machine, "gfx1") + 0x4000;
1673
1674   /* X/Y scroll values are the last word in char RAM */
1675   scroll_y = (buggybjr_vram[0x7ff] >> 10) & 0x3f;
1676   scroll_x = buggybjr_vram[0x7ff] & 0x1ff;
1677
1678   for (y = 0; y < 240; ++y)
2361   if (screen < 0)
16792362   {
1680      UINT32 d0 = 0, d1 = 0;
1681      UINT32 colour = 0;
1682      UINT32 y_offs;
1683      UINT32 x_offs;
1684      UINT32 y_gran;
1685
1686      /* There's no y-scrolling between scanlines 0 and 1 */
1687      if (y < 64)
1688         y_offs = y;
1689      else
1690      {
1691         y_offs = (y + (scroll_y | 0xc0) + 1) & 0xff;
1692
1693         /* Clamp */
1694         if (y_offs < 64)
1695            y_offs |= 0xc0;
1696      }
1697
1698      if ( (y_offs >= 64) && (y_offs < 128) )
1699         x_offs = scroll_x;
1700      else
1701         x_offs = 0;
1702
1703
1704      y_gran = y_offs & 7;
1705
1706      if (x_offs & 7)
1707      {
1708         UINT32 tilenum;
1709         UINT16 ram_val = buggybjr_vram[((y_offs << 3) & 0x7c0) + ((x_offs >> 3) & 0x3f)];
1710
1711         tilenum = (ram_val & 0x03ff) | ((ram_val & 0x8000) >> 5);
1712         colour = (ram_val & 0xfc00) >> 8;
1713         d0 = *(gfx2 + (tilenum << 3) + y_gran);
1714         d1 = *(gfx1 + (tilenum << 3) + y_gran);
1715      }
1716
1717      for (x = 0; x < 256; ++x)
1718      {
1719         UINT32 x_gran = x_offs & 7;
1720
1721         if (!x_gran)
1722         {
1723            UINT32 tilenum;
1724            UINT16 ram_val = buggybjr_vram[((y_offs << 3) & 0x7c0) + ((x_offs >> 3) & 0x3f)];
1725
1726            tilenum = (ram_val & 0x03ff) | ((ram_val & 0x8000) >> 5);
1727            colour = (ram_val & 0xfc00) >> 8;
1728            d0 = *(gfx2 + (tilenum << 3) + y_gran);
1729            d1 = *(gfx1 + (tilenum << 3) + y_gran);
1730         }
1731
1732         *bitmap++ = colour |
1733                  (((d1 >> (7 ^ x_gran)) & 1) << 1) |
1734                  ((d0 >> (7 ^ x_gran)) & 1);
1735
1736         x_offs = (x_offs + 1) & 0x1ff;
1737      }
1738
2363      bmp_stride = 256;
2364      x_offset = 0;
17392365   }
2366   else
2367   {
2368      bmp_stride = 768;
2369      x_offset = 256 * screen;
2370   }
17402371
1741   profiler_mark(PROFILER_END);
1742}
1743
1744VIDEO_UPDATE( buggybjr )
1745{
1746   int x, y;
1747   UINT8 *chr_pal = (memory_region(screen->machine, "proms") + 0x400);
1748
1749   memset(obj_bmp, 0, 256*240);
1750
1751   buggyboy_draw_char(screen->machine, chr_bmp);
1752   buggybjr_draw_road(screen->machine, rod_bmp);
1753   buggyboy_draw_objs(screen->machine, obj_bmp);
1754
17552372   for (y = 0; y < 240; ++y)
17562373   {
1757      UINT16 *bmp_addr = BITMAP_ADDR16(bitmap, y, 0);
2374      UINT32 x;
17582375
1759      UINT8 *chr_addr = chr_bmp + (y * 256);
1760      UINT8 *rod_addr = rod_bmp + (y * 256);
1761      UINT8 *obj_addr = obj_bmp + (y * 256);
2376      UINT32 bmp_offset = y * bmp_stride + x_offset;
17622377
2378      UINT8 *chr_addr = bb_chr_bmp + bmp_offset;
2379      UINT8 *rod_addr = bb_rod_bmp + bmp_offset;
2380      UINT8 *obj_addr = bb_obj_bmp + bmp_offset;
2381
17632382      UINT32 sky_en = BIT(vregs.sky, 7);
17642383      UINT32 sky_val = (((vregs.sky & 0x7f) + y) >> 2) & 0x3f;
17652384
2385      UINT16 *bmp_addr = BITMAP_ADDR16(bitmap, y, 0);
2386
17662387      for (x = 0; x < 256; ++x)
17672388      {
17682389         UINT32 out_val;
r3333r3334
17952416         *bmp_addr++ = (sel << 6) + out_val;
17962417      }
17972418   }
2419}
17982420
2421VIDEO_START( buggyboy )
2422{
2423   /* Allocate some bitmaps */
2424   bb_chr_bmp = auto_malloc(sizeof(UINT8) * 3 * 256 * 240);
2425   bb_obj_bmp = auto_malloc(sizeof(UINT8) * 3 * 256 * 240);
2426   bb_rod_bmp = auto_malloc(sizeof(UINT8) * 3 * 256 * 240);
2427}
2428
2429VIDEO_START( buggybjr )
2430{
2431   /* Allocate some bitmaps */
2432   bb_chr_bmp = auto_malloc(sizeof(UINT8) * 256 * 240);
2433   bb_obj_bmp = auto_malloc(sizeof(UINT8) * 256 * 240);
2434   bb_rod_bmp = auto_malloc(sizeof(UINT8) * 256 * 240);
2435}
2436
2437VIDEO_EOF( buggyboy )
2438{
2439   /* /VSYNC: Update TZ113 @ 219 */
2440   vregs.slin += vregs.slin_inc;
2441
2442   /* /VSYNC: Clear wave LFSR */
2443   vregs.wave_lfsr = 0;
2444}
2445
2446
2447VIDEO_UPDATE( buggyboy )
2448{
2449   const device_config *left_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "left");
2450   const device_config *center_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "center");
2451   const device_config *right_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "right");
2452
2453   if (screen == left_screen)
2454   {
2455      memset(bb_obj_bmp, 0, 768*240);
2456
2457      buggyboy_draw_char(screen->machine, bb_chr_bmp, 1);
2458//      buggyboy_draw_road(screen->machine, bb_rod_bmp, 1);
2459      buggyboy_draw_objs(screen->machine, bb_obj_bmp, 1);
2460
2461      bb_combine_layers(screen->machine, bitmap, 0);
2462   }
2463   else if (screen == center_screen)
2464   {
2465      bb_combine_layers(screen->machine, bitmap, 1);
2466   }
2467   else if (screen == right_screen)
2468   {
2469      bb_combine_layers(screen->machine, bitmap, 2);
2470   }
2471
17992472   return 0;
2473
18002474}
2475
2476VIDEO_UPDATE( buggybjr )
2477{
2478   memset(bb_obj_bmp, 0, 256*240);
2479
2480   buggyboy_draw_char(screen->machine, bb_chr_bmp, 0);
2481   buggybjr_draw_road(screen->machine, bb_rod_bmp, 0);
2482   buggyboy_draw_objs(screen->machine, bb_obj_bmp, 0);
2483
2484   bb_combine_layers(screen->machine, bitmap, -1);
2485   return 0;
2486}
src/mame/video/naughtyb.c
r3333r3334
4242   0*8, 28*8-1
4343};
4444
45static const res_net_decode_info naughtyb_decode_info =
46{
47   2,      /*  two proms          */
48   0,      /*  start at 0         */
49   255,   /*  end at 255         */
50   /*  R,   G,   B,   R,   G,   B */
51   {   0,   0,   0, 256, 256, 256},      /*  offsets */
52   {   0,   2,   1,  -1,   1,   0},      /*  shifts */
53   {0x01,0x01,0x01,0x02,0x02,0x02}          /*  masks */
54};
4555
56static const res_net_info naughtyb_net_info =
57{
58   RES_NET_VCC_5V | RES_NET_VBIAS_5V | RES_NET_VIN_OPEN_COL,
59   {
60      { RES_NET_AMP_NONE, 130, 270, 2, { 270, 1 } }, /* no resistor for bit1 */
61      { RES_NET_AMP_NONE, 130, 270, 2, { 270, 1 } }, /* no resistor for bit1 */
62      { RES_NET_AMP_NONE, 130, 270, 2, { 270, 1 } }  /* no resistor for bit1 */
63   }
64};
4665
4766/***************************************************************************
4867
r3333r3334
5069
5170  Naughty Boy has two 256x4 palette PROMs, one containing the high bits and
5271  the other the low bits (2x2x2 color space).
53  The palette PROMs are connected to the RGB output this way:
72  The palette PROMs are connected to a 7407 (hex open collector buffer),
73  which in turn is connected to the RGB output this way:
5474
5575  bit 3 --
5676        -- 270 ohm resistor  -- GREEN
r3333r3334
6282        -- BLUE
6383  bit 0 -- RED
6484
65  plus 270 ohm pullup and pulldown resistors on all lines
85  plus 130 ohm pullup and 270 ohm pulldown resistors on all lines
6686
6787***************************************************************************/
88
6889PALETTE_INIT( naughtyb )
6990{
70   /* note: there is no resistor on second PROM so we define second resistance as 0 */
71   static const int resistances[2] = { 270, 0 };
72   double rweights[2], gweights[2], bweights[2];
91   rgb_t   *rgb;
7392   int i;
7493
75   /* compute the color output resistor weights */
76   compute_resistor_weights(0,   255, -1.0,
77         2, resistances, rweights, 270, 270,
78         2, resistances, gweights, 270, 270,
79         2, resistances, bweights, 270, 270);
94   rgb = compute_res_net_all(color_prom, &naughtyb_decode_info, &naughtyb_net_info);
8095
8196   for (i = 0; i < 0x100; i++)
82   {
83      int bit0, bit1;
84      int r, g, b;
85      int swapped_i;
97      palette_set_color(machine, BITSWAP8(i,5,7,6,2,1,0,4,3), rgb[i]);
8698
87      /* red component */
88      bit0 = (color_prom[i | 0x000] >> 0) & 0x01;
89      bit1 = (color_prom[i | 0x100] >> 0) & 0x01;
90      r = combine_2_weights(rweights, bit0, bit1);
91
92      /* green component */
93      bit0 = (color_prom[i | 0x000] >> 2) & 0x01;
94      bit1 = (color_prom[i | 0x100] >> 2) & 0x01;
95      g = combine_2_weights(gweights, bit0, bit1);
96
97      /* blue component */
98      bit0 = (color_prom[i | 0x000] >> 1) & 0x01;
99      bit1 = (color_prom[i | 0x100] >> 1) & 0x01;
100      b = combine_2_weights(bweights, bit0, bit1);
101
102      swapped_i = BITSWAP8(i,5,7,6,2,1,0,4,3);
103      palette_set_color(machine, swapped_i, MAKE_RGB(r, g, b));
104   }
99   palette_normalize_range(machine->palette, 0, 255, 0, 255);
105100}
106101
107102
108
109103/***************************************************************************
110104
111105  Start the video hardware emulation.
src/mame/video/neogeo.c
r3333r3334
3535
3636static emu_timer *sprite_line_timer;
3737
38static const UINT8 *region_zoomy;
3839
3940
4041/*************************************
r3333r3334
504505            }
505506         }
506507
507         sprite_y_and_tile = memory_region(machine, "zoomy")[(zoom_y << 8) | zoom_line];
508         sprite_y_and_tile = region_zoomy[(zoom_y << 8) | zoom_line];
508509         sprite_y = sprite_y_and_tile & 0x0f;
509510         tile = sprite_y_and_tile >> 4;
510511
r3333r3334
902903   state_save_register_global(auto_animation_frame_counter);
903904
904905   state_save_register_postload(machine, regenerate_pens, NULL);
906
907   region_zoomy = memory_region(machine, "zoomy");
905908}
906909
907910
src/mame/video/taito_f3.c
r3333r3334
245245static const struct F3config f3_config_table[] =
246246{
247247   /* Name    Extend  Lag   Bpp */
248   { RINGRAGE,  0,     2,   5, 6 },
248   { RINGRAGE,  0,     2,   4, 4 },
249249   { ARABIANM,  0,     2,   5, 5 },   /* sprites 1200-120F contain 6bpp pixels but this seems to be a data error */
250250   { RIDINGF,   1,     1,   4, 4 },
251251   { GSEEKER,   0,     1,   4, 4 },
r3333r3334
270270   { KTIGER2,   0,     0,   4, 4 },
271271   { BUBBLEM,   1,     1,   4, 5 },
272272   { CLEOPATR,  0,     1,   4, 6 },
273   { PBOBBLE3,  0,     1,   4, 6 },
273   { PBOBBLE3,  0,     1,   4, 4 },
274274   { ARKRETRN,  1,     1,   5, 6 },
275275   { KIRAMEKI,  0,     1,   5, 6 },
276276   { PUCHICAR,  1,     1,   5, 6 },
277   { PBOBBLE4,  0,     1,   4, 6 },
277   { PBOBBLE4,  0,     1,   4, 4 },
278278   { POPNPOP,   1,     1,   6, 6 },
279279   { LANDMAKR,  1,     1,   5, 6 },
280280   {0}
r3333r3334
690690   tilemap_set_transparent_pen(vram_layer,0);
691691   tilemap_set_transparent_pen(pixel_layer,0);
692692
693   // Palettes have 4 bpp indexes despite up to 6 bpp data. The unused
694   // top bits in the gfx data are cleared later.
693   /* Palettes have 4 bpp indexes despite up to 6 bpp data. The unused */
694   /* top bits in the gfx data are cleared later.                      */
695695   machine->gfx[1]->color_granularity=16;
696696   machine->gfx[2]->color_granularity=16;
697697
r3333r3334
25572557
25582558            /*
25592559                    sprite priority==playfield priority
2560                        GSEEKER (plane leaving hangar) --> sprite
25602561                        BUBSYMPH (title)       ---> sprite
25612562                        DARIUSG (ZONE V' BOSS) ---> playfield
25622563                */
25632564
25642565            if (f3_game == BUBSYMPH ) sp++;      //BUBSYMPH (title)
2566            if (f3_game == GSEEKER ) sp++;      //GSEEKER (plane leaving hangar)
25652567
25662568                if(        sp>l0) sprite[0]|=sflg;
25672569            else if(sp<=l0 && sp>l1) sprite[1]|=sflg;
src/mame/drivers/senjyo.c
r3333r3334
979979ROM_END
980980
981981
982DRIVER_INIT( starforc )
982static DRIVER_INIT( starforc )
983983{
984984   is_senjyo = 0;
985985   senjyo_scrollhack = 1;
986986}
987DRIVER_INIT( starfore )
987static DRIVER_INIT( starfore )
988988{
989989   /* encrypted CPU */
990990   suprloco_decode(machine, "main");
r3333r3334
993993   senjyo_scrollhack = 0;
994994}
995995
996DRIVER_INIT( starfora )
996static DRIVER_INIT( starfora )
997997{
998998   /* encrypted CPU */
999999   yamato_decode(machine, "main");
r3333r3334
10021002   senjyo_scrollhack = 1;
10031003}
10041004
1005DRIVER_INIT( senjyo )
1005static DRIVER_INIT( senjyo )
10061006{
10071007   is_senjyo = 1;
10081008   senjyo_scrollhack = 0;
src/mame/drivers/system1.c
r3333r3334
395395ADDRESS_MAP_END
396396
397397
398#define COINAGE_PORT \
399   PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW A:1,2,3,4") \
400   PORT_DIPSETTING(   0x07, DEF_STR( 4C_1C ) ) \
401   PORT_DIPSETTING(   0x08, DEF_STR( 3C_1C ) ) \
402   PORT_DIPSETTING(   0x09, DEF_STR( 2C_1C ) ) \
403   PORT_DIPSETTING(   0x05, "2 Coins/1 Credit 4/2 5/3 6/4" ) \
404   PORT_DIPSETTING(   0x04, "2 Coins/1 Credit 4/3" ) \
405   PORT_DIPSETTING(   0x0f, DEF_STR( 1C_1C ) ) \
406/*  PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) Not allowed by mame coinage sorting, but valid */ \
407   PORT_DIPSETTING(   0x03, "1 Coin/1 Credit 5/6" ) \
408   PORT_DIPSETTING(   0x02, "1 Coin/1 Credit 4/5" ) \
409   PORT_DIPSETTING(   0x01, "1 Coin/1 Credit 2/3" ) \
410   PORT_DIPSETTING(   0x06, DEF_STR( 2C_3C ) ) \
411   PORT_DIPSETTING(   0x0e, DEF_STR( 1C_2C ) ) \
412   PORT_DIPSETTING(   0x0d, DEF_STR( 1C_3C ) ) \
413   PORT_DIPSETTING(   0x0c, DEF_STR( 1C_4C ) ) \
414   PORT_DIPSETTING(   0x0b, DEF_STR( 1C_5C ) ) \
415   PORT_DIPSETTING(   0x0a, DEF_STR( 1C_6C ) ) \
416   PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW A:5,6,7,8") \
417   PORT_DIPSETTING(   0x70, DEF_STR( 4C_1C ) ) \
418   PORT_DIPSETTING(   0x80, DEF_STR( 3C_1C ) ) \
419   PORT_DIPSETTING(   0x90, DEF_STR( 2C_1C ) ) \
420   PORT_DIPSETTING(   0x50, "2 Coins/1 Credit 4/2 5/3 6/4" ) \
421   PORT_DIPSETTING(   0x40, "2 Coins/1 Credit 4/3" ) \
422   PORT_DIPSETTING(   0xf0, DEF_STR( 1C_1C ) ) \
423/*  PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) Not allowed by mame coinage sorting, but valid */ \
424   PORT_DIPSETTING(   0x30, "1 Coin/1 Credit 5/6" ) \
425   PORT_DIPSETTING(   0x20, "1 Coin/1 Credit 4/5" ) \
426   PORT_DIPSETTING(   0x10, "1 Coin/1 Credit 2/3" ) \
427   PORT_DIPSETTING(   0x60, DEF_STR( 2C_3C ) ) \
428   PORT_DIPSETTING(   0xe0, DEF_STR( 1C_2C ) ) \
429   PORT_DIPSETTING(   0xd0, DEF_STR( 1C_3C ) ) \
430   PORT_DIPSETTING(   0xc0, DEF_STR( 1C_4C ) ) \
431   PORT_DIPSETTING(   0xb0, DEF_STR( 1C_5C ) ) \
432   PORT_DIPSETTING(   0xa0, DEF_STR( 1C_6C ) )
398/*************************************
399 *
400 *  Generic port definitions
401 *
402 *************************************/
433403
434/* If you don't like the description, feel free to change it */
435#define DSW0_BIT7 \
436   PORT_DIPNAME( 0x80, 0x80, "SW 0 Read From" ) \
437   PORT_DIPSETTING(   0x80, "Port $0D" ) \
438   PORT_DIPSETTING(   0x00, "Port $10" )
439
440static INPUT_PORTS_START( common )
404static INPUT_PORTS_START( system1_generic )
441405   PORT_START("P1")
442406   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
443407   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )
r3333r3334
468432   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
469433   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
470434
435   PORT_START("DSW1")
436   PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "SWB:1" )
437   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SWB:2" )
438   PORT_DIPUNUSED_DIPLOC( 0x04, 0x04, "SWB:3" )
439   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SWB:4" )
440   PORT_DIPUNUSED_DIPLOC( 0x10, 0x10, "SWB:5" )
441   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SWB:6" )
442   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SWB:7" )
443/* If you don't like the description, feel free to change it */
444   PORT_DIPNAME( 0x80, 0x80, "SW 0 Read From" ) PORT_DIPLOCATION("SWB:8")
445   PORT_DIPSETTING(   0x80, "Port $0D" )
446   PORT_DIPSETTING(   0x00, "Port $10" )
447
471448   PORT_START("DSW2")
472   COINAGE_PORT
449   PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWA:1,2,3,4")
450   PORT_DIPSETTING(    0x07, DEF_STR( 4C_1C ) )
451   PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) )
452   PORT_DIPSETTING(    0x09, DEF_STR( 2C_1C ) )
453   PORT_DIPSETTING(    0x05, "2 Coins/1 Credit 5/3 6/4" )
454   PORT_DIPSETTING(    0x04, "2 Coins/1 Credit 4/3" )
455   PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
456   PORT_DIPSETTING(    0x01, "1 Coin/1 Credit 2/3" )
457   PORT_DIPSETTING(    0x02, "1 Coin/1 Credit 4/5" )
458   PORT_DIPSETTING(    0x03, "1 Coin/1 Credit 5/6" )
459   PORT_DIPSETTING(    0x06, DEF_STR( 2C_3C ) )
460   PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
461   PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
462   PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
463   PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
464   PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
465/*  PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) Not allowed by mame coinage sorting, but valid */
466   PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SWA:5,6,7,8")
467   PORT_DIPSETTING(    0x70, DEF_STR( 4C_1C ) )
468   PORT_DIPSETTING(    0x80, DEF_STR( 3C_1C ) )
469   PORT_DIPSETTING(    0x90, DEF_STR( 2C_1C ) )
470   PORT_DIPSETTING(    0x50, "2 Coins/1 Credit 5/3 6/4" )
471   PORT_DIPSETTING(    0x40, "2 Coins/1 Credit 4/3" )
472   PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
473   PORT_DIPSETTING(    0x10, "1 Coin/1 Credit 2/3" )
474   PORT_DIPSETTING(    0x20, "1 Coin/1 Credit 4/5" )
475   PORT_DIPSETTING(    0x30, "1 Coin/1 Credit 5/6" )
476   PORT_DIPSETTING(    0x60, DEF_STR( 2C_3C ) )
477   PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
478   PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
479   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
480   PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
481   PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
482/*  PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) Not allowed by mame coinage sorting, but valid */
473483INPUT_PORTS_END
474484
485/*************************************
486 *
487 *  Game-specific port definitions
488 *
489 *************************************/
475490
476491static INPUT_PORTS_START( starjack )
477   PORT_INCLUDE( common )
492   PORT_INCLUDE( system1_generic )
478493
479   PORT_START("DSW1")
494   PORT_MODIFY("DSW1")
480495   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
481496   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
482497   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
502517INPUT_PORTS_END
503518
504519static INPUT_PORTS_START( starjacs )
505   PORT_INCLUDE( common )
520   PORT_INCLUDE( starjack )
506521
507   PORT_START("DSW1")
508   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
509   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
510   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
511   PORT_DIPNAME( 0x06, 0x06, DEF_STR( Lives ) )
512   PORT_DIPSETTING(   0x06, "3" )
513   PORT_DIPSETTING(   0x04, "4" )
514   PORT_DIPSETTING(   0x02, "5" )
515   PORT_DIPSETTING(   0x00, DEF_STR( Infinite ) )
522   PORT_MODIFY("DSW1")
516523   PORT_DIPNAME( 0x08, 0x08, "Ship" )
517524   PORT_DIPSETTING(   0x08, DEF_STR( Single ) )
518525   PORT_DIPSETTING(   0x00, "Multi" )
r3333r3334
521528   PORT_DIPSETTING(   0x20, "40k, then every 50k" )
522529   PORT_DIPSETTING(   0x10, "50k, then every 60k" )
523530   PORT_DIPSETTING(   0x00, "60k, then every 70k" )
524   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Difficulty ) )
525   PORT_DIPSETTING(   0xc0, DEF_STR( Easy ) )
526   PORT_DIPSETTING(   0x80, DEF_STR( Medium ) )
527   PORT_DIPSETTING(   0x40, DEF_STR( Hard ) )
528   PORT_DIPSETTING(   0x00, DEF_STR( Hardest ) )
529531INPUT_PORTS_END
530532
531533static INPUT_PORTS_START( regulus )
532   PORT_INCLUDE( common )
534   PORT_INCLUDE( system1_generic )
533535
534   PORT_START("DSW1")
536   PORT_MODIFY("DSW1")
535537   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
536538   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
537539   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
568570INPUT_PORTS_END
569571
570572static INPUT_PORTS_START( upndown )
571   PORT_INCLUDE( common )
573   PORT_INCLUDE( system1_generic )
572574
573575   PORT_MODIFY("P1")
574576   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* no button 2 */
r3333r3334
576578   PORT_MODIFY("P2")
577579   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* no button 2 */
578580
579   PORT_START("DSW1")
581   PORT_MODIFY("DSW1")
580582   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
581583   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
582584   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
602604INPUT_PORTS_END
603605
604606static INPUT_PORTS_START( mrviking )
605   PORT_INCLUDE( common )
607   PORT_INCLUDE( system1_generic )
606608
607609   PORT_MODIFY("P1")
608610   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
r3333r3334
612614   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
613615   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
614616
615   PORT_START("DSW1")
617   PORT_MODIFY("DSW1")
616618   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
617619   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
618620   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
632634   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) )
633635   PORT_DIPSETTING(   0x40, DEF_STR( Easy ) )
634636   PORT_DIPSETTING(   0x00, DEF_STR( Hard ) )
635   DSW0_BIT7
636637INPUT_PORTS_END
637638
638639/* Same as 'mrviking', but no "Maximum Credits" Dip Switch and "Difficulty" Dip Switch is
r3333r3334
653654INPUT_PORTS_END
654655
655656static INPUT_PORTS_START( swat )
656   PORT_INCLUDE( common )
657   PORT_INCLUDE( system1_generic )
657658
658   PORT_MODIFY("P1")
659   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
660   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY
661   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY
662   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY
663
664   PORT_MODIFY("P2")
665   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL
666   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL
667   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_COCKTAIL
668   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL
669
670   PORT_START("DSW1")
659   PORT_MODIFY("DSW1")
671660   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
672661   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
673662   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
694683INPUT_PORTS_END
695684
696685static INPUT_PORTS_START( flicky )
697   PORT_INCLUDE( common )
686   PORT_INCLUDE( system1_generic )
698687
699688   PORT_MODIFY("P1")
700689   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* no button 2 */
r3333r3334
707696   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* no button 2 */
708697   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* only 2way inputs */
709698   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* only 2way inputs */
710   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
711   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
699   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL
700   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
712701
713   PORT_START("DSW1")
702   PORT_MODIFY("DSW1")
714703   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
715704   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
716705   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
730719   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) )
731720   PORT_DIPSETTING(   0x40, DEF_STR( Easy ) )
732721   PORT_DIPSETTING(   0x00, DEF_STR( Hard ) )
733   DSW0_BIT7
734722INPUT_PORTS_END
735723
736724static INPUT_PORTS_START( wmatch )
737   PORT_START("P1")
725   PORT_INCLUDE( system1_generic )
726
727   PORT_MODIFY("P1")
738728   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_DOWN ) PORT_8WAY
739729   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_UP ) PORT_8WAY
740730   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_RIGHT ) PORT_8WAY
r3333r3334
744734   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_RIGHT ) PORT_8WAY
745735   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_LEFT ) PORT_8WAY
746736
747   PORT_START("P2")
737   PORT_MODIFY("P2")
748738   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_DOWN ) PORT_8WAY PORT_COCKTAIL
749739   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_UP ) PORT_8WAY PORT_COCKTAIL
750740   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_RIGHT ) PORT_8WAY PORT_COCKTAIL
r3333r3334
754744   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_RIGHT ) PORT_8WAY PORT_COCKTAIL
755745   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_LEFT ) PORT_8WAY PORT_COCKTAIL
756746
757   PORT_START("SYSTEM")
758   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
759   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
760   PORT_SERVICE_NO_TOGGLE( 0x04, IP_ACTIVE_LOW )
761   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE1 )
762   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
763   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
764   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 )            /* TURN P1 */
747   PORT_MODIFY("SYSTEM")
748   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 )         /* TURN P1 */
765749   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL   /* TURN P2 */
766750
767   PORT_START("DSW2")
768   COINAGE_PORT
769
770   PORT_START("DSW1")
751   PORT_MODIFY("DSW1")
771752   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
772753   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
773754   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
788769   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) )
789770   PORT_DIPSETTING(   0x40, DEF_STR( Easy ) )
790771   PORT_DIPSETTING(   0x00, DEF_STR( Hard ) )
791   DSW0_BIT7
792772INPUT_PORTS_END
793773
794774static INPUT_PORTS_START( bullfgt )
795   PORT_INCLUDE( common )
775   PORT_INCLUDE( system1_generic )
796776
797   PORT_START("DSW1")
777   PORT_MODIFY("DSW1")
798778   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
799779   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
800780   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
811791   PORT_DIPSETTING(   0x20, "50000" )
812792   PORT_DIPSETTING(   0x10, "70000" )
813793   PORT_DIPSETTING(   0x00, DEF_STR( None ) )
814   PORT_DIPNAME( 0x40, 0x40, "Unused SW 0-6" )
815   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
816   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
817   DSW0_BIT7
818794INPUT_PORTS_END
819795
820796static INPUT_PORTS_START( spatter )
821   PORT_INCLUDE( common )
797   PORT_INCLUDE( system1_generic )
822798
823   PORT_START("DSW1")
799   PORT_MODIFY("DSW1")
824800   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
825801   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
826802   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
840816   PORT_DIPNAME( 0x40, 0x40, "Reset Timer/Objects On Life Loss" )
841817   PORT_DIPSETTING(   0x40, DEF_STR( No ) )
842818   PORT_DIPSETTING(   0x00, DEF_STR( Yes ) )
843   DSW0_BIT7
844819INPUT_PORTS_END
845820
846821static INPUT_PORTS_START( pitfall2 )
847   PORT_INCLUDE( common )
822   PORT_INCLUDE( system1_generic )
848823
849   PORT_START("DSW1")
824   PORT_MODIFY("DSW1")
850825   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
851826   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
852827   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
873848INPUT_PORTS_END
874849
875850static INPUT_PORTS_START( pitfallu )
876   PORT_INCLUDE( common )
851   PORT_INCLUDE( pitfall2 )
877852
878   PORT_START("DSW1")  /* DSW0 */
879   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
880   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
881   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
853   PORT_MODIFY("DSW1")
882854   PORT_DIPNAME( 0x06, 0x06, DEF_STR( Lives ) )
883855   PORT_DIPSETTING(   0x06, "3" )
884856   PORT_DIPSETTING(   0x04, "4" )
r3333r3334
889861   PORT_DIPSETTING(   0x10, "2" )
890862   PORT_DIPSETTING(   0x08, "3" )
891863   PORT_DIPSETTING(   0x00, "4" )
892   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Allow_Continue ) )
893   PORT_DIPSETTING(   0x20, DEF_STR( No ) )
894   PORT_DIPSETTING(   0x00, DEF_STR( Yes ) )
895   PORT_DIPNAME( 0x40, 0x40, "Time" )
896   PORT_DIPSETTING(   0x00, "2 Minutes" )
897   PORT_DIPSETTING(   0x40, "3 Minutes" )
898   PORT_DIPNAME( 0x80, 0x80, "Unused SW 0-7" )
899   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
900   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
901864INPUT_PORTS_END
902865
903866static INPUT_PORTS_START( seganinj )
904   PORT_INCLUDE( common )
867   PORT_INCLUDE( system1_generic )
905868
906869   PORT_MODIFY("P1")
907870   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 )
r3333r3334
909872   PORT_MODIFY("P1")
910873   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_COCKTAIL
911874
912   PORT_START("DSW1")
875   PORT_MODIFY("DSW1")
913876   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
914877   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
915878   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
930893   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) )
931894   PORT_DIPSETTING(   0x40, DEF_STR( Easy ) )
932895   PORT_DIPSETTING(   0x00, DEF_STR( Hard ) )
933   DSW0_BIT7
934896INPUT_PORTS_END
935897
936898static INPUT_PORTS_START( imsorry )
937   PORT_INCLUDE( common )
899   PORT_INCLUDE( system1_generic )
938900
939   PORT_START("DSW1")
901   PORT_MODIFY("DSW1")
940902   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
941903   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
942904   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
956918   PORT_DIPNAME( 0x40, 0x40, "Unused SW 0-6" )
957919   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
958920   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
959   DSW0_BIT7
960921INPUT_PORTS_END
961922
962923static INPUT_PORTS_START( teddybb )
963   PORT_INCLUDE( common )
924   PORT_INCLUDE( system1_generic )
964925
965926   PORT_MODIFY("P1")
966927   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
r3333r3334
970931   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
971932   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
972933
973   PORT_START("DSW1")
934   PORT_MODIFY("DSW1")
974935   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
975936   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
976937   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
990951   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) )
991952   PORT_DIPSETTING(   0x40, DEF_STR( Easy ) )
992953   PORT_DIPSETTING(   0x00, DEF_STR( Hard ) )
993   DSW0_BIT7
994954INPUT_PORTS_END
995955
996956static INPUT_PORTS_START( hvymetal )
997   PORT_INCLUDE( common )
957   PORT_INCLUDE( system1_generic )
998958
999959   PORT_MODIFY("P1")
1000960   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
r3333r3334
1004964   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
1005965   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
1006966
1007   PORT_START("DSW1")
967   PORT_MODIFY("DSW1")
1008968   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
1009969   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
1010970   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
1030990INPUT_PORTS_END
1031991
1032992static INPUT_PORTS_START( myhero )
1033   PORT_INCLUDE( common )
993   PORT_INCLUDE( system1_generic )
1034994
1035995   PORT_MODIFY("P1")
1036996   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
r3333r3334
10401000   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
10411001   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
10421002
1043   PORT_START("DSW1")
1003   PORT_MODIFY("DSW1")
10441004   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
10451005   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
10461006   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
10601020   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) )
10611021   PORT_DIPSETTING(   0x40, DEF_STR( Easy ) )
10621022   PORT_DIPSETTING(   0x00, DEF_STR( Hard ) )
1063   DSW0_BIT7
10641023INPUT_PORTS_END
10651024
1025static INPUT_PORTS_START( chplft )
1026   PORT_INCLUDE( system1_generic )
1027
1028   PORT_MODIFY("DSW1")
1029   PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWA:1,2,3,4")
1030   PORT_DIPSETTING(    0x07, DEF_STR( 4C_1C ) )
1031   PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) )
1032   PORT_DIPSETTING(    0x09, DEF_STR( 2C_1C ) )
1033   PORT_DIPSETTING(    0x05, "2 Coins/1 Credit 5/3 6/4" )
1034   PORT_DIPSETTING(    0x04, "2 Coins/1 Credit 4/3" )
1035   PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
1036   PORT_DIPSETTING(    0x01, "1 Coin/1 Credit 2/3" )
1037   PORT_DIPSETTING(    0x02, "1 Coin/1 Credit 4/5" )
1038   PORT_DIPSETTING(    0x03, "1 Coin/1 Credit 5/6" )
1039   PORT_DIPSETTING(    0x06, DEF_STR( 2C_3C ) )
1040   PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
1041   PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
1042   PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
1043   PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
1044   PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
1045   PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SWA:5,6,7,8")
1046   PORT_DIPSETTING(    0x70, DEF_STR( 4C_1C ) )
1047   PORT_DIPSETTING(    0x80, DEF_STR( 3C_1C ) )
1048   PORT_DIPSETTING(    0x90, DEF_STR( 2C_1C ) )
1049   PORT_DIPSETTING(    0x50, "2 Coins/1 Credit 5/3 6/4" )
1050   PORT_DIPSETTING(    0x40, "2 Coins/1 Credit 4/3" )
1051   PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
1052   PORT_DIPSETTING(    0x10, "1 Coin/1 Credit 2/3" )
1053   PORT_DIPSETTING(    0x20, "1 Coin/1 Credit 4/5" )
1054   PORT_DIPSETTING(    0x30, "1 Coin/1 Credit 5/6" )
1055   PORT_DIPSETTING(    0x60, DEF_STR( 2C_3C ) )
1056   PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
1057   PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
1058   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
1059   PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
1060   PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
1061
1062   PORT_MODIFY("DSW2")
1063   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SWB:1")
1064   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
1065   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
1066   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SWB:2")
1067   PORT_DIPSETTING(   0x02, DEF_STR( Off ) )
1068   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
1069   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWB:3,4")
1070   PORT_DIPSETTING(   0x08, "2" )
1071   PORT_DIPSETTING(   0x0c, "3" )
1072   PORT_DIPSETTING(   0x04, "4" )
1073   PORT_DIPSETTING(   0x00, DEF_STR( Free_Play ) )
1074   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SWB:5")
1075   PORT_DIPSETTING(   0x10, "20k 70k 120k 170k" )
1076   PORT_DIPSETTING(   0x00, "50k 100k 150k 200k" )
1077   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SWB:6")
1078   PORT_DIPSETTING(   0x00, DEF_STR( Hard ) )
1079   PORT_DIPSETTING(   0x20, DEF_STR( Easy ) )
1080   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) ) PORT_DIPLOCATION("SWB:7")
1081   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
1082   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
1083   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) ) PORT_DIPLOCATION("SWB:8")
1084   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
1085   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
1086INPUT_PORTS_END
1087
10661088static INPUT_PORTS_START( shtngmst )
1067   PORT_START("P1")
1068   /*
1069    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1070    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )
1071    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 )
1072    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1073    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
1074    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
1075    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
1076    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
1077    */
1089   PORT_INCLUDE( chplft )
10781090
1079   PORT_START("P2")
1080   /*
1081    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1082    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
1083    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
1084    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1085    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
1086    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
1087    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
1088    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
1089    */
1091   PORT_MODIFY("P1")
1092   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
10901093
1091   PORT_START("SYSTEM")
1092   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
1093   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
1094   PORT_SERVICE_NO_TOGGLE( 0x04, IP_ACTIVE_LOW )
1095   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE1 )
1096   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
1097   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
1098   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1099   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1094   PORT_MODIFY("P2")
1095   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
11001096
1101   PORT_START("DSW2")
1097   PORT_MODIFY("DSW2")
11021098   PORT_DIPNAME( 0x01, 0x01, "DSW2" )
11031099   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
11041100   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
r3333r3334
11241120   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
11251121   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
11261122
1127   PORT_START("DSW1")
1128   COINAGE_PORT
1129
11301123   PORT_START("TRIGGER")  /* trigger is in here */
11311124   PORT_BIT( 0x3f, IP_ACTIVE_LOW, IPT_UNUSED )
11321125   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 )
r3333r3334
11691162   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
11701163INPUT_PORTS_END
11711164
1172
1173static INPUT_PORTS_START( chplft )
1174   PORT_INCLUDE( common )
1175
1176   PORT_MODIFY("DSW2")
1177   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW B:1")
1178   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
1179   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
1180   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW B:2")
1181   PORT_DIPSETTING(   0x02, DEF_STR( Off ) )
1182   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
1183   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW B:3,4")
1184   PORT_DIPSETTING(   0x08, "2" )
1185   PORT_DIPSETTING(   0x0c, "3" )
1186   PORT_DIPSETTING(   0x04, "4" )
1187   PORT_DIPSETTING(   0x00, DEF_STR( Free_Play ) )
1188   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW B:5")
1189   PORT_DIPSETTING(   0x10, "20k 70k 120k 170k" )
1190   PORT_DIPSETTING(   0x00, "50k 100k 150k 200k" )
1191   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW B:6")
1192   PORT_DIPSETTING(   0x00, DEF_STR( Hard ) )
1193   PORT_DIPSETTING(   0x20, DEF_STR( Easy ) )
1194   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW B:7")
1195   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
1196   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
1197   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW B:8")
1198   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
1199   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
1200
1201   PORT_START("DSW1")
1202   COINAGE_PORT
1203INPUT_PORTS_END
1204
12051165static INPUT_PORTS_START( 4dwarrio )
1206   PORT_INCLUDE( common )
1166   PORT_INCLUDE( system1_generic )
12071167
1208   PORT_START("DSW1")
1168   PORT_MODIFY("DSW1")
12091169   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
12101170   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
12111171   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
12261186   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) )
12271187   PORT_DIPSETTING(   0x40, DEF_STR( Easy ) )
12281188   PORT_DIPSETTING(   0x00, DEF_STR( Hard ) )
1229   DSW0_BIT7
12301189INPUT_PORTS_END
12311190
12321191static INPUT_PORTS_START( brain )
1233   PORT_INCLUDE( common )
1192   PORT_INCLUDE( system1_generic )
12341193
1235   PORT_START("DSW1")
1194   PORT_MODIFY("DSW1")
12361195   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
12371196   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
12381197   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
12591218INPUT_PORTS_END
12601219
12611220static INPUT_PORTS_START( gardia )
1262   PORT_INCLUDE( common )
1221   PORT_INCLUDE( system1_generic )
12631222
1264   PORT_START("DSW1")
1223   PORT_MODIFY("DSW1")
12651224   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
12661225   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
12671226   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
r3333r3334
12871246INPUT_PORTS_END
12881247
12891248static INPUT_PORTS_START( raflesia )
1290   PORT_INCLUDE( common )
1249   PORT_INCLUDE( system1_generic )
12911250
1292   PORT_START("DSW1")
1251   PORT_MODIFY("DSW1")
12931252   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
12941253   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
12951254   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
13091268   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) ) /* Manual lists this dip as "Unused" */
13101269   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
13111270   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
1312   DSW0_BIT7
13131271INPUT_PORTS_END
13141272
13151273static INPUT_PORTS_START( wboy )
1316   PORT_INCLUDE( common )
1274   PORT_INCLUDE( system1_generic )
13171275
13181276   PORT_MODIFY("P1")
13191277   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
r3333r3334
13311289   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL
13321290   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
13331291
1334   PORT_START("DSW1")
1292   PORT_MODIFY("DSW1")
13351293   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW B:1")
13361294   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
13371295   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
13691327INPUT_PORTS_END
13701328
13711329static INPUT_PORTS_START( wboysys2 )
1372   PORT_INCLUDE( common )
1330   PORT_INCLUDE( chplft )
13731331
13741332   PORT_MODIFY("P1")
13751333   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
r3333r3334
14111369   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW B:8")
14121370   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
14131371   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
1414
1415   PORT_START("DSW1")
1416   COINAGE_PORT
14171372INPUT_PORTS_END
14181373
14191374/* same as wboy, additional Energy Consumption switch */
r3333r3334
15291484*/
15301485
15311486static INPUT_PORTS_START( blockgal )
1532   PORT_START("P1")
1487   PORT_INCLUDE( chplft )
1488
1489   PORT_MODIFY("P1")
15331490   PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(60) PORT_KEYDELTA(15) PORT_REVERSE
15341491
1535   PORT_START("P2")
1492   PORT_MODIFY("P2")
15361493   PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(60) PORT_KEYDELTA(15) PORT_REVERSE PORT_COCKTAIL
15371494
1538   PORT_START("SYSTEM")
1539   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
1540   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
1541   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1542   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE1 )
1543   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
1544   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
1495   PORT_MODIFY("SYSTEM")
15451496   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 )
15461497   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
15471498
1548   PORT_START("DSW2")
1499   PORT_MODIFY("DSW2")
15491500   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
15501501   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
15511502   PORT_DIPSETTING(   0x01, DEF_STR( Cocktail ) )
r3333r3334
15681519   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
15691520   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
15701521   PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
1571
1572   PORT_START("DSW1")
1573   COINAGE_PORT
15741522INPUT_PORTS_END
15751523
15761524static INPUT_PORTS_START( tokisens )
1577   PORT_INCLUDE( common )
1525   PORT_INCLUDE( chplft )
15781526
15791527   PORT_MODIFY("DSW2")
15801528   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
r3333r3334
16001548   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
16011549   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
16021550   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
1603
1604   PORT_START("DSW1")
1605   COINAGE_PORT
16061551INPUT_PORTS_END
16071552
16081553static INPUT_PORTS_START( wbml )
1609   PORT_INCLUDE( common )
1554   PORT_INCLUDE( chplft )
16101555
16111556   PORT_MODIFY("DSW2")
16121557   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
r3333r3334
16321577   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
16331578   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
16341579   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
1635
1636   PORT_START("DSW1")
1637   COINAGE_PORT
16381580INPUT_PORTS_END
16391581
16401582static INPUT_PORTS_START( noboranb )
1641   PORT_INCLUDE( common )
1583   PORT_INCLUDE( system1_generic )
16421584
16431585   PORT_MODIFY("P1")
16441586   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )            // shot
r3333r3334
16711613   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
16721614   PORT_DIPSETTING(   0x80, DEF_STR( On ) )
16731615
1674   PORT_START("DSW1")
1616   PORT_MODIFY("DSW1")
16751617   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
16761618   PORT_DIPSETTING(   0x02, "2" )
16771619   PORT_DIPSETTING(   0x03, "3" )
r3333r3334
17031645
17041646*/
17051647static INPUT_PORTS_START( ufosensi )
1706   PORT_INCLUDE( common )
1648   PORT_INCLUDE( chplft )
17071649
17081650   PORT_MODIFY("P1")
17091651   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 )
r3333r3334
17341676   PORT_DIPNAME( 0x80, 0x80, "Invulnerability" )
17351677   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
17361678   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
1737
1738   PORT_START("DSW1")
1739   PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
1740   PORT_DIPSETTING(   0x07, DEF_STR( 4C_1C ) )
1741   PORT_DIPSETTING(   0x08, DEF_STR( 3C_1C ) )
1742   PORT_DIPSETTING(   0x09, DEF_STR( 2C_1C ) )
1743   PORT_DIPSETTING(   0x05, "2 Coins/1 Credit 5/3 6/4" )
1744   PORT_DIPSETTING(   0x04, "2 Coins/1 Credit 4/3" )
1745   PORT_DIPSETTING(   0x0f, DEF_STR( 1C_1C ) )
1746   PORT_DIPSETTING(   0x03, "1 Coin/1 Credit 5/6" )
1747   PORT_DIPSETTING(   0x02, "1 Coin/1 Credit 4/5" )
1748   PORT_DIPSETTING(   0x01, "1 Coin/1 Credit 2/3" )
1749   PORT_DIPSETTING(   0x06, DEF_STR( 2C_3C ) )
1750   PORT_DIPSETTING(   0x0e, DEF_STR( 1C_2C ) )
1751   PORT_DIPSETTING(   0x0d, DEF_STR( 1C_3C ) )
1752   PORT_DIPSETTING(   0x0c, DEF_STR( 1C_4C ) )
1753   PORT_DIPSETTING(   0x0b, DEF_STR( 1C_5C ) )
1754   PORT_DIPSETTING(   0x0a, DEF_STR( 1C_6C ) )
1755   PORT_DIPSETTING(   0x00, "Infinite Lives (both set)" )
1756   PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
1757   PORT_DIPSETTING(   0x70, DEF_STR( 4C_1C ) )
1758   PORT_DIPSETTING(   0x80, DEF_STR( 3C_1C ) )
1759   PORT_DIPSETTING(   0x90, DEF_STR( 2C_1C ) )
1760   PORT_DIPSETTING(   0x50, "2 Coins/1 Credit 5/3 6/4" )
1761   PORT_DIPSETTING(   0x40, "2 Coins/1 Credit 4/3" )
1762   PORT_DIPSETTING(   0xf0, DEF_STR( 1C_1C ) )
1763   PORT_DIPSETTING(   0x30, "1 Coin/1 Credit 5/6" )
1764   PORT_DIPSETTING(   0x20, "1 Coin/1 Credit 4/5" )
1765   PORT_DIPSETTING(   0x10, "1 Coin/1 Credit 2/3" )
1766   PORT_DIPSETTING(   0x60, DEF_STR( 2C_3C ) )
1767   PORT_DIPSETTING(   0xe0, DEF_STR( 1C_2C ) )
1768   PORT_DIPSETTING(   0xd0, DEF_STR( 1C_3C ) )
1769   PORT_DIPSETTING(   0xc0, DEF_STR( 1C_4C ) )
1770   PORT_DIPSETTING(   0xb0, DEF_STR( 1C_5C ) )
1771   PORT_DIPSETTING(   0xa0, DEF_STR( 1C_6C ) )
1772   PORT_DIPSETTING(   0x00, "Infinite Lives (both set)" )
17731679INPUT_PORTS_END
17741680
17751681static const gfx_layout charlayout =
src/mame/drivers/niyanpai.c
r3333r3334
574574   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
575575INPUT_PORTS_END
576576
577INPUT_PORTS_START( nbmjctrl_16 )
577static INPUT_PORTS_START( nbmjctrl_16 )
578578   PORT_START("KEY0")
579579   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START2 )
580580   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_KAN ) PORT_PLAYER(2)
src/mame/drivers/zn.c
r3333r3334
22432243   return jdredd_gun_mux;
22442244}
22452245
2246INTERRUPT_GEN( jdredd_vblank )
2246static INTERRUPT_GEN( jdredd_vblank )
22472247{
22482248   int x;
22492249   int y;
r3333r3334
28982898   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(2)
28992899INPUT_PORTS_END
29002900
2901INPUT_PORTS_START( jdredd )
2901static INPUT_PORTS_START( jdredd )
29022902   PORT_INCLUDE( zn )
29032903
29042904   PORT_MODIFY("P1")
r3333r3334
29362936   PORT_BIT( 0xffff, 0x0122, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_MINMAX(0x02d-1,0x217+1) PORT_SENSITIVITY(100) PORT_KEYDELTA(15) PORT_PLAYER(2)
29372937INPUT_PORTS_END
29382938
2939INPUT_PORTS_START( primrag2 )
2939static INPUT_PORTS_START( primrag2 )
29402940   PORT_INCLUDE( zn )
29412941
29422942   PORT_MODIFY("SYSTEM")
src/mame/drivers/paradise.c
r3333r3334
698698   ROM_LOAD( "9.u113", 0x00000, 0x80000, CRC(9c5337f0) SHA1(4d7a8069be4551aad9d7d32d835dcf91be079359) )
699699ROM_END
700700
701
702
703ROM_START( para2dx )
704   ROM_REGION( 0x44000, "main", 0 )      /* Z80 Code */
705   ROM_LOAD( "pdx2_u128.bin", 0x00000, 0x0c000, CRC(4cbd22e1) SHA1(ad69663109d3127f6472797ec8763097da94b7d4) )
706   ROM_CONTINUE(     0x10000, 0x34000    )
707
708   ROM_REGION( 0x80000, "gfx1", ROMREGION_DISPOSE | ROMREGION_INVERT)   /* 16x16x8 Sprites */
709   ROM_LOAD( "pdx2_u114.bin", 0x00000, 0x40000, CRC(3634b086) SHA1(6d079efb7be4fbe51d95d1f6b2c44dafdacb6016) )
710   ROM_LOAD( "pdx2_u115.bin", 0x40000, 0x40000, CRC(404409f4) SHA1(0763da81a1eb57037edd816e49a56dc8609fa502) )
711
712   ROM_REGION( 0x40000, "gfx2", ROMREGION_DISPOSE | ROMREGION_INVERT)   /* 8x8x4 Background */
713   ROM_LOAD( "pdx2_u094.bin", 0x00000, 0x40000,  CRC(87c4521b) SHA1(3ebd1e475e6125e9361b21160736103471c7aa2b) )
714
715   ROM_REGION( 0x100000, "gfx3", ROMREGION_DISPOSE | ROMREGION_INVERT)   /* 8x8x8 Foreground */
716   ROM_LOAD( "pdx2_u092.bin", 0x00000, 0x80000, CRC(d6797812) SHA1(b2d463b5932501382abcbbd911c492b6671c3cf7) )
717   ROM_LOAD( "pdx2_u093.bin", 0xc0000, 0x20000, BAD_DUMP CRC(36f4f8b2) SHA1(7d6a6bdeb867ab5105097a6efbb219ce5e922bb9) ) // wrong size!
718
719   ROM_REGION( 0x40000, "gfx4", ROMREGION_DISPOSE | ROMREGION_INVERT)   /* 8x8x8 Midground */
720   ROM_LOAD( "pdx2_u110.bin", 0x00000, 0x20000, CRC(59e828d1) SHA1(fd76c5a74e1be22bde52bcfbce179dc73591bec3) )
721   ROM_LOAD( "pdx2_u111.bin", 0x20000, 0x20000, CRC(619dd972) SHA1(c64d256d21da5821e27b1cd55351ad2a9b141f47) )
722
723   ROM_REGION( 0x40000, "oki1", 0 )   /* Samples */
724   ROM_LOAD( "pdx2_u085.bin", 0x00000, 0x40000, CRC(398b842e) SHA1(933759d2907640e85f11f532096ee1a912f67b53) )
725
726   ROM_REGION( 0x80000, "oki2", 0 )   /* Samples (banked) */
727   ROM_LOAD( "pdx2_u113.bin", 0x00000, 0x80000, CRC(9c5337f0) SHA1(4d7a8069be4551aad9d7d32d835dcf91be079359) )
728ROM_END
729
701730/***************************************************************************
702731
703732                          Target Ball
r3333r3334
9961025
9971026GAME( 1994+, paradise, 0,       paradise, paradise, paradise, ROT90, "Yun Sung", "Paradise", 0 )
9981027GAME( 1994+, paradlx,  0,       paradise, paradise, paradise, ROT90, "Yun Sung", "Paradise Deluxe", GAME_IMPERFECT_GRAPHICS )
1028GAME( 1994+, para2dx , 0,       paradise, paradise, paradise, ROT90, "Yun Sung", "Paradise 2 Deluxe", GAME_IMPERFECT_GRAPHICS )
9991029GAME( 1995,  tgtball,  0,       tgtball,  tgtball,  tgtball,  ROT0,  "Yun Sung", "Target Ball (Nude)", 0 )
10001030GAME( 1995,  tgtballa, tgtball, tgtball,  tgtball,  tgtball,  ROT0,  "Yun Sung", "Target Ball", 0 )
10011031GAME( 1996,  torus,    0,       torus,    torus,    torus,    ROT90, "Yun Sung", "Torus", 0 )
src/mame/drivers/videopkr.c
r3333r3334
254254static UINT8 te_40103;
255255static UINT8 ld_40103;
256256
257UINT8 c_io, hp_1, hp_2, bell, aux3;
257static UINT8 c_io, hp_1, hp_2, bell;
258258
259259
260260/*************************
r3333r3334
264264static tilemap *bg_tilemap;
265265
266266
267PALETTE_INIT( videopkr )
267static PALETTE_INIT( videopkr )
268268{
269269   int i;
270270
r3333r3334
299299}
300300
301301
302VIDEO_START( videopkr )
302static VIDEO_START( videopkr )
303303{
304304   bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
305305}
306306
307VIDEO_START( vidadcba )
307static VIDEO_START( vidadcba )
308308{
309309   bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
310310}
311311
312312
313VIDEO_UPDATE( videopkr )
313static VIDEO_UPDATE( videopkr )
314314{
315315   tilemap_mark_all_tiles_dirty(bg_tilemap);
316316   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
src/mame/drivers/gticlub.c
r3333r3334
544544   return 0;
545545}
546546
547TIMER_CALLBACK( network_irq_clear )
547static TIMER_CALLBACK( network_irq_clear )
548548{
549549   cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ2, CLEAR_LINE);
550550}
src/mame/drivers/namcona1.c
r3333r3334
465465         res = BITSWAP16(keyval, 22,26,31,23,18,20,16,30,24,21,25,19,17,29,28,27);
466466
467467         keyval >>= 1;
468printf("popcount(%08X) = %d\n", keyval & 0x58000c00, popcount(keyval & 0x58000c00));
468//          printf("popcount(%08X) = %d\n", keyval & 0x58000c00, popcount(keyval & 0x58000c00));
469469         if((!keyval) || (popcount(keyval & 0x58000c00) & 1))
470470            keyval ^= 0x80000000;
471471
src/mame/drivers/itgambl3.c
r3333r3334
4949*     Video Hardware     *
5050*************************/
5151
52VIDEO_START( itgambl3 )
52static VIDEO_START( itgambl3 )
5353{
5454}
5555
5656
57VIDEO_UPDATE( itgambl3 )
57static VIDEO_UPDATE( itgambl3 )
5858{
5959   return 0;
6060}
r3333r3334
158158*      Machine Reset      *
159159**************************/
160160
161MACHINE_RESET( itgambl3 )
161static MACHINE_RESET( itgambl3 )
162162{
163163   /* stop the CPU, we have no code for it anyway */
164164   cpunum_set_input_line(machine, 0, INPUT_LINE_HALT, ASSERT_LINE);
src/mame/drivers/chanbara.c
r0r3334
1/****************************************************************************************
2Chanbara
3Data East, 1985
4
5PCB Layout
6----------
7
8DE-0207-0
9|-----------------------------------------------------------|
10|             CP12.17H                     CP00-2.17C       |
11|                          2016                       6809  |
12|             CP13.15H                     CP01.15C         |
13|                          2016                             |
14|1  RCDM-I4   CP14.13H                     CP02.14C         |
15|8  RCDM-I1                                2016             |
16|W  RCDM-I1                                CP03.11C   2016  |
17|A  RCDM-I1                         2148   CP04.10C         |
18|Y  RCDM-I1                                CP05.9C          |
19|   RCDM-I1                2148            CP06.8C          |
20|  RM-C2                   2148                   TC15G032AY|
21|  PM-C1                            2148   CP07.6C          |
22|       DSW1                               CP08.5C          |
23|CP15.6K                   DECO                     DECO    |
24|CP16.5K                   VSC30           CP09.3C  HMC20   |
25|CP17.4K                                   CP10.2C          |
26|MB3730  558  558  YM3014  YM2203          CP11.1C   12MHz  |
27|-----------------------------------------------------------|
28Notes:
29      6809   - clock 1.500MHz [12/8]
30      YM2203 - clock 1.500MHz [12/8]
31      VSC30  - clock 3.000MHz [12/4, pin 7), custom DECO DIP40 IC
32      HMC20  - DECO HMC20 custom DIP28 IC. Provides many clocks each divided by 2
33               (i.e. 12MHz, 6MHz, 3MHz, 1.5MHz, 750kHz etc)
34               HSync is generated on pins 12 and 13 with 12/256/3. Actual xtal measures
35               11.9931MHz, which accounts for the measured HSync error (12/256/3 = 15.625kHz)
36      VSync  - 57.4122Hz
37      HSync  - 15.6161kHz
38
39------------------------
40
41 Driver by Tomasz Slanina & David Haywood
42
43ToDo:
44 there might still be some sprite banking issues
45
46
47****************************************************************************************/
48
49#include "driver.h"
50#include "sound/2203intf.h"
51
52static tilemap *bg_tilemap;
53static tilemap *bg2_tilemap;
54
55static UINT8 *videoram2, *colorram2;
56
57static PALETTE_INIT( chanbara )
58{
59   int i, red, green, blue;
60
61   for (i = 0;i < machine->config->total_colors;i++)
62   {
63      red = color_prom[i];
64      green = color_prom[machine->config->total_colors+i];
65      blue = color_prom[2*machine->config->total_colors+i];
66
67      palette_set_color_rgb(machine,i,pal4bit(red<<1),pal4bit(green<<1),pal4bit(blue<<1));
68   }
69}
70
71static WRITE8_HANDLER( chanbara_videoram_w )
72{
73   videoram[offset] = data;
74   tilemap_mark_tile_dirty(bg_tilemap, offset);
75}
76
77static WRITE8_HANDLER( chanbara_colorram_w )
78{
79   colorram[offset] = data;
80   tilemap_mark_tile_dirty(bg_tilemap, offset);
81}
82
83static WRITE8_HANDLER( chanbara_videoram2_w )
84{
85   videoram2[offset] = data;
86   tilemap_mark_tile_dirty(bg2_tilemap, offset);
87}
88
89static WRITE8_HANDLER( chanbara_colorram2_w )
90{
91   colorram2[offset] = data;
92   tilemap_mark_tile_dirty(bg2_tilemap, offset);
93}
94
95
96static TILE_GET_INFO( get_bg_tile_info )
97{
98   int code = videoram[tile_index] + ((colorram[tile_index] & 1) << 8);
99   int color = (colorram[tile_index] >> 1) & 0x1f;
100
101   SET_TILE_INFO(0, code, color, 0);
102}
103
104static TILE_GET_INFO( get_bg2_tile_info )
105{
106   int code = videoram2[tile_index];
107   int color = (colorram2[tile_index] >> 1) & 0x1f;
108
109   SET_TILE_INFO(2, code, color, 0);
110}
111
112static VIDEO_START(chanbara )
113{
114   bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows,8, 8, 32, 32);
115   bg2_tilemap = tilemap_create(get_bg2_tile_info, tilemap_scan_rows,16, 16, 16, 32);
116   tilemap_set_transparent_pen(bg_tilemap,0);
117}
118
119static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
120{
121   int offs;
122
123    for (offs = 0; offs < 0x80; offs += 4)
124   {
125      if(spriteram[offs + 0x80]&0x80)
126      {
127         int attr = spriteram[offs + 0];
128         int code = spriteram[offs + 1];
129         int color = spriteram[offs + 0x80]&0x1f;
130         int flipx = 0;
131         int flipy = attr & 2;
132         int sx = 240-spriteram[offs + 3];
133         int sy = 232-spriteram[offs+2];
134
135         sy+=16;
136
137         if (spriteram[offs + 0x80]&0x10) code += 0x200;
138         if (spriteram[offs + 0x80]&0x20) code += 0x400;
139         if (spriteram[offs + 0x80]&0x40) code += 0x100;
140
141         if(attr&0x10)
142         {
143            if(!flipy)
144            {
145
146               drawgfx(bitmap, machine->gfx[1], code, color, flipx, flipy, sx, sy-16,cliprect, TRANSPARENCY_PEN, 0);
147               drawgfx(bitmap, machine->gfx[1], code+1, color, flipx, flipy, sx, sy,   cliprect, TRANSPARENCY_PEN, 0);
148            }
149            else
150            {
151               drawgfx(bitmap, machine->gfx[1], code, color, flipx, flipy, sx, sy,cliprect, TRANSPARENCY_PEN, 0);
152               drawgfx(bitmap, machine->gfx[1], code+1, color, flipx, flipy, sx, sy-16,cliprect, TRANSPARENCY_PEN, 0);
153            }
154         }
155         else
156         {
157            drawgfx(bitmap, machine->gfx[1], code, color, flipx, flipy, sx, sy,cliprect, TRANSPARENCY_PEN, 0);
158         }
159      }
160   }
161}
162
163static UINT8 scroll;
164static UINT8 scrollhi;
165
166VIDEO_UPDATE( chanbara )
167{
168   tilemap_set_scrolly(bg2_tilemap,0,scroll | (scrollhi << 8));
169   tilemap_draw(bitmap, cliprect, bg2_tilemap, 0, 0);
170   draw_sprites(screen->machine, bitmap, cliprect);
171   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
172   return 0;
173}
174
175static ADDRESS_MAP_START( memmap, ADDRESS_SPACE_PROGRAM, 8 )
176   AM_RANGE(0x0000, 0x07ff) AM_RAM
177   AM_RANGE(0x0800, 0x0bff) AM_READ(SMH_RAM) AM_WRITE(chanbara_videoram_w) AM_BASE(&videoram)
178    AM_RANGE(0x0c00, 0x0fff) AM_READ(SMH_RAM) AM_WRITE(chanbara_colorram_w) AM_BASE(&colorram)
179    AM_RANGE(0x1000, 0x10ff) AM_RAM AM_BASE(&spriteram)
180    AM_RANGE(0x1800, 0x19ff) AM_READ(SMH_RAM) AM_WRITE(chanbara_videoram2_w) AM_BASE(&videoram2)
181    AM_RANGE(0x1a00, 0x1bff) AM_READ(SMH_RAM) AM_WRITE(chanbara_colorram2_w) AM_BASE(&colorram2)
182   AM_RANGE(0x2000, 0x2000) AM_READ_PORT("DSW0")
183   AM_RANGE(0x2001, 0x2001) AM_READ_PORT("SYSTEM")
184   AM_RANGE(0x2003, 0x2003) AM_READ_PORT("JOY")
185   AM_RANGE(0x3800, 0x3800) AM_READ(ym2203_status_port_0_r) AM_WRITE(ym2203_control_port_0_w)
186   AM_RANGE(0x3801, 0x3801) AM_WRITE(ym2203_write_port_0_w)
187   AM_RANGE(0x4000, 0x7fff) AM_READ(SMH_BANK1)
188   AM_RANGE(0x8000, 0xffff) AM_READ(SMH_ROM)
189ADDRESS_MAP_END
190
191/***************************************************************************/
192
193static INPUT_PORTS_START( chanbara )
194   PORT_START ("DSW0")
195   PORT_DIPNAME( 0x01,   0x01, DEF_STR( Unused ) )
196   PORT_DIPSETTING(      0x01, DEF_STR( Off ) )
197   PORT_DIPSETTING(      0x00, DEF_STR( On ) )
198   PORT_DIPNAME( 0x02,   0x02, DEF_STR( Unused ) )
199   PORT_DIPSETTING(      0x02, DEF_STR( Off ) )
200   PORT_DIPSETTING(      0x00, DEF_STR( On ) )
201   PORT_DIPNAME( 0x04,   0x04, DEF_STR( Unused ) )
202   PORT_DIPSETTING(      0x04, DEF_STR( Off ) )
203   PORT_DIPSETTING(      0x00, DEF_STR( On ) )
204   PORT_DIPNAME( 0x08,   0x08, DEF_STR( Unused ) )
205   PORT_DIPSETTING(      0x08, DEF_STR( Off ) )
206   PORT_DIPSETTING(      0x00, DEF_STR( On ) )
207   PORT_DIPNAME( 0x10,   0x10, DEF_STR( Unused ) )
208   PORT_DIPSETTING(      0x10, DEF_STR( Off ) )
209   PORT_DIPSETTING(      0x00, DEF_STR( On ) )
210   PORT_DIPNAME( 0x20,   0x20, DEF_STR( Unused ) )
211   PORT_DIPSETTING(      0x20, DEF_STR( Off ) )
212   PORT_DIPSETTING(      0x00, DEF_STR( On ) )
213   PORT_DIPNAME( 0x40,   0x40, DEF_STR( Unused ) )
214   PORT_DIPSETTING(      0x40, DEF_STR( Off ) )
215   PORT_DIPSETTING(      0x00, DEF_STR( On ) )
216   PORT_DIPNAME( 0x80,   0x80, DEF_STR( Unused ) )
217   PORT_DIPSETTING(      0x80, DEF_STR( Off ) )
218   PORT_DIPSETTING(      0x00, DEF_STR( On ) )
219
220   PORT_START ("SYSTEM")
221   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
222   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2    )
223   PORT_DIPNAME( 0x04,   0x04, "2" )
224   PORT_DIPSETTING(      0x04, DEF_STR( Off ) )
225   PORT_DIPSETTING(      0x00, DEF_STR( On ) )
226   PORT_DIPNAME( 0x08,   0x08, DEF_STR( Unused ) )
227   PORT_DIPSETTING(      0x08, DEF_STR( Off ) )
228   PORT_DIPSETTING(      0x00, DEF_STR( On ) )
229   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 )
230   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
231   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 )
232   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
233
234   /* System Port */
235   PORT_START ("JOY")
236   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN )
237   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP )
238   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_LEFT )
239   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_RIGHT )
240   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_DOWN )
241   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_UP )
242   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_LEFT )
243   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_RIGHT )
244INPUT_PORTS_END
245
246/***************************************************************************/
247
248static const gfx_layout tilelayout =
249{
250   8,8,   /* tile size */
251   RGN_FRAC(1,2),   /* number of tiles */
252   2,   /* bits per pixel */
253   { 0, 4 }, /* plane offsets */
254   { RGN_FRAC(1,2)+0,  RGN_FRAC(1,2)+1, RGN_FRAC(1,2)+2, RGN_FRAC(1,2)+3, 0,1,2,3 }, /* x offsets */
255   { 0*8,1*8,2*8,3*8, 4*8, 5*8, 6*8, 7*8 }, /* y offsets */
256   8*8   /* offset to next tile */
257};
258
259static const gfx_layout tile16layout =
260{
261   16,16,   /* tile size */
262   RGN_FRAC(1,4),   /* number of tiles */
263   3,   /* bits per pixel */
264   { RGN_FRAC(1,2),0,4 }, /* plane offsets */
265   { 16*8+RGN_FRAC(1,4)+0,16*8+ RGN_FRAC(1,4)+1,16*8+ RGN_FRAC(1,4)+2,16*8+ RGN_FRAC(1,4)+3,
266       0,1,2,3,
267      RGN_FRAC(1,4)+0,  RGN_FRAC(1,4)+1, RGN_FRAC(1,4)+2, RGN_FRAC(1,4)+3,
268      16*8+0, 16*8+1, 16*8+2, 16*8+3,
269
270   }, /* x offsets */
271   { 0*8,1*8,2*8,3*8, 4*8, 5*8, 6*8, 7*8,8*8,9*8,10*8,11*8,12*8,13*8,14*8,15*8 }, /* y offsets */
272   32*8   /* offset to next tile */
273};
274
275
276static const gfx_layout spritelayout =
277{
278   16,16,
279   RGN_FRAC(1,3),
280   3,
281   {  RGN_FRAC(2,3),RGN_FRAC(1,3), 0},
282   { 2*8*8+0,2*8*8+1,2*8*8+2,2*8*8+3,2*8*8+4,2*8*8+5,2*8*8+6,2*8*8+7,
283   0,1,2,3,4,5,6,7 },
284   { 0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8,
285   1*8*8+0*8,1*8*8+1*8,1*8*8+2*8,1*8*8+3*8,1*8*8+4*8,1*8*8+5*8,1*8*8+6*8,1*8*8+7*8 },
286   16*16
287};
288
289static GFXDECODE_START( chanbara )
290   GFXDECODE_ENTRY( "gfx1", 0x00000, tilelayout,   0x40, 32 )
291   GFXDECODE_ENTRY( "gfx2", 0x00000, spritelayout,   0x80, 16 )
292
293   GFXDECODE_ENTRY( "gfx3", 0x00000, tile16layout,   0, 32 )
294GFXDECODE_END
295/***************************************************************************/
296
297
298static WRITE8_HANDLER(chanbara_ay_out_0_w)
299{
300//  printf("chanbara_ay_out_0_w %02x\n",data);
301   scroll=data;
302}
303
304static WRITE8_HANDLER(chanbara_ay_out_1_w)
305{
306//  printf("chanbara_ay_out_1_w %02x\n",data);
307   memory_set_bankptr(1, memory_region(machine, "user1") + ((data&4)?0x4000:0x0000) );
308   scrollhi = data & 0x03;
309
310   //if (data&0xf8)    printf("chanbara_ay_out_1_w unused bits set %02x\n",data&0xf8);
311}
312
313static void sound_irq(running_machine *machine, int linestate)
314{
315   cpunum_set_input_line(machine, 0,0,linestate);
316}
317
318
319static const ym2203_interface ym2203_config =
320{
321   {
322         AY8910_LEGACY_OUTPUT,
323         AY8910_DEFAULT_LOADS,
324         0,
325         0,
326         chanbara_ay_out_0_w,
327         chanbara_ay_out_1_w,
328   },
329   sound_irq
330};
331
332static MACHINE_DRIVER_START( chanbara )
333   MDRV_CPU_ADD("main", M6809, 12000000/8)
334   MDRV_CPU_PROGRAM_MAP(memmap,0)
335
336   /* video hardware */
337   MDRV_SCREEN_ADD("main", RASTER)
338   MDRV_SCREEN_REFRESH_RATE(57.4122)
339   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
340   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
341   MDRV_SCREEN_SIZE(32*8, 32*8)
342   MDRV_SCREEN_VISIBLE_AREA(0, 32*8-1, 2*8, 30*8-1)
343
344   MDRV_GFXDECODE(chanbara)
345   MDRV_PALETTE_LENGTH(256)
346   MDRV_PALETTE_INIT(chanbara)
347
348   MDRV_VIDEO_START(chanbara)
349   MDRV_VIDEO_UPDATE(chanbara)
350
351   MDRV_SPEAKER_STANDARD_MONO("mono")
352
353   MDRV_SOUND_ADD("ym", YM2203, 12000000/8)
354   MDRV_SOUND_CONFIG(ym2203_config)
355   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
356MACHINE_DRIVER_END
357
358
359ROM_START( chanbara )
360   ROM_REGION( 0x10000, "main", 0 )
361   ROM_LOAD( "cp01.16c",     0x08000, 0x4000, CRC(a0c3c24c) SHA1(8445dc39dd763187a2d66c6165b487f146e7d474))
362   ROM_LOAD( "cp00-2.17c",   0x0c000, 0x4000, CRC(a045e463) SHA1(2eb546e16f163be6ed72238f2f0203527a957efd) )
363
364   ROM_REGION( 0x8000, "user1", 0 ) // background data
365   ROM_LOAD( "cp02.14c",     0x00000, 0x8000, CRC(c2b66cea) SHA1(f72f57add5f38313a72f5c521dce157edf49f70e) )
366
367   ROM_REGION( 0x02000, "gfx1", ROMREGION_DISPOSE ) // text layer
368   ROM_LOAD( "cp12.17h",        0x00000, 0x2000, CRC(b87b96de) SHA1(f8bb9f094917df305c4fed071edaa775071e40fd) )
369
370   ROM_REGION( 0x08000, "gfx3", ROMREGION_DISPOSE ) // bg layer
371   ROM_LOAD( "cp13.15h",        0x00000, 0x4000, CRC(2dc38c3d) SHA1(4bb1335b8285e91b51c28e74d8de11a8d6df0486) )
372   /* rom cp14.13h is expanded at 0x4000 - 0x8000 */
373
374   ROM_REGION( 0x08000, "gfx4", ROMREGION_DISPOSE )
375   ROM_LOAD( "cp14.13h",        0x00000, 0x2000, CRC(d31db368) SHA1(b62834137bfe4ac2013d2d16b0ead10bf2a2df83) )
376
377   ROM_REGION( 0x24000, "gfx2", ROMREGION_DISPOSE )
378   ROM_LOAD( "cp03.12c",     0x08000, 0x4000, CRC(dea247fb) SHA1(d54fa30813613ef6c3b5f86b563e9ab618a9f627))
379   ROM_LOAD( "cp04.10c",     0x04000, 0x4000, CRC(f7dce87b) SHA1(129ae41d70d96720e020ec1bc1d3f2d9e87ebf47) )
380   ROM_LOAD( "cp05.9c",      0x00000, 0x4000, CRC(df2dc3cb) SHA1(3505042c91566bb09fcd2102fecbe2034551b8eb) )
381
382   ROM_LOAD( "cp06.7c",     0x14000, 0x4000,  CRC(2f337c08) SHA1(657ee6776780fa0a979a278ff27a49b459232cad) )
383   ROM_LOAD( "cp07.6c",     0x10000, 0x4000, CRC(0e3727f2) SHA1(d177651bc20a56f5651ae5ce6f3d3ff7ad0e2053) )
384   ROM_LOAD( "cp08.5c",     0x0c000, 0x4000, CRC(4cf35192) SHA1(1891dcc412caf72ba5a2ea56c1cab35cb3ae6123) )
385
386   ROM_LOAD( "cp09.4c",     0x20000, 0x4000, CRC(3f58b647) SHA1(4eb212667aedd7c397a4911ac7f1b542c5c0a70d) )
387   ROM_LOAD( "cp10.2c",     0x1c000, 0x4000, CRC(bfa324c0) SHA1(c7ff09bb5f1dd2d3707970fae1fd60b6004250c0) )
388   ROM_LOAD( "cp11.1c",     0x18000, 0x4000, CRC(33e6160a) SHA1(b0171b554825072eebe935d12a6085d158b87bdc) )
389
390   ROM_REGION( 0x0300, "proms", 0 )
391   ROM_LOAD( "cp17.4k", 0x0000, 0x0100, CRC(cf03706e) SHA1(2dd2b29067f418ec590c56a38cc64d09d8dc8e09) ) /* red */
392   ROM_LOAD( "cp16.5k", 0x0100, 0x0100, CRC(5fedc8ba) SHA1(8b685ce71d833fefb3e4502d1dd0cca96ba9162a) ) /* green */
393   ROM_LOAD( "cp15.6k", 0x0200, 0x0100, CRC(655936eb) SHA1(762b419c0571fafd8e1c5e96d0d94999768ba325) ) /* blue */
394ROM_END
395
396
397static DRIVER_INIT(chanbara )
398{
399   UINT8   *src = memory_region(machine, "gfx4");
400   UINT8   *dst = memory_region(machine, "gfx3")+0x4000;
401
402   int i;
403   for (i=0;i<0x1000;i++)
404   {
405      dst[i+0x1000] = src[i]&0xf0;
406      dst[i+0x0000] = (src[i]&0x0f)<<4;
407      dst[i+0x3000] = src[i+0x1000]&0xf0;
408      dst[i+0x2000] = (src[i+0x1000]&0x0f)<<4;
409   }
410}
411
412GAME( 1985, chanbara, 0,      chanbara, chanbara, chanbara, ROT270, "Data East", "Chanbara", 0 )
src/mame/drivers/snk.c
r3333r3334
720720
721721*****************************************************************************/
722722
723CUSTOM_INPUT( gwar_rotary )
723static CUSTOM_INPUT( gwar_rotary )
724724{
725725   static int last_value[2] = {0, 0};
726726   static int cp_count[2] = {0, 0};
r3333r3334
739739   return value;
740740}
741741
742CUSTOM_INPUT( gwarb_rotary )
742static CUSTOM_INPUT( gwarb_rotary )
743743{
744744   if (input_port_read(field->port->machine, "JOYSTICK_MODE") == 1)
745745   {
src/mame/drivers/namconb1.c
r3333r3334
18011801
18021802static INPUT_PORTS_START( gunbulet )
18031803   PORT_START("MISC")
1804   PORT_DIPNAME( 0x01, 0x00, "DSW2 (unused)" )
1805   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1806   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
1807   PORT_DIPNAME( 0x02, 0x00, "DSW1 (unused)" )
1808   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1809   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
1804   PORT_DIPUNUSED_DIPLOC(0x01, 0x01, "SW1: 2")
1805   PORT_SERVICE_DIPLOC(0x02, 0x02, "SW1: 1")
1806
18101807   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
18111808   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
18121809   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN2 )
18131810   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 )
1814   PORT_DIPNAME( 0x40, 0x00, "Test switch" )
1815   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1816   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
1811   PORT_DIPNAME( 0x40, 0x40, "Test switch" )
1812   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1813   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
18171814   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 )
18181815
18191816   PORT_START("P1")
r3333r3334
18561853   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
18571854
18581855   PORT_START("MISC")
1859   PORT_DIPNAME( 0x01, 0x01, "Freeze Screen" )
1860   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1861   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
1862   PORT_DIPNAME( 0x02, 0x02, "DSW1 (Test)" )
1863   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1864   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
1856   PORT_DIPNAME( 0x01, 0x01, "Freeze Screen" ) PORT_DIPLOCATION("SW1: 2")
1857   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1858   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1859   PORT_SERVICE_DIPLOC(0x02, 0x02, "SW1: 1")
18651860   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
18661861   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 )
18671862   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
r3333r3334
18921887   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
18931888
18941889   PORT_START("MISC")
1895   PORT_DIPNAME( 0x01, 0x01, "Freeze Screen" )
1896   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1897   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
1898   PORT_DIPNAME( 0x02, 0x02, "DSW1 (Test)" )
1899   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1900   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
1890   PORT_DIPNAME( 0x01, 0x01, "Freeze Screen" ) PORT_DIPLOCATION("SW1: 2")
1891   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1892   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1893   PORT_SERVICE_DIPLOC(0x02, 0x02, "SW1: 1")
19011894   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
19021895   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
19031896   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 )
r3333r3334
19481941   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START4 )
19491942
19501943   PORT_START("MISC")
1951   PORT_DIPNAME( 0x01, 0x00, "DSW2 (unused)" )
1952   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1953   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
1954   PORT_DIPNAME( 0x02, 0x00, "DSW1 (unused)" )
1955   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1956   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
1944   PORT_DIPNAME( 0x01, 0x01, "Freeze Screen" ) PORT_DIPLOCATION("SW1: 2")
1945   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1946   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1947   PORT_SERVICE_DIPLOC(0x02, 0x02, "SW1: 1")
19571948   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
19581949   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 )
19591950   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN3 )
19601951   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN4 )
1961   PORT_DIPNAME( 0x40, 0x00, "Test switch" )
1962   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1963   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
1952   PORT_DIPNAME( 0x40, 0x40, "Test switch" )
1953   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1954   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
19641955   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 )
19651956INPUT_PORTS_END
19661957
src/mame/drivers/leland.c
r3333r3334
680680
681681   Port A of both chips is connected to a banking control
682682   register.
683
684   All 6 (3*2) AY-3-8910/12 outputs are tied together
685   and put with 1000 Ohm to gnd.
686   The following is a approximation, since
687   it does not take cross-chip mixing effects into account.
683688*/
684689
685690static const ay8910_interface ay8910_config =
686691{
687   AY8910_LEGACY_OUTPUT,
688   AY8910_DEFAULT_LOADS,
692   AY8910_SINGLE_OUTPUT,
693   {1000, 0, 0},
689694   leland_sound_port_r,
690695   0,
691696   leland_sound_port_w,
src/mame/drivers/shanghai.c
r3333r3334
410410};
411411
412412
413const ym2203_interface kothello_ym2203_interface =
413static const ym2203_interface kothello_ym2203_interface =
414414{
415415   {
416416      AY8910_LEGACY_OUTPUT,
src/mame/drivers/igs009.c
r3333r3334
295295                                Input Ports
296296***************************************************************************/
297297
298INPUT_PORTS_START( jingbell )
298static INPUT_PORTS_START( jingbell )
299299   PORT_START("DSW1")
300300   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) )
301301   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
src/mame/drivers/snesb.c
r3333r3334
433433   DRIVER_INIT_CALL(snes_hirom);
434434}
435435
436DRIVER_INIT( ffight2b )
436static DRIVER_INIT( ffight2b )
437437{
438438   INT32 i;
439439   UINT8 *rom = memory_region(machine, "user3");
src/mame/drivers/subsino.c
r3333r3334
2929***************************************************************************/
3030
3131static tilemap *tmap;
32int tiles_offset;
32static int tiles_offset;
3333
3434static WRITE8_HANDLER( subsino_tiles_offset_w )
3535{
r3333r3334
148148                                Input Ports
149149***************************************************************************/
150150
151INPUT_PORTS_START( smoto )
151static INPUT_PORTS_START( smoto )
152152
153153   PORT_START( "DSW1" )
154154   PORT_DIPUNKNOWN( 0x01, 0x01 )
src/mame/drivers/namcond1.c
r3333r3334
251251   AM_RANGE(0x000000, 0x07ffff) AM_READ(SMH_ROM)
252252   AM_RANGE(0x200000, 0x20ffff) AM_READWRITE( sharedram_sub_r, sharedram_sub_w )
253253   AM_RANGE(0xa00000, 0xa07fff) AM_READWRITE( c352_0_r, c352_0_w )
254   AM_RANGE(0xc00000, 0xc00001) AM_READ_PORT("P1_P2")
255   AM_RANGE(0xc00002, 0xc00003) AM_READ_PORT("DSW")
254   AM_RANGE(0xc00000, 0xc00001) AM_READ_PORT("DSW")
255   AM_RANGE(0xc00002, 0xc00003) AM_READ_PORT("P1_P2")
256256   AM_RANGE(0xc00010, 0xc00011) AM_NOP
257257   AM_RANGE(0xc00030, 0xc00031) AM_NOP
258258   AM_RANGE(0xc00040, 0xc00041) AM_NOP
src/mame/drivers/hikaru.c
r3333r3334
261261//static const struct sh4_config sh4cpu_config = {  1,  0,  1,  0,  0,  0,  1,  1,  0, CPU_CLOCK };
262262
263263
264VIDEO_START(hikaru)
264static VIDEO_START(hikaru)
265265{
266266
267267}
268268
269VIDEO_UPDATE(hikaru)
269static VIDEO_UPDATE(hikaru)
270270{
271271   return 0;
272272}
src/mame/drivers/namcos23.c
r3333r3334
11/*
2    Namco (Super) System 23
2    Namco System 22.5 and (Super) System 23
33    Extremely preliminary driver by R. Belmont, thanks to Phil Stroffolino & Olivier Galibert
44
55    Hardware: R4650 (MIPS III with IDT special instructions) main CPU @ 166 MHz
r3333r3334
1414    - Text layer is (almost?) identical to System 22 & Super System 22.
1515
1616    TODO:
17    - Text layer does not refresh properly in all cases, in spite of forced all-dirty.
18      Why?
17    - Palette is not right.
1918
20    - Palette is not right.  Games always write 16 bits at a time where the top 8 bits of each 16
21      appear to always be 0 (some sort of gamma correct?).
22
2319    - H8/3002 does not handshake.  Protocol should be the same as System 12 where the MIPS
2420      writes 0x3163 to offset 0x3002 in the shared RAM and the H8/3002 notices and sets it to 0x7106.
2521      The H8 currently never reads that location (core bug?).
r3333r3334
5248*Gunmen Wars      Namco, 1998    System 23
5349*Motocross Go!    Namco, 1997    System 23
5450*Panic Park       Namco, 1998    System 23
55Rapid River       Namco, 1997    System 23 (Actually Namco "Gorgon" hardware)
51Rapid River       Namco, 1997    System 22.5/Gorgon
5652Time Crisis II    Namco, 1997    System 23
5753*Underground King Namco, 1998    System 23
5854*Downhill Bikers  Namco, 199?    System 23
5955GP 500            Namco, 1999    Super System 23
60*Crisis Zone      Namco, 2000    Super System 23
56Crisis Zone      Namco, 2000    Super System 23 [not dumped, but have]
6157Final Furlong 2   Namco, 1999    Super System 23
6258*Guitar Jam       Namco, 1999    Super System 23
6359*Race On!         Namco, 1998    Super System 23
6460
65* - denotes not dumped yet (and hardware type not confirmed). If you can help with the remaining undumped S23/SS23 games,
61* - denotes not dumped yet (and hardware type not confirmed). If you can help with the remaining undumped S22.5/S23/SS23 games,
6662    please contact me at http://www.mameworld.net/gurudumps/
6763
6864The system comprises the following main boards....
r3333r3334
498494      ADM485   - Analog Devices ADM485 +5V Low Power EIA RS-485 Transceiver (SOIC8)
499495*/
500496
497/*
498Rapid River
499Namco, 1997
501500
501This game runs on hardware called "GORGON". It appears to be similar to
502System 23 but the PCBs are slightly larger.
503
504The system comprises Main PCB, ROM PCB and I/O PCB all located inside
505a metal box with 3 separate power supplies for 5V, 12V and 3.3V. Main
506input power is 115V.
507The game is controlled by rotating a paddle (for thrust) and turning it
508sideways (moves left/right).
509The rotation action is done with a 5K potentiometer whereby the thrust
510is achieved by moving the pot from full left to full right continuously.
511The left/right turning movement is just another 5K potentiometer connected
512to the column of the paddle center shaft.
513There are also some buttons just for test mode, including SELECT, UP & DOWN
514The player's seat has movement controlled by a compressor and several
515potentiometers. On bootup, the system tests the seat movement and displays
516a warning if it's not working. Pressing START allows the game to continue
517and function normally without the seat movement.
518
519
520Main PCB
521--------
522
5238664960102 (8664970102) GORGON MAIN PCB
524|------------------------------------------------------------------------------------------------------|
525|                                   J4                       J5                         J6             |
526|                              |---------|           |---------| |------| |---------|                  |
527|         |---------| |------| |         |           |         | |C401  | |         |HM534251 HM534251 |
528| CXD1178Q|         | |C381  | |  C374   |  |------| |  C417   | |      | |  304    |HM534251 HM534251 |
529|         |  C404   | |      | |         |  |C435  | |         | |------| |         |HM534251 HM534251 |
530|         |         | |------| |         |  |      | |         | |------| |         |                  |
531|         |         |          |---------|  |------| |---------| |C400  | |---------|                  |
532|         |---------|     |---------|       |------|             |      | |---------|                  |
533|                         |         |       |C435  |    341256   |------| |         |HM534251 HM534251 |
534|                         |  C397   |       |      |             |------| |  304    |HM534251 HM534251 |
535|  341256 341256  341256  |         |       |------|    341256   |C401  | |         |HM534251 HM534251 |
536|  M5M51008       341256  |         |     |---------|            |      | |         |                  |
537|                         |---------|     |         | |------|   |------| |---------|                  |
538|  M5M51008       341256         |------| |  C403   | |C406  |   |------| |---------|                  |
539|ADM485              |---------| |C379  | |         | |      |   |C400  | |         |HM534251 HM534251 |
540|                    |         | |      | |         | |------|   |      | |  304    |HM534251 HM534251 |
541|    M5M51008        |  C300   | |------| |---------|            |------| |         |HM534251 HM534251 |
542|                    |         | LH540204  LH540204              |------| |         |                  |
543|    M5M51008        |         |341256                 |------|  |C401  | |---------|                  |
544|J1   HCPL0611       |---------|341256                 |C407  |  |      | |---------|                  |
545|         DS8921                  PST575  PST575       |      |  |------| |         |                  |
546|  DS8921                                              |------|  |------| |  304    |HM534251 HM534251 |
547|                 M5M51008                                       |C400  | |         |HM534251 HM534251 |
548|       CY7C128             CY2291S                              |      | |         |                  |
549|         |------|M5M51008  14.31818MHz                          |------| |---------|                  |
550|         |C422  |          J9           M5M5256                 |------| |---------|         3V_BATT  |
551|         |      |341256                                         |C400  | |         |                  |
552|         |------|341256                                         |      | |  C399   |341256  LEDS(8)   |
553|                                   |------|      |--------|     |------| |         |341256            |
554|                                   |C352  |      |ALTERA  |     |------| |         |                  |
555|  ADM485        DSW1(2)   |------| |      |      |EPM7128 |     |C401  | |---------| DSW3(2)   DSW5(8)|
556|    2061ASC               |C416  | |------|      |        |     |      |     |---------| |---------|  |
557|      14.7456MHz          |      |               |--------|     |------|     |         | |NKK      |  |
558|PAL             |-----|   |------|    |------|                   D4516161    |  C413   | |NR4650   |  |
559|                |H8/  |               |C361  |                   D4516161    |         | |LQF-133  |  |
560|                |3002 |               |      |LC321664                       |         | |         |  |
561|  J10           |-----|               |------|    J8                         |---------| |---------|  |
562|------------------------------------------------------------------------------------------------------|
563Notes:
564      NKK NR4650 - R4600-based 64bit RISC CPU (Main CPU, QFP208, clock input source = CY2291S)
565      H8/3002  - Hitachi H8/3002 HD6413002F17 (Sound CPU, QFP100, running at 14.7456MHz)
566      EPM7128  - Altera EPM7128 FPGA labelled 'GOR-M1' (PLCC84)
567      PAL      - PALCE16V8H stamped 'GOR-M3' (PLCC20)
568      HM534251 - Hitachi HM534251 256k x4 Dynamic Video RAM (SOJ28)
569      N341256  - NKK 32k x8 SRAM (SOJ28)
570      M5M5256  - Mitsubishi 32k x8 SRAM (SOP28)
571      D4516161 - NEC uPD4516161AG5-A80 1M x16 (16MBit) SDRAM (SSOP50)
572      LC321664 - Sanyo 64k x16 EDO DRAM (SOJ40)
573      M5M51008 - Mitsubishi 128k x8 SRAM (SOP32)
574      CY7C128  - Cypress 2k x8 SRAM (SOJ28)
575      LH540204 - Sharp CMOS 4096 x 9 Asynchronous FIFO (PLCC32)
576      2061ASC-1- IC Designs 2061ASC-1 programmable clock generator (SOIC16)
577      DS8921   - Dallas Semiconductor DS8921 RS-422/423 Differential Line Driver and Receiver Pair (SOIC8)
578      HCPL0611 - Fairchild HCPL0611 High Speed 10MBits/sec Logic Gate Optocoupler (SOIC8)
579      ADM485   - Analog Devices ADM485 5V Low Power EIA RS-485 Transceiver (SOIC8)
580      PST575   - System Reset IC (SOIC8)
581      CXD1178Q - Sony CXD1178Q 8-bit RGB 3-channel D/A converter (QFP48)
582      J1       - 64 pin connector for connection of I/O board
583      J4/J5/J6 \
584      J8/J9    / Custom NAMCO connectors for connection of MEM(M1) PCB
585      J10      - Custom NAMCO connector for MSPM(FR) PCB
586
587
588      Namco Custom ICs
589      ----------------
590      C300 (QFP160)
591      304  (x4, QFP120)
592      C352 (QFP100)
593      C361 (QFP120)
594      C374 (QFP160)
595      C379 (QFP64)
596      C381 (QFP144)
597      C397 (QFP160)
598      C399 (QFP160)
599      C400 (QFP100)
600      C401 (x4, QFP64)
601      C403 (QFP136)
602      C404 (QFP208)
603      C406 (QFP120)
604      C407 (QFP64)
605      C413 (QFP208)
606      C416 (QFP176)
607      C417 (QFP208)
608      C422 (QFP64)
609      C435 (x2, TQFP144)
610
611
612Program ROM PCB
613---------------
614
615MSPM(FR) PCB 8699015200 (8699015100)
616|--------------------------|
617|            J1            |
618|                          |
619|  IC3               IC1   |
620|                          |
621|                          |
622|                    IC2   |
623|--------------------------|
624Notes:
625      J1 -  Connector to plug into Main PCB
626      IC1 \
627      IC2 / Main Program  (Fujitsu 29F016 16MBit FlashROM, TSOP48)
628      IC3 - Sound Program (Fujitsu 29F400T 4MBit FlashROM, TSOP48)
629
630      Games that use this PCB include...
631
632      Game           Code and revision
633      --------------------------------
634      Rapid River    RD3 Ver.C
635
636
637ROM PCB
638-------
639
640MEM(M1) PCB
6418664960202 (8664970202)
642|--------------------------------------------------------|
643|    J2(TEXTURE)        J3(POINT)           J5(SPRITE)   |
644| PAL1                                                   |
645|                                                        |
646|                                                        |
647|                                                        |
648| CCRL.11A                                               |
649|      CCRL.11E  PT3L.12J PT3H.12L  SPRLL.12P SPRLL.12T  |
650| CCRH.11B                                               |
651|      CCRH.11F                                          |
652|                PT2L.11J PT2H.11L  SPRLM.11P SPRLM.11T  |
653|                                                        |
654|                                                        |
655|                PT1L.10J PT1H.10L  SPRUM.10P SPRUM.10T  |
656|   PAL2        PAL3                                     |
657|                                                        |
658|                PT0L.9J  PT0H.9L   SPRUU.9P  SPRUU.9T   |
659|                                   JP7       JP9        |
660|                                   JP6       JP8        |
661| CGLL.8B     CGLL.8F                                    |
662|                                                        |
663|                                                        |
664| CGLM.7B     CGLM.7F                                    |
665|      JP2    JP4                                        |
666|      JP1    JP3                                        |
667| CGUM.6B     CGUM.6F                                    |
668|                                          J1(WAVE)      |
669|                                                        |
670| CGUU.5B     CGUU.5F                      WAVEH.3S      |
671|                                                        |
672|                    MTBH.5J               WAVEL.2S      |
673|                    MTAH.3J                      JP5    |
674|                    MTBL.2J                             |
675|                    MTAL.1J    KEYCUS                   |
676|                                                        |
677|                    J4(MOTION)                          |
678|--------------------------------------------------------|
679Notes:
680      PAL1 - PALCE16V8H stamped 'SS22M1' (PLCC20)
681      PAL2 - PALCE20V8H stamped 'SS22M2' (PLCC32)
682      PAL3 - PALCE20V8H stamped 'SS22M2' (PLCC32)
683      KEYCUS - MACH211 CPLD stamped 'KC012' (PLCC44)
684      J1->J5 - Custom NAMCO connectors for joining ROM PCB to Main PCB
685      JP1/JP2 \
686      JP3/JP4 |
687      JP5     | Jumpers to set ROM sizes (32M/64M)
688      JP6/JP7 |
689      JP8/JP9 /
690
691      ROMs
692      ----
693           PT*  - Point ROMs, sizes configurable to either 16M or 32M (SOP44)
694           MT*  - Motion ROMs, sizes configurable to either 32M or 64M (SOP44)
695           CG*  - Texture ROMs, sizes configurable to either 32M or 64M (SOP44)
696           CCR* - Texture Tilemap ROMs, sizes fixed at 16M (SOP44)
697           SPR* - Sprite ROMs, sizes configurable to either 32M or 64M (SOP44)
698           WAVE*- Wave ROMs, sizes configurable to either 32M or 64M (SOP44)
699
700I/O PCB
701-------
702
703V187 ASCA-2A PCB
7042477960102 (2477970102)
705|--------------------------------------------------------|
706|                   J105                                 |
707|                           |-------|        14.7456MHz  |
708|   J104                    |ALTERA |    ADM485   PST592 |
709|                           |EPM7064|     |-------|      |
710|                           |       |     |       |      |
711|                           |-------|     | C78   |      |
712|     LC78815                             |       |      |
713|                                         |-------|      |
714|     MB87078                              |---|         |
715| LA4705                                   |IC1| 62256   |
716|                                          |---|         |
717|         J101                J102                       |
718|--------------------------------------------------------|
719Notes:
720      IC1  - Atmel AT29C020 2MBit EEPROM labelled 'ASCA1 I/O-A' (PLCC32)
721      C78  - Namco Custom MCU, positively identified as a Hitachi H8/3334 (PLCC84)
722      EPM7064 - Altera EPM7064LC68-15 FPGA, labelled 'ASCA DR0' (PLCC68)
723      PST592 - System Reset IC (SOIC4)
724      ADM485 - Analog Devices +ADM485 5V Low Power EIA RS-485 Transceiver (SOIC8)
725      MB87078 - Fujitsu MB87078 Electronic Volume Control IC (SOIC24)
726      LC78815 - Sanyo LM78815 2-Channel 16-Bit D/A Converter (SOIC20)
727      J101 - 34 pin flat cable connector for filter board
728      J102 - 50 pin flat cable connector for filter board
729      J104 - 8 pin power connector (+5V, +12V, +3.3V)
730      J105 - 64 pin connector for connection of Main PCB
731*/
732
502733#include "driver.h"
503734#include "cpu/mips/mips3.h"
504735#include "cpu/h83002/h83002.h"
r3333r3334
525756    * ----.--xx.xxxx.xxxx code
526757    */
527758   SET_TILE_INFO( 0, data&0x03ff, data>>12, TILE_FLIPYX((data&0x0c00)>>10) );
528   if( data&0x8000 )
529   {
530      tileinfo->category = 1;
531   }
532759} /* TextTilemapGetInfo */
533760
534761static READ32_HANDLER( namcos23_textram_r )
r3333r3334
539766static WRITE32_HANDLER( namcos23_textram_w )
540767{
541768   COMBINE_DATA( &namcos23_textram[offset] );
542//  tilemap_mark_tile_dirty( bgtilemap, offset*2 );
543//  tilemap_mark_tile_dirty( bgtilemap, offset*2+1 );
544769}
545770
546771static VIDEO_START( ss23 )
547772{
548   bgtilemap = tilemap_create( TextTilemapGetInfo,tilemap_scan_rows,16,16,64,64 );
549   tilemap_set_transparent_pen( bgtilemap, 0xf );
773   bgtilemap = tilemap_create(TextTilemapGetInfo, tilemap_scan_rows, 16, 16, 64, 64);
774   tilemap_set_transparent_pen(bgtilemap, 0xf);
550775}
551776
552777#if 0
r3333r3334
647872   fillbitmap(priority_bitmap, 0, cliprect);
648873
649874   tilemap_mark_all_tiles_dirty(bgtilemap);
650   tilemap_draw( bitmap, cliprect, bgtilemap, 0/*flags*/, 0x1/*priority*/ ); /* opaque */
875   tilemap_draw( bitmap, cliprect, bgtilemap, 0/*flags*/, 0/*priority*/ ); /* opaque */
651876
652877#if 0
653878   static int bNew = 1;
r3333r3334
699924   return 0;
700925}
701926
927static VIDEO_UPDATE( gorgon )
928{
929   return 0;
930}
931
702932static WRITE32_HANDLER( s23_txtchar_w )
703933{
704934   COMBINE_DATA(&namcos23_charram[offset]   );
r3333r3334
7931023   }
7941024}
7951025
1026static UINT32 gorgon_vbl = 0;
1027static READ32_HANDLER( gorgon_vbl_r )
1028{
1029   gorgon_vbl ^= 0xffffffff;
1030
1031   return gorgon_vbl;
1032}
1033
1034static ADDRESS_MAP_START( gorgon_map, ADDRESS_SPACE_PROGRAM, 32 )
1035   AM_RANGE(0x00000000, 0x003fffff) AM_RAM
1036   AM_RANGE(0x02000000, 0x02000003) AM_READ( gorgon_vbl_r )
1037   AM_RANGE(0x04400000, 0x0440ffff) AM_RAM AM_BASE(&namcos23_shared_ram)
1038   AM_RANGE(0x04c3ff0c, 0x04c3ff0f) AM_RAM            // 3d FIFO
1039   AM_RANGE(0x0d000000, 0x0d000007) AM_READ(sysctl_stat_r)
1040   AM_RANGE(0x0fc00000, 0x0fffffff) AM_WRITENOP AM_ROM AM_REGION("user1", 0)
1041   AM_RANGE(0x1fc00000, 0x1fffffff) AM_WRITENOP AM_ROM AM_REGION("user1", 0)
1042ADDRESS_MAP_END
1043
7961044static ADDRESS_MAP_START( ss23_map, ADDRESS_SPACE_PROGRAM, 32 )
7971045   AM_RANGE(0x00000000, 0x003fffff) AM_RAM
7981046   AM_RANGE(0x02000000, 0x02000003) AM_READ( s23_unk_r )
799   AM_RANGE(0x04400000, 0x0440ffff) AM_BASE(&namcos23_shared_ram)
1047   AM_RANGE(0x04400000, 0x0440ffff) AM_RAM AM_BASE(&namcos23_shared_ram)
8001048   AM_RANGE(0x04c3ff08, 0x04c3ff0b) AM_WRITE( s23_mcuen_w )
8011049   AM_RANGE(0x04c3ff0c, 0x04c3ff0f) AM_RAM            // 3d FIFO
8021050   AM_RANGE(0x06800000, 0x06800fff) AM_RAM          // text layer palette
r3333r3334
10191267{
10201268}
10211269
1270static MACHINE_DRIVER_START( gorgon )
1271
1272   /* basic machine hardware */
1273   MDRV_CPU_ADD("main", R4650BE, 133000000)
1274   MDRV_CPU_CONFIG(config)
1275   MDRV_CPU_PROGRAM_MAP(gorgon_map, 0)
1276
1277   MDRV_CPU_ADD("audio", H83002, 14745600 )
1278   MDRV_CPU_PROGRAM_MAP( s23h8rwmap, 0 )
1279   MDRV_CPU_IO_MAP( s23h8iomap, 0 )
1280   MDRV_CPU_VBLANK_INT("main", irq1_line_pulse)
1281
1282   MDRV_SCREEN_ADD("main", RASTER)
1283   MDRV_SCREEN_REFRESH_RATE(60)
1284   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
1285   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1286   MDRV_SCREEN_SIZE(64*16, 30*16)
1287   MDRV_SCREEN_VISIBLE_AREA(0, 64*16-1, 0, 30*16-1)
1288
1289   MDRV_PALETTE_LENGTH(0x8000)
1290
1291   MDRV_GFXDECODE(namcos23)
1292
1293   MDRV_VIDEO_START(ss23)
1294   MDRV_VIDEO_UPDATE(gorgon)
1295
1296   /* sound hardware */
1297   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
1298
1299   MDRV_SOUND_ADD("c352", C352, 14745600)
1300   MDRV_SOUND_ROUTE(0, "right", 1.00)
1301   MDRV_SOUND_ROUTE(1, "left", 1.00)
1302   MDRV_SOUND_ROUTE(2, "right", 1.00)
1303   MDRV_SOUND_ROUTE(3, "left", 1.00)
1304MACHINE_DRIVER_END
1305
10221306static MACHINE_DRIVER_START( s23 )
10231307
10241308   /* basic machine hardware */
r3333r3334
10691353   MDRV_CPU_IO_MAP( s23h8iomap, 0 )
10701354   MDRV_CPU_VBLANK_INT("main", irq1_line_pulse)
10711355
1072
10731356   MDRV_SCREEN_ADD("main", RASTER)
10741357   MDRV_SCREEN_REFRESH_RATE(60)
10751358   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
r3333r3334
10941377   MDRV_SOUND_ROUTE(3, "left", 1.00)
10951378MACHINE_DRIVER_END
10961379
1380ROM_START( rapidrvr )
1381   ROM_REGION32_BE( 0x400000, "user1", 0 ) /* 4 megs for main R4650 code */
1382        ROM_LOAD16_BYTE( "rd3verc.ic2",  0x000000, 0x200000, CRC(c15c0f30) SHA1(9f529232818f3e184f81f62408a5cad615b05613) )
1383        ROM_LOAD16_BYTE( "rd3verc.ic1",  0x000001, 0x200000, CRC(9d7f4411) SHA1(d049efaa539d36ed0f73ca3f50a8f7112e67f865) )
1384
1385   ROM_REGION( 0x80000, "audio", 0 )   /* Hitachi H8/3002 MCU code */
1386   ROM_LOAD16_WORD_SWAP( "rd3verc.ic3",  0x000000, 0x080000, CRC(6e26fbaf) SHA1(4ab6637d22f0d26f7e1d10e9c80059c56f64303d) )
1387
1388   ROM_REGION( 0x800000, "sprite", 0 )   /* sprite? tilemap? tiles */
1389        ROM_LOAD16_BYTE( "rd1mtal.1j",   0x000000, 0x400000, CRC(8f0efa86) SHA1(9953461c258f2a96be275a7b18d6518ddfac3860) )
1390        ROM_LOAD16_BYTE( "rd1mtah.3j",   0x000001, 0x400000, CRC(d8fa0f3d) SHA1(0d5bdb3a2e7be1dffe11b74baa2c10bfe011ae92) )
1391
1392   ROM_REGION( 0x2000000, "textile", 0 )   /* texture tiles */
1393        ROM_LOAD( "rd1cguu.5b",   0x0000000, 0x800000, CRC(611bab41) SHA1(84cddb2b63bf8336e92aecb06eddf1b34af73540) )
1394        ROM_LOAD( "rd1cgum.6b",   0x0800000, 0x800000, CRC(c50de2ef) SHA1(24758a72b3569ce6a643a5786fce7c34b8aa692d) )
1395        ROM_LOAD( "rd1cgll.8b",   0x1000000, 0x800000, CRC(b58b92ac) SHA1(70ee6e0e5347e05817aa30d53d766b8ce0fc44e4) )
1396        ROM_LOAD( "rd1cglm.7b",   0x1800000, 0x800000, CRC(447067fa) SHA1(e2052373773594feb303e1924a4a820cf34ab55b) )
1397
1398   ROM_REGION( 0x2000000, "textile2", 0 )   /* texture tiles bank 2? */
1399        ROM_LOAD( "rd1spruu.9p",  0x0000000, 0x400000, CRC(f20a9673) SHA1(e5f1d552b0c42e102593ab578ff0b9ff814f8650) )
1400        ROM_LOAD( "rd1sprum.10p", 0x0800000, 0x400000, CRC(8e08b2c6) SHA1(a17331a4e41f677f604d1b74e7694cf920b03b66) )
1401        ROM_LOAD( "rd1sprll.12t", 0x1000000, 0x400000, CRC(8d450259) SHA1(27cccd1e7dad8880147bb85185982d8d27076e69) )
1402        ROM_LOAD( "rd1sprlm.11p", 0x1800000, 0x400000, CRC(6c8db3a5) SHA1(24d81fa11e9c835cddadec4cbd530738e258346c) )
1403
1404   ROM_REGION( 0x2000000, "textiledup", 0 )   /* duplicate bank of texture tiles */
1405        ROM_LOAD( "rd1cguu.5f",   0x0800000, 0x800000, CRC(611bab41) SHA1(84cddb2b63bf8336e92aecb06eddf1b34af73540) )
1406        ROM_LOAD( "rd1cgum.6f",   0x1800000, 0x800000, CRC(c50de2ef) SHA1(24758a72b3569ce6a643a5786fce7c34b8aa692d) )
1407        ROM_LOAD( "rd1cgll.8f",   0x1000000, 0x800000, CRC(b58b92ac) SHA1(70ee6e0e5347e05817aa30d53d766b8ce0fc44e4) )
1408        ROM_LOAD( "rd1cglm.7f",   0x0000000, 0x800000, CRC(447067fa) SHA1(e2052373773594feb303e1924a4a820cf34ab55b) )
1409
1410   ROM_REGION( 0x2000000, "textile2d", 0 )   /* duplicate of texture tiles bank 2? */
1411        ROM_LOAD( "rd1spruu.9t",  0x0000000, 0x400000, CRC(f20a9673) SHA1(e5f1d552b0c42e102593ab578ff0b9ff814f8650) )
1412        ROM_LOAD( "rd1sprum.10t", 0x0800000, 0x400000, CRC(8e08b2c6) SHA1(a17331a4e41f677f604d1b74e7694cf920b03b66) )
1413        ROM_LOAD( "rd1sprll.12p", 0x1000000, 0x400000, CRC(8d450259) SHA1(27cccd1e7dad8880147bb85185982d8d27076e69) )
1414        ROM_LOAD( "rd1sprlm.11t", 0x1800000, 0x400000, CRC(6c8db3a5) SHA1(24d81fa11e9c835cddadec4cbd530738e258346c) )
1415
1416   ROM_REGION( 0x400000, "textilemap", 0 )   /* texture tilemap */
1417        ROM_LOAD( "rd1ccrl.11a",  0x000000, 0x200000, CRC(b0ea2b32) SHA1(0dc45846725b0de619bc6bae69e3eb166ed21bf0) )
1418        ROM_LOAD( "rd1ccrh.11b",  0x200000, 0x200000, CRC(fafffb86) SHA1(15b0ba0252b99d0cac29fcb374fb895643f528fe) )
1419
1420   ROM_REGION( 0x400000, "textilemp2", 0 )   /* duplicate texture tilemap */
1421        ROM_LOAD( "rd1ccrl.11e",  0x000000, 0x200000, CRC(b0ea2b32) SHA1(0dc45846725b0de619bc6bae69e3eb166ed21bf0) )
1422        ROM_LOAD( "rd1ccrh.11f",  0x200000, 0x200000, CRC(fafffb86) SHA1(15b0ba0252b99d0cac29fcb374fb895643f528fe) )
1423
1424   ROM_REGION32_LE( 0x2000000, "pointrom", 0 )   /* 3D model data */
1425        ROM_LOAD32_WORD( "rd1pt0l.9j",   0x0000000, 0x400000, CRC(47b1c5a5) SHA1(021d4ca7b8674d8ed5daa701bf41b4a7164d992a) )
1426        ROM_LOAD32_WORD( "rd1pt0h.9l",   0x0000002, 0x400000, CRC(6f280eff) SHA1(9dd8c8903581d7a412146e50f4009e1d2b743f06) )
1427        ROM_LOAD32_WORD( "rd1pt1l.10j",  0x0800000, 0x400000, CRC(91131cb3) SHA1(e42c5e190c719f1cf2d6e91444062ab901be0e73) )
1428        ROM_LOAD32_WORD( "rd1pt1h.10l",  0x0800002, 0x400000, CRC(37bd9bdf) SHA1(b26c284024ea4ad4c67b2eefbfdd5ebb35a0118e) )
1429        ROM_LOAD32_WORD( "rd1pt2l.11j",  0x1000000, 0x400000, CRC(3423ff9f) SHA1(73823c179c866cbb601a23417acbbf5b3dc97213) )
1430        ROM_LOAD32_WORD( "rd1pt2h.11l",  0x1000002, 0x400000, CRC(fa601e83) SHA1(45c420538910f566e75d668306735f54c901669f) )
1431        ROM_LOAD32_WORD( "rd1pt3l.12j",  0x1800000, 0x400000, CRC(7216d63e) SHA1(77088ff05c2630996f4bdc87fe466f9b97611467) )
1432        ROM_LOAD32_WORD( "rd1pt3h.12l",  0x1800002, 0x400000, CRC(e82ff66a) SHA1(9e2c951136b26d969d2c9d030b7e0bad8bbbe3fb) )
1433
1434   ROM_REGION( 0x1000000, "c352", 0 ) /* C352 PCM samples */
1435        ROM_LOAD( "rd1wavel.2s",  0x000000, 0x800000, CRC(bf52c08c) SHA1(6745062e078e520484390fad1f723124aa4076d0) )
1436        ROM_LOAD( "rd1waveh.3s",  0x800000, 0x800000, CRC(ef0136b5) SHA1(a6d923ededca168fe555e0b86a72f53bec5424cc) )
1437ROM_END
1438
10971439ROM_START( timecrs2 )
10981440   ROM_REGION32_BE( 0x400000, "user1", 0 ) /* 4 megs for main R4650 code */
10991441        ROM_LOAD16_BYTE( "tss3verb.2",   0x000000, 0x200000, CRC(c7be691f) SHA1(5e2e7a0db3d8ce6dfeb6c0d99e9fe6a9f9cab467) )
r3333r3334
11311473        ROM_LOAD( "tss1waveh.2a", 0x800000, 0x800000, CRC(5c8758b4) SHA1(b85c8f6869900224ef83a2340b17f5bbb2801af9) )
11321474ROM_END
11331475
1134ROM_START( gp500 )
1476ROM_START( timcrs2b )
1477   ROM_REGION32_BE( 0x400000, "user1", 0 ) /* 4 megs for main R4650 code */
1478        ROM_LOAD16_BYTE( "tss2verb.ic2", 0x000000, 0x200000, CRC(9f56a4df) SHA1(5ecb3cd93726ab6be02762853fd6a45266d6c0bc) )
1479        ROM_LOAD16_BYTE( "tss2verb.ic1", 0x000001, 0x200000, CRC(aa147f71) SHA1(e00267d1a8286942c83dc35289ad65bd3cb6d8db) )
1480
1481   ROM_REGION( 0x80000, "audio", 0 )   /* Hitachi H8/3002 MCU code */
1482        ROM_LOAD16_WORD_SWAP( "tss3verb.3",   0x000000, 0x080000, CRC(41e41994) SHA1(eabc1a307c329070bfc6486cb68169c94ff8a162) )
1483
1484   ROM_REGION( 0x40000, "ioboard", 0 )   /* I/O board HD643334 H8/300 MCU code */
1485   ROM_LOAD( "tssioprog.ic3", 0x000000, 0x040000, CRC(edad4538) SHA1(1330189184a636328d956c0e435f8d9ad2e96a80) )
1486
1487   ROM_REGION( 0x2000000, "sprite", 0 )   /* sprite? tilemap? tiles */
1488        ROM_LOAD16_BYTE( "tss1mtal.2h",  0x0000000, 0x800000, CRC(bfc79190) SHA1(04bda00c4cc5660d27af4f3b0ee3550dea8d3805) )
1489        ROM_LOAD16_BYTE( "tss1mtah.2j",  0x0000001, 0x800000, CRC(697c26ed) SHA1(72f6f69e89496ba0c6183b35c3bde71f5a3c721f) )
1490        ROM_LOAD16_BYTE( "tss1mtbl.2f",  0x1000000, 0x800000, CRC(e648bea4) SHA1(3803d03e72b25fbcc124d5b25066d25629b76b94) )
1491        ROM_LOAD16_BYTE( "tss1mtbh.2m",  0x1000001, 0x800000, CRC(82582776) SHA1(7c790d09bac660ea1c62da3ffb21ab43f2461594) )
1492
1493   ROM_REGION( 0x2000000, "textile", 0 )   /* texture tiles */
1494        ROM_LOAD( "tss1cguu.4f",  0x0000000, 0x800000, CRC(76924e04) SHA1(751065d6ce658cbbcd88f854f6937ebd2204ec68) )
1495        ROM_LOAD( "tss1cgum.4j",  0x0800000, 0x800000, CRC(c22739e1) SHA1(8671ee047bb248033656c50befd1c35e5e478e1a) )
1496        ROM_LOAD( "tss1cgll.4m",  0x1000000, 0x800000, CRC(18433aaa) SHA1(08539beb2e66ec4e41062621fc098b121c669546) )
1497        ROM_LOAD( "tss1cglm.4k",  0x1800000, 0x800000, CRC(669974c2) SHA1(cfebe199631e38f547b38fcd35f1645b74e8dd0a) )
1498
1499   ROM_REGION( 0x600000, "textilemap", 0 )   /* texture tilemap */
1500        ROM_LOAD( "tss1ccrl.7f",  0x000000, 0x400000, CRC(3a325fe7) SHA1(882735dce7aeb36f9e88a983498360f5de901e9d) )
1501        ROM_LOAD( "tss1ccrh.7e",  0x400000, 0x200000, CRC(f998de1a) SHA1(371f540f505608297c5ffcfb623b983ca8310afb) )
1502
1503   ROM_REGION32_LE( 0x2000000, "pointrom", 0 )   /* 3D model data */
1504        ROM_LOAD32_WORD( "tss1pt0l.7c",  0x0000000, 0x400000, CRC(896f0fb4) SHA1(bdfa99eb21ce4fc8021f9d95a5558a34f9942c57) )
1505        ROM_LOAD32_WORD( "tss1pt0h.7a",  0x0000002, 0x400000, CRC(cdbe0ba8) SHA1(f8c6da31654c0a2a8024888ffb7fc1c783b2d629) )
1506        ROM_LOAD32_WORD( "tss1pt1l.5c",  0x0800000, 0x400000, CRC(5a09921f) SHA1(c23885708c7adf0b81c2c9346e21b869634a5b35) )
1507        ROM_LOAD32_WORD( "tss1pt1h.5a",  0x0800002, 0x400000, CRC(63647596) SHA1(833412be8f61686bd7e06c2738df740e0e585d0f) )
1508        ROM_LOAD32_WORD( "tss1pt2l.4c",  0x1000000, 0x400000, CRC(4b230d79) SHA1(794cee0a19993e90913f58507c53224f361e9663) )
1509        ROM_LOAD32_WORD( "tss1pt2h.4a",  0x1000002, 0x400000, CRC(9b06e22d) SHA1(cff5ed098112a4f0a2bc8937e226f50066e605b1) )
1510
1511   ROM_REGION( 0x1000000, "c352", 0 ) /* C352 PCM samples */
1512        ROM_LOAD( "tss1wavel.2c", 0x000000, 0x800000, CRC(deaead26) SHA1(72dac0c3f41d4c3c290f9eb1b50236ae3040a472) )
1513        ROM_LOAD( "tss1waveh.2a", 0x800000, 0x800000, CRC(5c8758b4) SHA1(b85c8f6869900224ef83a2340b17f5bbb2801af9) )
1514ROM_END
1515
1516ROM_START( 500gp )
11351517   /* r4650-generic-xrom-generic: NMON 1.0.8-sys23-19990105 P for SYSTEM23 P1 */
11361518   ROM_REGION32_BE( 0x400000, "user1", 0 ) /* 4 megs for main R4650 code */
11371519        ROM_LOAD16_BYTE( "5gp3verc.2",   0x000000, 0x200000, CRC(e2d43468) SHA1(5e861dd223c7fa177febed9803ac353cba18e19d) )
r3333r3334
12541636ROM_END
12551637
12561638/* Games */
1257//GAME( 199?, downhbkr,  0,      s23, 0, ss23, ROT0, "Namco",  "Downhill Bikers (DH3 Ver.A)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
1258GAME( 1997, timecrs2, 0,         s23, 0, ss23, ROT0, "Namco", "Time Crisis 2", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
1259GAME( 1999, gp500,    0,        ss23, 0, ss23, ROT0, "Namco", "GP500", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
1639GAME( 1997, rapidrvr, 0,      gorgon, 0, ss23, ROT0, "Namco", "Rapid River (RD3 Ver. C)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
1640GAME( 1997, timecrs2, 0,         s23, 0, ss23, ROT0, "Namco", "Time Crisis 2 (TSS3 Ver. B)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
1641GAME( 1997, timcrs2b, timecrs2,  s23, 0, ss23, ROT0, "Namco", "Time Crisis 2 (TSS2 Ver. B)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
1642GAME( 1999, 500gp,    0,        ss23, 0, ss23, ROT0, "Namco", "500GP", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
12601643GAME( 1999, finfurl2, 0,        ss23, 0, ss23, ROT0, "Namco", "Final Furlong 2 (World)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
12611644GAME( 1999, finfrl2j, finfurl2, ss23, 0, ss23, ROT0, "Namco", "Final Furlong 2 (Japan)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
src/mame/drivers/warpwarp.c
r3333r3334
825825   ROM_LOAD( "geebee.1k",    0x0000, 0x1000, CRC(8a5577e0) SHA1(356d33e19c6b4f519816ee4b65ff9b59d6c1b565) )
826826
827827   ROM_REGION( 0x800, "gfx1", 0 )
828   ROM_LOAD( "geebee.3a",    0x0000, 0x0400, CRC(f257b21b) SHA1(c788fd923438f1bffbff9ff3cd4c5c8b547c0c14) )
828   ROM_LOAD( "geebeeg.3a",   0x0000, 0x0400, CRC(a45932ba) SHA1(48f70742c42a9377f31fac3a1e43123751e57656) )
829829ROM_END
830830
831831ROM_START( navarone )
src/mame/drivers/plygonet.c
r3333r3334
198198}
199199#endif
200200
201READ32_HANDLER( dsp_host_interface_r )
201static READ32_HANDLER( dsp_host_interface_r )
202202{
203203   UINT32 value;
204204   UINT8 hi_addr = offset << 1;
src/mame/drivers/naomi.c
r3333r3334
5555                        on power-up.
5656      JP1             - set to 2-3. Alt setting is 1-2
5757      JP4             - set to 2-3. Alt setting is 1-2
58      93C46           - 128 bytes EEPROM
59      A179B 96K       - ?, made by TI
58      93C46           - 128 bytes serial EEPROM
59      A179B 96K       - TI SN75179B Differential driver and receiver pair (like RS485)
6060      ADM485          - Analog Devices ADM485
6161      BIOS.IC27       - 27C160 EPROM
6262      5264165         - Hitachi 5264165FTTA60 (video RAM)
r3333r3334
662662#include "dc.h"
663663
664664#define CPU_CLOCK (200000000)
665                                 /* MD2 MD1 MD0 MD6 MD4 MD3 MD5 MD7 MD8 */
665                                             /* MD2 MD1 MD0 MD6 MD4 MD3 MD5 MD7 MD8 */
666666static const struct sh4_config sh4cpu_config = {  1,  0,  1,  0,  0,  0,  1,  1,  0, CPU_CLOCK };
667667
668668static UINT32 *dc_sound_ram;
669static UINT32 rom_offset, dma_count;
669static UINT32 rom_offset, rom_offset_flags, dma_count;
670670UINT32 dma_offset;
671671
672672static INTERRUPT_GEN( naomi_vblank )
r3333r3334
716716
717717    Dimm board registers (add more information if you find it):
718718
719    NAOMI_DIMM_COMMAND = 5f703c (16 bit):
719    Name:                   Naomi   Dimm Bd.
720    NAOMI_DIMM_COMMAND    = 5f703c  14000014 (16 bit):
720721        if bits all 1 no dimm board present and other registers not used
721722        bit 15: during an interrupt is 1 if the dimm board has a command to be executed
722723        bit 14-9: 6 bit command number (naomi bios understands 0 1 3 4 5 6 8 9 a)
723        bit 8-0: higher 9 bits of 25 bit offset parameter
724    NAOMI_DIMM_OFFSETL = 5f7040 (16 bit):
725        bit 15-0: lower 16 bits of 25 bit offset parameter
726    NAOMI_DIMM_PARAMETERL = 5f7044 (16 bit)
727    NAOMI_DIMM_PARAMETERH = 5f7048 (16 bit)
728    NAOMI_DIMM_STATUS = 5f704c (16 bit):
729        bit 0: when read as 1 means something has happened write it to 0 to clear
730        bit 8: written to 1 at the end of the interrupt routine (signals command response available to dimm board ?)
724        bit 7-0: higher 8 bits of 24 bit offset parameter
725    NAOMI_DIMM_OFFSETL    = 5f7040  14000018 (16 bit):
726        bit 15-0: lower 16 bits of 24 bit offset parameter
727    NAOMI_DIMM_PARAMETERL = 5f7044  1400001c (16 bit)
728    NAOMI_DIMM_PARAMETERH = 5f7048  14000020 (16 bit)
729    NAOMI_DIMM_STATUS     = 5f704c  14000024 (16 bit):
730        bit 0: when 0 signal interrupt from naomi to dimm board
731        bit 8: when 0 signal interrupt from dimm board to naomi
731732*/
732733
733734// NOTE: all accesses are 16 or 32 bits wide but only 16 bits are valid
r3333r3334
812813      // ROM_OFFSETH
813814      rom_offset &= 0xffff;
814815      rom_offset |= (data & 0x1fff)<<16;
816      rom_offset_flags = data >> 13;
815817   }
816818   else if ((offset == 0) && ACCESSING_BITS_32_47)
817819   {
r3333r3334
819821      rom_offset &= 0xffff0000;
820822      rom_offset |= ((data >> 32) & 0xffff);
821823   }
824   if ((offset == 1) && ACCESSING_BITS_0_15)
825   {
826      // ROM_DATA
827      // Doa2 writes here (16 bit decryption key ?)
828      mame_printf_verbose("ROM: write %llx to 5f7008 (PC=%x)\n", data, activecpu_get_pc());
829   }
822830   else if ((offset == 15) && ACCESSING_BITS_0_15)
823831   {
824832      // NAOMI_BOARDID_WRITE
r3333r3334
11541162EPR-23605  - NAOMI BOOT ROM 2001 01/19  1.50 (Japan)
11551163EPR-23605A - NAOMI BOOT ROM 2001 06/20  1.60 (Japan)
11561164EPR-23605B - NAOMI BOOT ROM 2001 09/10  1.70 (Japan)
1165EPR-23605C - NAOMI BOOT ROM 2002 07/08  1.8- (Japan)
11571166EPR-23607  - NAOMI BOOT ROM 2001 01/19  1.50 (USA)
11581167EPR-23607B - NAOMI BOOT ROM 2001 09/10  1.70 (USA)
11591168EPR-23608  - NAOMI BOOT ROM 2001 01/19  1.50 (Export)
r3333r3334
11851194   ROM_LOAD16_WORD_SWAP_BIOS( 2, "epr-23607b.bin",   0x000000, 0x200000, CRC(f308c5e9) SHA1(5470ab1cee6afecbd8ca8cf40f8fbe4ec2cb1471) ) \
11861195   ROM_SYSTEM_BIOS( 3, "bios3", "epr-23607 (USA)"  ) \
11871196   ROM_LOAD16_WORD_SWAP_BIOS( 3, "epr-23607.bin",    0x000000, 0x200000, CRC(2b55add2) SHA1(547de5f97d3183c8cd069c4fa3c09f13d8b637d9) ) \
1188   ROM_SYSTEM_BIOS( 4, "bios4", "epr-23605b (Japan)" ) \
1189   ROM_LOAD16_WORD_SWAP_BIOS( 4, "epr-23605b.bin",   0x000000, 0x200000, CRC(3a3242d4) SHA1(aaca4df51ef91d926f8191d372f3dfe1d20d9484) ) \
1190   ROM_SYSTEM_BIOS( 5, "bios5", "epr-23605a (Japan)" ) \
1191   ROM_LOAD16_WORD_SWAP_BIOS( 5, "epr-23605a.bin",   0x000000, 0x200000, CRC(7bc3fc2d) SHA1(a4a9531a7c66ff30046908cf71f6c7b6fb59c392) ) \
1192   ROM_SYSTEM_BIOS( 6, "bios6", "epr-23605 (Japan)"  ) \
1193   ROM_LOAD16_WORD_SWAP_BIOS( 6, "epr-23605.bin",    0x000000, 0x200000, CRC(5731e446) SHA1(787b0844fc408cf124c12405c095c59948709ea6) )
1197   ROM_SYSTEM_BIOS( 4, "bios4", "epr-23605c (Japan)" ) \
1198   ROM_LOAD16_WORD_SWAP_BIOS( 4, "epr-23605c.bin",   0x000000, 0x200000, CRC(297ea6ed) SHA1(cfbfe57c80e6ee86a101fa83aec0a01e00c0f42a) ) \
1199   ROM_SYSTEM_BIOS( 5, "bios5", "epr-23605b (Japan)" ) \
1200   ROM_LOAD16_WORD_SWAP_BIOS( 5, "epr-23605b.bin",   0x000000, 0x200000, CRC(3a3242d4) SHA1(aaca4df51ef91d926f8191d372f3dfe1d20d9484) ) \
1201   ROM_SYSTEM_BIOS( 6, "bios6", "epr-23605a (Japan)" ) \
1202   ROM_LOAD16_WORD_SWAP_BIOS( 6, "epr-23605a.bin",   0x000000, 0x200000, CRC(7bc3fc2d) SHA1(a4a9531a7c66ff30046908cf71f6c7b6fb59c392) ) \
1203   ROM_SYSTEM_BIOS( 7, "bios7", "epr-23605 (Japan)"  ) \
1204   ROM_LOAD16_WORD_SWAP_BIOS( 7, "epr-23605.bin",    0x000000, 0x200000, CRC(5731e446) SHA1(787b0844fc408cf124c12405c095c59948709ea6) )
11941205
11951206/* this is one flashrom, however the second half looks like it's used for game settings, may differ between dumps, and may not be needed / could be blanked */
11961207#define AW_BIOS \
r3333r3334
12691280    int S3[8];
12701281};
12711282
1272struct AtomiswaveKey fotns_key = {
1283static const struct AtomiswaveKey fotns_key = {
12731284    {0,2,7,11,12,1,5,6,15,4,8,9,14,3,10,13},
12741285    {12,8,3,7,0,15,1,11,6,10,4,14,9,5,13,2},
12751286    {4,1,10,16,9,25,26,31,13,0,14,15,24,6,30,18,7,20,5,12,22,17,27,3,8,11,21,29,19,23,28,2},
r3333r3334
12781289    {7,1,6,5,4,2,0,3}
12791290};
12801291
1281struct AtomiswaveKey df_key = {
1292static const struct AtomiswaveKey df_key = {
12821293    {1,4,5,6,9,7,10,11,13,0,8,12,14,2,3,15},
12831294    {12,0,3,8,7,6,15,11,1,4,14,10,9,5,13,2},
12841295    {9,27,15,6,28,30,7,12,21,0,1,25,22,3,16,29,13,4,24,20,2,5,23,19,18,10,8,14,17,11,31,26},
r3333r3334
12881299};
12891300
12901301
1291UINT16 atomiswave_decrypt(UINT16 cipherText, int address, struct AtomiswaveKey* key)
1302static UINT16 atomiswave_decrypt(UINT16 cipherText, int address, const struct AtomiswaveKey* key)
12921303{
12931304    int b0,b1,b2,b3;
12941305    int aux;
r3333r3334
13141325}
13151326
13161327
1317DRIVER_INIT(fotns)
1328static DRIVER_INIT(fotns)
13181329{
13191330     int i;
13201331   UINT16 *src = (UINT16 *)(memory_region(machine, "user1"));
r3333r3334
13441355
13451356
13461357
1347DRIVER_INIT(demofist)
1358static DRIVER_INIT(demofist)
13481359{
13491360     int i;
13501361   UINT16 *src = (UINT16 *)(memory_region(machine, "user1"));
r3333r3334
25262537   NAOMI_BIOS
25272538
25282539   ROM_REGION( 0xb000000, "user1", 0)
2529   ROM_LOAD("epr22121.22", 0x0000000, 0x0400000,  CRC(30f93b5e) SHA1(0e33383e7ab9a721dab4708b063598f2e9c9f2e7) )
2540   ROM_LOAD("epr22121.22", 0x0000000, 0x0400000,  CRC(30f93b5e) SHA1(0e33383e7ab9a721dab4708b063598f2e9c9f2e7) ) // partially encrypted
25302541
25312542   ROM_LOAD("mpr-22100.ic1", 0x0800000, 0x0800000, CRC(92a53e5e) SHA1(87fcdeee9c4e65a3eb6eb345eed85d4f2df26c3c) )
25322543   ROM_LOAD("mpr-22101.ic2", 0x1000000, 0x0800000, CRC(14cd7dce) SHA1(5df14a5dad14bc922b4f88881dc2e9c8e74d6170) )
r3333r3334
27222733
27232734*/
27242735
2736#ifdef UNUSED_FUNCTION
27252737// rather crude function to write out a key file
27262738void naomi_write_keyfile(void)
27272739{
r3333r3334
27922804
27932805
27942806}
2807#endif
2808
27952809extern void naomi_game_decrypt(UINT64 key, UINT8* region, int length);
27962810
27972811
r3333r3334
28572871
28582872
28592873
2860DRIVER_INIT( ngdkey )
2874static DRIVER_INIT( ngdkey )
28612875{
28622876   UINT8* picdata = memory_region(machine,"picreturn");
28632877   UINT64 key;
src/mame/drivers/goal92.c
r3333r3334
287287   16*16
288288};
289289
290#ifdef UNUSED_FUNCTON
290#ifdef UNUSED_FUNCTION
291291static const gfx_layout layout_16x16x4_2 =
292292{
293293   16,16,
src/mame/drivers/firefox.c
r3333r3334
2626*/
2727
2828#include "mame.h"
29#include "deprecat.h"
3029#include "driver.h"
3130#include "cpu/m6809/m6809.h"
3231#include "cpu/m6502/m6502.h"
r3333r3334
3736#include "machine/6532riot.h"
3837#include "machine/x2212.h"
3938
39
40#define MASTER_XTAL      XTAL_14_31818MHz
41
42
4043/*
4144fff6=firq e4a2 when dav goes active/low
4245fff8=irq e38f  This is through a flip-flop so goes off (high as active low) only when reset_irq is active - low.
r3333r3334
5659/* FXXXXX for first field
5760   AXXXXX for second field */
5861
62static const device_config *laserdisc;
5963static int m_n_disc_lock;
6064static int m_n_disc_left_audio;
6165static int m_n_disc_right_audio;
6266static int m_n_disc_data;
63static int command_offset;
64static int command_data[ 3 ];
65static int manchester_data[ 6 ];
66static int manchester_offset;
67static int disc_reset;
68static int disk_opr = 0;
69static int dav = 0x80;
70static int dak_just_low = 0;  /* simulate the 15 uS time for the player to read the data */
71static int dak = 0x40; /* DAK or DSKFULL active low indicates player has data,
72                          reset when player has read data */
73static int disk_data; /* after a command is sent the first bit indicates an error, except of the data is 0x00 which indicates an invalid manchester data read (whatever that means) */
67static int m_n_disc_read_data;
7468
75int laser_disc_speed = 0;
76int laser_disc_field = 0;
77void laser_seek_frame( int frame )
78{
79}
80
81
8269/* 20 = DISKOPR - Active low
8370   40 = DISKFULL - Active low
8471   80 = DISKDAV - Active low data available
8572   */
86READ8_HANDLER( firefox_disc_status_r )
73static READ8_HANDLER( firefox_disc_status_r )
8774{
88   int n_data;
89   n_data = dav | dak | disk_opr; /* always operational */
90   logerror( "%08x: disc status r %02x\n", activecpu_get_pc(), n_data & ( 0x80 | 0x40 | 0x20 ) );
91   /*
92    fprintf(stderr,  "%08x: reading disc status r %02x\n", activecpu_get_pc(), n_data & ( 0x80 | 0x40 | 0x20 ) );
93    */
94   if(dak_just_low)
95   {
96      /* assume that the next status read will be after 15uS */
97      dak = 0x40;
98      dak_just_low = 0;
99   }
100   return n_data;
75   UINT8 result = 0xff;
76
77   result ^= 0x20;
78   if (!laserdisc_line_r(laserdisc, LASERDISC_LINE_READY))
79      result ^= 0x40;
80   if (laserdisc_line_r(laserdisc, LASERDISC_LINE_DATA_AVAIL))
81      result ^= 0x80;
82
83   return result;
10184}
10285
10386/* 4105 - DREAD */
10487/* this reset RDDSK (&DSKRD) */
105READ8_HANDLER( firefox_disc_data_r )
88static READ8_HANDLER( firefox_disc_data_r )
10689{
107   return disk_data;
90   return m_n_disc_read_data;
10891}
10992
11093/* DISK READ ENABLE */
11194/* 4218 - DSKREAD, set RDDSK */
112WRITE8_HANDLER( firefox_disc_read_w )
95static WRITE8_HANDLER( firefox_disc_read_w )
11396{
114   dav=0x80;
115   if( manchester_offset < 6 )
116   {
117      disk_data = manchester_data[ manchester_offset++ ];
118      if(manchester_offset < 6)
119       {
120         dav = 0; /* more data */
121         cpunum_set_input_line( machine, 0, M6809_FIRQ_LINE, ASSERT_LINE );
122      }
123
124   }
97   m_n_disc_read_data = laserdisc_data_r(laserdisc);
12598}
12699
127WRITE8_HANDLER( firefox_disc_lock_w )
100static WRITE8_HANDLER( firefox_disc_lock_w )
128101{
129102   m_n_disc_lock = data & 0x80;
130103}
131104
132WRITE8_HANDLER( firefox_disc_right_audio_enable_w )
105static WRITE8_HANDLER( audio_enable_w )
133106{
134   m_n_disc_right_audio = data & 0x80;
107   if (!(offset & 1))
108      m_n_disc_right_audio = data & 0x80;
109   else
110      m_n_disc_left_audio = data & 0x80;
135111}
136112
137WRITE8_HANDLER( firefox_disc_left_audio_enable_w )
113static WRITE8_HANDLER( firefox_disc_reset_w )
138114{
139   m_n_disc_left_audio = data & 0x80;
115   laserdisc_line_w(laserdisc, LASERDISC_LINE_RESET, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
140116}
141117
142WRITE8_HANDLER( firefox_disc_reset_w )
143{
144   disc_reset = (data & 0x80);
145   if(!disc_reset)
146   {
147      laser_disc_speed = 0;
148      manchester_offset = 6; /* no data available */
149      command_offset = 0;
150      dak = 0x40;
151      dav = 0x80;
152   }
153}
154
155118/* active low on dbb7 */
156WRITE8_HANDLER( firefox_disc_write_w )
119static WRITE8_HANDLER( firefox_disc_write_w )
157120{
158   if( ( data & 0x80 ) == 0 )
159   {
160      dak = 0; /* should go high after 15 uS */
161      dak_just_low = 1;
162      command_data[ command_offset++ ] = m_n_disc_data;
163      if( command_offset == 3 )
164      {
165         command_offset = 0;
166         switch( command_data[ 0 ] & 0xf0 )
167         {
168         case 0xf0:
169            logerror( "CMD: goto Frame #%01x%02x%02x & play forward\n", command_data[ 0 ] & 0x0f, command_data[ 1 ], command_data[ 2 ] );
170            laser_disc_field =
171               ( ( command_data[ 0 ] & 0x0f ) * 20000 ) +
172               ( (( command_data[ 1 ] & 0xf0 ) >> 4) * 2000 ) +
173               ( ( command_data[ 1 ] & 0x0f ) * 200 ) +
174               ( (( command_data[ 2 ] & 0xf0 ) >> 4) * 20 ) +
175               ( ( command_data[ 2 ] & 0x0f ) * 2 );
176            laser_seek_frame(laser_disc_field >> 1);
177            /*
178                fprintf(stderr, "CMD: goto frame #%01x%02x%02x & play forward disc_field %d\n", command_data[ 0 ] & 0x0f, command_data[ 1 ], command_data[ 2 ] , laser_disc_field);
179                */
180            laser_disc_speed = 1;
181            return;
182         case 0xd0:
183            /*
184                fprintf(stderr,  "CMD: goto Frame #%01x%02x%02x & halt (first field)\n", command_data[ 0 ] & 0x0f, command_data[ 1 ], command_data[ 2 ] );
185                */
186            laser_disc_field =
187               ( ( command_data[ 0 ] & 0x0f ) * 20000 ) +
188               ( (( command_data[ 1 ] & 0xf0 ) >> 4) * 2000 ) +
189               ( ( command_data[ 1 ] & 0x0f ) * 200 ) +
190               ( (( command_data[ 2 ] & 0xf0 ) >> 4) * 20 ) +
191               ( ( command_data[ 2 ] & 0x0f ) * 2 );
192            laser_seek_frame(laser_disc_field >> 1);
193            laser_disc_speed = 0;
194            return;
195         case 0x00:
196            switch( command_data[ 0 ] & 0x0f )
197            {
198            case 0x00:
199               switch( command_data[ 1 ] & 0xf0 )
200               {
201               case 0x00:
202                  laser_disc_speed = 1;
203                  return;
204               case 0x10:
205                  laser_disc_speed = -1;
206                  return;
207               case 0x20:
208                  laser_disc_speed = 0;
209                  return;
210               case 0x40:
211                  return;
212               case 0x50:
213                  return;
214               case 0xa0:
215                  laser_disc_speed = 75;
216                  return;
217               case 0xb0:
218                  laser_disc_speed = -75;
219                  return;
220               case 0xe0:
221                  return;
222               case 0xf0:
223                  return;
224               }
225               break;
226            case 0x02:
227               switch( command_data[ 1 ] )
228               {
229               case 0xb0:
230                  logerror( "CMD: Video ON/OFF %02x\n", command_data[ 2 ] );
231                  return;
232               case 0xb1:
233                  logerror( "CMD: Audio-I ON/OFF %02x\n", command_data[ 2 ] );
234                  return;
235               case 0xb2:
236                  logerror( "CMD: Audio-II ON/OFF %02x\n", command_data[ 2 ] );
237                  return;
238               case 0xb3:
239                  logerror( "CMD: CX ON/OFF %02x\n", command_data[ 2 ] );
240                  return;
241               }
242               break;
243            }
244            break;
245         }
246         logerror( "CMD: invalid %02x%02x%02x\n", command_data[ 0 ], command_data[ 1 ], command_data[ 2 ] );
247      }
248   }
121   if ( ( data & 0x80 ) == 0 )
122      laserdisc_data_w(laserdisc, m_n_disc_data);
249123}
250124
251125/* latch the data */
252WRITE8_HANDLER( firefox_disc_data_w )
126static WRITE8_HANDLER( firefox_disc_data_w )
253127{
254128   m_n_disc_data = data;
255129}
256130
257static TIMER_DEVICE_CALLBACK( laserdisk_timer_callback )
258{
259   if(param == 0 && laser_disc_speed != 0)
260   {
261      manchester_data[ 0 ] = ( ( laser_disc_field & 0x01 )?0xA0:0xF0 ) | ( ( laser_disc_field / 20000 ) % 10 );
262      manchester_data[ 1 ] = ( ( ( laser_disc_field / 2000 ) % 10 ) << 4 ) | ( ( laser_disc_field / 200 ) % 10 );
263      manchester_data[ 2 ] = ( ( ( laser_disc_field / 20 ) % 10 ) << 4 ) | ( ( laser_disc_field / 2 ) % 10 );
264      manchester_data[ 3 ] = 0xff;
265      manchester_data[ 4 ] = 0xff;
266      manchester_data[ 5 ] = 0xff;
267      manchester_offset = 0;
268      cpunum_set_input_line( Machine, 0, M6809_FIRQ_LINE, ASSERT_LINE );
269      dav = 0;  /* buffer contains info */
270131
271      laser_disc_field += laser_disc_speed;
272   }
273}
274
275
276
277132static unsigned char *tileram;
278static size_t tileram_size;
279133static unsigned char *tile_palette;
280134static unsigned char *sprite_palette;
281135static const device_config *nvram_1c;
r3333r3334
292146 *
293147 *************************************/
294148
295static void draw_sprites( bitmap_t *bitmap, int priority, const rectangle *visarea )
149static VIDEO_UPDATE( firefox )
296150{
151   int x;
152   int y;
297153   int sprite;
154   int gfxtop = video_screen_get_visible_area(screen)->min_y;
298155
156   fillbitmap( bitmap, 256, cliprect );
157
158   for( y = 0; y < 64; y++ )
159   {
160      for( x = 0; x < 64; x++ )
161      {
162         drawgfx( bitmap, screen->machine->gfx[ 0 ], tileram[ x + ( y * 64 ) ], 0, 0, 0, x * 8, gfxtop + y * 8, cliprect, TRANSPARENCY_PEN, 0 );
163      }
164   }
165
299166   for( sprite = 0; sprite < 32; sprite++ )
300167   {
301168      UINT8 *sprite_data = spriteram + ( 0x200 * sprite_bank ) + ( sprite * 16 );
r3333r3334
309176
310177         for( row = 0; row < 8; row++ )
311178         {
312            int code = sprite_data[ 15 - row ] + ( 256 * ( ( flags >> 6 ) & 3 ) );
313179            int color = 2 * ( ( flags >> 2 ) & 0x03 );
314            int flipx = flags & 0x20;
315180            int flipy = flags & 0x10;
181            int flipx = flags & 0x20;
182            int code = sprite_data[ 15 - row ] + ( 256 * ( ( flags >> 6 ) & 3 ) );
316183
317            if( ( flags & 1 ) == priority )
318            {
319               drawgfx( bitmap, Machine->gfx[ 1 ], code, color, flipx, flipy, x + 16, 500 - y - ( row * 16 ), visarea, TRANSPARENCY_PEN, 0 );
320            }
184            drawgfx( bitmap, screen->machine->gfx[ 1 ], code, color, flipx, flipy, x + 16, gfxtop + 500 - y - ( row * 16 ), cliprect, TRANSPARENCY_PEN, 0 );
321185         }
322186      }
323187   }
324188
325}
326
327VIDEO_UPDATE( firefox )
328{
329   int x;
330   int y;
331   const rectangle *visarea = video_screen_get_visible_area( Machine->primary_screen );
332
333   fillbitmap( bitmap, 256, visarea );
334
335   draw_sprites( bitmap, 1, visarea );
336
337   for( y = 0; y < 64; y++ )
338   {
339      for( x = 0; x < 64; x++ )
340      {
341         drawgfx( bitmap, Machine->gfx[ 0 ], tileram[ x + ( y * 64 ) ], 0, 0, 0, x * 8, y * 8, visarea, TRANSPARENCY_PEN, 0 );
342      }
343   }
344
345   draw_sprites( bitmap, 0, visarea );
346
347189   return 0;
348190}
349191
r3333r3334
351193{
352194   video_screen_update_now(timer->machine->primary_screen);
353195
354   cpunum_set_input_line( Machine, 0, M6809_IRQ_LINE, ASSERT_LINE );
196   cputag_set_input_line( timer->machine, "main", M6809_IRQ_LINE, ASSERT_LINE );
355197}
356198
357static void set_rgba( int start, int index, unsigned char *palette_ram )
199static void set_rgba( running_machine *machine, int start, int index, unsigned char *palette_ram )
358200{
359201   int r = palette_ram[ index ];
360202   int g = palette_ram[ index + 256 ];
361203   int b = palette_ram[ index + 512 ];
362204   int a = ( b & 3 ) * 0x55;
363205
364   palette_set_color( Machine, start + index, MAKE_RGB( r, g, b ) );
365   render_container_set_palette_alpha(render_container_get_screen(Machine->primary_screen), start + index, a);
206   palette_set_color( machine, start + index, MAKE_RGB( r, g, b ) );
207   render_container_set_palette_alpha(render_container_get_screen(machine->primary_screen), start + index, a);
366208}
367209
368210static WRITE8_HANDLER( tile_palette_w )
369211{
370212   tile_palette[ offset ] = data;
371   set_rgba( 0, offset & 0xff, tile_palette );
213   set_rgba( machine, 0, offset & 0xff, tile_palette );
372214}
373215
374216static WRITE8_HANDLER( sprite_palette_w )
375217{
376218   sprite_palette[ offset ] = data;
377   set_rgba( 256, offset & 0xff, sprite_palette );
219   set_rgba( machine, 256, offset & 0xff, sprite_palette );
378220}
379221
380WRITE8_HANDLER( firefox_objram_bank_w )
222static WRITE8_HANDLER( firefox_objram_bank_w )
381223{
382224   sprite_bank = data & 0x03;
383225}
r3333r3334
409251static WRITE8_HANDLER( main_to_sound_w )
410252{
411253   main_to_sound_flag = 1;
412   soundlatch_w(Machine, 0, data);
413   cputag_set_input_line(Machine, "audio", INPUT_LINE_NMI, PULSE_LINE);
254   soundlatch_w(machine, 0, data);
255   cputag_set_input_line(machine, "audio", INPUT_LINE_NMI, PULSE_LINE);
414256}
415257
416258static WRITE8_HANDLER( sound_reset_w )
r3333r3334
423265static READ8_HANDLER( main_to_sound_r )
424266{
425267   main_to_sound_flag = 0;
426   return soundlatch_r(Machine, 0);
268   return soundlatch_r(machine, 0);
427269}
428270
429271static WRITE8_HANDLER( sound_to_main_w )
430272{
431273   sound_to_main_flag = 1;
432   soundlatch2_w(Machine, 0, data);
274   soundlatch2_w(machine, 0, data);
433275}
434276
435277
r3333r3334
484326{
485327   if( control_num == 0 )
486328   {
487      return input_port_read( Machine, "PITCH" );
329      return input_port_read( machine, "PITCH" );
488330   }
489331
490   return input_port_read( Machine, "YAW" );
332   return input_port_read( machine, "YAW" );
491333}
492334
493335static WRITE8_HANDLER( adc_select_w )
r3333r3334
534376 *
535377 *************************************/
536378
537WRITE8_HANDLER( rom_bank_w )
379static WRITE8_HANDLER( rom_bank_w )
538380{
539381   memory_set_bank(1, data & 0x1f);
540382}
541383
542384static WRITE8_HANDLER( main_irq_clear_w )
543385{
544    cpunum_set_input_line( machine, 0, M6809_IRQ_LINE, CLEAR_LINE );
386    cputag_set_input_line( machine, "main", M6809_IRQ_LINE, CLEAR_LINE );
545387}
546388
547389static WRITE8_HANDLER( main_firq_clear_w )
548390{
549    cpunum_set_input_line( machine, 0, M6809_FIRQ_LINE, CLEAR_LINE );
391    cputag_set_input_line( machine, "main", M6809_FIRQ_LINE, CLEAR_LINE );
550392}
551393
552WRITE8_HANDLER( self_reset_w )
394static WRITE8_HANDLER( self_reset_w )
553395{
554   cpunum_set_input_line( Machine, 0, INPUT_LINE_RESET, PULSE_LINE );
396   cputag_set_input_line( machine, "main", INPUT_LINE_RESET, PULSE_LINE );
555397}
556398
557399
r3333r3334
562404 *
563405 *************************************/
564406
565WRITE8_HANDLER( led_w )
407static WRITE8_HANDLER( led_w )
566408{
567   if( ( data & 0x80 ) != 0 )
568   {
569       set_led_status( offset, 0 );
570   }
571   else
572   {
573       set_led_status( offset, 1 );
574   }
409    set_led_status( offset, ( data & 0x80 ) == 0 );
575410}
576411
577WRITE8_HANDLER( firefox_coin_counter_w )
412static WRITE8_HANDLER( firefox_coin_counter_w )
578413{
579414   coin_counter_w( offset, data & 0x80 );
580415}
581416
582417
583418
584MACHINE_START( firefox )
419static void firq_gen(const device_config *device, int state)
585420{
421   if (state)
422       cputag_set_input_line( device->machine, "main", M6809_FIRQ_LINE, ASSERT_LINE );
423}
424
425
426static MACHINE_START( firefox )
427{
586428   memory_configure_bank(1, 0, 32, memory_region(machine, "main") + 0x10000, 0x1000);
587429   nvram_1c = device_list_find_by_tag(machine->config->devicelist, X2212, "nvram_1c");
588430   nvram_1d = device_list_find_by_tag(machine->config->devicelist, X2212, "nvram_1d");
589431
432   laserdisc = device_list_find_by_tag(machine->config->devicelist, LASERDISC, "laserdisc");
433   vp931_set_data_ready_callback(laserdisc, firq_gen);
434
590435   control_num = 0;
591436   sprite_bank = 0;
592
593   command_data[ 0 ] = 0;
594   command_data[ 1 ] = 0;
595   command_data[ 2 ] = 0;
596   command_offset = 0;
597
598   laser_disc_field = 0;
599   laser_disc_speed = 0;
600   manchester_offset = 6;
601437}
602438
603439
r3333r3334
607443 *
608444 *************************************/
609445
610static ADDRESS_MAP_START( main_map , ADDRESS_SPACE_PROGRAM, 8)
446static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8)
611447   AM_RANGE(0x0000, 0x0fff) AM_RAM
612   AM_RANGE(0x1000, 0x1fff) AM_RAM AM_BASE(&tileram) AM_SIZE(&tileram_size)
613   AM_RANGE(0x2000, 0x27ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
448   AM_RANGE(0x1000, 0x1fff) AM_RAM AM_BASE(&tileram)
449   AM_RANGE(0x2000, 0x27ff) AM_RAM AM_BASE(&spriteram)
614450   AM_RANGE(0x2800, 0x2aff) AM_READWRITE(SMH_RAM, sprite_palette_w) AM_BASE(&sprite_palette)
615   AM_RANGE(0x2b00, 0x2b00) AM_WRITE(firefox_objram_bank_w)
616   AM_RANGE(0x2b01, 0x2bff) AM_RAM
451   AM_RANGE(0x2b00, 0x2b00) AM_MIRROR(0x04ff) AM_WRITE(firefox_objram_bank_w)
617452   AM_RANGE(0x2c00, 0x2eff) AM_READWRITE(SMH_RAM, tile_palette_w) AM_BASE(&tile_palette)
618   AM_RANGE(0x2f00, 0x2fff) AM_RAM
619453   AM_RANGE(0x3000, 0x3fff) AM_ROMBANK(1)
620   AM_RANGE(0x4000, 0x40ff) AM_READWRITE(nvram_r, nvram_w)
621   AM_RANGE(0x4100, 0x4100) AM_READ_PORT("IN0")
622   AM_RANGE(0x4101, 0x4101) AM_READ_PORT("IN1")
623   AM_RANGE(0x4102, 0x4102) AM_READ(firefox_disc_status_r)
624   AM_RANGE(0x4103, 0x4103) AM_READ_PORT("IN3")
625   AM_RANGE(0x4104, 0x4104) AM_READ_PORT("IN4")
626   AM_RANGE(0x4105, 0x4105) AM_READ(firefox_disc_data_r)
627   AM_RANGE(0x4106, 0x4106) AM_READ(sound_to_main_r)
628   AM_RANGE(0x4107, 0x4107) AM_READ(adc_r)
629   AM_RANGE(0x4200, 0x4200) AM_WRITE(main_irq_clear_w)
630   AM_RANGE(0x4208, 0x4208) AM_WRITE(main_firq_clear_w)
631   AM_RANGE(0x4210, 0x4210) AM_WRITE(watchdog_reset_w)
632   AM_RANGE(0x4218, 0x4218) AM_WRITE(firefox_disc_read_w)
633   AM_RANGE(0x4220, 0x4221) AM_WRITE(adc_select_w)
634   AM_RANGE(0x4230, 0x4230) AM_WRITE(self_reset_w)
635   AM_RANGE(0x4280, 0x4280) AM_WRITE(novram_recall_w)
636   AM_RANGE(0x4281, 0x4281) AM_WRITE(sound_reset_w)
637   AM_RANGE(0x4282, 0x4282) AM_WRITE(novram_store_w)
638   AM_RANGE(0x4283, 0x4283) AM_WRITE(firefox_disc_lock_w)
639   AM_RANGE(0x4284, 0x4284) AM_WRITE(firefox_disc_right_audio_enable_w)
640   AM_RANGE(0x4285, 0x4285) AM_WRITE(firefox_disc_left_audio_enable_w)
641   AM_RANGE(0x4286, 0x4286) AM_WRITE(firefox_disc_reset_w)
642   AM_RANGE(0x4287, 0x4287) AM_WRITE(firefox_disc_write_w)
643   AM_RANGE(0x4288, 0x4289) AM_WRITE(firefox_coin_counter_w)
644   AM_RANGE(0x428c, 0x428f) AM_WRITE(led_w)
645   AM_RANGE(0x4290, 0x4290) AM_WRITE(rom_bank_w)
646   AM_RANGE(0x4298, 0x4298) AM_WRITE(main_to_sound_w)
647   AM_RANGE(0x42a0, 0x42a7) AM_WRITE(firefox_disc_data_w)
454   AM_RANGE(0x4000, 0x40ff) AM_READWRITE(nvram_r, nvram_w)                  /* NOVRAM */
455   AM_RANGE(0x4100, 0x4100) AM_MIRROR(0x00f8) AM_READ_PORT("rdin0")         /* RDIN0 */
456   AM_RANGE(0x4101, 0x4101) AM_MIRROR(0x00f8) AM_READ_PORT("rdin1")         /* RDIN1 */
457   AM_RANGE(0x4102, 0x4102) AM_MIRROR(0x00f8) AM_READ(firefox_disc_status_r)   /* RDIN2 */
458   AM_RANGE(0x4103, 0x4103) AM_MIRROR(0x00f8) AM_READ_PORT("opt0")            /* OPT0 */
459   AM_RANGE(0x4104, 0x4104) AM_MIRROR(0x00f8) AM_READ_PORT("opt1")            /* OPT1 */
460   AM_RANGE(0x4105, 0x4105) AM_MIRROR(0x00f8) AM_READ(firefox_disc_data_r)      /* DREAD */
461   AM_RANGE(0x4106, 0x4106) AM_MIRROR(0x00f8) AM_READ(sound_to_main_r)         /* RDSOUND */
462   AM_RANGE(0x4107, 0x4107) AM_MIRROR(0x00f8) AM_READ(adc_r)               /* ADC */
463   AM_RANGE(0x4200, 0x4200) AM_MIRROR(0x0047) AM_WRITE(main_irq_clear_w)      /* RSTIRQ */
464   AM_RANGE(0x4208, 0x4208) AM_MIRROR(0x0047) AM_WRITE(main_firq_clear_w)      /* RSTFIRQ */
465   AM_RANGE(0x4210, 0x4210) AM_MIRROR(0x0047) AM_WRITE(watchdog_reset_w)      /* WDCLK */
466   AM_RANGE(0x4218, 0x4218) AM_MIRROR(0x0047) AM_WRITE(firefox_disc_read_w)   /* DSKREAD */
467   AM_RANGE(0x4220, 0x4223) AM_MIRROR(0x0044) AM_WRITE(adc_select_w)         /* ADCSTART */
468   AM_RANGE(0x4230, 0x4230) AM_MIRROR(0x0047) AM_WRITE(self_reset_w)         /* AMUCK */
469   AM_RANGE(0x4280, 0x4280) AM_MIRROR(0x0040) AM_WRITE(novram_recall_w)      /* LATCH0 -> NVRECALL */
470   AM_RANGE(0x4281, 0x4281) AM_MIRROR(0x0040) AM_WRITE(sound_reset_w)         /* LATCH0 -> RSTSOUND */
471   AM_RANGE(0x4282, 0x4282) AM_MIRROR(0x0040) AM_WRITE(novram_store_w)         /* LATCH0 -> NVRSTORE */
472   AM_RANGE(0x4283, 0x4283) AM_MIRROR(0x0040) AM_WRITE(firefox_disc_lock_w)   /* LATCH0 -> LOCK */
473   AM_RANGE(0x4284, 0x4285) AM_MIRROR(0x0040) AM_WRITE(audio_enable_w)         /* LATCH0 -> SWDSKR, SWDSKL */
474   AM_RANGE(0x4286, 0x4286) AM_MIRROR(0x0040) AM_WRITE(firefox_disc_reset_w)   /* LATCH0 -> RSTDSK */
475   AM_RANGE(0x4287, 0x4287) AM_MIRROR(0x0040) AM_WRITE(firefox_disc_write_w)   /* LATCH0 -> WRDSK */
476   AM_RANGE(0x4288, 0x4289) AM_MIRROR(0x0040) AM_WRITE(firefox_coin_counter_w)   /* LATCH1 -> COIN COUNTERR, COUNTERL */
477   AM_RANGE(0x428c, 0x428f) AM_MIRROR(0x0040) AM_WRITE(led_w)               /* LATCH1 -> LEDs */
478   AM_RANGE(0x4290, 0x4290) AM_MIRROR(0x0047) AM_WRITE(rom_bank_w)            /* WRTREG */
479   AM_RANGE(0x4298, 0x4298) AM_MIRROR(0x0047) AM_WRITE(main_to_sound_w)      /* WRSOUND */
480   AM_RANGE(0x42a0, 0x42a0) AM_MIRROR(0x0047) AM_WRITE(firefox_disc_data_w)   /* DSKLATCH */
648481   AM_RANGE(0x4400, 0xffff) AM_ROM
649482ADDRESS_MAP_END
650483
r3333r3334
678511 *************************************/
679512
680513INPUT_PORTS_START( firefox )
681   PORT_START("IN0")
514   PORT_START("rdin0")
682515   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
683516   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 )
684517   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 )
r3333r3334
688521   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
689522   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
690523
691   PORT_START("IN1")
524   PORT_START("rdin1")
692525   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(mainflag_r, NULL)
693526   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(soundflag_r, NULL)
694527   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_VBLANK )
r3333r3334
698531   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
699532   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN2 )
700533
701   PORT_START("IN3")
534   PORT_START("opt0")
702535   PORT_DIPNAME(    0x03, 0x00, "Coins Per Credit" )
703536   PORT_DIPSETTING( 0x00, "1 Coin 1 Credit" )
704537   PORT_DIPSETTING( 0x01, "2 Coins 1 Credit" )
r3333r3334
721554   PORT_DIPSETTING( 0x60, "2 Credits for 4 Coin Units" )
722555   PORT_DIPSETTING( 0xe0, DEF_STR( Free_Play ) )
723556
724   PORT_START("IN4")
557   PORT_START("opt1")
725558   PORT_DIPNAME( 0x01, 0x00, "Missions" )
726559   PORT_DIPSETTING(    0x00, "All .50" )
727560   PORT_DIPSETTING(    0x01, ".50 .75" )
r3333r3334
782615};
783616
784617static GFXDECODE_START( firefox )
785   GFXDECODE_ENTRY("tiles",   0, tilelayout, 0, 16)
618   GFXDECODE_ENTRY("tiles",   0, tilelayout,   0,  16)
786619   GFXDECODE_ENTRY("sprites", 0, spritelayout, 256, 32)
787620GFXDECODE_END
788621
r3333r3334
807640static MACHINE_DRIVER_START( firefox )
808641
809642   /* basic machine hardware */
810   MDRV_CPU_ADD("main", M6809, 4000000)
643   MDRV_CPU_ADD("main", M6809E, MASTER_XTAL/2)
811644   MDRV_CPU_PROGRAM_MAP(main_map, 0)
812   MDRV_TIMER_ADD_SCANLINE("32v", video_timer_callback, "main", 96, 128)
645   /* interrupts count starting at end of VBLANK, which is 44, so add 44 */
646   MDRV_TIMER_ADD_SCANLINE("32v", video_timer_callback, "main", 96+44, 128)
813647
814   MDRV_CPU_ADD("audio", M6502, 2000000)
648   MDRV_CPU_ADD("audio", M6502, MASTER_XTAL/8)
815649   MDRV_CPU_PROGRAM_MAP(audio_map, 0)
816650
651   MDRV_INTERLEAVE(100)
652
817653   MDRV_MACHINE_START(firefox)
654   MDRV_WATCHDOG_TIME_INIT(UINT64_ATTOTIME_IN_HZ((double)MASTER_XTAL/8/16/16/16/16))
818655
819656   /* video hardware */
820657   MDRV_LASERDISC_SCREEN_ADD_NTSC("main", BITMAP_FORMAT_INDEXED16)
r3333r3334
822659   MDRV_GFXDECODE(firefox)
823660   MDRV_PALETTE_LENGTH(512)
824661
825   MDRV_LASERDISC_ADD("laserdisc", PIONEER_PR8210, "main", "ldsound")
826   MDRV_LASERDISC_OVERLAY(firefox, 64*8, 64*8, BITMAP_FORMAT_INDEXED16)
827   MDRV_LASERDISC_OVERLAY_CLIP(7*8, 53*8-1, 1*8, 62*8-1)
828   MDRV_TIMER_ADD_SCANLINE("laserdisk", laserdisk_timer_callback, "main", 0, 0)
662   MDRV_LASERDISC_ADD("laserdisc", PHILLIPS_22VP931, "main", "ldsound")
663   MDRV_LASERDISC_OVERLAY(firefox, 64*8, 525, BITMAP_FORMAT_INDEXED16)
664   MDRV_LASERDISC_OVERLAY_CLIP(7*8, 53*8-1, 44, 480+44)
829665
830666   MDRV_DEVICE_ADD("nvram_1c",X2212)
831667   MDRV_DEVICE_ADD("nvram_1d",X2212)
832   MDRV_RIOT6532_ADD("riot", 1500000, riot_intf)
668   MDRV_RIOT6532_ADD("riot", MASTER_XTAL/8, riot_intf)
833669
834670   /* sound hardware */
835671   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
836672
837   MDRV_SOUND_ADD("pokey1", POKEY, 1500000)
673   MDRV_SOUND_ADD("pokey1", POKEY, MASTER_XTAL/8)
838674   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.20)
839675   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.20)
840676
841   MDRV_SOUND_ADD("pokey2", POKEY, 1500000)
677   MDRV_SOUND_ADD("pokey2", POKEY, MASTER_XTAL/8)
842678   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.20)
843679   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.20)
844680
845   MDRV_SOUND_ADD("pokey3", POKEY, 1500000)
681   MDRV_SOUND_ADD("pokey3", POKEY, MASTER_XTAL/8)
846682   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.20)
847683   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.20)
848684
849   MDRV_SOUND_ADD("pokey4", POKEY, 1500000)
685   MDRV_SOUND_ADD("pokey4", POKEY, MASTER_XTAL/8)
850686   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.20)
851687   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.20)
852688
853   MDRV_SOUND_ADD("tms", TMS5220, 640000)
689   MDRV_SOUND_ADD("tms", TMS5220, MASTER_XTAL/2/10)
854690   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.50)
855691   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.50)
856692
r3333r3334
858694   MDRV_SOUND_CONFIG(laserdisc_custom_interface)
859695   MDRV_SOUND_ROUTE(0, "left", 1.0)
860696   MDRV_SOUND_ROUTE(1, "right", 1.0)
861
862697MACHINE_DRIVER_END
863698
864699
r3333r3334
906741   ROM_LOAD( "136026.120",     0x1c000,  0x4000, CRC(e1b95923) SHA1(b6d0c0af0a8f55e728cd0f4c3222745eefd57f50)) /* 2a */
907742   ROM_LOAD( "136026.115",     0x20000,  0x4000, CRC(861abc82) SHA1(1845888d07162ae915364a2a91294731f1c5b3bd)) /* 1c */
908743   ROM_LOAD( "136026.119",     0x24000,  0x4000, CRC(959471b1) SHA1(a032209a209f51d34360d5c7ad32ec62150158d2)) /* 1a */
744
745   DISK_REGION( "laserdisc" )
746   DISK_IMAGE_READONLY( "firefox", 0, NO_DUMP )
909747ROM_END
910748
911749ROM_START( firefoxa )
r3333r3334
943781   ROM_LOAD( "136026.120",     0x1c000,  0x4000, CRC(e1b95923) SHA1(b6d0c0af0a8f55e728cd0f4c3222745eefd57f50)) /* 2a */
944782   ROM_LOAD( "136026.115",     0x20000,  0x4000, CRC(861abc82) SHA1(1845888d07162ae915364a2a91294731f1c5b3bd)) /* 1c */
945783   ROM_LOAD( "136026.119",     0x24000,  0x4000, CRC(959471b1) SHA1(a032209a209f51d34360d5c7ad32ec62150158d2)) /* 1a */
784
785   DISK_REGION( "laserdisc" )
786   DISK_IMAGE_READONLY( "firefox", 0, NO_DUMP )
946787ROM_END
947788
948789
src/mame/drivers/tx1.c
r3333r3334
1313        * TX-1 V8 (1984)
1414
1515    Notes:
16        * 'buggyboy' and 'tx1' are preliminary
16        * TX-1 tyre screech noises are not implemented yet.
1717        * 'buggyboy' set is using ROMs from 'buggybjr' for testing purposes
1818        until the original set can be dumped.
1919
r3333r3334
4747#include "rendlay.h"
4848#include "tx1.h"
4949
50
5051/*************************************
5152 *
5253 *  Globals
5354 *
5455 *************************************/
55UINT16   *tx1_math_ram;
56static UINT8 *z80_ram;
56
57UINT16 *tx1_math_ram;
58static UINT8  *z80_ram;
5759static UINT8  tx1_ppi_latch_a;
5860static UINT8  tx1_ppi_latch_b;
5961static UINT32 ts;
6062
6163
64/*************************************
65 *
66 *  CPU Control
67 *
68 *************************************/
69
6270/* Main CPU and Z80 synchronisation */
6371static WRITE16_HANDLER( z80_busreq_w )
6472{
r3333r3334
7583   cpunum_set_input_line(machine, 1, INPUT_LINE_TEST, CLEAR_LINE);
7684}
7785
78/* Z80 can trigger an interrupt itself */
86/* Z80 can trigger its own interrupts */
7987static WRITE8_HANDLER( z80_intreq_w )
8088{
8189   cpunum_set_input_line(machine, 2, 0, HOLD_LINE);
r3333r3334
184192   PORT_DIPSETTING(    0x80, "4" )
185193INPUT_PORTS_END
186194
187
188195static INPUT_PORTS_START( tx1a )
189   PORT_INCLUDE( tx1 )
196   PORT_INCLUDE(tx1)
190197
191   PORT_MODIFY( "DSW" )
198   PORT_MODIFY("DSW")
192199   PORT_DIPNAME( 0x000c, 0x0000, "Game Cost" )
193200   PORT_DIPSETTING(      0x0000, "1 Coin Unit for 1 Credit" )
194201   PORT_DIPSETTING(      0x0004, "2 Coin Units for 1 Credit" )
r3333r3334
407414   return z80_ram[offset];
408415}
409416
417static WRITE8_HANDLER( tx1_coin_cnt )
418{
419   coin_counter_w(0, data & 0x80);
420   coin_counter_w(1, data & 0x40);
421}
422
423static WRITE8_HANDLER( tx1_ppi_latch_w )
424{
425   tx1_ppi_latch_a = ((input_port_read(machine, "AN_BRAKE") & 0xf) << 4) | (input_port_read(machine, "AN_ACCELERATOR") & 0xf);
426   tx1_ppi_latch_b = input_port_read(machine, "AN_STEERING");
427}
428
429static READ8_HANDLER( tx1_ppi_porta_r )
430{
431   return tx1_ppi_latch_a;
432}
433
434static READ8_HANDLER( tx1_ppi_portb_r )
435{
436   return input_port_read(machine, "PPI_PORTD") | tx1_ppi_latch_b;
437}
438
439/* TODO */
440static READ8_HANDLER( bb_analog_r )
441{
442   if ( offset == 1 )
443      return ((input_port_read(machine, "AN_ACCELERATOR") & 0xf) << 4) | input_port_read(machine, "AN_STEERING");
444   else
445      return (input_port_read(machine, "AN_BRAKE") & 0xf) << 4;
446}
447
448static READ8_HANDLER( bbjr_analog_r )
449{
450   if ( offset == 0 )
451      return ((input_port_read(machine, "AN_ACCELERATOR") & 0xf) << 4) | input_port_read(machine, "AN_STEERING");
452   else
453      return (input_port_read(machine, "AN_BRAKE") & 0xf) << 4;
454}
455
456
410457/*************************************
411458 *
459 *  8255 PPI Interfaces
460 *
461 *************************************/
462
463/* Buggy Boy uses an 8255 PPI instead of YM2149 ports for inputs! */
464static const ppi8255_interface buggyboy_ppi8255_intf =
465{
466   input_port_1_r,
467   NULL,
468   input_port_2_r,
469   NULL,
470   NULL,
471   NULL
472};
473
474
475static const ppi8255_interface tx1_ppi8255_intf =
476{
477   tx1_ppi_porta_r,
478   tx1_ppi_portb_r,
479   input_port_4_r,
480   NULL,
481   NULL,
482   tx1_coin_cnt
483};
484
485
486/*************************************
487 *
412488 *  TX-1 Memory Maps
413489 *
414490 *************************************/
r3333r3334
418494   AM_RANGE(0x02000, 0x02fff) AM_MIRROR(0x1000) AM_RAM
419495   AM_RANGE(0x04000, 0x04fff) AM_MIRROR(0x1000) AM_RAM   AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size)
420496   AM_RANGE(0x06000, 0x06fff) AM_READWRITE(tx1_crtc_r, tx1_crtc_w)
421   AM_RANGE(0x08000, 0x09fff) AM_RAM_WRITE(tx1_vram_w) AM_BASE(&tx1_vram)
497   AM_RANGE(0x08000, 0x09fff) AM_RAM AM_BASE(&tx1_vram)
422498   AM_RANGE(0x0a000, 0x0afff) AM_RAM AM_SHARE(1) AM_BASE(&tx1_rcram)
423499   AM_RANGE(0x0b000, 0x0b001) AM_READWRITE(dipswitches_r, z80_busreq_w)
424500   AM_RANGE(0x0c000, 0x0c001) AM_WRITE(tx1_scolst_w)
r3333r3334
444520   AM_RANGE(0xfc000, 0xfffff) AM_ROM
445521ADDRESS_MAP_END
446522
447
448static WRITE8_HANDLER( tx1_ppi_latch_w )
449{
450   tx1_ppi_latch_a = ((input_port_read(machine, "AN_BRAKE") & 0xf) << 4) | (input_port_read(machine, "AN_ACCELERATOR") & 0xf);
451   tx1_ppi_latch_b = input_port_read(machine, "AN_STEERING");
452}
453
454static READ8_HANDLER( tx1_ppi_porta_r )
455{
456   return tx1_ppi_latch_a;
457}
458
459static READ8_HANDLER( tx1_ppi_portb_r )
460{
461   return input_port_read(machine, "PPI_PORTD") | tx1_ppi_latch_b;
462}
463
464523static ADDRESS_MAP_START( tx1_sound_prg, ADDRESS_SPACE_PROGRAM, 8 )
465524   AM_RANGE(0x0000, 0x1fff) AM_ROM
466525   AM_RANGE(0x3000, 0x37ff) AM_RAM AM_MIRROR(0x800) AM_BASE(&z80_ram)
r3333r3334
487546static ADDRESS_MAP_START( buggyboy_main, ADDRESS_SPACE_PROGRAM, 16 )
488547   AM_RANGE(0x00000, 0x03fff) AM_RAM AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size)
489548   AM_RANGE(0x04000, 0x04fff) AM_READWRITE(tx1_crtc_r, tx1_crtc_w)
490   AM_RANGE(0x08000, 0x09fff) AM_RAM_WRITE(buggyboy_vram_w) AM_BASE(&buggyboy_vram)
549   AM_RANGE(0x08000, 0x09fff) AM_RAM AM_BASE(&buggyboy_vram)
491550   AM_RANGE(0x0a000, 0x0afff) AM_RAM AM_SHARE(1) AM_BASE(&buggyboy_rcram) AM_SIZE(&buggyboy_rcram_size)
492551   AM_RANGE(0x0b000, 0x0b001) AM_READWRITE(dipswitches_r, z80_busreq_w)
493552   AM_RANGE(0x0c000, 0x0c001) AM_WRITE(buggyboy_scolst_w)
r3333r3334
502561static ADDRESS_MAP_START( buggybjr_main, ADDRESS_SPACE_PROGRAM, 16 )
503562   AM_RANGE(0x00000, 0x03fff) AM_RAM AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size)
504563   AM_RANGE(0x04000, 0x04fff) AM_READWRITE(tx1_crtc_r, tx1_crtc_w)
505   AM_RANGE(0x08000, 0x08fff) AM_RAM AM_BASE(&buggybjr_vram)
564   AM_RANGE(0x08000, 0x08fff) AM_RAM AM_BASE(&buggyboy_vram)
506565   AM_RANGE(0x0a000, 0x0afff) AM_RAM AM_SHARE(1) AM_BASE(&buggyboy_rcram) AM_SIZE(&buggyboy_rcram_size)
507566   AM_RANGE(0x0b000, 0x0b001) AM_READWRITE(dipswitches_r, z80_busreq_w)
508567   AM_RANGE(0x0c000, 0x0c001) AM_WRITE(buggyboy_scolst_w)
r3333r3334
528587   AM_RANGE(0xfc000, 0xfffff) AM_ROM
529588ADDRESS_MAP_END
530589
531
532/* TODO */
533static READ8_HANDLER( bb_analog_r )
534{
535   if ( offset == 1 )
536   {
537      return ((input_port_read(machine, "AN_ACCELERATOR") & 0xf) << 4) | input_port_read(machine, "AN_STEERING");
538   }
539   else
540   {
541      return (input_port_read(machine, "AN_BRAKE") & 0xf) << 4;
542   }
543}
544
545static READ8_HANDLER( bbjr_analog_r )
546{
547   if ( offset == 0 )
548   {
549      return ((input_port_read(machine, "AN_ACCELERATOR") & 0xf) << 4) | input_port_read(machine, "AN_STEERING");
550   }
551   else
552   {
553      return (input_port_read(machine, "AN_BRAKE") & 0xf) << 4;
554   }
555}
556
557590/* Buggy Boy Sound PCB TC033A */
558591static ADDRESS_MAP_START( buggyboy_sound_prg, ADDRESS_SPACE_PROGRAM, 8 )
559592   AM_RANGE(0x0000, 0x3fff) AM_ROM
r3333r3334
587620
588621/*************************************
589622 *
590 *  Graphics definitions
591 *
592 *************************************/
593
594static const gfx_layout char_layout =
595{
596   8,8,
597   2048,
598   2,
599   { 0, 8*8*2048 },
600   { 0,1,2,3,4,5,6,7 },
601   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
602   8*8
603};
604
605static GFXDECODE_START( buggyboy )
606   GFXDECODE_ENTRY( "gfx1", 0, char_layout, 0, 256 )
607GFXDECODE_END
608
609static GFXDECODE_START( tx1 )
610   GFXDECODE_ENTRY( "gfx1", 0, char_layout, 0, 16 )
611GFXDECODE_END
612
613
614/*************************************
615 *
616623 *  Sound Hardware
617624 *
618625 *************************************/
r3333r3334
650657   bb_ym1_b_w,
651658};
652659
653static WRITE8_HANDLER( tx1_coin_cnt )
654{
655   coin_counter_w(0, data & 0x80);
656   coin_counter_w(1, data & 0x40);
657}
658
659static const ppi8255_interface tx1_ppi8255_intf =
660{
661   tx1_ppi_porta_r,
662   tx1_ppi_portb_r,
663   input_port_4_r,
664   NULL,
665   NULL,
666   tx1_coin_cnt
667};
668
669660static const custom_sound_interface tx1_custom_interface =
670661{
671662   tx1_sh_start,
r3333r3334
673664   tx1_sh_reset
674665};
675666
676/* Buggy Boy uses an 8255 PPI instead of YM2149 ports for inputs! */
677static const ppi8255_interface buggyboy_ppi8255_intf =
678{
679   input_port_1_r,
680   NULL,
681   input_port_2_r,
682   NULL,
683   NULL,
684   NULL
685};
686
687667static const custom_sound_interface bb_custom_interface =
688668{
689669   buggyboy_sh_start,
r3333r3334
691671   buggyboy_sh_reset
692672};
693673
674
694675/*************************************
695676 *
696677 *  Machine driver
r3333r3334
714695   MDRV_MACHINE_START(tx1)
715696   MDRV_NVRAM_HANDLER(generic_0fill)
716697
717   MDRV_DEVICE_ADD( "ppi8255", PPI8255 )
718   MDRV_DEVICE_CONFIG( tx1_ppi8255_intf )
698   MDRV_DEVICE_ADD("ppi8255", PPI8255)
699   MDRV_DEVICE_CONFIG(tx1_ppi8255_intf)
719700
720   MDRV_GFXDECODE(tx1)
721   MDRV_PALETTE_LENGTH(256+(256*4)+(2048*4))
701   MDRV_PALETTE_LENGTH(256)
722702   MDRV_PALETTE_INIT(tx1)
723703   MDRV_VIDEO_EOF(tx1)
724704
r3333r3334
726706
727707   MDRV_SCREEN_ADD("left", RASTER)
728708   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
729   MDRV_SCREEN_REFRESH_RATE(60)
730709   MDRV_SCREEN_RAW_PARAMS(TX1_PIXEL_CLOCK, TX1_HTOTAL, TX1_HBEND, TX1_HBSTART, TX1_VTOTAL, TX1_VBEND, TX1_VBSTART)
731710
732711   MDRV_SCREEN_ADD("center", RASTER)
r3333r3334
772751   MDRV_MACHINE_START(buggyboy)
773752   MDRV_NVRAM_HANDLER(generic_0fill)
774753
775   MDRV_DEVICE_ADD( "ppi8255", PPI8255 )
776   MDRV_DEVICE_CONFIG( buggyboy_ppi8255_intf )
754   MDRV_DEVICE_ADD("ppi8255", PPI8255)
755   MDRV_DEVICE_CONFIG(buggyboy_ppi8255_intf)
777756
778   MDRV_GFXDECODE(buggyboy)
779757   MDRV_DEFAULT_LAYOUT(layout_triphsxs)
780758
781759   MDRV_SCREEN_ADD("left", RASTER)
r3333r3334
790768   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
791769   MDRV_SCREEN_RAW_PARAMS(BB_PIXEL_CLOCK, BB_HTOTAL, BB_HBEND, BB_HBSTART, BB_VTOTAL, BB_VBEND, BB_VBSTART)
792770
793   MDRV_PALETTE_LENGTH(256+(256*4)+(2048*4))
771   MDRV_PALETTE_LENGTH(256)
794772   MDRV_PALETTE_INIT(buggyboy)
795773   MDRV_VIDEO_START(buggyboy)
796774   MDRV_VIDEO_UPDATE(buggyboy)
r3333r3334
830808   MDRV_MACHINE_START(buggybjr)
831809   MDRV_NVRAM_HANDLER(generic_0fill)
832810
833
834811   MDRV_SCREEN_ADD("main", RASTER)
835812   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
836813#if 0
r3333r3334
842819   MDRV_SCREEN_VISIBLE_AREA(0, 255, 0, 239)
843820#endif
844821
845   MDRV_PALETTE_LENGTH(512)
846   MDRV_PALETTE_INIT(buggybjr)
822   MDRV_PALETTE_LENGTH(256)
823   MDRV_PALETTE_INIT(buggyboy)
847824   MDRV_VIDEO_START(buggybjr)
848825   MDRV_VIDEO_UPDATE(buggybjr)
849826   MDRV_VIDEO_EOF(buggyboy)
r3333r3334
865842   MDRV_SOUND_ROUTE(1, "frontright", 0.2)
866843MACHINE_DRIVER_END
867844
845
868846/*************************************
869847 *
870848 *  ROM definition(s)
r3333r3334
875853   ROM_REGION( 0x100000, "main", 0 )
876854   ROM_LOAD16_BYTE( "tx1_1c.ic22", 0xf0000, 0x4000, CRC(eedcee83) SHA1(7fa0590b142fb13c6562126a9bdd5a1e032880c7) )
877855   ROM_LOAD16_BYTE( "tx1_2c.ic29", 0xf0001, 0x4000, CRC(294bf5bf) SHA1(02b425caba8a187c58211bab27988205eb044558) )
878
879856   ROM_LOAD16_BYTE( "tx1_4c.ic54", 0xf8001, 0x4000, CRC(15bb8ef2) SHA1(83968f010ec555fcd0548a80562fb23a892b5afb) )
880857   ROM_LOAD16_BYTE( "tx1_3c.ic45", 0xf8000, 0x4000, CRC(21a8aa55) SHA1(21bc4adefb22a95fcd7a4e305bf0b05e2cb34129) )
881858
r3333r3334
894871   ROM_LOAD( "8411-136027-157.11", 0x00000, 0x2000, CRC(10ae3075) SHA1(69c5f62f2473aba848383eed3cecf15e273d86ca) )
895872
896873   /* 8x8 characters */
897   ROM_REGION( 0x20000, "gfx1", ROMREGION_DISPOSE )
874   ROM_REGION( 0x20000, "gfx1", 0 )
898875   ROM_LOAD( "tx1_21a.ic204", 0x0000, 0x4000, CRC(cd3441ad) SHA1(8e6597b3177b8aaa34ed3373d85fc4b6231e1333) )
899876   ROM_LOAD( "tx1_20a.ic174", 0x4000, 0x4000, CRC(dbe595fc) SHA1(1ed2f775f0a1b46a2ffbc056eb4ef732ed546d3c) )
900877
r3333r3334
902879   ROM_REGION( 0x40000, "gfx2", 0 )
903880   ROM_LOAD( "tx1_16b.ic203", 0x0000, 0x4000, CRC(1141c965) SHA1(4b90c1428bcbd72d0449c064856a5596269b3fc6) )
904881   ROM_LOAD( "tx1_18b.ic258", 0x4000, 0x4000, NO_DUMP )
882   ROM_LOAD( "tx1_15b.ic173", 0x8000, 0x4000, CRC(30d1a8d5) SHA1(b4c585b7b8a8920bb3949d643e9e10c17d4009a0) )
883   ROM_LOAD( "tx1_17b.ic232", 0xc000, 0x4000, CRC(364bb354) SHA1(a26581ca1088b979285471e2c6595048df84d75e) )
905884
906   /* 8x8 object chunks */
907   ROM_REGION( 0x40000, "gfx3", 0 )
908   ROM_LOAD( "tx1_15b.ic173", 0x0000, 0x4000, CRC(30d1a8d5) SHA1(b4c585b7b8a8920bb3949d643e9e10c17d4009a0) )
909   ROM_LOAD( "tx1_17b.ic232", 0x4000, 0x4000, CRC(364bb354) SHA1(a26581ca1088b979285471e2c6595048df84d75e) )
910
911885   /* Road LUTs */
912   ROM_REGION( 0x40000, "gfx4", 0 )
886   ROM_REGION( 0x40000, "gfx3", 0 )
913887   ROM_LOAD( "tx1_5a.ic56", 0x0000, 0x2000, CRC(5635b8c1) SHA1(5cc9437a2ff0843f1917f2451852d4561c240b24) )
914888   ROM_LOAD( "tx1_6a.ic66", 0x2000, 0x2000, CRC(03d83cf8) SHA1(5c0cfc6bf02ad2b3f37e1ceb493f69eb9829ab1e) )
915889   ROM_LOAD( "tx1_7a.ic76", 0x4000, 0x2000, CRC(ad56013a) SHA1(ae3a91f58f30daff334754476db33ad1d12569fc) )
r3333r3334
965939   ROM_LOAD( "xb10.ic40",  0x1300, 0x200, CRC(93deb894) SHA1(5ae9a21298c836fe649a52f3df2b4067f9012b91) )
966940   ROM_LOAD( "xb11.ic49",  0x1500, 0x200, CRC(aa5ed232) SHA1(f33e7bc2dd33ac6d75fb06b93c4dd58e5d10010d) )
967941
968   /* Road related */
942   /* Road stripes */
969943   ROM_LOAD( "xb12.ic50",  0x1700, 0x200, CRC(6b424cea) SHA1(83127326c20116b0a4be1126e163f9c6755e19dc) )
970
971   /* Arithmetic unit instructions */
972   ROM_LOAD16_BYTE( "xb02b.ic223", 0x1800, 0x200, CRC(22c77af6) SHA1(1be8585b95316b4fc5712cdaef699e676320cd4d) )
973   ROM_LOAD16_BYTE( "xb01b.ic213", 0x1801, 0x200, CRC(f6b8b70b) SHA1(b79374acf11d71db1e4ad3c494ac5f500a52677b) )
974944ROM_END
975945
976946/* Some PROMs haven't been confirmed to be the same as the Tatsumi set (but are very likely identical) */
r3333r3334
996966   ROM_LOAD( "8411-136027-157.11", 0x00000, 0x2000, CRC(10ae3075) SHA1(69c5f62f2473aba848383eed3cecf15e273d86ca) )
997967
998968   /* 8x8 characters */
999   ROM_REGION( 0x20000, "gfx1", ROMREGION_DISPOSE )
969   ROM_REGION( 0x20000, "gfx1", 0 )
1000970   ROM_LOAD( "8411-136027-156.204", 0x0000, 0x4000, CRC(60f3c616) SHA1(59c4361891e4274e27e6279c919e8fd6803af7cf) )
1001971   ROM_LOAD( "8411-136027-155.174", 0x4000, 0x4000, CRC(e59a6b72) SHA1(c10efa77ab421ac60b97227a8d547f50f8415670) )
1002972
r3333r3334
11761146   ROM_REGION( 0x10000, "audio", 0 )
11771147   ROM_LOAD( "bug35.11", 0x00000, 0x4000,  CRC(7aa16e9e) SHA1(ea54e56270f70351a62a78fa32027bb41ef9861e) )
11781148
1179   ROM_REGION( 0x20000, "gfx1", ROMREGION_DISPOSE )
1149   /* 8x8 characters */
1150   ROM_REGION( 0x8000, "gfx1", 0 )
11801151   ROM_LOAD( "bug34s.46", 0x00000, 0x4000, CRC(8ea8fec4) SHA1(75e67c9a59a86fcdedf2a70fafd303baa552aa18) )
11811152   ROM_LOAD( "bug33s.47", 0x04000, 0x4000, CRC(459c2b03) SHA1(ff62a86195042a349fbe799c638cf590fe9572bb) )
11821153
1183   ROM_REGION( 0x40000, "gfx2", ROMREGION_DISPOSE )
1184   ROM_LOAD( "bug26s.147", 0x0000, 0x8000, CRC(14033710) SHA1(e05afeb557ce14055fa8b4f6d8805307feaa1660) )
1185   ROM_LOAD( "bug19s.144", 0x8000, 0x8000, CRC(838e0697) SHA1(0e9aff2c4065d79350ddb55edff57a899c33ef1c) )
1154   /* 8x8 object chunks */
1155   ROM_REGION( 0x40000, "gfx2", 0 )
1156   ROM_LOAD( "bug26s.147", 0x00000, 0x8000, CRC(14033710) SHA1(e05afeb557ce14055fa8b4f6d8805307feaa1660) )
1157   ROM_LOAD( "bug19s.144", 0x08000, 0x8000, CRC(838e0697) SHA1(0e9aff2c4065d79350ddb55edff57a899c33ef1c) )
1158   ROM_LOAD( "bug28s.146", 0x10000, 0x8000, CRC(8b47d227) SHA1(a3e57594ad0085e8b1bd327c580eb36237f3e3d2) )
1159   ROM_LOAD( "bug21s.143", 0x18000, 0x8000, CRC(876a5666) SHA1(db485cdf35f63c080c919ee86374f63e577092c3) )
1160   ROM_LOAD( "bug30s.145", 0x20000, 0x8000, CRC(11d8e2a8) SHA1(9bf198229a12d331e8e7352b7ee3f39f6891f517) )
1161   ROM_LOAD( "bug23s.142", 0x28000, 0x8000, CRC(015db5d8) SHA1(39ef8b44f2eb9399fb1555cffa6763e06d59c181) )
11861162
1187   ROM_REGION( 0x40000, "gfx3", ROMREGION_DISPOSE )
1188   ROM_LOAD( "bug28s.146", 0x0000, 0x8000, CRC(8b47d227) SHA1(a3e57594ad0085e8b1bd327c580eb36237f3e3d2) )
1189   ROM_LOAD( "bug21s.143", 0x8000, 0x8000, CRC(876a5666) SHA1(db485cdf35f63c080c919ee86374f63e577092c3) )
1163   /* Road */
1164   ROM_REGION( 0x40000, "gfx6", 0 )
1165   ROM_LOAD( "bug11s.225", 0x0000, 0x4000, CRC(771af4e1) SHA1(a42b164dd0567c78c0d308ee48d63e5a284897bb) )
1166   ROM_LOAD( "bb3s", 0x4000, 0x200, CRC(2ab3d5ff) SHA1(9f8359cb4ba2e7d15dbb9dc21cd71c0902cd2153) )
1167   ROM_LOAD( "bb4s", 0x4200, 0x200, CRC(630f68a4) SHA1(d730f050353c688f81d090e33e00cd35e7b7b6fa) )
1168   ROM_LOAD( "bb5s", 0x4400, 0x200, CRC(65925c9e) SHA1(d1ff1cb9f83c09e52a96632945e4edfedc335fd4) )
1169   ROM_LOAD( "bb6.224", 0x4600, 0x200, CRC(ad43e02a) SHA1(c50a398020508f52ddf8d45881f211d17d096fa1) )
11901170
1191   ROM_REGION( 0x40000, "gfx4", ROMREGION_DISPOSE )
1192   ROM_LOAD( "bug30s.145", 0x0000, 0x8000, CRC(11d8e2a8) SHA1(9bf198229a12d331e8e7352b7ee3f39f6891f517) )
1193   ROM_LOAD( "bug23s.142", 0x8000, 0x8000, CRC(015db5d8) SHA1(39ef8b44f2eb9399fb1555cffa6763e06d59c181) )
1194
1195   ROM_REGION( 0x40000, "gfx5", ROMREGION_DISPOSE )
1196   ROM_LOAD( "bug16s.139", 0x0000,  0x8000, CRC(1903a9ad) SHA1(526c404c15e3f04b4afb27dee66e9deb0a6b9704) )
1197   ROM_LOAD( "bug17s.140", 0x8000,  0x8000, CRC(82cabdd4) SHA1(94324fcf83c373621fc40553473ae3cb552ab704) )
1198   ROM_LOAD( "bug18s.141", 0x10000, 0x4000, CRC(67786327) SHA1(32cc1f5bc654497c968ddcd4af29720c6d659482) )
1199
1200   ROM_REGION( 0x40000, "gfx6", 0)
1201   ROM_LOAD( "bb3s", 0x000, 0x200, CRC(2ab3d5ff) SHA1(9f8359cb4ba2e7d15dbb9dc21cd71c0902cd2153) )
1202   ROM_LOAD( "bb4s", 0x200, 0x200, CRC(630f68a4) SHA1(d730f050353c688f81d090e33e00cd35e7b7b6fa) )
1203   ROM_LOAD( "bb5s", 0x400, 0x200, CRC(65925c9e) SHA1(d1ff1cb9f83c09e52a96632945e4edfedc335fd4) )
1204   ROM_LOAD( "bug11s.225", 0x1000, 0x4000, CRC(771af4e1) SHA1(a42b164dd0567c78c0d308ee48d63e5a284897bb) )
1205
12061171   ROM_REGION( 0x10000, "user1", ROMREGION_LE )
12071172   ROM_LOAD16_BYTE( "bug9.138", 0x0000, 0x4000, CRC(7d84135b) SHA1(3c669c4e796e83672aceeb6de1aeea28f9f2fef0) )
12081173   ROM_LOAD16_BYTE( "bug10.95", 0x0001, 0x4000, CRC(b518dd6f) SHA1(7cefa2f9438306c81dc83cd260928c835eb9b712) )
r3333r3334
12301195   ROM_LOAD( "bb8.31", 0x1600, 0x100, CRC(2330ff4f) SHA1(e86eb63ce47572bcbbf325f9bb749d10d96bf2e7) )
12311196ROM_END
12321197
1198
12331199/*************************************
12341200 *
12351201 *  Game driver(s)
12361202 *
12371203 *************************************/
12381204
1239GAME( 1983, tx1,      0,        tx1,      tx1,      0, ROT0, "Tatsumi", "TX-1",                                   GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING )
1240GAME( 1983, tx1a,     tx1,      tx1,      tx1a,     0, ROT0, "Tatsumi", "TX-1 (Atari/Namco/Taito license)",       GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING )
1241GAME( 1985, buggyboy, buggybjr, buggyboy, buggyboy, 0, ROT0, "Tatsumi", "Buggy Boy/Speed Buggy (Cockpit)",        GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING )
1205GAME( 1983, tx1,      0,        tx1,      tx1,      0, ROT0, "Tatsumi", "TX-1",                                   GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
1206GAME( 1983, tx1a,     tx1,      tx1,      tx1a,     0, ROT0, "Tatsumi", "TX-1 (Atari/Namco/Taito license)",       GAME_IMPERFECT_SOUND )
1207GAME( 1985, buggyboy, buggybjr, buggyboy, buggyboy, 0, ROT0, "Tatsumi", "Buggy Boy/Speed Buggy (Cockpit)",        GAME_NOT_WORKING )
12421208GAME( 1986, buggybjr, 0,        buggybjr, buggybjr, 0, ROT0, "Tatsumi", "Buggy Boy Junior/Speed Buggy (Upright)", 0 )
src/mame/drivers/galaxi.c
r3333r3334
250250                                Input Ports
251251***************************************************************************/
252252
253INPUT_PORTS_START( galaxi )
253static INPUT_PORTS_START( galaxi )
254254
255255   PORT_START("INPUTS")
256256   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_BUTTON1  ) PORT_NAME("Hold 1") PORT_CODE(KEYCODE_Z)
r3333r3334
272272
273273INPUT_PORTS_END
274274
275INPUT_PORTS_START( magjoker )
275static INPUT_PORTS_START( magjoker )
276276
277277   PORT_START("INPUTS")
278278   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_BUTTON1  ) PORT_NAME("Hold 1") PORT_CODE(KEYCODE_Z)
src/mame/drivers/neodrvr.c
r3333r3334
367367   ROM_LOAD( name,     0x00000, 0x80000, hash )                                                \
368368   ROM_RELOAD(          0x10000, 0x80000 )
369369
370#define NEO_BIOS_AUDIO_ENCRYPTED_512K(name, hash) \
371   NEOGEO_BIOS \
372   ROM_REGION( 0x20000, "audiobios", 0 ) \
373   ROM_LOAD( "sm1.sm1", 0x00000, 0x20000, CRC(97cf998b) SHA1(977387a7c76ef9b21d0b01fa69830e949a9a9626) ) \
374   ROM_REGION( 0x90000, "audio", ROMREGION_ERASEFF ) \
375   ROM_REGION( 0x80000, "audiocrypt", 0 ) \
376   ROM_LOAD( name,     0x00000, 0x80000, hash ) \
370377
378#define NEO_BIOS_AUDIO_ENCRYPTED_256K(name, hash) \
379   NEOGEO_BIOS \
380   ROM_REGION( 0x20000, "audiobios", 0 ) \
381   ROM_LOAD( "sm1.sm1", 0x00000, 0x20000, CRC(97cf998b) SHA1(977387a7c76ef9b21d0b01fa69830e949a9a9626) ) \
382   ROM_REGION( 0x90000, "audio", ROMREGION_ERASEFF ) \
383   ROM_REGION( 0x80000, "audiocrypt", 0 ) \
384   ROM_LOAD( name,     0x00000, 0x40000, hash ) \
385
386#define NEO_BIOS_AUDIO_ENCRYPTED_128K(name, hash) \
387   NEOGEO_BIOS \
388   ROM_REGION( 0x20000, "audiobios", 0 ) \
389   ROM_LOAD( "sm1.sm1", 0x00000, 0x20000, CRC(97cf998b) SHA1(977387a7c76ef9b21d0b01fa69830e949a9a9626) ) \
390   ROM_REGION( 0x90000, "audio", ROMREGION_ERASEFF ) \
391   ROM_REGION( 0x80000, "audiocrypt", 0 ) \
392   ROM_LOAD( name,     0x00000, 0x20000, hash ) \
393
394
371395#define NO_DELTAT_REGION
372396
373397
r3333r3334
49985022   ROM_REGION( 0x20000, "fixedbios", 0 )
49995023   ROM_LOAD( "sfix.sfx",  0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
50005024
5001   /* The M1 ROM is encrypted, we load it here for reference and replace it with a decrypted version */
5002   ROM_REGION( 0x40000, "audiocrypt", 0 )
5003   ROM_LOAD( "257-m1.bin", 0x00000, 0x40000, CRC(4b749113) SHA1(2af2361146edd0ce3966614d90165a5c1afb8de4) )
5004   NEO_BIOS_AUDIO_256K( "257-m1_decrypted.bin", CRC(d404db70) SHA1(8cd1f3e140a9a367de23544e76371b0491287909) )
5025   /* Encrypted */
5026   NEO_BIOS_AUDIO_ENCRYPTED_256K( "257-m1.bin", CRC(4b749113) SHA1(2af2361146edd0ce3966614d90165a5c1afb8de4) )
50055027
50065028   ROM_REGION( 0x1000000, "ym", 0 )
50075029   ROM_LOAD( "257-v1.bin", 0x000000, 0x400000, CRC(17cde847) SHA1(4bcc0205b70dc6d9216b29025450c9c5b08cb65d) )
r3333r3334
50355057   ROM_REGION( 0x20000, "fixedbios", 0 )
50365058   ROM_LOAD( "sfix.sfx",  0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
50375059
5038   /* The M1 ROM is encrypted, we load it here for reference and replace it with a decrypted version */
5039   ROM_REGION( 0x40000, "audiocrypt", 0 )
5040   ROM_LOAD( "257-m1.bin", 0x00000, 0x40000, CRC(4b749113) SHA1(2af2361146edd0ce3966614d90165a5c1afb8de4) )
5041   NEO_BIOS_AUDIO_256K( "257-m1_decrypted.bin", CRC(d404db70) SHA1(8cd1f3e140a9a367de23544e76371b0491287909) )
5060   /* Encrypted */
5061   NEO_BIOS_AUDIO_ENCRYPTED_256K( "257-m1.bin", CRC(4b749113) SHA1(2af2361146edd0ce3966614d90165a5c1afb8de4) )
50425062
50435063   ROM_REGION( 0x1000000, "ym", 0 )
50445064   ROM_LOAD( "257-v1.bin", 0x000000, 0x400000, CRC(17cde847) SHA1(4bcc0205b70dc6d9216b29025450c9c5b08cb65d) )
r3333r3334
52045224   ROM_REGION( 0x20000, "fixedbios", 0 )
52055225   ROM_LOAD( "sfix.sfx",  0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
52065226
5207   /* The M1 ROM is encrypted, we load it here for reference and replace it with a decrypted version */
5208   ROM_REGION( 0x40000, "audiocrypt", 0 )
5209   ROM_LOAD( "265-262-m1.bin", 0x00000, 0x40000, CRC(a7f8119f) SHA1(71805b39b8b09c32425cf39f9de59b2f755976c2) ) /* yes it really does have a strange name */
5210   /* Decrypted */
5211   NEO_BIOS_AUDIO_256K( "265-262_decrypted-m1.bin", CRC(4bcc537b) SHA1(9fcf1342bcd53d5eec12c46ee41a51bf543256c2) )
5227   /* Encrypted */
5228   NEO_BIOS_AUDIO_ENCRYPTED_256K( "265-262-m1.bin", CRC(a7f8119f) SHA1(71805b39b8b09c32425cf39f9de59b2f755976c2) ) /* yes it really does have a strange name */
52125229
52135230   ROM_REGION( 0x1000000, "ym", 0 )
52145231   ROM_LOAD( "262-v1-08-e0.bin", 0x000000, 0x400000, CRC(83d49ecf) SHA1(2f2c116e45397652e77fcf5d951fa5f71b639572) )
r3333r3334
52435260   ROM_REGION( 0x20000, "fixedbios", 0 )
52445261   ROM_LOAD( "sfix.sfx",  0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
52455262
5246   /* The M1 ROM is encrypted, we load it here for reference and replace it with a decrypted version */
5247   ROM_REGION( 0x40000, "audiocrypt", 0 )
5248   ROM_LOAD( "265-262-m1.bin", 0x00000, 0x40000, CRC(a7f8119f) SHA1(71805b39b8b09c32425cf39f9de59b2f755976c2) ) /* yes it really does have a strange name */
5249   /* Decrypted */
5250   NEO_BIOS_AUDIO_256K( "265-262_decrypted-m1.bin", CRC(4bcc537b) SHA1(9fcf1342bcd53d5eec12c46ee41a51bf543256c2) )
5263   /* Encrypted */
5264   NEO_BIOS_AUDIO_ENCRYPTED_256K( "265-262-m1.bin", CRC(a7f8119f) SHA1(71805b39b8b09c32425cf39f9de59b2f755976c2) ) /* yes it really does have a strange name */
52515265
52525266   ROM_REGION( 0x1000000, "ym", 0 )
52535267   ROM_LOAD( "262-v1-08-e0.bin", 0x000000, 0x400000, CRC(83d49ecf) SHA1(2f2c116e45397652e77fcf5d951fa5f71b639572) )
r3333r3334
52825296   ROM_REGION( 0x20000, "fixedbios", 0 )
52835297   ROM_LOAD( "sfix.sfx",  0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
52845298
5285   /* The M1 ROM is encrypted, we load it here for reference and replace it with a decrypted version */
5286   ROM_REGION( 0x20000, "audiocrypt", 0 )
5287   ROM_LOAD( "263-m1.bin", 0x00000, 0x20000, CRC(46ac8228) SHA1(5aeea221050c98e4bb0f16489ce772bf1c80f787) )
5288   /* Decrypted */
5289   NEO_BIOS_AUDIO_128K( "263-m1_decrypted.bin", CRC(ef5db532) SHA1(4aeba9e206b8f309610eb7e1891644f39aa61830) )
5299   /* Encrypted */
5300   NEO_BIOS_AUDIO_ENCRYPTED_128K( "263-m1.bin", CRC(46ac8228) SHA1(5aeea221050c98e4bb0f16489ce772bf1c80f787) )
52905301
52915302   ROM_REGION( 0x1000000, "ym", 0 )
52925303   ROM_LOAD( "263-v1.bin", 0x000000, 0x800000, CRC(01e9b9cd) SHA1(0b045c2999449f7dab5ae8a42e957d5b6650431e) )
r3333r3334
53135324   NEO_SFIX_128K( "263-s1p.bin",  CRC(07ff87ce) SHA1(96ddb439de2a26bf9869015d7fb19129d40f3fd9) )
53145325
53155326   /* bootleg: non-encrypted m1 */
5316   NEO_BIOS_AUDIO_128K( "263-m1_decrypted.bin", CRC(ef5db532) SHA1(4aeba9e206b8f309610eb7e1891644f39aa61830) )
5327   NEO_BIOS_AUDIO_128K( "263-m1_bootleg.bin", CRC(ef5db532) SHA1(4aeba9e206b8f309610eb7e1891644f39aa61830) )
53175328
53185329   ROM_REGION( 0x1000000, "ym", 0 )
53195330   /* bootleg: non-encrypted samples */
r3333r3334
53445355   ROM_REGION( 0x20000, "fixedbios", 0 )
53455356   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
53465357
5347   ROM_REGION( 0x20000, "audiocrypt", 0 )
5348   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5349   ROM_LOAD( "264-m1.bin", 0x00000, 0x20000, CRC(4dbd7b43) SHA1(6b63756b0d2d30bbf13fbd219833c81fd060ef96) )
5350   /* Decrypted */
5351   NEO_BIOS_AUDIO_128K( "264-m1_decrypted.bin", CRC(c5d36af9) SHA1(320739d0cfa6cc84455ae1f7b1f9cdab3c018933) )
5358   /* Encrypted */
5359   NEO_BIOS_AUDIO_ENCRYPTED_128K( "264-m1.bin", CRC(4dbd7b43) SHA1(6b63756b0d2d30bbf13fbd219833c81fd060ef96) )
53525360
53535361   ROM_REGION( 0x1000000, "ym", 0 )
53545362   /* Encrypted */
r3333r3334
53825390   ROM_REGION( 0x20000, "fixedbios", 0 )
53835391   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
53845392
5385   ROM_REGION( 0x20000, "audiocrypt", 0 )
5386   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5387   ROM_LOAD( "265-m1.bin", 0x00000, 0x20000, CRC(85aaa632) SHA1(744fba4ca3bc3a5873838af886efb97a8a316104) )
5388   /* Decrypted */
5389   NEO_BIOS_AUDIO_128K( "265-m1_decrypted.bin", CRC(1c661a4b) SHA1(4e5aa862a0a182a806d538996ddc68d9f2dffaf7) )
5393   /* Encrypted */
5394   NEO_BIOS_AUDIO_ENCRYPTED_128K( "265-m1.bin", CRC(85aaa632) SHA1(744fba4ca3bc3a5873838af886efb97a8a316104) )
53905395
53915396   ROM_REGION( 0x1000000, "ym", 0 )
53925397   /* Encrypted */
r3333r3334
54145419
54155420   NEO_SFIX_128K( "265-s1p.bin", CRC(595e0006) SHA1(ff086bdaa6f40e9ad963e1100a27f44618d684ed) )
54165421
5417   ROM_REGION( 0x20000, "audiocrypt", 0 )
5418   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5419   ROM_LOAD( "265-m1.bin", 0x00000, 0x20000, CRC(85aaa632) SHA1(744fba4ca3bc3a5873838af886efb97a8a316104) )
5420   /* Decrypted */
5421   NEO_BIOS_AUDIO_128K( "265-m1_decrypted.bin", CRC(1c661a4b) SHA1(4e5aa862a0a182a806d538996ddc68d9f2dffaf7) )
5422   /* Correct To Use Decrypted? */
5423   NEO_BIOS_AUDIO_128K( "265-m1_bootleg.bin", CRC(1c661a4b) SHA1(4e5aa862a0a182a806d538996ddc68d9f2dffaf7) )
54225424
54235425   ROM_REGION( 0x1000000, "ym", 0 )
54245426   /* Encrypted */
r3333r3334
54465448
54475449   NEO_SFIX_128K( "265-s1pa.bin",  CRC(1a3ed064) SHA1(9749bb55c750e6b65d651998c2649c5fb68db68e))
54485450
5449   ROM_REGION( 0x20000, "audiocrypt", 0 )
5450   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5451   ROM_LOAD( "265-m1.bin", 0x00000, 0x20000, CRC(85aaa632) SHA1(744fba4ca3bc3a5873838af886efb97a8a316104) )
5452   /* Decrypted */
5453   NEO_BIOS_AUDIO_128K( "265-m1_decrypted.bin", CRC(1c661a4b) SHA1(4e5aa862a0a182a806d538996ddc68d9f2dffaf7) )
5451   /* Correct To Use Decrypted? */
5452   NEO_BIOS_AUDIO_128K( "265-m1_bootleg.bin", CRC(1c661a4b) SHA1(4e5aa862a0a182a806d538996ddc68d9f2dffaf7) )
54545453
54555454   ROM_REGION( 0x1000000, "ym", 0 )
54565455   /* Encrypted */
r3333r3334
54795478   NEO_SFIX_128K( "kf02m-s1.bin", CRC(348d6f2c) SHA1(586da8a936ebbb71af324339a4b60ec91dfa0990) )
54805479
54815480   /* Decrypted */
5482   NEO_BIOS_AUDIO_128K( "265-m1_decrypted.bin", CRC(1c661a4b) SHA1(4e5aa862a0a182a806d538996ddc68d9f2dffaf7) )
5481   NEO_BIOS_AUDIO_128K( "265-m1_bootleg.bin", CRC(1c661a4b) SHA1(4e5aa862a0a182a806d538996ddc68d9f2dffaf7) )
54835482
54845483   ROM_REGION( 0x1000000, "ym", 0 )
54855484   /* Encrypted */
r3333r3334
55065505   NEO_SFIX_128K( "k2k2m2s1.bin",  CRC(446e74c5) SHA1(efc2afb26578bad9eb21659c70eb0f827d6d1ef6) )
55075506
55085507   /* Decrypted */
5509   NEO_BIOS_AUDIO_128K( "265-m1_decrypted.bin", CRC(1c661a4b) SHA1(4e5aa862a0a182a806d538996ddc68d9f2dffaf7) )
5508   NEO_BIOS_AUDIO_128K( "265-m1_bootleg.bin", CRC(1c661a4b) SHA1(4e5aa862a0a182a806d538996ddc68d9f2dffaf7) )
55105509
55115510   ROM_REGION( 0x1000000, "ym", 0 )
55125511   /* Encrypted */
r3333r3334
55385537   ROM_REGION( 0x20000, "fixedbios", 0 )
55395538   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
55405539
5541   ROM_REGION( 0x20000, "audiocrypt", 0 )
5542   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5543   ROM_LOAD( "266-m1.bin", 0x00000, 0x20000, CRC(456c3e6c) SHA1(5a07d0186198a18d2dda1331093cf29b0b9b2984) )
5544   /* Decrypted */
5545   NEO_BIOS_AUDIO_128K( "266-m1_decrypted.bin", CRC(d2f3742d) SHA1(dd42f8a301f07e079fbc2bfd23e788baa03ca72d) )
5540   /* Encrypted */
5541   NEO_BIOS_AUDIO_ENCRYPTED_128K( "266-m1.bin", CRC(456c3e6c) SHA1(5a07d0186198a18d2dda1331093cf29b0b9b2984) )
55465542
55475543   ROM_REGION( 0x1000000, "ym", 0 )
55485544   /* Encrypted */
r3333r3334
55755571   ROM_REGION( 0x20000, "fixedbios", 0 )
55765572   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
55775573
5578   ROM_REGION( 0x80000, "audiocrypt", 0 )
5579   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5580   ROM_LOAD( "267-m1.bin", 0x00000, 0x80000, CRC(c7853ccd) SHA1(1b7a4c5093cf0fe3861ce44fd1d3b30c71ad0abe) )
5581   /* Decrypted */
5582   NEO_BIOS_AUDIO_512K( "267-m1_decrypted.bin", CRC(d58eaa8e) SHA1(4c4faf1da671a41b4d854790eb623a40cb35f256) )
5574   /* Encrypted */
5575   NEO_BIOS_AUDIO_ENCRYPTED_512K( "267-m1.bin", CRC(c7853ccd) SHA1(1b7a4c5093cf0fe3861ce44fd1d3b30c71ad0abe) )
55835576
55845577   ROM_REGION( 0x400000, "ym", 0 )
55855578   /* Encrypted */
r3333r3334
56065599   ROM_REGION( 0x20000, "fixedbios", 0 )
56075600   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
56085601
5609   ROM_REGION( 0x80000, "audiocrypt", 0 )
5610   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5611   ROM_LOAD( "268-m1.bin", 0x00000, 0x80000, CRC(4a5a6e0e) SHA1(df0f660f2465e1db7be5adfcaf5e88ad61a74a42) )
5612   /* Decrypted */
5613   NEO_BIOS_AUDIO_64K( "268-m1_decrypted.bin",  CRC(3c0655a7) SHA1(ae839d4c2b87a7aa3dd8e5caddc43eb75ee9b732) ) /* not a 100% match for encrypted version */
5602   /* Encrypted */
5603   NEO_BIOS_AUDIO_ENCRYPTED_512K( "268-m1.bin", CRC(4a5a6e0e) SHA1(df0f660f2465e1db7be5adfcaf5e88ad61a74a42) )
56145604
56155605   ROM_REGION( 0x1000000, "ym", 0 )
56165606   /* Encrypted */
r3333r3334
56445634   ROM_REGION( 0x20000, "fixedbios", 0 )
56455635   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
56465636
5647   ROM_REGION( 0x80000, "audiocrypt", 0 )
5648   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5649   ROM_LOAD( "268-m1h.bin", 0x00000, 0x80000, CRC(4a5a6e0e) SHA1(df0f660f2465e1db7be5adfcaf5e88ad61a74a42) ) /* Same as MVS above, but different label */
5650   /* Decrypted */
5651   NEO_BIOS_AUDIO_64K( "268-m1_decrypted.bin",  CRC(3c0655a7) SHA1(ae839d4c2b87a7aa3dd8e5caddc43eb75ee9b732) ) /* not a 100% match for encrypted version */
5637   /* Encrypted */
5638   NEO_BIOS_AUDIO_ENCRYPTED_512K( "268-m1h.bin", CRC(4a5a6e0e) SHA1(df0f660f2465e1db7be5adfcaf5e88ad61a74a42) ) /* Same as MVS above, but different label */
56525639
56535640   ROM_REGION( 0x1000000, "ym", 0 )
56545641   /* Encrypted */
r3333r3334
56855672   /* this contains both an ASIA and JAPAN bios, HARDDIP3 on the PCB selects which to use */
56865673   ROM_LOAD16_WORD_SWAP( "268-bios.bin", 0x00000, 0x80000, CRC(b4590283) SHA1(47047ed5b6062babc0a0bebcc30e4b3f021e115a) )
56875674
5688   ROM_REGION( 0x50000, "audio", 0 )
5689   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5690   ROM_LOAD( "268-m1.bin", 0x00000, 0x10000, CRC(58b107d0) SHA1(cc7fe66ff4f9c026cde4df06f86c848eb21f7af8) )
5691   /* Decrypted */
5692   ROM_LOAD( "268-m1_decrypted.bin", 0x00000, 0x10000, CRC(3c0655a7) SHA1(ae839d4c2b87a7aa3dd8e5caddc43eb75ee9b732) ) /* not a 100% match for encrypted version */
5693   ROM_RELOAD( 0x10000, 0x10000 )
56945675
5676   /* Encrypted */
5677   ROM_REGION( 0x80000, "audiocrypt", 0 )
5678   ROM_LOAD( "268-m1.bin", 0x00000, 0x80000, CRC(4a5a6e0e) SHA1(df0f660f2465e1db7be5adfcaf5e88ad61a74a42) )
5679   ROM_REGION( 0x90000, "audio", ROMREGION_ERASEFF )
5680
5681
5682   /* Encrypted */
5683
56955684   ROM_Y_ZOOM
56965685
56975686   ROM_REGION( 0x1000000, "ym", 0 )
r3333r3334
57215710   ROM_REGION( 0x20000, "fixedbios", 0 )
57225711   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
57235712
5724   ROM_REGION( 0x80000, "audiocrypt", 0 )
5725   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5726   ROM_LOAD( "268-m1.bin", 0x00000, 0x80000, CRC(4a5a6e0e) SHA1(df0f660f2465e1db7be5adfcaf5e88ad61a74a42) )
5727   /* Decrypted */
5728   NEO_BIOS_AUDIO_64K( "268-m1_decrypted.bin",  CRC(3c0655a7) SHA1(ae839d4c2b87a7aa3dd8e5caddc43eb75ee9b732) ) /* not a 100% match for encrypted version */
5713   /* Correct to use Decrypted Rom? */
5714   NEO_BIOS_AUDIO_64K( "268-m1_bootleg.bin",  CRC(3c0655a7) SHA1(ae839d4c2b87a7aa3dd8e5caddc43eb75ee9b732) ) /* not a 100% match for encrypted version */
57295715
57305716   ROM_REGION( 0x1000000, "ym", 0 )
57315717   /* Encrypted */
r3333r3334
57595745   /* this contains both an ASIA and JAPAN bios, HARDDIP3 on the PCB selects which to use */
57605746   ROM_LOAD16_WORD_SWAP( "sp-4x.sp1", 0x00000, 0x80000, CRC(b4590283) SHA1(47047ed5b6062babc0a0bebcc30e4b3f021e115a) )
57615747
5762   ROM_REGION( 0x90000, "audio", 0 )
5763   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5748   /* Encrypted */
5749   ROM_REGION( 0x80000, "audiocrypt", 0 )
57645750   ROM_LOAD( "269-m1.bin", 0x00000, 0x80000, CRC(f6819d00) SHA1(d3bbe09df502464f104e53501708ac6e2c1832c6) )
5765   /* Decrypted */
5766   ROM_LOAD( "269-m1_decrypted.bin", 0x00000, 0x80000, CRC(7b7bf462) SHA1(7466a6962de5242f71b9c52d7bd21a9832115e11) )
5767   ROM_RELOAD( 0x10000, 0x80000 )
5751   ROM_REGION( 0x90000, "audio", ROMREGION_ERASEFF )
57685752
57695753   ROM_Y_ZOOM
57705754
r3333r3334
57945778   /* this contains both an ASIA and JAPAN bios, HARDDIP3 on the PCB selects which to use */
57955779   ROM_LOAD16_WORD_SWAP( "sp-4x.sp1", 0x00000, 0x80000, CRC(b4590283) SHA1(47047ed5b6062babc0a0bebcc30e4b3f021e115a) )
57965780
5797   ROM_REGION( 0x90000, "audio", 0 )
5798   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5781   /* Encrypted */
5782   ROM_REGION( 0x80000, "audiocrypt", 0 )
57995783   ROM_LOAD( "269-m1.bin", 0x00000, 0x80000, CRC(f6819d00) SHA1(d3bbe09df502464f104e53501708ac6e2c1832c6) )
5800   /* Decrypted */
5801   ROM_LOAD( "269-m1_decrypted.bin", 0x00000, 0x80000, CRC(7b7bf462) SHA1(7466a6962de5242f71b9c52d7bd21a9832115e11) )
5802   ROM_RELOAD( 0x10000, 0x80000 )
5784   ROM_REGION( 0x90000, "audio", ROMREGION_ERASEFF )
58035785
58045786   ROM_Y_ZOOM
58055787
r3333r3334
58285810   ROM_REGION( 0x20000, "fixedbios", 0 )
58295811   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
58305812
5831   ROM_REGION( 0x80000, "audiocrypt", 0 )
5832   /* Encrypted, we load it here for reference and replace with decrypted ROM */
5833   ROM_LOAD( "269-m1.bin", 0x00000, 0x80000, CRC(f6819d00) SHA1(d3bbe09df502464f104e53501708ac6e2c1832c6) )
5834   /* Decrypted */
5835   NEO_BIOS_AUDIO_512K( "269-m1_decrypted.bin", CRC(7b7bf462) SHA1(7466a6962de5242f71b9c52d7bd21a9832115e11) )
5813   /* Encrypted */
5814   NEO_BIOS_AUDIO_ENCRYPTED_512K( "269-m1.bin", CRC(f6819d00) SHA1(d3bbe09df502464f104e53501708ac6e2c1832c6) )
58365815
58375816   ROM_REGION( 0x1000000, "ym", 0 )
58385817   /* Encrypted */
r3333r3334
60205999   ROM_REGION( 0x20000, "fixedbios", 0 )
60216000   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
60226001
6023   ROM_REGION( 0x80000, "audiocrypt", 0 )
6024   /* Encrypted, we load it here for reference and replace with decrypted ROM */
6025   ROM_LOAD( "270-m1.bin", 0x00000, 0x80000, CRC(49c9901a) SHA1(2623e9765a0eba58fee2de72851e9dc502344a3d) )
6026   /* Decrypted */
6027   NEO_BIOS_AUDIO_256K( "270-m1_decrypted.bin", CRC(e94a5e2b) SHA1(53ef2ad6583060af69fdde73576e09ba88affa55) ) /* not a 100% match for encrypted version */
6002   /* Encrypted */
6003   NEO_BIOS_AUDIO_ENCRYPTED_512K( "270-m1.bin", CRC(49c9901a) SHA1(2623e9765a0eba58fee2de72851e9dc502344a3d) )
60286004
60296005   ROM_REGION( 0x1000000, "ym", 0 )
60306006   /* Encrypted */
r3333r3334
60586034   ROM_REGION( 0x20000, "fixedbios", 0 )
60596035   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
60606036
6061   ROM_REGION( 0x80000, "audiocrypt", 0 )
6062   /* Encrypted, we load it here for reference and replace with decrypted ROM */
6063   ROM_LOAD( "270-m1.bin", 0x00000, 0x80000, CRC(49c9901a) SHA1(2623e9765a0eba58fee2de72851e9dc502344a3d) )
6064   /* Decrypted */
6065   NEO_BIOS_AUDIO_256K( "270-m1_decrypted.bin", CRC(e94a5e2b) SHA1(53ef2ad6583060af69fdde73576e09ba88affa55) ) /* not a 100% match for encrypted version */
6037   /* Encrypted */
6038   NEO_BIOS_AUDIO_ENCRYPTED_512K( "270-m1.bin", CRC(49c9901a) SHA1(2623e9765a0eba58fee2de72851e9dc502344a3d) )
60666039
60676040   ROM_REGION( 0x1000000, "ym", 0 )
60686041   /* Encrypted */
r3333r3334
60966069   ROM_REGION( 0x20000, "fixedbios", 0 )
60976070   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
60986071
6099   ROM_REGION( 0x80000, "audiocrypt", 0 )
6100   /* Encrypted, we load it here for reference and replace with decrypted ROM */
6101   ROM_LOAD( "270-m1.bin", 0x00000, 0x80000, CRC(49c9901a) SHA1(2623e9765a0eba58fee2de72851e9dc502344a3d) )
6102   /* Decrypted */
6103   NEO_BIOS_AUDIO_256K( "270-m1_decrypted.bin", CRC(e94a5e2b) SHA1(53ef2ad6583060af69fdde73576e09ba88affa55) ) /* not a 100% match for encrypted version */
6072   /* 0xf800 area doesn't match encrypted rom */
6073   NEO_BIOS_AUDIO_256K( "270-m1_bootleg.bin", CRC(e94a5e2b) SHA1(53ef2ad6583060af69fdde73576e09ba88affa55) ) /* not a 100% match for encrypted version */
61046074
6075   /* should this set use decrypted roms? */
6076
61056077   ROM_REGION( 0x1000000, "ym", 0 )
61066078   /* Encrypted */
61076079   ROM_LOAD( "270-v1.bin", 0x000000, 0x800000, CRC(62e434eb) SHA1(1985f5e88f8e866f9683b6cea901aa28c04b80bf) )
r3333r3334
61356107   ROM_REGION16_BE( 0x80000, "mainbios", 0 )
61366108   ROM_LOAD16_WORD_SWAP( "271-bios.bin", 0x00000, 0x080000, CRC(148dd727) SHA1(2cf592a16c7157de02a989675d47965f2b3a44dd) ) // encrypted
61376109
6138   ROM_REGION( 0x90000, "audio", 0 )
6139   /* Encrypted, we load it here for reference and replace with decrypted ROM */
6110   /* Encrypted */
6111   ROM_REGION( 0x80000, "audiocrypt", 0 )
61406112   ROM_LOAD( "271-m1.bin", 0x00000, 0x80000, CRC(d6bcf2bc) SHA1(df78bc95990eb8e8f3638dde6e1876354df7fe84) )
6141   /* Decrypted */
6142   ROM_LOAD( "271-m1_decrypted.bin", 0x00000, 0x80000, CRC(0e86af8f) SHA1(769102b67bb1a699cfa5674d66cdb46ae633cb65) )
6143   ROM_RELOAD( 0x10000, 0x80000 )
6113   ROM_REGION( 0x90000, "audio", ROMREGION_ERASEFF )
61446114
61456115   ROM_Y_ZOOM
61466116
r3333r3334
61746144   ROM_REGION( 0x20000, "fixedbios", 0 )
61756145   ROM_LOAD( "sfix.sfx",  0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
61766146
6177   ROM_REGION( 0x080000, "audiocrypt", 0 )
6178   /* The M1 ROM is encrypted, we load it here for reference and replace it with a decrypted version */
6179   ROM_LOAD( "271-m1c.bin", 0x00000, 0x080000, CRC(f5515629) SHA1(7516bf1b0207a3c8d41dc30c478f8d8b1f71304b) )
6180   /* Decrypted */
6181   NEO_BIOS_AUDIO_512K( "271-m1_decrypted.bin", CRC(0e86af8f) SHA1(769102b67bb1a699cfa5674d66cdb46ae633cb65) ) /* not a 100% match for encrypted version */
6147   /* Encrypted */
6148   NEO_BIOS_AUDIO_ENCRYPTED_512K( "271-m1c.bin", CRC(f5515629) SHA1(7516bf1b0207a3c8d41dc30c478f8d8b1f71304b) )
61826149
61836150   ROM_REGION( 0x1000000, "ym", 0 )
61846151   /* Encrypted */
r3333r3334
63296296   ROM_REGION( 0x20000, "fixedbios", 0 )
63306297   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
63316298
6332   ROM_REGION( 0x80000, "audiocrypt", 0 )
6333   /* Encrypted, we load it here for reference and replace with decrypted ROM */
6334   ROM_LOAD( "272-m1.bin", 0x00000, 0x80000, CRC(adeebf40) SHA1(8cbd63dda3fff4de38060405bf70cd9308c9e66e) )
6335   /* Decrypted */
6336   NEO_BIOS_AUDIO_512K( "272-m1_decrypted.bin", CRC(203d744e) SHA1(24fc73943009effa14eed0f7a29955f349ca8e8f) )
6299   NEO_BIOS_AUDIO_ENCRYPTED_512K( "272-m1.bin", CRC(adeebf40) SHA1(8cbd63dda3fff4de38060405bf70cd9308c9e66e) )
63376300
63386301   ROM_REGION( 0x1000000, "ym", 0 )
63396302   /* Encrypted */
r3333r3334
63676330   ROM_REGION( 0x20000, "fixedbios", 0 )
63686331   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
63696332
6370   ROM_REGION( 0x80000, "audiocrypt", 0 )
6371   /* Encrypted, we load it here for reference and replace with decrypted ROM */
6372   ROM_LOAD( "272-m1.bin", 0x00000, 0x80000, CRC(adeebf40) SHA1(8cbd63dda3fff4de38060405bf70cd9308c9e66e) )
6373   /* Decrypted */
6374   NEO_BIOS_AUDIO_512K( "272-m1_decrypted.bin", CRC(203d744e) SHA1(24fc73943009effa14eed0f7a29955f349ca8e8f) )
6333   /* Encrypted */
6334   NEO_BIOS_AUDIO_ENCRYPTED_512K( "272-m1.bin", CRC(adeebf40) SHA1(8cbd63dda3fff4de38060405bf70cd9308c9e66e) )
63756335
63766336   ROM_REGION( 0x1000000, "ym", 0 )
63776337   /* Encrypted */
r3333r3334
64056365   ROM_REGION( 0x20000, "fixedbios", 0 )
64066366   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
64076367
6408   ROM_REGION( 0x80000, "audiocrypt", 0 )
6409   /* Encrypted, we load it here for reference and replace with decrypted ROM */
6410   ROM_LOAD( "272-m1.bin", 0x00000, 0x80000, CRC(adeebf40) SHA1(8cbd63dda3fff4de38060405bf70cd9308c9e66e) )
6411   /* Decrypted */
6412   NEO_BIOS_AUDIO_512K( "272-m1_decrypted.bin", CRC(203d744e) SHA1(24fc73943009effa14eed0f7a29955f349ca8e8f) )
6368   /* Encrypted */
6369   NEO_BIOS_AUDIO_ENCRYPTED_512K( "272-m1.bin", CRC(adeebf40) SHA1(8cbd63dda3fff4de38060405bf70cd9308c9e66e) )
64136370
64146371   ROM_REGION( 0x1000000, "ym", 0 )
64156372   /* Encrypted */
r3333r3334
64436400   ROM_REGION( 0x20000, "fixedbios", 0 )
64446401   ROM_LOAD( "sfix.sfx", 0x000000, 0x20000, CRC(354029fc) SHA1(4ae4bf23b4c2acff875775d4cbff5583893ce2a1) )
64456402
6446   ROM_REGION( 0x80000, "audiocrypt", 0 )
6447    /* encrypted, we load it here for reference and replace with decrypted ROM */
6448   ROM_LOAD( "jgp-m1.bin", 0x00000, 0x80000, CRC(d163c690) SHA1(1dfd04d20c5985037f07cd01000d0b04f3a8f4f4) )
6449   /* Decrypted */
6450   NEO_BIOS_AUDIO_512K( "jgp-m1_decrypted.bin", CRC(1cab4de2) SHA1(112ff90806d8757db0685b88b762c45ed02548de) )
6403   /* Encrypted */
6404   NEO_BIOS_AUDIO_ENCRYPTED_512K( "jgp-m1.bin", CRC(d163c690) SHA1(1dfd04d20c5985037f07cd01000d0b04f3a8f4f4) )
64516405
64526406   ROM_REGION( 0x0200000, "ym", 0 )
64536407   ROM_LOAD( "jgp-v1.bin", 0x000000, 0x200000, CRC(443eadba) SHA1(3def3c22f0e276bc4c2fc7ff70ce473c08b0d2df) )
r3333r3334
67226676   ROM_LOAD16_WORD_SWAP( "5008-p2.rom", 0x100000, 0x400000, CRC(a649ec38) SHA1(5c63ed5e5c848940f587c966da4908d04cf1293c) )
67236677   ROM_LOAD16_WORD_SWAP( "5008-p3.rom", 0x500000, 0x200000, CRC(e629e13c) SHA1(6ebe080ce01c51064cb2f4d89315ba98a45ae727) )
67246678
6725   ROM_REGION( 0x200000, "audiocrypt", 0 )
6679   ROM_REGION( 0x200000, "audio", 0 )
67266680   ROM_LOAD( "5008-p1.rom", 0x000000, 0x200000, CRC(bf5469ba) SHA1(f05236d8fffab5836c0d27becdeeb80def32ee49) )
67276681
67286682   NEO_SFIX_128K( "5008-s1.rom", CRC(92410064) SHA1(1fb800b46341858207d3b6961a760289fbec7faa) )
67296683
6730   NEO_BIOS_AUDIO_128K( "5008-m1.rom", CRC(5a47d9ad) SHA1(0197737934653acc6c97221660d789e9914f3578) )
6684   //NEO_BIOS_AUDIO_128K( "5008-m1.rom", CRC(5a47d9ad) SHA1(0197737934653acc6c97221660d789e9914f3578) )
67316685   //NEO_BIOS_AUDIO_128K( "5004-m1.bin", CRC(f6fab859) SHA1(0184aa1394b9f9946d610278b53b846020dd88dc) )
67326686
67336687   ROM_REGION( 0x1000000, "ym", 0 )
r3333r3334
68946848{
68956849   kof2000_decrypt_68k(machine);
68966850   neogeo_fixed_layer_bank_type = 2;
6851   neogeo_cmc50_m1_decrypt(machine);
68976852   kof2000_neogeo_gfx_decrypt(machine, 0x00);
6853
68986854   DRIVER_INIT_CALL(neogeo);
68996855   kof2000_install_protection(machine);
69006856}
69016857
69026858static DRIVER_INIT( kof2001 )
69036859{
6860   neogeo_cmc50_m1_decrypt(machine);
69046861   kof2000_neogeo_gfx_decrypt(machine, 0x1e);
6862
69056863   DRIVER_INIT_CALL(neogeo);
69066864}
69076865
69086866static DRIVER_INIT( mslug4 )
69096867{
69106868   neogeo_fixed_layer_bank_type = 1; /* USA violent content screen is wrong -- not a bug, confirmed on real hardware! */
6869   neogeo_cmc50_m1_decrypt(machine);
69116870   kof2000_neogeo_gfx_decrypt(machine, 0x31);
69126871   DRIVER_INIT_CALL(neogeo);
69136872   neo_pcm2_snk_1999(machine, 8);
r3333r3334
69516910static DRIVER_INIT( kof2000n )
69526911{
69536912   neogeo_fixed_layer_bank_type = 2;
6913   neogeo_cmc50_m1_decrypt(machine);
69546914   kof2000_neogeo_gfx_decrypt(machine, 0x00);
6915
69556916   DRIVER_INIT_CALL(neogeo);
69566917}
69576918
r3333r3334
69946955{
69956956   neo_pcm2_snk_1999(machine, 16);
69966957   neogeo_fixed_layer_bank_type = 1;
6958   neogeo_cmc50_m1_decrypt(machine);
69976959   kof2000_neogeo_gfx_decrypt(machine, 0x3f);
69986960   DRIVER_INIT_CALL(neogeo);
69996961}
r3333r3334
70036965{
70046966   kof2002_decrypt_68k(machine);
70056967   neo_pcm2_swap(machine, 0);
6968   neogeo_cmc50_m1_decrypt(machine);
70066969   kof2000_neogeo_gfx_decrypt(machine, 0xec);
6970
6971
6972
6973
70076974   DRIVER_INIT_CALL(neogeo);
70086975}
70096976
r3333r3334
70387005   matrim_decrypt_68k(machine);
70397006   neo_pcm2_swap(machine, 1);
70407007   neogeo_fixed_layer_bank_type = 2;
7008   neogeo_cmc50_m1_decrypt(machine);
70417009   kof2000_neogeo_gfx_decrypt(machine, 0x6a);
7010
70427011   DRIVER_INIT_CALL(neogeo);
70437012}
70447013
r3333r3334
70467015{
70477016   neo_pcm2_snk_1999(machine, 4);
70487017   neogeo_fixed_layer_bank_type = 1;
7018   neogeo_cmc50_m1_decrypt(machine);
70497019   kof2000_neogeo_gfx_decrypt(machine, 0x2e);
7020
70507021   DRIVER_INIT_CALL(neogeo);
70517022}
70527023
r3333r3334
70557026   mslug5_decrypt_68k(machine);
70567027   neo_pcm2_swap(machine, 2);
70577028   neogeo_fixed_layer_bank_type = 1;
7029   neogeo_cmc50_m1_decrypt(machine);
70587030   kof2000_neogeo_gfx_decrypt(machine, 0x19);
7031
7032
70597033   DRIVER_INIT_CALL(neogeo);
70607034   install_pvc_protection(machine);
70617035}
r3333r3334
70647038{
70657039   mslug5_decrypt_68k(machine);
70667040   svcpcb_gfx_decrypt(machine);
7041   neogeo_cmc50_m1_decrypt(machine);
70677042   kof2000_neogeo_gfx_decrypt(machine, 0x19);
7043
70687044   neogeo_fixed_layer_bank_type = 2;
70697045   svcpcb_s1data_decrypt(machine);
70707046   neo_pcm2_swap(machine, 2);
r3333r3334
70987074
70997075   svcchaos_px_decrypt(machine);
71007076   svcpcb_gfx_decrypt(machine);
7077   neogeo_cmc50_m1_decrypt(machine);
71017078   kof2000_neogeo_gfx_decrypt(machine, 0x57);
7079
71027080   svcpcb_s1data_decrypt(machine);
71037081   neo_pcm2_swap(machine, 3);
71047082   neogeo_fixed_layer_bank_type = 2;
r3333r3334
71117089   svcchaos_px_decrypt(machine);
71127090   neo_pcm2_swap(machine, 3);
71137091   neogeo_fixed_layer_bank_type = 2;
7092   neogeo_cmc50_m1_decrypt(machine);
71147093   kof2000_neogeo_gfx_decrypt(machine, 0x57);
7094
7095
71157096   DRIVER_INIT_CALL(neogeo);
71167097   install_pvc_protection(machine);
71177098}
r3333r3334
71587139   samsho5_decrypt_68k(machine);
71597140   neo_pcm2_swap(machine, 4);
71607141   neogeo_fixed_layer_bank_type = 1;
7142   neogeo_cmc50_m1_decrypt(machine);
71617143   kof2000_neogeo_gfx_decrypt(machine, 0x0f);
7144
71627145   DRIVER_INIT_CALL(neogeo);
71637146}
71647147
r3333r3334
71757158{
71767159   kf2k3pcb_decrypt_68k(machine);
71777160   kf2k3pcb_gfx_decrypt(machine);
7161   kof2003biosdecode(machine);
7162
7163   neogeo_cmc50_m1_decrypt(machine);
7164
7165   /* extra little swap on the m1 - this must be performed AFTER the m1 decrypt
7166       or the m1 checksum (used to generate the key) for decrypting the m1 is
7167       incorrect */
7168   {
7169      int i;
7170      UINT8* rom = memory_region(machine, "audio");
7171      for (i=0;i<0x90000;i++)
7172      {
7173         rom[i] = BITSWAP8(rom[i], 5, 6, 1, 4, 3, 0, 7, 2);
7174      }
7175
7176   }
7177
71787178   kof2000_neogeo_gfx_decrypt(machine, 0x9d);
71797179   kf2k3pcb_decrypt_s1data(machine);
7180   kof2003biosdecode(machine);
7181   /* rom[i] = BITSWAP8(rom[i], 5, 6, 1, 4, 3, 0, 7, 2) -- extra encrypted m1 swap? not confirmed */
7180
71827181   neo_pcm2_swap(machine, 5);
71837182   neogeo_fixed_layer_bank_type = 2;
71847183   DRIVER_INIT_CALL(neogeo);
r3333r3334
71927191   kof2003_decrypt_68k(machine);
71937192   neo_pcm2_swap(machine, 5);
71947193   neogeo_fixed_layer_bank_type = 2;
7194   neogeo_cmc50_m1_decrypt(machine);
71957195   kof2000_neogeo_gfx_decrypt(machine, 0x9d);
7196
71967197   DRIVER_INIT_CALL(neogeo);
71977198   install_pvc_protection(machine);
71987199}
r3333r3334
72317232   samsh5p_decrypt_68k(machine);
72327233   neo_pcm2_swap(machine, 6);
72337234   neogeo_fixed_layer_bank_type = 1;
7235   neogeo_cmc50_m1_decrypt(machine);
72347236   kof2000_neogeo_gfx_decrypt(machine, 0x0d);
7237
7238
72357239   DRIVER_INIT_CALL(neogeo);
72367240}
72377241
r3333r3334
72417245   UINT16* extra_ram;
72427246
72437247   neogeo_fixed_layer_bank_type = 1;
7248   neogeo_cmc50_m1_decrypt(machine);
72447249   kof2000_neogeo_gfx_decrypt(machine, 0xac);
72457250
72467251   /* install some extra RAM */
src/mame/drivers/peplus.c
r3333r3334
779779
780780static CUSTOM_INPUT( peplus_input_r )
781781{
782    UINT8 inp_ret = 0x00;
783    UINT8 inp_read = input_port_read(field->port->machine, param);
782   UINT8 inp_ret = 0x00;
783   UINT8 inp_read = input_port_read(field->port->machine, param);
784784
785    if (inp_read & 0x01) inp_ret = 0x01;
786    if (inp_read & 0x02) inp_ret = 0x02;
787    if (inp_read & 0x04) inp_ret = 0x03;
788    if (inp_read & 0x08) inp_ret = 0x04;
789    if (inp_read & 0x10) inp_ret = 0x05;
790    if (inp_read & 0x20) inp_ret = 0x06;
791    if (inp_read & 0x40) inp_ret = 0x07;
785   if (inp_read & 0x01) inp_ret = 0x01;
786   if (inp_read & 0x02) inp_ret = 0x02;
787   if (inp_read & 0x04) inp_ret = 0x03;
788   if (inp_read & 0x08) inp_ret = 0x04;
789   if (inp_read & 0x10) inp_ret = 0x05;
790   if (inp_read & 0x20) inp_ret = 0x06;
791   if (inp_read & 0x40) inp_ret = 0x07;
792792
793    return inp_ret;
793   return inp_ret;
794794}
795795
796796static INPUT_PORTS_START( peplus )
r3333r3334
801801   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Lower Door") PORT_CODE(KEYCODE_I)
802802
803803   PORT_START("SENSOR")
804   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1) PORT_NAME("Coin In") PORT_IMPULSE(1)
804   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_NAME("Coin In") PORT_IMPULSE(1)
805805
806806   PORT_START("SW1")
807807   PORT_DIPNAME( 0x01, 0x01, "Line Frequency" )
r3333r3334
819819static INPUT_PORTS_START( peplus_schip )
820820   PORT_INCLUDE(peplus)
821821   PORT_START("IN_BANK1")
822   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1  ) PORT_NAME("Jackpot Reset") PORT_CODE(KEYCODE_L)
823   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2  ) PORT_NAME("Self Test") PORT_CODE(KEYCODE_K)
824    PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
825    PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
826   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
827   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
828    PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
822   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Jackpot Reset") PORT_CODE(KEYCODE_L)
823   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Self Test") PORT_CODE(KEYCODE_K)
824   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
825   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
826   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
827   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
828   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
829829
830    PORT_START("IN_BANK2")
831   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9  ) PORT_NAME("Deal-Spin-Start") PORT_CODE(KEYCODE_Q)
832   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
833   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
834   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
835   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
836   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
837    PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
830   PORT_START("IN_BANK2")
831   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_NAME("Deal-Spin-Start") PORT_CODE(KEYCODE_Q)
832   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
833   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
834   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
835   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
836   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
837   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
838838
839    PORT_START("IN0")
840    PORT_BIT( 0x07, IP_ACTIVE_LOW,  IPT_SPECIAL  ) PORT_CUSTOM(peplus_input_r, "IN_BANK1")
841    PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
842    PORT_BIT( 0x70, IP_ACTIVE_LOW,  IPT_SPECIAL  ) PORT_CUSTOM(peplus_input_r, "IN_BANK2")
843   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
839   PORT_START("IN0")
840   PORT_BIT( 0x07, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(peplus_input_r, "IN_BANK1")
841   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
842   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(peplus_input_r, "IN_BANK2")
843   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
844844INPUT_PORTS_END
845845
846846static INPUT_PORTS_START( peplus_poker )
847847   PORT_INCLUDE(peplus)
848848
849849   PORT_START("IN_BANK1")
850   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1  ) PORT_NAME("Jackpot Reset") PORT_CODE(KEYCODE_L)
851   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2  ) PORT_NAME("Self Test") PORT_CODE(KEYCODE_K)
852    PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3  ) PORT_NAME("Hold 1") PORT_CODE(KEYCODE_Z)
853    PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4  ) PORT_NAME("Hold 2") PORT_CODE(KEYCODE_X)
854   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON5  ) PORT_NAME("Hold 3") PORT_CODE(KEYCODE_C)
855   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6  ) PORT_NAME("Hold 4") PORT_CODE(KEYCODE_V)
856    PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON7  ) PORT_NAME("Hold 5") PORT_CODE(KEYCODE_B)
850   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Jackpot Reset") PORT_CODE(KEYCODE_L)
851   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Self Test") PORT_CODE(KEYCODE_K)
852   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Hold 1") PORT_CODE(KEYCODE_Z)
853   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Hold 2") PORT_CODE(KEYCODE_X)
854   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("Hold 3") PORT_CODE(KEYCODE_C)
855   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("Hold 4") PORT_CODE(KEYCODE_V)
856   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_NAME("Hold 5") PORT_CODE(KEYCODE_B)
857857
858    PORT_START("IN_BANK2")
859   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9  ) PORT_NAME("Deal-Spin-Start") PORT_CODE(KEYCODE_Q)
858   PORT_START("IN_BANK2")
859   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_NAME("Deal-Spin-Start") PORT_CODE(KEYCODE_Q)
860860   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON10 ) PORT_NAME("Max Bet") PORT_CODE(KEYCODE_W)
861   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
861   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
862862   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON12 ) PORT_NAME("Play Credit") PORT_CODE(KEYCODE_R)
863863   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON13 ) PORT_NAME("Cashout") PORT_CODE(KEYCODE_T)
864864   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON14 ) PORT_NAME("Change Request") PORT_CODE(KEYCODE_Y)
865    PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON15 ) PORT_NAME("Bill Acceptor") PORT_CODE(KEYCODE_U)
865   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON15 ) PORT_NAME("Bill Acceptor") PORT_CODE(KEYCODE_U)
866866
867    PORT_START("IN0")
868    PORT_BIT( 0x07, IP_ACTIVE_LOW,  IPT_SPECIAL  ) PORT_CUSTOM(peplus_input_r, "IN_BANK1")
869    PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
870    PORT_BIT( 0x70, IP_ACTIVE_LOW,  IPT_SPECIAL  ) PORT_CUSTOM(peplus_input_r, "IN_BANK2")
871   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
867   PORT_START("IN0")
868   PORT_BIT( 0x07, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(peplus_input_r, "IN_BANK1")
869   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
870   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(peplus_input_r, "IN_BANK2")
871   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
872872INPUT_PORTS_END
873873
874874static INPUT_PORTS_START( peplus_bjack )
875875   PORT_INCLUDE(peplus)
876876
877877   PORT_START("IN_BANK1")
878   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1  ) PORT_NAME("Jackpot Reset") PORT_CODE(KEYCODE_L)
879   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2  ) PORT_NAME("Self Test") PORT_CODE(KEYCODE_K)
880    PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3  ) PORT_NAME("Surrender") PORT_CODE(KEYCODE_Z)
881    PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4  ) PORT_NAME("Stand") PORT_CODE(KEYCODE_X)
882   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON5  ) PORT_NAME("Insurance") PORT_CODE(KEYCODE_C)
883   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6  ) PORT_NAME("Double Down") PORT_CODE(KEYCODE_V)
884    PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON7  ) PORT_NAME("Split") PORT_CODE(KEYCODE_B)
878   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Jackpot Reset") PORT_CODE(KEYCODE_L)
879   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Self Test") PORT_CODE(KEYCODE_K)
880   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Surrender") PORT_CODE(KEYCODE_Z)
881   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Stand") PORT_CODE(KEYCODE_X)
882   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("Insurance") PORT_CODE(KEYCODE_C)
883   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("Double Down") PORT_CODE(KEYCODE_V)
884   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_NAME("Split") PORT_CODE(KEYCODE_B)
885885
886    PORT_START("IN_BANK2")
887   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9  ) PORT_NAME("Deal-Spin-Start") PORT_CODE(KEYCODE_Q)
886   PORT_START("IN_BANK2")
887   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_NAME("Deal-Spin-Start") PORT_CODE(KEYCODE_Q)
888888   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON10 ) PORT_NAME("Max Bet") PORT_CODE(KEYCODE_W)
889   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
889   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
890890   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON12 ) PORT_NAME("Play Credit") PORT_CODE(KEYCODE_R)
891891   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON13 ) PORT_NAME("Cashout") PORT_CODE(KEYCODE_T)
892892   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON14 ) PORT_NAME("Change Request") PORT_CODE(KEYCODE_Y)
893    PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON15 ) PORT_NAME("Bill Acceptor") PORT_CODE(KEYCODE_U)
893   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON15 ) PORT_NAME("Bill Acceptor") PORT_CODE(KEYCODE_U)
894894
895    PORT_START("IN0")
896    PORT_BIT( 0x07, IP_ACTIVE_LOW,  IPT_SPECIAL  ) PORT_CUSTOM(peplus_input_r, "IN_BANK1")
897    PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
898    PORT_BIT( 0x70, IP_ACTIVE_LOW,  IPT_SPECIAL  ) PORT_CUSTOM(peplus_input_r, "IN_BANK2")
899   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
895   PORT_START("IN0")
896   PORT_BIT( 0x07, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(peplus_input_r, "IN_BANK1")
897   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
898   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(peplus_input_r, "IN_BANK2")
899   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
900900INPUT_PORTS_END
901901
902902static INPUT_PORTS_START( peplus_keno )
903903   PORT_INCLUDE(peplus)
904904
905    PORT_START("IN_BANK1")
906   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1  ) PORT_NAME("Jackpot Reset") PORT_CODE(KEYCODE_L)
907   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2  ) PORT_NAME("Self Test") PORT_CODE(KEYCODE_K)
908    PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
909    PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
910   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
911   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
912    PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON7  ) PORT_NAME("Erase") PORT_CODE(KEYCODE_B)
905   PORT_START("IN_BANK1")
906   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Jackpot Reset") PORT_CODE(KEYCODE_L)
907   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Self Test") PORT_CODE(KEYCODE_K)
908   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
909   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
910   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
911   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
912   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_NAME("Erase") PORT_CODE(KEYCODE_B)
913913
914    PORT_START("IN_BANK2")
915   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9  ) PORT_NAME("Deal-Spin-Start") PORT_CODE(KEYCODE_Q)
914   PORT_START("IN_BANK2")
915   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_NAME("Deal-Spin-Start") PORT_CODE(KEYCODE_Q)
916916   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON10 ) PORT_NAME("Max Bet") PORT_CODE(KEYCODE_W)
917   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
917   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
918918   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON12 ) PORT_NAME("Play Credit") PORT_CODE(KEYCODE_R)
919919   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON13 ) PORT_NAME("Cashout") PORT_CODE(KEYCODE_T)
920920   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON14 ) PORT_NAME("Change Request") PORT_CODE(KEYCODE_Y)
921    PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON15 ) PORT_NAME("Bill Acceptor") PORT_CODE(KEYCODE_U)
921   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON15 ) PORT_NAME("Bill Acceptor") PORT_CODE(KEYCODE_U)
922922
923    PORT_START("TOUCH_X")
924    PORT_BIT( 0xff, 0x08, IPT_LIGHTGUN_X ) PORT_MINMAX(0x00, 0x28) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(13)
925    PORT_START("TOUCH_Y")
923   PORT_START("TOUCH_X")
924   PORT_BIT( 0xff, 0x08, IPT_LIGHTGUN_X ) PORT_MINMAX(0x00, 0x28) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(13)
925   PORT_START("TOUCH_Y")
926926   PORT_BIT( 0xff, 0x08, IPT_LIGHTGUN_Y ) PORT_MINMAX(0x00, 0x19) PORT_CROSSHAIR(Y, -1.0, 0.0, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(13)
927927
928    PORT_START("IN0")
929    PORT_BIT( 0x07, IP_ACTIVE_LOW,  IPT_SPECIAL  ) PORT_CUSTOM(peplus_input_r, "IN_BANK1")
930    PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN  ) PORT_NAME("Light Pen") PORT_CODE(KEYCODE_A)
931    PORT_BIT( 0x70, IP_ACTIVE_LOW,  IPT_SPECIAL  ) PORT_CUSTOM(peplus_input_r, "IN_BANK2")
932   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
928   PORT_START("IN0")
929   PORT_BIT( 0x07, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(peplus_input_r, "IN_BANK1")
930   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Light Pen") PORT_CODE(KEYCODE_A)
931   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(peplus_input_r, "IN_BANK2")
932   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
933933INPUT_PORTS_END
934934
935935static INPUT_PORTS_START( peplus_slots )
936936   PORT_INCLUDE(peplus)
937937
938938   PORT_START("IN_BANK1")
939   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1  ) PORT_NAME("Jackpot Reset") PORT_CODE(KEYCODE_L)
940   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2  ) PORT_NAME("Self Test") PORT_CODE(KEYCODE_K)
941    PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
942    PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
943   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
944   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
945    PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN  )
939   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Jackpot Reset") PORT_CODE(KEYCODE_L)
940   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Self Test") PORT_CODE(KEYCODE_K)
941   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
942   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
943   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
944   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
945   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
946946
947    PORT_START("IN_BANK2")
948   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9  ) PORT_NAME("Deal-Spin-Start") PORT_CODE(KEYCODE_Q)
947   PORT_START("IN_BANK2")
948   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_NAME("Deal-Spin-Start") PORT_CODE(KEYCODE_Q)
949949   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON10 ) PORT_NAME("Max Bet") PORT_CODE(KEYCODE_W)
950   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
950   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
951951   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON12 ) PORT_NAME("Play Credit") PORT_CODE(KEYCODE_R)
952952   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON13 ) PORT_NAME("Cashout") PORT_CODE(KEYCODE_T)
953953   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON14 ) PORT_NAME("Change Request") PORT_CODE(KEYCODE_Y)
954    PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON15 ) PORT_NAME("Bill Acceptor") PORT_CODE(KEYCODE_U)
954   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON15 ) PORT_NAME("Bill Acceptor") PORT_CODE(KEYCODE_U)
955955
956    PORT_START("IN0")
957    PORT_BIT( 0x07, IP_ACTIVE_LOW,  IPT_SPECIAL  ) PORT_CUSTOM(peplus_input_r, "IN_BANK1")
958    PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
959    PORT_BIT( 0x70, IP_ACTIVE_LOW,  IPT_SPECIAL  ) PORT_CUSTOM(peplus_input_r, "IN_BANK2")
960   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
956   PORT_START("IN0")
957   PORT_BIT( 0x07, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(peplus_input_r, "IN_BANK1")
958   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
959   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(peplus_input_r, "IN_BANK2")
960   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
961961INPUT_PORTS_END
962962
963963/* same as peplus_poker with additionnal fake option to enable the "Autohold" feature */
src/mame/drivers/namcoic.c
r3333r3334
693693/* nth_byte32 is a general-purpose utility function, which allows us to
694694 * read from 32-bit aligned memory as if it were an array of bytes.
695695 */
696#ifdef UNUSED_FUNCTON
696#ifdef UNUSED_FUNCTION
697697INLINE UINT8
698698nth_byte32( const UINT32 *pSource, int which )
699699{
src/mame/drivers/quizpun2.c
r3333r3334
7575   tilemap_mark_tile_dirty(fg_tmap, offset/4);
7676}
7777
78VIDEO_START(quizpun2)
78static VIDEO_START(quizpun2)
7979{
8080   bg_tmap = tilemap_create(   get_bg_tile_info, tilemap_scan_rows,   8,16, 0x20,0x20   );
8181   fg_tmap = tilemap_create(   get_fg_tile_info, tilemap_scan_rows,   8,16, 0x20,0x20   );
r3333r3334
8484   tilemap_set_transparent_pen(fg_tmap, 0);
8585}
8686
87VIDEO_UPDATE(quizpun2)
87static VIDEO_UPDATE(quizpun2)
8888{
8989   int layers_ctrl = -1;
9090
r3333r3334
335335                                Input Ports
336336***************************************************************************/
337337
338INPUT_PORTS_START( quizpun2 )
338static INPUT_PORTS_START( quizpun2 )
339339   PORT_START("DSW")
340340   PORT_SERVICE( 0x01, IP_ACTIVE_LOW )
341341   PORT_DIPUNKNOWN( 0x02, 0x02 )
src/mame/drivers/gamecstl.c
r3333r3334
3636
3737    0x05 0xFF 0xFF 0xFF 0xFF 0x02
3838
39    CPUID info:
40    Original set:
41
42    CPUID Level:       EAX:           EBX:           ECX:           EDX:
43    00000000       00000003       756E6547       6C65746E       49656E69
44    00000001       0000068A       00000002       00000000       0387F9FF
45    00000002       03020101       00000000       00000000       0C040882
46    00000003       00000000       00000000       CA976D2E       000082F6
47    80000000       00000000       00000000       CA976D2E       000082F6
48    C0000000       00000000       00000000       CA976D2E       000082F6
49
50
51    Version 2:
52    CPUID Level:       EAX:           EBX:           ECX:           EDX:
53    00000000       00000003       756E6547       6C65746E       49656E69
54    00000001       0000068A       00000002       00000000       0387F9FF
55    00000002       03020101       00000000       00000000       0C040882
56    00000003       00000000       00000000       B8BA1941       00038881
57    80000000       00000000       00000000       B8BA1941       00038881
58    C0000000       00000000       00000000       B8BA1941       00038881
59
3960*/
4061
4162#include "driver.h"
r3333r3334
735756// not the correct BIOS, f205v owes me a dump of it...
736757ROM_START(gamecstl)
737758   ROM_REGION32_LE(0x40000, "user1", 0)
738   ROM_LOAD("p5tx-la.bin", 0x00000, 0x40000, BAD_DUMP CRC(072e6d51) SHA1(70414349b37e478fc28ecbaba47ad1033ae583b7))
759   ROM_LOAD( "bios.bin",     0x000000, 0x040000, CRC(27834ce9) SHA1(134c546dd75138c6f4bc5729b40e20e118454df9) )
739760
740761   ROM_REGION(0x08100, "gfx1", 0)
741762   ROM_LOAD("cga.chr",     0x00000, 0x01000, CRC(42009069) SHA1(ed08559ce2d7f97f68b9f540bddad5b6295294dd))
r3333r3334
744765   DISK_IMAGE( "gamecstl", 0, MD5(501ddbebb530b8fd67eb64a4a2de3e35) SHA1(2477468ef1c1d4529057064a319ebfe9fd8facd7) )
745766ROM_END
746767
768ROM_START(gamecst2)
769   ROM_REGION32_LE(0x40000, "user1", 0)
770   ROM_LOAD( "bios.bin",     0x000000, 0x040000, CRC(27834ce9) SHA1(134c546dd75138c6f4bc5729b40e20e118454df9) )
771
772   ROM_REGION(0x08100, "gfx1", 0)
773   ROM_LOAD("cga.chr",     0x00000, 0x01000, CRC(42009069) SHA1(ed08559ce2d7f97f68b9f540bddad5b6295294dd))
774
775   DISK_REGION( "ide" )
776   DISK_IMAGE( "gamecst2", 0, MD5(ef880a411521e0c6e10f715ad9dd796e) SHA1(8243d7d2eacedf358334821c9401c1b945524a69) )
777ROM_END
778
747779/*****************************************************************************/
748780
749781GAME(2002, gamecstl, 0,   gamecstl, gamecstl, gamecstl,   ROT0,   "Cristaltec",  "GameCristal", GAME_NOT_WORKING | GAME_NO_SOUND)
782GAME(2002, gamecst2, gamecstl, gamecstl, gamecstl, gamecstl, ROT0, "Cristaltec", "GameCristal (version 2.613)", GAME_NOT_WORKING | GAME_NO_SOUND)
750783
src/mame/drivers/guab.c
r3333r3334
3535#define FDC_LOG(x) do { if (LOG_FDC_COMMANDS) mame_printf_debug x; } while(0)
3636
3737
38enum
38enum int_levels
3939{
4040   INT_UNKNOWN1     = 1,
4141   INT_UNKNOWN2     = 2,
r3333r3334
4444   INT_TMS34061     = 5,
4545   INT_FLOPPYCTRL   = 6,
4646   INT_WATCHDOG_INT = 7,
47} int_levels;
47};
4848
4949
5050/*************************************
r3333r3334
272272#define DISK_TRACK_SIZE      (DISK_SECTOR_SIZE * DISK_SECTORS)
273273#define DISK_SIDE_SIZE      (DISK_TRACK_SIZE * DISK_TRACKS)
274274
275enum
275enum wd1770_status
276276{
277277   BUSY          = 1 << 0,
278278   DATA_REQUEST    = 1 << 1,
r3333r3334
285285   SPIN_UP          = 1 << 5,
286286   WRITE_PROTECT    = 1 << 6,
287287   MOTOR_ON       = 1 << 7
288} wd1770_status;
288};
289289
290290
291291static TIMER_CALLBACK( fdc_data_callback )
src/mame/drivers/srmp6.c
r3333r3334
546546static ADDRESS_MAP_START( srmp6, ADDRESS_SPACE_PROGRAM, 16 )
547547   AM_RANGE(0x000000, 0x0fffff) AM_ROM
548548   AM_RANGE(0x200000, 0x23ffff) AM_RAM               // work RAM
549   AM_RANGE(0x600000, 0x7fffff) AM_READ(SMH_BANK1)   // banked ROM (used by ROM check)
550   AM_RANGE(0x800000, 0x9fffff) AM_ROM AM_REGION("nile", 0)
549   AM_RANGE(0x600000, 0x7fffff) AM_READ(SMH_BANK1)      // banked ROM (used by ROM check)
550   AM_RANGE(0x800000, 0x9fffff) AM_ROM AM_REGION("user1", 0)
551551
552552   AM_RANGE(0x300000, 0x300005) AM_READWRITE(srmp6_inputs_r, srmp6_input_select_w)      // inputs
553553   AM_RANGE(0x480000, 0x480fff) AM_RAM_WRITE(paletteram_w) AM_BASE(&paletteram16)
src/mame/drivers/cubeqst.c
r3333r3334
3737
3838#define ALPHA_PEN         8192
3939
40enum
40enum cpu_indices
4141{
4242   MAIN_CPU   = 0,
4343   ROTATE_CPU = 1,
4444   LINE_CPU   = 2,
4545   SOUND_CPU  = 3,
46} cpu_indices;
46};
4747
4848
4949/*************************************
r3333r3334
469469} cquest_sound;
470470
471471/* Called by the sound CPU emulation */
472void sound_dac_w(UINT16 data)
472static void sound_dac_w(UINT16 data)
473473{
474474   int side = data & 1;
475475   int chan = (data >> 1) & 7;
r3333r3334
504504   }
505505}
506506
507void *cquest_sh_start(int clock, const custom_sound_interface *config)
507static void *cquest_sh_start(int clock, const custom_sound_interface *config)
508508{
509509   /* Allocate the stream */
510510   cquest_stream = stream_create(0, 2, Machine->sample_rate, NULL, cquest_stream_update);
src/tools/chdcd.c
r3333r3334
119119   return f;
120120}
121121
122chd_error chdcd_parse_gdi(const char *tocfname, cdrom_toc *outtoc, chdcd_track_input_info *outinfo)
122static chd_error chdcd_parse_gdi(const char *tocfname, cdrom_toc *outtoc, chdcd_track_input_info *outinfo)
123123{
124124   FILE *infile;
125125   int i, numtracks;
src/osd/windows/debugwin.c
r3333r3334
309309//  debugwin_seq_pressed
310310//============================================================
311311
312int debugwin_seq_pressed(void)
312static int debugwin_seq_pressed(void)
313313{
314314   const input_seq *seq = input_type_seq(Machine, IPT_UI_DEBUG_BREAK, 0, SEQ_TYPE_STANDARD);
315315   int result = FALSE;
r3333r3334
485485void debugwin_update_during_game(running_machine *machine)
486486{
487487   // if we're running live, do some checks
488   if (!winwindow_has_focus() && !debug_cpu_is_stopped(machine) && mame_get_phase(Machine) == MAME_PHASE_RUNNING)
488   if (!winwindow_has_focus() && !debug_cpu_is_stopped(machine) && mame_get_phase(machine) == MAME_PHASE_RUNNING)
489489   {
490490      // see if the interrupt key is pressed and break if it is
491491      if (debugwin_seq_pressed())
r3333r3334
493493         HWND focuswnd = GetFocus();
494494         debugwin_info *info;
495495
496         debug_cpu_halt_on_next_instruction(Machine, "User-initiated break\n");
496         debug_cpu_halt_on_next_instruction(machine, -1, "User-initiated break\n");
497497
498498         // if we were focused on some window's edit box, reset it to default
499499         for (info = window_list; info; info = info->next)
src/emu/debug/debugcpu.c
r3333r3334
5555   debug_cpu_info   cpuinfo[MAX_CPU];
5656   debug_cpu_info *livecpu;
5757   debug_cpu_info *visiblecpu;
58   debug_cpu_info *breakcpu;
5859
5960   UINT8         within_instruction_hook;
6061   UINT8         vblank_occurred;
r3333r3334
424425   /* update the target execution end time */
425426   info->endexectime = endtime;
426427
427   /* if a VBLANK occurred, check on things */
428   if (global.vblank_occurred && global.execution_state != EXECUTION_STATE_STOPPED)
428   /* if we're running, do some periodic updating */
429   if (global.execution_state != EXECUTION_STATE_STOPPED)
429430   {
430      global.vblank_occurred = FALSE;
431
432      /* if we were waiting for a VBLANK, signal it now */
433      if ((info->flags & DEBUG_FLAG_STOP_VBLANK) != 0)
431      /* check for periodic updates */
432      if (info == global.visiblecpu && osd_ticks() > global.last_periodic_update_time + osd_ticks_per_second()/4)
434433      {
435         global.execution_state = EXECUTION_STATE_STOPPED;
436         debug_console_printf("Stopped at VBLANK\n");
434         debug_view_update_all();
435         global.last_periodic_update_time = osd_ticks();
437436      }
438437
439      /* check for debug keypresses */
440      else if (ui_input_pressed(machine, IPT_UI_DEBUG_BREAK))
438      /* check for pending breaks */
439      else if (info == global.breakcpu)
441440      {
442441         global.execution_state = EXECUTION_STATE_STOPPED;
443         debug_console_printf("User-initiated break\n");
442         global.breakcpu = NULL;
444443      }
445444
446      /* while we're here, check for a periodic update */
447      else if (info == global.visiblecpu && osd_ticks() > global.last_periodic_update_time + osd_ticks_per_second()/4)
445      /* if a VBLANK occurred, check on things */
446      if (global.vblank_occurred)
448447      {
449         debug_view_update_all();
450         global.last_periodic_update_time = osd_ticks();
448         global.vblank_occurred = FALSE;
449
450         /* if we were waiting for a VBLANK, signal it now */
451         if ((info->flags & DEBUG_FLAG_STOP_VBLANK) != 0)
452         {
453            global.execution_state = EXECUTION_STATE_STOPPED;
454            debug_console_printf("Stopped at VBLANK\n");
455         }
456
457         /* check for debug keypresses */
458         else if (ui_input_pressed(machine, IPT_UI_DEBUG_BREAK))
459            debug_cpu_halt_on_next_instruction(machine, -1, "User-initiated break\n");
451460      }
452461   }
453462
r3333r3334
593602
594603      /* reset any transient state */
595604      reset_transient_flags(machine);
605      global.breakcpu = NULL;
596606
597607      /* update all views */
598608      debug_view_update_all();
r3333r3334
798808    specified exception fires
799809-------------------------------------------------*/
800810
811#ifdef UNUSED_FUNCTION
801812void debug_cpu_go_exception(int exception)
802813{
803814   debug_cpu_info *info = global.livecpu;
r3333r3334
810821   info->flags |= DEBUG_FLAG_STOP_EXCEPTION;
811822   global.execution_state = EXECUTION_STATE_RUNNING;
812823}
824#endif
813825
814826
815827/*-------------------------------------------------
r3333r3334
928940    the debugger on the next instruction
929941-------------------------------------------------*/
930942
931void debug_cpu_halt_on_next_instruction(running_machine *machine, const char *fmt, ...)
943void debug_cpu_halt_on_next_instruction(running_machine *machine, int cpunum, const char *fmt, ...)
932944{
945   debug_cpu_info *info;
933946   va_list arg;
934947
948   /* pick the best CPU to land on */
949   if (cpunum != -1)
950      info = &global.cpuinfo[cpunum];
951   else if (global.visiblecpu != NULL)
952      info = global.visiblecpu;
953   else
954      info = global.livecpu;
955
956   /* if something is pending on this CPU already, ignore this request */
957   if (info != NULL && info == global.breakcpu)
958      return;
959
935960   va_start(arg, fmt);
936961   debug_console_vprintf(fmt, arg);
937962   va_end(arg);
938963
939   global.execution_state = EXECUTION_STATE_STOPPED;
940   if (global.livecpu != NULL)
941      compute_debug_flags(machine, global.livecpu);
964   if (info == global.livecpu)
965   {
966      global.execution_state = EXECUTION_STATE_STOPPED;
967      if (global.livecpu != NULL)
968         compute_debug_flags(machine, global.livecpu);
969   }
970   else
971      global.breakcpu = info;
942972}
943973
944974
src/emu/debug/debugvw.c
r3333r3334
585585         view->update_pending = 0;
586586
587587         /* resize the viewdata if needed */
588         size = view->visible_rows*view->visible_cols;
588         size = view->visible_rows * view->visible_cols;
589589         if (size > view->viewdata_size)
590590         {
591591            view->viewdata_size = size;
src/emu/debug/debugcpu.h
r3333r3334
247247
248248int debug_cpu_within_instruction_hook(running_machine *machine);
249249const debug_cpu_info *debug_get_cpu_info(int cpunum);
250void debug_cpu_halt_on_next_instruction(running_machine *machine, const char *fmt, ...) ATTR_PRINTF(2,3);
250void debug_cpu_halt_on_next_instruction(running_machine *machine, int cpunum, const char *fmt, ...) ATTR_PRINTF(3,4);
251251int   debug_cpu_is_stopped(running_machine *machine);
252252void debug_cpu_trace_printf(int cpunum, const char *fmt, ...) ATTR_PRINTF(2,3);
253253void debug_cpu_source_script(running_machine *machine, const char *file);
src/emu/cpu/mcs48/mcs48.c
r3333r3334
276276INLINE void execute_add(UINT8 dat)
277277{
278278   UINT16 temp = A + dat;
279   UINT16 temp4 = (A & 0x0f) + (dat & 0x0f);
279280
280281   PSW &= ~(C_FLAG | A_FLAG);
281   PSW |= ((A ^ temp) << 2) & A_FLAG;
282   PSW |= (temp4 << 2) & A_FLAG;
282283   PSW |= (temp >> 1) & C_FLAG;
283284   A = temp;
284285}
r3333r3334
292293INLINE void execute_addc(UINT8 dat)
293294{
294295   UINT16 temp = A + dat + CARRYIN;
296   UINT16 temp4 = (A & 0x0f) + (dat & 0x0f) + CARRYIN;
295297
296298   PSW &= ~(C_FLAG | A_FLAG);
297   PSW |= ((A ^ temp) << 2) & A_FLAG;
299   PSW |= (temp4 << 2) & A_FLAG;
298300   PSW |= (temp >> 1) & C_FLAG;
299301   A = temp;
300302}
src/emu/cpu/m37710/m7700ds.c
r3333r3334
438438      case RELW:
439439      case PER :
440440         var = read_16(oprom,1);
441         sprintf(ptr, " %06x (%s)", pb | ((pc + 1 + var)&0xffff), int_16_str(var));
442441         length += 2;
442         sprintf(ptr, " %06x (%s)", pb | ((pc + length + var)&0xffff), int_16_str(var));
443443         break;
444444      case IMM :
445445         if((opcode->flag == M && !m_flag) || (opcode->flag == X && !x_flag))
src/emu/cpu/cubeqcpu/cubeqcpu.c
r3333r3334
5656   "RAMU ",
5757};
5858
59enum
59enum alu_src
6060{
6161   AQ = 0,
6262   AB = 1,
r3333r3334
6666   DA = 5,
6767   DQ = 6,
6868   DZ = 7,
69} alu_src;
69};
7070
71enum
71enum alu_ins
7272{
7373   ADD   = 0,
7474   SUBR  = 1,
r3333r3334
7878   NOTRS = 5,
7979   EXOR  = 6,
8080   EXNOR = 7,
81} alu_ins;
81};
8282
83enum
83enum alu_dst
8484{
8585   QREG  = 0,
8686   NOP   = 1,
r3333r3334
9090   RAMD  = 5,
9191   RAMQU = 6,
9292   RAMU  = 7,
93} alu_dest;
93};
9494
9595/***************************************************************************
9696    MACROS
r3333r3334
517517#define SND_PC         (cquestsnd.pc)
518518#define SND_DATA_IN      (_ramen ? cquestsnd.sound_data[cquestsnd.platch] : cquestsnd.dinlatch)
519519
520enum
520enum snd_latch_type
521521{
522522   PLTCH = 0,
523523   DAC = 1,
524524   ADLATCH = 2,
525} snd_latch_type;
525};
526526
527527static int do_sndjmp(int jmp)
528528{
r3333r3334
820820
821821#define ROT_PC         (cquestrot.pc & 0x1ff)
822822
823enum
823enum rot_spf
824824{
825825   SPF_UNUSED0 = 0,
826826   SPF_UNUSED1 = 1,
r3333r3334
832832   SPF_MULT   = 7,
833833   SPF_DRED   = 8,
834834   SPF_DWRT   = 9,
835} rot_spf;
835};
836836
837enum
837enum rot_yout
838838{
839839   YOUT_UNUSED0 = 0,
840840   YOUT_UNUSED1 = 1,
r3333r3334
844844   YOUT_Y2DYN   = 5,
845845   YOUT_Y2R    = 6,
846846   YOUT_Y2D    = 7,
847} rot_yout;
847};
848848
849849/* Sync is asserted for the duration of every fourth cycle */
850850/* The Dynamic RAM latch clocks in a value at the end of this cycle */
r3333r3334
12971297
12981298#define VISIBLE_FIELD   !cquestlin.field
12991299
1300enum
1300enum line_spf
13011301{
13021302   LSPF_UNUSUED = 0,
13031303   LSPF_FSTOP   = 1,
r3333r3334
13071307   LSPF_MULT    = 5,
13081308   LSPF_LSTOP   = 6,
13091309   LSPF_BRES    = 7,
1310} line_spf;
1310};
13111311
1312enum
1312enum line_latch
13131313{
13141314   LLATCH_UNUSED   = 0,
13151315   LLATCH_SEQLATCH = 1,
r3333r3334
13191319   LLATCH_FADLATCH = 5,
13201320   LLATCH_CLATCH   = 6,
13211321   LLATCH_ZLATCH   = 7,
1322} line_latch;
1322};
13231323
1324enum
1324enum sreg_bits
13251325{
13261326   SREG_E0     = 0,
13271327   SREG_DX_DY  = 1,
r3333r3334
13311331   SREG_LDX_DY = 5,
13321332   SREG_LDY    = 6,
13331333   SREG_LDX    = 7,
1334} sreg_bits;
1334};
13351335
13361336INLINE int do_linjmp(int jmp)
13371337{
src/emu/cpu/dsp56k/dsp56dsm.c
r3333r3334
66
77***************************************************************************/
88
9#include "dsp56k.h"
9/*
10NOTES:
11*** There seems to be a disagreement in dasm with bytes like this : 0500 0307
12    On one hand, you can dasm it like this :  add      Y1,A          X:(R2+00),Y0
13    On the other, you can dasm it like this : move(m)  P:(R2+00),B0
14    The interesting doc pages for this are the following : move(m) . A-155
15                                                           mem move + short displacement . A-139
16                                                           add . A-23
17    (POSSIBILITY : Maybe Add can't have a mem move + short displacement parallel move?)
18    (CURRENT SOLUTION : I'm completely ignoring mem move + short displacements for now)
1019
11/* Main opcode categories */
12static unsigned assemble_x_memory_data_move_ALU_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
13static unsigned assemble_dual_x_memory_data_read_ALU_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
14static unsigned assemble_no_parallel_move_ALU_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
15static unsigned assemble_parallel_register_to_register_moveALU_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
16static unsigned assemble_coorperative_x_memory_data_move_ALU_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
17static unsigned assemble_TCC_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
18static unsigned assemble_bitfield_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
19static unsigned assemble_no_parallel_move_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
20static unsigned assemble_immediate_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
21static unsigned assemble_movec_opcodes(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
22static unsigned assemble_misc_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
23static unsigned assemble_unique_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc);
20*** This disassembler has been 75% tested.  There may remain some bugs, but it disassembles
21    Polygonet Commanders' memtest code 100% accurate (to my knowledge).
22*/
2423
25/* Sub-opcode decoding */
26static void decode_data_ALU_opcode(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
27static void decode_data_ALU_opcode_dual_move(const UINT16 op_byte, char* opcode_str, char* arg_str);
24#include "dsp56k.h"
2825
29/* Direct opcode decoding */
30static unsigned decode_TCC_opcode(const UINT16 op, char* opcode_str, char* arg_str);
31static unsigned decode_bitfield_opcode(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
32static unsigned decode_no_parallel_move_opcode(const UINT16 op, const UINT16 op2, const UINT16 pc, char* opcode_str, char* arg_str);
33static unsigned decode_immediate_opcode(const UINT16 op, const UINT16 pc, char* opcode_str, char* arg_str);
34static unsigned decode_movec_opcodes(const UINT16 op, const UINT16 op2, const UINT16 pc, char* opcode_str, char* arg_str);
35static unsigned decode_misc_opcode(const UINT16 op, const UINT16 pc, char* opcode_str, char* arg_str);
36static unsigned decode_unique_opcode(const UINT16 op, const UINT16 op2, const UINT16 pc, char* opcode_str, char* arg_str);
26/*******************/
27/* Dasm prototypes */
28/*******************/
29static size_t dsp56k_dasm_add_2      (const UINT16 op_byte, char* opcode_str, char* arg_str);
30static size_t dsp56k_dasm_mac_1      (const UINT16 op_byte, char* opcode_str, char* arg_str);
31static size_t dsp56k_dasm_macr_1   (const UINT16 op_byte, char* opcode_str, char* arg_str);
32static size_t dsp56k_dasm_move_1   (const UINT16 op_byte, char* opcode_str, char* arg_str);
33static size_t dsp56k_dasm_mpy_1      (const UINT16 op_byte, char* opcode_str, char* arg_str);
34static size_t dsp56k_dasm_mpyr_1   (const UINT16 op_byte, char* opcode_str, char* arg_str);
35static size_t dsp56k_dasm_sub_1      (const UINT16 op_byte, char* opcode_str, char* arg_str);
36static size_t dsp56k_dasm_tfr_2      (const UINT16 op_byte, char* opcode_str, char* arg_str);
37static size_t dsp56k_dasm_mpy_2      (const UINT16 op_byte, char* opcode_str, char* arg_str);
38static size_t dsp56k_dasm_mac_2      (const UINT16 op_byte, char* opcode_str, char* arg_str);
39static size_t dsp56k_dasm_clr      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
40static size_t dsp56k_dasm_add      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
41static size_t dsp56k_dasm_move      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
42static size_t dsp56k_dasm_tfr      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
43static size_t dsp56k_dasm_rnd      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
44static size_t dsp56k_dasm_tst      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
45static size_t dsp56k_dasm_inc      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
46static size_t dsp56k_dasm_inc24      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
47static size_t dsp56k_dasm_or      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
48static size_t dsp56k_dasm_asr      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
49static size_t dsp56k_dasm_asl      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
50static size_t dsp56k_dasm_lsr      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
51static size_t dsp56k_dasm_lsl      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
52static size_t dsp56k_dasm_eor      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
53static size_t dsp56k_dasm_subl      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
54static size_t dsp56k_dasm_sub      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
55static size_t dsp56k_dasm_clr2      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
56static size_t dsp56k_dasm_sbc      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
57static size_t dsp56k_dasm_cmp      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
58static size_t dsp56k_dasm_neg      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
59static size_t dsp56k_dasm_not      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
60static size_t dsp56k_dasm_dec      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
61static size_t dsp56k_dasm_dec24      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
62static size_t dsp56k_dasm_and      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
63static size_t dsp56k_dasm_abs      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
64static size_t dsp56k_dasm_ror      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
65static size_t dsp56k_dasm_rol      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
66static size_t dsp56k_dasm_cmpm      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
67static size_t dsp56k_dasm_mpy      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
68static size_t dsp56k_dasm_mpyr      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
69static size_t dsp56k_dasm_mac      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
70static size_t dsp56k_dasm_macr      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
71static size_t dsp56k_dasm_adc      (const UINT16 op, char* opcode_str, char* arg_str);
72static size_t dsp56k_dasm_andi      (const UINT16 op, char* opcode_str, char* arg_str);
73static size_t dsp56k_dasm_asl4      (const UINT16 op, char* opcode_str, char* arg_str);
74static size_t dsp56k_dasm_asr4      (const UINT16 op, char* opcode_str, char* arg_str);
75static size_t dsp56k_dasm_asr16      (const UINT16 op, char* opcode_str, char* arg_str);
76static size_t dsp56k_dasm_bfop      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
77static size_t dsp56k_dasm_bcc      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc);
78static size_t dsp56k_dasm_bcc_1      (const UINT16 op, char* opcode_str, char* arg_str, const offs_t pc);
79static size_t dsp56k_dasm_bcc_2      (const UINT16 op, char* opcode_str, char* arg_str);
80static size_t dsp56k_dasm_bra      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc);
81static size_t dsp56k_dasm_bra_1      (const UINT16 op, char* opcode_str, char* arg_str, const offs_t pc);
82static size_t dsp56k_dasm_bra_2      (const UINT16 op, char* opcode_str, char* arg_str);
83static size_t dsp56k_dasm_brkc      (const UINT16 op, char* opcode_str, char* arg_str);
84static size_t dsp56k_dasm_bscc      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc);
85static size_t dsp56k_dasm_bscc_1   (const UINT16 op, char* opcode_str, char* arg_str);
86static size_t dsp56k_dasm_bsr      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc);
87static size_t dsp56k_dasm_bsr_1      (const UINT16 op, char* opcode_str, char* arg_str);
88static size_t dsp56k_dasm_chkaau   (const UINT16 op, char* opcode_str, char* arg_str);
89static size_t dsp56k_dasm_debug      (const UINT16 op, char* opcode_str, char* arg_str);
90static size_t dsp56k_dasm_debugcc   (const UINT16 op, char* opcode_str, char* arg_str);
91static size_t dsp56k_dasm_div      (const UINT16 op, char* opcode_str, char* arg_str);
92static size_t dsp56k_dasm_dmac      (const UINT16 op, char* opcode_str, char* arg_str);
93static size_t dsp56k_dasm_do      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
94static size_t dsp56k_dasm_do_1      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
95static size_t dsp56k_dasm_do_2      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
96static size_t dsp56k_dasm_doforever   (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
97static size_t dsp56k_dasm_enddo      (const UINT16 op, char* opcode_str, char* arg_str);
98static size_t dsp56k_dasm_ext      (const UINT16 op, char* opcode_str, char* arg_str);
99static size_t dsp56k_dasm_illegal   (const UINT16 op, char* opcode_str, char* arg_str);
100static size_t dsp56k_dasm_imac      (const UINT16 op, char* opcode_str, char* arg_str);
101static size_t dsp56k_dasm_impy      (const UINT16 op, char* opcode_str, char* arg_str);
102static size_t dsp56k_dasm_jcc      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
103static size_t dsp56k_dasm_jcc_1      (const UINT16 op, char* opcode_str, char* arg_str);
104static size_t dsp56k_dasm_jmp      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
105static size_t dsp56k_dasm_jmp_1      (const UINT16 op, char* opcode_str, char* arg_str);
106static size_t dsp56k_dasm_jscc      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
107static size_t dsp56k_dasm_jscc_1   (const UINT16 op, char* opcode_str, char* arg_str);
108static size_t dsp56k_dasm_jsr      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
109static size_t dsp56k_dasm_jsr_1      (const UINT16 op, char* opcode_str, char* arg_str);
110static size_t dsp56k_dasm_jsr_2      (const UINT16 op, char* opcode_str, char* arg_str);
111static size_t dsp56k_dasm_lea      (const UINT16 op, char* opcode_str, char* arg_str);
112static size_t dsp56k_dasm_lea_1      (const UINT16 op, char* opcode_str, char* arg_str);
113static size_t dsp56k_dasm_macsuuu   (const UINT16 op, char* opcode_str, char* arg_str);
114static size_t dsp56k_dasm_move_2   (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
115static size_t dsp56k_dasm_movec      (const UINT16 op, char* opcode_str, char* arg_str);
116static size_t dsp56k_dasm_movec_1   (const UINT16 op, char* opcode_str, char* arg_str);
117static size_t dsp56k_dasm_movec_2   (const UINT16 op, char* opcode_str, char* arg_str);
118static size_t dsp56k_dasm_movec_3   (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
119static size_t dsp56k_dasm_movec_4   (const UINT16 op, char* opcode_str, char* arg_str);
120static size_t dsp56k_dasm_movec_5   (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
121static size_t dsp56k_dasm_movei      (const UINT16 op, char* opcode_str, char* arg_str);
122static size_t dsp56k_dasm_movem      (const UINT16 op, char* opcode_str, char* arg_str);
123static size_t dsp56k_dasm_movem_1   (const UINT16 op, char* opcode_str, char* arg_str);
124static size_t dsp56k_dasm_movem_2   (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str);
125static size_t dsp56k_dasm_movep      (const UINT16 op, char* opcode_str, char* arg_str);
126static size_t dsp56k_dasm_movep_1   (const UINT16 op, char* opcode_str, char* arg_str);
127static size_t dsp56k_dasm_moves      (const UINT16 op, char* opcode_str, char* arg_str);
128static size_t dsp56k_dasm_mpysuuu   (const UINT16 op, char* opcode_str, char* arg_str);
129static size_t dsp56k_dasm_negc      (const UINT16 op, char* opcode_str, char* arg_str);
130static size_t dsp56k_dasm_nop      (const UINT16 op, char* opcode_str, char* arg_str);
131static size_t dsp56k_dasm_norm      (const UINT16 op, char* opcode_str, char* arg_str);
132static size_t dsp56k_dasm_ori      (const UINT16 op, char* opcode_str, char* arg_str);
133static size_t dsp56k_dasm_rep      (const UINT16 op, char* opcode_str, char* arg_str);
134static size_t dsp56k_dasm_rep_1      (const UINT16 op, char* opcode_str, char* arg_str);
135static size_t dsp56k_dasm_rep_2      (const UINT16 op, char* opcode_str, char* arg_str);
136static size_t dsp56k_dasm_repcc      (const UINT16 op, char* opcode_str, char* arg_str);
137static size_t dsp56k_dasm_reset      (const UINT16 op, char* opcode_str, char* arg_str);
138static size_t dsp56k_dasm_rti      (const UINT16 op, char* opcode_str, char* arg_str);
139static size_t dsp56k_dasm_rts      (const UINT16 op, char* opcode_str, char* arg_str);
140static size_t dsp56k_dasm_stop      (const UINT16 op, char* opcode_str, char* arg_str);
141static size_t dsp56k_dasm_swap      (const UINT16 op, char* opcode_str, char* arg_str);
142static size_t dsp56k_dasm_swi      (const UINT16 op, char* opcode_str, char* arg_str);
143static size_t dsp56k_dasm_tcc      (const UINT16 op, char* opcode_str, char* arg_str);
144static size_t dsp56k_dasm_tfr2      (const UINT16 op, char* opcode_str, char* arg_str);
145static size_t dsp56k_dasm_tfr3      (const UINT16 op, char* opcode_str, char* arg_str);
146static size_t dsp56k_dasm_tst2      (const UINT16 op, char* opcode_str, char* arg_str);
147static size_t dsp56k_dasm_wait      (const UINT16 op, char* opcode_str, char* arg_str);
148static size_t dsp56k_dasm_zero      (const UINT16 op, char* opcode_str, char* arg_str);
37149
38/* Parallel operation decoding */
39static void decode_x_memory_data_move(const UINT16 op_byte, char* parallel_move_str);
40static void decode_dual_x_memory_data_read(const UINT16 op, char* parallel_move_str, char* parallel_move_str2);
41static void decode_register_to_register_data_move(const UINT16 op_byte, char* parallel_move_str, char* d_register);
42static void decode_parallel_cooperative_x_memory_data_move(const UINT16 op_byte, char* parallel_move_str, char* d_register);
43150
44
45/* Helper functions */
46#define BITS(CUR,MASK) (dsp56k_op_mask(CUR,MASK))
47static UINT16 dsp56k_op_mask(UINT16 op, UINT16 mask);
48static void pad_string(const int dest_length, char* string);
49
50enum bbbType  { BBB_UPPER, BBB_MIDDLE, BBB_LOWER };
51
151/***************************/
52152/* Table decoder functions */
153/***************************/
53154static int  decode_BBB_table  (UINT16 BBB);
54155static void decode_cccc_table (UINT16 cccc, char *mnemonic);
55156static void decode_DDDDD_table(UINT16 DDDDD, char *SD);
r3333r3334
64165static void decode_JJJF_table (UINT16 JJJ, UINT16 F, char *S, char *D);
65166static void decode_JJF_table  (UINT16 JJ, UINT16 F, char *S, char *D);
66167static void decode_JF_table   (UINT16 J, UINT16 F, char *S, char *D);
67/* static void decode_k_table    (UINT16 k, char *Dnot); */
168static void decode_k_table    (UINT16 k, char *Dnot);
68169static void decode_kSign_table(UINT16 k, char *plusMinus);
69170static void decode_KKK_table  (UINT16 KKK, char *D1, char *D2);
70/* static int  decode_NN_table   (UINT16 NN); */
171static int  decode_NN_table   (UINT16 NN);
172static int  decode_TT_table   (UINT16 TT);
71173static void decode_QQF_table  (UINT16 QQ, UINT16 F, char *S1, char *S2, char *D);
72174static void decode_QQF_special_table(UINT16 QQ, UINT16 F, char *S1, char *S2, char *D);
73175static void decode_QQQF_table (UINT16 QQQ, UINT16 F, char *S1, char *S2, char *D);
r3333r3334
83185static void assemble_ea_from_MM_table(UINT16 MM, int n, char *ea);
84186static void assemble_ea_from_t_table (UINT16 t, UINT16 val, char *ea);
85187static void assemble_ea_from_q_table (UINT16 q, int n, char *ea);
86/* static void assemble_ea_from_z_table (UINT16 z, int n, char *ea); */
188static void assemble_ea_from_z_table (UINT16 z, int n, char *ea);
87189
88190static void assemble_D_from_P_table(UINT16 P, UINT16 ppppp, char *D);
89191static void assemble_arguments_from_W_table(UINT16 W, char *args, char ma, char *SD, char *ea);
90192static void assemble_reg_from_W_table(UINT16 W, char *args, char ma, char *SD, UINT8 xx);
91193
92194static void assemble_address_from_IO_short_address(UINT16 pp, char *ea);
93static INT8 get_6_bit_relative_value(UINT16 bits);
195static INT8 get_6_bit_signed_value(UINT16 bits);
94196
95197
198/**********************************/
199/* Parallel memory move functions */
200/**********************************/
201static void decode_x_memory_data_move(const UINT16 op, char* parallel_move_str);
202static void decode_x_memory_data_move2(const UINT16 op, char* parallel_move_str, char* d_register);
203static void decode_dual_x_memory_data_read(const UINT16 op, char* parallel_move_str, char* parallel_move_str2);
204static void decode_register_to_register_data_move(const UINT16 op, char* parallel_move_str, char* d_register);
205static void decode_x_memory_data_write_and_register_data_move(const UINT16 op, char* parallel_move_str, char* parallel_move_str2);
206static void decode_address_register_update(const UINT16 op, char* parallel_move_str);
207static void decode_x_memory_data_move_with_short_displacement(const UINT16 op, const UINT16 op2, char* parallel_move_str);
208
209/********************/
210/* Helper functions */
211/********************/
212#define BITS(CUR,MASK) (dsp56k_op_mask(CUR,MASK))
213static UINT16 dsp56k_op_mask(UINT16 op, UINT16 mask);
214static void pad_string(const int dest_length, char* string);
215
216enum bbbType  { BBB_UPPER, BBB_MIDDLE, BBB_LOWER };
217
218
96219/*****************************/
97220/* Main disassembly function */
98221/*****************************/
99222offs_t dsp56k_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram)
100223{
224   /* ORDER: Handle parallel types in the ALU */
225   /*        Handle the rest */
101226   unsigned size = 0;
227
228   char arg_str[128] = "";
229   char opcode_str[128] = "";
230   char parallel_move_str[128] = "";
231   char parallel_move_str2[128] = "";
232
102233   const UINT16 op  = oprom[0] | (oprom[1] << 8);
103234   const UINT16 op2 = oprom[2] | (oprom[3] << 8);
104235
105   /* FILTER FOR PARALLEL DATA MOVES */
106   if (BITS(op,0x8000))
236   /* Dual X Memory Data Read : 011m mKKK -rr- ---- : A-142*/
237   if ((op & 0xe000) == 0x6000)
107238   {
108      /* ALU opcode with a single parallel data move */
109      size = assemble_x_memory_data_move_ALU_opcode(buffer, op, op2, pc);
239      /* Quote: (MOVE, MAC(R), MPY(R), ADD, SUB, TFR) */
240      UINT16 op_byte = op & 0x00ff;
241
242      /* ADD : 011m mKKK 0rru Fuuu : A-22 */
243      if ((op & 0xe080) == 0x6000)
244      {
245         size = dsp56k_dasm_add_2(op_byte, opcode_str, arg_str);
246      }
247      /* MAC : 011m mKKK 1xx0 F1QQ : A-122 */
248      else if ((op & 0xe094) == 0x6084)
249      {
250         size = dsp56k_dasm_mac_1(op_byte, opcode_str, arg_str);
251      }
252      /* MACR: 011m mKKK 1--1 F1QQ : A-124 */
253      else if ((op & 0xe094) == 0x6094)
254      {
255         size = dsp56k_dasm_macr_1(op_byte, opcode_str, arg_str);
256      }
257      /* MOVE : 011m mKKK 0rr1 0000 : A-128 */
258      else if ((op & 0xe09f) == 0x6010)
259      {
260         size = dsp56k_dasm_move_1(op_byte, opcode_str, arg_str);
261      }
262      /* MPY : 011m mKKK 1xx0 F0QQ : A-160 */
263      else if ((op & 0xe094) == 0x6080)
264      {
265         size = dsp56k_dasm_mpy_1(op_byte, opcode_str, arg_str);
266      }
267      /* MPYR : 011m mKKK 1--1 F0QQ : A-162 */
268      else if ((op & 0xe094) == 0x6090)
269      {
270         size = dsp56k_dasm_mpyr_1(op_byte, opcode_str, arg_str);
271      }
272      /* SUB : 011m mKKK 0rru Fuuu : A-202 */
273      else if ((op & 0xe080) == 0x6000)
274      {
275         size = dsp56k_dasm_sub_1(op_byte, opcode_str, arg_str);
276      }
277      /* TFR : 011m mKKK 0rr1 F0DD : A-212 */
278      else if ((op & 0xe094) == 0x6010)
279      {
280         size = dsp56k_dasm_tfr_2(op_byte, opcode_str, arg_str);
281      }
282
283      /* Now evaluate the parallel data move */
284      decode_dual_x_memory_data_read(op, parallel_move_str, parallel_move_str2);
110285   }
111   else if (BITS(op,0xe000) == 0x3)
286   /* X Memory Data Write and Register Data Move : 0001 011k RRDD ---- : A-140 */
287   else if ((op & 0xfe00) == 0x1600)
112288   {
113      /* ALU opcode with two parallel data moves */
114      size = assemble_dual_x_memory_data_read_ALU_opcode(buffer, op, op2, pc);
289      /* Quote: (MPY or MAC) */
290      UINT16 op_byte = op & 0x00ff;
291
292      /* MPY : 0001 0110 RRDD FQQQ : A-160 */
293      if ((op & 0xff00) == 0x1600)
294      {
295         size = dsp56k_dasm_mpy_2(op_byte, opcode_str, arg_str);
296      }
297      /* MAC : 0001 0111 RRDD FQQQ : A-122 */
298      else if ((op & 0xff00) == 0x1700)
299      {
300         size = dsp56k_dasm_mac_2(op_byte, opcode_str, arg_str);
301      }
302
303      /* Now evaluate the parallel data move */
304      decode_x_memory_data_write_and_register_data_move(op, parallel_move_str, parallel_move_str2);
115305   }
116   else if (BITS(op,0xff00) == 0x4a)
306
307   /* Handle Other parallel types */
308   else
117309   {
118      /* ALU opcode without any parallel data move */
119      size = assemble_no_parallel_move_ALU_opcode(buffer, op, op2, pc);
310      /***************************************/
311      /* 32 General parallel move operations */
312      /***************************************/
313
314      enum pType { kNoParallelDataMove,
315                kRegisterToRegister,
316                kAddressRegister,
317                kXMemoryDataMove,
318                kXMemoryDataMove2,
319                kXMemoryDataMoveWithDisp };
320
321      UINT16 op_byte = 0x0000;
322      char d_register[32] = "";
323      int parallelType = -1;
324
325      /* Note: it's important that NPDM comes before RtRDM here */
326      /* No Parallel Data Move : 0100 1010 ---- ---- : A-131 */
327      if ((op & 0xff00) == 0x4a00)
328      {
329         op_byte = op & 0x00ff;
330         parallelType = kNoParallelDataMove;
331      }
332      /* Register to Register Data Move : 0100 IIII ---- ---- : A-133 */
333      else if ((op & 0xf000) == 0x4000)
334      {
335         op_byte = op & 0x00ff;
336         parallelType = kRegisterToRegister;
337      }
338      /* Address Register Update : 0011 0zRR ---- ---- : A-135 */
339      else if ((op & 0xf800) == 0x3000)
340      {
341         op_byte = op & 0x00ff;
342         parallelType = kAddressRegister;
343      }
344      /* X Memory Data Move : 1mRR HHHW ---- ---- : A-137 */
345      else if ((op & 0x8000) == 0x8000)
346      {
347         op_byte = op & 0x00ff;
348         parallelType = kXMemoryDataMove;
349      }
350      /* X Memory Data Move : 0101 HHHW ---- ---- : A-137 */
351      else if ((op & 0xf000) == 0x5000)
352      {
353         op_byte = op & 0x00ff;
354         parallelType = kXMemoryDataMove2;
355      }
356      /* X Memory Data Move with short displacement : 0000 0101 BBBB BBBB ---- HHHW ---- ---- : A-139 */
357      else if ((op & 0xff00) == 0x0500)
358      {
359         /* See notes at top of file! */
360         /* op_byte = op2 & 0x00ff; */
361         /* parallelType = kXMemoryDataMoveWithDisp; */
362         /* DO NOTHING FOR NOW */
363      }
364
365
366      if (parallelType != -1)
367      {
368         /* Note: There is much overlap between opcodes down here */
369         /*       To this end, certain ops must come before others in the list */
370
371         /* CLR : .... .... 0000 F001 : A-60 */
372         if ((op_byte & 0x00f7) == 0x0001)
373         {
374            size = dsp56k_dasm_clr(op_byte, opcode_str, arg_str, d_register);
375         }
376         /* ADD : .... .... 0000 FJJJ : A-22 */
377         else if ((op_byte & 0x00f0) == 0x0000)
378         {
379            size = dsp56k_dasm_add(op_byte, opcode_str, arg_str, d_register);
380         }
381
382
383         /* MOVE : .... .... 0001 0001 : A-128 */
384         else if ((op_byte & 0x00ff) == 0x0011)
385         {
386            size = dsp56k_dasm_move(op_byte, opcode_str, arg_str, d_register);
387         }
388         /* TFR : .... .... 0001 FJJJ : A-212 */
389         else if ((op_byte & 0x00f0) == 0x0010)
390         {
391            size = dsp56k_dasm_tfr(op_byte, opcode_str, arg_str, d_register);
392         }
393
394
395         /* RND : .... .... 0010 F000 : A-188 */
396         else if ((op_byte & 0x00f7) == 0x0020)
397         {
398            size = dsp56k_dasm_rnd(op_byte, opcode_str, arg_str, d_register);
399         }
400         /* TST : .... .... 0010 F001 : A-218 */
401         else if ((op_byte & 0x00f7) == 0x0021)
402         {
403            size = dsp56k_dasm_tst(op_byte, opcode_str, arg_str, d_register);
404         }
405         /* INC : .... .... 0010 F010 : A-104 */
406         else if ((op_byte & 0x00f7) == 0x0022)
407         {
408            size = dsp56k_dasm_inc(op_byte, opcode_str, arg_str, d_register);
409         }
410         /* INC24 : .... .... 0010 F011 : A-106 */
411         else if ((op_byte & 0x00f7) == 0x0023)
412         {
413            size = dsp56k_dasm_inc24(op_byte, opcode_str, arg_str, d_register);
414         }
415         /* OR : .... .... 0010 F1JJ : A-176 */
416         else if ((op_byte & 0x00f4) == 0x0024)
417         {
418            size = dsp56k_dasm_or(op_byte, opcode_str, arg_str, d_register);
419         }
420
421
422         /* ASR : .... .... 0011 F000 : A-32 */
423         else if ((op_byte & 0x00f7) == 0x0030)
424         {
425            size = dsp56k_dasm_asr(op_byte, opcode_str, arg_str, d_register);
426         }
427         /* ASL : .... .... 0011 F001 : A-28 */
428         else if ((op_byte & 0x00f7) == 0x0031)
429         {
430            size = dsp56k_dasm_asl(op_byte, opcode_str, arg_str, d_register);
431         }
432         /* LSR : .... .... 0011 F010 : A-120 */
433         else if ((op_byte & 0x00f7) == 0x0032)
434         {
435            size = dsp56k_dasm_lsr(op_byte, opcode_str, arg_str, d_register);
436         }
437         /* LSL : .... .... 0011 F011 : A-118 */
438         else if ((op_byte & 0x00f7) == 0x0033)
439         {
440            size = dsp56k_dasm_lsl(op_byte, opcode_str, arg_str, d_register);
441         }
442         /* EOR : .... .... 0011 F1JJ : A-94 */
443         else if ((op_byte & 0x00f4) == 0x0034)
444         {
445            size = dsp56k_dasm_eor(op_byte, opcode_str, arg_str, d_register);
446         }
447
448
449         /* SUBL : .... .... 0100 F001 : A-204 */
450         else if ((op_byte & 0x00f7) == 0x0041)
451         {
452            size = dsp56k_dasm_subl(op_byte, opcode_str, arg_str, d_register);
453         }
454         /* SUB : .... .... 0100 FJJJ : A-202 */
455         else if ((op_byte & 0x00f0) == 0x0040)
456         {
457            size = dsp56k_dasm_sub(op_byte, opcode_str, arg_str, d_register);
458         }
459
460
461         /* CLR24 : .... .... 0101 F001 : A-62 */
462         else if ((op_byte & 0x00f7) == 0x0051)
463         {
464            size = dsp56k_dasm_clr2(op_byte, opcode_str, arg_str, d_register);
465         }
466         /* SBC : .... .... 0101 F01J : A-198 */
467         else if ((op_byte & 0x00f6) == 0x0052)
468         {
469            size = dsp56k_dasm_sbc(op_byte, opcode_str, arg_str, d_register);
470         }
471         /* CMP : .... .... 0101 FJJJ : A-64 */
472         else if ((op_byte & 0x00f0) == 0x0050)
473         {
474            size = dsp56k_dasm_cmp(op_byte, opcode_str, arg_str, d_register);
475         }
476
477
478         /* NEG : .... .... 0110 F000 : A-166 */
479         else if ((op_byte & 0x00f7) == 0x0060)
480         {
481            size = dsp56k_dasm_neg(op_byte, opcode_str, arg_str, d_register);
482         }
483         /* NOT : .... .... 0110 F001 : A-174 */
484         else if ((op_byte & 0x00f7) == 0x0061)
485         {
486            size = dsp56k_dasm_not(op_byte, opcode_str, arg_str, d_register);
487         }
488         /* DEC : .... .... 0110 F010 : A-72 */
489         else if ((op_byte & 0x00f7) == 0x0062)
490         {
491            size = dsp56k_dasm_dec(op_byte, opcode_str, arg_str, d_register);
492         }
493         /* DEC24 : .... .... 0110 F011 : A-74 */
494         else if ((op_byte & 0x00f7) == 0x0063)
495         {
496            size = dsp56k_dasm_dec24(op_byte, opcode_str, arg_str, d_register);
497         }
498         /* AND : .... .... 0110 F1JJ : A-24 */
499         else if ((op_byte & 0x00f4) == 0x0064)
500         {
501            size = dsp56k_dasm_and(op_byte, opcode_str, arg_str, d_register);
502         }
503
504
505         /* ABS : .... .... 0111 F001 : A-18 */
506         if ((op_byte & 0x00f7) == 0x0071)
507         {
508            size = dsp56k_dasm_abs(op_byte, opcode_str, arg_str, d_register);
509         }
510         /* ROR : .... .... 0111 F010 : A-192 */
511         else if ((op_byte & 0x00f7) == 0x0072)
512         {
513            size = dsp56k_dasm_ror(op_byte, opcode_str, arg_str, d_register);
514         }
515         /* ROL : .... .... 0111 F011 : A-190 */
516         else if ((op_byte & 0x00f7) == 0x0073)
517         {
518            size = dsp56k_dasm_rol(op_byte, opcode_str, arg_str, d_register);
519         }
520         /* CMPM : .... .... 0111 FJJJ : A-66 */
521         else if ((op_byte & 0x00f0) == 0x0070)
522         {
523            size = dsp56k_dasm_cmpm(op_byte, opcode_str, arg_str, d_register);
524         }
525
526
527         /* MPY : .... .... 1k00 FQQQ : A-160    -- CONFIRMED TYPO IN DOCS (HHHH vs HHHW) */
528         else if ((op_byte & 0x00b0) == 0x0080)
529         {
530            size = dsp56k_dasm_mpy(op_byte, opcode_str, arg_str, d_register);
531         }
532         /* MPYR : .... .... 1k01 FQQQ : A-162 */
533         else if ((op_byte & 0x00b0) == 0x0090)
534         {
535            size = dsp56k_dasm_mpyr(op_byte, opcode_str, arg_str, d_register);
536         }
537         /* MAC : .... .... 1k10 FQQQ : A-122 */
538         else if ((op_byte & 0x00b0) == 0x00a0)
539         {
540            size = dsp56k_dasm_mac(op_byte, opcode_str, arg_str, d_register);
541         }
542         /* MACR : .... .... 1k11 FQQQ : A-124   -- DRAMA - rr vs xx (805) */
543         else if ((op_byte & 0x00b0) == 0x00b0)
544         {
545            size = dsp56k_dasm_macr(op_byte, opcode_str, arg_str, d_register);
546         }
547
548
549         /* Now evaluate the parallel data move */
550         switch (parallelType)
551         {
552         case kNoParallelDataMove:
553            /* DO NOTHING */
554            size = 1;
555            break;
556         case kRegisterToRegister:
557            decode_register_to_register_data_move(op, parallel_move_str, d_register);
558            size = 1;
559            break;
560         case kAddressRegister:
561            decode_address_register_update(op, parallel_move_str);
562            size = 1;
563            break;
564         case kXMemoryDataMove:
565            decode_x_memory_data_move(op, parallel_move_str);
566            size = 1;
567            break;
568         case kXMemoryDataMove2:
569            decode_x_memory_data_move2(op, parallel_move_str, d_register);
570            size = 1;
571            break;
572         case kXMemoryDataMoveWithDisp:
573            decode_x_memory_data_move_with_short_displacement(op, op2, parallel_move_str);
574            size = 2;
575            break;
576         }
577      }
120578   }
121   else if (BITS(op,0xf000) == 0x4)   /* TODO */
579
580   /* Assemble and return parallel move operation */
581   if (size > 0)
122582   {
123      /* ALU opcode with a parallel register to register move */
124      size = assemble_parallel_register_to_register_moveALU_opcode(buffer, op, op2, pc);
583      char space[32] = "";
584
585      pad_string(11, opcode_str);
586      if (strlen(parallel_move_str) != 0)
587         pad_string(15, arg_str);
588      if (strlen(parallel_move_str2) != 0)
589         sprintf(space, " ");
590
591      sprintf(buffer, "%s%s%s%s%s", opcode_str, arg_str, parallel_move_str, space, parallel_move_str2);
592
593      return (size | DASMFLAG_SUPPORTED);
125594   }
126   else if (BITS(op,0xf800) == 0x6)   /* TODO */
595
596
597   /******************************/
598   /* Remaining non-parallel ops */
599   /******************************/
600
601   /* ADC : 0001 0101 0000 F01J : A-20 */
602   if ((op & 0xfff6) == 0x1502)
127603   {
128      /* ALU opcode with an address register update */
129      sprintf(buffer, "Parallel address register update unimplemented.");
130      size = 1;
604      size = dsp56k_dasm_adc(op, opcode_str, arg_str);
131605   }
132   else if (BITS(op,0xf000) == 0x5)
606   /* ANDI : 0001 1EE0 iiii iiii : A-26 */
607   /* (MoveP sneaks in here if you don't check 0x0600) */
608   else if (((op & 0xf900) == 0x1800) & ((op & 0x0600) != 0x0000))
133609   {
134      /* ALU opcode with an cooperative x data memory move */
135      size = assemble_coorperative_x_memory_data_move_ALU_opcode(buffer, op, op2, pc);
610      size = dsp56k_dasm_andi(op, opcode_str, arg_str);
136611   }
137   else if (BITS(op,0xff00) == 0x05)   /* TODO */
612   /* ASL4 : 0001 0101 0011 F001 : A-30 */
613   else if ((op & 0xfff7) == 0x1531)
138614   {
139      /* ALU opcode with x memory data move + short displacement */
140      sprintf(buffer, "Parallel x memory data move + short displacement unimplemented.");
141      size = 2;
615      size = dsp56k_dasm_asl4(op, opcode_str, arg_str);
142616   }
143   else if (BITS(op,0xfe00) == 0xb)   /* TODO */
617   /* ASR4 : 0001 0101 0011 F000 : A-34 */
618   else if ((op & 0xfff7) == 0x1530)
144619   {
145      /* ALU opcode with x memory data write and register data move */
146      /* Don't forget these two, unique cases */
147      /* MPY             X       0001 0110 xxxx xxxx */
148      /* MAC             X       0001 0111 xxxx xxxx */
149      sprintf(buffer, "Parallel x memory data write and register data move unimplemented.");
150      size = 1;
620      size = dsp56k_dasm_asr4(op, opcode_str, arg_str);
151621   }
152
153   /* Tcc is a unique critter */
154   if (BITS(op,0xfc00) == 0x4)
622   /* ASR16 : 0001 0101 0111 F000 : A-36 */
623   else if ((op & 0xfff7) == 0x1570)
155624   {
156      size = assemble_TCC_opcode(buffer, op, op2, pc);
625      size = dsp56k_dasm_asr16(op, opcode_str, arg_str);
157626   }
158
159   /* Operations that do not allow a parallel move */
160   if (BITS(op,0xff00) == 0x14)
627   /* BFCHG : 0001 0100 11Pp pppp BBB1 0010 iiii iiii : A-38 */
628   else if (((op & 0xffc0) == 0x14c0) && ((op2 & 0x1f00) == 0x1200))
161629   {
162      size = assemble_bitfield_opcode(buffer, op, op2, pc);
630      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
163631   }
164   if (BITS(op,0xff00) == 0x15)
632   /* BFCHG : 0001 0100 101- --RR BBB1 0010 iiii iiii : A-38 */
633   else if (((op & 0xffe0) == 0x14a0) && ((op2 & 0x1f00) == 0x1200))
165634   {
166      size = assemble_no_parallel_move_opcode(buffer, op, op2, pc);
635      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
167636   }
168   if (BITS(op,0xf800) == 0x3)
637   /* BFCHG : 0001 0100 100D DDDD BBB1 0010 iiii iiii : A-38 */
638   else if (((op & 0xffe0) == 0x1480) && ((op2 & 0x1f00) == 0x1200))
169639   {
170      size = assemble_immediate_opcode(buffer, op, op2, pc);
640      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
171641   }
172   if (BITS(op,0xf800) == 0x7)
642   /* BFCLR : 0001 0100 11Pp pppp BBB0 0100 iiii iiii : A-40 */
643   else if (((op & 0xffc0) == 0x14c0) && ((op2 & 0x1f00) == 0x0400))
173644   {
174      size = assemble_movec_opcodes(buffer, op, op2, pc);
645      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
175646   }
176   if (BITS(op,0xf000) == 0x2)
647   /* BFCLR : 0001 0100 101- --RR BBB0 0100 iiii iiii : A-40 */
648   else if (((op & 0xffe0) == 0x14a0) && ((op2 & 0x1f00) == 0x0400))
177649   {
178      size = assemble_misc_opcode(buffer, op, op2, pc);
650      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
179651   }
180
181   if (BITS(op,0xf000) == 0x0)
652   /* BFCLR : 0001 0100 100D DDDD BBB0 0100 iiii iiii : A-40 */
653   else if (((op & 0xffe0) == 0x1480) && ((op2 & 0x1f00) == 0x0400))
182654   {
183      size = assemble_unique_opcode(buffer, op, op2, pc);
655      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
184656   }
657   /* BFSET : 0001 0100 11Pp pppp BBB1 1000 iiii iiii : A-42 */
658   else if (((op & 0xffc0) == 0x14c0) && ((op2 & 0x1f00) == 0x1800))
659   {
660      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
661   }
662   /* BFSET : 0001 0100 101- --RR BBB1 1000 iiii iiii : A-42 */
663   else if (((op & 0xffe0) == 0x14a0) && ((op2 & 0x1f00) == 0x1800))
664   {
665      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
666   }
667   /* BFSET : 0001 0100 100D DDDD BBB1 1000 iiii iiii : A-42 */
668   else if (((op & 0xffe0) == 0x1480) && ((op2 & 0x1f00) == 0x1800))
669   {
670      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
671   }
672   /* BFTSTH : 0001 0100 01Pp pppp BBB1 0000 iiii iiii : A-44 */
673   else if (((op & 0xffc0) == 0x1440) && ((op2 & 0x1f00) == 0x1000))
674   {
675      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
676   }
677   /* BFTSTH : 0001 0100 001- --RR BBB1 0000 iiii iiii : A-44 */
678   else if (((op & 0xffe0) == 0x1420) && ((op2 & 0x1f00) == 0x1000))
679   {
680      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
681   }
682   /* BFTSTH : 0001 0100 000D DDDD BBB1 0000 iiii iiii : A-44 */
683   else if (((op & 0xffe0) == 0x1400) && ((op2 & 0x1f00) == 0x1000))
684   {
685      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
686   }
687   /* BFTSTL : 0001 0100 01Pp pppp BBB0 0000 iiii iiii : A-46 */
688   else if (((op & 0xffc0) == 0x1440) && ((op2 & 0x1f00) == 0x0000))
689   {
690      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
691   }
692   /* BFTSTL : 0001 0100 001- --RR BBB0 0000 iiii iiii : A-46 */
693   else if (((op & 0xffe0) == 0x1420) && ((op2 & 0x1f00) == 0x0000))
694   {
695      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
696   }
697   /* BFTSTL : 0001 0100 000D DDDD BBB0 0000 iiii iiii : A-46 */
698   else if (((op & 0xffe0) == 0x1400) && ((op2 & 0x1f00) == 0x0000))
699   {
700      size = dsp56k_dasm_bfop(op, op2, opcode_str, arg_str);
701   }
702   /* Bcc : 0000 0111 --11 cccc xxxx xxxx xxxx xxxx : A-48 */
703   else if (((op & 0xff30) == 0x0730) && ((op2 & 0x0000) == 0x0000))
704   {
705      size = dsp56k_dasm_bcc(op, op2, opcode_str, arg_str, pc);
706   }
707   /* Bcc : 0010 11cc ccee eeee : A-48 */
708   else if ((op & 0xfc00) == 0x2c00)
709   {
710      size = dsp56k_dasm_bcc_1(op, opcode_str, arg_str, pc);
711   }
712   /* Bcc : 0000 0111 RR10 cccc : A-48 */
713   else if ((op & 0xff30) == 0x0720)
714   {
715      size = dsp56k_dasm_bcc_2(op, opcode_str, arg_str);
716   }
717   /* BRA : 0000 0001 0011 11-- xxxx xxxx xxxx xxxx : A-50 */
718   else if (((op & 0xfffc) == 0x013c) && ((op2 & 0x0000) == 0x0000))
719   {
720      size = dsp56k_dasm_bra(op, op2, opcode_str, arg_str, pc);
721   }
722   /* BRA : 0000 1011 aaaa aaaa : A-50 */
723   else if ((op & 0xff00) == 0x0b00)
724   {
725      size = dsp56k_dasm_bra_1(op, opcode_str, arg_str, pc);
726   }
727   /* BRA : 0000 0001 0010 11RR : A-50 */
728   else if ((op & 0xfffc) == 0x012c)
729   {
730      size = dsp56k_dasm_bra_2(op, opcode_str, arg_str);
731   }
732   /* BRKc : 0000 0001 0001 cccc : A-52 */
733   else if ((op & 0xfff0) == 0x0110)
734   {
735      size = dsp56k_dasm_brkc(op, opcode_str, arg_str);
736   }
737   /* BScc : 0000 0111 --01 cccc xxxx xxxx xxxx xxxx : A-54 */
738   else if (((op & 0xff30) == 0x0710) && ((op2 & 0x0000) == 0x0000))
739   {
740      size = dsp56k_dasm_bscc(op, op2, opcode_str, arg_str, pc);
741   }
742   /* BScc: 0000 0111 RR00 cccc : A-54 */
743   else if ((op & 0xff30) == 0x0700)
744   {
745      size = dsp56k_dasm_bscc_1(op, opcode_str, arg_str);
746   }
747   /* BSR : 0000 0001 0011 10-- xxxx xxxx xxxx xxxx : A-56 */
748   else if (((op & 0xfffc) == 0x0138) && ((op2 & 0x0000) == 0x0000))
749   {
750      size = dsp56k_dasm_bsr(op, op2, opcode_str, arg_str, pc);
751   }
752   /* BSR : 0000 0001 0010 10RR : A-56 */
753   else if ((op & 0xfffc) == 0x0128)
754   {
755      size = dsp56k_dasm_bsr_1(op, opcode_str, arg_str);
756   }
757   /* CHKAAU : 0000 0000 0000 0100 : A-58 */
758   else if ((op & 0xffff) == 0x0004)
759   {
760      size = dsp56k_dasm_chkaau(op, opcode_str, arg_str);
761   }
762   /* DEBUG : 0000 0000 0000 0001 : A-68 */
763   else if ((op & 0xffff) == 0x0001)
764   {
765      size = dsp56k_dasm_debug(op, opcode_str, arg_str);
766   }
767   /* DEBUGcc : 0000 0000 0101 cccc : A-70 */
768   else if ((op & 0xfff0) == 0x0050)
769   {
770      size = dsp56k_dasm_debugcc(op, opcode_str, arg_str);
771   }
772   /* DIV : 0001 0101 0--0 F1DD : A-76 */
773   /* WARNING : DOCS SAY THERE IS A PARALLEL MOVE HERE !!! */
774   else if ((op & 0xff94) == 0x1504)
775   {
776      size = dsp56k_dasm_div(op, opcode_str, arg_str);
777   }
778   /* DMAC : 0001 0101 10s1 FsQQ : A-80 */
779   else if ((op & 0xffd0) == 0x1590)
780   {
781      size = dsp56k_dasm_dmac(op, opcode_str, arg_str);
782   }
783   /* DO : 0000 0000 110- --RR xxxx xxxx xxxx xxxx : A-82 */
784   else if (((op & 0xffe0) == 0x00c0) && ((op2 & 0x0000) == 0x0000))
785   {
786      size = dsp56k_dasm_do(op, op2, opcode_str, arg_str);
787   }
788   /* DO : 0000 1110 iiii iiii xxxx xxxx xxxx xxxx : A-82 */
789   else if (((op & 0xff00) == 0x0e00) && ((op2 & 0x0000) == 0x0000))
790   {
791      size = dsp56k_dasm_do_1(op, op2, opcode_str, arg_str);
792   }
793   /* DO : 0000 0100 000D DDDD xxxx xxxx xxxx xxxx : A-82 */
794   else if (((op & 0xffe0) == 0x0400) && ((op2 & 0x0000) == 0x0000))
795   {
796      size = dsp56k_dasm_do_2(op, op2, opcode_str, arg_str);
797   }
798   /* DO FOREVER : 0000 0000 0000 0010 xxxx xxxx xxxx xxxx : A-88 */
799   else if (((op & 0xffff) == 0x0002) && ((op2 & 0x0000) == 0x0000))
800   {
801      size = dsp56k_dasm_doforever(op, op2, opcode_str, arg_str);
802   }
803   /* ENDDO : 0000 0000 0000 1001 : A-92 */
804   else if ((op & 0xffff) == 0x0009)
805   {
806      size = dsp56k_dasm_enddo(op, opcode_str, arg_str);
807   }
808   /* EXT : 0001 0101 0101 F010 : A-96 */
809   else if ((op & 0xfff7) == 0x1552)
810   {
811      size = dsp56k_dasm_ext(op, opcode_str, arg_str);
812   }
813   /* ILLEGAL : 0000 0000 0000 1111 : A-98 */
814   else if ((op & 0xffff) == 0x000f)
815   {
816      size = dsp56k_dasm_illegal(op, opcode_str, arg_str);
817   }
818   /* IMAC : 0001 0101 1010 FQQQ : A-100 */
819   else if ((op & 0xfff0) == 0x15a0)
820   {
821      size = dsp56k_dasm_imac(op, opcode_str, arg_str);
822   }
823   /* IMPY : 0001 0101 1000 FQQQ : A-102 */
824   else if ((op & 0xfff0) == 0x1580)
825   {
826      size = dsp56k_dasm_impy(op, opcode_str, arg_str);
827   }
828   /* Jcc : 0000 0110 --11 cccc xxxx xxxx xxxx xxxx : A-108 */
829   else if (((op & 0xff30) == 0x0630) && ((op2 & 0x0000) == 0x0000))
830   {
831      size = dsp56k_dasm_jcc(op, op2, opcode_str, arg_str);
832   }
833   /* Jcc : 0000 0110 RR10 cccc : A-108 */
834   else if ((op & 0xff30) == 0x0620 )
835   {
836      size = dsp56k_dasm_jcc_1(op, opcode_str, arg_str);
837   }
838   /* JMP : 0000 0001 0011 01-- xxxx xxxx xxxx xxxx : A-110 */
839   else if (((op & 0xfffc) == 0x0134) && ((op2 & 0x0000) == 0x0000))
840   {
841      size = dsp56k_dasm_jmp(op, op2, opcode_str, arg_str);
842   }
843   /* JMP : 0000 0001 0010 01RR : A-110 */
844   else if ((op & 0xfffc) == 0x0124)
845   {
846      size = dsp56k_dasm_jmp_1(op, opcode_str, arg_str);
847   }
848   /* JScc : 0000 0110 --01 cccc xxxx xxxx xxxx xxxx : A-112 */
849   else if (((op & 0xff30) == 0x0610) && ((op2 & 0x0000) == 0x0000))
850   {
851      size = dsp56k_dasm_jscc(op, op2, opcode_str, arg_str);
852   }
853   /* JScc : 0000 0110 RR00 cccc : A-112 */
854   else if ((op & 0xff30) == 0x0600)
855   {
856      size = dsp56k_dasm_jscc_1(op, opcode_str, arg_str);
857   }
858   /* JSR : 0000 0001 0011 00-- xxxx xxxx xxxx xxxx : A-114 */
859   else if (((op & 0xfffc) == 0x0130) && ((op2 & 0x0000) == 0x0000))
860   {
861      size = dsp56k_dasm_jsr(op, op2, opcode_str, arg_str);
862   }
863   /* JSR : 0000 1010 AAAA AAAA : A-114 */
864   else if ((op & 0xff00) == 0x0a00)
865   {
866      size = dsp56k_dasm_jsr_1(op, opcode_str, arg_str);
867   }
868   /* JSR : 0000 0001 0010 00RR : A-114 */
869   else if ((op & 0xfffc) == 0x0120)
870   {
871      size = dsp56k_dasm_jsr_2(op, opcode_str, arg_str);
872   }
873   /* LEA : 0000 0001 11TT MMRR : A-116 */
874   else if ((op & 0xffc0) == 0x01c0)
875   {
876      size = dsp56k_dasm_lea(op, opcode_str, arg_str);
877   }
878   /* LEA : 0000 0001 10NN MMRR : A-116 */
879   else if ((op & 0xffc0) == 0x0180)
880   {
881      size = dsp56k_dasm_lea_1(op, opcode_str, arg_str);
882   }
883   /* MAC(su,uu) : 0001 0101 1110 FsQQ : A-126 */
884   else if ((op & 0xfff0) == 0x15e0)
885   {
886      size = dsp56k_dasm_macsuuu(op, opcode_str, arg_str);
887   }
888   /* MOVE : 0000 0101 BBBB BBBB ---- HHHW 0001 0001 : A-128 */
889   else if (((op & 0xff00) == 0x0500) && ((op2 & 0x00ff) == 0x0011))
890   {
891      size = dsp56k_dasm_move_2(op, op2, opcode_str, arg_str);
892   }
893   /* MOVE(C) : 0011 1WDD DDD0 MMRR : A-144 */
894   else if ((op & 0xf810) == 0x3800)
895   {
896      size = dsp56k_dasm_movec(op, opcode_str, arg_str);
897   }
898   /* MOVE(C) : 0011 1WDD DDD1 q0RR : A-144 */
899   else if ((op & 0xf814) == 0x3810)
900   {
901      size = dsp56k_dasm_movec_1(op, opcode_str, arg_str);
902   }
903   /* MOVE(C) : 0011 1WDD DDD1 Z11- : A-144 */
904   else if ((op & 0xf816) == 0x3816)
905   {
906      size = dsp56k_dasm_movec_2(op, opcode_str, arg_str);
907   }
908   /* MOVE(C) : 0011 1WDD DDD1 t10- xxxx xxxx xxxx xxxx : A-144 */
909   else if (((op & 0xf816) == 0x3814) && ((op2 & 0x0000) == 0x0000))
910   {
911      size = dsp56k_dasm_movec_3(op, op2, opcode_str, arg_str);
912   }
913   /* MOVE(C) : 0010 10dd dddD DDDD : A-144 */
914   else if ((op & 0xfc00) == 0x2800)
915   {
916      size = dsp56k_dasm_movec_4(op, opcode_str, arg_str);
917   }
918   /* MOVE(C) : 0000 0101 BBBB BBBB 0011 1WDD DDD0 ---- : A-144 */
919   else if (((op & 0xff00) == 0x0500) && ((op2 & 0xf810) == 0x3800))
920   {
921      size = dsp56k_dasm_movec_5(op, op2, opcode_str, arg_str);
922   }
923   /* MOVE(I) : 0010 00DD BBBB BBBB : A-150 */
924   else if ((op & 0xfc00) == 0x2000)
925   {
926      size = dsp56k_dasm_movei(op, opcode_str, arg_str);
927   }
928   /* MOVE(M) : 0000 001W RR0M MHHH : A-152 */
929   else if ((op & 0xfe20) == 0x0200)
930   {
931      size = dsp56k_dasm_movem(op, opcode_str, arg_str);
932   }
933   /* MOVE(M) : 0000 001W RR11 mmRR : A-152 */
934   else if ((op & 0xfe30) == 0x0230)
935   {
936      size = dsp56k_dasm_movem_1(op, opcode_str, arg_str);
937   }
938   /* MOVE(M) : 0000 0101 BBBB BBBB 0000 001W --0- -HHH : A-152 */
939   else if (((op & 0xff00) == 0x0500) && ((op2 & 0xfe20) == 0x0200))
940   {
941      size = dsp56k_dasm_movem_2(op, op2, opcode_str, arg_str);
942   }
943   /* MOVE(P) : 0001 100W HH1p pppp : A-156 */
944   else if ((op & 0xfe20) == 0x1820)
945   {
946      size = dsp56k_dasm_movep(op, opcode_str, arg_str);
947   }
948   /* MOVE(P) : 0000 110W RRmp pppp : A-156 */
949   else if ((op & 0xfe00) == 0x0c00)
950   {
951      size = dsp56k_dasm_movep_1(op, opcode_str, arg_str);
952   }
953   /* MOVE(S) : 0001 100W HH0a aaaa : A-158 */
954   else if ((op & 0xfe20) == 0x1800)
955   {
956      size = dsp56k_dasm_moves(op, opcode_str, arg_str);
957   }
958   /* MPY(su,uu) : 0001 0101 1100 FsQQ : A-164 */
959   else if ((op & 0xfff0) == 0x15c0)
960   {
961      size = dsp56k_dasm_mpysuuu(op, opcode_str, arg_str);
962   }
963   /* NEGC : 0001 0101 0110 F000 : A-168 */
964   else if ((op & 0xfff7) == 0x1560)
965   {
966      size = dsp56k_dasm_negc(op, opcode_str, arg_str);
967   }
968   /* NOP : 0000 0000 0000 0000 : A-170 */
969   else if ((op & 0xffff) == 0x0000)
970   {
971      size = dsp56k_dasm_nop(op, opcode_str, arg_str);
972   }
973   /* NORM : 0001 0101 0010 F0RR : A-172 */
974   else if ((op & 0xfff4) == 0x1520)
975   {
976      size = dsp56k_dasm_norm(op, opcode_str, arg_str);
977   }
978   /* ORI : 0001 1EE1 iiii iiii : A-178 */
979   else if ((op & 0xf900) == 0x1900)
980   {
981      size = dsp56k_dasm_ori(op, opcode_str, arg_str);
982   }
983   /* REP : 0000 0000 111- --RR : A-180 */
984   else if ((op & 0xffe0) == 0x00e0)
985   {
986      size = dsp56k_dasm_rep(op, opcode_str, arg_str);
987   }
988   /* REP : 0000 1111 iiii iiii : A-180 */
989   else if ((op & 0xff00) == 0x0f00)
990   {
991      size = dsp56k_dasm_rep_1(op, opcode_str, arg_str);
992   }
993   /* REP : 0000 0100 001D DDDD : A-180 */
994   else if ((op & 0xffe0) == 0x0420)
995   {
996      size = dsp56k_dasm_rep_2(op, opcode_str, arg_str);
997   }
998   /* REPcc : 0000 0001 0101 cccc : A-184 */
999   else if ((op & 0xfff0) == 0x0150)
1000   {
1001      size = dsp56k_dasm_repcc(op, opcode_str, arg_str);
1002   }
1003   /* RESET : 0000 0000 0000 1000 : A-186 */
1004   else if ((op & 0xffff) == 0x0008)
1005   {
1006      size = dsp56k_dasm_reset(op, opcode_str, arg_str);
1007   }
1008   /* RTI : 0000 0000 0000 0111 : A-194 */
1009   else if ((op & 0xffff) == 0x0007)
1010   {
1011      size = dsp56k_dasm_rti(op, opcode_str, arg_str);
1012   }
1013   /* RTS : 0000 0000 0000 0110 : A-196 */
1014   else if ((op & 0xffff) == 0x0006)
1015   {
1016      size = dsp56k_dasm_rts(op, opcode_str, arg_str);
1017   }
1018   /* STOP : 0000 0000 0000 1010 : A-200 */
1019   else if ((op & 0xffff) == 0x000a)
1020   {
1021      size = dsp56k_dasm_stop(op, opcode_str, arg_str);
1022   }
1023   /* SWAP : 0001 0101 0111 F001 : A-206 */
1024   else if ((op & 0xfff7) == 0x1571)
1025   {
1026      size = dsp56k_dasm_swap(op, opcode_str, arg_str);
1027   }
1028   /* SWI : 0000 0000 0000 0101 : A-208 */
1029   else if ((op & 0xffff) == 0x0005)
1030   {
1031      size = dsp56k_dasm_swi(op, opcode_str, arg_str);
1032   }
1033   /* Tcc : 0001 00cc ccTT Fh0h : A-210 */
1034   else if ((op & 0xfc02) == 0x1000)
1035   {
1036      size = dsp56k_dasm_tcc(op, opcode_str, arg_str);
1037   }
1038   /* TFR(2) : 0001 0101 0000 F00J : A-214 */
1039   else if ((op & 0xfff6) == 0x1500)
1040   {
1041      size = dsp56k_dasm_tfr2(op, opcode_str, arg_str);
1042   }
1043   /* TFR(3) : 0010 01mW RRDD FHHH : A-216 */
1044   else if ((op & 0xfc00) == 0x2400)
1045   {
1046      size = dsp56k_dasm_tfr3(op, opcode_str, arg_str);
1047   }
1048   /* TST(2) : 0001 0101 0001 -1DD : A-220 */
1049   else if ((op & 0xfff4) == 0x1514)
1050   {
1051      size = dsp56k_dasm_tst2(op, opcode_str, arg_str);
1052   }
1053   /* WAIT : 0000 0000 0000 1011 : A-222 */
1054   else if ((op & 0xffff) == 0x000b)
1055   {
1056      size = dsp56k_dasm_wait(op, opcode_str, arg_str);
1057   }
1058   /* ZERO : 0001 0101 0101 F000 : A-224 */
1059   else if ((op & 0xfff7) == 0x1550)
1060   {
1061      size = dsp56k_dasm_zero(op, opcode_str, arg_str);
1062   }
1851063
186   /* Not recognized?  Nudge debugger onto the next opcode. */
187   if (size == 0)
1064
1065   /* Assemble opcode string buffer */
1066   if (size >= 1)
1881067   {
1068      pad_string(11, opcode_str);
1069      sprintf(buffer, "%s%s", opcode_str, arg_str);
1070   }
1071   /* Not recognized?  Nudge debugger onto the next word */
1072   else if (size == 0)
1073   {
1891074      sprintf(buffer, "unknown");
1901075      size = 1;
1911076   }
1921077
193   return size | DASMFLAG_SUPPORTED;
1078   return (size | DASMFLAG_SUPPORTED);
1941079}
1951080
196static unsigned assemble_x_memory_data_move_ALU_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
197{
198   /* All operations are of length 1 */
199   unsigned opSize = 1;
2001081
201   /* Recovered strings */
202   char arg_str[128] = "";
203   char opcode_str[128] = "";
204   char parallel_move_str[128] = "";
205   char d_register[128] = "";
1082/*******************************/
1083/* 32 Parallel move operations */
1084/*******************************/
2061085
207   /* Init */
208   sprintf(buffer, " ");
1086/* ADD : 011m mKKK 0rru Fuuu : A-22 */
1087static size_t dsp56k_dasm_add_2(const UINT16 op_byte, char* opcode_str, char* arg_str)
1088{
1089   /* TODO: How strange.  Same as SUB?  Investigate */
1090   char D[32];
1091   char S1[32];
1092   char arg[32];
1093   decode_uuuuF_table(BITS(op_byte,0x17), BITS(op_byte,0x08), arg, S1, D);
1094   sprintf(opcode_str, "%s", arg);
1095   sprintf(arg_str, "%s,%s", S1, D);
1096   return 1;
1097}
2091098
210   /* First, decode the Data ALU opcode */
211   decode_data_ALU_opcode(BITS(op,0x00ff), opcode_str, arg_str, d_register);
1099/* MAC : 011m mKKK 1xx0 F1QQ : A-122 */
1100static size_t dsp56k_dasm_mac_1(const UINT16 op_byte, char* opcode_str, char* arg_str)
1101{
1102   char D[32];
1103   char S1[32];
1104   char S2[32];
1105   /* Oddly, these 4 mpxx ops have identical operand ordering as compared to single memory move equivalents */
1106   decode_QQF_table(BITS(op_byte,0x03), BITS(op_byte,0x08), S1, S2, D);
1107   sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1108   sprintf(opcode_str, "mac");
1109   return 1;
1110}
2121111
213   /* Next, decode the X Memory Data Move */
214   decode_x_memory_data_move(BITS(op,0xff00), parallel_move_str);
1112/* MACR: 011m mKKK 1--1 F1QQ : A-124 */
1113static size_t dsp56k_dasm_macr_1(const UINT16 op_byte, char* opcode_str, char* arg_str)
1114{
1115   char D[32];
1116   char S1[32];
1117   char S2[32];
1118   /* Oddly, these 4 mpxx ops have identical operand ordering as compared to single memory move equivalents */
1119   decode_QQF_table(BITS(op_byte,0x03), BITS(op_byte,0x08), S1, S2, D);
1120   sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1121   sprintf(opcode_str, "macr");
1122   return 1;
1123}
2151124
216   /* Finally, assemble the full opcode */
217   pad_string(11, opcode_str);
218   pad_string(15, arg_str);
219   sprintf(buffer, "%s%s%s", opcode_str, arg_str, parallel_move_str);
1125/* MOVE : 011m mKKK 0rr1 0000 : A-128 */
1126static size_t dsp56k_dasm_move_1(const UINT16 op_byte, char* opcode_str, char* arg_str)
1127{
1128   /* TODO: This MOVE opcode is .identical. to the TFR one.  Investigate */
1129   char D[32];
1130   char S1[32];
1131   decode_DDF_table(BITS(op_byte,0x03), BITS(op_byte,0x08), S1, D);
1132   sprintf(opcode_str, "tfr");
1133   sprintf(arg_str, "%s,%s", S1, D);
1134   return 1;
1135}
2201136
221   return opSize;
1137/* MPY : 011m mKKK 1xx0 F0QQ : A-160 */
1138static size_t dsp56k_dasm_mpy_1(const UINT16 op_byte, char* opcode_str, char* arg_str)
1139{
1140   char D[32];
1141   char S1[32];
1142   char S2[32];
1143   /* Oddly, these 4 mpxx ops have identical operand ordering as compared to single memory move equivalents */
1144   decode_QQF_table(BITS(op_byte,0x03), BITS(op_byte,0x08), S1, S2, D);
1145   sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1146   sprintf(opcode_str, "mpy");
1147   return 1;
2221148}
2231149
224static unsigned assemble_dual_x_memory_data_read_ALU_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
1150/* MPYR : 011m mKKK 1--1 F0QQ : A-162 */
1151static size_t dsp56k_dasm_mpyr_1(const UINT16 op_byte, char* opcode_str, char* arg_str)
2251152{
226   /* All operations are of length 1 */
227   unsigned opSize = 1;
1153   char D[32];
1154   char S1[32];
1155   char S2[32];
1156   /* Oddly, these 4 mpxx ops have identical operand ordering as compared to single memory move equivalents */
1157   decode_QQF_table(BITS(op_byte,0x03), BITS(op_byte,0x08), S1, S2, D);
1158   sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1159   sprintf(opcode_str, "mpyr");
1160   return 1;
1161}
2281162
229   /* Recovered strings */
230   char arg_str[128] = "";
231   char opcode_str[128] = "";
232   char parallel_move_str[128] = "";
233   char parallel_move_str2[128] = "";
1163/* SUB : 011m mKKK 0rru Fuuu : A-202 */
1164static size_t dsp56k_dasm_sub_1(const UINT16 op_byte, char* opcode_str, char* arg_str)
1165{
1166   /* TODO - overlap with ADD (up above) */
1167   char D[32];
1168   char S1[32];
1169   char arg[32];
1170   decode_uuuuF_table(BITS(op_byte,0x17), BITS(op_byte,0x08), arg, S1, D);
1171   sprintf(opcode_str, "%s", arg);
1172   sprintf(arg_str, "%s,%s", S1, D);
1173   return 1;
1174}
2341175
235   /* Init */
236   sprintf(buffer, " ");
1176/* TFR : 011m mKKK 0rr1 F0DD : A-212 */
1177static size_t dsp56k_dasm_tfr_2(const UINT16 op_byte, char* opcode_str, char* arg_str)
1178{
1179   /* TODO - Same as move above. Investigate */
1180   char D[32];
1181   char S1[32];
1182   decode_DDF_table(BITS(op_byte,0x03), BITS(op_byte,0x08), S1, D);
1183   sprintf(opcode_str, "tfr");
1184   sprintf(arg_str, "%s,%s", S1, D);
1185   return 1;
1186}
2371187
238   /* First, decode the Data ALU opcode */
239   decode_data_ALU_opcode_dual_move(BITS(op,0x00ff), opcode_str, arg_str);
1188/* MPY : 0001 0110 RRDD FQQQ : A-160 */
1189static size_t dsp56k_dasm_mpy_2(const UINT16 op_byte, char* opcode_str, char* arg_str)
1190{
1191/*  TODO
1192    // MPY - 0001 0110 RRDD FQQQ
1193    decode_k_table(BITS(op,0x0100), Dnot);
1194    Rnum = decode_RR_table(BITS(op,0x00c0));
1195    decode_DD_table(BITS(op,0x0030), S);
1196    decode_QQQF_table(BITS(op,0x0007), BITS(op,0x0008), S1, S2, D);
1197    sprintf(buffer, "mpy       %s,%s,%s %s,(R%d)+N%d %s,%s", S1, S2, D, Dnot, Rnum, Rnum, S, Dnot);
1198    // Strange, but not entirely out of the question - this 'k' parameter is hardcoded
1199    // I cheat here and do the parallel memory data move above - this specific one is only used twice
1200    retSize = 1;
1201*/
1202   return 0;
1203}
2401204
241   /* Next, decode the Dual X Memory Data Read */
242   decode_dual_x_memory_data_read(op, parallel_move_str, parallel_move_str2);
1205/* MAC : 0001 0111 RRDD FQQQ : A-122 */
1206static size_t dsp56k_dasm_mac_2(const UINT16 op_byte, char* opcode_str, char* arg_str)
1207{
1208/*  TODO
1209    // MAC - 0001 0111 RRDD FQQQ
1210    decode_k_table(BITS(op,0x0100), Dnot);
1211    Rnum = decode_RR_table(BITS(op,0x00c0));
1212    decode_DD_table(BITS(op,0x0030), S);
1213    decode_QQQF_table(BITS(op,0x0007), BITS(op,0x0008), S1, S2, D);
1214    sprintf(buffer, "mac       %s,%s,%s %s,(R%d)+N%d %s,%s", S1, S2, D, Dnot, Rnum, Rnum, S, Dnot);
1215    // Strange, but not entirely out of the question - this 'k' parameter is hardcoded
1216    // I cheat here and do the parallel memory data move above - this specific one is only used twice
1217    retSize = 1;
1218*/
1219   return 0;
1220}
2431221
244   /* Finally, assemble the full opcode */
245   pad_string(11, opcode_str);
246   pad_string(15, arg_str);
247   sprintf(buffer, "%s%s%s %s", opcode_str, arg_str, parallel_move_str, parallel_move_str2);
1222/* CLR : .... .... 0000 F001 : A-60 */
1223static size_t dsp56k_dasm_clr(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1224{
1225   char D[32];
1226   decode_F_table(BITS(op_byte,0x08), D);
1227   sprintf(opcode_str, "clr");
1228   sprintf(arg_str, "%s", D);
1229   sprintf(d_register, "%s", D);
1230   return 1;
1231}
2481232
249   return opSize;
1233/* ADD : .... .... 0000 FJJJ : A-22 */
1234static size_t dsp56k_dasm_add(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1235{
1236   char D[32];
1237   char S1[32];
1238   decode_JJJF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, D);
1239   sprintf(opcode_str, "add");
1240   sprintf(arg_str, "%s,%s", S1, D);
1241   sprintf(d_register, "%s", D);
1242   return 1;
2501243}
2511244
252static unsigned assemble_no_parallel_move_ALU_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
1245/* MOVE : .... .... 0001 0001 : A-128 */
1246static size_t dsp56k_dasm_move(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
2531247{
254   /* All operations are of length 1 */
255   unsigned opSize = 1;
1248   /* Equivalent to a NOP (+ parallel move) */
1249   sprintf(opcode_str, "move");
1250   sprintf(arg_str, " ");
1251   sprintf(d_register, " ");
1252   return 1;
1253}
2561254
257   /* Recovered strings */
258   char arg_str[128] = "";
259   char opcode_str[128] = "";
260   char d_register[128] = "";
1255/* TFR : .... .... 0001 FJJJ : A-212 */
1256static size_t dsp56k_dasm_tfr(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1257{
1258   char D[32];
1259   char S1[32];
1260   decode_JJJF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, D);
1261   sprintf(opcode_str, "tfr");
1262   sprintf(arg_str, "%s,%s", S1, D);
1263   sprintf(d_register, "%s", D);
1264   return 1;
1265}
2611266
262   /* Init */
263   sprintf(buffer, " ");
1267/* RND : .... .... 0010 F000 : A-188 */
1268static size_t dsp56k_dasm_rnd(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1269{
1270   char D[32];
1271   decode_F_table(BITS(op_byte,0x08), D);
1272   sprintf(opcode_str, "rnd");
1273   sprintf(arg_str, "%s", D);
1274   sprintf(d_register, "%s", D);
1275   return 1;
1276}
2641277
265   /* First, decode the Data ALU opcode */
266   decode_data_ALU_opcode(BITS(op,0x00ff), opcode_str, arg_str, d_register);
1278/* TST : .... .... 0010 F001 : A-218 */
1279static size_t dsp56k_dasm_tst(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1280{
1281   char D[32];
1282   decode_F_table(BITS(op_byte,0x08), D);
1283   sprintf(opcode_str, "tst");
1284   sprintf(arg_str, "%s", D);
1285   sprintf(d_register, "%s", D);
1286   return 1;
1287}
2671288
268   /* Finally, assemble the full opcode */
269   pad_string(11, opcode_str);
270   sprintf(buffer, "%s%s", opcode_str, arg_str);
1289/* INC : .... .... 0010 F010 : A-104 */
1290static size_t dsp56k_dasm_inc(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1291{
1292   char D[32];
1293   decode_F_table(BITS(op_byte,0x08), D);
1294   sprintf(opcode_str, "inc");
1295   sprintf(arg_str, "%s", D);
1296   sprintf(d_register, "%s", D);
1297   return 1;
1298}
2711299
272   return opSize;
1300/* INC24 : .... .... 0010 F011 : A-106 */
1301static size_t dsp56k_dasm_inc24(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1302{
1303   char D[32];
1304   decode_F_table(BITS(op_byte,0x08), D);
1305   sprintf(opcode_str, "inc24");
1306   sprintf(arg_str, "%s", D);
1307   sprintf(d_register, "%s", D);
1308   return 1;
2731309}
2741310
275static unsigned assemble_parallel_register_to_register_moveALU_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
1311/* OR : .... .... 0010 F1JJ : A-176 */
1312static size_t dsp56k_dasm_or(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
2761313{
277   /* All operations are of length 1 */
278   unsigned opSize = 1;
1314   char D[32];
1315   char S1[32];
1316   decode_JJF_table(BITS(op_byte,0x03),BITS(op_byte,0x08), S1, D);
1317   sprintf(opcode_str, "or");
1318   sprintf(arg_str, "%s,%s", S1, D);
1319   sprintf(d_register, "%s", D);
1320   return 1;
1321}
2791322
280   /* Recovered strings */
281   char arg_str[128] = "";
282   char opcode_str[128] = "";
283   char d_register[128] = "";
284   char parallel_move_str[128] = "";
1323/* ASR : .... .... 0011 F000 : A-32 */
1324static size_t dsp56k_dasm_asr(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1325{
1326   char D[32];
1327   decode_F_table(BITS(op_byte,0x08), D);
1328   sprintf(opcode_str, "asr");
1329   sprintf(arg_str, "%s", D);
1330   sprintf(d_register, "%s", D);
1331   return 1;
1332}
2851333
286   /* Init */
287   sprintf(buffer, " ");
1334/* ASL : .... .... 0011 F001 : A-28 */
1335static size_t dsp56k_dasm_asl(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1336{
1337   char D[32];
1338   decode_F_table(BITS(op_byte,0x08), D);
1339   sprintf(opcode_str, "asl");
1340   sprintf(arg_str, "%s", D);
1341   sprintf(d_register, "%s", D);
1342   return 1;
1343}
2881344
289   /* First, decode the Data ALU opcode */
290   decode_data_ALU_opcode(BITS(op,0x00ff), opcode_str, arg_str, d_register);
1345/* LSR : .... .... 0011 F010 : A-120 */
1346static size_t dsp56k_dasm_lsr(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1347{
1348   char D[32];
1349   decode_F_table(BITS(op_byte,0x08), D);
1350   sprintf(opcode_str, "lsr");
1351   sprintf(arg_str, "%s", D);
1352   sprintf(d_register, "%s", D);
1353   return 1;
1354}
2911355
292   /* Next, decode the X Memory Data Move */
293   decode_register_to_register_data_move(BITS(op,0xff00), parallel_move_str, d_register);
1356/* LSL : .... .... 0011 F011 : A-118 */
1357static size_t dsp56k_dasm_lsl(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1358{
1359   char D[32];
1360   decode_F_table(BITS(op_byte,0x08), D);
1361   sprintf(opcode_str, "lsl");
1362   sprintf(arg_str, "%s", D);
1363   sprintf(d_register, "%s", D);
1364   return 1;
1365}
2941366
295   /* Finally, assemble the full opcode */
296   pad_string(11, opcode_str);
297   pad_string(15, arg_str);
298   sprintf(buffer, "%s%s%s", opcode_str, arg_str, parallel_move_str);
299
300   return opSize;
1367/* EOR : .... .... 0011 F1JJ : A-94 */
1368static size_t dsp56k_dasm_eor(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1369{
1370   char D[32];
1371   char S1[32];
1372   decode_JJF_table(BITS(op_byte,0x03),BITS(op_byte,0x08), S1, D);
1373   sprintf(opcode_str, "eor");
1374   sprintf(arg_str, "%s,%s", S1, D);
1375   sprintf(d_register, "%s", D);
1376   return 1;
3011377}
3021378
303static unsigned assemble_coorperative_x_memory_data_move_ALU_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
1379/* SUBL : .... .... 0100 F001 : A-204 */
1380static size_t dsp56k_dasm_subl(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
3041381{
305   /* All operations are of length 1 */
306   unsigned opSize = 1;
1382   sprintf(opcode_str, "subl");
3071383
308   /* Recovered strings */
309   char arg_str[128] = "";
310   char opcode_str[128] = "";
311   char parallel_move_str[128] = "";
312   char d_register[128] = "";
1384   /* Only one option for the F table */
1385   if (!BITS(op_byte,0x08))
1386   {
1387      sprintf(arg_str, "B,A");
1388      sprintf(d_register, "A");
1389   }
1390   else
1391   {
1392      sprintf(arg_str, "!");
1393   }
3131394
314   /* Init */
315   sprintf(buffer, " ");
1395   return 1;
1396}
3161397
317   /* First, decode the Data ALU opcode */
318   decode_data_ALU_opcode(BITS(op,0x00ff), opcode_str, arg_str, d_register);
1398/* SUB : .... .... 0100 FJJJ : A-202 */
1399static size_t dsp56k_dasm_sub(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1400{
1401   char D[32];
1402   char S1[32];
1403   decode_JJJF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, D);
1404   sprintf(opcode_str, "sub");
1405   sprintf(arg_str, "%s,%s", S1, D);
1406   sprintf(d_register, "%s", D);
1407   return 1;
1408}
3191409
320   /* Next, decode the X Memory Data Move */
321   decode_parallel_cooperative_x_memory_data_move(BITS(op,0xff00), parallel_move_str, d_register);
1410/* CLR24 : .... .... 0101 F001 : A-62 */
1411static size_t dsp56k_dasm_clr2(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1412{
1413   char D[32];
1414   decode_F_table(BITS(op_byte,0x08), D);
1415   sprintf(opcode_str, "clr24");
1416   sprintf(arg_str, "%s", D);
1417   sprintf(d_register, "%s", D);
1418   return 1;
1419}
3221420
323   /* Finally, assemble the full opcode */
324   pad_string(11, opcode_str);
325   pad_string(15, arg_str);
326   sprintf(buffer, "%s%s%s", opcode_str, arg_str, parallel_move_str);
1421/* SBC : .... .... 0101 F01J : A-198 */
1422static size_t dsp56k_dasm_sbc(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1423{
1424   char D[32];
1425   char S1[32];
1426   decode_JF_table(BITS(op_byte,0x01), BITS(op_byte,0x08), S1, D);
1427   sprintf(opcode_str, "sbc");
1428   sprintf(arg_str, "%s,%s", S1, D);
1429   sprintf(d_register, "%s", D);
1430   return 1;
1431}
3271432
328   return opSize;
1433/* CMP : .... .... 0101 FJJJ : A-64 */
1434static size_t dsp56k_dasm_cmp(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1435{
1436   char D[32];
1437   char S1[32];
1438   decode_JJJF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, D);
1439   /* TODO: This is a JJJF limited */
1440   sprintf(opcode_str, "cmp");
1441   sprintf(arg_str, "%s,%s", S1,D);
1442   sprintf(d_register, "%s", D);
1443   return 1;
3291444}
3301445
331static unsigned assemble_TCC_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
1446/* NEG : .... .... 0110 F000 : A-166 */
1447static size_t dsp56k_dasm_neg(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
3321448{
333   /* TCC is of length 1 */
334   unsigned opSize = 1;
1449   char D[32];
1450   decode_F_table(BITS(op_byte,0x08), D);
1451   sprintf(opcode_str, "neg");
1452   sprintf(arg_str, "%s", D);
1453   sprintf(d_register, "%s", D);
1454   return 1;
1455}
3351456
336   /* Recovered strings */
337   char arg_str[128] = "";
338   char opcode_str[128] = "";
1457/* NOT : .... .... 0110 F001 : A-174 */
1458static size_t dsp56k_dasm_not(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1459{
1460   char D[32];
1461   decode_F_table(BITS(op_byte,0x08), D);
1462   sprintf(opcode_str, "not");
1463   sprintf(arg_str, "%s", D);
1464   sprintf(d_register, "%s", D);
1465   return 1;
1466}
3391467
340   /* Init */
341   sprintf(buffer, " ");
1468/* DEC : .... .... 0110 F010 : A-72 */
1469static size_t dsp56k_dasm_dec(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1470{
1471   char D[32];
1472   decode_F_table(BITS(op_byte,0x08), D);
1473   sprintf(opcode_str, "dec");
1474   sprintf(arg_str, "%s", D);
1475   sprintf(d_register, "%s", D);
1476   return 1;
1477}
3421478
343   /* Simply decode the opcode and its arguments */
344   opSize = decode_TCC_opcode(op, opcode_str, arg_str);
1479/* DEC24 : .... .... 0110 F011 : A-74 */
1480static size_t dsp56k_dasm_dec24(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1481{
1482   char D[32];
1483   decode_F_table(BITS(op_byte,0x08), D);
1484   sprintf(opcode_str, "dec24");
1485   sprintf(arg_str, "%s", D);
1486   sprintf(d_register, "%s", D);
1487   return 1;
1488}
3451489
346   /* Finally, assemble the full opcode */
347   pad_string(11, opcode_str);
348   sprintf(buffer, "%s%s", opcode_str, arg_str);
349
350   return opSize;
1490/* AND : .... .... 0110 F1JJ : A-24 */
1491static size_t dsp56k_dasm_and(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1492{
1493   char D[32];
1494   char S1[32];
1495   decode_JJF_table(BITS(op_byte,0x03),BITS(op_byte,0x08), S1, D);
1496   sprintf(opcode_str, "and");
1497   sprintf(arg_str, "%s,%s", S1, D);
1498   sprintf(d_register, "%s", D);
1499   return 1;
3511500}
3521501
353static unsigned assemble_bitfield_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
1502/* ABS : .... .... 0111 F001 : A-18 */
1503static size_t dsp56k_dasm_abs(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
3541504{
355   /* All bitfield ops are length 2 */
356   unsigned opSize = 2;
357
358   /* Recovered strings */
359   char arg_str[128] = "";
360   char opcode_str[128] = "";
361
362   /* Init */
363   sprintf(buffer, " ");
364
365   /* Simply decode the opcode and its arguments */
366   opSize = decode_bitfield_opcode(op, op2, opcode_str, arg_str);
367
368   /* Finally, assemble the full opcode */
369   pad_string(11, opcode_str);
370   sprintf(buffer, "%s%s", opcode_str, arg_str);
371
372   return opSize;
1505   char D[32];
1506   decode_F_table(BITS(op_byte,0x08), D);
1507   sprintf(opcode_str, "abs");
1508   sprintf(arg_str, "%s", D);
1509   sprintf(d_register, "%s", D);
1510   return 1;
3731511}
3741512
375static unsigned assemble_no_parallel_move_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
1513/* ROR : .... .... 0111 F010 : A-192 */
1514static size_t dsp56k_dasm_ror(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
3761515{
377   /* Length is variable */
378   unsigned opSize = 0;
379
380   /* Recovered strings */
381   char arg_str[128] = "";
382   char opcode_str[128] = "";
383
384   /* Init */
385   sprintf(buffer, " ");
386
387   /* Simply decode the opcode and its arguments */
388   opSize = decode_no_parallel_move_opcode(op, op2, pc, opcode_str, arg_str);
389
390   /* Finally, assemble the full opcode */
391   pad_string(11, opcode_str);
392   sprintf(buffer, "%s%s", opcode_str, arg_str);
393
394   return opSize;
1516   char D[32];
1517   decode_F_table(BITS(op_byte,0x08), D);
1518   sprintf(opcode_str, "ror");
1519   sprintf(arg_str, "%s", D);
1520   sprintf(d_register, "%s", D);
1521   return 1;
3951522}
3961523
397static unsigned assemble_immediate_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
1524/* ROL : .... .... 0111 F011 : A-190 */
1525static size_t dsp56k_dasm_rol(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
3981526{
399   /* Length is variable */
400   unsigned opSize = 0;
401
402   /* Recovered strings */
403   char arg_str[128] = "";
404   char opcode_str[128] = "";
405
406   /* Init */
407   sprintf(buffer, " ");
408
409   /* Decode the 4 opcode and their arguments */
410   opSize = decode_immediate_opcode(op, pc, opcode_str, arg_str);
411
412   /* Finally, assemble the full opcode */
413   pad_string(11, opcode_str);
414   sprintf(buffer, "%s%s", opcode_str, arg_str);
415
416   return opSize;
1527   char D[32];
1528   decode_F_table(BITS(op_byte,0x08), D);
1529   sprintf(opcode_str, "rol");
1530   sprintf(arg_str, "%s", D);
1531   sprintf(d_register, "%s", D);
1532   return 1;
4171533}
4181534
419static unsigned assemble_movec_opcodes(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
1535/* CMPM : .... .... 0111 FJJJ : A-66 */
1536static size_t dsp56k_dasm_cmpm(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
4201537{
421   /* Length is variable */
422   unsigned opSize = 0;
423
424   /* Recovered strings */
425   char arg_str[128] = "";
426   char opcode_str[128] = "";
427
428   /* Init */
429   sprintf(buffer, " ");
430
431   /* Simply decode the opcode and its arguments */
432   opSize = decode_movec_opcodes(op, op2, pc, opcode_str, arg_str);
433
434   /* Finally, assemble the full opcode */
435   pad_string(11, opcode_str);
436   sprintf(buffer, "%s%s", opcode_str, arg_str);
437
438   return opSize;
1538   char D[32];
1539   char S1[32];
1540   decode_JJJF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, D);
1541   /* TODO: This is JJJF limited */
1542   sprintf(opcode_str, "cmpm");
1543   sprintf(arg_str, "%s,%s", S1,D);
1544   sprintf(d_register, "%s", D);
1545   return 1;
4391546}
4401547
441static unsigned assemble_misc_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
1548/* MPY : .... .... 1k00 FQQQ : A-160    -- CONFIRMED TYPO IN DOCS (HHHH vs HHHW) */
1549static size_t dsp56k_dasm_mpy(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
4421550{
443   /* Length is variable */
444   unsigned opSize = 0;
445
446   /* Recovered strings */
447   char arg_str[128] = "";
448   char opcode_str[128] = "";
449
450   /* Init */
451   sprintf(buffer, " ");
452
453   /* Simply decode the opcode and its arguments */
454   opSize = decode_misc_opcode(op, pc, opcode_str, arg_str);
455
456   /* Finally, assemble the full opcode */
457   pad_string(11, opcode_str);
458   sprintf(buffer, "%s%s", opcode_str, arg_str);
459
460   return opSize;
1551   char D[32];
1552   char S1[32];
1553   char S2[32];
1554   char SIGN[32];
1555   decode_QQQF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, S2, D);
1556   decode_kSign_table(BITS(op_byte,0x40), SIGN);
1557   sprintf(opcode_str, "mpy");
1558   sprintf(arg_str, "(%s)%s,%s,%s", SIGN, S2, S1, D);
1559   sprintf(d_register, "%s", D);
1560   return 1;
4611561}
4621562
463/* Working except for a TODO */
464static unsigned assemble_unique_opcode(char* buffer, const UINT16 op, const UINT16 op2, const unsigned pc)
1563/* MPYR : .... .... 1k01 FQQQ : A-162 */
1564static size_t dsp56k_dasm_mpyr(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
4651565{
466   /* Length is variable */
467   unsigned opSize = 0;
468
469   /* Recovered strings */
470   char arg_str[128] = "";
471   char opcode_str[128] = "";
472
473   /* Init */
474   sprintf(buffer, " ");
475
476   /* Simply decode the opcode and its arguments */
477   opSize = decode_unique_opcode(op, op2, pc, opcode_str, arg_str);
478
479   /* Finally, assemble the full opcode */
480   pad_string(11, opcode_str);
481   sprintf(buffer, "%s%s", opcode_str, arg_str);
482
483   return opSize;
1566   char D[32];
1567   char S1[32];
1568   char S2[32];
1569   char SIGN[32];
1570   decode_QQQF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, S2, D);
1571   decode_kSign_table(BITS(op_byte,0x40), SIGN);
1572   sprintf(opcode_str, "mpyr");
1573   sprintf(arg_str, "(%s)%s,%s,%s", SIGN, S2, S1, D);
1574   sprintf(d_register, "%s", D);
1575   return 1;
4841576}
4851577
486
487/**************************/
488/* Actual opcode decoding */
489/**************************/
490static void decode_data_ALU_opcode(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1578/* MAC : .... .... 1k10 FQQQ : A-122 */
1579static size_t dsp56k_dasm_mac(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
4911580{
492   char D[128];
493   char S1[128];
494
495   if (!BITS(op_byte, 0x80))
496   {
497      switch(BITS(op_byte,0x70))
498      {
499         case 0x0:
500            if (BITS(op_byte,0x07) == 0x1)
501            {
502               /* CLR - 1mRR HHHW 0000 F001 */
503               decode_F_table(BITS(op_byte,0x08), D);
504               sprintf(opcode_str, "clr");
505               sprintf(arg_str, "%s", D);
506            }
507            else
508            {
509               /* ADD - 1mRR HHHW 0000 FJJJ */
510               decode_JJJF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, D);
511               sprintf(opcode_str, "add");
512               sprintf(arg_str, "%s,%s", S1, D);
513            }
514            break;
515
516         case 0x1:
517            if (BITS(op_byte,0x0f) == 0x1)
518            {
519               /* MOVE - 1mRR HHHW 0001 0001 */
520               /* Equivalent to a NOP (+ parallel move) */
521               sprintf(opcode_str, "move");
522               sprintf(arg_str, " ");
523            }
524            else
525            {
526               /* TFR - 1mRR HHHW 0001 FJJJ */
527               decode_JJJF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, D);
528               sprintf(opcode_str, "tfr");
529               sprintf(arg_str, "%s,%s", S1, D);
530            }
531            break;
532
533         case 0x2:
534            if (BITS(op_byte,0x07) == 0x0)
535            {
536               /* RND - 1mRR HHHW 0010 F000 */
537               decode_F_table(BITS(op_byte,0x08), D);
538               sprintf(opcode_str, "rnd");
539               sprintf(arg_str, "%s", D);
540            }
541            else if (BITS(op_byte,0x07) == 0x1)
542            {
543               /* TST - 1mRR HHHW 0010 F001 */
544                  decode_F_table(BITS(op_byte,0x08), D);
545               sprintf(opcode_str, "tst");
546               sprintf(arg_str, "%s", D);
547            }
548            else if (BITS(op_byte,0x07) == 0x2)
549            {
550               /* INC - 1mRR HHHW 0010 F010 */
551               decode_F_table(BITS(op_byte,0x08), D);
552               sprintf(opcode_str, "inc");
553               sprintf(arg_str, "%s", D);
554            }
555            else if (BITS(op_byte,0x07) == 0x3)
556            {
557               /* INC24 - 1mRR HHHW 0010 F011 */
558               decode_F_table(BITS(op_byte,0x08), D);
559               sprintf(opcode_str, "inc24");
560               sprintf(arg_str, "%s", D);
561            }
562            else
563            {
564               /* OR - 1mRR HHHW 0010 F1JJ */
565               decode_JJF_table(BITS(op_byte,0x03),BITS(op_byte,0x08), S1, D);
566               sprintf(opcode_str, "or");
567               sprintf(arg_str, "%s,%s", S1, D);
568            }
569            break;
570
571         case 0x3:
572            if (BITS(op_byte,0x07) == 0x0)
573            {
574               /* ASR - 1mRR HHHW 0011 F000 */
575               decode_F_table(BITS(op_byte,0x08), D);
576               sprintf(opcode_str, "asr");
577               sprintf(arg_str, "%s", D);
578            }
579            else if (BITS(op_byte,0x07) == 0x1)
580            {
581                   /* ASL - 1mRR HHHW 0011 F001 */
582                   decode_F_table(BITS(op_byte,0x08), D);
583               sprintf(opcode_str, "asl");
584               sprintf(arg_str, "%s", D);
585            }
586            else if (BITS(op_byte,0x07) == 0x2)
587            {
588               /* LSR - 1mRR HHHW 0011 F010 */
589               decode_F_table(BITS(op_byte,0x08), D);
590               sprintf(opcode_str, "lsr");
591               sprintf(arg_str, "%s", D);
592            }
593            else if (BITS(op_byte,0x07) == 0x3)
594            {
595                   /* LSL - 1mRR HHHW 0011 F011 */
596                   decode_F_table(BITS(op_byte,0x08), D);
597               sprintf(opcode_str, "lsl");
598               sprintf(arg_str, "%s", D);
599            }
600            else
601            {
602               /* EOR - 1mRR HHHW 0011 F1JJ */
603               decode_JJF_table(BITS(op_byte,0x03),BITS(op_byte,0x08), S1, D);
604               sprintf(opcode_str, "eor");
605               sprintf(arg_str, "%s,%s", S1, D);
606            }
607            break;
608
609         case 0x4:
610            if (BITS(op_byte,0x07) == 0x1)
611            {
612               /* SUBL - 1mRR HHHW 0100 F001 */
613               sprintf(opcode_str, "subl");
614
615               /* Only one option for the F table */
616               if (!BITS(op_byte,0x08))
617                  sprintf(arg_str, "B,A");
618               else
619                  sprintf(arg_str, "!");
620            }
621            else
622            {
623               /* SUB - 1mRR HHHW 0100 FJJJ */
624               decode_JJJF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, D);
625               sprintf(opcode_str, "sub");
626               sprintf(arg_str, "%s,%s", S1, D);
627            }
628            break;
629
630         case 0x5:
631            if (BITS(op_byte,0x07) == 0x1)
632            {
633               /* CLR24 - 1mRR HHHW 0101 F001 */
634               decode_F_table(BITS(op_byte,0x08), D);
635               sprintf(opcode_str, "clr24");
636               sprintf(arg_str, "%s", D);
637            }
638            else if (BITS(op_byte,0x06) == 0x1)
639            {
640               /* SBC - 1mRR HHHW 0101 F01J */
641               decode_JF_table(BITS(op_byte,0x01), BITS(op_byte,0x08), S1, D);
642               sprintf(opcode_str, "sbc");
643               sprintf(arg_str, "%s,%s", S1, D);
644            }
645            else
646            {
647               /* CMP - 1mRR HHHW 0101 FJJJ */
648               decode_JJJF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, D);
649               /* TODO: This is a JJJF limited */
650               sprintf(opcode_str, "cmp");
651               sprintf(arg_str, "%s,%s", S1,D);
652            }
653            break;
654
655         case 0x6:
656            if (BITS(op_byte,0x07) == 0x0)
657            {
658               /* NEG - 1mRR HHHW 0110 F000 */
659               decode_F_table(BITS(op_byte,0x08), D);
660               sprintf(opcode_str, "neg");
661               sprintf(arg_str, "%s", D);
662            }
663            else if (BITS(op_byte,0x07) == 0x1)
664            {
665               /* NOT - 1mRR HHHW 0110 F001 */
666               decode_F_table(BITS(op_byte,0x08), D);
667               sprintf(opcode_str, "not");
668               sprintf(arg_str, "%s", D);
669            }
670            else if (BITS(op_byte,0x07) == 0x2)
671            {
672               /* DEC - 1mRR HHHW 0110 F010 */
673               decode_F_table(BITS(op_byte,0x08), D);
674               sprintf(opcode_str, "dec");
675               sprintf(arg_str, "%s", D);
676            }
677            else if (BITS(op_byte,0x07) == 0x3)
678            {
679               /* DEC24 - 1mRR HHHW 0110 F011 */
680               decode_F_table(BITS(op_byte,0x08), D);
681               sprintf(opcode_str, "dec24");
682               sprintf(arg_str, "%s", D);
683            }
684            else
685            {
686               /* AND - 1mRR HHHW 0110 F1JJ */
687               decode_JJF_table(BITS(op_byte,0x03),BITS(op_byte,0x08), S1, D);
688               sprintf(opcode_str, "and");
689               sprintf(arg_str, "%s,%s", S1, D);
690            }
691            break;
692
693         case 0x7:
694            if (BITS(op_byte,0x07) == 0x1)
695            {
696               /* ABS - 1mRR HHHW 0111 F001 */
697               decode_F_table(BITS(op_byte,0x08), D);
698               sprintf(opcode_str, "abs");
699               sprintf(arg_str, "%s", D);
700            }
701            else if (BITS(op_byte,0x07) == 0x2)
702            {
703               /* ROR - 1mRR HHHW 0111 F010 */
704               decode_F_table(BITS(op_byte,0x08), D);
705               sprintf(opcode_str, "ror");
706               sprintf(arg_str, "%s", D);
707            }
708            else if (BITS(op_byte,0x07) == 0x3)
709            {
710               /* ROL - 1mRR HHHW 0111 F011 */
711               decode_F_table(BITS(op_byte,0x08), D);
712               sprintf(opcode_str, "rol");
713               sprintf(arg_str, "%s", D);
714            }
715            else
716            {
717               /* CMPM - 1mRR HHHW 0111 FJJJ */
718               decode_JJJF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, D);
719               /* TODO: This is JJJF limited */
720               sprintf(opcode_str, "cmpm");
721               sprintf(arg_str, "%s,%s", S1,D);
722            }
723            break;
724      }
725   }
726   else
727   {
728      char S2[128];
729      char SIGN[128];
730
731        decode_QQQF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, S2, D);
732        decode_kSign_table(BITS(op_byte,0x40), SIGN);
733
734        switch(BITS(op_byte,0x30))
735        {
736         /* MPY - 1mRR HHHH 1k00 FQQQ */
737            case 0x0:
738            sprintf(opcode_str, "mpy");
739            sprintf(arg_str, "(%s)%s,%s,%s", SIGN, S2, S1, D);
740            break;
741
742            /* MPYR - 1mRR HHHH 1k01 FQQQ */
743            case 0x1:
744            sprintf(opcode_str, "mpyr");
745            sprintf(arg_str, "(%s)%s,%s,%s", SIGN, S2, S1, D);
746            break;
747
748            /* MAC - 1mRR HHHH 1k10 FQQQ */
749            case 0x2:
750            sprintf(opcode_str, "mac");
751            sprintf(arg_str, "(%s)%s,%s,%s", SIGN, S2, S1, D);
752            break;
753
754            /* MACR - 1mRR HHHH 1k11 FQQQ */
755            case 0x3:
756            sprintf(opcode_str, "macr");
757               /* TODO: It's a little odd that macr is S1,S2 while everyone else is S2,S1.  Check! */
758            sprintf(arg_str, "(%s)%s,%s,%s", SIGN, S1, S2, D);
759            break;
760        }
761   }
762
763   /* For the cooperative x data memory move */
1581   char D[32];
1582   char S1[32];
1583   char S2[32];
1584   char SIGN[32];
1585   decode_QQQF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, S2, D);
1586   decode_kSign_table(BITS(op_byte,0x40), SIGN);
1587   sprintf(opcode_str, "mac");
1588   sprintf(arg_str, "(%s)%s,%s,%s", SIGN, S2, S1, D);
7641589   sprintf(d_register, "%s", D);
1590   return 1;
7651591}
7661592
767/* TODO: Triple-check these.  There's weirdness around TFR & MOVE */
768static void decode_data_ALU_opcode_dual_move(const UINT16 op_byte, char* opcode_str, char* arg_str)
1593/* MACR : .... .... 1k11 FQQQ : A-124   -- DRAMA - rr vs xx (805) */
1594static size_t dsp56k_dasm_macr(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
7691595{
7701596   char D[32];
7711597   char S1[32];
7721598   char S2[32];
773   char arg[32];
1599   char SIGN[32];
1600   decode_QQQF_table(BITS(op_byte,0x07), BITS(op_byte,0x08), S1, S2, D);
1601   decode_kSign_table(BITS(op_byte,0x40), SIGN);
1602   sprintf(opcode_str, "macr");
1603   /* TODO: It's a little odd that macr is S1,S2 while everyone else (mac, mpy, mpyr) is S2,S1.  Check! */
1604   sprintf(arg_str, "(%s)%s,%s,%s", SIGN, S1, S2, D);
1605   sprintf(d_register, "%s", D);
1606   return 1;
1607}
7741608
775   if (!BITS(op_byte,0x80))
776   {
777      if (BITS(op_byte,0x14) != 0x2)
778      {
779         /* ADD - 011m mKKK 0rru Fuuu */
780         /* SUB - 011m mKKK 0rru Fuuu */
781         /* These two opcodes are conflated */
782         decode_uuuuF_table(BITS(op_byte,0x17), BITS(op_byte,0x08), arg, S1, D);
783         sprintf(opcode_str, "%s", arg);
784         sprintf(arg_str, "%s,%s", S1, D);
785      }
786      else if (BITS(op_byte,0x14) == 0x2)
787      {
788         /* TFR - 011m mKKK 0rr1 F0DD */
789         /* MOVE - 011m mKKK 0rr1 0000 */
790         /* TODO: This MOVE opcode is .identical. to the TFR one.  Investigate. */
791         decode_DDF_table(BITS(op_byte,0x03), BITS(op_byte,0x08), S1, D);
792         sprintf(opcode_str, "tfr");
793         sprintf(arg_str, "%s,%s", S1, D);
794      }
795   }
796   else
797   {
798      decode_QQF_table(BITS(op_byte,0x03), BITS(op_byte,0x08), S1, S2, D);
799      sprintf(arg_str, "%s,%s,%s", S1, S2, D);   /* Oddly, these 4 have identical operand ordering as */
800                                       /* compared to single memory move equivalents */
801      switch (BITS(op_byte,0x14))
802      {
803         case 0x0:
804            /* MPY - 011m mKKK 1rr0 F0QQ */
805            sprintf(opcode_str, "mpy");
806            break;
8071609
808         case 0x1:
809            /* MAC - 011m mKKK 1rr0 F1QQ */
810            sprintf(opcode_str, "mac");
811            break;
1610/******************************/
1611/* Remaining non-parallel ops */
1612/******************************/
8121613
813         case 0x2:
814            /* MPYR - 011m mKKK 1rr1 F0QQ */
815            sprintf(opcode_str, "mpyr");
816            break;
1614/* ADC : 0001 0101 0000 F01J : A-20 */
1615static size_t dsp56k_dasm_adc(const UINT16 op, char* opcode_str, char* arg_str)
1616{
1617   char D[32];
1618   char S1[32];
1619   decode_JF_table(BITS(op,0x0001), BITS(op,0x0008), S1, D);
1620   sprintf(opcode_str, "adc");
1621   sprintf(arg_str, "%s,%s", S1, D);
1622   return 1;
1623}
8171624
818         case 0x3:
819            /* MACR - 011m mKKK 1rr1 F1QQ */
820            sprintf(opcode_str, "macr");
821            break;
822      }
823   }
1625/* ANDI : 0001 1EE0 iiii iiii : A-26 */
1626static size_t dsp56k_dasm_andi(const UINT16 op, char* opcode_str, char* arg_str)
1627{
1628   char D[32];
1629   decode_EE_table(BITS(op,0x0600), D);
1630   sprintf(opcode_str, "and(i)");
1631   sprintf(arg_str, "#%02x,%s", BITS(op,0x00ff), D);
1632   return 1;
8241633}
8251634
826static unsigned decode_TCC_opcode(const UINT16 op, char* opcode_str, char* arg_str)
1635/* ASL4 : 0001 0101 0011 F001 : A-30 */
1636static size_t dsp56k_dasm_asl4(const UINT16 op, char* opcode_str, char* arg_str)
8271637{
828   int Rnum = -1;
829   char M[32];
8301638   char D[32];
831   char S[32];
1639   decode_F_table(BITS(op,0x0008), D);
1640   sprintf(opcode_str, "asl4");
1641   sprintf(arg_str, "%s", D);
1642   return 1;
1643}
8321644
833   decode_cccc_table(BITS(op,0x03c0), M);
834   sprintf(opcode_str, "t.%s", M);
1645/* ASR4 : 0001 0101 0011 F000 : A-34 */
1646static size_t dsp56k_dasm_asr4(const UINT16 op, char* opcode_str, char* arg_str)
1647{
1648   char D[32];
1649   decode_F_table(BITS(op,0x0008), D);
1650   sprintf(opcode_str, "asr4");
1651   sprintf(arg_str, "%s", D);
1652   return 1;
1653}
8351654
836   Rnum = decode_RR_table(BITS(op,0x0030));
837   decode_h0hF_table(BITS(op,0x0007),BITS(op,0x0008), S, D);
838   sprintf(arg_str, "%s,%s  R0,R%d", S, D, Rnum);
839
840   /* TODO: Investigate
841    if (S1[0] == D[0] && D[0] == 'A')
842        sprintf(buffer, "t.%s  %s,%s", M, S1, D);
843    else
844        sprintf(buffer, "t.%s  %s,%s  R0,R%d", M, S1, D, Rnum);
845    */
846
1655/* ASR16 : 0001 0101 0111 F000 : A-36 */
1656static size_t dsp56k_dasm_asr16(const UINT16 op, char* opcode_str, char* arg_str)
1657{
1658   char D[32];
1659   decode_F_table(BITS(op,0x0008), D);
1660   sprintf(opcode_str, "asr16");
1661   sprintf(arg_str, "%s", D);
8471662   return 1;
8481663}
8491664
850/* TODO: Check all (dual-world) */
851static unsigned decode_bitfield_opcode(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
1665/* BFCHG  : 0001 0100 11Pp pppp BBB1 0010 iiii iiii : A-38 */
1666/* BFCHG  : 0001 0100 101- --RR BBB1 0010 iiii iiii : A-38 */
1667/* BFCHG  : 0001 0100 100D DDDD BBB1 0010 iiii iiii : A-38 */
1668/* BFCLR  : 0001 0100 11Pp pppp BBB0 0100 iiii iiii : A-40 */
1669/* BFCLR  : 0001 0100 101- --RR BBB0 0100 iiii iiii : A-40 */
1670/* BFCLR  : 0001 0100 100D DDDD BBB0 0100 iiii iiii : A-40 */
1671/* BFSET  : 0001 0100 11Pp pppp BBB1 1000 iiii iiii : A-42 */
1672/* BFSET  : 0001 0100 101- --RR BBB1 1000 iiii iiii : A-42 */
1673/* BFSET  : 0001 0100 100D DDDD BBB1 1000 iiii iiii : A-42 */
1674/* BFTSTH : 0001 0100 01Pp pppp BBB1 0000 iiii iiii : A-44 */
1675/* BFTSTH : 0001 0100 001- --RR BBB1 0000 iiii iiii : A-44 */
1676/* BFTSTH : 0001 0100 000D DDDD BBB1 0000 iiii iiii : A-44 */
1677/* BFTSTL : 0001 0100 01Pp pppp BBB0 0000 iiii iiii : A-46 */
1678/* BFTSTL : 0001 0100 001- --RR BBB0 0000 iiii iiii : A-46 */
1679/* BFTSTL : 0001 0100 000D DDDD BBB0 0000 iiii iiii : A-46 */
1680static size_t dsp56k_dasm_bfop(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
8521681{
8531682   char D[32];
8541683   int upperMiddleLower = -1;
r3333r3334
8951724   return 2;
8961725}
8971726
898static unsigned decode_no_parallel_move_opcode(const UINT16 op, const UINT16 op2, const UINT16 pc, char* opcode_str, char* arg_str)
1727/* Bcc : 0000 0111 --11 cccc xxxx xxxx xxxx xxxx : A-48 */
1728static size_t dsp56k_dasm_bcc(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc)
8991729{
900   unsigned retSize = 1;
1730   char M[32];
1731   decode_cccc_table(BITS(op,0x000f), M);
1732   sprintf(opcode_str, "b.%s", M);
1733   sprintf(arg_str, "%d (0x%04x)", (INT16)op2, pc + 2 + (INT16)op2);
1734   return 2;
1735}
9011736
902   int Rnum = -1;
903   char A[32];
904   char D[32];
905   char S1[32];
906   char S2[32];
1737/* Bcc : 0010 11cc ccee eeee : A-48 */
1738static size_t dsp56k_dasm_bcc_1(const UINT16 op, char* opcode_str, char* arg_str, const offs_t pc)
1739{
1740   char M[32];
1741   INT8 relativeInt;
1742   decode_cccc_table(BITS(op,0x3c0), M);
1743   relativeInt = get_6_bit_signed_value(BITS(op,0x003f));
1744   sprintf(opcode_str, "b.%s", M);
1745   sprintf(arg_str, "%d (0x%04x)", relativeInt, pc + 1 + relativeInt);
1746   return 1;
1747}
9071748
908   switch(BITS(op,0x0074))
909   {
910      case 0x0:
911         if (BITS(op,0x0006) == 0x0)
912         {
913            /* TFR(2) - 0001 0101 0000 F00J */
914            decode_JF_table(BITS(op,0x0001),BITS(op,0x0008), D, S1);
915            sprintf(opcode_str, "tfr2");
916            sprintf(arg_str, "%s,%s", S1, D);
917         }
918         else if (BITS(op,0x0006) == 0x1)
919         {
920            /* ADC - 0001 0101 0000 F01J */
921            decode_JF_table(BITS(op,0x0001),BITS(op,0x0008), S1, D);
922            sprintf(opcode_str, "adc");
923            sprintf(arg_str, "%s,%s", S1, D);
924         }
925         break;
1749/* Bcc : 0000 0111 RR10 cccc : A-48 */
1750static size_t dsp56k_dasm_bcc_2(const UINT16 op, char* opcode_str, char* arg_str)
1751{
1752   int Rnum;
1753   char M[32];
1754   decode_cccc_table(BITS(op,0x000f), M);
1755   Rnum = decode_RR_table(BITS(op,0x00c0));
1756   sprintf(opcode_str, "b.%s", M);
1757   sprintf(arg_str, "R%d", Rnum);
1758   return 1;
1759}
9261760
927      case 0x3:
928         /* TST(2) - 0001 0101 0001 -1DD */
929         decode_DD_table(BITS(op,0x0003), S1);
930         sprintf(opcode_str, "tst2");
931         sprintf(arg_str, "%s", S1);
932         break;
1761/* BRA : 0000 0001 0011 11-- xxxx xxxx xxxx xxxx : A-50 */
1762static size_t dsp56k_dasm_bra(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc)
1763{
1764   sprintf(opcode_str, "bra");
1765   sprintf(arg_str, "%d (0x%04x)", (INT16)op2, pc + 2 + op2);
1766   return 2;
1767}
9331768
934      case 0x4:
935         /* NORM - 0001 0101 0010 F0RR */
936         decode_F_table(BITS(op,0x0008), D);
937         Rnum = decode_RR_table(BITS(op,0x0003));
938         sprintf(opcode_str, "norm");
939         sprintf(arg_str, "R%d,%s", Rnum, D);
940         break;
1769/* BRA : 0000 1011 aaaa aaaa : A-50 */
1770static size_t dsp56k_dasm_bra_1(const UINT16 op, char* opcode_str, char* arg_str, const offs_t pc)
1771{
1772   sprintf(opcode_str, "bra");
1773   sprintf(arg_str, "%d (0x%02x)", (INT8)BITS(op,0x00ff), pc + 1 + (INT8)BITS(op,0x00ff));
1774   return 1;
1775}
9411776
942      case 0x6:
943         if (BITS(op,0x0003) == 0x0)
944         {
945            /* ASR4 - 0001 0101 0011 F000 */
946            decode_F_table(BITS(op,0x0008), D);
947            sprintf(opcode_str, "asr4");
948            sprintf(arg_str, "%s", D);
949         }
950         else if (BITS(op,0x0003) == 0x1)
951         {
952            /* ASL4 - 0001 0101 0011 F001 */
953            decode_F_table(BITS(op,0x0008), D);
954            sprintf(opcode_str, "asl4");
955            sprintf(arg_str, "%s", D);
956         }
957         break;
1777/* BRA : 0000 0001 0010 11RR : A-50 */
1778static size_t dsp56k_dasm_bra_2(const UINT16 op, char* opcode_str, char* arg_str)
1779{
1780   int Rnum;
1781   Rnum = decode_RR_table(BITS(op,0x0003));
1782   sprintf(opcode_str, "bra");
1783   sprintf(arg_str, "R%d", Rnum);
1784   return 1;
1785}
9581786
959      case 0x1: case 0x5: case 0x9: case 0xd:
960         /* DIV - 0001 0101 0--0 F1DD */
961         decode_DDF_table(BITS(op,0x0003), BITS(op,0x0008), S1, D);
962         sprintf(opcode_str, "div");
963         sprintf(arg_str, "%s,%s", S1, D);
964         break;
1787/* BRKc : 0000 0001 0001 cccc : A-52 */
1788static size_t dsp56k_dasm_brkc(const UINT16 op, char* opcode_str, char* arg_str)
1789{
1790   char M[32];
1791   decode_cccc_table(BITS(op,0x000f), M);
1792   sprintf(opcode_str, "brk.%s", M);
1793   sprintf(arg_str, " ");
1794   return 1;
1795}
9651796
966      case 0xa:
967         if (BITS(op,0x0003) == 0x0)
968         {
969            /* ZERO - 0001 0101 0101 F000 */
970            decode_F_table(BITS(op,0x0008), D);
971            sprintf(opcode_str, "zero");
972            sprintf(arg_str, "%s", D);
973         }
974         else if (BITS(op,0x0003) == 0x2)
975         {
976            /* EXT - 0001 0101 0101 F010 */
977            decode_F_table(BITS(op,0x0008), D);
978            sprintf(opcode_str, "ext");
979            sprintf(arg_str, "%s", D);
980         }
981         break;
1797/* BScc : 0000 0111 --01 cccc xxxx xxxx xxxx xxxx : A-54 */
1798static size_t dsp56k_dasm_bscc(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc)
1799{
1800   char M[32];
1801   decode_cccc_table(BITS(op,0x000f), M);
1802   sprintf(opcode_str, "bs.%s", M);
1803   sprintf(arg_str, "%d (0x%04x)", (INT16)op2, pc + 2 + (INT16)op2);
1804   return (2 | DASMFLAG_STEP_OVER);   /* probably */
1805}
9821806
983      case 0xc:
984         if (BITS(op,0x0003) == 0x0)
985         {
986            /* NEGC - 0001 0101 0110 F000 */
987            decode_F_table(BITS(op,0x0008), D);
988            sprintf(opcode_str, "negc");
989            sprintf(arg_str, "%s", D);
990         }
991         break;
1807/* BScc: 0000 0111 RR00 cccc : A-54 */
1808static size_t dsp56k_dasm_bscc_1(const UINT16 op, char* opcode_str, char* arg_str)
1809{
1810   int Rnum;
1811   char M[32];
1812   decode_cccc_table(BITS(op,0x000f), M);
1813   Rnum = decode_RR_table(BITS(op,0x00c0));
1814   sprintf(opcode_str, "bs.%s", M);
1815   sprintf(arg_str, "R%d", Rnum);
1816   return (1 | DASMFLAG_STEP_OVER);   /* probably.  What's the diff between a branch and a jump? */
1817}
9921818
993      case 0xe:
994         if (BITS(op,0x0003) == 0x0)
995         {
996            /* ASR16 - 0001 0101 0111 F000 */
997            decode_F_table(BITS(op,0x0008), D);
998            sprintf(opcode_str, "asr16");
999            sprintf(arg_str, "%s", D);
1000         }
1001         else if (BITS(op,0x0003) == 0x1)
1002         {
1003            /* SWAP - 0001 0101 0111 F001 */
1004            decode_F_table(BITS(op,0x0008), D);
1005            sprintf(opcode_str, "swap");
1006            sprintf(arg_str, "%s", D);
1007         }
1008         break;
1009   }
1819/* BSR : 0000 0001 0011 10-- xxxx xxxx xxxx xxxx : A-56 */
1820static size_t dsp56k_dasm_bsr(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc)
1821{
1822   sprintf(opcode_str, "bsr");
1823   sprintf(arg_str, "%d (0x%04x)", (INT16)op2, pc + 2 + (INT16)op2);
1824   return (2 | DASMFLAG_STEP_OVER);
1825}
10101826
1011   switch(BITS(op,0x00f0))
1012   {
1013      case 0x8:
1014         /* IMPY - 0001 0101 1000 FQQQ */
1015         decode_QQQF_table(BITS(op,0x0007), BITS(op,0x0008), S1, S2, D);
1016         sprintf(opcode_str, "impy");
1017         sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1018         break;
1019      case 0xa:
1020         /* IMAC - 0001 0101 1010 FQQQ */
1021         decode_QQQF_table(BITS(op,0x0007), BITS(op,0x0008), S1, S2, D);
1022         sprintf(opcode_str, "imac");
1023         sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1024         break;
1025      case 0x9: case 0xb:
1026         /* DMAC(ss,su,uu) - 0001 0101 10s1 FsQQ */
1027         decode_ss_table(BITS(op,0x0024), A);
1028         decode_QQF_special_table(BITS(op,0x0003), BITS(op,0x0008), S1, S2, D);     /* Special QQF */
1029         sprintf(opcode_str, "dmac(%s)", A);
1030         sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1031         break;
1032      case 0xc:
1033         /* MPY(su,uu) - 0001 0101 1100 FsQQ */
1034         decode_s_table(BITS(op,0x0004), A);
1035         decode_QQF_special_table(BITS(op,0x0003), BITS(op,0x0008), S1, S2, D);     /* Special QQF */
1036         sprintf(opcode_str, "mpy(%s)", A);
1037         sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1038         break;
1039      case 0xe:
1040         /* MAC(su,uu) - 0001 0101 1110 FsQQ */
1041         decode_s_table(BITS(op,0x0004), A);
1042         decode_QQF_special_table(BITS(op,0x0003), BITS(op,0x0008), S1, S2, D);      /* Special QQF */
1043         sprintf(opcode_str, "mac(%s)", A);
1044         sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1045         break;
1046   }
1827/* BSR : 0000 0001 0010 10RR : A-56 */
1828static size_t dsp56k_dasm_bsr_1(const UINT16 op, char* opcode_str, char* arg_str)
1829{
1830   int Rnum;
1831   Rnum = decode_RR_table(BITS(op,0x0003));
1832   sprintf(opcode_str, "bsr");
1833   sprintf(arg_str, "R%d", Rnum);
1834   return (1 | DASMFLAG_STEP_OVER);
1835}
10471836
1048   return retSize;
1837/* CHKAAU : 0000 0000 0000 0100 : A-58 */
1838static size_t dsp56k_dasm_chkaau(const UINT16 op, char* opcode_str, char* arg_str)
1839{
1840   sprintf(opcode_str, "chkaau");
1841   sprintf(arg_str, " ");
1842   return 1;
10491843}
10501844
1051static unsigned decode_immediate_opcode(const UINT16 op, const UINT16 pc, char* opcode_str, char* arg_str)
1845/* DEBUG : 0000 0000 0000 0001 : A-68 */
1846static size_t dsp56k_dasm_debug(const UINT16 op, char* opcode_str, char* arg_str)
10521847{
1053   unsigned retSize = 1;
1848   sprintf(opcode_str, "debug");
1849   sprintf(arg_str, " ");
1850   return 1;
1851}
10541852
1055   if (BITS(op,0x0600))
1056   {
1057      if (!BITS(op,0x0100))
1058      {
1059         /* ANDI - 0001 1EE0 iiii iiii */
1060         char D[32];
1061         decode_EE_table(BITS(op,0x0600), D);
1062         sprintf(opcode_str, "and(i)");
1063         sprintf(arg_str, "#%02x,%s", BITS(op,0x00ff), D);
1064      }
1065      else
1066      {
1067         /* ORI - 0001 1EE1 iiii iiii */
1068         char D[32];
1069            decode_EE_table(BITS(op,0x0600), D);
1070         sprintf(opcode_str, "or(i)");
1071         sprintf(arg_str, "#%02x,%s", BITS(op,0x00ff), D);
1072      }
1073   }
1074   else
1075   {
1076      if (!BITS(op,0x0020))
1077      {
1078         /* MOVE(S) - 0001 100W HH0a aaaa */
1079         char A[32];
1080         char SD[32];
1081         char args[32];
1082         decode_HH_table(BITS(op,0x00c0), SD);
1083         sprintf(A, "00%02x", BITS(op,0x001f));
1084         assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, A);
1085         sprintf(opcode_str, "move(s)");
1086         sprintf(arg_str, "%s", args);
1087      }
1088      else
1089      {
1090         /* MOVE(P) - 0001 100W HH1p pppp */
1091         char A[32];
1092         char SD[32];
1093         char args[32];
1094         char fullAddy[128];
1095         decode_HH_table(BITS(op,0x00c0), SD);
1096         assemble_address_from_IO_short_address(BITS(op,0x001f), fullAddy);   /* Convert Short Absolute Address to full 16-bit */
1097         sprintf(A, "%02x (%s)", BITS(op,0x001f), fullAddy);
1098         assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, A);
1099         sprintf(opcode_str, "move(p)");
1100         sprintf(arg_str, "%s", args);
1101      }
1102   }
1853/* DEBUGcc : 0000 0000 0101 cccc : A-70 */
1854static size_t dsp56k_dasm_debugcc(const UINT16 op, char* opcode_str, char* arg_str)
1855{
1856   char M[32];
1857   decode_cccc_table(BITS(op,0x000f), M);
1858   sprintf(opcode_str, "debug.%s", M);
1859   sprintf(arg_str, " ");
1860   return 1;
1861}
11031862
1104   return retSize;
1863/* DIV : 0001 0101 0--0 F1DD : A-76 */
1864/* WARNING : DOCS SAY THERE IS A PARALLEL MOVE HERE !!! */
1865static size_t dsp56k_dasm_div(const UINT16 op, char* opcode_str, char* arg_str)
1866{
1867   char D[32];
1868   char S1[32];
1869   decode_DDF_table(BITS(op,0x0003), BITS(op,0x0008), S1, D);
1870   sprintf(opcode_str, "div");
1871   sprintf(arg_str, "%s,%s", S1, D);
1872   return 1;
11051873}
11061874
1107static unsigned decode_movec_opcodes(const UINT16 op, const UINT16 op2, const UINT16 pc, char* opcode_str, char* arg_str)
1875/* DMAC : 0001 0101 10s1 FsQQ : A-80 */
1876static size_t dsp56k_dasm_dmac(const UINT16 op, char* opcode_str, char* arg_str)
11081877{
1109   unsigned retSize = 1;
1878   char A[32];
1879   char D[32];
1880   char S1[32];
1881   char S2[32];
1882   decode_ss_table(BITS(op,0x0024), A);
1883   decode_QQF_special_table(BITS(op,0x0003), BITS(op,0x0008), S1, S2, D);     /* Special QQF */
1884   sprintf(opcode_str, "dmac(%s)", A);
1885   sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1886   return 1;
1887}
11101888
1111   char SD[32];
1112   char ea[32];
1113   char args[64];
1114   int Rnum = -1;
1889/* DO : 0000 0000 110- --RR xxxx xxxx xxxx xxxx : A-82 */
1890static size_t dsp56k_dasm_do(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
1891{
1892   int Rnum;
1893   Rnum = decode_RR_table(BITS(op,0x0003));
1894   sprintf(opcode_str, "do");
1895   sprintf(arg_str, "X:(R%d),%02x", Rnum, op2);
1896   return 2;
1897}
11151898
1116   if (BITS(op,0x0010) == 0x0)
1117   {
1118      /* MOVE(C) - 0011 1WDD DDD0 MMRR */
1119      decode_DDDDD_table(BITS(op,0x03e0), SD);
1120      Rnum = decode_RR_table(BITS(op,0x0003));
1121      assemble_ea_from_MM_table(BITS(op,0x000c), Rnum, ea);
1122      assemble_arguments_from_W_table(BITS(op,0x0400), args, 'X', SD, ea);
1123      sprintf(opcode_str, "move(c)");
1124      sprintf(arg_str, "%s", args);
1125   }
1126   else
1127   {
1128      if (BITS(op,0x0004) == 0x0)
1129      {
1130         /* MOVE(C) - 0011 1WDD DDD1 q0RR */
1131         decode_DDDDD_table(BITS(op,0x03e0), SD);
1132         Rnum = decode_RR_table(BITS(op,0x0003));
1133         assemble_ea_from_q_table(BITS(op,0x0008), Rnum, ea);
1134         assemble_arguments_from_W_table(BITS(op,0x0400), args, 'X', SD, ea);
1135         sprintf(opcode_str, "move(c)");
1136         sprintf(arg_str, "%s", args);
1137      }
1138      else
1139      {
1140         switch(BITS(op,0x0006))
1141         {
1142            /* MOVE(C) - 0011 1WDD DDD1 t10- xxxx xxxx xxxx xxxx */
1143            case 0x2:
1144               decode_DDDDD_table(BITS(op,0x03e0), SD);
1145               assemble_ea_from_t_table(BITS(op,0x0008), op2, ea);
1146               /* !!! I'm pretty sure this is  in the right order - same issue as the WTables !!! */
1147               if (BITS(op,0x0400))                                    /* fixed - 02/03/05 */
1148                  sprintf(args, "%s,%s", ea, SD);
1149               else
1150                  sprintf(args, "%s,%s", SD, ea);
1151               sprintf(opcode_str, "move(c)");
1152               sprintf(arg_str, "%s", args);
1153               retSize = 2;
1154               break;
1899/* DO : 0000 1110 iiii iiii xxxx xxxx xxxx xxxx : A-82 */
1900static size_t dsp56k_dasm_do_1(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
1901{
1902   sprintf(opcode_str, "do");
1903   sprintf(arg_str, "#%02x,%04x", BITS(op,0x00ff), op2);
1904   return 2;
1905}
11551906
1156            /* MOVE(C) - 0011 1WDD DDD1 Z11- */
1157            case 0x3:
1158               decode_DDDDD_table(BITS(op,0x03e0), SD);
1159               decode_Z_table(BITS(op,0x0008), ea);
1160               assemble_arguments_from_W_table(BITS(op,0x0400), args, 'X', SD, ea);
1161               sprintf(opcode_str, "move(c)");
1162               sprintf(arg_str, "%s", args);
1163               break;
1164         }
1165      }
1166   }
1907/* DO : 0000 0100 000D DDDD xxxx xxxx xxxx xxxx : A-82 */
1908static size_t dsp56k_dasm_do_2(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
1909{
1910   char S1[32];
1911   decode_DDDDD_table(BITS(op,0x001f), S1);
1912   sprintf(opcode_str, "do");
1913   sprintf(arg_str, "%s,%04x", S1, op2);
1914   return 2;
1915}
11671916
1168   return retSize;
1917/* DO FOREVER : 0000 0000 0000 0010 xxxx xxxx xxxx xxxx : A-88 */
1918static size_t dsp56k_dasm_doforever(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
1919{
1920   sprintf(opcode_str, "doForever");
1921   sprintf(arg_str, "%04x", op2);
1922   return 2;
11691923}
11701924
1171static unsigned decode_misc_opcode(const UINT16 op, const UINT16 pc, char* opcode_str, char* arg_str)
1925/* ENDDO : 0000 0000 0000 1001 : A-92 */
1926static size_t dsp56k_dasm_enddo(const UINT16 op, char* opcode_str, char* arg_str)
11721927{
1173   unsigned retSize = 1;
1928   sprintf(opcode_str, "enddo");
1929   sprintf(arg_str, " ");
1930   return 1;
1931}
11741932
1175   char M[32];
1933/* EXT : 0001 0101 0101 F010 : A-96 */
1934static size_t dsp56k_dasm_ext(const UINT16 op, char* opcode_str, char* arg_str)
1935{
1936   char D[32];
1937   decode_F_table(BITS(op,0x0008), D);
1938   sprintf(opcode_str, "ext");
1939   sprintf(arg_str, "%s", D);
1940   return 1;
1941}
1942
1943/* ILLEGAL : 0000 0000 0000 1111 : A-98 */
1944static size_t dsp56k_dasm_illegal(const UINT16 op, char* opcode_str, char* arg_str)
1945{
1946   sprintf(opcode_str, "illegal");
1947   sprintf(arg_str, " ");
1948   return 1;
1949}
1950
1951/* IMAC : 0001 0101 1010 FQQQ : A-100 */
1952static size_t dsp56k_dasm_imac(const UINT16 op, char* opcode_str, char* arg_str)
1953{
1954   char D[32];
11761955   char S1[32];
1177   char SD[32];
1178   char D1[32];
1179   char ea[32];
1180   char args[64];
1181   int Rnum = -1;
1182   int relativeInt = 666;
1956   char S2[32];
1957   decode_QQQF_table(BITS(op,0x0007), BITS(op,0x0008), S1, S2, D);
1958   sprintf(opcode_str, "imac");
1959   sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1960   return 1;
1961}
11831962
1184   switch(BITS(op,0x0c00))
1185   {
1186      /* MOVE(I) - 0010 00DD BBBB BBBB */
1187      case 0x0:
1188         decode_DD_table(BITS(op,0x0300), D1);
1189         sprintf(opcode_str, "move(i)");
1190         sprintf(arg_str, "#%02x,%s", BITS(op,0x00ff), D1);
1191         break;
1963/* IMPY : 0001 0101 1000 FQQQ : A-102 */
1964static size_t dsp56k_dasm_impy(const UINT16 op, char* opcode_str, char* arg_str)
1965{
1966   char D[32];
1967   char S1[32];
1968   char S2[32];
1969   decode_QQQF_table(BITS(op,0x0007), BITS(op,0x0008), S1, S2, D);
1970   sprintf(opcode_str, "impy");
1971   sprintf(arg_str, "%s,%s,%s", S1, S2, D);
1972   return 1;
1973}
11921974
1193      /* TFR(3) - 0010 01mW RRDD FHHH */
1194      case 0x1:
1195            decode_DDF_table(BITS(op,0x0030), BITS(op,0x0008), D1, S1);          /* Intentionally switched */
1196         decode_HHH_table(BITS(op,0x0007), SD);
1197         Rnum = decode_RR_table(BITS(op,0x00c0));
1198         assemble_ea_from_m_table(BITS(op,0x0200), Rnum, ea);
1199         assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, ea);
1200         sprintf(opcode_str, "tfr3");
1201         sprintf(arg_str, "%s,%s %s", S1, D1, args);
1202         break;
1975/* Jcc : 0000 0110 --11 cccc xxxx xxxx xxxx xxxx : A-108 */
1976static size_t dsp56k_dasm_jcc(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
1977{
1978   char M[32];
1979   decode_cccc_table(BITS(op,0x000f), M);
1980   sprintf(opcode_str, "j.%s", M);
1981   sprintf(arg_str, "%04x", op2);
1982   return 2;
1983}
12031984
1204      /* MOVE(C) - 0010 10dd dddD DDDD */
1205      case 0x2:
1206         decode_DDDDD_table(BITS(op,0x03e0), S1);
1207         decode_DDDDD_table(BITS(op,0x001f), D1);
1208         sprintf(opcode_str, "move(c)");
1209         sprintf(arg_str, "%s,%s", S1, D1);
1210         break;
1985/* Jcc : 0000 0110 RR10 cccc : A-108 */
1986static size_t dsp56k_dasm_jcc_1(const UINT16 op, char* opcode_str, char* arg_str)
1987{
1988   int Rnum;
1989   char M[32];
1990   decode_cccc_table(BITS(op,0x000f), M);
1991   Rnum = decode_RR_table(BITS(op,0x00c0));
1992   sprintf(opcode_str, "j.%s", M);
1993   sprintf(arg_str, "R%d", Rnum);
1994   return 1;
1995}
12111996
1212      /* B.cc - 0010 11cc ccee eeee */
1213      case 0x3:
1214         decode_cccc_table(BITS(op,0x3c0), M);
1215         relativeInt = get_6_bit_relative_value(BITS(op,0x003f));
1216         sprintf(opcode_str, "b.%s", M);
1217         sprintf(arg_str, "%04x (%d)", (int)pc + relativeInt, relativeInt);
1218         break;
1219   }
1997/* JMP : 0000 0001 0011 01-- xxxx xxxx xxxx xxxx : A-110 */
1998static size_t dsp56k_dasm_jmp(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
1999{
2000   sprintf(opcode_str, "jmp");
2001   sprintf(arg_str, "%04x", op2);
2002   return 2;
2003}
12202004
1221   return retSize;
2005/* JMP : 0000 0001 0010 01RR : A-110 */
2006static size_t dsp56k_dasm_jmp_1(const UINT16 op, char* opcode_str, char* arg_str)
2007{
2008   int Rnum;
2009   Rnum = decode_RR_table(BITS(op,0x0003));
2010   sprintf(opcode_str, "jmp");
2011   sprintf(arg_str, "R%d", Rnum);
2012   return 1;
12222013}
12232014
1224/* TODO: Check all dual-word guys */
1225static unsigned decode_unique_opcode(const UINT16 op, const UINT16 op2, const UINT16 pc, char* opcode_str, char* arg_str)
2015/* JScc : 0000 0110 --01 cccc xxxx xxxx xxxx xxxx : A-112 */
2016static size_t dsp56k_dasm_jscc(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
12262017{
1227   unsigned retSize = 1;
2018   char M[32];
2019   decode_cccc_table(BITS(op,0x000f), M);
2020   sprintf(opcode_str, "js.%s", M);
2021   sprintf(arg_str, "%04x", op2);
2022   return (2 |DASMFLAG_STEP_OVER);   /* probably */
2023}
12282024
2025/* JScc : 0000 0110 RR00 cccc : A-112 */
2026static size_t dsp56k_dasm_jscc_1(const UINT16 op, char* opcode_str, char* arg_str)
2027{
2028   int Rnum;
2029   char M[32];
2030   decode_cccc_table(BITS(op,0x000f), M);
2031   Rnum = decode_RR_table(BITS(op,0x00c0));
2032   sprintf(opcode_str, "js.%s", M);
2033   sprintf(arg_str, "R%d", Rnum);
2034   return (1 | DASMFLAG_STEP_OVER);   /* probably.  What's the diff between a branch and a jump? */
2035}
2036
2037/* JSR : 0000 0001 0011 00-- xxxx xxxx xxxx xxxx : A-114 */
2038static size_t dsp56k_dasm_jsr(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
2039{
2040   sprintf(opcode_str, "jsr");
2041   sprintf(arg_str, "%04x", op2);
2042   return (2 | DASMFLAG_STEP_OVER);
2043}
2044
2045/* JSR : 0000 1010 AAAA AAAA : A-114 */
2046static size_t dsp56k_dasm_jsr_1(const UINT16 op, char* opcode_str, char* arg_str)
2047{
2048   sprintf(opcode_str, "jsr");
2049   sprintf(arg_str, "%d (0x%02x)", BITS(op,0x00ff), BITS(op,0x00ff));
2050   return (1 | DASMFLAG_STEP_OVER);
2051}
2052
2053/* JSR : 0000 0001 0010 00RR : A-114 */
2054static size_t dsp56k_dasm_jsr_2(const UINT16 op, char* opcode_str, char* arg_str)
2055{
2056   int Rnum;
2057   Rnum = decode_RR_table(BITS(op,0x0003));
2058   sprintf(opcode_str, "jsr");
2059   sprintf(arg_str, "R%d", Rnum);
2060   return (1 | DASMFLAG_STEP_OVER);
2061}
2062
2063/* LEA : 0000 0001 11TT MMRR : A-116 */
2064static size_t dsp56k_dasm_lea(const UINT16 op, char* opcode_str, char* arg_str)
2065{
2066   int Rnum;
2067   int Tnum;
12292068   char ea[32];
1230   char ea2[32];
2069   Tnum = decode_TT_table(BITS(op,0x0030));
2070   Rnum = decode_RR_table(BITS(op,0x0003));
2071   assemble_ea_from_MM_table(BITS(op,0x000c), Rnum, ea);
2072   sprintf(opcode_str, "lea");
2073   sprintf(arg_str, "%s,R%d", ea, Tnum);
2074   return 1;
2075}
2076
2077/* LEA : 0000 0001 10NN MMRR : A-116 */
2078static size_t dsp56k_dasm_lea_1(const UINT16 op, char* opcode_str, char* arg_str)
2079{
2080   int Nnum;
2081   int Rnum;
2082   char ea[32];
2083   Nnum = decode_NN_table(BITS(op,0x0030));
2084   Rnum = decode_RR_table(BITS(op,0x0003));
2085   assemble_ea_from_MM_table(BITS(op,0x000c), Rnum, ea);
2086   sprintf(opcode_str, "lea");
2087   sprintf(arg_str, "%s,N%d", ea, Nnum);
2088   return 1;
2089}
2090
2091/* MAC(su,uu) : 0001 0101 1110 FsQQ : A-126 */
2092static size_t dsp56k_dasm_macsuuu(const UINT16 op, char* opcode_str, char* arg_str)
2093{
2094   char A[32];
2095   char D[32];
12312096   char S1[32];
2097   char S2[32];
2098   decode_s_table(BITS(op,0x0004), A);
2099   decode_QQF_special_table(BITS(op,0x0003), BITS(op,0x0008), S1, S2, D);      /* Special QQF */
2100   sprintf(opcode_str, "mac(%s)", A);
2101   sprintf(arg_str, "%s,%s,%s", S1, S2, D);
2102   return 1;
2103}
2104
2105/* MOVE : 0000 0101 BBBB BBBB ---- HHHW 0001 0001 : A-128 */
2106static size_t dsp56k_dasm_move_2(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
2107{
2108   UINT8 B;
12322109   char SD[32];
12332110   char args[32];
2111   B = BITS(op,0x00ff);
2112   decode_HHH_table(BITS(op2,0x0e00), SD);
2113   assemble_reg_from_W_table(BITS(op2,0x0100), args, 'X', SD, B);
2114   sprintf(opcode_str, "move");
2115   sprintf(arg_str, "%s", args);
2116   return 2;
2117}
12342118
1235   if (BITS(op,0x0ff0) == 0x0)
1236   {
1237      switch (BITS(op,0x000f))
1238      {
1239         /* NOP - 0000 0000 0000 0000 */
1240         case 0x0:
1241            sprintf(opcode_str, "nop");
1242            sprintf(arg_str, " ");
1243            break;
2119/* MOVE(C) : 0011 1WDD DDD0 MMRR : A-144 */
2120static size_t dsp56k_dasm_movec(const UINT16 op, char* opcode_str, char* arg_str)
2121{
2122   int Rnum;
2123   char ea[32];
2124   char SD[32];
2125   char args[32];
2126   decode_DDDDD_table(BITS(op,0x03e0), SD);
2127   Rnum = decode_RR_table(BITS(op,0x0003));
2128   assemble_ea_from_MM_table(BITS(op,0x000c), Rnum, ea);
2129   assemble_arguments_from_W_table(BITS(op,0x0400), args, 'X', SD, ea);
2130   sprintf(opcode_str, "move(c)");
2131   sprintf(arg_str, "%s", args);
2132   return 1;
2133}
12442134
1245         /* Debug - 0000 0000 0000 0001 */
1246         case 0x1:
1247            sprintf(opcode_str, "debug");
1248            sprintf(arg_str, " ");
1249            break;
2135/* MOVE(C) : 0011 1WDD DDD1 q0RR : A-144 */
2136static size_t dsp56k_dasm_movec_1(const UINT16 op, char* opcode_str, char* arg_str)
2137{
2138   int Rnum;
2139   char ea[32];
2140   char SD[32];
2141   char args[32];
2142   decode_DDDDD_table(BITS(op,0x03e0), SD);
2143   Rnum = decode_RR_table(BITS(op,0x0003));
2144   assemble_ea_from_q_table(BITS(op,0x0008), Rnum, ea);
2145   assemble_arguments_from_W_table(BITS(op,0x0400), args, 'X', SD, ea);
2146   sprintf(opcode_str, "move(c)");
2147   sprintf(arg_str, "%s", args);
2148   return 1;
2149}
12502150
1251         /* DO FOREVER - 0000 0000 0000 0010 xxxx xxxx xxxx xxxx */
1252         case 0x2:
1253            sprintf(opcode_str, "doForever");
1254            sprintf(arg_str, "%04x", op2);
1255            retSize = 2;
1256            break;
2151/* MOVE(C) : 0011 1WDD DDD1 Z11- : A-144 */
2152static size_t dsp56k_dasm_movec_2(const UINT16 op, char* opcode_str, char* arg_str)
2153{
2154   char ea[32];
2155   char SD[32];
2156   char args[32];
2157   decode_DDDDD_table(BITS(op,0x03e0), SD);
2158   decode_Z_table(BITS(op,0x0008), ea);
2159   assemble_arguments_from_W_table(BITS(op,0x0400), args, 'X', SD, ea);
2160   sprintf(opcode_str, "move(c)");
2161   sprintf(arg_str, "%s", args);
2162   return 1;
2163}
12572164
1258         /* chkaau - 0000 0000 0000 0100 */
1259         case 0x4:
1260            sprintf(opcode_str, "chkaau");
1261            sprintf(arg_str, " ");
1262            break;
2165/* MOVE(C) : 0011 1WDD DDD1 t10- xxxx xxxx xxxx xxxx : A-144 */
2166static size_t dsp56k_dasm_movec_3(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
2167{
2168   char ea[32];
2169   char SD[32];
2170   char args[32];
2171   decode_DDDDD_table(BITS(op,0x03e0), SD);
2172   assemble_ea_from_t_table(BITS(op,0x0008), op2, ea);
2173   if (BITS(op,0x0400))                           /* order fixed - 02/03/05 */
2174      sprintf(args, "%s,%s", ea, SD);
2175   else
2176      sprintf(args, "%s,%s", SD, ea);
2177   sprintf(opcode_str, "move(c)");
2178   sprintf(arg_str, "%s", args);
2179   return 2;
2180}
12632181
1264         /* SWI - 0000 0000 0000 0101 */
1265         case 0x5:
1266            sprintf(opcode_str, "swi");
1267            sprintf(arg_str, " ");
1268            break;
2182/* MOVE(C) : 0010 10dd dddD DDDD : A-144 */
2183static size_t dsp56k_dasm_movec_4(const UINT16 op, char* opcode_str, char* arg_str)
2184{
2185   char D1[32];
2186   char S1[32];
2187   decode_DDDDD_table(BITS(op,0x03e0), S1);
2188   decode_DDDDD_table(BITS(op,0x001f), D1);
2189   sprintf(opcode_str, "move(c)");
2190   sprintf(arg_str, "%s,%s", S1, D1);
2191   return 1;
2192}
12692193
1270         /* RTS - 0000 0000 0000 0110 */
1271         case 0x6:
1272            sprintf(opcode_str, "rts");
1273            sprintf(arg_str, " ");
1274            retSize |= DASMFLAG_STEP_OUT;
1275            break;
2194/* MOVE(C) : 0000 0101 BBBB BBBB 0011 1WDD DDD0 ---- : A-144 */
2195static size_t dsp56k_dasm_movec_5(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
2196{
2197   UINT8 B;
2198   char SD[32];
2199   char args[32];
2200   B = BITS(op,0x00ff);
2201   decode_DDDDD_table(BITS(op2,0x03e0), SD);
2202   assemble_reg_from_W_table(BITS(op2,0x0400), args, 'X', SD, B);
2203   sprintf(opcode_str, "move(c)");
2204   sprintf(arg_str, "%s", args);
2205   return 2;
2206}
12762207
1277         /* RTI - 0000 0000 0000 0111 */
1278         case 0x7:
1279            sprintf(opcode_str, "rti");
1280            sprintf(arg_str, " ");
1281                retSize |= DASMFLAG_STEP_OUT;
1282            break;
2208/* MOVE(I) : 0010 00DD BBBB BBBB : A-150 */
2209static size_t dsp56k_dasm_movei(const UINT16 op, char* opcode_str, char* arg_str)
2210{
2211   char D1[32];
2212   decode_DD_table(BITS(op,0x0300), D1);
2213   sprintf(opcode_str, "move(i)");
2214   sprintf(arg_str, "#%02x,%s", BITS(op,0x00ff), D1);
2215   return 1;
2216}
12832217
1284         /* RESET - 0000 0000 0000 1000 */
1285         case 0x8:
1286            sprintf(opcode_str, "reset");
1287            sprintf(arg_str, " ");
1288            break;
2218/* MOVE(M) : 0000 001W RR0M MHHH : A-152 */
2219static size_t dsp56k_dasm_movem(const UINT16 op, char* opcode_str, char* arg_str)
2220{
2221   int Rnum;
2222   char ea[32];
2223   char SD[32];
2224   char args[32];
2225   Rnum = decode_RR_table(BITS(op,0x00c0));
2226   decode_HHH_table(BITS(op,0x0007), SD);
2227   assemble_ea_from_MM_table(BITS(op,0x0018), Rnum, ea);
2228   assemble_arguments_from_W_table(BITS(op,0x0100), args, 'P', SD, ea);
2229   sprintf(opcode_str, "move(m)");
2230   sprintf(arg_str, "%s", args);
2231   return 1;
2232}
12892233
1290         /* Enddo - 0000 0000 0000 1001 */
1291         case 0x9:
1292            sprintf(opcode_str, "enddo");
1293            sprintf(arg_str, " ");
1294            break;
2234/* MOVE(M) : 0000 001W RR11 mmRR : A-152 */
2235static size_t dsp56k_dasm_movem_1(const UINT16 op, char* opcode_str, char* arg_str)
2236{
2237   char ea[32];
2238   char SD[32];
2239   char ea2[32];
2240   char args[32];
2241   assemble_eas_from_m_table(BITS(op,0x000c), BITS(op,0x00c0), BITS(op,0x0003), ea, ea2);
2242   sprintf(SD, "P:%s", ea);
2243   assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, ea2);
2244   sprintf(opcode_str, "move(m)");
2245   sprintf(arg_str, "%s", args);
2246   return 1;
2247}
12952248
1296         /* STOP - 0000 0000 0000 1010 */
1297         case 0xa:
1298            sprintf(opcode_str, "stop");
1299            sprintf(arg_str, " ");
1300            break;
2249/* MOVE(M) : 0000 0101 BBBB BBBB 0000 001W --0- -HHH : A-152 */
2250static size_t dsp56k_dasm_movem_2(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str)
2251{
2252   UINT8 B;
2253   char SD[32];
2254   char args[32];
2255   B = BITS(op,0x00ff);
2256   decode_HHH_table(BITS(op2,0x0007), SD);
2257   assemble_reg_from_W_table(BITS(op2,0x0100), args, 'P', SD, B);
2258   sprintf(opcode_str, "move(m)");
2259   sprintf(arg_str, "%s", args);
2260   /* !!! The docs list the read/write order backwards for all move(m)'s - crackbabies ??? */
2261   return 2;
2262}
13012263
1302         /* WAIT - 0000 0000 0000 1011 */
1303         case 0xb:
1304            sprintf(opcode_str, "wait");
1305            sprintf(arg_str, " ");
1306            break;
2264/* MOVE(P) : 0001 100W HH1p pppp : A-156 */
2265static size_t dsp56k_dasm_movep(const UINT16 op, char* opcode_str, char* arg_str)
2266{
2267   char A[32];
2268   char SD[32];
2269   char args[32];
2270   char fullAddy[128];
2271   decode_HH_table(BITS(op,0x00c0), SD);
2272   assemble_address_from_IO_short_address(BITS(op,0x001f), fullAddy);   /* Convert Short Absolute Address to full 16-bit */
2273   sprintf(A, "%02x (%s)", BITS(op,0x001f), fullAddy);
2274   assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, A);
2275   sprintf(opcode_str, "move(p)");
2276   sprintf(arg_str, "%s", args);
2277   return 1;
2278}
13072279
1308         /* ILLEGAL - 0000 0000 0000 1111 */
1309         case 0xf:
1310            sprintf(opcode_str, "illegal");
1311            sprintf(arg_str, " ");
1312            break;
1313      }
1314   }
1315   else if (BITS(op,0x0f00) == 0x0)
1316   {
1317      int Rnum = -1;
1318      char M[32] = "";
2280/* MOVE(P) : 0000 110W RRmp pppp : A-156 */
2281static size_t dsp56k_dasm_movep_1(const UINT16 op, char* opcode_str, char* arg_str)
2282{
2283   int Rnum;
2284   char ea[32];
2285   char SD[32];
2286   char args[32];
2287   char fullAddy[128];      /* Convert Short Absolute Address to full 16-bit */
2288   Rnum = decode_RR_table(BITS(op,0x00c0));
2289   assemble_ea_from_m_table(BITS(op,0x0020), Rnum, ea);
2290   assemble_address_from_IO_short_address(BITS(op,0x001f), fullAddy);
2291   sprintf(SD, "X:%02x (%s)", BITS(op,0x001f), fullAddy);
2292   assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, ea);
2293   sprintf(opcode_str, "move(p)");
2294   sprintf(arg_str, "%s", args);
2295   return 1;
2296}
13192297
1320      switch(BITS(op,0x00e0))
1321      {
1322         case 0x2:
1323            /* DEBUG.cc - 0000 0000 0101 cccc */
1324            decode_cccc_table(BITS(op,0x000f), M);
1325            sprintf(opcode_str, "debug.%s", M);
1326            sprintf(arg_str, " ");
1327            break;
2298/* MOVE(S) : 0001 100W HH0a aaaa : A-158 */
2299static size_t dsp56k_dasm_moves(const UINT16 op, char* opcode_str, char* arg_str)
2300{
2301   char A[32];
2302   char SD[32];
2303   char args[32];
2304   decode_HH_table(BITS(op,0x00c0), SD);
2305   sprintf(A, "00%02x", BITS(op,0x001f));
2306   assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, A);
2307   sprintf(opcode_str, "move(s)");
2308   sprintf(arg_str, "%s", args);
2309   return 1;
2310}
13282311
1329         case 0x6:
1330            /* DO - 0000 0000 110- --RR xxxx xxxx xxxx xxxx */
1331            Rnum = decode_RR_table(BITS(op,0x0003));
1332            sprintf(opcode_str, "do");
1333            sprintf(arg_str, "X:(R%d),%02x", Rnum, op2);
1334                retSize = 2;
1335            break;
2312/* MPY(su,uu) : 0001 0101 1100 FsQQ : A-164 */
2313static size_t dsp56k_dasm_mpysuuu(const UINT16 op, char* opcode_str, char* arg_str)
2314{
2315   char A[32];
2316   char D[32];
2317   char S1[32];
2318   char S2[32];
2319   decode_s_table(BITS(op,0x0004), A);
2320   decode_QQF_special_table(BITS(op,0x0003), BITS(op,0x0008), S1, S2, D);     /* Special QQF */
2321   sprintf(opcode_str, "mpy(%s)", A);
2322   sprintf(arg_str, "%s,%s,%s", S1, S2, D);
2323   return 1;
2324}
13362325
1337         case 0x7:
1338            /* REP - 0000 0000 111- --RR */
1339            Rnum = decode_RR_table(BITS(op,0x0003));
1340            sprintf(opcode_str, "rep");
1341            sprintf(arg_str, "X:(R%d)", Rnum);
1342            break;
1343      }
1344   }
1345   else if (BITS(op,0x0f00) == 0x1)
1346   {
1347      char M[32] = "";
2326/* NEGC : 0001 0101 0110 F000 : A-168 */
2327static size_t dsp56k_dasm_negc(const UINT16 op, char* opcode_str, char* arg_str)
2328{
2329   char D[32];
2330   decode_F_table(BITS(op,0x0008), D);
2331   sprintf(opcode_str, "negc");
2332   sprintf(arg_str, "%s", D);
2333   return 1;
2334}
13482335
1349      if (BITS(op,0x00f0) == 0x1)
1350      {
1351         /* BRK.cc - 0000 0001 0001 cccc */
1352         decode_cccc_table(BITS(op,0x000f), M);
1353         sprintf(opcode_str, "brk.%s", M);
1354         sprintf(arg_str, " ");
1355      }
1356      else if (BITS(op,0x00f0) == 0x2)
1357      {
1358         /* All 4 instructions have the same RR encoding */
1359         int Rnum = decode_RR_table(BITS(op,0x0003));
2336/* NOP : 0000 0000 0000 0000 : A-170 */
2337static size_t dsp56k_dasm_nop(const UINT16 op, char* opcode_str, char* arg_str)
2338{
2339   sprintf(opcode_str, "nop");
2340   sprintf(arg_str, " ");
2341   return 1;
2342}
13602343
1361         switch(BITS(op,0x000c))
1362         {
1363            /* JSR - 0000 0001 0010 00RR */
1364            case 0x0:
1365                    sprintf(opcode_str, "jsr");
1366                    sprintf(arg_str, "R%d", Rnum);
1367                    retSize |= DASMFLAG_STEP_OVER;
1368               break;
2344/* NORM : 0001 0101 0010 F0RR : A-172 */
2345static size_t dsp56k_dasm_norm(const UINT16 op, char* opcode_str, char* arg_str)
2346{
2347   int Rnum;
2348   char D[32];
2349   decode_F_table(BITS(op,0x0008), D);
2350   Rnum = decode_RR_table(BITS(op,0x0003));
2351   sprintf(opcode_str, "norm");
2352   sprintf(arg_str, "R%d,%s", Rnum, D);
2353   return 1;
2354}
13692355
1370            /* JMP - 0000 0001 0010 01RR */
1371            case 0x1:
1372                    sprintf(opcode_str, "jmp");
1373                    sprintf(arg_str, "R%d", Rnum);
1374               break;
2356/* ORI : 0001 1EE1 iiii iiii : A-178 */
2357static size_t dsp56k_dasm_ori(const UINT16 op, char* opcode_str, char* arg_str)
2358{
2359   char D[32];
2360   decode_EE_table(BITS(op,0x0600), D);
2361   sprintf(opcode_str, "or(i)");
2362   sprintf(arg_str, "#%02x,%s", BITS(op,0x00ff), D);
2363   return 1;
2364}
13752365
1376            /* BSR - 0000 0001 0010 10RR */
1377            case 0x2:
1378                    sprintf(opcode_str, "bsr");
1379                    sprintf(arg_str, "R%d", Rnum);
1380                    retSize |= DASMFLAG_STEP_OVER;
1381               break;
2366/* REP : 0000 0000 111- --RR : A-180 */
2367static size_t dsp56k_dasm_rep(const UINT16 op, char* opcode_str, char* arg_str)
2368{
2369   int Rnum;
2370   Rnum = decode_RR_table(BITS(op,0x0003));
2371   sprintf(opcode_str, "rep");
2372   sprintf(arg_str, "X:(R%d)", Rnum);
2373   return 1;
2374}
13822375
1383            /* BRA - 0000 0001 0010 11RR */
1384            case 0x3:
1385                    sprintf(opcode_str, "bra");
1386                    sprintf(arg_str, "R%d", Rnum);
1387               break;
1388         }
1389      }
1390      else if (BITS(op,0x00f0) == 0x3)
1391      {
1392         switch(BITS(op,0x000c))
1393         {
1394            /* JSR - 0000 0001 0011 00-- xxxx xxxx xxxx xxxx */
1395            case 0x0:
1396               sprintf(opcode_str, "jsr");
1397               sprintf(arg_str, "%04x", op2);
1398               retSize = 2;
1399                    retSize |= DASMFLAG_STEP_OVER;
1400               break;
2376/* REP : 0000 1111 iiii iiii : A-180 */
2377static size_t dsp56k_dasm_rep_1(const UINT16 op, char* opcode_str, char* arg_str)
2378{
2379   sprintf(opcode_str, "rep");
2380   sprintf(arg_str, "%d (0x%02x)", BITS(op,0x00ff), BITS(op,0x00ff));
2381   return 1;
2382}
14012383
1402            /* JMP - 0000 0001 0011 01-- xxxx xxxx xxxx xxxx */
1403            case 0x1:
1404               sprintf(opcode_str, "jmp");
1405               sprintf(arg_str, "%04x", op2);
1406               retSize = 2;
1407               break;
2384/* REP : 0000 0100 001D DDDD : A-180 */
2385static size_t dsp56k_dasm_rep_2(const UINT16 op, char* opcode_str, char* arg_str)
2386{
2387   char S1[32];
2388   decode_DDDDD_table(BITS(op,0x001f), S1);
2389   sprintf(opcode_str, "rep");
2390   sprintf(arg_str, "%s", S1);
2391   return 1;
2392}
14082393
1409            /* BSR - 0000 0001 0011 10-- xxxx xxxx xxxx xxxx */
1410            case 0x2:
1411               sprintf(opcode_str, "bsr");
1412               sprintf(arg_str, "%d (0x%04x)", (INT16)op2, pc + (INT16)op2);
1413               retSize = 2;
1414               retSize |= DASMFLAG_STEP_OVER;
1415               break;
2394/* REPcc : 0000 0001 0101 cccc : A-184 */
2395static size_t dsp56k_dasm_repcc(const UINT16 op, char* opcode_str, char* arg_str)
2396{
2397   char M[32];
2398   decode_cccc_table(BITS(op,0x000f), M);
2399   sprintf(opcode_str, "rep.%s", M);
2400   sprintf(arg_str, " ");
2401   return 1;
2402}
14162403
1417            /* BRA - 0000 0001 0011 11-- xxxx xxxx xxxx xxxx */
1418            case 0x3:
1419               sprintf(opcode_str, "bra");
1420               sprintf(arg_str, "%d (0x%04x)", op2, op2);
1421                    retSize = 2;
1422               break;
1423         }
1424      }
1425      else if (BITS(op,0x00f0) == 0x5)
1426      {
1427         char M[32] = "";
2404/* RESET : 0000 0000 0000 1000 : A-186 */
2405static size_t dsp56k_dasm_reset(const UINT16 op, char* opcode_str, char* arg_str)
2406{
2407   sprintf(opcode_str, "reset");
2408   sprintf(arg_str, " ");
2409   return 1;
2410}
14282411
1429         /* REP.cc - 0000 0001 0101 cccc */
1430         decode_cccc_table(BITS(op,0x000f), M);
1431         sprintf(opcode_str, "rep.%s", M);
1432         sprintf(arg_str, " ");
1433         /* !!! Should I decode the next instruction and put it here ???  probably... */
1434      }
1435      else if (BITS(op,0x0080) == 0x1)
1436      {
1437         /* LEA - 0000 0001 10TT MMRR */
1438         /*     - 0000 0001 11NN MMRR */
1439         int Rnum = decode_RR_table(BITS(op,0x0030));
1440            assemble_ea_from_MM_table(BITS(op,0x000c), BITS(op,0x0003), ea);
1441         sprintf(opcode_str, "lea");
1442            if (BITS(op,0x0040))
1443            sprintf(arg_str, "%s,R%d", ea, Rnum);
1444            else
1445            sprintf(arg_str, "%s,N%d", ea, Rnum);
1446      }
1447   }
1448   else if (BITS(op,0x0e00) == 0x1)
1449   {
1450      sprintf(opcode_str, "move(m)");
2412/* RTI : 0000 0000 0000 0111 : A-194 */
2413static size_t dsp56k_dasm_rti(const UINT16 op, char* opcode_str, char* arg_str)
2414{
2415   sprintf(opcode_str, "rti");
2416   sprintf(arg_str, " ");
2417   return (1 | DASMFLAG_STEP_OUT);
2418}
14512419
1452      if (BITS(op,0x0020) == 0x0)
1453      {
1454         /* MOVE(M) - 0000 001W RR0M MHHH */
1455         int Rnum = decode_RR_table(BITS(op,0x00c0));
1456         decode_HHH_table(BITS(op,0x0007), SD);
1457         assemble_ea_from_MM_table(BITS(op,0x0018), Rnum, ea);
1458         assemble_arguments_from_W_table(BITS(op,0x0100), args, 'P', SD, ea);
1459         sprintf(arg_str, "%s", args);
1460      }
1461      else
1462      {
1463         /* MOVE(M) - 0000 001W RR11 mmRR */
1464         assemble_eas_from_m_table(BITS(op,0x000c), BITS(op,0x00c0), BITS(op,0x0003), ea, ea2);
1465            sprintf(SD, "P:%s", ea);
1466            assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, ea2);
1467         sprintf(arg_str, "%s", args);
1468      }
1469   }
1470   else if (BITS(op,0x0f00) == 0x4)
1471   {
1472      if (BITS(op,0x0020) == 0x0)
1473      {
1474         /* DO - 0000 0100 000D DDDD xxxx xxxx xxxx xxxx */
1475         decode_DDDDD_table(BITS(op,0x001f), S1);
1476         sprintf(opcode_str, "do");
1477         sprintf(arg_str, "%s,%04x", S1, op2);
1478         retSize = 2;
1479      }
1480      else
1481      {
1482         /* REP - 0000 0100 001D DDDD */
1483            decode_DDDDD_table(BITS(op,0x001f), S1);
1484         sprintf(opcode_str, "rep");
1485         sprintf(arg_str, "%s", S1);
1486      }
1487   }
1488   else if (BITS(op,0x0f00) == 0x5)
1489   {
1490      UINT8 B;
2420/* RTS : 0000 0000 0000 0110 : A-196 */
2421static size_t dsp56k_dasm_rts(const UINT16 op, char* opcode_str, char* arg_str)
2422{
2423   sprintf(opcode_str, "rts");
2424   sprintf(arg_str, " ");
2425   return (1 | DASMFLAG_STEP_OUT);
2426}
14912427
1492      if (BITS(op2,0xfe20) == 0x02)
1493      {
1494         /* MOVE(M) - 0000 0101 BBBB BBBB | 0000 001W --0- -HHH */
1495         B = BITS(op,0x00ff);
1496         decode_HHH_table(BITS(op2,0x0007), SD);
1497         assemble_reg_from_W_table(BITS(op2,0x0100), args, 'P', SD, B);
1498         sprintf(opcode_str, "move(m)");
1499         sprintf(arg_str, "%s", args);
1500         /* !!! The docs list the read/write order backwards for all move(m)'s - crackbabies ??? */
1501         retSize = 2;
1502      }
1503      else if (BITS(op2,0xf810) == 0x0e)
1504      {
1505         /* MOVE(C) - 0000 0101 BBBB BBBB | 0011 1WDD DDD0 ---- */
1506         B = BITS(op,0x00ff);
1507            decode_DDDDD_table(BITS(op2,0x03e0), SD);
1508            assemble_reg_from_W_table(BITS(op2,0x0400), args, 'X', SD, B);
1509         sprintf(opcode_str, "move(c)");
1510         sprintf(arg_str, "%s", args);
1511            retSize = 2;
1512      }
1513      else if (BITS(op2,0x00ff) == 0x11)
1514      {
1515         /* MOVE - 0000 0101 BBBB BBBB | ---- HHHW 0001 0001 */
1516         B = BITS(op,0x00ff);
1517            decode_HHH_table(BITS(op2,0x0e00), SD);
1518            assemble_reg_from_W_table(BITS(op2,0x0100), args, 'X', SD, B);
1519         sprintf(opcode_str, "move");
1520         sprintf(arg_str, "%s", args);
1521            retSize = 2;
1522      }
1523   }
1524   else if (BITS(op,0x0f00) == 0x6)
1525   {
1526      int Rnum = -1;
1527      char M[32] = "";
2428/* STOP : 0000 0000 0000 1010 : A-200 */
2429static size_t dsp56k_dasm_stop(const UINT16 op, char* opcode_str, char* arg_str)
2430{
2431   sprintf(opcode_str, "stop");
2432   sprintf(arg_str, " ");
2433   return 1;
2434}
15282435
1529      switch(BITS(op,0x0030))
1530      {
1531         case 0x0:
1532            /* JS.cc - 0000 0110 RR00 cccc */
1533            decode_cccc_table(BITS(op,0x000f), M);
1534                Rnum = decode_RR_table(BITS(op,0x00c0));
1535            sprintf(opcode_str, "js.%s", M);
1536            sprintf(arg_str, "R%d", Rnum);
1537            retSize |= DASMFLAG_STEP_OVER;   /* probably.  What's the diff between a branch and a jump? */
1538            break;
2436/* SWAP : 0001 0101 0111 F001 : A-206 */
2437static size_t dsp56k_dasm_swap(const UINT16 op, char* opcode_str, char* arg_str)
2438{
2439   char D[32];
2440   decode_F_table(BITS(op,0x0008), D);
2441   sprintf(opcode_str, "swap");
2442   sprintf(arg_str, "%s", D);
2443   return 1;
2444}
15392445
1540         case 0x1:
1541            /* JS.cc - 0000 0110 --01 cccc xxxx xxxx xxxx xxxx */
1542            decode_cccc_table(BITS(op,0x000f), M);
1543            sprintf(opcode_str, "js.%s", M);
1544            sprintf(arg_str, "%04x", op2);
1545                retSize = 2;
1546            retSize |= DASMFLAG_STEP_OVER;   /* probably */
1547            break;
2446/* SWI : 0000 0000 0000 0101 : A-208 */
2447static size_t dsp56k_dasm_swi(const UINT16 op, char* opcode_str, char* arg_str)
2448{
2449   sprintf(opcode_str, "swi");
2450   sprintf(arg_str, " ");
2451   return 1;
2452}
15482453
1549         case 0x2:
1550            /* J.cc - 0000 0110 RR10 cccc */
1551            decode_cccc_table(BITS(op,0x000f), M);
1552                Rnum = decode_RR_table(BITS(op,0x00c0));
1553            sprintf(opcode_str, "j.%s", M);
1554                sprintf(arg_str, "R%d", Rnum);
1555            break;
2454/* Tcc : 0001 00cc ccTT Fh0h : A-210 */
2455static size_t dsp56k_dasm_tcc(const UINT16 op, char* opcode_str, char* arg_str)
2456{
2457   int Rnum = -1;
2458   char M[32];
2459   char D[32];
2460   char S[32];
15562461
1557         case 0x3:
1558            /* J.cc - 0000 0110 --11 cccc xxxx xxxx xxxx xxxx */
1559            decode_cccc_table(BITS(op,0x000f), M);
1560            sprintf(opcode_str, "j.%s", M);
1561            sprintf(arg_str, "%04x", op2);
1562                retSize = 2;
1563            break;
1564      }
1565   }
1566   else if (BITS(op,0x0f00) == 0x7)
1567   {
1568      int Rnum = -1;
1569      char M[32] = "";
2462   decode_cccc_table(BITS(op,0x03c0), M);
2463   sprintf(opcode_str, "t.%s", M);
15702464
1571      switch(BITS(op,0x0030))
1572      {
1573         case 0x0:
1574            /* BS.cc - 0000 0111 RR00 cccc */
1575            decode_cccc_table(BITS(op,0x000f), M);
1576                Rnum = decode_RR_table(BITS(op,0x00c0));
1577            sprintf(opcode_str, "bs.%s", M);
1578            sprintf(arg_str, "R%d", Rnum);
1579            retSize |= DASMFLAG_STEP_OVER;   /* probably.  What's the diff between a branch and a jump? */
1580            break;
2465   Rnum = decode_RR_table(BITS(op,0x0030));
2466   decode_h0hF_table(BITS(op,0x0007),BITS(op,0x0008), S, D);
2467   sprintf(arg_str, "%s,%s  R0,R%d", S, D, Rnum);
15812468
1582         case 0x1:
1583            /* BS.cc - 0000 0111 --01 cccc xxxx xxxx xxxx xxxx */
1584            decode_cccc_table(BITS(op,0x000f), M);
1585            sprintf(opcode_str, "bs.%s", M);
1586            sprintf(arg_str, "%d (0x%04x)", (INT16)(op2), op2);
1587            retSize = 2;
1588            retSize |= DASMFLAG_STEP_OVER;   /* probably */
1589            break;
2469   /* TODO: Investigate
2470    if (S1[0] == D[0] && D[0] == 'A')
2471        sprintf(buffer, "t.%s  %s,%s", M, S1, D);
2472    else
2473        sprintf(buffer, "t.%s  %s,%s  R0,R%d", M, S1, D, Rnum);
2474    */
2475   return 1;
2476}
15902477
1591         case 0x2:
1592            /* B.cc - 0000 0111 RR10 cccc */
1593            decode_cccc_table(BITS(op,0x000f), M);
1594                Rnum = decode_RR_table(BITS(op,0x00c0));
1595            sprintf(opcode_str, "b.%s", M);
1596            sprintf(arg_str, "R%d", Rnum);
1597            break;
2478/* TFR(2) : 0001 0101 0000 F00J : A-214 */
2479static size_t dsp56k_dasm_tfr2(const UINT16 op, char* opcode_str, char* arg_str)
2480{
2481   char D[32];
2482   char S1[32];
2483   decode_JF_table(BITS(op,0x0001),BITS(op,0x0008), D, S1);
2484   sprintf(opcode_str, "tfr2");
2485   sprintf(arg_str, "%s,%s", S1, D);
2486   return 1;
2487}
15982488
1599         case 0x3:
1600            /* B.cc - 0000 0111 --11 cccc xxxx xxxx xxxx xxxx */
1601            decode_cccc_table(BITS(op,0x000f), M);
1602            sprintf(opcode_str, "b.%s", M);
1603            sprintf(arg_str, "%04x (%d)", op2, op2);
1604            retSize = 2;
1605            break;
1606      }
1607   }
1608   else if (BITS(op,0x0800))
1609   {
1610      int Rnum = -1;
2489/* TFR(3) : 0010 01mW RRDD FHHH : A-216 */
2490static size_t dsp56k_dasm_tfr3(const UINT16 op, char* opcode_str, char* arg_str)
2491{
2492   int Rnum;
2493   char ea[32];
2494   char D1[32];
2495   char S1[32];
2496   char SD[32];
2497   char args[32];
2498   decode_DDF_table(BITS(op,0x0030), BITS(op,0x0008), D1, S1);          /* Intentionally switched */
2499   decode_HHH_table(BITS(op,0x0007), SD);
2500   Rnum = decode_RR_table(BITS(op,0x00c0));
2501   assemble_ea_from_m_table(BITS(op,0x0200), Rnum, ea);
2502   assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, ea);
2503   sprintf(opcode_str, "tfr3");
2504   sprintf(arg_str, "%s,%s %s", S1, D1, args);
2505   return 1;
2506}
16112507
1612      switch (BITS(op,0x0700))
1613      {
1614         /* JSR - 0000 1010 AAAA AAAA */
1615         case 0x2:
1616            sprintf(opcode_str, "jsr");
1617            sprintf(arg_str, "%d (0x%02x)", BITS(op,0x00ff), BITS(op,0x00ff));
1618                retSize |= DASMFLAG_STEP_OVER;
1619            break;
2508/* TST(2) : 0001 0101 0001 -1DD : A-220 */
2509static size_t dsp56k_dasm_tst2(const UINT16 op, char* opcode_str, char* arg_str)
2510{
2511   char S1[32];
2512   decode_DD_table(BITS(op,0x0003), S1);
2513   sprintf(opcode_str, "tst2");
2514   sprintf(arg_str, "%s", S1);
2515   return 1;
2516}
16202517
1621         /* BRA - 0000 1011 aaaa aaaa */
1622         case 0x3:
1623            sprintf(opcode_str, "bra");
1624            sprintf(arg_str, "%d (0x%02x)", (INT8)BITS(op,0x00ff), pc + (INT8)BITS(op,0x00ff));
1625            break;
2518/* WAIT : 0000 0000 0000 1011 : A-222 */
2519static size_t dsp56k_dasm_wait(const UINT16 op, char* opcode_str, char* arg_str)
2520{
2521   sprintf(opcode_str, "wait");
2522   sprintf(arg_str, " ");
2523   return 1;
2524}
16262525
1627         /* MOVE(P) - 0000 110W RRmp pppp */
1628         case 0x4: case 0x5:
1629         {
1630            char fullAddy[128];      /* Convert Short Absolute Address to full 16-bit */
1631            Rnum = decode_RR_table(BITS(op,0x00c0));
1632            assemble_ea_from_m_table(BITS(op,0x0020), Rnum, ea);
1633            assemble_address_from_IO_short_address(BITS(op,0x001f), fullAddy);
1634            sprintf(SD, "X:%02x (%s)", BITS(op,0x001f), fullAddy);
1635            assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, ea);
1636            sprintf(opcode_str, "move(p)");
1637            sprintf(arg_str, "%s", args);
1638            break;
1639         }
2526/* ZERO : 0001 0101 0101 F000 : A-224 */
2527static size_t dsp56k_dasm_zero(const UINT16 op, char* opcode_str, char* arg_str)
2528{
2529   char D[32];
2530   decode_F_table(BITS(op,0x0008), D);
2531   sprintf(opcode_str, "zero");
2532   sprintf(arg_str, "%s", D);
2533   return 1;
2534}
16402535
1641         /* DO - 0000 1110 iiii iiii xxxx xxxx xxxx xxxx */
1642         case 0x6:
1643            sprintf(opcode_str, "do");
1644            sprintf(arg_str, "#%02x,%04x", BITS(op,0x00ff), op2);
1645            retSize = 2;
1646            break;
16472536
1648         /* REP - 0000 1111 iiii iiii */
1649         case 0x7:
1650            sprintf(opcode_str, "rep");
1651            sprintf(arg_str, "%d (0x%02x)", BITS(op,0x00ff), BITS(op,0x00ff));
1652            break;
1653      }
1654   }
16552537
1656   return retSize;
1657}
1658
1659
1660/*******************************/
1661/* Parallel data move decoding */
1662/*******************************/
1663static void decode_x_memory_data_move(const UINT16 op_byte, char* parallel_move_str)
2538/**********************************/
2539/* Parallel memory move functions */
2540/**********************************/
2541/* X Memory Data Move : 1mRR HHHW ---- ---- : A-137 */
2542static void decode_x_memory_data_move(const UINT16 op, char* parallel_move_str)
16642543{
16652544   int Rnum;
16662545   char SD[32];
16672546   char ea[32];
16682547   char args[32];
16692548
1670   /* Byte: 1mRR HHHW ---- ---- */
1671   Rnum = decode_RR_table(BITS(op_byte,0x30));
1672   decode_HHH_table(BITS(op_byte,0x0e), SD);
1673   assemble_ea_from_m_table(BITS(op_byte,0x40), Rnum, ea);
1674   assemble_arguments_from_W_table(BITS(op_byte,0x01), args, 'X', SD, ea);
2549   Rnum = decode_RR_table(BITS(op,0x3000));
2550   decode_HHH_table(BITS(op,0x0e00), SD);
2551   assemble_ea_from_m_table(BITS(op,0x4000), Rnum, ea);
2552   assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, ea);
16752553
16762554   sprintf(parallel_move_str, "%s", args);
16772555}
16782556
2557/* X Memory Data Move : 0101 HHHW ---- ---- : A-137 */
2558static void decode_x_memory_data_move2(const UINT16 op, char* parallel_move_str, char* d_register)
2559{
2560   char SD[32] ;
2561   char args[32] ;
2562   char dest[32] ;
2563
2564   if (d_register[0] == 'B')
2565      sprintf(dest, "(A1)");
2566   else if (d_register[0] == 'A')
2567      sprintf(dest, "(B1)");
2568   else
2569      sprintf(dest, "(A1)");
2570
2571   decode_HHH_table(BITS(op,0x0e00), SD) ;
2572   assemble_arguments_from_W_table(BITS(op,0x0100), args, 'X', SD, dest) ;
2573
2574   sprintf(parallel_move_str, "%s", args);
2575}
2576
2577/* Dual X Memory Data Read : 011m mKKK -rr- ---- : A-142*/
16792578static void decode_dual_x_memory_data_read(const UINT16 op, char* parallel_move_str, char* parallel_move_str2)
16802579{
16812580   int Rnum;
r3333r3334
16842583   char ea1[32] = "";
16852584   char ea2[32] = "";
16862585
1687   /* 011m mKKK -rr- ---- */
16882586   Rnum = decode_rr_table(BITS(op,0x0060));
16892587   decode_KKK_table(BITS(op,0x0700), D1, D2);
16902588   assemble_eas_from_m_table(BITS(op,0x1800), Rnum, 3, ea1, ea2);
16912589
1692   /* TODO : Should the ^F's be replaced? */
2590   /* TODO : The ^F's should likely be replaced */
16932591
16942592   if (Rnum == -1)
16952593   {
r3333r3334
17002598   sprintf(parallel_move_str2, "X:%s,%s", ea2, D2);
17012599}
17022600
1703static void decode_register_to_register_data_move(const UINT16 op_byte, char* parallel_move_str, char* d_register)
2601/* Register to Register Data Move : 0100 IIII ---- ---- : A-133 */
2602static void decode_register_to_register_data_move(const UINT16 op, char* parallel_move_str, char* d_register)
17042603{
17052604   char S[32];
17062605   char D[32];
17072606
1708   decode_IIII_table(BITS(op_byte,0x0f), S, D);
2607   decode_IIII_table(BITS(op,0x0f00), S, D);
17092608
17102609   if (D[0] == '^' && D[1] == 'F')
17112610   {
r3333r3334
17202619   sprintf(parallel_move_str, "%s,%s", S, D);
17212620}
17222621
1723static void decode_parallel_cooperative_x_memory_data_move(const UINT16 op_byte, char* parallel_move_str, char* d_register)
2622/* Address Register Update : 0011 0zRR ---- ---- : A-135 */
2623static void decode_address_register_update(const UINT16 op, char* parallel_move_str)
17242624{
1725   char SD[32] ;
1726   char args[32] ;
1727   char dest[32] ;
2625   char ea[32];
2626   int Rnum;
2627   Rnum = decode_RR_table(BITS(op,0x0300));
2628   assemble_ea_from_z_table(BITS(op,0x0400), Rnum, ea);
2629   sprintf(parallel_move_str, "%s", ea);
2630}
17282631
1729   if (d_register[0] == 'B')
1730      sprintf(dest, "(A1)");
1731   else if (d_register[0] == 'A')
1732      sprintf(dest, "(B1)");
1733   else
1734      sprintf(dest, "(A1)");
2632/* X Memory Data Write and Register Data Move : 0001 011k RRDD ---- : A-140 */
2633static void decode_x_memory_data_write_and_register_data_move(const UINT16 op, char* parallel_move_str, char* parallel_move_str2)
2634{
2635   int Rnum;
2636   char S[32];
2637   char Dnot[32];
17352638
1736   decode_HHH_table(BITS(op_byte,0x0e), SD) ;
1737   assemble_arguments_from_W_table(BITS(op_byte,0x01), args, 'X', SD, dest) ;
2639   /* TODO : Cross-check the Dnot stuff against the MPY & MAC things. */
2640   /* It's likely correct as-is, since the ALU op and this guy probably decode the same bit, */
2641   /* but i may have to pass in d_register just to be sure? */
2642   decode_k_table(BITS(op,0x0100), Dnot);
2643   Rnum = decode_RR_table(BITS(op,0x00c0));
2644   decode_DD_table(BITS(op,0x0030), S);
17382645
1739   sprintf(parallel_move_str, "%s", args);
2646   /* TODO : is Nn correct here? */
2647   sprintf(parallel_move_str,  "%s,X:(R%d)+N%d", Dnot, Rnum, Rnum);
2648   sprintf(parallel_move_str2, "%s,%s", S, Dnot);
17402649}
17412650
1742/* MISSING MPY */
1743/*
1744        char S[32];
2651/* X Memory Data Move with short displacement : 0000 0101 BBBB BBBB ---- HHHW ---- ---- : A-139 */
2652static void decode_x_memory_data_move_with_short_displacement(const UINT16 op, const UINT16 op2, char* parallel_move_str)
2653{
2654   INT8 B;
2655   char SD[32];
2656   char args[32];
17452657
1746        // MPY - 0001 0110 RRDD FQQQ
1747        decode_k_table(BITS(op,0x0100), Dnot);
1748        Rnum = decode_RR_table(BITS(op,0x00c0));
1749        decode_DD_table(BITS(op,0x0030), S);
1750        decode_QQQF_table(BITS(op,0x0007), BITS(op,0x0008), S1, S2, D);
1751        sprintf(buffer, "mpy       %s,%s,%s %s,(R%d)+N%d %s,%s", S1, S2, D, Dnot, Rnum, Rnum, S, Dnot);
1752        // Strange, but not entirely out of the question - this 'k' parameter is hardcoded
1753        // I cheat here and do the parallel memory data move above - this specific one is only used twice
1754        retSize = 1;
1755*/
2658   B = (char)(op & 0x00ff);
2659   decode_HHH_table(BITS(op2,0x0e00), SD);
2660   assemble_reg_from_W_table(BITS(op2,0x0100), args, 'X', SD, B);
2661   sprintf(parallel_move_str, "%s", args);
2662}
17562663
1757/* MISSING MAC */
1758/*
1759        char S[32];
17602664
1761        // MAC - 0001 0111 RRDD FQQQ
1762        decode_k_table(BITS(op,0x0100), Dnot);
1763        Rnum = decode_RR_table(BITS(op,0x00c0));
1764        decode_DD_table(BITS(op,0x0030), S);
1765        decode_QQQF_table(BITS(op,0x0007), BITS(op,0x0008), S1, S2, D);
1766        sprintf(buffer, "mac       %s,%s,%s %s,(R%d)+N%d %s,%s", S1, S2, D, Dnot, Rnum, Rnum, S, Dnot);
1767        // Strange, but not entirely out of the question - this 'k' parameter is hardcoded
1768        // I cheat here and do the parallel memory data move above - this specific one is only used twice
1769        retSize = 1;
1770*/
1771
1772
1773
17742665/******************/
17752666/* Table decoding */
17762667/******************/
2668
17772669static int decode_BBB_table(UINT16 BBB)
17782670{
17792671   switch(BBB)
r3333r3334
20172909   }
20182910}
20192911
2020#ifdef UNUSED_FUNCTION
20212912static void decode_k_table(UINT16 k, char *Dnot)
20222913{
20232914   switch(k)
r3333r3334
20262917      case 0x1: sprintf(Dnot, "A"); break;
20272918   }
20282919}
2029#endif
20302920
20312921static void decode_kSign_table(UINT16 k, char *plusMinus)
20322922{
r3333r3334
20522942   }
20532943}
20542944
2055#ifdef UNUSED_FUNCTION
20562945static int decode_NN_table(UINT16 NN)
20572946{
20582947   return NN;
20592948}
2060#endif
20612949
2950static int decode_TT_table(UINT16 TT)
2951{
2952   return TT;
2953}
2954
20622955static void decode_QQF_table(UINT16 QQ, UINT16 F, char *S1, char *S2, char *D)
20632956{
20642957   UINT16 switchVal = (QQ << 1) | F;
r3333r3334
22443137   }
22453138}
22463139
2247
2248#ifdef UNUSED_FUNCTION
22493140static void assemble_ea_from_z_table(UINT16 z, int n, char *ea)
22503141{
22513142   switch(z)
r3333r3334
22543145      case 0x1: sprintf(ea, "(R%d)+N%d", n, n); break;
22553146   }
22563147}
2257#endif
22583148
22593149static void assemble_D_from_P_table(UINT16 P, UINT16 ppppp, char *D)
22603150{
r3333r3334
22963186   sprintf(ea, "%.04x", fullAddy);
22973187}
22983188
2299static INT8 get_6_bit_relative_value(UINT16 bits)
3189static INT8 get_6_bit_signed_value(UINT16 bits)
23003190{
23013191   UINT16 fullAddy = bits;
23023192   if (fullAddy & 0x0020)
r3333r3334
23393229   }
23403230}
23413231
2342
2343
2344
2345/*
2346
2347Data ALU Ops
2348--------------------
2349
2350CLR             X       1xxx xxxx 0000 x001
2351ADD             X       1xxx xxxx 0000 xxxx
2352
2353MOVE            X       1xxx xxxx 0001 0001
2354TFR             X       1xxx xxxx 0001 xxxx
2355
2356RND             X       1xxx xxxx 0010 x000
2357TST             X       1xxx xxxx 0010 x001
2358INC             X       1xxx xxxx 0010 x010
2359INC24           X       1xxx xxxx 0010 x011
2360OR              X       1xxx xxxx 0010 x1xx
2361
2362ASR             X       1xxx xxxx 0011 x000
2363ASL             X       1xxx xxxx 0011 x001
2364LSR             X       1xxx xxxx 0011 x010
2365LSL             X       1xxx xxxx 0011 x011
2366EOR             X       1xxx xxxx 0011 x1xx
2367
2368SUBL            X       1xxx xxxx 0100 x001
2369SUB             X       1xxx xxxx 0100 xxxx
2370
2371CLR24           X       1xxx xxxx 0101 x001
2372SBC             X       1xxx xxxx 0101 x01x
2373CMP             X       1xxx xxxx 0101 xxxx
2374
2375NEG             X       1xxx xxxx 0110 x000
2376NOT             X       1xxx xxxx 0110 x001
2377DEC             X       1xxx xxxx 0110 x010
2378DEC24           X       1xxx xxxx 0110 x011
2379AND             X       1xxx xxxx 0110 x1xx
2380
2381ABS             X       1xxx xxxx 0111 x001
2382ROR             X       1xxx xxxx 0111 x010
2383ROL             X       1xxx xxxx 0111 x011
2384CMPM            X       1xxx xxxx 0111 xxxx
2385
2386MPY             X       1xxx xxxx 1x00 xxxx
2387MPYR            X       1xxx xxxx 1x01 xxxx
2388MAC             X       1xxx xxxx 1x10 xxxx
2389MACR            X       1xxx xxxx 1x11 xxxx
2390
2391
2392VERY STRANGE XMDM!      0101 HHHW xxxx xxxx
2393
2394
2395DXMDR
2396-----------------
2397
2398ADD             X       011x xxxx 0xxx xxxx
2399SUB             X       011x xxxx 0xxx xxxx
2400TFR             X       011x xxxx 0xx1 x0xx
2401MOVE            X       011x xxxx 0xx1 0000
2402
2403MPY             X       011x xxxx 1xx0 x0xx
2404MAC             X       011x xxxx 1xx0 x1xx
2405MPYR            X       011x xxxx 1XX1 x0xx
2406MACR            X       011x xxxx 1XX1 x1xx
2407
2408TODO: don't forget us
2409x memory data write and register data move - unique
2410-----------------
2411MPY             X       0001 0110 xxxx xxxx
2412MAC             X       0001 0111 xxxx xxxx
2413
2414ODDBALL
2415-------
2416Tcc             X       0001 00xx xxxx xx0x
2417
2418BITFIELD
2419-----------------
2420
2421BFTSTL          X       0001 0100 000x xxxx . xxx0 0000 xxxx xxxx
2422BFTSTH          X       0001 0100 000x xxxx . xxx1 0000 xxxx xxxx
2423BFTSTL          X       0001 0100 001X XXxx . xxx0 0000 xxxx xxxx
2424BFTSTH          X       0001 0100 001X XXxx . xxx1 0000 xxxx xxxx
2425BFTSTL          X       0001 0100 01xx xxxx . xxx0 0000 xxxx xxxx
2426BFTSTH          X       0001 0100 01xx xxxx . xxx1 0000 xxxx xxxx
2427BFCLR           X       0001 0100 100x xxxx . xxx0 0100 xxxx xxxx
2428BFCHG           X       0001 0100 100x xxxx . xxx1 0010 xxxx xxxx
2429BFSET           X       0001 0100 100x xxxx . xxx1 1000 xxxx xxxx
2430BFCLR           X       0001 0100 101X XXxx . xxx0 0100 xxxx xxxx
2431BFCHG           X       0001 0100 101X XXxx . xxx1 0010 xxxx xxxx
2432BFSET           X       0001 0100 101X XXxx . xxx1 1000 xxxx xxxx
2433BFCHG           X       0001 0100 11xx xxxx . xxx1 0010 xxxx xxxx
2434BFCLR           X       0001 0100 11xx xxxx . xxx0 0100 xxxx xxxx
2435BFSET           X       0001 0100 11xx xxxx . xxx1 1000 xxxx xxxx
2436
2437
2438NPM
2439-----------------
2440
2441TFR2            X       0001 0101 0000 x00x
2442ADC             X       0001 0101 0000 x01x
2443
2444TST2            X       0001 0101 0001 X1xx
2445
2446NORM            X       0001 0101 0010 x0xx
2447
2448ASR4            X       0001 0101 0011 x000
2449ASL4            X       0001 0101 0011 x001
2450
2451DIV             X       0001 0101 0XX0 x1xx
2452
2453ZERO            X       0001 0101 0101 x000
2454EXT             X       0001 0101 0101 x010
2455
2456NEGC            X       0001 0101 0110 x000
2457
2458ASR16           X       0001 0101 0111 x000
2459SWAP            X       0001 0101 0111 x001
2460
2461IMPY            X       0001 0101 1000 xxxx
2462IMAC            X       0001 0101 1010 xxxx
2463DMAC(ss,su,uu)  X       0001 0101 10x1 xxxx
2464MPY(su,uu)      X       0001 0101 1100 xxxx
2465MAC(su,uu)      X       0001 0101 1110 xxxx
2466
2467IMMEDIATE
2468-----------------
2469
2470ANDI            X       0001 1xx0 xxxx xxxx
2471ORI             X       0001 1xx1 xxxx xxxx
2472
2473
2474SPECIAL
2475-----------------
2476
2477MOVE(S)         X       0001 100x xx0x xxxx
2478MOVE(P)         X       0001 100x xx1x xxxx
2479
2480-----------------
2481
2482MOVE(I)         X       0010 00xx xxxx xxxx
2483TFR3            X       0010 01xx xxxx xxxx
2484MOVE(C)         X       0010 10xx xxxx xxxx
2485Bcc             X       0010 11xx xxxx xxxx
2486
2487-----------------
2488
2489MOVE(C)         X       0011 1xxx xxx0 xxxx
2490MOVE(C)         X       0011 1xxx xxx1 x0xx
2491MOVE(C)         X       0011 1xxx xxx1 x10X xxxx xxxx xxxx xxxx
2492MOVE(C)         X       0011 1xxx xxx1 x11X
2493
2494
2495
2496
2497
2498
2499
2500
2501-----------------
2502
2503NOP             X       0000 0000 0000 0000
2504DEBUG           X       0000 0000 0000 0001
2505DO FOREVER      X       0000 0000 0000 0010 xxxx xxxx xxxx xxxx
2506CHKAAU          X       0000 0000 0000 0100
2507SWI             X       0000 0000 0000 0101
2508RTS             X       0000 0000 0000 0110
2509RTI             X       0000 0000 0000 0111
2510RESET           X       0000 0000 0000 1000
2511ENDDO           X       0000 0000 0000 1001
2512STOP            X       0000 0000 0000 1010
2513WAIT            X       0000 0000 0000 1011
2514ILLEGAL         X       0000 0000 0000 1111
2515
2516DEBUGcc         X       0000 0000 0101 xxxx
2517DOLoop          X       0000 0000 110X XXxx xxxx xxxx xxxx xxxx
2518REP             X       0000 0000 111X XXxx
2519
2520BRKcc           X       0000 0001 0001 xxxx
2521
2522JSR             X       0000 0001 0010 00xx
2523JMP             X       0000 0001 0010 01xx
2524BSR             X       0000 0001 0010 10xx
2525BRA             X       0000 0001 0010 11xx
2526
2527JSR             X       0000 0001 0011 00XX xxxx xxxx xxxx xxxx
2528JMP             X       0000 0001 0011 01XX xxxx xxxx xxxx xxxx
2529BSR             X       0000 0001 0011 10XX xxxx xxxx xxxx xxxx
2530BRA             X       0000 0001 0011 11XX xxxx xxxx xxxx xxxx
2531
2532REPcc           X       0000 0001 0101 xxxx
2533
2534LEA             X       0000 0001 10xx xxxx
2535LEA             X       0000 0001 11xx xxxx
2536
2537-----------------
2538
2539MOVE(M)         X       0000 001x xx0x xxxx
2540MOVE(M)         X       0000 001x xx11 xxxx
2541
2542-----------------
2543
2544DOLoop          X       0000 0100 000x xxxx xxxx xxxx xxxx xxxx
2545REP             X       0000 0100 001x xxxx
2546
2547-----------------
2548
2549MOVE(M)         X       0000 0101 xxxx xxxx 0000 001x XX0X Xxxx
2550MOVE(C)         X       0000 0101 xxxx xxxx 0011 1xxx xxx0 XXXX
2551MOVE            X       0000 0101 xxxx xxxx XXXX xxxx 0001 0001
2552
2553-----------------
2554
2555JScc            X       0000 0110 xx00 xxxx
2556JScc            X       0000 0110 XX01 xxxx xxxx xxxx xxxx xxxx
2557Jcc             X       0000 0110 xx10 xxxx
2558Jcc             X       0000 0110 XX11 xxxx xxxx xxxx xxxx xxxx
2559
2560BScc            X       0000 0111 xx00 xxxx
2561BScc            X       0000 0111 XX01 xxxx xxxx xxxx xxxx xxxx
2562Bcc             X       0000 0111 xx10 xxxx
2563Bcc             X       0000 0111 XX11 xxxx xxxx xxxx xxxx xxxx
2564
2565-----------------
2566
2567JSR             X       0000 1010 xxxx xxxx
2568BRA             X       0000 1011 xxxx xxxx
2569MOVE(P)         X       0000 110x xxxx xxxx
2570DOLoop          X       0000 1110 xxxx xxxx xxxx xxxx xxxx xxxx
2571REP             X       0000 1111 xxxx xxxx
2572
2573*/
src/emu/cpu/i8085/i8085.c
r3333r3334
12211221         M_RST(7);
12221222         break;
12231223   }
1224   /* For 8080 NF flag is not used but bit is always set */
1225   if(!I.cputype ) {
1226      I.AF.b.l = I.AF.b.l | NF;
1227   }
12281224}
12291225
12301226static void Interrupt(void)
src/emu/cpu/g65816/g65816ds.c
r3333r3334
250250      case RELW:
251251      case PER :
252252         var = read_16(address+1);
253         sprintf(ptr, " %06x (%s)", pb | ((pc + 1 + var)&0xffff), int_16_str(var));
254253         length += 2;
254         sprintf(ptr, " %06x (%s)", pb | ((pc + length + var)&0xffff), int_16_str(var));
255255         break;
256256      case IMM :
257257         if((opcode->flag == M && !m_flag) || (opcode->flag == X && !x_flag))
src/emu/cpu/arm7/arm7core.c
r3333r3334
125125void (*arm7_coproc_dt_r_callback)(UINT32 insn, UINT32 *prn, UINT32 (*read32)(UINT32 addr));
126126void (*arm7_coproc_dt_w_callback)(UINT32 insn, UINT32 *prn, void (*write32)(UINT32 addr, UINT32 data));
127127
128#ifdef UNUSED_DEFINITION
128129// custom dasm callback handlers for co-processor instructions
129130char *(*arm7_dasm_cop_dt_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0);
130131char *(*arm7_dasm_cop_rt_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0);
131132char *(*arm7_dasm_cop_do_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0);
133#endif
132134
133135
134136/***************************************************************************
src/emu/cpu/arm7/arm7core.h
r3333r3334
403403extern UINT32 arm7_disasm(char *pBuf, UINT32 pc, UINT32 opcode);
404404extern UINT32 thumb_disasm(char *pBuf, UINT32 pc, UINT16 opcode);
405405
406#ifdef UNUSED_DEFINITION
406407extern char *(*arm7_dasm_cop_dt_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0);
407408extern char *(*arm7_dasm_cop_rt_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0);
408409extern char *(*arm7_dasm_cop_do_callback)(char *pBuf, UINT32 opcode, char *pConditionCode, char *pBuf0);
410#endif
409411
410412#endif /* __ARM7CORE_H__ */
src/emu/uimenu.c
r3333r3334
31513151   /* if nothing there, add a single multiline item and return */
31523152   if (matchcount == 0)
31533153   {
3154      ui_menu_item_append(menu, "No games found. Please check the rompath specified in the mame.ini file.\n\n"
3155                          "If this is your first time using MAME, please see the config.txt file in "
3156                          "the docs directory for information on configuring MAME.", NULL, MENU_FLAG_MULTILINE | MENU_FLAG_REDTEXT, NULL);
3154      ui_menu_item_append(menu, "No "GAMESNOUN" found. Please check the rompath specified in the "CONFIGNAME".ini file.\n\n"
3155                          "If this is your first time using "APPNAME", please see the config.txt file in "
3156                          "the docs directory for information on configuring "APPNAME, NULL, MENU_FLAG_MULTILINE | MENU_FLAG_REDTEXT, NULL);
31573157      return;
31583158   }
31593159
src/emu/emu.mak
r3333r3334
142142   $(EMUMACHINE)/ldcore.o \
143143   $(EMUMACHINE)/ldpr8210.o \
144144   $(EMUMACHINE)/ldv1000.o \
145   $(EMUMACHINE)/ldvp931.o \
145146   $(EMUMACHINE)/mb3773.o \
146147   $(EMUMACHINE)/mb87078.o \
147148   $(EMUMACHINE)/mc146818.o \
src/emu/machine/ldpr8210.c
r3333r3334
349349    player data
350350-------------------------------------------------*/
351351
352void pr8210_overlay(laserdisc_state *ld, bitmap_t *bitmap)
352static void pr8210_overlay(laserdisc_state *ld, bitmap_t *bitmap)
353353{
354354//  ldplayer_data *player = ld->player;
355355}
r3333r3334
804804ADDRESS_MAP_END
805805
806806
807MACHINE_DRIVER_START( simutrek )
807static MACHINE_DRIVER_START( simutrek )
808808   MDRV_CPU_ADD("simutrek", I8748, XTAL_6MHz)
809809   MDRV_CPU_IO_MAP(simutrek_portmap,0)
810810
src/emu/machine/ldvp931.c
r0r3334
1/*************************************************************************
2
3    ldvp931.c
4
5    Philips 22VP931 laserdisc emulation.
6
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10**************************************************************************
11
12    Still to do:
13
14        * determine actual slow/fast speeds
15        *
16
17*************************************************************************/
18
19#include "ldcore.h"
20#include "cpu/mcs48/mcs48.h"
21
22
23
24/***************************************************************************
25    DEBUGGING
26***************************************************************************/
27
28#define LOG_COMMANDS            0
29#define LOG_PORTS               0
30
31
32
33/***************************************************************************
34    CONSTANTS
35***************************************************************************/
36
37/* Philips 22VP931 specific information */
38#define VP931_SCAN_SPEED            (2000 / 30)         /* 2000 frames/second */
39#define VP931_SCAN_FAST_SPEED         (4000 / 30)         /* 4000 frames/second */
40
41
42
43/***************************************************************************
44    TYPE DEFINITIONS
45***************************************************************************/
46
47/* player-specific data */
48struct _ldplayer_data
49{
50   /* low-level emulation data */
51   int               cpunum;               /* CPU index of the 8049 */
52   const device_config *tracktimer;         /* timer device */
53   int               lastframe;
54   UINT8            out0;               /* output 0 state */
55   UINT8            out1;               /* output 1 state */
56   UINT8            port1;               /* port 1 state */
57   UINT8            daticval;            /* latched DATIC value */
58   UINT8            daticerp;            /* /ERP value from DATIC */
59   UINT8            datastrobe;            /* DATA STROBE line from DATIC */
60   UINT8            fromcontroller;         /* command byte from the controller */
61   UINT8            fromcontroller_pending;   /* TRUE if data is pending */
62   UINT8            tocontroller;         /* command byte to the controller */
63   UINT8            tocontroller_pending;   /* TRUE if data is pending */
64   INT8            trackdir;            /* direction of tracking */
65   UINT8            trackstate;            /* state of tracking */
66   UINT8            cmdbuf[3];            /* 3 bytes worth of commands */
67   UINT8            cmdcount;            /* number of command bytes seen */
68   INT16            advanced;            /* number of frames advanced */
69   void (*data_ready_cb)(const device_config *device, int state); /* data ready callback */
70};
71
72
73
74/***************************************************************************
75    FUNCTION PROTOTYPES
76***************************************************************************/
77
78static void vp931_init(laserdisc_state *ld);
79static void vp931_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int fieldnum, attotime curtime);
80static INT32 vp931_update(laserdisc_state *ld, const vbi_metadata *vbi, int fieldnum, attotime curtime);
81static void vp931_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data);
82static UINT8 vp931_data_r(laserdisc_state *ld);
83static UINT8 vp931_ready(laserdisc_state *ld);
84static UINT8 vp931_data_ready(laserdisc_state *ld);
85
86static WRITE8_HANDLER( output0_w );
87static WRITE8_HANDLER( output1_w );
88static WRITE8_HANDLER( lcd_w );
89static READ8_HANDLER( keypad_r );
90static READ8_HANDLER( datic_r );
91static READ8_HANDLER( from_controller_r );
92static WRITE8_HANDLER( to_controller_w );
93static READ8_HANDLER( port1_r );
94static WRITE8_HANDLER( port1_w );
95static READ8_HANDLER( port2_r );
96static WRITE8_HANDLER( port2_w );
97static READ8_HANDLER( t0_r );
98static READ8_HANDLER( t1_r );
99static TIMER_CALLBACK( vbi_data_fetch );
100static TIMER_CALLBACK( deferred_data_w );
101static TIMER_CALLBACK( irq_off );
102static TIMER_CALLBACK( datastrobe_off );
103static TIMER_CALLBACK( erp_off );
104static TIMER_DEVICE_CALLBACK( track_timer );
105
106
107
108/***************************************************************************
109    INLINE FUNCTIONS
110***************************************************************************/
111
112/*-------------------------------------------------
113    find_vp931 - find our device; assumes there
114    is only one
115-------------------------------------------------*/
116
117INLINE laserdisc_state *find_vp931(running_machine *machine)
118{
119   return ldcore_get_safe_token(device_list_first(machine->config->devicelist, LASERDISC));
120}
121
122
123
124/***************************************************************************
125    22VP931 ROM AND MACHINE INTERFACES
126***************************************************************************/
127
128static ADDRESS_MAP_START( vp931_portmap, ADDRESS_SPACE_IO, 8 )
129   AM_RANGE(0x00, 0x00) AM_MIRROR(0xcf) AM_READWRITE(keypad_r, output0_w)
130   AM_RANGE(0x10, 0x10) AM_MIRROR(0xcf) AM_WRITE(output1_w)
131   AM_RANGE(0x20, 0x20) AM_MIRROR(0xcf) AM_READWRITE(datic_r, lcd_w)
132   AM_RANGE(0x30, 0x30) AM_MIRROR(0xcf) AM_READWRITE(from_controller_r, to_controller_w)
133   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(port1_r, port1_w)
134   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READWRITE(port2_r, port2_w)
135   AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ(t0_r)
136   AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(t1_r)
137ADDRESS_MAP_END
138
139
140static MACHINE_DRIVER_START( vp931 )
141   MDRV_CPU_ADD("vp931", I8049, XTAL_11MHz)
142   MDRV_CPU_IO_MAP(vp931_portmap,0)
143   MDRV_TIMER_ADD("tracktimer", track_timer)
144MACHINE_DRIVER_END
145
146
147ROM_START( vp931 )
148   ROM_REGION( 0x800, "vp931", ROMREGION_LOADBYNAME )
149   ROM_LOAD( "at-6-1_a.bin", 0x000, 0x800, CRC(e11b3c8d) SHA1(ea2d7f6a044ed085ce5e09d8b1b1a21c37f0e9b8) )
150ROM_END
151
152
153
154/***************************************************************************
155    PR-8210 PLAYER INTERFACE
156***************************************************************************/
157
158const ldplayer_interface vp931_interface =
159{
160   LASERDISC_TYPE_PHILLIPS_22VP931,         /* type of the player */
161   sizeof(ldplayer_data),                  /* size of the state */
162   "Phillips 22VP931",                     /* name of the player */
163   rom_vp931,                           /* pointer to ROM region information */
164   machine_config_vp931,                  /* pointer to machine configuration */
165   vp931_init,                           /* initialization callback */
166   vp931_vsync,                        /* vsync callback */
167   vp931_update,                        /* update callback */
168   NULL,                              /* overlay callback */
169   vp931_data_w,                        /* parallel data write */
170   {                                 /* single line write: */
171      NULL,                           /*    LASERDISC_LINE_ENTER */
172      NULL                           /*    LASERDISC_LINE_CONTROL */
173   },
174   vp931_data_r,                        /* parallel data read */
175   {                                 /* single line read: */
176      vp931_ready,                     /*    LASERDISC_LINE_READY */
177      NULL,                           /*    LASERDISC_LINE_STATUS */
178      NULL,                           /*    LASERDISC_LINE_COMMAND */
179      vp931_data_ready,                  /*    LASERDISC_LINE_DATA_AVAIL */
180   }
181};
182
183
184
185/***************************************************************************
186    PUBLIC FUNCTIONS
187***************************************************************************/
188
189/*-------------------------------------------------
190    vp931_set_data_ready_callback - set the data
191    ready callback
192-------------------------------------------------*/
193
194void vp931_set_data_ready_callback(const device_config *device, void (*callback)(const device_config *device, int state))
195{
196   laserdisc_state *ld = ldcore_get_safe_token(device);
197   ld->player->data_ready_cb = callback;
198}
199
200
201
202/***************************************************************************
203    PHILLIPS 22VP931 IMPLEMENTATION
204***************************************************************************/
205
206/*-------------------------------------------------
207    vp931_init - Pioneer PR-8210-specific
208    initialization
209-------------------------------------------------*/
210
211static void vp931_init(laserdisc_state *ld)
212{
213   astring *tempstring = astring_alloc();
214   ldplayer_data *player = ld->player;
215
216   /* find our CPU */
217   astring_printf(tempstring, "%s:%s", ld->device->tag, "vp931");
218   player->cpunum = mame_find_cpu_index(ld->device->machine, astring_c(tempstring));
219
220   /* find our timer */
221   astring_printf(tempstring, "%s:%s", ld->device->tag, "tracktimer");
222   player->tracktimer = device_list_find_by_tag(ld->device->machine->config->devicelist, TIMER, astring_c(tempstring));
223   timer_device_set_ptr(player->tracktimer, ld);
224
225   astring_free(tempstring);
226}
227
228
229/*-------------------------------------------------
230    vp931_vsync - VSYNC callback, called at the
231    start of the blanking period
232-------------------------------------------------*/
233
234static void vp931_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int fieldnum, attotime curtime)
235{
236   /* reset our command counter (debugging only) */
237   ld->player->cmdcount = 0;
238
239   /* set the ERP signal to 1 to indicate start of frame, and set a timer to turn it off */
240   ld->player->daticerp = 1;
241   timer_set(video_screen_get_time_until_pos(ld->screen, 15*2, 0), ld, 0, erp_off);
242}
243
244
245/*-------------------------------------------------
246    vp931_update - update callback, called on
247    the first visible line of the frame
248-------------------------------------------------*/
249
250static INT32 vp931_update(laserdisc_state *ld, const vbi_metadata *vbi, int fieldnum, attotime curtime)
251{
252   /* set the first VBI timer to go at the start of line 16 */
253   timer_set(video_screen_get_time_until_pos(ld->screen, 16*2, 0), ld, LASERDISC_CODE_LINE16 << 2, vbi_data_fetch);
254
255   /* play forward by default */
256   return fieldnum;
257}
258
259
260/*-------------------------------------------------
261    vp931_data_w - handle a parallel data write
262    to the 22VP931
263-------------------------------------------------*/
264
265static void vp931_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data)
266{
267   /* set a timer to synchronize execution before sending the data */
268   timer_call_after_resynch(ld, data, deferred_data_w);
269}
270
271
272/*-------------------------------------------------
273    vp931_data_r - handle a parallel data read
274    from the 22VP931
275-------------------------------------------------*/
276
277static UINT8 vp931_data_r(laserdisc_state *ld)
278{
279   ldplayer_data *player = ld->player;
280
281   /* if data is pending, clear the pending flag and notify any callbacks */
282   if (player->tocontroller_pending)
283   {
284      player->tocontroller_pending = FALSE;
285      if (player->data_ready_cb != NULL)
286         (*player->data_ready_cb)(ld->device, FALSE);
287   }
288
289   /* also boost interleave for 4 scanlines to ensure proper communications */
290   cpu_boost_interleave(attotime_zero, attotime_mul(video_screen_get_scan_period(ld->screen), 4));
291   return player->tocontroller;
292}
293
294
295/*-------------------------------------------------
296    vp931_ready - return the status of "ready"
297    to the caller (ready to accept another
298    command)
299-------------------------------------------------*/
300
301static UINT8 vp931_ready(laserdisc_state *ld)
302{
303   /* if data is pending, we are not ready */
304   ldplayer_data *player = ld->player;
305   return player->fromcontroller_pending ? CLEAR_LINE : ASSERT_LINE;
306}
307
308
309/*-------------------------------------------------
310    vp931_data_ready - return the status of
311    "data available" to the caller
312-------------------------------------------------*/
313
314static UINT8 vp931_data_ready(laserdisc_state *ld)
315{
316   ldplayer_data *player = ld->player;
317   return player->tocontroller_pending ? ASSERT_LINE : CLEAR_LINE;
318}
319
320
321/*-------------------------------------------------
322    output0_w - controls audio/video squelch
323    and other bits
324-------------------------------------------------*/
325
326static WRITE8_HANDLER( output0_w )
327{
328   laserdisc_state *ld = find_vp931(machine);
329   ldplayer_data *player = ld->player;
330
331   /*
332        $80 = n/c
333        $40 = LED (?) -> C335
334        $20 = LED (?)
335        $10 = LED (?) -> CX
336        $08 = EJECT
337        $04 = inverted -> AUDIO MUTE II
338        $02 = inverted -> AUDIO MUTE I
339        $01 = inverted -> VIDEO MUTE
340    */
341
342   if (LOG_PORTS && (player->out0 ^ data) & 0xff)
343   {
344      printf("%03X:out0:", activecpu_get_pc());
345      if ( (data & 0x80)) printf(" ???");
346      if ( (data & 0x40)) printf(" LED1");
347      if ( (data & 0x20)) printf(" LED2");
348      if ( (data & 0x10)) printf(" LED3");
349      if ( (data & 0x08)) printf(" EJECT");
350      if (!(data & 0x04)) printf(" AUDMUTE2");
351      if (!(data & 0x02)) printf(" AUDMUTE1");
352      if (!(data & 0x01)) printf(" VIDMUTE");
353      printf("\n");
354      player->out0 = data;
355   }
356
357   /* update a/v squelch */
358   ldcore_set_audio_squelch(ld, !(data & 0x02), !(data & 0x04));
359   ldcore_set_video_squelch(ld, !(data & 0x01));
360}
361
362
363/*-------------------------------------------------
364    output1_w - controls scanning behaviors
365-------------------------------------------------*/
366
367static WRITE8_HANDLER( output1_w )
368{
369   laserdisc_state *ld = find_vp931(machine);
370   ldplayer_data *player = ld->player;
371   INT32 speed = 0;
372
373   /*
374        $80 = n/c
375        $40 = n/c
376        $20 = n/c
377        $10 = n/c
378        $08 = inverted -> SMS
379        $04 = inverted -> SSS
380        $02 = inverted -> SCAN CMD
381        $01 = OSM
382    */
383
384   if (LOG_PORTS && (player->out1 ^ data) & 0x08)
385   {
386      mame_printf_debug("%03X:out1:", activecpu_get_pc());
387      if (!(data & 0x08)) mame_printf_debug(" SMS");
388      mame_printf_debug("\n");
389      player->out1 = data;
390   }
391
392   /* speed is 0 unless SCAN CMD is clear */
393   speed = 0;
394   if (!(data & 0x02))
395   {
396      /* fast/slow is based on bit 2 */
397      speed = (data & 0x04) ? VP931_SCAN_FAST_SPEED : VP931_SCAN_SPEED;
398
399      /* direction is based on bit 0 */
400      if (data & 0x01)
401         speed = -speed;
402   }
403
404   /* update the speed */
405   ldcore_set_slider_speed(ld, speed);
406}
407
408
409/*-------------------------------------------------
410    lcd_w - vestigial LCD frame display
411-------------------------------------------------*/
412
413static WRITE8_HANDLER( lcd_w )
414{
415   /*
416        Frame number is written as 5 digits here; however, it is not actually
417        connected
418    */
419}
420
421
422/*-------------------------------------------------
423    keypad_r - vestigial keypad/button controls
424-------------------------------------------------*/
425
426static READ8_HANDLER( keypad_r )
427{
428   /*
429        From the code, this is apparently a vestigial keypad with basic controls:
430            $01 = play
431            $02 = still
432            $04 = jump 25 frames backward
433            $08 = jump 25 frames forward
434            $10 = search for frame 50(?)
435            $20 = search for frame 350(?)
436            $40 = reset
437            $80 = play reverse
438    */
439   return 0x00;
440}
441
442
443/*-------------------------------------------------
444    datic_r - read the latched value from the
445    DATIC circuit
446-------------------------------------------------*/
447
448static READ8_HANDLER( datic_r )
449{
450   laserdisc_state *ld = find_vp931(machine);
451   return ld->player->daticval;
452}
453
454
455/*-------------------------------------------------
456    from_controller_r - read the value the
457    external controller wrote
458-------------------------------------------------*/
459
460static READ8_HANDLER( from_controller_r )
461{
462   laserdisc_state *ld = find_vp931(machine);
463   ldplayer_data *player = ld->player;
464
465   /* clear the pending flag and return the data */
466   player->fromcontroller_pending = FALSE;
467   return player->fromcontroller;
468}
469
470
471/*-------------------------------------------------
472    to_controller_w - write a value back to the
473    external controller
474-------------------------------------------------*/
475
476static WRITE8_HANDLER( to_controller_w )
477{
478   laserdisc_state *ld = find_vp931(machine);
479   ldplayer_data *player = ld->player;
480
481   /* set the pending flag and stash the data */
482   player->tocontroller_pending = TRUE;
483   player->tocontroller = data;
484
485   /* signal to the callback if provided */
486   if (player->data_ready_cb != NULL)
487      (*player->data_ready_cb)(ld->device, TRUE);
488
489   /* also boost interleave for 4 scanlines to ensure proper communications */
490   cpu_boost_interleave(attotime_zero, attotime_mul(video_screen_get_scan_period(ld->screen), 4));
491}
492
493
494/*-------------------------------------------------
495    port1_r - read the 8048 I/O port 1
496-------------------------------------------------*/
497
498static READ8_HANDLER( port1_r )
499{
500   laserdisc_state *ld = find_vp931(machine);
501   ldplayer_data *player = ld->player;
502   UINT8 result = 0x00;
503
504   /*
505        $80 = P17 = (in) unsure
506        $40 = P16 = (in) /ERP from datic circuit
507        $20 = P15 = (in) D105
508    */
509
510   if (!player->daticerp)
511      result |= 0x40;
512
513   return result;
514}
515
516
517/*-------------------------------------------------
518    port1_w - write the 8048 I/O port 1
519-------------------------------------------------*/
520
521static WRITE8_HANDLER( port1_w )
522{
523   laserdisc_state *ld = find_vp931(machine);
524   ldplayer_data *player = ld->player;
525
526   /*
527        $10 = P14 = (out) D104 -> /SPEED
528        $08 = P13 = (out) D103 -> /TIMER ENABLE
529        $04 = P12 = (out) D102 -> /REV
530        $02 = P11 = (out) D101 -> /FORW
531        $01 = P10 = (out) D100 -> some op-amp then to C334, B56, B332
532    */
533
534   if (LOG_PORTS && (player->port1 ^ data) & 0x1f)
535   {
536      printf("%03X:port1:", activecpu_get_pc());
537      if (!(data & 0x10)) printf(" SPEED");
538      if (!(data & 0x08)) printf(" TIMENABLE");
539      if (!(data & 0x04)) printf(" REV");
540      if (!(data & 0x02)) printf(" FORW");
541      if (!(data & 0x01)) printf(" OPAMP");
542      printf("\n");
543   }
544
545   /* if bit 0 is set, we are not tracking */
546   if (data & 0x01)
547      player->trackdir = 0;
548
549   /* if bit 0 is clear and we weren't tracking before, initialize the state */
550   else if (player->trackdir == 0)
551   {
552      player->advanced = 0;
553
554      /* if bit 2 is clear, we are moving backwards */
555      if (!(data & 0x04))
556      {
557         player->trackdir = -1;
558         player->trackstate = 1;
559      }
560
561      /* if bit 1 is clear, we are moving forward */
562      else if (!(data & 0x02))
563      {
564         player->trackdir = 1;
565         player->trackstate = 0;
566      }
567   }
568
569   /* if we have a timer, adjust it */
570   if (player->tracktimer != NULL)
571   {
572      /* turn it off if we're not tracking */
573      if (player->trackdir == 0)
574         timer_device_adjust_periodic(player->tracktimer, attotime_never, 0, attotime_never);
575
576      /* if we just started tracking, or if the speed was changed, reprime the timer */
577      else if (((player->port1 ^ data) & 0x11) != 0)
578      {
579         /* speeds here are just guesses, but work with the player logic; this is the time per half-track */
580         attotime speed = (data & 0x10) ? ATTOTIME_IN_USEC(60) : ATTOTIME_IN_USEC(10);
581
582         /* always start with an initial long delay; the code expects this */
583         timer_device_adjust_periodic(player->tracktimer, ATTOTIME_IN_USEC(100), 0, speed);
584      }
585   }
586
587   player->port1 = data;
588}
589
590
591/*-------------------------------------------------
592    port2_r - read from the 8048 I/O port 2
593-------------------------------------------------*/
594
595static READ8_HANDLER( port2_r )
596{
597   laserdisc_state *ld = find_vp931(machine);
598   ldplayer_data *player = ld->player;
599   UINT8 result = 0x00;
600
601   /*
602        $80 = P27 = (in) set/reset latch; set by FOC LS, reset by IGR
603        $20 = P25 = (in) D125 -> 0 when data written to controller is preset, reset to 1 when read
604        $10 = P24 = (in) D124 -> 0 when data from controller is present, reset to 1 on a read
605    */
606
607   if (!player->tocontroller_pending)
608      result |= 0x20;
609   if (!player->fromcontroller_pending)
610      result |= 0x10;
611
612   return result;
613}
614
615
616/*-------------------------------------------------
617    port2_w - write the 8048 I/O port 2
618-------------------------------------------------*/
619
620static WRITE8_HANDLER( port2_w )
621{
622   /*
623        $40 = P26 = (out) cleared while data is sent back & forth; set afterwards
624                    [Not actually connected, but this is done in the code]
625    */
626}
627
628
629/*-------------------------------------------------
630    t0_r - return the T0 line status, which is
631    connected to the DATIC's data strobe line
632-------------------------------------------------*/
633
634static READ8_HANDLER( t0_r )
635{
636   laserdisc_state *ld = find_vp931(machine);
637   return ld->player->datastrobe;
638}
639
640
641/*-------------------------------------------------
642    t1_r - return the T1 line status, which is
643    connected to the tracking state and is used
644    to count the number of tracks advanced
645-------------------------------------------------*/
646
647static READ8_HANDLER( t1_r )
648{
649   laserdisc_state *ld = find_vp931(machine);
650   return ld->player->trackstate;
651}
652
653
654/*-------------------------------------------------
655    vbi_data_fetch - called 4 times per scanline
656    on lines 16, 17, and 18 to feed the VBI data
657    through one byte at a time
658-------------------------------------------------*/
659
660static TIMER_CALLBACK( vbi_data_fetch )
661{
662   laserdisc_state *ld = ptr;
663   ldplayer_data *player = ld->player;
664   int which = param & 3;
665   int line = param >> 2;
666   UINT32 code = 0;
667
668   /* fetch the code and compute the DATIC latched value */
669   if (line >= LASERDISC_CODE_LINE16 && line <= LASERDISC_CODE_LINE18)
670      code = laserdisc_get_field_code(ld->device, line);
671
672   /* at the start of each line, signal an interrupt and use a timer to turn it off */
673   if (which == 0)
674   {
675      cpunum_set_input_line(machine, player->cpunum, MCS48_INPUT_IRQ, ASSERT_LINE);
676      timer_set(ATTOTIME_IN_NSEC(5580), ld, 0, irq_off);
677   }
678
679   /* clock the data strobe on each subsequent callback */
680   else if (code != 0)
681   {
682      player->daticval = code >> (8 * (3 - which));
683      player->datastrobe = 1;
684      timer_set(ATTOTIME_IN_NSEC(5000), ld, 0, datastrobe_off);
685   }
686
687   /* determine the next bit to fetch and reprime ourself */
688   if (++which == 4)
689   {
690      which = 0;
691      line++;
692   }
693   if (line <= LASERDISC_CODE_LINE18 + 1)
694      timer_set(video_screen_get_time_until_pos(ld->screen, line*2, which * 2 * video_screen_get_width(ld->screen) / 4), ld, (line << 2) | which, vbi_data_fetch);
695}
696
697
698/*-------------------------------------------------
699    deferred_data_w - handle a write from the
700    external controller
701-------------------------------------------------*/
702
703static TIMER_CALLBACK( deferred_data_w )
704{
705   laserdisc_state *ld = ptr;
706   ldplayer_data *player = ld->player;
707
708   /* set the value and mark it pending */
709   player->fromcontroller = param;
710   player->fromcontroller_pending = TRUE;
711
712   /* track the commands for debugging purposes */
713   if (player->cmdcount < ARRAY_LENGTH(player->cmdbuf))
714   {
715      player->cmdbuf[player->cmdcount++] = param;
716      if (LOG_COMMANDS && player->cmdcount == 3)
717         printf("Cmd: %02X %02X %02X\n", player->cmdbuf[0], player->cmdbuf[1], player->cmdbuf[2]);
718   }
719}
720
721
722/*-------------------------------------------------
723    irq_off - turn off the 8048 IRQ signal
724-------------------------------------------------*/
725
726static TIMER_CALLBACK( irq_off )
727{
728   laserdisc_state *ld = ptr;
729   cpunum_set_input_line(machine, ld->player->cpunum, MCS48_INPUT_IRQ, CLEAR_LINE);
730}
731
732
733/*-------------------------------------------------
734    datastrobe_off - turn off the DATIC data
735    strobe signal
736-------------------------------------------------*/
737
738static TIMER_CALLBACK( datastrobe_off )
739{
740   laserdisc_state *ld = ptr;
741   ld->player->datastrobe = 0;
742}
743
744
745/*-------------------------------------------------
746    erp_off - turn off the DATIC ERP signal
747-------------------------------------------------*/
748
749static TIMER_CALLBACK( erp_off )
750{
751   laserdisc_state *ld = ptr;
752   ld->player->daticerp = 0;
753}
754
755
756/*-------------------------------------------------
757    track_timer - advance by one half-track
758-------------------------------------------------*/
759
760static TIMER_DEVICE_CALLBACK( track_timer )
761{
762   laserdisc_state *ld = ptr;
763   ldplayer_data *player = ld->player;
764
765   /* advance by the count and toggle the state */
766   player->trackstate ^= 1;
767   if ((player->trackdir < 0 && !player->trackstate) || (player->trackdir > 0 && player->trackstate))
768   {
769      ldcore_advance_slider(ld, player->trackdir);
770      player->advanced += player->trackdir;
771   }
772}
src/emu/machine/laserdsc.h
r3333r3334
3737/* laserdisc control lines */
3838#define LASERDISC_LINE_ENTER      0         /* "ENTER" key/line */
3939#define LASERDISC_LINE_CONTROL      1         /* "CONTROL" line */
40#define LASERDISC_INPUT_LINES      2
40#define LASERDISC_LINE_RESET      2         /* "RESET" line */
41#define LASERDISC_INPUT_LINES      3
4142
4243/* laserdisc status lines */
4344#define LASERDISC_LINE_READY      0         /* "READY" line */
r3333r3334
4748#define LASERDISC_OUTPUT_LINES      4
4849
4950/* laserdisc field codes */
50#define LASERDISC_CODE_WHITE_FLAG   0         /* boolean white flag */
51#define LASERDISC_CODE_LINE16      1         /* 24-bit line 16 code */
52#define LASERDISC_CODE_LINE17      2         /* 24-bit line 17 code */
53#define LASERDISC_CODE_LINE18      3         /* 24-bit line 18 code */
54#define LASERDISC_CODE_LINE1718      4         /* 24-bit best of line 17/18 code */
51#define LASERDISC_CODE_WHITE_FLAG   11         /* boolean white flag */
52#define LASERDISC_CODE_LINE16      16         /* 24-bit line 16 code */
53#define LASERDISC_CODE_LINE17      17         /* 24-bit line 17 code */
54#define LASERDISC_CODE_LINE18      18         /* 24-bit line 18 code */
55#define LASERDISC_CODE_LINE1718      1718      /* 24-bit best of line 17/18 code */
5556
5657/* device configuration */
5758enum
r3333r3334
161162int laserdisc_get_video(const device_config *device, bitmap_t **bitmap);
162163
163164/* return the raw philips or white flag codes */
164UINT32 laserdisc_get_field_code(const device_config *device, UINT8 code);
165UINT32 laserdisc_get_field_code(const device_config *device, UINT32 code);
165166
166167
167168
r3333r3334
186187/* specify the "slow" speed of the Pioneer PR-7820 */
187188void pr7820_set_slow_speed(const device_config *device, double frame_rate_scaler);
188189
190/* set a callback for data ready on the Phillips 22VP931 */
191void vp931_set_data_ready_callback(const device_config *device, void (*callback)(const device_config *device, int state));
192
189193/* control the audio squelch of the Simutrek modified players */
190194void simutrek_set_audio_squelch(const device_config *device, int state);
191195
src/emu/machine/ldcore.c
r3333r3334
151151   &simutrek_interface,
152152   &ldv1000_interface,
153153//  &ldp1450_interface,
154//  &vp932_interface
154//  &vp932_interface,
155   &vp931_interface
155156};
156157
157158const custom_sound_interface laserdisc_custom_interface =
r3333r3334
560561    information read from the disc
561562-------------------------------------------------*/
562563
563UINT32 laserdisc_get_field_code(const device_config *device, UINT8 code)
564UINT32 laserdisc_get_field_code(const device_config *device, UINT32 code)
564565{
565566   laserdisc_state *ld = get_safe_token(device);
566567   ldcore_data *ldcore = ld->core;
r3333r3334
888889   ldcore_data *ldcore = ld->core;
889890   UINT32 tracknum = ldcore->curtrack;
890891   UINT32 fieldnum = ldcore->fieldnum;
892   UINT32 curfield = tracknum * 2 + fieldnum;
891893   frame_data *frame;
892894   UINT32 vbiframe;
893895   UINT32 readhunk;
894896   INT32 chdtrack;
895897
896   /* if the previous field had a frame number, and the new field immediately follows it,
897       force the new field to pair with the previous one */
898898   frame = &ldcore->frame[ldcore->videoindex];
899   if ((ldcore->metadata[fieldnum ^ 1].line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE && (tracknum * 2 + fieldnum == frame->lastfield + 1))
900      frame->numfields = 1;
901899
902   /* otherwise, keep the frames in sync with the absolute field numbers */
903   else if (frame->numfields == 2 && fieldnum != 0)
904      frame->numfields--;
900   /* special cases for playing forward */
901   if (curfield == frame->lastfield + 1)
902   {
903      /* if the previous field had a frame number, force the new field to pair with the previous one */
904      if ((ldcore->metadata[fieldnum ^ 1].line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE)
905         frame->numfields = 1;
905906
906   /* if we already have both fields on the current videoindex, advance */
907   else if (frame->numfields >= 2)
907      /* if the twice-previous field was a frame number, and we've moved one since then, consider this one done */
908      else if (frame->numfields >= 2 && (ldcore->metadata[fieldnum].line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE)
909      {
910         ldcore->videoindex = (ldcore->videoindex + 1) % ARRAY_LENGTH(ldcore->frame);
911         frame = &ldcore->frame[ldcore->videoindex];
912         frame->numfields = 0;
913      }
914   }
915
916   /* all other cases */
917   else
908918   {
909      ldcore->videoindex = (ldcore->videoindex + 1) % ARRAY_LENGTH(ldcore->frame);
910      frame = &ldcore->frame[ldcore->videoindex];
911      frame->numfields = 0;
919      /* otherwise, keep the frames in sync with the absolute field numbers */
920      if (frame->numfields == 2 && fieldnum != 0)
921         frame->numfields--;
922
923      /* if we already have both fields on the current videoindex, advance */
924      else if (frame->numfields >= 2)
925      {
926         ldcore->videoindex = (ldcore->videoindex + 1) % ARRAY_LENGTH(ldcore->frame);
927         frame = &ldcore->frame[ldcore->videoindex];
928         frame->numfields = 0;
929      }
912930   }
913931
914932   /* if we're squelched, reset the frame counter */
r3333r3334
13331351         rectangle clip = *cliprect;
13341352
13351353         /* scale the cliprect to the overlay size and then call the update callback */
1336         clip.min_x = 0;
1337         clip.max_x = ldcore->config.overwidth - 1;
1354         clip.min_x = ldcore->config.overclip.min_x;
1355         clip.max_x = ldcore->config.overclip.max_x;
13381356         clip.min_y = cliprect->min_y * overbitmap->height / bitmap->height;
13391357         if (cliprect->min_y == visarea->min_y)
13401358            clip.min_y = MIN(clip.min_y, ldcore->config.overclip.min_y);
src/emu/machine/ldcore.h
r3333r3334
172172extern const ldplayer_interface simutrek_interface;
173173extern const ldplayer_interface ldv1000_interface;
174174extern const ldplayer_interface ldp1450_interface;
175extern const ldplayer_interface vp931_interface;
175176extern const ldplayer_interface vp932_interface;
176177
177178
src/emu/sound/multipcm.c
r3333r3334
182182   return lin2expvol[slot->EG.volume>>EG_SHIFT];
183183}
184184
185unsigned int Get_RATE(unsigned int *Steps,unsigned int rate,unsigned int val)
185static unsigned int Get_RATE(unsigned int *Steps,unsigned int rate,unsigned int val)
186186{
187187   int r=4*val+rate;
188188   if(val==0)
r3333r3334
312312
313313
314314
315void WriteSlot(struct _MultiPCM *ptChip,struct _SLOT *slot,int reg,unsigned char data)
315static void WriteSlot(struct _MultiPCM *ptChip,struct _SLOT *slot,int reg,unsigned char data)
316316{
317317   slot->Regs[reg]=data;
318318
r3333r3334
481481   }
482482}
483483
484unsigned char multi_pcm_reg_r(int chip, int offset)
484static unsigned char multi_pcm_reg_r(int chip, int offset)
485485{
486486//  struct _MultiPCM *ptChip = sndti_token(SOUND_MULTIPCM, chip);
487487   return 0;
src/emu/ui.c
r3333r3334
263263
264264static int rescale_notifier(running_machine *machine, int width, int height)
265265{
266   /* always allow "small" rescaling */
267   if (width < 500 || height < 500)
266   /* always allow rescaling for a "small" area and for screenless drivers */
267   if (width < 500 || height < 500 || machine->primary_screen == NULL)
268268      return TRUE;
269269
270270   /* if we've currently disallowed rescaling, turn on a message next frame */
src/emu/debugger.h
r3333r3334
8282INLINE void debugger_break(running_machine *machine)
8383{
8484   if ((machine->debug_flags & DEBUG_FLAG_ENABLED) != 0)
85      debug_cpu_halt_on_next_instruction(machine, "Internal breakpoint\n");
85      debug_cpu_halt_on_next_instruction(machine, cpu_getactivecpu(), "Internal breakpoint\n");
8686}
8787
8888
src/emu/clifront.c
r3333r3334
484484   for (drvindex = 0; drivers[drvindex]; drvindex++)
485485      if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
486486      {
487         machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
487488         const rom_entry *region, *rom, *chunk;
489         const rom_source *source;
488490
489491         /* print the header */
490492         if (count > 0)
r3333r3334
492494         mame_printf_info("This is the list of the ROMs required for driver \"%s\".\n"
493495               "Name            Size Checksum\n", drivers[drvindex]->name);
494496
495         /* iterate over regions and then ROMs within the region */
496         for (region = drivers[drvindex]->rom; region; region = rom_next_region(region))
497            for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
498            {
499               const char *name = ROM_GETNAME(rom);
500               const char* hash = ROM_GETHASHDATA(rom);
501               char hashbuf[HASH_BUF_SIZE];
502               int length = -1;
503
504               /* accumulate the total length of all chunks */
505               if (ROMREGION_ISROMDATA(region))
497         /* iterate over sources, regions and then ROMs within the region */
498         for (source = rom_first_source(drivers[drvindex], config); source != NULL; source = rom_next_source(drivers[drvindex], config, source))
499            for (region = rom_first_region(drivers[drvindex], source); region != NULL; region = rom_next_region(region))
500               for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
506501               {
507                  length = 0;
508                  for (chunk = rom_first_chunk(rom); chunk; chunk = rom_next_chunk(chunk))
509                     length += ROM_GETLENGTH(chunk);
510               }
502                  const char *name = ROM_GETNAME(rom);
503                  const char *hash = ROM_GETHASHDATA(rom);
504                  char hashbuf[HASH_BUF_SIZE];
505                  int length = -1;
511506
512               /* start with the name */
513               mame_printf_info("%-12s ", name);
507                  /* accumulate the total length of all chunks */
508                  if (ROMREGION_ISROMDATA(region))
509                  {
510                     length = 0;
511                     for (chunk = rom_first_chunk(rom); chunk; chunk = rom_next_chunk(chunk))
512                        length += ROM_GETLENGTH(chunk);
513                  }
514514
515               /* output the length next */
516               if (length >= 0)
517                  mame_printf_info("%7d", length);
518               else
519                  mame_printf_info("       ");
515                  /* start with the name */
516                  mame_printf_info("%-12s ", name);
520517
521               /* output the hash data */
522               if (!hash_data_has_info(hash, HASH_INFO_NO_DUMP))
523               {
524                  if (hash_data_has_info(hash, HASH_INFO_BAD_DUMP))
525                     mame_printf_info(" BAD");
518                  /* output the length next */
519                  if (length >= 0)
520                     mame_printf_info("%7d", length);
521                  else
522                     mame_printf_info("       ");
526523
527                  hash_data_print(hash, 0, hashbuf);
528                  mame_printf_info(" %s", hashbuf);
524                  /* output the hash data */
525                  if (!hash_data_has_info(hash, HASH_INFO_NO_DUMP))
526                  {
527                     if (hash_data_has_info(hash, HASH_INFO_BAD_DUMP))
528                        mame_printf_info(" BAD");
529
530                     hash_data_print(hash, 0, hashbuf);
531                     mame_printf_info(" %s", hashbuf);
532                  }
533                  else
534                     mame_printf_info(" NO GOOD DUMP KNOWN");
535
536                  /* end with a CR */
537                  mame_printf_info("\n");
529538               }
530               else
531                  mame_printf_info(" NO GOOD DUMP KNOWN");
532539
533               /* end with a CR */
534               mame_printf_info("\n");
535            }
536
537540         count++;
541         machine_config_free(config);
538542      }
539543
540544   return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
src/emu/timer.c
r3333r3334
572572
573573void timer_device_adjust_oneshot(const device_config *timer, attotime duration, INT32 param)
574574{
575#ifndef NDEBUG
575#ifdef MAME_DEBUG
576576   timer_config *config = timer->inline_config;
577577
578   /* only makes sense for periodic timers */
579   assert(config->type == TIMER_TYPE_PERIODIC);
578   /* doesn't make sense for scanline timers */
579   assert(config->type != TIMER_TYPE_SCANLINE);
580580#endif
581581
582582   timer_device_adjust_periodic(timer, duration, param, attotime_never);
r3333r3334
624624void timer_device_adjust_periodic(const device_config *timer, attotime start_delay, INT32 param, attotime period)
625625{
626626   timer_state *state = get_safe_token(timer);
627#ifndef NDEBUG
627#ifdef MAME_DEBUG
628628   timer_config *config = timer->inline_config;
629629
630   /* only makes sense for periodic timers */
631   assert(config->type == TIMER_TYPE_PERIODIC);
630   /* doesn't make sense for scanline timers */
631   assert(config->type != TIMER_TYPE_SCANLINE);
632632#endif
633633
634634   state->start_delay = start_delay;
r3333r3334
688688void timer_device_reset(const device_config *timer)
689689{
690690   timer_state *state = get_safe_token(timer);
691#ifndef NDEBUG
691#ifdef MAME_DEBUG
692692   timer_config *config = timer->inline_config;
693693
694   /* only makes sense for periodic timers */
695   assert(config->type == TIMER_TYPE_PERIODIC);
694   /* doesn't make sense for scanline timers */
695   assert(config->type != TIMER_TYPE_SCANLINE);
696696#endif
697697
698698   timer_adjust_periodic(state->timer, state->start_delay, 0, state->period);
r3333r3334
745745
746746
747747/*-------------------------------------------------
748    timer_get_param
749    timer_get_param_ptr - returns the callback
748    timer_get_param - returns the callback
750749    parameter of a timer
751750-------------------------------------------------*/
752751
r3333r3334
759758int timer_device_get_param(const device_config *timer)
760759{
761760   timer_state *state = get_safe_token(timer);
762#ifndef NDEBUG
761#ifdef MAME_DEBUG
763762   timer_config *config = timer->inline_config;
764763
765   /* only makes sense for periodic timers */
766   assert(config->type == TIMER_TYPE_PERIODIC);
764   /* doesn't make sense for scanline timers */
765   assert(config->type != TIMER_TYPE_SCANLINE);
767766#endif
768767
769768   return state->param;
770769}
771770
772771
773void *timer_get_param_ptr(emu_timer *which)
772/*-------------------------------------------------
773    timer_set_param - changes the callback
774    parameter of a timer
775-------------------------------------------------*/
776
777void timer_set_param(emu_timer *which, int param)
774778{
779   which->param = param;
780}
781
782
783void timer_device_set_param(const device_config *timer, int param)
784{
785   timer_state *state = get_safe_token(timer);
786#ifdef MAME_DEBUG
787   timer_config *config = timer->inline_config;
788
789   /* doesn't make sense for scanline timers */
790   assert(config->type != TIMER_TYPE_SCANLINE);
791#endif
792
793   state->param = param;
794}
795
796
797/*-------------------------------------------------
798    timer_get_ptr - returns the callback pointer
799    of a timer
800-------------------------------------------------*/
801
802void *timer_get_ptr(emu_timer *which)
803{
775804   return which->ptr;
776805}
777806
778807
779void *timer_device_get_param_ptr(const device_config *timer)
808void *timer_device_get_ptr(const device_config *timer)
780809{
781810   timer_state *state = get_safe_token(timer);
782811   return state->ptr;
783812}
784813
785814
815/*-------------------------------------------------
816    timer_set_ptr - changes the callback pointer
817    of a timer
818-------------------------------------------------*/
819
820void timer_set_ptr(emu_timer *which, void *ptr)
821{
822   which->ptr = ptr;
823}
824
825
826void timer_device_set_ptr(const device_config *timer, void *ptr)
827{
828   timer_state *state = get_safe_token(timer);
829   state->ptr = ptr;
830}
831
832
833
786834/***************************************************************************
787835    TIMING FUNCTIONS
788836***************************************************************************/
r3333r3334
9941042
9951043   /* get and validate the configuration */
9961044   config = device->inline_config;
997   assert((config->type == TIMER_TYPE_PERIODIC) || (config->type == TIMER_TYPE_SCANLINE));
1045   assert(config->type == TIMER_TYPE_PERIODIC || config->type == TIMER_TYPE_SCANLINE || config->type == TIMER_TYPE_GENERIC);
9981046   assert(config->callback != NULL);
9991047
10001048   /* copy the pointer parameter */
r3333r3334
10071055   /* type based configuration */
10081056   switch (config->type)
10091057   {
1058      case TIMER_TYPE_GENERIC:
1059         /* make sure that only the applicable parameters are filled in */
1060         assert(config->screen == NULL);
1061         assert(config->first_vpos == 0);
1062         assert(config->increment == 0);
1063         assert(config->start_delay == 0);
1064         assert(config->period == 0);
1065
1066         /* copy the optional integer parameter */
1067         state->param = config->param;
1068
1069         /* convert the start_delay and period into attotime */
1070         state->period = attotime_never;
1071         state->start_delay = attotime_zero;
1072
1073         /* register for state saves */
1074         state_save_register_item(unique_tag, 0, state->param);
1075
1076         /* allocate the backing timer */
1077         param = (void *)device;
1078         state->timer = timer_alloc(periodic_timer_device_timer_callback, param);
1079         break;
1080
10101081      case TIMER_TYPE_PERIODIC:
10111082         /* make sure that only the applicable parameters are filled in */
10121083         assert(config->screen == NULL);
src/emu/cheat.c
r3333r3334
221221    the format
222222-------------------------------------------------*/
223223
224const char *format_int(astring *string, UINT64 value, int format)
224static const char *format_int(astring *string, UINT64 value, int format)
225225{
226226   switch (format)
227227   {
src/emu/timer.h
r3333r3334
2828enum
2929{
3030   TIMER_TYPE_PERIODIC = 0,
31   TIMER_TYPE_SCANLINE
31   TIMER_TYPE_SCANLINE,
32   TIMER_TYPE_GENERIC
3233};
3334
3435
r3333r3334
105106    TIMER DEVICE CONFIGURATION MACROS
106107***************************************************************************/
107108
109#define MDRV_TIMER_ADD(_tag, _callback) \
110   MDRV_DEVICE_ADD(_tag, TIMER) \
111   MDRV_DEVICE_CONFIG_DATA32(timer_config, type, TIMER_TYPE_GENERIC) \
112   MDRV_DEVICE_CONFIG_DATAPTR(timer_config, callback, _callback) \
113
108114#define MDRV_TIMER_ADD_PERIODIC(_tag, _callback, _period) \
109115   MDRV_DEVICE_ADD(_tag, TIMER) \
110116   MDRV_DEVICE_CONFIG_DATA32(timer_config, type, TIMER_TYPE_PERIODIC) \
r3333r3334
224230int timer_get_param(emu_timer *which);
225231int timer_device_get_param(const device_config *timer);
226232
227void *timer_get_param_ptr(emu_timer *which);
228void *timer_device_get_param_ptr(const device_config *timer);
233/* changes the callback parameter of a timer */
234void timer_set_param(emu_timer *which, int param);
235void timer_device_set_param(const device_config *timer, int param);
229236
237/* returns the callback pointer of a timer */
238void *timer_get_ptr(emu_timer *which);
239void *timer_device_get_ptr(const device_config *timer);
230240
241/* changes the callback pointer of a timer */
242void timer_set_ptr(emu_timer *which, void *ptr);
243void timer_device_set_ptr(const device_config *timer, void *ptr);
231244
245
246
232247/* ----- timing functions ----- */
233248
234249/* return the time since the last trigger */
src/lib/util/png.c
r3333r3334
5858}
5959
6060
61#ifdef UNUSED_FUNCTON
61#ifdef UNUSED_FUNCTION
6262INLINE UINT16 fetch_16bit(UINT8 *v)
6363{
6464   return BIG_ENDIANIZE_INT16(*(UINT16 *)v);
r3333r3334
7777}
7878
7979
80#ifdef UNUSED_FUNCTON
80#ifdef UNUSED_FUNCTION
8181INLINE void put_16bit(UINT8 *v, UINT16 data)
8282{
8383   *(UINT16 *)v = BIG_ENDIANIZE_INT16(data);
src/lib/util/bitmap.c
r3333r3334
198198         }
199199         else
200200         {
201            for (y = fill.min_y; y <= fill.max_y; y++)
201            UINT16 *destrow, *destrow0;
202
203            /* Fill the first line the hard way */
204            destrow  = BITMAP_ADDR16(dest, fill.min_y, 0);
205            for (x = fill.min_x; x <= fill.max_x; x++)
206               destrow[x] = (UINT16)color;
207
208            /* For the other lines, just copy the first one */
209            destrow0 = BITMAP_ADDR16(dest, fill.min_y, fill.min_x);
210            for (y = fill.min_y + 1; y <= fill.max_y; y++)
202211            {
203               UINT16 *destrow = BITMAP_ADDR16(dest, y, 0);
204               for (x = fill.min_x; x <= fill.max_x; x++)
205                  destrow[x] = (UINT16)color;
212               destrow = BITMAP_ADDR16(dest, y, fill.min_x);
213               memcpy(destrow, destrow0, (fill.max_x + 1 - fill.min_x) * 2);
206214            }
207215         }
208216         break;
r3333r3334
216224         }
217225         else
218226         {
219            for (y = fill.min_y; y <= fill.max_y; y++)
227            UINT32 *destrow, *destrow0;
228
229            /* Fill the first line the hard way */
230            destrow  = BITMAP_ADDR32(dest, fill.min_y, 0);
231            for (x = fill.min_x; x <= fill.max_x; x++)
232               destrow[x] = (UINT32)color;
233
234            /* For the other lines, just copy the first one */
235            destrow0 = BITMAP_ADDR32(dest, fill.min_y, fill.min_x);
236            for (y = fill.min_y + 1; y <= fill.max_y; y++)
220237            {
221               UINT32 *destrow = BITMAP_ADDR32(dest, y, 0);
222               for (x = fill.min_x; x <= fill.max_x; x++)
223                  destrow[x] = (UINT32)color;
238               destrow = BITMAP_ADDR32(dest, y, fill.min_x);
239               memcpy(destrow, destrow0, (fill.max_x + 1 - fill.min_x) * 4);
224240            }
225241         }
226242         break;
src/mess/osd/windows/menu.c
r3333r3334
17501750#endif // HAS_PROFILER
17511751
17521752      case ID_OPTIONS_DEBUGGER:
1753         debug_cpu_halt_on_next_instruction(machine, "User-initiated break\n");
1753         debug_cpu_halt_on_next_instruction(machine, -1, "User-initiated break\n");
17541754         break;
17551755
17561756      case ID_OPTIONS_CONFIGURATION:
docs/messnew.txt
r3333r3334
171171
172172Source Changes:
173173----------------
174- The core is based on MAME 0.127u4.  This incorporates all features of the
174- The core is based on MAME 0.127u5.  This incorporates all features of the
175175  update to this core.  [MAME team]
176176
177177- Refactored ZIP path code out of src/mess/image.c, made more testable.  [Nate

Previous 15994 Revisions Next


© 1998-2018 The MESS Team