Previous 15994 Revisions Next

r3486 Friday 24th October, 2008 at 02:04:39 UTC by Nathan Woods
Updated to MAME 0.128u1 core
[docs]messnew.txt
[src/emu]cpuexec.h cpuintrf.c romload.h
[src/emu/cpu]cpu.mak
[src/emu/cpu/cubeqcpu]cubeqcpu.c
[src/emu/cpu/dsp56k]dsp56dsm.c dsp56k.c dsp56mem.c dsp56ops.c dsp56pcu.c
[src/emu/cpu/i8051]i8051.c i8051.h i8051ops.c
[src/emu/cpu/m68000]m68k_in.c
[src/emu/cpu/sh2]sh2.c sh2.h sh2comn.c sh2comn.h
[src/emu/machine]ldvp931.c z80pio.c
[src/emu/sound]aica.c
[src/emu/video]tms34061.c
[src/mame]mame.mak mamedriv.c
[src/mame/drivers]bnstars.c cardline.c cloak.c cosmic.c cps3.c cubeqst.c ddealer.c fastlane.c fuukifg2.c fuukifg3.c itech8.c kaneko16.c legionna.c lethalj.c limenko.c m107.c m72.c magictg.c* megadriv.c megasys1.c merit.c meritm.c micro3d.c midwunit.c mirage.c namconb1.c namcos2.c neodrvr.c pacman.c peplus.c plygonet.c policetr.c psattack.c* psikyosh.c segahang.c segas16a.c segas16b.c segas18.c shangha3.c sliver.c sslam.c stv.c stvinit.c superqix.c system1.c tnzs.c toaplan1.c vamphalf.c videopkr.c yumefuda.c
[src/mame/includes]itech8.h neogeo.h
[src/mame/machine]irem_cpu.c neoboot.c neocrypt.c
[src/mame/video]cloak.c itech8.c taito_f3.c
[src/mess/drivers]genesis.c
[src/mess/machine]kb_keytro.c

src/mame/machine/irem_cpu.c
r3485r3486
2626    In The Hunt                        Irem    D8000011A1 020
2727    Risky Challenge/Gussun Oyoyo       Irem    D8000019A1 022 9331NK700
2828    Match It II/Shisensho II           Irem    D8000020A1 023 9320NK700
29    World PK Soccer                  Irem    D8000021A1
29    World PK Soccer/Kick for the Goal  Irem    D8000021A1 024 9335NK701
3030    Ninja Baseball Batman              Irem    D8000021A1 024 9335NK700
3131    Perfect Soldiers                   Irem    D8000022A1
3232    Dream Soccer '94                   Irem    D8000023A1 026
src/mame/machine/neoboot.c
r3485r3486
299299}
300300
301301
302/* The King of Fighters 2002 (bootleg) */
303
304
305// Thanks to IQ_132 for the info
306void kof2002b_gfx_decrypt(running_machine *machine, UINT8 *src, int size)
307{
308   int i, j;
309   int t[ 8 ][ 10 ] =
310   {
311      { 0, 8, 7, 3, 4, 5, 6, 2, 1 },
312      { 1, 0, 8, 4, 5, 3, 7, 6, 2 },
313      { 2, 1, 0, 3, 4, 5, 8, 7, 6 },
314      { 6, 2, 1, 5, 3, 4, 0, 8, 7 },
315      { 7, 6, 2, 5, 3, 4, 1, 0, 8 },
316      { 0, 1, 2, 3, 4, 5, 6, 7, 8 },
317      { 2, 1, 0, 4, 5, 3, 6, 7, 8 },
318      { 8, 0, 7, 3, 4, 5, 6, 2, 1 },
319   };
320
321   UINT8 *dst = malloc_or_die( 0x10000 );
322
323   for ( i = 0; i < size; i+=0x10000 )
324   {
325      memcpy( dst, src+i, 0x10000 );
326
327      for ( j = 0; j < 0x200; j++ )
328      {
329         int n = (( j % 0x40) / 8 );
330         int ofst = BITSWAP16(j, 15, 14, 13, 12, 11, 10, 9, t[n][0], t[n][1], t[n][2],
331                         t[n][3], t[n][4], t[n][5], t[n][6], t[n][7], t[n][8]);
332         memcpy( src+i+ofst*128, dst+j*128, 128 );
333      }
334   }
335   free( dst );
336}
337
338
302339/* The King of Fighters 2002 Magic Plus (bootleg) */
303340
304341
r3485r3486
327364/* The King of Fighters 2002 Magic Plus II (bootleg) */
328365
329366
330void kof2km2_px_decrypt( running_machine *machine )
367void kf2k2mp2_px_decrypt( running_machine *machine )
331368{
332369   UINT8 *src = memory_region(machine, "main");
333370   UINT8 *dst = malloc_or_die(0x600000);
r3485r3486
10821119   memcpy( rom-0x10000, rom, 0x10000 );
10831120
10841121   /* decrypt gfx */
1085   cthd2003_c( machine, 0);
1122   cthd2003_c( machine, 0 );
10861123}
10871124
src/mame/machine/neocrypt.c
r3485r3486
669669}
670670
671671
672/* svc has an additional scramble on top of the standard CMC scrambling */
672/* ms5pcb and svcpcb have an additional scramble on top of the standard CMC scrambling */
673673void svcpcb_gfx_decrypt(running_machine *machine)
674674{
675675   static const UINT8 xor[ 4 ] = { 0x34, 0x21, 0xc4, 0xe9 };
r3485r3486
718718}
719719
720720
721/* Razoola & Halrin */
721/* kf2k3pcb has an additional scramble on top of the standard CMC scrambling */
722/* Thanks to Razoola & Halrin for the info */
722723void kf2k3pcb_gfx_decrypt(running_machine *machine)
723724{
724725   static const UINT8 xor[ 4 ] = { 0x34, 0x21, 0xc4, 0xe9 };
r3485r3486
749750}
750751
751752
753/* and a further swap on the s1 data */
754void kf2k3pcb_decrypt_s1data(running_machine *machine)
755{
756   UINT8 *src;
757   UINT8 *dst;
758   int i;
759   int tx_size = memory_region_length( machine, "fixed" );
760   int srom_size = memory_region_length( machine, "sprites" );
761
762   src = memory_region( machine, "sprites" ) + srom_size - 0x1000000 - 0x80000; // Decrypt S
763   dst = memory_region( machine, "fixed" );
764
765   for( i = 0; i < tx_size / 2; i++ )
766   {
767      dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ];
768   }
769
770   src = memory_region( machine, "sprites" ) + srom_size - 0x80000;
771   dst = memory_region( machine, "fixed" ) + 0x80000;
772
773   for( i = 0; i < tx_size / 2; i++ )
774   {
775      dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ];
776   }
777
778   dst = memory_region( machine, "fixed" );
779
780   for( i = 0; i < tx_size; i++ )
781   {
782      dst[ i ] = BITSWAP8( dst[ i ] ^ 0xd2, 4, 0, 7, 2, 5, 1, 6, 3 );
783   }
784}
785
786
752787/***************************************************************************
753788
789NeoGeo 'M' ROM encryption
790  CMC50 protection chip
791
792***************************************************************************/
793
794
795static const UINT8 m1_address_8_15_xor[256] =
796{
797        0x0a, 0x72, 0xb7, 0xaf, 0x67, 0xde, 0x1d, 0xb1, 0x78, 0xc4, 0x4f, 0xb5, 0x4b, 0x18, 0x76, 0xdd,
798        0x11, 0xe2, 0x36, 0xa1, 0x82, 0x03, 0x98, 0xa0, 0x10, 0x5f, 0x3f, 0xd6, 0x1f, 0x90, 0x6a, 0x0b,
799        0x70, 0xe0, 0x64, 0xcb, 0x9f, 0x38, 0x8b, 0x53, 0x04, 0xca, 0xf8, 0xd0, 0x07, 0x68, 0x56, 0x32,
800        0xae, 0x1c, 0x2e, 0x48, 0x63, 0x92, 0x9a, 0x9c, 0x44, 0x85, 0x41, 0x40, 0x09, 0xc0, 0xc8, 0xbf,
801        0xea, 0xbb, 0xf7, 0x2d, 0x99, 0x21, 0xf6, 0xba, 0x15, 0xce, 0xab, 0xb0, 0x2a, 0x60, 0xbc, 0xf1,
802        0xf0, 0x9e, 0xd5, 0x97, 0xd8, 0x4e, 0x14, 0x9d, 0x42, 0x4d, 0x2c, 0x5c, 0x2b, 0xa6, 0xe1, 0xa7,
803        0xef, 0x25, 0x33, 0x7a, 0xeb, 0xe7, 0x1b, 0x6d, 0x4c, 0x52, 0x26, 0x62, 0xb6, 0x35, 0xbe, 0x80,
804        0x01, 0xbd, 0xfd, 0x37, 0xf9, 0x47, 0x55, 0x71, 0xb4, 0xf2, 0xff, 0x27, 0xfa, 0x23, 0xc9, 0x83,
805        0x17, 0x39, 0x13, 0x0d, 0xc7, 0x86, 0x16, 0xec, 0x49, 0x6f, 0xfe, 0x34, 0x05, 0x8f, 0x00, 0xe6,
806        0xa4, 0xda, 0x7b, 0xc1, 0xf3, 0xf4, 0xd9, 0x75, 0x28, 0x66, 0x87, 0xa8, 0x45, 0x6c, 0x20, 0xe9,
807        0x77, 0x93, 0x7e, 0x3c, 0x1e, 0x74, 0xf5, 0x8c, 0x3e, 0x94, 0xd4, 0xc2, 0x5a, 0x06, 0x0e, 0xe8,
808        0x3d, 0xa9, 0xb2, 0xe3, 0xe4, 0x22, 0xcf, 0x24, 0x8e, 0x6b, 0x8a, 0x8d, 0x84, 0x4a, 0xd2, 0x91,
809        0x88, 0x79, 0x57, 0xa5, 0x0f, 0xcd, 0xb9, 0xac, 0x3b, 0xaa, 0xb3, 0xd1, 0xee, 0x31, 0x81, 0x7c,
810        0xd7, 0x89, 0xd3, 0x96, 0x43, 0xc5, 0xc6, 0xc3, 0x69, 0x7f, 0x46, 0xdf, 0x30, 0x5b, 0x6e, 0xe5,
811        0x08, 0x95, 0x9b, 0xfb, 0xb8, 0x58, 0x0c, 0x61, 0x50, 0x5d, 0x3a, 0xa2, 0x29, 0x12, 0xfc, 0x51,
812        0x7d, 0x1a, 0x02, 0x65, 0x54, 0x5e, 0x19, 0xcc, 0xdc, 0xdb, 0x73, 0xed, 0xad, 0x59, 0x2f, 0xa3,
813};
814
815static const UINT8 m1_address_0_7_xor[256] =
816{
817        0xf4, 0xbc, 0x02, 0xf7, 0x2c, 0x3d, 0xe8, 0xd9, 0x50, 0x62, 0xec, 0xbd, 0x53, 0x73, 0x79, 0x61,
818        0x00, 0x34, 0xcf, 0xa2, 0x63, 0x28, 0x90, 0xaf, 0x44, 0x3b, 0xc5, 0x8d, 0x3a, 0x46, 0x07, 0x70,
819        0x66, 0xbe, 0xd8, 0x8b, 0xe9, 0xa0, 0x4b, 0x98, 0xdc, 0xdf, 0xe2, 0x16, 0x74, 0xf1, 0x37, 0xf5,
820        0xb7, 0x21, 0x81, 0x01, 0x1c, 0x1b, 0x94, 0x36, 0x09, 0xa1, 0x4a, 0x91, 0x30, 0x92, 0x9b, 0x9a,
821        0x29, 0xb1, 0x38, 0x4d, 0x55, 0xf2, 0x56, 0x18, 0x24, 0x47, 0x9d, 0x3f, 0x80, 0x1f, 0x22, 0xa4,
822        0x11, 0x54, 0x84, 0x0d, 0x25, 0x48, 0xee, 0xc6, 0x59, 0x15, 0x03, 0x7a, 0xfd, 0x6c, 0xc3, 0x33,
823        0x5b, 0xc4, 0x7b, 0x5a, 0x05, 0x7f, 0xa6, 0x40, 0xa9, 0x5d, 0x41, 0x8a, 0x96, 0x52, 0xd3, 0xf0,
824        0xab, 0x72, 0x10, 0x88, 0x6f, 0x95, 0x7c, 0xa8, 0xcd, 0x9c, 0x5f, 0x32, 0xae, 0x85, 0x39, 0xac,
825        0xe5, 0xd7, 0xfb, 0xd4, 0x08, 0x23, 0x19, 0x65, 0x6b, 0xa7, 0x93, 0xbb, 0x2b, 0xbf, 0xb8, 0x35,
826        0xd0, 0x06, 0x26, 0x68, 0x3e, 0xdd, 0xb9, 0x69, 0x2a, 0xb2, 0xde, 0x87, 0x45, 0x58, 0xff, 0x3c,
827        0x9e, 0x7d, 0xda, 0xed, 0x49, 0x8c, 0x14, 0x8e, 0x75, 0x2f, 0xe0, 0x6e, 0x78, 0x6d, 0x20, 0xd2,
828        0xfa, 0x2d, 0x51, 0xcc, 0xc7, 0xe7, 0x1d, 0x27, 0x97, 0xfc, 0x31, 0xdb, 0xf8, 0x42, 0xe3, 0x99,
829        0x5e, 0x83, 0x0e, 0xb4, 0x2e, 0xf6, 0xc0, 0x0c, 0x4c, 0x57, 0xb6, 0x64, 0x0a, 0x17, 0xa3, 0xc1,
830        0x77, 0x12, 0xfe, 0xe6, 0x8f, 0x13, 0x71, 0xe4, 0xf9, 0xad, 0x9f, 0xce, 0xd5, 0x89, 0x7e, 0x0f,
831        0xc2, 0x86, 0xf3, 0x67, 0xba, 0x60, 0x43, 0xc9, 0x04, 0xb3, 0xb0, 0x1e, 0xb5, 0xc8, 0xeb, 0xa5,
832        0x76, 0xea, 0x5c, 0x82, 0x1a, 0x4f, 0xaa, 0xca, 0xe1, 0x0b, 0x4e, 0xcb, 0x6a, 0xef, 0xd1, 0xd6,
833};
834
835
836/* The CMC50 hardware does a checksum of the first 64kb of the M1 rom,
837   ,and uses this checksum as the basis of the key with which to decrypt
838   the rom */
839
840static UINT16 generate_cs16(UINT8 *rom, int size)
841{
842    UINT16 cs16;
843    int i;
844    cs16 = 0x0000;
845    for (i=0;i<size;i++ )
846    {
847        cs16 += rom[i];
848    }
849    return cs16&0xFFFF;
850}
851
852
853int m1_address_scramble(int address, UINT16 key)
854{
855   int block;
856   int aux;
857
858   const int p1[8][16] = {
859      {15,14,10,7,1,2,3,8,0,12,11,13,6,9,5,4},
860      {7,1,8,11,15,9,2,3,5,13,4,14,10,0,6,12},
861      {8,6,14,3,10,7,15,1,4,0,2,5,13,11,12,9},
862      {2,8,15,9,3,4,11,7,13,6,0,10,1,12,14,5},
863      {1,13,6,15,14,3,8,10,9,4,7,12,5,2,0,11},
864      {11,15,3,4,7,0,9,2,6,14,12,1,8,5,10,13},
865      {10,5,13,8,6,15,1,14,11,9,3,0,12,7,4,2},
866      {9,3,7,0,2,12,4,11,14,10,5,8,15,13,1,6},
867   };
868
869   block = (address>>16)&7;
870   aux = address&0xffff;
871
872        aux ^= BITSWAP16(key,12,0,2,4,8,15,7,13,10,1,3,6,11,9,14,5);
873   aux = BITSWAP16(aux,
874      p1[block][15],p1[block][14],p1[block][13],p1[block][12],
875      p1[block][11],p1[block][10],p1[block][9],p1[block][8],
876      p1[block][7],p1[block][6],p1[block][5],p1[block][4],
877      p1[block][3],p1[block][2],p1[block][1],p1[block][0]);
878        aux ^= m1_address_0_7_xor[(aux>>8)&0xff];
879   aux ^= m1_address_8_15_xor[aux&0xff]<<8;
880   aux = BITSWAP16(aux, 7,15,14,6,5,13,12,4,11,3,10,2,9,1,8,0);
881
882   return (block<<16)|aux;
883}
884
885
886void neogeo_cmc50_m1_decrypt(running_machine *machine)
887{
888   UINT8* rom = memory_region(machine, "audiocrypt");
889   size_t rom_size = 0x80000;
890   UINT8* rom2 = memory_region(machine, "audio");
891
892   UINT8* buffer = malloc_or_die(rom_size);
893
894   UINT32 i;
895
896   UINT16 key=generate_cs16(rom,0x10000);
897
898   //printf("key %04x\n",key);
899
900   for (i=0; i<rom_size; i++)
901   {
902      buffer[i] = rom[m1_address_scramble(i,key)];
903   }
904
905   memcpy(rom,buffer,rom_size);
906
907   memcpy(rom2,rom,0x10000);
908   memcpy(rom2+0x10000,rom,0x80000);
909
910   #if 0
911   {
912      FILE *fp;
913      const char *gamename = machine->gamedrv->name;
914      char filename[256];
915      sprintf(filename, "%s_m1.dump", gamename);
916
917      fp=fopen(filename, "w+b");
918      if (fp)
919      {
920         fwrite(rom, rom_size, 1, fp);
921         fclose(fp);
922      }
923   }
924   #endif
925
926
927   #if 0
928   {
929      FILE *fp;
930      const char *gamename = machine->gamedrv->name;
931      char filename[256];
932      sprintf(filename, "%s_m1extra.dump", gamename);
933
934      fp=fopen(filename, "w+b");
935      if (fp)
936      {
937         fwrite(&rom[0xf800], 0x800, 1, fp);
938         fclose(fp);
939      }
940   }
941   #endif
942
943   free( buffer );
944}
945
946
947/***************************************************************************
948
754949NeoGeo 'P' ROM encryption
755950
756951***************************************************************************/
757952
953
758954/* Kof98 uses an early encryption, quite different from the others */
759955void kof98_decrypt_68k(running_machine *machine)
760956{
r3485r3486
10331229}
10341230
10351231
1036/* mslug5, svc, kof2003 have updated P rom scramble */
1232/* kf2k3pcb, kof2003, kof2003h, mslug5 and svc have updated P rom scramble */
10371233void mslug5_decrypt_68k(running_machine *machine)
10381234{
10391235   static const UINT8 xor1[ 0x20 ] = { 0xc2, 0x4b, 0x74, 0xfd, 0x0b, 0x34, 0xeb, 0xd7, 0x10, 0x6d, 0xf9, 0xce, 0x5d, 0xd5, 0x61, 0x29, 0xf5, 0xbe, 0x0d, 0x82, 0x72, 0x45, 0x0f, 0x24, 0xb3, 0x34, 0x1b, 0x99, 0xea, 0x09, 0xf3, 0x03 };
r3485r3486
11241320}
11251321
11261322
1127void kf2k3pcb_decrypt_s1data(running_machine *machine)
1128{
1129   UINT8 *src;
1130   UINT8 *dst;
1131   int i;
1132   int tx_size = memory_region_length( machine, "fixed" );
1133   int srom_size = memory_region_length( machine, "sprites" );
1134
1135   src = memory_region( machine, "sprites" ) + srom_size - 0x1000000 - 0x80000; // Decrypt S
1136   dst = memory_region( machine, "fixed" );
1137
1138   for( i = 0; i < tx_size / 2; i++ )
1139   {
1140      dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ];
1141   }
1142
1143   src = memory_region( machine, "sprites" ) + srom_size - 0x80000;
1144   dst = memory_region( machine, "fixed" ) + 0x80000;
1145
1146   for( i = 0; i < tx_size / 2; i++ )
1147   {
1148      dst[ i ] = src[ (i & ~0x1f) + ((i & 7) << 2) + ((~i & 8) >> 2) + ((i & 0x10) >> 4) ];
1149   }
1150
1151   dst = memory_region( machine, "fixed" );
1152
1153   for( i = 0; i < tx_size; i++ )
1154   {
1155      dst[ i ] = BITSWAP8( dst[ i ] ^ 0xd2, 4, 0, 7, 2, 5, 1, 6, 3 );
1156   }
1157}
1158
1159
11601323void kf2k3pcb_decrypt_68k(running_machine *machine)
11611324{
11621325   static const UINT8 xor2[ 0x20 ] = { 0xb4, 0x0f, 0x40, 0x6c, 0x38, 0x07, 0xd0, 0x3f, 0x53, 0x08, 0x80, 0xaa, 0xbe, 0x07, 0xc0, 0xfa, 0xd0, 0x08, 0x10, 0xd2, 0xf1, 0x03, 0x70, 0x7e, 0x87, 0x0b, 0x40, 0xf6, 0x2a, 0x0a, 0xe0, 0xf9 };
r3485r3486
12931456}
12941457
12951458
1296void kof2003biosdecode(running_machine *machine)
1297{
1298   static const UINT8 address[0x80]={
1299      0xb9,0xb8,0x36,0x37,0x3d,0x3c,0xb2,0xb3,
1300      0xb9,0xb8,0x36,0x37,0x3d,0x3c,0xb2,0xb3,
1301      0x65,0xea,0x6f,0xe0,0xe1,0x6e,0xeb,0x64,
1302      0x65,0xea,0x6f,0xe0,0xe1,0x6e,0xeb,0x64,
1303      0x45,0xca,0x47,0xc8,0xc9,0x46,0xcb,0x44,
1304      0x45,0xca,0x47,0xc8,0xc9,0x46,0xcb,0x44,
1305      0x9a,0x15,0x98,0x17,0x1e,0x91,0x1c,0x93,
1306      0x9a,0x15,0x98,0x17,0x1e,0x91,0x1c,0x93,
1307      0x7e,0xf1,0x7c,0xf3,0xf0,0x7f,0xf2,0x7d,
1308      0x7e,0xf1,0x7c,0xf3,0xf0,0x7f,0xf2,0x7d,
1309      0x27,0xa8,0x25,0xaa,0xa3,0x2c,0xa1,0x2e,
1310      0x27,0xa8,0x25,0xaa,0xa3,0x2c,0xa1,0x2e,
1311      0x04,0x8b,0x06,0x89,0x80,0x0f,0x82,0x0d,
1312      0x04,0x8b,0x06,0x89,0x80,0x0f,0x82,0x0d,
1313      0xd3,0xd2,0x5c,0x5d,0x57,0x56,0xd8,0xd9,
1314      0xd3,0xd2,0x5c,0x5d,0x57,0x56,0xd8,0xd9,
1315   };
1316   UINT16*src= (UINT16*)memory_region( machine, "mainbios" );
1317   UINT16*buf= malloc_or_die(0x80000);
1318   int   a,addr;
1319
1320      for (a=0;a<0x80000/2;a++)
1321      {
1322         //data xor
1323         #ifdef LSB_FIRST
1324         if (src[a] & 0x0004)   src[a] ^= 0x0001;
1325         if (src[a] & 0x0010)   src[a] ^= 0x0002;
1326         if (src[a] & 0x0020)   src[a] ^= 0x0008;
1327         #else
1328         if (src[a] & 0x0400)   src[a] ^= 0x0100;
1329         if (src[a] & 0x1000)   src[a] ^= 0x0200;
1330         if (src[a] & 0x2000)   src[a] ^= 0x0800;
1331         #endif
1332         //address xor
1333         addr  = a & ~0xff;
1334         addr |= address[BYTE_XOR_LE(a & 0x7f)];
1335         if ( a & 0x00008)   addr ^= 0x0008;
1336         if ( a & 0x00080)   addr ^= 0x0080;
1337         if ( a & 0x00200)   addr ^= 0x0100;
1338         if (~a & 0x02000)   addr ^= 0x0400;
1339         if (~a & 0x10000)   addr ^= 0x1000;
1340         if ( a & 0x02000)   addr ^= 0x8000;
1341         buf[addr]=src[a];
1342      }
1343      memcpy(src,buf,0x80000);
1344      free(buf);
1345}
1346
1347
13481459/***************************************************************************
13491460
13501461NeoGeo 'V' (PCM) ROM encryption
r3485r3486
14111522}
14121523
14131524
1414static const UINT8 m1_address_8_15_xor[256] =
1415{
1416        0x0a, 0x72, 0xb7, 0xaf, 0x67, 0xde, 0x1d, 0xb1, 0x78, 0xc4, 0x4f, 0xb5, 0x4b, 0x18, 0x76, 0xdd,
1417        0x11, 0xe2, 0x36, 0xa1, 0x82, 0x03, 0x98, 0xa0, 0x10, 0x5f, 0x3f, 0xd6, 0x1f, 0x90, 0x6a, 0x0b,
1418        0x70, 0xe0, 0x64, 0xcb, 0x9f, 0x38, 0x8b, 0x53, 0x04, 0xca, 0xf8, 0xd0, 0x07, 0x68, 0x56, 0x32,
1419        0xae, 0x1c, 0x2e, 0x48, 0x63, 0x92, 0x9a, 0x9c, 0x44, 0x85, 0x41, 0x40, 0x09, 0xc0, 0xc8, 0xbf,
1420        0xea, 0xbb, 0xf7, 0x2d, 0x99, 0x21, 0xf6, 0xba, 0x15, 0xce, 0xab, 0xb0, 0x2a, 0x60, 0xbc, 0xf1,
1421        0xf0, 0x9e, 0xd5, 0x97, 0xd8, 0x4e, 0x14, 0x9d, 0x42, 0x4d, 0x2c, 0x5c, 0x2b, 0xa6, 0xe1, 0xa7,
1422        0xef, 0x25, 0x33, 0x7a, 0xeb, 0xe7, 0x1b, 0x6d, 0x4c, 0x52, 0x26, 0x62, 0xb6, 0x35, 0xbe, 0x80,
1423        0x01, 0xbd, 0xfd, 0x37, 0xf9, 0x47, 0x55, 0x71, 0xb4, 0xf2, 0xff, 0x27, 0xfa, 0x23, 0xc9, 0x83,
1424        0x17, 0x39, 0x13, 0x0d, 0xc7, 0x86, 0x16, 0xec, 0x49, 0x6f, 0xfe, 0x34, 0x05, 0x8f, 0x00, 0xe6,
1425        0xa4, 0xda, 0x7b, 0xc1, 0xf3, 0xf4, 0xd9, 0x75, 0x28, 0x66, 0x87, 0xa8, 0x45, 0x6c, 0x20, 0xe9,
1426        0x77, 0x93, 0x7e, 0x3c, 0x1e, 0x74, 0xf5, 0x8c, 0x3e, 0x94, 0xd4, 0xc2, 0x5a, 0x06, 0x0e, 0xe8,
1427        0x3d, 0xa9, 0xb2, 0xe3, 0xe4, 0x22, 0xcf, 0x24, 0x8e, 0x6b, 0x8a, 0x8d, 0x84, 0x4a, 0xd2, 0x91,
1428        0x88, 0x79, 0x57, 0xa5, 0x0f, 0xcd, 0xb9, 0xac, 0x3b, 0xaa, 0xb3, 0xd1, 0xee, 0x31, 0x81, 0x7c,
1429        0xd7, 0x89, 0xd3, 0x96, 0x43, 0xc5, 0xc6, 0xc3, 0x69, 0x7f, 0x46, 0xdf, 0x30, 0x5b, 0x6e, 0xe5,
1430        0x08, 0x95, 0x9b, 0xfb, 0xb8, 0x58, 0x0c, 0x61, 0x50, 0x5d, 0x3a, 0xa2, 0x29, 0x12, 0xfc, 0x51,
1431        0x7d, 0x1a, 0x02, 0x65, 0x54, 0x5e, 0x19, 0xcc, 0xdc, 0xdb, 0x73, 0xed, 0xad, 0x59, 0x2f, 0xa3,
1432};
1525/***************************************************************************
14331526
1434static const UINT8 m1_address_0_7_xor[256] =
1435{
1436        0xf4, 0xbc, 0x02, 0xf7, 0x2c, 0x3d, 0xe8, 0xd9, 0x50, 0x62, 0xec, 0xbd, 0x53, 0x73, 0x79, 0x61,
1437        0x00, 0x34, 0xcf, 0xa2, 0x63, 0x28, 0x90, 0xaf, 0x44, 0x3b, 0xc5, 0x8d, 0x3a, 0x46, 0x07, 0x70,
1438        0x66, 0xbe, 0xd8, 0x8b, 0xe9, 0xa0, 0x4b, 0x98, 0xdc, 0xdf, 0xe2, 0x16, 0x74, 0xf1, 0x37, 0xf5,
1439        0xb7, 0x21, 0x81, 0x01, 0x1c, 0x1b, 0x94, 0x36, 0x09, 0xa1, 0x4a, 0x91, 0x30, 0x92, 0x9b, 0x9a,
1440        0x29, 0xb1, 0x38, 0x4d, 0x55, 0xf2, 0x56, 0x18, 0x24, 0x47, 0x9d, 0x3f, 0x80, 0x1f, 0x22, 0xa4,
1441        0x11, 0x54, 0x84, 0x0d, 0x25, 0x48, 0xee, 0xc6, 0x59, 0x15, 0x03, 0x7a, 0xfd, 0x6c, 0xc3, 0x33,
1442        0x5b, 0xc4, 0x7b, 0x5a, 0x05, 0x7f, 0xa6, 0x40, 0xa9, 0x5d, 0x41, 0x8a, 0x96, 0x52, 0xd3, 0xf0,
1443        0xab, 0x72, 0x10, 0x88, 0x6f, 0x95, 0x7c, 0xa8, 0xcd, 0x9c, 0x5f, 0x32, 0xae, 0x85, 0x39, 0xac,
1444        0xe5, 0xd7, 0xfb, 0xd4, 0x08, 0x23, 0x19, 0x65, 0x6b, 0xa7, 0x93, 0xbb, 0x2b, 0xbf, 0xb8, 0x35,
1445        0xd0, 0x06, 0x26, 0x68, 0x3e, 0xdd, 0xb9, 0x69, 0x2a, 0xb2, 0xde, 0x87, 0x45, 0x58, 0xff, 0x3c,
1446        0x9e, 0x7d, 0xda, 0xed, 0x49, 0x8c, 0x14, 0x8e, 0x75, 0x2f, 0xe0, 0x6e, 0x78, 0x6d, 0x20, 0xd2,
1447        0xfa, 0x2d, 0x51, 0xcc, 0xc7, 0xe7, 0x1d, 0x27, 0x97, 0xfc, 0x31, 0xdb, 0xf8, 0x42, 0xe3, 0x99,
1448        0x5e, 0x83, 0x0e, 0xb4, 0x2e, 0xf6, 0xc0, 0x0c, 0x4c, 0x57, 0xb6, 0x64, 0x0a, 0x17, 0xa3, 0xc1,
1449        0x77, 0x12, 0xfe, 0xe6, 0x8f, 0x13, 0x71, 0xe4, 0xf9, 0xad, 0x9f, 0xce, 0xd5, 0x89, 0x7e, 0x0f,
1450        0xc2, 0x86, 0xf3, 0x67, 0xba, 0x60, 0x43, 0xc9, 0x04, 0xb3, 0xb0, 0x1e, 0xb5, 0xc8, 0xeb, 0xa5,
1451        0x76, 0xea, 0x5c, 0x82, 0x1a, 0x4f, 0xaa, 0xca, 0xe1, 0x0b, 0x4e, 0xcb, 0x6a, 0xef, 0xd1, 0xd6,
1452};
1527NeoGeo 'SP1' (BIOS) ROM encryption
14531528
1529***************************************************************************/
14541530
1455/* The CMC50 hardware does a checksum of the first 64kb of the M1 rom,
1456   ,and uses this checksum as the basis of the key with which to decrypt
1457   the rom */
14581531
1459static UINT16 generate_cs16(UINT8 *rom, int size)
1532/* only found on kf2k3pcb */
1533void kof2003biosdecode(running_machine *machine)
14601534{
1461    UINT16 cs16;
1462    int i;
1463    cs16 = 0x0000;
1464    for (i=0;i<size;i++ )
1465    {
1466        cs16 += rom[i];
1467    }
1468    return cs16&0xFFFF;
1469}
1470
1471
1472int m1_address_scramble(int address, UINT16 key)
1473{
1474   int block;
1475   int aux;
1476
1477   const int p1[8][16] = {
1478      {15,14,10,7,1,2,3,8,0,12,11,13,6,9,5,4},
1479      {7,1,8,11,15,9,2,3,5,13,4,14,10,0,6,12},
1480      {8,6,14,3,10,7,15,1,4,0,2,5,13,11,12,9},
1481      {2,8,15,9,3,4,11,7,13,6,0,10,1,12,14,5},
1482      {1,13,6,15,14,3,8,10,9,4,7,12,5,2,0,11},
1483      {11,15,3,4,7,0,9,2,6,14,12,1,8,5,10,13},
1484      {10,5,13,8,6,15,1,14,11,9,3,0,12,7,4,2},
1485      {9,3,7,0,2,12,4,11,14,10,5,8,15,13,1,6},
1535   static const UINT8 address[0x80]={
1536      0xb9,0xb8,0x36,0x37,0x3d,0x3c,0xb2,0xb3,
1537      0xb9,0xb8,0x36,0x37,0x3d,0x3c,0xb2,0xb3,
1538      0x65,0xea,0x6f,0xe0,0xe1,0x6e,0xeb,0x64,
1539      0x65,0xea,0x6f,0xe0,0xe1,0x6e,0xeb,0x64,
1540      0x45,0xca,0x47,0xc8,0xc9,0x46,0xcb,0x44,
1541      0x45,0xca,0x47,0xc8,0xc9,0x46,0xcb,0x44,
1542      0x9a,0x15,0x98,0x17,0x1e,0x91,0x1c,0x93,
1543      0x9a,0x15,0x98,0x17,0x1e,0x91,0x1c,0x93,
1544      0x7e,0xf1,0x7c,0xf3,0xf0,0x7f,0xf2,0x7d,
1545      0x7e,0xf1,0x7c,0xf3,0xf0,0x7f,0xf2,0x7d,
1546      0x27,0xa8,0x25,0xaa,0xa3,0x2c,0xa1,0x2e,
1547      0x27,0xa8,0x25,0xaa,0xa3,0x2c,0xa1,0x2e,
1548      0x04,0x8b,0x06,0x89,0x80,0x0f,0x82,0x0d,
1549      0x04,0x8b,0x06,0x89,0x80,0x0f,0x82,0x0d,
1550      0xd3,0xd2,0x5c,0x5d,0x57,0x56,0xd8,0xd9,
1551      0xd3,0xd2,0x5c,0x5d,0x57,0x56,0xd8,0xd9,
14861552   };
1553   UINT16*src= (UINT16*)memory_region( machine, "mainbios" );
1554   UINT16*buf= malloc_or_die(0x80000);
1555   int   a,addr;
14871556
1488   block = (address>>16)&7;
1489   aux = address&0xffff;
1490
1491        aux ^= BITSWAP16(key,12,0,2,4,8,15,7,13,10,1,3,6,11,9,14,5);
1492   aux = BITSWAP16(aux,
1493      p1[block][15],p1[block][14],p1[block][13],p1[block][12],
1494      p1[block][11],p1[block][10],p1[block][9],p1[block][8],
1495      p1[block][7],p1[block][6],p1[block][5],p1[block][4],
1496      p1[block][3],p1[block][2],p1[block][1],p1[block][0]);
1497        aux ^= m1_address_0_7_xor[(aux>>8)&0xff];
1498   aux ^= m1_address_8_15_xor[aux&0xff]<<8;
1499   aux = BITSWAP16(aux, 7,15,14,6,5,13,12,4,11,3,10,2,9,1,8,0);
1500
1501   return (block<<16)|aux;
1502}
1503
1504
1505void neogeo_cmc50_m1_decrypt(running_machine *machine)
1506{
1507   UINT8* rom = memory_region(machine, "audiocrypt");
1508   size_t rom_size = 0x80000;
1509   UINT8* rom2 = memory_region(machine, "audio");
1510
1511   UINT8* buffer = malloc_or_die(rom_size);
1512
1513   UINT32 i;
1514
1515   UINT16 key=generate_cs16(rom,0x10000);
1516
1517   //printf("key %04x\n",key);
1518
1519   for (i=0; i<rom_size; i++)
1520   {
1521      buffer[i] = rom[m1_address_scramble(i,key)];
1522   }
1523
1524   memcpy(rom,buffer,rom_size);
1525
1526   memcpy(rom2,rom,0x10000);
1527   memcpy(rom2+0x10000,rom,0x80000);
1528
1529   #if 0
1530   {
1531      FILE *fp;
1532      const char *gamename = machine->gamedrv->name;
1533      char filename[256];
1534      sprintf(filename, "%s_m1.dump", gamename);
1535
1536      fp=fopen(filename, "w+b");
1537      if (fp)
1557      for (a=0;a<0x80000/2;a++)
15381558      {
1539         fwrite(rom, rom_size, 1, fp);
1540         fclose(fp);
1559         //data xor
1560         #ifdef LSB_FIRST
1561         if (src[a] & 0x0004)   src[a] ^= 0x0001;
1562         if (src[a] & 0x0010)   src[a] ^= 0x0002;
1563         if (src[a] & 0x0020)   src[a] ^= 0x0008;
1564         #else
1565         if (src[a] & 0x0400)   src[a] ^= 0x0100;
1566         if (src[a] & 0x1000)   src[a] ^= 0x0200;
1567         if (src[a] & 0x2000)   src[a] ^= 0x0800;
1568         #endif
1569         //address xor
1570         addr  = a & ~0xff;
1571         addr |= address[BYTE_XOR_LE(a & 0x7f)];
1572         if ( a & 0x00008)   addr ^= 0x0008;
1573         if ( a & 0x00080)   addr ^= 0x0080;
1574         if ( a & 0x00200)   addr ^= 0x0100;
1575         if (~a & 0x02000)   addr ^= 0x0400;
1576         if (~a & 0x10000)   addr ^= 0x1000;
1577         if ( a & 0x02000)   addr ^= 0x8000;
1578         buf[addr]=src[a];
15411579      }
1542   }
1543   #endif
1580      memcpy(src,buf,0x80000);
1581      free(buf);
1582}
15441583
15451584
1546   #if 0
1547   {
1548      FILE *fp;
1549      const char *gamename = machine->gamedrv->name;
1550      char filename[256];
1551      sprintf(filename, "%s_m1extra.dump", gamename);
1552
1553      fp=fopen(filename, "w+b");
1554      if (fp)
1555      {
1556         fwrite(&rom[0xf800], 0x800, 1, fp);
1557         fclose(fp);
1558      }
1559   }
1560   #endif
1561
1562   free( buffer );
1563}
src/mame/mamedriv.c
r3485r3486
14901490   /* M107 */
14911491   DRIVER( firebarr )   /* (c) 1993 Irem (Japan) */
14921492   DRIVER( dsoccr94 )   /* (c) 1994 Irem (Data East Corporation license) */
1493   DRIVER( kftgoal )   /* (c) 1994 Jaleco */
14931494   DRIVER( wpksoc )   /* (c) 1995 Jaleco */
14941495
14951496   /* Gottlieb/Mylstar games (Gottlieb became Mylstar in 1983) */
r3485r3486
17631764   DRIVER( drtopplj )   /* B19 (c) 1987 Taito Corporation (Japan) */
17641765   DRIVER( kageki )   /* B35 (c) 1988 Taito America Corporation + Romstar license (US) */
17651766   DRIVER( kagekij )   /* B35 (c) 1988 Taito Corporation (Japan) */
1766   DRIVER( kagekia )   /* B35 (c) 1992 (hack?) */
1767   DRIVER( kagekih )   /* B35 (c) 1992 (hack) */
17671768   DRIVER( chukatai )   /* B44 (c) 1988 Taito Corporation Japan (World) */
17681769   DRIVER( chukatau )   /* B44 (c) 1988 Taito Corporation (US) */
17691770   DRIVER( chukataj )   /* B44 (c) 1988 Taito Corporation (Japan) */
17701771   DRIVER( kabukiz )   /* B50 (c) 1988 Taito Corporation Japan (World) */
17711772   DRIVER( kabukizj )   /* B50 (c) 1988 Taito Corporation (Japan) */
17721773   DRIVER( tnzs )      /* B53 (c) 1988 Taito Corporation Japan (World) (new logo) */
1773   DRIVER( tnzsjn )   /* B53 (c) 1988 Taito Corporation (Japan) (new logo) */
17741774   DRIVER( tnzsj )      /* B53 (c) 1988 Taito Corporation (Japan) (new logo) */
1775   DRIVER( tnzsjo )   /* B53 (c) 1988 Taito Corporation (Japan) (new logo) */
17751776   DRIVER( tnzso )      /* B53?(c) 1988 Taito Corporation Japan (World) (old logo) */
17761777   DRIVER( insectx )   /* B97 (c) 1989 Taito Corporation Japan (World) */
17771778   DRIVER( champbwl )   /* (c)1989 Romstar.  not Taito, but the same Seta video chips */
r3485r3486
20682069   DRIVER( ktiger )   /* B30 / TP-011 (c) 1987 Taito Corporation (Japan) */
20692070   DRIVER( gulfwar2 )   /* (c) 1991 Comad */
20702071
2071   DRIVER( rallybik )   /* B45 / TP-012 (c) 1988 Taito */
2072   DRIVER( truxton )   /* B65 / TP-013B (c) 1988 Taito */
2072   DRIVER( rallybik )   /* B45 / TP-O12 (c) 1988 Taito */
2073   DRIVER( truxton )   /* B65 / TP-O13B (c) 1988 Taito */
20732074   DRIVER( hellfire )   /* B90 / TP-??? (c) 1989 Toaplan + Taito license */
20742075   DRIVER( hellfir1 )   /* B90 / TP-??? (c) 1989 Toaplan + Taito license */
20752076   DRIVER( hellfir2 )   /* B90 / TP-??? (c) 1989 Toaplan + Taito license */
2076   DRIVER( zerowing )   /* TP-015 (c) 1989 Toaplan */
2077   DRIVER( zerowng2 )   /* TP-015 (c) 1989 Toaplan */
2078   DRIVER( demonwld )   /* TP-016 (c) 1990 Toaplan (+ Taito license when set to Japan) */
2079   DRIVER( demonwl1 )   /* TP-016 (c) 1989 Toaplan + Taito license */
2080   DRIVER( demonwl2 )   /* TP-016 (c) 1989 Toaplan */
2081   DRIVER( demonwl3 )   /* TP-016 (c) 1989 Toaplan */
2082   DRIVER( demonwl4 )   /* TP-016 (c) 1989 Toaplan */
2083   DRIVER( fireshrk )   /* TP-017 (c) 1990 Toaplan */
2084   DRIVER( samesame )   /* TP-017 (c) 1989 Toaplan */
2085   DRIVER( samesam2 )   /* TP-017 (c) 1989 Toaplan */
2086   DRIVER( outzone )   /* TP-018 (c) 1990 Toaplan */
2087   DRIVER( outzonea )   /* TP-018 (c) 1990 Toaplan */
2088   DRIVER( outzoneb )   /* TP-018 (c) 1990 Toaplan */
2089   DRIVER( outzonec )   /* TP-018 (c) 1990 Toaplan */
2090   DRIVER( vimana )   /* TP-019 (c) 1991 Toaplan (+ Tecmo license when set to Japan) */
2091   DRIVER( vimana1 )   /* TP-019 (c) 1991 Toaplan (+ Tecmo license when set to Japan)  */
2092   DRIVER( vimanan )   /* TP-019 (c) 1991 Toaplan (+ Nova Apparate GMBH & Co license) */
2077   DRIVER( zerowing )   /* TP-O15 (c) 1989 Toaplan */
2078   DRIVER( zerowng2 )   /* TP-O15 (c) 1989 Toaplan */
2079   DRIVER( demonwld )   /* TP-O16 (c) 1990 Toaplan (+ Taito license when set to Japan) */
2080   DRIVER( demonwl1 )   /* TP-O16 (c) 1989 Toaplan + Taito license */
2081   DRIVER( demonwl2 )   /* TP-O16 (c) 1989 Toaplan */
2082   DRIVER( demonwl3 )   /* TP-O16 (c) 1989 Toaplan */
2083   DRIVER( demonwl4 )   /* TP-O16 (c) 1989 Toaplan */
2084   DRIVER( fireshrk )   /* TP-O17 (c) 1990 Toaplan */
2085   DRIVER( fireshd )   /* TP-O17 (c) 1990 Toaplan */
2086   DRIVER( fireshdh )   /* TP-O17 (c) 1990 Toaplan */
2087   DRIVER( samesame )   /* TP-O17 (c) 1989 Toaplan */
2088   DRIVER( samesam2 )   /* TP-O17 (c) 1989 Toaplan */
2089   DRIVER( outzone )   /* TP-O18 (c) 1990 Toaplan */
2090   DRIVER( outzonea )   /* TP-O18 (c) 1990 Toaplan */
2091   DRIVER( outzoneb )   /* TP-O18 (c) 1990 Toaplan */
2092   DRIVER( outzonec )   /* TP-O18 (c) 1990 Toaplan */
2093   DRIVER( vimana )   /* TP-O19 (c) 1991 Toaplan (+ Tecmo license when set to Japan) */
2094   DRIVER( vimana1 )   /* TP-O19 (c) 1991 Toaplan (+ Tecmo license when set to Japan)  */
2095   DRIVER( vimanan )   /* TP-O19 (c) 1991 Toaplan (+ Nova Apparate GMBH & Co license) */
20932096   DRIVER( snowbros )   /* MIN16-02 (c) 1990 Toaplan + Romstar license */
20942097   DRIVER( snowbroa )   /* MIN16-02 (c) 1990 Toaplan + Romstar license */
20952098   DRIVER( snowbrob )   /* MIN16-02 (c) 1990 Toaplan + Romstar license */
r3485r3486
30923095   DRIVER( bowlrama )   /* (c) 1991 P & P Marketing */
30933096   DRIVER( wfortune )   /* (c) 1989 GameTek */
30943097   DRIVER( wfortuna )   /* (c) 1989 GameTek */
3098   DRIVER( grmatch )   /* (c) 1989 GameTek */
30953099   DRIVER( stratab )   /* (c) 1990 Strata/Incredible Technologies */
30963100   DRIVER( stratab1 )   /* (c) 1990 Strata/Incredible Technologies */
30973101   DRIVER( sstrike )   /* (c) 1990 Strata/Incredible Technologies */
r3485r3486
57895793   DRIVER( ms4plus )   /* bootleg */
57905794   DRIVER( rotd )      /* 0264 (c) 2002 Evoga */
57915795   DRIVER( kof2002 )   /* 0265 (c) 2002 Eolith / Playmore */
5796   DRIVER( kof2002b )   /* bootleg */
57925797   DRIVER( kf2k2pls )   /* bootleg */
57935798   DRIVER( kf2k2pla )   /* bootleg */
57945799   DRIVER( kf2k2mp )   /* bootleg */
r3485r3486
64356440   DRIVER( denjinmk )   /* (c) 199? Banpresto */
64366441   DRIVER( sdgndmrb )   /* (c) 1993 Banpresto */
64376442   DRIVER( cupsoc )   /* (c) 1992 Seibu */
6443   DRIVER( cupsoca )   /* (c) 1992 Seibu */
64386444   DRIVER( cupsocs )   /* (c) 1992 Seibu */
64396445   DRIVER( cupsocs2 )   /* (c) 1992 Seibu */
64406446   DRIVER( cupsocsb )   /* bootleg */
r3485r3486
76147620   DRIVER( topbladv )   /* 2002 Sonokong. Top Blade V */
76157621   DRIVER( officeye )
76167622
7623   DRIVER( psattack )   /* 2004 Uniana */
7624
76177625   /* Bell Fruit Cobra Hardware */
76187626   DRIVER( inquiztr )   /* 1989 BFM */
76197627   DRIVER( escounts )   /* 1990 BFM */
r3485r3486
77497757   DRIVER( policetr )   /* (c) 1996 P&P Marketing */
77507758   DRIVER( polict11 )   /* (c) 1996 P&P Marketing */
77517759   DRIVER( polict10 )   /* (c) 1996 P&P Marketing */
7760   DRIVER( plctr13a )   /* (c) 1996 P&P Marketing */
77527761   DRIVER( plctr13b )   /* (c) 1996 P&P Marketing */
77537762   DRIVER( sshooter )   /* (c) 1998 P&P Marketing */
77547763   DRIVER( sshoot12 )   /* (c) 1998 P&P Marketing */
r3485r3486
78587867   DRIVER( skyarmy )   /* (c) 1982 Shoei */
78597868   DRIVER( lethalj )   /* (c) 1996 The Game Room */
78607869   DRIVER( eggventr )   /* (c) 1997 The Game Room */
7870   DRIVER( eggvent8 )   /* (c) 1997 The Game Room */
78617871   DRIVER( eggvent7 )   /* (c) 1997 The Game Room */
78627872   DRIVER( eggventa )   /* (c) 1997 The Game Room (Allied Leisure license) */
78637873   DRIVER( eggvntdx )   /* (c) 1997 The Game Room */
r3485r3486
82668276   DRIVER( blackt96 )   /* (c) 1996 D.G.R.M. of Korea */
82678277   DRIVER( lucky74 )   /* (c) 1988 Wing Co., Ltd */
82688278   DRIVER( lucky74a )   /* (c) 1988 Wing Co., Ltd */
8279   DRIVER( magictg )   /* (c) 199? Acclaim */
8280   DRIVER( magictga )   /* (c) 199? Acclaim */
82698281
82708282   /* InterFlip / Recreativos Franco */
82718283   DRIVER( videopkr )   /* (c) 1984 InterFlip */
src/mame/includes/itech8.h
r3485r3486
3838WRITE8_HANDLER( itech8_tms34061_w );
3939READ8_HANDLER( itech8_tms34061_r );
4040
41WRITE8_HANDLER( grmatch_palette_w );
42WRITE8_HANDLER( grmatch_xscroll_w );
43TIMER_DEVICE_CALLBACK( grmatch_palette_update );
44
4145VIDEO_UPDATE( itech8_2layer );
46VIDEO_UPDATE( itech8_grmatch );
4247VIDEO_UPDATE( itech8_2page );
4348VIDEO_UPDATE( itech8_2page_large );
src/mame/includes/neogeo.h
r3485r3486
9393void decrypt_kf10thep(running_machine *machine);
9494void decrypt_kf2k5uni(running_machine *machine);
9595void neogeo_bootleg_sx_decrypt(running_machine *machine, int value);
96void kof2002b_gfx_decrypt(running_machine *machine, UINT8 *src, int size);
9697void kf2k2mp_decrypt(running_machine *machine);
97void kof2km2_px_decrypt(running_machine *machine);
98void kf2k2mp2_px_decrypt(running_machine *machine);
9899void decrypt_cthd2003(running_machine *machine);
99100void patch_cthd2003(running_machine *machine);
100101void decrypt_ct2k3sp(running_machine *machine);
src/mame/mame.mak
r3485r3486
7979CPUS += N7751
8080CPUS += M58715
8181CPUS += I8X41
82CPUS += I8031
83CPUS += I8032
8284CPUS += I8051
8385CPUS += I8052
8486CPUS += I8751
8587CPUS += I8752
88CPUS += I80C31
89CPUS += I80C32
90CPUS += I80C51
91CPUS += I80C52
92CPUS += I87C51
93CPUS += I87C52
94CPUS += AT89C4051
8695CPUS += DS5002FP
8796CPUS += M6800
8897CPUS += M6801
r3485r3486
15391548   $(DRIVERS)/comebaby.o \
15401549   $(DRIVERS)/coolpool.o \
15411550   $(DRIVERS)/cowrace.o \
1542   $(DRIVERS)/crystal.o $(VIDEO)/vrender0.o \
1551   $(DRIVERS)/crystal.o $(DRIVERS)/psattack.o $(VIDEO)/vrender0.o \
15431552   $(DRIVERS)/cubeqst.o \
15441553   $(DRIVERS)/cybertnk.o \
15451554   $(DRIVERS)/dcheese.o $(VIDEO)/dcheese.o \
r3485r3486
15941603   $(DRIVERS)/lucky8.o \
15951604   $(DRIVERS)/magic10.o \
15961605   $(DRIVERS)/magicfly.o \
1606   $(DRIVERS)/magictg.o \
15971607   $(DRIVERS)/malzak.o $(VIDEO)/malzak.o \
15981608   $(DRIVERS)/mcatadv.o $(VIDEO)/mcatadv.o \
15991609   $(DRIVERS)/micro3d.o \
src/mame/video/cloak.c
r3485r3486
126126
127127READ8_HANDLER( graph_processor_r )
128128{
129   UINT8 ret = current_bitmap_videoram_accessed[(bitmap_videoram_address_y << 8) | bitmap_videoram_address_x];
129   UINT8 ret = current_bitmap_videoram_displayed[(bitmap_videoram_address_y << 8) | bitmap_videoram_address_x];
130130
131131   adjust_xy(offset);
132132
src/mame/video/itech8.c
r3485r3486
154154static UINT8 *grom_base;
155155static UINT32 grom_size;
156156
157static UINT8 grmatch_palcontrol;
158static UINT8 grmatch_xscroll;
159static rgb_t grmatch_palette[2][16];
157160
158161
162
159163/*************************************
160164 *
161165 *  TMS34061 interfacing
r3485r3486
198202   page_select = 0xc0;
199203
200204   /* fetch the GROM base */
201   grom_base = memory_region(machine, "gfx1");
202   grom_size = memory_region_length(machine, "gfx1");
205   grom_base = memory_region(machine, "grom");
206   grom_size = memory_region_length(machine, "grom");
203207}
204208
205209
r3485r3486
396400         /* swap pixels for X flip in 4bpp mode */
397401         if (xflip && transmaskhi != 0xff)
398402            pix = (pix >> 4) | (pix << 4);
403         pix &= mask;
399404
400405         /* draw upper pixel */
401406         if (!transparent || (pix & transmaskhi))
402407         {
403            tms_state.vram[addr] = (tms_state.vram[addr] & (0x0f << shift)) | ((pix & mask & 0xf0) >> shift);
408            tms_state.vram[addr] = (tms_state.vram[addr] & (0x0f << shift)) | ((pix & 0xf0) >> shift);
404409            tms_state.latchram[addr] = (tms_state.latchram[addr] & (0x0f << shift)) | ((color & 0xf0) >> shift);
405410         }
406411
r3485r3486
408413         if (!transparent || (pix & transmasklo))
409414         {
410415            offs_t addr1 = addr + shift/4;
411            tms_state.vram[addr1] = (tms_state.vram[addr1] & (0xf0 >> shift)) | ((pix & mask & 0x0f) << shift);
416            tms_state.vram[addr1] = (tms_state.vram[addr1] & (0xf0 >> shift)) | ((pix & 0x0f) << shift);
412417            tms_state.latchram[addr1] = (tms_state.latchram[addr1] & (0xf0 >> shift)) | ((color & 0x0f) << shift);
413418         }
414419
r3485r3486
566571
567572/*************************************
568573 *
574 *  Special Grudge Match handlers
575 *
576 *************************************/
577
578WRITE8_HANDLER( grmatch_palette_w )
579{
580   /* set the palette control; examined in the scanline callback */
581   grmatch_palcontrol = data;
582}
583
584
585WRITE8_HANDLER( grmatch_xscroll_w )
586{
587   /* update the X scroll value */
588   video_screen_update_now(machine->primary_screen);
589   grmatch_xscroll = data;
590}
591
592
593TIMER_DEVICE_CALLBACK( grmatch_palette_update )
594{
595   /* if the high bit is set, we are supposed to latch the palette values */
596   if (grmatch_palcontrol & 0x80)
597   {
598      /* the TMS34070s latch at the start of the frame, based on the first few bytes */
599      UINT32 page_offset = (tms_state.dispstart & 0x0ffff) | grmatch_xscroll;
600      int page, x;
601
602      /* iterate over both pages */
603      for (page = 0; page < 2; page++)
604      {
605         const UINT8 *base = &tms_state.vram[(page * 0x20000 + page_offset) & 0x3ffff];
606         for (x = 0; x < 16; x++)
607         {
608            UINT8 data0 = base[x * 2 + 0];
609            UINT8 data1 = base[x * 2 + 1];
610            grmatch_palette[page][x] = MAKE_RGB(pal4bit(data0 >> 0), pal4bit(data1 >> 4), pal4bit(data1 >> 0));
611         }
612      }
613   }
614}
615
616
617
618/*************************************
619 *
569620 *  Main refresh
570621 *
571622 *************************************/
r3485r3486
606657}
607658
608659
660VIDEO_UPDATE( itech8_grmatch )
661{
662   UINT32 page_offset;
663   int x, y;
664
665   /* first get the current display state */
666   tms34061_get_display_state(&tms_state);
667
668   /* if we're blanked, just fill with black */
669   if (tms_state.blanked)
670   {
671      fillbitmap(bitmap, get_black_pen(screen->machine), cliprect);
672      return 0;
673   }
674
675   /* there are two layers: */
676   /*    top layer @ 0x00000 is 4bpp, colors come from TMS34070, enabled via palette control */
677   /* bottom layer @ 0x20000 is 4bpp, colors come from TMS34070, enabled via palette control */
678   /* 4bpp pixels are packed 2 to a byte */
679   /* xscroll is set via a separate register */
680   page_offset = (tms_state.dispstart & 0x0ffff) | grmatch_xscroll;
681   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
682   {
683      UINT8 *base0 = &tms_state.vram[0x00000 + ((page_offset + y * 256) & 0xffff)];
684      UINT8 *base2 = &tms_state.vram[0x20000 + ((page_offset + y * 256) & 0xffff)];
685      UINT32 *dest = BITMAP_ADDR32(bitmap, y, 0);
686
687      for (x = cliprect->min_x & ~1; x <= cliprect->max_x; x += 2)
688      {
689         UINT8 pix0 = base0[x / 2];
690         UINT8 pix2 = base2[x / 2];
691
692         if ((pix0 & 0xf0) != 0)
693            dest[x] = grmatch_palette[0][pix0 >> 4];
694         else
695            dest[x] = grmatch_palette[1][pix2 >> 4];
696
697         if ((pix0 & 0x0f) != 0)
698            dest[x + 1] = grmatch_palette[0][pix0 & 0x0f];
699         else
700            dest[x + 1] = grmatch_palette[1][pix2 & 0x0f];
701      }
702   }
703   return 0;
704}
705
706
609707VIDEO_UPDATE( itech8_2page )
610708{
611709   UINT32 page_offset;
src/mame/video/taito_f3.c
r3485r3486
24102410            {
24112411               if(alpha_type==1)
24122412               {
2413                  /* if (f3_alpha_level_2as==0   && f3_alpha_level_2ad==255)
2414                         *     alpha_mode[i]=3; alpha_mode_flag[i] |= 0x80;}
2415                         * will display continue screen in gseeker (mt 00026) */
24132416                  if     (f3_alpha_level_2as==0   && f3_alpha_level_2ad==255) alpha_mode[i]=0;
24142417                  else if(f3_alpha_level_2as==255 && f3_alpha_level_2ad==0  ) alpha_mode[i]=1;
24152418               }
src/mame/drivers/sslam.c
r3485r3486
395395static WRITE16_HANDLER( powerbls_sound_w )
396396{
397397   soundlatch_w(machine,0,data & 0xff);
398   cpunum_set_input_line(machine, 1,I8051_INT1_LINE,PULSE_LINE);
398   cpunum_set_input_line(machine, 1,I8051_INT1_LINE,HOLD_LINE);
399399}
400400
401401/* Memory Maps */
r3485r3486
489489//   (data & 0x40) -> always set
490490}
491491
492static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
493   AM_RANGE(0x0000, 0x07ff) AM_ROM
494ADDRESS_MAP_END
495
496492static ADDRESS_MAP_START( sound_io_map, ADDRESS_SPACE_IO, 8 )
497   AM_RANGE(0x0001, 0x0001) AM_WRITE(playmark_snd_control_w)
498   AM_RANGE(0x0003, 0x0003) AM_READWRITE(playmark_snd_command_r, playmark_oki_w)
493   AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_WRITE(playmark_snd_control_w)
494   AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_READWRITE(playmark_snd_command_r, playmark_oki_w)
499495ADDRESS_MAP_END
500496
501497/* Input Ports */
r3485r3486
734730
735731   MDRV_CPU_ADD("audio", I8051, 12000000)
736732   MDRV_CPU_FLAGS(CPU_DISABLE)      /* Internal code is not dumped - 2 boards were protected */
737   MDRV_CPU_PROGRAM_MAP(sound_map,0)
738   MDRV_CPU_IO_MAP(0,0)
739733
740734   /* video hardware */
741735   MDRV_SCREEN_ADD("main", RASTER)
r3485r3486
766760   MDRV_CPU_PROGRAM_MAP(powerbls_map, 0)
767761   MDRV_CPU_VBLANK_INT("main", irq2_line_hold)
768762
769   MDRV_CPU_ADD("audio", I8051, 12000000)
770   MDRV_CPU_PROGRAM_MAP(sound_map,0)
763   MDRV_CPU_ADD("audio", I80C51, 12000000)      /* 83C751 */
771764   MDRV_CPU_IO_MAP(sound_io_map,0)
772765
773766   /* video hardware */
r3485r3486
829822   ROM_RELOAD ( 0xe00001, 0x80000 )
830823   ROM_RELOAD ( 0xf00001, 0x80000 )
831824
832   ROM_REGION( 0x0800, "audio", 0 )
825   ROM_REGION( 0x1000, "audio", 0 )
833826   ROM_LOAD( "s87c751.bin",  0x0000, 0x0800, NO_DUMP )
834827
835828   ROM_REGION( 0x200000, "gfx1", ROMREGION_DISPOSE  ) /* Bg */
r3485r3486
889882   ROM_RELOAD ( 0xe00001, 0x80000 )
890883   ROM_RELOAD ( 0xf00001, 0x80000 )
891884
892   ROM_REGION( 0x0800, "audio", 0 )
885   ROM_REGION( 0x1000, "audio", 0 )
893886   ROM_LOAD( "s87c751.bin",  0x0000, 0x0800, NO_DUMP )
894887
895888   ROM_REGION( 0x200000, "gfx1", ROMREGION_DISPOSE  ) /* Bg */
r3485r3486
920913   ROM_LOAD16_BYTE( "21.u67", 0x00000, 0x40000, CRC(4e302381) SHA1(5685d15fd3137866093ff13b95a7df2265a8bc64) )
921914   ROM_LOAD16_BYTE( "22.u66", 0x00001, 0x40000, CRC(89b70599) SHA1(57a5d71e4d8ca62fffe2e81116c5236d2194ae11) )
922915
923   ROM_REGION( 0x0800, "audio", 0 )
916   ROM_REGION( 0x1000, "audio", 0 )
924917   ROM_LOAD( "s87c751.bin",  0x0000, 0x0800, CRC(5b8b2d3a) SHA1(c3409243dfc0ca959a80f6890c87b4ce9eb0741d) )
925918
926919   ROM_REGION( 0x200000, "gfx1", ROMREGION_DISPOSE  ) /* Bg */
src/mame/drivers/policetr.c
r3485r3486
1313
1414Note:   Police Trainer v1.3B runs on the same revision PCB as Sharpshooter - Rev 0.5B
1515        If you hold the test button down and boot the game, all program roms
16        fail the checksum.  However, each checksum listed matches the checksum
17        printed on the ROM label.  This has been verified on an original PCB.
16        fail the checksum.  This has been verified on an original PCB.
17        See below for specific information on each set.
1818Note:   Police Trainer v1.0 (Rev 0.2 PCB), the checksum results in MAME have been
1919        verified to be the same as an original PCB.
2020
r3485r3486
557557ROM_END
558558
559559
560ROM_START( plctr13b ) /* Rev 0.5B PCB , unknown program rom date */
560ROM_START( plctr13a ) /* Rev 0.5B PCB , unknown program rom date. Actual version is V1.3B */
561561   ROM_REGION( 0x400000, "gfx1", ROMREGION_ERASE00 )
562562   ROM_LOAD16_BYTE( "pt-u121.bin", 0x000000, 0x100000, CRC(56b0b00a) SHA1(4034fe373a61f756f4813f0c20b1cf05e4338059) )
563563   ROM_LOAD16_BYTE( "pt-u120.bin", 0x000001, 0x100000, CRC(ca664142) SHA1(2727ecb9287b4ed30088e017bb6b8763dfb75b2f) )
564564   ROM_LOAD16_BYTE( "pt-u125.bin", 0x200000, 0x100000, CRC(e9ccf3a0) SHA1(b3fd8c094f76ace4cf403c3d0f6bd6c5d8db7d6a) )
565565   ROM_LOAD16_BYTE( "pt-u124.bin", 0x200001, 0x100000, CRC(f4acf921) SHA1(5b244e9a51304318fa0c03eb7365b3c12627d19b) )
566566
567   ROM_REGION32_BE( 0x100000, "user1", 0 )
567   ROM_REGION32_BE( 0x100000, "user1", 0 ) /* Program roms are type 27C020 */
568568/*
569Note: If you set the dipswitch to service mode and reset the game within Mame.
570      All 4 program ROMs fail the checksum code... IE: they show in red
571      instead of green.  But, the listed checksums on the screen match the
572      checksums printed on the ROM labels... this seems wierd to me.
573      However, this has been verified to happen on a real PCB
569Note: With this version, the program roms are twice the size of those found on all other Police Trainer sets. Like the set listed below,
570      if you set the dipswitch to service mode and reset the game within Mame. All 4 program ROMs fail the checksum code and the listed
571      checksums on the screen match the set below.  IE: U110=556D, U111=E5F1, U112=974C & U113=CB73
574572
575      There was a PCB on eBay that used mask roms for the program roms with the following checksum
576      values printed on the labels
573      However, if you check the Diagnostics screen, the program rom checksum is 6819480C which is different then the set below. So it
574      looks like it's checking the extra code.  The roms do not contain identical halves, so it's unknown what the "new" data is or does.
577575
578      U110  050C
579      u111  F343
580      U112  201D
581      U113  FB46
576      This set has also been found using mask roms for the program roms which would indicate it was the final version.
577*/
578   ROM_LOAD32_BYTE( "pt-av13.u113", 0x00000, 0x40000, CRC(909c052d) SHA1(23bd4849261ee5cc2414a4043ee929ccf1bd6806) ) /* Checksum printed on label  FB46 */
579   ROM_LOAD32_BYTE( "pt-av13.u112", 0x00001, 0x40000, CRC(f9dc9ca8) SHA1(52de7bc8c9aa7834d953b9f9e2a65e06f8042f0a) ) /* Checksum printed on label  201D */
580   ROM_LOAD32_BYTE( "pt-av13.u111", 0x00002, 0x40000, CRC(8c4f3a64) SHA1(4953e6fc26bae7d6e7c7230f4ca76e3f5032af14) ) /* Checksum printed on label  F343 */
581   ROM_LOAD32_BYTE( "pt-av13.u110", 0x00003, 0x40000, CRC(738a8277) SHA1(423a9bcecb82959f38ae79a0728d72eb13ed93b3) ) /* Checksum printed on label  050C */
582582
583      These are different then the current set and might have the checksum test corrected.
583   ROM_REGION( 0x600000, "bsmt", 0 )
584   ROM_LOAD( "pt-u160.bin", 0x000000, 0x100000, CRC(f267f813) SHA1(ae58507947fe2e9701b5df46565fd9908e2f9d77) )
585   ROM_RELOAD(              0x3f8000, 0x100000 )
586   ROM_LOAD( "pt-u162.bin", 0x100000, 0x100000, CRC(75fe850e) SHA1(ab8cf24ae6e5cf80f6a9a34e46f2b1596879643b) )
587   ROM_RELOAD(              0x4f8000, 0x100000 )
588ROM_END
584589
590
591ROM_START( plctr13b ) /* Rev 0.5B PCB , unknown program rom date Actual version is V1.3B */
592   ROM_REGION( 0x400000, "gfx1", ROMREGION_ERASE00 )
593   ROM_LOAD16_BYTE( "pt-u121.bin", 0x000000, 0x100000, CRC(56b0b00a) SHA1(4034fe373a61f756f4813f0c20b1cf05e4338059) )
594   ROM_LOAD16_BYTE( "pt-u120.bin", 0x000001, 0x100000, CRC(ca664142) SHA1(2727ecb9287b4ed30088e017bb6b8763dfb75b2f) )
595   ROM_LOAD16_BYTE( "pt-u125.bin", 0x200000, 0x100000, CRC(e9ccf3a0) SHA1(b3fd8c094f76ace4cf403c3d0f6bd6c5d8db7d6a) )
596   ROM_LOAD16_BYTE( "pt-u124.bin", 0x200001, 0x100000, CRC(f4acf921) SHA1(5b244e9a51304318fa0c03eb7365b3c12627d19b) )
597
598   ROM_REGION32_BE( 0x100000, "user1", 0 ) /* Program roms are type 27C010 */
599/*
600Note: If you set the dipswitch to service mode and reset the game within Mame. All 4 program ROMs fail the checksum code, IE: they
601      show in red instead of green.  But, the listed checksums on the screen match the checksums printed on the ROM labels. However,
602      this has been verified to happen on a real PCB
603
604      The program rom checksum in the diagnostic screen is 17551773
585605*/
586   ROM_LOAD32_BYTE( "ptb-u113.v13", 0x00000, 0x20000, CRC(d636c00d) SHA1(ef989eb85b51a64ca640297c1286514c8d7f8f76) )
587   ROM_LOAD32_BYTE( "ptb-u112.v13", 0x00001, 0x20000, CRC(86f0497e) SHA1(d177023f7cb2e01de60ef072212836dc94759c1a) )
588   ROM_LOAD32_BYTE( "ptb-u111.v13", 0x00002, 0x20000, CRC(39e96d6a) SHA1(efe6ffe70432b94c98f3d7247408a6d2f6f9e33d) )
589   ROM_LOAD32_BYTE( "ptb-u110.v13", 0x00003, 0x20000, CRC(d7e6f4cb) SHA1(9dffe4937bc5cf47d870f06ae0dced362cd2dd66) )
606   ROM_LOAD32_BYTE( "ptb-u113.v13", 0x00000, 0x20000, CRC(d636c00d) SHA1(ef989eb85b51a64ca640297c1286514c8d7f8f76) ) /* Checksum printed on label  CB73 */
607   ROM_LOAD32_BYTE( "ptb-u112.v13", 0x00001, 0x20000, CRC(86f0497e) SHA1(d177023f7cb2e01de60ef072212836dc94759c1a) ) /* Checksum printed on label  974C */
608   ROM_LOAD32_BYTE( "ptb-u111.v13", 0x00002, 0x20000, CRC(39e96d6a) SHA1(efe6ffe70432b94c98f3d7247408a6d2f6f9e33d) ) /* Checksum printed on label  E5F1 */
609   ROM_LOAD32_BYTE( "ptb-u110.v13", 0x00003, 0x20000, CRC(d7e6f4cb) SHA1(9dffe4937bc5cf47d870f06ae0dced362cd2dd66) ) /* Checksum printed on label  556D */
590610
591611   ROM_REGION( 0x600000, "bsmt", 0 )
592612   ROM_LOAD( "pt-u160.bin", 0x000000, 0x100000, CRC(f267f813) SHA1(ae58507947fe2e9701b5df46565fd9908e2f9d77) )
r3485r3486
715735GAME( 1996, polict11, policetr, policetr, polict10, policetr, ROT0, "P & P Marketing", "Police Trainer (Rev 1.1)", 0 )
716736GAME( 1996, polict10, policetr, policetr, polict10, policetr, ROT0, "P & P Marketing", "Police Trainer (Rev 1.0)", 0 )
717737
738GAME( 1996, plctr13a, policetr, sshooter, policetr, plctr13b, ROT0, "P & P Marketing", "Police Trainer (Rev 1.3B Newer)", 0 )
718739GAME( 1996, plctr13b, policetr, sshooter, policetr, plctr13b, ROT0, "P & P Marketing", "Police Trainer (Rev 1.3B)", 0 )
719740GAME( 1998, sshooter, 0,        sshooter, policetr, sshooter, ROT0, "P & P Marketing", "Sharpshooter (Rev 1.7)", 0 )
720741GAME( 1998, sshoot12, sshooter, sshooter, sshoot11, sshoot12, ROT0, "P & P Marketing", "Sharpshooter (Rev 1.2)", 0 )
src/mame/drivers/system1.c
r3485r3486
15501550   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
15511551INPUT_PORTS_END
15521552
1553/*************************************
1554 *
1555 *  Graphics definitions
1556 *
1557 *************************************/
1558
15531559static const gfx_layout charlayout =
15541560{
15551561   8,8,
r3485r3486
15661572   GFXDECODE_ENTRY( "gfx1", 0, charlayout, 512, 128 )
15671573GFXDECODE_END
15681574
1575/*************************************
1576 *
1577 *  Machine driver
1578 *
1579 *************************************/
15691580
1570
15711581static MACHINE_DRIVER_START( system1 )
15721582
15731583   /* basic machine hardware */
r3485r3486
16601670MACHINE_DRIVER_END
16611671
16621672
1673static MACHINE_DRIVER_START( dakkochn )
16631674
1675   /* basic machine hardware */
1676   MDRV_IMPORT_FROM( chplft )
1677   MDRV_CPU_MODIFY("main")
1678   MDRV_CPU_IO_MAP(wbml_io_map,0)
1679
1680   /* video hardware */
1681   MDRV_VIDEO_START(wbml)
1682
1683MACHINE_DRIVER_END
1684
1685
16641686static MACHINE_DRIVER_START( brain )
16651687
16661688   /* basic machine hardware */
r3485r3486
16901712
16911713MACHINE_DRIVER_END
16921714
1715
16931716static MACHINE_DRIVER_START( shtngmst )
16941717
16951718   /* basic machine hardware */
r3485r3486
17061729
17071730   MDRV_VIDEO_UPDATE(choplifter)
17081731
1709
17101732MACHINE_DRIVER_END
17111733
17121734
r3485r3486
17261748
17271749MACHINE_DRIVER_END
17281750
1751
17291752static MACHINE_DRIVER_START( blckgalb )
17301753
17311754   /* basic machine hardware */
r3485r3486
17381761
17391762MACHINE_DRIVER_END
17401763
1764
17411765static MACHINE_DRIVER_START( ufosensi )
17421766
17431767   /* basic machine hardware */
r3485r3486
17491773
17501774   /* video hardware */
17511775   MDRV_VIDEO_UPDATE(ufosensi)
1776
17521777MACHINE_DRIVER_END
17531778
1754/***************************************************************************
1779/*************************************
1780 *
1781 *  ROM definition(s)
1782 *
1783 *************************************/
17551784
1756  Game driver(s)
1757
1758***************************************************************************/
1759
17601785/* Since the standard System 1 PROM has part # 5317, Star Jacker, whose first */
17611786/* ROM is #5318, is probably the first or second System 1 game produced */
17621787ROM_START( starjack )
r3485r3486
39113936   ROM_LOAD( "nobo_pr.13a", 0x0300, 0x0100, CRC(648350b8) SHA1(c7986aa9127ef5b50b845434cb4e81dff9861cd2) ) /* timing? (not used) */
39123937ROM_END
39133938
3939/*************************************
3940 *
3941 *  Generic driver initialization
3942 *
3943 *************************************/
3944
39143945static DRIVER_INIT( regulus )   { regulus_decode(machine, "main"); }
39153946static DRIVER_INIT( mrviking )   { mrviking_decode(machine, "main"); }
3916static DRIVER_INIT( swat )      { swat_decode(machine, "main"); }
3947static DRIVER_INIT( swat )   { swat_decode(machine, "main"); }
39173948static DRIVER_INIT( flicky )   { flicky_decode(machine, "main"); }
39183949static DRIVER_INIT( wmatch )   { wmatch_decode(machine, "main"); }
39193950static DRIVER_INIT( bullfgtj )   { bullfgtj_decode(machine, "main"); }
r3485r3486
39263957static DRIVER_INIT( hvymetal )   { hvymetal_decode(machine, "main"); }
39273958static DRIVER_INIT( myheroj )   { myheroj_decode(machine, "main"); }
39283959static DRIVER_INIT( 4dwarrio )   { fdwarrio_decode(machine, "main"); }
3929static DRIVER_INIT( wboy )      { astrofl_decode(machine, "main"); }
3930static DRIVER_INIT( wboy2 )      { wboy2_decode(machine, "main"); }
3960static DRIVER_INIT( wboy )   { astrofl_decode(machine, "main"); }
3961static DRIVER_INIT( wboy2 )   { wboy2_decode(machine, "main"); }
39313962static DRIVER_INIT( gardia )   { gardia_decode(machine, "main"); }
39323963static DRIVER_INIT( gardiab )   { gardiab_decode(machine, "main"); }
39333964
39343965
39353966
39363967static DRIVER_INIT( blockgal )   { mc8123_decrypt_rom(machine, "main", "user1", 0, 0); }
3937static DRIVER_INIT( wbml )      { mc8123_decrypt_rom(machine, "main", "user1", 1, 4); }
3968static DRIVER_INIT( wbml )   { mc8123_decrypt_rom(machine, "main", "user1", 1, 4); }
39383969static DRIVER_INIT( ufosensi )  { mc8123_decrypt_rom(machine, "main", "user1", 1, 4); }
39393970
39403971static UINT8 dakkochn_control;
r3485r3486
40524083   memory_configure_bank_decrypted(1, 0, 4, memory_region(machine, "main") + 0x30000, 0x4000);
40534084}
40544085
4086/*************************************
4087 *
4088 *  Game driver(s)
4089 *
4090 *************************************/
40554091
40564092GAME( 1983, starjack, 0,        small,    starjack, 0,        ROT270, "Sega",            "Star Jacker (Sega)", GAME_SUPPORTS_SAVE )
40574093GAME( 1983, starjacs, starjack, small,    starjacs, 0,        ROT270, "Stern",           "Star Jacker (Stern)", GAME_SUPPORTS_SAVE )
r3485r3486
41194155GAME( 1987, wbmljb,   wbml,     wbml,     wbml,     bootlegb, ROT0,   "bootleg",         "Wonder Boy in Monster Land (Japan not encrypted)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
41204156GAME( 1987, wbmlb,    wbml,     wbml,     wbml,     bootlegb, ROT0,   "bootleg",         "Wonder Boy in Monster Land (English bootleg)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE)
41214157GAME( 1987, wbmlbg,   wbml,     wbml,     wbml,     bootlegb, ROT0,   "bootleg",         "Wonder Boy in Monster Land (Galaxy Electronics English bootleg)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE)
4122GAME( 1987, dakkochn, 0,        wbml,     wbml,     dakkochn, ROT0,   "Whiteboard",      "DakkoChan House (MC-8123, 317-0014)", GAME_NOT_WORKING | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
4158GAME( 1987, dakkochn, 0,        dakkochn, wbml,     dakkochn, ROT0,   "Whiteboard",      "DakkoChan House (MC-8123, 317-0014)", GAME_NOT_WORKING | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS )
41234159GAME( 1988, ufosensi, 0,        ufosensi, ufosensi, ufosensi, ROT0,   "Sega",            "Ufo Senshi Yohko Chan (MC-8123, 317-0064)", GAME_SUPPORTS_SAVE )
41244160GAME( 1988, ufosensb, ufosensi, ufosensi, ufosensi, bootlegb, ROT0,   "bootleg",         "Ufo Senshi Yohko Chan (not encrypted)", GAME_SUPPORTS_SAVE )
src/mame/drivers/megadriv.c
r3485r3486
6565#include "sound/fm.h"
6666#include "cpu/m68000/m68000.h"
6767#include "megadriv.h"
68#include "cpu/sh2/sh2.h"
6869
69
7070#define MEGADRIV_VDP_VRAM(address) megadrive_vdp_vram[(address)&0x7fff]
7171
7272/* the same on all systems? */
73#define MASTER_CLOCK_NTSC      53693100
73#define MASTER_CLOCK_NTSC 53693175
74#define MASTER_CLOCK_PAL  53203424
75
76#define SEGACD_CLOCK      12500000
77
7478/* timing details */
7579static int megadriv_framerate;
7680static int megadrive_total_scanlines;
r3485r3486
8589static int megadrive_irq6_pending = 0;
8690static int megadrive_irq4_pending = 0;
8791
92/* 32x! */
93static int _32x_master_cpu_number;
94static int _32x_slave_cpu_number;
95static int _32x_is_connected;
96
97static UINT16* _32x_dram0;
98static UINT16* _32x_dram1;
99static UINT16 *_32x_display_dram, *_32x_access_dram;
100static UINT16* _32x_palette;
101static UINT16* _32x_palette_lookup;
102/* SegaCD! */
103static int _segacd_68k_cpu_number;
104/* SVP (virtua racing) */
105static int _svp_cpu_number;
106
107
108static int _genesis_snd_z80_cpu_number;
109
88110int segac2_bg_pal_lookup[4] = { 0x00, 0x10, 0x20, 0x30 };
89111int segac2_sp_pal_lookup[4] = { 0x00, 0x10, 0x20, 0x30 };
90112
91113// hacks for C2
92114int genvdp_use_cram = 1; // c2 uses it's own palette ram
93int genesis_has_z80 = 1; // c2 doesn't have a z80..
115int genesis_has_z80;
94116int genesis_always_irq6 = 0; // c2 never enables the irq6, different source??
95117int genesis_other_hacks = 1; // misc hacks
96118
r3485r3486
24842506
24852507/****************************************** 32X related ******************************************/
24862508
2487static READ16_HANDLER( _32x_reg_r )
2488{
2489   return mame_rand(machine);
2490}
24912509
2492static UINT16 _32x_68k_comms[0x8];
2493static UINT16 _32x_palette[0x400/2];
2494
2495static READ16_HANDLER( _32x_68k_comms_r )
2496{
2497   return _32x_68k_comms[offset];
2498}
2499
2500static WRITE16_HANDLER(_32x_68k_comms_w)
2501{
2502   _32x_68k_comms[offset] = data;
2503}
2504
2505static READ16_HANDLER( _32x_68k_palette_r )
2506{
2507   return _32x_palette[offset];
2508}
2509
2510static WRITE16_HANDLER( _32x_68k_palette_w )
2511{
2512   _32x_palette[offset] = data;
2513}
2514
2515static ADDRESS_MAP_START( _32x_readmem, ADDRESS_SPACE_PROGRAM, 16 )
2516   AM_RANGE(0x000000 , 0x3fffff) AM_READ(SMH_ROM)
2517
2518   AM_RANGE(0x880000 , 0x8fffff) AM_READ(SMH_BANK2)
2519   AM_RANGE(0x900000 , 0x9fffff) AM_READ(SMH_BANK3)
2520
2521   AM_RANGE(0xa00000 , 0xa01fff) AM_READ(megadriv_68k_read_z80_ram)
2522   AM_RANGE(0xa04000 , 0xa04003) AM_READ(megadriv_68k_YM2612_read)
2523   AM_RANGE(0xa10000 , 0xa1001f) AM_READ(megadriv_68k_io_read)
2524   AM_RANGE(0xa11100 , 0xa11101) AM_READ(megadriv_68k_check_z80_bus)
2525
2526
2527   AM_RANGE(0xa15120 , 0xa1512f) AM_READ(_32x_68k_comms_r )
2528   AM_RANGE(0xa1518a , 0xa1518b) AM_READ(_32x_reg_r)
2529   AM_RANGE(0xa15200 , 0xa153ff) AM_READ(_32x_68k_palette_r )
2530
2531   AM_RANGE(0xc00000 , 0xc0001f) AM_READ(megadriv_vdp_r)
2532   AM_RANGE(0xd00000 , 0xd0001f) AM_READ(megadriv_vdp_r) // the earth defend
2533   AM_RANGE(0xe00000 , 0xe0ffff) AM_READ(SMH_RAM) AM_MIRROR(0x1f0000)
2510static ADDRESS_MAP_START( sh2_main_map, ADDRESS_SPACE_PROGRAM, 32 )
2511   AM_RANGE(0x0000000 , 0x0003fff) AM_ROM
25342512ADDRESS_MAP_END
25352513
2536static ADDRESS_MAP_START( _32x_writemem, ADDRESS_SPACE_PROGRAM, 16 )
2537   AM_RANGE(0x000000 , 0x3fffff) AM_WRITE(SMH_ROM)
2538
2539   AM_RANGE(0x880000, 0x8fffff) AM_WRITE(SMH_ROM)
2540   AM_RANGE(0x900000, 0x9fffff) AM_WRITE(SMH_ROM)
2541
2542
2543   AM_RANGE(0xa00000 , 0xa01fff) AM_WRITE(megadriv_68k_write_z80_ram)
2544   AM_RANGE(0xa02000 , 0xa03fff) AM_WRITE(megadriv_68k_write_z80_ram)
2545   AM_RANGE(0xa04000 , 0xa04003) AM_WRITE(megadriv_68k_YM2612_write)
2546   AM_RANGE(0xa06000 , 0xa06001) AM_WRITE(megadriv_68k_z80_bank_write)
2547   AM_RANGE(0xa10000 , 0xa1001f) AM_WRITE(megadriv_68k_io_write)
2548   AM_RANGE(0xa11100 , 0xa11101) AM_WRITE(megadriv_68k_req_z80_bus)
2549   AM_RANGE(0xa11200 , 0xa11201) AM_WRITE(megadriv_68k_req_z80_reset)
2550
2551   AM_RANGE(0xa15120 , 0xa1512f) AM_WRITE(_32x_68k_comms_w )
2552   AM_RANGE(0xa15200 , 0xa153ff) AM_WRITE(_32x_68k_palette_w )
2553
2554
2555   AM_RANGE(0xc00000 , 0xc0001f) AM_WRITE(megadriv_vdp_w)
2556   AM_RANGE(0xd00000 , 0xd0001f) AM_WRITE(megadriv_vdp_w)
2557   AM_RANGE(0xe00000 , 0xe0ffff) AM_WRITE(SMH_RAM) AM_MIRROR(0x1f0000) AM_BASE(&megadrive_ram)
2514static ADDRESS_MAP_START( sh2_slave_map, ADDRESS_SPACE_PROGRAM, 32 )
2515   AM_RANGE(0x0000000 , 0x0003fff) AM_ROM
25582516ADDRESS_MAP_END
25592517
2560static ADDRESS_MAP_START( sh2main_readmem, ADDRESS_SPACE_PROGRAM, 32 )
2561   AM_RANGE(0x0000000 , 0x0003fff) AM_READ(SMH_ROM)
2562   AM_RANGE(0x2000000 , 0x23fffff) AM_READ(SMH_BANK4)
2518static ADDRESS_MAP_START( segacd_map, ADDRESS_SPACE_PROGRAM, 16 )
2519   AM_RANGE(0x0000000 , 0x0003fff) AM_RAM
25632520ADDRESS_MAP_END
25642521
2565static ADDRESS_MAP_START( sh2main_writemem, ADDRESS_SPACE_PROGRAM, 32 )
2566   AM_RANGE(0x0000000 , 0x0003fff) AM_WRITE(SMH_ROM)
2567   AM_RANGE(0x2000000 , 0x23fffff) AM_WRITE(SMH_ROM)
2568ADDRESS_MAP_END
25692522
2570
2571static ADDRESS_MAP_START( sh2slave_readmem, ADDRESS_SPACE_PROGRAM, 32 )
2572   AM_RANGE(0x0000000 , 0x0003fff) AM_READ(SMH_ROM)
2573   AM_RANGE(0x2000000 , 0x23fffff) AM_READ(SMH_BANK4)
2574ADDRESS_MAP_END
2575
2576static ADDRESS_MAP_START( sh2slave_writemem, ADDRESS_SPACE_PROGRAM, 32 )
2577   AM_RANGE(0x0000000 , 0x0003fff) AM_WRITE(SMH_ROM)
2578   AM_RANGE(0x2000000 , 0x23fffff) AM_WRITE(SMH_ROM)
2579ADDRESS_MAP_END
2580
2581
25822523/****************************************** END 32X related *************************************/
25832524
25842525/****************************************** SVP related *****************************************/
r3485r3486
29852926   /* IRQs are not used by this CPU */
29862927MACHINE_DRIVER_END
29872928
2929MACHINE_DRIVER_START( megdsvppal )
2930   MDRV_IMPORT_FROM(megadpal)
29882931
2932   MDRV_CPU_ADD("svp", SSP1601, MASTER_CLOCK_PAL / 7 * 3) /* ~23 MHz (guessed) */
2933   MDRV_CPU_PROGRAM_MAP(svp_ssp_map, 0)
2934   MDRV_CPU_IO_MAP(svp_ext_map, 0)
2935   /* IRQs are not used by this CPU */
2936MACHINE_DRIVER_END
2937
29892938/****************************************** END SVP related *************************************/
29902939
29912940
r3485r3486
33313280   /* Clear our Render Buffer */
33323281   for (x=0;x<320;x++)
33333282   {
3334      video_renderline[x]=MEGADRIVE_REG07_BGCOLOUR;
3283      video_renderline[x]=MEGADRIVE_REG07_BGCOLOUR | 0x20000; // mark as BG
33353284   }
33363285
33373286   memset(highpri_renderline, 0, 320);
r3485r3486
43884337
43894338   }
43904339
4340   if (_32x_is_connected)
4341   {
4342      UINT32 lineoffs;
4343      lineoffs = _32x_display_dram[scanline];
4344
4345      for (x=0;x<320;x++)
4346      {
4347         UINT16 coldata;
4348         coldata = _32x_display_dram[lineoffs];
4349
4350         {
4351            if  ((_32x_palette[(coldata & 0xff00)>>8] & 0x8000)==0x8000)
4352               lineptr[x] = _32x_palette_lookup[(coldata & 0xff00)>>8];
4353
4354            x++;
4355
4356            if  ((_32x_palette[(coldata & 0x00ff)>>0] & 0x8000)==0x8000)
4357               lineptr[x] = _32x_palette_lookup[(coldata & 0x00ff)];
4358         }
4359
4360         lineoffs++;
4361
4362      }
4363   }
4364
43914365}
43924366
43934367static void genesis_render_scanline(running_machine *machine, int scanline)
r3485r3486
47724746
47734747
47744748
4775if (genesis_has_z80)
4776{
4749   if (genesis_has_z80)
4750   {
47774751      if (genesis_scanline_counter==megadrive_z80irq_scanline)
47784752      {
47794753         if ((genz80.z80_has_bus==1) && (genz80.z80_is_reset==0)) cpunum_set_input_line(machine, 1,0,HOLD_LINE);
r3485r3486
47824756      {
47834757         cpunum_set_input_line(machine, 1,0,CLEAR_LINE);
47844758      }
4785}
4759   }
47864760
47874761   }
47884762   else /* pretend we're still on the same scanline to compensate for rounding errors */
r3485r3486
48194793   /* default state of z80 = reset, with bus */
48204794   mame_printf_debug("Resetting Megadrive / Genesis\n");
48214795
4796
4797
48224798   switch (input_port_read_safe(machine, "REGION", 0x00))
48234799   {
48244800
r3485r3486
48514827      break;
48524828   }
48534829
4854if (genesis_has_z80)
4855{
4856   genz80.z80_is_reset = 1;
4857   cpunum_set_input_line(machine, genz80.z80_cpunum, INPUT_LINE_RESET, ASSERT_LINE);
4858   genz80.z80_has_bus = 1;
4859   cpunum_set_input_line(machine, genz80.z80_cpunum, INPUT_LINE_HALT, CLEAR_LINE);
4860   genz80.z80_bank_pos = 0;
4861   genz80.z80_bank_addr = 0;
4862   genesis_scanline_counter = -1;
4863}
4830   if (genesis_has_z80)
4831   {
4832      genz80.z80_is_reset = 1;
4833      cpunum_set_input_line(machine, genz80.z80_cpunum, INPUT_LINE_RESET, ASSERT_LINE);
4834      genz80.z80_has_bus = 1;
4835      cpunum_set_input_line(machine, genz80.z80_cpunum, INPUT_LINE_HALT, CLEAR_LINE);
4836      genz80.z80_bank_pos = 0;
4837      genz80.z80_bank_addr = 0;
4838      genesis_scanline_counter = -1;
4839   }
48644840
48654841   megadrive_imode = 0;
48664842
r3485r3486
48764852   timer_adjust_oneshot(frame_timer, attotime_zero, 0);
48774853   timer_adjust_oneshot(scanline_timer,  attotime_zero, 0);
48784854
4879if (genesis_other_hacks)
4880{
4881//  set_refresh_rate(megadriv_framerate);
4882   cpunum_set_clockscale(machine, 0, 0.9950f); /* Fatal Rewind is very fussy... */
4883//  cpunum_set_clockscale(machine, 0, 0.3800f); /* Fatal Rewind is very fussy... */
4855   if (genesis_other_hacks)
4856   {
4857   //  set_refresh_rate(megadriv_framerate);
4858      cpunum_set_clockscale(machine, 0, 0.9950f); /* Fatal Rewind is very fussy... */
4859   //  cpunum_set_clockscale(machine, 0, 0.3800f); /* Fatal Rewind is very fussy... */
48844860
4885   memset(megadrive_ram,0x00,0x10000);
4886}
4861      memset(megadrive_ram,0x00,0x10000);
4862   }
48874863
48884864   irq4counter = -1;
48894865   megadrive_total_scanlines = 262;
r3485r3486
48924868   megadrive_z80irq_scanline = 226;
48934869
48944870
4871   /* if any of these extra CPUs exist, pause them until we actually turn them on */
4872   if (_32x_master_cpu_number != -1)
4873   {
4874      cpunum_set_input_line(machine, _32x_master_cpu_number, INPUT_LINE_RESET, ASSERT_LINE);
4875      cpunum_set_input_line(machine, _32x_master_cpu_number, INPUT_LINE_HALT, ASSERT_LINE);
4876   }
48954877
4878   if (_32x_slave_cpu_number != -1)
4879   {
4880      cpunum_set_input_line(machine, _32x_slave_cpu_number, INPUT_LINE_RESET, ASSERT_LINE);
4881      cpunum_set_input_line(machine, _32x_slave_cpu_number, INPUT_LINE_HALT, ASSERT_LINE);
4882   }
4883
4884   if (_segacd_68k_cpu_number != -1 )
4885   {
4886      cpunum_set_input_line(machine, _segacd_68k_cpu_number, INPUT_LINE_RESET, ASSERT_LINE);
4887      cpunum_set_input_line(machine, _segacd_68k_cpu_number, INPUT_LINE_HALT, ASSERT_LINE);
4888   }
4889
48964890}
48974891
48984892void megadriv_stop_scanline_timer(void)
r3485r3486
50945088   MDRV_CPU_PROGRAM_MAP(megadriv_readmem,megadriv_writemem)
50955089   /* IRQs are handled via the timers */
50965090
5097   MDRV_CPU_ADD("sound", Z80, MASTER_CLOCK_NTSC / 15) /* 3.58 MHz */
5091   MDRV_CPU_ADD("genesis_snd_z80", Z80, MASTER_CLOCK_NTSC / 15) /* 3.58 MHz */
50985092   MDRV_CPU_PROGRAM_MAP(z80_readmem,z80_writemem)
50995093   MDRV_CPU_IO_MAP(z80_portmap,0)
51005094   /* IRQ handled via the timers */
51015095
51025096   MDRV_MACHINE_RESET(megadriv)
51035097
5104
51055098   MDRV_SCREEN_ADD("megadriv", RASTER)
51065099   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB15)
51075100   MDRV_SCREEN_REFRESH_RATE(60)
r3485r3486
51205113   MDRV_VIDEO_EOF(megadriv) /* Used to Sync the timing */
51215114
51225115   /* sound hardware */
5123#if 0
5124   MDRV_SPEAKER_STANDARD_MONO("mono")
5116   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
51255117
51265118   MDRV_SOUND_ADD("ym", YM2612, MASTER_CLOCK_NTSC/7) /* 7.67 MHz */
5127   MDRV_SOUND_ROUTE(0, "mono", 0.50)
5128   MDRV_SOUND_ROUTE(1, "mono", 0.50)
5119   MDRV_SOUND_ROUTE(0, "left", 0.50)
5120   MDRV_SOUND_ROUTE(1, "right", 0.50)
51295121
51305122   /* sound hardware */
51315123   MDRV_SOUND_ADD("sn", SN76496, MASTER_CLOCK_NTSC/15)
5132   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) /* 3.58 MHz */
5133#else
5124   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.25) /* 3.58 MHz */
5125   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right",0.25) /* 3.58 MHz */
5126MACHINE_DRIVER_END
5127
5128/************ PAL hardware has a different master clock *************/
5129
5130MACHINE_DRIVER_START( megadpal )
5131   MDRV_CPU_ADD("main", M68000, MASTER_CLOCK_PAL / 7) /* 7.67 MHz */
5132   MDRV_CPU_PROGRAM_MAP(megadriv_readmem,megadriv_writemem)
5133   /* IRQs are handled via the timers */
5134
5135   MDRV_CPU_ADD("genesis_snd_z80", Z80, MASTER_CLOCK_PAL / 15) /* 3.58 MHz */
5136   MDRV_CPU_PROGRAM_MAP(z80_readmem,z80_writemem)
5137   MDRV_CPU_IO_MAP(z80_portmap,0)
5138   /* IRQ handled via the timers */
5139
5140   MDRV_MACHINE_RESET(megadriv)
5141
5142   MDRV_SCREEN_ADD("megadriv", RASTER)
5143   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB15)
5144   MDRV_SCREEN_REFRESH_RATE(60)
5145   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) // Vblank handled manually.
5146   MDRV_SCREEN_SIZE(64*8, 64*8)
5147   MDRV_SCREEN_VISIBLE_AREA(0, 32*8-1, 0, 28*8-1)
5148
5149#ifndef MESS
5150   MDRV_NVRAM_HANDLER(megadriv)
5151#endif
5152
5153   MDRV_PALETTE_LENGTH(0x200)
5154
5155   MDRV_VIDEO_START(megadriv)
5156   MDRV_VIDEO_UPDATE(megadriv) /* Copies a bitmap */
5157   MDRV_VIDEO_EOF(megadriv) /* Used to Sync the timing */
5158
5159   /* sound hardware */
51345160   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
51355161
5136   MDRV_SOUND_ADD("ym", YM2612, MASTER_CLOCK_NTSC/7) /* 7.67 MHz */
5162   MDRV_SOUND_ADD("ym", YM2612, MASTER_CLOCK_PAL/7) /* 7.67 MHz */
51375163   MDRV_SOUND_ROUTE(0, "left", 0.50)
51385164   MDRV_SOUND_ROUTE(1, "right", 0.50)
51395165
51405166   /* sound hardware */
5141   MDRV_SOUND_ADD("sn", SN76496, MASTER_CLOCK_NTSC/15)
5167   MDRV_SOUND_ADD("sn", SN76496, MASTER_CLOCK_PAL/15)
51425168   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.25) /* 3.58 MHz */
51435169   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right",0.25) /* 3.58 MHz */
5144#endif
5145
51465170MACHINE_DRIVER_END
51475171
5148MACHINE_DRIVER_START( megadpal )
5172
5173
5174static const sh2_cpu_core sh2_conf_master = { 0, NULL };
5175static const sh2_cpu_core sh2_conf_slave  = { 1, NULL };
5176
5177MACHINE_DRIVER_START( genesis_32x )
51495178   MDRV_IMPORT_FROM(megadriv)
51505179
5151   MDRV_SCREEN_MODIFY("megadriv")
5152   MDRV_SCREEN_REFRESH_RATE(50)
5180   MDRV_CPU_ADD("32x_master_sh2", SH2, (MASTER_CLOCK_NTSC*3)/7 )
5181   MDRV_CPU_PROGRAM_MAP(sh2_main_map, 0)
5182   MDRV_CPU_CONFIG(sh2_conf_master)
5183
5184   MDRV_CPU_ADD("32x_slave_sh2", SH2, (MASTER_CLOCK_NTSC*3)/7 )
5185   MDRV_CPU_PROGRAM_MAP(sh2_slave_map, 0)
5186   MDRV_CPU_CONFIG(sh2_conf_slave)
51535187MACHINE_DRIVER_END
51545188
5155MACHINE_DRIVER_START( _32x )
5189MACHINE_DRIVER_START( genesis_scd )
51565190   MDRV_IMPORT_FROM(megadriv)
5157   MDRV_CPU_MODIFY("main")
5158   MDRV_CPU_PROGRAM_MAP(_32x_readmem,_32x_writemem)
51595191
5160   MDRV_CPU_ADD("SH2main", SH2, 10000000 )
5161   MDRV_CPU_PROGRAM_MAP(sh2main_readmem,sh2main_writemem)
5192   MDRV_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */
5193   MDRV_CPU_PROGRAM_MAP(segacd_map,0)
5194MACHINE_DRIVER_END
51625195
5163   MDRV_CPU_ADD("SH2slave", SH2, 10000000 )
5164   MDRV_CPU_PROGRAM_MAP(sh2slave_readmem,sh2slave_writemem)
5196MACHINE_DRIVER_START( genesis_32x_scd )
5197   MDRV_IMPORT_FROM(genesis_32x)
5198
5199   MDRV_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */
5200   MDRV_CPU_PROGRAM_MAP(segacd_map,0)
51655201MACHINE_DRIVER_END
51665202
5203
51675204/* Callback when the genesis enters interrupt code */
51685205static IRQ_CALLBACK(genesis_int_callback)
51695206{
r3485r3486
51885225
51895226static void megadriv_init_common(running_machine *machine)
51905227{
5228   /* Look to see if this system has the standard Sound Z80 */
5229   _genesis_snd_z80_cpu_number = mame_find_cpu_index(machine, "genesis_snd_z80");
5230   if (_genesis_snd_z80_cpu_number != -1)
5231   {
5232      printf("GENESIS Sound Z80 cpu found %d\n", _genesis_snd_z80_cpu_number );
5233      genesis_has_z80 = 1;
5234   }
5235   else
5236   {
5237      genesis_has_z80 = 0;
5238   }
51915239
5240   /* Look to see if this system has the 32x Master SH2 */
5241   _32x_master_cpu_number = mame_find_cpu_index(machine, "32x_master_sh2");
5242   if (_32x_master_cpu_number != -1)
5243   {
5244      printf("32x MASTER SH2 cpu found %d\n", _32x_master_cpu_number );
5245   }
51925246
5247   /* Look to see if this system has the 32x Slave SH2 */
5248   _32x_slave_cpu_number = mame_find_cpu_index(machine, "32x_slave_sh2");
5249   if (_32x_slave_cpu_number != -1)
5250   {
5251      printf("32x SLAVE SH2 cpu found %d\n", _32x_slave_cpu_number );
5252   }
51935253
5194if (genesis_has_z80)
5195{
5196   genz80.z80_cpunum = 1;
5197   genz80.z80_prgram = auto_malloc(0x2000);
5198   memory_set_bankptr( 1, genz80.z80_prgram );
5199}
5254   if ((_32x_master_cpu_number != -1) && (_32x_slave_cpu_number != -1))
5255   {
5256      _32x_is_connected = 1;
5257   }
5258   else
5259   {
5260      _32x_is_connected = 0;
5261   }
52005262
5263   _segacd_68k_cpu_number = mame_find_cpu_index(machine, "segacd_68k");
5264   if (_segacd_68k_cpu_number != -1)
5265   {
5266      printf("Sega CD secondary 68k cpu found %d\n", _segacd_68k_cpu_number );
5267   }
5268
5269   _svp_cpu_number = mame_find_cpu_index(machine, "svp");
5270   if (_svp_cpu_number != -1)
5271   {
5272      printf("SVP (cpu) found %d\n", _svp_cpu_number );
5273   }
5274
5275
5276   if (genesis_has_z80)
5277   {
5278      genz80.z80_cpunum = 1;
5279      genz80.z80_prgram = auto_malloc(0x2000);
5280      memory_set_bankptr( 1, genz80.z80_prgram );
5281   }
5282
52015283   cpunum_set_irq_callback(0, genesis_int_callback);
52025284   megadriv_backupram = NULL;
52035285   megadriv_backupram_length = 0;
r3485r3486
52385320      mame_printf_debug("\n");
52395321   }
52405322
5323   /* if we have an SVP cpu then do some extra initilization for it */
5324   if (_svp_cpu_number != -1)
5325   {
5326      svp_init(machine);
5327   }
5328
5329
52415330}
52425331
52435332DRIVER_INIT( megadriv_c2 )
52445333{
52455334   genvdp_use_cram = 0;
5246   genesis_has_z80 = 0;
52475335   genesis_always_irq6 = 1;
52485336   genesis_other_hacks = 0;
52495337
r3485r3486
52585346DRIVER_INIT( megadriv )
52595347{
52605348   genvdp_use_cram = 1;
5261   genesis_has_z80 = 1;
52625349   genesis_always_irq6 = 0;
52635350   genesis_other_hacks = 1;
52645351
r3485r3486
52715358DRIVER_INIT( megadrij )
52725359{
52735360   genvdp_use_cram = 1;
5274   genesis_has_z80 = 1;
52755361   genesis_always_irq6 = 0;
52765362   genesis_other_hacks = 1;
52775363
r3485r3486
52845370DRIVER_INIT( megadrie )
52855371{
52865372   genvdp_use_cram = 1;
5287   genesis_has_z80 = 1;
52885373   genesis_always_irq6 = 0;
52895374   genesis_other_hacks = 1;
52905375
r3485r3486
52945379   hazemdchoice_megadriv_framerate = 50;
52955380}
52965381
5297DRIVER_INIT( megadsvp )
5298{
5299   genvdp_use_cram = 1;
5300   genesis_has_z80 = 1;
5301   genesis_always_irq6 = 0;
5302   genesis_other_hacks = 1;
53035382
5304   megadriv_init_common(machine);
5305   svp_init(machine);
5306   hazemdchoice_megadrive_region_export = 1;
5307   hazemdchoice_megadrive_region_pal = 0;
5308   hazemdchoice_megadriv_framerate = 60;
5309}
5310
5311
53125383/* used by megatech */
53135384static READ8_HANDLER( z80_unmapped_port_r )
53145385{
r3485r3486
53615432   memory_install_readwrite8_handler(machine, 1, ADDRESS_SPACE_PROGRAM, 0x8000, 0xffff, 0, 0, z80_read_68k_banked_data, z80_write_68k_banked_data);
53625433}
53635434
5435// these are tests for 'special case' hardware to make sure I don't break anything while rearranging things
5436//
5437
5438/*
5439a1518a / 410a
5440
5441vhp- ---- ---- --fb
5442
5443v = 1=vblank   r/o
5444h = 1=hblank   r/o
5445p = 0=palette access approval   r/o
5446- = unused
5447f = 0=MD framebuffer access, 1 = SH2   r/o
5448b = 0=DRAM0 accessed by VDP, 1=DRAM1   r/w
5449*/
5450static UINT16 _32x_a1518a_reg;
5451static READ16_HANDLER( _32x_68k_fbcontrol_r )
5452{
5453
5454   UINT16 retdata = _32x_a1518a_reg;
5455   UINT16 hpos = get_hposition();
5456   int megadrive_hblank_flag = 0;
5457
5458   if (megadrive_vblank_flag) retdata |= 0x8000;
5459
5460   if (hpos>400) megadrive_hblank_flag = 1;
5461   if (hpos>460) megadrive_hblank_flag = 0;
5462
5463   if (megadrive_hblank_flag) retdata |= 0x4000;
5464
5465   return retdata;
5466}
5467
5468static WRITE16_HANDLER( _32x_68k_fbcontrol_w )
5469{
5470   // bit 0 is the framebuffer select;
5471   _32x_a1518a_reg = (_32x_a1518a_reg & 0xfffe) | (data & 1);
5472
5473   if (_32x_a1518a_reg & 1)
5474   {
5475      _32x_access_dram = _32x_dram0;
5476      _32x_display_dram = _32x_dram1;
5477   }
5478   else
5479   {
5480      _32x_display_dram = _32x_dram0;
5481      _32x_access_dram = _32x_dram1;
5482   }
5483
5484}
5485
5486
5487
5488
5489
5490static READ16_HANDLER( _32x_68k_dram_r )
5491{
5492   return _32x_access_dram[offset];
5493}
5494
5495static WRITE16_HANDLER( _32x_68k_dram_w )
5496{
5497   COMBINE_DATA(&_32x_access_dram[offset]);
5498}
5499
5500static READ16_HANDLER( _32x_68k_palette_r )
5501{
5502   return _32x_palette[offset];
5503}
5504
5505static WRITE16_HANDLER( _32x_68k_palette_w )
5506{
5507   int r,g,b, p;
5508
5509   COMBINE_DATA(&_32x_palette[offset]);
5510   data = _32x_palette[offset];
5511
5512   r = ((data >> 0)  & 0x1f);
5513   g = ((data >> 5)  & 0x1f);
5514   b = ((data >> 10) & 0x1f);
5515   p = ((data >> 15) & 0x01); // priority 'through' bit
5516
5517   _32x_palette_lookup[offset] = (r << 10) | (g << 5) | (b << 0);
5518
5519   palette_set_color_rgb(Machine,offset+0x40,pal5bit(r),pal5bit(g),pal5bit(b));
5520
5521}
5522
5523/*
5524// returns MARS, the system ID of the 32x
5525static READ16_HANDLER( _32x_68k_MARS_r )
5526{
5527    switch (offset)
5528    {
5529        case 0:
5530            return 0x4d41;
5531
5532        case 1:
5533            return 0x5253;
5534    }
5535
5536    return 0x0000;
5537}
5538*/
5539
5540DRIVER_INIT( _32x )
5541{
5542   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x03fffff, 0, 0, SMH_BANK10, SMH_BANK10);
5543   memory_set_bankptr( 10, memory_region(machine, "gamecart") );
5544
5545   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0880000, 0x08fffff, 0, 0, SMH_BANK11, SMH_BANK11); // 'fixed' 512kb rom bank
5546   memory_set_bankptr( 11, memory_region(machine, "gamecart") );
5547
5548   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0900000, 0x09fffff, 0, 0, SMH_BANK12, SMH_BANK12); // 'bankable' 1024kb rom bank
5549   memory_set_bankptr( 12, memory_region(machine, "gamecart") );
5550
5551//  memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x00000ff, 0, 0, SMH_BANK10, SMH_BANK10);
5552//  memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000100, 0x03fffff, 0, 0, SMH_NOP, SMH_NOP );
5553//  memory_set_bankptr( 10, memory_region(machine, "32x_68k_bios") );
5554
5555   _32x_dram0 = auto_malloc(0x20000);
5556   _32x_dram1 = auto_malloc(0x20000);
5557
5558   memset(_32x_dram0, 0x00, 0x20000);
5559   memset(_32x_dram1, 0x00, 0x20000);
5560
5561   _32x_palette = auto_malloc(0x200);
5562   _32x_palette_lookup = auto_malloc(0x200);
5563
5564   memset(_32x_palette, 0x00, 0x200);
5565   memset(_32x_palette_lookup, 0x00, 0x200);
5566
5567
5568   _32x_display_dram = _32x_dram0;
5569   _32x_access_dram = _32x_dram1;
5570
5571   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0840000, 0x085ffff, 0, 0, _32x_68k_dram_r, _32x_68k_dram_w); // access to 'display ram' (framebuffer)
5572
5573   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15200, 0x0a153ff, 0, 0, _32x_68k_palette_r, _32x_68k_palette_w); // access to 'palette' xRRRRRGGGGGBBBBB
5574
5575   _32x_a1518a_reg = 0x00; // inital value
5576   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a1518a, 0x0a1518b, 0, 0, _32x_68k_fbcontrol_r, _32x_68k_fbcontrol_w); // framebuffer control regs
5577
5578//  memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a130ec, 0x0a151ef, 0, 0, _32x_68k_MARS_r); // system ID
5579
5580
5581   DRIVER_INIT_CALL(megadriv);
5582}
5583
5584#if 0
5585
5586ROM_START( 32x_bios )
5587   ROM_REGION16_BE( 0x400000, "main", ROMREGION_ERASE00 )
5588
5589   ROM_REGION16_BE( 0x400000, "gamecart", 0 ) /* 68000 Code */
5590   ROM_LOAD( "32xquin.rom", 0x000000,  0x005d124, CRC(93d4b0a3) SHA1(128bd0b6e048c749da1a2f4c3abd6a867539a293))
5591//  ROM_LOAD( "32x_babe.rom", 0x000000,  0x14f80, CRC(816b0cb4) SHA1(dc16d3170d5809b57192e03864b7136935eada64) )
5592//  ROM_LOAD( "32xhot.rom", 0x000000,  0x01235c, CRC(da9c93c9) SHA1(a62652eb8ad8c62b36f6b1ffb96922d045c4e3ac))
5593//  ROM_LOAD( "knux.rom", 0x000000,  0x300000, CRC(d0b0b842) SHA1(0c2fff7bc79ed26507c08ac47464c3af19f7ced7) )
5594
5595   ROM_REGION16_BE( 0x400000, "32x_68k_bios", 0 ) /* 68000 Code */
5596   ROM_LOAD( "32x_g_bios.bin", 0x000000,  0x000100, CRC(5c12eae8) SHA1(dbebd76a448447cb6e524ac3cb0fd19fc065d944) )
5597
5598   ROM_REGION( 0x400000, "32x_master_sh2", 0 ) /* SH2 Code */
5599   ROM_LOAD( "32x_m_bios.bin", 0x000000,  0x000800, CRC(dd9c46b8) SHA1(1e5b0b2441a4979b6966d942b20cc76c413b8c5e) )
5600
5601   ROM_REGION( 0x400000, "32x_slave_sh2", 0 ) /* SH2 Code */
5602   ROM_LOAD( "32x_s_bios.bin", 0x000000,  0x000400, CRC(bfda1fe5) SHA1(4103668c1bbd66c5e24558e73d4f3f92061a109a) )
5603ROM_END
5604
5605ROM_START( segacd )
5606   ROM_REGION16_BE( 0x400000, "main", ROMREGION_ERASE00 )
5607   ROM_LOAD( "segacd_model2_bios_2_11_u.bin", 0x000000,  0x020000, CRC(2e49d72c) SHA1(328a3228c29fba244b9db2055adc1ec4f7a87e6b) )
5608ROM_END
5609
5610/* some games use the 32x and SegaCD together to give better quality FMV */
5611ROM_START( 32x_scd )
5612   ROM_REGION16_BE( 0x400000, "main", ROMREGION_ERASE00 )
5613
5614   ROM_REGION16_BE( 0x400000, "gamecart", 0 ) /* 68000 Code */
5615   ROM_LOAD( "segacd_model2_bios_2_11_u.bin", 0x000000,  0x020000, CRC(2e49d72c) SHA1(328a3228c29fba244b9db2055adc1ec4f7a87e6b) )
5616
5617   ROM_REGION16_BE( 0x400000, "32x_68k_bios", 0 ) /* 68000 Code */
5618   ROM_LOAD( "32x_g_bios.bin", 0x000000,  0x000100, CRC(5c12eae8) SHA1(dbebd76a448447cb6e524ac3cb0fd19fc065d944) )
5619
5620   ROM_REGION( 0x400000, "32x_master_sh2", 0 ) /* SH2 Code */
5621   ROM_LOAD( "32x_m_bios.bin", 0x000000,  0x000800, CRC(dd9c46b8) SHA1(1e5b0b2441a4979b6966d942b20cc76c413b8c5e) )
5622
5623   ROM_REGION( 0x400000, "32x_slave_sh2", 0 ) /* SH2 Code */
5624   ROM_LOAD( "32x_s_bios.bin", 0x000000,  0x000400, CRC(bfda1fe5) SHA1(4103668c1bbd66c5e24558e73d4f3f92061a109a) )
5625ROM_END
5626
5627ROM_START( g_virr )
5628   ROM_REGION( 0x400000, "main", 0 ) /* 68000 Code */
5629   ROM_LOAD( "g_virr.bin", 0x000000, 0x200000, CRC(7e1a324a) SHA1(ff969ae53120cc4e7cb1a8a7e47458f2eb8a2165) )
5630ROM_END
5631ROM_START( g_virrj )
5632   ROM_REGION( 0x400000, "main", 0 ) /* 68000 Code */
5633   ROM_LOAD( "g_virrj.bin", 0x000000, 0x200000, CRC(53a293b5) SHA1(0ad38a3ab1cc99edac72184f8ae420e13df5cac6) )
5634ROM_END
5635ROM_START( g_virre )
5636   ROM_REGION( 0x400000, "main", 0 ) /* 68000 Code */
5637   ROM_LOAD( "g_virre.bin", 0x000000, 0x200000, CRC(9624d4ef) SHA1(2c3812f8a010571e51269a33a989598787d27c2d) )
5638ROM_END
5639ROM_START( g_virrea )
5640   ROM_REGION( 0x400000, "main", 0 ) /* 68000 Code */
5641   ROM_LOAD( "g_virrea.bin", 0x000000, 0x200000, CRC(5a943df9) SHA1(2c08ea556c79d48e88ff5202944c161ae1b41c63) )
5642ROM_END
5643
5644GAME( 1994, 32x_bios,    0,        genesis_32x,        megadriv,    _32x,    ROT0,   "Sega", "32X Bios", GAME_NOT_WORKING )
5645GAME( 1994, segacd,      0,        genesis_scd,        megadriv,    megadriv,ROT0,   "Sega", "Sega-CD Model 2 BIOS V2.11 (U)", GAME_NOT_WORKING )
5646GAME( 1994, 32x_scd,     0,        genesis_32x_scd,    megadriv,    _32x,    ROT0,   "Sega", "Sega-CD Model 2 BIOS V2.11 (U) (with 32X)", GAME_NOT_WORKING )
5647GAME( 1994, g_virr,      0,        megdsvp,            megadriv,   megadriv, ROT0,   "Sega", "Virtua Racing (U) [!]", 0 )
5648GAME( 1994, g_virrj ,    g_virr,   megdsvp,            megadriv,   megadrij, ROT0,   "Sega", "Virtua Racing (J) [!]", 0 )
5649GAME( 1994, g_virre ,    g_virr,   megdsvppal,         megadriv,   megadrie, ROT0,   "Sega", "Virtua Racing (E) [!]", 0 )
5650GAME( 1994, g_virrea,    g_virr,   megdsvppal,         megadriv,   megadrie, ROT0,   "Sega", "Virtua Racing (E) [a1]", 0 )
5651
5652#endif
src/mame/drivers/magictg.c
r0r3486
1/*
2
3 Skeleton Driver
4
5Magic the Gathereing: Armageddon by Acclaim
6
7TOP Board
8.20u    27c4001 stickered   U20
9                #1537 V1.0  a 1 was hadwritten over the 0
10
11.u7     stamped     (c) 1997
12                ACCLAIM COINOP
13                ARMAGEDDON
14                SND3 P/N 1605
15                9806 D
16
17
18.u8     stamped     (c) 1997 11/25/97
19                ACCLAIM COINOP
20                ARMAGEDDON
21                1534 SND0
22                9752 D
23
24.u13        stamped     (c) 1997 11/25/97
25                ACCLAIM COINOP
26                ARMAGEDDON
27                1536 SND2
28                9752 D
29
30.u14        stamped     (c) 1997 11/25/97
31                ACCLAIM COINOP
32                ARMAGEDDON
33                1535 SND1
34                9752 D
35
36Analog devices  ADSP 2181
37Xilinx      XC5202
38dt71256 x2
39Analog Devices  AD1866R
40
41Bottom board
42.u32    27c801      stickered   4
43.u33    27c801      stickered   3
44.u34    27c801      stickered   2
45.u35    27c801      stickered   1
46.u58    AT17C128    stickered   CC3E
47.u66    GAL16V8D
48
49Xilinx  XC4005E
50Xilinx  XC95108 stickered   ACCLAIM COIN-OP
51                CSC2_10.JED
52                B710/0B84
53                U40 p/N 1611
54
553dFX    500-0003-03     x2
56    BF1684.1
57TI  TVP3409
58    V53C16258HK40       x24
59    V53C511816500K60    x4
602 big chips with heat sinks on them, one by each 3dFX part
612 big chips with heat sinks on them, by the EPROMS
6214.31818 Oscillator by the TI part
6350.0000 Oscillator by EPROMS
6433.0000 Oscillator by the V53C511816500K60
65KM622560LG-7 by Battery
66
67Bottom daughter board
68All read as 29F800B
69.u9     stamped     (c) 1997
70                ACCLAIM COINOP
71                ARMAGEDDON S0
72                1514 11/25/97
73                9803 D
74
75
76.u10        stamped     (c) 1997
77                ACCLAIM COINOP
78                ARMAGEDDON S1
79                1515 11/25/97
80                9803 D
81
82.u11        stamped     (c) 1997
83                ACCLAIM COINOP
84                ARMAGEDDON S3
85                1517 11/25/97
86                9803 D
87
88.u12        stamped     (c) 1997
89                ACCLAIM COINOP
90                ARMAGEDDON S2
91                1516 11/25/97
92                9803 D
93
94.u20        stamped     (c) 1997
95                ACCLAIM COINOP
96                ARMAGEDDON K0
97                1543 11/25/97
98                9752 D
99
100Xilinx  XC4010E
101Zoran   ZR36120PQC
102Zoran   ZR36016PQC
103Xilinx  XC3120A
104    DT72811
105    DT71256 x2
106    DT72271
10729.500000 osciallator by ZR36120PQC
108Medium size chip with heat sink on it
109
110
111*/
112
113#include "driver.h"
114#include "cpu/mips/mips3.h"
115
116
117VIDEO_START(magictg)
118{
119
120}
121
122VIDEO_UPDATE(magictg)
123{
124   return 0;
125}
126
127/* ?? */
128static const mips3_config config =
129{
130   16384,            /* code cache size */
131   16384            /* data cache size */
132};
133
134
135static ADDRESS_MAP_START( magictg_map, ADDRESS_SPACE_PROGRAM, 32 )
136   AM_RANGE(0x00000000, 0x00ffffff) AM_RAM
137   AM_RANGE(0x1fc00000, 0x1fc7ffff) AM_WRITENOP AM_ROM AM_REGION("user1", 0)
138ADDRESS_MAP_END
139
140
141
142static MACHINE_DRIVER_START( magictg )
143   /* basic machine hardware */
144   MDRV_CPU_ADD("main", R4600BE, 10000000)  // ?? what cpu?
145   MDRV_CPU_CONFIG(config)
146   MDRV_CPU_PROGRAM_MAP(magictg_map, 0)
147
148   MDRV_SCREEN_ADD("main", RASTER)
149   MDRV_SCREEN_REFRESH_RATE(60)
150   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
151   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
152   MDRV_SCREEN_SIZE(1024, 1024)
153   MDRV_SCREEN_VISIBLE_AREA(0, 511, 16, 447)
154
155   MDRV_PALETTE_LENGTH(0x1000)
156
157   MDRV_VIDEO_START(magictg)
158   MDRV_VIDEO_UPDATE(magictg)
159MACHINE_DRIVER_END
160
161static INPUT_PORTS_START( magictg )
162   PORT_START("IPT_TEST")
163INPUT_PORTS_END
164
165/* the SMT rom are almost certainly dumped too small */
166
167ROM_START( magictg )
168   ROM_REGION32_BE( 0x400000, "user1", 0 ) /* MIPs code? */
169   ROM_LOAD16_BYTE( "magic.u34", 0x000000, 0x100000, CRC(2e8971e2) SHA1(9bdf433a7c7257389ebdf131317ef26a7d4e1ba2) )
170   ROM_LOAD16_BYTE( "magic.u35", 0x000001, 0x100000, CRC(e2202143) SHA1(f07b7da81508cd4594f66e34dabd904a21eb03f0) )
171   ROM_LOAD16_BYTE( "magic.u32", 0x200000, 0x100000, CRC(f1d530e3) SHA1(fcc392804cd6b98917a869cc5d3826278b7ba90b) )
172   ROM_LOAD16_BYTE( "magic.u33", 0x200001, 0x100000, CRC(b2330cfc) SHA1(559c35426588b349ef31bf8b296b950912f6fcc7) )
173
174   ROM_REGION32_BE( 0x80000, "user2", 0 ) /* ADSP 2181 code? */
175   ROM_LOAD( "magic.20u", 0x00000, 0x80000, CRC(50968301) SHA1(e9bdd0c942f0c66e18aa8de5a04edb51cdf1fee8) )
176
177   ROM_REGION32_BE( 0x400000, "user3", 0 ) /* ADSP samples */
178   ROM_LOAD( "magic.snd0.u8", 0x000000, 0x100000, BAD_DUMP CRC(ef3384ed) SHA1(0b2fa03e3da691590c705ff9d4e26ffbe374cd0f) )
179   ROM_LOAD( "magic.snd1.u14",0x100000, 0x100000, BAD_DUMP CRC(d591dc93) SHA1(6a7627659de8b9e4cde7c314504f0ee087ecab4d) )
180   ROM_LOAD( "magic.snd2.u13",0x200000, 0x100000, BAD_DUMP CRC(d81cb2e1) SHA1(f62f85ce094cfe48373d0929bfdb76522315da81) )
181   ROM_LOAD( "magic.snd3.u7", 0x300000, 0x100000, BAD_DUMP CRC(6c8e0475) SHA1(9cafbc85d20390e9cd5d55e3c48a049e40a833ca) ) // basically empty
182
183   ROM_REGION( 0x400000, "user4", 0 ) /* ? */
184   ROM_LOAD( "magic.s0.u9",  0x000000, 0x100000, BAD_DUMP CRC(b1d9e54e) SHA1(c4964fcab4aa3d37cbfaeac0c35be31597fdd0aa) )
185   ROM_LOAD( "magic.s1.u10", 0x100000, 0x100000, BAD_DUMP CRC(ccce2af7) SHA1(23d6e1bcf1ae9787f20b9bb14c2553b9a6d6b12c) )
186   ROM_LOAD( "magic.s2.u12", 0x200000, 0x100000, BAD_DUMP CRC(eb8d1607) SHA1(353410b20d121b0bbecef4735a692f0c1d09ce9b) )
187   ROM_LOAD( "magic.s3.u11", 0x300000, 0x100000, BAD_DUMP CRC(58c33f8e) SHA1(af09105b17b95882f7ff90ec64081e8b1d429e0b) )
188
189   ROM_REGION( 0x100000, "user5", 0 ) /* ? */
190   ROM_LOAD( "magic.k0.u20", 0x000000, 0x100000, BAD_DUMP CRC(aeb617fa) SHA1(4853c1c3631b798312d9146a90158490f2252119) )
191ROM_END
192
193ROM_START( magictga )
194   ROM_REGION32_BE( 0x400000, "user1", 0 ) /* MIPs code? */
195   ROM_LOAD16_BYTE( "magic.u63", 0x000000, 0x100000, CRC(a10d45f1) SHA1(0ede10f19cf70baf7b43e3f672532b4be1a179f8) )
196   ROM_LOAD16_BYTE( "magic.u64", 0x000001, 0x100000, CRC(8fdb6060) SHA1(b638244cad86dc60435a4a9150a5b639f5d61a3f) )
197   ROM_LOAD16_BYTE( "magic.u61", 0x200000, 0x100000, CRC(968891d6) SHA1(67ab87039864bb148d20795333ffa7a23e3b84f2) )
198   ROM_LOAD16_BYTE( "magic.u62", 0x200001, 0x100000, CRC(690946eb) SHA1(6c9b02367704309f4fde5cbd9d195a45c32c3861) )
199
200   // this set was incomplete, none of these roms were dumped for it, are they the same?
201   #if 0
202   ROM_REGION32_BE( 0x80000, "user2", 0 ) /* ADSP 2181 code? */
203   ROM_LOAD( "magic.20u", 0x00000, 0x80000, CRC(50968301) SHA1(e9bdd0c942f0c66e18aa8de5a04edb51cdf1fee8) )
204
205   ROM_REGION32_BE( 0x400000, "user3", 0 ) /* ADSP samples */
206   ROM_LOAD( "magic.snd0.u8", 0x000000, 0x100000, BAD_DUMP CRC(ef3384ed) SHA1(0b2fa03e3da691590c705ff9d4e26ffbe374cd0f) )
207   ROM_LOAD( "magic.snd1.u14",0x100000, 0x100000, BAD_DUMP CRC(d591dc93) SHA1(6a7627659de8b9e4cde7c314504f0ee087ecab4d) )
208   ROM_LOAD( "magic.snd2.u13",0x200000, 0x100000, BAD_DUMP CRC(d81cb2e1) SHA1(f62f85ce094cfe48373d0929bfdb76522315da81) )
209   ROM_LOAD( "magic.snd3.u7", 0x300000, 0x100000, BAD_DUMP CRC(6c8e0475) SHA1(9cafbc85d20390e9cd5d55e3c48a049e40a833ca) ) // basically empty
210
211   ROM_REGION( 0x400000, "user4", 0 ) /* ? */
212   ROM_LOAD( "magic.s0.u9",  0x000000, 0x100000, BAD_DUMP CRC(b1d9e54e) SHA1(c4964fcab4aa3d37cbfaeac0c35be31597fdd0aa) )
213   ROM_LOAD( "magic.s1.u10", 0x100000, 0x100000, BAD_DUMP CRC(ccce2af7) SHA1(23d6e1bcf1ae9787f20b9bb14c2553b9a6d6b12c) )
214   ROM_LOAD( "magic.s2.u12", 0x200000, 0x100000, BAD_DUMP CRC(eb8d1607) SHA1(353410b20d121b0bbecef4735a692f0c1d09ce9b) )
215   ROM_LOAD( "magic.s3.u11", 0x300000, 0x100000, BAD_DUMP CRC(58c33f8e) SHA1(af09105b17b95882f7ff90ec64081e8b1d429e0b) )
216
217   ROM_REGION( 0x100000, "user5", 0 ) /* ? */
218   ROM_LOAD( "magic.k0.u20", 0x000000, 0x100000, BAD_DUMP CRC(aeb617fa) SHA1(4853c1c3631b798312d9146a90158490f2252119) )
219   #endif
220ROM_END
221
222GAME( 199?, magictg,  0,        magictg, magictg, 0, ROT0, "Acclaim", "Magic the Gathering: Armageddon (set 1)", GAME_NOT_WORKING|GAME_NO_SOUND )
223GAME( 199?, magictga, magictg,  magictg, magictg, 0, ROT0, "Acclaim", "Magic the Gathering: Armageddon (set 2)", GAME_NOT_WORKING|GAME_NO_SOUND )
224
src/mame/drivers/videopkr.c
r3485r3486
899899   AM_RANGE(0x0000, 0x0fff) AM_ROM
900900ADDRESS_MAP_END
901901
902static ADDRESS_MAP_START( i8051_sound_dat, ADDRESS_SPACE_DATA, 8 )
902static ADDRESS_MAP_START( i8051_sound_port, ADDRESS_SPACE_IO, 8 )
903903   AM_RANGE(0x0000, 0x1ff) AM_RAM
904   /* ports */
905   AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P0) AM_READWRITE(baby_sound_p0_r, baby_sound_p0_w)
906   AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READWRITE(baby_sound_p1_r, baby_sound_p1_w)
907   AM_RANGE(MCS51_PORT_P2, MCS51_PORT_P2) AM_READWRITE(baby_sound_p2_r, baby_sound_p2_w)
908   AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_READWRITE(baby_sound_p3_r, baby_sound_p3_w)
904909ADDRESS_MAP_END
905910
906static ADDRESS_MAP_START( i8051_sound_port, ADDRESS_SPACE_IO, 8 )
907   AM_RANGE(0x00, 0x00) AM_READWRITE(baby_sound_p0_r, baby_sound_p0_w)
908   AM_RANGE(0x01, 0x01) AM_READWRITE(baby_sound_p1_r, baby_sound_p1_w)
909   AM_RANGE(0x02, 0x02) AM_READWRITE(baby_sound_p2_r, baby_sound_p2_w)
910   AM_RANGE(0x03, 0x03) AM_READWRITE(baby_sound_p3_r, baby_sound_p3_w)
911ADDRESS_MAP_END
912911
913
914912/************************
915913*      Input Ports      *
916914************************/
r3485r3486
12261224   /* basic machine hardware */
12271225   MDRV_IMPORT_FROM(videopkr)
12281226   MDRV_CPU_REPLACE("main", I8039, CPU_CLOCK_ALT)
1229   MDRV_CPU_REPLACE("sound", I8051, CPU_CLOCK )
1227   /* most likely romless or eprom */
1228   MDRV_CPU_REPLACE("sound", I8031, CPU_CLOCK )
12301229   MDRV_CPU_PROGRAM_MAP(i8051_sound_mem, 0)
1231   MDRV_CPU_DATA_MAP(i8051_sound_dat, 0)
12321230   MDRV_CPU_IO_MAP(i8051_sound_port, 0)
12331231
12341232   /* video hardware */
src/mame/drivers/cloak.c
r3485r3486
166166   AM_RANGE(0x0400, 0x07ff) AM_RAM_WRITE(cloak_videoram_w) AM_BASE(&videoram)
167167   AM_RANGE(0x0800, 0x0fff) AM_RAM AM_SHARE(1)
168168   AM_RANGE(0x1000, 0x100f) AM_READWRITE(pokey1_r, pokey1_w)      /* DSW0 also */
169//  AM_RANGE(0x1008, 0x1008) AM_READ(SMH_RAM)
170169   AM_RANGE(0x1800, 0x180f) AM_READWRITE(pokey2_r, pokey2_w)      /* DSW1 also */
171170   AM_RANGE(0x2000, 0x2000) AM_READ_PORT("P1")
172171   AM_RANGE(0x2200, 0x2200) AM_READ_PORT("P2")
173172   AM_RANGE(0x2400, 0x2400) AM_READ_PORT("SYSTEM")
174173   AM_RANGE(0x2600, 0x2600) AM_WRITE(cloak_custom_w)
175174   AM_RANGE(0x2800, 0x29ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
175   AM_RANGE(0x2f00, 0x2fff) AM_NOP
176176   AM_RANGE(0x3000, 0x30ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
177177   AM_RANGE(0x3200, 0x327f) AM_WRITE(cloak_paletteram_w)
178178   AM_RANGE(0x3800, 0x3801) AM_WRITE(cloak_coin_counter_w)
r3485r3486
398398   ROM_REGION( 0x2000, "gfx2", ROMREGION_DISPOSE )
399399   ROM_LOAD( "136023-107.bin",      0x0000, 0x1000, CRC(c42c84a4) SHA1(6f241e772f8b46c8d3acad2e967f1ab530886b11) )
400400   ROM_LOAD( "136023-108.bin",      0x1000, 0x1000, CRC(4fe13d58) SHA1(b21a32b2ff5363ab35fd1438344a04deb4077dbc) )
401
402   ROM_REGION( 0x100, "proms", 0 )
403   ROM_LOAD( "136023-116.3n",  0x000, 0x100, CRC(ef2668e5) SHA1(442df346a40b1e20d599ed9877c699e00ab518ba) ) /* 82S129 Vertical timing PROM */
401404ROM_END
402405
403406
r3485r3486
424427   ROM_REGION( 0x2000, "gfx2", ROMREGION_DISPOSE )
425428   ROM_LOAD( "136023-107.bin",      0x0000, 0x1000, CRC(c42c84a4) SHA1(6f241e772f8b46c8d3acad2e967f1ab530886b11) )
426429   ROM_LOAD( "136023-108.bin",      0x1000, 0x1000, CRC(4fe13d58) SHA1(b21a32b2ff5363ab35fd1438344a04deb4077dbc) )
430
431   ROM_REGION( 0x100, "proms", 0 )
432   ROM_LOAD( "136023-116.3n",  0x000, 0x100, CRC(ef2668e5) SHA1(442df346a40b1e20d599ed9877c699e00ab518ba) ) /* 82S129 Vertical timing PROM */
427433ROM_END
428434
429435
r3485r3486
450456   ROM_REGION( 0x2000, "gfx2", ROMREGION_DISPOSE )
451457   ROM_LOAD( "136023-107.bin",      0x0000, 0x1000, CRC(c42c84a4) SHA1(6f241e772f8b46c8d3acad2e967f1ab530886b11) )
452458   ROM_LOAD( "136023-108.bin",      0x1000, 0x1000, CRC(4fe13d58) SHA1(b21a32b2ff5363ab35fd1438344a04deb4077dbc) )
459
460   ROM_REGION( 0x100, "proms", 0 )
461   ROM_LOAD( "136023-116.3n",  0x000, 0x100, CRC(ef2668e5) SHA1(442df346a40b1e20d599ed9877c699e00ab518ba) ) /* 82S129 Vertical timing PROM */
453462ROM_END
454463
455464
r3485r3486
476485   ROM_REGION( 0x2000, "gfx2", ROMREGION_DISPOSE )
477486   ROM_LOAD( "136023-107.bin",      0x0000, 0x1000, CRC(c42c84a4) SHA1(6f241e772f8b46c8d3acad2e967f1ab530886b11) )
478487   ROM_LOAD( "136023-108.bin",      0x1000, 0x1000, CRC(4fe13d58) SHA1(b21a32b2ff5363ab35fd1438344a04deb4077dbc) )
488
489   ROM_REGION( 0x100, "proms", 0 )
490   ROM_LOAD( "136023-116.3n",  0x000, 0x100, CRC(ef2668e5) SHA1(442df346a40b1e20d599ed9877c699e00ab518ba) ) /* 82S129 Vertical timing PROM */
479491ROM_END
480492
481493
r3485r3486
502514   ROM_REGION( 0x2000, "gfx2", ROMREGION_DISPOSE )
503515   ROM_LOAD( "136107-023.bin",      0x0000, 0x1000, CRC(c42c84a4) SHA1(6f241e772f8b46c8d3acad2e967f1ab530886b11) )
504516   ROM_LOAD( "136108-023.bin",      0x1000, 0x1000, CRC(4fe13d58) SHA1(b21a32b2ff5363ab35fd1438344a04deb4077dbc) )
517
518   ROM_REGION( 0x100, "proms", 0 )
519   ROM_LOAD( "136023-116.3n",  0x000, 0x100, CRC(ef2668e5) SHA1(442df346a40b1e20d599ed9877c699e00ab518ba) ) /* 82S129 Vertical timing PROM */
505520ROM_END
506521
507522
r3485r3486
528543   ROM_REGION( 0x2000, "gfx2", ROMREGION_DISPOSE )
529544   ROM_LOAD( "136107-023.bin",      0x0000, 0x1000, CRC(c42c84a4) SHA1(6f241e772f8b46c8d3acad2e967f1ab530886b11) )
530545   ROM_LOAD( "136108-023.bin",      0x1000, 0x1000, CRC(4fe13d58) SHA1(b21a32b2ff5363ab35fd1438344a04deb4077dbc) )
546
547   ROM_REGION( 0x100, "proms", 0 )
548   ROM_LOAD( "136023-116.3n",  0x000, 0x100, CRC(ef2668e5) SHA1(442df346a40b1e20d599ed9877c699e00ab518ba) ) /* 82S129 Vertical timing PROM */
531549ROM_END
532550
533551
r3485r3486
554572   ROM_REGION( 0x2000, "gfx2", ROMREGION_DISPOSE )
555573   ROM_LOAD( "136107-023.bin",      0x0000, 0x1000, CRC(c42c84a4) SHA1(6f241e772f8b46c8d3acad2e967f1ab530886b11) )
556574   ROM_LOAD( "136108-023.bin",      0x1000, 0x1000, CRC(4fe13d58) SHA1(b21a32b2ff5363ab35fd1438344a04deb4077dbc) )
575
576   ROM_REGION( 0x100, "proms", 0 )
577   ROM_LOAD( "136023-116.3n",  0x000, 0x100, CRC(ef2668e5) SHA1(442df346a40b1e20d599ed9877c699e00ab518ba) ) /* 82S129 Vertical timing PROM */
557578ROM_END
558579
559580
r3485r3486
580601   ROM_REGION( 0x2000, "gfx2", ROMREGION_DISPOSE )
581602   ROM_LOAD( "136107-023.bin",      0x0000, 0x1000, CRC(c42c84a4) SHA1(6f241e772f8b46c8d3acad2e967f1ab530886b11) )
582603   ROM_LOAD( "136108-023.bin",      0x1000, 0x1000, CRC(4fe13d58) SHA1(b21a32b2ff5363ab35fd1438344a04deb4077dbc) )
604
605   ROM_REGION( 0x100, "proms", 0 )
606   ROM_LOAD( "136023-116.3n",  0x000, 0x100, CRC(ef2668e5) SHA1(442df346a40b1e20d599ed9877c699e00ab518ba) ) /* 82S129 Vertical timing PROM */
583607ROM_END
584608
585609
src/mame/drivers/kaneko16.c
r3485r3486
34963496   ROM_LOAD( "rb-013.u68",  0x300000, 0x100000, CRC(28c37fe8) SHA1(e10dd1a810983077328b44e6e33ce2e899c506d2) )
34973497
34983498   ROM_REGION( 0x100000, "oki1", 0 )   /* Samples */
3499   /* order is probably wrong, but until it does more we can't tell */
3500   ROM_LOAD( "rb-003.101",  0x000000, 0x080000, CRC(2cac25d7) SHA1(0412c317bf650a93051b9304d23035efde0c026a) )
3501   ROM_LOAD( "rb-000.u43",  0x080000, 0x040000, CRC(c7c848ac) SHA1(77754efd6efeac50a40dcd530de504090257d8b3) )
3499   /* Upper 128kB of M6295 address region is bank-switched? */
3500   ROM_LOAD( "rb-000.u43",  0x000000, 0x080000, CRC(58ad1a62) SHA1(1d2643b5f6eac22682972a88d284e00de3e3b223) )
3501   ROM_LOAD( "rb-003.101",  0x080000, 0x080000, CRC(2cac25d7) SHA1(0412c317bf650a93051b9304d23035efde0c026a) )
35023502
3503   ROM_REGION( 0x100000, "oki2", 0 )   /* Samples */
3504   /* order is probably wrong, but until it does more we can't tell */
3505   ROM_LOAD( "rb-001.u44",   0x000000, 0x080000, CRC(09c779e3) SHA1(c9c9bf939d58d329b87e0aa08ec3d35f7440d3c7) )
3506   ROM_LOAD( "rb-002.u45",   0x080000, 0x080000, CRC(55de7003) SHA1(cc349fd8671926cafed4d86d1a5cb671e591c408) )
3503   ROM_REGION( 0x200000, "oki2", 0 )   /* Samples */
3504   /* Upper 128kB of M6295 address region is bank-switched? */
3505   ROM_LOAD( "rb-001.u44",   0x000000, 0x100000, CRC(7cf774b3) SHA1(3fb0a5096ce9480f97e311439042eb8cbc26efb4) )
3506   ROM_LOAD( "rb-002.u45",   0x100000, 0x100000, CRC(e4b30444) SHA1(be6756dce3721226e0b7f5d4d168008c31aeea8e) )
35073507ROM_END
35083508
35093509ROM_START( brapboyj ) /* The Japanese version has an extra rom??? and used a rom sub board */
r3485r3486
35323532   ROM_LOAD( "rb-013.u68",  0x300000, 0x100000, CRC(28c37fe8) SHA1(e10dd1a810983077328b44e6e33ce2e899c506d2) )
35333533
35343534   ROM_REGION( 0x100000, "oki1", 0 )   /* Samples */
3535   /* order is probably wrong, but until it does more we can't tell */
3536   ROM_LOAD( "rb-003.101",  0x000000, 0x080000, CRC(2cac25d7) SHA1(0412c317bf650a93051b9304d23035efde0c026a) )
3537   ROM_LOAD( "rb-000.u43",  0x080000, 0x040000, CRC(c7c848ac) SHA1(77754efd6efeac50a40dcd530de504090257d8b3) )
3535   /* Upper 128kB of M6295 address region is bank-switched? */
3536   ROM_LOAD( "rb-000.u43",  0x000000, 0x080000, CRC(58ad1a62) SHA1(1d2643b5f6eac22682972a88d284e00de3e3b223) )
3537   ROM_LOAD( "rb-003.101",  0x080000, 0x080000, CRC(2cac25d7) SHA1(0412c317bf650a93051b9304d23035efde0c026a) )
35383538
3539   ROM_REGION( 0x100000, "oki2", 0 )   /* Samples */
3540   /* order is probably wrong, but until it does more we can't tell */
3541   ROM_LOAD( "rb-001.u44",   0x000000, 0x080000, CRC(09c779e3) SHA1(c9c9bf939d58d329b87e0aa08ec3d35f7440d3c7) )
3542   ROM_LOAD( "rb-002.u45",   0x080000, 0x080000, CRC(55de7003) SHA1(cc349fd8671926cafed4d86d1a5cb671e591c408) )
3539   ROM_REGION( 0x200000, "oki2", 0 )   /* Samples */
3540   /* Upper 128kB of M6295 address region is bank-switched? */
3541   ROM_LOAD( "rb-001.u44",   0x000000, 0x100000, CRC(7cf774b3) SHA1(3fb0a5096ce9480f97e311439042eb8cbc26efb4) )
3542   ROM_LOAD( "rb-002.u45",   0x100000, 0x100000, CRC(e4b30444) SHA1(be6756dce3721226e0b7f5d4d168008c31aeea8e) )
35433543ROM_END
35443544
35453545/**********************************************************************
src/mame/drivers/limenko.c
r3485r3486
2626#include "driver.h"
2727#include "machine/eeprom.h"
2828#include "sound/okim6295.h"
29#include "cpu/i8051/i8051.h"
2930
3031static tilemap *bg_tilemap, *md_tilemap, *fg_tilemap;
3132static UINT32 *bg_videoram, *md_videoram, *fg_videoram, *limenko_videoreg;
r3485r3486
188189   AM_RANGE(0x5000, 0x5003) AM_WRITE(spotty_soundlatch_w)
189190ADDRESS_MAP_END
190191
191static ADDRESS_MAP_START( spotty_sound_prg_map, ADDRESS_SPACE_PROGRAM, 8 )
192   AM_RANGE(0x0000, 0x0fff) AM_ROM
193ADDRESS_MAP_END
194
195192static UINT8 spotty_sound_cmd=0;
196193static WRITE8_HANDLER( spotty_sound_cmd_w )
197194{
r3485r3486
214211}
215212
216213static ADDRESS_MAP_START( spotty_sound_io_map, ADDRESS_SPACE_IO, 8 )
217   AM_RANGE(0x0001, 0x0001) AM_READWRITE(spotty_sound_r, okim6295_data_0_w) //? sound latch and ?
218   AM_RANGE(0x0003, 0x0003) AM_READWRITE(spotty_sound_cmd_r, spotty_sound_cmd_w) //not sure about anything...
214   AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READWRITE(spotty_sound_r, okim6295_data_0_w) //? sound latch and ?
215   AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_READWRITE(spotty_sound_cmd_r, spotty_sound_cmd_w) //not sure about anything...
219216ADDRESS_MAP_END
220217
221218/*****************************************************************************************************
r3485r3486
673670   MDRV_CPU_IO_MAP(spotty_io_map,0)
674671   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
675672
676   MDRV_CPU_ADD("audio", I8051, 4000000)   /* 4 MHz */
677   MDRV_CPU_PROGRAM_MAP(spotty_sound_prg_map, 0)
678   MDRV_CPU_DATA_MAP(0, 0)
673   MDRV_CPU_ADD("audio", AT89C4051, 4000000)   /* 4 MHz */
679674   MDRV_CPU_IO_MAP(spotty_sound_io_map,0)
680675
681676   MDRV_NVRAM_HANDLER(93C46)
src/mame/drivers/lethalj.c
r3485r3486
700700ROM_END
701701
702702
703ROM_START( eggvent8 )
704   ROM_REGION16_LE( 0x100000, "user1", 0 )      /* 34010 code */
705   ROM_LOAD16_BYTE( "eggvc8.8", 0x000000, 0x020000, CRC(5a130c04) SHA1(00408912b436efa003bb02dce90fae4fe33a0180) )
706   ROM_LOAD16_BYTE( "eggvc9.8", 0x000001, 0x020000, CRC(3ac0a95b) SHA1(7f3bd0e6d2d790af4aa6881ea8de8b296a64164a) )
707   ROM_COPY( "user1", 0x000000, 0x040000, 0x040000 )
708   ROM_COPY( "user1", 0x000000, 0x080000, 0x080000 )
709
710   ROM_REGION16_LE( 0x600000, "gfx1", 0 )         /* graphics data */
711   ROM_LOAD16_BYTE( "egr1.bin",  0x000000, 0x100000, CRC(f73f80d9) SHA1(6278b45579a256b9576ba6d4f5a15fab26797c3d) )
712   ROM_LOAD16_BYTE( "egr2.bin",  0x000001, 0x100000, CRC(3a9ba910) SHA1(465aa3119af103aa65b25042b3572fdcb9c1887a) )
713   ROM_LOAD16_BYTE( "egr4.bin",  0x200000, 0x100000, CRC(4ea5900e) SHA1(20341337ee3c6c22580c52312156b818f4187693) )
714   ROM_LOAD16_BYTE( "egr3.bin",  0x200001, 0x100000, CRC(3f8dfc73) SHA1(83a168069f896ea7e67a97c6d591d09b19d5f486) )
715   ROM_LOAD16_BYTE( "egr6.3",    0x400000, 0x100000, CRC(f299d818) SHA1(abbb333c43675d34c59201b5d297779cfea8b092) )
716   ROM_LOAD16_BYTE( "egr5.3",    0x400001, 0x100000, CRC(ebfca07b) SHA1(20465d14b41d99651166f221057737d7b3cc770c) )
717
718   ROM_REGION( 0x40000, "oki1", 0 )            /* sound data */
719   ROM_LOAD( "eu20.bin", 0x00000, 0x40000, CRC(3760b1db) SHA1(70e258a6036f9ce26b354c4df57e0e4d2c871bcb) )
720
721   ROM_REGION( 0x40000, "oki2", 0 )            /* sound data */
722   ROM_LOAD( "eu21.bin", 0x00000, 0x40000, CRC(3760b1db) SHA1(70e258a6036f9ce26b354c4df57e0e4d2c871bcb) )
723
724   ROM_REGION( 0x40000, "oki3", 0 )            /* sound data */
725   ROM_LOAD( "eu18.bin", 0x00000, 0x40000, CRC(3760b1db) SHA1(70e258a6036f9ce26b354c4df57e0e4d2c871bcb) )
726ROM_END
727
728
703729ROM_START( eggvent7 )
704730   ROM_REGION16_LE( 0x100000, "user1", 0 )      /* 34010 code */
705731   ROM_LOAD16_BYTE( "eggvc8.7", 0x000000, 0x020000, CRC(99999899) SHA1(e3908600fa711baa7f7562f86498ec7e988a5bea) )
r3485r3486
907933
908934GAME( 1996, lethalj,  0,        lethalj,  lethalj,  0,        ROT0,  "The Game Room", "Lethal Justice", 0 )
909935GAME( 1997, eggventr, 0,        gameroom, eggventr, 0,        ROT0,  "The Game Room", "Egg Venture (Release 10)", 0 )
936GAME( 1997, eggvent8, eggventr, gameroom, eggventr, 0,        ROT0,  "The Game Room", "Egg Venture (Release 8)", 0 )
910937GAME( 1997, eggvent7, eggventr, gameroom, eggventr, 0,        ROT0,  "The Game Room", "Egg Venture (Release 7)", 0 )
911938GAME( 1997, eggventa, eggventr, gameroom, eggventr, 0,        ROT0,  "The Game Room (Allied Leisure license)", "Egg Venture (A.L. Release)", 0 )
912939GAME( 1997, eggvntdx, eggventr, gameroom, eggvntdx, 0,        ROT0,  "The Game Room", "Egg Venture Deluxe", 0 )
src/mame/drivers/itech8.c
r3485r3486
99        * Strata Bowling [2 sets]
1010        * Super Strike Bowling
1111        * Wheel of Fortune [2 sets]
12        * Grudge Match
1213        * Golden Tee Golf [2 sets]
1314        * Golden Tee Golf II [3 sets]
1415        * Slick Shot [3 sets]
r3485r3486
143144
144145    Summary:
145146
146        There are 7 known variants of PCBs for these games. All the PCBs
147        There are 8 known variants of PCBs for these games. All the PCBs
147148        have the following features in common:
148149
149150            68B09 @ 2 MHz for the main CPU
r3485r3486
151152
152153            68B09 @ 2 MHz for the sound CPU
153154            2k RAM for the sound CPU
154            YM2203C or YM3812 for music
155            OKI M6295 for speech
155            YM2203C, YM2608B or YM3812 for music
156            OKI M6295 for speech (except for YM2608B-based system)
156157
157158            TMS34061 for the video controller
158159            ITV4400 custom blitter for rendering
159            6-bit RAMDAC for palette
160            6-bit RAMDAC for palette, or 2xTMS34070NL (Grudge Match only)
160161            From 2-8 64k x 4-bit VRAM chips for frame buffers
161162
162163        An overview of each style PCB is given below:
163164
164        Wheel of Fortune-style
165        Wheel Watcher (Wheel of Fortune)-style
165166            * Single board
166167            * YM2203C for music
167168            * 2 VRAM chips for a single 8-bit 256x256 video page
168169
170        Grudge Match-style
171            * Single board
172            * YM2608B for music
173            * 4 VRAM chips for two 4-bit 512x256 layers
174
169175        Strata Bowling-style
170176            * Single board
171177            * YM2203C for music
r3485r3486
202208
203209****************************************************************************
204210
205    ----------------
206    Wheel of Fortune
207    ----------------
211    --------------------------------
212    Wheel Watcher (Wheel of Fortune)
213    --------------------------------
208214
209215        +------------------------------------+-+
210216        |    Bt476KP35                       | |
r3485r3486
240246        ITV4400 = IT custom blitter
241247
242248
249    -------------
250    Grudge Match
251    ------------
252
253        +------------------------------------+-+
254        | TMS34070NL                         | |
255        | TMS34070NL  DIPSW4                 | |
256        | TMS4461-15   8MHz                  | |
257        | TMS4461-15                         | |
258        | TMS4461-15                         | |
259        | TMS4461-15                         | |
260        |                                    | |
261        |       TMS34061                     +-
262        |                                      |
263        |          ITV4400                     |
264        |  GROM6                     SROM0     |
265        |  GROM5                               |
266        |  GROM4                               |
267        |  GROM3    MK40702B-20      YM2608B   |
268        |  GROM2    U5-PGM    MK6116           |
269        |  GROM1              U27-SND          |
270        |  GROM0                               |
271        |        MC68B09         MC68B09       |
272        +--------------------------------------+
273
274        GROM0-6 = AM27C010-25
275        U5-PGM = D27512-25
276        U27-SND = 27C256-20
277        SROM0 = AM27C010-25
278        ITVS = ???
279        MT42C4064Z = 64k x 4 VRAM (2 populated on Wheel of Fortune)
280        MK40702B = zero-power RAM
281        MK6116 = 2k x 8 RAM
282        TMS34070NL = 16-color RAMDAC
283        TMS34061 = video controller
284        ITV4400 = IT custom blitter
285
286
243287    ------------------------------
244288    Strata Bowling/Golden Tee Golf
245289    ------------------------------
r3485r3486
459503#include "video/tlc34076.h"
460504#include "itech8.h"
461505#include "sound/2203intf.h"
506#include "sound/2608intf.h"
462507#include "sound/3812intf.h"
463508#include "sound/okim6295.h"
464509
r3485r3486
944989ADDRESS_MAP_END
945990
946991
992/*------ YM2608B-based sound ------*/
993static ADDRESS_MAP_START( sound2608b_map, ADDRESS_SPACE_PROGRAM, 8 )
994   AM_RANGE(0x1000, 0x1000) AM_WRITENOP
995   AM_RANGE(0x2000, 0x2000) AM_READ(sound_data_r)
996   AM_RANGE(0x4000, 0x4000) AM_READWRITE(ym2608_status_port_0_a_r, ym2608_control_port_0_a_w)
997   AM_RANGE(0x4001, 0x4001) AM_WRITE(ym2608_data_port_0_a_w)
998   AM_RANGE(0x4002, 0x4002) AM_READWRITE(ym2608_status_port_0_b_r, ym2608_control_port_0_b_w)
999   AM_RANGE(0x4003, 0x4003) AM_WRITE(ym2608_data_port_0_b_w)
1000   AM_RANGE(0x6000, 0x67ff) AM_RAM
1001   AM_RANGE(0x8000, 0xffff) AM_ROM
1002ADDRESS_MAP_END
1003
1004
9471005/*------ YM3812-based sound ------*/
9481006static ADDRESS_MAP_START( sound3812_map, ADDRESS_SPACE_PROGRAM, 8 )
9491007   AM_RANGE(0x0000, 0x0000) AM_WRITENOP
r3485r3486
10241082INPUT_PORTS_END
10251083
10261084
1085static INPUT_PORTS_START( grmatch )
1086   PORT_START("40")
1087   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(special_r, NULL)   /* input from sound board */
1088   PORT_BIT( 0x06, IP_ACTIVE_LOW, IPT_UNUSED )
1089   PORT_DIPNAME( 0x08, 0x08, "Adjustments Lockout" )
1090   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1091   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1092   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Coinage ) )
1093   PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
1094   PORT_DIPSETTING(    0x10, DEF_STR( 1C_1C ) )
1095   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Difficulty ) )
1096   PORT_DIPSETTING(    0x20, "1" )
1097   PORT_DIPSETTING(    0x00, "3" )
1098   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
1099   PORT_SERVICE_NO_TOGGLE( 0x80, IP_ACTIVE_LOW )
1100
1101   PORT_START("60")
1102   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
1103   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
1104   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
1105   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
1106   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
1107   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
1108   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
1109   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
1110
1111   PORT_START("80")
1112   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
1113   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
1114   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
1115   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
1116   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
1117   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
1118   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 )
1119   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
1120INPUT_PORTS_END
1121
1122
10271123static INPUT_PORTS_START( stratab )
10281124   PORT_START("40")
10291125   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(special_r, NULL)   /* input from sound board */
r3485r3486
16151711};
16161712
16171713
1714static const ym2608_interface ym2608b_config =
1715{
1716   {
1717      AY8910_LEGACY_OUTPUT,
1718      AY8910_DEFAULT_LOADS,
1719      NULL,
1720      NULL,
1721      NULL,
1722      ym2203_portb_out,
1723   },
1724   generate_sound_irq
1725};
1726
1727
16181728static const ym3812_interface ym3812_config =
16191729{
16201730   generate_sound_irq
r3485r3486
16521762
16531763   /* sound hardware */
16541764   MDRV_SPEAKER_STANDARD_MONO("mono")
1655
1656   MDRV_SOUND_ADD("oki", OKIM6295, CLOCK_8MHz/8) // was /128??
1657   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128, not /132, so unsure so pin 7 not verified
1658   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
16591765MACHINE_DRIVER_END
16601766
16611767
r3485r3486
16811787   MDRV_SOUND_ROUTE(1, "mono", 0.07)
16821788   MDRV_SOUND_ROUTE(2, "mono", 0.07)
16831789   MDRV_SOUND_ROUTE(3, "mono", 0.75)
1790
1791   MDRV_SOUND_ADD("oki", OKIM6295, CLOCK_8MHz/8) // was /128??
1792   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128, not /132, so unsure so pin 7 not verified
1793   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
16841794MACHINE_DRIVER_END
16851795
16861796
1797static MACHINE_DRIVER_START( itech8_sound_ym2608b )
1798
1799   /* basic machine hardware */
1800   MDRV_CPU_ADD("sound", M6809, CLOCK_8MHz/4)
1801   MDRV_CPU_PROGRAM_MAP(sound2608b_map,0)
1802
1803   /* sound hardware */
1804   MDRV_SOUND_ADD("ym", YM2608, CLOCK_8MHz)
1805   MDRV_SOUND_CONFIG(ym2608b_config)
1806   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
1807MACHINE_DRIVER_END
1808
1809
16871810static MACHINE_DRIVER_START( itech8_sound_ym3812 )
16881811
16891812   /* basic machine hardware */
r3485r3486
16941817   MDRV_SOUND_ADD("ym", YM3812, CLOCK_8MHz/2)
16951818   MDRV_SOUND_CONFIG(ym3812_config)
16961819   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
1820
1821   MDRV_SOUND_ADD("oki", OKIM6295, CLOCK_8MHz/8) // was /128??
1822   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128, not /132, so unsure so pin 7 not verified
1823   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
16971824MACHINE_DRIVER_END
16981825
16991826
r3485r3486
17071834   MDRV_SOUND_ADD("ym", YM3812, CLOCK_8MHz/2)
17081835   MDRV_SOUND_CONFIG(ym3812_config)
17091836   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
1837
1838   MDRV_SOUND_ADD("oki", OKIM6295, CLOCK_8MHz/8) // was /128??
1839   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128, not /132, so unsure so pin 7 not verified
1840   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
17101841MACHINE_DRIVER_END
17111842
17121843
r3485r3486
17251856MACHINE_DRIVER_END
17261857
17271858
1859static MACHINE_DRIVER_START( grmatch )
1860
1861   /* basic machine hardware */
1862   MDRV_IMPORT_FROM(itech8_core_hi)
1863   MDRV_IMPORT_FROM(itech8_sound_ym2608b)
1864
1865   /* video hardware */
1866   MDRV_SCREEN_MODIFY("main")
1867   MDRV_SCREEN_VISIBLE_AREA(0, 399, 0, 239)
1868   MDRV_VIDEO_UPDATE(itech8_grmatch)
1869
1870   /* palette updater */
1871   MDRV_TIMER_ADD_SCANLINE("palette", grmatch_palette_update, "main", 0, 0)
1872MACHINE_DRIVER_END
1873
1874
17281875static MACHINE_DRIVER_START( stratab_hi )
17291876
17301877   /* basic machine hardware */
r3485r3486
18962043   ROM_REGION( 0x10000, "sound", 0 )
18972044   ROM_LOAD( "wofsnd", 0x08000, 0x8000, CRC(0a6aa5dc) SHA1(42eef40a4300d6d16d9e2af678432a02be05f104) )
18982045
1899   ROM_REGION( 0xc0000, "gfx1", 0 )
2046   ROM_REGION( 0xc0000, "grom", 0 )
19002047   ROM_LOAD( "wofgrom0", 0x00000, 0x10000, CRC(9a157b2c) SHA1(c349b41ba00cf6e2fec32872627c8cfdd8b5c1b9) )
19012048   ROM_LOAD( "wofgrom1", 0x10000, 0x10000, CRC(5064739b) SHA1(424e3f94333f8ca21ac39b64b684cf6b487164d3) )
19022049   ROM_LOAD( "wofgrom2", 0x20000, 0x10000, CRC(3d393b2b) SHA1(2c94d2dab7369c099c470cf96391b033f39add78) )
r3485r3486
19162063   ROM_REGION( 0x10000, "sound", 0 )
19172064   ROM_LOAD( "wofsnd", 0x08000, 0x8000, CRC(0a6aa5dc) SHA1(42eef40a4300d6d16d9e2af678432a02be05f104) )
19182065
1919   ROM_REGION( 0xc0000, "gfx1", 0 )
2066   ROM_REGION( 0xc0000, "grom", 0 )
19202067   ROM_LOAD( "wofgrom0", 0x00000, 0x10000, CRC(9a157b2c) SHA1(c349b41ba00cf6e2fec32872627c8cfdd8b5c1b9) )
19212068   ROM_LOAD( "wofgrom1", 0x10000, 0x10000, CRC(5064739b) SHA1(424e3f94333f8ca21ac39b64b684cf6b487164d3) )
19222069   ROM_LOAD( "wofgrom2", 0x20000, 0x10000, CRC(3d393b2b) SHA1(2c94d2dab7369c099c470cf96391b033f39add78) )
r3485r3486
19272074ROM_END
19282075
19292076
2077ROM_START( grmatch )
2078   ROM_REGION( 0x1c000, "main", 0 )
2079   ROM_LOAD( "grudgematch.u5", 0x04000, 0x4000, CRC(11cadec9) SHA1(e21df623d1311ea63bafa2d6d0d94eb7d13232da) )
2080   ROM_CONTINUE(               0x10000, 0xc000 )
2081   ROM_COPY( "main",           0x14000, 0x8000, 0x8000 )
2082
2083   ROM_REGION( 0x10000, "sound", 0 )
2084   ROM_LOAD( "grudgematch.u27", 0x08000, 0x8000, CRC(59c18e63) SHA1(0d00c9cc683ff17e3213ba343ae65d533b57a243) )
2085
2086   ROM_REGION( 0xe0000, "grom", 0 )
2087   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(9064eff9) SHA1(4c80432ef359266c43b4691b503f529ed018a655) )
2088   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(6919c314) SHA1(e4a7ca77ee27ea8e41a236806e689c964d981210) )
2089   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(36b1682c) SHA1(6098b8aa576522c3cea66b5ac8f9406bf4222008) )
2090   ROM_LOAD( "grom3.bin", 0x60000, 0x20000, CRC(7bf05f61) SHA1(269e1cacf319d9f2a2b865ac6573e690f36827a1) )
2091   ROM_LOAD( "grom4.bin", 0x80000, 0x20000, CRC(55bded89) SHA1(61e0c60e391327a5fdda704c7756fcd6e11253c5) )
2092   ROM_LOAD( "grom5.bin", 0xa0000, 0x20000, CRC(37b47b2e) SHA1(352204d3e95e6db556aacf053c42d0d5871245a7) )
2093   ROM_LOAD( "grom6.bin", 0xc0000, 0x20000, CRC(860ee822) SHA1(2ca821c2fa220065b99b99b7487fe9666f338c75) )
2094
2095   ROM_REGION( 0x20000, "ym", 0 )
2096   ROM_LOAD( "srom0.bin", 0x00000, 0x20000, CRC(49bce954) SHA1(68a8b11c03722349d673f7383288c63054f0d6f6) )
2097ROM_END
2098
2099
19302100ROM_START( stratab )
19312101   ROM_REGION( 0x1c000, "main", 0 )
19322102   ROM_LOAD( "sbprogv3.bin", 0x08000, 0x8000, CRC(a5ae728f) SHA1(85098eef1614d5148e8082df4c936883662292ee) )
r3485r3486
19352105   ROM_REGION( 0x10000, "sound", 0 )
19362106   ROM_LOAD( "sbsnds.bin", 0x08000, 0x8000, CRC(b36c8f0a) SHA1(c4c3edf3352d95561f76705087338c1946137447) )
19372107
1938   ROM_REGION( 0xc0000, "gfx1", 0 )
2108   ROM_REGION( 0xc0000, "grom", 0 )
19392109   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(a915b0bd) SHA1(0955c7ebb48e97ccffc18c5deec6eccce1d68de8) )
19402110   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(340c661f) SHA1(150f9158fa6d956d08051c67c17723b1d8c66867) )
19412111   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(5df9f1cf) SHA1(cad87f63ac0e902dffeeaa42538fc73f792d87d9) )
r3485r3486
19532123   ROM_REGION( 0x10000, "sound", 0 )
19542124   ROM_LOAD( "sbsnds.bin", 0x08000, 0x8000, CRC(b36c8f0a) SHA1(c4c3edf3352d95561f76705087338c1946137447) )
19552125
1956   ROM_REGION( 0xc0000, "gfx1", 0 )
2126   ROM_REGION( 0xc0000, "grom", 0 )
19572127   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(a915b0bd) SHA1(0955c7ebb48e97ccffc18c5deec6eccce1d68de8) )
19582128   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(340c661f) SHA1(150f9158fa6d956d08051c67c17723b1d8c66867) )
19592129   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(5df9f1cf) SHA1(cad87f63ac0e902dffeeaa42538fc73f792d87d9) )
r3485r3486
19722142   ROM_REGION( 0x10000, "sound", 0 )
19732143   ROM_LOAD( "u27.bin", 0x08000, 0x8000, CRC(358d2440) SHA1(7b09350c89f9d2c86dc187d8812bbf26b576a38f) )
19742144
1975   ROM_REGION( 0xc0000, "gfx1", 0 )
2145   ROM_REGION( 0xc0000, "grom", 0 )
19762146   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(a29c688a) SHA1(32dbb996a5e4c23cfd44b79312ac4a767658f20a) )
19772147   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(b52a23f6) SHA1(092961acf47875179b44342e2dd8955670e67ea2) )
19782148   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(9b8e3a61) SHA1(1b5682b1328d6c97b604fb71512e8f72322a688f) )
r3485r3486
19942164   ROM_REGION( 0x10000, "sound", 0 )
19952165   ROM_LOAD( "snd-u27.256", 0x08000, 0x8000, CRC(471da557) SHA1(32bfe450a42d9eb6c14edcfa2b4e33f65a11126e) )
19962166
1997   ROM_REGION( 0xb0000, "gfx1", 0 )
2167   ROM_REGION( 0xb0000, "grom", 0 )
19982168   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(a29c688a) SHA1(32dbb996a5e4c23cfd44b79312ac4a767658f20a) )
19992169   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(b52a23f6) SHA1(092961acf47875179b44342e2dd8955670e67ea2) )
20002170   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(9b8e3a61) SHA1(1b5682b1328d6c97b604fb71512e8f72322a688f) )
r3485r3486
20172187   ROM_REGION( 0x10000, "sound", 0 )
20182188   ROM_LOAD( "u27.bin", 0x08000, 0x8000, CRC(dd2a5905) SHA1(dc93f13de3953852a6757361eb9683a57d3ed326) )
20192189
2020   ROM_REGION( 0xc0000, "gfx1", 0 )
2190   ROM_REGION( 0xc0000, "grom", 0 )
20212191   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(a29c688a) SHA1(32dbb996a5e4c23cfd44b79312ac4a767658f20a) )
20222192   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(a4182776) SHA1(9f4704d1a61a4fffce454c82cb3eb4629d9a2006) )
20232193   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(0580bb99) SHA1(012d473bc63632a5ed1a250daa54a00a4e30e8b2) )
r3485r3486
20422212   ROM_REGION( 0x10000, "sound", 0 )
20432213   ROM_LOAD( "u27.bin", 0x08000, 0x8000, CRC(dd2a5905) SHA1(dc93f13de3953852a6757361eb9683a57d3ed326) )
20442214
2045   ROM_REGION( 0xc0000, "gfx1", 0 )
2215   ROM_REGION( 0xc0000, "grom", 0 )
20462216   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(a29c688a) SHA1(32dbb996a5e4c23cfd44b79312ac4a767658f20a) )
20472217   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(a4182776) SHA1(9f4704d1a61a4fffce454c82cb3eb4629d9a2006) )
20482218   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(0580bb99) SHA1(012d473bc63632a5ed1a250daa54a00a4e30e8b2) )
r3485r3486
20732243   ROM_CONTINUE(        0x00000, 0x0800 )
20742244   ROM_CONTINUE(        0x00000, 0x0800 )
20752245
2076   ROM_REGION( 0xc0000, "gfx1", 0 )
2246   ROM_REGION( 0xc0000, "grom", 0 )
20772247   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(e60c2804) SHA1(e62d11b6c4439a70a2f32df72c8c64e2f110351e) )
20782248   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(d764d542) SHA1(43fc0c9b627484a670d87da91e212741b137e995) )
20792249
r3485r3486
20972267   ROM_CONTINUE(        0x00000, 0x0800 )
20982268   ROM_CONTINUE(        0x00000, 0x0800 )
20992269
2100   ROM_REGION( 0xc0000, "gfx1", 0 )
2270   ROM_REGION( 0xc0000, "grom", 0 )
21012271   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(e60c2804) SHA1(e62d11b6c4439a70a2f32df72c8c64e2f110351e) )
21022272   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(d764d542) SHA1(43fc0c9b627484a670d87da91e212741b137e995) )
21032273
r3485r3486
21212291   ROM_CONTINUE(        0x00000, 0x0800 )
21222292   ROM_CONTINUE(        0x00000, 0x0800 )
21232293
2124   ROM_REGION( 0xc0000, "gfx1", 0 )
2294   ROM_REGION( 0xc0000, "grom", 0 )
21252295   ROM_LOAD( "pool-grom.0", 0x00000, 0x10000, CRC(e6d0edc6) SHA1(5287a31bbdde1e4291d8e9e6b99d3aa12bfb6e18) )
21262296   ROM_LOAD( "pool-grom.1", 0x10000, 0x10000, CRC(5a071aa2) SHA1(9c5506e37625d213429b1231d457d7ce8a7a81ff) )
21272297   ROM_LOAD( "pool-grom.2", 0x20000, 0x10000, CRC(c0bdf4e0) SHA1(3b7c635375c5e5fddcbc1bd1b186c960081ec37e) )
r3485r3486
21472317   ROM_CONTINUE(            0x00000, 0x0800 )
21482318   ROM_CONTINUE(            0x00000, 0x0800 )
21492319
2150   ROM_REGION( 0xc0000, "gfx1", 0 )
2320   ROM_REGION( 0xc0000, "grom", 0 )
21512321   ROM_LOAD( "dynobop.gr0", 0x00000, 0x20000, CRC(3525a7a3) SHA1(fe0b08203c135d55507506936dc34e1503e4906b) )
21522322   ROM_LOAD( "dynobop.gr1", 0x20000, 0x20000, CRC(1544a232) SHA1(60bba76537c82887db8e38c6a87c528afdd385d0) )
21532323
r3485r3486
21702340   ROM_CONTINUE(        0x00000, 0x0800 )
21712341   ROM_CONTINUE(        0x00000, 0x0800 )
21722342
2173   ROM_REGION( 0xc0000, "gfx1", 0 )
2343   ROM_REGION( 0xc0000, "grom", 0 )
21742344   ROM_LOAD( "sstgrom0.bin", 0x00000, 0x20000, CRC(9cfb9849) SHA1(5aa860c0c6e3916ebdb8898ee44f633bf3347ca8) )
21752345   ROM_LOAD( "sstgrom1.bin", 0x20000, 0x20000, CRC(d9ea14e1) SHA1(4cddf3237c203b0a3f7ae770f85f1be35e9e1b78) )
21762346   ROM_LOAD( "sstgrom2.bin", 0x40000, 0x20000, CRC(dcd97bf7) SHA1(95361222ac58bf74539f2a7e80574bcd848c615e) )
r3485r3486
21892359   ROM_REGION( 0x10000, "sound", 0 )
21902360   ROM_LOAD( "pd-snd.bin", 0x08000, 0x8000, CRC(4925401c) SHA1(e35983bec4a0dd4cb1d942fd909790b1adeb415d) )
21912361
2192   ROM_REGION( 0xc0000, "gfx1", 0 )
2362   ROM_REGION( 0xc0000, "grom", 0 )
21932363   ROM_LOAD( "pd-grom0.bin", 0x00000, 0x20000, CRC(7c2573e7) SHA1(d6a2a16277ad854c66927d88c5617d05eefe1057) )
21942364   ROM_LOAD( "pd-grom1.bin", 0x20000, 0x20000, CRC(e7c06aeb) SHA1(4be54b078d886359bf6ed376019cc1f6f04f52d6) )
21952365
r3485r3486
22072377   ROM_REGION( 0x10000, "sound", 0 )
22082378   ROM_LOAD( "tensnd.v1", 0x08000, 0x8000, CRC(f034a694) SHA1(3540e2edff2ce47504260ec856bab9b638d9260d) )
22092379
2210   ROM_REGION( 0xc0000, "gfx1", 0 )
2380   ROM_REGION( 0xc0000, "grom", 0 )
22112381   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(1e69ebae) SHA1(a32e2c2f4e4a527ae6b57adeccd2c4d2045ab5fe) )
22122382   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(4e6a22d5) SHA1(3c2d51dd874f61c0a557ea2c1968afa02d9bfc42) )
22132383   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(c0b643a9) SHA1(d240f703a55c39ce4a969612fbb9cd76e4b849ac) )
r3485r3486
22312401   ROM_REGION( 0x10000, "sound", 0 )
22322402   ROM_LOAD( "tensnd.v1", 0x08000, 0x8000, CRC(f034a694) SHA1(3540e2edff2ce47504260ec856bab9b638d9260d) )
22332403
2234   ROM_REGION( 0xc0000, "gfx1", 0 )
2404   ROM_REGION( 0xc0000, "grom", 0 )
22352405   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(1e69ebae) SHA1(a32e2c2f4e4a527ae6b57adeccd2c4d2045ab5fe) )
22362406   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(4e6a22d5) SHA1(3c2d51dd874f61c0a557ea2c1968afa02d9bfc42) )
22372407   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(c0b643a9) SHA1(d240f703a55c39ce4a969612fbb9cd76e4b849ac) )
r3485r3486
22562426   ROM_REGION( 0x10000, "sound", 0 )
22572427   ROM_LOAD( "ahrsnd11.bin", 0x08000, 0x8000, CRC(dec57dca) SHA1(21a8ead10b0434629f41f6b067c49b6622569a6c) )
22582428
2259   ROM_REGION( 0xc0000, "gfx1", 0 )
2429   ROM_REGION( 0xc0000, "grom", 0 )
22602430   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(5ef57fe5) SHA1(e877979e034a61968b432037501e25a302a17a9a) )
22612431   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(6aca95c0) SHA1(da7a899bf0812a7af178e48b5a626ce56a836579) )
22622432   ROM_LOAD( "grom2.bin", 0x40000, 0x10000, CRC(6d6fde1b) SHA1(aaabc45d4b566be42e8d28d767e4771a96d9caae) )
r3485r3486
22752445   ROM_REGION( 0x10000, "sound", 0 )
22762446   ROM_LOAD( "sound.u27", 0x08000, 0x8000, CRC(b99beb70) SHA1(8d82c3b081a1afb236afa658abb3aa605c6c2264) )
22772447
2278   ROM_REGION( 0xc0000, "gfx1", 0 )
2448   ROM_REGION( 0xc0000, "grom", 0 )
22792449   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(5c02348d) SHA1(c85352728d94b3a5ca78c2493e98bdb4b3206bed) )
22802450   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(85a7a3a2) SHA1(7fb7be67c75867fcccf4272f1ce42f2af94c16e6) )
22812451   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(bfe11f18) SHA1(5e8d36c6a86a8eb883f50620fbfcea3d8398faeb) )
r3485r3486
22942464   ROM_REGION( 0x10000, "sound", 0 )
22952465   ROM_LOAD( "sound.u27", 0x08000, 0x8000, CRC(b99beb70) SHA1(8d82c3b081a1afb236afa658abb3aa605c6c2264) )
22962466
2297   ROM_REGION( 0xc0000, "gfx1", 0 )
2467   ROM_REGION( 0xc0000, "grom", 0 )
22982468   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(5c02348d) SHA1(c85352728d94b3a5ca78c2493e98bdb4b3206bed) )
22992469   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(85a7a3a2) SHA1(7fb7be67c75867fcccf4272f1ce42f2af94c16e6) )
23002470   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(bfe11f18) SHA1(5e8d36c6a86a8eb883f50620fbfcea3d8398faeb) )
r3485r3486
23142484   ROM_REGION( 0x10000, "sound", 0 )
23152485   ROM_LOAD( "nn_snd10.u27", 0x08000, 0x8000, CRC(74771b2f) SHA1(0a963d2962699bb1b4d08bd486979151d0a228da) )
23162486
2317   ROM_REGION( 0xc0000, "gfx1", 0 )
2487   ROM_REGION( 0xc0000, "grom", 0 )
23182488   ROM_LOAD( "nn_grom0.bin", 0x00000, 0x20000, CRC(064d1464) SHA1(4ce5bcadad93586c9af2b0c499d7a7140b080cdb) )
23192489   ROM_LOAD( "nn_grom1.bin", 0x20000, 0x20000, CRC(622d9a0b) SHA1(f084dcf194cfc658f97f36972f2b2ff30e834fc5) )
23202490   ROM_LOAD( "nn_grom2.bin", 0x40000, 0x20000, CRC(e7eb4020) SHA1(29ceb535d1dfddf8c12cf78919ea10f6b956b8b3) )
r3485r3486
23392509   ROM_REGION( 0x10000, "sound", 0 )
23402510   ROM_LOAD( "u27", 0x08000, 0x8000, CRC(59f87f0e) SHA1(46f38aca35a7c2faee227b4c950d20a6076c6fa7) )
23412511
2342   ROM_REGION( 0x100000, "gfx1", 0 )
2512   ROM_REGION( 0x100000, "grom", 0 )
23432513   ROM_LOAD( "grom00",       0x00000, 0x40000, CRC(3eacbad9) SHA1(bff1ec6a24ccf983434e4e9453c30f36fa397534) )
23442514   ROM_LOAD( "grom01",       0x40000, 0x40000, CRC(864cc269) SHA1(06f92889cd20881faeb59ec06ca1578ead2294f4) )
23452515   ROM_LOAD( "grom02-2.st2", 0x80000, 0x40000, CRC(47904233) SHA1(6a4d10e8f7b75582f706a74b37d59788613ffc61) )
r3485r3486
23692539   ROM_REGION( 0x10000, "sound", 0 )
23702540   ROM_LOAD( "u27", 0x08000, 0x8000, CRC(59f87f0e) SHA1(46f38aca35a7c2faee227b4c950d20a6076c6fa7) )
23712541
2372   ROM_REGION( 0x100000, "gfx1", 0 )
2542   ROM_REGION( 0x100000, "grom", 0 )
23732543   ROM_LOAD( "grom00",       0x00000, 0x40000, CRC(3eacbad9) SHA1(bff1ec6a24ccf983434e4e9453c30f36fa397534) )
23742544   ROM_LOAD( "grom01",       0x40000, 0x40000, CRC(864cc269) SHA1(06f92889cd20881faeb59ec06ca1578ead2294f4) )
23752545   ROM_LOAD( "grom02-2.st2", 0x80000, 0x40000, CRC(47904233) SHA1(6a4d10e8f7b75582f706a74b37d59788613ffc61) )
r3485r3486
23942564   ROM_REGION( 0x10000, "sound", 0 )
23952565   ROM_LOAD( "u27", 0x08000, 0x8000, CRC(59f87f0e) SHA1(46f38aca35a7c2faee227b4c950d20a6076c6fa7) )
23962566
2397   ROM_REGION( 0x100000, "gfx1", 0 )
2567   ROM_REGION( 0x100000, "grom", 0 )
23982568   ROM_LOAD( "grom00", 0x00000, 0x40000, CRC(3eacbad9) SHA1(bff1ec6a24ccf983434e4e9453c30f36fa397534) )
23992569   ROM_LOAD( "grom01", 0x40000, 0x40000, CRC(864cc269) SHA1(06f92889cd20881faeb59ec06ca1578ead2294f4) )
24002570   ROM_LOAD( "grom02", 0x80000, 0x40000, CRC(34e567d5) SHA1(d0eb6fd0da8b9c3bfe7d4ecfb4bd903e4926b63a) )
r3485r3486
24192589   ROM_REGION( 0x10000, "sound", 0 )
24202590   ROM_LOAD( "rrbsndv1.u27", 0x08000, 0x8000, CRC(8eda5f53) SHA1(f256544a8c87125587719460ed0fef14efef9015) )
24212591
2422   ROM_REGION( 0x100000, "gfx1", 0 )
2592   ROM_REGION( 0x100000, "grom", 0 )
24232593   ROM_LOAD( "grom00", 0x00000, 0x40000, CRC(3eacbad9) SHA1(bff1ec6a24ccf983434e4e9453c30f36fa397534) )
24242594   ROM_LOAD( "grom01", 0x40000, 0x40000, CRC(864cc269) SHA1(06f92889cd20881faeb59ec06ca1578ead2294f4) )
24252595   ROM_LOAD( "grom02", 0x80000, 0x40000, CRC(34e567d5) SHA1(d0eb6fd0da8b9c3bfe7d4ecfb4bd903e4926b63a) )
r3485r3486
24392609   ROM_REGION( 0x10000, "sound", 0 )
24402610   ROM_LOAD( "nc-snd", 0x08000, 0x8000, CRC(f9d5b4e1) SHA1(e5c3774db349b60baf11baecf55ac432871e612c) )
24412611
2442   ROM_REGION( 0x180000, "gfx1", 0 )
2612   ROM_REGION( 0x180000, "grom", 0 )
24432613   ROM_LOAD( "nc-grom0", 0x000000, 0x40000, CRC(532f7bff) SHA1(cc7a64ad1581f37ff4bcad78c11aad355a6e9aa8) )
24442614   ROM_LOAD( "nc-grom1", 0x040000, 0x40000, CRC(45640d4a) SHA1(1b59ae2a74fef535c646586422f17b39c9ae247b) )
24452615   ROM_LOAD( "nc-grom2", 0x080000, 0x40000, CRC(c8281d06) SHA1(f75d4e858f9bc19e5234f184b75818e448638c15) )
r3485r3486
24612631   ROM_REGION( 0x10000, "sound", 0 )
24622632   ROM_LOAD( "sndv1.u27", 0x08000, 0x8000, CRC(55734876) SHA1(eb5ef816acbc6e35642749e38a2908b7ba359b9d) )
24632633
2464   ROM_REGION( 0xc0000, "gfx1", 0 )
2634   ROM_REGION( 0xc0000, "grom", 0 )
24652635   ROM_LOAD( "grom00.bin", 0x00000, 0x40000, CRC(c3a7b54b) SHA1(414d693bc5337d578d2630817dd647cf7e5cbcf7) )
24662636   ROM_LOAD( "grom01.bin", 0x40000, 0x40000, BAD_DUMP CRC(2c834cf9) SHA1(49eb070ca4439d4fcd2d8a2db62d3c99b824bf99) ) /* Self test checksum reports BAD */
24672637   ROM_LOAD( "grom02.bin", 0x80000, 0x40000, CRC(aebe6c45) SHA1(15e64fcb36cb1064988ee5cd45699d501a6e7f01) )
r3485r3486
24812651   ROM_REGION( 0x10000, "sound", 0 )
24822652   ROM_LOAD( "sndv1.u27", 0x08000, 0x8000, CRC(55734876) SHA1(eb5ef816acbc6e35642749e38a2908b7ba359b9d) )
24832653
2484   ROM_REGION( 0xc0000, "gfx1", 0 )
2654   ROM_REGION( 0xc0000, "grom", 0 )
24852655   ROM_LOAD( "grom0.bin", 0x00000, 0x20000, CRC(a29c688a) SHA1(32dbb996a5e4c23cfd44b79312ac4a767658f20a) )
24862656   ROM_LOAD( "grom1.bin", 0x20000, 0x20000, CRC(a4182776) SHA1(9f4704d1a61a4fffce454c82cb3eb4629d9a2006) )
24872657   ROM_LOAD( "grom2.bin", 0x40000, 0x20000, CRC(0580bb99) SHA1(012d473bc63632a5ed1a250daa54a00a4e30e8b2) )
r3485r3486
25042674 *
25052675 *************************************/
25062676
2677static DRIVER_INIT( grmatch )
2678{
2679   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0160, 0x0160, 0, 0, grmatch_palette_w);
2680   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0180, 0x0180, 0, 0, grmatch_xscroll_w);
2681   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x01e0, 0x01ff, 0, 0, SMH_UNMAP);
2682}
2683
2684
25072685static DRIVER_INIT( slikshot )
25082686{
25092687   memory_install_read8_handler (machine, 0, ADDRESS_SPACE_PROGRAM, 0x0180, 0x0180, 0, 0, slikshot_z80_r);
r3485r3486
25742752GAME( 1989, wfortune, 0,        wfortune,          wfortune, 0,        ROT0,   "GameTek", "Wheel Of Fortune", 0 )
25752753GAME( 1989, wfortuna, wfortune, wfortune,          wfortune, 0,        ROT0,   "GameTek", "Wheel Of Fortune (alternate)", 0 )
25762754
2755/* Grudge Match-style PCB */
2756GAME( 1989, grmatch,  0,        grmatch,           grmatch,  grmatch,  ROT0,   "Yankee Game Technology", "Grudge Match (Yankee Game Technology)", 0 )
2757
25772758/* Strata Bowling-style PCB */
25782759GAME( 1990, stratab,  0,        stratab_hi,        stratab,  0,        ROT270, "Strata/Incredible Technologies", "Strata Bowling (V3)", 0 )
25792760GAME( 1990, stratab1, stratab,  stratab_hi,        stratab,  0,        ROT270, "Strata/Incredible Technologies", "Strata Bowling (V1)", 0 )
src/mame/drivers/namconb1.c
r3485r3486
893893   // C74 BIOS has a very short window on the CPU sync signal, so immediately let the '020 at it
894894   if ((offset == 0x6000/2) && (data & 0x80))
895895   {
896      cpu_spinuntil_time(ATTOTIME_IN_CYCLES(300, 1));
896      cpu_spinuntil_time(ATTOTIME_IN_CYCLES(300, 1));   // was 300
897897   }
898898}
899899
r3485r3486
10741074   ROM_LOAD32_WORD( "gn2mprlb.15b", 0x00002, 0x80000, CRC(fe2d9425) SHA1(51b166a629cbb522720d63720558816b496b6b76) )
10751075   ROM_LOAD32_WORD( "gn2mprub.13b", 0x00000, 0x80000, CRC(3bf4985a) SHA1(f559e0d5f55d23d886fe61bd7d5ca556acc7f87c) )
10761076
1077   ROM_REGION( 0x4000, "c75", 0 ) /* C75 program */
1077   ROM_REGION16_LE( 0x4000, "c75", 0 ) /* C75 program */
10781078   ROM_LOAD( "c75.bin", 0, 0x4000, CRC(42f539a5) SHA1(3103e5a0a2867620309fd4fe478a2be0effbeff8) )
10791079
10801080   ROM_REGION16_LE( 0x80000, "c75data", 0 ) /* sound data */
r3485r3486
11041104   ROM_LOAD32_WORD( "gn1-mprl.bin", 0x00002, 0x80000, CRC(f99e309e) SHA1(3fe0ddf756e6849f8effc7672456cbe32f65c98a) )
11051105   ROM_LOAD32_WORD( "gn1-mpru.bin", 0x00000, 0x80000, CRC(72a4db07) SHA1(8c5e1e51cd961b311d03f7b21f36a5bd5e8e9104) )
11061106
1107   ROM_REGION( 0x4000, "c75", 0 ) /* C75 program */
1107   ROM_REGION16_LE( 0x4000, "c75", 0 ) /* C75 program */
11081108   ROM_LOAD( "c75.bin", 0, 0x4000, CRC(42f539a5) SHA1(3103e5a0a2867620309fd4fe478a2be0effbeff8) )
11091109
11101110   ROM_REGION16_LE( 0x80000, "c75data", 0 ) /* sound data */
r3485r3486
11341134   ROM_LOAD32_WORD( "nr2-mpru.13b", 0x00000, 0x80000, CRC(049b97cb) SHA1(0e344b29a4d4bdc854fa9849589772df2eeb0a05) )
11351135   ROM_LOAD32_WORD( "nr2-mprl.15b", 0x00002, 0x80000, CRC(0431b6d4) SHA1(54c96e8ac9e753956c31bdef79d390f1c20e10ff) )
11361136
1137   ROM_REGION( 0x4000, "c75", 0 ) /* C75 program */
1137   ROM_REGION16_LE( 0x4000, "c75", 0 ) /* C75 program */
11381138   ROM_LOAD( "c75.bin", 0, 0x4000, CRC(42f539a5) SHA1(3103e5a0a2867620309fd4fe478a2be0effbeff8) )
11391139
11401140   ROM_REGION16_LE( 0x80000, "c75data", 0 ) /* sound data */
r3485r3486
11711171   ROM_LOAD32_WORD( "nr1-mpru", 0x00000, 0x80000, CRC(42ef71f9) SHA1(20e3cb63e1fde293c60c404b378d901d635c4b79) )
11721172   ROM_LOAD32_WORD( "nr1-mprl", 0x00002, 0x80000, CRC(fae5f62c) SHA1(143d716abbc834aac6270db3bbb89ec71ea3804d) )
11731173
1174   ROM_REGION( 0x4000, "c75", 0 ) /* C75 program */
1174   ROM_REGION16_LE( 0x4000, "c75", 0 ) /* C75 program */
11751175   ROM_LOAD( "c75.bin", 0, 0x4000, CRC(42f539a5) SHA1(3103e5a0a2867620309fd4fe478a2be0effbeff8) )
11761176
11771177   ROM_REGION16_LE( 0x80000, "c75data", 0 ) /* sound data */
r3485r3486
12081208   ROM_LOAD32_WORD( "gse2mprl.bin", 0x00002, 0x80000, CRC(a514349c) SHA1(1f7ec81cd6193410d2f01e6f0f84878561fc8035) )
12091209   ROM_LOAD32_WORD( "gse2mpru.bin", 0x00000, 0x80000, CRC(b6afd238) SHA1(438a3411ac8ce3d22d5da8c0800738cb8d2994a9) )
12101210
1211   ROM_REGION( 0x4000, "c75", 0 ) /* C75 program */
1211   ROM_REGION16_LE( 0x4000, "c75", 0 ) /* C75 program */
12121212   ROM_LOAD( "c75.bin", 0, 0x4000, CRC(42f539a5) SHA1(3103e5a0a2867620309fd4fe478a2be0effbeff8) )
12131213
12141214   ROM_REGION16_LE( 0x80000, "c75data", 0 ) /* sound data */
r3485r3486
13621362   ROM_LOAD32_WORD( "gs1mprl.15b", 0x00002, 0x80000, CRC(1e6c3626) SHA1(56abe21884fd87df10996db19c49ce14214d4b73) )
13631363   ROM_LOAD32_WORD( "gs1mpru.13b", 0x00000, 0x80000, CRC(ef355179) SHA1(0ab0ef4301a318681bb5827d35734a0732b35484) )
13641364
1365   ROM_REGION( 0x4000, "c75", 0 ) /* C75 program */
1365   ROM_REGION16_LE( 0x4000, "c75", 0 ) /* C75 program */
13661366   ROM_LOAD( "c75.bin", 0, 0x4000, CRC(42f539a5) SHA1(3103e5a0a2867620309fd4fe478a2be0effbeff8) )
13671367
13681368   ROM_REGION16_LE( 0x80000, "c75data", 0 ) /* sound data */
r3485r3486
13901390   ROM_LOAD32_WORD( "ss51mprl.bin", 0x00002, 0x80000, CRC(c9e0107d) SHA1(0f10582416023a86ea1ef2679f3f06016c086e08) )
13911391   ROM_LOAD32_WORD( "ss51mpru.bin", 0x00000, 0x80000, CRC(0d93d261) SHA1(5edef26e2c86dbc09727d910af92747d022e4fed) )
13921392
1393   ROM_REGION( 0x4000, "c75", 0 ) /* C75 program */
1393   ROM_REGION16_LE( 0x4000, "c75", 0 ) /* C75 program */
13941394   ROM_LOAD( "c75.bin", 0, 0x4000, CRC(42f539a5) SHA1(3103e5a0a2867620309fd4fe478a2be0effbeff8) )
13951395
13961396   ROM_REGION16_LE( 0x80000, "c75data", 0 ) /* sound data */
r3485r3486
14191419   ROM_LOAD32_WORD( "ss61mprl.bin", 0x00002, 0x80000, CRC(06f55e73) SHA1(6be26f8a2ef600bf07c580f210d7b265ac464002) )
14201420   ROM_LOAD32_WORD( "ss61mpru.bin", 0x00000, 0x80000, CRC(0abdbb83) SHA1(67e8b712291f9bcf2c3a52fbc451fad54679cab8) )
14211421
1422   ROM_REGION( 0x4000, "c75", 0 ) /* C75 program */
1422   ROM_REGION16_LE( 0x4000, "c75", 0 ) /* C75 program */
14231423   ROM_LOAD( "c75.bin", 0, 0x4000, CRC(42f539a5) SHA1(3103e5a0a2867620309fd4fe478a2be0effbeff8) )
14241424
14251425   ROM_REGION16_LE( 0x80000, "c75data", 0 ) /* sound data */
r3485r3486
14471447   ROM_LOAD32_WORD( "ss71mprl.bin", 0x00002, 0x80000, CRC(bd60b50e) SHA1(9e00bacd506182ab2af2c0efdd5cc401b3e46485) )
14481448   ROM_LOAD32_WORD( "ss71mpru.bin", 0x00000, 0x80000, CRC(3444f5a8) SHA1(8d0f35b3ba8f65dbc67c3b2d273833227a8b8b2a) )
14491449
1450   ROM_REGION( 0x4000, "c75", 0 ) /* C75 program */
1450   ROM_REGION16_LE( 0x4000, "c75", 0 ) /* C75 program */
14511451   ROM_LOAD( "c75.bin", 0, 0x4000, CRC(42f539a5) SHA1(3103e5a0a2867620309fd4fe478a2be0effbeff8) )
14521452
14531453   ROM_REGION16_LE( 0x80000, "c75data", 0 ) /* sound data */
r3485r3486
14751475   ROM_LOAD32_WORD( "vsj1mprl.15b", 0x00002, 0x80000, CRC(83a60d92) SHA1(c3db0c79f772a79418914353a3d6ecc4883ea54e) )
14761476   ROM_LOAD32_WORD( "vsj1mpru.13b", 0x00000, 0x80000, CRC(c63eb92d) SHA1(f93bd4b91daee645677955020dc8df14dc9bfd27) )
14771477
1478   ROM_REGION( 0x4000, "c75", 0 ) /* C75 program */
1478   ROM_REGION16_LE( 0x4000, "c75", 0 ) /* C75 program */
14791479   ROM_LOAD( "c75.bin", 0, 0x4000, CRC(42f539a5) SHA1(3103e5a0a2867620309fd4fe478a2be0effbeff8) )
14801480
14811481   ROM_REGION16_LE( 0x80000, "c75data", 0 ) /* sound data */
src/mame/drivers/cosmic.c
r3485r3486
195195    #endif
196196}
197197
198
199static WRITE8_HANDLER( cosmica_sound_output_w )
200{
201    static int  sound_enabled=1;
202    static int dive_bomb_b_select=0;
203
204    /* Sound Enable / Disable */
205    if (offset == 11)
206    {
207       int count;
208       if (data == 0)
209           for(count=0; count<12; count++) sample_stop(count);
210   else
211   {
212     sample_start(0, 0, 1); /*Background Noise*/
213   }
214
215       sound_enabled = data;
216    }
217
218    if (sound_enabled)
219    {
220        switch (offset)
221        {
222      case 0: if (data) sample_start(1, 2, 0); break; /*Dive Bombing Type A*/
223
224      case 2:   /*Dive Bombing Type B (Main Control)*/
225
226
227         if (data)
228         {
229
230           switch(dive_bomb_b_select)
231           {
232
233             case 2:
234
235               if (sample_playing(2))
236               {
237                 sample_stop(2);
238                    sample_start(2, 3, 0); break;
239               }
240               else
241                     sample_start(2, 3, 0); break;
242
243
244             case 3:
245
246               if (sample_playing(3))
247               {
248                 sample_stop(3);
249                    sample_start(3, 4, 0); break;
250               }
251               else
252                     sample_start(3, 4, 0); break;
253
254
255             case 4:
256               if (sample_playing(4))
257               {
258                 sample_stop(4);
259                    sample_start(4, 5, 0); break;
260               }
261               else
262                     sample_start(4, 5, 0); break;
263
264
265
266             case 5:
267               if (sample_playing(5))
268               {
269                 sample_stop(5);
270                    sample_start(5, 6, 0); break;
271               }
272               else
273                     sample_start(5, 6, 0); break;
274
275
276             case 6:
277               if (sample_playing(6))
278               {
279                 sample_stop(6);
280                    sample_start(6, 7, 0); break;
281               }
282               else
283                     sample_start(6, 7, 0); break;
284
285             case 7:
286
287               if (sample_playing(7))
288               {
289                 sample_stop(7);
290                    sample_start(7, 8, 0); break;
291               }
292               else
293                     sample_start(7, 8, 0); break;
294           }
295         }
296
297      case 3: /*Dive Bombing Type B (G.S.B)*/
298
299         if (data)
300           dive_bomb_b_select |= 0x04;
301         else
302           dive_bomb_b_select &= 0xFB;
303         break;
304
305
306      case 4: /*Dive Bombing Type B (M.S.B)*/
307         if (data)
308           dive_bomb_b_select |= 0x02;
309         else
310           dive_bomb_b_select &= 0xFD;
311
312         break;
313
314      case 5: /*Dive Bombing Type B (L.S.B)*/
315
316
317         if (data)
318           dive_bomb_b_select |= 0x01;
319         else
320           dive_bomb_b_select &= 0xFE;
321         break;
322
323
324      case 6: if (data) sample_start(8, 9, 0); break; /*Fire Control*/
325
326      case 7: if (data) sample_start(9, 10, 0); break; /*Small Explosion*/
327
328      case 8: if (data) sample_start(10, 11, 0); break; /*Loud Explosion*/
329
330      case 9:
331       if (data)
332        sample_start(11, 1, 1);
333      else
334       sample_stop(11);
335
336      break; /*Extend Sound control*/
337
338      case 12:
339       if (data) sample_start(11,12, 0); break; /*Insert Coin*/
340        }
341    }
342
343    #ifdef MAME_DEBUG
344    logerror("Sound output %x=%x\n",offset,data);
345   #endif
346}
347
348
349
350
198351static INTERRUPT_GEN( panic_interrupt )
199352{
200353   if (cpu_getiloops() != 0)
r3485r3486
343496   AM_RANGE(0x0000, 0x3fff) AM_WRITE(SMH_ROM)
344497   AM_RANGE(0x4000, 0x5fff) AM_WRITE(SMH_RAM) AM_BASE(&videoram) AM_SIZE(&videoram_size)
345498   AM_RANGE(0x6000, 0x601f) AM_WRITE(SMH_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
499   AM_RANGE(0x7000, 0x700b) AM_WRITE(cosmica_sound_output_w)
346500   AM_RANGE(0x700c, 0x700d) AM_WRITE(cosmic_color_register_w)
347501   AM_RANGE(0x700f, 0x700f) AM_WRITE(flip_screen_w)
348502ADDRESS_MAP_END
r3485r3486
844998GFXDECODE_END
845999
8461000
1001static const char *cosmica_sample_names[] =
1002{
1003   "*cosmica",
1004   "backgr.wav",
1005   "extend.wav",
1006   "divea.wav",
1007   "diveb1.wav",
1008   "diveb2.wav",
1009   "diveb3.wav",
1010   "diveb4.wav",
1011   "diveb5.wav",
1012   "diveb6.wav",
1013   "fire.wav",
1014   "loudexp.wav",
1015   "smallexp.wav",
1016   "coin.wav",
1017   0       /* end of array */
1018};
1019
1020
1021static const samples_interface cosmica_samples_interface =
1022{
1023   13,   /* 12 channels */
1024   cosmica_sample_names
1025};
1026
1027
8471028static const char *const panic_sample_names[] =
8481029{
8491030   "*panic",
r3485r3486
9521133
9531134   MDRV_PALETTE_INIT(cosmica)
9541135   MDRV_VIDEO_UPDATE(cosmica)
1136
1137   /* sound hardware */
1138   MDRV_SPEAKER_STANDARD_MONO("mono")
1139
1140   MDRV_SOUND_ADD("samples", SAMPLES, 0)
1141   MDRV_SOUND_CONFIG(cosmica_samples_interface)
1142   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
1143
1144   MDRV_SOUND_ADD("dac", DAC, 0)
1145   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
1146
9551147MACHINE_DRIVER_END
9561148
9571149
r3485r3486
14061598
14071599
14081600GAME( 1979, cosmicg,  0,       cosmicg,  cosmicg,  cosmicg, ROT270, "Universal", "Cosmic Guerilla", GAME_NO_COCKTAIL )
1409GAME( 1979, cosmica,  0,       cosmica,  cosmica,  0,       ROT270, "Universal", "Cosmic Alien", GAME_NO_SOUND )
1410GAME( 1979, cosmica2, cosmica, cosmica,  cosmica,  0,       ROT270, "Universal", "Cosmic Alien (older)", GAME_NO_SOUND )
1601GAME( 1979, cosmica,  0,       cosmica,  cosmica,  0,       ROT270, "Universal", "Cosmic Alien", 0 )
1602GAME( 1979, cosmica2, cosmica, cosmica,  cosmica,  0,       ROT270, "Universal", "Cosmic Alien (older)", 0 )
14111603GAME( 1980, nomnlnd,  0,       nomnlnd,  nomnlnd,  nomnlnd, ROT270, "Universal", "No Man's Land", GAME_IMPERFECT_SOUND )
14121604GAME( 1980, nomnlndg, nomnlnd, nomnlnd,  nomnlndg, nomnlnd, ROT270, "Universal (Gottlieb license)", "No Man's Land (Gottlieb)", GAME_IMPERFECT_SOUND )
14131605GAME( 1980, magspot,  0,       magspot,  magspot,  0,       ROT270, "Universal", "Magical Spot", GAME_IMPERFECT_SOUND )
src/mame/drivers/toaplan1.c
r3485r3486
1313    ROM set     Toaplan
1414    name        board No        Game name
1515    --------------------------------------------------
16    rallybik    TP-012      Rally Bike/Dash Yarou
17    truxton     TP-013B     Truxton/Tatsujin
16    rallybik    TP-O12      Rally Bike/Dash Yarou
17    truxton     TP-O13B     Truxton/Tatsujin
1818    hellfire    B90         HellFire (2 Player version) Uses Taito rom ID number
1919    hellfir1    B90         HellFire (1 Player version) Uses Taito rom ID number
2020    hellfir2    B90         HellFire (2 Player, ealier version) Uses Taito rom ID number
21    zerowing    TP-015      Zero Wing
22    zerowng2    TP-015      Zero Wing (2 player simultaneous version, Williams Electronics Games, Inc)
23    demonwld    TP-016      Demon's World/Horror Story [1990]
24    demonwl1    TP-016      Demon's World/Horror Story [1989] (Taito license)
25    demonwl2    TP-016      Demon's World/Horror Story [1989] (early edition)
26    demonwl3    TP-016      Demon's World/Horror Story [1989] (first edition)
27    fireshrk    TP-017      Fire Shark (World)           [1990]
28    samesame    TP-017      Same! Same! Same! (Japan)    [1989] (1 Player version)
29    samesam2    TP-017      Same! Same! Same! (Japan)    [1989] (2 Player version)
30    outzone     TP-018      Out Zone
31    outzonea    TP-018      Out Zone (From board serial number 2122)
32    vimana      TP-019      Vimana (From board serial number 1547.04 [July '94])
33    vimana1     TP-019      Vimana (Older version)
34    vimanan     TP-019      Vimana (Nova Apparate GMBH & Co  license)
21    zerowing    TP-O15      Zero Wing
22    zerowng2    TP-O15      Zero Wing (2 player simultaneous version, Williams Electronics Games, Inc)
23    demonwld    TP-O16      Demon's World/Horror Story [1990]
24    demonwl1    TP-O16      Demon's World/Horror Story [1989] (Taito license)
25    demonwl2    TP-O16      Demon's World/Horror Story [1989] (early edition)
26    demonwl3    TP-O16      Demon's World/Horror Story [1989] (first edition)
27    fireshrk    TP-O17      Fire Shark (World)           [1990]
28    samesame    TP-O17      Same! Same! Same! (Japan)    [1989] (1 Player version)
29    samesam2    TP-O17      Same! Same! Same! (Japan)    [1989] (2 Player version)
30    outzone     TP-O18      Out Zone
31    outzonea    TP-O18      Out Zone (From board serial number 2122)
32    vimana      TP-O19      Vimana (From board serial number 1547.04 [July '94])
33    vimana1     TP-O19      Vimana (Older version)
34    vimanan     TP-O19      Vimana (Nova Apparate GMBH & Co  license)
3535
3636
3737Notes:
r3485r3486
920920   PORT_DIPSETTING(    0x00, "USA (Romstar)" )
921921INPUT_PORTS_END
922922
923
923924static INPUT_PORTS_START( outzone )
924925   TOAPLAN1_VBLANK_INPUT
925926
r3485r3486
18971898   ROM_LOAD( "hd647180.017",  0x00000, 0x08000, NO_DUMP )
18981899
18991900   ROM_REGION( 0x80000, "gfx1", ROMREGION_DISPOSE )
1900   ROM_LOAD( "o17_05.bin",  0x00000, 0x20000, CRC(565315f8) SHA1(6b1c5ef52359483228b329c89c2e1174e3fbf017) )
1901   ROM_LOAD( "o17_06.bin",  0x20000, 0x20000, CRC(95262d4c) SHA1(16f3aabecb1c87ce7eadf4f0ff61b29a4c017614) )
1902   ROM_LOAD( "o17_07.bin",  0x40000, 0x20000, CRC(4c4b735c) SHA1(812c3bf46bd7764b2bb812bd2b9eb0331ed257ae) )
1903   ROM_LOAD( "o17_08.bin",  0x60000, 0x20000, CRC(95c6586c) SHA1(ff87901f79d80f73ad09664b0c0d892898570616) )
1901   ROM_LOAD( "o17_05.12j",  0x00000, 0x20000, CRC(565315f8) SHA1(6b1c5ef52359483228b329c89c2e1174e3fbf017) )
1902   ROM_LOAD( "o17_06.13j",  0x20000, 0x20000, CRC(95262d4c) SHA1(16f3aabecb1c87ce7eadf4f0ff61b29a4c017614) )
1903   ROM_LOAD( "o17_07.12l",  0x40000, 0x20000, CRC(4c4b735c) SHA1(812c3bf46bd7764b2bb812bd2b9eb0331ed257ae) )
1904   ROM_LOAD( "o17_08.13l",  0x60000, 0x20000, CRC(95c6586c) SHA1(ff87901f79d80f73ad09664b0c0d892898570616) )
19041905
19051906   ROM_REGION( 0x80000, "gfx2", ROMREGION_DISPOSE )
1906   ROM_LOAD( "o17_01.bin",  0x00000, 0x20000, CRC(ea12e491) SHA1(02190722b7c5383471e0af9596be7039a5367240) )
1907   ROM_LOAD( "o17_02.bin",  0x20000, 0x20000, CRC(32a13a9f) SHA1(1446acdfd21cd41f3d97aaf30f498c0c5d890605) )
1908   ROM_LOAD( "o17_03.bin",  0x40000, 0x20000, CRC(68723dc9) SHA1(4f1b7aa2469c955e03737b611a7d2524f1e4f61e) )
1909   ROM_LOAD( "o17_04.bin",  0x60000, 0x20000, CRC(fe0ecb13) SHA1(634a49262b9c092c25f11b14c6757fe94ea9eddc) )
1907   ROM_LOAD( "o17_01.1d",  0x00000, 0x20000, CRC(ea12e491) SHA1(02190722b7c5383471e0af9596be7039a5367240) )
1908   ROM_LOAD( "o17_02.3d",  0x20000, 0x20000, CRC(32a13a9f) SHA1(1446acdfd21cd41f3d97aaf30f498c0c5d890605) )
1909   ROM_LOAD( "o17_03.5d",  0x40000, 0x20000, CRC(68723dc9) SHA1(4f1b7aa2469c955e03737b611a7d2524f1e4f61e) )
1910   ROM_LOAD( "o17_04.7d",  0x60000, 0x20000, CRC(fe0ecb13) SHA1(634a49262b9c092c25f11b14c6757fe94ea9eddc) )
19101911
19111912   ROM_REGION( 0x40, "proms", 0 )      /* nibble bproms, lo/hi order to be determined */
1912   ROM_LOAD( "tp017_13.bpr",  0x00, 0x20, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) )   /* sprite attribute (flip/position) ?? */
1913   ROM_LOAD( "tp017_14.bpr",  0x20, 0x20, CRC(a1e17492) SHA1(9ddec4c97f2d541f69f3c32c47aaa21fd9699ae2) )   /* ??? */
1913   ROM_LOAD( "prom14.25b",  0x00, 0x20, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) )   /* sprite attribute (flip/position) ?? */
1914   ROM_LOAD( "prom15.20c",  0x20, 0x20, CRC(a1e17492) SHA1(9ddec4c97f2d541f69f3c32c47aaa21fd9699ae2) )   /* ??? */
19141915ROM_END
19151916
19161917ROM_START( samesam2 )
19171918   ROM_REGION( 0x080000, "main", 0 )   /* Main 68K code */
19181919   ROM_LOAD16_BYTE( "o17_09x.bin", 0x000000, 0x08000, CRC(3472e03e) SHA1(a0f12622a1963bfac2d5f357afbfb5d7db2cd8df) )
19191920   ROM_LOAD16_BYTE( "o17_10x.bin", 0x000001, 0x08000, CRC(a3ac49b5) SHA1(c5adf026b9129b64acee5a079e102377a8488220) )
1920   ROM_LOAD16_BYTE( "o17_11x.bin", 0x040000, 0x20000, CRC(6beac378) SHA1(041ba98a89a4bac32575858db8a061bdf7804594) )
1921   ROM_LOAD16_BYTE( "o17_12x.bin", 0x040001, 0x20000, CRC(6adb6eb5) SHA1(9b6e63aa50d271c2bb0b4cf822fc6f3684f10230) )
1921   ROM_LOAD16_BYTE( "o17_11ii.7j", 0x040000, 0x20000, CRC(6beac378) SHA1(041ba98a89a4bac32575858db8a061bdf7804594) )
1922   ROM_LOAD16_BYTE( "o17_12ii.7l", 0x040001, 0x20000, CRC(6adb6eb5) SHA1(9b6e63aa50d271c2bb0b4cf822fc6f3684f10230) )
19221923
19231924   ROM_REGION( 0x10000, "cpu1", 0 )   /* Sound HD647180 code */
19241925   /* sound CPU is a HD647180 (Z180) with internal ROM - not yet supported */
19251926   ROM_LOAD( "hd647180.017",  0x00000, 0x08000, NO_DUMP )
19261927
19271928   ROM_REGION( 0x80000, "gfx1", ROMREGION_DISPOSE )
1928   ROM_LOAD( "o17_05.bin",  0x00000, 0x20000, CRC(565315f8) SHA1(6b1c5ef52359483228b329c89c2e1174e3fbf017) )
1929   ROM_LOAD( "o17_06.bin",  0x20000, 0x20000, CRC(95262d4c) SHA1(16f3aabecb1c87ce7eadf4f0ff61b29a4c017614) )
1930   ROM_LOAD( "o17_07.bin",  0x40000, 0x20000, CRC(4c4b735c) SHA1(812c3bf46bd7764b2bb812bd2b9eb0331ed257ae) )
1931   ROM_LOAD( "o17_08.bin",  0x60000, 0x20000, CRC(95c6586c) SHA1(ff87901f79d80f73ad09664b0c0d892898570616) )
1929   ROM_LOAD( "o17_05.12j",  0x00000, 0x20000, CRC(565315f8) SHA1(6b1c5ef52359483228b329c89c2e1174e3fbf017) )
1930   ROM_LOAD( "o17_06.13j",  0x20000, 0x20000, CRC(95262d4c) SHA1(16f3aabecb1c87ce7eadf4f0ff61b29a4c017614) )
1931   ROM_LOAD( "o17_07.12l",  0x40000, 0x20000, CRC(4c4b735c) SHA1(812c3bf46bd7764b2bb812bd2b9eb0331ed257ae) )
1932   ROM_LOAD( "o17_08.13l",  0x60000, 0x20000, CRC(95c6586c) SHA1(ff87901f79d80f73ad09664b0c0d892898570616) )
19321933
19331934   ROM_REGION( 0x80000, "gfx2", ROMREGION_DISPOSE )
1934   ROM_LOAD( "o17_01.bin",  0x00000, 0x20000, CRC(ea12e491) SHA1(02190722b7c5383471e0af9596be7039a5367240) )
1935   ROM_LOAD( "o17_02.bin",  0x20000, 0x20000, CRC(32a13a9f) SHA1(1446acdfd21cd41f3d97aaf30f498c0c5d890605) )
1936   ROM_LOAD( "o17_03.bin",  0x40000, 0x20000, CRC(68723dc9) SHA1(4f1b7aa2469c955e03737b611a7d2524f1e4f61e) )
1937   ROM_LOAD( "o17_04.bin",  0x60000, 0x20000, CRC(fe0ecb13) SHA1(634a49262b9c092c25f11b14c6757fe94ea9eddc) )
1935   ROM_LOAD( "o17_01.1d",  0x00000, 0x20000, CRC(ea12e491) SHA1(02190722b7c5383471e0af9596be7039a5367240) )
1936   ROM_LOAD( "o17_02.3d",  0x20000, 0x20000, CRC(32a13a9f) SHA1(1446acdfd21cd41f3d97aaf30f498c0c5d890605) )
1937   ROM_LOAD( "o17_03.5d",  0x40000, 0x20000, CRC(68723dc9) SHA1(4f1b7aa2469c955e03737b611a7d2524f1e4f61e) )
1938   ROM_LOAD( "o17_04.7d",  0x60000, 0x20000, CRC(fe0ecb13) SHA1(634a49262b9c092c25f11b14c6757fe94ea9eddc) )
19381939
19391940   ROM_REGION( 0x40, "proms", 0 )      /* nibble bproms, lo/hi order to be determined */
1940   ROM_LOAD( "tp017_13.bpr",  0x00, 0x20, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) )   /* sprite attribute (flip/position) ?? */
1941   ROM_LOAD( "tp017_14.bpr",  0x20, 0x20, CRC(a1e17492) SHA1(9ddec4c97f2d541f69f3c32c47aaa21fd9699ae2) )   /* ??? */
1941   ROM_LOAD( "prom14.25b",  0x00, 0x20, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) )   /* sprite attribute (flip/position) ?? */
1942   ROM_LOAD( "prom15.20c",  0x20, 0x20, CRC(a1e17492) SHA1(9ddec4c97f2d541f69f3c32c47aaa21fd9699ae2) )   /* ??? */
19421943ROM_END
19431944
19441945ROM_START( fireshrk )
19451946   ROM_REGION( 0x080000, "main", 0 )   /* Main 68K code */
19461947   ROM_LOAD16_BYTE( "09.bin",      0x000000, 0x08000, CRC(f0c70e6f) SHA1(037690448786d61aa116b24b638430c577ea78e2) )
19471948   ROM_LOAD16_BYTE( "10.bin",      0x000001, 0x08000, CRC(9d253d77) SHA1(0414d1f475abb9ccfd7daa11c2f400a14f25db09) )
1949   ROM_LOAD16_BYTE( "o17_11ii.7j", 0x040000, 0x20000, CRC(6beac378) SHA1(041ba98a89a4bac32575858db8a061bdf7804594) )
1950   ROM_LOAD16_BYTE( "o17_12ii.7l", 0x040001, 0x20000, CRC(6adb6eb5) SHA1(9b6e63aa50d271c2bb0b4cf822fc6f3684f10230) )
1951
1952   ROM_REGION( 0x10000, "cpu1", 0 )   /* Sound HD647180 code */
1953   /* sound CPU is a HD647180 (Z180) with internal ROM - not yet supported */
1954   ROM_LOAD( "hd647180.017",  0x00000, 0x08000, NO_DUMP )
1955
1956   ROM_REGION( 0x80000, "gfx1", ROMREGION_DISPOSE )
1957   ROM_LOAD( "o17_05.12j",  0x00000, 0x20000, CRC(565315f8) SHA1(6b1c5ef52359483228b329c89c2e1174e3fbf017) )
1958   ROM_LOAD( "o17_06.13j",  0x20000, 0x20000, CRC(95262d4c) SHA1(16f3aabecb1c87ce7eadf4f0ff61b29a4c017614) )
1959   ROM_LOAD( "o17_07.12l",  0x40000, 0x20000, CRC(4c4b735c) SHA1(812c3bf46bd7764b2bb812bd2b9eb0331ed257ae) )
1960   ROM_LOAD( "o17_08.13l",  0x60000, 0x20000, CRC(95c6586c) SHA1(ff87901f79d80f73ad09664b0c0d892898570616) )
1961
1962   ROM_REGION( 0x80000, "gfx2", ROMREGION_DISPOSE )
1963   ROM_LOAD( "o17_01.1d",  0x00000, 0x20000, CRC(ea12e491) SHA1(02190722b7c5383471e0af9596be7039a5367240) )
1964   ROM_LOAD( "o17_02.3d",  0x20000, 0x20000, CRC(32a13a9f) SHA1(1446acdfd21cd41f3d97aaf30f498c0c5d890605) )
1965   ROM_LOAD( "o17_03.5d",  0x40000, 0x20000, CRC(68723dc9) SHA1(4f1b7aa2469c955e03737b611a7d2524f1e4f61e) )
1966   ROM_LOAD( "o17_04.7d",  0x60000, 0x20000, CRC(fe0ecb13) SHA1(634a49262b9c092c25f11b14c6757fe94ea9eddc) )
1967
1968   ROM_REGION( 0x40, "proms", 0 )      /* nibble bproms, lo/hi order to be determined */
1969   ROM_LOAD( "prom14.25b",  0x00, 0x20, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) )   /* sprite attribute (flip/position) ?? */
1970   ROM_LOAD( "prom15.20c",  0x20, 0x20, CRC(a1e17492) SHA1(9ddec4c97f2d541f69f3c32c47aaa21fd9699ae2) )   /* ??? */
1971ROM_END
1972
1973ROM_START( fireshd )
1974   ROM_REGION( 0x080000, "main", 0 )   /* Main 68K code */
1975   ROM_LOAD16_BYTE( "o17_09dyn.8j",0x000000, 0x10000, CRC(e25eee27) SHA1(1ff3f838123180a0b6672c9beee6c0f0092a0f94) )
1976   ROM_LOAD16_BYTE( "o17_10dyn.8l",0x000001, 0x10000, CRC(c4c58cf6) SHA1(5867ecf66cd6c16cfcc54a581d3f4a8b666fd839) )
1977   ROM_LOAD16_BYTE( "o17_11ii.7j", 0x040000, 0x20000, CRC(6beac378) SHA1(041ba98a89a4bac32575858db8a061bdf7804594) )
1978   ROM_LOAD16_BYTE( "o17_12ii.7l", 0x040001, 0x20000, CRC(6adb6eb5) SHA1(9b6e63aa50d271c2bb0b4cf822fc6f3684f10230) )
1979
1980   ROM_REGION( 0x10000, "cpu1", 0 )   /* Sound HD647180 code */
1981   /* sound CPU is a HD647180 (Z180) with internal ROM - not yet supported */
1982   ROM_LOAD( "hd647180.017",  0x00000, 0x08000, NO_DUMP )
1983
1984   ROM_REGION( 0x80000, "gfx1", ROMREGION_DISPOSE )
1985   ROM_LOAD( "o17_05.12j",  0x00000, 0x20000, CRC(565315f8) SHA1(6b1c5ef52359483228b329c89c2e1174e3fbf017) )
1986   ROM_LOAD( "o17_06.13j",  0x20000, 0x20000, CRC(95262d4c) SHA1(16f3aabecb1c87ce7eadf4f0ff61b29a4c017614) )
1987   ROM_LOAD( "o17_07.12l",  0x40000, 0x20000, CRC(4c4b735c) SHA1(812c3bf46bd7764b2bb812bd2b9eb0331ed257ae) )
1988   ROM_LOAD( "o17_08.13l",  0x60000, 0x20000, CRC(95c6586c) SHA1(ff87901f79d80f73ad09664b0c0d892898570616) )
1989
1990   ROM_REGION( 0x80000, "gfx2", ROMREGION_DISPOSE )
1991   ROM_LOAD( "o17_01.1d",  0x00000, 0x20000, CRC(ea12e491) SHA1(02190722b7c5383471e0af9596be7039a5367240) )
1992   ROM_LOAD( "o17_02.3d",  0x20000, 0x20000, CRC(32a13a9f) SHA1(1446acdfd21cd41f3d97aaf30f498c0c5d890605) )
1993   ROM_LOAD( "o17_03.5d",  0x40000, 0x20000, CRC(68723dc9) SHA1(4f1b7aa2469c955e03737b611a7d2524f1e4f61e) )
1994   ROM_LOAD( "o17_04.7d",  0x60000, 0x20000, CRC(fe0ecb13) SHA1(634a49262b9c092c25f11b14c6757fe94ea9eddc) )
1995
1996   ROM_REGION( 0x40, "proms", 0 )      /* nibble bproms, lo/hi order to be determined */
1997   ROM_LOAD( "prom14.25b",  0x00, 0x20, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) )   /* sprite attribute (flip/position) ?? */
1998   ROM_LOAD( "prom15.20c",  0x20, 0x20, CRC(a1e17492) SHA1(9ddec4c97f2d541f69f3c32c47aaa21fd9699ae2) )   /* ??? */
1999ROM_END
2000
2001ROM_START( fireshdh )
2002   ROM_REGION( 0x080000, "main", 0 )   /* Main 68K code */
2003   ROM_LOAD16_BYTE( "o17_09dyh.8j",0x000000, 0x10000, CRC(7b4c14dd) SHA1(d40dcf223f16c0f507aeb282d1524dbf1349c536) )
2004   ROM_LOAD16_BYTE( "o17_10dyh.8l",0x000001, 0x10000, CRC(a3f159f9) SHA1(afc9630ca38da730f7cf4954d1333954e8d75787) )
19482005   ROM_LOAD16_BYTE( "o17_11x.bin", 0x040000, 0x20000, CRC(6beac378) SHA1(041ba98a89a4bac32575858db8a061bdf7804594) )
19492006   ROM_LOAD16_BYTE( "o17_12x.bin", 0x040001, 0x20000, CRC(6adb6eb5) SHA1(9b6e63aa50d271c2bb0b4cf822fc6f3684f10230) )
19502007
r3485r3486
19532010   ROM_LOAD( "hd647180.017",  0x00000, 0x08000, NO_DUMP )
19542011
19552012   ROM_REGION( 0x80000, "gfx1", ROMREGION_DISPOSE )
1956   ROM_LOAD( "o17_05.bin",  0x00000, 0x20000, CRC(565315f8) SHA1(6b1c5ef52359483228b329c89c2e1174e3fbf017) )
1957   ROM_LOAD( "o17_06.bin",  0x20000, 0x20000, CRC(95262d4c) SHA1(16f3aabecb1c87ce7eadf4f0ff61b29a4c017614) )
1958   ROM_LOAD( "o17_07.bin",  0x40000, 0x20000, CRC(4c4b735c) SHA1(812c3bf46bd7764b2bb812bd2b9eb0331ed257ae) )
1959   ROM_LOAD( "o17_08.bin",  0x60000, 0x20000, CRC(95c6586c) SHA1(ff87901f79d80f73ad09664b0c0d892898570616) )
2013   ROM_LOAD( "o17_05.12j",  0x00000, 0x20000, CRC(565315f8) SHA1(6b1c5ef52359483228b329c89c2e1174e3fbf017) )
2014   ROM_LOAD( "o17_06.13j",  0x20000, 0x20000, CRC(95262d4c) SHA1(16f3aabecb1c87ce7eadf4f0ff61b29a4c017614) )
2015   ROM_LOAD( "o17_07.12l",  0x40000, 0x20000, CRC(4c4b735c) SHA1(812c3bf46bd7764b2bb812bd2b9eb0331ed257ae) )
2016   ROM_LOAD( "o17_08.13l",  0x60000, 0x20000, CRC(95c6586c) SHA1(ff87901f79d80f73ad09664b0c0d892898570616) )
19602017
19612018   ROM_REGION( 0x80000, "gfx2", ROMREGION_DISPOSE )
1962   ROM_LOAD( "o17_01.bin",  0x00000, 0x20000, CRC(ea12e491) SHA1(02190722b7c5383471e0af9596be7039a5367240) )
1963   ROM_LOAD( "o17_02.bin",  0x20000, 0x20000, CRC(32a13a9f) SHA1(1446acdfd21cd41f3d97aaf30f498c0c5d890605) )
1964   ROM_LOAD( "o17_03.bin",  0x40000, 0x20000, CRC(68723dc9) SHA1(4f1b7aa2469c955e03737b611a7d2524f1e4f61e) )
1965   ROM_LOAD( "o17_04.bin",  0x60000, 0x20000, CRC(fe0ecb13) SHA1(634a49262b9c092c25f11b14c6757fe94ea9eddc) )
2019   ROM_LOAD( "o17_01.1d",  0x00000, 0x20000, CRC(ea12e491) SHA1(02190722b7c5383471e0af9596be7039a5367240) )
2020   ROM_LOAD( "o17_02.3d",  0x20000, 0x20000, CRC(32a13a9f) SHA1(1446acdfd21cd41f3d97aaf30f498c0c5d890605) )
2021   ROM_LOAD( "o17_03.5d",  0x40000, 0x20000, CRC(68723dc9) SHA1(4f1b7aa2469c955e03737b611a7d2524f1e4f61e) )
2022   ROM_LOAD( "o17_04.7d",  0x60000, 0x20000, CRC(fe0ecb13) SHA1(634a49262b9c092c25f11b14c6757fe94ea9eddc) )
19662023
19672024   ROM_REGION( 0x40, "proms", 0 )      /* nibble bproms, lo/hi order to be determined */
1968   ROM_LOAD( "tp017_13.bpr",  0x00, 0x20, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) )   /* sprite attribute (flip/position) ?? */
1969   ROM_LOAD( "tp017_14.bpr",  0x20, 0x20, CRC(a1e17492) SHA1(9ddec4c97f2d541f69f3c32c47aaa21fd9699ae2) )   /* ??? */
2025   ROM_LOAD( "prom14.25b",  0x00, 0x20, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) )   /* sprite attribute (flip/position) ?? */
2026   ROM_LOAD( "prom15.20c",  0x20, 0x20, CRC(a1e17492) SHA1(9ddec4c97f2d541f69f3c32c47aaa21fd9699ae2) )   /* ??? */
19702027ROM_END
19712028
2029
19722030/*
19732031Out Zone - Seems to be a later version, Differences:
19742032
r3485r3486
21962254GAME( 1989, demonwl3, demonwld, demonwld, demonwl1, demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (set 4)", 0 )
21972255GAME( 1989, demonwl4, demonwld, demonwld, demonwl1, demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (set 5)", 0 )
21982256GAME( 1990, fireshrk, 0,        samesame, fireshrk, toaplan1, ROT270, "Toaplan", "Fire Shark", GAME_NO_SOUND )
2199GAME( 1989, samesame, fireshrk, samesame, samesame, toaplan1, ROT270, "Toaplan", "Same! Same! Same!", GAME_NO_SOUND )
2200GAME( 1989, samesam2, fireshrk, samesame, samesam2, toaplan1, ROT270, "Toaplan", "Same! Same! Same! (2P Ver.)", GAME_NO_SOUND )
2257GAME( 1990, fireshd,  fireshrk, samesame, samesam2, toaplan1, ROT270, "Toaplan (Dooyong license)", "Fire Shark (Korea, set 1, easier)", GAME_NO_SOUND )
2258GAME( 1990, fireshdh, fireshrk, samesame, samesam2, toaplan1, ROT270, "Toaplan (Dooyong license)", "Fire Shark (Korea, set 2, harder)", GAME_NO_SOUND )
2259GAME( 1989, samesame, fireshrk, samesame, samesame, toaplan1, ROT270, "Toaplan", "Same! Same! Same! (2 player alternating ver.)", GAME_NO_SOUND )
2260GAME( 1989, samesam2, fireshrk, samesame, samesam2, toaplan1, ROT270, "Toaplan", "Same! Same! Same!", GAME_NO_SOUND )
22012261GAME( 1990, outzone,  0,        outzone,  outzone,  toaplan1, ROT270, "Toaplan", "Out Zone (set 1)", 0 ) // later fixed version
22022262GAME( 1990, outzonea, outzone,  outzone,  outzone,  toaplan1, ROT270, "Toaplan", "Out Zone (set 2)", 0 )
22032263GAME( 1990, outzoneb, outzone,  outzone,  outzoneb, toaplan1, ROT270, "Toaplan", "Out Zone (set 3, prototype?)", 0 ) // early revision at least
src/mame/drivers/ddealer.c
r3485r3486
11/*
22Double Dealer (c)NMK 1991
33
4Based on jalmah.c and nmk.c drivers
5Skeleton driver by Tomasz Slanina
6Protection vectors provided by Angelo Salese
4driver by Angelo Salese & David Haywood,based on early work by Tomasz Slanina
75
6Appears to be a down-grade of the nmk16 HW
7
88TODO:
9-check Video Registers memory at 0x8c1e0-0x8c1ef.They appear to control cards movements,game should be in a playable state;
10-finish the vector protection;
11-implement coin simulation;
12-merge this with the nmk16 driver.Appears to be similar to Hacha Mecha Fighter
9-When you use the "gun card" the game gives "minus" points,but points are always added,inaccurate protection?
10-Understand better the video emulation and convert it to tilemaps;
11-A Double Dealer manual is needed for the coinage settings and coin/credit simulation;
12-Decap + emulate MCU, required if the random number generation is going to be accurate;
1313
14
1514--
1615
1716pcb marked  GD91071
1817
191868000P10
2019YM2203C
2191071-3 (????) marked as "3" on the pcb
2091071-3 (Mask ROM)
2221NMK-110 8131 ( Mitsubishi M50747 MCU ?)
2322NMK 901
2423NMK 902
r3485r3486
112111
113112#include "driver.h"
114113#include "cpu/m68000/m68000.h"
114#include "sound/2203intf.h"
115115
116static UINT16 *mcu_shared_ram;
117static UINT16 *sc3_vram,*sc0_vram;
116static UINT16 *mcu_shared_ram,*work_ram;
117static UINT16 *back_vram,*left_fg_vram_top, *right_fg_vram_top, *right_fg_vram_bottom, *left_fg_vram_bottom;
118118static UINT16 *ddealer_vregs;
119static tilemap *sc3_tilemap,*sc0_tilemap;
120
119static tilemap *back_tilemap;
121120static int respcount;
121static int ddealer_flipscreen;
122122
123static TILEMAP_MAPPER( bg_scan )
123static WRITE16_HANDLER( ddealer_flipscreen_w )
124124{
125   /* logical (col,row) -> memory offset */
126   return (row & 0x0f) + ((col & 0xff) << 4) + ((row & 0x70) << 8);
125   ddealer_flipscreen = data & 0x01;
127126}
128127
129static TILE_GET_INFO( get_sc0_tile_info )
128static TILE_GET_INFO( get_back_tile_info )
130129{
131   int code = sc0_vram[tile_index];
130   int code = back_vram[tile_index];
132131   SET_TILE_INFO(
133         1,
134         code & 0xfff,
135         code >> 12,
136         0);
137}
138
139static TILE_GET_INFO( get_sc3_tile_info )
140{
141   int code = sc3_vram[tile_index];
142   SET_TILE_INFO(
143132         0,
144133         code & 0xfff,
145134         code >> 12,
r3485r3486
148137
149138static VIDEO_START( ddealer )
150139{
151   sc3_tilemap = tilemap_create(get_sc3_tile_info,tilemap_scan_cols,8,8,64,32);
152   sc0_tilemap = tilemap_create(get_sc0_tile_info,bg_scan,16,16,256,32);
153
154   tilemap_set_transparent_pen(sc0_tilemap,15);
140   ddealer_flipscreen = 0;
141   back_tilemap = tilemap_create(get_back_tile_info,tilemap_scan_cols,8,8,64,32);
155142}
156143
157#if 0
158static void ddealer_protection(running_machine *machine)
144static void ddealer_draw_video_layer( UINT16* vreg_base, UINT16* top, UINT16* bottom, bitmap_t* bitmap, const rectangle *cliprect, int flipy)
159145{
146   const gfx_element *gfx = Machine->gfx[1];
160147
161   if(prot==0)
162148   {
163      shared_ram[0xe000/2]=0x4ef9;
164      shared_ram[0xe002/2]=0x0000;
165      shared_ram[0xe004/2]=0x0796;
166   }
149      INT16 sx, sy;
150      int x,y, count;
151      UINT16* src;
167152
168   shared_ram[0xe008/2]=0x0001;
169   shared_ram[0xe00a/2]=0x0001;
170   shared_ram[0xe00c/2]=0x0001;
171   shared_ram[0xe00e/2]=0x0001;
153      sx =  ((vreg_base[0x4/2] & 0xff));
154      sx |= ((vreg_base[0x2/2] & 0xff) << 8);
172155
173   shared_ram[0xe010/2]=mame_rand(machine) & 0xffff;
174   shared_ram[0xe012/2]=mame_rand(machine) & 0xffff;
175   shared_ram[0xe014/2]=mame_rand(machine) & 0xffff;
176   shared_ram[0xe016/2]=mame_rand(machine) & 0xffff;
156      sx &=0x7ff;
157      if (sx & 0x400) sx-=0x800;
177158
159      sy =  ((vreg_base[0x8/2] & 0xff));
160      sy |= ((vreg_base[0x6/2] & 0xff) << 8);
161
162
163      if (!flipy)
164      {
165         sx -= 64; // video shift
166
167
168         /* the tilemaps seems to be split into top / bottom pieces */
169         count = 0;
170         src = top;
171         for (x=0;x<128;x++)
172         {
173            for (y=0;y<16;y++)
174            {
175               UINT16 tile = (src[count]&0x0fff);
176               UINT16 colr = (src[count]&0xf000)>>12;
177               count++;
178               drawgfx(bitmap,gfx,tile,colr,0,flipy,(x*16)-sx,(y*16)-sy,cliprect,TRANSPARENCY_PEN,15);
179            }
180         }
181         count = 0;
182         src = bottom;
183         sy -= 256;
184         for (x=0;x<128;x++)
185         {
186            for (y=0;y<16;y++)
187            {
188               UINT16 tile = (src[count]&0x0fff);
189               UINT16 colr = (src[count]&0xf000)>>12;
190               count++;
191               drawgfx(bitmap,gfx,tile,colr,0,flipy,(x*16)-sx,(y*16)-sy,cliprect,TRANSPARENCY_PEN,15);
192            }
193         }
194      }
195      else
196      {
197         sx -= 0x6d0;
198         sy -= 16;
199
200         /* the tilemaps seems to be split into top / bottom pieces */
201         count = 0;
202         src = top;
203         for (x=128;x>0;x--)
204         {
205            for (y=16;y>0;y--)
206            {
207               UINT16 tile = (src[count]&0x0fff);
208               UINT16 colr = (src[count]&0xf000)>>12;
209               count++;
210               drawgfx(bitmap,gfx,tile,colr,flipy,flipy,(x*16)+sx,(y*16)+sy,cliprect,TRANSPARENCY_PEN,15);
211            }
212         }
213         count = 0;
214         src = bottom;
215         sy -= 256;
216         for (x=128;x>0;x--)
217         {
218            for (y=16;y>0;y--)
219            {
220               UINT16 tile = (src[count]&0x0fff);
221               UINT16 colr = (src[count]&0xf000)>>12;
222               count++;
223               drawgfx(bitmap,gfx,tile,colr,flipy,flipy,(x*16)+sx,(y*16)+sy,cliprect,TRANSPARENCY_PEN,15);
224            }
225         }
226      }
227   }
178228}
179#endif
180229
230
181231static VIDEO_UPDATE( ddealer )
182232{
183   tilemap_set_scrollx( sc3_tilemap, 0, -64);
233   tilemap_set_scrollx( back_tilemap, 0, ddealer_flipscreen? -192: -64);
234   tilemap_set_flip(back_tilemap, ddealer_flipscreen? TILEMAP_FLIPY|TILEMAP_FLIPX:0);
235   tilemap_draw(bitmap,cliprect,back_tilemap,0,0);
184236
185   tilemap_draw(bitmap,cliprect,sc3_tilemap,0,0);
186   tilemap_draw(bitmap,cliprect,sc0_tilemap,0,0);
237   /* the fg tilemap handling is a little hacky right now,
238       i'm not sure if it should be a single tilemap with
239       rowscroll / linescroll, or two tilemaps which can be
240       combined, the flipscreen case makes things more
241       difficult to understand */
187242
188   /*temporary*/
189   if(input_code_pressed_once(KEYCODE_Z))
190      mcu_shared_ram[0x000/2]++;
243   if (!ddealer_flipscreen)
244   {
245      if (ddealer_vregs[0xcc/2] & 0x80)
246      {
247         ddealer_draw_video_layer(&ddealer_vregs[0x1e0/2], left_fg_vram_top, left_fg_vram_bottom, bitmap, cliprect, ddealer_flipscreen);
248         ddealer_draw_video_layer(&ddealer_vregs[0xcc/2], right_fg_vram_top, right_fg_vram_bottom, bitmap, cliprect, ddealer_flipscreen);
249      }
250      else
251      {
252         ddealer_draw_video_layer(&ddealer_vregs[0x1e0/2], left_fg_vram_top, left_fg_vram_bottom, bitmap, cliprect, ddealer_flipscreen);
253      }
254   }
255   else
256   {
257      if (ddealer_vregs[0xcc/2] & 0x80)
258      {
259         ddealer_draw_video_layer(&ddealer_vregs[0xcc/2], left_fg_vram_top, left_fg_vram_bottom, bitmap, cliprect, ddealer_flipscreen);
260         ddealer_draw_video_layer(&ddealer_vregs[0x1e0/2], right_fg_vram_top, right_fg_vram_bottom, bitmap, cliprect, ddealer_flipscreen);
261      }
262      else
263      {
264         ddealer_draw_video_layer(&ddealer_vregs[0x1e0/2], left_fg_vram_top, left_fg_vram_bottom, bitmap, cliprect, ddealer_flipscreen);
265      }
266
267   }
268
191269   return 0;
192270}
193271
194WRITE16_HANDLER( sc3_vram_w )
272static TIMER_DEVICE_CALLBACK( ddealer_mcu_sim )
195273{
196   int oldword = sc3_vram[offset];
197   int newword = oldword;
198   COMBINE_DATA(&newword);
274   /*coin/credit simulation*/
275   /*$fe002 is used,might be for multiple coins for one credit settings.*/
276   static UINT8 input_pressed;
277   static UINT16 coin_input;
199278
200   if (oldword != newword)
279   coin_input = (~(input_port_read(timer->machine, "IN0")));
280
281   if(coin_input & 0x01)//coin 1
201282   {
202      sc3_vram[offset] = newword;
203      tilemap_mark_tile_dirty(sc3_tilemap,offset);
283      if((input_pressed & 0x01) == 0)
284         mcu_shared_ram[0x000/2]++;
285      input_pressed = (input_pressed & 0xfe) | 1;
204286   }
205}
287   else
288      input_pressed = (input_pressed & 0xfe);
206289
290   if(coin_input & 0x02)//coin 2
291   {
292      if((input_pressed & 0x02) == 0)
293         mcu_shared_ram[0x000/2]++;
294      input_pressed = (input_pressed & 0xfd) | 2;
295   }
296   else
297      input_pressed = (input_pressed & 0xfd);
207298
208WRITE16_HANDLER( sc0_vram_w )
209{
210   int oldword = sc0_vram[offset];
211   int newword = oldword;
212   COMBINE_DATA(&newword);
299   if(coin_input & 0x04)//service 1
300   {
301      if((input_pressed & 0x04) == 0)
302         mcu_shared_ram[0x000/2]++;
303      input_pressed = (input_pressed & 0xfb) | 4;
304   }
305   else
306      input_pressed = (input_pressed & 0xfb);
213307
214   if (oldword != newword)
308   /*0x104/2 is some sort of "start-lock",i.e. used on the girl selection.
309      Without it,the game "steals" one credit if you press the start button on that.*/
310   if(mcu_shared_ram[0x000/2] > 0 && work_ram[0x104/2] & 1)
215311   {
216      sc0_vram[offset] = newword;
217      tilemap_mark_tile_dirty(sc0_tilemap,offset);
312      if(coin_input & 0x08)//start 1
313      {
314         if((input_pressed & 0x08) == 0 && (~(work_ram[0x100/2] & 1)))
315            mcu_shared_ram[0x000/2]--;
316         input_pressed = (input_pressed & 0xf7) | 8;
317      }
318      else
319         input_pressed = (input_pressed & 0xf7);
320
321      if(coin_input & 0x10)//start 2
322      {
323         if((input_pressed & 0x10) == 0 && (~(work_ram[0x100/2] & 2)))
324            mcu_shared_ram[0x000/2]--;
325         input_pressed = (input_pressed & 0xef) | 0x10;
326      }
327      else
328         input_pressed = (input_pressed & 0xef);
218329   }
330
331   /*random number generators,controls order of cards*/
332   mcu_shared_ram[0x10/2] = mame_rand(timer->machine) & 0xffff;
333   mcu_shared_ram[0x12/2] = mame_rand(timer->machine) & 0xffff;
334   mcu_shared_ram[0x14/2] = mame_rand(timer->machine) & 0xffff;
335   mcu_shared_ram[0x16/2] = mame_rand(timer->machine) & 0xffff;
219336}
220337
338
339
340WRITE16_HANDLER( back_vram_w )
341{
342   COMBINE_DATA(&back_vram[offset]);
343   tilemap_mark_tile_dirty(back_tilemap,offset);
344}
345
346
221347WRITE16_HANDLER( ddealer_vregs_w )
222348{
223349   COMBINE_DATA(&ddealer_vregs[offset]);
224350}
225351
352/******************************************************************************************************
353
354Protection handling,identical to Hacha Mecha Fighter / Thunder Dragon with different vectors.
355
356******************************************************************************************************/
357
226358#define PROT_JSR(_offs_,_protvalue_,_pc_) \
227359   if(mcu_shared_ram[(_offs_)/2] == _protvalue_) \
228360   { \
r3485r3486
245377
246378   switch(offset)
247379   {
248      /*
249            shared_ram[0xe490/2]=0x4ef9;
250            shared_ram[0xe492/2]=0x0000;
251            shared_ram[0xe494/2]=0x9696;// write to tx tilemap
252            shared_ram[0xe4a0/2]=0x4ef9;
253            shared_ram[0xe4a2/2]=0x0000;
254            shared_ram[0xe4a4/2]=0x95fe;// write to bg tilemap,might be 0x9634
255            shared_ram[0xe4c0/2]=0x4ef9;
256            shared_ram[0xe4c2/2]=0x0000;
257            shared_ram[0xe4c4/2]=0x9634;// unsure about this,tx tilemap
258            shared_ram[0xe4e0/2]=0x4ef9;
259            shared_ram[0xe4e2/2]=0x0000;
260            shared_ram[0xe4e4/2]=0x5ac6;//palette ram buffer
261        */
262380      case 0x086/2: PROT_INPUT(0x086/2,0x1234,0x100/2,0x80000); break;
263381      case 0x164/2: PROT_INPUT(0x164/2,0x5678,0x104/2,0x80002); break;
264382      case 0x62e/2: PROT_INPUT(0x62e/2,0x9ca3,0x108/2,0x80008); break;
265383      case 0x734/2: PROT_INPUT(0x734/2,0xaba2,0x10c/2,0x8000a); break;
384/*These enables something for sure,maybe the random number generator?*/
266385 //00054C: 33FC B891 000F E828        move.w  #$b891, $fe828.l
267386 //000554: 33FC C760 000F E950        move.w  #$c760, $fe950.l
268387 //00055C: 33FC D45F 000F EA7C        move.w  #$d45f, $fea7c.l
269388 //000564: 33FC E32E 000F ED4A        move.w  #$e32e, $fed4a.l
270//006992-7348-7518
271/*
272fe400->score sub-routine
273fe410-><unused>
274fe420->called before you enter into the gameplay,cards initialize? a39a will break lots of things
275fe430->called in some circumstances after 420 (ASM-wise)
276fe440->called during attract
277389
278fe470->called when it should update the graphics
279A0 = f3072
280A2 = 9cf4c
281A3 = 9ce9c
282
2836176 is the player 2
284
285work ram addresses
286f031e->
287f3010->mirror for inputs player 1
288f5010->mirror for inputs player 2
289*/
290
291      case 0x40e/2: PROT_JSR(0x40e,0x8011,0x6992);//0x89e); break;//0x6992); break;
390      case 0x40e/2: PROT_JSR(0x40e,0x8011,0x6992); break;//score
292391      case 0x41e/2: break;//unused
293      case 0x42e/2: PROT_JSR(0x42e,0x8007,0x6004); break;//0x89e); break;//0xa39a); break;
294      case 0x43e/2: PROT_JSR(0x43e,0x801d,0x89e);  break;//0x62f2); break;//0x6176); break;//0x6ebe); break;//0x9b6);  break;//801d
295      case 0x44e/2: PROT_JSR(0x44e,0x8028,0x68f6); break;
296      case 0x45e/2: PROT_JSR(0x45e,0x803e,0x6f90); break;
297      case 0x46e/2: PROT_JSR(0x46e,0x8033,0x93c2); break;
298      case 0x47e/2: PROT_JSR(0x47e,0x8026,0x89e);  break;//0x6786); break; //wrong,just to let pass the check
299      case 0x48e/2: PROT_JSR(0x48e,0x8012,0x6176); break;
300/**/   case 0x49e/2: PROT_JSR(0x49e,0x8004,0x9696); break;
301      case 0x4ae/2: PROT_JSR(0x4ae,0x8035,0x95fe); break;
302      case 0x4be/2: PROT_JSR(0x4be,0x8009,0x89e);  break;//0xa74);  break; //wrong
303/**/   case 0x4ce/2: PROT_JSR(0x4ce,0x802a,0x9656); break;//z
392      case 0x42e/2: PROT_JSR(0x42e,0x8007,0x6004); break;//cards on playfield/hand (ram side)
393      case 0x43e/2: PROT_JSR(0x43e,0x801d,0x6176); break;//second player sub-routine
394      case 0x44e/2: PROT_JSR(0x44e,0x8028,0x6932); break;//"gun card" logic
395      case 0x45e/2: PROT_JSR(0x45e,0x803e,0x6f90); break;//card delete
396      case 0x46e/2: PROT_JSR(0x46e,0x8033,0x93c2); break;//card movements
397      case 0x47e/2: PROT_JSR(0x47e,0x8026,0x67a0); break;//cards on playfield (vram side)
398      case 0x48e/2: PROT_JSR(0x48e,0x8012,0x6824); break;//cards on hand (vram side)
399      case 0x49e/2: PROT_JSR(0x49e,0x8004,0x9696); break;//write to text layer
400      case 0x4ae/2: PROT_JSR(0x4ae,0x8035,0x95fe); break;//write to scroll layer
401      case 0x4be/2: PROT_JSR(0x4be,0x8009,0x9634); break;//show girls sub-routine
402      case 0x4ce/2: PROT_JSR(0x4ce,0x802a,0x9656); break;
304403      case 0x4de/2: PROT_JSR(0x4de,0x803b,0x96c2); break;
305/**/   case 0x4ee/2: PROT_JSR(0x4ee,0x800c,0x5ca4); break;//correct
306      case 0x4fe/2: PROT_JSR(0x4fe,0x8018,0x6004); break;//0x9818); break;//6004?
404      case 0x4ee/2: PROT_JSR(0x4ee,0x800c,0x5ca4); break;//palette ram buffer
405      case 0x4fe/2: PROT_JSR(0x4fe,0x8018,0x9818); break;
406      /*Start-up vector,I think that only the first ram address can be written by the main CPU,or it is a whole sequence.*/
307407      case 0x000/2:
308408         if(mcu_shared_ram[0x000/2] == 0x60fe)
309409         {
310            mcu_shared_ram[0x000/2] = 0x0000;
311            mcu_shared_ram[0x002/2] = 0x0000;
410            mcu_shared_ram[0x000/2] = 0x0000;//coin counter
411            mcu_shared_ram[0x002/2] = 0x0000;//coin counter "decimal point"
312412            mcu_shared_ram[0x004/2] = 0x4ef9;
313//              mcu_shared_ram[0x006/2] = 0x0000;
314//              mcu_shared_ram[0x008/2] = 0x0000;
315//              mcu_shared_ram[0x00a/2] = 0x0000;
316//              mcu_shared_ram[0x00c/2] = 0x0000;
317//              mcu_shared_ram[0x00e/2] = 0x0000;
318413         }
319414         break;
320415      case 0x002/2:
321416      case 0x004/2:
322         if(mcu_shared_ram[0x002/2] == 0x0000 && mcu_shared_ram[0x004/2] == 0x0214) //<- he believes to be astute...
323            mcu_shared_ram[0x004/2] = 0x4ef9;//0604
417         if(mcu_shared_ram[0x002/2] == 0x0000 && mcu_shared_ram[0x004/2] == 0x0214)
418            mcu_shared_ram[0x004/2] = 0x4ef9;
324419         break;
325420      case 0x008/2:
326421         if(mcu_shared_ram[0x008/2] == 0x000f)
r3485r3486
332427   }
333428}
334429
430static WRITE16_HANDLER( YM2203_w )
431{
432   switch (offset) {
433   case 0: ym2203_control_port_0_w(machine,0,data & 0xff); break;
434   case 1: ym2203_write_port_0_w(machine,0,data & 0xff); break;
435   }
436}
437
335438static ADDRESS_MAP_START( ddealer, ADDRESS_SPACE_PROGRAM, 16 )
336439   AM_RANGE(0x000000, 0x03ffff) AM_ROM
337440   AM_RANGE(0x080000, 0x080001) AM_READ_PORT("IN0")
338441   AM_RANGE(0x080002, 0x080003) AM_READ_PORT("IN1")
339442   AM_RANGE(0x080008, 0x080009) AM_READ_PORT("DSW1")
340443   AM_RANGE(0x08000a, 0x08000b) AM_READ_PORT("UNK")
341   AM_RANGE(0x084000, 0x084003) AM_RAM // ym ?
444   AM_RANGE(0x084000, 0x084003) AM_WRITE( YM2203_w ) // ym ?
342445   AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBRGBx_word_w) AM_BASE(&paletteram16) // palette ram
343446   AM_RANGE(0x08c000, 0x08cfff) AM_RAM_WRITE(ddealer_vregs_w) AM_BASE(&ddealer_vregs) // palette ram
344   AM_RANGE(0x090000, 0x093fff) AM_RAM_WRITE(sc0_vram_w) AM_BASE(&sc0_vram) // bg tilemap
345   AM_RANGE(0x09c000, 0x09ffff) AM_RAM_WRITE(sc3_vram_w) AM_BASE(&sc3_vram) // fg tilemap
346   AM_RANGE(0x0f0000, 0x0fdfff) AM_RAM
447
448   /* this might actually be 1 tilemap with some funky rowscroll / columnscroll enabled, I'm not sure */
449   AM_RANGE(0x090000, 0x090fff) AM_RAM AM_BASE(&left_fg_vram_top)
450   AM_RANGE(0x091000, 0x091fff) AM_RAM AM_BASE(&right_fg_vram_top)
451   AM_RANGE(0x092000, 0x092fff) AM_RAM AM_BASE(&left_fg_vram_bottom)
452   AM_RANGE(0x093000, 0x093fff) AM_RAM AM_BASE(&right_fg_vram_bottom)
453   //AM_RANGE(0x094000, 0x094001) AM_NOP // always 0?
454   AM_RANGE(0x098000, 0x098001) AM_WRITE(ddealer_flipscreen_w)
455   AM_RANGE(0x09c000, 0x09cfff) AM_RAM_WRITE(back_vram_w) AM_BASE(&back_vram) // bg tilemap
456   AM_RANGE(0x0f0000, 0x0fdfff) AM_RAM AM_BASE(&work_ram)
347457   AM_RANGE(0x0fe000, 0x0fefff) AM_RAM_WRITE(ddealer_mcu_shared_w) AM_BASE(&mcu_shared_ram)
348458   AM_RANGE(0x0ff000, 0x0fffff) AM_RAM
349459ADDRESS_MAP_END
350460
351/*copied from hachamf*/
352461static INPUT_PORTS_START( ddealer )
353462   PORT_START("IN0")
354463   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
r3485r3486
356465   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
357466   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
358467   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
359   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
468   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) //used,"test" in service mode,unknown purpose
360469   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
361   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) //bryan:  test mode in some games?
470   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
362471
363472   PORT_START("IN1")
364473   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
r3485r3486
378487   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_UNKNOWN )
379488   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_UNKNOWN )
380489
490   /*bits 0-7 are almost surely to be coinage.*/
381491   PORT_START("DSW1")
382   PORT_DIPNAME( 0x0700, 0x0700, DEF_STR( Coin_A ) )
383   PORT_DIPSETTING(    0x0100, DEF_STR( 4C_1C ) )
384   PORT_DIPSETTING(    0x0200, DEF_STR( 3C_1C ) )
385   PORT_DIPSETTING(    0x0300, DEF_STR( 2C_1C ) )
386   PORT_DIPSETTING(    0x0700, DEF_STR( 1C_1C ) )
387   PORT_DIPSETTING(    0x0600, DEF_STR( 1C_2C ) )
388   PORT_DIPSETTING(    0x0500, DEF_STR( 1C_3C ) )
389   PORT_DIPSETTING(    0x0400, DEF_STR( 1C_4C ) )
390   PORT_DIPSETTING(    0x0000, DEF_STR( Free_Play ) )
391   PORT_DIPNAME( 0x3800, 0x3800, DEF_STR( Coin_B ) )
392   PORT_DIPSETTING(    0x0800, DEF_STR( 4C_1C ) )
393   PORT_DIPSETTING(    0x1000, DEF_STR( 3C_1C ) )
394   PORT_DIPSETTING(    0x1800, DEF_STR( 2C_1C ) )
395   PORT_DIPSETTING(    0x3800, DEF_STR( 1C_1C ) )
396   PORT_DIPSETTING(    0x3000, DEF_STR( 1C_2C ) )
397   PORT_DIPSETTING(    0x2800, DEF_STR( 1C_3C ) )
398   PORT_DIPSETTING(    0x2000, DEF_STR( 1C_4C ) )
399   PORT_DIPSETTING(    0x0000, DEF_STR( Free_Play ) )
400   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
401   PORT_DIPSETTING(    0x4000, DEF_STR( Off ) )
402   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
403   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
404   PORT_DIPSETTING(    0x8000, DEF_STR( Off ) )
405   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
406
407492   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
408493   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
409494   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
410   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Language ) )
411   PORT_DIPSETTING(    0x00, DEF_STR( English ) )
412   PORT_DIPSETTING(    0x02, DEF_STR( Japanese ) )
413   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Difficulty ) )
414   PORT_DIPSETTING(    0x04, DEF_STR( Easy ) )
415   PORT_DIPSETTING(    0x0c, DEF_STR( Normal ) )
416   PORT_DIPSETTING(    0x08, DEF_STR( Hard ) )
417   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
495   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
496   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
497   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
498   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
499   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
500   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
501   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
502   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
503   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
418504   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
419505   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
420506   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
421507   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
422508   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
423509   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
424   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Lives ) )
425   PORT_DIPSETTING(    0x00, "1" )
426   PORT_DIPSETTING(    0x40, "2" )
427   PORT_DIPSETTING(    0xc0, "3" )
428   PORT_DIPSETTING(    0x80, "4" )
510   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
511   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
512   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
513   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
514   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
515   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
429516
517   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Flip_Screen ) )
518   PORT_DIPSETTING(    0x0100, DEF_STR( Off ) )
519   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
520   PORT_DIPNAME( 0x0200, 0x0000, DEF_STR( Demo_Sounds ) )
521   PORT_DIPSETTING(    0x0200, DEF_STR( Off ) )
522   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
523   PORT_DIPNAME( 0x0400, 0x0000, DEF_STR( Language ) )
524   PORT_DIPSETTING(    0x0400, DEF_STR( Japanese ) )
525   PORT_DIPSETTING(    0x0000, DEF_STR( English ) )
526   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
527   PORT_DIPSETTING(    0x0800, DEF_STR( Off ) )
528   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
529   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
530   PORT_DIPSETTING(    0x1000, DEF_STR( Off ) )
531   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
532   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
533   PORT_DIPSETTING(    0x2000, DEF_STR( Off ) )
534   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
535   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
536   PORT_DIPSETTING(    0x4000, DEF_STR( Off ) )
537   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
538   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
539   PORT_DIPSETTING(    0x8000, DEF_STR( Off ) )
540   PORT_DIPSETTING(    0x0000, DEF_STR( On ) )
541
430542   PORT_START("UNK")
431543INPUT_PORTS_END
432544
r3485r3486
473585   MDRV_CPU_ADD("main" , M68000, 10000000)
474586   MDRV_CPU_PROGRAM_MAP(ddealer,0)
475587   MDRV_CPU_VBLANK_INT("main", ddealer_interrupt)
476   MDRV_CPU_PERIODIC_INT(irq1_line_hold, 112)
588   MDRV_CPU_PERIODIC_INT(irq1_line_hold, 90)//guess,controls music tempo,112 is way too fast
477589
590   // M50747 or NMK-110 8131 MCU
591
478592   MDRV_GFXDECODE(ddealer)
479593
480
481594   MDRV_SCREEN_ADD("main", RASTER)
482595   MDRV_SCREEN_REFRESH_RATE(60)
483596   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
r3485r3486
491604   MDRV_VIDEO_START(ddealer)
492605   MDRV_VIDEO_UPDATE(ddealer)
493606
607   MDRV_TIMER_ADD_PERIODIC("coinsim", ddealer_mcu_sim, HZ(10000)) // not real, but for simulating the MCU
608
494609   MDRV_SPEAKER_STANDARD_MONO("mono")
610   MDRV_SOUND_ADD("ym", YM2203, 6000000 / 4)//guess
611   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
495612MACHINE_DRIVER_END
496613
497614
r3485r3486
511628
512629   res = resp[respcount++];
513630   if (resp[respcount]<0)
514   {
515631       respcount = 0;
516      // ddealer_protection(machine);
517632
518   }
519633   return res;
520634}
521635
522/*static WRITE16_HANDLER( ddealer_mcu_w )
523{
524    if(data==1)
525    {
526        prot=1;
527        shared_ram[0xe000/2]=0;
528        shared_ram[0xe002/2]=0;
529        shared_ram[0xe004/2]=0;
530        shared_ram[0xe006/2]=0;
531    }
532}
533*/
534636static DRIVER_INIT( ddealer )
535637{
536638   memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xfe01c, 0xfe01d, 0, 0, ddealer_mcu_r );
537//  memory_install_write16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xfe01e, 0xfe01f, 0, 0, ddealer_mcu_w );
538639}
539640
540641ROM_START( ddealer )
r3485r3486
542643   ROM_LOAD16_BYTE( "1.ic6", 0x00001, 0x20000, CRC(ce0dff50) SHA1(2d7a03f6b9609aea7511a4dc49560a901b0b9f19) )
543644   ROM_LOAD16_BYTE( "2.ic28", 0x00000, 0x20000, CRC(f00c346f) SHA1(bd73efb19d5f9efc88210d92a82a3f4595b41097) )
544645
646   ROM_REGION( 0x40000, "mcu", 0 ) /* M50747? MCU Code */
647   ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP ) // might be NMK-110 8131 chip
648
545649   ROM_REGION( 0x20000, "gfx1", 0 ) /* BG0 */
546650   ROM_LOAD( "4.ic65", 0x00000, 0x20000, CRC(4939ff1b) SHA1(af2f2feeef5520d775731a58cbfc8fcc913b7348) )
547651
r3485r3486
553657   ROM_LOAD( "6.ic86", 0x100, 0x100, NO_DUMP )
554658ROM_END
555659
556GAME( 1991, ddealer,  0, ddealer, ddealer, ddealer,  ROT0, "NMK", "Double Dealer", GAME_NOT_WORKING | GAME_NO_SOUND)
660GAME( 1991, ddealer,  0, ddealer, ddealer, ddealer,  ROT0, "NMK", "Double Dealer", 0 )
557661
src/mame/drivers/sliver.c
r3485r3486
435435   AM_RANGE(0x0000, 0xffff) AM_ROM
436436ADDRESS_MAP_END
437437
438static ADDRESS_MAP_START( soundmem_data, ADDRESS_SPACE_DATA, 8 )
438static ADDRESS_MAP_START( soundmem_io, ADDRESS_SPACE_IO, 8 )
439439   AM_RANGE(0x0100, 0x0100) AM_READWRITE( okim6295_status_0_r, okim6295_data_0_w )
440440   AM_RANGE(0x0101, 0x0101) AM_READ(soundlatch_r)
441   /* ports */
442   AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_WRITE( oki_setbank )
441443ADDRESS_MAP_END
442444
443static ADDRESS_MAP_START( soundmem_io, ADDRESS_SPACE_IO, 8 )
444   AM_RANGE(0x0001, 0x0001) AM_WRITE( oki_setbank )
445ADDRESS_MAP_END
446
447445static VIDEO_START(sliver)
448446{
449447   sliver_bitmap_bg = video_screen_auto_bitmap_alloc(machine->primary_screen);
r3485r3486
540538
541539   MDRV_CPU_ADD("audio", I8051, 8000000)
542540   MDRV_CPU_PROGRAM_MAP(soundmem_prg,0)
543   MDRV_CPU_DATA_MAP(soundmem_data,0)
544541   MDRV_CPU_IO_MAP(soundmem_io,0)
545542
546543
src/mame/drivers/cps3.c
r3485r3486
1313
1414ToDo: (in order or priority?)
1515
16There are currently a bunch of hacks in here to workaround the way the encryption works on the actual
17PCB.  It seems that the SH2 DMA should bypass the encryption, returning values directly stored in the
18BIOS and/or flashROMs.  Without modification to the CPU core this isn't possible.  The hacks currently
19in the driver allow the Flash commands to be sent correctly from the BIOS rom (they're stored
20unencrypted) and allow the Flash type and Rom checksums to pass, needed for the flash routines.
21
22The SCSI / CD Rom controller code here is limited, it's designed for the needs of CPS3 only, we should
23fix MAME's generic implementation and use that.
24
2516Street Fighter 3 2nd Impact uses flipped tilemaps during flashing, emulate this.
2617
2718Figure out proper IRQ10 generation:
r3485r3486
3223
3324Alpha Blending Effects
3425    These are actually palette manipulation effects, not true blending.  How the values are used is
35    not currently 100% understood, however it seems good enough for Warzard etc. at the moment.
26    not currently 100% understood. They are incorrect if you use player 2 in Warzard
3627
3728Linezoom
3829    Is it used anywhere??
r3485r3486
5344
5445Gaps in Sprite Zooming
5546 probably cause by use of drawgfx instead of processing as a single large sprite, but could also be due to the
56 positioning of each part of the sprite.
47 positioning of each part of the sprite.  Warzard is confirmed to have gaps during some cutscenes on real hardware.
5748
5849---
5950
r3485r3486
345336   #define DMA_XOR(a)   ((a) ^ 2)
346337#endif
347338
348static int cps3_use_fastboot;
349339
350340static UINT32* decrypted_bios;
341
351342static UINT32* decrypted_gamerom;
352343static UINT32 cram_gfxflash_bank;
353344static UINT32* cps3_nops;
r3485r3486
616607
617608/* Encryption */
618609
619static UINT32 cps3_key1, cps3_key2, cps3_isSpecial;
610static UINT32 cps3_key1, cps3_key2;
611static int cps3_altEncryption; // sfiii2 has different encryption, data isn't encrypted outside of the bios
620612
621613static UINT16 rotate_left(UINT16 value, int n)
622614{
r3485r3486
699691      UINT32 xormask = cps3_mask(i, cps3_key1, cps3_key2);
700692
701693      /* a bit of a hack, don't decrypt the FLASH commands which are transfered by SH2 DMA */
702      if (((i<0x1ff00) || (i>0x1ff6b)) && (i<0x20000) )
703      {
694//      if (((i<0x1ff00) || (i>0x1ff6b)) && (i<0x20000) )
695//      {
704696         decrypted_bios[i/4] = dword ^ xormask;
705      }
706      else
707      {
708         decrypted_bios[i/4] = dword;
709      }
697//      }
698//      else
699//      {
700//          decrypted_bios[i/4] = dword;
701//      }
710702   }
711703#if 0
712704   /* Dump to file */
r3485r3486
726718#endif
727719}
728720
729static DRIVER_INIT( cps3crpt )
721static DRIVER_INIT( cps3 )
730722{
731723   const char *gamename = machine->gamedrv->name;
732724   const struct game_keys2 *k = &keys_table2[0];
r3485r3486
737729
738730   cps3_key1 = -1;
739731   cps3_key2 = -1;
740   cps3_isSpecial = -1;
732   cps3_altEncryption = -1;
741733
742734   while (k->name)
743735   {
r3485r3486
746738         // we have a proper key set the global variables to it (so that we can decrypt code in ram etc.)
747739         cps3_key1 = k->keys[0];
748740         cps3_key2 = k->keys[1];
749         cps3_isSpecial = k->isSpecial;
741         cps3_altEncryption = k->isSpecial;
750742         break;
751743      }
752744      ++k;
r3485r3486
13641356      opbase->rom = (UINT8*)decrypted_gamerom-0x06000000;
13651357      opbase->ram = (UINT8*)decrypted_gamerom-0x06000000;
13661358
1367      if (cps3_isSpecial) opbase->ram = (UINT8*) memory_region(machine, "user4")-0x06000000;
1359      if (cps3_altEncryption) opbase->ram = (UINT8*) memory_region(machine, "user4")-0x06000000;
13681360
13691361
13701362      return ~0;
r3485r3486
15621554   return result;
15631555}
15641556
1565/* In certain situations (SH2 DMA?) the reads must bypass the encryption device,
1566   this is used when checking the flash roms, and performing rom tests.  Without
1567   modification to the SH2 core this requires PC based hacks to work correctly */
1568static UINT32 cps3_bios_test_hack;
1569static UINT32 cps3_game_test_hack;
15701557
1571struct cps3_test_hacks
1572{
1573   const char *name;             /* game driver name */
1574   const UINT32 bios_test_hack;
1575   const UINT32 game_test_hack;
1576};
15771558
1578static const struct cps3_test_hacks testhack_table[] =
1579{
1580   // name        mainram address  code address
1581   { "jojo",      0x0011c2a,         0x6172566  },
1582   { "jojon",     0x0011c2a,         0x6172566  },
1583   { "jojoalt",   0x0011c2a,         0x6172796  },
1584   { "jojoaltn",  0x0011c2a,         0x6172796  },
1585   { "jojoba",    0x0011c8e,         0x61c45ba  },
1586   { "jojoban",   0x0011c8e,         0x61c45ba  },
1587   { "jojobane",  0x0011c8e,         0x61c45ba  },
1588   { "sfiii",     0x00166b2,         0x63cdff2  },
1589   { "sfiiiu",    0x00166b2,         0x63cdff2  },
1590   { "sfiiin",    0x00166b2,         0x63cdff2  },
1591   { "sfiii2",    0,                 0          },
1592   { "sfiii2u",   0,                 0          },
1593   { "sfiii2n",   0,                 0          },
1594   { "sfiii3",    0x0011c42,         0x613a9fa  },
1595   { "sfiii3n",   0x0011c42,         0x613a9fa  },
1596   { "sfiii3a",   0x0011c42,         0x613ab46  },
1597   { "sfiii3an",  0x0011c42,         0x613ab46  },
1598   { "warzard",   0x001652e,         0x60105ee  },
1599   { "redearth",  0x001652e,         0x60105ee  },
1600   { 0 }   // end of table
1601};
1602
1603static DRIVER_INIT( cps3_testhacks )
1604{
1605   const char *gamename = machine->gamedrv->name;
1606   const struct cps3_test_hacks *k = &testhack_table[0];
1607
1608   cps3_bios_test_hack = 0;
1609   cps3_game_test_hack = 0;
1610
1611   while (k->name)
1612   {
1613      if (strcmp(k->name, gamename) == 0)
1614      {
1615         cps3_bios_test_hack = k->bios_test_hack;
1616         cps3_game_test_hack = k->game_test_hack;
1617
1618         cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 1);
1619         cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, cps3_bios_test_hack);
1620         cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 2);
1621         cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, cps3_game_test_hack);
1622
1623         break;
1624      }
1625      ++k;
1626   }
1627   printf("testhacks %08x %08x\n",cps3_bios_test_hack,cps3_game_test_hack);
1628}
1629
1630
16311559static READ32_HANDLER( cps3_flash1_r )
16321560{
16331561   UINT32 retvalue = cps3_flashmain_r(0, offset,mem_mask);
16341562
1635   if (activecpu_get_pc()==cps3_bios_test_hack) return retvalue; // initial flash tests / bios tests
1636   if (activecpu_get_pc()==cps3_game_test_hack) return retvalue; // test menu rom tests
1637   if (cps3_isSpecial) return retvalue; // sfiii2.. (no encrypted data)
1563   if (cps3_altEncryption) return retvalue;
16381564
16391565   retvalue = retvalue ^ cps3_mask(0x6000000+offset*4, cps3_key1, cps3_key2);
16401566   return retvalue;
r3485r3486
16441570{
16451571   UINT32 retvalue = cps3_flashmain_r(4, offset,mem_mask);
16461572
1647   if (activecpu_get_pc()==cps3_bios_test_hack) return retvalue; // initial flash tests / bios tests
1648   if (activecpu_get_pc()==cps3_game_test_hack) return retvalue; // test menu rom tests
1649   if (cps3_isSpecial) return retvalue; // sfiii2.. (no encrypted data)
1573   if (cps3_altEncryption) return retvalue;
16501574
16511575   retvalue = retvalue ^ cps3_mask(0x6800000+offset*4, cps3_key1, cps3_key2);
16521576   return retvalue;
r3485r3486
24212345};
24222346
24232347
2424static emu_timer* fastboot_timer;
24252348
2426static TIMER_CALLBACK( fastboot_timer_callback )
2427{
2428   UINT32 *rom =  (UINT32*)decrypted_gamerom;//memory_region ( machine, "user4" );
2429   if (cps3_isSpecial) rom = (UINT32*)memory_region(machine, "user4");
24302349
2431//  printf("fastboot callback %08x %08x", rom[0], rom[1]);
2432   cpunum_set_reg(0,SH2_PC, rom[0]);
2433   cpunum_set_reg(0,SH2_R15, rom[1]);
2434   cpunum_set_reg(0,SH2_VBR, 0x6000000);
2435}
2436
24372350static const SCSIConfigTable dev_table =
24382351{
24392352   1,                                      /* 1 SCSI device */
r3485r3486
24602373static MACHINE_RESET( cps3 )
24612374{
24622375   current_table_address = -1;
2463
2464   if (cps3_use_fastboot)
2465   {
2466      fastboot_timer = timer_alloc(fastboot_timer_callback, NULL);
2467   //  printf("reset\n");
2468      timer_adjust_oneshot(fastboot_timer, attotime_zero, 0);
2469   }
24702376}
24712377
24722378#define MASTER_CLOCK   42954500
r3485r3486
26602566
26612567
26622568
2569static UINT32 cps3_dma_callback(UINT32 src, UINT32 dst, UINT32 data, int size)
2570{
2571   /*
2572      on the actual CPS3 hardware the SH2 DMA bypasses the encryption.
26632573
2574      to handle this in MAME we use this callback, and reverse the effect of the
2575      encryption that would otherwise be applied.  this allows us to avoid per-game,
2576      per-PC hacks.  this approach is however still a little messy.
2577
2578    */
2579
2580   /* I doubt this is endian safe.. needs checking / fixing */
2581   if (size==0)
2582   {
2583      if ((src&3)==0) data <<=24;
2584      if ((src&3)==1) data <<=16;
2585      if ((src&3)==2) data <<=8;
2586      if ((src&3)==3) data <<=0;
2587   }
2588
2589
2590   if (src<0x80000)
2591   {
2592      int offs = (src&0x07ffff)>>2;
2593      data = data ^ cps3_mask(offs*4, cps3_key1, cps3_key2);
2594   }
2595   else if (src>=0x6000000 && src<0x6800000)
2596   {
2597      int offs = (src&0x07fffff)>>2;
2598      if (!cps3_altEncryption) data = data ^ cps3_mask(0x6000000+offs*4, cps3_key1, cps3_key2);
2599   }
2600   else if (src>=0x6800000 && src<0x7000000)
2601   {
2602      int offs = (src&0x07fffff)>>2;
2603      if (!cps3_altEncryption) data = data ^ cps3_mask(0x6800000+offs*4, cps3_key1, cps3_key2);
2604   }
2605   else
2606   {
2607      //printf("PC %08x :src %08x, dst %08x, returning %08x\n", activecpu_get_pc(), src, dst, data);
2608   }
2609
2610   /* I doubt this is endian safe.. needs checking / fixing */
2611   if (size==0)
2612   {
2613      if ((src&3)==0) data >>=24;
2614      if ((src&3)==1)   data >>=16;
2615      if ((src&3)==2)   data >>=8;
2616      if ((src&3)==3) data >>=0;
2617
2618      data &=0x000000ff;
2619   }
2620
2621   return data;
2622}
2623
2624
2625
2626static const sh2_cpu_core sh2_conf_cps3 = {
2627   0, // master
2628   (void*)cps3_dma_callback
2629};
2630
26642631static MACHINE_DRIVER_START( cps3 )
26652632   /* basic machine hardware */
26662633   MDRV_CPU_ADD("main", SH2, 6250000*4) // external clock is 6.25 Mhz, it sets the intenral multiplier to 4x (this should probably be handled in the core..)
26672634   MDRV_CPU_PROGRAM_MAP(cps3_map,0)
26682635   MDRV_CPU_VBLANK_INT("main", cps3_vbl_interrupt)
26692636   MDRV_CPU_PERIODIC_INT(cps3_other_interrupt,80) /* ?source? */
2637   MDRV_CPU_CONFIG(sh2_conf_cps3)
26702638
26712639   /* video hardware */
26722640   MDRV_SCREEN_ADD("main", RASTER)
r3485r3486
29712939   ROM_LOAD( "50",  0x2000000, 0x400000, CRC(2f5b44bd) SHA1(7ffdbed5b6899b7e31414a0828e04543d07435e4) )
29722940ROM_END
29732941
2974/* Idle loop skipping speedups */
2975static UINT32 cps3_speedup_ram_address;
2976static UINT32 cps3_speedup_code_address;
29772942
2978struct cps3_speedups
2979{
2980   const char *name;             /* game driver name */
2981   const UINT32 ram_address;
2982   const UINT32 code_address;
2983};
2943/*****************************************************************************************
2944  CPS3 game region / special flag information
2945*****************************************************************************************/
29842946
2985static const struct cps3_speedups speedup_table[] =
2986{
2987   // name        mainram address  code address
2988   { "jojo",      0x223c0,         0x600065a  },
2989   { "jojon",     0x223c0,         0x600065a  },
2990   { "jojoalt",   0x223d8,         0x600065a  },
2991   { "jojoaltn",  0x223d8,         0x600065a  },
2992   { "jojoba",    0x267dc,         0x600065a  },
2993   { "jojoban",   0x267dc,         0x600065a  },
2994   { "jojobane",  0x267dc,         0x600065a  },
2995   { "sfiii",     0x0cc6c,         0x6000882  },
2996   { "sfiiiu",    0x0cc6c,         0x6000882  },
2997   { "sfiiin",    0x0cc6c,         0x6000882  },
2998   { "sfiii2",    0x0dfe4,         0x6000882  },
2999   { "sfiii2u",   0x0dfe4,         0x6000882  },
3000   { "sfiii2n",   0x0dfe4,         0x6000882  },
3001   { "sfiii3",    0x0d794,         0x6000882  },
3002   { "sfiii3n",   0x0d794,         0x6000882  },
3003   { "sfiii3a",   0x0d794,         0x6000882  },
3004   { "sfiii3an",  0x0d794,         0x6000882  },
3005   { "warzard",   0x2136c,         0x600194c  },
3006   { "redearth",  0x2136c,         0x600194c  },
3007   { 0 }   // end of table
3008};
2947/*****************************************************************************************
30092948
3010static READ32_HANDLER(cps3_speedup_r)
3011{
3012//  printf("speedup read %08x %d\n",activecpu_get_pc(), cpu_getexecutingcpu());
3013   if (cpu_getexecutingcpu()>=0) // prevent cheat search crash..
3014      if (activecpu_get_pc()==cps3_speedup_code_address) {cpu_spinuntil_int();return cps3_mainram[cps3_speedup_ram_address/4];}
2949    JoJo's Venture
30152950
3016   return cps3_mainram[cps3_speedup_ram_address/4];
3017}
2951    XXXXXX 0
2952    JAPAN 1
2953    ASIA 2
2954    EURO 3
2955    USA 4
2956    HISPANIC 5
2957    BRAZIL 6
2958    OCEANIA 7
30182959
3019static DRIVER_INIT( cps3_speedups )
3020{
3021   const char *gamename = machine->gamedrv->name;
3022   const struct cps3_speedups *k = &speedup_table[0];
2960    DEVELOPMENT VERSION add 0x70 mask!
30232961
3024   cps3_speedup_ram_address = 0;
3025   cps3_speedup_code_address = 0;
2962    UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
2963    rom[0x1fec8/4]^=0x00000001; // region hack (clear jpn)
30262964
3027   while (k->name)
3028   {
3029      if (strcmp(k->name, gamename) == 0)
3030      {
3031         cps3_speedup_ram_address = k->ram_address;
3032         cps3_speedup_code_address = k->code_address;
3033         break;
3034      }
3035      ++k;
3036   }
2965    rom[0x1fec8/4]^=0x00000004; // region
2966    rom[0x1fec8/4]^=0x00000070; // DEV mode
2967    rom[0x1fecc/4]^=0x01000000; // nocd
30372968
3038   //printf("speedup %08x %08x\n",cps3_speedup_ram_address,cps3_speedup_code_address);
2969*****************************************************************************************/
30392970
3040   if (cps3_speedup_code_address!=0)
3041   {
3042      cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 0);
3043      cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, cps3_speedup_code_address);
30442971
3045      memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, cps3_speedup_ram_address+0x02000000, cps3_speedup_ram_address+0x02000003, 0, 0, cps3_speedup_r );
3046   }
3047}
2972/*****************************************************************************************
30482973
2974    JoJo's Bizarre Adventure: Heritage for the Future
30492975
3050/* PLEASE leave the region / NOCD information here even once CD emulation is done, its useful for debugging */
2976    XXXXXX 0
2977    JAPAN 1
2978    ASIA 2
2979    EURO 3
2980    USA 4
2981    HISPANIC 5
2982    BRAZIL 6
2983    OCEANIA 7
30512984
2985    DEVELOPMENT VERSION add 0x70 mask!
30522986
3053static DRIVER_INIT( jojo )
3054{
3055   // XXXXXX 0
3056   // JAPAN 1
3057   // ASIA 2
3058   // EURO 3
3059   // USA 4
3060   // HISPANIC 5
3061   // BRAZIL 6
3062   // OCEANIA 7
2987    UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
2988    rom[0x1fec8/4]^=0x00000001; // region (clear jpn)
2989    rom[0x1fec8/4]^=0x00000002; // region
2990    rom[0x1fec8/4]^=0x00000070; // DEV mode
2991    rom[0x1fecc/4]^=0x01000000; // nocd
30632992
3064   // DEVELOPMENT VERSION add 0x70 mask!
2993*****************************************************************************************/
30652994
3066//  UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
3067//  rom[0x1fec8/4]^=0x00000001; // region hack (clear jpn)
2995/*****************************************************************************************
30682996
3069//  rom[0x1fec8/4]^=0x00000004; // region
3070//  rom[0x1fec8/4]^=0x00000070; // DEV mode
3071//  rom[0x1fecc/4]^=0x01000000; // nocd
2997    Red Earth / Warzard
30722998
3073   cps3_use_fastboot = 0;
3074   DRIVER_INIT_CALL(cps3crpt);
3075   DRIVER_INIT_CALL(cps3_speedups);
3076   DRIVER_INIT_CALL(cps3_testhacks);
2999    JAPAN 1
3000    ASIA 2
3001    EURO 3
3002    USA 4
3003    HISPANIC 5
3004    BRAZIL 6
3005    OCEANIA 7
3006    ASIA NCD 8
30773007
3008    UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
3009    rom[0x1fed8/4]^=0x00000001; // clear region to 0 (invalid)
3010    rom[0x1fed8/4]^=0x00000008; // region 8 - ASIA NO CD - doesn't actually skip the CD
3011                                // test on startup, only during game, must be another flag
3012                                // somewhere too, and we don't have any actual NCD dumps
3013                                // to compare (or it expects SCSI to report there being
3014                                // no cd drive?)
30783015
3079}
3016*****************************************************************************************/
30803017
3081static DRIVER_INIT (jojoba)
3082{
3083   // XXXXXX 0
3084   // JAPAN 1
3085   // ASIA 2
3086   // EURO 3
3087   // USA 4
3088   // HISPANIC 5
3089   // BRAZIL 6
3090   // OCEANIA 7
3018/*****************************************************************************************
30913019
3092   // DEVELOPMENT VERSION add 0x70 mask!
3020   Street Fighter III: New Generation
30933021
3094//  UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
3095//  rom[0x1fec8/4]^=0x00000001; // region (clear jpn)
3096//  rom[0x1fec8/4]^=0x00000002; // region
3097//  rom[0x1fec8/4]^=0x00000070; // DEV mode
3098//  rom[0x1fecc/4]^=0x01000000; // nocd
3022    JAPAN 1
3023    ASIA NCD 2
3024    EURO 3
3025    USA 4
3026    HISPANIC 5
3027    BRAZIL 6
3028    OCEANIA 7
3029    ASIA 8
30993030
3100   DRIVER_INIT_CALL(cps3crpt);
3101   DRIVER_INIT_CALL(cps3_speedups);
3102   DRIVER_INIT_CALL(cps3_testhacks);
3031    // bios rom also lists korea, but game rom does not.
31033032
3104   cps3_use_fastboot = 0;
3105}
3033    UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
3034    rom[0x1fec8/4]^=0x00000001; // region (clear region)
3035    rom[0x1fec8/4]^=0x00000008; // region
3036    rom[0x1fecc/4]^=0x01000000; // nocd - this ONLY skips the cd check in the bios test
3037                                // menu is region is ASIA NCD, otherwise it will report
3038                                // NG, Asia was probably the only NCD region for this
31063039
3040*****************************************************************************************/
31073041
3108static DRIVER_INIT( warzard )
3109{
3110   // JAPAN 1
3111   // ASIA 2
3112   // EURO 3
3113   // USA 4
3114   // HISPANIC 5
3115   // BRAZIL 6
3116   // OCEANIA 7
3117   // ASIA NCD 8
3042/*****************************************************************************************
31183043
3119//  UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
3120//  rom[0x1fed8/4]^=0x00000001; // clear region to 0 (invalid)
3121//  rom[0x1fed8/4]^=0x00000008; // region 8 - ASIA NO CD - doesn't actually skip the CD test on startup,
3122                               // only during game, must be another flag somewhere too, and we don't have
3123                               // any actual NCD dumps to compare (or it expects SCSI to report there being
3124                               // no cd drive?)
3044    Street Fighter III 2nd Impact
31253045
3126   DRIVER_INIT_CALL(cps3crpt);
3127   DRIVER_INIT_CALL(cps3_speedups);
3128   DRIVER_INIT_CALL(cps3_testhacks);
3046    JAPAN 1
3047    ASIA NCD 2
3048    EURO 3
3049    USA 4
3050    HISPANIC 5
3051    BRAZIL 6
3052    OCEANIA 7
3053    ASIA 8
31293054
3130   cps3_use_fastboot = 0; // required due to cd check, even with ASIA NO CD selected, not req. with CD emulation
3131}
3055    UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
3056    rom[0x1fec8/4]^=0x00000001; // region (clear region)
3057    rom[0x1fec8/4]^=0x00000008; // region
3058    rom[0x1fecc/4]^=0x01000000; // nocd - this ONLY skips the cd check in the bios test
3059                                // menu is region is ASIA NCD, otherwise it will report
3060                                // NG, Asia was probably the only NCD region for this
31323061
3062*****************************************************************************************/
31333063
3134static DRIVER_INIT( sfiii )
3135{
3136   // JAPAN 1
3137   // ASIA NCD 2
3138   // EURO 3
3139   // USA 4
3140   // HISPANIC 5
3141   // BRAZIL 6
3142   // OCEANIA 7
3143   // ASIA 8
31443064
3145   // bios rom also lists korea, but game rom does not.
3065/*****************************************************************************************
31463066
3147//  UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
3148//  rom[0x1fec8/4]^=0x00000001; // region (clear region)
3149//  rom[0x1fec8/4]^=0x00000008; // region
3150//  rom[0x1fecc/4]^=0x01000000; // nocd - this ONLY skips the cd check in the bios test menu is region is ASIA NCD, otherwise it will report NG, Asia was probably the only NCD region for this
3067    Street Fighter III 3rd Strike
31513068
3152   cps3_use_fastboot = 0;
3069    JAPAN 1
3070    ASIA 2
3071    EURO 3
3072    USA 4
3073    HISPANIC 5
3074    BRAZIL 6
3075    OCEANIA 7
31533076
3154   DRIVER_INIT_CALL(cps3crpt);
3155   DRIVER_INIT_CALL(cps3_speedups);
3156   DRIVER_INIT_CALL(cps3_testhacks);
3077    UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
3078    rom[0x1fec8/4]^=0x00000004; // region (clear region)
3079    rom[0x1fec8/4]^=0x00000001; // region
3080    rom[0x1fecc/4]^=0x01000000; // nocd
31573081
3158}
3082*****************************************************************************************/
31593083
3160static DRIVER_INIT( sfiii2 )
3161{
3162   // JAPAN 1
3163   // ASIA NCD 2
3164   // EURO 3
3165   // USA 4
3166   // HISPANIC 5
3167   // BRAZIL 6
3168   // OCEANIA 7
3169   // ASIA 8
31703084
3171//  UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
3172//  rom[0x1fec8/4]^=0x00000001; // region (clear region)
3173//  rom[0x1fec8/4]^=0x00000008; // region
3174//  rom[0x1fecc/4]^=0x01000000; // nocd - this ONLY skips the cd check in the bios test menu is region is ASIA NCD, otherwise it will report NG, Asia was probably the only NCD region for this
31753085
3176   cps3_use_fastboot = 0; // not required
3177
3178   DRIVER_INIT_CALL(cps3crpt);
3179   DRIVER_INIT_CALL(cps3_speedups);
3180   DRIVER_INIT_CALL(cps3_testhacks);
3181}
3182
3183
3184static DRIVER_INIT( sfiii3 )
3185{
3186   // JAPAN 1
3187   // ASIA 2
3188   // EURO 3
3189   // USA 4
3190   // HISPANIC 5
3191   // BRAZIL 6
3192   // OCEANIA 7
3193
3194//  UINT32 *rom =  (UINT32*)memory_region ( machine, "user1" );
3195
3196//  rom[0x1fec8/4]^=0x00000004; // region (clear region)
3197//  rom[0x1fec8/4]^=0x00000001; // region
3198//  rom[0x1fecc/4]^=0x01000000; // nocd
3199
3200   DRIVER_INIT_CALL(cps3crpt);
3201   DRIVER_INIT_CALL(cps3_speedups);
3202   DRIVER_INIT_CALL(cps3_testhacks);
3203
3204   cps3_use_fastboot = 0;
3205}
3206
32073086/* todo: use BIOS for the bios roms, having clones only for CD / No CD */
32083087
3209GAME( 1997, sfiii,   0,        cps3, cps3, sfiii,  ROT0,   "Capcom", "Street Fighter III: New Generation (Japan, 970204)", GAME_IMPERFECT_GRAPHICS )
3210GAME( 1997, sfiiiu,  sfiii,    cps3, cps3, sfiii,  ROT0,   "Capcom", "Street Fighter III: New Generation (USA, 970204)", GAME_IMPERFECT_GRAPHICS )
3088GAME( 1997, sfiii,   0,        cps3, cps3, cps3,  ROT0,   "Capcom", "Street Fighter III: New Generation (Japan, 970204)", GAME_IMPERFECT_GRAPHICS )
3089GAME( 1997, sfiiiu,  sfiii,    cps3, cps3, cps3,  ROT0,   "Capcom", "Street Fighter III: New Generation (USA, 970204)", GAME_IMPERFECT_GRAPHICS )
32113090
3212GAME( 1997, sfiii2,  0,        cps3, cps3, sfiii2, ROT0,   "Capcom", "Street Fighter III 2nd Impact: Giant Attack (Japan, 970930)", GAME_IMPERFECT_GRAPHICS )
3213GAME( 1997, sfiii2u, sfiii2,   cps3, cps3, sfiii2, ROT0,   "Capcom", "Street Fighter III 2nd Impact: Giant Attack (USA, 970930)", GAME_IMPERFECT_GRAPHICS )
3091GAME( 1997, sfiii2,  0,        cps3, cps3, cps3, ROT0,   "Capcom", "Street Fighter III 2nd Impact: Giant Attack (Japan, 970930)", GAME_IMPERFECT_GRAPHICS )
3092GAME( 1997, sfiii2u, sfiii2,   cps3, cps3, cps3, ROT0,   "Capcom", "Street Fighter III 2nd Impact: Giant Attack (USA, 970930)", GAME_IMPERFECT_GRAPHICS )
32143093
3215GAME( 1999, sfiii3,  0,        cps3, cps3, sfiii3, ROT0,   "Capcom", "Street Fighter III 3rd Strike: Fight for the Future (USA, 990512)", GAME_IMPERFECT_GRAPHICS )
3216GAME( 1999, sfiii3a, sfiii3,   cps3, cps3, sfiii3, ROT0,   "Capcom", "Street Fighter III 3rd Strike: Fight for the Future (USA, 990608)", GAME_IMPERFECT_GRAPHICS )
3094GAME( 1999, sfiii3,  0,        cps3, cps3, cps3, ROT0,   "Capcom", "Street Fighter III 3rd Strike: Fight for the Future (USA, 990512)", GAME_IMPERFECT_GRAPHICS )
3095GAME( 1999, sfiii3a, sfiii3,   cps3, cps3, cps3, ROT0,   "Capcom", "Street Fighter III 3rd Strike: Fight for the Future (USA, 990608)", GAME_IMPERFECT_GRAPHICS )
32173096
3218GAME( 1998, jojo,    0,        cps3, cps3, jojo,   ROT0,   "Capcom", "JoJo's Venture / JoJo no Kimyouna Bouken (Japan, 981202)", GAME_IMPERFECT_GRAPHICS )
3219GAME( 1998, jojoalt, jojo,     cps3, cps3, jojo,   ROT0,   "Capcom", "JoJo's Venture / JoJo no Kimyouna Bouken (Japan, 990108)", GAME_IMPERFECT_GRAPHICS )
3097GAME( 1998, jojo,    0,        cps3, cps3, cps3, ROT0,   "Capcom", "JoJo's Venture / JoJo no Kimyouna Bouken (Japan, 981202)", GAME_IMPERFECT_GRAPHICS )
3098GAME( 1998, jojoalt, jojo,     cps3, cps3, cps3, ROT0,   "Capcom", "JoJo's Venture / JoJo no Kimyouna Bouken (Japan, 990108)", GAME_IMPERFECT_GRAPHICS )
32203099
3221GAME( 1999, jojoba,  0,        cps3, cps3, jojoba, ROT0,   "Capcom", "JoJo's Bizarre Adventure: Heritage for the Future / JoJo no Kimyouna Bouken: Miraie no Isan (Japan, 990913)", GAME_IMPERFECT_GRAPHICS )
3100GAME( 1999, jojoba,  0,        cps3, cps3, cps3, ROT0,   "Capcom", "JoJo's Bizarre Adventure: Heritage for the Future / JoJo no Kimyouna Bouken: Miraie no Isan (Japan, 990913)", GAME_IMPERFECT_GRAPHICS )
32223101
3223GAME( 1996, redearth,0,        cps3, cps3, warzard,  ROT0,   "Capcom", "Red Earth (Euro, 961121)", GAME_IMPERFECT_GRAPHICS )
3224GAME( 1996, warzard, redearth, cps3, cps3, warzard,  ROT0,   "Capcom", "Warzard (Japan, 961121)", GAME_IMPERFECT_GRAPHICS )
3102GAME( 1996, redearth,0,        cps3, cps3, cps3, ROT0,   "Capcom", "Red Earth (Euro, 961121)", GAME_IMPERFECT_GRAPHICS )
3103GAME( 1996, warzard, redearth, cps3, cps3, cps3, ROT0,   "Capcom", "Warzard (Japan, 961121)", GAME_IMPERFECT_GRAPHICS )
32253104
32263105/* NO-CD sets */
32273106
3228GAME( 1997, sfiiin,  sfiii,    cps3, cps3, sfiii, ROT0,   "Capcom", "Street Fighter III: New Generation (Asia, 970204, NO CD)", GAME_IMPERFECT_GRAPHICS )
3107GAME( 1997, sfiiin,  sfiii,    cps3, cps3, cps3, ROT0,   "Capcom", "Street Fighter III: New Generation (Asia, 970204, NO CD)", GAME_IMPERFECT_GRAPHICS )
32293108
3230GAME( 1997, sfiii2n, sfiii2,   cps3, cps3, sfiii2, ROT0,   "Capcom", "Street Fighter III 2nd Impact: Giant Attack (Asia, 970930, NO CD)", GAME_IMPERFECT_GRAPHICS )
3109GAME( 1997, sfiii2n, sfiii2,   cps3, cps3, cps3, ROT0,   "Capcom", "Street Fighter III 2nd Impact: Giant Attack (Asia, 970930, NO CD)", GAME_IMPERFECT_GRAPHICS )
32313110
3232GAME( 1999, sfiii3n, sfiii3,   cps3, cps3, sfiii3, ROT0,   "Capcom", "Street Fighter III 3rd Strike: Fight for the Future (Japan, 990512, NO CD)", GAME_IMPERFECT_GRAPHICS )
3233GAME( 1999, sfiii3an,sfiii3,   cps3, cps3, sfiii3, ROT0,   "Capcom", "Street Fighter III 3rd Strike: Fight for the Future (Japan, 990608, NO CD)", GAME_IMPERFECT_GRAPHICS )
3111GAME( 1999, sfiii3n, sfiii3,   cps3, cps3, cps3, ROT0,   "Capcom", "Street Fighter III 3rd Strike: Fight for the Future (Japan, 990512, NO CD)", GAME_IMPERFECT_GRAPHICS )
3112GAME( 1999, sfiii3an,sfiii3,   cps3, cps3, cps3, ROT0,   "Capcom", "Street Fighter III 3rd Strike: Fight for the Future (Japan, 990608, NO CD)", GAME_IMPERFECT_GRAPHICS )
32343113
3235GAME( 1998, jojon,   jojo,     cps3, cps3, jojo,   ROT0,   "Capcom", "JoJo's Venture / JoJo no Kimyouna Bouken (Asia, 981202, NO CD)", GAME_IMPERFECT_GRAPHICS )
3236GAME( 1998, jojoaltn,jojo,     cps3, cps3, jojo,   ROT0,   "Capcom", "JoJo's Venture / JoJo no Kimyouna Bouken (Asia, 990108, NO CD)", GAME_IMPERFECT_GRAPHICS )
3114GAME( 1998, jojon,   jojo,     cps3, cps3, cps3, ROT0,   "Capcom", "JoJo's Venture / JoJo no Kimyouna Bouken (Asia, 981202, NO CD)", GAME_IMPERFECT_GRAPHICS )
3115GAME( 1998, jojoaltn,jojo,     cps3, cps3, cps3, ROT0,   "Capcom", "JoJo's Venture / JoJo no Kimyouna Bouken (Asia, 990108, NO CD)", GAME_IMPERFECT_GRAPHICS )
32373116
3238GAME( 1999, jojoban, jojoba,   cps3, cps3, jojoba, ROT0,   "Capcom", "JoJo's Bizarre Adventure: Heritage for the Future / JoJo no Kimyouna Bouken: Miraie no Isan (Japan, 990913, NO CD)", GAME_IMPERFECT_GRAPHICS )
3239GAME( 1999, jojobane,jojoba,   cps3, cps3, jojoba, ROT0,   "Capcom", "JoJo's Bizarre Adventure: Heritage for the Future / JoJo no Kimyouna Bouken: Miraie no Isan (Euro, 990913, NO CD)", GAME_IMPERFECT_GRAPHICS )
3117GAME( 1999, jojoban, jojoba,   cps3, cps3, cps3, ROT0,   "Capcom", "JoJo's Bizarre Adventure: Heritage for the Future / JoJo no Kimyouna Bouken: Miraie no Isan (Japan, 990913, NO CD)", GAME_IMPERFECT_GRAPHICS )
3118GAME( 1999, jojobane,jojoba,   cps3, cps3, cps3, ROT0,   "Capcom", "JoJo's Bizarre Adventure: Heritage for the Future / JoJo no Kimyouna Bouken: Miraie no Isan (Euro, 990913, NO CD)", GAME_IMPERFECT_GRAPHICS )
32403119
32413120// We don't have any actual warzard / red earth no cd bios sets, but keep this here anyway
3242GAME( 1996, redeartn,redearth, cps3, cps3, warzard,ROT0,   "Capcom", "Red Earth (961121, NO CD)", GAME_NOT_WORKING )
3121GAME( 1996, redeartn,redearth, cps3, cps3, cps3, ROT0,   "Capcom", "Red Earth (961121, NO CD)", GAME_NOT_WORKING )
src/mame/drivers/yumefuda.c
r3485r3486
11/*******************************************************************************************
22
3Yumefuda (c) 198? Alba
3Yumefuda (c) 1991 Alba
44
55driver by Angelo Salese
66
77Notes:
8-I think the name of this hardware is "Alba ZG board",an older(?) revision of the
9 "Alba ZC board" used by Hanaroku (hanaroku.c driver).
10 My guess is that this game is dated 1986/1987.
8-I think the name of this hardware is "Alba ZG board",a newer revision of the
9 "Alba ZC board" used by Hanaroku (hanaroku.c driver).Test mode says clearly that this is
10 from 1991.
1111
1212TODO:
13-Correct Bankswitch emulation.Obviously I'm not happy with the current implementation...
14-Finish controls.
15-"Custom RAM" emulation might be a simple protection issue.
16-Need a proper screenshot of the real thing for the colors but I think they are accurate.
13-Add coin counter,coin lock etc.;
14-Controls dynamically changes if you turn on the Panel Type DIP-SW,I'd imagine that the "royal
15 panel" is just a dedicated panel for this game;
16-"Custom RAM" emulation: might be a (weak) protection device or related to the "Back-up RAM NG"
17 msg that pops up at every start-up.
18-Video registers...are they of a custom hardware or a common device?
1719
1820============================================================================================
1921Code disassembling
r3485r3486
8789
8890/***************************************************************************************/
8991
90
91
9292static const gfx_layout charlayout =
9393{
9494   8,8,
r3485r3486
164164      case 0x02: return input_port_read(machine, "IN2");
165165      case 0x04: return input_port_read(machine, "IN3");
166166      case 0x08: return input_port_read(machine, "IN4");
167      /* FIXME: Was this a quick hack? */
168      case 0x10: return 0xff; //return input_port_read(machine, "IN5");
169      case 0x20: return 0xff; //return input_port_read(machine, "IN6");
167      case 0x10: return input_port_read(machine, "IN5");
168      case 0x20: return input_port_read(machine, "IN6");
170169   }
170
171   //popmessage("%02x",mux_data);
171172   return 0xff;
172173}
173174
r3485r3486
175176{
176177   int new_bank = (data&0xc0)>>6;
177178
178   //0x10000 service mode
179   //0x10000 "Learn Mode"
179180   //0x12000 gameplay
180181   //0x14000 bonus game
181182   //0x16000 ?
r3485r3486
191192   mux_data = data & ~0xc0;
192193}
193194
195static WRITE8_HANDLER( yumefuda_videoregs_w )
196{
197   static UINT8 address;
198
199   if(offset == 0)
200      address = data;
201   else
202   {
203      switch(address)
204      {
205         case 0x0d: flip_screen_set(data & 0x80); break;
206         default:
207            logerror("Video Register %02x called with %02x data\n",address,data);
208      }
209   }
210}
211
212static READ8_HANDLER( in7_r )
213{
214   return input_port_read(machine, "DSW1");
215}
216
217static READ8_HANDLER( in8_r )
218{
219   return input_port_read(machine, "DSW2");
220}
221
222static const ay8910_interface ay8910_config =
223{
224   AY8910_LEGACY_OUTPUT,
225   AY8910_DEFAULT_LOADS,
226   in7_r,
227   in8_r,
228   NULL,
229   NULL
230};
231
194232/***************************************************************************************/
195233
196234static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
r3485r3486
208246
209247static ADDRESS_MAP_START( port_map, ADDRESS_SPACE_IO, 8 )
210248   ADDRESS_MAP_GLOBAL_MASK(0xff)
249   AM_RANGE(0x00, 0x01) AM_WRITE(yumefuda_videoregs_w)
211250   AM_RANGE(0x40, 0x40) AM_READWRITE(ay8910_read_port_0_r, ay8910_control_port_0_w)
212251   AM_RANGE(0x41, 0x41) AM_WRITE(ay8910_write_port_0_w)
213252   AM_RANGE(0x80, 0x80) AM_WRITE(mux_w)
r3485r3486
252291   MDRV_SPEAKER_STANDARD_MONO("mono")
253292
254293   MDRV_SOUND_ADD("ay", AY8910, 1500000)
294   MDRV_SOUND_CONFIG(ay8910_config)
255295   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
256296MACHINE_DRIVER_END
257297
r3485r3486
259299
260300static INPUT_PORTS_START( yumefuda )
261301   PORT_START( "IN0")
262   PORT_DIPNAME( 0x01, 0x01, "Port 0" )
263   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
264   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
265   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2)
266   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
267   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
268   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
302   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 Flip-Flop")  PORT_CODE(KEYCODE_F)
303   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Coupon Credit") PORT_CODE(KEYCODE_7) PORT_IMPULSE(2) //coupon
304   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Note Credit")   PORT_CODE(KEYCODE_6) PORT_IMPULSE(2) //note
269305   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2)
270   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
271   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
272   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
273   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
274   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
275   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
276   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
277   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
278   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
279   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
280   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
281   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
306   PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
282307
283308   PORT_START( "IN1")
284   PORT_DIPNAME( 0x01, 0x01, "Port 1" )
285   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
286   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
287   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
288   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
289   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
290   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
291   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
292   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
293   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
294   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
295   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
296   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
297   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
298   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
299   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 BET Button") PORT_CODE(KEYCODE_RALT)
300   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
301   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
302   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
303   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
309   PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
310   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(KEYCODE_Z)
311   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(KEYCODE_X)
312   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CODE(KEYCODE_C)
313   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CODE(KEYCODE_V)
304314
305315   PORT_START( "IN2")
306   PORT_DIPNAME( 0x01, 0x01, "Port 2" )
307   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
308   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
309   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
310   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
311   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
312   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
313   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
314   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
315   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
316   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
317   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
318   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON3 )
319   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
320   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 )
321   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 )
316   PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
317   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_B)
318   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("P1 No Button")  PORT_CODE(KEYCODE_A)
319   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("P1 Yes Button") PORT_CODE(KEYCODE_Q)
320   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_CODE(KEYCODE_N)
322321
323322   PORT_START( "IN3")
324   PORT_DIPNAME( 0x01, 0x01, "Port 3" )
325   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
326   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
327   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
328   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
329   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
330   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
331   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
332   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
333   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
334   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
335   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
336   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
337   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
338   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
339   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("P1 Button 6 / Yes") PORT_CODE(KEYCODE_RCONTROL)
340   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON5 )
341   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
342   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
343   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
323   PORT_BIT( 0x9f, IP_ACTIVE_LOW, IPT_UNUSED )
324   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 )
325   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 BET Button") PORT_CODE(KEYCODE_2)
344326
327   /*These three are actually used if you use the Royal Panel type*/
345328   PORT_START( "IN4")
346   PORT_DIPNAME( 0x01, 0x01, "Port 4" )
329   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
330
331    PORT_START( "IN5")
332   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
333
334    PORT_START( "IN6")
335   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
336
337    /*Unused,on the PCB there's just one bank*/
338    PORT_START("DSW1")
339   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
340
341   /*Added by translating the manual*/
342    PORT_START("DSW2")
343   PORT_DIPNAME( 0x01, 0x01, "Learn Mode" )//SW Dip-Switches
347344   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
348345   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
349   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
346   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Service_Mode ) )
350347   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
351348   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
352   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
353   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
354   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
355   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
356   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
357   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
358   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
359   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
360   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
361   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
362   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
363   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
364   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
365   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
366   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
367   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
368   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
369   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
370/*
371    PORT_START( "IN5")
372    PORT_DIPNAME( 0x01, 0x01, "Port 5" )
373    PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
374    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
375    PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
376    PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
377    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
378    PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
379    PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
380    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
381    PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
382    PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
383    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
349   PORT_DIPNAME( 0x04, 0x04, "Hopper Payout" )
350   PORT_DIPSETTING(    0x04, "Hanafuda Type" )//hanaawase
351   PORT_DIPSETTING(    0x00, "Royal Type" )
352      PORT_DIPNAME( 0x08, 0x08, "Panel Type" )
353    PORT_DIPSETTING(    0x08, "Hanafuda Panel" )//hanaawase
354    PORT_DIPSETTING(    0x00, "Royal Panel" )
384355    PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
385356    PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
386357    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
387358    PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
388359    PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
389360    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
390    PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
361    PORT_DIPNAME( 0x40, 0x00, DEF_STR( Flip_Screen ) )//Screen Orientation
391362    PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
392363    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
393    PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
394    PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
395    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
396
397    PORT_START( "IN6")
398    PORT_DIPNAME( 0x01, 0x01, "Port 6" )
399    PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
400    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
401    PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
402    PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
403    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
404    PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
405    PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
406    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
407    PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
408    PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
409    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
410    PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
411    PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
412    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
413    PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
414    PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
415    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
416    PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
417    PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
418    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
419    PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
420    PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
421    PORT_DIPSETTING(    0x00, DEF_STR( On ) )*/
364    PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) )//Screen Flip
365    PORT_DIPSETTING(    0x80, DEF_STR( Upright ) )
366    PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )//pressing Flip-Flop button makes the screen flip
422367INPUT_PORTS_END
423368
424369/***************************************************************************************/
r3485r3486
436381   ROM_LOAD("zg001003.u3", 0xc000, 0x4000, CRC(5822ff27) SHA1(d40fa0790de3c912f770ef8f610bd8c42bc3500f))
437382ROM_END
438383
439GAME( 198?, yumefuda, 0, yumefuda, yumefuda, 0, ROT0, "Alba", "(Medal) Yumefuda [BET]", GAME_NOT_WORKING )
384GAME( 1991, yumefuda, 0, yumefuda, yumefuda, 0, ROT0, "Alba", "(Medal) Yumefuda [BET]", 0 )
src/mame/drivers/tnzs.c
r3485r3486
22
33
44Notes:
5- There are three versions of TNZS supported.
6  1) "tnzs". New hardware revision. 3 Z80 and no M-Chip (8742 MPU).
7  2) "tnzsj". Standard hardware. 2 Z80 and the M-Chip.
8  3) "tnzso". Standard hardware. Harder gameplay, old Taito logo. Maybe a prototype?
9  The three versions all have different levels!
5- There are four versions of TNZS supported.
6  1) "tnzs".   New hardware revision. 3 Z80 and no M-Chip (8742 MPU).
7  2) "tnzsj".  New hardware revision. 3 Z80 and no M-Chip (8742 MPU).
8  3) "tnzsjo". Standard hardware. 2 Z80 and the M-Chip.
9  4) "tnzso".  Standard hardware. Harder gameplay, old Taito logo. Maybe a prototype?
1010
1111- TNZS hidden level select: keep service coin pressed (default:9) and reset the game.
1212  When SERVICE SWITCH ERROR appears, release service coin and press 1 player start
r3485r3486
1414  starting level and press 1 player start to start. You'll also get 255 lives.
1515  If you have enough patience and go up until the level reads "Q-1" (which corresponds
1616  to 1-1), AND the "Invulnerability" dip switch is On, you'll be invulnerable.
17  Invulnerability isn't possible in 'tnzso' (level select is stucked to level 6-1).
1718
1819
1920Hardware datails for the newer tnzs board (from pictures):
r3485r3486
4344
4445
4546
47Stephh's notes (based on the games Z80 code and some tests) :
48
491) 'plumppop'
50
51  - Region stored at 0x7fff.b (CPU1) then 0xef49 (shared RAM)
52  - Sets :
53      * 'plumppop' : region = 0x00
54  - Coinage relies on bit 0 of the region (code at 0x5141 in CPU1) :
55      * .......0 : TAITO_COINAGE_JAPAN_OLD
56      * .......1 : TAITO_COINAGE_WORLD
57  - Notice screen relies on bit 1 of the region (code at 0x16e8) :
58      * ......0. : Yes
59      * ......1. : No
60  - Copyright relies on bits 2 and 3 of the region (code at 0x276d) :
61      * ....00.. : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
62      * ....01.. : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED" (US)
63      * ....10.. : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World)
64      * ....11.. : "TAITO CORP. JAPAN" / "LICENCED TO -------"
65
66
672) 'extrmatn' and clones
68
692a) 'extrmatn'
70
71  - Region stored at 0x7fff.b (CPU1) then 0x16 is stored at 0xef1d (shared RAM) !
72  - Sets :
73      * 'extrmatn' : region = 0x16
74  - New value is stored at 0xef1d (shared RAM) :
75      * 'extrmatn' : 0x16
76  - Coinage relies on bit 0 of the region (code at 0x4703 in CPU1) :
77      * .......0 : TAITO_COINAGE_JAPAN_OLD
78      * .......1 : TAITO_COINAGE_WORLD
79  - Notice screen relies on bit 1 of the new value (code at 0x4285) :
80      * ......0. : Yes
81      * ......1. : No
82  - Copyright relies on bits 2 and 3 of the new value (code at 0x0cfe) :
83      * ....00.. : "TAITO CORPORATION" / "     FOR U.S.A.    " (Japan)
84      * ....01.. : "WORLD GAMES     " / "     FOR U.S.A.    " (US)
85      * ....10.. : "TAITO CORP. JAPAN" / "     FOR U.S.A.    " (World)
86      * ....11.. : "TAITO CORP. JAPAN" / "LICENCED TO        "
87  - 'ret' + modified byte to please checksum at 0x8df5 (bank = 0x07) : unknown effect
88
892b) 'extrmatj'
90
91  - Region stored at 0x7fff.b (CPU1) then 0x00 is stored at 0xef1d (shared RAM) !
92  - Sets :
93      * 'extrmatj' : region = 0x00
94  - Coinage relies on bit 0 of the region (code at 0x4703 in CPU1) :
95      * .......0 : TAITO_COINAGE_JAPAN_OLD
96      * .......1 : TAITO_COINAGE_WORLD
97  - Notice screen relies on bit 1 of the new value (code at 0x4285) :
98      * ......0. : Yes
99      * ......1. : No
100  - Copyright relies on bits 2 and 3 of the new value (code at 0x0cfe) :
101      * ....00.. : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
102      * ....01.. : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED" (US)
103      * ....10.. : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World)
104      * ....11.. : "TAITO CORP. JAPAN" / "LICENCED TO           "
105  - Code and data differences :
106      * 0x8df5 (bank = 0x07) : normal routine but still unknown effect
107      * 0x01e0 (CPU1) : 0x00 instead of 0x16 (value for region tests)
108
109
1103) 'arknoid2' and clones
111
1123a) 'arknoid2' and 'arknid2j'
113
114  - Region stored at 0x9fde.b (CPU1 - bank = 0x00) then stored at 0xe7f0 (shared RAM)
115  - Coin mode stored at 0x9fff.b (CPU1 - bank = 0x00) then stored at 0xe7f1 (shared RAM)
116  - Sets :
117      * 'arknoid2' : region = 0x02 - coin mode = 0x01
118      * 'arknid2j' : region = 0x00 - coin mode = 0x00
119  - Coinage relies on coin mode (code at 0x0b17 in CPU1) :
120      * 0x00 : TAITO_COINAGE_JAPAN_OLD
121      * else : TAITO_COINAGE_WORLD
122  - Notice screen relies on region (code at 0x495b) :
123      * 0x00 : Yes
124      * else : No
125  - Copyright relies on region (code at 0x4774) :
126      * 0x00 : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
127      * 0x01 : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED" (US)
128      * 0x02 : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World)
129      * 0x03 : "TAITO AMERICA CORP." / "LICENCED TO ROMSTAR" / "FOR U.S.A."
130
1313b) 'arknid2u'
132
133  - Region stored at 0x9fde.b (CPU1 - bank = 0x00) then stored at 0xe7f0 (shared RAM)
134  - Coin mode stored at 0x9fff.b (CPU1 - bank = 0x00) then stored at 0xe7f1 (shared RAM)
135  - Sets :
136      * 'arknid2u' : region = 0x03 - coin mode = 0x00
137  - Coinage relies on coin mode (code at 0x0b17 in CPU1) :
138      * 0x00 : TAITO_COINAGE_JAPAN_OLD
139      * else : TAITO_COINAGE_WORLD
140  - Notice screen relies on region (code at 0x2e47) :
141      * 0x00 : Yes
142      * else : No
143  - Copyright relies on region (code at 0x475b) :
144      * 0x00 : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
145      * 0x01 : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED" (US)
146      * 0x02 : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World)
147      * 0x03 : "TAITO AMERICA CORP." / "LICENCED TO ROMSTAR" / "FOR U.S.A."
148  - Levels differences :
149      * new level 1
150      * levels 3 left and 17 left are swapped
151      * levels 17 right and 20 right are swapped
152
153
1544) 'drtoppel' and clones
155
156  - Region stored at 0x7fff.b (CPU1) then 0xe000 (shared RAM)
157  - Sets :
158      * 'drtoppel' : region = 0x03
159      * 'drtopplu' : region = 0x02
160      * 'drtopplj' : region = 0x01
161  - These 3 games are 100% the same, only region differs !
162    However, dumps for 'drtoppel' and 'drtopplu' are unsure (wrong ROM numbers).
163  - Coinage relies on region (code at 0x5141 in CPU1) :
164      * 0x01 and 0x02 : TAITO_COINAGE_JAPAN_OLD
165      * 0x03 and 0x04 : TAITO_COINAGE_WORLD
166  - Notice screen relies on region (code at 0x9331 - bank = 0x03) :
167      * 0x01 : Yes
168      * else : No
169  - Title relies on region (code at 0x90a4 - bank = 0x03) :
170      * 0x01 : Japanese
171      * else : English
172  - Copyright relies on region (code at 0x9b62 - bank = 0x03) :
173      * 0x01 : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
174      * 0x02 : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED" (US)
175      * else : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World / ???)
176
177
1785) 'kageki' and clones
179
1805a) 'kageki'
181
182  - Region stored at 0x9fff.b (CPU1 - bank = 0x03) then 0xe000 (shared RAM)
183  - Sets :
184      * 'kageki'   : region = 0x02
185  - Coinage relies on region (code at 0x0099 in CPU1) :
186      * 0x01 and 0x02 : TAITO_COINAGE_JAPAN_OLD
187      * 0x03 and 0x04 : TAITO_COINAGE_WORLD
188  - No notice screen
189  - Copyright relies on region (code at 0x1eeb) :
190      * 0x01 : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
191      * 0x02 : "TAITO AMERICA CORP." / "LICENCED TO ROMSTAR" / "FOR U.S.A." (US)
192      * else : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World / ???)
193  - English text on bad guys screens when game starts + English samples
194  - 2 players gameplay : players fight against each other in a best of 3 VS match,
195    then the winner is allowed to fight against the CPU enemies.
196    This is the reason why I've named DSWA bit 0 as "Unused".
197    Note that if there is a draw (same energy for both players), player 1 wins.
198
1995b) 'kagekij'
200
201  - Region stored at 0x9fff.b (CPU1 - bank = 0x03) then 0xe000 (shared RAM)
202  - Sets :
203      * 'kagekij'  : region = 0x01
204  - Coinage relies on region (code at 0x0099 in CPU1) :
205      * 0x01 and 0x02 : TAITO_COINAGE_JAPAN_OLD
206      * 0x03 and 0x04 : TAITO_COINAGE_WORLD
207  - No notice screen
208  - Copyright relies on region (code at 0x1eb3) :
209      * 0x01 : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
210      * 0x02 : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED" (US)
211      * else : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World / ???)
212  - Japanese text on bad guys screens when game starts + Japanese samples
213  - 2 players gameplay : players fight one after the other against CPU enemies.
214    Once an enemy is defeated or a player is dead, it's the other player turn.
215  - Code and data differences :
216      * CPU0 to be looked at carefully
217      * 0x9fff (CPU1 - bank = 0x03) : 0x01 instead of 0x02 (value for region tests)
218
2195c) 'kagekih'
220
221  - Region stored at 0x9fff.b (CPU1 - bank = 0x03) then 0xe000 (shared RAM)
222  - Sets :
223      * 'kagekij'  : region = 0x01
224  - This set really looks like a hack :
225      * year has been changed from 1988 to 1992
226      * the game uses Japanese ROMS, but CPU0 ROM displays Engish text
227        on bad guys screens when game starts
228  - Coinage relies on region (code at 0x0099 in CPU1) :
229      * 0x01 and 0x02 : TAITO_COINAGE_JAPAN_OLD
230      * 0x03 and 0x04 : TAITO_COINAGE_WORLD
231  - No notice screen
232  - Copyright relies on region (code at 0x1ee0) :
233      * 0x01 : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
234      * 0x02 : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED" (US)
235      * else : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World / ???)
236  - English text on bad guys screens when game starts but Japanese samples !
237  - 2 players gameplay : players fight against each other in a best of 3 VS match,
238    then the winner is allowed to fight against the CPU enemies.
239    This is the reason why I've named DSWA bit 0 as "Unused".
240    Note that if there is a draw (same energy for both players), player 1 wins.
241  - Code and data differences :
242      * CPU0 to be looked at carefully
243      * 0x9fff (CPU1 - bank = 0x03) : 0x01 instead of 0x02 (value for region tests)
244
245
2466) 'chukatai' and clones
247
248  - Region stored at 0x9fff.b (CPU1 - bank = 0x03) then 0xe01a (shared RAM)
249  - Sets :
250      * 'chukatai' : region = 0x03
251      * 'chukatau' : region = 0x02
252      * 'chukataj' : region = 0x01
253  - These 3 games are 100% the same, only region differs !
254    However, dumps for 'chukatai' and 'chukatau' are unsure (wrong ROM numbers).
255  - Coinage relies on region (code at 0x0114 in CPU1) :
256      * 0x01 and 0x02 : TAITO_COINAGE_JAPAN_OLD
257      * 0x03 and 0x04 : TAITO_COINAGE_WORLD
258  - Notice screen relies on region (code at 0x0253) :
259      * 0x01 : Yes
260      * else : No
261  - Copyright relies on region (code at 0x0b38) :
262      * 0x01 : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
263      * 0x02 : "TAITO AMERICA CORPORATION" / "ALL RIGHTS RESERVED" (US)
264      * else : "TAITO CORPORATION JAPAN" / "ALL RIGHTS RESERVED" (World / ???)
265    I still need to understand how the strings are displayed though.
266  - Power-ups display is affected by the region
267
268
2697) 'tnzs' and clones
270
2717a) 'tnzs' and 'tnzsj'
272
273  - Region stored at 0x7fff.b (CPU1)
274  - Sets :
275      * 'tnzs'     : region = 0x03
276      * 'tnzsj'    : region = 0x01
277  - These 2 games are 100% the same, only region differs !
278  - Code at 0x00fb (CPU1) changes region to another value :
279      * 0x01 -> 0x00
280      * 0x02 -> 0x06
281      * 0x03 -> 0x0b
282      * 0x04 -> 0x0e
283    This value is stored at 0xd035 (CPU1) then 0xef1d (shared RAM).
284  - Coinage relies on bit 0 of the new value (code at 0x0aa7 in CPU1) :
285      * .......0 : TAITO_COINAGE_JAPAN_OLD
286      * .......1 : TAITO_COINAGE_WORLD
287  - Notice screen relies on bit 1 of the new value (code at 0xbed0 - bank = 0x05) :
288      * ......0. : Yes
289      * ......1. : No
290  - Copyright relies on bits 2 and 3 of the new value (code at 0x12eb) :
291      * ....00.. : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
292      * ....01.. : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED" (US)
293      * ....10.. : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World)
294      * ....11.. : "TAITO CORP. JAPAN" / "LICENCED TO           "
295  - New Taito logo
296
2977b) 'tnzsjo'
298
299  - Region stored at 0x7fff.b (CPU1)
300  - Sets :
301      * 'tnzsjo'   : region = 0x01
302  - Code at 0x00f7 (CPU1) changes region to another value :
303      * 0x01 -> 0x00
304      * 0x02 -> 0x06
305      * 0x03 -> 0x0b
306      * 0x04 -> 0x0e
307    This value is stored at 0xd035 (CPU1) then 0xef1d (shared RAM).
308  - Coinage relies on bit 0 of the new value (code at 0x5f68 in CPU1) :
309      * .......0 : TAITO_COINAGE_JAPAN_OLD
310      * .......1 : TAITO_COINAGE_WORLD
311  - Notice screen relies on bit 1 of the new value (code at 0xbbb5 - bank = 0x05) :
312      * ......0. : Yes
313      * ......1. : No
314  - Copyright relies on bits 2 and 3 of the new value (code at 0x12ed) :
315      * ....00.. : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
316      * ....01.. : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED" (US)
317      * ....10.. : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World)
318      * ....11.. : "TAITO CORP. JAPAN" / "LICENCED TO           "
319  - New Taito logo
320  - levels are different from 'tnzs'
321
3227c) 'tnzso'
323
324  - Region stored at 0x7fff.b (CPU1)
325  - Sets :
326      * 'tnzso'    : region = 0x03
327  - Code at 0x021e (CPU1) changes region to another value :
328      * 0x01 -> 0x00
329      * 0x02 -> 0x06
330      * 0x03 -> 0x0b
331      * 0x04 -> 0x0e
332    This value is stored at 0xd46b (CPU1) then 0xef1d (shared RAM).
333  - Coinage relies on bit 0 of the new value (code at 0x5d91 in CPU1) :
334      * .......0 : TAITO_COINAGE_JAPAN_OLD
335      * .......1 : TAITO_COINAGE_WORLD
336  - Notice screen relies on bit 1 of the new value (code at 0x0cdd) :
337      * ......0. : Yes
338      * ......1. : No
339  - Copyright relies on bits 2 and 3 of the new value (code at 0x1062) :
340      * ....00.. : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
341      * ....01.. : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED" (US)
342      * ....10.. : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World)
343      * ....11.. : "TAITO CORP. JAPAN" / "LICENCED TO           "
344  - Old Taito logo
345  - levels are different from 'tnzs' and 'tnzsjo'
346
347
3488) 'kabukiz' and clones
349
350  - No region byte : a value is loaded in register A each time it is needed !
351  - Sets :
352      * 'kabukiz'  : value = 0x02
353      * 'kabukizj' : value = 0x00
354  - Coinage relies on register A (code at 0x016c in CPU1)
355      * 0x02 : TAITO_COINAGE_WORLD
356      * else : TAITO_COINAGE_JAPAN_OLD
357  - Notice screen relies on register A (code at 0x0b30 in CPU1) :
358      * 0x00 : Yes
359      * else : No
360  - Copyright relies on register A (code at 0x0d4e in CPU1)
361      * 0x00 : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
362      * 0x01 : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED" (US)
363      * else : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED" (World)
364  - 'babukizj' has extra code in CPU1 to be looked at carefully.
365
366
3679) 'insectx'
368
369  - Region stored at 0x9fff.b (CPU1 - bank = 0x03) then 0xec21 (shared RAM)
370  - Sets :
371      * 'insectx'  : region = 0x03
372  - Coinage relies on region (code at 0x025b in CPU1) :
373      * 0x01 : TAITO_COINAGE_JAPAN_OLD
374      * 0x02 : TAITO_COINAGE_US
375      * else : TAITO_COINAGE_WORLD
376  - Notice screen relies on region (code at 0x0a6c) :
377      * 0x01 : Yes
378      * else : No
379  - Copyright relies on region (code at 0xac16 - bank = 0x02) :
380      * 0x01 : "TAITO CORPORATION" / "ALL RIGHTS RESERVED" (Japan)
381      * 0x02 : "TAITO AMERICA CORPORATION" / "ALL RIGHTS RESERVED" (US)
382      * else : "TAITO CORPORATION JAPAN" / "ALL RIGHTS RESERVED" (World)
383  - This game doesn't use standard settings for "Difficulty" Dip Switch :
384    look at table at 0x1b86 (4 * 2 bytes) and especially table at 0x4731
385    (4 bytes) which determines end of level boss energy via code at 0x46e2,
386    and you'll notice that "Easy" and "Hard" settings are swapped.
387    End of level boss energy is stored at 0xe484 and 0xe485 (LSB first).
388
389
39010) 'jpopnics'
391
392  - Region stored at 0x7fff.b (CPU1) then 0xef49 (shared RAM)
393  - Sets :
394      * 'jpopnics' : region = 0x00
395  - Coinage relies on bit 0 of the region (code at 0x5141 in CPU1) :
396      * .......0 : TAITO_COINAGE_JAPAN_OLD
397      * .......1 : TAITO_COINAGE_WORLD
398    However, coinage is in fact always 1C_1C for both coin slots due to
399    'ret' instruction at 0x5151 and way coins are handled at 0x4f60.
400  - Notice screen relies on bit 1 of the region (code at 0x16e8) :
401      * ......0. : Yes
402      * ......1. : No
403    Notice screen displays "Korea" instead of "Japan".
404  - Copyright relies on bits 2 and 3 of the region (code at 0x276d),
405    but table at 0x2781 is the same for any combinaison :
406      * ....??.. : "NICS CO. LTD. 1992" / "ALL RIGHTS RESERVED"
407
408
46409TODO:
47410-----
48411- Find out how the hardware credit-counter works (MPU)
49- Verify dip switches
412- Fix MCU simulation errors :
413    * avoid credits to be increased when in "test mode" to avoid coin lockout
414      (needed to complete special test mode in 'extermatn' and 'arknoid2')
415    * why are credits limited to 9 in some games ?
416      pressing SERVICE1 allows to go up to 100 and cause this :
417        . 'plumppop' : freeze
418        . 'extrmatn' : reset
419        . 'arknoid2' : coin overflow
50420- Fix video offsets (See Dr Toppel in Flip-Screen - also affects Chuka Taisen)
51421- Video scroll side flicker in Chuka Taisen, Insector X, Dr Toppel, Kabuki Z
52- Sprite/background sync during scrolling, e.g. insectorx, kabukiz.
422- Sprite/background sync during scrolling, e.g. insectx, kabukiz.
53423- Merge video driver with seta.c (it's the same thing but seta.c assumes a 16-bit CPU)
424- Figure out remaining unknown Dip Switches in 'plumppop' and 'jpopnics'
425- Get rid of the COMMON_* macros to use generic INPUT_PORTS definition
426  and PORT_INCLUDE macro by changing the ym2203_config definition
54427
428
55429Arkanoid 2:
56430  - What do writes at $f400 do ?
57431  - Why does the game zero the $fd00 area ?
r3485r3486
569943   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(jpopnics_palette_w) AM_BASE(&paletteram)
570944ADDRESS_MAP_END
571945
572#ifdef UNUSED_FUNCTION
573READ8_HANDLER( moo_r )
574{
575   return mame_rand(machine);
576}
577
578READ8_HANDLER( bbb_r )
579{
580   return 0xff;
581}
582#endif
583
584946static WRITE8_HANDLER( jpopnics_subbankswitch_w )
585947{
586948   UINT8 *RAM = memory_region(machine, "sub");
r3485r3486
589951   memory_set_bankptr (2, &RAM[0x10000 + 0x2000 * (data & 3)]);
590952}
591953
592
593954static ADDRESS_MAP_START( jpopnics_sub_map, ADDRESS_SPACE_PROGRAM, 8 )
594955   AM_RANGE(0x0000, 0x7fff) AM_ROM
595956   AM_RANGE(0x8000, 0x9fff) AM_READWRITE(SMH_BANK2, SMH_ROM)
r3485r3486
608969   AM_RANGE(0xf000, 0xf003) AM_READ(arknoid2_sh_f000_r)
609970ADDRESS_MAP_END
610971
972
611973#define COMMON_IN2\
612974   PORT_START("IN2")\
613975   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )\
r3485r3486
629991   PORT_BIT( 0x01, coinstate, IPT_COIN2 )\
630992   PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNUSED )
631993
632static INPUT_PORTS_START( extrmatn )
994
995static INPUT_PORTS_START( plumppop )
996   /* 0xb001 (CPU1) port 0 -> 0xef0e (shared RAM) */
633997   PORT_START("DSWA")
634   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
998   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )               /* code at 0x6e99 - is it ever called ? */
635999   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
6361000   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1001   TAITO_DSWA_BITS_1_TO_3
1002   TAITO_COINAGE_JAPAN_OLD
1003
1004   /* 0xb001 (CPU1) port 1 -> 0xef0f (shared RAM) */
1005   PORT_START("DSWB")
1006   TAITO_DIFFICULTY
1007   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )            /* table at 0x2b86 */
1008   PORT_DIPSETTING(    0x08, "50k 200k 150k+" )
1009   PORT_DIPSETTING(    0x0c, "50k 250k 200k+" )
1010   PORT_DIPSETTING(    0x04, "100k 300k 200k+" )
1011   PORT_DIPSETTING(    0x00, "100k 400k 300k+" )
1012   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
1013   PORT_DIPSETTING(    0x20, "2" )
1014   PORT_DIPSETTING(    0x30, "3" )
1015   PORT_DIPSETTING(    0x10, "4" )
1016   PORT_DIPSETTING(    0x00, "5" )
1017   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )               /* code at 0x3dcc */
1018   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1019   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1020   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) )
1021   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
1022   PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
1023
1024   PORT_START("IN0")
1025   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1026   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1027   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1028   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1029   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
1030   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 Button 2 (Cheat)")
1031   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1032   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
1033
1034   PORT_START("IN1")
1035   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1036   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1037   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1038   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1039   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
1040   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Button 2 (Cheat)")    /* not working ? */
1041   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1042   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
1043
1044   PORT_START("IN2")
1045   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )
1046   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_TILT )
1047   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1048   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1049   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN1 )
1050   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN2 )
1051   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1052   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1053
1054   COMMON_COIN1(IP_ACTIVE_HIGH)
1055   COMMON_COIN2(IP_ACTIVE_HIGH)
1056
1057   PORT_START("AN1")      /* spinner 1 - read at f000/1 */
1058   PORT_BIT( 0xffff, 0x0000, IPT_DIAL ) PORT_SENSITIVITY(70) PORT_KEYDELTA(15) PORT_PLAYER(1)
1059
1060   PORT_START("AN2")      /* spinner 2 - read at f002/3 */
1061   PORT_BIT( 0xffff, 0x0000, IPT_DIAL ) PORT_SENSITIVITY(70) PORT_KEYDELTA(15) PORT_PLAYER(2)
1062INPUT_PORTS_END
1063
1064
1065static INPUT_PORTS_START( extrmatn )
1066   /* 0xb001 (CPU1) port 0 -> 0xef0e (shared RAM) */
1067   PORT_START("DSWA")
1068   PORT_DIPUNUSED( 0x01, IP_ACTIVE_LOW )
6371069   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
6381070   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
6391071   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6401072   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
641   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
642   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
643   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1073   PORT_DIPUNUSED( 0x08, IP_ACTIVE_LOW )
6441074   TAITO_COINAGE_JAPAN_OLD
6451075
1076   /* 0xb001 (CPU1) port 1 -> 0xef0f (shared RAM) */
6461077   PORT_START("DSWB")
647   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
648   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
649   PORT_DIPSETTING(    0x03, DEF_STR( Normal ) )
650   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
651   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
652   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
653   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
654   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
655   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
656   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
657   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
658   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
659   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
660   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
661   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
662   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
663   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1078   TAITO_DIFFICULTY
1079   PORT_DIPUNUSED( 0x04, IP_ACTIVE_LOW )
1080   PORT_DIPUNUSED( 0x08, IP_ACTIVE_LOW )
1081   PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )
1082   PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )
6641083   PORT_DIPNAME( 0xc0, 0xc0, "Damage Multiplier" )
6651084   PORT_DIPSETTING(    0xc0, "*1" )
6661085   PORT_DIPSETTING(    0x80, "*1.5" )
r3485r3486
6781097   COMMON_COIN2(IP_ACTIVE_HIGH)
6791098INPUT_PORTS_END
6801099
1100
6811101static INPUT_PORTS_START( arknoid2 )
1102   /* 0xb001 (CPU1) port 0 -> 0xe001 (shared RAM) */
6821103   PORT_START("DSWA")
683   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
684   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
685   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
686   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
687   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
688   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
689   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
690   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
691   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
692   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
1104   TAITO_MACHINE_COCKTAIL
6931105   TAITO_COINAGE_WORLD
6941106
1107   /* 0xb001 (CPU1) port 1 -> 0xe002 (shared RAM) */
6951108   PORT_START("DSWB")
696   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
697   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
698   PORT_DIPSETTING(    0x03, DEF_STR( Normal ) )
699   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
700   PORT_DIPSETTING(    0x00, DEF_STR( Very_Hard ) )
701   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
702   PORT_DIPSETTING(    0x00, "50k 150k" )
703   PORT_DIPSETTING(    0x0c, "100k 200k" )
704   PORT_DIPSETTING(    0x04, "50k Only" )
705   PORT_DIPSETTING(    0x08, "100k Only" )
1109   TAITO_DIFFICULTY
1110   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )            /* table at 0x6f1e (W and J) or 0x6f1b (Romstar) */
1111   PORT_DIPSETTING(    0x00, "50k 150k 150k+" )
1112   PORT_DIPSETTING(    0x0c, "100k 200k 200k+" )
1113   PORT_DIPSETTING(    0x04, "50k only" )
1114   PORT_DIPSETTING(    0x08, "100k only" )
7061115   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
7071116   PORT_DIPSETTING(    0x20, "2" )
7081117   PORT_DIPSETTING(    0x30, "3" )
7091118   PORT_DIPSETTING(    0x10, "4" )
7101119   PORT_DIPSETTING(    0x00, "5" )
711   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
712   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
713   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1120   PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
7141121   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Allow_Continue ) )
7151122   PORT_DIPSETTING(    0x80, DEF_STR( No ) )
7161123   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
r3485r3486
7511158   TAITO_COINAGE_JAPAN_OLD
7521159INPUT_PORTS_END
7531160
754static INPUT_PORTS_START( plumppop )
1161
1162static INPUT_PORTS_START( drtoppel )
1163   /* 0xb001 (CPU1) port 0 -> 0xe042 (shared RAM) */
7551164   PORT_START("DSWA")
756   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
757   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
758   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
759   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
760   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
761   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
762   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
763   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
764   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
765   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
766   TAITO_COINAGE_JAPAN_OLD
1165   TAITO_MACHINE_COCKTAIL
1166   TAITO_COINAGE_WORLD
7671167
1168   /* 0xb001 (CPU1) port 1 -> 0xe043 (shared RAM) */
7681169   PORT_START("DSWB")
769   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
770   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
771   PORT_DIPSETTING(    0x03, DEF_STR( Medium ) )
772   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
773   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
774   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
775   PORT_DIPSETTING(    0x08, "50k 150k" )
776   PORT_DIPSETTING(    0x0c, "70k 200k" )
777   PORT_DIPSETTING(    0x04, "100k 250k" )
778   PORT_DIPSETTING(    0x00, "200k 300k" )
1170   TAITO_DIFFICULTY
1171   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )            /* table at 0x256d (4 * 9 bytes) */
1172   PORT_DIPSETTING(    0x0c, "30k 100k 200k 100k+" )            /* 30k  100k  200k  300k  400k  500k  600k  700k */
1173   PORT_DIPSETTING(    0x00, "50k 100k 200k 200k+" )            /* 50k  100k  200k  400k  600k  800k 1000k 1200k */
1174   PORT_DIPSETTING(    0x04, "30k 100k" )
1175   PORT_DIPSETTING(    0x08, "30k only" )
7791176   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
7801177   PORT_DIPSETTING(    0x20, "2" )
7811178   PORT_DIPSETTING(    0x30, "3" )
7821179   PORT_DIPSETTING(    0x10, "4" )
7831180   PORT_DIPSETTING(    0x00, "5" )
784   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
785   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
786   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
787   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) )
788   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
789   PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
1181   PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
1182   PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
7901183
7911184   PORT_START("IN0")
792   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
793   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
794   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
795   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
796   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
797   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 Button 2 (Cheat)")// Cop out, I know, but I've never played this (EC)
798   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
799   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
1185   TAITO_JOY_LRUD_2_BUTTONS_START( 1 )
8001186
8011187   PORT_START("IN1")
802   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
803   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
804   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
805   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
806   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
807   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P2 Button 2 (Cheat)") PORT_PLAYER(2)
808   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
809   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
1188   TAITO_JOY_LRUD_2_BUTTONS_START( 2 )
8101189
811   PORT_START("IN2")
812   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )
813   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_TILT )
814   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
815   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
816   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN1 )
817   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_COIN2 )
818   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
819   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
820
1190   COMMON_IN2
8211191   COMMON_COIN1(IP_ACTIVE_HIGH)
8221192   COMMON_COIN2(IP_ACTIVE_HIGH)
1193INPUT_PORTS_END
8231194
824   PORT_START("AN1")      /* spinner 1 - read at f000/1 */
825   PORT_BIT( 0xffff, 0x0000, IPT_DIAL ) PORT_SENSITIVITY(70) PORT_KEYDELTA(15)
1195static INPUT_PORTS_START( drtopplu )
1196   PORT_INCLUDE( drtoppel )
8261197
827   PORT_START("AN2")      /* spinner 2 - read at f002/3 */
828   PORT_BIT( 0xffff, 0x0000, IPT_DIAL ) PORT_SENSITIVITY(70) PORT_KEYDELTA(15) PORT_PLAYER(2)
1198   PORT_MODIFY("DSWA")
1199   TAITO_COINAGE_JAPAN_OLD
8291200INPUT_PORTS_END
8301201
8311202
832static INPUT_PORTS_START( jpopnics )
1203static INPUT_PORTS_START( kageki )
1204   /* special (see kageki_csport_* handlers) -> 0xe03b (shared RAM) */
1205   PORT_START("DSWA")
1206   TAITO_MACHINE_NO_COCKTAIL                                    /* see notes */
1207   TAITO_COINAGE_JAPAN_OLD
1208
1209   /* special (see kageki_csport_* handlers) -> 0xe03c (shared RAM) */
1210   PORT_START("DSWB")
1211   TAITO_DIFFICULTY
1212   PORT_DIPUNUSED( 0x04, IP_ACTIVE_LOW )
1213   PORT_DIPUNUSED( 0x08, IP_ACTIVE_LOW )
1214   PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )
1215   PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )
1216   PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
1217   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) )
1218   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
1219   PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
1220
8331221   PORT_START("IN0")
834   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
1222   TAITO_JOY_LRUD_2_BUTTONS_START( 1 )
8351223
8361224   PORT_START("IN1")
837   PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
838   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
839   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 Button 2 (Cheat)")
840   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
841   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
1225   TAITO_JOY_LRUD_2_BUTTONS_START( 2 )
8421226
8431227   PORT_START("IN2")
844   PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
845   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
846   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P2 Button 2 (Cheat)") PORT_PLAYER(2)
847   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
848   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
1228   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )
1229   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_TILT )
1230   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1231   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1232   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 )
1233   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
1234   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1235   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1236INPUT_PORTS_END
8491237
850    PORT_START("DSWA")
851   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
852   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
853   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
854   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
855   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
856   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
857   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
858   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
859   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
860   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
861   TAITO_COINAGE_JAPAN_OLD
1238static INPUT_PORTS_START( kagekij )
1239   PORT_INCLUDE( kageki )
8621240
863     PORT_START("DSWB")
864     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
865     PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
866     PORT_DIPSETTING(    0x03, DEF_STR( Medium ) )
867     PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
868     PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
869     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
870     PORT_DIPSETTING(    0x08, "50k 150k" )
871     PORT_DIPSETTING(    0x0c, "70k 200k" )
872     PORT_DIPSETTING(    0x04, "100k 250k" )
873     PORT_DIPSETTING(    0x00, "200k 300k" )
874     PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
875     PORT_DIPSETTING(    0x20, "2" )
876     PORT_DIPSETTING(    0x30, "3" )
877     PORT_DIPSETTING(    0x10, "4" )
878     PORT_DIPSETTING(    0x00, "5" )
879     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
880     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
881     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
882     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) )
883     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
884     PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
1241   PORT_MODIFY("DSWA")
1242   TAITO_MACHINE_COCKTAIL                                       /* see notes */
1243INPUT_PORTS_END
8851244
886   PORT_START("COIN1")
887   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
8881245
889   PORT_START("COIN2")
890   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
891
892   PORT_START("AN1")      /* spinner 1 - read at f000/1 */
893   PORT_BIT( 0xffff, 0x0000, IPT_DIAL ) PORT_SENSITIVITY(70) PORT_KEYDELTA(15)
894
895   PORT_START("AN2")      /* spinner 2 - read at f002/3 */
896   PORT_BIT( 0xffff, 0x0000, IPT_DIAL ) PORT_SENSITIVITY(70) PORT_KEYDELTA(15) PORT_PLAYER(2)
897INPUT_PORTS_END
898
899static INPUT_PORTS_START( drtoppel )
1246static INPUT_PORTS_START( chukatai )
1247   /* 0xb001 (CPU1) port 0 -> 0xe015 (shared RAM) */
9001248   PORT_START("DSWA")
901   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
902   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
903   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
904   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
905   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
906   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
907   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
908   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
909   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
910   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
1249   TAITO_MACHINE_COCKTAIL
9111250   TAITO_COINAGE_WORLD
9121251
1252   /* 0xb001 (CPU1) port 1 -> 0xe016 (shared RAM) */
9131253   PORT_START("DSWB")
914   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
915   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
916   PORT_DIPSETTING(    0x03, DEF_STR( Medium ) )
917   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
918   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
919   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
920   PORT_DIPSETTING(    0x0c, "30000" )
921   PORT_DIPSETTING(    0x00, DEF_STR( Unknown ) )
922   PORT_DIPSETTING(    0x04, DEF_STR( Unknown ) )
923   PORT_DIPSETTING(    0x08, DEF_STR( Unknown ) )
1254   TAITO_DIFFICULTY
1255   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )            /* tables : 1st at 0xb070 (bank = 0x02) and inc. at 0x09df */
1256   PORT_DIPSETTING(    0x08, "40k 240k 200k+" )
1257   PORT_DIPSETTING(    0x0c, "60k 360k 300k+" )
1258   PORT_DIPSETTING(    0x04, "100k 500k 400k+" )
1259   PORT_DIPSETTING(    0x00, "150k 650k 500k+" )
9241260   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
925   PORT_DIPSETTING(    0x20, "2" )
1261   PORT_DIPSETTING(    0x00, "1" )
1262   PORT_DIPSETTING(    0x10, "2" )
9261263   PORT_DIPSETTING(    0x30, "3" )
927   PORT_DIPSETTING(    0x10, "4" )
928   PORT_DIPSETTING(    0x00, "5" )
929   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
930   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
931   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
932   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
933   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
934   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1264   PORT_DIPSETTING(    0x20, "4" )
1265   PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
1266   PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
9351267
9361268   PORT_START("IN0")
9371269   TAITO_JOY_LRUD_2_BUTTONS_START( 1 )
r3485r3486
9441276   COMMON_COIN2(IP_ACTIVE_HIGH)
9451277INPUT_PORTS_END
9461278
947static INPUT_PORTS_START( drtopplu )
948   PORT_INCLUDE( drtoppel )
1279static INPUT_PORTS_START( chukatau )
1280   PORT_INCLUDE( chukatai )
9491281
9501282   PORT_MODIFY("DSWA")
9511283   TAITO_COINAGE_JAPAN_OLD
9521284INPUT_PORTS_END
9531285
954static INPUT_PORTS_START( chukatai )
1286
1287static INPUT_PORTS_START( tnzs )
1288   /* 0xb002 (CPU1) -> 0xef0e (shared RAM) */
9551289   PORT_START("DSWA")
9561290   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
9571291   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
r3485r3486
9601294   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
9611295   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
9621296   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
963   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
964   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
965   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
1297   PORT_DIPNAME( 0x08, 0x08, "Invulnerability (Debug)" )        // see notes
1298   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1299   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
9661300   TAITO_COINAGE_WORLD
9671301
1302   /* 0xb003 (CPU1) -> 0xef0f (shared RAM) */
9681303   PORT_START("DSWB")
969   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
970   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
971   PORT_DIPSETTING(    0x03, DEF_STR( Medium ) )
972   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
973   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
974   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
975   PORT_DIPSETTING(    0x08, "100k 300k 440k" )
976   PORT_DIPSETTING(    0x00, "100k 300k 500k" )
977   PORT_DIPSETTING(    0x0c, "100k 400k" )
978   PORT_DIPSETTING(    0x04, "100k 500k" )
1304   TAITO_DIFFICULTY
1305   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )            /* table at 0x09c84 */
1306   PORT_DIPSETTING(    0x00, "50k 150k 150k+" )
1307   PORT_DIPSETTING(    0x0c, "70k 200k 200k+" )
1308   PORT_DIPSETTING(    0x04, "100k 250k 250k+" )
1309   PORT_DIPSETTING(    0x08, "200k 300k 300k+" )
9791310   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
980   PORT_DIPSETTING(    0x00, "1" )
981   PORT_DIPSETTING(    0x10, "2" )
1311   PORT_DIPSETTING(    0x20, "2" )
9821312   PORT_DIPSETTING(    0x30, "3" )
983   PORT_DIPSETTING(    0x20, "4" )
984   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
985   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
986   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
987   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
988   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
989   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1313   PORT_DIPSETTING(    0x00, "4" )
1314   PORT_DIPSETTING(    0x10, "5" )
1315   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
1316   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
1317   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
1318   PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
9901319
9911320   PORT_START("IN0")
9921321   TAITO_JOY_LRUD_2_BUTTONS_START( 1 )
r3485r3486
9941323   PORT_START("IN1")
9951324   TAITO_JOY_LRUD_2_BUTTONS_START( 2 )
9961325
997   COMMON_IN2
998   COMMON_COIN1(IP_ACTIVE_HIGH)
999   COMMON_COIN2(IP_ACTIVE_HIGH)
1326   PORT_START("IN2")
1327   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )
1328   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_TILT )
1329   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1330   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1331   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 )
1332   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
1333   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1334   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
10001335INPUT_PORTS_END
10011336
1002static INPUT_PORTS_START( chukatau )
1003   PORT_INCLUDE( chukatai )
1337static INPUT_PORTS_START( tnzsj )
1338   PORT_INCLUDE( tnzs )
10041339
10051340   PORT_MODIFY("DSWA")
10061341   TAITO_COINAGE_JAPAN_OLD
10071342INPUT_PORTS_END
10081343
1009static INPUT_PORTS_START( tnzs )
1344static INPUT_PORTS_START( tnzsjo )
1345   /* 0xb001 (CPU1) port 0 -> 0xef0e (shared RAM) */
10101346   PORT_START("DSWA")
10111347   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
10121348   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
r3485r3486
10201356   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
10211357   TAITO_COINAGE_JAPAN_OLD
10221358
1359   /* 0xb001 (CPU1) port 1 -> 0xef0f (shared RAM) */
10231360   PORT_START("DSWB")
1024   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
1025   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
1026   PORT_DIPSETTING(    0x03, DEF_STR( Medium ) )
1027   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
1028   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
1029   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
1030   PORT_DIPSETTING(    0x00, "50000 150000" )
1031   PORT_DIPSETTING(    0x0c, "70000 200000" )
1032   PORT_DIPSETTING(    0x04, "100000 250000" )
1033   PORT_DIPSETTING(    0x08, "200000 300000" )
1361   TAITO_DIFFICULTY
1362   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )            /* table at 0x09caf */
1363   PORT_DIPSETTING(    0x00, "50k 150k 150k+" )
1364   PORT_DIPSETTING(    0x0c, "70k 200k 200k+" )
1365   PORT_DIPSETTING(    0x04, "100k 250k 250k+" )
1366   PORT_DIPSETTING(    0x08, "200k 300k 300k+" )
10341367   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
10351368   PORT_DIPSETTING(    0x20, "2" )
10361369   PORT_DIPSETTING(    0x30, "3" )
r3485r3486
10391372   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
10401373   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
10411374   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
1042   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
1043   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1044   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1375   PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
10451376
10461377   PORT_START("IN0")
10471378   TAITO_JOY_LRUD_2_BUTTONS_START( 1 )
r3485r3486
10541385   COMMON_COIN2(IP_ACTIVE_LOW)
10551386INPUT_PORTS_END
10561387
1057static INPUT_PORTS_START( tnzsb )
1058   PORT_INCLUDE( tnzs )
1388static INPUT_PORTS_START( tnzso )
1389   PORT_INCLUDE( tnzsjo )
10591390
10601391   PORT_MODIFY("DSWA")
1392   PORT_DIPUNUSED( 0x08, IP_ACTIVE_LOW )                        /* value read at 0x356b but not tested nor stored elsewhere */
10611393   TAITO_COINAGE_WORLD
10621394
1063   PORT_MODIFY("IN1")
1064   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_COCKTAIL
1065   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_COCKTAIL
1066   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_COCKTAIL
1067   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_COCKTAIL
1068   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
1069   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
1070   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1071   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2)
1072
1073   PORT_MODIFY("IN2")
1074   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 )
1075   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
1076
1077   PORT_MODIFY("COIN1")   /* not present in the bootleg */
1078   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
1079
1080   PORT_MODIFY("COIN2")   /* not present in the bootleg */
1081   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
1395   PORT_MODIFY("DSWB")
1396   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )            /* table at 0x09afb */
1397   PORT_DIPSETTING(    0x00, "10k 100k 100k+" )
1398   PORT_DIPSETTING(    0x0c, "10k 150k 150k+" )
1399   PORT_DIPSETTING(    0x04, "10k 200k 200k+" )
1400   PORT_DIPSETTING(    0x08, "10k 300k 300k+" )
10821401INPUT_PORTS_END
10831402
1084static INPUT_PORTS_START( tnzs2 )
1085   PORT_INCLUDE( tnzs )
10861403
1087   PORT_MODIFY("DSWA")
1088   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
1089   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1090   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1091   TAITO_COINAGE_WORLD
1092
1093   PORT_MODIFY("DSWB")
1094   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
1095   PORT_DIPSETTING(    0x00, "10000 100000" )
1096   PORT_DIPSETTING(    0x0c, "10000 150000" )
1097   PORT_DIPSETTING(    0x08, "10000 200000" )
1098   PORT_DIPSETTING(    0x04, "10000 300000" )
1099INPUT_PORTS_END
1100
11011404static INPUT_PORTS_START( kabukiz )
1405   /* 0xb002 (CPU1) */
11021406   PORT_START("DSWA")
1103   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
1104   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
1105   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
1106   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
1107   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
1108   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1109   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
1110   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
1111   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1112   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
1113   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
1114   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
1115   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1116   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
1117   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1118   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1119   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
1120   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1121   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1407   TAITO_MACHINE_COCKTAIL
1408   PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )
1409   PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )
1410   PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
11221411   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) )
11231412   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
11241413   PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
11251414
1415   /* 0xb003 (CPU1) */
11261416   PORT_START("DSWB")
1127   PORT_DIPNAME( 0x03, 0x02, DEF_STR( Difficulty ) )
1128   PORT_DIPSETTING(    0x03, DEF_STR( Easy ) )
1129   PORT_DIPSETTING(    0x02, DEF_STR( Normal ) )
1130   PORT_DIPSETTING(    0x01, DEF_STR( Medium ) )
1131   PORT_DIPSETTING(    0x00, DEF_STR( Hard ) )
1132   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
1133   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
1134   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1135   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
1136   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1137   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1138   TAITO_COINAGE_JAPAN_OLD
1417   TAITO_DIFFICULTY
1418   PORT_DIPUNUSED( 0x04, IP_ACTIVE_LOW )
1419   PORT_DIPUNUSED( 0x08, IP_ACTIVE_LOW )
1420   TAITO_COINAGE_WORLD
11391421
11401422   PORT_START("IN0")
11411423   TAITO_JOY_LRUD_2_BUTTONS_START( 1 )
11421424
11431425   PORT_START("IN1")
1144   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_COCKTAIL
1145   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_COCKTAIL
1146   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_COCKTAIL
1147   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_COCKTAIL
1148   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
1149   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
1150   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1151   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2)
1426   TAITO_JOY_LRUD_2_BUTTONS_START( 2 )
11521427
11531428   PORT_START("IN2")
11541429   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )
r3485r3486
11591434   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
11601435   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
11611436   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1437INPUT_PORTS_END
11621438
1439static INPUT_PORTS_START( kabukizj )
1440   PORT_INCLUDE( kabukiz )
1441
1442   PORT_MODIFY("DSWB")
1443   TAITO_COINAGE_JAPAN_OLD
11631444INPUT_PORTS_END
11641445
1446
11651447static INPUT_PORTS_START( insectx )
1448   /* 0xb001 (CPU1) port 0 -> 0xec06 (shared RAM) */
11661449   PORT_START("DSWA")
1167   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
1168   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
1169   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
1170   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
1171   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
1172   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1173   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
1174   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
1175   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1176   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
1450   TAITO_MACHINE_COCKTAIL
11771451   TAITO_COINAGE_WORLD
11781452
1453   /* 0xb001 (CPU1) port 1 -> 0xec07 (shared RAM) */
11791454   PORT_START("DSWB")
1180   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
1181   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
1455   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )            /* see notes */
1456   PORT_DIPSETTING(    0x01, DEF_STR( Easy ) )
11821457   PORT_DIPSETTING(    0x03, DEF_STR( Medium ) )
1183   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
1458   PORT_DIPSETTING(    0x02, DEF_STR( Hard ) )
11841459   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
1185   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
1186   PORT_DIPSETTING(    0x08, "100k 200k 300k 440k" )
1187   PORT_DIPSETTING(    0x0c, "100k 400k" )
1188   PORT_DIPSETTING(    0x04, "100k 500k" )
1189   PORT_DIPSETTING(    0x00, "150000 Only" )
1460   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )            /* code at 0xaacc - bank = 0x02 */
1461   PORT_DIPSETTING(    0x08, "40k 240k 200k+" )
1462   PORT_DIPSETTING(    0x0c, "60k 360k 300k+" )
1463   PORT_DIPSETTING(    0x04, "100k 500k 400k+" )
1464   PORT_DIPSETTING(    0x00, "150k 650k 500k+" )
11901465   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
11911466   PORT_DIPSETTING(    0x00, "1" )
11921467   PORT_DIPSETTING(    0x10, "2" )
11931468   PORT_DIPSETTING(    0x30, "3" )
11941469   PORT_DIPSETTING(    0x20, "4" )
1195   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
1196   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1197   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1198   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
1199   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1200   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1470   PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
1471   PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
12011472
12021473   PORT_START("IN0")
12031474   TAITO_JOY_LRUD_2_BUTTONS_START( 1 )
r3485r3486
12161487   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
12171488INPUT_PORTS_END
12181489
1219static INPUT_PORTS_START( kageki )
1220   PORT_START("DSWA")
1221   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
1222   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
1223   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
1224   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
1225   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
1490
1491static INPUT_PORTS_START( jpopnics )
1492   /* 0xc600 (CPU1) -> 0xef0e (shared RAM) */
1493    PORT_START("DSWA")
1494   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )               /* code at 0x6e99 - is it ever called ? */
1495   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
12261496   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1227   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
1228   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
1229   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1230   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
1231   TAITO_COINAGE_JAPAN_OLD
1497   TAITO_DSWA_BITS_1_TO_3
1498   PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )                        /* see notes */
1499   PORT_DIPUNUSED( 0x20, IP_ACTIVE_LOW )                        /* see notes */
1500   PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )                        /* see notes */
1501   PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )                        /* see notes */
12321502
1233   PORT_START("DSWB")
1234   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
1235   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
1236   PORT_DIPSETTING(    0x03, DEF_STR( Medium ) )
1237   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
1238   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
1239   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
1240   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
1241   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1242   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
1243   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1244   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1245   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
1246   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
1247   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1248   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
1249   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1250   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1251   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
1503   /* 0xc601 (CPU1) -> 0xef0f (shared RAM) */
1504     PORT_START("DSWB")
1505   TAITO_DIFFICULTY
1506   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )            /* table at 0x2b86 */
1507   PORT_DIPSETTING(    0x08, "50k 200k 150k+" )
1508   PORT_DIPSETTING(    0x0c, "50k 250k 200k+" )
1509   PORT_DIPSETTING(    0x04, "100k 300k 200k+" )
1510   PORT_DIPSETTING(    0x00, "100k 400k 300k+" )
1511     PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
1512     PORT_DIPSETTING(    0x20, "2" )
1513     PORT_DIPSETTING(    0x30, "3" )
1514     PORT_DIPSETTING(    0x10, "4" )
1515     PORT_DIPSETTING(    0x00, "5" )
1516   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )               /* code at 0x3dcc */
12521517   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
12531518   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1254   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) )
1255   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
1256   PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
1519     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) )
1520     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
1521     PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
12571522
12581523   PORT_START("IN0")
1259   TAITO_JOY_LRUD_2_BUTTONS_START( 1 )
1524   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
12601525
12611526   PORT_START("IN1")
1262   TAITO_JOY_LRUD_2_BUTTONS_START( 2 )
1527   PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
1528   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
1529   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 Button 2 (Cheat)")
1530   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
1531   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
12631532
12641533   PORT_START("IN2")
1265   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )
1266   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_TILT )
1267   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1268   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1269   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 )
1270   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
1271   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1272   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1534   PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
1535   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
1536   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Button 2 (Cheat)")    /* not working ? */
1537   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
1538   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
1539
1540   PORT_START("COIN1")
1541   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
1542
1543   PORT_START("COIN2")
1544   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
1545
1546   PORT_START("AN1")      /* spinner 1 - read at f000/1 */
1547   PORT_BIT( 0xffff, 0x0000, IPT_DIAL ) PORT_SENSITIVITY(70) PORT_KEYDELTA(15) PORT_PLAYER(1)
1548
1549   PORT_START("AN2")      /* spinner 2 - read at f002/3 */
1550   PORT_BIT( 0xffff, 0x0000, IPT_DIAL ) PORT_SENSITIVITY(70) PORT_KEYDELTA(15) PORT_PLAYER(2)
12731551INPUT_PORTS_END
12741552
1553
12751554static const gfx_layout tnzs_charlayout =
12761555{
12771556   16,16,
r3485r3486
19982277    supported because it appears to be a different code revision to the other supported sets
19992278*/
20002279
2001ROM_START( kagekia )
2280ROM_START( kagekih )
20022281   ROM_REGION( 0x30000, "main", 0 )
2003   ROM_LOAD( "b35_16.11c", 0x00000, 0x08000, CRC(1cf67603) SHA1(0627285ac69e44312d7694c64b96a81489d8663c) )   /* World? (hacked) ver */
2282   ROM_LOAD( "b35_16.11c", 0x00000, 0x08000, CRC(1cf67603) SHA1(0627285ac69e44312d7694c64b96a81489d8663c) )   /* hacked ver */
20042283   ROM_CONTINUE(           0x18000, 0x08000 )
20052284   ROM_LOAD( "b35-10.9c",  0x20000, 0x10000, CRC(b150457d) SHA1(a58e46e7dfdc93c2cc7c04d623d7754f85ba693b) )
20062285
r3485r3486
22322511   ROM_LOAD( "b53-21.1",   0xe0000, 0x20000, CRC(9800c54d) SHA1(761647177d621ac2cdd8b009876eed35809f3c92) )
22332512ROM_END
22342513
2235ROM_START( tnzsjn )
2514ROM_START( tnzsj )
22362515   ROM_REGION( 0x30000, "main", 0 )   /* 64k + bankswitch areas for the first CPU */
22372516   ROM_LOAD( "b53-24.1",   0x00000, 0x08000, CRC(d66824c6) SHA1(fd381ac0dc52ce670c3fde320ea60a209e288a52) )
22382517   ROM_CONTINUE(           0x18000, 0x18000 )      /* banked at 8000-bfff */
r3485r3486
22572536
22582537/* tnzs - old style PCB sets */
22592538
2260ROM_START( tnzsj )
2539ROM_START( tnzsjo )
22612540   ROM_REGION( 0x30000, "main", 0 )   /* 64k + bankswitch areas for the first CPU */
22622541   ROM_LOAD( "b53-10.32", 0x00000, 0x08000, CRC(a73745c6) SHA1(73eb38e75e08312d752332f988dc655084b4a86d) )
22632542   ROM_CONTINUE(          0x18000, 0x18000 )      /* banked at 8000-bfff */
r3485r3486
23082587Kabuki Z
23092588Taito, 1988
23102589
2311This PCB runs on Taito/Seta hardware and the exact same PCB as The New Zealand Story.
2590This PCB runs on Taito/Seta hardware and the exact same newer PCB as The New Zealand Story.
23122591As such, everything here also applies to The New Zealand Story.
23132592
23142593PCB Layout
r3485r3486
24152694GAME( 1987, drtopplu, drtoppel, drtoppel, drtopplu, drtoppel, ROT90,  "Taito America Corporation", "Dr. Toppel's Adventure (US)", 0 ) /* Possible region hack */
24162695GAME( 1987, drtopplj, drtoppel, drtoppel, drtopplu, drtoppel, ROT90,  "Taito Corporation", "Dr. Toppel's Tankentai (Japan)", 0 )
24172696GAME( 1988, kageki,   0,        kageki,   kageki,   kageki,   ROT90,  "Taito America Corporation (Romstar license)", "Kageki (US)", 0 )
2418GAME( 1988, kagekij,  kageki,   kageki,   kageki,   kageki,   ROT90,  "Taito Corporation", "Kageki (Japan)", 0 )
2419GAME( 1992, kagekia,  kageki,   kageki,   kageki,   kageki,   ROT90,  "Taito Corporation", "Kageki (World?, hack)", 0 ) // date is hacked at least, might also be a Japan set hacked to show english
2697GAME( 1988, kagekij,  kageki,   kageki,   kagekij,  kageki,   ROT90,  "Taito Corporation", "Kageki (Japan)", 0 )
2698GAME( 1992, kagekih,  kageki,   kageki,   kageki,   kageki,   ROT90,  "Taito Corporation", "Kageki (hack)", 0 ) // date is hacked at least, might also be a Japan set hacked to show english
24202699GAME( 1988, chukatai, 0,        tnzs,     chukatai, chukatai, ROT0,   "Taito Corporation Japan", "Chuka Taisen (World)", 0 ) /* Possible region hack */
24212700GAME( 1988, chukatau, chukatai, tnzs,     chukatau, chukatai, ROT0,   "Taito America Corporation", "Chuka Taisen (US)", 0 ) /* Possible region hack */
24222701GAME( 1988, chukataj, chukatai, tnzs,     chukatau, chukatai, ROT0,   "Taito Corporation", "Chuka Taisen (Japan)", 0 )
2423GAME( 1988, tnzs,     0,        tnzsb,    tnzsb,    tnzsb,    ROT0,   "Taito Corporation Japan", "The NewZealand Story (World, newer) (newer PCB)", 0 )
2424GAME( 1988, tnzsjn,   tnzs,     tnzsb,    tnzsb,    tnzsb,    ROT0,   "Taito Corporation", "The NewZealand Story (Japan) (newer PCB)", 0 )
2425GAME( 1988, tnzsj,    tnzs,     tnzs,     tnzs,     tnzs,     ROT0,   "Taito Corporation", "The NewZealand Story (Japan) (older PCB)", 0 )
2426GAME( 1988, tnzso,    tnzs,     tnzs,     tnzs2,    tnzs,     ROT0,   "Taito Corporation Japan", "The NewZealand Story (World, older) (older PCB)", 0 )
2702GAME( 1988, tnzs,     0,        tnzsb,    tnzs,     tnzsb,    ROT0,   "Taito Corporation Japan", "The NewZealand Story (World, new version) (newer PCB)", 0 )
2703GAME( 1988, tnzsj,    tnzs,     tnzsb,    tnzsj,    tnzsb,    ROT0,   "Taito Corporation", "The NewZealand Story (Japan, new version) (newer PCB)", 0 )
2704GAME( 1988, tnzsjo,   tnzs,     tnzs,     tnzsjo,   tnzs,     ROT0,   "Taito Corporation", "The NewZealand Story (Japan, old version) (older PCB)", 0 )
2705GAME( 1988, tnzso,    tnzs,     tnzs,     tnzso,    tnzs,     ROT0,   "Taito Corporation Japan", "The NewZealand Story (World, prototype?) (older PCB)", 0 )
24272706GAME( 1988, kabukiz,  0,        kabukiz,  kabukiz,  kabukiz,  ROT0,   "Taito Corporation Japan", "Kabuki-Z (World)", 0 )
2428GAME( 1988, kabukizj, kabukiz,  kabukiz,  kabukiz, kabukiz,  ROT0,   "Taito Corporation", "Kabuki-Z (Japan)", 0 )
2707GAME( 1988, kabukizj, kabukiz,  kabukiz,  kabukizj, kabukiz,  ROT0,   "Taito Corporation", "Kabuki-Z (Japan)", 0 )
24292708GAME( 1989, insectx,  0,        insectx,  insectx,  insectx,  ROT0,   "Taito Corporation Japan", "Insector X (World)", 0 )
24302709GAME( 1992, jpopnics, 0,        jpopnics, jpopnics, 0,        ROT0,   "Nics", "Jumping Pop (Nics, Korean bootleg of Plump Pop)", GAME_IMPERFECT_GRAPHICS )
2431
src/mame/drivers/plygonet.c
r3485r3486
6060
6161static int init_eeprom_count;
6262
63static UINT32 *shared_ram;
64static UINT16 *dsp56k_shared_ram_16;
63/* 68k-side shared ram */
64static UINT32* shared_ram;
6565
66static UINT16* dsp56k_p_mirror;
67static UINT16* dsp56k_p_8000;
68static const UINT16 dsp56k_bank00_size = 0x1000;      static UINT16* dsp56k_bank00_ram;
69static const UINT16 dsp56k_bank01_size = 0x1000;      static UINT16* dsp56k_bank01_ram;
70static const UINT16 dsp56k_bank02_size = 0x4000;      static UINT16* dsp56k_bank02_ram;
71static const UINT16 dsp56k_shared_ram_16_size = 0x2000;   static UINT16* dsp56k_shared_ram_16;
72static const UINT16 dsp56k_bank04_size = 0x1fc0;      static UINT16* dsp56k_bank04_ram;
73
6674static const eeprom_interface eeprom_intf =
6775{
6876   7,            /* address bits */
r3485r3486
181189}
182190
183191/* DSP communications */
184#ifdef UNUSED_FUNCTION
185static int dsp_state;
186static READ32_HANDLER( dsp_r )
187{
188   static int dsp_states[] =
189   {
190      0, 1, 0, 1, 1,
191   };
192
193   logerror("Dsp Read %08x\n", offset);
194
195   logerror("dsp state %d at PC=%x\n", dsp_state, activecpu_get_pc());
196
197   return dsp_states[dsp_state]<<24;
198}
199#endif
200
201192static READ32_HANDLER( dsp_host_interface_r )
202193{
203194   UINT32 value;
r3485r3486
211202   if (mem_mask == 0x0000ff00)   { value <<= 8;  }
212203   if (mem_mask == 0xff000000) { value <<= 24; }
213204
214   logerror("Dsp HI Read %08x (HI %04x) = %08x\n", mem_mask, hi_addr, value);
205   logerror("Dsp HI Read (host-side) %08x (HI %04x) = %08x (@%x)\n", mem_mask, hi_addr, value, activecpu_get_pc());
215206
216207   return value;
217208}
r3485r3486
275266   if (mem_mask == 0x0000ff00)   { hi_data = (data & 0x0000ff00) >> 8;  }
276267   if (mem_mask == 0xff000000) { hi_data = (data & 0xff000000) >> 24; }
277268
278   logerror("write %08x %08x %08x (HI %04x)\n", offset, mem_mask, data, hi_addr);
269   logerror("write (host-side) %08x %08x %08x (HI %04x)\n", offset, mem_mask, data, hi_addr);
279270   dsp56k_host_interface_write(hi_addr, hi_data);
280271}
281272
282#ifdef UNUSED_FUNCTION
283static WRITE32_HANDLER( dsp_w )
273
274static READ32_HANDLER( network_r )
284275{
285   logerror("write %08x %08x %08x\n", offset, mem_mask, data);
276   return 0x08000000;
277}
286278
287   if (mem_mask == 0xff000000)
279
280/**********************************************************************************/
281/*******                            DSP56k maps                             *******/
282/**********************************************************************************/
283
284/* It's believed this is hard-wired to return (at least) bit 15 as 0 - causes a host interface bootup */
285static READ16_HANDLER( dsp56k_bootload_r )
286{
287   return 0x7fff;
288}
289
290static OPBASE_HANDLER( plygonet_dsp56k_opbase_handler )
291{
292   if (address >= 0x7000 && address <= 0x7fff)
288293   {
289      // write to 6000
290      if (data>>24 == 8)
291      {
292         dsp_state = 0;
293         logerror("entering state 0: uploaded program wakeup\n");
294      }
294      opbase->rom = opbase->ram = (void*)(dsp56k_p_mirror - 0x7000);
295      return ~0;
295296   }
296   else
297   else if (address >= 0x8000 && address <= 0x87ff)
297298   {
298      // write to 6002
299      if (data>>8 == 0x97)
300      {
301         unsigned char *RAM = (unsigned char *)shared_ram;
302         int i;
303         unsigned short write;
299      opbase->rom = opbase->ram = (void*)(dsp56k_p_8000 - 0x8000);
300      return ~0;
301   }
304302
305         dsp_state = 1;
306         logerror("entering state 1: shared RAM test #1\n");
303   return address;
304}
307305
308         write = 0xfff0;
309         for (i = 0; i < 0x2000/2; i++)
310         {
311            RAM[i*4+3] = (write>>8)&0xff;
312            RAM[i*4+2] = (write&0xff);
313            write--;
314            RAM[i*4+1] = (write>>8)&0xff;
315            RAM[i*4]   = (write&0xff);
316            write--;
317         }
318      }
306/* The dsp56k's Port C Data register (0xffe3) :
307   Program code (function 4e) configures it as general purpose output I/O pins (ffc1 = 0000 & ffc3 = 0fff).
319308
320      if (data>>8 == 0x98)
321      {
322         unsigned char *RAM = (unsigned char *)shared_ram;
323         int i;
324         unsigned short write, track;
309   XXXX ---- ---- ----  . Reserved bits
310   ---- ???- -?-- ----  . unknown
311   ---- ---- --x- ----  . [Bank Group A] Enable bit for "001c banking"?
312   ---- ---- ---x xx--  . [Group A bank control] Believed to bank memory from 0x8000-0xbfff
313   ---- ---- ---- --x-  . [Bank Group B] Enable bit for "0181 banking"?
314   ---- ---x x--- ---x  . [Group B bank control] Believed to bank various other memory regions
325315
326         dsp_state = 1;
327         logerror("entering state 3: shared RAM test #2\n");
316   001c banking is fairly easy - it happens in a loop and writes from 8000 to bfff
317   0181 banking is very weird  - it happens in a nested loop and writes from 6000-6fff, 7000-7fff, and 8000-ffbf
318                                 bit 0002 turns on *just* before this happens.
319*/
320enum { BANK_GROUP_A, BANK_GROUP_B, INVALID_BANK_GROUP };
328321
329         track = 0xfff0;
330         for (i = 0; i < 0x2000/2; i++)
331         {
332            write = track ^ 0xffff;
333            RAM[i*4+3] = (write>>8)&0xff;
334            RAM[i*4+2] = (write&0xff);
335            track--;
336            write = track ^ 0xffff;
337            RAM[i*4+1] = (write>>8)&0xff;
338            RAM[i*4]   = (write&0xff);
339            track--;
340         }
341      }
322static UINT8 dsp56k_bank_group(void)
323{
324   UINT16 portC = dsp56k_get_peripheral_memory(0xffe3);
342325
343      if (data>>8 == 0x99)
344      {
345         logerror("entering state 4: DSP board RAM test\n");
346         dsp_state = 4;
347      }
326   /* If bank group B is on, it overrides bank group A */
327   if (portC & 0x0002)
328      return BANK_GROUP_B;
329   else if (portC & 0x0020)
330      return BANK_GROUP_A;
331
332   return INVALID_BANK_GROUP;
333}
334
335static UINT8 dsp56k_bank_num(UINT8 bank_group)
336{
337   UINT16 portC = dsp56k_get_peripheral_memory(0xffe3);
338
339   if (bank_group == BANK_GROUP_A)
340   {
341      const UINT16 bit3   = (portC & 0x0010) >> 2;
342      const UINT16 bits21 = (portC & 0x000c) >> 2;
343      return (bit3 | bits21);
348344   }
345   else if (bank_group == BANK_GROUP_B)
346   {
347      const UINT16 bits32 = (portC & 0x0180) >> 6;
348      const UINT16 bit1   = (portC & 0x0001) >> 0;
349      return (bits32 | bit1);
350   }
351
352   if (bank_group == INVALID_BANK_GROUP)
353      fatalerror("Plygonet: dsp56k bank num invalid.\n");
354
355   return 0;
349356}
350#endif
351357
352/**********************************************************************************/
353358
354/* It's believed this is hard-wired to return (at least) bit 15 as 0 - causes a host interface bootup */
355static READ16_HANDLER( dsp56k_bootload_r )
359/* BANK HANDLERS */
360static READ16_HANDLER( dsp56k_ram_bank00_read )
356361{
357   return 0x7fff;
362   UINT8 en_group = dsp56k_bank_group();
363   UINT8 bank_num = dsp56k_bank_num(en_group);
364   UINT32 driver_bank_offset = (en_group * dsp56k_bank00_size * 8) + (bank_num * dsp56k_bank00_size);
365
366   return dsp56k_bank00_ram[driver_bank_offset + offset];
358367}
359368
369static WRITE16_HANDLER( dsp56k_ram_bank00_write )
370{
371   UINT8 en_group = dsp56k_bank_group();
372   UINT8 bank_num = dsp56k_bank_num(en_group);
373   UINT32 driver_bank_offset = (en_group * dsp56k_bank00_size * 8) + (bank_num * dsp56k_bank00_size);
374
375   COMBINE_DATA(&dsp56k_bank00_ram[driver_bank_offset + offset]);
376}
377
378
379static READ16_HANDLER( dsp56k_ram_bank01_read )
380{
381   UINT8 en_group = dsp56k_bank_group();
382   UINT8 bank_num = dsp56k_bank_num(en_group);
383   UINT32 driver_bank_offset = (en_group * dsp56k_bank01_size * 8) + (bank_num * dsp56k_bank01_size);
384
385   return dsp56k_bank01_ram[driver_bank_offset + offset];
386}
387
388static WRITE16_HANDLER( dsp56k_ram_bank01_write )
389{
390   UINT8 en_group = dsp56k_bank_group();
391   UINT8 bank_num = dsp56k_bank_num(en_group);
392   UINT32 driver_bank_offset = (en_group * dsp56k_bank01_size * 8) + (bank_num * dsp56k_bank01_size);
393
394   COMBINE_DATA(&dsp56k_bank01_ram[driver_bank_offset + offset]);
395
396   /* For now, *always* combine P:0x7000-0x7fff with bank01 with no regard to the banking hardware. */
397   dsp56k_p_mirror[offset] = data;
398}
399
400
401static READ16_HANDLER( dsp56k_ram_bank02_read )
402{
403   UINT8 en_group = dsp56k_bank_group();
404   UINT8 bank_num = dsp56k_bank_num(en_group);
405   UINT32 driver_bank_offset = (en_group * dsp56k_bank02_size * 8) + (bank_num * dsp56k_bank02_size);
406
407   return dsp56k_bank02_ram[driver_bank_offset + offset];
408}
409
410static WRITE16_HANDLER( dsp56k_ram_bank02_write )
411{
412   UINT8 en_group = dsp56k_bank_group();
413   UINT8 bank_num = dsp56k_bank_num(en_group);
414   UINT32 driver_bank_offset = (en_group * dsp56k_bank02_size * 8) + (bank_num * dsp56k_bank02_size);
415
416   COMBINE_DATA(&dsp56k_bank02_ram[driver_bank_offset + offset]);
417}
418
419
420static READ16_HANDLER( dsp56k_shared_ram_read )
421{
422   UINT8 en_group = dsp56k_bank_group();
423   UINT8 bank_num = dsp56k_bank_num(en_group);
424   UINT32 driver_bank_offset = (en_group * dsp56k_shared_ram_16_size * 8) + (bank_num * dsp56k_shared_ram_16_size);
425
426   return dsp56k_shared_ram_16[driver_bank_offset + offset];
427}
428
429static WRITE16_HANDLER( dsp56k_shared_ram_write )
430{
431   UINT8 en_group = dsp56k_bank_group();
432   UINT8 bank_num = dsp56k_bank_num(en_group);
433   UINT32 driver_bank_offset = (en_group * dsp56k_shared_ram_16_size * 8) + (bank_num * dsp56k_shared_ram_16_size);
434
435   COMBINE_DATA(&dsp56k_shared_ram_16[driver_bank_offset + offset]);
436
437   /* Bank group A with offset 0 is believed to be the shared region */
438   if (en_group == BANK_GROUP_A && bank_num == 0)
439   {
440      if (offset % 2)
441         shared_ram[offset>>1] = ((dsp56k_shared_ram_16[offset-1]) << 16) | dsp56k_shared_ram_16[offset] ;
442      else
443         shared_ram[offset>>1] = ((dsp56k_shared_ram_16[offset])   << 16) | dsp56k_shared_ram_16[offset+1] ;
444   }
445}
446
447
448static READ16_HANDLER( dsp56k_ram_bank04_read )
449{
450   UINT8 en_group = dsp56k_bank_group();
451   UINT8 bank_num = dsp56k_bank_num(en_group);
452   UINT32 driver_bank_offset = (en_group * dsp56k_bank04_size * 8) + (bank_num * dsp56k_bank04_size);
453
454   return dsp56k_bank04_ram[driver_bank_offset + offset];
455}
456
457static WRITE16_HANDLER( dsp56k_ram_bank04_write )
458{
459   UINT8 en_group = dsp56k_bank_group();
460   UINT8 bank_num = dsp56k_bank_num(en_group);
461   UINT32 driver_bank_offset = (en_group * dsp56k_bank04_size * 8) + (bank_num * dsp56k_bank04_size);
462
463   COMBINE_DATA(&dsp56k_bank04_ram[driver_bank_offset + offset]);
464}
465
466
467
360468/**********************************************************************************/
361469
362470static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 32 )
363471   AM_RANGE(0x000000, 0x1fffff) AM_ROM
364   AM_RANGE(0x200000, 0x21ffff) AM_RAM      // PSAC2 tilemap
365   AM_RANGE(0x440000, 0x440fff) AM_RAM      // PSAC2 lineram
472   AM_RANGE(0x200000, 0x21ffff) AM_RAM      /* PSAC2 tilemap */
473   AM_RANGE(0x440000, 0x440fff) AM_RAM      /* PSAC2 lineram */
366474   AM_RANGE(0x480000, 0x480003) AM_READ(polygonet_eeprom_r)
367475   AM_RANGE(0x4C0000, 0x4C0003) AM_WRITE(polygonet_eeprom_w)
368476   AM_RANGE(0x500000, 0x503fff) AM_RAM_WRITE(shared_ram_write) AM_BASE(&shared_ram)
369477   AM_RANGE(0x504000, 0x504003) AM_WRITE(dsp_w_lines)
370   /*AM_RANGE(0x506004, 0x506007) AM_READ(dsp_r)*/
371478   AM_RANGE(0x506000, 0x50600f) AM_READWRITE(dsp_host_interface_r, dsp_host_interface_w)
372////AM_RANGE(0x506000, 0x506003) AM_WRITE(dsp_w)
373479   AM_RANGE(0x540000, 0x540fff) AM_READWRITE(polygonet_ttl_ram_r, polygonet_ttl_ram_w)
374480   AM_RANGE(0x541000, 0x54101f) AM_RAM
375481   AM_RANGE(0x580000, 0x5807ff) AM_RAM
376   /*AM_RANGE(0x580800, 0x580803) AM_RAM*/      // network RAM / registers?
482   AM_RANGE(0x580800, 0x580803) AM_READWRITE(network_r, SMH_NOP)
483   AM_RANGE(0x580800, 0x580803) AM_RAM      /* network RAM | registers? */
484//  AM_RANGE(0x600000, 0x600000)
377485   AM_RANGE(0x600004, 0x600007) AM_WRITE(sound_w)
378486   AM_RANGE(0x600008, 0x60000b) AM_READ(sound_r)
379487   AM_RANGE(0x640000, 0x640003) AM_WRITE(sound_irq_w)
380488   AM_RANGE(0x680000, 0x680003) AM_WRITE(watchdog_reset32_w)
381489   AM_RANGE(0x700000, 0x73ffff) AM_READ(psac_rom_r)
382490   AM_RANGE(0x780000, 0x79ffff) AM_READ(ttl_rom_r)
383   AM_RANGE(0xff8000, 0xffffff) AM_READ(SMH_RAM)
384   AM_RANGE(0xff8000, 0xffffff) AM_WRITE(SMH_RAM)
491   AM_RANGE(0xff8000, 0xffffff) AM_RAM
385492ADDRESS_MAP_END
386493
387494/**********************************************************************************/
388495
389496static ADDRESS_MAP_START( dsp_program_map, ADDRESS_SPACE_PROGRAM, 16 )
497   AM_RANGE(0x7000, 0x7fff) AM_RAM AM_BASE(&dsp56k_p_mirror)   /* Unsure of size, but 0x1000 matches bank01 */
498   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE(&dsp56k_p_8000)
390499   AM_RANGE(0xc000, 0xc000) AM_READ(dsp56k_bootload_r)
391   AM_RANGE(0x8000, 0x87ff) AM_RAM      // the dsp memtests here
392500ADDRESS_MAP_END
393501
394502static ADDRESS_MAP_START( dsp_data_map, ADDRESS_SPACE_DATA, 16 )
395   AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE(&dsp56k_shared_ram_16)
503   AM_RANGE(0x0800, 0x5fff) AM_RAM         /* Appears to not be affected by banking? */
504   AM_RANGE(0x6000, 0x6fff) AM_READWRITE(dsp56k_ram_bank00_read, dsp56k_ram_bank00_write)
505   AM_RANGE(0x7000, 0x7fff) AM_READWRITE(dsp56k_ram_bank01_read, dsp56k_ram_bank01_write)   /* Mirrored in program space @ 0x8000 */
506   AM_RANGE(0x8000, 0xbfff) AM_READWRITE(dsp56k_ram_bank02_read, dsp56k_ram_bank02_write)
507   AM_RANGE(0xc000, 0xdfff) AM_READWRITE(dsp56k_shared_ram_read, dsp56k_shared_ram_write)
508   AM_RANGE(0xe000, 0xffbf) AM_READWRITE(dsp56k_ram_bank04_read, dsp56k_ram_bank04_write)
396509ADDRESS_MAP_END
397510
398511/**********************************************************************************/
r3485r3486
461574
462575   /* Set the dsp56k lines */
463576   /* It's presumed the hardware has hard-wired operating mode 1 (MODA = 1, MODB = 0) */
577   /* TODO: This should work, but the MAME core appears to do something funny.
578             Not a big deal - it's hacked in dsp_w_lines. */
464579   //cpunum_set_input_line(machine, mame_find_cpu_index(machine, "dsp"), INPUT_LINE_RESET, ASSERT_LINE);
465580   //cpunum_set_input_line(machine, mame_find_cpu_index(machine, "dsp"), DSP56K_IRQ_MODA, ASSERT_LINE);
466581   //cpunum_set_input_line(machine, mame_find_cpu_index(machine, "dsp"), DSP56K_IRQ_MODB, CLEAR_LINE);
r3485r3486
471586   MDRV_CPU_PROGRAM_MAP(main_map, 0)
472587   MDRV_CPU_VBLANK_INT_HACK(polygonet_interrupt, 2)
473588
474   MDRV_CPU_ADD("dsp", DSP56156, 10000000)      /* should be 40.0 MHz/? */
589   MDRV_CPU_ADD("dsp", DSP56156, 10000000)      /* xtal is 40.0 MHz */
475590   MDRV_CPU_PROGRAM_MAP(dsp_program_map, 0)
476591   MDRV_CPU_DATA_MAP(dsp_data_map, 0)
477592
r3485r3486
484599   MDRV_GFXDECODE(plygonet)
485600   MDRV_NVRAM_HANDLER(polygonet)
486601
602   /* TODO: TEMPORARY!  UNTIL A MORE LOCALIZED SYNC CAN BE MADE */
603   MDRV_INTERLEAVE(50000)
604
487605   /* video hardware */
488606   MDRV_SCREEN_ADD("main", RASTER)
489607   MDRV_SCREEN_REFRESH_RATE(60)
r3485r3486
525643
526644static DRIVER_INIT(polygonet)
527645{
528   /* set default bankswitch */
646   /* Set default bankswitch */
529647   cur_sound_region = 2;
530648   reset_sound_region(machine);
649
650   /* Allocate space for the dsp56k banking */
651   dsp56k_bank00_ram    = auto_malloc(2 * 8 * dsp56k_bank00_size        * sizeof(UINT16));      /* 2 bank sets, 8 potential banks each */
652   dsp56k_bank01_ram    = auto_malloc(2 * 8 * dsp56k_bank01_size        * sizeof(UINT16));
653   dsp56k_bank02_ram    = auto_malloc(2 * 8 * dsp56k_bank02_size        * sizeof(UINT16));
654   dsp56k_shared_ram_16 = auto_malloc(2 * 8 * dsp56k_shared_ram_16_size * sizeof(UINT16));
655   dsp56k_bank04_ram    = auto_malloc(2 * 8 * dsp56k_bank04_size        * sizeof(UINT16));
656
657   /* Clear the newly-allocated memory */
658   memset(dsp56k_bank00_ram,    0, 2 * 8 * dsp56k_bank00_size        * sizeof(UINT16));
659   memset(dsp56k_bank01_ram,    0, 2 * 8 * dsp56k_bank01_size        * sizeof(UINT16));
660   memset(dsp56k_bank02_ram,    0, 2 * 8 * dsp56k_bank02_size        * sizeof(UINT16));
661   memset(dsp56k_shared_ram_16, 0, 2 * 8 * dsp56k_shared_ram_16_size * sizeof(UINT16));
662   memset(dsp56k_bank04_ram,    0, 2 * 8 * dsp56k_bank04_size        * sizeof(UINT16));
663
664   /* The dsp56k occasionally executes out of mapped memory */
665   memory_set_opbase_handler(1, plygonet_dsp56k_opbase_handler);
531666}
532667
533668ROM_START( plygonet )
src/mame/drivers/stv.c
r3485r3486
972972         return 0xffffffff;
973973      }
974974      break;
975      case 5:
976      switch(port_sel)
977      {
978         case 0x77:
979         {
980            //popmessage("(PC=%06x) offs 5 %04x %02x",activecpu_get_pc(),port_sel,((ioga[5] & 0xff0000) >> 16));
981            logerror("(PC=%06x) offs 5 %04x %02x\n",activecpu_get_pc(),port_sel,((ioga[5] & 0xff0000) >> 16));
982
983            //stv_workram_h[0x8e830/4] = ((ioga[5] & 0xff0000) >> 16) ^ 0x3;
984            //stv_workram_h[0x8e834/4] = ((ioga[5] & 0xff0000) >> 16) ^ 0x3;
985            return (ioga[5] & 0xff0000) >> 16;//stv_workram_h[0x8e830/4];//sound board data
986         }
987         default: return 0xffffffff;
988      }
989      break;
975990      case 6:
976991      switch(port_sel)
977992      {
978993         case 0x60:  return ioga[5];
994         case 0x77:
995         {
996            //popmessage("(PC=%06x) offs 6 %04x %02x",activecpu_get_pc(),port_sel,((ioga[5] & 0xff0000) >> 16));
997            logerror("(PC=%06x) offs 6 %04x %02x\n",activecpu_get_pc(),port_sel,((ioga[5] & 0xff0000) >> 16));
998            return 0;//sound board status,non-zero = processing
999         }
9791000         default:
9801001         //popmessage("offs: 6 %02x",port_sel);
9811002         return 0xffffffff;
r3485r3486
24992520
25002521GFXDECODE_END
25012522
2502static const sh2_cpu_core sh2_conf_master = { 0 };
2503static const sh2_cpu_core sh2_conf_slave  = { 1 };
2523static const sh2_cpu_core sh2_conf_master = { 0, NULL };
2524static const sh2_cpu_core sh2_conf_slave  = { 1, NULL };
25042525
25052526static int scsp_last_line = 0;
25062527
r3485r3486
27022723
27032724( add 0x2000000 for real memory map location )
27042725
27050x0000000 - 0x01fffff IC13 Header can be read from here ..
27060x0200000 - 0x03fffff IC7  .. or here (some games have both ic7 and ic13 but the header is in ic13 in these cases)
27260x0000000 - 0x01fffff IC13 Header can be read from here .. IC13 roms are loaded on ODD bytes only
27270x0200000 - 0x03fffff IC7  Header can also be read from here.  If No IC7 is present it seems to mirror IC13, but loaded normally (mausuke)
270727280x0400000 - 0x07fffff IC2
270827290x0800000 - 0x0bfffff IC3
270927300x0c00000 - 0x0ffffff IC4
r3485r3486
27262747   STV_BIOS
27272748
27282749   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2729   ROM_LOAD( "epr20825.13",                0x0000000, 0x0100000, CRC(94a9ad8f) SHA1(861311c14cfa9f560752aa5b023c147a539cf135) )
2730   ROM_RELOAD ( 0x0100000, 0x0100000 )
2731   ROM_RELOAD ( 0x0200000, 0x0100000 )
2732   ROM_RELOAD ( 0x0300000, 0x0100000 )
2750
2751   ROM_LOAD16_BYTE( "epr20825.13",                0x0000001, 0x0100000, CRC(94a9ad8f) SHA1(861311c14cfa9f560752aa5b023c147a539cf135) )
2752
27332753   ROM_LOAD16_WORD_SWAP( "mpr20827.2",     0x0400000, 0x0400000, CRC(65cabbb3) SHA1(5e7cb090101dc42207a4084465e419f4311b6baf) ) // good (was .12)
27342754   ROM_LOAD16_WORD_SWAP( "mpr20828.3",     0x0800000, 0x0400000, CRC(3934d44a) SHA1(969406b8bfac43b30f4d732702ca8cffeeefffb9) ) // good (was .13)
27352755   ROM_LOAD16_WORD_SWAP( "mpr20829.4",     0x0c00000, 0x0400000, CRC(814308c3) SHA1(45c3f551690224c95acd156ae8f8397667927a04) ) // good (was .14)
r3485r3486
27492769   STV_BIOS
27502770
27512771   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2752   ROM_LOAD( "fpr17969.13",               0x0000000, 0x0100000, CRC(bee327e5) SHA1(1d226db72d6ef68fd294f60659df7f882b25def6) )
2753   ROM_RELOAD ( 0x0100000, 0x0100000 )
2754   ROM_RELOAD ( 0x0200000, 0x0100000 )
2755   ROM_RELOAD ( 0x0300000, 0x0100000 )
2772
2773   ROM_LOAD16_BYTE( "fpr17969.13",               0x0000001, 0x0100000, CRC(bee327e5) SHA1(1d226db72d6ef68fd294f60659df7f882b25def6) )
2774
27562775   ROM_LOAD16_WORD_SWAP( "mpr17970.2",    0x0400000, 0x0400000, CRC(bc4d6f91) SHA1(dcc241dcabea59325decfba3fd5e113c07958422) ) // good
27572776   ROM_LOAD16_WORD_SWAP( "mpr17971.3",    0x0800000, 0x0400000, CRC(c780a3b3) SHA1(99587eea528a6413cacc3e4d3d1dbfff57b03dca) ) // good
27582777   ROM_LOAD16_WORD_SWAP( "mpr17972.4",    0x0c00000, 0x0400000, CRC(8f29815a) SHA1(e86acd8096f2aee5f5e3ddfd3abb4f5c2b11df66) ) // good
r3485r3486
27632782   STV_BIOS
27642783
27652784   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2766   /* it tests .13 at 0x000000 - 0x1fffff but reports as bad even if we put the rom there */
2767   ROM_LOAD( "fpr19553.13",    0x000000, 0x100000, CRC(d4fb6a5e) SHA1(bd3cfb4f451b6c9612e42af5ddcbffa14f057329) )
2768   ROM_RELOAD ( 0x0100000, 0x0100000 )
2769   ROM_RELOAD ( 0x0200000, 0x0100000 )
2770   ROM_RELOAD ( 0x0300000, 0x0100000 )
2785
2786   ROM_LOAD16_BYTE( "fpr19553.13",    0x000001, 0x100000, CRC(d4fb6a5e) SHA1(bd3cfb4f451b6c9612e42af5ddcbffa14f057329) )
2787
27712788   ROM_LOAD16_WORD_SWAP( "mpr19554.2",     0x400000, 0x400000, CRC(5a3ebcac) SHA1(46e3d1cf515a7ff8a8f97e5050b29dbbeb5060c0) ) // good
27722789   ROM_LOAD16_WORD_SWAP( "mpr19555.3",     0x800000, 0x400000, CRC(74f6e6b8) SHA1(8080860550eb770e04447e344fb337748a249761) ) // good
27732790ROM_END
r3485r3486
28052822   STV_BIOS
28062823
28072824   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2808   ROM_LOAD( "epr18967.a",               0x0000000, 0x0100000, CRC(ac59c186) SHA1(7d4924d1e4c1b9257b58a690de988b3f6486e86f) )
2809   ROM_RELOAD ( 0x0100000, 0x0100000 )
2810   ROM_RELOAD ( 0x0200000, 0x0100000 )
2811   ROM_RELOAD ( 0x0300000, 0x0100000 )
2825
2826   ROM_LOAD16_BYTE( "epr18967a.13",               0x0000001, 0x0100000, CRC(ac59c186) SHA1(7d4924d1e4c1b9257b58a690de988b3f6486e86f) )
2827
28122828   ROM_LOAD16_WORD_SWAP( "mpr18968.2",    0x0400000, 0x0400000, CRC(11a891de) SHA1(1a4fa8d7e07e1d8fdc8122ef8a5b93723c007cda) ) // good (was .1)
28132829   ROM_LOAD16_WORD_SWAP( "mpr18969.3",    0x0800000, 0x0400000, CRC(199cc47d) SHA1(d78f7c6be7e9b43e208244c5c8722245f4c653e1) ) // good (was .2)
28142830   ROM_LOAD16_WORD_SWAP( "mpr18970.4",    0x0c00000, 0x0400000, CRC(8b7a509e) SHA1(8f4d36a858231764ed09b26a1141d1f055eee092) ) // good (was .3)
r3485r3486
28202836   STV_BIOS
28212837
28222838   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2823   ROM_LOAD( "epr18967.13",               0x0000000, 0x0100000, CRC(c0446674) SHA1(4917089d95613c9d2a936ed9fe3ebd22f461aa4f) )
2824   ROM_RELOAD ( 0x0100000, 0x0100000 )
2825   ROM_RELOAD ( 0x0200000, 0x0100000 )
2826   ROM_RELOAD ( 0x0300000, 0x0100000 )
2839
2840   ROM_LOAD16_BYTE( "epr18967.13",               0x0000001, 0x0100000, CRC(c0446674) SHA1(4917089d95613c9d2a936ed9fe3ebd22f461aa4f) )
2841
28272842   ROM_LOAD16_WORD_SWAP( "mpr18968.2",    0x0400000, 0x0400000, CRC(11a891de) SHA1(1a4fa8d7e07e1d8fdc8122ef8a5b93723c007cda) ) // good (was .1)
28282843   ROM_LOAD16_WORD_SWAP( "mpr18969.3",    0x0800000, 0x0400000, CRC(199cc47d) SHA1(d78f7c6be7e9b43e208244c5c8722245f4c653e1) ) // good (was .2)
28292844   ROM_LOAD16_WORD_SWAP( "mpr18970.4",    0x0c00000, 0x0400000, CRC(8b7a509e) SHA1(8f4d36a858231764ed09b26a1141d1f055eee092) ) // good (was .3)
r3485r3486
28352850   STV_BIOS
28362851
28372852   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2838   ROM_LOAD( "fpr19119.13",               0x0000000, 0x0100000, CRC(de5c4f7c) SHA1(35f670a15e9c86edbe2fe718470f5a75b5b096ac) )
2839   ROM_RELOAD ( 0x0100000, 0x0100000 )
2840   ROM_RELOAD ( 0x0200000, 0x0100000 )
2841   ROM_RELOAD ( 0x0300000, 0x0100000 )
2853
2854   ROM_LOAD16_BYTE( "fpr19119.13",               0x0000001, 0x0100000, CRC(de5c4f7c) SHA1(35f670a15e9c86edbe2fe718470f5a75b5b096ac) )
2855
28422856   ROM_LOAD16_WORD_SWAP( "mpr19115.2",    0x0400000, 0x0400000, CRC(6fe06a30) SHA1(dedb90f800bae8fd9df1023eb5bec7fb6c9d0179) ) // good
28432857   ROM_LOAD16_WORD_SWAP( "mpr19116.3",    0x0800000, 0x0400000, CRC(af9e627b) SHA1(a53921c3185a93ec95299bf1c29e744e2fa3b8c0) ) // good
28442858   ROM_LOAD16_WORD_SWAP( "mpr19117.4",    0x0c00000, 0x0400000, CRC(74520ff1) SHA1(16c1acf878664b3bd866c9b94f3695ae892ac12f) ) // good
r3485r3486
28492863   STV_BIOS
28502864
28512865   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2852   ROM_LOAD( "fpr19114.13",               0x0000000, 0x0100000, CRC(1fd22a5f) SHA1(c3d9653b12354a73a3e15f23a2ab7992ffb83e46) )
2853   ROM_RELOAD ( 0x0100000, 0x0100000 )
2854   ROM_RELOAD ( 0x0200000, 0x0100000 )
2855   ROM_RELOAD ( 0x0300000, 0x0100000 )
2866
2867   ROM_LOAD16_BYTE( "fpr19114.13",               0x0000001, 0x0100000, CRC(1fd22a5f) SHA1(c3d9653b12354a73a3e15f23a2ab7992ffb83e46) )
2868
28562869   ROM_LOAD16_WORD_SWAP( "mpr19115.2",    0x0400000, 0x0400000, CRC(6fe06a30) SHA1(dedb90f800bae8fd9df1023eb5bec7fb6c9d0179) ) // good
28572870   ROM_LOAD16_WORD_SWAP( "mpr19116.3",    0x0800000, 0x0400000, CRC(af9e627b) SHA1(a53921c3185a93ec95299bf1c29e744e2fa3b8c0) ) // good
28582871   ROM_LOAD16_WORD_SWAP( "mpr19117.4",    0x0c00000, 0x0400000, CRC(74520ff1) SHA1(16c1acf878664b3bd866c9b94f3695ae892ac12f) ) // good
r3485r3486
28632876   STV_BIOS
28642877
28652878   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2866   ROM_LOAD( "epr18137.13",               0x0000000, 0x0080000, CRC(151aa9bc) SHA1(0959c60f31634816825acb57413838dcddb17d31) )
2867   ROM_RELOAD ( 0x0080000, 0x0080000 )
2868   ROM_RELOAD ( 0x0100000, 0x0080000 )
2869   ROM_RELOAD ( 0x0180000, 0x0080000 )
2870   ROM_RELOAD ( 0x0200000, 0x0080000 )
2871   ROM_RELOAD ( 0x0280000, 0x0080000 )
2872   ROM_RELOAD ( 0x0300000, 0x0080000 )
2873   ROM_RELOAD ( 0x0380000, 0x0080000 )
2879   ROM_LOAD16_BYTE( "epr18137.13",               0x0000001, 0x0080000, CRC(151aa9bc) SHA1(0959c60f31634816825acb57413838dcddb17d31) )
2880   ROM_RELOAD( 0x100001, 0x0080000 )
2881
28742882   ROM_LOAD16_WORD_SWAP( "mpr18138.2",    0x0400000, 0x0400000, CRC(f5567049) SHA1(6eb35e4b5fbda39cf7e8c42b6a568bd53a364d6d) ) // good
28752883   ROM_LOAD16_WORD_SWAP( "mpr18139.3",    0x0800000, 0x0400000, CRC(f36b4878) SHA1(e3f63c0046bd37b7ab02fb3865b8ebcf4cf68e75) ) // good
28762884   ROM_LOAD16_WORD_SWAP( "mpr18140.4",    0x0c00000, 0x0400000, CRC(228850a0) SHA1(d83f7fa7df08407fa45a13661393679b88800805) ) // good
r3485r3486
29122920   STV_BIOS
29132921
29142922   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2915   ROM_LOAD( "fr18541a.13",               0x0000000, 0x0100000, CRC(8c61a17c) SHA1(a8aef27b53482923a506f7daa4b7a38653b4d8a4) ) //(header is read from here, not ic7 even if both are populated on this board)
2916   ROM_RELOAD ( 0x0100000, 0x0100000 )
2917   ROM_RELOAD ( 0x0200000, 0x0100000 )
2918   ROM_RELOAD ( 0x0300000, 0x0100000 )
2923   ROM_LOAD16_BYTE( "fr18541a.13",               0x0000001, 0x0100000, CRC(8c61a17c) SHA1(a8aef27b53482923a506f7daa4b7a38653b4d8a4) ) //(header is read from here, not ic7 even if both are populated on this board)
29192924
29202925   ROM_LOAD16_WORD_SWAP( "mpr18538.7",    0x0200000, 0x0200000, CRC(7b5230c5) SHA1(70cebc3281580b43adf42c37318e12159c28a13d) ) // good
29212926   ROM_LOAD16_WORD_SWAP( "mpr18533.2",    0x0400000, 0x0400000, CRC(7181fe51) SHA1(646f95e1a5b64d721e961352cee6fd5adfd031ec) ) // good
r3485r3486
29332938   STV_BIOS
29342939
29352940   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2936   ROM_LOAD( "epr20424.13",               0x0000000, 0x0100000, CRC(4e61fa46) SHA1(e34624d98cbdf2dd04d997167d3c4decd2f208f7) ) //(header is read from here, not ic7 even if both are populated on this board)
2937   ROM_RELOAD ( 0x0100000, 0x0100000 )
2941   ROM_LOAD16_BYTE( "epr20424.13",               0x0000001, 0x0100000, CRC(4e61fa46) SHA1(e34624d98cbdf2dd04d997167d3c4decd2f208f7) ) //(header is read from here, not ic7 even if both are populated on this board)
29382942
29392943   ROM_LOAD16_WORD_SWAP( "mpr20431.7",    0x0200000, 0x0200000, CRC(ea656ced) SHA1(b2d6286081bd46a89d1284a2757b87d0bca1bbde) ) // good
29402944   ROM_LOAD16_WORD_SWAP( "mpr20426.2",    0x0400000, 0x0400000, CRC(897d1747) SHA1(f3fb2c4ef8bc2c1658907e822f2ee2b88582afdd) ) // good
r3485r3486
29542958   STV_BIOS
29552959
29562960   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2957   ROM_LOAD( "finlarch.13",               0x0000000, 0x0100000, CRC(4505fa9e) SHA1(96c6399146cf9c8f1d27a8fb6a265f937258004a) )
2958   ROM_RELOAD ( 0x0100000, 0x0100000 )
2959   ROM_RELOAD ( 0x0200000, 0x0100000 )
2960   ROM_RELOAD ( 0x0300000, 0x0100000 )
2961   ROM_LOAD16_BYTE( "finlarch.13",               0x0000001, 0x0100000, CRC(4505fa9e) SHA1(96c6399146cf9c8f1d27a8fb6a265f937258004a) )
2962
29612963   ROM_LOAD16_WORD_SWAP( "mpr18257.2",    0x0400000, 0x0400000, CRC(137fdf55) SHA1(07a02fe531b3707e063498f5bc9749bd1b4cadb3) ) // good
29622964   ROM_RELOAD(                            0x1400000, 0x0400000 )
29632965   ROM_LOAD16_WORD_SWAP( "mpr18258.3",    0x0800000, 0x0400000, CRC(f519c505) SHA1(5cad39314e46b98c24a71f1c2c10c682ef3bdcf3) ) // good
r3485r3486
29732975   STV_BIOS
29742976
29752977   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
2976   ROM_LOAD( "epr17766.13",               0x0000000, 0x0080000, CRC(a83fcd62) SHA1(4ce77ebaa0e93c6553ad8f7fb87cbdc32433402b) )
2977   ROM_RELOAD ( 0x0080000, 0x0080000 )
2978   ROM_RELOAD ( 0x0100000, 0x0080000 )
2979   ROM_RELOAD ( 0x0180000, 0x0080000 )
2980   ROM_RELOAD ( 0x0200000, 0x0080000 )
2981   ROM_RELOAD ( 0x0280000, 0x0080000 )
2982   ROM_RELOAD ( 0x0300000, 0x0080000 )
2983   ROM_RELOAD ( 0x0380000, 0x0080000 )
2978   ROM_LOAD16_BYTE( "epr17766.13",               0x0000001, 0x0080000, CRC(a83fcd62) SHA1(4ce77ebaa0e93c6553ad8f7fb87cbdc32433402b) )
2979   ROM_RELOAD( 0x0100001, 0x0080000 )
2980
29842981   ROM_LOAD16_WORD_SWAP( "mpr17768.2",    0x0400000, 0x0400000, CRC(d6808a7d) SHA1(83a97bbe1160cb45b3bdcbde8adc0d9bae5ded60) ) // good
29852982   ROM_LOAD16_WORD_SWAP( "mpr17769.3",    0x0800000, 0x0400000, CRC(3471dd35) SHA1(24febddfe70984cebc0e6948ad718e0e6957fa82) ) // good
29862983   ROM_LOAD16_WORD_SWAP( "mpr17770.4",    0x0c00000, 0x0400000, CRC(06978a00) SHA1(a8d1333a9f4322e28b23724937f595805315b136) ) // good
r3485r3486
30413038   STV_BIOS
30423039
30433040   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3044   ROM_LOAD( "epr18937.13",               0x0000000, 0x0080000, CRC(1f40d766) SHA1(35d9751c1b23cfbf448f2a9e9cf3b121929368ae) )
3045   ROM_RELOAD ( 0x0100000, 0x0100000 )
3046   ROM_RELOAD ( 0x0200000, 0x0100000 )
3047   ROM_RELOAD ( 0x0300000, 0x0100000 )
3041   ROM_LOAD16_BYTE( "epr18937.13",               0x0000001, 0x0080000, CRC(1f40d766) SHA1(35d9751c1b23cfbf448f2a9e9cf3b121929368ae) )
3042   ROM_RELOAD( 0x0100001, 0x0080000)
3043
30483044   ROM_LOAD16_WORD_SWAP( "mpr18944.7",    0x0200000, 0x0100000, CRC(f7f75ce5) SHA1(0787ece9f89cc1847889adbf08ba5d3ccbc405de) ) // good
30493045   ROM_LOAD16_WORD_SWAP( "mpr18939.2",    0x0400000, 0x0400000, CRC(ef95a6e6) SHA1(3026c52ad542997d5b0e621b389c0e01240cb486) ) // good
30503046   ROM_LOAD16_WORD_SWAP( "mpr18940.3",    0x0800000, 0x0400000, CRC(cabab4cd) SHA1(b251609573c4b0ccc933188f32226855b25fd9da) ) // good
r3485r3486
30593055   STV_BIOS
30603056
30613057   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3062   ROM_LOAD( "epr18737.13",               0x0000000, 0x0080000, CRC(cfad6c49) SHA1(fc69980a351ed13307706db506c79c774eabeb66) ) // bad
3063   ROM_RELOAD ( 0x0100000, 0x0100000 )
3064   ROM_RELOAD ( 0x0200000, 0x0100000 )
3065   ROM_RELOAD ( 0x0300000, 0x0100000 )
3058   ROM_LOAD16_BYTE( "epr18737.13",               0x0000001, 0x0080000, CRC(cfad6c49) SHA1(fc69980a351ed13307706db506c79c774eabeb66) ) // bad
3059   ROM_RELOAD( 0x0100001, 0x0080000)
3060
30663061   ROM_LOAD16_WORD_SWAP( "mpr18738.2",    0x0400000, 0x0400000, CRC(4b3c175a) SHA1(b6d2438ae1d3d51950a7ed1eaadf2dae45c4e7b1) ) // good
30673062   ROM_LOAD16_WORD_SWAP( "mpr18739.3",    0x0800000, 0x0400000, CRC(eb41fa67) SHA1(d12acebb1df9eafd17aff1841087f5017225e7e7) ) // good
30683063   ROM_LOAD16_WORD_SWAP( "mpr18740.4",    0x0c00000, 0x0200000, CRC(9ca7962f) SHA1(a09e0db2246b34ca7efa3165afbc5ba292a95398) ) // good
r3485r3486
30723067   STV_BIOS
30733068
30743069   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3075   ROM_LOAD( "epr20416.13",               0x0000000, 0x0100000, CRC(8bf0176d) SHA1(5bd468e2ffed042ee84e2ceb8712ff5883a1d824) ) // bad
3076   ROM_RELOAD ( 0x0100000, 0x0100000 )
3077   ROM_RELOAD ( 0x0200000, 0x0100000 )
3078   ROM_RELOAD ( 0x0300000, 0x0100000 )
3070   ROM_LOAD16_BYTE( "epr20416.13",               0x0000001, 0x0100000, CRC(8bf0176d) SHA1(5bd468e2ffed042ee84e2ceb8712ff5883a1d824) ) // bad
3071
30793072   ROM_LOAD16_WORD_SWAP( "mpr20417.2",    0x0400000, 0x0400000, CRC(636c2a08) SHA1(47986b71d68f6a1852e4e2b03ca7b6e48e83718b) ) // good
30803073   ROM_LOAD16_WORD_SWAP( "mpr20418.3",    0x0800000, 0x0400000, CRC(3f0d9e34) SHA1(2ec81e40ebf689d17b6421820bfb0a1280a8ef25) ) // good
30813074   ROM_LOAD16_WORD_SWAP( "mpr20419.4",    0x0c00000, 0x0400000, CRC(ec969815) SHA1(b59782174051f5717b06f43e57dd8a2a6910d95f) ) // good
r3485r3486
31183111   STV_BIOS
31193112
31203113   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3121   ROM_LOAD( "epr18852.13",               0x0000000, 0x0080000, CRC(d12414ec) SHA1(0f42ec9e41983781b6892622b00398a102072aa7) ) // bad
3122   ROM_RELOAD ( 0x0080000, 0x0080000 )
3123   ROM_RELOAD ( 0x0100000, 0x0080000 )
3124   ROM_RELOAD ( 0x0180000, 0x0080000 )
3125   ROM_RELOAD ( 0x0200000, 0x0080000 )
3126   ROM_RELOAD ( 0x0280000, 0x0080000 )
3127   ROM_RELOAD ( 0x0300000, 0x0080000 )
3128   ROM_RELOAD ( 0x0380000, 0x0080000 )
3114   ROM_LOAD16_BYTE( "epr18852.13",               0x0000001, 0x0080000, CRC(d12414ec) SHA1(0f42ec9e41983781b6892622b00398a102072aa7) ) // bad
3115   ROM_RELOAD ( 0x0100001, 0x0080000 )
3116
31293117   ROM_LOAD16_WORD_SWAP( "mpr18853.2",    0x0400000, 0x0400000, CRC(b9268c97) SHA1(8734e3f0e6b2849d173e3acc9d0308084a4e84fd) ) // good
31303118   ROM_LOAD16_WORD_SWAP( "mpr18854.3",    0x0800000, 0x0400000, CRC(3113c8bc) SHA1(4e4600646ddd1978988d27430ffdf0d1d405b804) ) // good
31313119   ROM_LOAD16_WORD_SWAP( "mpr18855.4",    0x0c00000, 0x0400000, CRC(daf6ad0c) SHA1(2a14a6a42e4eb68abb7a427e43062dfde2d13c5c) ) // good
r3485r3486
31483136   STV_BIOS
31493137
31503138   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3151   ROM_LOAD( "epr19531.13",               0x0000000, 0x0080000, CRC(ac81024f) SHA1(b22c7c1798fade7ae992ff83b138dd23e6292d3f) ) // bad
3152   ROM_RELOAD ( 0x0080000, 0x0080000 )
3153   ROM_RELOAD ( 0x0100000, 0x0080000 )
3154   ROM_RELOAD ( 0x0180000, 0x0080000 )
3155   ROM_RELOAD ( 0x0200000, 0x0080000 )
3156   ROM_RELOAD ( 0x0280000, 0x0080000 )
3157   ROM_RELOAD ( 0x0300000, 0x0080000 )
3158   ROM_RELOAD ( 0x0380000, 0x0080000 )
3139   ROM_LOAD16_BYTE( "epr19531.13",               0x0000001, 0x0080000, CRC(ac81024f) SHA1(b22c7c1798fade7ae992ff83b138dd23e6292d3f) ) // bad
3140   ROM_RELOAD ( 0x0100001, 0x0080000 )
3141
31593142   ROM_LOAD16_WORD_SWAP( "mpr19533.2",    0x0400000, 0x0400000, CRC(17ec54ba) SHA1(d4cdc86926519291cc78980ec513e1cfc677e76e) ) // good
31603143   ROM_LOAD16_WORD_SWAP( "mpr19534.3",    0x0800000, 0x0400000, CRC(820e4781) SHA1(7ea5626ad4e1929a5ec28a99ec12bc364df8f70d) ) // good
31613144   ROM_LOAD16_WORD_SWAP( "mpr19535.4",    0x0c00000, 0x0400000, CRC(94fadfa4) SHA1(a7d0727cf601e00f1ea31e6bf3e591349c3f6030) ) // good
r3485r3486
31843167   STV_BIOS
31853168
31863169   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3187   ROM_LOAD( "sando-r.13",               0x0000000, 0x0100000, CRC(fe63a239) SHA1(01502d4494f968443581cd2c74f25967d41f775e) )
3188   ROM_RELOAD ( 0x0100000, 0x0100000 )
3189   ROM_RELOAD ( 0x0200000, 0x0100000 )
3190   ROM_RELOAD ( 0x0300000, 0x0100000 )
3170   ROM_LOAD16_BYTE( "sando-r.13",               0x0000001, 0x0100000, CRC(fe63a239) SHA1(01502d4494f968443581cd2c74f25967d41f775e) )
3171
31913172   ROM_LOAD16_WORD_SWAP( "mpr18635.8",   0x1c00000, 0x0400000, CRC(441e1368) SHA1(acb2a7e8d44c2203b8d3c7a7b70e20ffb120bebf) ) // good
31923173   ROM_RELOAD(                           0x0400000, 0x0400000 )
31933174   ROM_LOAD16_WORD_SWAP( "mpr18636.9",   0x2000000, 0x0400000, CRC(fff1dd80) SHA1(36b8e1526a4370ae33fd4671850faf51c448bca4) ) // good
r3485r3486
32513232   STV_BIOS
32523233
32533234   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3254   ROM_LOAD( "ic11",               0x0000000, 0x0200000, CRC(9abae8d4) SHA1(ddbe4c8fff8fa59d63e278e95f245145d2da8aeb) )
3255   ROM_RELOAD ( 0x0100000, 0x0200000 )
3256   ROM_RELOAD ( 0x0200000, 0x0200000 )
3257   ROM_RELOAD ( 0x0300000, 0x0200000 )
3235   ROM_LOAD16_BYTE( "ic11",               0x0000001, 0x0200000, CRC(9abae8d4) SHA1(ddbe4c8fff8fa59d63e278e95f245145d2da8aeb) )
32583236
32593237   ROM_LOAD( "ic13",    0x0400000, 0x0200000, CRC(f72c1d13) SHA1(a2b168d187034024b83fbbe2f5eec78816285da9) ) // ic2 good
32603238   ROM_LOAD( "ic14",    0x0600000, 0x0200000, CRC(bcd72105) SHA1(fb88a1f2589fef5d9845027646259ec8e781771b) ) // ic2 good
r3485r3486
32743252   STV_BIOS
32753253
32763254   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3277   ROM_LOAD( "epr20542.13",               0x0000000, 0x0100000, CRC(0e632db5) SHA1(9bc52794892eec22d381387d13a0388042e30714) )
3278   ROM_RELOAD ( 0x0100000, 0x0100000 )
3279   ROM_RELOAD ( 0x0200000, 0x0100000 )
3280   ROM_RELOAD ( 0x0300000, 0x0100000 )
3255   ROM_LOAD16_BYTE( "epr20542.13",               0x0000001, 0x0100000, CRC(0e632db5) SHA1(9bc52794892eec22d381387d13a0388042e30714) )
3256
32813257   ROM_LOAD16_WORD_SWAP( "mpr20544.2",    0x0400000, 0x0400000, CRC(661fff5e) SHA1(41f4ddda7adf004b52cc9a076606a60f31947d19) ) // good
32823258   ROM_LOAD16_WORD_SWAP( "mpr20545.3",    0x0800000, 0x0400000, CRC(8e3a37be) SHA1(a3227cdc4f03bb088e7f9aed225b238da3283e01) ) // good
32833259   ROM_LOAD16_WORD_SWAP( "mpr20546.4",    0x0c00000, 0x0400000, CRC(72020886) SHA1(e80bdeb11b726eb23f2283950d65d55e31a5672e) ) // good
r3485r3486
32913267   STV_BIOS
32923268
32933269   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3294   ROM_LOAD( "seabassf.13",               0x0000000, 0x0100000, CRC(6d7c39cc) SHA1(d9d1663134420b75c65ee07d7d547254785f2f83) )
3295   ROM_RELOAD ( 0x0100000, 0x0100000 )
3296   ROM_RELOAD ( 0x0200000, 0x0100000 )
3297   ROM_RELOAD ( 0x0300000, 0x0100000 )
3270   ROM_LOAD16_BYTE( "seabassf.13",               0x0000001, 0x0100000, CRC(6d7c39cc) SHA1(d9d1663134420b75c65ee07d7d547254785f2f83) )
3271
32983272   ROM_LOAD16_WORD_SWAP( "mpr20551.2",    0x0400000, 0x0400000, CRC(9a0c6dd8) SHA1(26600372cc673ce3678945f4b5dc4e3ab31643a4) ) // good
32993273   ROM_LOAD16_WORD_SWAP( "mpr20552.3",    0x0800000, 0x0400000, CRC(5f46b0aa) SHA1(1aa576b15971c0ffb4e08d4802246841b31b6f35) ) // good
33003274   ROM_LOAD16_WORD_SWAP( "mpr20553.4",    0x0c00000, 0x0400000, CRC(c0f8a6b6) SHA1(2038b9231a950450267be0db24b31d8035db79ad) ) // good
r3485r3486
33283302   STV_BIOS
33293303
33303304   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3331   ROM_LOAD( "epr18777.13",               0x0000000, 0x0080000, CRC(8d180866) SHA1(d47ebabab6e06400312d39f68cd818852e496b96) )
3332   ROM_RELOAD ( 0x0080000, 0x0080000 )
3333   ROM_RELOAD ( 0x0100000, 0x0080000 )
3334   ROM_RELOAD ( 0x0180000, 0x0080000 )
3335   ROM_RELOAD ( 0x0200000, 0x0080000 )
3336   ROM_RELOAD ( 0x0280000, 0x0080000 )
3337   ROM_RELOAD ( 0x0300000, 0x0080000 )
3338   ROM_RELOAD ( 0x0380000, 0x0080000 )
3305   ROM_LOAD16_BYTE( "epr18777.13",               0x0000001, 0x0080000, CRC(8d180866) SHA1(d47ebabab6e06400312d39f68cd818852e496b96) )
3306   ROM_RELOAD ( 0x0100001, 0x0080000 )
3307
33393308   ROM_LOAD16_WORD_SWAP( "mpr18778.8",    0x1c00000, 0x0400000, CRC(25e1300e) SHA1(64f3843f62cee34a47244ad5ee78fb2aa35289e3) ) // good
33403309   ROM_LOAD16_WORD_SWAP( "mpr18779.9",    0x2000000, 0x0400000, CRC(51e2fabd) SHA1(3aa361149af516f16d7d422596ee82014a183c2b) ) // good
33413310   ROM_LOAD16_WORD_SWAP( "mpr18780.10",   0x2400000, 0x0400000, CRC(8cd4dd74) SHA1(9ffec1280b3965d52f643894bdfecdd792028191) ) // good
r3485r3486
33473316   STV_BIOS
33483317
33493318   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3350   ROM_LOAD( "fpr19188.13",               0x0000000, 0x0100000, CRC(45a27e32) SHA1(96e1bab8bdadf7071afac2a0a6dd8fd8989f12a6) )
3351   ROM_RELOAD ( 0x0100000, 0x0100000 )
3352   ROM_RELOAD ( 0x0200000, 0x0100000 )
3353   ROM_RELOAD ( 0x0300000, 0x0100000 )
3319   ROM_LOAD16_BYTE( "fpr19188.13",               0x0000001, 0x0100000, CRC(45a27e32) SHA1(96e1bab8bdadf7071afac2a0a6dd8fd8989f12a6) )
3320
33543321   ROM_LOAD16_WORD_SWAP( "mpr19189.2",    0x0400000, 0x0400000, CRC(0b202a3e) SHA1(6691b5af2cacd6092ec03886b78c2565953fa297) ) // good
33553322   ROM_LOAD16_WORD_SWAP( "mpr19190.3",    0x0800000, 0x0400000, CRC(1777ded8) SHA1(dd332ac79f0a6d82b6bde35b795b2845003dd1a5) ) // good
33563323   ROM_LOAD16_WORD_SWAP( "mpr19191.4",    0x0c00000, 0x0400000, CRC(ec6eb07b) SHA1(01fe4832ece8638ea6f4060099d9105fe8092c88) ) // good
r3485r3486
33623329   STV_BIOS
33633330
33643331   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3365   ROM_LOAD( "epr21488.13",               0x0000000, 0x0080000, CRC(71c9def1) SHA1(a544a0b4046307172d2c1bf426ed24845f87d894) )
3366   ROM_RELOAD ( 0x0080000, 0x0080000 )
3367   ROM_RELOAD ( 0x0100000, 0x0080000 )
3368   ROM_RELOAD ( 0x0180000, 0x0080000 )
3369   ROM_RELOAD ( 0x0200000, 0x0080000 )
3370   ROM_RELOAD ( 0x0280000, 0x0080000 )
3371   ROM_RELOAD ( 0x0300000, 0x0080000 )
3372   ROM_RELOAD ( 0x0380000, 0x0080000 )
3332   ROM_LOAD16_BYTE( "epr21488.13",               0x0000001, 0x0080000, CRC(71c9def1) SHA1(a544a0b4046307172d2c1bf426ed24845f87d894) )
3333   ROM_RELOAD ( 0x0100001, 0x0080000 )
3334
33733335   ROM_LOAD16_WORD_SWAP( "mpr21489.2",    0x0400000, 0x0400000, CRC(4c85152b) SHA1(78f2f1c31718d5bf631d8813daf9a11ea2a0e451) ) // ic2 good (was .12)
33743336   ROM_LOAD16_WORD_SWAP( "mpr21490.3",    0x0800000, 0x0400000, CRC(03da67f8) SHA1(02f9ba7549ca552291dc0ff1b631103015838bba) ) // ic3 good (was .13)
33753337   ROM_LOAD16_WORD_SWAP( "mpr21491.4",    0x0c00000, 0x0400000, CRC(cf7ee784) SHA1(af823df2d60d8ef3d17628b95a04136b807ca095) ) // ic4 good (was .14)
r3485r3486
33813343   STV_BIOS
33823344
33833345   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3384   ROM_LOAD( "fpr17834.13",               0x0000000, 0x0100000, CRC(746ef686) SHA1(e31c317991a687662a8a2a45aed411001e5f1941) )
3385   ROM_RELOAD ( 0x0100000, 0x0100000 )
3386   ROM_RELOAD ( 0x0200000, 0x0100000 )
3387   ROM_RELOAD ( 0x0300000, 0x0100000 )
3346   ROM_LOAD16_BYTE( "fpr17834.13",               0x0000001, 0x0100000, CRC(746ef686) SHA1(e31c317991a687662a8a2a45aed411001e5f1941) )
3347
33883348   ROM_LOAD16_WORD_SWAP( "mpr17836.2",    0x0400000, 0x0400000, CRC(55e9642d) SHA1(5198291cd1dce0398eb47760db2c19eae99273b0) ) // good
33893349   ROM_LOAD16_WORD_SWAP( "mpr17837.3",    0x0800000, 0x0400000, CRC(13d1e667) SHA1(cd513ceb33cc20032090113b61227638cf3b3998) ) // good
33903350   ROM_LOAD16_WORD_SWAP( "mpr17838.4",    0x0c00000, 0x0400000, CRC(f9e70032) SHA1(8efdbcce01bdf77acfdb293545c59bf224a9c7d2) ) // good
r3485r3486
33993359   STV_BIOS
34003360
34013361   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3402   ROM_LOAD( "epr20819.13",    0x0000000, 0x0100000, CRC(d930dfc8) SHA1(f66cc955181720661a0334fe67fa5750ddf9758b) )
3403   ROM_RELOAD ( 0x0100000, 0x0100000 )
3404   ROM_RELOAD ( 0x0200000, 0x0100000 )
3405   ROM_RELOAD ( 0x0300000, 0x0100000 )
3362   ROM_LOAD16_BYTE( "epr20819.13",    0x0000001, 0x0100000, CRC(d930dfc8) SHA1(f66cc955181720661a0334fe67fa5750ddf9758b) )
3363
34063364   ROM_LOAD16_WORD_SWAP( "mpr20821.2",    0x0400000, 0x0400000, CRC(2d930d23) SHA1(5fcaf4257f3639cb3aa407d2936f616499a09d97) ) // ic2 good (was .12)
34073365   ROM_LOAD16_WORD_SWAP( "mpr20822.3",    0x0800000, 0x0400000, CRC(8b33a5e2) SHA1(d5689ac8aad63509febe9aa4077351be09b2d8d4) ) // ic3 good (was .13)
34083366   ROM_LOAD16_WORD_SWAP( "mpr20823.4",    0x0c00000, 0x0400000, CRC(6e6d4e95) SHA1(c387d03ba27580c62ac0bf780915fdf41552df6f) ) // ic4 good (was .14)
r3485r3486
34133371   STV_BIOS
34143372
34153373   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3416   ROM_LOAD( "fpr18914.13",               0x0000000, 0x0100000, CRC(cd35730a) SHA1(645b52b449766beb740ab8f99957f8f431351ceb) )
3417   ROM_RELOAD ( 0x0100000, 0x0100000 )
3418   ROM_RELOAD ( 0x0200000, 0x0100000 )
3419   ROM_RELOAD ( 0x0300000, 0x0100000 )
3374   ROM_LOAD16_BYTE( "fpr18914.13",               0x0000001, 0x0100000, CRC(cd35730a) SHA1(645b52b449766beb740ab8f99957f8f431351ceb) )
3375
34203376   ROM_LOAD16_WORD_SWAP( "mpr18916.4",    0x0c00000, 0x0400000, CRC(4aae3ddb) SHA1(b75479e73f1bce3f0c27fbd90820fa51eb1914a6) ) // good
34213377   ROM_LOAD16_WORD_SWAP( "mpr18917.5",    0x1000000, 0x0400000, CRC(edf6edc3) SHA1(478e958f4f10a8126a00c83feca4a55ad6c25503) ) // good
34223378   ROM_LOAD16_WORD_SWAP( "mpr18918.6",    0x1400000, 0x0400000, CRC(d3a95036) SHA1(e300bbbb71fb06027dc539c9bbb12946770ffc95) ) // good
r3485r3486
34323388   STV_BIOS
34333389
34343390   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3435   ROM_LOAD( "epr17944.13",               0x0000000, 0x0100000, CRC(a5bdc560) SHA1(d3830480a611b7d88760c672ce46a2ea74076487) )
3436   ROM_RELOAD ( 0x0100000, 0x0100000 )
3437   ROM_RELOAD ( 0x0200000, 0x0100000 )
3438   ROM_RELOAD ( 0x0300000, 0x0100000 )
3391   ROM_LOAD16_BYTE( "epr17944.13",               0x0000001, 0x0100000, CRC(a5bdc560) SHA1(d3830480a611b7d88760c672ce46a2ea74076487) )
3392
34393393   ROM_LOAD16_WORD_SWAP( "mpr17946.2",    0x0400000, 0x0400000, CRC(4cb245f7) SHA1(363d9936b27043b5858c956a45736ac05aefc54e) ) // good
34403394   ROM_LOAD16_WORD_SWAP( "mpr17947.3",    0x0800000, 0x0400000, CRC(fef4a9fb) SHA1(1b4bd095962db769da17d3644df10f62d041e914) ) // good
34413395   ROM_LOAD16_WORD_SWAP( "mpr17948.4",    0x0c00000, 0x0400000, CRC(3e2b251a) SHA1(be6191c18727d7cbc6399fd4c1aaae59304af30c) ) // good
r3485r3486
34643418   STV_BIOS
34653419
34663420   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3467   ROM_LOAD( "fpr20108.13",    0x0000000, 0x0100000, CRC(1ef9ced0) SHA1(abc90ce341cd17bb77349d611d6879389611f0bf) ) // bad
3468   ROM_RELOAD ( 0x0100000, 0x0100000 )
3469   ROM_RELOAD ( 0x0200000, 0x0100000 )
3470   ROM_RELOAD ( 0x0300000, 0x0100000 )
3421   ROM_LOAD16_BYTE( "fpr20108.13",    0x0000001, 0x0100000, CRC(1ef9ced0) SHA1(abc90ce341cd17bb77349d611d6879389611f0bf) ) // bad
3422
34713423   ROM_LOAD16_WORD_SWAP( "mpr20110.2",    0x0400000, 0x0400000, CRC(238ef832) SHA1(20fade5730ff8e249a1450c41bfdff6e133f4768) ) // good
34723424   ROM_LOAD16_WORD_SWAP( "mpr20111.3",    0x0800000, 0x0400000, CRC(b0a86f69) SHA1(e66427f70413ad43fccc38423962c5eeda01094f) ) // good
34733425   ROM_LOAD16_WORD_SWAP( "mpr20112.4",    0x0c00000, 0x0400000, CRC(3ba2b49b) SHA1(5ad154a8b774075479d791e29cbaf221d47557fc) ) // good
r3485r3486
34813433   STV_BIOS
34823434
34833435   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3484   ROM_LOAD( "epr20398.13",    0x0000000, 0x0100000, CRC(3fb56a0b) SHA1(13c2fa2d94b106d39e46f71d15fbce3607a5965a) ) // bad
3485   ROM_RELOAD ( 0x0100000, 0x0100000 )
3486   ROM_RELOAD ( 0x0200000, 0x0100000 )
3487   ROM_RELOAD ( 0x0300000, 0x0100000 )
3436   ROM_LOAD16_BYTE( "epr20398.13",    0x0000001, 0x0100000, CRC(3fb56a0b) SHA1(13c2fa2d94b106d39e46f71d15fbce3607a5965a) ) // bad
3437
34883438   ROM_LOAD16_WORD_SWAP( "mpr20400.2",    0x0400000, 0x0400000, CRC(1edfbe05) SHA1(b0edd3f3d57408101ae6eb0aec742afbb4d289ca) ) // good
34893439   ROM_LOAD16_WORD_SWAP( "mpr20401.3",    0x0800000, 0x0400000, CRC(99e98937) SHA1(e1b4d12a0b4d0fe97a62fcc085e19cce77657c99) ) // good
34903440   ROM_LOAD16_WORD_SWAP( "mpr20402.4",    0x0c00000, 0x0400000, CRC(4572aa60) SHA1(8b2d76ea8c6e2f472c6ee7c9b6ad6e80e6a1a85a) ) // good
r3485r3486
35123462   STV_BIOS
35133463
35143464   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3515   ROM_LOAD(             "ic13.bin",      0x0000000, 0x0100000, CRC(b456f4cd) SHA1(91cbe703ec7c1dd45eb3b05bdfeb06e3570599d1) )
3516   /* mirroring is essential on this one */
3517   ROM_RELOAD ( 0x0100000, 0x0100000 )
3518   ROM_RELOAD ( 0x0200000, 0x0100000 )
3519   ROM_RELOAD ( 0x0300000, 0x0100000 )
3465   ROM_LOAD16_BYTE(             "ic13.bin",      0x0000001, 0x0100000, CRC(b456f4cd) SHA1(91cbe703ec7c1dd45eb3b05bdfeb06e3570599d1) )
3466   ROM_RELOAD_PLAIN ( 0x0200000, 0x0100000 ) // needs the rom mapped here to appear 'normal'
3467   ROM_RELOAD_PLAIN ( 0x0300000, 0x0100000 )
35203468
35213469   ROM_LOAD16_WORD_SWAP( "mcj-00.2",      0x0400000, 0x0200000, CRC(4eeacd6f) SHA1(104ca230f22cd11cc536b34abd482e54791b4d0f) )// good
35223470   ROM_LOAD16_WORD_SWAP( "mcj-01.3",      0x0800000, 0x0200000, CRC(365a494b) SHA1(29713dfc83a9ade63ebcc7994d14cd785c4500b9) )// good
r3485r3486
35763524   STV_BIOS
35773525
35783526   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3579   ROM_LOAD( "epr-18821.ic13",  0x0000000, 0x0080000, CRC(9a6658e2) SHA1(16dbae3d9ab584713afcb403f89fe71049609245) )
3580   ROM_RELOAD ( 0x0080000, 0x0080000 )
3581   ROM_RELOAD ( 0x0100000, 0x0080000 )
3582   ROM_RELOAD ( 0x0180000, 0x0080000 )
3583   ROM_RELOAD ( 0x0200000, 0x0080000 )
3584   ROM_RELOAD ( 0x0280000, 0x0080000 )
3585   ROM_RELOAD ( 0x0300000, 0x0080000 )
3586   ROM_RELOAD ( 0x0380000, 0x0080000 )
3527   ROM_LOAD16_BYTE( "epr-18821.ic13",  0x0000001, 0x0080000, CRC(9a6658e2) SHA1(16dbae3d9ab584713afcb403f89fe71049609245) )
3528   ROM_RELOAD ( 0x0100001, 0x0080000 )
3529
35873530//  ROM_LOAD16_WORD_SWAP( "mpr17946.2",    0x0400000, 0x0400000, CRC(4cb245f7) SHA1(363d9936b27043b5858c956a45736ac05aefc54e) ) // good
35883531//  ROM_LOAD16_WORD_SWAP( "mpr17947.3",    0x0800000, 0x0400000, CRC(fef4a9fb) SHA1(1b4bd095962db769da17d3644df10f62d041e914) ) // good
35893532//  ROM_LOAD16_WORD_SWAP( "mpr17948.4",    0x0c00000, 0x0400000, CRC(3e2b251a) SHA1(be6191c18727d7cbc6399fd4c1aaae59304af30c) ) // good
r3485r3486
36213564   ROM_COPY( "main",0,0,0x080000)
36223565
36233566   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3624   ROM_LOAD(             "epr18344.a",      0x0000000, 0x0100000,  CRC(5a7de018) SHA1(88e0c2a9a9d4ebf699878c0aa9737af85f95ccf8) )
3625   ROM_RELOAD ( 0x0100000, 0x0100000 )
3626   ROM_RELOAD ( 0x0200000, 0x0100000 )
3627   ROM_RELOAD ( 0x0300000, 0x0100000 )
3567   ROM_LOAD16_BYTE(             "epr18344.a",      0x0000001, 0x0100000,  CRC(5a7de018) SHA1(88e0c2a9a9d4ebf699878c0aa9737af85f95ccf8) )
3568
36283569   ROM_LOAD16_WORD_SWAP( "mpr18273.ic2",      0x0400000, 0x0200000, NO_DUMP )
36293570   ROM_LOAD16_WORD_SWAP( "mpr18274.ic3",      0x0800000, 0x0200000, NO_DUMP )
36303571
r3485r3486
36373578   STV_BIOS
36383579
36393580   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3640   ROM_LOAD( "flash.ic13",               0x0000000, 0x0100000, CRC(e6f0aca0) SHA1(251d4d9c5a332d13af3a144c5eb9d8e7836bdd1b) ) // good
3641   ROM_RELOAD ( 0x0100000, 0x0100000 )
3642   ROM_RELOAD ( 0x0200000, 0x0100000 )
3643   ROM_RELOAD ( 0x0300000, 0x0100000 )
3581   ROM_LOAD16_BYTE( "flash.ic13",               0x0000001, 0x0100000, CRC(e6f0aca0) SHA1(251d4d9c5a332d13af3a144c5eb9d8e7836bdd1b) ) // good
36443582
36453583   ROM_LOAD16_WORD_SWAP( "mpr-19354.ic2",    0x0400000, 0x0400000, CRC(a23822e7) SHA1(10ca5d39dcaaf35b80168a08d8a18d77fba1d2ce) ) // good
36463584   ROM_LOAD16_WORD_SWAP( "mpr-19355.ic3",    0x0800000, 0x0400000, CRC(d70e5ebc) SHA1(2d560f6b6e693b2b91cf5ff5c4f0890cc2176f91) ) // good
r3485r3486
36553593   STV_BIOS
36563594
36573595   ROM_REGION32_BE( 0x3000000, "user1", 0 ) /* SH2 code */
3658   ROM_LOAD( "epr-21300a.ic13",    0x0000000, 0x0100000, CRC(899d829e) SHA1(b6c6da92dc108353998b29c0659d288645541519) ) // good
3659   ROM_RELOAD ( 0x0100000, 0x0100000 )
3660   ROM_RELOAD ( 0x0200000, 0x0100000 )
3661   ROM_RELOAD ( 0x0300000, 0x0100000 )
3596   ROM_LOAD16_BYTE( "epr-21300a.ic13",    0x0000001, 0x0100000, CRC(899d829e) SHA1(b6c6da92dc108353998b29c0659d288645541519) ) // good
3597
36623598   ROM_LOAD16_WORD_SWAP( "mpr-21290.ic2",    0x0400000, 0x0400000, CRC(a49d29f3) SHA1(8f6c26fd9e94a9e03dd0029026d205cf481fe151) ) // good
36633599   ROM_LOAD16_WORD_SWAP( "mpr-21291.ic3",    0x0800000, 0x0400000, CRC(9452ba20) SHA1(8a9ff546901715f99bb911616c74ae30ebd7c6d7) ) // good
36643600   ROM_LOAD16_WORD_SWAP( "mpr-21292.ic4",    0x0c00000, 0x0400000, CRC(f60268e2) SHA1(5c2febb94553a941a68e9611617750a89c82e783) ) // good
r3485r3486
37353671
37363672//GAME YEAR, NAME,     PARENT,  MACH, INP, INIT,      MONITOR
37373673/* Playable */
3738GAME( 1998, astrass,   stvbios, stv, stv,  astrass,   ROT0,   "Sunsoft",               "Astra SuperStars (J 980514 V1.002)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3739GAME( 1995, bakubaku,  stvbios, stv, stv,  bakubaku,  ROT0,   "Sega",                   "Baku Baku Animal (J 950407 V1.000)", GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS )
3740GAME( 1996, batmanfr,  stvbios, stv, batmanfr,batmanfr, ROT0, "Acclaim",               "Batman Forever (JUE 960507 V1.000)", GAME_NO_SOUND )
3741GAME( 1996, colmns97,  stvbios, stv, stv,  colmns97,  ROT0,   "Sega",                   "Columns '97 (JET 961209 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3742GAME( 1997, cotton2,   stvbios, stv, stv,  cotton2,   ROT0,   "Success",                "Cotton 2 (JUET 970902 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3743GAME( 1998, cottonbm,  stvbios, stv, stv,  cottonbm,  ROT0,   "Success",                "Cotton Boomerang (JUET 980709 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3744GAME( 1995, critcrsh,  stvbios, stv, critcrsh, ic13,  ROT0,   "Sega",                    "Critter Crusher (EA 951204 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3745GAME( 1999, danchih,   stvbios, stv, stvmp,danchih,   ROT0,   "Altron (Tecmo license)",   "Danchi de Hanafuda (J 990607 V1.400)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3746GAME( 1996, diehard,   stvbios, stv, stv,  diehard,   ROT0,   "Sega",                   "Die Hard Arcade (UET 960515 V1.000)", GAME_IMPERFECT_SOUND  )
3747GAME( 1996, dnmtdeka,  diehard, stv, stv,  dnmtdeka,  ROT0,   "Sega",                   "Dynamite Deka (J 960515 V1.000)", GAME_IMPERFECT_SOUND  )
3748GAME( 1995, ejihon,    stvbios, stv, stv,  ic13,      ROT0,   "Sega",                   "Ejihon Tantei Jimusyo (J 950613 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3749GAME( 1995, fhboxers,  stvbios, stv, stv,  fhboxers,  ROT0,   "Sega",                   "Funky Head Boxers (JUETBKAL 951218 V1.000)", GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS )
3750GAME( 1994, gaxeduel,  stvbios, stv, stv,  gaxeduel,  ROT0,   "Sega",                    "Golden Axe - The Duel (JUETL 950117 V1.000)", GAME_IMPERFECT_SOUND )
3751GAME( 1998, grdforce,  stvbios, stv, stv,  grdforce,  ROT0,   "Success",                "Guardian Force (JUET 980318 V0.105)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3752GAME( 1998, groovef,   stvbios, stv, stv,  groovef,   ROT0,   "Atlus",                  "Power Instinct 3 - Groove On Fight (J 970416 V1.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3753GAME( 1997, hanagumi,  stvbios, stv, stv,  hanagumi,  ROT0,   "Sega",                   "Hanagumi Taisen Columns - Sakura Wars (J 971007 V1.010)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3754GAME( 1996, introdon,  stvbios, stv, stv,  ic13,      ROT0,   "Sunsoft / Success",         "Karaoke Quiz Intro Don Don! (J 960213 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3755GAME( 1995, kiwames,   stvbios, stv, stvmp,ic13,      ROT0,   "Athena",                 "Pro Mahjong Kiwame S (J 951020 V1.208)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3756GAME( 1997, maruchan,  stvbios, stv, stv,  maruchan,  ROT0,   "Sega / Toyosuisan",          "Maru-Chan de Goo! (J 971216 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3757GAME( 1996, mausuke,   stvbios, stv, stv,  mausuke,   ROT0,   "Data East",              "Mausuke no Ojama the World (J 960314 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3758GAME( 1998, othellos,  stvbios, stv, stv,  othellos,  ROT0,   "Success",                "Othello Shiyouyo (J 980423 V1.002)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3759GAME( 1995, pblbeach,  stvbios, stv, stv,  pblbeach,  ROT0,   "T&E Soft",                 "Pebble Beach - The Great Shot (JUE 950913 V0.990)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3760GAME( 1996, prikura,   stvbios, stv, stv,  prikura,   ROT0,   "Atlus",                  "Princess Clara Daisakusen (J 960910 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3761GAME( 1996, puyosun,   stvbios, stv, stv,  puyosun,   ROT0,   "Compile",                "Puyo Puyo Sun (J 961115 V0.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3762GAME( 1998, rsgun,     stvbios, stv, stv,  rsgun,     ROT0,   "Treasure",              "Radiant Silvergun (JUET 980523 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3763GAME( 1998, sasissu,   stvbios, stv, stv,  sasissu,   ROT0,   "Sega",                    "Taisen Tanto-R Sashissu!! (J 980216 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3764GAME( 1999, sanjeon,   sasissu, stv, stv,  sanjeon,   ROT0,   "Sega / Deniam",             "DaeJeon! SanJeon SuJeon (Korea)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3765GAME( 1997, seabass,   stvbios, stv, stv,  seabass,   ROT0,   "A wave inc. (Able license)","Sea Bass Fishing (JUET 971110 V0.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3766GAME( 1995, shanhigw,  stvbios, stv, stv,  shanhigw,  ROT0,   "Sunsoft / Activision",      "Shanghai - The Great Wall / Shanghai Triple Threat (JUE 950623 V1.005)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3767GAME( 1997, shienryu,  stvbios, stv, stv,  shienryu,  ROT270, "Warashi",                "Shienryu (JUET 961226 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3768GAME( 1995, smleague,  stvbios, stv, stv,  smleague,  ROT0,   "Sega",                    "Super Major League (U 960108 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3769GAME( 1995, finlarch,  smleague,stv, stv,  finlarch,  ROT0,   "Sega",                    "Final Arch (J 950714 V1.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3770GAME( 1998, sss,       stvbios, stv, stv,  sss,       ROT0,   "Capcom / Cave / Victor",     "Steep Slope Sliders (JUET 981110 V1.000)", GAME_IMPERFECT_SOUND )
3771GAME( 1995, sandor,    stvbios, stv, stv,  sandor,    ROT0,   "Sega",                    "Puzzle & Action: Sando-R (J 951114 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3772GAME( 1997, thunt,     sandor,  stv, stv,  thunt,     ROT0,   "Sega",                     "Puzzle & Action: Treasure Hunt (JUET 970901 V2.00E)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3773GAME( 1997, thuntk,    sandor,  stv, stv,  sandor,    ROT0,   "Sega / Deniam",            "Puzzle & Action: BoMulEul Chajara (Korea)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3774GAME( 1996, sokyugrt,  stvbios, stv, stv,  sokyugrt,  ROT0,   "Raizing / 8ing",            "Soukyugurentai / Terra Diver (JUET 960821 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3775GAME( 1995, suikoenb,  stvbios, stv, stv,  suikoenb,  ROT0,   "Data East",                "Suikoenbu / Outlaws of the Lost Dynasty (JUETL 950314 V2.001)", GAME_IMPERFECT_SOUND )
3776GAME( 1996, vfkids,    stvbios, stv, stv,  ic13,      ROT0,   "Sega",                   "Virtua Fighter Kids (JUET 960319 V0.000)", GAME_IMPERFECT_SOUND )
3777GAME( 1997, winterht,  stvbios, stv, stv,  winterht,  ROT0,   "Sega",                   "Winter Heat (JUET 971012 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3778GAME( 1997, znpwfv,    stvbios, stv, stv,  znpwfv,    ROT0,   "Sega",                    "Zen Nippon Pro-Wrestling Featuring Virtua (J 971123 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3779GAME( 1997, nclubv3,   stvbios, stv, stv,  nameclv3,  ROT0,   "Sega",                    "Name Club Ver.3 (J 970723 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) // seems to work, although it could do with speedups, and the printer isn't emulated..
3674GAME( 1998, astrass,   stvbios, stv, stv,        astrass,      ROT0,   "Sunsoft",                       "Astra SuperStars (J 980514 V1.002)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3675GAME( 1995, bakubaku,  stvbios, stv, stv,        stv,          ROT0,   "Sega",                      "Baku Baku Animal (J 950407 V1.000)", GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS )
3676GAME( 1996, batmanfr,  stvbios, stv, batmanfr,   batmanfr,    ROT0,    "Acclaim",                       "Batman Forever (JUE 960507 V1.000)", GAME_NO_SOUND )
3677GAME( 1996, colmns97,  stvbios, stv, stv,        colmns97,     ROT0,   "Sega",                      "Columns '97 (JET 961209 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3678GAME( 1997, cotton2,   stvbios, stv, stv,        cotton2,      ROT0,   "Success",                   "Cotton 2 (JUET 970902 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3679GAME( 1998, cottonbm,  stvbios, stv, stv,        cottonbm,     ROT0,   "Success",                   "Cotton Boomerang (JUET 980709 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3680GAME( 1995, critcrsh,  stvbios, stv, critcrsh,   stv,         ROT0,   "Sega",                       "Critter Crusher (EA 951204 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3681GAME( 1999, danchih,   stvbios, stv, stvmp,      danchih,      ROT0,   "Altron (Tecmo license)",        "Danchi de Hanafuda (J 990607 V1.400)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3682GAME( 1996, diehard,   stvbios, stv, stv,        diehard,      ROT0,   "Sega",                      "Die Hard Arcade (UET 960515 V1.000)", GAME_IMPERFECT_SOUND  )
3683GAME( 1996, dnmtdeka,  diehard, stv, stv,       dnmtdeka,     ROT0,   "Sega",                      "Dynamite Deka (J 960515 V1.000)", GAME_IMPERFECT_SOUND  )
3684GAME( 1995, ejihon,    stvbios, stv, stv,        stv,          ROT0,   "Sega",                      "Ejihon Tantei Jimusyo (J 950613 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3685GAME( 1995, fhboxers,  stvbios, stv, stv,        fhboxers,     ROT0,   "Sega",                      "Funky Head Boxers (JUETBKAL 951218 V1.000)", GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS )
3686GAME( 1994, gaxeduel,  stvbios, stv, stv,        gaxeduel,     ROT0,   "Sega",                       "Golden Axe - The Duel (JUETL 950117 V1.000)", GAME_IMPERFECT_SOUND )
3687GAME( 1998, grdforce,  stvbios, stv, stv,        grdforce,     ROT0,   "Success",                   "Guardian Force (JUET 980318 V0.105)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3688GAME( 1998, groovef,   stvbios, stv, stv,        groovef,      ROT0,   "Atlus",                     "Power Instinct 3 - Groove On Fight (J 970416 V1.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3689GAME( 1997, hanagumi,  stvbios, stv, stv,        hanagumi,     ROT0,   "Sega",                      "Hanagumi Taisen Columns - Sakura Wars (J 971007 V1.010)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3690GAME( 1996, introdon,  stvbios, stv, stv,        stv,          ROT0,   "Sunsoft / Success",            "Karaoke Quiz Intro Don Don! (J 960213 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3691GAME( 1995, kiwames,   stvbios, stv, stvmp,      stv,          ROT0,   "Athena",                    "Pro Mahjong Kiwame S (J 951020 V1.208)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3692GAME( 1997, maruchan,  stvbios, stv, stv,        maruchan,     ROT0,   "Sega / Toyosuisan",             "Maru-Chan de Goo! (J 971216 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3693GAME( 1996, mausuke,   stvbios, stv, stv,        mausuke,      ROT0,   "Data East",                 "Mausuke no Ojama the World (J 960314 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3694GAME( 1998, othellos,  stvbios, stv, stv,        othellos,     ROT0,   "Success",                   "Othello Shiyouyo (J 980423 V1.002)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3695GAME( 1995, pblbeach,  stvbios, stv, stv,        pblbeach,     ROT0,   "T&E Soft",                      "Pebble Beach - The Great Shot (JUE 950913 V0.990)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3696GAME( 1996, prikura,   stvbios, stv, stv,        prikura,      ROT0,   "Atlus",                     "Princess Clara Daisakusen (J 960910 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3697GAME( 1996, puyosun,   stvbios, stv, stv,        puyosun,      ROT0,   "Compile",                   "Puyo Puyo Sun (J 961115 V0.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3698GAME( 1998, rsgun,     stvbios, stv, stv,        rsgun,        ROT0,   "Treasure",                      "Radiant Silvergun (JUET 980523 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3699GAME( 1998, sasissu,   stvbios, stv, stv,        sasissu,      ROT0,   "Sega",                       "Taisen Tanto-R Sashissu!! (J 980216 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3700GAME( 1999, sanjeon,   sasissu, stv, stv,        sanjeon,      ROT0,   "Sega / Deniam",                "DaeJeon! SanJeon SuJeon (AJTUE 990412 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3701GAME( 1997, seabass,   stvbios, stv, stv,        seabass,      ROT0,   "A wave inc. (Able license)",   "Sea Bass Fishing (JUET 971110 V0.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3702GAME( 1995, shanhigw,  stvbios, stv, stv,        shanhigw,     ROT0,   "Sunsoft / Activision",         "Shanghai - The Great Wall / Shanghai Triple Threat (JUE 950623 V1.005)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3703GAME( 1997, shienryu,  stvbios, stv, stv,        shienryu,     ROT270, "Warashi",                   "Shienryu (JUET 961226 V1.000)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3704GAME( 1995, smleague,  stvbios, stv, stv,        smleague,     ROT0,   "Sega",                       "Super Major League (U 960108 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3705GAME( 1995, finlarch,  smleague,stv, stv,        finlarch,     ROT0,   "Sega",                       "Final Arch (J 950714 V1.001)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3706GAME( 1998, sss,       stvbios, stv, stv,        sss,          ROT0,   "Capcom / Cave / Victor",        "Steep Slope Sliders (JUET 981110 V1.000)", GAME_IMPERFECT_SOUND )
3707GAME( 1995, sandor,    stvbios, stv, stv,        sandor,       ROT0,   "Sega",                       "Puzzle & Action: Sando-R (J 951114 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3708GAME( 1997, thunt,     sandor,  stv, stv,        thunt,        ROT0,   "Sega",                           "Puzzle & Action: Treasure Hunt (JUET 970901 V2.00E)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3709GAME( 1997, thuntk,    sandor,  stv, stv,        sandor,       ROT0,   "Sega / Deniam",                  "Puzzle & Action: BoMulEul Chajara (JUET 970125 V2.00K)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3710GAME( 1996, sokyugrt,  stvbios, stv, stv,        sokyugrt,     ROT0,   "Raizing / 8ing",               "Soukyugurentai / Terra Diver (JUET 960821 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3711GAME( 1995, suikoenb,  stvbios, stv, stv,        suikoenb,     ROT0,   "Data East",                   "Suikoenbu / Outlaws of the Lost Dynasty (JUETL 950314 V2.001)", GAME_IMPERFECT_SOUND )
3712GAME( 1996, vfkids,    stvbios, stv, stv,        stv,          ROT0,   "Sega",                      "Virtua Fighter Kids (JUET 960319 V0.000)", GAME_IMPERFECT_SOUND )
3713GAME( 1997, winterht,  stvbios, stv, stv,        winterht,     ROT0,   "Sega",                      "Winter Heat (JUET 971012 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3714GAME( 1997, znpwfv,    stvbios, stv, stv,        znpwfv,       ROT0,   "Sega",                       "Zen Nippon Pro-Wrestling Featuring Virtua (J 971123 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3715GAME( 1997, nclubv3,   stvbios, stv, stv,        nameclv3,     ROT0,   "Sega",                       "Name Club Ver.3 (J 970723 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) // seems to work, although it could do with speedups, and the printer isn't emulated..
37803716
37813717/* Almost */
3782GAME( 1997, vmahjong,  stvbios, stv, stvmp,stv,       ROT0,   "Micronet",                 "Virtual Mahjong (J 961214 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3783GAME( 1998, myfairld,  stvbios, stv, stvmp,stv,       ROT0,   "Micronet",                 "Virtual Mahjong 2 - My Fair Lady (J 980608 V1.000)", GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING )
3784GAME( 1998, twcup98,   stvbios, stv, stv,  twcup98,   ROT0,   "Tecmo",                    "Tecmo World Cup '98 (JUET 980410 V1.000)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS|GAME_NOT_WORKING ) // player movement
3785GAME( 1997, stress,    stvbios, stv, stv,  ic13,      ROT0,   "Sega",                    "Stress Busters", GAME_NOT_WORKING ) // needs printer
3718GAME( 1997, vmahjong,  stvbios, stv, stvmp,      stv,          ROT0,   "Micronet",                    "Virtual Mahjong (J 961214 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3719GAME( 1998, myfairld,  stvbios, stv, stvmp,      stv,          ROT0,   "Micronet",                    "Virtual Mahjong 2 - My Fair Lady (J 980608 V1.000)", GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING )
3720GAME( 1998, twcup98,   stvbios, stv, stv,        twcup98,      ROT0,   "Tecmo",                       "Tecmo World Cup '98 (JUET 980410 V1.000)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS|GAME_NOT_WORKING ) // player movement
3721GAME( 1998, stress,    stvbios, stv, stv,        stv,          ROT0,   "Sega",                       "Stress Busters (J 981020 V1.000)", GAME_NOT_WORKING ) // needs printer
37863722
37873723/* Doing Something.. but not enough yet */
3788GAME( 1998, elandore,  stvbios, stv, stv,  elandore,  ROT0,   "Sai-Mate",                 "Elan Doree - Legend of Dragon (JUET 980922 V1.006)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )//japanese name?
3789GAME( 1995, vfremix,   stvbios, stv, stv,  vfremix,   ROT0,   "Sega",                    "Virtua Fighter Remix (JUETBKAL 950428 V1.000)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
3790GAME( 1997, findlove,  stvbios, stv, stv,  ic13,      ROT0,   "Daiki / FCF",               "Find Love (J 971212 V1.000)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
3791GAME( 1996, decathlt,  stvbios, stv, stv,  decathlt,  ROT0,   "Sega",                    "Decathlete (JUET 960709 V1.001)", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3792GAME( 1996, decathlo,  decathlt, stv, stv,  decathlt,  ROT0,   "Sega",                    "Decathlete (JUET 960424 V1.000)", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3724GAME( 1998, elandore,  stvbios, stv, stv,        elandore,     ROT0,   "Sai-Mate",                    "Touryuu Densetsu Elan-Doree / Elan Doree - Legend of Dragoon (JUET 980922 V1.006)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
3725GAME( 1995, vfremix,   stvbios, stv, stv,        vfremix,      ROT0,   "Sega",                       "Virtua Fighter Remix (JUETBKAL 950428 V1.000)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
3726GAME( 1997, findlove,  stvbios, stv, stv,        stv,          ROT0,   "Daiki / FCF",                   "Find Love (J 971212 V1.000)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
3727GAME( 1996, decathlt,  stvbios, stv, stv,        decathlt,     ROT0,   "Sega",                       "Decathlete (JUET 960709 V1.001)", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
3728GAME( 1996, decathlo,  decathlt,stv, stv,        decathlt,    ROT0,     "Sega",                       "Decathlete (JUET 960424 V1.000)", GAME_NO_SOUND | GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION )
37933729
37943730
37953731/* not working,black screen */
3796GAME( 1999, ffreveng,  stvbios, stv, stv,  ffreveng,  ROT0,   "Capcom",                   "Final Fight Revenge (JUET 990714 V1.000)", GAME_UNEMULATED_PROTECTION | GAME_NO_SOUND | GAME_NOT_WORKING )
3732GAME( 1999, ffreveng,  stvbios, stv, stv,        ffreveng,     ROT0,   "Capcom",                      "Final Fight Revenge (JUET 990714 V1.000)", GAME_UNEMULATED_PROTECTION | GAME_NO_SOUND | GAME_NOT_WORKING )
3733GAME( 1996, magzun,    stvbios, stv, stv,        stv,         ROT0,   "Sega",                       "Magical Zunou Power (J 961031 V1.000)", GAME_NOT_WORKING )
37973734/* CD games */
3798GAME( 1995, sfish2,    0, stv, stv,  ic13,    ROT0,   "Sega",                   "Sport Fishing 2 (UET 951106 V1.10e)", GAME_NO_SOUND | GAME_NOT_WORKING )
3799GAME( 1995, sfish2j,   sfish2, stv, stv,  ic13,    ROT0,   "Sega",                   "Sport Fishing 2 (J 951201 V1.100)", GAME_NO_SOUND | GAME_NOT_WORKING )
3800GAME( 1997, magzun,    stvbios, stv, stv,  ic13,      ROT0,   "Sega",                    "Magical Zunou Power", GAME_NOT_WORKING )
3735GAME( 1995, sfish2,    0,       stv, stv,        stv,      ROT0,   "Sega",                         "Sport Fishing 2 (UET 951106 V1.10e)", GAME_NO_SOUND | GAME_NOT_WORKING )
3736GAME( 1995, sfish2j,   sfish2,    stv, stv,        stv,         ROT0,   "Sega",                         "Sport Fishing 2 (J 951201 V1.100)", GAME_NO_SOUND | GAME_NOT_WORKING )
38013737
38023738/*
38033739This is the known list of undumped ST-V games:
r3485r3486
38063742    Sport Fishing
38073743    Aroma Club
38083744    Movie Club
3809    Name Club
3745    Name Club (other versions)
3746    Print Club 2
3747    Youen Denshi Mahjong Yuugi Gal Jan
3748    Danchi de Quiz: Okusan 4taku Desu yo!
38103749    NBA Action (?)
38113750    Quiz Omaeni Pipon Cho! (?)
3812
38133751Others may exist as well...
38143752*/
38153753
src/mame/drivers/vamphalf.c
r3485r3486
565565   AM_RANGE( 0x0000, 0xffff) AM_ROM
566566ADDRESS_MAP_END
567567
568static ADDRESS_MAP_START( qs1000_data_map, ADDRESS_SPACE_DATA, 8 )
568static ADDRESS_MAP_START( qs1000_io_map, ADDRESS_SPACE_IO, 8 )
569569   AM_RANGE( 0x0000, 0x007f) AM_RAM   // RAM?  wavetable registers?  not sure.
570570ADDRESS_MAP_END
571571
r3485r3486
606606static MACHINE_DRIVER_START( sound_qs1000 )
607607   MDRV_CPU_ADD("audio", I8052, 24000000/4)   /* 6 MHz? */
608608   MDRV_CPU_PROGRAM_MAP(qs1000_prg_map, 0)
609   MDRV_CPU_DATA_MAP( qs1000_data_map, 0 )
609   MDRV_CPU_IO_MAP( qs1000_io_map, 0 )
610610
611611MACHINE_DRIVER_END
612612
src/mame/drivers/bnstars.c
r3485r3486
490490
491491static VIDEO_UPDATE(bnstars)
492492{
493   const device_config *left_screen  = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "left");
494   const device_config *right_screen = device_list_find_by_tag(screen->machine->config->devicelist, VIDEO_SCREEN, "right");
493495
494496   fillbitmap(priority_bitmap,0,cliprect);
495497
496   if (screen==0)
498   if (screen==left_screen)
497499   {
498500      fillbitmap(bitmap,0,cliprect);   /* bg color */
499501
r3485r3486
511513
512514      draw_sprites(screen->machine,bitmap,cliprect, ms32_spram, 0x20000, 0);
513515   }
514   else
516   else if (screen == right_screen)
515517   {
516518      fillbitmap(bitmap,0x8000+0,cliprect);   /* bg color */
517519
src/mame/drivers/meritm.c
r3485r3486
12791279   ROM_LOAD( "9255-41-07_u38-r0g", 0x300000, 0x80000,  CRC(71eac4d4) SHA1(73b9ed876f0af94bbd88503921a2b4f26bcfd397) ) /* Location U38, 02/11/1997 11:59:41 - New Jersey version */
12801280   ROM_RELOAD(                     0x380000, 0x80000)
12811281
1282   ROM_REGION( 0x8000, "user1", 0 ) // nvram
1283   ROM_LOAD( "megat4sn.nv",  0x0000, 0x8000, CRC(1ac8de52) SHA1(d4e7e455f581d7c5192209995af1b98d7802e50f) )
1284
12821285   ROM_REGION( 0x1000, "user2", 0 ) // PALs
12831286   ROM_LOAD( "sc3943.u20",     0x000, 0x117, CRC(5a72fe78) SHA1(4b1a36904eb7048518507fe14bdade5c2589dbd7) )
12841287   ROM_LOAD( "sc3944-0a.u19",  0x000, 0x2dd, CRC(4cc46c5e) SHA1(0bab970df1539ce905f43603ad13171b05449a01) )
r3485r3486
14361439GAME( 1996, megat3te,  megat3, meritm_crt260, meritm_crt260, megat3te, ROT0, "Merit", "Megatouch III Tournament Edition (9255-30-01 ROE, Standard version)", GAME_IMPERFECT_GRAPHICS )
14371440GAME( 1996, megat4,    0,      meritm_crt260, meritm_crt260, megat4,   ROT0, "Merit", "Megatouch IV (9255-40-01 ROE, Standard version)", GAME_IMPERFECT_GRAPHICS )
14381441GAME( 1996, megat4a,   megat4, meritm_crt260, meritm_crt260, megat4,   ROT0, "Merit", "Megatouch IV (9255-40-01 ROD, Standard version)", GAME_IMPERFECT_GRAPHICS )
1439GAME( 1996, megat4sn,  megat4, meritm_crt260, meritm_crt260, megat4,   ROT0, "Merit", "Super Megatouch IV (9255-41-07 ROG, New Jersey version)", GAME_IMPERFECT_GRAPHICS|GAME_NOT_WORKING )
1442GAME( 1996, megat4sn,  megat4, meritm_crt260, meritm_crt260, megat4,   ROT0, "Merit", "Super Megatouch IV (9255-41-07 ROG, New Jersey version)", GAME_IMPERFECT_GRAPHICS )
14401443GAME( 1996, megat4te,  megat4, meritm_crt260, meritm_crt260, megat4te, ROT0, "Merit", "Megatouch IV Tournament Edition (9255-50-01 ROD, Standard version)", GAME_IMPERFECT_GRAPHICS )
14411444GAME( 1997, megat5,    0,      meritm_crt260, meritm_crt260, megat5,   ROT0, "Merit", "Megatouch 5 (9255-60-01 ROC, Standard version)", GAME_IMPERFECT_GRAPHICS|GAME_NOT_WORKING )
14421445GAME( 1998, megat5nj,  megat5, meritm_crt260, meritm_crt260, megat5,   ROT0, "Merit", "Megatouch 5 (9255-60-07 RON, New Jersey version)", GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/mirage.c
r3485r3486
11/* Mirage Youjuu Mahjongden
22
3todo: inputs, eeprom?
4      sound (is mbl-03.10a a bad dump?)
3TODO:
4-eeprom emulation?
5-priorities
6-sample banking
7
8Notes:To enter into Test Mode you need to keep pressed the Mahjong A button at start-up.
59*/
610
711/*
r3485r3486
140144   return mame_rand(machine);
141145}
142146
147static UINT32 mux_data;
148
149static WRITE16_HANDLER( mirage_mux_w )
150{
151   mux_data = data & 0xffff;
152}
153
143154static READ16_HANDLER( mirage_input_r )
144155{
145   UINT16 port = input_port_read(machine, "MIRAGE0");
146   return port;
156   switch(mux_data & 0x1f)
157   {
158      case 0x01: return input_port_read(machine, "KEY0");
159      case 0x02: return input_port_read(machine, "KEY1");
160      case 0x04: return input_port_read(machine, "KEY2");
161      case 0x08: return input_port_read(machine, "KEY3");
162      case 0x10: return input_port_read(machine, "KEY4");
163   }
164
165   return 0xffff;
147166}
148167
149168static ADDRESS_MAP_START( mirage_readmem, ADDRESS_SPACE_PROGRAM, 16 )
r3485r3486
185204
186205   AM_RANGE(0x130000, 0x1307ff) AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
187206
188   AM_RANGE(0x150000, 0x150001) AM_WRITE(SMH_NOP)
189   AM_RANGE(0x150002, 0x150003) AM_WRITE(SMH_NOP)
207   AM_RANGE(0x140000, 0x140001) AM_READWRITE(okim6295_status_1_lsb_r, okim6295_data_1_lsb_w)
208   AM_RANGE(0x140002, 0x140003) AM_READWRITE(okim6295_status_1_lsb_r, okim6295_data_1_lsb_w)
190209
210//  AM_RANGE(0x140008, 0x140009) AM_WRITE(okim1_rombank_w)
211
212   AM_RANGE(0x150000, 0x150001) AM_READWRITE(okim6295_status_0_lsb_r, okim6295_data_0_lsb_w)
213   AM_RANGE(0x150002, 0x150003) AM_READWRITE(okim6295_status_0_lsb_r, okim6295_data_0_lsb_w)
214
215//  AM_RANGE(0x150008, 0x150009) AM_WRITE(okim0_rombank_w)
216
191217   AM_RANGE(0x160000, 0x160001) AM_WRITE(SMH_NOP)
192218
193219   AM_RANGE(0x168000, 0x16800f) AM_WRITE(SMH_RAM) AM_BASE(&deco16_pf12_control)
r3485r3486
195221   AM_RANGE(0x16a000, 0x16a001) AM_WRITE(SMH_NOP)
196222
197223   AM_RANGE(0x16c000, 0x16c001) AM_WRITE(SMH_NOP)
198   AM_RANGE(0x16c002, 0x16c003) AM_WRITE(SMH_NOP) // input multiplex?
199   AM_RANGE(0x16c004, 0x16c005) AM_WRITE(SMH_NOP)
224   AM_RANGE(0x16c002, 0x16c003) AM_WRITE(SMH_NOP)
225   AM_RANGE(0x16c004, 0x16c005) AM_WRITE(mirage_mux_w)
200226
201227   AM_RANGE(0x16e000, 0x16e001) AM_WRITE(SMH_NOP)
202228
r3485r3486
207233
208234static INPUT_PORTS_START( mirage )
209235   PORT_START("SYSTEM_IN")
210   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
211   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
212    PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
213    PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
214    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
236   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )
237   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
238   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )
215239   PORT_SERVICE( 0x0008, IP_ACTIVE_LOW )
216240   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_VBLANK )
217241   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Flip_Screen ) )
r3485r3486
248272    PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
249273    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
250274
251   PORT_START("MIRAGE0")
252   PORT_BIT(  0x0001, IP_ACTIVE_LOW, IPT_SERVICE1 ) /* Inputs start here???? */
253    PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
254    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
255    PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
256    PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
257    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
258    PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
259    PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
260    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
261    PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
262    PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
263    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
264    PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
265    PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
266    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
267    PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) ) /* Makes selections in "Test Mode" when changing from "Off" to "On" */
268    PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
269    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
270    PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
271    PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
272    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
273    PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
274    PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
275    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
276    PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
277    PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
278    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
279    PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
280    PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
281    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
282    PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
283    PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
284    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
285    PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
286    PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
287    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
288    PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
289    PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
290    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
291    PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
292    PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
293    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
294    PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
295    PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
296    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
297    PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
298    PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
299    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
275   PORT_START("KEY0")
276    PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_A )
277    PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_E )
278    PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_I )
279    PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_M )
280    PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_MAHJONG_KAN )
281    PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_START1 )
282    PORT_BIT( 0xffc0, IP_ACTIVE_LOW, IPT_UNUSED )
300283
284   PORT_START("KEY1")
285    PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_C )
286    PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_G )
287    PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_K )
288    PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )
289    PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_MAHJONG_RON )
290    PORT_BIT( 0xffe0, IP_ACTIVE_LOW, IPT_UNUSED )
291
292   PORT_START("KEY2")
293   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_FLIP_FLOP )
294    PORT_BIT( 0xfff7, IP_ACTIVE_LOW, IPT_UNUSED )
295
296   PORT_START("KEY3")
297    PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_B )
298    PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_F )
299    PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_J )
300    PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_N )
301   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )
302    PORT_BIT( 0xffe0, IP_ACTIVE_LOW, IPT_UNUSED )
303
304   PORT_START("KEY4")
305    PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_D )
306    PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_H )
307    PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_L )
308    PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_PON )
309    PORT_BIT( 0xfff0, IP_ACTIVE_LOW, IPT_UNUSED )
301310INPUT_PORTS_END
302311
303312
r3485r3486
367376   /* sound hardware */
368377   MDRV_SPEAKER_STANDARD_MONO("mono")
369378
370   MDRV_SOUND_ADD("oki1", OKIM6295, 1000000)
379   MDRV_SOUND_ADD("oki1", OKIM6295, 2500000)
371380   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified
372381   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
373382
r3485r3486
392401   ROM_REGION( 0x200000, "oki1", 0 )   /* M6295 samples */
393402   ROM_LOAD( "mbl-03.10a", 0x000000, 0x200000, CRC(4a599703) SHA1(b49e84faa2d6acca952740d30fc8d1a33ac47e79) )
394403
395   ROM_REGION( 0x200000, "oki2", 0 )   /* M6295 samples */
404   ROM_REGION( 0x100000, "oki2", 0 )   /* M6295 samples */
396405   ROM_LOAD( "mbl-04.12k", 0x000000, 0x100000, CRC(b533123d) SHA1(2cb2f11331d00c2d282113932ed2836805f4fc6e) )
397406ROM_END
398407
408#if 0
399409static void descramble_sound( running_machine *machine, const char *region )
400410{
401411   UINT8 *rom = memory_region(machine, region);
r3485r3486
434444#endif
435445
436446}
447#endif
437448
438
439449static DRIVER_INIT( mirage )
440450{
441451   deco56_decrypt_gfx(machine, "gfx1");
442   descramble_sound(machine, "oki1");
452   //descramble_sound(machine, "oki1");
443453}
444454
445GAME( 1994, mirage, 0,        mirage, mirage, mirage, ROT0, "Mitchell", "Mirage Youjuu Mahjongden (Japan)", GAME_NOT_WORKING )
455GAME( 1994, mirage, 0,        mirage, mirage, mirage, ROT0, "Mitchell", "Mirage Youjuu Mahjongden (Japan)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
src/mame/drivers/midwunit.c
r3485r3486
12311231GAME( 1994, mk3r20,   mk3,       wunit, mk3,      mk3r20,   ROT0, "Midway", "Mortal Kombat 3 (rev 2.0)", GAME_SUPPORTS_SAVE )
12321232GAME( 1994, mk3r10,   mk3,       wunit, mk3,      mk3r10,   ROT0, "Midway", "Mortal Kombat 3 (rev 1.0)", GAME_SUPPORTS_SAVE )
12331233GAME( 1994, mk3p40,   mk3,       wunit, mk3,      mk3r10,   ROT0, "Midway", "Mortal Kombat 3 (rev 1 chip label p4.0)", GAME_SUPPORTS_SAVE )
1234GAME( 1994, umk3,     mk3,       wunit, mk3,      umk3,     ROT0, "Midway", "Ultimate Mortal Kombat 3 (rev 1.2)", GAME_SUPPORTS_SAVE )
1235GAME( 1994, umk3r11,  mk3,       wunit, mk3,      umk3r11,  ROT0, "Midway", "Ultimate Mortal Kombat 3 (rev 1.1)", GAME_SUPPORTS_SAVE )
1236GAME( 1994, umk3r10,  mk3,       wunit, mk3,      umk3r11,  ROT0, "Midway", "Ultimate Mortal Kombat 3 (rev 1.0)", GAME_SUPPORTS_SAVE )
1234GAME( 1994, umk3,     0,         wunit, mk3,      umk3,     ROT0, "Midway", "Ultimate Mortal Kombat 3 (rev 1.2)", GAME_SUPPORTS_SAVE )
1235GAME( 1994, umk3r11,  umk3,      wunit, mk3,      umk3r11,  ROT0, "Midway", "Ultimate Mortal Kombat 3 (rev 1.1)", GAME_SUPPORTS_SAVE )
1236GAME( 1994, umk3r10,  umk3,      wunit, mk3,      umk3r11,  ROT0, "Midway", "Ultimate Mortal Kombat 3 (rev 1.0)", GAME_SUPPORTS_SAVE )
12371237
12381238GAME( 1995, wwfmania, 0,         wunit, wwfmania, wwfmania, ROT0, "Midway", "WWF: Wrestlemania (rev 1.30 08/10/95)", GAME_SUPPORTS_SAVE )
12391239GAME( 1995, wwfmanib, wwfmania,  wunit, wwfmania, wwfmania, ROT0, "Midway", "WWF: Wrestlemania (rev 1.20 08/02/95)", GAME_SUPPORTS_SAVE )
src/mame/drivers/namcos2.c
r3485r3486
887887   NAMCOS2_MCU_DIAL_DEFAULT
888888INPUT_PORTS_END
889889
890static INPUT_PORTS_START( kyukaidk )
891   PORT_INCLUDE( default )
892
893   PORT_MODIFY("DSW")
894   /* Must be 'L' for correct C140 output */
895   PORT_DIPNAME( 0x20, 0x00, "$2000-5" )
896   PORT_DIPSETTING(   0x20, "H" )
897   PORT_DIPSETTING(   0x00, "L" )
898INPUT_PORTS_END
899
890900static INPUT_PORTS_START( gollygho )
891901   PORT_START("MCUB")
892902   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r3485r3486
13141324   NAMCOS2_MCU_DIAL_DEFAULT
13151325INPUT_PORTS_END
13161326
1317static INPUT_PORTS_START( sgunner )
1327static INPUT_PORTS_START( sgunner )
13181328   PORT_START("MCUB")      /* 63B05Z0 - PORT B */
13191329   PORT_BIT( 0x3f, IP_ACTIVE_LOW, IPT_UNUSED )
13201330   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 )
r3485r3486
48824892GAME( 1989, burnfrco, burnforc, default3, default,  burnforc, ROT0,   "Namco", "Burning Force (Japan old version)", 0 )
48834893GAME( 1989, marvland, 0,        default,  default,  marvland, ROT0,   "Namco", "Marvel Land (US)", 0 )
48844894GAME( 1989, marvlanj, marvland, default,  default,  marvlanj, ROT0,   "Namco", "Marvel Land (Japan)", 0 )
4885GAME( 1990, kyukaidk, 0,        default,  default,  kyukaidk, ROT0,   "Namco", "Kyuukai Douchuuki (Japan new version)", 0 )
4886GAME( 1990, kyukaido, kyukaidk, default,  default,  kyukaidk, ROT0,   "Namco", "Kyuukai Douchuuki (Japan old version)", 0 )
4895GAME( 1990, kyukaidk, 0,        default,  kyukaidk, kyukaidk, ROT0,   "Namco", "Kyuukai Douchuuki (Japan new version)", 0 )
4896GAME( 1990, kyukaido, kyukaidk, default,  kyukaidk, kyukaidk, ROT0,   "Namco", "Kyuukai Douchuuki (Japan old version)", 0 )
48874897GAME( 1990, dsaber,   0,        default3, default,  dsaber,   ROT90,  "Namco", "Dragon Saber", 0 )
48884898GAME( 1990, dsaberj,  dsaber,   default3, default,  dsaberj,  ROT90,  "Namco", "Dragon Saber (Japan)", 0 )
48894899GAME( 1990, finalap2, 0,        finallap, finallap, finalap2, ROT0,   "Namco", "Final Lap 2", GAME_NOT_WORKING|GAME_IMPERFECT_GRAPHICS  )
src/mame/drivers/merit.c
r3485r3486
1010  TODO:
1111  - add flipscreen according to schematics
1212  - pitboss: dip switches
13  - casino5: seems to have 0x2000 ram, with 0x2000, will keep resetting.
1314  - general - add named output notifiers
1415
1516Notes: it's important that "user1" is 0xa0000 bytes with empty space filled
r3485r3486
287288   /* other bits unknown */
288289}
289290
291
290292static ADDRESS_MAP_START( pitboss_map, ADDRESS_SPACE_PROGRAM, 8 )
291293   AM_RANGE(0x0000, 0x5fff) AM_ROM
292294   AM_RANGE(0x6000, 0x67ff) AM_RAM
r3485r3486
303305
304306static ADDRESS_MAP_START( bigappg_map, ADDRESS_SPACE_PROGRAM, 8 )
305307   AM_RANGE(0x0000, 0x5fff) AM_ROM
306   AM_RANGE(0xa000, 0xafff) AM_RAM
308   AM_RANGE(0xa000, 0xbfff) AM_RAM
307309   AM_RANGE(0xc004, 0xc007) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)
308310   AM_RANGE(0xc008, 0xc00b) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)
309311   AM_RANGE(0xe000, 0xe000) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
r3485r3486
313315   AM_RANGE(0xf800, 0xfbff) AM_READWRITE(palette_r, palette_w)
314316ADDRESS_MAP_END
315317
318/* Address decoding is done by prom u13 on crt200a hardware. It decodes
319 * the following addr lines: 2,3,9,13,14,15 ==> E20C
320 * ==> mirror 1DF3 & ~effective_addr_lines
321 * */
316322
317323static ADDRESS_MAP_START( trvwhiz_map, ADDRESS_SPACE_PROGRAM, 8 )
318324   AM_RANGE(0x0000, 0x3fff) AM_ROM
r3485r3486
320326   AM_RANGE(0x5400, 0x54ff) AM_WRITE(low_offset_w)
321327   AM_RANGE(0x5800, 0x58ff) AM_WRITE(med_offset_w)
322328   AM_RANGE(0x6000, 0x67ff) AM_RAM
323   AM_RANGE(0xa000, 0xa003) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)
324   AM_RANGE(0xc000, 0xc003) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)
325   AM_RANGE(0xe000, 0xe000) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
326   AM_RANGE(0xe001, 0xe001) AM_DEVWRITE(MC6845, "crtc", mc6845_register_w)
329   AM_RANGE(0xa000, 0xa003) AM_MIRROR(0x1df0) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)
330   AM_RANGE(0xc000, 0xc003) AM_MIRROR(0x1df0) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)
331   AM_RANGE(0xe000, 0xe000) AM_MIRROR(0x05f0) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
332   AM_RANGE(0xe001, 0xe001) AM_MIRROR(0x05f0) AM_DEVWRITE(MC6845, "crtc", mc6845_register_w)
327333   AM_RANGE(0xe800, 0xefff) AM_RAM AM_BASE(&ram_attr)
328334   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_BASE(&ram_video)
329335   AM_RANGE(0xf800, 0xfbff) AM_READWRITE(palette_r, palette_w)
r3485r3486
338344static ADDRESS_MAP_START( phrcraze_map, ADDRESS_SPACE_PROGRAM, 8 )
339345   AM_RANGE(0x0000, 0x7fff) AM_ROM
340346   AM_RANGE(0xa000, 0xbfff) AM_RAM
341   AM_RANGE(0xc008, 0xc00b) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)
342   AM_RANGE(0xc00c, 0xc00f) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)
347   AM_RANGE(0xc008, 0xc00b) AM_MIRROR(0x1df0) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)
348   AM_RANGE(0xc00c, 0xc00f) AM_MIRROR(0x1df0) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)
343349   AM_RANGE(0xce00, 0xceff) AM_READWRITE(questions_r, high_offset_w)
344350   AM_RANGE(0xd600, 0xd6ff) AM_WRITE(low_offset_w)
345351   AM_RANGE(0xda00, 0xdaff) AM_WRITE(med_offset_w)
346   AM_RANGE(0xe000, 0xe000) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
347   AM_RANGE(0xe001, 0xe001) AM_DEVWRITE(MC6845, "crtc", mc6845_register_w)
352   AM_RANGE(0xe000, 0xe000) AM_MIRROR(0x05f0) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
353   AM_RANGE(0xe001, 0xe001) AM_MIRROR(0x05f0) AM_DEVWRITE(MC6845, "crtc", mc6845_register_w)
348354   AM_RANGE(0xe800, 0xefff) AM_RAM AM_BASE(&ram_attr)
349355   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_BASE(&ram_video)
350356   AM_RANGE(0xf800, 0xfbff) AM_READWRITE(palette_r, palette_w)
351357ADDRESS_MAP_END
352358
353359static ADDRESS_MAP_START( phrcraze_io_map, ADDRESS_SPACE_IO, 8 )
354   AM_RANGE(0xc004, 0xc004) AM_WRITE(ay8910_control_port_0_w)
355   AM_RANGE(0xc104, 0xc104) AM_WRITE(ay8910_write_port_0_w)
360   AM_RANGE(0xc004, 0xc004) AM_MIRROR(0x1cf3) AM_WRITE(ay8910_control_port_0_w)
361   AM_RANGE(0xc104, 0xc104) AM_MIRROR(0x1cf3) AM_WRITE(ay8910_write_port_0_w)
356362ADDRESS_MAP_END
357363
358364
359365static ADDRESS_MAP_START( tictac_map, ADDRESS_SPACE_PROGRAM, 8 )
360366   AM_RANGE(0x0000, 0x7fff) AM_ROM
361367   AM_RANGE(0x8000, 0x9fff) AM_RAM
362   AM_RANGE(0xc004, 0xc007) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)
363   AM_RANGE(0xc008, 0xc00b) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)
368   AM_RANGE(0xc004, 0xc007) AM_MIRROR(0x1df0) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)
369   AM_RANGE(0xc008, 0xc00b) AM_MIRROR(0x1df0) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)
364370   AM_RANGE(0xce00, 0xceff) AM_READWRITE(questions_r, high_offset_w)
365371   AM_RANGE(0xd600, 0xd6ff) AM_WRITE(low_offset_w)
366372   AM_RANGE(0xda00, 0xdaff) AM_WRITE(med_offset_w)
367   AM_RANGE(0xe000, 0xe000) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
368   AM_RANGE(0xe001, 0xe001) AM_DEVWRITE(MC6845, "crtc", mc6845_register_w)
373   AM_RANGE(0xe000, 0xe000) AM_MIRROR(0x05f0) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
374   AM_RANGE(0xe001, 0xe001) AM_MIRROR(0x05f0) AM_DEVWRITE(MC6845, "crtc", mc6845_register_w)
369375   AM_RANGE(0xe800, 0xefff) AM_RAM AM_BASE(&ram_attr)
370376   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_BASE(&ram_video)
371377   AM_RANGE(0xf800, 0xfbff) AM_READWRITE(palette_r, palette_w)
372378ADDRESS_MAP_END
373379
374380static ADDRESS_MAP_START( tictac_io_map, ADDRESS_SPACE_IO, 8 )
375   AM_RANGE(0xc00c, 0xc00c) AM_WRITE(ay8910_control_port_0_w)
376   AM_RANGE(0xc10c, 0xc10c) AM_WRITE(ay8910_write_port_0_w)
381   AM_RANGE(0xc00c, 0xc00c) AM_MIRROR(0x1cf3) AM_WRITE(ay8910_control_port_0_w)
382   AM_RANGE(0xc10c, 0xc10c) AM_MIRROR(0x1cf3) AM_WRITE(ay8910_write_port_0_w)
377383ADDRESS_MAP_END
378384
379385
380386static ADDRESS_MAP_START( trvwhziv_map, ADDRESS_SPACE_PROGRAM, 8 )
381387   AM_RANGE(0x0000, 0x7fff) AM_ROM
382388   AM_RANGE(0xa000, 0xbfff) AM_RAM
383   AM_RANGE(0xc004, 0xc007) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)
384   AM_RANGE(0xc008, 0xc00b) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)
389   AM_RANGE(0xc004, 0xc007) AM_MIRROR(0x1df0) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w)
390   AM_RANGE(0xc008, 0xc00b) AM_MIRROR(0x1df0) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w)
385391   AM_RANGE(0xce00, 0xceff) AM_READWRITE(questions_r, high_offset_w)
386392   AM_RANGE(0xd600, 0xd6ff) AM_WRITE(low_offset_w)
387393   AM_RANGE(0xda00, 0xdaff) AM_WRITE(med_offset_w)
388   AM_RANGE(0xe000, 0xe000) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
389   AM_RANGE(0xe001, 0xe001) AM_DEVWRITE(MC6845, "crtc", mc6845_register_w)
394   AM_RANGE(0xe000, 0xe000) AM_MIRROR(0x05f0) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
395   AM_RANGE(0xe001, 0xe001) AM_MIRROR(0x05f0) AM_DEVWRITE(MC6845, "crtc", mc6845_register_w)
390396   AM_RANGE(0xe800, 0xefff) AM_RAM AM_BASE(&ram_attr)
391397   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_BASE(&ram_video)
392398   AM_RANGE(0xf800, 0xfbff) AM_READWRITE(palette_r, palette_w)
src/mame/drivers/m72.c
r3485r3486
8989#include "iremipt.h"
9090#include "m72.h"
9191#include "cpu/nec/nec.h"
92#include "cpu/i8051/i8051.h"
9293
9394
9495#define MASTER_CLOCK      XTAL_32MHz
r3485r3486
9899static UINT16 *protection_ram;
99100static emu_timer *scanline_timer;
100101static UINT8 m72_irq_base;
102static UINT8 mcu_snd_cmd_latch;
103static UINT8 mcu_sample_latch;
104static UINT32 mcu_sample_addr;
101105
102106static TIMER_CALLBACK( m72_scanline_interrupt );
103107
r3485r3486
108112   scanline_timer = timer_alloc(m72_scanline_interrupt, NULL);
109113}
110114
115static TIMER_CALLBACK( synch_callback )
116{
117   //cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(8000000));
118   cpu_boost_interleave(ATTOTIME_IN_HZ(MASTER_CLOCK/4/12), ATTOTIME_IN_SEC(8));
119}
120
111121static MACHINE_RESET( m72 )
112122{
113123   m72_irq_base = 0x20;
124   mcu_sample_addr = 0;
125   mcu_snd_cmd_latch = 0;
126
114127   MACHINE_RESET_CALL(m72_sound);
128
129   state_save_register_global(mcu_sample_addr);
130   state_save_register_global(mcu_snd_cmd_latch);
131
115132   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
133   timer_call_after_resynch( NULL, 0, synch_callback);
116134}
117135
118136static MACHINE_RESET( xmultipl )
r3485r3486
153171   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline);
154172}
155173
174/***************************************************************************
156175
176Protection emulation
157177
178Currently only available for lohtb2, since this is the only game
179with a dumped 8751.
180
181The protection device does
182
183* provide startup code
184* provide checksums
185* feed samples to the sound cpu
186
187***************************************************************************/
188
189static TIMER_CALLBACK( delayed_ram16_w )
190{
191   UINT16 val = ((UINT32) param) & 0xffff;
192   UINT16 offset = (((UINT32) param) >> 16) & 0xffff;
193   UINT16 *ram = ptr;
194
195   ram[offset] = val;
196}
197
198static TIMER_CALLBACK( mcu_irq0_clear )
199{
200   cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
201}
202
203
204static WRITE16_HANDLER( m72_main_mcu_sound_w )
205{
206   if (data & 0xfff0)
207      logerror("sound_w: %04x %04x\n", mem_mask, data);
208
209   if (ACCESSING_BITS_0_7)
210   {
211      mcu_snd_cmd_latch = data;
212      cputag_set_input_line(machine, "mcu", 1, ASSERT_LINE);
213   }
214}
215
216static WRITE16_HANDLER( m72_main_mcu_w)
217{
218   UINT16 val = protection_ram[offset];
219
220   COMBINE_DATA(&val);
221
222   /* 0x07fe is used for synchronization as well.
223     * This address however will not trigger an interrupt
224     */
225
226   if (offset == 0x0fff/2 && ACCESSING_BITS_8_15)
227   {
228      protection_ram[offset] = val;
229      cputag_set_input_line(machine, "mcu", 0, ASSERT_LINE);
230      /* Line driven, most likely by write line */
231      timer_set(ATTOTIME_IN_CYCLES(2, mame_find_cpu_index(machine, "mcu")), NULL, 0, mcu_irq0_clear);
232   }
233   else
234      timer_call_after_resynch( protection_ram, (offset<<16) | val, delayed_ram16_w);
235}
236
237static WRITE8_HANDLER( m72_mcu_data_w )
238{
239   UINT16 val;
240   if (offset&1) val = (protection_ram[offset/2] & 0x00ff) | (data << 8);
241   else val = (protection_ram[offset/2] & 0xff00) | (data&0xff);
242
243   timer_call_after_resynch( protection_ram, ((offset >>1 ) << 16) | val, delayed_ram16_w);
244}
245
246static READ8_HANDLER(m72_mcu_data_r )
247{
248   UINT8 ret;
249
250   if (offset&1) ret = (protection_ram[offset/2] & 0xff00)>>8;
251   else ret = (protection_ram[offset/2] & 0x00ff);
252
253   return ret;
254}
255
256static INTERRUPT_GEN( m72_mcu_int )
257{
258   //mcu_snd_cmd_latch |= 0x11; /* 0x10 is special as well - FIXME */
259   mcu_snd_cmd_latch = 0x10 | (mame_rand(machine) & 1); /* 0x10 is special as well - FIXME */
260   cputag_set_input_line(machine, "mcu", 1, ASSERT_LINE);
261}
262
263static READ8_HANDLER(m72_mcu_sample_r )
264{
265   UINT8 sample;
266   sample = memory_region(machine, "samples")[mcu_sample_addr++];
267   return sample;
268}
269
270static WRITE8_HANDLER(m72_mcu_ack_w )
271{
272   cputag_set_input_line(machine, "mcu", 1, CLEAR_LINE);
273   mcu_snd_cmd_latch = 0;
274}
275
276static READ8_HANDLER(m72_mcu_snd_r )
277{
278   return mcu_snd_cmd_latch;
279}
280
281static READ8_HANDLER(m72_mcu_port_r )
282{
283   logerror("port read: %02x\n", offset);
284   return 0;
285}
286
287static WRITE8_HANDLER(m72_mcu_port_w )
288{
289   if (offset == 1)
290   {
291      mcu_sample_latch = data;
292      cputag_set_input_line(machine, "sound", INPUT_LINE_NMI, PULSE_LINE);
293   }
294   else
295      logerror("port: %02x %02x\n", offset, data);
296
297}
298
299static WRITE8_HANDLER( m72_mcu_low_w )
300{
301   mcu_sample_addr = (mcu_sample_addr & 0xffe000) | (data<<5);
302   logerror("low: %02x %02x %08x\n", offset, data, mcu_sample_addr);
303}
304
305static WRITE8_HANDLER( m72_mcu_high_w )
306{
307   mcu_sample_addr = (mcu_sample_addr & 0x1fff) | (data<<(8+5));
308   logerror("high: %02x %02x %08x\n", offset, data, mcu_sample_addr);
309}
310
311static WRITE8_HANDLER( m72_snd_cpu_sample_w )
312{
313   //dac_signed_data_w(0,data);
314   dac_data_w(0,data);
315}
316
317static READ8_HANDLER( m72_snd_cpu_sample_r )
318{
319   return mcu_sample_latch;
320}
321
322INLINE DRIVER_INIT( loht_mcu )
323{
324   int cpunum = mame_find_cpu_index(machine, "main");
325   int sndnum = mame_find_cpu_index(machine, "sound");
326
327   protection_ram = auto_malloc(0x10000);
328   memory_install_read16_handler(machine, cpunum, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xbffff, 0, 0, SMH_BANK1);
329   memory_install_write16_handler(machine, cpunum, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xb0fff, 0, 0, m72_main_mcu_w);
330   memory_set_bankptr(1, protection_ram);
331
332   //memory_install_write16_handler(machine, cpunum, ADDRESS_SPACE_IO, 0xc0, 0xc1, 0, 0, loht_sample_trigger_w);
333   memory_install_write16_handler(machine, cpunum, ADDRESS_SPACE_IO, 0xc0, 0xc1, 0, 0, m72_main_mcu_sound_w);
334
335   /* sound cpu */
336   memory_install_write8_handler(machine, sndnum, ADDRESS_SPACE_IO, 0x82, 0x82, 0xff, 0, m72_snd_cpu_sample_w);
337   memory_install_read8_handler (machine, sndnum, ADDRESS_SPACE_IO, 0x84, 0x84, 0xff, 0, m72_snd_cpu_sample_r);
338}
339
340
158341/***************************************************************************
159342
160343Sample playback
r3485r3486
541724   /* since we skip the startup tests, clear video RAM to prevent garbage on title screen */
542725   memset(m72_videoram2,0,0x4000);
543726}
544#if 0
545int stepping = 0;
546727
547static TIMER_CALLBACK( single_step )
548{
549   if (param>0)
550      timer_set( ATTOTIME_IN_NSEC(20), NULL, param-1, single_step);
551   else
552      stepping = 0;
553}
554static TIMER_CALLBACK( delayed_ram16_w )
555{
556   UINT16 val = ((UINT32) param) & 0xffff;
557   UINT16 offset = (((UINT32) param) >> 16) & 0xffff;
558   UINT16 *ram = ptr;
559
560   ram[offset] = val;
561
562   if (!stepping)
563   {
564      stepping = 1;
565      timer_call_after_resynch( NULL, 50, single_step);
566   }
567}
568#else
569static TIMER_CALLBACK( delayed_ram16_w )
570{
571   UINT16 val = ((UINT32) param) & 0xffff;
572   UINT16 offset = (((UINT32) param) >> 16) & 0xffff;
573   UINT16 *ram = ptr;
574
575   ram[offset] = val;
576}
577
578#endif
579
580static WRITE16_HANDLER( m72_main_mcu_w)
581{
582   UINT16 val = protection_ram[offset];
583
584   COMBINE_DATA(&val);
585
586   if (offset == 0x0fff/2 && ACCESSING_BITS_8_15)
587   {
588      protection_ram[offset] = val;
589      cputag_set_input_line(machine, "mcu", 0, PULSE_LINE);
590   }
591   else
592      timer_call_after_resynch( protection_ram, (offset<<16) | val, delayed_ram16_w);
593}
594
595static DRIVER_INIT( loht_mcu )
596{
597   int cpunum =  mame_find_cpu_index(machine, "main");
598
599   protection_ram = auto_malloc(0x1000);
600   memset(protection_ram, 0xff, 0x1000);
601   memory_install_read16_handler(machine, cpunum, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xb0fff, 0, 0, SMH_BANK1);
602   memory_install_write16_handler(machine, cpunum, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xb0fff, 0, 0, m72_main_mcu_w);
603   memory_set_bankptr(1, protection_ram);
604
605   memory_install_write16_handler(machine, cpunum, ADDRESS_SPACE_IO, 0xc0, 0xc1, 0, 0, loht_sample_trigger_w);
606
607}
608
609728static DRIVER_INIT( xmultipl )
610729{
611730   install_protection_handler(machine, xmultipl_code,xmultipl_crc);
r3485r3486
800919   AM_RANGE(0x02, 0x03) AM_WRITE(m72_port02_w)   /* coin counters, reset sound cpu, other stuff? */
801920   AM_RANGE(0x04, 0x05) AM_WRITE(m72_dmaon_w)
802921   AM_RANGE(0x06, 0x07) AM_WRITE(m72_irq_line_w)
803   AM_RANGE(0x40, 0x43) AM_WRITE(SMH_NOP) /* Interrupt controller, only written to at bootup */
922   //AM_RANGE(0x40, 0x43) AM_WRITE(SMH_NOP) /* Interrupt controller, only written to at bootup */
804923   AM_RANGE(0x80, 0x81) AM_WRITE(m72_scrolly1_w)
805924   AM_RANGE(0x82, 0x83) AM_WRITE(m72_scrollx1_w)
806925   AM_RANGE(0x84, 0x85) AM_WRITE(m72_scrolly2_w)
r3485r3486
9161035   AM_RANGE(0x42, 0x42) AM_WRITE(m72_sound_irq_ack_w)
9171036ADDRESS_MAP_END
9181037
1038#if 0
1039/* TODO: internal - should be removed */
1040static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
1041   //ADDRESS_MAP_UNMAP_HIGH
1042   AM_RANGE(0x0000, 0x0fff) AM_ROM
1043ADDRESS_MAP_END
1044#endif
9191045
1046#if 0
1047static ADDRESS_MAP_START( mcu_data_map, ADDRESS_SPACE_DATA, 8 )
1048   //ADDRESS_MAP_UNMAP_HIGH
1049   AM_RANGE(0x0000, 0x0000) AM_READWRITE(m72_mcu_sample_r, m72_mcu_low_w)
1050   AM_RANGE(0x0001, 0x0001) AM_WRITE(m72_mcu_high_w)
1051   AM_RANGE(0x0002, 0x0002) AM_READWRITE(m72_mcu_snd_r, m72_mcu_ack_w)
1052   /* shared at b0000 - b0fff on the main cpu */
1053   AM_RANGE(0xc000, 0xcfff) AM_RAM AM_READWRITE(m72_mcu_data_r,m72_mcu_data_w )
1054ADDRESS_MAP_END
1055
1056static ADDRESS_MAP_START( mcu_io_map, ADDRESS_SPACE_IO, 8 )
1057   //ADDRESS_MAP_UNMAP_HIGH
1058   AM_RANGE(0x0000, 0x0003) AM_READWRITE(m72_mcu_port_r, m72_mcu_port_w)
1059ADDRESS_MAP_END
1060#else
1061static ADDRESS_MAP_START( mcu_io_map, ADDRESS_SPACE_IO, 8 )
1062   /* External access */
1063   AM_RANGE(0x0000, 0x0000) AM_READWRITE(m72_mcu_sample_r, m72_mcu_low_w)
1064   AM_RANGE(0x0001, 0x0001) AM_WRITE(m72_mcu_high_w)
1065   AM_RANGE(0x0002, 0x0002) AM_READWRITE(m72_mcu_snd_r, m72_mcu_ack_w)
1066   /* shared at b0000 - b0fff on the main cpu */
1067   AM_RANGE(0xc000, 0xcfff) AM_RAM AM_READWRITE(m72_mcu_data_r,m72_mcu_data_w )
1068
1069   /* Ports */
1070   AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P3) AM_READWRITE(m72_mcu_port_r, m72_mcu_port_w)
1071ADDRESS_MAP_END
1072
1073#endif
1074
9201075#define COIN_MODE_1 \
9211076   PORT_DIPNAME( 0x00f0, 0x00f0, DEF_STR( Coinage ) ) PORT_CONDITION("DSW", 0x0400, PORTCOND_NOTEQUALS, 0x0000) PORT_DIPLOCATION("SW1:5,6,7,8") \
9221077   PORT_DIPSETTING(      0x00a0, DEF_STR( 6C_1C ) ) \
r3485r3486
16611816   MDRV_SOUND_ROUTE(1, "right", 1.0)
16621817MACHINE_DRIVER_END
16631818
1819static MACHINE_DRIVER_START( m72_base )
16641820
1665static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
1666   ADDRESS_MAP_UNMAP_HIGH
1667   AM_RANGE(0x0000, 0x0fff) AM_ROM
1668ADDRESS_MAP_END
1669
1670static WRITE8_HANDLER( m72_mcu_data_w )
1671{
1672   UINT16 val;
1673   if (offset&1) val = (protection_ram[offset/2] & 0x00ff) | (data << 8);
1674   else val = (protection_ram[offset/2] & 0xff00) | (data&0xff);
1675
1676   if (offset == 6 && data == 0xfe)
1677      /* Hack - The v30 overshoots and will not see the unlock written to offset 6
1678         * We thus delay the lock, i.e. storing an unconditional branch to 6
1679         * here. This is highly time critical ... */
1680      timer_set(ATTOTIME_IN_USEC(10), protection_ram, ((offset >>1 ) << 16) | val, delayed_ram16_w);
1681   else
1682      timer_call_after_resynch( protection_ram, ((offset >>1 ) << 16) | val, delayed_ram16_w);
1683}
1684
1685static READ8_HANDLER(m72_mcu_data_r )
1686{
1687   UINT8 ret;
1688
1689   if (offset&1) ret = (protection_ram[offset/2] & 0xff00)>>8;
1690   else ret = (protection_ram[offset/2] & 0x00ff);
1691
1692   return ret;
1693}
1694
1695static ADDRESS_MAP_START( mcu_data_map, ADDRESS_SPACE_DATA, 8 )
1696   ADDRESS_MAP_UNMAP_HIGH
1697   /* shared at b0000 - b0fff on the main cpu */
1698   AM_RANGE(0xc000, 0xcfff) AM_READWRITE(m72_mcu_data_r,m72_mcu_data_w )
1699ADDRESS_MAP_END
1700
1701
1702static MACHINE_DRIVER_START( m72 )
1703
17041821   /* basic machine hardware */
17051822   MDRV_CPU_ADD("main",V30,MASTER_CLOCK/2/2)   /* 16 MHz external freq (8MHz internal) */
17061823   MDRV_CPU_PROGRAM_MAP(m72_map,0)
r3485r3486
17091826   MDRV_CPU_ADD("sound",Z80, SOUND_CLOCK)
17101827   MDRV_CPU_PROGRAM_MAP(sound_ram_map,0)
17111828   MDRV_CPU_IO_MAP(sound_portmap,0)
1712   MDRV_CPU_VBLANK_INT_HACK(fake_nmi,128)   /* clocked by V1? (Vigilante) */
1713                        /* IRQs are generated by main Z80 and YM2151 */
17141829
17151830   MDRV_MACHINE_START(m72)
17161831   MDRV_MACHINE_RESET(m72)
r3485r3486
17391854   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.40)
17401855MACHINE_DRIVER_END
17411856
1857static MACHINE_DRIVER_START( m72 )
1858
1859   MDRV_IMPORT_FROM(m72_base)
1860   MDRV_CPU_MODIFY("main")
1861   MDRV_CPU_VBLANK_INT_HACK(fake_nmi,128)   /* clocked by V1? (Vigilante) */
1862                     /* IRQs are generated by main Z80 and YM2151 */
1863MACHINE_DRIVER_END
1864
1865
17421866static MACHINE_DRIVER_START( m72_8751 )
17431867
1744   MDRV_IMPORT_FROM(m72)
1868   MDRV_IMPORT_FROM(m72_base)
17451869
1746   MDRV_CPU_ADD("mcu",I8751, 16000000)
1747   MDRV_CPU_PROGRAM_MAP(mcu_map,0)
1748   MDRV_CPU_DATA_MAP(mcu_data_map,0)
1749   //MDRV_CPU_VBLANK_INT("main", irq0_line_pulse)
1750   MDRV_INTERLEAVE(1000)
1870   MDRV_CPU_ADD("mcu",I8751, MASTER_CLOCK/2)
1871   /* internal - MDRV_CPU_PROGRAM_MAP(mcu_map,0) */
1872   //MDRV_CPU_DATA_MAP(mcu_data_map,0)
1873   MDRV_CPU_IO_MAP(mcu_io_map,0)
1874   MDRV_CPU_VBLANK_INT("main", m72_mcu_int)
1875   //MDRV_INTERLEAVE(1000)
17511876
17521877MACHINE_DRIVER_END
17531878
r3485r3486
21582283MACHINE_DRIVER_END
21592284
21602285static const nec_config kengo_config ={ gunforce_decryption_table, };
2286
21612287static MACHINE_DRIVER_START( kengo )
21622288   MDRV_IMPORT_FROM( cosmccop )
21632289   MDRV_CPU_MODIFY("main")
src/mame/drivers/legionna.c
r3485r3486
18421842   ROM_LOAD( "copx-d1.bin",  0x000000, 0x080000, CRC(029bc402) SHA1(0f64e4c32d95abfa3920b39ed3cf0cc6eb50191b) )
18431843ROM_END
18441844
1845ROM_START( cupsoca )
1846   ROM_REGION( 0x100000, "main", 0 )   /* 68000 code */
1847   ROM_LOAD32_BYTE( "1.bin",   0x000000, 0x040000, CRC(d5f76bd6) SHA1(5e7c3843f6f497a24b8236a9307d347fb24dd0d5) )
1848   ROM_LOAD32_BYTE( "2.bin",   0x000001, 0x040000, CRC(34966aa1) SHA1(f07bca19bd92a60c04aa9b23e5d2d2eac073d2e4) )
1849   ROM_LOAD32_BYTE( "3.bin",   0x000002, 0x040000, CRC(2b7934ec) SHA1(b78e7079e03b23853397a3848c93f60702ac1c33) )
1850   ROM_LOAD32_BYTE( "4.bin",   0x000003, 0x040000, CRC(f4aa1d90) SHA1(eb94efc8cc623434b4c9a22e63d262e80ca84d83) )
1851
1852   ROM_REGION( 0x20000, "audio", 0 )   /* Z80 code, banked data */
1853   ROM_LOAD( "seibu7.8a",    0x000000, 0x08000, CRC(f63329f9) SHA1(51736de48efc14415cfdf169b43623d4c95fde2b) )
1854   ROM_CONTINUE(           0x010000, 0x08000 )   /* banked stuff */
1855   ROM_COPY( "audio", 0, 0x018000, 0x08000 )
1856
1857   ROM_REGION( 0x020000, "gfx1", ROMREGION_DISPOSE )
1858   ROM_LOAD16_BYTE( "6.bin",   0x000000, 0x010000, CRC(a9e15910) SHA1(305541b16a87d0e38871240fa2e111bb9332e93c) )
1859   ROM_LOAD16_BYTE( "5.bin",   0x000001, 0x010000, CRC(73a3e024) SHA1(aeb359dd2dc9eb96330f494c44123bab3f5986a4) )
1860
1861   ROM_REGION( 0x200000, "gfx2", ROMREGION_DISPOSE )
1862   ROM_LOAD( "obj.8c",       0x000000, 0x100000, CRC(e2377895) SHA1(1d1c7f31a08a464139cdaf383a5e1ade0717dc9f) )
1863
1864   ROM_REGION( 0x100000, "gfx3", ROMREGION_DISPOSE )   /* MBK tiles */
1865   ROM_LOAD( "back-1.4y",    0x000000, 0x100000, CRC(3dfea0ec) SHA1(8f41d267e488e07831946ef898d593897f10bfe2) )
1866
1867   ROM_REGION( 0x020000, "gfx4", ROMREGION_DISPOSE )   /* not used */
1868
1869   ROM_REGION( 0x080000, "gfx5", ROMREGION_DISPOSE )   /* BK3 tiles */
1870   ROM_LOAD( "back-2.6y",    0x000000, 0x080000, CRC(e07712af) SHA1(2a0285d6a1e0141838e898252b8d922a6263b05f) )
1871
1872   ROM_REGION( 0x080000, "gfx6", ROMREGION_DISPOSE )   /* LBK tiles */
1873   ROM_COPY( "gfx5", 0x00000, 0x00000, 0x080000 )
1874
1875   ROM_REGION( 0x040000, "oki", 0 )   /* ADPCM samples */
1876   ROM_LOAD( "seibu8.7a",    0x000000, 0x040000, CRC(6f594808) SHA1(218aa12068aa587c7656355f6a6b86d97c868774) )
1877
1878   ROM_REGION( 0x080000, "user1", 0 )
1879   ROM_LOAD( "copx-d1.bin",  0x000000, 0x080000, CRC(029bc402) SHA1(0f64e4c32d95abfa3920b39ed3cf0cc6eb50191b) )
1880ROM_END
1881
18451882ROM_START( cupsocs )
18461883   ROM_REGION( 0x100000, "main", 0 )   /* 68000 code */
18471884   ROM_LOAD32_BYTE( "1_10n.bin",   0x000000, 0x040000, CRC(b67835c5) SHA1(4fa562630d1f9cfb6f5bfff3295ebbdd227e4da5) )
r3485r3486
20692106GAME( 1993, sdgndmrb, 0,        sdgndmrb, sdgndmrb, 0,         ROT0, "Banpresto", "SD Gundam Sangokushi Rainbow Tairiku Senki", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
20702107GAME( 1993, denjinmk, 0,        denjinmk, denjinmk, denjinmk, ROT0, "Banpresto", "Denjin Makai", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
20712108
2072GAME( 1992, cupsoc,   0,        cupsoc,   cupsoc,   0,        ROT0, "Seibu", "Seibu Cup Soccer", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2109GAME( 1992, cupsoc,   0,        cupsoc,   cupsoc,   0,        ROT0, "Seibu", "Seibu Cup Soccer (set 1)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2110GAME( 1992, cupsoca,  cupsoc,   cupsoc,   cupsoc,   0,        ROT0, "Seibu", "Seibu Cup Soccer (set 2)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
20732111GAME( 1992, cupsocs,  cupsoc,   cupsoc,   cupsoc,   0,        ROT0, "Seibu", "Seibu Cup Soccer :Selection: (set 1)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
20742112GAME( 1992, cupsocs2, cupsoc,   cupsoc,   cupsoc,   0,        ROT0, "Seibu", "Seibu Cup Soccer :Selection: (set 2)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
20752113GAME( 1992, cupsocsb, cupsoc,   cupsocbl, cupsoc,   cupsoc,   ROT0, "bootleg", "Seibu Cup Soccer :Selection: (bootleg)", GAME_NOT_WORKING | GAME_NO_SOUND )
src/mame/drivers/micro3d.c
r3485r3486
108108/* Probably wrong and a bit crap */
109109static int data_to_i8031(void)
110110{
111     mame_printf_debug("68k sent data: %x\n",M68681.TBB);
112     return M68681.TBB;
111   mame_printf_debug("68k sent data: %x\n",M68681.TBB);
112    M68681.SRB |=0x0400;                   // Data has been sent - TX ready for more.
113    // Write to sound board
114    if(M68681.IMR & 0x1000)
115    {
116       cpunum_set_input_line_and_vector(Machine, 0,3, HOLD_LINE, M68681.IVR);         // Generate an interrupt, if allowed.
117    }
118   return M68681.TBB;
113119}
114120
115121static void data_from_i8031(int data)
116122{
117     M68681.RBB  = data<<8;                         // Put into receive buffer.
118     M68681.SRB |= 0x0100;                          // Set Receiver B ready.
119     if(M68681.IMR & 0x1000)
120     {
121        cpunum_set_input_line_and_vector(Machine, 0,3, HOLD_LINE, M68681.IVR);    // Generate a receiver interrupt.
122        mame_printf_debug("INTERRUPT!!!\n");
123     }
124   mame_printf_debug("8031 sent data: %x\n",data);
123   M68681.RBB  = data<<8;                         // Put into receive buffer.
124   M68681.SRB |= 0x0100;                          // Set Receiver B ready.
125   if(M68681.IMR & 0x1000)
126   {
127      cpunum_set_input_line_and_vector(Machine, 0,3, HOLD_LINE, M68681.IVR);    // Generate a receiver interrupt.
128      mame_printf_debug("INTERRUPT!!!\n");
129   }
130   mame_printf_debug("8031 sent data: %x\n",data);
125131}
126132
127133
r3485r3486
205211
206212static DRIVER_INIT( f15se21 )
207213{
214#if 1
208215       UINT16 *rom = (UINT16 *)memory_region(machine, "main");
209
210216       rom[0x2A8B3]=0x6006;                          //055166: 6606                     bne     5516e -> bra
211217       rom[0x2A8BF]=0x4E71;                          //05517E: 6704                     beq     55184 -> nop
212218       rom[0x28AD1]=0x4E71;                          //0515A2: 67F8                     beq     5159c -> nop
213219       rom[0x28A9E]=0x4E71;
214220       rom[0x28ABD]=0x4E71;
215221       rom[0x28C3B]=0x4E71;
222#endif
216223}
217224
218225static INPUT_PORTS_START( stankatk )
r3485r3486
492499
493500}
494501
495
496
497502/* I should really re-write all this. */
498503
499504static WRITE16_HANDLER( m68681_w )
r3485r3486
537542      case 0x0a:        break;
538543
539544      case 0x0b:        M68681.TBB = value;                   //  Fill transmit buffer
545#if 0
540546                        M68681.SRB |=0x0400;                   // Data has been sent - TX ready for more.
541547                        // Write to sound board
542548                        if(M68681.IMR & 0x1000)
r3485r3486
545551                        }
546552                        cpunum_set_input_line(machine, 2, I8051_RX_LINE, ASSERT_LINE);                      // Generate 8031 interrupt
547553                        mame_printf_debug("Sound board TX: %4X at PC=%4X\n",value,activecpu_get_pc());
554#endif
555                        M68681.SRB &=~0x0400;                   // Data has been sent - TX ready for more.
556                        cpunum_set_input_line(machine, 2, I8051_RX_LINE, ASSERT_LINE);                      // Generate 8031 interrupt
557                        mame_printf_debug("Sound board TX: %4X at PC=%4X\n",value,activecpu_get_pc());
548558                        break;
549559
550560      case 0x0c:        //mame_printf_debug("IVR: %d",value);
r3485r3486
588598        case 0x09:     return M68681.SRB;                              // Status Register B
589599
590600        case 0x0b:     mame_printf_debug("\nHost received: %x\n",M68681.RBB);
591                       M68681.SRB^=0x0100;                             // No longer have data.
601                    M68681.SRB^=0x0100;                             // No longer have data.
602                    //M68681.SRB &= ~0x0100;                             // No longer have data.
592603                       return M68681.RBB;
593604                                                                       // RX B - Monitor Port
594605}
r3485r3486
786797/* P1.7 = SELFTEST I         P3.7                                     */
787798/*====================================================================*/
788799
800static UINT8 port_latch[4];
789801static WRITE8_HANDLER(sound_io_w)
790802{
791
792switch(offset)
793{
794        case 0x01:  break;
795        case 0x03:  //if(data & 0x4) speech_bank=0;
796
797                    if(data & 0x10)
798                    {
799                       upd7759_0_reset_w(machine,0,0);
800                    }
801                    else
802                    {
803                       upd7759_0_reset_w(machine,0,1);
804                    }
805                    break;
803   port_latch[offset] = data;
804   switch(offset)
805   {
806        case 0x01:
807           break;
808        case 0x03:
809           upd7759_set_bank_base(0, (data & 0x4) ? 0x20000 : 0);
810           upd7759_0_reset_w(machine,0,(data & 0x10) ? 0 : 1);
811   }
806812}
807}
808813
809814static READ8_HANDLER(sound_io_r)
810815{
816   switch(offset)
817   {
818           case 0x01:  return (port_latch[offset] & 0x7f) | input_port_read_safe(machine, "SOUND", 0);      /* Test push switch */
819           case 0x03:  return (port_latch[offset] & 0xf7) | (upd7759_0_busy_r(machine,0) ? 0x08 : 0);
820           default:    return 0;
821   }
811822
812switch(offset)
813{
814        case 0x01:  return input_port_read_safe(machine, "SOUND", 0);      /* Test push switch */
815        case 0x03:  return (int)(upd7759_0_busy_r(machine,0))<<3;
816        default:    return 0;
817823}
818824
825static WRITE8_HANDLER( upd7759_port_start_w)
826{
827   upd7759_0_start_w(machine, offset, 0);
828   upd7759_0_port_w(machine, offset, data);
829   upd7759_0_start_w(machine, offset, 1);
819830}
820831
821832static ADDRESS_MAP_START( soundmem_prg, ADDRESS_SPACE_PROGRAM, 8 )
r3485r3486
825836
826837/* FFXX - 00XX    */
827838
828static ADDRESS_MAP_START( soundmem_data, ADDRESS_SPACE_DATA, 8 )
839static ADDRESS_MAP_START( soundmem_io, ADDRESS_SPACE_IO, 8 )
829840   AM_RANGE(0x0000, 0x07ff) AM_RAM                                  /* 2Kb RAM */
830841   AM_RANGE(0xfd00, 0xfd00) AM_WRITE(ym2151_register_port_0_w)
831842   AM_RANGE(0xfd01, 0xfd01) AM_READWRITE(ym2151_status_port_0_r,ym2151_data_port_0_w)
832   AM_RANGE(0xfe00, 0xfe00) AM_WRITE(upd7759_0_port_w)
843   AM_RANGE(0xfe00, 0xfe00) AM_WRITE(upd7759_port_start_w)
833844   AM_RANGE(0xff00, 0xff00) AM_WRITE(dac_0_data_w)   /* DAC A - used for S&H, special effects? */
834845   AM_RANGE(0xff01, 0xff01) AM_WRITE(dac_1_data_w)   /* DAC B - 'SPEECH' */
846   /* ports */
847   AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P3) AM_READWRITE(sound_io_r,sound_io_w)
835848ADDRESS_MAP_END
836849
837static ADDRESS_MAP_START( soundmem_io, ADDRESS_SPACE_IO, 8 )
838         AM_RANGE(0x00, 0xff) AM_READWRITE(sound_io_r,sound_io_w)
839ADDRESS_MAP_END
840850
841
842
843851static const tms34010_config vgb_config =
844852{
845853   FALSE,                     /* halt on reset ????? - check this */
r3485r3486
864872
865873   MDRV_CPU_ADD("audio", I8051, 11059000)
866874   MDRV_CPU_PROGRAM_MAP(soundmem_prg,0)
867   MDRV_CPU_DATA_MAP(soundmem_data,0)
868875   MDRV_CPU_IO_MAP(soundmem_io,0)
869876
870877   MDRV_MACHINE_RESET(micro3d)
src/mame/drivers/superqix.c
r3485r3486
109109#include "driver.h"
110110#include "deprecat.h"
111111#include "cpu/m6805/m6805.h"
112#include "cpu/i8051/i8051.h"
112113#include "sound/ay8910.h"
113114#include "sound/samples.h"
114115
r3485r3486
603604
604605
605606/* I8751 memory handlers */
606static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
607   AM_RANGE(0x0000, 0x0fff) AM_RAM   AM_REGION("mcu", 0) // AM_ROM
608ADDRESS_MAP_END
609607
610608static ADDRESS_MAP_START( mcu_io_map, ADDRESS_SPACE_IO, 8 )
611   AM_RANGE(0x01, 0x01) AM_WRITE(mcu_p1_w)
612   AM_RANGE(0x03, 0x03) AM_READWRITE(mcu_p3_r, mcu_p3_w)
609   AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_WRITE(mcu_p1_w)
610   AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_READWRITE(mcu_p3_r, mcu_p3_w)
613611ADDRESS_MAP_END
614612
615613
r3485r3486
10591057   MDRV_CPU_VBLANK_INT_HACK(sqix_interrupt,6)   /* ??? */
10601058
10611059   MDRV_CPU_ADD("mcu", I8751, 12000000/3)   /* ??? */
1062   MDRV_CPU_PROGRAM_MAP(mcu_map,0)
10631060   MDRV_CPU_IO_MAP(mcu_io_map,0)
10641061
10651062   MDRV_INTERLEAVE(500)
src/mame/drivers/psikyosh.c
r3485r3486
379379               memcpy(eeprom_data+0xf0, mjgtaste_eeprom, 0x10);
380380            }
381381
382
383
382384            eeprom_set_data(eeprom_data,0x100);
383385         }
386         else if (memory_region(machine,"user1")) /* if there is an eeprom in the romdef, use that */
387          {
388            UINT8 eeprom_data[0x100];
389             printf("user1\n");
390             memcpy(eeprom_data, memory_region(machine,"user1"), 0x100);
391             eeprom_set_data(eeprom_data,0x100);
392
393         }
384394      }
385395   }
386396}
r3485r3486
639649   MDRV_CPU_PROGRAM_MAP(ps5_readmem,ps5_writemem)
640650MACHINE_DRIVER_END
641651
642#if 0
643652static MACHINE_DRIVER_START( psikyo5_240 )
644653   /* basic machine hardware */
645654   MDRV_IMPORT_FROM(psikyo3v1)
r3485r3486
651660   MDRV_SCREEN_MODIFY("main")
652661   MDRV_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 30*8-1)
653662MACHINE_DRIVER_END
654#endif
655663
656664static INPUT_PORTS_START( common )
657665   PORT_START("INPUTS")
r3485r3486
11251133    // might need byteswapping to reprogram actual chip/
11261134    ROM_LOAD( "tgm2p.default.nv", 0x000, 0x100, CRC(b2328b40) SHA1(e6cda4d6f4e91b9f78d2ca84a5eee6c3bd03fe02) )
11271135ROM_END
1128*/
11291136
1130/* are these right? should i fake the counter return?
1131   'speedups / idle skipping isn't needed for 'hotgmck, hgkairak'
1132   as the core catches and skips the idle loops automatically'
11331137*/
11341138
1135static READ32_HANDLER( soldivid_speedup_r )
1136{
1137 /*
1138PC  : 0001AE74: MOV.L   @R14,R1
1139PC  : 0001AE76: ADD     #$01,R1
1140PC  : 0001AE78: MOV.L   R1,@R14
1141PC  : 0001AE7A: MOV.L   @($7C,PC),R3
1142PC  : 0001AE7C: MOV.L   @R3,R0
1143PC  : 0001AE7E: TST     R0,R0
1144PC  : 0001AE80: BT      $0001AE74
1145*/
1146   if (activecpu_get_pc()==0x0001AFAA) cpu_spinuntil_int(); // Character Select + InGame
1147   if (activecpu_get_pc()==0x0001AE74) cpu_spinuntil_int(); // Everything Else?
11481139
1149   return psh_ram[0x00000C/4];
1150}
1151
1152static READ32_HANDLER( s1945ii_speedup_r )
1153{
1154/*
1155PC  : 0609FC68: MOV.L   @R13,R1  // R13 is 600000C  R1 is counter  (read from r13)
1156PC  : 0609FC6A: ADD     #$01,R1  // add 1 to counter
1157PC  : 0609FC6C: MOV.L   R1,@R13  // write it back
1158PC  : 0609FC6E: MOV.L   @($3C,PC),R3 // 609fdac into r3
1159PC  : 0609FC70: MOV.L   @R3,R0  // whats there into r0
1160PC  : 0609FC72: TST     R0,R0 // test
1161PC  : 0609FC74: BT      $0609FC68
1162*/
1163   if (activecpu_get_pc()==0x609FC68) cpu_spinuntil_int(); // Title Screens
1164   if (activecpu_get_pc()==0x609FED2) cpu_spinuntil_int(); // In Game
1165   if (activecpu_get_pc()==0x60A0170) cpu_spinuntil_int(); // Attract Demo
1166
1167   return psh_ram[0x00000C/4];
1168}
1169
1170static READ32_HANDLER( daraku_speedup_r )
1171{
1172/*
1173PC  : 00047618: MOV.L   @($BC,PC),R0
1174PC  : 0004761A: MOV.L   @R0,R1
1175PC  : 0004761C: ADD     #$01,R1
1176PC  : 0004761E: MOV.L   R1,@R0
1177PC  : 00047620: MOV.L   @($BC,PC),R3
1178PC  : 00047622: MOV.L   @R3,R0
1179PC  : 00047624: TST     R0,R0
1180PC  : 00047626: BT      $00047618
1181*/
1182   if (activecpu_get_pc()==0x0004761a) cpu_spinuntil_int(); // title
1183   if (activecpu_get_pc()==0x00047976) cpu_spinuntil_int(); // ingame
1184
1185   return psh_ram[0x00000C/4];
1186}
1187
1188static READ32_HANDLER( sbomberb_speedup_r )
1189{
1190/*
1191PC  : 060A10EC: MOV.L   @R13,R3
1192PC  : 060A10EE: ADD     #$01,R3
1193PC  : 060A10F0: MOV.L   R3,@R13
1194PC  : 060A10F2: MOV.L   @($34,PC),R1
1195PC  : 060A10F4: MOV.L   @R1,R2
1196PC  : 060A10F6: TST     R2,R2
1197PC  : 060A10F8: BT      $060A10EC
1198*/
1199   if (activecpu_get_pc()==0x060A10EC) cpu_spinuntil_int(); // title
1200   if (activecpu_get_pc()==0x060A1658) cpu_spinuntil_int(); // attract
1201   if (activecpu_get_pc()==0x060A1380) cpu_spinuntil_int(); // game
1202
1203   return psh_ram[0x00000C/4];
1204}
1205
1206static READ32_HANDLER( gunbird2_speedup_r )
1207{
1208/*
1209PC  : 06028972: MOV.L   @R14,R3   // r14 is 604000c on this one
1210PC  : 06028974: MOV.L   @($D4,PC),R1
1211PC  : 06028976: ADD     #$01,R3
1212PC  : 06028978: MOV.L   R3,@R14
1213PC  : 0602897A: MOV.L   @R1,R2
1214PC  : 0602897C: TST     R2,R2
1215PC  : 0602897E: BT      $06028972
1216*/
1217   if (activecpu_get_pc()==0x06028972) cpu_spinuntil_int();
1218   if (activecpu_get_pc()==0x06028E62) cpu_spinuntil_int();
1219   if (activecpu_get_pc()==0x06028BE4) cpu_spinuntil_int();
1220
1221   return psh_ram[0x04000C/4];
1222}
1223
1224static READ32_HANDLER( s1945iii_speedup_r )
1225{
1226   if (activecpu_get_pc()==0x0602B462) cpu_spinuntil_int(); // start up text
1227   if (activecpu_get_pc()==0x0602B6E0) cpu_spinuntil_int(); // intro attract
1228   if (activecpu_get_pc()==0x0602BC1C) cpu_spinuntil_int(); // game attract
1229   if (activecpu_get_pc()==0x0602B97A) cpu_spinuntil_int(); // game
1230
1231   return psh_ram[0x06000C/4];
1232}
1233
1234
1235static READ32_HANDLER( dragnblz_speedup_r )
1236{
1237   if (activecpu_get_pc()==0x0602743e) cpu_spinuntil_int(); // startup texts
1238   if (activecpu_get_pc()==0x060276e4) cpu_spinuntil_int(); // attract intro
1239   if (activecpu_get_pc()==0x06027C72) cpu_spinuntil_int(); // attract game
1240   if (activecpu_get_pc()==0x060279A6) cpu_spinuntil_int(); // game
1241
1242   return psh_ram[0x006000C/4];
1243}
1244
1245static READ32_HANDLER( gnbarich_speedup_r )
1246{
1247/*
1248PC  :0602CAE6: MOV.L   @R14,R3 // R14 = 0x606000C
1249PC  :0602CAE8: MOV.L   @($F4,PC),R1
1250PC  :0602CAEA: ADD     #$01,R3
1251PC  :0602CAEC: MOV.L   R3,@R14 // R14 = 0x606000C
1252PC  :0602CAEE: MOV.L   @R1,R2
1253PC  :0602CAF0: TST     R2,R2
1254PC  :0602CAF2: BT      $0602CAE6
1255*/
1256
1257   if (activecpu_get_pc()==0x0602CAE6) cpu_spinuntil_int(); // title logos
1258   if (activecpu_get_pc()==0x0602CD86) cpu_spinuntil_int(); // attract intro
1259   if (activecpu_get_pc()==0x0602D2ee) cpu_spinuntil_int(); // game attract
1260   if (activecpu_get_pc()==0x0602D040) cpu_spinuntil_int(); // game play
1261
1262   return psh_ram[0x006000C/4];
1263}
1264
1265static READ32_HANDLER( mjgtaste_speedup_r )
1266{
1267
1268   if (activecpu_get_pc()==0x6031f02) {cpu_spinuntil_int();return psh_ram[0x006000C/4];} // title logos
1269   if (activecpu_get_pc()==0x603214a) {cpu_spinuntil_int();return psh_ram[0x006000C/4];} // attract game
1270
1271//  mame_printf_debug("at %08x\n",activecpu_get_pc());
1272
1273   return psh_ram[0x006000C/4];
1274}
1275
12761140static DRIVER_INIT( soldivid )
12771141{
12781142   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
1279   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 0);
1280   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x1afaa);
1281   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 1);
1282   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x1ae74);
1283   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x600000c, 0x600000f, 0, 0, soldivid_speedup_r );
12841143   use_factory_eeprom=eeprom_0;
12851144}
12861145
12871146static DRIVER_INIT( s1945ii )
12881147{
12891148   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
1290   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 0);
1291   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x609fc68);
1292   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 1);
1293   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x609fed2);
1294   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 2);
1295   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x60a0170);
1296   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x600000c, 0x600000f, 0, 0, s1945ii_speedup_r );
12971149   use_factory_eeprom=eeprom_DEFAULT;
12981150}
12991151
13001152static DRIVER_INIT( daraku )
13011153{
13021154   UINT8 *RAM = memory_region(machine, "main");
1303   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
1304   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 0);
1305   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x4761a);
1306   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 1);
1307   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x47976);
13081155   memory_set_bankptr(1,&RAM[0x100000]);
1309   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x600000c, 0x600000f, 0, 0, daraku_speedup_r );
1156   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
13101157   use_factory_eeprom=eeprom_DARAKU;
13111158}
13121159
13131160static DRIVER_INIT( sbomberb )
13141161{
13151162   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
1316   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 0);
1317   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x60a10ec);
1318   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 1);
1319   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x60a1658);
1320   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 2);
1321   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x60a1380);
1322   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x600000c, 0x600000f, 0, 0, sbomberb_speedup_r );
13231163   use_factory_eeprom=eeprom_DEFAULT;
13241164}
13251165
13261166static DRIVER_INIT( gunbird2 )
13271167{
13281168   UINT8 *RAM = memory_region(machine, "main");
1329   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
1330   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 0);
1331   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x6028972);
1332   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 1);
1333   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x6028e62);
1334   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 2);
1335   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x6028be4);
13361169   memory_set_bankptr(1,&RAM[0x100000]);
1337   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x604000c, 0x604000f, 0, 0, gunbird2_speedup_r );
1170   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
13381171   use_factory_eeprom=eeprom_DEFAULT;
13391172}
13401173
13411174static DRIVER_INIT( s1945iii )
13421175{
13431176   UINT8 *RAM = memory_region(machine, "main");
1344   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
1345   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 0);
1346   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x602b462);
1347   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 1);
1348   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x602b6e0);
1349   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 2);
1350   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x602bc1c);
1351   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 3);
1352   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x602b97a);
13531177   memory_set_bankptr(1,&RAM[0x100000]);
1354   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x606000c, 0x606000f, 0, 0, s1945iii_speedup_r );
1178   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
13551179   use_factory_eeprom=eeprom_S1945III;
13561180}
13571181
13581182static DRIVER_INIT( dragnblz )
13591183{
13601184   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
1361   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 0);
1362   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x602743e);
1363   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 1);
1364   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x60276e4);
1365   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 2);
1366   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x6027c72);
1367   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 3);
1368   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x60279a6);
1369   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x606000c, 0x606000f, 0, 0, dragnblz_speedup_r );
13701185   use_factory_eeprom=eeprom_DRAGNBLZ;
13711186}
13721187
13731188static DRIVER_INIT( gnbarich )
13741189{
13751190   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
1376   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 0);
1377   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x602cae6);
1378   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 1);
1379   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x602cd86);
1380   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 2);
1381   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x602d2ee);
1382   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 3);
1383   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x602d040);
1384   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x606000c, 0x606000f, 0, 0, gnbarich_speedup_r );
13851191   use_factory_eeprom=eeprom_GNBARICH;
13861192}
13871193
13881194static DRIVER_INIT( mjgtaste )
13891195{
13901196   cpunum_set_info_int(0, CPUINFO_INT_SH2_DRC_OPTIONS, SH2DRC_FASTEST_OPTIONS);
1391   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 0);
1392   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x6031f02);
1393   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, 1);
1394   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x603214a);
1395   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x606000c, 0x606000f, 0, 0, mjgtaste_speedup_r );
13961197   use_factory_eeprom=eeprom_MJGTASTE;
13971198   /* needs to install mahjong controls too (can select joystick in test mode tho) */
13981199}
src/mame/drivers/neodrvr.c
r3485r3486
45284528
45294529   ROM_Y_ZOOM
45304530
4531   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4531   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
45324532   ROM_REGION( 0x20000, "fixed", 0 )
45334533   ROM_FILL( 0x000000, 0x20000, 0 )
45344534   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
45644564
45654565   ROM_Y_ZOOM
45664566
4567   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4567   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
45684568   ROM_REGION( 0x20000, "fixed", 0 )
45694569   ROM_FILL( 0x000000, 0x20000, 0 )
45704570   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
46024602
46034603   ROM_Y_ZOOM
46044604
4605   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4605   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
46064606   ROM_REGION( 0x20000, "fixed", 0 )
46074607   ROM_FILL( 0x000000, 0x20000, 0 )
46084608   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
46384638
46394639   ROM_Y_ZOOM
46404640
4641   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4641   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
46424642   ROM_REGION( 0x20000, "fixed", 0 )
46434643   ROM_FILL( 0x000000, 0x20000, 0 )
46444644   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
47044704
47054705   ROM_Y_ZOOM
47064706
4707   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4707   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
47084708   ROM_REGION( 0x20000, "fixed", 0 )
47094709   ROM_FILL( 0x000000, 0x20000, 0 )
47104710   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
47334733
47344734   ROM_Y_ZOOM
47354735
4736   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4736   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
47374737   ROM_REGION( 0x80000, "fixed", 0 )   /* larger char set */
47384738   ROM_FILL( 0x000000, 0x20000, 0 )
47394739   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
47694769
47704770   ROM_Y_ZOOM
47714771
4772   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4772   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
47734773   ROM_REGION( 0x80000, "fixed", 0 )   /* larger char set */
47744774   ROM_FILL( 0x000000, 0x20000, 0 )
47754775   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
48324832
48334833   ROM_Y_ZOOM
48344834
4835   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4835   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
48364836   ROM_REGION( 0x20000, "fixed", 0 )
48374837   ROM_FILL( 0x000000, 0x20000, 0 )
48384838   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
48664866
48674867   ROM_Y_ZOOM
48684868
4869   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4869   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
48704870   ROM_REGION( 0x20000, "fixed", 0 )
48714871   ROM_FILL( 0x000000, 0x20000, 0 )
48724872   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
48984898
48994899   ROM_Y_ZOOM
49004900
4901   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4901   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
49024902   ROM_REGION( 0x80000, "fixed", 0 ) /* larger char set */
49034903   ROM_FILL( 0x000000, 0x20000, 0 )
49044904   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
49334933
49344934   ROM_Y_ZOOM
49354935
4936   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4936   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
49374937   ROM_REGION( 0x80000, "fixed", 0 ) /* larger char set */
49384938   ROM_FILL( 0x000000, 0x20000, 0 )
49394939   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
49694969
49704970   ROM_Y_ZOOM
49714971
4972   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
4972   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
49734973   ROM_REGION( 0x80000, "fixed", 0 )   /* larger char set */
49744974   ROM_FILL( 0x000000, 0x20000, 0 )
49754975   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
50045004
50055005   ROM_Y_ZOOM
50065006
5007   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5007   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
50085008   ROM_REGION( 0x80000, "fixed", 0 )   /* larger char set */
50095009   ROM_FILL( 0x000000, 0x20000, 0 )
50105010   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
50395039
50405040   ROM_Y_ZOOM
50415041
5042   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5042   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
50435043   ROM_REGION( 0x20000, "fixed", 0 )
50445044   ROM_FILL( 0x000000, 0x20000, 0 )
50455045   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
50925092
50935093   ROM_Y_ZOOM
50945094
5095   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5095   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
50965096   ROM_REGION( 0x20000, "fixed", 0 )
50975097   ROM_FILL( 0x000000, 0x20000, 0 )
50985098   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
51195119
51205120   ROM_Y_ZOOM
51215121
5122   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5122   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
51235123   ROM_REGION( 0x20000, "fixed", 0 )
51245124   ROM_FILL( 0x000000, 0x20000, 0 )
51255125   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
51495149
51505150   ROM_Y_ZOOM
51515151
5152   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5152   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
51535153   ROM_REGION( 0x20000, "fixed", 0 )
51545154   ROM_FILL( 0x000000, 0x20000, 0 )
51555155   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
51855185
51865186   ROM_Y_ZOOM
51875187
5188   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5188   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
51895189   ROM_REGION( 0x20000, "fixed", 0 )
51905190   ROM_FILL( 0x000000, 0x20000, 0 )
51915191   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
52215221
52225222   ROM_Y_ZOOM
52235223
5224   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5224   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
52255225   ROM_REGION( 0x80000, "fixed", 0 )   /* larger char set */
52265226   ROM_FILL( 0x000000, 0x20000, 0 )
52275227   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
52535253
52545254   ROM_Y_ZOOM
52555255
5256   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5256   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
52575257   ROM_REGION( 0x20000, "fixed", 0 )
52585258   ROM_FILL( 0x000000, 0x20000, 0 )
52595259   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
52885288
52895289   ROM_Y_ZOOM
52905290
5291   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5291   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
52925292   ROM_REGION( 0x20000, "fixed", 0 )
52935293   ROM_FILL( 0x000000, 0x20000, 0 )
52945294   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
53235323
53245324   ROM_Y_ZOOM
53255325
5326   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5326   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
53275327   ROM_REGION( 0x80000, "fixed", 0 )
53285328   ROM_FILL( 0x000000, 0x80000, 0 )
53295329   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
53575357
53585358   ROM_Y_ZOOM
53595359
5360   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5360   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
53615361   ROM_REGION( 0x20000, "fixed", 0 )
53625362   ROM_FILL( 0x000000, 0x20000, 0 )
53635363   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
53855385
53865386   ROM_Y_ZOOM
53875387
5388   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5388   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
53895389   ROM_REGION( 0x20000, "fixed", 0 )
53905390   ROM_FILL( 0x000000, 0x20000, 0 )
53915391   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
54205420
54215421   ROM_Y_ZOOM
54225422
5423   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5423   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
54245424   ROM_REGION( 0x20000, "fixed", 0 )
54255425   ROM_FILL( 0x000000, 0x20000, 0 )
54265426   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
54555455
54565456   ROM_Y_ZOOM
54575457
5458   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5458   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
54595459   ROM_REGION( 0x80000, "fixed", 0 ) /* larger char set */
54605460   ROM_FILL( 0x000000, 0x80000, 0 )
54615461   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
54885488
54895489   ROM_Y_ZOOM
54905490
5491   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5491   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
54925492   ROM_REGION( 0x20000, "fixed", 0 )
54935493   ROM_FILL( 0x000000, 0x20000, 0 )
54945494   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
55235523
55245524   ROM_Y_ZOOM
55255525
5526   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5526   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
55275527   ROM_REGION( 0x20000, "fixed", 0 )
55285528   ROM_FILL( 0x000000, 0x20000, 0 )
55295529   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
55595559
55605560   ROM_Y_ZOOM
55615561
5562   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5562   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
55635563   ROM_REGION( 0x80000, "fixed", 0 ) /* larger char set */
55645564   ROM_FILL( 0x000000, 0x80000, 0 )
55655565   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
55955595
55965596   ROM_Y_ZOOM
55975597
5598   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5598   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
55995599   ROM_REGION( 0x80000, "fixed", 0 ) /* larger char set */
56005600   ROM_FILL( 0x000000, 0x80000, 0 )
56015601   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
56305630
56315631   ROM_Y_ZOOM
56325632
5633   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5633   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
56345634   ROM_REGION( 0x20000, "fixed", 0 )
56355635   ROM_FILL( 0x000000, 0x20000, 0 )
56365636   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
56645664
56655665   ROM_Y_ZOOM
56665666
5667   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5667   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
56685668   ROM_REGION( 0x20000, "fixed", 0 )
56695669   ROM_FILL( 0x000000, 0x20000, 0 )
56705670   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
56995699
57005700   ROM_Y_ZOOM
57015701
5702   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5702   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
57035703   ROM_REGION( 0x20000, "fixed", 0 )
57045704   ROM_FILL( 0x000000, 0x20000, 0 )
57055705   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
57345734
57355735   ROM_Y_ZOOM
57365736
5737   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
5737   /* The Encrypted Boards do not have an s1 rom, data for it comes from the Cx ROMs */
57385738   ROM_REGION( 0x20000, "fixed", 0 )
57395739   ROM_FILL( 0x000000, 0x20000, 0 )
57405740   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
58155815   ROM_LOAD32_WORD_SWAP( "268-p1r.bin", 0x000000, 0x400000, NO_DUMP )
58165816   ROM_LOAD32_WORD_SWAP( "268-p2r.bin", 0x000002, 0x400000, NO_DUMP )
58175817
5818   /* The Encrypted Boards do _not_ have an s1 rom, data for it comes from the Cx ROMs */
58195818   ROM_REGION( 0x20000, "fixed", 0 )
58205819   ROM_FILL( 0x000000, 0x20000, 0 )
58215820   ROM_REGION( 0x20000, "fixedbios", 0 )
r3485r3486
62806279
62816280/* The King of Fighters 2002 bootlegs */
62826281
6282ROM_START( kof2002b )
6283   ROM_REGION( 0x500000, "main", 0 )
6284   ROM_LOAD16_WORD_SWAP( "265-p1.bin", 0x000000, 0x100000, CRC(9ede7323) SHA1(ad9d45498777fda9fa58e75781f48e09aee705a6) )
6285   ROM_LOAD16_WORD_SWAP( "2k2-p2.bin", 0x100000, 0x400000, CRC(6dbee4df) SHA1(9a9646c81b233b44213c624b898c19f83e9a07f8) )
6286
6287   NEO_SFIX_128K( "2k2-s1.bin", CRC(2255f5bf) SHA1(8a82b3e9717df30b580b9d0bac0b403f8102a002) )
6288
6289   /* Encrypted */
6290   NEO_BIOS_AUDIO_ENCRYPTED_128K( "265-m1.bin", CRC(85aaa632) SHA1(744fba4ca3bc3a5873838af886efb97a8a316104) )
6291
6292   ROM_REGION( 0x1000000, "ym", 0 )
6293   /* Encrypted */
6294   ROM_LOAD( "265-v1.bin", 0x000000, 0x800000, CRC(15e8f3f5) SHA1(7c9e6426b9fa6db0158baa17a6485ffce057d889) )
6295   ROM_LOAD( "265-v2.bin", 0x800000, 0x800000, CRC(da41d6f9) SHA1(a43021f1e58947dcbe3c8ca5283b20b649f0409d) )
6296
6297   NO_DELTAT_REGION
6298
6299   ROM_REGION( 0x4000000, "sprites", 0 )
6300   ROM_LOAD16_BYTE( "2k2-c1.bin", 0x0000000, 0x800000, CRC(f25d3d66) SHA1(eb1da3e171c126d91e851ce141840709a2f62f8a) ) /* Plane 0,1 */
6301   ROM_LOAD16_BYTE( "2k2-c2.bin", 0x0000001, 0x800000, CRC(e3e66f1d) SHA1(af93e9e134816353d6187a53959c6e418b83ad8d) ) /* Plane 2,3 */
6302   ROM_LOAD16_BYTE( "2k2-c3.bin", 0x1000000, 0x800000, CRC(8732fa30) SHA1(81c482b375c04bcfbbc69e3e2a2e9ab567c9bb78) ) /* Plane 0,1 */
6303   ROM_LOAD16_BYTE( "2k2-c4.bin", 0x1000001, 0x800000, CRC(0989fd40) SHA1(355d6b2c528319e41ce89952c5cf5bcc47cd6de0) ) /* Plane 2,3 */
6304   ROM_LOAD16_BYTE( "2k2-c5.bin", 0x2000000, 0x800000, CRC(60635cd2) SHA1(0cf2c54e003edfcdbed64e0570e6b800e7ed3c1b) ) /* Plane 0,1 */
6305   ROM_LOAD16_BYTE( "2k2-c6.bin", 0x2000001, 0x800000, CRC(bd736824) SHA1(d897fc8248ace145fef57d8aa393eaebc4a1ccc4) ) /* Plane 2,3 */
6306   ROM_LOAD16_BYTE( "2k2-c7.bin", 0x3000000, 0x800000, CRC(2da8d8cf) SHA1(ab8aa88b8e1baba88e5fc01d0f3cb55503b6c81a) ) /* Plane 0,1 */
6307   ROM_LOAD16_BYTE( "2k2-c8.bin", 0x3000001, 0x800000, CRC(2048404a) SHA1(d6d0f049ffc196334825328e0472b04e04bf6695) ) /* Plane 2,3 */
6308ROM_END
6309
62836310ROM_START( kf2k2pls )
62846311   ROM_REGION( 0x500000, "main", 0 )
62856312   ROM_LOAD16_WORD_SWAP( "2k2-p1p.bin", 0x000000, 0x100000, CRC(3ab03781) SHA1(86946c19f1c4d9ab5cde86688d698bf63118a39d) )
r3485r3486
71667193   DRIVER_INIT_CALL(neogeo);
71677194}
71687195
7196static DRIVER_INIT( kof2002b )
7197{
7198   kof2002_decrypt_68k(machine);
7199   neo_pcm2_swap(machine, 0);
7200   neogeo_cmc50_m1_decrypt(machine);
7201   kof2002b_gfx_decrypt(machine, memory_region(machine, "sprites"),0x4000000);
7202   kof2002b_gfx_decrypt(machine, memory_region(machine, "fixed"),0x20000);
7203   DRIVER_INIT_CALL(neogeo);
7204}
7205
71697206static DRIVER_INIT( kf2k2pls )
71707207{
71717208   kof2002_decrypt_68k(machine);
r3485r3486
71877224
71887225static DRIVER_INIT( kf2k2mp2 )
71897226{
7190   kof2km2_px_decrypt(machine);
7227   kf2k2mp2_px_decrypt(machine);
71917228   neo_pcm2_swap(machine, 0);
71927229   neogeo_cmc50_m1_decrypt(machine);
71937230   neogeo_bootleg_sx_decrypt(machine, 1);
r3485r3486
76477684GAME( 2003, ct2k3sp,  kof2001,  neogeo,   neogeo,   ct2k3sp,  ROT0, "bootleg", "Crouching Tiger Hidden Dragon 2003 Super Plus (The King of Fighters 2001 bootleg)", 0 ) /* Protected Hack / Bootleg of kof2001 */
76487685GAME( 2003, ct2k3sa,  kof2001,  neogeo,   neogeo,   ct2k3sa,  ROT0, "bootleg", "Crouching Tiger Hidden Dragon 2003 Super Plus alternate (The King of Fighters 2001 bootleg)", 0 ) /* Hack / Bootleg of kof2001 */
76497686GAME( 2002, kof2002,  neogeo,   neogeo,   neogeo,   kof2002,  ROT0, "Eolith / Playmore", "The King of Fighters 2002" , 0 ) /* Encrypted GFX */
7687GAME( 2002, kof2002b, kof2002,  neogeo,   neogeo,   kof2002b, ROT0, "bootleg", "The King of Fighters 2002 (bootleg)", 0 )
76507688GAME( 2002, kf2k2pls, kof2002,  neogeo,   neogeo,   kf2k2pls, ROT0, "bootleg", "The King of Fighters 2002 Plus (bootleg set 1)" , 0 ) /* Encrypted GFX */
76517689GAME( 2002, kf2k2pla, kof2002,  neogeo,   neogeo,   kf2k2pls, ROT0, "bootleg", "The King of Fighters 2002 Plus (bootleg set 2)" , 0 ) /* Encrypted GFX */
76527690GAME( 2002, kf2k2mp,  kof2002,  neogeo,   neogeo,   kf2k2mp,  ROT0, "bootleg", "The King of Fighters 2002 Magic Plus (bootleg)" , 0 ) /* Encrypted GFX */
r3485r3486
76807718GAME( 2003, samsh5sh, samsh5sp, neogeo,   neogeo,   samsh5sp, ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V Special / Samurai Spirits Zero Special (set 2, censored)", 0 )
76817719GAME( 2003, samsh5sn, samsh5sp, neogeo,   neogeo,   samsh5sp, ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V Special / Samurai Spirits Zero Special (set 3, less censored)", 0 )
76827720
7683/* there are other bootlegs kof2002b etc. kof96ep, kf2k1pls? -- work out which should be supported */
7721/* there are other bootlegs kof96ep, kf2k1pls etc.? -- work out which should be supported */
76847722
76857723/* Alpha Denshi Co. / ADK (changed name in 1993) */
76867724GAME( 1990, maglord,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Magician Lord (set 1)", 0 )
r3485r3486
78027840GAME( 1996, neodrift, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Neo Drift Out - New Technology", 0 )
78037841GAME( 1996, breakers, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Breakers", 0 )
78047842GAME( 1997, puzzldpr, puzzledp, neogeo,   neogeo,   neogeo,   ROT0, "Taito (Visco license)", "Puzzle De Pon! R!", 0 )
7805GAME( 1998, breakrev, breakers, neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Breakers Revenge", 0 )
7843GAME( 1998, breakrev, neogeo,  neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Breakers Revenge", 0 )
78067844GAME( 1998, flipshot, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Battle Flip Shot", 0 )
78077845GAME( 1999, ctomaday, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Captain Tomaday", 0 )
78087846GAME( 1999, ganryu,   neogeo,   neogeo,   neogeo,   ganryu,   ROT0, "Visco", "Ganryu / Musashi Ganryuki" , 0 )   /* Encrypted GFX */
src/mame/drivers/cardline.c
r3485r3486
7878{
7979   static int var=0;
8080   var^=0x10;
81   //printf("var %d\n",var);
8182   return var;
8283}
8384
r3485r3486
9899   AM_RANGE(0x0000, 0xffff) AM_ROM
99100ADDRESS_MAP_END
100101
101static ADDRESS_MAP_START( mem_data, ADDRESS_SPACE_DATA, 8 )
102static ADDRESS_MAP_START( mem_io, ADDRESS_SPACE_IO, 8 )
102103   AM_RANGE(0x0000, 0x1fff) AM_RAM
103104   AM_RANGE(0x2003, 0x2003) AM_READ_PORT("IN0")
104105   AM_RANGE(0x2005, 0x2005) AM_READ_PORT("IN1")
r3485r3486
113114   AM_RANGE(0x3003, 0x3003) AM_NOP
114115   AM_RANGE(0xc000, 0xdfff) AM_WRITE(vram_w) AM_BASE(&videoram)
115116   AM_RANGE(0xe000, 0xffff) AM_WRITE(attr_w) AM_BASE(&colorram)
117   /* Ports */
118   AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READWRITE(unk_r, video_w)
116119ADDRESS_MAP_END
117120
118static ADDRESS_MAP_START( mem_io, ADDRESS_SPACE_IO, 8 )
119  AM_RANGE(0x01, 0x01) AM_READWRITE(unk_r, video_w)
120ADDRESS_MAP_END
121121
122122static INPUT_PORTS_START( cardline )
123123   PORT_START("IN0")
r3485r3486
194194static MACHINE_DRIVER_START( cardline )
195195
196196   /* basic machine hardware */
197   MDRV_CPU_ADD("main", I8051,12000000)
197   MDRV_CPU_ADD("main", I80C32,12000000)
198198   MDRV_CPU_PROGRAM_MAP(mem_prg,0)
199   MDRV_CPU_DATA_MAP(mem_data,0)
200199   MDRV_CPU_IO_MAP(mem_io,0)
200   //MDRV_CPU_VBLANK_INT("main", irq1_line_hold)
201201
202202   /* video hardware */
203203   MDRV_SCREEN_ADD("main", RASTER)
src/mame/drivers/peplus.c
r3485r3486
487487   return sf000_ram[offset];
488488}
489489
490/* External RAM Callback for I8052 */
491static READ32_HANDLER( peplus_external_ram_iaddr )
492{
493   if (mem_mask == 0xff) {
494      return (io_port[2] << 8) | offset;
495   } else {
496      return offset;
497   }
498}
499
500490/* Last Color in Every Palette is bgcolor */
501491static READ8_HANDLER( peplus_bgcolor_r )
502492{
r3485r3486
541531      last_cycles = activecpu_gettotalcycles();
542532   } else {
543533      /* Process Next Coin Optic State */
544      if (curr_cycles - last_cycles > 600000 && coin_state != 0) {
534      if (curr_cycles - last_cycles > 600000/6 && coin_state != 0) {
545535         coin_state++;
546536         if (coin_state > 5)
547537            coin_state = 0;
r3485r3486
571561         break;
572562   }
573563
574   if (curr_cycles - last_door > 6000) { // Guessing with 6000
564   if (curr_cycles - last_door > 6000/12) { // Guessing with 6000
575565      if ((input_port_read_safe(machine, "DOOR",0xff) & 0x01) == 0x01) {
576566         door_open = (!door_open & 0x01);
577567      } else {
r3485r3486
580570      last_door = activecpu_gettotalcycles();
581571   }
582572
583   if (curr_cycles - last_coin_out > 600000 && coin_out_state != 0) { // Guessing with 600000
573   if (curr_cycles - last_coin_out > 600000/12 && coin_out_state != 0) { // Guessing with 600000
584574      if (coin_out_state != 2) {
585575            coin_out_state = 2; // Coin-Out Off
586576        } else {
r3485r3486
711701   AM_RANGE(0x0000, 0xffff) AM_ROM AM_BASE(&program_ram)
712702ADDRESS_MAP_END
713703
714static ADDRESS_MAP_START( peplus_datamap, ADDRESS_SPACE_DATA, 8 )
704static ADDRESS_MAP_START( peplus_iomap, ADDRESS_SPACE_IO, 8 )
715705   // Battery-backed RAM (0x1000-0x01fff Extended RAM for Superboards Only)
716706   AM_RANGE(0x0000, 0x1fff) AM_READWRITE(peplus_cmos_r, peplus_cmos_w) AM_BASE(&cmos_ram)
717707
r3485r3486
763753
764754    // Superboard Data
765755   AM_RANGE(0xf000, 0xffff) AM_READWRITE(peplus_sf000_r, peplus_sf000_w) AM_BASE(&sf000_ram)
766ADDRESS_MAP_END
767756
768static ADDRESS_MAP_START( peplus_iomap, ADDRESS_SPACE_IO, 8 )
769   ADDRESS_MAP_GLOBAL_MASK(0xff)
770
771   // I/O Ports
772   AM_RANGE(0x00, 0x03) AM_READ(peplus_io_r) AM_WRITE(peplus_io_w) AM_BASE(&io_port)
757   /* Ports start here */
758   AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P3) AM_READ(peplus_io_r) AM_WRITE(peplus_io_w) AM_BASE(&io_port)
773759ADDRESS_MAP_END
774760
775
776761/*************************
777762*      Input ports       *
778763*************************/
r3485r3486
1010995   // basic machine hardware
1011996   MDRV_CPU_ADD("main", I8052, 3686400*2)
1012997   MDRV_CPU_PROGRAM_MAP(peplus_map, 0)
1013   MDRV_CPU_DATA_MAP(peplus_datamap, 0)
998   //MDRV_CPU_DATA_MAP(peplus_datamap, 0)
1014999   MDRV_CPU_IO_MAP(peplus_iomap, 0)
10151000   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
10161001
r3485r3486
10471032/* Normal board */
10481033static void peplus_init(void)
10491034{
1050   /* External RAM callback */
1051   i8051_set_eram_iaddr_callback(peplus_external_ram_iaddr);
1052
10531035    /* EEPROM is a X2404P 4K-bit Serial I2C Bus */
10541036   i2cmem_init(0, I2CMEM_SLAVE_ADDRESS, 8, eeprom_NVRAM_SIZE, NULL);
10551037
src/mame/drivers/segas16a.c
r3485r3486
871871 *
872872 *************************************/
873873
874static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
874static ADDRESS_MAP_START( mcu_io_map, ADDRESS_SPACE_DATA, 8 )
875875   ADDRESS_MAP_UNMAP_HIGH
876   AM_RANGE(0x0000, 0x0fff) AM_ROM
877876ADDRESS_MAP_END
878877
879static ADDRESS_MAP_START( mcu_data_map, ADDRESS_SPACE_DATA, 8 )
880   ADDRESS_MAP_UNMAP_HIGH
881ADDRESS_MAP_END
882878
883879
884
885880/*************************************
886881 *
887882 *  Generic port definitions
r3485r3486
18301825   MDRV_CPU_VBLANK_INT("main", i8751_main_cpu_vblank)
18311826
18321827   MDRV_CPU_ADD("mcu", I8751, 8000000)
1833   MDRV_CPU_PROGRAM_MAP(mcu_map,0)
1834   MDRV_CPU_DATA_MAP(mcu_data_map,0)
1828   MDRV_CPU_IO_MAP(mcu_io_map,0)
18351829   MDRV_CPU_VBLANK_INT("main", irq0_line_pulse)
18361830MACHINE_DRIVER_END
18371831
src/mame/drivers/segahang.c
r3485r3486
485485 *
486486 *************************************/
487487
488static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
489   ADDRESS_MAP_UNMAP_HIGH
490   AM_RANGE(0x0000, 0x0fff) AM_ROM
488static ADDRESS_MAP_START( mcu_io_map, ADDRESS_SPACE_IO, 8 )
491489ADDRESS_MAP_END
492490
493static ADDRESS_MAP_START( mcu_data_map, ADDRESS_SPACE_DATA, 8 )
494   ADDRESS_MAP_UNMAP_HIGH
495ADDRESS_MAP_END
496491
497492
498
499493/*************************************
500494 *
501495 *  Generic port definitions
r3485r3486
10341028   MDRV_IMPORT_FROM(sound_board_2203)
10351029
10361030   MDRV_CPU_ADD("mcu", I8751, 8000000)
1037   MDRV_CPU_PROGRAM_MAP(mcu_map,0)
1038   MDRV_CPU_DATA_MAP(mcu_data_map,0)
1031   MDRV_CPU_IO_MAP(mcu_io_map,0)
10391032   MDRV_CPU_VBLANK_INT("main", irq0_line_pulse)
10401033MACHINE_DRIVER_END
10411034
src/mame/drivers/stvinit.c
r3485r3486
1313
1414#define FIRST_SPEEDUP_SLOT   (2)         // in case we remove/alter the BIOS speedups later
1515
16/*
17IC-13 rom shifter routine,on 2000000-21fffff the game maps the rom bytes on the
18ODD (in every sense) bytes.This gets the IC-13 rom status to good and ends a emulation
19weird issue once and for all...
20We need to remove this and add the whole thing into the ROM loading structure...
21*/
22static void ic13_shifter(running_machine *machine)
23{
24   UINT32 *rom = (UINT32 *)memory_region(machine, "user1");
25   UINT32 i;
26   UINT32 *tmp = malloc_or_die(0x80000*2);
2716
28   for(i=(0);i<(0x100000-1);i+=8)
29   {
30      //mame_printf_debug("%08x\n",i);
31      tmp[((i)/4)+0] = rom[(i/2)/4]; /*0.0 -> 2.1 -> 4.2*/
32      tmp[((i)/4)+1] = rom[(i/2)/4]; /*1.0 -> 3.1 -> 5.2*/
33   }
3417
35   for(i=(0);i<(0x100000-1);i+=8)
36   {
37      //mame_printf_debug("%08x\n",i);
38      tmp[(i/4)+0] = ((tmp[(i/4)+0] & 0xff000000) >> 8) | ((tmp[(i/4)+0] & 0x00ff0000) >> 16);
39      tmp[(i/4)+1] = ((tmp[(i/4)+1] & 0x0000ff00) << 8) | ((tmp[(i/4)+1] & 0x000000ff) >> 0);
40   }
41
42   for(i=(0);i<(0x100000-1);i+=4)
43   {
44      //mame_printf_debug("%08x\n",i);
45      rom[i/4] = tmp[(i)/4];
46   }
47
48   for(i=(0x300000);i<(0x400000-1);i+=8)
49   {
50      //mame_printf_debug("%08x\n",i);
51      tmp[((i-0x300000)/4)+0] = rom[(i/2)/4]; /*0.0 -> 2.1 -> 4.2*/
52      tmp[((i-0x300000)/4)+1] = rom[(i/2)/4]; /*1.0 -> 3.1 -> 5.2*/
53   }
54
55   for(i=(0);i<(0x100000-1);i+=8)
56   {
57      //mame_printf_debug("%08x\n",i);
58      tmp[(i/4)+0] = ((tmp[(i/4)+0] & 0xff000000) >> 8) | ((tmp[(i/4)+0] & 0x00ff0000) >> 16);
59      tmp[(i/4)+1] = ((tmp[(i/4)+1] & 0x0000ff00) << 8) | ((tmp[(i/4)+1] & 0x000000ff) >> 0);
60   }
61
62   for(i=(0x100000);i<(0x200000-1);i+=4)
63   {
64      //mame_printf_debug("%08x\n",i);
65      rom[i/4] = tmp[(i-0x100000)/4];
66   }
67   free(tmp);
68}
69
70DRIVER_INIT ( ic13 )
71{
72   ic13_shifter(machine);
73   DRIVER_INIT_CALL(stv);
74}
7518/*
7619EEPROM write 0000 to address 2d
7720EEPROM write 0000 to address 2e
r3485r3486
371314      memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x60ffc10, 0x60ffc13, 0, 0, puyosun_speedup_r ); // idle loop of main cpu
372315   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)puyosun_slave_speedup );
373316
374   DRIVER_INIT_CALL(ic13);
317   DRIVER_INIT_CALL(stv);
375318
376319   minit_boost = sinit_boost = 0;
377320   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
r3485r3486
401344
402345      memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x60ffc10, 0x60ffc13, 0, 0, mausuke_speedup_r ); // idle loop of main cpu
403346
404   DRIVER_INIT_CALL(ic13);
347   DRIVER_INIT_CALL(stv);
405348
406349   minit_boost = sinit_boost = 0;
407350   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
r3485r3486
552495   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x60985a0, 0x60985a3, 0, 0, dnmtdeka_speedup_r ); // idle loop of main cpu
553496   memory_install_readwrite32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x060e0ad4, 0x060e0bc3, 0, 0, dnmtdeka_cmd_read, dnmtdeka_cmd_write );
554497
555   DRIVER_INIT_CALL(ic13);
498   DRIVER_INIT_CALL(stv);
556499}
557500
558501static int diehard_pending_commands;
r3485r3486
645588   memory_install_write32_handler(machine, 1, ADDRESS_SPACE_PROGRAM, 0x060e0dd8, 0x060e0ddb, 0, 0, diehard_cmd_ack_write );
646589
647590
648   DRIVER_INIT_CALL(ic13);
591   DRIVER_INIT_CALL(stv);
649592}
650593
651594static READ32_HANDLER( fhboxers_speedup_r )
r3485r3486
684627      memory_install_read32_handler(machine, 1, ADDRESS_SPACE_PROGRAM, 0x6090740, 0x6090743, 0, 0, fhboxers_speedup2_r ); // idle loop of second cpu
685628     memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x06090bb4, 0x06090bb7, 0, 0, fhboxers_speedup3_r ); // idle loop of main cpu
686629
687   DRIVER_INIT_CALL(ic13);
630   DRIVER_INIT_CALL(stv);
688631}
689632
690633
691static READ32_HANDLER( bakubaku_speedup_r )
692{
693   if (activecpu_get_pc()==0x06036dc6) cpu_spinuntil_int(); // title logos
694634
695   return stv_workram_h[0x0833f0/4];
696}
697635
698static READ32_HANDLER( bakubaku_speedup2_r )
699{
700   if (activecpu_get_pc()==0x06033760)    cpunum_set_input_line(machine, 1, INPUT_LINE_HALT, ASSERT_LINE);
701
702   return stv_workram_h[0x0033762/4];
703}
704
705DRIVER_INIT(bakubaku)
706{
707   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, FIRST_SPEEDUP_SLOT);
708   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x6036dc6);
709   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_SELECT, FIRST_SPEEDUP_SLOT+1);
710   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x6033760);
711
712      memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x60833f0, 0x60833f3, 0, 0, bakubaku_speedup_r ); // idle loop of main cpu
713      memory_install_read32_handler(machine, 1, ADDRESS_SPACE_PROGRAM, 0x60fdfe8, 0x60fdfeb, 0, 0, bakubaku_speedup2_r ); // turn off slave sh2, is it needed after boot ??
714
715   DRIVER_INIT_CALL(ic13);
716}
717
718636static READ32_HANDLER( groovef_hack1_r )
719637{
720638   if(activecpu_get_pc() == 0x6005e7c) stv_workram_h[0x0fffcc/4] = 0x00000000;
r3485r3486
900818
901819   install_astrass_protection(machine);
902820
903   DRIVER_INIT_CALL(ic13);
821   DRIVER_INIT_CALL(stv);
904822}
905823
906824/* Treasure Hunt idle loop skipping */
r3485r3486
962880
963881   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf *)thunt_slave_speedup);
964882
965   DRIVER_INIT_CALL(ic13);
883   DRIVER_INIT_CALL(stv);
966884
967885   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(1);
968886}
r3485r3486
999917   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x060314f8, 0x060314fb, 0, 0, sandor_speedup_r );
1000918   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x06075a2c, 0x06075a2f, 0, 0, sandor_speedup2_r );
1001919   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf *)sandor_slave_speedup);
1002   DRIVER_INIT_CALL(ic13);
920   DRIVER_INIT_CALL(stv);
1003921   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(1);
1004922
1005923}
r3485r3486
11071025
11081026   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)colmns97_slave_speedup );
11091027
1110   DRIVER_INIT_CALL(ic13);
1028   DRIVER_INIT_CALL(stv);
11111029
11121030   minit_boost = sinit_boost = 0;
11131031
r3485r3486
11371055
11381056   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)winterht_slave_speedup );
11391057
1140   DRIVER_INIT_CALL(ic13);
1058   DRIVER_INIT_CALL(stv);
11411059
11421060   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(2);
11431061}
r3485r3486
11671085
11681086   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)seabass_slave_speedup );
11691087
1170   DRIVER_INIT_CALL(ic13);
1088   DRIVER_INIT_CALL(stv);
11711089
11721090   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(5);
11731091}
r3485r3486
11951113   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x06074f98, 0x06074f9b, 0, 0, vfremix_speedup_r );
11961114   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)vfremix_slave_speedup );
11971115
1198   DRIVER_INIT_CALL(ic13);
1116   DRIVER_INIT_CALL(stv);
11991117
12001118   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(20);
12011119}
r3485r3486
12251143   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x060ffc10, 0x060ffc13, 0, 0, sss_speedup_r );
12261144   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)sss_slave_speedup );
12271145
1228   DRIVER_INIT_CALL(ic13);
1146   DRIVER_INIT_CALL(stv);
12291147
12301148   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
12311149}
r3485r3486
12771195
12781196   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)sasissu_slave_speedup );
12791197
1280   DRIVER_INIT_CALL(ic13);
1198   DRIVER_INIT_CALL(stv);
12811199
12821200   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(2);
12831201}
r3485r3486
12941212   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x6012ee4);
12951213
12961214   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x002f4068, 0x002f406b, 0, 0, gaxeduel_speedup_r);
1297   DRIVER_INIT_CALL(ic13);
1215   DRIVER_INIT_CALL(stv);
12981216}
12991217
13001218static READ32_HANDLER(suikoenb_speedup_r)
r3485r3486
13091227   cpunum_set_info_int(0, CPUINFO_INT_SH2_PCFLUSH_ADDR, 0x6013f7a);
13101228
13111229   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x060705d0, 0x060705d3, 0, 0, suikoenb_speedup_r);
1312   DRIVER_INIT_CALL(ic13);
1230   DRIVER_INIT_CALL(stv);
13131231}
13141232
13151233
13161234DRIVER_INIT(sokyugrt)
13171235{
1318   DRIVER_INIT_CALL(ic13);
1236   DRIVER_INIT_CALL(stv);
13191237   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
13201238
13211239}
r3485r3486
13541272   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)znpwfv_slave_speedup );
13551273   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x60ffc10, 0x60ffc13, 0, 0, znpwfv_speedup_r );
13561274
1357   DRIVER_INIT_CALL(ic13);
1275   DRIVER_INIT_CALL(stv);
13581276   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_NSEC(500);
13591277}
13601278
r3485r3486
13811299   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)twcup98_slave_speedup );
13821300   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x60ffc10, 0x60ffc13, 0, 0, twcup98_speedup_r );
13831301
1384   DRIVER_INIT_CALL(ic13);
1302   DRIVER_INIT_CALL(stv);
13851303   install_standard_protection(machine);
13861304
13871305   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(5);
r3485r3486
14101328   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)smleague_slave_speedup );
14111329   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x60ffc10, 0x60ffc13, 0, 0, smleague_speedup_r );
14121330
1413   DRIVER_INIT_CALL(ic13);
1331   DRIVER_INIT_CALL(stv);
14141332
14151333   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
14161334}
r3485r3486
14291347
14301348   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x60ffc10, 0x60ffc13, 0, 0, finlarch_speedup_r );
14311349
1432   DRIVER_INIT_CALL(ic13);
1350   DRIVER_INIT_CALL(stv);
14331351
14341352}
14351353
r3485r3486
14651383   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)maruchan_slave_speedup );
14661384   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x60ffc10, 0x60ffc13, 0, 0, maruchan_speedup_r );
14671385
1468   DRIVER_INIT_CALL(ic13);
1386   DRIVER_INIT_CALL(stv);
14691387
14701388   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
14711389}
r3485r3486
14851403
14861404   memory_install_read32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0606c398, 0x0606c39b, 0, 0, pblbeach_speedup_r );
14871405
1488   DRIVER_INIT_CALL(ic13);
1406   DRIVER_INIT_CALL(stv);
14891407}
14901408
14911409static READ32_HANDLER( shanhigw_speedup_r )
r3485r3486
15831501DRIVER_INIT(decathlt)
15841502{
15851503   install_decathlt_protection(machine);
1586   DRIVER_INIT_CALL(ic13);
1504   DRIVER_INIT_CALL(stv);
15871505}
15881506
15891507static READ32_HANDLER( nameclv3_speedup_r )
src/mame/drivers/psattack.c
r0r3486
1/*
2    P's Attack
3    using VRender0 System on a Chip
4
5    This is basically the same hardware as Crystal System, but with a CF card for the game
6
7    Skeleton driver only
8
9
10P's Attack (c) 2004 Uniana Co., Ltd
11
12+----------1||||---1|||||--1|||||---------------------------+
13|VOL       TICKET  GUN_1P  GUN_2P                 +---------|
14|                                                 |         |
15+-+                                               |  256MB  |
16  |       CC-DAC                                  | Compact |
17+-+                                  EMUL*        |  Flash  |
18|                                                 |         |
19|J          +---+                                 +---------|
20|A          |   |                                           |
21|M          | R |   25.1750MHz              +--------------+|
22|M          | A |                           |     42Pin*   ||
23|A          | M |                           +--------------+|
24|           |   |                           +--------------+|
25|C          +---+       +------------+      |     SYS      ||
26|O                      |            |      +--------------+|
27|N          +---+       |            |                      |
28|N          |   |       |VRenderZERO+|                      |
29|E SERVICE  | R |       | MagicEyes  |  +-------+    62256* |
30|C          | A |       |            |  |  RAM  |           |
31|T TEST     | M |       |            |  +-------+    62256* |
32|O          |   |       +------------+                      |
33|R RESET    +---+                                           |
34|                                   14.31818MHz             |
35+-+                                                         |
36  |                                EEPROM                   |
37+-+                GAL                                 DSW  |
38|                                                           |
39|  VGA                           PIC               BAT3.6V* |
40+-----------------------------------------------------------+
41
42* denotes unpopulated device
43
44RAM are Samsung K4S641632H-TC75
45VGA is a standard PC 15 pin VGA connection
46DSW is 2 switch dipswitch (switches 3-8 are unpopulated)
47PIC is a Microchip PIC16C711-041/P (silkscreened on the PCB as COSTOM)
48SYS is a ST M27C160 EPROM (silkscreened on the PCB as SYSTEM_ROM_32M)
49GAL is a GAL16V8B (not dumped)
50EMUL is an unpopulated 8 pin connector
51EEPROM is a 93C86 16K 5.0v Serial EEPROM (2048x8-bit or 1024x16-bit)
52CC-DAC is a TDA1311A Stereo Continuous Calibration DAC
53
54TICKET is a 5 pin connector:
55
56  1| +12v
57  2| IN
58  3| OUT
59  4| GND
60  5| LED
61
62GUN_xP are 6 pin gun connectors (pins 1-4 match the UNICO sytle guns):
63
64  1| GND
65  2| SW
66  3| +5v
67  4| SENS
68  5| SOL
69  6| GND
70
71
72*/
73
74#include "driver.h"
75#include "cpu/se3208/se3208.h"
76#include "video/vrender0.h"
77#include "machine/ds1302.h"
78#include "sound/vrender0.h"
79
80static READ32_HANDLER( psattack_unk_r )
81{
82   return 0xffffffff;
83}
84
85static ADDRESS_MAP_START( psattack_mem, ADDRESS_SPACE_PROGRAM, 32 )
86   AM_RANGE(0x00000000, 0x001fffff) AM_ROM
87   AM_RANGE(0x01402204, 0x01402207) AM_READ(psattack_unk_r)
88   AM_RANGE(0x01402804, 0x01402807) AM_READ(psattack_unk_r)
89
90
91   AM_RANGE(0x02000000, 0x027fffff) AM_RAM
92ADDRESS_MAP_END
93
94
95static MACHINE_START(psattack)
96{
97
98}
99
100static MACHINE_RESET(psattack)
101{
102
103}
104
105static VIDEO_START(psattack)
106{
107
108}
109
110
111static VIDEO_UPDATE(psattack)
112{
113   return 0;
114}
115
116static VIDEO_EOF(psattack)
117{
118
119}
120
121static INTERRUPT_GEN(psattack_interrupt)
122{
123
124}
125
126static INPUT_PORTS_START(psattack)
127   PORT_START("Unknown")
128   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
129   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
130   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
131   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
132   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
133   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
134   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
135   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
136   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
137   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
138   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
139   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
140   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
141   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
142   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
143   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
144   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
145   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
146   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
147   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
148   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
149   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
150   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
151   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
152INPUT_PORTS_END
153
154static const vr0_interface vr0_config =
155{
156   0x04800000
157};
158
159
160static MACHINE_DRIVER_START( psattack )
161   MDRV_CPU_ADD("main", SE3208, 43000000)
162   MDRV_CPU_PROGRAM_MAP(psattack_mem,0)
163    MDRV_CPU_VBLANK_INT("main", psattack_interrupt)
164
165   MDRV_MACHINE_START(psattack)
166   MDRV_MACHINE_RESET(psattack)
167
168   //MDRV_NVRAM_HANDLER(generic_0fill)
169
170   MDRV_SCREEN_ADD("main", RASTER)
171   MDRV_SCREEN_REFRESH_RATE(60)
172   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
173   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
174   MDRV_SCREEN_SIZE(320, 240)
175   MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 239)
176
177   MDRV_VIDEO_START(psattack)
178   MDRV_VIDEO_UPDATE(psattack)
179   MDRV_VIDEO_EOF(psattack)
180
181   MDRV_PALETTE_INIT(RRRRR_GGGGGG_BBBBB)
182   MDRV_PALETTE_LENGTH(65536)
183
184   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
185
186   MDRV_SOUND_ADD("vrender", VRENDER0, 0)
187   MDRV_SOUND_CONFIG(vr0_config)
188   MDRV_SOUND_ROUTE(0, "left", 1.0)
189   MDRV_SOUND_ROUTE(1, "right", 1.0)
190MACHINE_DRIVER_END
191
192
193ROM_START( psattack )
194   ROM_REGION( 0x200000, "main", 0 )
195   ROM_LOAD("5.sys",  0x000000, 0x200000, CRC(f09878e4) SHA1(25b8dbac47d3911615c8874746e420ece13e7181) )
196
197   ROM_REGION( 0x4010, "pic16c711", 0 )
198   ROM_LOAD("16c711.pic",  0x0000, 0x137b, CRC(617d8292) SHA1(d32d6054ce9db2e31efaf41015afcc78ed32f6aa) ) // raw dump
199   ROM_LOAD("16c711.bin",  0x0000, 0x4010, CRC(b316693f) SHA1(eba1f75043bd415268eedfdb95c475e73c14ff86) ) // converted to binary
200
201   DISK_REGION( "cfcard" )
202   DISK_IMAGE_READONLY( "psattack", 0, SHA1(5faa2525b159d3107d516e1d73a24bf689ffac92) MD5(880d79cffca06cd71e7e29746dd83970) )
203ROM_END
204
205
206
207static DRIVER_INIT(psattack)
208{
209
210}
211
212GAME( 2004, psattack, 0, psattack, psattack, psattack, ROT0, "Uniana", "P's Attack", GAME_NOT_WORKING )
213
src/mame/drivers/fastlane.c
r3485r3486
55Driver by Manuel Abadia <manu@teleline.es>
66
77TODO:
8- is the game playable? How do you end a level?
98- colors don't seem 100% accurate.
109- verify that sound is correct (volume and bank switching)
1110
src/mame/drivers/segas16b.c
r3485r3486
17961796 *
17971797 *************************************/
17981798
1799static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
1799static ADDRESS_MAP_START( mcu_io_map, ADDRESS_SPACE_IO, 8 )
18001800   ADDRESS_MAP_UNMAP_HIGH
1801   AM_RANGE(0x0000, 0x0fff) AM_ROM
1801   AM_RANGE(0x0000, 0x001f) AM_MIRROR(0xff00) AM_READWRITE(segaic16_memory_mapper_r, segaic16_memory_mapper_w)
18021802ADDRESS_MAP_END
18031803
1804static ADDRESS_MAP_START( mcu_data_map, ADDRESS_SPACE_DATA, 8 )
1805   ADDRESS_MAP_UNMAP_HIGH
1806   AM_RANGE(0x0000, 0x001f) AM_READWRITE(segaic16_memory_mapper_r, segaic16_memory_mapper_w)
1807ADDRESS_MAP_END
18081804
18091805
1810
18111806/*************************************
18121807 *
18131808 *  Generic port definitions
r3485r3486
32823277   MDRV_CPU_VBLANK_INT("main", i8751_main_cpu_vblank)
32833278
32843279   MDRV_CPU_ADD("mcu", I8751, MASTER_CLOCK_8MHz)
3285   MDRV_CPU_PROGRAM_MAP(mcu_map,0)
3286   MDRV_CPU_DATA_MAP(mcu_data_map,0)
3280   MDRV_CPU_IO_MAP(mcu_io_map,0)
32873281   MDRV_CPU_VBLANK_INT("main", irq0_line_pulse)
32883282MACHINE_DRIVER_END
32893283
src/mame/drivers/fuukifg2.c
r3485r3486
3030
3131- The scroll values are generally wrong when flip screen is on and rasters are often incorrect
3232
33- gogomile M6295 banking is incorrect (the story sequence should have speech)
34
3335***************************************************************************/
3436
3537#include "driver.h"
r3485r3486
425427            also used for water effects and titlescreen linescroll on gogomile
426428*/
427429
428static TIMER_CALLBACK( irq_off )
429{
430   cpunum_set_input_line(machine, 0, param, CLEAR_LINE);
431}
432
433430static TIMER_CALLBACK( level_1_interrupt_callback )
434431{
435   cpunum_set_input_line(machine, 0, 1, ASSERT_LINE);
436   timer_set(ATTOTIME_IN_USEC(1), NULL, 1, irq_off);
432   cpunum_set_input_line(machine, 0, 1, HOLD_LINE);
437433   timer_set(video_screen_get_time_until_pos(machine->primary_screen, 248, 0), NULL, 0, level_1_interrupt_callback);
438434}
439435
440436
441437static TIMER_CALLBACK( vblank_interrupt_callback )
442438{
443   cpunum_set_input_line(machine, 0, 3, ASSERT_LINE);   // VBlank IRQ
444   timer_set(ATTOTIME_IN_USEC(1), NULL, 3, irq_off);
439   cpunum_set_input_line(machine, 0, 3, HOLD_LINE);   // VBlank IRQ
445440   timer_set(video_screen_get_time_until_vblank_start(machine->primary_screen), NULL, 0, vblank_interrupt_callback);
446441}
447442
448443
449444static TIMER_CALLBACK( raster_interrupt_callback )
450445{
451   cpunum_set_input_line(machine, 0, 5, ASSERT_LINE);   // Raster Line IRQ
452   timer_set(ATTOTIME_IN_USEC(1), NULL, 5, irq_off);
446   cpunum_set_input_line(machine, 0, 5, HOLD_LINE);   // Raster Line IRQ
453447   video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen));
454448   timer_adjust_oneshot(raster_interrupt_timer, video_screen_get_frame_period(machine->primary_screen), 0);
455449}
r3485r3486
689683
690684***************************************************************************/
691685
692GAME( 1995, gogomile, 0,        fuuki16, gogomile, 0, ROT0, "Fuuki", "Go Go! Mile Smile", 0 )
693GAME( 1995, gogomilj, gogomile, fuuki16, gogomilj, 0, ROT0, "Fuuki", "Susume! Mile Smile (Japan)", 0 )
686GAME( 1995, gogomile, 0,        fuuki16, gogomile, 0, ROT0, "Fuuki", "Go Go! Mile Smile", GAME_IMPERFECT_SOUND )
687GAME( 1995, gogomilj, gogomile, fuuki16, gogomilj, 0, ROT0, "Fuuki", "Susume! Mile Smile (Japan)", GAME_IMPERFECT_SOUND )
694688GAME( 1996, pbancho,  0,        fuuki16, pbancho,  0, ROT0, "Fuuki", "Gyakuten!! Puzzle Bancho (Japan)", 0)
695689
src/mame/drivers/shangha3.c
r3485r3486
9999   }
100100}
101101
102static WRITE16_HANDLER( blocken_coinctrl_w )
103{
104   if (ACCESSING_BITS_0_7)
105   {
106      /* the sound ROM bank is selected by the main CPU! */
107      okim6295_set_bank_base(0, ((data >> 4) & 3) * 0x40000);
102108
109      coin_lockout_w(0,~data & 0x04);
110      coin_lockout_w(1,~data & 0x04);
111      coin_counter_w(0,data & 0x01);
112      coin_counter_w(1,data & 0x02);
113   }
114}
115
116
103117static WRITE16_HANDLER( heberpop_sound_command_w )
104118{
105119   if (ACCESSING_BITS_0_7)
r3485r3486
174188   AM_RANGE(0x000000, 0x0fffff) AM_WRITE(SMH_ROM)
175189   AM_RANGE(0x100008, 0x100009) AM_WRITE(shangha3_blitter_go_w)
176190   AM_RANGE(0x10000a, 0x10000b) AM_WRITE(SMH_NOP)   /* irq ack? */
177   AM_RANGE(0x10000c, 0x10000d) AM_WRITE(heberpop_coinctrl_w)
191   AM_RANGE(0x10000c, 0x10000d) AM_WRITE(blocken_coinctrl_w)
178192   AM_RANGE(0x10000e, 0x10000f) AM_WRITE(heberpop_sound_command_w)
179193   AM_RANGE(0x200000, 0x200fff) AM_WRITE(paletteram16_RRRRRGGGGGBBBBBx_word_w) AM_BASE(&paletteram16)
180194   AM_RANGE(0x300000, 0x30ffff) AM_WRITE(SMH_RAM) AM_BASE(&shangha3_ram) AM_SIZE(&shangha3_ram_size)   /* gfx & work ram */
r3485r3486
664678   ROM_LOAD( "ic100j.bin",   0x200000, 0x80000, CRC(a34786fd) SHA1(7d4879cbaa055c2ddbe6d20dd946bf0e3e069d4d) )
665679   /* 280000-37ffff empty */
666680
667   ROM_REGION( 0x80000, "oki", 0 )   /* samples for M6295 */
668   ROM_LOAD( "ic53.bin",     0x0000, 0x80000, CRC(86108c56) SHA1(aa405fa2eec5cc178ef6226f229a12dac09504f0) )
681   ROM_REGION( 0x80000, "samples", 0 )   /* samples for M6295 */
682    ROM_LOAD( "ic53.bin",     0x0000, 0x80000, CRC(86108c56) SHA1(aa405fa2eec5cc178ef6226f229a12dac09504f0) )
683
684   ROM_REGION( 0x100000, "oki", 0 )
685   /* $00000-$20000 stays the same in all sound banks, */
686   /* the second half of the bank is what gets switched */
687   ROM_COPY( "samples", 0x000000, 0x000000, 0x020000)
688   ROM_COPY( "samples", 0x000000, 0x020000, 0x020000)
689   ROM_COPY( "samples", 0x000000, 0x040000, 0x020000)
690   ROM_COPY( "samples", 0x020000, 0x060000, 0x020000)
691   ROM_COPY( "samples", 0x000000, 0x080000, 0x020000)
692   ROM_COPY( "samples", 0x040000, 0x0a0000, 0x020000)
693   ROM_COPY( "samples", 0x000000, 0x0c0000, 0x020000)
694   ROM_COPY( "samples", 0x060000, 0x0e0000, 0x020000)
669695ROM_END
670696
671697
src/mame/drivers/m107.c
r3485r3486
44
55    Fire Barrel                             (c) 1993 Irem Corporation
66    Dream Soccer '94                        (c) 1994 Data East Corporation
7    Kick for the Goal                       (c) 1994 Jaleco
78    World PK Soccer                         (c) 1995 Jaleco
89
910
r3485r3486
1213    Emulation by Bryan McPhail, mish@tendril.co.uk
1314
1415
16To Do:
17  Hook up EEPROM in Kick for the Goal / World PK Soccer
18
15192008-08
1620Dip locations have been added assuming that the layout is the same as the
1721m92 boards (and earlier Irem boards). However, it would be nice to have them
r3485r3486
561565
562566ROM_START( wpksoc )
563567   ROM_REGION( 0x180000, "main", 0 ) /* v30 main cpu */
564   ROM_LOAD16_BYTE( "pkeurd.h0", 0x000001, 0x040000, CRC(b4917788) SHA1(673294c518eaf28354fa6a3058f9325c6d9ddde6) )
565   ROM_LOAD16_BYTE( "pkeurd.l0", 0x000000, 0x040000, CRC(03816bae) SHA1(832e2ec722b41d41626fec583fc11e9ff62cdaa0) )
568   ROM_LOAD16_BYTE( "pk-h0-eur-d.h0", 0x000001, 0x040000, CRC(b4917788) SHA1(673294c518eaf28354fa6a3058f9325c6d9ddde6) )
569   ROM_LOAD16_BYTE( "pk-l0-eur-d.l0", 0x000000, 0x040000, CRC(03816bae) SHA1(832e2ec722b41d41626fec583fc11e9ff62cdaa0) )
566570
567571   ROM_REGION( 0x100000, "sound", 0 )
568   ROM_LOAD16_BYTE( "pkos.sh0", 0x000001, 0x010000, CRC(1145998c) SHA1(cdb2a428e0f35302b81696dab02d3dd2c433f6e5) )
569   ROM_LOAD16_BYTE( "pkos.sl0", 0x000000, 0x010000, CRC(542ee1c7) SHA1(b934adeecbba17cf96b06a2b1dc1ceaebdf9ad10) )
572   ROM_LOAD16_BYTE( "pk-sh0.sh0", 0x000001, 0x010000, CRC(1145998c) SHA1(cdb2a428e0f35302b81696dab02d3dd2c433f6e5) )
573   ROM_LOAD16_BYTE( "pk-sl0.sl0", 0x000000, 0x010000, CRC(542ee1c7) SHA1(b934adeecbba17cf96b06a2b1dc1ceaebdf9ad10) )
570574
571575   ROM_REGION( 0x200000, "gfx1", ROMREGION_DISPOSE )   /* chars */
572   ROM_LOAD16_BYTE( "pkos.c00", 0x000000, 0x80000, CRC(42ae3d73) SHA1(e4777066155c9882695ebff0412bd879b8d6f716) )
573   ROM_LOAD16_BYTE( "pkos.c10", 0x000001, 0x80000, CRC(86acf45c) SHA1(3b3d2abcf8000161a37d5e2619df529533aea47d) )
574   ROM_LOAD16_BYTE( "pkos.c01", 0x100000, 0x80000, CRC(b0d33f87) SHA1(f2c0e3a10615c6861a3f6fd82a3f066e8e264233) )
575   ROM_LOAD16_BYTE( "pkos.c11", 0x100001, 0x80000, CRC(19de7d63) SHA1(6d0633e412b47accaecc887a5c39f542eda49e81) )
576   ROM_LOAD16_BYTE( "pk-c00-os.c00", 0x000000, 0x80000, CRC(42ae3d73) SHA1(e4777066155c9882695ebff0412bd879b8d6f716) )
577   ROM_LOAD16_BYTE( "pk-c10-os.c10", 0x000001, 0x80000, CRC(86acf45c) SHA1(3b3d2abcf8000161a37d5e2619df529533aea47d) )
578   ROM_LOAD16_BYTE( "pk-c01-os.c01", 0x100000, 0x80000, CRC(b0d33f87) SHA1(f2c0e3a10615c6861a3f6fd82a3f066e8e264233) )
579   ROM_LOAD16_BYTE( "pk-c11-os.c11", 0x100001, 0x80000, CRC(19de7d63) SHA1(6d0633e412b47accaecc887a5c39f542eda49e81) )
576580
577581   ROM_REGION( 0x400000, "gfx2", ROMREGION_DISPOSE )   /* sprites */
578   ROM_LOAD16_BYTE( "pk.000", 0x000000, 0x80000, CRC(165ce027) SHA1(3510b323c683ade4dd7307b539072bb342b6796d) )
579   ROM_LOAD16_BYTE( "pk.001", 0x000001, 0x80000, CRC(e2745147) SHA1(99026525449c2ca84e054a7d633c400e0e836461) )
580   ROM_LOAD16_BYTE( "pk.010", 0x100000, 0x80000, CRC(6c171b73) SHA1(a99c9f012f21373daea08d28554cc36170f4e1fa) )
581   ROM_LOAD16_BYTE( "pk.011", 0x100001, 0x80000, CRC(471c0bf4) SHA1(1cace5ffd5db91850662de929cb9086dc154d662) )
582   ROM_LOAD16_BYTE( "pk.020", 0x200000, 0x80000, CRC(c886dad1) SHA1(9b58a2f108547c3f55399932a7e56031c5658737) )
583   ROM_LOAD16_BYTE( "pk.021", 0x200001, 0x80000, CRC(91e877ff) SHA1(3df095632728ab16ab229d592ab12d3df44b2629) )
584   ROM_LOAD16_BYTE( "pk.030", 0x300000, 0x80000, CRC(3390621c) SHA1(4138c690666f78b1c5cf83d815ed6b37239a94b4) )
585   ROM_LOAD16_BYTE( "pk.031", 0x300001, 0x80000, CRC(4d322804) SHA1(b5e2b40e3ce83b6f97b2b57edaa79df6968d0997) )
582   ROM_LOAD16_BYTE( "pk-000.000", 0x000000, 0x80000, CRC(165ce027) SHA1(3510b323c683ade4dd7307b539072bb342b6796d) )
583   ROM_LOAD16_BYTE( "pk-001.001", 0x000001, 0x80000, CRC(e2745147) SHA1(99026525449c2ca84e054a7d633c400e0e836461) )
584   ROM_LOAD16_BYTE( "pk-010.010", 0x100000, 0x80000, CRC(6c171b73) SHA1(a99c9f012f21373daea08d28554cc36170f4e1fa) )
585   ROM_LOAD16_BYTE( "pk-011.011", 0x100001, 0x80000, CRC(471c0bf4) SHA1(1cace5ffd5db91850662de929cb9086dc154d662) )
586   ROM_LOAD16_BYTE( "pk-020.020", 0x200000, 0x80000, CRC(c886dad1) SHA1(9b58a2f108547c3f55399932a7e56031c5658737) )
587   ROM_LOAD16_BYTE( "pk-021.021", 0x200001, 0x80000, CRC(91e877ff) SHA1(3df095632728ab16ab229d592ab12d3df44b2629) )
588   ROM_LOAD16_BYTE( "pk-030.030", 0x300000, 0x80000, CRC(3390621c) SHA1(4138c690666f78b1c5cf83d815ed6b37239a94b4) )
589   ROM_LOAD16_BYTE( "pk-031.031", 0x300001, 0x80000, CRC(4d322804) SHA1(b5e2b40e3ce83b6f97b2b57edaa79df6968d0997) )
586590
587591   ROM_REGION( 0x100000, "irem", 0 )    /* ADPCM samples */
588   ROM_LOAD( "pk.da0", 0x000000, 0x80000, CRC(26a34cf4) SHA1(a8a7cd91cdc6d644ee02ca16e7fdc8debf8f3a5f) )
592   ROM_LOAD( "pk-da0.da0", 0x000000, 0x80000, CRC(26a34cf4) SHA1(a8a7cd91cdc6d644ee02ca16e7fdc8debf8f3a5f) )
589593ROM_END
590594
595ROM_START( kftgoal )
596   ROM_REGION( 0x180000, "main", 0 ) /* v30 main cpu */
597   ROM_LOAD16_BYTE( "pk-h0-usa-d.h0", 0x000001, 0x040000, CRC(aed4cde0) SHA1(2fe04bf93c353108b82a0b6017229e9b0f451b06) )
598   ROM_LOAD16_BYTE( "pk-l0-usa-d.l0", 0x000000, 0x040000, CRC(39fe30d2) SHA1(e0c117da4fe9c779dd534ee0d09685aeb5f579c6) )
599
600   ROM_REGION( 0x100000, "sound", 0 )
601   ROM_LOAD16_BYTE( "pk-sh0.sh0", 0x000001, 0x010000, CRC(1145998c) SHA1(cdb2a428e0f35302b81696dab02d3dd2c433f6e5) )
602   ROM_LOAD16_BYTE( "pk-sl0.sl0", 0x000000, 0x010000, CRC(542ee1c7) SHA1(b934adeecbba17cf96b06a2b1dc1ceaebdf9ad10) )
603
604   ROM_REGION( 0x200000, "gfx1", ROMREGION_DISPOSE )   /* chars */
605   ROM_LOAD16_BYTE( "pk-c00-os.c00", 0x000000, 0x80000, CRC(42ae3d73) SHA1(e4777066155c9882695ebff0412bd879b8d6f716) )
606   ROM_LOAD16_BYTE( "pk-c10-os.c10", 0x000001, 0x80000, CRC(86acf45c) SHA1(3b3d2abcf8000161a37d5e2619df529533aea47d) )
607   ROM_LOAD16_BYTE( "pk-c01-os.c01", 0x100000, 0x80000, CRC(b0d33f87) SHA1(f2c0e3a10615c6861a3f6fd82a3f066e8e264233) )
608   ROM_LOAD16_BYTE( "pk-c11-os.c11", 0x100001, 0x80000, CRC(19de7d63) SHA1(6d0633e412b47accaecc887a5c39f542eda49e81) )
609
610   ROM_REGION( 0x400000, "gfx2", ROMREGION_DISPOSE )   /* sprites */
611   ROM_LOAD16_BYTE( "pk-000-usa.000", 0x000000, 0x80000, CRC(72e905ab) SHA1(5f47f0db0a19311cb74c39ea9d86f6909b926aa8) )
612   ROM_LOAD16_BYTE( "pk-001-usa.001", 0x000001, 0x80000, CRC(eec4f43c) SHA1(93133389701c8752fc288f3f82da2646446804ca) )
613   ROM_LOAD16_BYTE( "pk-010-usa.010", 0x100000, 0x80000, CRC(b3339d73) SHA1(1f59591a24434cf7d754d211c1a20591c1d7234c) )
614   ROM_LOAD16_BYTE( "pk-011-usa.011", 0x100001, 0x80000, CRC(bab2b7cf) SHA1(53997c5dc204a4f510624dcdef949e859ad79d23) )
615   ROM_LOAD16_BYTE( "pk-020-usa.020", 0x200000, 0x80000, CRC(740a0bef) SHA1(89782d6d76e0cbd99047dc9a4d3c00bbab0d6bce) )
616   ROM_LOAD16_BYTE( "pk-021-usa.021", 0x200001, 0x80000, CRC(f44208a6) SHA1(e6436bacebca786de1521ce7a207aca686e312a0) )
617   ROM_LOAD16_BYTE( "pk-030-usa.030", 0x300000, 0x80000, CRC(8eceef50) SHA1(e39a2420a6259a8571a71fd3f9b003b0e0abea3b) )
618   ROM_LOAD16_BYTE( "pk-031-usa.031", 0x300001, 0x80000, CRC(8aa7dc04) SHA1(8aebdf50a832acf00fcfebb35ab49a06d13bc444) )
619
620   ROM_REGION( 0x100000, "irem", 0 )    /* ADPCM samples */
621   ROM_LOAD( "pk-da0.da0", 0x000000, 0x80000, CRC(26a34cf4) SHA1(a8a7cd91cdc6d644ee02ca16e7fdc8debf8f3a5f) )
622
623   ROM_REGION( 0x2000, "user1", 0 ) /* ST M28C64C-20PI Eeprom */
624   ROM_LOAD( "st-m28c64c.eeprom", 0x000, 0x2000, CRC(8e0c8b7c) SHA1(0b57290d709e6d54ce1bb3a5c01b80590203c1dd) )
625ROM_END
626
591627/***************************************************************************/
592628
593629static DRIVER_INIT( firebarr )
r3485r3486
635671
636672/***************************************************************************/
637673
638GAME( 1993, firebarr, 0, firebarr, firebarr, firebarr, ROT270, "Irem", "Fire Barrel (Japan)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
639GAME( 1994, dsoccr94, 0, dsoccr94, dsoccr94, dsoccr94, ROT0,   "Irem (Data East Corporation license)", "Dream Soccer '94", 0 )
640GAME( 1995, wpksoc,   0, wpksoc,   wpksoc,   wpksoc,   ROT0,   "Jaleco", "World PK Soccer", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS )
674GAME( 1993, firebarr,      0, firebarr, firebarr, firebarr, ROT270, "Irem", "Fire Barrel (Japan)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
675GAME( 1994, dsoccr94,      0, dsoccr94, dsoccr94, dsoccr94, ROT0,   "Irem (Data East Corporation license)", "Dream Soccer '94", 0 )
676GAME( 1995, wpksoc,        0, wpksoc,   wpksoc,   wpksoc,   ROT0,   "Jaleco", "World PK Soccer", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS )
677GAME( 1994, kftgoal,  wpksoc, wpksoc,   wpksoc,   wpksoc,   ROT0,   "Jaleco", "Kick for the Goal", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/megasys1.c
r3485r3486
13031303   ROM_LOAD( "2",  0x000000, 0x040000, CRC(05bc04d9) SHA1(b903edf39393cad2b4b6b58b10651304793aaa3e) )
13041304
13051305   ROM_REGION( 0x0200, "proms", 0 )      /* Priority PROM */
1306   ROM_LOAD( "ph.bin",        0x0000, 0x0200, CRC(8359650a) SHA1(97d0105f06c64340fb19a541db03481a7e0b5e05) )
1306//  ROM_LOAD( "ph.bin",        0x0000, 0x0200, CRC(8359650a) SHA1(97d0105f06c64340fb19a541db03481a7e0b5e05) )
1307   // the bootleg prom is a different format, i don't know how to use it
1308   ROM_LOAD( "82s147",        0x0000, 0x0200, CRC(547eccc0) SHA1(44dd92e899a7852d2fd937b7d45519315b8b4d4f) )
13071309ROM_END
13081310
13091311
src/mame/drivers/pacman.c
r3485r3486
553553
554554static READ8_HANDLER( maketrax_special_port2_r )
555555{
556   int data = input_port_read(machine, "IN1");
556   int data = input_port_read(machine, "DSW1");
557557   int pc = activecpu_get_previouspc();
558558
559559   if ((pc == 0x1973) || (pc == 0x2389)) return data | 0x40;
r3485r3486
596596
597597static READ8_HANDLER( korosuke_special_port2_r )
598598{
599   int data = input_port_read(machine, "IN1");
599   int data = input_port_read(machine, "DSW1");
600600   int pc = activecpu_get_previouspc();
601601
602602   if ((pc == 0x196e) || (pc == 0x2387)) return data | 0x40;
src/mame/drivers/fuukifg3.c
r3485r3486
543543
544544***************************************************************************/
545545
546static TIMER_CALLBACK( irq_off )
547{
548   cpunum_set_input_line(machine, 0, param, CLEAR_LINE);
549}
550
551546static TIMER_CALLBACK( level_1_interrupt_callback )
552547{
553   cpunum_set_input_line(machine, 0, 1, ASSERT_LINE);
554   timer_set(ATTOTIME_IN_USEC(1), NULL, 1, irq_off);
548   cpunum_set_input_line(machine, 0, 1, HOLD_LINE);
555549   timer_set(video_screen_get_time_until_pos(machine->primary_screen, 248, 0), NULL, 0, level_1_interrupt_callback);
556550}
557551
558552
559553static TIMER_CALLBACK( vblank_interrupt_callback )
560554{
561   cpunum_set_input_line(machine, 0, 3, ASSERT_LINE);   // VBlank IRQ
562   timer_set(ATTOTIME_IN_USEC(1), NULL, 3, irq_off);
555   cpunum_set_input_line(machine, 0, 3, HOLD_LINE);   // VBlank IRQ
563556   timer_set(video_screen_get_time_until_vblank_start(machine->primary_screen), NULL, 0, vblank_interrupt_callback);
564557}
565558
566559
567560static TIMER_CALLBACK( raster_interrupt_callback )
568561{
569   cpunum_set_input_line(machine, 0, 5, ASSERT_LINE);   // Raster Line IRQ
570   timer_set(ATTOTIME_IN_USEC(1), NULL, 5, irq_off);
562   cpunum_set_input_line(machine, 0, 5, HOLD_LINE);   // Raster Line IRQ
571563   video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen));
572564   timer_adjust_oneshot(raster_interrupt_timer, video_screen_get_frame_period(machine->primary_screen), 0);
573565}
src/mame/drivers/cubeqst.c
r3485r3486
479479   MDRV_CPU_PROGRAM_MAP(line_sound_map, 0)
480480   MDRV_CPU_CONFIG(snd_config)
481481
482   MDRV_INTERLEAVE(700)
482   MDRV_INTERLEAVE(800)
483483
484484   MDRV_MACHINE_START(cubeqst)
485485   MDRV_MACHINE_RESET(cubeqst)
src/mame/drivers/segas18.c
r3485r3486
629629 *
630630 *************************************/
631631
632static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
632static ADDRESS_MAP_START( mcu_io_map, ADDRESS_SPACE_IO, 8 )
633633   ADDRESS_MAP_UNMAP_HIGH
634   AM_RANGE(0x0000, 0x0fff) AM_ROM
634   /* port 2 not used for high order address byte */
635   AM_RANGE(0x0000, 0x001f) AM_MIRROR(0xff00) AM_READWRITE(segaic16_memory_mapper_r, segaic16_memory_mapper_w)
635636ADDRESS_MAP_END
636637
637static ADDRESS_MAP_START( mcu_data_map, ADDRESS_SPACE_DATA, 8 )
638   ADDRESS_MAP_UNMAP_HIGH
639   AM_RANGE(0x0000, 0x001f) AM_READWRITE(segaic16_memory_mapper_r, segaic16_memory_mapper_w)
640ADDRESS_MAP_END
641638
642639
643
644640/*************************************
645641 *
646642 *  Generic port definitions
r3485r3486
13101306   MDRV_CPU_VBLANK_INT_HACK(NULL,0)
13111307
13121308   MDRV_CPU_ADD("mcu", I8751, 8000000)
1313   MDRV_CPU_PROGRAM_MAP(mcu_map,0)
1314   MDRV_CPU_DATA_MAP(mcu_data_map,0)
1309   MDRV_CPU_IO_MAP(mcu_io_map,0)
13151310   MDRV_CPU_VBLANK_INT("main", irq0_line_pulse)
13161311MACHINE_DRIVER_END
13171312
src/emu/romload.h
r3485r3486
251251#define ROM_LOAD32_WORD_SWAP(name,offset,length,hash) ROMX_LOAD(name, offset, length, hash, ROM_GROUPWORD | ROM_REVERSE | ROM_SKIP(2))
252252#define ROM_LOAD32_DWORD(name,offset,length,hash)   ROMX_LOAD(name, offset, length, hash, ROM_GROUPDWORD)
253253
254/* ----- ROM_RELOAD related macros ----- */
255#define ROM_RELOAD(offset,length)               { NULL, NULL, offset, length, ROMENTRYTYPE_RELOAD | ROM_INHERITFLAGS },
256#define ROM_RELOAD_PLAIN(offset,length)               { NULL, NULL, offset, length, ROMENTRYTYPE_RELOAD },
254257
255258/* ----- additional ROM-related macros ----- */
256259#define ROM_CONTINUE(offset,length)               { NULL, NULL, offset, length, ROMENTRYTYPE_CONTINUE | ROM_INHERITFLAGS },
257#define ROM_RELOAD(offset,length)               { NULL, NULL, offset, length, ROMENTRYTYPE_RELOAD | ROM_INHERITFLAGS },
258260#define ROM_IGNORE(length)                     { NULL, NULL, 0,      length, ROMENTRYTYPE_IGNORE | ROM_INHERITFLAGS },
259261#define ROM_FILL(offset,length,value)            { NULL, (const char *)value, offset, length, ROMENTRYTYPE_FILL },
260262#define ROM_COPY(srctag,srcoffs,offset,length)       { srctag, (const char *)srcoffs, offset, length, ROMENTRYTYPE_COPY },
src/emu/cpu/m68000/m68k_in.c
r3485r3486
12621262M68KMAKE_OP(adda, 32, ., .)
12631263{
12641264   uint* r_dst = &AX;
1265   uint src = M68KMAKE_GET_OPER_AY_32;
12651266
1266   *r_dst = MASK_OUT_ABOVE_32(*r_dst + M68KMAKE_GET_OPER_AY_32);
1267   *r_dst = MASK_OUT_ABOVE_32(*r_dst + src);
12671268}
12681269
12691270
r3485r3486
97859786M68KMAKE_OP(suba, 32, ., .)
97869787{
97879788   uint* r_dst = &AX;
9789   uint src = M68KMAKE_GET_OPER_AY_32;
97889790
9789   *r_dst = MASK_OUT_ABOVE_32(*r_dst - M68KMAKE_GET_OPER_AY_32);
9791   *r_dst = MASK_OUT_ABOVE_32(*r_dst - src);
97909792}
97919793
97929794
src/emu/cpu/cpu.mak
r3485r3486
650650# Intel 8051 and derivatives
651651#-------------------------------------------------
652652
653CPUDEFS += -DHAS_I8031=$(if $(filter I8031,$(CPUS)),1,0)
654CPUDEFS += -DHAS_I8032=$(if $(filter I8032,$(CPUS)),1,0)
653655CPUDEFS += -DHAS_I8051=$(if $(filter I8051,$(CPUS)),1,0)
654656CPUDEFS += -DHAS_I8052=$(if $(filter I8052,$(CPUS)),1,0)
655657CPUDEFS += -DHAS_I8751=$(if $(filter I8751,$(CPUS)),1,0)
656658CPUDEFS += -DHAS_I8752=$(if $(filter I8752,$(CPUS)),1,0)
659CPUDEFS += -DHAS_I80C31=$(if $(filter I80C31,$(CPUS)),1,0)
660CPUDEFS += -DHAS_I80C32=$(if $(filter I80C32,$(CPUS)),1,0)
661CPUDEFS += -DHAS_I80C51=$(if $(filter I80C51,$(CPUS)),1,0)
662CPUDEFS += -DHAS_I80C52=$(if $(filter I80C52,$(CPUS)),1,0)
663CPUDEFS += -DHAS_I87C51=$(if $(filter I87C51,$(CPUS)),1,0)
664CPUDEFS += -DHAS_I87C52=$(if $(filter I87C52,$(CPUS)),1,0)
665CPUDEFS += -DHAS_AT89C4051=$(if $(filter AT89C4051,$(CPUS)),1,0)
657666
658ifneq ($(filter I8051 I8052 I8751 I8752,$(CPUS)),)
667ifneq ($(filter I8031 I8032 I8051 I8052 I8751 I8752 I80C31 I80C32 I80C51 I80C52 I87C51 I87C52 AT89C4051,$(CPUS)),)
659668OBJDIRS += $(CPUOBJ)/i8051
660669CPUOBJS += $(CPUOBJ)/i8051/i8051.o
661670DBGOBJS += $(CPUOBJ)/i8051/8051dasm.o
src/emu/cpu/cubeqcpu/cubeqcpu.c
r3485r3486
341341
342342   memset(&cquestsnd, 0, sizeof(cquestsnd));
343343
344   cquestsnd_state_register(index, "cquestsnd");
345
346344   cquestsnd.dac_w = _config->dac_w;
347345   cquestsnd.sound_data = (UINT16*)memory_region(Machine, _config->sound_data_region);
348346
349347   /* Allocate RAM shared with 68000 */
350348   cquestsnd.sram = malloc(4096);
349
350   cquestsnd_state_register(index, "cquestsnd");
351351}
352352
353353
r3485r3486
407407{
408408   memset(&cquestrot, 0, sizeof(cquestrot));
409409
410   cquestrot_state_register(index, "cquestrot");
411
412410   /* Allocate RAM */
413411   cquestrot.dram = malloc(16384 * sizeof(UINT16));  /* Shared with 68000 */
414412   cquestrot.sram = malloc(2048 * sizeof(UINT16));   /* Private */
413
414   cquestrot_state_register(index, "cquestrot");
415415}
416416
417417
r3485r3486
483483{
484484   memset(&cquestlin, 0, sizeof(cquestlin));
485485
486   cquestlin_state_register(index, "cquestlin");
487
488486   /* Allocate RAM */
489487   cquestlin.sram = malloc(4096 * sizeof(UINT16));      /* Shared with rotate CPU */
490488   cquestlin.ptr_ram = malloc(1024);                    /* Pointer RAM */
491489   cquestlin.e_stack = malloc(32768 * sizeof(UINT32));  /* Stack DRAM: 32kx20 */
492490   cquestlin.o_stack = malloc(32768 * sizeof(UINT32));  /* Stack DRAM: 32kx20 */
491
492   cquestlin_state_register(index, "cquestlin");
493493}
494494
495495
src/emu/cpu/dsp56k/dsp56mem.c
r3485r3486
3131/* Work */
3232static READ16_HANDLER( peripheral_register_r )
3333{
34   logerror("Peripheral read 0x%04x\n", O2A(offset));
34   // (printf) logerror("Peripheral read 0x%04x\n", O2A(offset));
3535
3636   switch (O2A(offset))
3737   {
r3485r3486
168168   // Its primary behavior is RAM
169169   // COMBINE_DATA(&dsp56k_peripheral_ram[offset]);
170170
171   logerror("Peripheral write 0x%04x = %04x\n", O2A(offset), data);
171   // (printf) logerror("Peripheral write 0x%04x = %04x\n", O2A(offset), data);
172172
173173   // 4-8
174174   switch (O2A(offset))
r3485r3486
929929   external_x_wait_states_set(0x1f);
930930   external_p_wait_states_set(0x1f);
931931}
932
933
934/* MISC*/
935UINT16 dsp56k_get_peripheral_memory(UINT16 addr)
936{
937   return dsp56k_peripheral_ram[A2O(addr)];
938}
src/emu/cpu/dsp56k/dsp56ops.c
r3485r3486
1515//
1616//
1717
18// Helper functions and macros
19#define BITS(CUR,MASK) (Dsp56kOpMask(CUR,MASK))
20static UINT16 Dsp56kOpMask(UINT16 op, UINT16 mask) ;
18/************************/
19/* Datatypes and macros */
20/************************/
21enum dataType { DT_BYTE,
22            DT_WORD,
23            DT_DOUBLE_WORD,
24            DT_LONG_WORD };
2125
22enum dataType { DT_BYTE, DT_WORD, DT_DOUBLE_WORD, DT_LONG_WORD } ;
26struct _typed_pointer
27{
28   void* addr;
29   char  data_type;
30};
31typedef struct _typed_pointer typed_pointer;
2332
24// This function's areguments are written source->destination to fall in line with the processor's paradigm...
25static void SetDestinationValue(void *sourcePointer, unsigned char sourceType,
26                        void *destinationPointer, unsigned char destinationType) ;
2733
28static void SetDataMemoryValue   (void *sourcePointer, unsigned char sourceType, UINT32 destinationAddr) ;
29static void SetProgramMemoryValue(void *sourcePointer, unsigned char sourceType, UINT32 destinationAddr) ;
34#define WORD(X) (X<<1)
35#define BITS(CUR,MASK) (Dsp56kOpMask(CUR,MASK))
3036
3137
32// Main opcode categories
33static unsigned ExecuteDataALUOpcode(int parallelType) ;
34static unsigned ExecuteDXMDROpcode(void) ;
35static unsigned ExecuteNPMOpcode(void) ;
36static unsigned ExecuteMisfitOpcode(void) ;
37static unsigned ExecuteSpecialOpcode(void) ;
3838
39/*********************/
40/* Opcode prototypes */
41/*********************/
42static size_t dsp56k_op_add_2    (const UINT16 op_byte, UINT8* cycles);
43static size_t dsp56k_op_mac_1    (const UINT16 op_byte, UINT8* cycles);
44static size_t dsp56k_op_macr_1    (const UINT16 op_byte, UINT8* cycles);
45static size_t dsp56k_op_move_1    (const UINT16 op_byte, UINT8* cycles);
46static size_t dsp56k_op_mpy_1    (const UINT16 op_byte, UINT8* cycles);
47static size_t dsp56k_op_mpyr_1    (const UINT16 op_byte, UINT8* cycles);
48static size_t dsp56k_op_sub_1    (const UINT16 op_byte, UINT8* cycles);
49static size_t dsp56k_op_tfr_2    (const UINT16 op_byte, UINT8* cycles);
50static size_t dsp56k_op_mpy_2    (const UINT16 op_byte, UINT8* cycles);
51static size_t dsp56k_op_mac_2    (const UINT16 op_byte, UINT8* cycles);
52static size_t dsp56k_op_clr       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
53static size_t dsp56k_op_add       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
54static size_t dsp56k_op_move    (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
55static size_t dsp56k_op_tfr       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
56static size_t dsp56k_op_rnd       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
57static size_t dsp56k_op_tst       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
58static size_t dsp56k_op_inc       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
59static size_t dsp56k_op_inc24    (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
60static size_t dsp56k_op_or       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
61static size_t dsp56k_op_asr       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
62static size_t dsp56k_op_asl       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
63static size_t dsp56k_op_lsr       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
64static size_t dsp56k_op_lsl       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
65static size_t dsp56k_op_eor       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
66static size_t dsp56k_op_subl    (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
67static size_t dsp56k_op_sub       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
68static size_t dsp56k_op_clr24    (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
69static size_t dsp56k_op_sbc       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
70static size_t dsp56k_op_cmp       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
71static size_t dsp56k_op_neg       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
72static size_t dsp56k_op_not       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
73static size_t dsp56k_op_dec       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
74static size_t dsp56k_op_dec24    (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
75static size_t dsp56k_op_and       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
76static size_t dsp56k_op_abs       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
77static size_t dsp56k_op_ror       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
78static size_t dsp56k_op_rol       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
79static size_t dsp56k_op_cmpm    (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
80static size_t dsp56k_op_mpy       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
81static size_t dsp56k_op_mpyr    (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
82static size_t dsp56k_op_mac       (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
83static size_t dsp56k_op_macr    (const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles);
84static size_t dsp56k_op_adc       (const UINT16 op, UINT8* cycles);
85static size_t dsp56k_op_andi    (const UINT16 op, UINT8* cycles);
86static size_t dsp56k_op_asl4    (const UINT16 op, UINT8* cycles);
87static size_t dsp56k_op_asr4    (const UINT16 op, UINT8* cycles);
88static size_t dsp56k_op_asr16    (const UINT16 op, UINT8* cycles);
89static size_t dsp56k_op_bfop    (const UINT16 op, const UINT16 op2, UINT8* cycles);
90static size_t dsp56k_op_bfop_1    (const UINT16 op, const UINT16 op2, UINT8* cycles);
91static size_t dsp56k_op_bfop_2    (const UINT16 op, const UINT16 op2, UINT8* cycles);
92static size_t dsp56k_op_bcc       (const UINT16 op, const UINT16 op2, UINT8* cycles);
93static size_t dsp56k_op_bcc_1    (const UINT16 op, UINT8* cycles);
94static size_t dsp56k_op_bcc_2    (const UINT16 op, UINT8* cycles);
95static size_t dsp56k_op_bra       (const UINT16 op, const UINT16 op2, UINT8* cycles);
96static size_t dsp56k_op_bra_1    (const UINT16 op, UINT8* cycles);
97static size_t dsp56k_op_bra_2    (const UINT16 op, UINT8* cycles);
98static size_t dsp56k_op_brkc    (const UINT16 op, UINT8* cycles);
99static size_t dsp56k_op_bscc    (const UINT16 op, const UINT16 op2, UINT8* cycles);
100static size_t dsp56k_op_bscc_1    (const UINT16 op, UINT8* cycles);
101static size_t dsp56k_op_bsr       (const UINT16 op, const UINT16 op2, UINT8* cycles);
102static size_t dsp56k_op_bsr_1    (const UINT16 op, UINT8* cycles);
103static size_t dsp56k_op_chkaau    (const UINT16 op, UINT8* cycles);
104static size_t dsp56k_op_debug    (const UINT16 op, UINT8* cycles);
105static size_t dsp56k_op_debugcc    (const UINT16 op, UINT8* cycles);
106static size_t dsp56k_op_div       (const UINT16 op, UINT8* cycles);
107static size_t dsp56k_op_dmac    (const UINT16 op, UINT8* cycles);
108static size_t dsp56k_op_do       (const UINT16 op, const UINT16 op2, UINT8* cycles);
109static size_t dsp56k_op_do_1    (const UINT16 op, const UINT16 op2, UINT8* cycles);
110static size_t dsp56k_op_do_2    (const UINT16 op, const UINT16 op2, UINT8* cycles);
111static size_t dsp56k_op_doforever(const UINT16 op, const UINT16 op2, UINT8* cycles);
112static size_t dsp56k_op_enddo    (const UINT16 op, UINT8* cycles);
113static size_t dsp56k_op_ext       (const UINT16 op, UINT8* cycles);
114static size_t dsp56k_op_illegal    (const UINT16 op, UINT8* cycles);
115static size_t dsp56k_op_imac    (const UINT16 op, UINT8* cycles);
116static size_t dsp56k_op_impy    (const UINT16 op, UINT8* cycles);
117static size_t dsp56k_op_jcc       (const UINT16 op, const UINT16 op2, UINT8* cycles);
118static size_t dsp56k_op_jcc_1    (const UINT16 op, UINT8* cycles);
119static size_t dsp56k_op_jmp       (const UINT16 op, const UINT16 op2, UINT8* cycles);
120static size_t dsp56k_op_jmp_1    (const UINT16 op, UINT8* cycles);
121static size_t dsp56k_op_jscc    (const UINT16 op, const UINT16 op2, UINT8* cycles);
122static size_t dsp56k_op_jscc_1    (const UINT16 op, UINT8* cycles);
123static size_t dsp56k_op_jsr       (const UINT16 op, const UINT16 op2, UINT8* cycles);
124static size_t dsp56k_op_jsr_1    (const UINT16 op, UINT8* cycles);
125static size_t dsp56k_op_jsr_2    (const UINT16 op, UINT8* cycles);
126static size_t dsp56k_op_lea       (const UINT16 op, UINT8* cycles);
127static size_t dsp56k_op_lea_1    (const UINT16 op, UINT8* cycles);
128static size_t dsp56k_op_macsuuu    (const UINT16 op, UINT8* cycles);
129static size_t dsp56k_op_move_2    (const UINT16 op, const UINT16 op2, UINT8* cycles);
130static size_t dsp56k_op_movec    (const UINT16 op, UINT8* cycles);
131static size_t dsp56k_op_movec_1    (const UINT16 op, UINT8* cycles);
132static size_t dsp56k_op_movec_2    (const UINT16 op, UINT8* cycles);
133static size_t dsp56k_op_movec_3    (const UINT16 op, const UINT16 op2, UINT8* cycles);
134static size_t dsp56k_op_movec_4    (const UINT16 op, UINT8* cycles);
135static size_t dsp56k_op_movec_5    (const UINT16 op, const UINT16 op2, UINT8* cycles);
136static size_t dsp56k_op_movei    (const UINT16 op, UINT8* cycles);
137static size_t dsp56k_op_movem    (const UINT16 op, UINT8* cycles);
138static size_t dsp56k_op_movem_1    (const UINT16 op, UINT8* cycles);
139static size_t dsp56k_op_movem_2    (const UINT16 op, const UINT16 op2, UINT8* cycles);
140static size_t dsp56k_op_movep    (const UINT16 op, UINT8* cycles);
141static size_t dsp56k_op_movep_1    (const UINT16 op, UINT8* cycles);
142static size_t dsp56k_op_moves    (const UINT16 op, UINT8* cycles);
143static size_t dsp56k_op_mpysuuu    (const UINT16 op, UINT8* cycles);
144static size_t dsp56k_op_negc    (const UINT16 op, UINT8* cycles);
145static size_t dsp56k_op_nop       (const UINT16 op, UINT8* cycles);
146static size_t dsp56k_op_norm    (const UINT16 op, UINT8* cycles);
147static size_t dsp56k_op_ori       (const UINT16 op, UINT8* cycles);
148static size_t dsp56k_op_rep       (const UINT16 op, UINT8* cycles);
149static size_t dsp56k_op_rep_1    (const UINT16 op, UINT8* cycles);
150static size_t dsp56k_op_rep_2    (const UINT16 op, UINT8* cycles);
151static size_t dsp56k_op_repcc    (const UINT16 op, UINT8* cycles);
152static size_t dsp56k_op_reset    (const UINT16 op, UINT8* cycles);
153static size_t dsp56k_op_rti       (const UINT16 op, UINT8* cycles);
154static size_t dsp56k_op_rts       (const UINT16 op, UINT8* cycles);
155static size_t dsp56k_op_stop    (const UINT16 op, UINT8* cycles);
156static size_t dsp56k_op_swap    (const UINT16 op, UINT8* cycles);
157static size_t dsp56k_op_swi       (const UINT16 op, UINT8* cycles);
158static size_t dsp56k_op_tcc       (const UINT16 op, UINT8* cycles);
159static size_t dsp56k_op_tfr2    (const UINT16 op, UINT8* cycles);
160static size_t dsp56k_op_tfr3    (const UINT16 op, UINT8* cycles);
161static size_t dsp56k_op_tst2    (const UINT16 op, UINT8* cycles);
162static size_t dsp56k_op_wait    (const UINT16 op, UINT8* cycles);
163static size_t dsp56k_op_zero    (const UINT16 op, UINT8* cycles);
39164
40// Actual opcode implementations
41165
42// Data ALU Ops
43static int ClrOperation(void **wd, UINT64 *pa) ;
44static int AddOperation(void **wd, UINT64 *pa) ;
45static int NotOperation(void **wd, UINT64 *pa) ;
46static int LsrOperation(void **wd, UINT64 *pa) ;
47static int AsrOperation(void **wd, UINT64 *pa) ;
48static int TfrDataALUOperation(void **wd, UINT64 *pa) ;
49static int EorOperation(void **wd, UINT64 *pa) ;
50static int CmpOperation(void **wd, UINT64 *pa) ;
51static int Dec24Operation(void **wd, UINT64 *pa) ;
52static int AndOperation(void **wd, UINT64 *pa) ;
53static int OrOperation(void **wd, UINT64 *pa) ;
54static int TstOperation(void **wd, UINT64 *pa) ;
166static void execute_register_to_register_data_move(const UINT16 op, typed_pointer* d_register, UINT64* prev_accum_value);
167static void execute_x_memory_data_move (const UINT16 op, typed_pointer* d_register, UINT64* prev_accum_value);
168static void execute_x_memory_data_move2(const UINT16 op, typed_pointer* d_register);
55169
56static int MoveCOperation(void) ;
57static int MoveMOperation(void) ;
58static int MoveIOperation(void) ;
59static int MovePOperation(void) ;
60170
61static int AndiOperation(void) ;
62//static int OriOperation(void) ;
171static UINT16 decode_BBB_bitmask(UINT16 BBB, UINT16 *iVal);
172static int decode_cccc_table(UINT16 cccc);
173static void decode_DDDDD_table(UINT16 DDDDD, typed_pointer* ret);
174static void decode_DD_table(UINT16 DD, typed_pointer* ret);
175static void decode_F_table(UINT16 F, typed_pointer* ret);
176static void decode_h0hF_table(UINT16 h0h, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret);
177static void decode_HH_table(UINT16 HH, typed_pointer* ret);
178static void decode_HHH_table(UINT16 HHH, typed_pointer* ret);
179static void decode_IIII_table(UINT16 IIII, typed_pointer* src_ret, typed_pointer* dst_ret, void *working);
180static void decode_JJJF_table(UINT16 JJJ, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret);
181static void decode_JJF_table(UINT16 JJ, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret);
182static void decode_QQF_special_table(UINT16 QQ, UINT16 F, void **S1, void **S2, void **D);
183static void decode_RR_table(UINT16 RR, typed_pointer* ret);
184static void decode_Z_table(UINT16 Z, typed_pointer* ret);
185static void execute_m_table(int x, UINT16 m);
186static void execute_MM_table(UINT16 rnum, UINT16 MM);
187static UINT16 execute_q_table(int x, UINT16 q);
188#ifdef UNUSED_FUNCTION
189static void execute_z_table(int x, UINT16 z);
190#endif
191static UINT16 assemble_address_from_Pppppp_table(UINT16 P, UINT16 ppppp);
192static UINT16 assemble_address_from_IO_short_address(UINT16 pp);
193static UINT16 assemble_address_from_6bit_signed_relative_short_address(UINT16 srs);
63194
64static int BitfieldOperation(void) ;
65static int JmpOperation(void) ;
66static int BsrOperation(void) ;
67static int JsrOperation(void) ;
68static int DoOperation(void) ;
69static int TccOperation(void) ;
70static int BraOperation(void) ;
71static int BsccOperation(void) ;
72static int BccOperation(void) ;
73static int Tst2Operation(void) ;
74static int MACsuuuOperation(void) ;
75static int RepOperation(void) ;
195static void dsp56k_process_loop(void);
196static void dsp56k_process_rep(size_t repSize);
76197
77static void EndOfLoopProcessing(void) ;
78static void EndOfRepProcessing(void) ;
79198
80// Parallel memory data moves
81static void XMDMOperation(UINT16 parameters, void *working, UINT64 *pa) ;
82static void XMDMSpecialOperation(UINT16 parameters, void *working) ;
83static void ARUOperation(UINT16 parameters) ;
84static void RRDMOperation(UINT16 parameters, void *working,  UINT64 *pa) ;
85199
86// For decoding the different types of tables...
87static void *DecodeDDDDDTable(UINT16 DDDDD, unsigned char *dt) ;
88static void *DecodeRRTable(UINT16 RR, unsigned char *dt) ;
89static void *DecodeDDTable(UINT16 DD, unsigned char *dt) ;
90static void *DecodeHHHTable(UINT16 HHH, unsigned char *dt) ;
91static void *DecodeHHTable(UINT16 HH, unsigned char *dt) ;
92static void *DecodeZTable(UINT16 Z, unsigned char *dt) ;
93static UINT16 DecodeBBBBitMask(UINT16 BBB, UINT16 *iVal) ;
94static int DecodeccccTable(UINT16 cccc) ;
95static void Decodeh0hFTable(UINT16 h0h, UINT16 F, void **source, unsigned char *st, void **dest, unsigned char *dt) ;
96static void *DecodeFTable(UINT16 F, unsigned char *dt) ;
97static void DecodeJJJFTable(UINT16 JJJ, UINT16 F, void **source, unsigned char *st, void **dest, unsigned char *dt) ;
98static void DecodeJJFTable(UINT16 JJ, UINT16 F, void **source, unsigned char *st, void **dest, unsigned char *dt) ;
99static void DecodeQQFTableSp(UINT16 QQ, UINT16 F, void **S1, void **S2, void **D) ;
100static void DecodeIIIITable(UINT16 IIII, void **source, unsigned char *st, void **dest, unsigned char *dt, void *working) ;
200/********************/
201/* Helper Functions */
202/********************/
203static UINT16 Dsp56kOpMask(UINT16 op, UINT16 mask);
101204
102static void ExecuteMMTable(int x, UINT16 MM) ;
103static void ExecutemTable(int x, UINT16 m) ;
104static void ExecutezTable(int x, UINT16 z) ;
105static UINT16 ExecuteqTable(int x, UINT16 q) ;
205/* These arguments are written source->destination to fall in line with the processor's paradigm. */
206static void SetDestinationValue(typed_pointer source, typed_pointer dest);
106207
107static UINT16 AssembleDFromPTable(UINT16 P, UINT16 ppppp) ;
208static void SetDataMemoryValue(typed_pointer source, UINT32 destinationAddr);
209static void SetProgramMemoryValue(typed_pointer source, UINT32 destinationAddr);
108210
109static UINT16 AssembleAddressFromIOShortAddress(UINT16 pp) ;
110static UINT16 AssembleAddressFrom6BitSignedRelativeShortAddress(UINT16 srs) ;
111211
112212
113213/***************************************************************************
114214    IMPLEMENTATION
115215***************************************************************************/
116216
117#ifdef UNUSED_FUNCTION
118static void unimplemented(void)
119{
120   fatalerror("Unimplemented OP @ %04X: %04X", PC-2, OP) ;
121}
122#endif
123
124
125217static void execute_one(void)
126218{
127   unsigned size = 666 ;
219   UINT16 op;
220   UINT16 op2;
221   size_t size = 0x1337;
222   UINT8 cycle_count = 0;
128223
224   /* For MAME */
129225   debugger_instruction_hook(Machine, PC);
130   OP = ROPCODE(PC<<1);
226   OP = ROPCODE(WORD(PC));
131227
132   if (BITS(OP,0x8000))                                 // First, the parallel data move instructions
228   /* The words we're going to be working with */
229   op = ROPCODE(WORD(PC));
230   op2 = ROPCODE(WORD(PC) + WORD(1));
231
232
233   /* DECODE */
234   /* Dual X Memory Data Read : 011m mKKK -rr- ---- : A-142*/
235   if ((op & 0xe000) == 0x6000)
133236   {
134      size = ExecuteDataALUOpcode(PARALLEL_TYPE_XMDM) ;
237      /* Quote: (MOVE, MAC(R), MPY(R), ADD, SUB, TFR) */
238      UINT16 op_byte = op & 0x00ff;
239
240      /* ADD : 011m mKKK 0rru Fuuu : A-22 */
241      if ((op & 0xe080) == 0x6000)
242      {
243         size = dsp56k_op_add_2(op_byte, &cycle_count);
244      }
245      /* MAC : 011m mKKK 1xx0 F1QQ : A-122 */
246      else if ((op & 0xe094) == 0x6084)
247      {
248         size = dsp56k_op_mac_1(op_byte, &cycle_count);
249      }
250      /* MACR: 011m mKKK 1--1 F1QQ : A-124 */
251      else if ((op & 0xe094) == 0x6094)
252      {
253         size = dsp56k_op_macr_1(op_byte, &cycle_count);
254      }
255      /* MOVE : 011m mKKK 0rr1 0000 : A-128 */
256      else if ((op & 0xe09f) == 0x6010)
257      {
258         size = dsp56k_op_move_1(op_byte, &cycle_count);
259      }
260      /* MPY : 011m mKKK 1xx0 F0QQ : A-160 */
261      else if ((op & 0xe094) == 0x6080)
262      {
263         size = dsp56k_op_mpy_1(op_byte, &cycle_count);
264      }
265      /* MPYR : 011m mKKK 1--1 F0QQ : A-162 */
266      else if ((op & 0xe094) == 0x6090)
267      {
268         size = dsp56k_op_mpyr_1(op_byte, &cycle_count);
269      }
270      /* SUB : 011m mKKK 0rru Fuuu : A-202 */
271      else if ((op & 0xe080) == 0x6000)
272      {
273         size = dsp56k_op_sub_1(op_byte, &cycle_count);
274      }
275      /* TFR : 011m mKKK 0rr1 F0DD : A-212 */
276      else if ((op & 0xe094) == 0x6010)
277      {
278         size = dsp56k_op_tfr_2(op_byte, &cycle_count);
279      }
280
281      /* Now evaluate the parallel data move */
282      // TODO // decode_dual_x_memory_data_read(op, parallel_move_str, parallel_move_str2);
135283   }
136   else if (BITS(OP,0xf000) == 0x5)
284   /* X Memory Data Write and Register Data Move : 0001 011k RRDD ---- : A-140 */
285   else if ((op & 0xfe00) == 0x1600)
137286   {
138      size = ExecuteDataALUOpcode(PARALLEL_TYPE_XMDM_SPECIAL) ;
139   }
140   else if (BITS(OP,0xff00) == 0x4a)
141   {
142      size = ExecuteDataALUOpcode(PARALLEL_TYPE_NODM) ;
143   }
144   else if (BITS(OP,0xf000) == 0x04)
145   {
146      size = ExecuteDataALUOpcode(PARALLEL_TYPE_RRDM) ;
147   }
148   else if (BITS(OP,0xf800) == 0x06)
149   {
150      size = ExecuteDataALUOpcode(PARALLEL_TYPE_ARU) ;
151   }
287      /* Quote: (MPY or MAC) */
288      UINT16 op_byte = op & 0x00ff;
152289
290      /* MPY : 0001 0110 RRDD FQQQ : A-160 */
291      if ((op & 0xff00) == 0x1600)
292      {
293         size = dsp56k_op_mpy_2(op_byte, &cycle_count);
294      }
295      /* MAC : 0001 0111 RRDD FQQQ : A-122 */
296      else if ((op & 0xff00) == 0x1700)
297      {
298         size = dsp56k_op_mac_2(op_byte, &cycle_count);
299      }
153300
154   else if (BITS(OP,0x4000))
155   {
156      size = ExecuteDXMDROpcode() ;
301      /* Now evaluate the parallel data move */
302      // TODO // decode_x_memory_data_write_and_register_data_move(op, parallel_move_str, parallel_move_str2);
157303   }
158   else if (BITS(OP,0xf000) == 0x1)
159   {
160      size = ExecuteNPMOpcode() ;
161   }
162   else if (BITS(OP,0x2000))
163   {
164      size = ExecuteMisfitOpcode() ;
165   }
166   else if (BITS(OP,0xf000) == 0x0)
167   {
168      size = ExecuteSpecialOpcode();
169   }
170304
171   if (size == 666)
305   /* Handle Other parallel types */
306   else
172307   {
173      mame_printf_debug("unimplemented at %04x\n", PC) ;
174      size = 1 ;                  // Just to get the debugger past the bad opcode
175   }
308      /***************************************/
309      /* 32 General parallel move operations */
310      /***************************************/
176311
312      enum pType { kNoParallelDataMove,
313                kRegisterToRegister,
314                kAddressRegister,
315                kXMemoryDataMove,
316                kXMemoryDataMove2,
317                kXMemoryDataMoveWithDisp };
177318
178   PC += size ;
179   change_pc(PC) ;
319      int parallelType = -1;
320      UINT16 op_byte = 0x0000;
321      typed_pointer d_register = {NULL, DT_BYTE};
322      UINT64 prev_accum_value = U64(0x0000000000000000);
180323
181   // Loop processing
182   if (LF_bit())
183   {
184      if (PC == LA)
324      /* Note: it's important that NPDM comes before RtRDM here */
325      /* No Parallel Data Move : 0100 1010 ---- ---- : A-131 */
326      if ((op & 0xff00) == 0x4a00)
185327      {
186         // You're on the last instruction of the loop...
187         if (LC != 1)                        // Strange, the == 1 thing...
328         op_byte = op & 0x00ff;
329         parallelType = kNoParallelDataMove;
330      }
331      /* Register to Register Data Move : 0100 IIII ---- ---- : A-133 */
332      else if ((op & 0xf000) == 0x4000)
333      {
334         op_byte = op & 0x00ff;
335         parallelType = kRegisterToRegister;
336      }
337      /* Address Register Update : 0011 0zRR ---- ---- : A-135 */
338      else if ((op & 0xf800) == 0x3000)
339      {
340         op_byte = op & 0x00ff;
341         parallelType = kAddressRegister;
342      }
343      /* X Memory Data Move : 1mRR HHHW ---- ---- : A-137 */
344      else if ((op & 0x8000) == 0x8000)
345      {
346         op_byte = op & 0x00ff;
347         parallelType = kXMemoryDataMove;
348      }
349      /* X Memory Data Move : 0101 HHHW ---- ---- : A-137 */
350      else if ((op & 0xf000) == 0x5000)
351      {
352         op_byte = op & 0x00ff;
353         parallelType = kXMemoryDataMove2;
354      }
355      /* X Memory Data Move with short displacement : 0000 0101 BBBB BBBB ---- HHHW ---- ---- : A-139 */
356      else if ((op & 0xff00) == 0x0500)
357      {
358         /* See notes at top of file! */
359         /* op_byte = op2 & 0x00ff; */
360         /* parallelType = kXMemoryDataMoveWithDisp; */
361         /* DO NOTHING FOR NOW */
362      }
363
364
365      if (parallelType != -1)
366      {
367         /* Note: There is much overlap between opcodes down here */
368         /*       To this end, certain ops must come before others in the list */
369
370         /* CLR : .... .... 0000 F001 : A-60 */
371         if ((op_byte & 0x00f7) == 0x0001)
188372         {
189            LC-- ;
190            PC = SSH ;
191            change_pc(PC) ;
373            size = dsp56k_op_clr(op_byte, &d_register, &prev_accum_value, &cycle_count);
192374         }
193         else
375         /* ADD : .... .... 0000 FJJJ : A-22 */
376         else if ((op_byte & 0x00f0) == 0x0000)
194377         {
195            EndOfLoopProcessing() ;
378            size = dsp56k_op_add(op_byte, &d_register, &prev_accum_value, &cycle_count);
196379         }
197      }
198   }
199380
200   // Rep processing
201   if (core.repFlag)
202   {
203      if (PC == core.repAddr)
204      {
205         if (LC != 1)
381
382         /* MOVE : .... .... 0001 0001 : A-128 */
383         else if ((op_byte & 0x00ff) == 0x0011)
206384         {
207            LC-- ;
208            PC -= size ;                        // Eh, seems reasonable :)
209            change_pc(PC) ;
385            size = dsp56k_op_move(op_byte, &d_register, &prev_accum_value, &cycle_count);
210386         }
211         else
387         /* TFR : .... .... 0001 FJJJ : A-212 */
388         else if ((op_byte & 0x00f0) == 0x0010)
212389         {
213            EndOfRepProcessing() ;
390            size = dsp56k_op_tfr(op_byte, &d_register, &prev_accum_value, &cycle_count);
214391         }
215      }
216   }
217392
218   dsp56k_icount -= 4;               /* Temporarily hard-coded at 4 clocks per opcode */
219}
220393
394         /* RND : .... .... 0010 F000 : A-188 */
395         else if ((op_byte & 0x00f7) == 0x0020)
396         {
397            size = dsp56k_op_rnd(op_byte, &d_register, &prev_accum_value, &cycle_count);
398         }
399         /* TST : .... .... 0010 F001 : A-218 */
400         else if ((op_byte & 0x00f7) == 0x0021)
401         {
402            size = dsp56k_op_tst(op_byte, &d_register, &prev_accum_value, &cycle_count);
403         }
404         /* INC : .... .... 0010 F010 : A-104 */
405         else if ((op_byte & 0x00f7) == 0x0022)
406         {
407            size = dsp56k_op_inc(op_byte, &d_register, &prev_accum_value, &cycle_count);
408         }
409         /* INC24 : .... .... 0010 F011 : A-106 */
410         else if ((op_byte & 0x00f7) == 0x0023)
411         {
412            size = dsp56k_op_inc24(op_byte, &d_register, &prev_accum_value, &cycle_count);
413         }
414         /* OR : .... .... 0010 F1JJ : A-176 */
415         else if ((op_byte & 0x00f4) == 0x0024)
416         {
417            size = dsp56k_op_or(op_byte, &d_register, &prev_accum_value, &cycle_count);
418         }
221419
222static unsigned ExecuteDataALUOpcode(int parallelType)
223{
224   unsigned retSize = 666 ;
225420
226   void *workingDest = 0x00 ;
227
228   // Whenever an instruction uses an accumulator as both a destination operand for a Data ALU operation and
229   //   as a source for a parallel move operation, the parallel move operation will use the value in the accumulator
230   //   prior to execution of any Data ALU operation.
231   UINT64 previousAccum = 0 ;
232
233   switch(BITS(OP,0x0070))
234   {
235
236      case 0x0:
237         if (BITS(OP,0x0007) == 0x1)
421         /* ASR : .... .... 0011 F000 : A-32 */
422         else if ((op_byte & 0x00f7) == 0x0030)
238423         {
239            // CLR - 1mRR HHHW 0000 F001
240                retSize = ClrOperation(&workingDest, &previousAccum) ;
424            size = dsp56k_op_asr(op_byte, &d_register, &prev_accum_value, &cycle_count);
241425         }
242         else
426         /* ASL : .... .... 0011 F001 : A-28 */
427         else if ((op_byte & 0x00f7) == 0x0031)
243428         {
244            // ADD - 1mRR HHHW 0000 FJJJ
245            retSize = AddOperation(&workingDest, &previousAccum) ;
429            size = dsp56k_op_asl(op_byte, &d_register, &prev_accum_value, &cycle_count);
246430         }
247         break ;
248
249      case 0x1:
250         if (BITS(OP,0x000f) == 0x1)
431         /* LSR : .... .... 0011 F010 : A-120 */
432         else if ((op_byte & 0x00f7) == 0x0032)
251433         {
252            // MOVE - 1mRR HHHW 0001 0001
253            retSize = 1 ;
434            size = dsp56k_op_lsr(op_byte, &d_register, &prev_accum_value, &cycle_count);
254435         }
255         else
436         /* LSL : .... .... 0011 F011 : A-118 */
437         else if ((op_byte & 0x00f7) == 0x0033)
256438         {
257            // TFR - 1mRR HHHW 0001 FJJJ
258            retSize = TfrDataALUOperation(&workingDest, &previousAccum) ;
439            size = dsp56k_op_lsl(op_byte, &d_register, &prev_accum_value, &cycle_count);
259440         }
260         break ;
441         /* EOR : .... .... 0011 F1JJ : A-94 */
442         else if ((op_byte & 0x00f4) == 0x0034)
443         {
444            size = dsp56k_op_eor(op_byte, &d_register, &prev_accum_value, &cycle_count);
445         }
261446
262      case 0x2:
263         if (BITS(OP,0x0007) == 0x0)
447
448         /* SUBL : .... .... 0100 F001 : A-204 */
449         else if ((op_byte & 0x00f7) == 0x0041)
264450         {
265            // RND - 1mRR HHHW 0010 F000
451            size = dsp56k_op_subl(op_byte, &d_register, &prev_accum_value, &cycle_count);
266452         }
267         else if (BITS(OP,0x0007) == 0x1)
453         /* SUB : .... .... 0100 FJJJ : A-202 */
454         else if ((op_byte & 0x00f0) == 0x0040)
268455         {
269            // TST - 1mRR HHHW 0010 F001
270            retSize = TstOperation(&workingDest, &previousAccum);
456            size = dsp56k_op_sub(op_byte, &d_register, &prev_accum_value, &cycle_count);
271457         }
272         else if (BITS(OP,0x0007) == 0x2)
458
459
460         /* CLR24 : .... .... 0101 F001 : A-62 */
461         else if ((op_byte & 0x00f7) == 0x0051)
273462         {
274            // INC - 1mRR HHHW 0010 F010
463            size = dsp56k_op_clr24(op_byte, &d_register, &prev_accum_value, &cycle_count);
275464         }
276         else if (BITS(OP,0x0007) == 0x3)
465         /* SBC : .... .... 0101 F01J : A-198 */
466         else if ((op_byte & 0x00f6) == 0x0052)
277467         {
278            // INC24 - 1mRR HHHW 0010 F011
468            size = dsp56k_op_sbc(op_byte, &d_register, &prev_accum_value, &cycle_count);
279469         }
280         else
470         /* CMP : .... .... 0101 FJJJ : A-64 */
471         else if ((op_byte & 0x00f0) == 0x0050)
281472         {
282            // OR - 1mRR HHHW 0010 F1JJ
283            retSize = OrOperation(&workingDest, &previousAccum) ;
473            size = dsp56k_op_cmp(op_byte, &d_register, &prev_accum_value, &cycle_count);
284474         }
285         break ;
286475
287      case 0x3:
288         if (BITS(OP,0x0007) == 0x0)
476
477         /* NEG : .... .... 0110 F000 : A-166 */
478         else if ((op_byte & 0x00f7) == 0x0060)
289479         {
290            // ASR - 1mRR HHHW 0011 F000
291            retSize = AsrOperation(&workingDest, &previousAccum) ;
480            size = dsp56k_op_neg(op_byte, &d_register, &prev_accum_value, &cycle_count);
292481         }
293         else if (BITS(OP,0x0007) == 0x1)
482         /* NOT : .... .... 0110 F001 : A-174 */
483         else if ((op_byte & 0x00f7) == 0x0061)
294484         {
295            // ASL - 1mRR HHHW 0011 F001
485            size = dsp56k_op_not(op_byte, &d_register, &prev_accum_value, &cycle_count);
296486         }
297         else if (BITS(OP,0x0007) == 0x2)
487         /* DEC : .... .... 0110 F010 : A-72 */
488         else if ((op_byte & 0x00f7) == 0x0062)
298489         {
299            // LSR - 1mRR HHHW 0011 F010
300            retSize = LsrOperation(&workingDest, &previousAccum) ;
490            size = dsp56k_op_dec(op_byte, &d_register, &prev_accum_value, &cycle_count);
301491         }
302         else if (BITS(OP,0x0007) == 0x3)
492         /* DEC24 : .... .... 0110 F011 : A-74 */
493         else if ((op_byte & 0x00f7) == 0x0063)
303494         {
304            // LSL - 1mRR HHHW 0011 F011
495            size = dsp56k_op_dec24(op_byte, &d_register, &prev_accum_value, &cycle_count);
305496         }
306         else
497         /* AND : .... .... 0110 F1JJ : A-24 */
498         else if ((op_byte & 0x00f4) == 0x0064)
307499         {
308            // EOR - 1mRR HHHW 0011 F1JJ
309            retSize = EorOperation(&workingDest, &previousAccum) ;
500            size = dsp56k_op_and(op_byte, &d_register, &prev_accum_value, &cycle_count);
310501         }
311         break ;
312/*
313        case 0x4:
314            if (BITS(op,0x0007) == 0x1)
315            {
316                // SUBL - 1mRR HHHW 0100 F001
317            }
318            else
319            {
320                // SUB - 1mRR HHHW 0100 FJJJ
321            }
322            break ;
323*/
324      case 0x5:
325         if (BITS(OP,0x0007) == 0x1)
502
503
504         /* ABS : .... .... 0111 F001 : A-18 */
505         if ((op_byte & 0x00f7) == 0x0071)
326506         {
327            // CLR24 - 1mRR HHHW 0101 F001
507            size = dsp56k_op_abs(op_byte, &d_register, &prev_accum_value, &cycle_count);
328508         }
329         else if (BITS(OP,0x0006) == 0x1)
509         /* ROR : .... .... 0111 F010 : A-192 */
510         else if ((op_byte & 0x00f7) == 0x0072)
330511         {
331            // SBC - 1mRR HHHW 0101 F01J
512            size = dsp56k_op_ror(op_byte, &d_register, &prev_accum_value, &cycle_count);
332513         }
333         else
514         /* ROL : .... .... 0111 F011 : A-190 */
515         else if ((op_byte & 0x00f7) == 0x0073)
334516         {
335            // CMP - 1mRR HHHW 0101 FJJJ
336            retSize = CmpOperation(&workingDest, &previousAccum) ;
517            size = dsp56k_op_rol(op_byte, &d_register, &prev_accum_value, &cycle_count);
337518         }
338         break ;
519         /* CMPM : .... .... 0111 FJJJ : A-66 */
520         else if ((op_byte & 0x00f0) == 0x0070)
521         {
522            size = dsp56k_op_cmpm(op_byte, &d_register, &prev_accum_value, &cycle_count);
523         }
339524
340      case 0x6:
341         if (BITS(OP,0x0007) == 0x0)
525
526         /* MPY : .... .... 1k00 FQQQ : A-160    -- CONFIRMED TYPO IN DOCS (HHHH vs HHHW) */
527         else if ((op_byte & 0x00b0) == 0x0080)
342528         {
343            // NEG - 1mRR HHHW 0110 F000
529            size = dsp56k_op_mpy(op_byte, &d_register, &prev_accum_value, &cycle_count);
344530         }
345         else if (BITS(OP,0x0007) == 0x1)
531         /* MPYR : .... .... 1k01 FQQQ : A-162 */
532         else if ((op_byte & 0x00b0) == 0x0090)
346533         {
347            // NOT - 1mRR HHHW 0110 F001
348            retSize = NotOperation(&workingDest, &previousAccum) ;
534            size = dsp56k_op_mpyr(op_byte, &d_register, &prev_accum_value, &cycle_count);
349535         }
350         else if (BITS(OP,0x0007) == 0x2)
536         /* MAC : .... .... 1k10 FQQQ : A-122 */
537         else if ((op_byte & 0x00b0) == 0x00a0)
351538         {
352            // DEC - 1mRR HHHW 0110 F010
539            size = dsp56k_op_mac(op_byte, &d_register, &prev_accum_value, &cycle_count);
353540         }
354         else if (BITS(OP,0x0007) == 0x3)
541         /* MACR : .... .... 1k11 FQQQ : A-124   -- DRAMA - rr vs xx (805) */
542         else if ((op_byte & 0x00b0) == 0x00b0)
355543         {
356            // DEC24 - 1mRR HHHW 0110 F011
357            retSize = Dec24Operation(&workingDest, &previousAccum) ;
544            size = dsp56k_op_macr(op_byte, &d_register, &prev_accum_value, &cycle_count);
358545         }
359         else
546
547
548         /* Now evaluate the parallel data move */
549         switch (parallelType)
360550         {
361            // AND - 1mRR HHHW 0110 F1JJ
362            retSize = AndOperation(&workingDest, &previousAccum) ;
551         case kNoParallelDataMove:
552            /* DO NOTHING */
553            break;
554         case kRegisterToRegister:
555            execute_register_to_register_data_move(op, &d_register, &prev_accum_value);
556            break;
557         case kAddressRegister:
558            // TODO // decode_address_register_update(op, parallel_move_str);
559            break;
560         case kXMemoryDataMove:
561            execute_x_memory_data_move(op, &d_register, &prev_accum_value);
562            break;
563         case kXMemoryDataMove2:
564            execute_x_memory_data_move2(op, &d_register);
565            break;
566         case kXMemoryDataMoveWithDisp:
567            // TODO // decode_x_memory_data_move_with_short_displacement(op, op2, parallel_move_str);
568            break;
363569         }
364         break ;
365/*
366        case 0x7:
367            if (BITS(op,0x0007) == 0x1)
368            {
369                // ABS - 1mRR HHHW 0111 F001
370            }
371            if (BITS(op,0x0007) == 0x2)
372            {
373                // ROR - 1mRR HHHW 0111 F010
374            }
375            if (BITS(op,0x0007) == 0x3)
376            {
377                // ROL - 1mRR HHHW 0111 F011
378            }
379            else
380            {
381                // CMPM - 1mRR HHHW 0111 FJJJ
382            }
383
384            break ;
385*/
570      }
386571   }
387572
388/*
389    // Otherwise you're looking at a MPY/MAC operation...
390    if (BITS(op,0x0080))                                                                    // Maybe i should un-consolidate here?
391    {
392        DecodeQQQFTable(BITS(op,0x0007), BITS(op,0x0008), S1, S2, D) ;
393        DecodekSignTable(BITS(op,0x0040), sign) ;
394
395        switch(BITS(op,0x00b0))
396        {
397            // MPY - 1mRR HHHH 1k00 FQQQ
398            case 0x4: sprintf(buffer, "mpy       (%s)%s,%s,%s", sign, S2, S1, D)  ; break ;
399
400            // MPYR - 1mRR HHHH 1k01 FQQQ
401            case 0x5: sprintf(buffer, "mpyr      (%s)%s,%s,%s", sign, S2, S1, D) ; break ;
402
403            // MAC - 1mRR HHHH 1k10 FQQQ
404            case 0x6: sprintf(buffer, "mac       (%s)%s,%s,%s", sign, S2, S1, D)  ; break ;
405
406            // MACR - 1mRR HHHH 1k11 FQQQ
407            case 0x7: sprintf(buffer, "macr      (%s)%s,%s,%s", sign, S1, S2, D) ; break ;
408            // !! It's a little odd that macr is S1,S2 while everyone else is S2,S1 !!
409        }
410
411        retSize = 1 ;
412    }
413*/
414
415   // Do the parallel move parallel'y :)
416    // Someday we may have to check against the special cases to throw exceptions !!
417   switch (parallelType)
573   /* Drop out if you've already completed your work. */
574   if (size != 0x1337)
418575   {
419      case PARALLEL_TYPE_XMDM:
420         XMDMOperation(BITS(OP,0xff00), workingDest, &previousAccum) ;
421         break ;
576      PC += size;
577      change_pc(PC);
422578
423      case PARALLEL_TYPE_RRDM:
424         RRDMOperation(BITS(OP,0xff00), workingDest, &previousAccum) ;
425         break ;
579      dsp56k_process_loop();
580      dsp56k_process_rep(size);
426581
427      case PARALLEL_TYPE_XMDM_SPECIAL:
428         // pa is not needed because the XMDM dest is always the .opposite. of the regular dest.
429         XMDMSpecialOperation(BITS(OP,0xff00), workingDest) ;
430         break ;
431
432      case PARALLEL_TYPE_NODM:
433         // do nothing
434         break ;
435
436      case PARALLEL_TYPE_ARU:
437         ARUOperation(BITS(OP,0xff00)) ;
438         break ;
582      dsp56k_icount -= 4;   /* Temporarily hard-coded at 4 clocks per opcode */   /* cycle_count */
583      return;
439584   }
440585
441   return retSize ;
442}
443586
444static unsigned ExecuteDXMDROpcode(void)
445{
446   unsigned retSize = 666 ;
587   /******************************/
588   /* Remaining non-parallel ops */
589   /******************************/
447590
448   return retSize ;
449}
450
451static unsigned ExecuteNPMOpcode(void)
452{
453   unsigned retSize = 666 ;
454
455   if (BITS(OP,0x0f00) == 0x4)
591   /* ADC : 0001 0101 0000 F01J : A-20 */
592   if ((op & 0xfff6) == 0x1502)
456593   {
457      retSize = BitfieldOperation() ;
594      size = dsp56k_op_adc(op, &cycle_count);
458595   }
459   else if (BITS(OP,0x0f00) == 0x5)
596   /* ANDI : 0001 1EE0 iiii iiii : A-26 */
597   /* (MoveP sneaks in here if you don't check 0x0600) */
598   else if (((op & 0xf900) == 0x1800) & ((op & 0x0600) != 0x0000))
460599   {
461      switch(BITS(OP,0x0074))
462      {
463         case 0x0:
464            if (BITS(OP,0x0006) == 0x0)
465            {
466               // TFR(2) - 0001 0101 0000 F00J
467               retSize = 1 ;
468            }
469            else if (BITS(OP,0x0006) == 0x1)
470            {
471               // ADC - 0001 0101 0000 F01J
472               retSize = 1 ;
473            }
474            break ;
475
476         case 0x3:
477               // TST(2) - 0001 0101 0001 -1DD
478               retSize = Tst2Operation() ; break ;
479
480         case 0x4:
481               // NORM - 0001 0101 0010 F0RR
482               retSize = 1 ; break ;
483
484         case 0x6:
485            if (BITS(OP,0x0003) == 0x0)
486            {
487               // ASR4 - 0001 0101 0011 F000
488               retSize = 1 ;
489            }
490            else if (BITS(OP,0x0003) == 0x1)
491            {
492               // ASL4 - 0001 0101 0011 F001
493               retSize = 1 ;
494            }
495            break ;
496
497         case 0x1: case 0x5: case 0x9: case 0xd:
498               // DIV - 0001 0101 0--0 F1DD
499               retSize = 1 ; break ;
500
501         case 0xa:
502            if (BITS(OP,0x0003) == 0x0)
503            {
504               // ZERO - 0001 0101 0101 F000
505               retSize = 1 ;
506            }
507            else if (BITS(OP,0x0003) == 0x2)
508            {
509               // EXT - 0001 0101 0101 F010
510               retSize = 1 ;
511            }
512            break ;
513
514         case 0xc:
515            if (BITS(OP,0x0003) == 0x0)
516            {
517               // NEGC - 0001 0101 0110 F000
518               retSize = 1 ;
519            }
520            break ;
521
522         case 0xe:
523            if (BITS(OP,0x0003) == 0x0)
524            {
525               // ASR16 - 0001 0101 0111 F000
526               retSize = 1 ;
527            }
528            else if (BITS(OP,0x0003) == 0x1)
529            {
530               // SWAP - 0001 0101 0111 F001
531               retSize = 1 ;
532            }
533            break ;
534      }
535
536      switch(BITS(OP,0x00f0))
537      {
538         case 0x8:
539            // IMPY - 0001 0101 1000 FQQQ
540            retSize = 1 ; break ;
541         case 0xa:
542            // IMAC - 0001 0101 1010 FQQQ
543            retSize = 1 ; break ;
544         case 0x9: case 0xb:
545            // DMAC(ss,su,uu) - 0001 0101 10s1 FsQQ
546            retSize = 1 ; break ;
547         case 0xc:
548            // MPY(su,uu) - 0001 0101 1100 FsQQ
549            retSize = 1 ; break ;
550         case 0xe:
551            // MAC(su,uu) - 0001 0101 1110 FsQQ
552            retSize = MACsuuuOperation() ; break ;
553      }
600      size = dsp56k_op_andi(op, &cycle_count);
554601   }
555   else if ((BITS(OP,0x0f00) == 0x6))
602   /* ASL4 : 0001 0101 0011 F001 : A-30 */
603   else if ((op & 0xfff7) == 0x1531)
556604   {
557      retSize = 1 ;
605      size = dsp56k_op_asl4(op, &cycle_count);
558606   }
559   else if ((BITS(OP,0x0f00) == 0x7))
607   /* ASR4 : 0001 0101 0011 F000 : A-34 */
608   else if ((op & 0xfff7) == 0x1530)
560609   {
561      retSize = 1 ;
610      size = dsp56k_op_asr4(op, &cycle_count);
562611   }
563   else if ((BITS(OP,0x0800) == 0x1))
612   /* ASR16 : 0001 0101 0111 F000 : A-36 */
613   else if ((op & 0xfff7) == 0x1570)
564614   {
565      if (BITS(OP,0x0600))
566      {
567         if (!BITS(OP,0x0100))
568         {
569            // ANDI - 0001 1EE0 iiii iiii
570            retSize = AndiOperation() ;
571         }
572         else
573         {
574            // ORI - 0001 1EE1 iiii iiii
575         }
576      }
577      else
578      {
579         if (!BITS(OP,0x0020))
580         {
581            // MOVE(S) - 0001 100W HH0a aaaa
582         }
583         else
584         {
585            // MOVE(P) - 0001 100W HH1p pppp
586            retSize = MovePOperation() ;
587         }
588      }
615      size = dsp56k_op_asr16(op, &cycle_count);
589616   }
590   else if ((BITS(OP,0x0c00) == 0x0))
617   /* BFCHG : 0001 0100 11Pp pppp BBB1 0010 iiii iiii : A-38 */
618   else if (((op & 0xffc0) == 0x14c0) && ((op2 & 0x1f00) == 0x1200))
591619   {
592      retSize = TccOperation() ;
620      size = dsp56k_op_bfop(op, op2, &cycle_count);
593621   }
594
595   return retSize ;
596}
597
598static unsigned ExecuteMisfitOpcode(void)
599{
600   unsigned retSize = 666 ;
601
602   if (BITS(OP,0x1000)== 0x0)
622   /* BFCHG : 0001 0100 101- --RR BBB1 0010 iiii iiii : A-38 */
623   else if (((op & 0xffe0) == 0x14a0) && ((op2 & 0x1f00) == 0x1200))
603624   {
604      switch(BITS(OP,0x0c00))
605      {
606         // MOVE(I) - 0010 00DD BBBB BBBB
607         case 0x0:
608            retSize = MoveIOperation() ;
609            break ;
610
611/*
612            case 0x1:
613                // TFR(3) - 0010 01mW RRDD FHHH
614                break ;
615*/
616         case 0x2:
617            // MOVE(C) - 0010 10dd dddD DDDD
618            retSize = MoveCOperation() ;
619            break ;
620
621         case 0x3:
622            // B.cc - 0010 11cc ccee eeee
623            retSize = BccOperation() ;
624            break ;
625      }
625      size = dsp56k_op_bfop_1(op, op2, &cycle_count);
626626   }
627   else
627   /* BFCHG : 0001 0100 100D DDDD BBB1 0010 iiii iiii : A-38 */
628   else if (((op & 0xffe0) == 0x1480) && ((op2 & 0x1f00) == 0x1200))
628629   {
629      // MOVE(C) - 0011 1WDD DDD0 MMRR
630      // MOVE(C) - 0011 1WDD DDD1 q0RR
631      // MOVE(C) - 0011 1WDD DDD1 t10- xxxx xxxx xxxx xxxx
632      // MOVE(C) - 0011 1WDD DDD1 Z11-
633      retSize = MoveCOperation() ;
630      size = dsp56k_op_bfop_2(op, op2, &cycle_count);
634631   }
635
636   return retSize ;
637}
638
639static unsigned ExecuteSpecialOpcode(void)
640{
641   unsigned retSize = 666 ;
642
643   if (BITS(OP,0x0ff0) == 0x0)
632   /* BFCLR : 0001 0100 11Pp pppp BBB0 0100 iiii iiii : A-40 */
633   else if (((op & 0xffc0) == 0x14c0) && ((op2 & 0x1f00) == 0x0400))
644634   {
645      switch (BITS(OP,0x000f))
646      {
647         // NOP - 0000 0000 0000 0000
648         case 0x0:
649            retSize = 1 ;
650            break ;
651
652         // DO FOREVER - 0000 0000 0000 0010 xxxx xxxx xxxx xxxx
653         case 0x2:
654            // !!! IMPLEMENT ME NEXT;
655            retSize = 0;
656            break;
657
658         // RTS - 0000 0000 0000 0110
659         case 0x6:
660            PC = SSH ;
661            SR = SSL ;
662            SP-- ;
663            retSize = 0 ;
664            change_pc(PC) ;
665            break ;
666
667         // RTI - 0000 0000 0000 0111
668         case 0x7:
669            PC = SSH;
670            SR = SSL;
671            SP--;
672            retSize = 0;
673            change_pc(PC);
674            break;
675      }
635      size = dsp56k_op_bfop(op, op2, &cycle_count);
676636   }
677   else if (BITS(OP,0x0f00) == 0x0)
637   /* BFCLR : 0001 0100 101- --RR BBB0 0100 iiii iiii : A-40 */
638   else if (((op & 0xffe0) == 0x14a0) && ((op2 & 0x1f00) == 0x0400))
678639   {
679      retSize = 1 ;
640      size = dsp56k_op_bfop_1(op, op2, &cycle_count);
680641   }
681   else if (BITS(OP,0x0f00) == 0x1)
642   /* BFCLR : 0001 0100 100D DDDD BBB0 0100 iiii iiii : A-40 */
643   else if (((op & 0xffe0) == 0x1480) && ((op2 & 0x1f00) == 0x0400))
682644   {
683      if (BITS(OP,0x00f0) == 0x1)
684      {
685         retSize = 1 ;
686      }
687      else if (BITS(OP,0x00f0) == 0x2)
688      {
689         switch(BITS(OP,0x000c))                        // Consolidation can happen here
690         {
691            // JSR - 0000 0001 0010 00RR
692            // JMP - 0000 0001 0010 01RR
693            case 0x1: retSize = JmpOperation(); break;
694            // BSR - 0000 0001 0010 10RR
695            // BRA - 0000 0001 0010 11RR
696            default:  retSize = 1;
697         }
698      }
699      else if (BITS(OP,0x00f0) == 0x3)
700      {
701         switch(BITS(OP,0x000c))
702         {
703            // JSR - 0000 0001 0011 00-- xxxx xxxx xxxx xxxx
704            case 0x0: retSize = JsrOperation() ; break ;
705            // JMP - 0000 0001 0011 01-- xxxx xxxx xxxx xxxx
706            case 0x1: retSize = JmpOperation() ; break ;
707            // BSR - 0000 0001 0011 10-- xxxx xxxx xxxx xxxx
708            case 0x2: retSize = BsrOperation() ; break ;
709         }
710      }
711      else if (BITS(OP,0x00f0) == 0x5)
712      {
713         retSize = 1 ;
714      }
715      else if (BITS(OP,0x0080) == 0x1)
716      {
717         retSize = 1 ;
718      }
645      size = dsp56k_op_bfop_2(op, op2, &cycle_count);
719646   }
720   else if (BITS(OP,0x0e00) == 0x1)
647   /* BFSET : 0001 0100 11Pp pppp BBB1 1000 iiii iiii : A-42 */
648   else if (((op & 0xffc0) == 0x14c0) && ((op2 & 0x1f00) == 0x1800))
721649   {
722      if (BITS(OP,0x0020) == 0x0)
723      {
724         // MOVE(M) - 0000 001W RR0M MHHH
725         retSize = MoveMOperation() ;
726      }
650      size = dsp56k_op_bfop(op, op2, &cycle_count);
727651   }
728   else if (BITS(OP,0x0f00) == 0x4)
652   /* BFSET : 0001 0100 101- --RR BBB1 1000 iiii iiii : A-42 */
653   else if (((op & 0xffe0) == 0x14a0) && ((op2 & 0x1f00) == 0x1800))
729654   {
730      if (BITS(OP,0x0020) == 0x0)
731      {
732         // DO - 0000 0100 000D DDDD xxxx xxxx xxxx xxxx
733         retSize = DoOperation() ;
734      }
735      else
736      {
737         // REP - 0000 0100 001D DDDD
738         retSize = RepOperation() ;
739      }
655      size = dsp56k_op_bfop_1(op, op2, &cycle_count);
740656   }
741   else if (BITS(OP,0x0f00) == 0x5)
657   /* BFSET : 0001 0100 100D DDDD BBB1 1000 iiii iiii : A-42 */
658   else if (((op & 0xffe0) == 0x1480) && ((op2 & 0x1f00) == 0x1800))
742659   {
743       UINT16 op2 = ROPCODE((PC<<1)+2) ;
744
745      if (BITS(op2,0xfe20) == 0x02)
746      {
747         // MOVE(M) - 0000 0101 BBBB BBBB | 0000 001W --0- -HHH
748         retSize = MoveMOperation() ;
749      }
750      else if (BITS(op2,0xf810) == 0x0e)
751      {
752         // MOVE(C) - 0000 0101 BBBB BBBB | 0011 1WDD DDD0 ----
753      }
754      else if (BITS(op2,0x00ff) == 0x11)
755      {
756         // MOVE - 0000 0101 BBBB BBBB | ---- HHHW 0001 0001
757      }
660      size = dsp56k_op_bfop_2(op, op2, &cycle_count);
758661   }
759   else if (BITS(OP,0x0f00) == 0x6)
662   /* BFTSTH : 0001 0100 01Pp pppp BBB1 0000 iiii iiii : A-44 */
663   else if (((op & 0xffc0) == 0x1440) && ((op2 & 0x1f00) == 0x1000))
760664   {
761      retSize = 1 ;
665      size = dsp56k_op_bfop(op, op2, &cycle_count);
762666   }
763   else if (BITS(OP,0x0f00) == 0x7)
667   /* BFTSTH : 0001 0100 001- --RR BBB1 0000 iiii iiii : A-44 */
668   else if (((op & 0xffe0) == 0x1420) && ((op2 & 0x1f00) == 0x1000))
764669   {
765      switch(BITS(OP,0x0030))
766      {
767         // BS.cc - 0000 0111 RR00 cccc
768         case 0x0: retSize = 1 ; break ;
769
770         // BS.cc - 0000 0111 --01 cccc xxxx xxxx xxxx xxxx
771         case 0x1: retSize = BsccOperation() ; break ;
772
773         // B.cc - 0000 0111 RR10 cccc
774         case 0x2: retSize = 1 ; break ;
775
776         // B.cc - 0000 0111 --11 cccc xxxx xxxx xxxx xxxx
777         case 0x3: retSize = BccOperation() ; break ;
778      }
670      size = dsp56k_op_bfop_1(op, op2, &cycle_count);
779671   }
780   else if (BITS(OP,0x0800))
672   /* BFTSTH : 0001 0100 000D DDDD BBB1 0000 iiii iiii : A-44 */
673   else if (((op & 0xffe0) == 0x1400) && ((op2 & 0x1f00) == 0x1000))
781674   {
782      switch (BITS(OP,0x0700))
783      {
784         // BRA - 0000 1011 aaaa aaaa
785         case 0x3: retSize = BraOperation() ; break ;
675      size = dsp56k_op_bfop_2(op, op2, &cycle_count);
676   }
677   /* BFTSTL : 0001 0100 01Pp pppp BBB0 0000 iiii iiii : A-46 */
678   else if (((op & 0xffc0) == 0x1440) && ((op2 & 0x1f00) == 0x0000))
679   {
680      size = dsp56k_op_bfop(op, op2, &cycle_count);
681   }
682   /* BFTSTL : 0001 0100 001- --RR BBB0 0000 iiii iiii : A-46 */
683   else if (((op & 0xffe0) == 0x1420) && ((op2 & 0x1f00) == 0x0000))
684   {
685      size = dsp56k_op_bfop_1(op, op2, &cycle_count);
686   }
687   /* BFTSTL : 0001 0100 000D DDDD BBB0 0000 iiii iiii : A-46 */
688   else if (((op & 0xffe0) == 0x1400) && ((op2 & 0x1f00) == 0x0000))
689   {
690      size = dsp56k_op_bfop_2(op, op2, &cycle_count);
691   }
692   /* Bcc : 0000 0111 --11 cccc xxxx xxxx xxxx xxxx : A-48 */
693   else if (((op & 0xff30) == 0x0730) && ((op2 & 0x0000) == 0x0000))
694   {
695      size = dsp56k_op_bcc(op, op2, &cycle_count);
696   }
697   /* Bcc : 0010 11cc ccee eeee : A-48 */
698   else if ((op & 0xfc00) == 0x2c00)
699   {
700      size = dsp56k_op_bcc_1(op, &cycle_count);
701   }
702   /* Bcc : 0000 0111 RR10 cccc : A-48 */
703   else if ((op & 0xff30) == 0x0720)
704   {
705      size = dsp56k_op_bcc_2(op, &cycle_count);
706   }
707   /* BRA : 0000 0001 0011 11-- xxxx xxxx xxxx xxxx : A-50 */
708   else if (((op & 0xfffc) == 0x013c) && ((op2 & 0x0000) == 0x0000))
709   {
710      size = dsp56k_op_bra(op, op2, &cycle_count);
711   }
712   /* BRA : 0000 1011 aaaa aaaa : A-50 */
713   else if ((op & 0xff00) == 0x0b00)
714   {
715      size = dsp56k_op_bra_1(op, &cycle_count);
716   }
717   /* BRA : 0000 0001 0010 11RR : A-50 */
718   else if ((op & 0xfffc) == 0x012c)
719   {
720      size = dsp56k_op_bra_2(op, &cycle_count);
721   }
722   /* BRKc : 0000 0001 0001 cccc : A-52 */
723   else if ((op & 0xfff0) == 0x0110)
724   {
725      size = dsp56k_op_brkc(op, &cycle_count);
726   }
727   /* BScc : 0000 0111 --01 cccc xxxx xxxx xxxx xxxx : A-54 */
728   else if (((op & 0xff30) == 0x0710) && ((op2 & 0x0000) == 0x0000))
729   {
730      size = dsp56k_op_bscc(op, op2, &cycle_count);
731   }
732   /* BScc : 0000 0111 RR00 cccc : A-54 */
733   else if ((op & 0xff30) == 0x0700)
734   {
735      size = dsp56k_op_bscc_1(op, &cycle_count);
736   }
737   /* BSR : 0000 0001 0011 10-- xxxx xxxx xxxx xxxx : A-56 */
738   else if (((op & 0xfffc) == 0x0138) && ((op2 & 0x0000) == 0x0000))
739   {
740      size = dsp56k_op_bsr(op, op2, &cycle_count);
741   }
742   /* BSR : 0000 0001 0010 10RR : A-56 */
743   else if ((op & 0xfffc) == 0x0128)
744   {
745      size = dsp56k_op_bsr_1(op, &cycle_count);
746   }
747   /* CHKAAU : 0000 0000 0000 0100 : A-58 */
748   else if ((op & 0xffff) == 0x0004)
749   {
750      size = dsp56k_op_chkaau(op, &cycle_count);
751   }
752   /* DEBUG : 0000 0000 0000 0001 : A-68 */
753   else if ((op & 0xffff) == 0x0001)
754   {
755      size = dsp56k_op_debug(op, &cycle_count);
756   }
757   /* DEBUGcc : 0000 0000 0101 cccc : A-70 */
758   else if ((op & 0xfff0) == 0x0050)
759   {
760      size = dsp56k_op_debugcc(op, &cycle_count);
761   }
762   /* DIV : 0001 0101 0--0 F1DD : A-76 */
763   /* WARNING : DOCS SAY THERE IS A PARALLEL MOVE HERE !!! */
764   else if ((op & 0xff94) == 0x1504)
765   {
766      size = dsp56k_op_div(op, &cycle_count);
767   }
768   /* DMAC : 0001 0101 10s1 FsQQ : A-80 */
769   else if ((op & 0xffd0) == 0x1590)
770   {
771      size = dsp56k_op_dmac(op, &cycle_count);
772   }
773   /* DO : 0000 0000 110- --RR xxxx xxxx xxxx xxxx : A-82 */
774   else if (((op & 0xffe0) == 0x00c0) && ((op2 & 0x0000) == 0x0000))
775   {
776      size = dsp56k_op_do(op, op2, &cycle_count);
777   }
778   /* DO : 0000 1110 iiii iiii xxxx xxxx xxxx xxxx : A-82 */
779   else if (((op & 0xff00) == 0x0e00) && ((op2 & 0x0000) == 0x0000))
780   {
781      size = dsp56k_op_do_1(op, op2, &cycle_count);
782   }
783   /* DO : 0000 0100 000D DDDD xxxx xxxx xxxx xxxx : A-82 */
784   else if (((op & 0xffe0) == 0x0400) && ((op2 & 0x0000) == 0x0000))
785   {
786      size = dsp56k_op_do_2(op, op2, &cycle_count);
787   }
788   /* DO FOREVER : 0000 0000 0000 0010 xxxx xxxx xxxx xxxx : A-88 */
789   else if (((op & 0xffff) == 0x0002) && ((op2 & 0x0000) == 0x0000))
790   {
791      size = dsp56k_op_doforever(op, op2, &cycle_count);
792   }
793   /* ENDDO : 0000 0000 0000 1001 : A-92 */
794   else if ((op & 0xffff) == 0x0009)
795   {
796      size = dsp56k_op_enddo(op, &cycle_count);
797   }
798   /* EXT : 0001 0101 0101 F010 : A-96 */
799   else if ((op & 0xfff7) == 0x1552)
800   {
801      size = dsp56k_op_ext(op, &cycle_count);
802   }
803   /* ILLEGAL : 0000 0000 0000 1111 : A-98 */
804   else if ((op & 0xffff) == 0x000f)
805   {
806      size = dsp56k_op_illegal(op, &cycle_count);
807   }
808   /* IMAC : 0001 0101 1010 FQQQ : A-100 */
809   else if ((op & 0xfff0) == 0x15a0)
810   {
811      size = dsp56k_op_imac(op, &cycle_count);
812   }
813   /* IMPY : 0001 0101 1000 FQQQ : A-102 */
814   else if ((op & 0xfff0) == 0x1580)
815   {
816      size = dsp56k_op_impy(op, &cycle_count);
817   }
818   /* Jcc : 0000 0110 --11 cccc xxxx xxxx xxxx xxxx : A-108 */
819   else if (((op & 0xff30) == 0x0630) && ((op2 & 0x0000) == 0x0000))
820   {
821      size = dsp56k_op_jcc(op, op2, &cycle_count);
822   }
823   /* Jcc : 0000 0110 RR10 cccc : A-108 */
824   else if ((op & 0xff30) == 0x0620 )
825   {
826      size = dsp56k_op_jcc_1(op, &cycle_count);
827   }
828   /* JMP : 0000 0001 0011 01-- xxxx xxxx xxxx xxxx : A-110 */
829   else if (((op & 0xfffc) == 0x0134) && ((op2 & 0x0000) == 0x0000))
830   {
831      size = dsp56k_op_jmp(op, op2, &cycle_count);
832   }
833   /* JMP : 0000 0001 0010 01RR : A-110 */
834   else if ((op & 0xfffc) == 0x0124)
835   {
836      size = dsp56k_op_jmp_1(op, &cycle_count);
837   }
838   /* JScc : 0000 0110 --01 cccc xxxx xxxx xxxx xxxx : A-112 */
839   else if (((op & 0xff30) == 0x0610) && ((op2 & 0x0000) == 0x0000))
840   {
841      size = dsp56k_op_jscc(op, op2, &cycle_count);
842   }
843   /* JScc : 0000 0110 RR00 cccc : A-112 */
844   else if ((op & 0xff30) == 0x0600)
845   {
846      size = dsp56k_op_jscc_1(op, &cycle_count);
847   }
848   /* JSR : 0000 0001 0011 00-- xxxx xxxx xxxx xxxx : A-114 */
849   else if (((op & 0xfffc) == 0x0130) && ((op2 & 0x0000) == 0x0000))
850   {
851      size = dsp56k_op_jsr(op, op2, &cycle_count);
852   }
853   /* JSR : 0000 1010 AAAA AAAA : A-114 */
854   else if ((op & 0xff00) == 0x0a00)
855   {
856      size = dsp56k_op_jsr_1(op, &cycle_count);
857   }
858   /* JSR : 0000 0001 0010 00RR : A-114 */
859   else if ((op & 0xfffc) == 0x0120)
860   {
861      size = dsp56k_op_jsr_2(op, &cycle_count);
862   }
863   /* LEA : 0000 0001 11TT MMRR : A-116 */
864   else if ((op & 0xffc0) == 0x01c0)
865   {
866      size = dsp56k_op_lea(op, &cycle_count);
867   }
868   /* LEA : 0000 0001 10NN MMRR : A-116 */
869   else if ((op & 0xffc0) == 0x0180)
870   {
871      size = dsp56k_op_lea_1(op, &cycle_count);
872   }
873   /* MAC(su,uu) : 0001 0101 1110 FsQQ : A-126 */
874   else if ((op & 0xfff0) == 0x15e0)
875   {
876      size = dsp56k_op_macsuuu(op, &cycle_count);
877   }
878   /* MOVE : 0000 0101 BBBB BBBB ---- HHHW 0001 0001 : A-128 */
879   else if (((op & 0xff00) == 0x0500) && ((op2 & 0x00ff) == 0x0011))
880   {
881      size = dsp56k_op_move_2(op, op2, &cycle_count);
882   }
883   /* MOVE(C) : 0011 1WDD DDD0 MMRR : A-144 */
884   else if ((op & 0xf810) == 0x3800)
885   {
886      size = dsp56k_op_movec(op, &cycle_count);
887   }
888   /* MOVE(C) : 0011 1WDD DDD1 q0RR : A-144 */
889   else if ((op & 0xf814) == 0x3810)
890   {
891      size = dsp56k_op_movec_1(op, &cycle_count);
892   }
893   /* MOVE(C) : 0011 1WDD DDD1 Z11- : A-144 */
894   else if ((op & 0xf816) == 0x3816)
895   {
896      size = dsp56k_op_movec_2(op, &cycle_count);
897   }
898   /* MOVE(C) : 0011 1WDD DDD1 t10- xxxx xxxx xxxx xxxx : A-144 */
899   else if (((op & 0xf816) == 0x3814) && ((op2 & 0x0000) == 0x0000))
900   {
901      size = dsp56k_op_movec_3(op, op2, &cycle_count);
902   }
903   /* MOVE(C) : 0010 10dd dddD DDDD : A-144 */
904   else if ((op & 0xfc00) == 0x2800)
905   {
906      size = dsp56k_op_movec_4(op, &cycle_count);
907   }
908   /* MOVE(C) : 0000 0101 BBBB BBBB 0011 1WDD DDD0 ---- : A-144 */
909   else if (((op & 0xff00) == 0x0500) && ((op2 & 0xf810) == 0x3800))
910   {
911      size = dsp56k_op_movec_5(op, op2, &cycle_count);
912   }
913   /* MOVE(I) : 0010 00DD BBBB BBBB : A-150 */
914   else if ((op & 0xfc00) == 0x2000)
915   {
916      size = dsp56k_op_movei(op, &cycle_count);
917   }
918   /* MOVE(M) : 0000 001W RR0M MHHH : A-152 */
919   else if ((op & 0xfe20) == 0x0200)
920   {
921      size = dsp56k_op_movem(op, &cycle_count);
922   }
923   /* MOVE(M) : 0000 001W RR11 mmRR : A-152 */
924   else if ((op & 0xfe30) == 0x0230)
925   {
926      size = dsp56k_op_movem_1(op, &cycle_count);
927   }
928   /* MOVE(M) : 0000 0101 BBBB BBBB 0000 001W --0- -HHH : A-152 */
929   else if (((op & 0xff00) == 0x0500) && ((op2 & 0xfe20) == 0x0200))
930   {
931      size = dsp56k_op_movem_2(op, op2, &cycle_count);
932   }
933   /* MOVE(P) : 0001 100W HH1p pppp : A-156 */
934   else if ((op & 0xfe20) == 0x1820)
935   {
936      size = dsp56k_op_movep(op, &cycle_count);
937   }
938   /* MOVE(P) : 0000 110W RRmp pppp : A-156 */
939   else if ((op & 0xfe00) == 0x0c00)
940   {
941      size = dsp56k_op_movep_1(op, &cycle_count);
942   }
943   /* MOVE(S) : 0001 100W HH0a aaaa : A-158 */
944   else if ((op & 0xfe20) == 0x1800)
945   {
946      size = dsp56k_op_moves(op, &cycle_count);
947   }
948   /* MPY(su,uu) : 0001 0101 1100 FsQQ : A-164 */
949   else if ((op & 0xfff0) == 0x15c0)
950   {
951      size = dsp56k_op_mpysuuu(op, &cycle_count);
952   }
953   /* NEGC : 0001 0101 0110 F000 : A-168 */
954   else if ((op & 0xfff7) == 0x1560)
955   {
956      size = dsp56k_op_negc(op, &cycle_count);
957   }
958   /* NOP : 0000 0000 0000 0000 : A-170 */
959   else if ((op & 0xffff) == 0x0000)
960   {
961      size = dsp56k_op_nop(op, &cycle_count);
962   }
963   /* NORM : 0001 0101 0010 F0RR : A-172 */
964   else if ((op & 0xfff4) == 0x1520)
965   {
966      size = dsp56k_op_norm(op, &cycle_count);
967   }
968   /* ORI : 0001 1EE1 iiii iiii : A-178 */
969   else if ((op & 0xf900) == 0x1900)
970   {
971      size = dsp56k_op_ori(op, &cycle_count);
972   }
973   /* REP : 0000 0000 111- --RR : A-180 */
974   else if ((op & 0xffe0) == 0x00e0)
975   {
976      size = dsp56k_op_rep(op, &cycle_count);
977   }
978   /* REP : 0000 1111 iiii iiii : A-180 */
979   else if ((op & 0xff00) == 0x0f00)
980   {
981      size = dsp56k_op_rep_1(op, &cycle_count);
982   }
983   /* REP : 0000 0100 001D DDDD : A-180 */
984   else if ((op & 0xffe0) == 0x0420)
985   {
986      size = dsp56k_op_rep_2(op, &cycle_count);
987   }
988   /* REPcc : 0000 0001 0101 cccc : A-184 */
989   else if ((op & 0xfff0) == 0x0150)
990   {
991      size = dsp56k_op_repcc(op, &cycle_count);
992   }
993   /* RESET : 0000 0000 0000 1000 : A-186 */
994   else if ((op & 0xffff) == 0x0008)
995   {
996      size = dsp56k_op_reset(op, &cycle_count);
997   }
998   /* RTI : 0000 0000 0000 0111 : A-194 */
999   else if ((op & 0xffff) == 0x0007)
1000   {
1001      size = dsp56k_op_rti(op, &cycle_count);
1002   }
1003   /* RTS : 0000 0000 0000 0110 : A-196 */
1004   else if ((op & 0xffff) == 0x0006)
1005   {
1006      size = dsp56k_op_rts(op, &cycle_count);
1007   }
1008   /* STOP : 0000 0000 0000 1010 : A-200 */
1009   else if ((op & 0xffff) == 0x000a)
1010   {
1011      size = dsp56k_op_stop(op, &cycle_count);
1012   }
1013   /* SWAP : 0001 0101 0111 F001 : A-206 */
1014   else if ((op & 0xfff7) == 0x1571)
1015   {
1016      size = dsp56k_op_swap(op, &cycle_count);
1017   }
1018   /* SWI : 0000 0000 0000 0101 : A-208 */
1019   else if ((op & 0xffff) == 0x0005)
1020   {
1021      size = dsp56k_op_swi(op, &cycle_count);
1022   }
1023   /* Tcc : 0001 00cc ccTT Fh0h : A-210 */
1024   else if ((op & 0xfc02) == 0x1000)
1025   {
1026      size = dsp56k_op_tcc(op, &cycle_count);
1027   }
1028   /* TFR(2) : 0001 0101 0000 F00J : A-214 */
1029   else if ((op & 0xfff6) == 0x1500)
1030   {
1031      size = dsp56k_op_tfr2(op, &cycle_count);
1032   }
1033   /* TFR(3) : 0010 01mW RRDD FHHH : A-216 */
1034   else if ((op & 0xfc00) == 0x2400)
1035   {
1036      size = dsp56k_op_tfr3(op, &cycle_count);
1037   }
1038   /* TST(2) : 0001 0101 0001 -1DD : A-220 */
1039   else if ((op & 0xfff4) == 0x1514)
1040   {
1041      size = dsp56k_op_tst2(op, &cycle_count);
1042   }
1043   /* WAIT : 0000 0000 0000 1011 : A-222 */
1044   else if ((op & 0xffff) == 0x000b)
1045   {
1046      size = dsp56k_op_wait(op, &cycle_count);
1047   }
1048   /* ZERO : 0001 0101 0101 F000 : A-224 */
1049   else if ((op & 0xfff7) == 0x1550)
1050   {
1051      size = dsp56k_op_zero(op, &cycle_count);
1052   }
7861053
787         // MOVE(P) - 0000 110W RRmp pppp
788         case 0x4: case 0x5: retSize = MovePOperation() ; break ;
7891054
790         // DO - 0000 1110 iiii iiii xxxx xxxx xxxx xxxx
791         case 0x6: retSize = DoOperation() ;  break ;
792
793         // REP - 0000 1111 iiii iiii
794         case 0x7: retSize = RepOperation() ; break ;
795      }
1055   /* Not recognized?  Nudge debugger onto the next word */
1056   if (size == 0x1337)
1057   {
1058      logerror("DSP56k: Unimplemented opcode at 0x%04x : %04x\n", PC, op);
1059      size = 1 ;                  // Just to get the debugger past the bad opcode
7961060   }
7971061
798   return retSize ;
799}
1062   /* Must have been a good opcode */
1063   PC += size;
1064   change_pc(PC);
8001065
801/*
802IMPLEMENTATIONS
803*/
1066   dsp56k_process_loop();
1067   dsp56k_process_rep(size);
8041068
805static int BitfieldOperation(void)
806{
807   int retSize = 0 ;
1069   dsp56k_icount -= 4;   /* Temporarily hard-coded at 4 clocks per opcode */   /* cycle_count */
1070}
8081071
809   // BITFIELD OPERATIONS
810   // ONLY PARTIALLY IMPLEMENTED !!!
8111072
812   // Get the next part of the opcode...
813   UINT16 op2 = ROPCODE((PC<<1)+2) ;
8141073
815   unsigned char dt = 0x00 ;
816   void *destinationReg = 0x00 ;
817   void *rReg = 0x00 ;
8181074
819   UINT16 destAddr = 0x00 ;
1075/***************************************************************************
1076    Opcode implementations
1077***************************************************************************/
8201078
821    UINT16 opVal ;
1079/*******************************/
1080/* 32 Parallel move operations */
1081/*******************************/
8221082
823   // Get the universal immediate value and its proper mask...
824   UINT16 iVal    = op2 & 0x00ff ;
825   DecodeBBBBitMask(BITS(op2,0xe000), &iVal) ;
1083/* ADD : 011m mKKK 0rru Fuuu : A-22 */
1084static size_t dsp56k_op_add_2(const UINT16 op_byte, UINT8* cycles)
1085{
1086   /* S L E U N Z V C */
1087   /* * * * * * * * * */
1088   return 0;
1089}
8261090
827   // Figure out where data you'll be dealing with comes from...
828   switch(BITS(OP,0x00e0))
829   {
830      case 0x6: case 0x7: case 0x2: case 0x3:
831         destAddr = AssembleDFromPTable(BITS(OP,0x0020), BITS(OP,0x001f)) ;
832         break ;
1091/* MAC : 011m mKKK 1xx0 F1QQ : A-122 */
1092static size_t dsp56k_op_mac_1(const UINT16 op_byte, UINT8* cycles)
1093{
1094   /* S L E U N Z V C */
1095   /* * * * * * * * - */
1096   return 0;
1097}
8331098
834      case 0x5:             case 0x1:
835         rReg = DecodeRRTable(BITS(OP,0x0003), &dt) ;
836         destAddr = *((UINT16*)rReg) ;
837         break ;
1099/* MACR: 011m mKKK 1--1 F1QQ : A-124 */
1100static size_t dsp56k_op_macr_1(const UINT16 op_byte, UINT8* cycles)
1101{
1102   /* S L E U N Z V C */
1103   /* * * * * * * * - */
1104   return 0;
1105}
8381106
839      case 0x4: case 0x0:
840         destinationReg = DecodeDDDDDTable(BITS(OP,0x001f), &dt) ;
841         break ;
842   }
1107/* MOVE : 011m mKKK 0rr1 0000 : A-128 */
1108static size_t dsp56k_op_move_1(const UINT16 op_byte, UINT8* cycles)
1109{
1110   /* S L E U N Z V C */
1111   /* * * - - - - - - */
1112   return 0;
1113}
8431114
844   // Grab the value to operate on...
845   if (destinationReg)
846   {
847      if (dt == DT_LONG_WORD)
848         opVal = (*((PAIR64*)destinationReg)).w.h ;
849      else
850         opVal = *((UINT16*)destinationReg) ;
851   }
852   else
853      opVal = data_read_word_16le(destAddr<<1) ;
1115/* MPY : 011m mKKK 1xx0 F0QQ : A-160 */
1116static size_t dsp56k_op_mpy_1(const UINT16 op_byte, UINT8* cycles)
1117{
1118   /* S L E U N Z V C */
1119   /* * * * * * * * - */
1120   return 0;
1121}
8541122
855   // Do the necessary bitfield operation...
856   switch(BITS(op2,0x1f00))
857   {
858      // bfchg
859      case 0x12:
860         if ((iVal & opVal) == iVal)   C_bit_set(1);      // test
861         else                     C_bit_set(0) ;
1123/* MPYR : 011m mKKK 1--1 F0QQ : A-162 */
1124static size_t dsp56k_op_mpyr_1(const UINT16 op_byte, UINT8* cycles)
1125{
1126   /* S L E U N Z V C */
1127   /* * * * * * * * - */
1128   return 0;
1129}
8621130
863         opVal ^= iVal ;                           // and change
864         break ;
1131/* SUB : 011m mKKK 0rru Fuuu : A-202 */
1132static size_t dsp56k_op_sub_1(const UINT16 op_byte, UINT8* cycles)
1133{
1134   /* S L E U N Z V C */
1135   /* * * * * * * * * */
1136   return 0;
1137}
8651138
866      // bfclr
867      case 0x04:
868         opVal &= (~iVal) ;
869         break ;
1139/* TFR : 011m mKKK 0rr1 F0DD : A-212 */
1140static size_t dsp56k_op_tfr_2(const UINT16 op_byte, UINT8* cycles)
1141{
1142   /* S L E U N Z V C */
1143   /* - - - - - - - - */
1144   return 0;
1145}
8701146
871      // bfset
872      case 0x18:
873         opVal |= iVal ;
874         break ;
1147/* MPY : 0001 0110 RRDD FQQQ : A-160 */
1148static size_t dsp56k_op_mpy_2(const UINT16 op_byte, UINT8* cycles)
1149{
1150   /* S L E U N Z V C */
1151   /* * * * * * * * - */
1152   return 0;
1153}
8751154
876      // bfsth
877      case 0x10:
878         mame_printf_debug("BFSTH - not here yet") ;
879         break ;
880
881      // bftstl
882      case 0x00:
883         if ((iVal & opVal) == 0)   C_bit_set(1);
884         else                   C_bit_set(0);
885         retSize = 2; return retSize;            /* It's just a test - no need to go on */
886         break ;
887   }
888
889   // Put the data back where it belongs
890   // !!! When setting A and B, I'm pretty sure if it's supposed to pass through the normal 'setDestValue' pipe but not entirely !!!
891   //     (in other words, does clearing ff.ffff.ffff with 001c really result in ff.ffe3.0000 or ff.ffe3.ffff) ???
892   if (destinationReg)
893      SetDestinationValue(&opVal, DT_WORD, destinationReg, dt) ;
894   else
895      SetDataMemoryValue(&opVal, DT_WORD, destAddr<<1) ;
896
897   retSize = 2 ;
898   return retSize ;
1155/* MAC : 0001 0111 RRDD FQQQ : A-122 */
1156static size_t dsp56k_op_mac_2(const UINT16 op_byte, UINT8* cycles)
1157{
1158   /* S L E U N Z V C */
1159   /* * * * * * * * - */
1160   return 0;
8991161}
9001162
901static int MoveCOperation(void)
1163/* CLR : .... .... 0000 F001 : A-60 */
1164static size_t dsp56k_op_clr(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
9021165{
903   int retSize = 0 ;
1166   typed_pointer D = {NULL, DT_LONG_WORD};
1167   typed_pointer clear = {NULL, DT_LONG_WORD};
1168   UINT64 clear_val = U64(0x0000000000000000);
9041169
905   unsigned char W = 0x00 ;
1170   decode_F_table(BITS(op_byte,0x0008), &D);
9061171
907   unsigned char sdt = 0x00 ;
908   void *SD ;
1172   *p_accum = *((UINT64*)D.addr);
9091173
910   // ONLY PARTIALLY IMPLEMENTED !!!
1174   clear.addr = &clear_val;
1175   clear.data_type = DT_LONG_WORD;
1176   SetDestinationValue(clear, D);
9111177
912   SD = DecodeDDDDDTable(BITS(OP,0x03e0), &sdt) ;
913   W  = BITS(OP,0x0400) ;
1178   d_register->addr = D.addr;
1179   d_register->data_type = D.data_type;
9141180
915   if (BITS(OP,0x1000))
916   {
917      // Single source/destination move(c)
918      if (!BITS(OP,0x0010))
919      {
920         // MM in move(c)
1181   /* S L E U N Z V C */
1182   /* * * * * * * 0 - */
1183   /* TODO - S&L */
1184   E_bit_set(0);
1185   U_bit_set(1);
1186   N_bit_set(0);
1187   Z_bit_set(1);
1188   V_bit_set(0);
9211189
922         // Get the r register...
923         unsigned char rt = 0x00 ;
924         void *R ;
1190   cycles += 2;   /* TODO: + mv oscillator clock cycles */
1191   return 1;
1192}
9251193
926         R = DecodeRRTable(BITS(OP,0x0003), &rt) ;
1194/* ADD : .... .... 0000 FJJJ : A-22 */
1195static size_t dsp56k_op_add(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1196{
1197   UINT64 addVal = 0;
9271198
928         if (W)
929         {
930            // !!! does this work ???
931            UINT16 data = data_read_word_16le((*((UINT16*)R))<<1) ;
932            SetDestinationValue(&data, DT_WORD, SD, sdt) ;
933         }
934         else
935         {
936            SetDataMemoryValue(SD, sdt, (*((UINT16*)R))<<1) ;
937         }
1199   typed_pointer S = {NULL, DT_BYTE};
1200   typed_pointer D = {NULL, DT_BYTE};
1201   decode_JJJF_table(BITS(op_byte,0x0007),BITS(op_byte,0x0008), &S, &D);
9381202
939         ExecuteMMTable(BITS(OP,0x0003), BITS(OP,0x000c)) ;
940         retSize = 1 ;
941      }
942      else
943      {
944         if (!BITS(OP,0x0004))
945         {
946            // q in move(c)
1203   *p_accum = *((UINT64*)D.addr);
9471204
948            // Figure out the true addr...
949            UINT16 addr = ExecuteqTable(BITS(OP,0x0003), BITS(OP,0x0008));
1205   switch(S.data_type)
1206   {
1207      case DT_WORD:        addVal = (UINT64)*((UINT16*)S.addr) << 16; break;
1208      case DT_DOUBLE_WORD: addVal = (UINT64)*((UINT32*)S.addr);       break;
1209      case DT_LONG_WORD:   addVal = (UINT64)*((UINT64*)S.addr);       break;
1210   }
9501211
951            if (W)
952            {
953               // !!! does this work ???
954               UINT16 data = data_read_word_16le(addr<<1) ;
955               SetDestinationValue(&data, DT_WORD, SD, sdt) ;
956            }
957            else
958            {
959               SetDataMemoryValue(SD, sdt, addr<<1);
960            }
1212   /* TODO: Verify : Sign-extend everyone for proper addition op */
1213   if (addVal &  U64(0x0000000080000000))
1214      addVal |= U64(0xffffffff00000000);
9611215
962            retSize = 1 ;
963         }
964         else
965         {
966            if (BITS(OP,0x0002))
967            {
968               // Z in move(c)
969               unsigned char rt = 0x00;
970               void *Z;
1216   /* Operate*/
1217   *((UINT64*)D.addr) += addVal;
9711218
972               Z = DecodeZTable(BITS(OP,0x0008), &rt);
1219   d_register->addr = D.addr;
1220   d_register->data_type = D.data_type;
9731221
974               if (W)
975               {
976                  // Unimplemented
977                  retSize = 666 ;
978               }
979               else
980               {
981                  SetDataMemoryValue(SD, sdt, (*((UINT16*)Z))<<1);
982                  retSize = 1;
983               }
984            }
985            else
986            {
987               // 2-word move(c)
988                UINT16 nextWord = ROPCODE((PC<<1)+2) ;
1222   /* S L E U N Z V C */
1223   /* * * * * * * * * */
1224   /* TODO S, L, E, U, V, C */
1225   if (*((UINT64*)D.addr) & U64(0x0000008000000000)) N_bit_set(1);
1226   if (*((UINT64*)D.addr) == 0) Z_bit_set(1);
9891227
990               if (BITS(OP,0x0008))
991               {
992                  // #xxxx - value read directly out of the opcode
993                  SetDestinationValue(&nextWord, DT_WORD, SD, sdt) ;
994               }
995               else
996               {
997                  // X:xxxx = value resides in X memory...
998                  if (W)
999                  {
1000                     // Read from X-data memory...
1001                     // !!! Does this work ???
1002                     UINT16 data = data_read_word_16le(nextWord<<1) ;
1003                     SetDestinationValue(&data, DT_WORD, SD, sdt) ;
1004                  }
1005                  else
1006                  {
1007                     // Write to X-data memory...
1008                     SetDataMemoryValue(SD, sdt, nextWord<<1) ;
1009                  }
1010               }
1228   cycles += 2;      /* TODO: + mv oscillator cycles */
1229   return 1;
1230}
10111231
1012               retSize = 2 ;
1013            }
1014         }
1015      }
1016   }
1017   else if (BITS(OP,0x2000))
1018   {
1019      // Source and Destination explicit
1020      unsigned char dt = 0x00 ;
1021      void *D ;
1232/* MOVE : .... .... 0001 0001 : A-128 */
1233static size_t dsp56k_op_move(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1234{
1235   /* S L E U N Z V C */
1236   /* * * - - - - - - */
1237   return 0;
1238}
10221239
1023      D = DecodeDDDDDTable(BITS(OP,0x001f), &dt) ;
1024      SetDestinationValue(SD, sdt, D, dt) ;
1240/* TFR : .... .... 0001 FJJJ : A-212 */
1241static size_t dsp56k_op_tfr(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1242{
1243   /* S L E U N Z V C */
1244   /* - - - - - - - - */
1245   return 0;
1246}
10251247
1026      retSize = 1 ;
1027   }
1028   else
1029   {
1030      // Double source/destination move(c)
1031
1032      retSize = 666 ;
1033   }
1034
1035   return retSize ;
1248/* RND : .... .... 0010 F000 : A-188 */
1249static size_t dsp56k_op_rnd(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1250{
1251   /* S L E U N Z V C */
1252   /* * * * * * * * - */
1253   return 0;
10361254}
10371255
1038static int MoveMOperation(void)
1256/* TST : .... .... 0010 F001 : A-218 */
1257static size_t dsp56k_op_tst(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
10391258{
1040   int retSize = 0 ;
1259   typed_pointer D = {NULL, DT_LONG_WORD};
10411260
1042   // ONLY PARTIALLY IMPLEMENTED !!!
1261   decode_F_table(BITS(op_byte,0x0008), &D);
10431262
1044   if (BITS(OP,0x0400))
1045   {
1046      // The double word MoveM operation...
1047       UINT16 nextWord = ROPCODE((PC<<1)+2) ;
1263   *p_accum = *((UINT64*)D.addr);
10481264
1049      UINT8 increment = BITS(OP,0x00ff) ;
1265   d_register->addr = D.addr;
1266   d_register->data_type = D.data_type;
10501267
1051      int W = BITS(nextWord, 0x0100) ;
1268   /* S L E U N Z V C */
1269   /* 0 * * * * * 0 0 */
1270   /* TODO: S, L, E, U */
1271   if ((*((UINT64*)D.addr)) & U64(0x0000008000000000)) N_bit_set(1); else N_bit_set(0);
1272   if ((*((UINT64*)D.addr)) == 0)                      Z_bit_set(1); else Z_bit_set(0);
1273   V_bit_set(0);
1274   C_bit_set(0);
10521275
1053      unsigned char sdt = 0x00 ;
1054      void *sdReg = 0x00 ;
1055      sdReg = DecodeHHHTable(BITS(nextWord,0x0007), &sdt) ;
1276   cycles += 2;   /* TODO: + mv oscillator clock cycles */
1277   return 1;
1278}
10561279
1057      if (W)
1058      {
1059         // Read from Program Memory...
1060         UINT16 data = program_read_word_16le((R2<<1)+(increment<<1)) ;
1061         SetDestinationValue(&data, DT_WORD, sdReg, sdt) ;
1062      }
1063      else
1064      {
1065         // Write to Program Memory...
1066         // !!! Does this work ???
1067         // SetMemoryValue(sdReg, sdt, ((R2<<1)+(increment<<1))) ;
1068      }
1280/* INC : .... .... 0010 F010 : A-104 */
1281static size_t dsp56k_op_inc(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1282{
1283   /* S L E U N Z V C */
1284   /* * * * * * * * * */
1285   return 0;
1286}
10691287
1070      retSize = 2 ;
1071   }
1072   else
1073   {
1074      // The single word MoveM operation...
1288/* INC24 : .... .... 0010 F011 : A-106 */
1289static size_t dsp56k_op_inc24(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1290{
1291   /* S L E U N Z V C */
1292   /* * * * * * ? * * */
1293   /* Z - Set if the 24 most significant bits of the destination result are all zeroes. */
1294   return 0;
1295}
10751296
1076      // Decode which way the data is going...
1077      int W = BITS(OP,0x0100) ;
1297/* OR : .... .... 0010 F1JJ : A-176 */
1298static size_t dsp56k_op_or(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1299{
1300   typed_pointer S = {NULL, DT_BYTE};
1301   typed_pointer D = {NULL, DT_BYTE};
10781302
1079      // Decode which R Register we're working with...
1080      unsigned char rt = 0x00 ;
1081      void *rReg = 0x00 ;
1082      rReg = DecodeRRTable(BITS(OP,0x00c0), &rt) ;
1303   decode_JJF_table(BITS(op_byte,0x0003), BITS(op_byte,0x0008), &S, &D);
10831304
1084      if (BITS(OP,0x0020))
1085      {
1086         // R and R operation
1087         retSize = 666 ;
1088      }
1089      else
1090      {
1091         // R and SD operation
1092         // Decode the SD register...
1093         unsigned char sdt = 0x00 ;
1094         void *sdReg = 0x00 ;
1095         sdReg = DecodeHHHTable(BITS(OP,0x0007), &sdt) ;
1305   /* Save some data for the parallel move */
1306   *p_accum = *((UINT64*)D.addr);
10961307
1097         if (W)
1098         {
1099            // Read from Program Memory...
1100            UINT16 data = program_read_word_16le( (*((UINT16*)rReg)) << 1 ) ;
1101            SetDestinationValue(&data, DT_WORD, sdReg, sdt) ;
1102         }
1103         else
1104         {
1105            // Write to Program Memory...
1106            SetProgramMemoryValue(sdReg, sdt, (*((UINT16*)rReg)) << 1 ) ;
1107         }
1308   /* OR a word of S with A1|B1 */
1309   ((PAIR64*)D.addr)->w.h = *((UINT16*)S.addr) | ((PAIR64*)D.addr)->w.h;
11081310
1109         // Execute the increment part of the opcode...
1110         ExecuteMMTable(BITS(OP,0x00c0), BITS(OP,0x0018)) ;
1311   d_register->addr = D.addr;
1312   d_register->data_type = D.data_type;
11111313
1112         retSize = 1 ;
1113      }
1114   }
1314   /* S L E U N Z V C */
1315   /* * * - - ? ? 0 - */
1316   /* TODO: S, L */
1317   if ( *((UINT64*)D.addr) & U64(0x0000000080000000))       N_bit_set(1); else N_bit_set(0);
1318   if ((*((UINT64*)D.addr) & U64(0x00000000ffff0000)) == 0) Z_bit_set(1); else Z_bit_set(0);
1319   V_bit_set(0);
11151320
1116   return retSize ;
1321   cycles += 2;      /* TODO: + mv oscillator cycles */
1322   return 1;
11171323}
11181324
1119static int MoveIOperation(void)
1325/* ASR : .... .... 0011 F000 : A-32 */
1326static size_t dsp56k_op_asr(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
11201327{
1121   int retSize = 1 ;
1328   typed_pointer D = {NULL, DT_BYTE};
1329   decode_F_table(BITS(op_byte,0x0008), &D);
11221330
1123   // The 8-bit signed immediate operand is stored in the low byte of destination
1124   //   register D after having been sign extended.
1331   *p_accum = *((UINT64*)D.addr);
11251332
1126   INT8 immediateVal = OP & 0x00ff ;
1127   UINT16 immediateWord ;
1333   *((UINT64*)D.addr) = (*((UINT64*)D.addr)) >> 1;
11281334
1129   unsigned char dt = 0x00 ;
1130   void *destinationReg = 0x00 ;
1335   /* Make sure the MSB is maintained */
1336   if (*p_accum & U64(0x0000008000000000))
1337      *((UINT64*)D.addr) |= U64(0x0000008000000000);
1338   else
1339      *((UINT64*)D.addr) &= (~U64(0x0000008000000000));
11311340
1132   destinationReg = DecodeDDTable(BITS(OP,0x0300), &dt) ;
1341   /* For the parallel move */
1342   d_register->addr = D.addr;
1343   d_register->data_type = D.data_type;
11331344
1134   // Sign extend the immediate value...
1135   // !!! On Intel architecture this works correctly, does it work everywhere ???
1136   immediateWord = (INT16)immediateVal ;
1345   /* S L E U N Z V C */
1346   /* * * * * * * 0 ? */
1347   /* TODO: S, L, E, U */
1348   if (*((UINT64*)D.addr) & U64(0x0000008000000000)) N_bit_set(1);
1349   if (*((UINT64*)D.addr) == 0) Z_bit_set(1);
1350   V_bit_set(0);
1351   if (*p_accum & U64(0x0000000000000001)) C_bit_set(1);
11371352
1138   SetDestinationValue(&immediateWord, DT_WORD, destinationReg, dt) ;
1353   cycles += 2;      /* TODO: + mv oscillator cycles */
1354   return 1;
1355}
11391356
1140   return retSize ;
1357/* ASL : .... .... 0011 F001 : A-28 */
1358static size_t dsp56k_op_asl(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1359{
1360   /* S L E U N Z V C */
1361   /* * * * * * * ? ? */
1362   /* V - Set if an arithmetic overflow occurs in the 40 bit result. Also set if the most significant
1363           bit of the destination operand is changed as a result of the left shift. Cleared otherwise. */
1364    /* C - Set if bit 39 of source operand is set. Cleared otherwise. */
1365   return 0;
11411366}
11421367
1143static int MovePOperation(void)
1368/* LSR : .... .... 0011 F010 : A-120 */
1369static size_t dsp56k_op_lsr(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
11441370{
1145   int retSize = 1 ;
1371   typed_pointer D = {NULL, DT_BYTE};
1372   decode_F_table(BITS(op_byte,0x0008), &D);
11461373
1147   if (BITS(OP,0x1000))
1148   {
1149      // X:<pp> and SD
1150      UINT16 pp ;
1151      UINT16 W  ;
1374   *p_accum = *((UINT64*)D.addr);
11521375
1153      unsigned char sdt = 0x00 ;
1154      void *SD = 0x00 ;
1376   ((PAIR64*)D.addr)->w.h = (((PAIR64*)D.addr)->w.h) >> 1;
11551377
1156      SD = DecodeHHTable(BITS(OP,0x00c0), &sdt) ;
1378   /* Make sure bit 31 gets a 0 */
1379   ((PAIR64*)D.addr)->w.h &= (~0x8000);
11571380
1158      pp = BITS(OP,0x001f) ;
1159      pp = AssembleAddressFromIOShortAddress(pp) ;
1381   /* For the parallel move */
1382   d_register->addr = D.addr;
1383   d_register->data_type = D.data_type;
11601384
1161      W = BITS(OP,0x0100) ;
1385   /* S L E U N Z V C */
1386   /* * * - - ? ? 0 ? */
1387   /* TODO: S, L */
1388   N_bit_set(0);
1389   if (((PAIR64*)D.addr)->w.h == 0) Z_bit_set(1);
1390   V_bit_set(0);
1391   if (*p_accum & U64(0x0000000000010000)) C_bit_set(1);
11621392
1163      if (W)
1164      {
1165         UINT16 data = data_read_word_16le(pp<<1) ;
1166         SetDestinationValue(&data, DT_WORD, SD, sdt) ;
1167      }
1168      else
1169      {
1170         SetDataMemoryValue(SD, sdt, pp<<1) ;
1171      }
1172   }
1173   else
1174   {
1175      // X:<Rx> and X:<pp>
1176      UINT16 pp ;
1177      UINT16 W  ;
1393   cycles += 2;      /* TODO: + mv oscillator cycles */
1394   return 1;
1395}
11781396
1179      unsigned char sdrt = 0x00 ;
1180      void *sdrReg       = 0x00 ;
1181      sdrReg = DecodeRRTable(BITS(OP,0x00c0), &sdrt) ;
1397/* LSL : .... .... 0011 F011 : A-118 */
1398static size_t dsp56k_op_lsl(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1399{
1400   /* S L E U N Z V C */
1401   /* * * - - ? ? 0 ? */
1402   /* N - Set if bit 31 of the result is set. Cleared otherwise. */
1403   /* Z - Set if bits 16-31 of the result are zero. Cleared otherwise. */
1404   /* C - Set if bit 31 of the source operand is set. Cleared otherwise. */
1405   return 0;
1406}
11821407
1183      pp = BITS(OP,0x001f) ;
1184      pp = AssembleAddressFromIOShortAddress(pp) ;
1408/* EOR : .... .... 0011 F1JJ : A-94 */
1409static size_t dsp56k_op_eor(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1410{
1411   /* S L E U N Z V C */
1412   /* * * - - ? ? 0 - */
1413   /* N - Set if bit 31 of the result is set. Cleared otherwise. */
1414   /* Z - Set if bits 16-31 of the result are zero. Cleared otherwise. */
1415   return 0;
1416}
11851417
1186      W = BITS(OP,0x0100) ;
1418/* SUBL : .... .... 0100 F001 : A-204 */
1419static size_t dsp56k_op_subl(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1420{
1421   /* S L E U N Z V C */
1422   /* * * * * * * ? * */
1423   /* V - Set if an arithmetic overflow occurs in the 40 bit result. Also set if the most significant
1424           bit of the destination operand is changed as a result of the left shift. Cleared otherwise. */
1425   return 0;
1426}
11871427
1188      // A little different than most W if's - opposite read and write thingies...
1189      if (W)
1190      {
1191         UINT16 data = data_read_word_16le( (*((UINT16*)sdrReg))<<1 ) ;      // read the word out
1192         SetDataMemoryValue(&data, DT_WORD, pp<<1) ;
1193      }
1194      else
1195      {
1196         mame_printf_debug("NOTHING HERE (yet)\n") ;
1197      }
1428/* SUB : .... .... 0100 FJJJ : A-202 */
1429static size_t dsp56k_op_sub(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1430{
1431   /* S L E U N Z V C */
1432   /* * * * * * * * * */
1433   return 0;
1434}
11981435
1199      // Postincrement
1200      ExecutemTable(BITS(OP,0x00c0), BITS(OP,0x0020)) ;
1201   }
1436/* CLR24 : .... .... 0101 F001 : A-62 */
1437static size_t dsp56k_op_clr24(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1438{
1439   /* S L E U N Z V C */
1440   /* * * * * * ? 0 - */
1441   /* Z - Set if the 24 most significant bits of the destination result are all zeroes. */
1442   return 0;
1443}
12021444
1203   return retSize ;
1445/* SBC : .... .... 0101 F01J : A-198 */
1446static size_t dsp56k_op_sbc(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1447{
1448   /* S L E U N Z V C */
1449   /* * * * * * * * * */
1450   return 0;
12041451}
12051452
1206
1207static int JmpOperation(void)
1453/* CMP : .... .... 0101 FJJJ : A-64 */
1454static size_t dsp56k_op_cmp(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
12081455{
1209   int retSize = 0 ;
1456   UINT64 cmpVal = 0;
1457   UINT64 result = 0;
12101458
1211   core.ppc = PC;
1459   typed_pointer S = {NULL, DT_BYTE};
1460   typed_pointer D = {NULL, DT_BYTE};
12121461
1213   if (BITS(OP,0x0010))
1462   decode_JJJF_table(BITS(op_byte,0x0007),BITS(op_byte,0x0008), &S, &D);
1463
1464   *p_accum = *((UINT64*)D.addr);
1465
1466   switch(S.data_type)
12141467   {
1215      PC = (ROPCODE((PC<<1)+2)) ;      // Can this offset by 2 bytes be handled better?  Say, for example, by moving "1 word"?
1216      change_pc(PC) ;
1468      case DT_WORD:        cmpVal = (UINT64)*((UINT16*)S.addr);  break;
1469      case DT_DOUBLE_WORD: cmpVal = (UINT64)*((UINT32*)S.addr);  break;
1470      case DT_LONG_WORD:   cmpVal = (UINT64)*((UINT64*)S.addr);  break;
12171471   }
1218   else
1219   {
1220      unsigned char rt = 0x00 ;
1221      void *R = 0x00 ;
12221472
1223      R = DecodeRRTable(BITS(OP,0x0003), &rt);
1473   result = *((UINT64*)D.addr) - cmpVal;
12241474
1225      PC = *((UINT16*)R);
1226      change_pc(PC);
1227   }
1475   d_register->addr = D.addr;
1476   d_register->data_type = D.data_type;
12281477
1229   retSize = 0 ;               // Jump with no offset.
1478   /* S L E U N Z V C */
1479   /* * * * * * * * * */
1480   /* TODO: S, L, E, U, N, V, C */
1481   if (result == 0) Z_bit_set(1);      /* TODO: Do you clear it if this isn't true? */
12301482
1231   return retSize ;
1483
1484   cycles += 2;      /* TODO: + mv oscillator clock cycles */
1485   return 1;
12321486}
12331487
1234static int BsrOperation(void)
1488/* NEG : .... .... 0110 F000 : A-166 */
1489static size_t dsp56k_op_neg(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
12351490{
1236   int retSize = 0 ;
1491   /* S L E U N Z V C */
1492   /* * * * * * * * * */
1493   return 0;
1494}
12371495
1238   INT16 branchOffset = (ROPCODE((PC<<1)+2)) ;   // Can this offset by 2 bytes be handled better?  Say, for example, by moving "1 word"?
1496/* NOT : .... .... 0110 F001 : A-174 */
1497static size_t dsp56k_op_not(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1498{
1499   typed_pointer D = {NULL, DT_BYTE};
1500   decode_F_table(BITS(op_byte,0x0008), &D);
12391501
1240   // "The PC Contains the address of the next instruction"
1241   PC += 2 ;
1242   core.ppc = PC ;
1502   *p_accum = *((UINT64*)D.addr);
12431503
1244   // Push the PC to the stack...
1245   SP++ ;               // !!! I'm not so sure about this 'pre-increment'
1246                     //     The reason it might be there is that SSH and SSL are supposed to point to the top of the
1247                     //     stack (and the docs seem to imply this behaviour).  But it wastes the first stack entry ???
1248                     //     !!! I think i've read somewhere that PC == 1 when the stack is empty ???
1249                     //     !!! I also .know. there are only 15 stack entries - could this be why ???
1250   SSH = PC ;
1251   SSL = SR ;
1504   /* Invert bits [16:31] of D */
1505   ((PAIR64*)D.addr)->w.h = ~(((PAIR64*)D.addr)->w.h);
12521506
1253   PC += branchOffset ;
1507   d_register->addr = D.addr;
1508   d_register->data_type = D.data_type;
12541509
1255   retSize = 0 ;                           // Branch and then no offset.
1510   /* S L E U N Z V C */
1511   /* * * - - ? ? 0 - */
1512   /* TODO: S?, L */
1513   if ( *((UINT64*)D.addr) & U64(0x0000000080000000))       N_bit_set(1);
1514   if ((*((UINT64*)D.addr) & U64(0x00000000ffff0000)) == 0) Z_bit_set(1);
1515   V_bit_set(0);
12561516
1257   change_pc(PC) ;
1258
1259   return retSize ;
1517   cycles += 2;      /* TODO: + mv oscillator cycles */
1518   return 1;
12601519}
12611520
1262static int JsrOperation(void)
1521/* DEC : .... .... 0110 F010 : A-72 */
1522static size_t dsp56k_op_dec(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
12631523{
1264   int retSize = 0;
1265
1266   // Handle other JSR types!
1267   INT16 branchOffset = (ROPCODE((PC<<1)+2)) ;   // Can this offset by 2 bytes be handled better?  Say, for example, by moving "1 word"?
1268
1269   // The docs say nothing of this, but I swear it *must* be true
1270   PC += 2 ;
1271   core.ppc = PC ;
1272
1273   // See bsr operation
1274   SP++;
1275   SSH = PC;
1276   SSL = SR;
1277
1278   PC = branchOffset;
1279
1280   return retSize;
1524   /* S L E U N Z V C */
1525   /* * * * * * * * * */
1526   return 0;
12811527}
12821528
1283static int BraOperation(void)
1529/* DEC24 : .... .... 0110 F011 : A-74 */
1530static size_t dsp56k_op_dec24(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
12841531{
1285   int retSize = 0 ;
1532   UINT32 workBits24;
12861533
1287   // Branch to the location in program memory at location PC+displacement.
1288   INT16 branchOffset = 0x00;
1534   typed_pointer D = {NULL, DT_BYTE};
1535   decode_F_table(BITS(op_byte,0x0008), &D);
12891536
1290   if (BITS(OP,0x0800))
1291   {
1292      // 8 bit immediate (relative) offset
1293      branchOffset = (INT8)BITS(OP,0x00ff) ;
1537   /* Save some data for the parallel move */
1538   *p_accum = *((UINT64*)D.addr);
12941539
1295      // "The PC Contains the address of the next instruction"
1296      PC += 1 ;
1297   }
1298   else if (BITS(OP,0x0010))
1299   {
1300      // 16 bit immediate (relative) offset
1301      retSize = 666 ;
1302   }
1303   else if (!BITS(OP,0x0010))
1304   {
1305      // 16 bit Rx offset
1306      retSize = 666 ;
1307   }
1540   /* TODO: I wonder if workBits24 should be signed? */
1541   workBits24 = ((*((UINT64*)D.addr)) & U64(0x000000ffffff0000)) >> 16;
1542   workBits24--;
1543   workBits24 &= 0x00ffffff;      /* Solves -x issues */
13081544
1309   core.ppc = PC ;
1310   PC += branchOffset ;
1545   /* Set the D bits with the dec result */
1546   *((UINT64*)D.addr) &= U64(0x000000000000ffff);
1547   *((UINT64*)D.addr) |= (((UINT64)(workBits24)) << 16);
13111548
1312   change_pc(PC) ;
1549   d_register->addr = D.addr;
1550   d_register->data_type = D.data_type;
13131551
1314   return retSize ;
1552   /* S L E U N Z V C */
1553   /* * * * * * ? * * */
1554   /* TODO: S, L, E, U, V, C */
1555   if ( *((UINT64*)D.addr) & U64(0x0000008000000000))       N_bit_set(1);
1556   if ((*((UINT64*)D.addr) & U64(0x000000ffffff0000)) == 0) Z_bit_set(1);
1557
1558   cycles += 2;      /* TODO: + mv oscillator clock cycles */
1559   return 1;
13151560}
13161561
1317
1318static int DoOperation(void)
1562/* AND : .... .... 0110 F1JJ : A-24 */
1563static size_t dsp56k_op_and(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
13191564{
1320   int retSize = 0 ;
1565   typed_pointer S = {NULL, DT_BYTE};
1566   typed_pointer D = {NULL, DT_BYTE};
13211567
1322   UINT16 offset ;
1568   decode_JJF_table(BITS(op_byte,0x0003), BITS(op_byte,0x0008), &S, &D);
13231569
1324   // First instruction cycle
1325   SP++ ;
1326   SSH = LA ;
1327   SSL = LC ;
1570   /* Save some data for the parallel move */
1571   *p_accum = *((UINT64*)D.addr);
13281572
1329   if (BITS(OP,0x0800))
1330   {
1331      // #xx,expr
1332      LC = BITS(OP,0x00ff) ;
1333      retSize = 2 ;
1334   }
1335   else if (BITS(OP,0x0400))
1336   {
1337      // S,expr
1338      unsigned char sdt = 0x00 ;
1339      void *SD ;
1573   /* AND a word of S with A1|B1 */
1574   ((PAIR64*)D.addr)->w.h = *((UINT16*)S.addr) & ((PAIR64*)D.addr)->w.h;
13401575
1341      // !!! Watch out for the special cases (FamilyManual page 276) !!!
1342      SD = DecodeDDDDDTable(BITS(OP,0x001f), &sdt) ;
1343      SetDestinationValue(SD, sdt, &LC, DT_WORD) ;
1344      retSize = 2 ;
1345   }
1346   else
1347   {
1348      // X:(Rn),expr
1349      retSize = 666 ;
1350   }
1576   d_register->addr = D.addr;
1577   d_register->data_type = D.data_type;
13511578
1579   /* S L E U N Z V C */
1580   /* * * - - ? ? 0 - */
1581   /* TODO: S, L */
1582   if ( *((UINT64*)D.addr) & U64(0x0000000080000000))       N_bit_set(1);
1583   if ((*((UINT64*)D.addr) & U64(0x00000000ffff0000)) == 0) Z_bit_set(1);
1584   V_bit_set(0);
13521585
1353   // Second instruction cycle
1354   SP++ ;
1355   SSH = PC+2 ;         // The value in the Program Counter (PC) register pushed onto the system stack is the address of the first instruction following the DO instruction
1356   SSL = SR ;
1586   cycles += 2;      /* TODO: + mv oscillator cycles */
1587   return 1;
1588}
13571589
1358   offset = 0x00 ;         // The offset is the same for all DO instructions...
1359   offset = (ROPCODE((PC<<1)+2)) ;
1360   offset += PC+2 ;
1361   LA = offset ;
1590/* ABS : .... .... 0111 F001 : A-18 */
1591static size_t dsp56k_op_abs(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1592{
1593   /* S L E U N Z V C */
1594   /* * * * * * * * - */
1595   return 0;
1596}
13621597
1598/* ROR : .... .... 0111 F010 : A-192 */
1599static size_t dsp56k_op_ror(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1600{
1601   /* S L E U N Z V C */
1602   /* * * - - ? ? 0 ? */
1603   /* N - Set if bit 31 of the result is set. Cleared otherwise. */
1604   /* Z - Set if bits 16-31 of the result are zero. Cleared otherwise. */
1605   /* C - Set if bit 16 of the source operand is set. Cleared otherwise. */
1606   return 0;
1607}
13631608
1364   // Third instruction cycle
1365   LF_bit_set(1);
1609/* ROL : .... .... 0111 F011 : A-190 */
1610static size_t dsp56k_op_rol(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1611{
1612   /* S L E U N Z V C */
1613   /* * * - - ? ? 0 ? */
1614   /* N - Set if bit 31 of the result is set. Cleared otherwise. */
1615   /* Z - Set if bits 16-31 of the result are zero. Cleared otherwise. */
1616   /* C - Set if bit 31 of the source operand is set. Cleared otherwise. */
1617    return 0;
1618}
13661619
1367   return retSize ;
1620/* CMPM : .... .... 0111 FJJJ : A-66 */
1621static size_t dsp56k_op_cmpm(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1622{
1623   /* S L E U N Z V C */
1624   /* * * * * * * * * */
1625   return 0;
13681626}
13691627
1370static void EndOfLoopProcessing(void)
1628/* MPY : .... .... 1k00 FQQQ : A-160    -- CONFIRMED TYPO IN DOCS (HHHH vs HHHW) */
1629static size_t dsp56k_op_mpy(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
13711630{
1372   SR = SSL ;
1373   SP-- ;
1374   LA = SSH ;
1375   LC = SSL ;
1376   SP-- ;
1631   /* S L E U N Z V C */
1632   /* * * * * * * * - */
1633   return 0;
13771634}
13781635
1379static int Dec24Operation(void **wd, UINT64 *pa)
1636/* MPYR : .... .... 1k01 FQQQ : A-162 */
1637static size_t dsp56k_op_mpyr(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
13801638{
1381   int retSize = 1 ;
1639   /* S L E U N Z V C */
1640   /* * * * * * * * - */
1641   return 0;
1642}
13821643
1383   UINT64 decMe ;
1644/* MAC : .... .... 1k10 FQQQ : A-122 */
1645static size_t dsp56k_op_mac(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1646{
1647   /* S L E U N Z V C */
1648   /* * * * * * * * - */
1649   return 0;
1650}
13841651
1385   unsigned char drt = 0x00 ;
1386   void *D = 0x00 ;
1387   D = DecodeFTable(BITS(OP,0x0008), &drt) ;
1652/* MACR : .... .... 1k11 FQQQ : A-124   -- DRAMA - rr vs xx (805) */
1653static size_t dsp56k_op_macr(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
1654{
1655   /* S L E U N Z V C */
1656   /* * * * * * * * - */
1657   return 0;
1658}
13881659
1389   *pa = *((UINT64*)D) ;   // backup the previous value
13901660
1391   // !! I wonder if this should be a signed int instead !!
1392   decMe = (*((UINT64*)D) & (UINT64)U64(0xffffff0000)) >> 16 ;
1393   decMe-- ;
1394   decMe &= (UINT64)U64(0x0000000000ffffff) ;                  // For wraparound - Make sure no bits get set improperly in A/B
1661/******************************/
1662/* Remaining non-parallel ops */
1663/******************************/
13951664
1396//  UINT8 carryBit = (*((UINT64*)D) & 0x0000008000000000) >> 39 ;   // For determinating carry status...
1665/* ADC : 0001 0101 0000 F01J : A-20 */
1666static size_t dsp56k_op_adc(const UINT16 op, UINT8* cycles)
1667{
1668   /* S L E U N Z V C */
1669   /* - * * * * * * * */
1670   return 0;
1671}
13971672
1398   *((UINT64*)D) &= (UINT64)U64(0x000000000000ffff) ;            // Prepare the destination to be set...
1399   *((UINT64*)D) |= (decMe << 16) ;                  // Set the top 24 bits accordingly...
1673/* ANDI : 0001 1EE0 iiii iiii : A-26 */
1674static size_t dsp56k_op_andi(const UINT16 op, UINT8* cycles)
1675{
1676   UINT16 immediate = BITS(op,0x00ff);
14001677
1401   // Carry flag (C) - HACK
1402//  if (decMe == 0x0000000000ff7fff)
1403//      SET_cBIT() ;
1404//  else
1405//      CLEAR_cBIT() ;
1678   /* There is not currently a good way to refer to CCR or MR.  Explicitly decode here. */
1679   switch(BITS(op,0x0600))
1680   {
1681      case 0x01:   /* MR */
1682         SR &= ((immediate << 8) | 0x00ff);
1683         break;
14061684
1407   // Carry flag (C)
1408//  UINT8 postCarryBit = (*((UINT64*)D) & 0x0000008000000000) >> 39 ;
1409//  if (postCarryBit != carryBit)   SET_cBIT() ;
1410//  else                          CLEAR_cBIT() ;
1685      case 0x02:   /* CCR */
1686         SR &= (immediate | 0xff00);
1687         break;
14111688
1412    *wd = D ;
1689      case 0x03:   /* OMR */
1690         OMR &= (UINT8)(immediate);
1691         break;
14131692
1414/*
1415    UINT32 decMe = ((*((PAIR64*)D)).b.h4 << 16) | (*((PAIR64*)D)).w.h ;
1693      default:
1694         fatalerror("DSP56k - BAD EE value in andi operation") ;
1695   }
14161696
1417    int fflag = 0 ;
1418    if (decMe == 0x00007fff) fflag = 1 ;
1697   /* S L E U N Z V C */
1698   /* - ? ? ? ? ? ? ? */
1699   /* All ? bits - Cleared if the corresponding bit in the immediate data is cleared and if the operand
1700       is the CCR. Not affected otherwise. */
1701   cycles += 2;
1702   return 1;
1703}
14191704
1420    if (fflag) mame_printf_debug("%08x\n", decMe) ;
1705/* ASL4 : 0001 0101 0011 F001 : A-30 */
1706static size_t dsp56k_op_asl4(const UINT16 op, UINT8* cycles)
1707{
1708   /* S L E U N Z V C */
1709   /* - ? * * * * ? ? */
1710   /* V - Set if an arithmetic overflow occurs in the 40 bit result. Also set if bit 5 through 39 are
1711           not the same. */
1712   /* C - Set if bit 36 of source operand is set. Cleared otherwise. */
1713   return 0;
1714}
14211715
1422    decMe-- ;
1716/* ASR4 : 0001 0101 0011 F000 : A-34 */
1717static size_t dsp56k_op_asr4(const UINT16 op, UINT8* cycles)
1718{
1719   /* S L E U N Z V C */
1720   /* - * * * * * 0 ? */
1721   /* C - Set if bit 3 of source operand is set. Cleared otherwise. */
1722   return 0;
1723}
14231724
1424    if (fflag) mame_printf_debug("%08x\n", decMe) ;
1725/* ASR16 : 0001 0101 0111 F000 : A-36 */
1726static size_t dsp56k_op_asr16(const UINT16 op, UINT8* cycles)
1727{
1728   /* S L E U N Z V C */
1729   /* - * * * * * 0 ? */
1730   /* C - Set if bit 15 of source operand is set. Cleared otherwise. */
1731   return 0;
1732}
14251733
1426    decMe &= 0x00ffffff ;
1734/* BFCHG  : 0001 0100 11Pp pppp BBB1 0010 iiii iiii : A-38 */
1735/* BFCLR  : 0001 0100 11Pp pppp BBB0 0100 iiii iiii : A-40 */
1736/* BFSET  : 0001 0100 11Pp pppp BBB1 1000 iiii iiii : A-42 */
1737/* BFTSTH : 0001 0100 01Pp pppp BBB1 0000 iiii iiii : A-44 */
1738/* BFTSTL : 0001 0100 01Pp pppp BBB0 0000 iiii iiii : A-46 */
1739static size_t dsp56k_op_bfop(const UINT16 op, const UINT16 op2, UINT8* cycles)
1740{
1741   UINT16 workAddr = 0x0000;
1742   UINT16 workingWord = 0x0000;
1743   UINT16 previousValue = 0x0000;
1744   typed_pointer tempTP = { NULL, DT_BYTE };
14271745
1428    if (fflag) mame_printf_debug("%08x\n", decMe) ;
1746   UINT16 iVal = op2 & 0x00ff;
1747   decode_BBB_bitmask(BITS(op2,0xe000), &iVal);
14291748
1430    UINT8 carryBit = ((*((PAIR64*)D)).b.h4 & 0x80) >> 7 ;
1749   workAddr = assemble_address_from_Pppppp_table(BITS(OP,0x0020), BITS(OP,0x001f));
1750   previousValue = data_read_word_16le(WORD(workAddr));
1751   workingWord = previousValue;
14311752
1432    (*((PAIR64*)D)).b.h4 = (decMe & 0x00ff0000) >> 16 ;
1433    (*((PAIR64*)D)).w.h  = (decMe & 0x0000ffff) ;
1753   switch(BITS(op2, 0x1f00))
1754   {
1755      case 0x12:   /* BFCHG */
1756         workingWord ^= iVal;
1757         break;
1758      case 0x04:   /* BFCLR */
1759         workingWord = workingWord & (~iVal);
1760         break;
1761      case 0x18:   /* BFSET */
1762         workingWord = workingWord | iVal;
1763         break;
1764      case 0x10:   /* BFTSTH */
1765         /* Just the test below */
1766         break;
1767      case 0x00:   /* BFTSTL */
1768         /* Just the test below */
1769         break;
1770   }
14341771
1435    if (fflag) mame_printf_debug("%2x\n", (*((PAIR64*)D)).b.h4) ;
1436    if (fflag) mame_printf_debug("%4x\n", (*((PAIR64*)D)).w.h) ;
1772   tempTP.addr = &workingWord;
1773   tempTP.data_type = DT_WORD;
1774   SetDataMemoryValue(tempTP, WORD(workAddr));
14371775
1438    // Carry flag (C)
1439    UINT8 postCarryBit = ((*((PAIR64*)D)).b.h4 & 0x80) >> 7 ;
1440    if (postCarryBit != carryBit)   SET_cBIT() ;
1441    else                          CLEAR_cBIT() ;
1776   /* S L E U N Z V C */
1777   /* - * - - - - - ? */
1778   /* TODO: L */
1779   switch(BITS(op2, 0x1f00))
1780   {
1781      case 0x12:   /* BFCHG */
1782         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1783      case 0x04:   /* BFCLR */
1784         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1785      case 0x18:   /* BFSET */
1786         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1787      case 0x10:   /* BFTSTH */
1788         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1789      case 0x00:   /* BFTSTL */
1790         if ((iVal & previousValue) == 0x0000) C_bit_set(1); else C_bit_set(0); break;
1791   }
14421792
1443    *wd = D ;
1444*/
1445   return retSize ;
1793   cycles += 4;    /* TODO: + mvb oscillator clock cycles */
1794   return 2;
14461795}
14471796
1448static int AddOperation(void **wd, UINT64 *pa)
1797/* BFCHG  : 0001 0100 101- --RR BBB1 0010 iiii iiii : A-38 */
1798/* BFCLR  : 0001 0100 101- --RR BBB0 0100 iiii iiii : A-40 */
1799/* BFSET  : 0001 0100 101- --RR BBB1 1000 iiii iiii : A-42 */
1800/* BFTSTH : 0001 0100 001- --RR BBB1 0000 iiii iiii : A-44 */
1801/* BFTSTL : 0001 0100 001- --RR BBB0 0000 iiii iiii : A-46 */
1802static size_t dsp56k_op_bfop_1(const UINT16 op, const UINT16 op2, UINT8* cycles)
14491803{
1450   UINT64 addVal = 0x00;
1804   UINT16 workAddr = 0x0000;
1805   UINT16 workingWord = 0x0000;
1806   UINT16 previousValue = 0x0000;
1807   typed_pointer R = { NULL, DT_BYTE };
1808   typed_pointer tempTP = { NULL, DT_BYTE };
14511809
1452   unsigned char st = 0x00, dt = 0x00 ;
1453   void *S = 0x00, *D = 0x00;
1810   UINT16 iVal = op2 & 0x00ff;
1811   decode_BBB_bitmask(BITS(op2,0xe000), &iVal);
14541812
1455   DecodeJJJFTable(BITS(OP,0x0007),BITS(OP,0x0008), &S, &st, &D, &dt) ;
1813   decode_RR_table(BITS(op,0x0003), &R);
14561814
1457   *pa = *((UINT64*)D) ;   // backup the previous value
1815   workAddr = *((UINT16*)R.addr);
1816   previousValue = data_read_word_16le(WORD(workAddr));
1817   workingWord = previousValue;
14581818
1459   switch(st)
1819   switch(BITS(op2, 0x1f00))
14601820   {
1461      case DT_WORD:        addVal = (UINT64)*((UINT16*)S) << 16 ; break ;
1462      case DT_DOUBLE_WORD: addVal = (UINT64)*((UINT32*)S) ;       break ;
1463      case DT_LONG_WORD:   addVal = (UINT64)*((UINT64*)S) ;       break ;
1821      case 0x12:   /* BFCHG */
1822         workingWord ^= iVal;
1823         break;
1824      case 0x04:   /* BFCLR */
1825         workingWord = workingWord & (~iVal);
1826         break;
1827      case 0x18:   /* BFSET */
1828         workingWord = workingWord | iVal;
1829         break;
1830      case 0x10:   /* BFTSTH */
1831         /* Just the test below */
1832         break;
1833      case 0x00:   /* BFTSTL */
1834         /* Just the test below */
1835         break;
14641836   }
14651837
1466   *((UINT64*)D) += addVal ;
1838   tempTP.addr = &workingWord;
1839   tempTP.data_type = DT_WORD;
1840   SetDataMemoryValue(tempTP, WORD(workAddr));
14671841
1468   *wd = D ;
1842   /* S L E U N Z V C */
1843   /* - * - - - - - ? */
1844   /* TODO: L */
1845   switch(BITS(op2, 0x1f00))
1846   {
1847      case 0x12:   /* BFCHG */
1848         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1849      case 0x04:   /* BFCLR */
1850         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1851      case 0x18:   /* BFSET */
1852         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1853      case 0x10:   /* BFTSTH */
1854         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1855      case 0x00:   /* BFTSTL */
1856         if ((iVal & previousValue) == 0x0000) C_bit_set(1); else C_bit_set(0); break;
1857   }
14691858
1470    return 1 ;
1859   cycles += 4;    /* TODO: + mvb oscillator clock cycles */
1860   return 2;
14711861}
14721862
1473static int LsrOperation(void **wd, UINT64 *pa)
1863/* BFCHG  : 0001 0100 100D DDDD BBB1 0010 iiii iiii : A-38 */
1864/* BFCLR  : 0001 0100 100D DDDD BBB0 0100 iiii iiii : A-40 */
1865/* BFSET  : 0001 0100 100D DDDD BBB1 1000 iiii iiii : A-42 */
1866/* BFTSTH : 0001 0100 000D DDDD BBB1 0000 iiii iiii : A-44 */
1867/* BFTSTL : 0001 0100 000D DDDD BBB0 0000 iiii iiii : A-46 */
1868static size_t dsp56k_op_bfop_2(const UINT16 op, const UINT16 op2, UINT8* cycles)
14741869{
1475   int retSize = 1 ;
1870   UINT16 workingWord = 0x0000;
1871   UINT16 previousValue = 0x0000;
14761872
1477   UINT16 result ;
1873   UINT16 iVal = op2 & 0x00ff;
1874   typed_pointer S = { NULL, DT_BYTE };
14781875
1479   unsigned char dt = 0x00 ;
1480   void *D = 0x00 ;
1876   decode_BBB_bitmask(BITS(op2,0xe000), &iVal);
1877   decode_DDDDD_table(BITS(op,0x001f), &S);
14811878
1482   D = DecodeFTable(BITS(OP,0x0008), &dt) ;
1879   /* A & B are special */
1880   if (S.data_type == DT_LONG_WORD)
1881      previousValue = ((PAIR64*)S.addr)->w.h;
1882   else
1883      previousValue = *((UINT16*)S.addr);
14831884
1484   *pa = *((UINT64*)D) ;   // backup the previous value
1885   workingWord = previousValue;
14851886
1486    // !!! Make sure to hold the MS bit and shift the LS bit properly !!!
1887   switch(BITS(op2, 0x1f00))
1888   {
1889      case 0x12:   /* BFCHG */
1890         workingWord ^= iVal;
1891         break;
1892      case 0x04:   /* BFCLR */
1893         workingWord = workingWord & (~iVal);
1894         break;
1895      case 0x18:   /* BFSET */
1896         workingWord = workingWord | iVal;
1897         break;
1898      case 0x10:   /* BFTSTH */
1899         /* Just the test below */
1900         break;
1901      case 0x00:   /* BFTSTL */
1902         /* Just the test below */
1903         break;
1904   }
14871905
1488   result = (*((PAIR64*)D)).w.h >> 1 ;
1489   (*((PAIR64*)D)).w.h = result ;
1906   /* Put the data back where it belongs (A & B are special) */
1907   if (S.data_type == DT_LONG_WORD)
1908      ((PAIR64*)S.addr)->w.h = workingWord;
1909   else
1910      *((UINT16*)S.addr) = workingWord;
14901911
1491   *wd = D ;
1492   return retSize ;
1912   /* S L E U N Z V C */
1913   /* - * - - - - - ? */
1914   /* TODO: L */
1915   switch(BITS(op2, 0x1f00))
1916   {
1917      case 0x12:   /* BFCHG */
1918         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1919      case 0x04:   /* BFCLR */
1920         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1921      case 0x18:   /* BFSET */
1922         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1923      case 0x10:   /* BFTSTH */
1924         if ((iVal & previousValue) == iVal) C_bit_set(1); else C_bit_set(0); break;
1925      case 0x00:   /* BFTSTL */
1926         if ((iVal & previousValue) == 0x0000) C_bit_set(1); else C_bit_set(0); break;
1927   }
1928
1929   cycles += 4;    /* TODO: + mvb oscillator clock cycles */
1930   return 2;
14931931}
14941932
1495static int AsrOperation(void **wd, UINT64 *pa)
1933/* Bcc : 0000 0111 --11 cccc xxxx xxxx xxxx xxxx : A-48 */
1934static size_t dsp56k_op_bcc(const UINT16 op, const UINT16 op2, UINT8* cycles)
14961935{
1497   int retSize = 1 ;
1936   /* S L E U N Z V C */
1937   /* - - - - - - - - */
1938   return 0;
1939}
14981940
1499   unsigned char dt = 0x00 ;
1500   void *D = 0x00 ;
1941/* Bcc : 0010 11cc ccee eeee : A-48 */
1942static size_t dsp56k_op_bcc_1(const UINT16 op, UINT8* cycles)
1943{
1944   int shouldBranch = decode_cccc_table(BITS(op,0x03c0));
15011945
1502   D = DecodeFTable(BITS(OP,0x0008), &dt) ;
1946   if (shouldBranch)
1947   {
1948      INT16 offset = (INT16)assemble_address_from_6bit_signed_relative_short_address(BITS(op,0x003f));
15031949
1504   *pa = *((UINT64*)D) ;   // backup the previous value
1950      PC += 1;
15051951
1506    // !!! Make sure to hold the MS bit and shift the LS bit properly !!!
1952      core.ppc = PC;
1953      PC += offset;
1954      change_pc(PC) ;
15071955
1508   *((UINT64*)D) = (*((UINT64*)D)) >> 1 ;
1956      cycles += 4;
1957      return 0;
1958   }
1959   else
1960   {
1961      cycles += 4;
1962      return 1;
1963   }
15091964
1510   *wd = D ;
1511   return retSize ;
1965   /* S L E U N Z V C */
1966   /* - - - - - - - - */
1967   return 0;
15121968}
15131969
1514static int NotOperation(void **wd, UINT64 *pa)
1970/* Bcc : 0000 0111 RR10 cccc : A-48 */
1971static size_t dsp56k_op_bcc_2(const UINT16 op, UINT8* cycles)
15151972{
1516   int retSize = 1 ;
1973   /* S L E U N Z V C */
1974   /* - - - - - - - - */
1975   return 0;
1976}
15171977
1518   unsigned char dt = 0x00 ;
1519   void *D = 0x00 ;
1978/* BRA : 0000 0001 0011 11-- xxxx xxxx xxxx xxxx : A-50 */
1979static size_t dsp56k_op_bra(const UINT16 op, const UINT16 op2, UINT8* cycles)
1980{
1981   /* S L E U N Z V C */
1982   /* - - - - - - - - */
1983   return 0;
1984}
15201985
1521   D = DecodeFTable(BITS(OP,0x0008), &dt) ;
1986/* BRA : 0000 1011 aaaa aaaa : A-50 */
1987static size_t dsp56k_op_bra_1(const UINT16 op, UINT8* cycles)
1988{
1989   /* 8 bit immediate, relative offset */
1990   INT8 branchOffset = (INT8)BITS(op,0x00ff);
15221991
1523   *pa = *((UINT64*)D) ;   // backup the previous value
1992   /* "The PC Contains the address of the next instruction" */
1993   PC += 1;
15241994
1525   (*((PAIR64*)D)).w.h ^= 0xffff ;
1995   /* Jump */
1996   core.ppc = PC;
1997   PC += branchOffset;
1998   change_pc(PC);
15261999
1527   *wd = D ;
1528   return retSize ;
2000   /* S L E U N Z V C */
2001   /* - - - - - - - - */
2002   cycles += 4; /* TODO: + jx oscillator clock cycles */
2003   return 0;
15292004}
15302005
2006/* BRA : 0000 0001 0010 11RR : A-50 */
2007static size_t dsp56k_op_bra_2(const UINT16 op, UINT8* cycles)
2008{
2009   /* S L E U N Z V C */
2010   /* - - - - - - - - */
2011   return 0;
2012}
15312013
1532static int EorOperation(void **wd, UINT64 *pa)
2014/* BRKc : 0000 0001 0001 cccc : A-52 */
2015static size_t dsp56k_op_brkc(const UINT16 op, UINT8* cycles)
15332016{
1534   int retSize = 1 ;
2017   /* S L E U N Z V C */
2018   /* - - - - - - - - */
2019   return 0;
2020}
15352021
1536   UINT16 result ;
2022/* BScc : 0000 0111 --01 cccc xxxx xxxx xxxx xxxx : A-54 */
2023static size_t dsp56k_op_bscc(const UINT16 op, const UINT16 op2, UINT8* cycles)
2024{
2025   int shouldBranch = decode_cccc_table(BITS(op,0x000f));
15372026
1538   unsigned char st = 0x00, dt = 0x00 ;
1539   void *S = 0x00, *D = 0x00;
2027   if (shouldBranch)
2028   {
2029      /* The PC Contains the address of the next instruction */
2030      PC += 2;
15402031
1541   DecodeJJFTable(BITS(OP,0x0003),BITS(OP,0x0008), &S, &st, &D, &dt) ;
2032      /* Push */
2033      SP++;
2034      SSH = PC;
2035      SSL = SR;
15422036
1543   *pa = *((UINT64*)D) ;   // backup the previous value
2037      /* Change */
2038      core.ppc = PC;
2039      PC = PC + (INT16)op2;
2040      change_pc(PC);
2041   }
15442042
1545   // This operation does an XOR of a word of S with A1/B1...
1546   result = *((UINT16*)S) ^ (*((PAIR64*)D)).w.h ;
1547   (*((PAIR64*)D)).w.h = result ;
2043   /* S L E U N Z V C */
2044   /* - - - - - - - - */
2045   cycles += 4;      /* TODO: + jx oscillator clock cycles */
2046   return 2;
2047}
15482048
1549   *wd = D ;
1550   return retSize ;
2049/* BScc : 0000 0111 RR00 cccc : A-54 */
2050static size_t dsp56k_op_bscc_1(const UINT16 op, UINT8* cycles)
2051{
2052   /* S L E U N Z V C */
2053   /* - - - - - - - - */
2054   return 0;
15512055}
15522056
1553static int TfrDataALUOperation(void **wd, UINT64 *pa)
2057/* BSR : 0000 0001 0011 10-- xxxx xxxx xxxx xxxx : A-56 */
2058static size_t dsp56k_op_bsr(const UINT16 op, const UINT16 op2, UINT8* cycles)
15542059{
1555   int retSize = 1 ;
2060   /* The PC Contains the address of the next instruction */
2061   PC += 2;
15562062
1557   unsigned char st = 0x00, dt = 0x00 ;
1558   void *S = 0x00, *D = 0x00;
2063   /* Push */
2064   SP++;
2065   SSH = PC;
2066   SSL = SR;
15592067
1560   DecodeJJJFTable(BITS(OP,0x0007),BITS(OP,0x0008), &S, &st, &D, &dt) ;
2068   /* Change */
2069   core.ppc = PC;
2070   PC = PC + (INT16)op2;
2071   change_pc(PC);
15612072
1562   *pa = *((UINT64*)D) ;   // backup the previous value
2073   /* S L E U N Z V C */
2074   /* - - - - - - - - */
2075   cycles += 4;   /* TODO: + jx oscillator clock cycles */
2076   return 0;
2077}
15632078
1564   SetDestinationValue(S, st, D, dt) ;
2079/* BSR : 0000 0001 0010 10RR : A-56 */
2080static size_t dsp56k_op_bsr_1(const UINT16 op, UINT8* cycles)
2081{
2082   /* S L E U N Z V C */
2083   /* - - - - - - - - */
2084   return 0;
2085}
15652086
1566   *wd = D ;
1567   return retSize ;
2087/* CHKAAU : 0000 0000 0000 0100 : A-58 */
2088static size_t dsp56k_op_chkaau(const UINT16 op, UINT8* cycles)
2089{
2090   /* S L E U N Z V C */
2091   /* - - - - ? ? ? - */
2092   /* V - Set if the result of the last address ALU update performed a modulo wrap. Cleared if
2093           result of the last address ALU did not perform a modulo wrap.*/
2094   /* Z - Set if the result of the last address ALU update is 0. Cleared if the result of the last
2095           address ALU is positive. */
2096   /* N - Set if the result of the last address ALU update is negative. Cleared if the result of the
2097           last address ALU is positive. */
2098   return 0;
15682099}
15692100
1570static int AndOperation(void **wd, UINT64 *pa)
2101/* DEBUG : 0000 0000 0000 0001 : A-68 */
2102static size_t dsp56k_op_debug(const UINT16 op, UINT8* cycles)
15712103{
1572   int retSize = 1 ;
2104   /* S L E U N Z V C */
2105   /* - - - - - - - - */
2106   return 0;
2107}
15732108
1574   UINT16 result ;
2109/* DEBUGcc : 0000 0000 0101 cccc : A-70 */
2110static size_t dsp56k_op_debugcc(const UINT16 op, UINT8* cycles)
2111{
2112   /* S L E U N Z V C */
2113   /* - - - - - - - - */
2114   return 0;
2115}
15752116
1576   unsigned char st = 0x00, dt = 0x00 ;
1577   void *S = 0x00, *D = 0x00;
2117/* DIV : 0001 0101 0--0 F1DD : A-76 */
2118/* WARNING : DOCS SAY THERE IS A PARALLEL MOVE HERE !!! */
2119static size_t dsp56k_op_div(const UINT16 op, UINT8* cycles)
2120{
2121   /* S L E U N Z V C */
2122   /* - * - - - - ? ? */
2123   /* V - Set if an arithmetic overflow occurs in the 40 bit result. Also set if the most significantst
2124           bit of the destination operand is changed as a result of the left shift. Cleared otherwise. */
2125   /* C - Set if bit 39 of the result is cleared. Cleared otherwise. */
2126   return 0;
2127}
15782128
1579   DecodeJJFTable(BITS(OP,0x0003),BITS(OP,0x0008), &S, &st, &D, &dt) ;
2129/* DMAC : 0001 0101 10s1 FsQQ : A-80 */
2130static size_t dsp56k_op_dmac(const UINT16 op, UINT8* cycles)
2131{
2132   /* S L E U N Z V C */
2133   /* - * * * * * * - */
2134   return 0;
2135}
15802136
1581   *pa = *((UINT64*)D) ;   // backup the previous value
1582
1583   // This operation does an AND of a word of S with A1/B1...
1584   result = *((UINT16*)S) & (*((PAIR64*)D)).w.h ;
1585   (*((PAIR64*)D)).w.h = result ;
1586
1587   *wd = D ;
1588   return retSize ;
2137/* DO : 0000 0000 110- --RR xxxx xxxx xxxx xxxx : A-82 */
2138static size_t dsp56k_op_do(const UINT16 op, const UINT16 op2, UINT8* cycles)
2139{
2140   /* S L E U N Z V C */
2141   /* - * - - - - - - */
2142   return 0;
15892143}
15902144
1591static int OrOperation(void **wd, UINT64 *pa)
2145/* DO : 0000 1110 iiii iiii xxxx xxxx xxxx xxxx : A-82 */
2146static size_t dsp56k_op_do_1(const UINT16 op, const UINT16 op2, UINT8* cycles)
15922147{
1593   int retSize = 1 ;
2148   UINT8 iValue = BITS(op,0x00ff);
15942149
1595   UINT16 result ;
2150   /* Don't execute if the loop counter == 0 */
2151   if (iValue != 0x00)
2152   {
2153      /* First instruction cycle */
2154      SP++;                  /* TODO: Should i really inc here first? */
2155      SSH = LA;
2156      SSL = LC;
2157      LC = (UINT16)iValue;
15962158
1597   unsigned char st = 0x00, dt = 0x00 ;
1598   void *S = 0x00, *D = 0x00;
15992159
1600   DecodeJJFTable(BITS(OP,0x0003),BITS(OP,0x0008), &S, &st, &D, &dt) ;
2160      /* Second instruction cycle */
2161      SP++;                  /* TODO: See above */
2162      SSH = PC + 2;            /* Keep these stack entries in 'word-based-index' space */
2163      SSL = SR;
2164      LA = PC + 2 + op2;         /* TODO: The docs subtract 1 from here? */
16012165
1602   *pa = *((UINT64*)D) ;   // backup the previous value
16032166
1604   // This operation does an OR of a word of S with A1/B1...
1605   result = *((UINT16*)S) | (*((PAIR64*)D)).w.h ;
1606   (*((PAIR64*)D)).w.h = result ;
2167      /* Third instruction cycle */
2168      LF_bit_set(1);
16072169
1608   *wd = D ;
1609   return retSize ;
2170
2171      /* S L E U N Z V C */
2172      /* - * - - - - - - */
2173      /* TODO : L */
2174
2175      cycles += 6;   /* TODO: + mv oscillator cycles */
2176   }
2177   else
2178   {
2179      cycles += 10;   /* TODO: + mv oscillator cycles */
2180   }
2181
2182   return 2;
16102183}
16112184
1612
1613static int TccOperation(void)
2185/* DO : 0000 0100 000D DDDD xxxx xxxx xxxx xxxx : A-82 */
2186static size_t dsp56k_op_do_2(const UINT16 op, const UINT16 op2, UINT8* cycles)
16142187{
1615   int retSize = 1 ;
2188   UINT16 lValue = 0x0000;
2189   typed_pointer S = {NULL, DT_BYTE};
2190   decode_DDDDD_table(BITS(op,0x001f), &S);
16162191
1617   int transfer = DecodeccccTable(BITS(OP,0x03c0)) ;
2192   /* TODO: Does not work for sources A&B - Fix per the docs */
2193   lValue = *((UINT16*)S.addr);
16182194
1619    // !!! WARNING === TESTING !!!
1620   // transfer = 1 ;
2195   /* TODO: Fix for special cased SP S */
2196   if (S.addr == &SP)
2197      logerror("DSP56k: do with SP as the source not properly implemented yet.\n");
16212198
1622   if (transfer)
2199   /* TODO: Fix for special cased SSSL S */
2200   if (S.addr == &SSL)
2201      logerror("DSP56k: do with SP as the source not properly implemented yet.\n");
2202
2203   /* Don't execute if the loop counter == 0 */
2204   if (lValue != 0x00)
16232205   {
1624      unsigned char st = 0x00, dt = 0x00 ;
1625      void *S = 0x00, *D = 0x00;
2206      /* First instruction cycle */
2207      SP++;                  /* TODO: Should i really inc here first? */
2208      SSH = LA;
2209      SSL = LC;
2210      LC = (UINT16)lValue;
16262211
1627      unsigned char drt    = 0x00 ;
1628      void *destinationReg = 0x00 ;
16292212
1630      Decodeh0hFTable(BITS(OP,0x0007),BITS(OP,0x0008), &S, &st, &D, &dt) ;
2213      /* Second instruction cycle */
2214      SP++;                  /* TODO: See above */
2215      SSH = PC + 2;            /* Keep these stack entries in 'word-based-index' space */
2216      SSL = SR;
2217      LA = PC + 2 + op2;         /* TODO: The docs subtract 1 from here? */
16312218
1632      SetDestinationValue(S, st, D, dt) ;
16332219
1634      // !!! What's up with that A,A* thing in the docs?  Does that mean "do not transfer R0 to Rn ???
1635      destinationReg = DecodeRRTable(BITS(OP,0x0030), &drt) ; // Actually a TT table, but it's the same
2220      /* Third instruction cycle */
2221      LF_bit_set(1);
16362222
1637      SetDestinationValue(&R0, DT_WORD, destinationReg, drt) ;
2223
2224      /* S L E U N Z V C */
2225      /* - * - - - - - - */
2226      /* TODO : L */
2227
2228      cycles += 6;   /* TODO: + mv oscillator cycles */
16382229   }
2230   else
2231   {
2232      cycles += 10;   /* TODO: + mv oscillator cycles */
2233   }
16392234
1640   // Otherwise it's a NOP
2235   return 2;
2236}
16412237
1642   return retSize ;
2238/* DO FOREVER : 0000 0000 0000 0010 xxxx xxxx xxxx xxxx : A-88 */
2239static size_t dsp56k_op_doforever(const UINT16 op, const UINT16 op2, UINT8* cycles)
2240{
2241   /* S L E U N Z V C */
2242   /* - - - - - - - - */
2243   return 0;
16432244}
16442245
1645static int ClrOperation(void **wd, UINT64 *pa)
2246/* ENDDO : 0000 0000 0000 1001 : A-92 */
2247static size_t dsp56k_op_enddo(const UINT16 op, UINT8* cycles)
16462248{
1647   int retSize = 1 ;
2249   /* S L E U N Z V C */
2250   /* - - - - - - - - */
2251   return 0;
2252}
16482253
1649   UINT64 clearValue = 0 ;
2254/* EXT : 0001 0101 0101 F010 : A-96 */
2255static size_t dsp56k_op_ext(const UINT16 op, UINT8* cycles)
2256{
2257   /* S L E U N Z V C */
2258   /* - * * * * * * - */
2259   return 0;
2260}
16502261
1651   unsigned char drt    = 0x00 ;
1652   void *destinationReg = 0x00 ;
2262/* ILLEGAL : 0000 0000 0000 1111 : A-98 */
2263static size_t dsp56k_op_illegal(const UINT16 op, UINT8* cycles)
2264{
2265   /* S L E U N Z V C */
2266   /* - - - - - - - - */
2267   return 0;
2268}
16532269
1654   destinationReg = DecodeFTable(BITS(OP,0x0008), &drt) ;
2270/* IMAC : 0001 0101 1010 FQQQ : A-100 */
2271static size_t dsp56k_op_imac(const UINT16 op, UINT8* cycles)
2272{
2273   /* S L E U N Z V C */
2274   /* - * ? ? * ? ? - */
2275   /* Z - Set if the 24 most significant bits of the destination result are all zeroes. */
2276   /* U,E - Will not be set correctly by this instruction*/
2277   /* V - Set to zero regardless of the overflow */
2278   return 0;
2279}
16552280
1656   *pa = *((UINT64*)destinationReg) ;   // backup the previous value
2281/* IMPY : 0001 0101 1000 FQQQ : A-102 */
2282static size_t dsp56k_op_impy(const UINT16 op, UINT8* cycles)
2283{
2284   /* S L E U N Z V C */
2285   /* - * ? ? * ? ? - */
2286   /* Z - Set if the 24 most significant bits of the destination result are all zeroes. */
2287   /* U,E - Will not be set correctly by this instruction*/
2288   /* V - Set to zero regardless of the overflow */
2289   return 0;
2290}
16572291
1658   SetDestinationValue(&clearValue, DT_LONG_WORD, destinationReg, drt) ;
2292/* Jcc : 0000 0110 --11 cccc xxxx xxxx xxxx xxxx : A-108 */
2293static size_t dsp56k_op_jcc(const UINT16 op, const UINT16 op2, UINT8* cycles)
2294{
2295   /* S L E U N Z V C */
2296   /* - - - - - - - - */
2297   return 0;
2298}
16592299
1660    *wd = destinationReg ;
1661   return retSize ;
2300/* Jcc : 0000 0110 RR10 cccc : A-108 */
2301static size_t dsp56k_op_jcc_1(const UINT16 op, UINT8* cycles)
2302{
2303   /* S L E U N Z V C */
2304   /* - - - - - - - - */
2305   return 0;
16622306}
16632307
1664static int TstOperation(void **wd, UINT64 *pa)
2308/* JMP : 0000 0001 0011 01-- xxxx xxxx xxxx xxxx : A-110 */
2309static size_t dsp56k_op_jmp(const UINT16 op, const UINT16 op2, UINT8* cycles)
16652310{
1666   int retSize = 1 ;
2311   core.ppc = PC;
2312   PC = op2;
2313   change_pc(PC);
16672314
1668   unsigned char drt    = 0x00 ;
1669   void *destinationReg = 0x00 ;
1670   destinationReg = DecodeFTable(BITS(OP,0x0008), &drt) ;
2315   /* S L E U N Z V C */
2316   /* - - - - - - - - */
16712317
1672   // S - "computed according to the standard definition (section A.4)"
1673   // L - can't be done until after data move
1674   // E - set if signed integer portion is in use
1675   // U - set according to the standard definition of the U bit
1676   // N - set if bit 39 is set
1677   if (*((UINT64*)destinationReg) & (UINT64)U64(0x8000000000)) N_bit_set(1);
1678   else                                              N_bit_set(0);
2318   cycles += 4;   /* TODO: + jx */
2319   return 0;
2320}
16792321
1680   // Z - set if == 0
1681   if (*((UINT64*)destinationReg) == 0) Z_bit_set(1);
1682   else                         Z_bit_set(0);
2322/* JMP : 0000 0001 0010 01RR : A-110 */
2323static size_t dsp56k_op_jmp_1(const UINT16 op, UINT8* cycles)
2324{
2325   typed_pointer R = { NULL, DT_BYTE };
2326   decode_RR_table(BITS(op,0x0003), &R);
16832327
1684   // V&C - always cleared
1685   V_bit_set(0);
1686   C_bit_set(0);
2328   core.ppc = PC;
2329   PC = *((UINT16*)R.addr);
2330   change_pc(PC);
16872331
1688   *pa = *((UINT64*)destinationReg) ;   // backup the previous value (no change here)
1689   *wd = destinationReg;
2332   /* S L E U N Z V C */
2333   /* - - - - - - - - */
16902334
1691   return retSize ;
2335   cycles += 4;   /* TODO: + jx */
2336   return 0;
16922337}
16932338
1694static int AndiOperation(void)
2339/* JScc : 0000 0110 --01 cccc xxxx xxxx xxxx xxxx : A-112 */
2340static size_t dsp56k_op_jscc(const UINT16 op, const UINT16 op2, UINT8* cycles)
16952341{
1696   int retSize = 1 ;
2342   /* S L E U N Z V C */
2343   /* - - - - - - - - */
2344   return 0;
2345}
16972346
1698   UINT16 andMe = BITS(OP,0x00ff) ;
2347/* JScc : 0000 0110 RR00 cccc : A-112 */
2348static size_t dsp56k_op_jscc_1(const UINT16 op, UINT8* cycles)
2349{
2350   /* S L E U N Z V C */
2351   /* - - - - - - - - */
2352   return 0;
2353}
16992354
1700   // Because I don't have a good way to access MR and CCR right now, i'm going to
1701   //   hard-code decoding EE here and in the OriOperation as well...
1702   switch(BITS(OP,0x0600))
1703   {
1704      // MR
1705      case 0x01:
1706         SR  &= ((andMe << 8) | 0x00ff) ;
1707         break ;
2355/* JSR : 0000 0001 0011 00-- xxxx xxxx xxxx xxxx : A-114 */
2356static size_t dsp56k_op_jsr(const UINT16 op, const UINT16 op2, UINT8* cycles)
2357{
2358   /* TODO: It says "signed" absolute offset.  Weird. */
2359   UINT16 branchOffset = op2;
17082360
1709      // CCR
1710      case 0x03:
1711         SR  &= ((andMe)      | 0xff00) ;
1712         break ;
2361   /* TODO: Verify, since it's not in the docs, but it must be true */
2362   PC += 2;
17132363
1714      // OMR
1715      case 0x02:
1716         OMR &= (UINT8)(andMe) ;
1717         break ;
2364   SP++;
2365   SSH = PC;
2366   SSL = SR;
17182367
1719      default:
1720         fatalerror("DSP56k - BAD EE value in andi operation") ;
1721   }
2368   core.ppc = PC;
2369   PC = branchOffset;
2370   change_pc(PC);
17222371
2372   /* S L E U N Z V C */
2373   /* - - - - - - - - */
2374   cycles += 4;      /* TODO: + jx oscillator cycles */
2375   return 0;
2376}
17232377
1724   return retSize ;
2378/* JSR : 0000 1010 AAAA AAAA : A-114 */
2379static size_t dsp56k_op_jsr_1(const UINT16 op, UINT8* cycles)
2380{
2381   /* S L E U N Z V C */
2382   /* - - - - - - - - */
2383   return 0;
17252384}
17262385
1727#ifdef UNUSED_FUNCTION
1728// !!! NOT IMPLEMENTED YET - JUST PUT HERE TO BE NEXT TO ANDI SOMEDAY !!!
1729static int OriOperation(void)
2386/* JSR : 0000 0001 0010 00RR : A-114 */
2387static size_t dsp56k_op_jsr_2(const UINT16 op, UINT8* cycles)
17302388{
1731   int retSize = 1 ;
2389   /* S L E U N Z V C */
2390   /* - - - - - - - - */
2391   return 0;
2392}
17322393
1733   return retSize ;
2394/* LEA : 0000 0001 11TT MMRR : A-116 */
2395static size_t dsp56k_op_lea(const UINT16 op, UINT8* cycles)
2396{
2397   /* S L E U N Z V C */
2398   /* - - - - - - - - */
2399   return 0;
17342400}
1735#endif
17362401
1737static int CmpOperation(void **wd, UINT64 *pa)
2402/* LEA : 0000 0001 10NN MMRR : A-116 */
2403static size_t dsp56k_op_lea_1(const UINT16 op, UINT8* cycles)
17382404{
1739   int retSize = 1 ;
2405   /* S L E U N Z V C */
2406   /* - - - - - - - - */
2407   return 0;
2408}
17402409
1741   UINT64 cmpVal ;
1742   UINT64 result ;
2410/* MAC(su,uu) : 0001 0101 1110 FsQQ : A-126 */
2411static size_t dsp56k_op_macsuuu(const UINT16 op, UINT8* cycles)
2412{
2413   UINT8 s = 0;
2414   INT64 result = 0;
17432415
1744   unsigned char st = 0x00, dt = 0x00 ;
1745   void *S = 0x00, *D = 0x00;
2416   void* D = NULL;
2417   void* S1 = NULL;
2418   void* S2 = NULL;
17462419
1747   DecodeJJJFTable(BITS(OP,0x0007),BITS(OP,0x0008), &S, &st, &D, &dt) ;
2420   decode_QQF_special_table(BITS(op,0x0003), BITS(op,0x0008), &S1, &S2, &D);
17482421
1749   *pa = *((UINT64*)D) ;   // backup the previous value - not necessary for cmp :)
2422   s = BITS(op,0x0004);
17502423
1751   switch(st)
2424   /* Fixed-point 2's complement multiplication requires a shift */
2425   if (s)
17522426   {
1753      default:
1754      case DT_WORD:        cmpVal = (UINT64)*((UINT16*)S) ; break ;
1755      case DT_DOUBLE_WORD: cmpVal = (UINT64)*((UINT32*)S) ; break ;
1756      case DT_LONG_WORD:   cmpVal = (UINT64)*((UINT64*)S) ; break ;
2427      /* Unsigned * Unsigned */
2428      UINT32 s1 = (UINT32)(*((UINT16*)S1));
2429      UINT32 s2 = (UINT32)(*((UINT16*)S2));
2430      result = ( s1 * s2 ) << 1;
17572431   }
2432   else
2433   {
2434      /* Signed * Unsigned */
2435      UINT32 s1 = (UINT32)((INT32)(*((UINT16*)S1)));
2436      UINT32 s2 = (UINT32)(*((UINT16*)S2));
2437      result = ( s1 * s2 ) << 1;
2438   }
17582439
1759   result = *((UINT64*)D) - cmpVal ;
2440   (*((UINT64*)D)) += result;
17602441
1761   if (result == 0)
1762      Z_bit_set(1) ;
1763   else
1764      Z_bit_set(0) ;
2442   /* S L E U N Z V C */
2443   /* - * * * * * * - */
2444   /* TODO: L, E, U, V */
2445   if ( *((UINT64*)D) & U64(0x0000008000000000))      N_bit_set(1);
2446   if ((*((UINT64*)D) & U64(0x000000ffffffffff)) == 0) Z_bit_set(1);
17652447
1766    *wd = D ;
1767   return retSize ;
2448   cycles += 2;
2449   return 1;
17682450}
17692451
1770static int BsccOperation(void)
2452/* MOVE : 0000 0101 BBBB BBBB ---- HHHW 0001 0001 : A-128 */
2453static size_t dsp56k_op_move_2(const UINT16 op, const UINT16 op2, UINT8* cycles)
17712454{
1772   int retSize = 0 ;
2455   /* S L E U N Z V C */
2456   /* * * - - - - - - */
2457   return 0;
2458}
17732459
1774   // Decode the condition
1775   int transfer = DecodeccccTable(BITS(OP,0x000f)) ;
2460/* MOVE(C) : 0011 1WDD DDD0 MMRR : A-144 */
2461static size_t dsp56k_op_movec(const UINT16 op, UINT8* cycles)
2462{
2463   UINT8 W;
2464   typed_pointer R = { NULL, DT_BYTE };
2465   typed_pointer SD = { NULL, DT_BYTE };
17762466
1777   // TESTING !!!
1778   // transfer = 0 ;
2467   W = BITS(op,0x0400);
2468   decode_DDDDD_table(BITS(op,0x03e0), &SD);
2469   decode_RR_table(BITS(op,0x0003), &R);
17792470
1780   // 1 or 2 word operation...
1781   if (transfer)
2471   if (W)
17822472   {
1783      if (BITS(OP,0x0010))
1784      {
1785         // 2 word immediate offset...
1786         INT16 branchOffset = (INT16)ROPCODE((PC<<1)+2) ;
2473      /* Write D */
2474      UINT16 value = data_read_word_16le(WORD(*((UINT16*)R.addr))) ;
2475      typed_pointer temp_src = { &value, DT_WORD };
2476      SetDestinationValue(temp_src, SD);
2477   }
2478   else
2479   {
2480      /* Read S */
2481      UINT16 dataMemOffset = *((UINT16*)R.addr);
2482      SetDataMemoryValue(SD, WORD(dataMemOffset));
2483   }
17872484
1788         // "The PC Contains the address of the next instruction"
1789         PC += 2 ;
1790         core.ppc = PC ;
2485   execute_MM_table(BITS(op,0x0003), BITS(op,0x000c));
17912486
1792         SP++ ;
1793         SSH = PC ;
1794         SSL = SR ;
2487   /* S L E U N Z V C */
2488   /* * ? ? ? ? ? ? ? */
2489   /* All ? bits - If SR is specified as a destination operand, set according to the corresponding
2490       bit of the source operand. If SR is not specified as a destination operand, L is set if data
2491       limiting occurred. All ? bits are not affected otherwise.*/
2492   if (W && (SD.addr != &SR))
2493   {
2494      /* If you're writing to something other than the SR */
2495      /* TODO */
2496   }
17952497
1796         PC += branchOffset ;
2498   cycles += 2;   /* TODO: + mvc */
2499   return 1;
2500}
17972501
1798         change_pc(PC) ;
1799      }
1800      else
1801      {
1802         // 1 word Rx offset...
1803      }
2502/* MOVE(C) : 0011 1WDD DDD1 q0RR : A-144 */
2503static size_t dsp56k_op_movec_1(const UINT16 op, UINT8* cycles)
2504{
2505   UINT8 W;
2506   UINT16 memOffset;
2507   typed_pointer SD = {NULL, DT_BYTE};
18042508
1805      retSize = 0 ;
2509   W = BITS(op,0x0400);
2510   decode_DDDDD_table(BITS(op,0x03e0), &SD);
2511   memOffset = execute_q_table(BITS(op,0x0003), BITS(op,0x0008));
2512
2513   if (W)
2514   {
2515      /* Write D */
2516      UINT16 tempData = data_read_word_16le(WORD(memOffset));
2517      typed_pointer temp_src = { (void*)&tempData, DT_WORD };
2518      SetDestinationValue(temp_src, SD);
18062519   }
18072520   else
18082521   {
1809      if (BITS(OP,0x0010))
1810         retSize = 2 ;
1811      else
1812         retSize = 1 ;
2522      /* Read S */
2523      UINT16 tempData = *((UINT16*)SD.addr);
2524      typed_pointer temp_src = { (void*)&tempData, DT_WORD };
2525      SetDataMemoryValue(temp_src, WORD(memOffset));
18132526   }
18142527
1815   return retSize ;
2528   /* S L E U N Z V C */
2529   /* * ? ? ? ? ? ? ? */
2530   /* All ? bits - If SR is specified as a destination operand, set according to the corresponding
2531       bit of the source operand. If SR is not specified as a destination operand, L is set if data
2532       limiting occurred. All ? bits are not affected otherwise.*/
2533   if (W && (SD.addr != &SR))
2534   {
2535      /* If you're writing to something other than the SR */
2536      /* TODO */
2537   }
2538
2539   cycles += 2;      /* + mvc oscillator clock cycles */
2540   return 1;
18162541}
18172542
1818static int BccOperation(void)
2543/* MOVE(C) : 0011 1WDD DDD1 Z11- : A-144 */
2544static size_t dsp56k_op_movec_2(const UINT16 op, UINT8* cycles)
18192545{
1820   int retSize = 0 ;
2546   UINT8 W;
2547   UINT16 memOffset;
2548   typed_pointer SD = {NULL, DT_BYTE};
2549   typed_pointer XMemOffset = {NULL, DT_BYTE};
18212550
1822   if (!BITS(OP,0x2000))
2551   W = BITS(op,0x0400);
2552   decode_Z_table(BITS(op,0x0008), &XMemOffset);
2553   decode_DDDDD_table(BITS(op,0x03e0), &SD);
2554
2555   memOffset = *((UINT16*)XMemOffset.addr);
2556
2557   if (W)
18232558   {
1824      int branch = DecodeccccTable(BITS(OP,0x000f)) ;
2559      /* Write D */
2560      UINT16 tempData = data_read_word_16le(WORD(memOffset));
2561      typed_pointer temp_src = { (void*)&tempData, DT_WORD };
2562      SetDestinationValue(temp_src, SD);
2563   }
2564   else
2565   {
2566      /* Read S */
2567      UINT16 tempData = *((UINT16*)SD.addr);
2568      typed_pointer temp_src = { (void*)&tempData, DT_WORD };
2569      SetDataMemoryValue(temp_src, WORD(memOffset));
2570   }
18252571
1826      if (branch)
1827      {
1828         if (BITS(OP,0x0010))
1829         {
1830            // B.cc xxxx
1831             INT16 op2 = ROPCODE((PC<<1)+2) ;
18322572
1833            // The PC contains the address of the next instruction
1834            PC += 2 ;
1835             core.ppc = PC ;
1836            PC += op2 ;
2573   /* S L E U N Z V C */
2574   /* * ? ? ? ? ? ? ? */
2575   /* All ? bits - If SR is specified as a destination operand, set according to the corresponding
2576       bit of the source operand. If SR is not specified as a destination operand, L is set if data
2577       limiting occurred. All ? bits are not affected otherwise.*/
2578   if (W && (SD.addr != &SR))
2579   {
2580      /* If you're writing to something other than the SR */
2581      /* TODO */
2582   }
18372583
1838            change_pc(PC) ;
1839         }
1840         else
1841         {
1842            // B.cc Rn
1843         }
2584   cycles += 2;      /* + mvc oscillator clock cycles */
2585   return 1;
2586}
2587
2588/* MOVE(C) : 0011 1WDD DDD1 t10- xxxx xxxx xxxx xxxx : A-144 */
2589static size_t dsp56k_op_movec_3(const UINT16 op, const UINT16 op2, UINT8* cycles)
2590{
2591   UINT8 W;
2592   UINT8 t;
2593   typed_pointer SD = { NULL, DT_BYTE };
2594
2595   W = BITS(op,0x0400);
2596   t = BITS(op,0x0008);
2597   decode_DDDDD_table(BITS(op,0x03e0), &SD);
2598
2599   if (W)
2600   {
2601      /* Write D */
2602      if (t)
2603      {
2604         /* 16-bit long data */
2605         typed_pointer temp_src = { (void*)&op2, DT_WORD };
2606         SetDestinationValue(temp_src, SD);
18442607      }
18452608      else
18462609      {
1847         if (BITS(OP,0x0010))
1848            retSize = 2 ;
1849         else
1850            retSize = 1 ;
2610         /* 16-bit long address */
2611         UINT16 tempD = data_read_word_16le(WORD(op2));
2612         typed_pointer tempTP = {&tempD, DT_WORD};
2613         SetDestinationValue(tempTP, SD);
18512614      }
18522615   }
18532616   else
18542617   {
1855      // B.cc aa
1856      int branch = DecodeccccTable(BITS(OP,0x03c0)) ;
1857
1858      if (branch)
2618      /* Read S */
2619      if (t)
18592620      {
1860         INT16 offset = (INT16)AssembleAddressFrom6BitSignedRelativeShortAddress(BITS(OP,0x003f)) ;
1861
1862         PC += 1 ;
1863         core.ppc = PC ;
1864         PC += offset ;
1865
1866         change_pc(PC) ;
2621         /* 16-bit long data */
2622         logerror("DSP56k: Movec - I don't think this exists?");
18672623      }
18682624      else
18692625      {
1870         retSize = 1 ;
2626         /* 16-bit long address */
2627         SetDataMemoryValue(SD, WORD(op2));
18712628      }
18722629   }
18732630
1874   return retSize ;
2631   /* S L E U N Z V C */
2632   /* * ? ? ? ? ? ? ? */
2633   /* All ? bits - If SR is specified as a destination operand, set according to the corresponding
2634       bit of the source operand. If SR is not specified as a destination operand, L is set if data
2635       limiting occurred. All ? bits are not affected otherwise.*/
2636   if (W && (SD.addr != &SR))
2637   {
2638      /* If you're writing to something other than the SR */
2639      /* TODO */
2640   }
2641
2642   cycles += 2;   /* TODO: + mvc */
2643   return 2;
18752644}
18762645
1877static int Tst2Operation(void)
2646/* MOVE(C) : 0010 10dd dddD DDDD : A-144 */
2647static size_t dsp56k_op_movec_4(const UINT16 op, UINT8* cycles)
18782648{
1879   int retSize = 1 ;
2649   typed_pointer S = {NULL, DT_BYTE};
2650   typed_pointer D = {NULL, DT_BYTE};
18802651
1881   unsigned char dt = 0x00 ;
1882   void *destinationReg = 0x00 ;
2652   decode_DDDDD_table(BITS(op,0x03e0), &S);
2653   decode_DDDDD_table(BITS(op,0x001f), &D);
18832654
1884   destinationReg = DecodeDDTable(BITS(OP,0x0003), &dt) ;
2655   SetDestinationValue(S, D);
18852656
1886   // unnormalized
2657   /* S L E U N Z V C */
2658   /* * ? ? ? ? ? ? ? */
2659   /* All ? bits - If SR is specified as a destination operand, set according to the corresponding
2660       bit of the source operand. If SR is not specified as a destination operand, L is set if data
2661       limiting occurred. All ? bits are not affected otherwise.*/
2662   if (D.addr != &SR)
2663   {
2664      /* If you're writing to something other than the SR */
2665      /* TODO */
2666   }
18872667
1888   // negative
1889   // bit 31 of A or B ???
2668   cycles += 2;
2669   return 1;
2670}
18902671
1891   // zero
1892   if ( (*((UINT16*)destinationReg)) == 0)
1893      Z_bit_set(1);
2672/* MOVE(C) : 0000 0101 BBBB BBBB 0011 1WDD DDD0 ---- : A-144 */
2673static size_t dsp56k_op_movec_5(const UINT16 op, const UINT16 op2, UINT8* cycles)
2674{
2675   /* S L E U N Z V C */
2676   /* * ? ? ? ? ? ? ? */
2677   /* All ? bits - If SR is specified as a destination operand, set according to the corresponding
2678       bit of the source operand. If SR is not specified as a destination operand, L is set if data
2679       limiting occurred. All ? bits are not affected otherwise.*/
2680   return 0;
2681}
2682
2683/* MOVE(I) : 0010 00DD BBBB BBBB : A-150 */
2684static size_t dsp56k_op_movei(const UINT16 op, UINT8* cycles)
2685{
2686   typed_pointer D = {NULL, DT_BYTE};
2687   typed_pointer immTP = {NULL, DT_BYTE};
2688
2689   /* Typecasting to INT16 sign-extends the BBBBBBBB operand */
2690   UINT16 immediateSignExtended = (INT16)(op & 0x00ff);
2691   immTP.addr = &immediateSignExtended;
2692   immTP.data_type = DT_WORD;
2693
2694   decode_DD_table(BITS(op,0x0300), &D);
2695
2696   SetDestinationValue(immTP, D);
2697
2698   /* S L E U N Z V C */
2699   /* - - - - - - - - */
2700   cycles += 2;
2701   return 1;
2702}
2703
2704/* MOVE(M) : 0000 001W RR0M MHHH : A-152 */
2705static size_t dsp56k_op_movem(const UINT16 op, UINT8* cycles)
2706{
2707   UINT8 W;
2708   typed_pointer R = { NULL, DT_BYTE };
2709   typed_pointer SD = { NULL, DT_BYTE };
2710
2711   W = BITS(op,0x0100);
2712   decode_RR_table(BITS(op,0x00c0), &R);
2713   decode_HHH_table(BITS(op,0x0007), &SD);
2714
2715   if (W)
2716   {
2717      /* Read from Program Memory */
2718      typed_pointer data;
2719      UINT16 ldata = program_read_word_16le(WORD(*((UINT16*)R.addr)));
2720
2721      data.addr = &ldata;
2722      data.data_type = DT_WORD;
2723      SetDestinationValue(data, SD) ;
2724   }
18942725   else
1895      Z_bit_set(0);
2726   {
2727      /* Write to Program Memory */
2728      SetProgramMemoryValue(SD, WORD(*((UINT16*)R.addr))) ;
2729   }
18962730
1897   // always clear C flag
1898   C_bit_set(0) ;
2731   execute_MM_table(BITS(op,0x00c0), BITS(op,0x0018));
18992732
1900   return retSize ;
2733   /* S L E U N Z V C */
2734   /* * * - - - - - - */
2735   /* TODO: S, L */
2736   cycles += 2;   /* TODO: + mvm oscillator clock cycles */
2737   return 1;
19012738}
19022739
1903static int MACsuuuOperation(void)
2740/* MOVE(M) : 0000 001W RR11 mmRR : A-152 */
2741static size_t dsp56k_op_movem_1(const UINT16 op, UINT8* cycles)
19042742{
1905   int retSize = 1 ;
2743   /* S L E U N Z V C */
2744   /* * * - - - - - - */
2745   return 0;
2746}
19062747
1907   INT64 result = 0 ;
2748/* MOVE(M) : 0000 0101 BBBB BBBB 0000 001W --0- -HHH : A-152 */
2749static size_t dsp56k_op_movem_2(const UINT16 op, const UINT16 op2, UINT8* cycles)
2750{
2751   /* S L E U N Z V C */
2752   /* * * - - - - - - */
2753   return 0;
2754}
19082755
1909   int s ;
1910   void *S1 = 0x00, *S2 = 0x00, *D = 0x00 ;
2756/* MOVE(P) : 0001 100W HH1p pppp : A-156 */
2757static size_t dsp56k_op_movep(const UINT16 op, UINT8* cycles)
2758{
2759   UINT16 W;
2760   UINT16 pp;
2761   typed_pointer SD = {NULL, DT_BYTE};
19112762
1912   DecodeQQFTableSp(BITS(OP,0x0003), BITS(OP,0x0008), &S1, &S2, &D) ;
2763   decode_HH_table(BITS(op,0x00c0), &SD);
2764   /* TODO: Special cases for A & B */
19132765
1914   s = BITS(OP,0x0004) ;
2766   pp = op & 0x001f;
2767   pp = assemble_address_from_IO_short_address(pp);
19152768
1916   // !!! There is no way this is right - wtf is EXT:MSP:LSP format ???
1917   if (!s)
2769   W = BITS(op,0x0100);
2770
2771   if (W)
19182772   {
1919      // su
1920      result = ( (INT32)(*((UINT16*)S1)) *  (UINT32)(*((UINT16*)S2)) ) << 1 ;
2773      UINT16 data = data_read_word_16le(WORD(pp));
2774
2775      typed_pointer tempTP;
2776      tempTP.addr = &data;
2777      tempTP.data_type = DT_WORD;
2778
2779      SetDestinationValue(tempTP, SD);
19212780   }
19222781   else
19232782   {
1924      // uu
1925      result = ( (UINT32)(*((UINT16*)S1)) * (UINT32)(*((UINT16*)S2)) ) << 1 ;
2783      SetDataMemoryValue(SD, WORD(pp));
19262784   }
19272785
1928   (*((UINT64*)D)) += result ;
2786   /* S L E U N Z V C */
2787   /* * * - - - - - - */
2788   /* TODO: S, L */
19292789
1930   return retSize ;
2790   cycles += 4;      /* TODO: + mvp oscillator cycles */
2791   return 1;
19312792}
19322793
1933static int RepOperation(void)
2794/* MOVE(P) : 0000 110W RRmp pppp : A-156 */
2795static size_t dsp56k_op_movep_1(const UINT16 op, UINT8* cycles)
19342796{
1935   int retSize = 1 ;
2797   // X:<Rx> and X:<pp>
2798   UINT16 W;
2799   UINT16 pp;
19362800
1937   UINT16 count = 0x0000 ;
2801   typed_pointer SD = {NULL, DT_BYTE};
2802   decode_RR_table(BITS(op,0x00c0), &SD);
19382803
1939   if (BITS(OP,0x0f00) == 0xf)
2804   pp = op & 0x001f;
2805   pp = assemble_address_from_IO_short_address(pp);
2806
2807   W = BITS(OP,0x0100);
2808
2809   /* A little different than most W if's - opposite read and write */
2810   if (W)
19402811   {
1941      // immediate
1942      count = BITS(OP,0x00ff) ;
2812      UINT16 data = data_read_word_16le(WORD(*((UINT16*)SD.addr)));
2813
2814      typed_pointer tempTP;
2815      tempTP.addr = &data;
2816      tempTP.data_type = DT_WORD;
2817
2818      SetDataMemoryValue(tempTP, WORD(pp));
19432819   }
1944   else if (BITS(OP,0x0f00) == 0x4)
2820   else
19452821   {
1946      // SD
1947      unsigned char st = 0x00 ;
1948      void *S ;
2822      /* TODO */
2823      fatalerror("dsp56k : move(p) NOTHING HERE (yet)\n") ;
2824   }
19492825
1950      S = DecodeDDDDDTable(BITS(OP,0x001f), &st) ;
1951      SetDestinationValue(S, st, &count, DT_WORD);
2826   // Postincrement
2827   execute_m_table(BITS(OP,0x00c0), BITS(OP,0x0020));
2828
2829   /* S L E U N Z V C */
2830   /* * * - - - - - - */
2831   /* TODO: S, L */
2832   cycles += 4;      /* TODO: + mvp oscillator cycles */
2833   return 1;
2834}
2835
2836/* MOVE(S) : 0001 100W HH0a aaaa : A-158 */
2837static size_t dsp56k_op_moves(const UINT16 op, UINT8* cycles)
2838{
2839   /* S L E U N Z V C */
2840   /* * * - - - - - - */
2841   return 0;
2842}
2843
2844/* MPY(su,uu) : 0001 0101 1100 FsQQ : A-164 */
2845static size_t dsp56k_op_mpysuuu(const UINT16 op, UINT8* cycles)
2846{
2847   /* S L E U N Z V C */
2848   /* - * * * * * * - */
2849   return 0;
2850}
2851
2852/* NEGC : 0001 0101 0110 F000 : A-168 */
2853static size_t dsp56k_op_negc(const UINT16 op, UINT8* cycles)
2854{
2855   /* S L E U N Z V C */
2856   /* - * * * * * * * */
2857   return 0;
2858}
2859
2860/* NOP : 0000 0000 0000 0000 : A-170 */
2861static size_t dsp56k_op_nop(const UINT16 op, UINT8* cycles)
2862{
2863   /* S L E U N Z V C */
2864   /* - - - - - - - - */
2865   return 1;
2866}
2867
2868/* NORM : 0001 0101 0010 F0RR : A-172 */
2869static size_t dsp56k_op_norm(const UINT16 op, UINT8* cycles)
2870{
2871   /* S L E U N Z V C */
2872   /* - * * * * * ? - */
2873   /* V - Set if an arithmetic overflow occurs in the 40 bit result. Also set if the most significantst
2874           bit of the destination operand is changed as a result of the left shift. Cleared otherwise. */
2875   return 0;
2876}
2877
2878/* ORI : 0001 1EE1 iiii iiii : A-178 */
2879static size_t dsp56k_op_ori(const UINT16 op, UINT8* cycles)
2880{
2881   /* S L E U N Z V C */
2882   /* - ? ? ? ? ? ? ? */
2883   /* All ? bits - Set if the corresponding bit in the immediate data is set and if the operand is the
2884       CCR. Not affected otherwise. */
2885   return 0;
2886}
2887
2888/* REP : 0000 0000 111- --RR : A-180 */
2889static size_t dsp56k_op_rep(const UINT16 op, UINT8* cycles)
2890{
2891   /* S L E U N Z V C */
2892   /* - * - - - - - - */
2893   return 0;
2894}
2895
2896/* REP : 0000 1111 iiii iiii : A-180 */
2897static size_t dsp56k_op_rep_1(const UINT16 op, UINT8* cycles)
2898{
2899   /* TODO: This is non-interruptable, probably have to turn off interrupts here */
2900   UINT16 iVal = op & 0x00ff;
2901
2902   if (iVal != 0)
2903   {
2904      TEMP = LC;
2905      LC = iVal;
2906
2907      core.repFlag = 1;
2908      core.repAddr = PC + WORD(1);
2909
2910      cycles += 4;      /* TODO: + mv oscillator clock cycles */
19522911   }
19532912   else
19542913   {
1955      // X:(Rn)
2914      cycles += 6;      /* TODO: + mv oscillator clock cycles */
19562915   }
19572916
1958   TEMP = LC ;
1959   LC = count ;
19602917
1961   core.repFlag = 1 ;
1962   core.repAddr = PC + (retSize<<1) ;
2918   /* S L E U N Z V C */
2919   /* - * - - - - - - */
2920    /* TODO: L */
2921   return 1;
2922}
19632923
1964   return retSize ;
2924/* REP : 0000 0100 001D DDDD : A-180 */
2925static size_t dsp56k_op_rep_2(const UINT16 op, UINT8* cycles)
2926{
2927   /* TODO: This is non-interruptable, probably have to turn off interrupts here */
2928   UINT16 repValue;
2929   typed_pointer D = {NULL, DT_BYTE};
2930   decode_DDDDD_table(BITS(op,0x001f), &D);
2931
2932   /* TODO: handle special A&B source cases */
2933   if (D.addr == &A || D.addr == &B)
2934      logerror("DSP56k ERROR : Rep with A or B instruction not implemented yet!\n");
2935
2936   repValue = *((UINT16*)D.addr);
2937
2938   if (repValue != 0)
2939   {
2940      TEMP = LC;
2941      LC = repValue;
2942
2943      core.repFlag = 1;
2944      core.repAddr = PC + WORD(1);
2945
2946      cycles += 4;      /* TODO: + mv oscillator clock cycles */
2947   }
2948   else
2949   {
2950      cycles += 6;      /* TODO: + mv oscillator clock cycles */
2951   }
2952
2953   /* S L E U N Z V C */
2954   /* - * - - - - - - */
2955   /* TODO: L */
2956   return 1;
19652957}
19662958
1967static void EndOfRepProcessing(void)
2959/* REPcc : 0000 0001 0101 cccc : A-184 */
2960static size_t dsp56k_op_repcc(const UINT16 op, UINT8* cycles)
19682961{
1969   LC = TEMP ;
2962   /* S L E U N Z V C */
2963   /* - - - - - - - - */
2964   return 0;
2965}
19702966
1971   core.repFlag = 0 ;
1972   core.repAddr = 0x0000 ;
2967/* RESET : 0000 0000 0000 1000 : A-186 */
2968static size_t dsp56k_op_reset(const UINT16 op, UINT8* cycles)
2969{
2970   /* S L E U N Z V C */
2971   /* - - - - - - - - */
2972   return 0;
19732973}
19742974
2975/* RTI : 0000 0000 0000 0111 : A-194 */
2976static size_t dsp56k_op_rti(const UINT16 op, UINT8* cycles)
2977{
2978   core.ppc = PC;
2979   PC = SSH;
2980   change_pc(PC);
19752981
1976/*
1977DECODERS
1978*/
1979static void *DecodeDDDDDTable(UINT16 DDDDD, unsigned char *dt)
2982   SR = SSL;
2983   SP = SP - 1;
2984
2985   /* S L E U N Z V C */
2986   /* ? ? ? ? ? ? ? ? */
2987   /* All ? bits - Set according to value pulled from the stack. */
2988   cycles += 4;      /* TODO: + rx oscillator clock cycles */
2989   return 0;
2990}
2991
2992/* RTS : 0000 0000 0000 0110 : A-196 */
2993static size_t dsp56k_op_rts(const UINT16 op, UINT8* cycles)
19802994{
1981   void *retAddress = 0x00 ;
2995   /* Pop */
2996   core.ppc = PC;
2997   PC = SSH;
2998   change_pc(PC);
19822999
1983   switch(DDDDD)
3000   /* SR = SSL; The status register is not affected. */
3001
3002   SP--;
3003
3004   /* S L E U N Z V C */
3005   /* - - - - - - - - */
3006   cycles += 4;   /* TODO: + rx oscillator clock cycles */
3007   return 0;
3008}
3009
3010/* STOP : 0000 0000 0000 1010 : A-200 */
3011static size_t dsp56k_op_stop(const UINT16 op, UINT8* cycles)
3012{
3013   /* S L E U N Z V C */
3014   /* - - - - - - - - */
3015   return 0;
3016}
3017
3018/* SWAP : 0001 0101 0111 F001 : A-206 */
3019static size_t dsp56k_op_swap(const UINT16 op, UINT8* cycles)
3020{
3021   /* S L E U N Z V C */
3022   /* - - - - - - - - */
3023   return 0;
3024}
3025
3026/* SWI : 0000 0000 0000 0101 : A-208 */
3027static size_t dsp56k_op_swi(const UINT16 op, UINT8* cycles)
3028{
3029   /* S L E U N Z V C */
3030   /* - - - - - - - - */
3031   return 0;
3032}
3033
3034/* Tcc : 0001 00cc ccTT Fh0h : A-210 */
3035static size_t dsp56k_op_tcc(const UINT16 op, UINT8* cycles)
3036{
3037   int shouldTransfer = decode_cccc_table(BITS(op,0x03c0));
3038
3039   if (shouldTransfer)
19843040   {
1985      case 0x00: retAddress = &X0  ; *dt = DT_WORD ;      break ;
1986      case 0x01: retAddress = &Y0  ; *dt = DT_WORD ;      break ;
1987      case 0x02: retAddress = &X1  ; *dt = DT_WORD ;      break ;
1988      case 0x03: retAddress = &Y1  ; *dt = DT_WORD ;      break ;
1989      case 0x04: retAddress = &A   ; *dt = DT_LONG_WORD ; break ;
1990      case 0x05: retAddress = &B   ; *dt = DT_LONG_WORD ; break ;
1991      case 0x06: retAddress = &A0  ; *dt = DT_WORD ;      break ;
1992      case 0x07: retAddress = &B0  ; *dt = DT_WORD ;      break ;
1993      case 0x08: retAddress = &LC  ; *dt = DT_WORD ;      break ;
1994      case 0x09: retAddress = &SR  ; *dt = DT_WORD ;      break ;
1995      case 0x0a: retAddress = &OMR ; *dt = DT_BYTE ;      break ;
1996      case 0x0b: retAddress = &SP  ; *dt = DT_BYTE ;      break ;
1997      case 0x0c: retAddress = &A1  ; *dt = DT_WORD ;      break ;
1998      case 0x0d: retAddress = &B1  ; *dt = DT_WORD ;      break ;
1999      case 0x0e: retAddress = &A2  ; *dt = DT_BYTE ;      break ;
2000      case 0x0f: retAddress = &B2  ; *dt = DT_BYTE ;      break ;
3041      typed_pointer S = {NULL, DT_BYTE};
3042      typed_pointer D = {NULL, DT_BYTE};
3043      typed_pointer S2 = {&R0, DT_WORD};
3044      typed_pointer D2 = {NULL, DT_BYTE};
20013045
2002      case 0x10: retAddress = &R0  ; *dt = DT_WORD ;      break ;
2003      case 0x11: retAddress = &R1  ; *dt = DT_WORD ;      break ;
2004      case 0x12: retAddress = &R2  ; *dt = DT_WORD ;      break ;
2005      case 0x13: retAddress = &R3  ; *dt = DT_WORD ;      break ;
2006      case 0x14: retAddress = &M0  ; *dt = DT_WORD ;      break ;
2007      case 0x15: retAddress = &M1  ; *dt = DT_WORD ;      break ;
2008      case 0x16: retAddress = &M2  ; *dt = DT_WORD ;      break ;
2009      case 0x17: retAddress = &M3  ; *dt = DT_WORD ;      break ;
2010      case 0x18: retAddress = &SSH ; *dt = DT_WORD ;      break ;
2011      case 0x19: retAddress = &SSL ; *dt = DT_WORD ;      break ;
2012      case 0x1a: retAddress = &LA  ; *dt = DT_WORD ;      break ;
2013      //no 0x1b
2014      case 0x1c: retAddress = &N0  ; *dt = DT_WORD ;      break ;
2015      case 0x1d: retAddress = &N1  ; *dt = DT_WORD ;      break ;
2016      case 0x1e: retAddress = &N2  ; *dt = DT_WORD ;      break ;
2017      case 0x1f: retAddress = &N3  ; *dt = DT_WORD ;      break ;
3046      decode_h0hF_table(BITS(op,0x0007),BITS(op,0x0008), &S, &D);
3047      SetDestinationValue(S, D);
3048
3049      /* TODO: What's up with that A,A* thing in the docs?  Can you only ignore the R0->RX transfer if you do an A,A? */
3050      decode_RR_table(BITS(op,0x0030), &D2); /* TT is the same as RR */
3051      SetDestinationValue(S2, D2);
20183052   }
20193053
2020   return retAddress ;
3054   /* S L E U N Z V C */
3055   /* - - - - - - - - */
3056   cycles += 2;
3057   return 1;
20213058}
20223059
2023static void *DecodeRRTable(UINT16 RR, unsigned char *dt)
3060/* TFR(2) : 0001 0101 0000 F00J : A-214 */
3061static size_t dsp56k_op_tfr2(const UINT16 op, UINT8* cycles)
20243062{
2025   void *retAddress = 0x00 ;
3063   /* S L E U N Z V C */
3064   /* - * - - - - - - */
3065   return 0;
3066}
20263067
2027   switch(RR)
3068/* TFR(3) : 0010 01mW RRDD FHHH : A-216 */
3069static size_t dsp56k_op_tfr3(const UINT16 op, UINT8* cycles)
3070{
3071   /* S L E U N Z V C */
3072   /* * * - - - - - - */
3073   return 0;
3074}
3075
3076/* TST(2) : 0001 0101 0001 -1DD : A-220 */
3077static size_t dsp56k_op_tst2(const UINT16 op, UINT8* cycles)
3078{
3079   typed_pointer D = {NULL, DT_BYTE};
3080   decode_DD_table(BITS(op,0x0003), &D);
3081
3082   /* S L E U N Z V C */
3083   /* - * * * * * 0 0 */
3084   /* (L,E,U should be set to 0) */
3085   L_bit_set(0);
3086   E_bit_set(0);
3087   // U_bit_set(0);    /* TODO: Conflicting opinions?  "Set if unnormalized."  Documentation is weird (A&B?) */
3088   if ((*((UINT16*)D.addr)) &  0x8000) N_bit_set(1); else N_bit_set(0);
3089   if ((*((UINT16*)D.addr)) == 0x0000) Z_bit_set(1); else Z_bit_set(0);
3090   // V_bit_set(0);    /* TODO: Verify as well! */
3091   C_bit_set(0);
3092
3093   cycles += 2;
3094   return 1;
3095}
3096
3097/* WAIT : 0000 0000 0000 1011 : A-222 */
3098static size_t dsp56k_op_wait(const UINT16 op, UINT8* cycles)
3099{
3100   /* S L E U N Z V C */
3101   /* - - - - - - - - */
3102   return 0;
3103}
3104
3105/* ZERO : 0001 0101 0101 F000 : A-224 */
3106static size_t dsp56k_op_zero(const UINT16 op, UINT8* cycles)
3107{
3108   /* S L E U N Z V C */
3109   /* - * * * * * * - */
3110   return 0;
3111}
3112
3113
3114
3115/***************************************************************************
3116    Table decoding
3117***************************************************************************/
3118static UINT16 decode_BBB_bitmask(UINT16 BBB, UINT16 *iVal)
3119{
3120   UINT16 retVal = 0x0000;
3121
3122   switch(BBB)
20283123   {
2029      case 0x00: retAddress = &R0 ; *dt = DT_WORD ; break ;
2030      case 0x01: retAddress = &R1 ; *dt = DT_WORD ; break ;
2031      case 0x02: retAddress = &R2 ; *dt = DT_WORD ; break ;
2032      case 0x03: retAddress = &R3 ; *dt = DT_WORD ; break ;
3124      case 0x4: retVal = 0xff00;  *iVal <<= 8;  break;
3125      case 0x2: retVal = 0x0ff0;  *iVal <<= 4;  break;
3126      case 0x1: retVal = 0x00ff;  *iVal <<= 0;  break;
20333127   }
20343128
2035   return retAddress ;
3129   return retVal;
20363130}
20373131
2038static void *DecodeDDTable(UINT16 DD, unsigned char *dt)
3132static int decode_cccc_table(UINT16 cccc)
20393133{
2040   void *retAddress = 0x00 ;
3134   int retVal = 0;
20413135
2042   switch(DD)
3136   /* Not fully tested */
3137   switch (cccc)
20433138   {
2044      case 0x00: retAddress = &X0 ; *dt = DT_WORD ; break ;
2045      case 0x01: retAddress = &Y0 ; *dt = DT_WORD ; break ;
2046      case 0x02: retAddress = &X1 ; *dt = DT_WORD ; break ;
2047      case 0x03: retAddress = &Y1 ; *dt = DT_WORD ; break ;
3139      /* Arranged according to mnemonic table - not decoding table */
3140      case 0x0: if( C_bit() == 0)                              retVal = 1;  break;  // cc(hs)
3141      case 0x8: if( C_bit() == 1)                              retVal = 1;  break;  // cs(lo)
3142      case 0x5: if( E_bit() == 0)                              retVal = 1;  break;  // ec
3143      case 0xa: if( Z_bit() == 1)                              retVal = 1;  break;  // eq
3144      case 0xd: if( E_bit() == 1)                              retVal = 1;  break;  // es
3145      case 0x1: if((N_bit() ^  V_bit()) == 0)                  retVal = 1;  break;  // ge
3146      case 0x7: if((Z_bit() | (N_bit() ^ V_bit())) == 0)       retVal = 1;  break;  // gt
3147      case 0x6: if( L_bit() == 0)                              retVal = 1;  break;  // lc
3148      case 0xf: if((Z_bit() | (N_bit() ^ V_bit())) == 1)       retVal = 1;  break;  // le
3149      case 0xe: if( L_bit() == 1)                              retVal = 1;  break;  // ls
3150      case 0x9: if((N_bit() ^  V_bit()) == 1)                  retVal = 1;  break;  // lt
3151      case 0xb: if( N_bit() == 1)                              retVal = 1;  break;  // mi
3152      case 0x2: if( Z_bit() == 0)                              retVal = 1;  break;  // ne
3153      case 0xc: if((Z_bit() | ((!U_bit()) & (!E_bit()))) == 1) retVal = 1;  break;  // nr
3154      case 0x3: if( N_bit() == 0)                              retVal = 1;  break;  // pl
3155      case 0x4: if((Z_bit() | ((!U_bit()) & (!E_bit()))) == 0) retVal = 1;  break;  // nn
20483156   }
20493157
2050   return retAddress ;
3158   return retVal;
20513159}
20523160
2053static void *DecodeHHHTable(UINT16 HHH, unsigned char *dt)
3161static void decode_DDDDD_table(UINT16 DDDDD, typed_pointer* ret)
20543162{
2055   void *retAddress = 0x00 ;
3163   switch(DDDDD)
3164   {
3165      case 0x00: ret->addr = &X0;  ret->data_type = DT_WORD;       break;
3166      case 0x01: ret->addr = &Y0;  ret->data_type = DT_WORD;       break;
3167      case 0x02: ret->addr = &X1;  ret->data_type = DT_WORD;       break;
3168      case 0x03: ret->addr = &Y1;  ret->data_type = DT_WORD;       break;
3169      case 0x04: ret->addr = &A ;  ret->data_type = DT_LONG_WORD;  break;
3170      case 0x05: ret->addr = &B ;  ret->data_type = DT_LONG_WORD;  break;
3171      case 0x06: ret->addr = &A0;  ret->data_type = DT_WORD;       break;
3172      case 0x07: ret->addr = &B0;  ret->data_type = DT_WORD;       break;
3173      case 0x08: ret->addr = &LC;  ret->data_type = DT_WORD;       break;
3174      case 0x09: ret->addr = &SR;  ret->data_type = DT_WORD;       break;
3175      case 0x0a: ret->addr = &OMR; ret->data_type = DT_BYTE;       break;
3176      case 0x0b: ret->addr = &SP;  ret->data_type = DT_BYTE;       break;
3177      case 0x0c: ret->addr = &A1;  ret->data_type = DT_WORD;       break;
3178      case 0x0d: ret->addr = &B1;  ret->data_type = DT_WORD;       break;
3179      case 0x0e: ret->addr = &A2;  ret->data_type = DT_BYTE;       break;
3180      case 0x0f: ret->addr = &B2;  ret->data_type = DT_BYTE;       break;
20563181
2057   switch(HHH)
3182      case 0x10: ret->addr = &R0;  ret->data_type = DT_WORD;       break;
3183      case 0x11: ret->addr = &R1;  ret->data_type = DT_WORD;       break;
3184      case 0x12: ret->addr = &R2;  ret->data_type = DT_WORD;       break;
3185      case 0x13: ret->addr = &R3;  ret->data_type = DT_WORD;       break;
3186      case 0x14: ret->addr = &M0;  ret->data_type = DT_WORD;       break;
3187      case 0x15: ret->addr = &M1;  ret->data_type = DT_WORD;       break;
3188      case 0x16: ret->addr = &M2;  ret->data_type = DT_WORD;       break;
3189      case 0x17: ret->addr = &M3;  ret->data_type = DT_WORD;       break;
3190      case 0x18: ret->addr = &SSH; ret->data_type = DT_WORD;       break;
3191      case 0x19: ret->addr = &SSL; ret->data_type = DT_WORD;       break;
3192      case 0x1a: ret->addr = &LA;  ret->data_type = DT_WORD;       break;
3193      //no 0x1b
3194      case 0x1c: ret->addr = &N0;  ret->data_type = DT_WORD;       break;
3195      case 0x1d: ret->addr = &N1;  ret->data_type = DT_WORD;       break;
3196      case 0x1e: ret->addr = &N2;  ret->data_type = DT_WORD;       break;
3197      case 0x1f: ret->addr = &N3;  ret->data_type = DT_WORD;       break;
3198   }
3199}
3200
3201static void decode_DD_table(UINT16 DD, typed_pointer* ret)
3202{
3203   switch(DD)
20583204   {
2059      case 0x0: retAddress = &X0 ; *dt = DT_WORD ;      break ;
2060      case 0x1: retAddress = &Y0 ; *dt = DT_WORD ;      break ;
2061      case 0x2: retAddress = &X1 ; *dt = DT_WORD ;      break ;
2062      case 0x3: retAddress = &Y1 ; *dt = DT_WORD ;      break ;
2063      case 0x4: retAddress = &A  ; *dt = DT_LONG_WORD ; break ;
2064      case 0x5: retAddress = &B  ; *dt = DT_LONG_WORD ; break ;
2065      case 0x6: retAddress = &A0 ; *dt = DT_WORD ;      break ;
2066      case 0x7: retAddress = &B0 ; *dt = DT_WORD ;      break ;
3205      case 0x00: ret->addr = &X0;  ret->data_type = DT_WORD;  break;
3206      case 0x01: ret->addr = &Y0;  ret->data_type = DT_WORD;  break;
3207      case 0x02: ret->addr = &X1;  ret->data_type = DT_WORD;  break;
3208      case 0x03: ret->addr = &Y1;  ret->data_type = DT_WORD;  break;
20673209   }
3210}
20683211
2069   return retAddress ;
3212static void decode_F_table(UINT16 F, typed_pointer* ret)
3213{
3214   switch(F)
3215   {
3216      case 0x0: ret->addr = &A;  ret->data_type = DT_LONG_WORD;  break;
3217      case 0x1: ret->addr = &B;  ret->data_type = DT_LONG_WORD;  break;
3218   }
20703219}
20713220
2072static void *DecodeHHTable(UINT16 HH, unsigned char *dt)
3221static void decode_h0hF_table(UINT16 h0h, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret)
20733222{
2074   void *retAddress = 0x00 ;
3223   UINT16 switchVal = (h0h << 1) | F ;
20753224
3225   switch (switchVal)
3226   {
3227      case 0x8: src_ret->addr = &X0;  src_ret->data_type = DT_WORD;       dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3228      case 0x9: src_ret->addr = &X0;  src_ret->data_type = DT_WORD;       dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3229      case 0xa: src_ret->addr = &Y0;  src_ret->data_type = DT_WORD;       dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3230      case 0xb: src_ret->addr = &Y0;  src_ret->data_type = DT_WORD;       dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3231      case 0x2: src_ret->addr = &A;   src_ret->data_type = DT_LONG_WORD;  dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3232      case 0x1: src_ret->addr = &A;   src_ret->data_type = DT_LONG_WORD;  dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3233      case 0x0: src_ret->addr = &B;   src_ret->data_type = DT_LONG_WORD;  dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3234      case 0x3: src_ret->addr = &B;   src_ret->data_type = DT_LONG_WORD;  dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3235   }
3236}
3237
3238static void decode_HH_table(UINT16 HH, typed_pointer* ret)
3239{
20763240   switch(HH)
20773241   {
2078      case 0x0: retAddress = &X0 ; *dt = DT_WORD ;      break ;
2079      case 0x1: retAddress = &Y0 ; *dt = DT_WORD ;      break ;
2080      case 0x2: retAddress = &A  ; *dt = DT_LONG_WORD ; break ;
2081      case 0x3: retAddress = &B  ; *dt = DT_LONG_WORD ; break ;
3242      case 0x0: ret->addr = &X0;  ret->data_type = DT_WORD;       break;
3243      case 0x1: ret->addr = &Y0;  ret->data_type = DT_WORD;       break;
3244      case 0x2: ret->addr = &A;   ret->data_type = DT_LONG_WORD;  break;
3245      case 0x3: ret->addr = &B;   ret->data_type = DT_LONG_WORD;  break;
20823246   }
3247}
20833248
2084   return retAddress ;
3249static void decode_HHH_table(UINT16 HHH, typed_pointer* ret)
3250{
3251   switch(HHH)
3252   {
3253      case 0x0: ret->addr = &X0;  ret->data_type = DT_WORD;       break;
3254      case 0x1: ret->addr = &Y0;  ret->data_type = DT_WORD;       break;
3255      case 0x2: ret->addr = &X1;  ret->data_type = DT_WORD;       break;
3256      case 0x3: ret->addr = &Y1;  ret->data_type = DT_WORD;       break;
3257      case 0x4: ret->addr = &A;   ret->data_type = DT_LONG_WORD;  break;
3258      case 0x5: ret->addr = &B;   ret->data_type = DT_LONG_WORD;  break;
3259      case 0x6: ret->addr = &A0;  ret->data_type = DT_WORD;       break;
3260      case 0x7: ret->addr = &B0;  ret->data_type = DT_WORD;       break;
3261   }
20853262}
20863263
2087static void *DecodeZTable(UINT16 Z, unsigned char *dt)
3264static void decode_IIII_table(UINT16 IIII, typed_pointer* src_ret, typed_pointer* dst_ret, void *working)
20883265{
2089   void *retAddress = 0x00 ;
3266   void *opposite = 0x00 ;
20903267
2091   switch(Z)
3268   if (working == &A) opposite = &B ;
3269   else               opposite = &A ;
3270
3271   switch(IIII)
20923272   {
2093      // Fixed as per the Family Manual addendum
2094      case 0x01: retAddress = &A1 ; *dt = DT_WORD ; break ;
2095      case 0x00: retAddress = &B1 ; *dt = DT_WORD ; break ;
3273      case 0x0: src_ret->addr = &X0;      src_ret->data_type = DT_WORD;       dst_ret->addr = opposite;  dst_ret->data_type = DT_LONG_WORD;  break;
3274      case 0x1: src_ret->addr = &Y0;      src_ret->data_type = DT_WORD;       dst_ret->addr = opposite;  dst_ret->data_type = DT_LONG_WORD;  break;
3275      case 0x2: src_ret->addr = &X1;      src_ret->data_type = DT_WORD;       dst_ret->addr = opposite;  dst_ret->data_type = DT_LONG_WORD;  break;
3276      case 0x3: src_ret->addr = &Y1;      src_ret->data_type = DT_WORD;       dst_ret->addr = opposite;  dst_ret->data_type = DT_LONG_WORD;  break;
3277      case 0x4: src_ret->addr = &A;       src_ret->data_type = DT_LONG_WORD;  dst_ret->addr = &X0;       dst_ret->data_type = DT_WORD;       break;
3278      case 0x5: src_ret->addr = &B;       src_ret->data_type = DT_LONG_WORD;  dst_ret->addr = &Y0;       dst_ret->data_type = DT_WORD;       break;
3279      case 0x6: src_ret->addr = &A0;      src_ret->data_type = DT_WORD;       dst_ret->addr = &X0;       dst_ret->data_type = DT_WORD;       break;
3280      case 0x7: src_ret->addr = &B0;      src_ret->data_type = DT_WORD;       dst_ret->addr = &Y0;       dst_ret->data_type = DT_WORD;       break;
3281      case 0x8: src_ret->addr = working;  src_ret->data_type = DT_LONG_WORD;  dst_ret->addr = opposite;  dst_ret->data_type = DT_LONG_WORD;  break;
3282      case 0x9: src_ret->addr = working;  src_ret->data_type = DT_LONG_WORD;  dst_ret->addr = opposite;  dst_ret->data_type = DT_LONG_WORD;  break;
3283      case 0xc: src_ret->addr = &A;       src_ret->data_type = DT_LONG_WORD;  dst_ret->addr = &X1;       dst_ret->data_type = DT_WORD;       break;
3284      case 0xd: src_ret->addr = &B;       src_ret->data_type = DT_LONG_WORD;  dst_ret->addr = &Y1;       dst_ret->data_type = DT_WORD;       break;
3285      case 0xe: src_ret->addr = &A0;      src_ret->data_type = DT_WORD;       dst_ret->addr = &X1;       dst_ret->data_type = DT_WORD;       break;
3286      case 0xf: src_ret->addr = &B0;      src_ret->data_type = DT_WORD;       dst_ret->addr = &Y1;       dst_ret->data_type = DT_WORD;       break;
20963287   }
3288}
20973289
2098   return retAddress ;
3290static void decode_JJJF_table(UINT16 JJJ, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret)
3291{
3292   UINT16 switchVal = (JJJ << 1) | F ;
3293
3294   switch(switchVal)
3295   {
3296      case 0x0: src_ret->addr = &B;   src_ret->data_type = DT_LONG_WORD;    dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3297      case 0x1: src_ret->addr = &A;   src_ret->data_type = DT_LONG_WORD;    dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3298      case 0x4: src_ret->addr = &X;   src_ret->data_type = DT_DOUBLE_WORD;  dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3299      case 0x5: src_ret->addr = &X;   src_ret->data_type = DT_DOUBLE_WORD;  dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3300      case 0x6: src_ret->addr = &Y;   src_ret->data_type = DT_DOUBLE_WORD;  dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3301      case 0x7: src_ret->addr = &Y;   src_ret->data_type = DT_DOUBLE_WORD;  dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3302      case 0x8: src_ret->addr = &X0;  src_ret->data_type = DT_WORD;         dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3303      case 0x9: src_ret->addr = &X0;  src_ret->data_type = DT_WORD;         dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3304      case 0xa: src_ret->addr = &Y0;  src_ret->data_type = DT_WORD;         dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3305      case 0xb: src_ret->addr = &Y0;  src_ret->data_type = DT_WORD;         dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3306      case 0xc: src_ret->addr = &X1;  src_ret->data_type = DT_WORD;         dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3307      case 0xd: src_ret->addr = &X1;  src_ret->data_type = DT_WORD;         dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3308      case 0xe: src_ret->addr = &Y1;  src_ret->data_type = DT_WORD;         dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3309      case 0xf: src_ret->addr = &Y1;  src_ret->data_type = DT_WORD;         dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3310   }
20993311}
21003312
3313static void decode_JJF_table(UINT16 JJ, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret)
3314{
3315   UINT16 switchVal = (JJ << 1) | F ;
21013316
2102static UINT16 DecodeBBBBitMask(UINT16 BBB, UINT16 *iVal)
3317   switch (switchVal)
3318   {
3319      case 0x0: src_ret->addr = &X0;  src_ret->data_type = DT_WORD;  dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3320      case 0x1: src_ret->addr = &X0;  src_ret->data_type = DT_WORD;  dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3321      case 0x2: src_ret->addr = &Y0;  src_ret->data_type = DT_WORD;  dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3322      case 0x3: src_ret->addr = &Y0;  src_ret->data_type = DT_WORD;  dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3323      case 0x4: src_ret->addr = &X1;  src_ret->data_type = DT_WORD;  dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3324      case 0x5: src_ret->addr = &X1;  src_ret->data_type = DT_WORD;  dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3325      case 0x6: src_ret->addr = &Y1;  src_ret->data_type = DT_WORD;  dst_ret->addr = &A;  dst_ret->data_type = DT_LONG_WORD;  break;
3326      case 0x7: src_ret->addr = &Y1;  src_ret->data_type = DT_WORD;  dst_ret->addr = &B;  dst_ret->data_type = DT_LONG_WORD;  break;
3327   }
3328}
3329
3330static void decode_QQF_special_table(UINT16 QQ, UINT16 F, void **S1, void **S2, void **D)
21033331{
2104   UINT16 retVal = 0x00 ;
3332   UINT16 switchVal = (QQ << 1) | F ;
21053333
2106   switch(BBB)
3334   switch(switchVal)
21073335   {
2108      case 0x4: retVal = 0xff00 ; *iVal <<= 8 ; break ;
2109      case 0x2: retVal = 0x0ff0 ; *iVal <<= 4 ; break ;
2110      case 0x1: retVal = 0x00ff ; *iVal <<= 0 ; break ;
3336      case 0x0: *S1 = &Y0;  *S2 = &X0;  *D = &A;  break;
3337      case 0x1: *S1 = &Y0;  *S2 = &X0;  *D = &B;  break;
3338      case 0x2: *S1 = &Y1;  *S2 = &X0;  *D = &A;  break;
3339      case 0x3: *S1 = &Y1;  *S2 = &X0;  *D = &B;  break;
3340      case 0x4: *S1 = &X1;  *S2 = &Y0;  *D = &A;  break;
3341      case 0x5: *S1 = &X1;  *S2 = &Y0;  *D = &B;  break;
3342      case 0x6: *S1 = &X1;  *S2 = &Y1;  *D = &A;  break;
3343      case 0x7: *S1 = &X1;  *S2 = &Y1;  *D = &B;  break;
21113344   }
3345}
21123346
2113   return retVal ;
3347static void decode_RR_table(UINT16 RR, typed_pointer* ret)
3348{
3349   switch(RR)
3350   {
3351      case 0x00: ret->addr = &R0;  ret->data_type = DT_WORD;  break;
3352      case 0x01: ret->addr = &R1;  ret->data_type = DT_WORD;  break;
3353      case 0x02: ret->addr = &R2;  ret->data_type = DT_WORD;  break;
3354      case 0x03: ret->addr = &R3;  ret->data_type = DT_WORD;  break;
3355   }
21143356}
21153357
2116static void ExecuteMMTable(int x, UINT16 MM)
3358static void decode_Z_table(UINT16 Z, typed_pointer* ret)
21173359{
3360   switch(Z)
3361   {
3362      /* Fixed as per the Family Manual addendum */
3363      case 0x01: ret->addr = &A1;  ret->data_type = DT_WORD;  break;
3364      case 0x00: ret->addr = &B1;  ret->data_type = DT_WORD;  break;
3365   }
3366}
3367
3368static void execute_m_table(int x, UINT16 m)
3369{
21183370   UINT16 *rX = 0x00 ;
21193371   UINT16 *nX = 0x00 ;
21203372
21213373   switch(x)
21223374   {
2123      case 0x0: rX = &R0 ; nX = &N0 ; break ;
2124      case 0x1: rX = &R1 ; nX = &N1 ; break ;
2125      case 0x2: rX = &R2 ; nX = &N2 ; break ;
2126      case 0x3: rX = &R3 ; nX = &N3 ; break ;
3375      case 0x0: rX = &R0;  nX = &N0; break;
3376      case 0x1: rX = &R1;  nX = &N1; break;
3377      case 0x2: rX = &R2;  nX = &N2; break;
3378      case 0x3: rX = &R3;  nX = &N3; break;
21273379   }
21283380
2129   switch(MM)
3381   switch(m)
21303382   {
2131      case 0x0: /* do nothing */      break ;
2132      case 0x1: (*rX)++ ;             break ;
2133      case 0x2: (*rX)-- ;             break ;
2134      case 0x3: (*rX) = (*rX)+(*nX) ; break ;
3383      case 0x0: (*rX)++;             break;
3384      case 0x1: (*rX) = (*rX)+(*nX); break;
21353385   }
21363386}
21373387
2138static void ExecutemTable(int x, UINT16 m)
3388static void execute_MM_table(UINT16 rnum, UINT16 MM)
21393389{
21403390   UINT16 *rX = 0x00 ;
21413391   UINT16 *nX = 0x00 ;
21423392
2143   switch(x)
3393   switch(rnum)
21443394   {
2145      case 0x0: rX = &R0 ; nX = &N0 ; break ;
2146      case 0x1: rX = &R1 ; nX = &N1 ; break ;
2147      case 0x2: rX = &R2 ; nX = &N2 ; break ;
2148      case 0x3: rX = &R3 ; nX = &N3 ; break ;
3395      case 0x0: rX = &R0;  nX = &N0;  break;
3396      case 0x1: rX = &R1;  nX = &N1;  break;
3397      case 0x2: rX = &R2;  nX = &N2;  break;
3398      case 0x3: rX = &R3;  nX = &N3;  break;
21493399   }
21503400
2151   switch(m)
3401   switch(MM)
21523402   {
2153      case 0x0: (*rX)++ ;             break ;
2154      case 0x1: (*rX) = (*rX)+(*nX) ; break ;
3403      case 0x0: /* do nothing */      break;
3404      case 0x1: (*rX)++ ;             break;
3405      case 0x2: (*rX)-- ;             break;
3406      case 0x3: (*rX) = (*rX)+(*nX) ; break;
21553407   }
21563408}
21573409
2158static void ExecutezTable(int x, UINT16 z)
3410/* Returns R value */
3411static UINT16 execute_q_table(int x, UINT16 q)
21593412{
2160   UINT16 *rX = 0x00 ;
2161   UINT16 *nX = 0x00 ;
3413   UINT16 *rX = 0x0000;
3414   UINT16 *nX = 0x0000;
21623415
21633416   switch(x)
21643417   {
2165      case 0x0: rX = &R0 ; nX = &N0 ; break ;
2166      case 0x1: rX = &R1 ; nX = &N1 ; break ;
2167      case 0x2: rX = &R2 ; nX = &N2 ; break ;
2168      case 0x3: rX = &R3 ; nX = &N3 ; break ;
3418      case 0x0: rX = &R0;  nX = &N0;  break;
3419      case 0x1: rX = &R1;  nX = &N1;  break;
3420      case 0x2: rX = &R2;  nX = &N2;  break;
3421      case 0x3: rX = &R3;  nX = &N3;  break;
21693422   }
21703423
2171   if (!z)
3424   switch(q)
21723425   {
2173      (*rX)-- ;
3426      case 0x0: /* No permanent changes */ ; return (*rX)+(*nX); break;
3427      case 0x1: (*rX)--;                  return (*rX);      break;   // This one is special - it's a *PRE-decrement*!
21743428   }
2175   else
2176   {
2177      (*rX) = (*rX)+(*nX) ;
2178   }
3429
3430   /* Should not get here */
3431   exit(1);
3432   return 0x00;
21793433}
21803434
2181// Returns R address
2182static UINT16 ExecuteqTable(int x, UINT16 q)
3435#ifdef UNUSED_FUNCTION
3436static void execute_z_table(int x, UINT16 z)
21833437{
21843438   UINT16 *rX = 0x00 ;
21853439   UINT16 *nX = 0x00 ;
r3485r3486
21923446      case 0x3: rX = &R3 ; nX = &N3 ; break ;
21933447   }
21943448
2195   switch(q)
3449   if (!z)
21963450   {
2197      case 0x0: /* No permanent changes */ ; return (*rX)+(*nX); break;
2198      case 0x1: (*rX)--;                  return (*rX);      break;   // This one is special - it's a *PRE-decrement*!
3451      (*rX)-- ;
21993452   }
2200
2201   exit(1);
2202   return 0x00;
3453   else
3454   {
3455      (*rX) = (*rX)+(*nX) ;
3456   }
22033457}
2204
2205static UINT16 AssembleDFromPTable(UINT16 P, UINT16 ppppp)
3458#endif
3459static UINT16 assemble_address_from_Pppppp_table(UINT16 P, UINT16 ppppp)
22063460{
22073461   UINT16 destAddr = 0x00 ;
22083462
22093463   switch (P)
22103464   {
2211      case 0x0: destAddr = ppppp ; break ;
2212      case 0x1: destAddr = AssembleAddressFromIOShortAddress(ppppp) ; break ;
3465      case 0x0: destAddr = ppppp;  break;      /* TODO:  Does this really only address up to 0x32? */
3466      case 0x1: destAddr = assemble_address_from_IO_short_address(ppppp);  break;
22133467   }
22143468
22153469   return destAddr ;
22163470}
22173471
2218
2219static UINT16 AssembleAddressFromIOShortAddress(UINT16 pp)
3472static UINT16 assemble_address_from_IO_short_address(UINT16 pp)
22203473{
2221   UINT16 fullAddy = 0xffe0 ;
2222   fullAddy |= pp ;
2223   return fullAddy ;
3474   UINT16 fullAddy = 0xffe0;
3475   fullAddy |= pp;
3476   return fullAddy;
22243477}
22253478
2226static UINT16 AssembleAddressFrom6BitSignedRelativeShortAddress(UINT16 srs)
3479static UINT16 assemble_address_from_6bit_signed_relative_short_address(UINT16 srs)
22273480{
22283481   UINT16 fullAddy = srs ;
2229   if (fullAddy & 0x0020) fullAddy |= 0xffc0 ;
3482   if (fullAddy & 0x0020)
3483      fullAddy |= 0xffc0 ;
22303484
22313485   return fullAddy ;
22323486}
22333487
2234static int DecodeccccTable(UINT16 cccc)
3488static void dsp56k_process_loop(void)
22353489{
2236   int retVal = 0 ;
3490   if (LF_bit())
3491   {
3492      if (PC == LA)
3493      {
3494         if (LC == 1)
3495         {
3496            /* End of loop processing */
3497            SR = SSL;   /* TODO: A-83.  I believe only the Loop Flag comes back here. */
3498            SP--;
22373499
2238   // !!! go back and check me again someday - potential bugs !!!
2239   switch (cccc)
2240   {
2241      // Arranged according to mnemonic table - not decoding table...
2242      case 0x0: if( C_bit() == 0)                              retVal = 1 ; break ; // cc(hs)
2243      case 0x8: if( C_bit() == 1)                              retVal = 1 ; break ; // cs(lo)
2244      case 0x5: if( E_bit() == 0)                              retVal = 1 ; break ; // ec
2245      case 0xa: if( Z_bit() == 1)                              retVal = 1 ; break ; // eq
2246      case 0xd: if( E_bit() == 1)                              retVal = 1 ; break ; // es
2247      case 0x1: if((N_bit() ^ V_bit()) == 0)                   retVal = 1 ; break ; // ge
2248      case 0x7: if((Z_bit() + (N_bit() ^ V_bit())) == 0)       retVal = 1 ; break ; // gt
2249      case 0x6: if( L_bit() == 0)                              retVal = 1 ; break ; // lc
2250      case 0xf: if((Z_bit() + (N_bit() ^ V_bit())) == 1)       retVal = 1 ; break ; // le
2251      case 0xe: if( L_bit() == 1)                              retVal = 1 ; break ; // ls
2252      case 0x9: if((N_bit() ^ V_bit()) == 1)                   retVal = 1 ; break ; // lt
2253      case 0xb: if( N_bit() == 1)                              retVal = 1 ; break ; // mi
2254      case 0x2: if( Z_bit() == 0)                              retVal = 1 ; break ; // ne
2255      case 0xc: if((Z_bit() + ((!U_bit()) & (!E_bit()))) == 1) retVal = 1 ; break ; // nr
2256      case 0x3: if( N_bit() == 0)                              retVal = 1 ; break ; // pl
2257      case 0x4: if((Z_bit() + ((!U_bit()) & (!E_bit()))) == 0) retVal = 1 ; break ; // nn
3500            LA = SSH;
3501            LC = SSL;
3502            SP--;
3503         }
3504         else
3505         {
3506            LC--;
3507            PC = SSH;
3508            change_pc(PC);
3509         }
3510      }
22583511   }
2259
2260   return retVal ;
22613512}
22623513
2263static void Decodeh0hFTable(UINT16 h0h, UINT16 F,
2264                void **source, unsigned char *st,
2265                void **dest,   unsigned char *dt)
3514static void dsp56k_process_rep(size_t repSize)
22663515{
2267   UINT16 switchVal = (h0h << 1) | F ;
2268
2269   switch (switchVal)
3516   if (core.repFlag)
22703517   {
2271      case 0x8: *source = &X0 ; *st = DT_WORD ;      *dest = &A ; *dt = DT_LONG_WORD ; break ;
2272      case 0x9: *source = &X0 ; *st = DT_WORD ;      *dest = &B ; *dt = DT_LONG_WORD ; break ;
2273      case 0xa: *source = &Y0 ; *st = DT_WORD ;      *dest = &A ; *dt = DT_LONG_WORD ; break ;
2274      case 0xb: *source = &Y0 ; *st = DT_WORD ;      *dest = &B ; *dt = DT_LONG_WORD ; break ;
2275      case 0x2: *source = &A  ; *st = DT_LONG_WORD ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2276      case 0x1: *source = &A  ; *st = DT_LONG_WORD ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
2277      case 0x0: *source = &B  ; *st = DT_LONG_WORD ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2278      case 0x3: *source = &B  ; *st = DT_LONG_WORD ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
3518      if (PC == core.repAddr)
3519      {
3520         if (LC == 1)
3521         {
3522            /* End of rep processing */
3523            LC = TEMP;
3524            core.repFlag = 0;
3525            core.repAddr = 0x0000;
3526         }
3527         else
3528         {
3529            LC--;
3530            PC -= repSize;      /* A little strange - rewind by the size of the rep'd op */
3531            change_pc(PC);
3532         }
3533      }
22793534   }
22803535}
22813536
2282static void *DecodeFTable(UINT16 F, unsigned char *dt)
2283{
2284   void *retAddress = 0x00 ;
22853537
2286   switch(F)
2287   {
2288      case 0x0: retAddress = &A ; *dt = DT_LONG_WORD ; break ;
2289      case 0x1: retAddress = &B ; *dt = DT_LONG_WORD ; break ;
2290   }
2291
2292   return retAddress ;
2293}
2294
2295static void DecodeJJJFTable(UINT16 JJJ, UINT16 F,
2296                void **source, unsigned char *st,
2297                void **dest,   unsigned char *dt)
3538/***************************************************************************
3539    Parallel Memory Ops
3540***************************************************************************/
3541/* Register to Register Data Move : 0100 IIII ---- ---- */
3542static void execute_register_to_register_data_move(const UINT16 op, typed_pointer* d_register, UINT64* prev_accum_value)
22983543{
2299   UINT16 switchVal = (JJJ << 1) | F ;
3544   typed_pointer S = {NULL, DT_BYTE};
3545   typed_pointer D = {NULL, DT_BYTE};
23003546
2301   switch(switchVal)
2302   {
2303      case 0x0: *source = &B  ; *st = DT_LONG_WORD   ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2304      case 0x1: *source = &A  ; *st = DT_LONG_WORD   ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
2305      case 0x4: *source = &X  ; *st = DT_DOUBLE_WORD ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2306      case 0x5: *source = &X  ; *st = DT_DOUBLE_WORD ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
2307      case 0x6: *source = &Y  ; *st = DT_DOUBLE_WORD ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2308      case 0x7: *source = &Y  ; *st = DT_DOUBLE_WORD ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
2309      case 0x8: *source = &X0 ; *st = DT_WORD        ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2310      case 0x9: *source = &X0 ; *st = DT_WORD        ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
2311      case 0xa: *source = &Y0 ; *st = DT_WORD        ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2312      case 0xb: *source = &Y0 ; *st = DT_WORD        ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
2313      case 0xc: *source = &X1 ; *st = DT_WORD        ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2314      case 0xd: *source = &X1 ; *st = DT_WORD        ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
2315      case 0xe: *source = &Y1 ; *st = DT_WORD        ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2316      case 0xf: *source = &Y1 ; *st = DT_WORD        ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
2317   }
2318}
3547   decode_IIII_table(BITS(op,0x0f00), &S, &D, d_register->addr);
23193548
2320static void DecodeJJFTable(UINT16 JJ, UINT16 F,
2321               void **source, unsigned char *st,
2322               void **dest, unsigned char *dt)
2323{
2324   UINT16 switchVal = (JJ << 1) | F ;
2325
2326   switch (switchVal)
3549   /* If the source is the same as the ALU destination, use the previous accumulator value */
3550   if (d_register->addr == S.addr)
23273551   {
2328      case 0x0: *source = &X0 ; *st = DT_WORD ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2329      case 0x1: *source = &X0 ; *st = DT_WORD ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
2330      case 0x2: *source = &Y0 ; *st = DT_WORD ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2331      case 0x3: *source = &Y0 ; *st = DT_WORD ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
2332      case 0x4: *source = &X1 ; *st = DT_WORD ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2333      case 0x5: *source = &X1 ; *st = DT_WORD ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
2334      case 0x6: *source = &Y1 ; *st = DT_WORD ; *dest = &A ; *dt = DT_LONG_WORD ; break ;
2335      case 0x7: *source = &Y1 ; *st = DT_WORD ; *dest = &B ; *dt = DT_LONG_WORD ; break ;
3552      typed_pointer tempTP;
3553      tempTP.addr = prev_accum_value;
3554      tempTP.data_type = DT_LONG_WORD;
3555      SetDestinationValue(tempTP, D);
23363556   }
2337}
2338
2339// Types not necessary - we know what we are...
2340static void DecodeQQFTableSp(UINT16 QQ, UINT16 F, void **S1, void **S2, void **D)
2341{
2342   UINT16 switchVal = (QQ << 1) | F ;
2343
2344   switch(switchVal)
3557   else
23453558   {
2346      case 0x0: *S1 = &Y0 ; *S2 = &X0 ; *D = &A ; break ;
2347      case 0x1: *S1 = &Y0 ; *S2 = &X0 ; *D = &B ; break ;
2348      case 0x2: *S1 = &Y1 ; *S2 = &X0 ; *D = &A ; break ;
2349      case 0x3: *S1 = &Y1 ; *S2 = &X0 ; *D = &B ; break ;
2350      case 0x4: *S1 = &X1 ; *S2 = &Y0 ; *D = &A ; break ;
2351      case 0x5: *S1 = &X1 ; *S2 = &Y0 ; *D = &B ; break ;
2352      case 0x6: *S1 = &X1 ; *S2 = &Y1 ; *D = &A ; break ;
2353      case 0x7: *S1 = &X1 ; *S2 = &Y1 ; *D = &B ; break ;
3559      SetDestinationValue(S, D);
23543560   }
23553561}
23563562
2357static void DecodeIIIITable(UINT16 IIII,
2358                void **source, unsigned char *st,
2359                void **dest, unsigned char *dt,
2360                void *working)
3563/* X Memory Data Move : 1mRR HHHW ---- ---- : A-137 */
3564static void execute_x_memory_data_move(const UINT16 op, typed_pointer* d_register, UINT64* prev_accum_value)
23613565{
2362   void *opposite = 0x00 ;
3566   UINT16 W;
3567   typed_pointer R = {NULL, DT_BYTE};
3568   typed_pointer SD = {NULL, DT_BYTE};
23633569
2364   if (working == &A) opposite = &B ;
2365   else               opposite = &A ;
3570   W = BITS(op,0x0100);
3571   decode_HHH_table(BITS(op,0x0e00), &SD);
3572   decode_RR_table(BITS(op,0x3000),&R);
23663573
2367   switch(IIII)
3574   if (W)
23683575   {
2369      case 0x0: *source = &X0      ; *st = DT_WORD ;      *dest = opposite ; *dt = DT_LONG_WORD ; break ;
2370      case 0x1: *source = &Y0      ; *st = DT_WORD ;      *dest = opposite ; *dt = DT_LONG_WORD ; break ;
2371      case 0x2: *source = &X1      ; *st = DT_WORD ;      *dest = opposite ; *dt = DT_LONG_WORD ; break ;
2372      case 0x3: *source = &Y1      ; *st = DT_WORD ;      *dest = opposite ; *dt = DT_LONG_WORD ; break ;
2373      case 0x4: *source = &A       ; *st = DT_LONG_WORD ; *dest = &X0      ; *dt = DT_WORD ;      break ;
2374      case 0x5: *source = &B       ; *st = DT_LONG_WORD ; *dest = &Y0      ; *dt = DT_WORD ;      break ;
2375      case 0x6: *source = &A0      ; *st = DT_WORD ;      *dest = &X0      ; *dt = DT_WORD ;      break ;
2376      case 0x7: *source = &B0      ; *st = DT_WORD ;      *dest = &Y0      ; *dt = DT_WORD ;      break ;
2377      case 0x8: *source = working  ; *st = DT_LONG_WORD ; *dest = opposite ; *dt = DT_LONG_WORD ; break ;
2378      case 0x9: *source = working  ; *st = DT_LONG_WORD ; *dest = opposite ; *dt = DT_LONG_WORD ; break ;
2379      case 0xc: *source = &A       ; *st = DT_LONG_WORD ; *dest = &X1      ; *dt = DT_WORD ;      break ;
2380      case 0xd: *source = &B       ; *st = DT_LONG_WORD ; *dest = &Y1      ; *dt = DT_WORD ;      break ;
2381      case 0xe: *source = &A0      ; *st = DT_WORD ;      *dest = &X1      ; *dt = DT_WORD ;      break ;
2382      case 0xf: *source = &B0      ; *st = DT_WORD ;      *dest = &Y1      ; *dt = DT_WORD ;      break ;
2383   }
2384}
3576      /* From X:<ea> to SD */
3577      UINT16 data = data_read_word_16le(WORD(*((UINT16*)R.addr)));
23853578
2386/*
2387MEMORY OPS
2388*/
3579      typed_pointer tempTP;
3580      tempTP.addr = &data;
3581      tempTP.data_type = DT_WORD;
23893582
2390static void XMDMOperation(UINT16 parameters, void *working, UINT64 *pa)
2391{
2392   UINT16 W ;
2393   unsigned char rdt = 0x00 ;
2394   void *R = 0x00 ;
2395
2396   unsigned char sdt = 0x00 ;
2397   void *SD = 0x00 ;
2398
2399   // Get the source
2400   SD = DecodeHHHTable(BITS(parameters,0x000e), &sdt) ;
2401
2402   // Get the destination
2403   R = DecodeRRTable(BITS(parameters,0x0030), &rdt) ;
2404
2405   // Move the data
2406   W = BITS(parameters,0x0001) ;
2407
2408   if (W)
2409   {
2410      // from X:<ea> to SD...
2411      // !!! TODO : Fill in similar comments for other "if (W)'s" !!!
2412      UINT16 data = data_read_word_16le((*((UINT16*)R))<<1) ;      // read the word out
2413      SetDestinationValue(&data, DT_WORD, SD, sdt) ;
3583      SetDestinationValue(tempTP, SD);
24143584   }
24153585   else
24163586   {
2417      // from SD to X:<ea>...
3587      /* From SD to X:<ea> */
3588      /* If the source is the same as the ALU destination, use the previous accumulator value */
3589      if (d_register->addr == SD.addr)
3590      {
3591         typed_pointer tempTP;
3592         tempTP.addr = prev_accum_value;
3593         tempTP.data_type = DT_LONG_WORD;
24183594
2419      // If the source is the same as the ALU destination, use the Previous Accumulator value
2420      if (working == SD)
2421      {
2422         // the value before the ALU operation was executed...
2423         SetDataMemoryValue(pa, DT_LONG_WORD, (*((UINT16*)R))<<1) ;
3595         SetDataMemoryValue(tempTP, WORD(*((UINT16*)R.addr))) ;
24243596      }
24253597      else
24263598      {
2427         // Expected memory move
2428         SetDataMemoryValue(SD, sdt, (*((UINT16*)R))<<1) ;
3599         SetDataMemoryValue(SD, WORD(*((UINT16*)R.addr))) ;
24293600      }
24303601   }
24313602
2432   // Postincrement
2433   ExecutemTable(BITS(parameters,0x0030), BITS(parameters,0x0040)) ;
3603   execute_m_table(BITS(op,0x3000), BITS(op,0x4000));
24343604}
24353605
2436static void RRDMOperation(UINT16 parameters, void *working, UINT64 *pa)
3606
3607/* X Memory Data Move : 0101 HHHW ---- ---- : A-137 */
3608/* NOTE: previous accumulator value is not needed since ^F1 is always the opposite accumulator */
3609static void execute_x_memory_data_move2(const UINT16 op, typed_pointer* d_register)
24373610{
2438   unsigned char st = 0x00, dt = 0x00 ;
2439   void *S = 0x00, *D = 0x00;
3611   UINT16 W;
3612   UINT16* mem_offset = NULL;
3613   typed_pointer SD = {NULL, DT_BYTE};
24403614
2441   DecodeIIIITable(BITS(parameters,0x000f), &S, &st, &D, &dt, working) ;
3615   W = BITS(op,0x0100);
3616   decode_HHH_table(BITS(op,0x0e000), &SD);
24423617
2443   // If the source is what we're working with, use the old value
2444   if (S == working)
2445      SetDestinationValue(pa, DT_LONG_WORD, D, dt) ;
3618   if (d_register->addr == &A)
3619      mem_offset = &B1;
24463620   else
2447      SetDestinationValue(S, st, D, dt) ;
2448}
3621      mem_offset = &A1;
24493622
2450
2451static void XMDMSpecialOperation(UINT16 parameters, void *working)
2452{
2453    UINT16 W ;
2454   UINT16 *dest = 0x00 ;
2455
2456   // Get the source/destination
2457   unsigned char sdt = 0x00 ;
2458   void *SD = 0x00 ;
2459   SD = DecodeHHHTable(BITS(parameters,0x000e), &sdt) ;
2460
2461   // Get the opposite A/B depending on what was used before
2462    if (working == &A)
2463        dest = &B1 ;
2464    else if (working == &B)
2465        dest = &A1 ;
2466    else
2467    {
2468        mame_printf_debug("WTF MF\n") ;
2469        return ;
2470    }
2471
2472   // Move the data
2473   W = BITS(parameters,0x0001) ;
2474
24753623   if (W)
24763624   {
2477      // from X:<ea> to SD...
2478      // !!! DOES THIS WORK ???
2479      UINT16 data = data_read_word_16le((*dest)<<1) ;      // read the word out
2480      SetDestinationValue(&data, DT_WORD, SD, sdt) ;
3625      /* Write D */
3626      UINT16 value = data_read_word_16le(WORD(*mem_offset));
3627      typed_pointer tempV = {&value, DT_WORD};
3628      SetDestinationValue(tempV, SD);
24813629   }
24823630   else
24833631   {
2484      // Normal memory move
2485      SetDataMemoryValue(SD, sdt, (*dest)<<1) ;
3632      /* Read S */
3633      SetDataMemoryValue(SD, WORD(*mem_offset));
24863634   }
24873635}
24883636
2489static void ARUOperation(UINT16 parameters)
2490{
2491   ExecutezTable(BITS(parameters, 0x0003), BITS(parameters, 0x0004)) ;
2492}
24933637
2494
2495/*
2496HELPERS
2497*/
3638/***************************************************************************
3639    Helper Functions
3640***************************************************************************/
24983641static UINT16 Dsp56kOpMask(UINT16 cur, UINT16 mask)
24993642{
25003643   int i ;
r3485r3486
25163659   return temp ;
25173660}
25183661
2519
2520static void SetDestinationValue(void *sourcePointer, unsigned char sourceType,
2521                   void *destinationPointer, unsigned char destinationType)
3662static void SetDestinationValue(typed_pointer source, typed_pointer dest)
25223663{
25233664   UINT64 destinationValue = 0 ;
25243665
2525   switch(destinationType)
3666   switch(dest.data_type)
25263667   {
3668      /* Copying to an 8-bit value */
25273669      case DT_BYTE:
2528         switch(sourceType)
3670         switch(source.data_type)
25293671         {
2530            case DT_BYTE:        *((UINT8*)destinationPointer) = *((UINT8*) sourcePointer) ; break ;
2531            case DT_WORD:        *((UINT8*)destinationPointer) = *((UINT16*)sourcePointer) ; break ;
2532            case DT_DOUBLE_WORD: *((UINT8*)destinationPointer) = *((UINT32*)sourcePointer) ; break ;
2533            case DT_LONG_WORD:   *((UINT8*)destinationPointer) = *((UINT64*)sourcePointer) ; break ;
3672            /* From a ? */
3673            case DT_BYTE:        *((UINT8*)dest.addr) = (*((UINT8*) source.addr)) & 0xff; break;
3674            case DT_WORD:        *((UINT8*)dest.addr) = (*((UINT16*)source.addr)) & 0x00ff; break;
3675            case DT_DOUBLE_WORD: *((UINT8*)dest.addr) = (*((UINT32*)source.addr)) & 0x000000ff; break;
3676            case DT_LONG_WORD:   *((UINT8*)dest.addr) = (*((UINT64*)source.addr)) & U64(0x00000000000000ff); break;
25343677         }
25353678      break ;
25363679
3680      /* Copying to a 16-bit value */
25373681      case DT_WORD:
2538         switch(sourceType)
3682         switch(source.data_type)
25393683         {
2540            case DT_BYTE:        *((UINT16*)destinationPointer) = *((UINT8*) sourcePointer) ; break ;
2541            case DT_WORD:        *((UINT16*)destinationPointer) = *((UINT16*)sourcePointer) ; break ;
2542            case DT_DOUBLE_WORD: *((UINT16*)destinationPointer) = *((UINT32*)sourcePointer) ; break ;
2543            // !!! This one is interesting too - shifter limiter action !!!
2544            case DT_LONG_WORD:   *((UINT16*)destinationPointer) = *((UINT64*)sourcePointer) ; break ;
3684            case DT_BYTE:        *((UINT16*)dest.addr) = (*((UINT8*) source.addr)) & 0xff; break;
3685            case DT_WORD:        *((UINT16*)dest.addr) = (*((UINT16*)source.addr)) & 0xffff; break;
3686            case DT_DOUBLE_WORD: *((UINT16*)dest.addr) = (*((UINT32*)source.addr)) & 0x0000ffff; break;
3687            case DT_LONG_WORD:   *((UINT16*)dest.addr) = (*((UINT64*)source.addr)) & U64(0x000000000000ffff); break;   /* Shift limiter action? */
25453688         }
25463689      break ;
25473690
3691      /* Copying to a 32-bit value */
25483692      case DT_DOUBLE_WORD:
2549         switch(sourceType)
3693         switch(source.data_type)
25503694         {
2551            case DT_BYTE:        *((UINT32*)destinationPointer) = *((UINT8*) sourcePointer) ; break ;
2552            case DT_WORD:        *((UINT32*)destinationPointer) = *((UINT16*)sourcePointer) ; break ;
2553            case DT_DOUBLE_WORD: *((UINT32*)destinationPointer) = *((UINT32*)sourcePointer) ; break ;
2554            case DT_LONG_WORD:   *((UINT32*)destinationPointer) = *((UINT64*)sourcePointer) ; break ;
3695            case DT_BYTE:        *((UINT32*)dest.addr) = (*((UINT8*) source.addr)) & 0xff; break;
3696            case DT_WORD:        *((UINT32*)dest.addr) = (*((UINT16*)source.addr)) & 0xffff; break;
3697            case DT_DOUBLE_WORD: *((UINT32*)dest.addr) = (*((UINT32*)source.addr)) & 0xffffffff; break;
3698            case DT_LONG_WORD:   *((UINT32*)dest.addr) = (*((UINT64*)source.addr)) & U64(0x00000000ffffffff); break;
25553699         }
25563700      break ;
25573701
3702      /* Copying to a 64-bit value */
25583703      case DT_LONG_WORD:
2559         switch(sourceType)
3704         switch(source.data_type)
25603705         {
2561            case DT_BYTE:        *((UINT64*)destinationPointer) = *((UINT8*) sourcePointer) ; break ;
3706            case DT_BYTE:        *((UINT64*)dest.addr) = (*((UINT8*)source.addr)) & 0xff; break;
25623707
2563            // !!! sign extending works on intel, others ???
2564                // !!! Need to check the shift limiter here too !!!
2565            case DT_WORD:        destinationValue = (*((INT16*)sourcePointer)) << 16 ;        // Insure sign extending
2566                            destinationValue &= (UINT64)U64(0x000000ffffff0000) ;
2567                            *((UINT64*)destinationPointer) = destinationValue ;        break ;
3708            case DT_WORD:        destinationValue = (*((INT16*)source.addr)) << 16;         /* Sign extend */
3709                            destinationValue &= U64(0x000000ffffff0000);
3710                            *((UINT64*)dest.addr) = destinationValue; break;         /* Forget not, yon shift register */
25683711
2569            case DT_DOUBLE_WORD: *((UINT64*)destinationPointer) = *((UINT32*)sourcePointer) ; break ;
2570            case DT_LONG_WORD:   *((UINT64*)destinationPointer) = *((UINT64*)sourcePointer) ; break ;
3712            case DT_DOUBLE_WORD: *((UINT64*)dest.addr) = (*((UINT32*)source.addr)) & 0xffffffff; break;
3713            case DT_LONG_WORD:   *((UINT64*)dest.addr) = (*((UINT64*)source.addr)) & U64(0x000000ffffffffff); break;
25713714         }
25723715      break ;
25733716   }
25743717}
25753718
2576// !! redundant functions (data and memory) can be handled with function pointers !!
2577static void SetDataMemoryValue(void *sourcePointer, unsigned char sourceType, UINT32 destinationAddr)
3719/* TODO: Wait-state timings! */
3720static void SetDataMemoryValue(typed_pointer source, UINT32 destinationAddr)
25783721{
2579   // mame_printf_debug("%d %x\n", sourceType, destinationAddr) ;
2580
2581   // I wonder if this is how this should be done???
2582   switch(sourceType)
3722   switch(source.data_type)
25833723   {
2584      case DT_BYTE:        data_write_word_16le(destinationAddr, (UINT16)( (*((UINT8*) sourcePointer) & 0xff)               ) ) ; break ;
2585      case DT_WORD:        data_write_word_16le(destinationAddr, (UINT16)( (*((UINT16*)sourcePointer) & 0xffff)             ) ) ; break ;
2586      case DT_DOUBLE_WORD: data_write_word_16le(destinationAddr, (UINT16)( (*((UINT32*)sourcePointer) & 0x0000ffff)         ) ) ; break ;
3724      case DT_BYTE:        data_write_word_16le(destinationAddr, (UINT16)( (*((UINT8*) source.addr) & 0xff)               ) ) ; break ;
3725      case DT_WORD:        data_write_word_16le(destinationAddr, (UINT16)( (*((UINT16*)source.addr) & 0xffff)             ) ) ; break ;
3726      case DT_DOUBLE_WORD: data_write_word_16le(destinationAddr, (UINT16)( (*((UINT32*)source.addr) & 0x0000ffff)         ) ) ; break ;
25873727
25883728      // !!! Is this universal ???
25893729      // !!! Forget not, yon shift-limiter !!!
2590      case DT_LONG_WORD:   data_write_word_16le(destinationAddr, (UINT16)( ((*((UINT64*)sourcePointer)) & (UINT64)U64(0x00000000ffff0000)) >> 16) ) ; break ;
3730      case DT_LONG_WORD:   data_write_word_16le(destinationAddr, (UINT16)( ((*((UINT64*)source.addr)) & U64(0x00000000ffff0000)) >> 16) ) ; break ;
25913731   }
25923732}
25933733
2594static void SetProgramMemoryValue(void *sourcePointer, unsigned char sourceType, UINT32 destinationAddr)
3734/* TODO: Wait-state timings! */
3735static void SetProgramMemoryValue(typed_pointer source, UINT32 destinationAddr)
25953736{
2596   // I wonder if this is how this should be done???
2597   switch(sourceType)
3737   switch(source.data_type)
25983738   {
2599      case DT_BYTE:        program_write_word_16le(destinationAddr, (UINT16)( (*((UINT8*) sourcePointer) & 0xff)               ) ) ; break ;
2600      case DT_WORD:        program_write_word_16le(destinationAddr, (UINT16)( (*((UINT16*)sourcePointer) & 0xffff)             ) ) ; break ;
2601      case DT_DOUBLE_WORD: program_write_word_16le(destinationAddr, (UINT16)( (*((UINT32*)sourcePointer) & 0x0000ffff)         ) ) ; break ;
3739      case DT_BYTE:        program_write_word_16le(destinationAddr, (UINT16)( (*((UINT8*) source.addr) & 0xff)               ) ) ; break ;
3740      case DT_WORD:        program_write_word_16le(destinationAddr, (UINT16)( (*((UINT16*)source.addr) & 0xffff)             ) ) ; break ;
3741      case DT_DOUBLE_WORD: program_write_word_16le(destinationAddr, (UINT16)( (*((UINT32*)source.addr) & 0x0000ffff)         ) ) ; break ;
26023742
26033743      // !!! Is this universal ???
26043744      // !!! Forget not, yon shift-limiter !!!
2605      case DT_LONG_WORD:   program_write_word_16le(destinationAddr, (UINT16)( ((*((UINT64*)sourcePointer)) & (UINT64)U64(0x00000000ffff0000)) >> 16) ) ; break ;
3745      case DT_LONG_WORD:   program_write_word_16le(destinationAddr, (UINT16)( ((*((UINT64*)source.addr)) & U64(0x00000000ffff0000)) >> 16) ) ; break ;
26063746   }
26073747}
26083748
src/emu/cpu/dsp56k/dsp56dsm.c
r3485r3486
5252static size_t dsp56k_dasm_eor      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
5353static size_t dsp56k_dasm_subl      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
5454static 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);
55static size_t dsp56k_dasm_clr24      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
5656static size_t dsp56k_dasm_sbc      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
5757static size_t dsp56k_dasm_cmp      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
5858static size_t dsp56k_dasm_neg      (const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register);
r3485r3486
461461         /* CLR24 : .... .... 0101 F001 : A-62 */
462462         else if ((op_byte & 0x00f7) == 0x0051)
463463         {
464            size = dsp56k_dasm_clr2(op_byte, opcode_str, arg_str, d_register);
464            size = dsp56k_dasm_clr24(op_byte, opcode_str, arg_str, d_register);
465465         }
466466         /* SBC : .... .... 0101 F01J : A-198 */
467467         else if ((op_byte & 0x00f6) == 0x0052)
r3485r3486
14081408}
14091409
14101410/* CLR24 : .... .... 0101 F001 : A-62 */
1411static size_t dsp56k_dasm_clr2(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
1411static size_t dsp56k_dasm_clr24(const UINT16 op_byte, char* opcode_str, char* arg_str, char* d_register)
14121412{
14131413   char D[32];
14141414   decode_F_table(BITS(op_byte,0x08), D);
r3485r3486
18201820static size_t dsp56k_dasm_bsr(const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc)
18211821{
18221822   sprintf(opcode_str, "bsr");
1823   sprintf(arg_str, "%d (0x%04x)", (INT16)op2, pc + 2 + (INT16)op2);
1823   sprintf(arg_str, "%x (0x%04x)", (INT16)op2, pc + 2 + (INT16)op2);
18241824   return (2 | DASMFLAG_STEP_OVER);
18251825}
18261826
r3485r3486
26062606
26072607   decode_IIII_table(BITS(op,0x0f00), S, D);
26082608
2609   if (S[0] == 'F')
2610   {
2611      S[0] = d_register[0];
2612      S[1] = 0x00;
2613   }
2614
26092615   if (D[0] == '^' && D[1] == 'F')
26102616   {
26112617      if (d_register[0] == 'B')
r3485r3486
26132619      else if (d_register[0] == 'A')
26142620         sprintf(D, "B");
26152621      else
2616         sprintf(D, "A");
2622         sprintf(D, "A");   /* In the case of no data ALU operation */
26172623   }
26182624
26192625   sprintf(parallel_move_str, "%s,%s", S, D);
src/emu/cpu/dsp56k/dsp56pcu.c
r3485r3486
211211   IPR = 0x0000;
212212
213213   // FM.5-4
214//  I_bits_set(0x03); This is what the manual says, but i'm dubious!  Polygonet's HI interrupt wouldn't happen with the I bits set.
215   I_bits_set(0x00);
214   I_bits_set(0x03);
216215   S_bits_set(0);
217216   L_bit_set(0);
218217   S_bit_set(0);
r3485r3486
287286         {
288287            // The host command input has a floating vector.
289288            const UINT16 irq_vector = HV_bits() << 1;
289
290            core.ppc = PC;
290291            PC = irq_vector;
292            change_pc(PC);
291293
292294            // TODO: 5-9 5-11 Gotta' Clear HC (HCP gets it too) when taking this exception!
293295            HC_bit_set(0);
src/emu/cpu/dsp56k/dsp56k.c
r3485r3486
461461    CORE INCLUDE
462462***************************************************************************/
463463
464#define OP   core.op
465#define ROPCODE(pc)   cpu_readop16(pc)
466
464#define OP (core.op)
467465#include "dsp56ops.c"
468466
469467/***************************************************************************
src/emu/cpu/sh2/sh2comn.h
r3485r3486
128128   int     dma_timer_active[2];
129129
130130   int     is_slave, cpu_number, cpu_type;
131   int  (*dma_callback_kludge)(UINT32 src, UINT32 dst, UINT32 data, int size);
131132
132133   void   (*ftcsr_read_callback)(UINT32 data);
133134
src/emu/cpu/sh2/sh2.h
r3485r3486
8989struct _sh2_cpu_core
9090{
9191  int is_slave;
92  int  (*dma_callback_kludge)(UINT32 src, UINT32 dst, UINT32 data, int size);
9293};
9394
9495extern void sh2_get_info(UINT32 state, cpuinfo *info);
src/emu/cpu/sh2/sh2comn.c
r3485r3486
155155      {
156156         int incs, incd, size;
157157         UINT32 src, dst, count;
158         UINT32 dmadata;
158159         incd = (sh2->m[0x63+4*dma] >> 14) & 3;
159160         incs = (sh2->m[0x63+4*dma] >> 12) & 3;
160161         size = (sh2->m[0x63+4*dma] >> 10) & 3;
r3485r3486
186187                  src --;
187188               if(incd == 2)
188189                  dst --;
189               program_write_byte_32be(dst, program_read_byte_32be(src));
190
191               dmadata = program_read_byte_32be(src);
192               if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(src, dst, dmadata, size);
193               program_write_byte_32be(dst, dmadata);
194
190195               if(incs == 1)
191196                  src ++;
192197               if(incd == 1)
r3485r3486
198203            dst &= ~1;
199204            for(;count > 0; count --)
200205            {
206
201207               if(incs == 2)
202208                  src -= 2;
203209               if(incd == 2)
204210                  dst -= 2;
205               program_write_word_32be(dst, program_read_word_32be(src));
211
212               // check: should this really be using read_word_32 / write_word_32?
213               dmadata   = program_read_word_32be(src);
214               if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(src, dst, dmadata, size);
215               program_write_word_32be(dst, dmadata);
216
206217               if(incs == 1)
207218                  src += 2;
208219               if(incd == 1)
r3485r3486
218229                  src -= 4;
219230               if(incd == 2)
220231                  dst -= 4;
221               program_write_dword_32be(dst, program_read_dword_32be(src));
232
233               dmadata   = program_read_dword_32be(src);
234               if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(src, dst, dmadata, size);
235               program_write_dword_32be(dst, dmadata);
236
222237               if(incs == 1)
223238                  src += 4;
224239               if(incd == 1)
r3485r3486
234249            {
235250               if(incd == 2)
236251                  dst -= 16;
237               program_write_dword_32be(dst, program_read_dword_32be(src));
238               program_write_dword_32be(dst+4, program_read_dword_32be(src+4));
239               program_write_dword_32be(dst+8, program_read_dword_32be(src+8));
240               program_write_dword_32be(dst+12, program_read_dword_32be(src+12));
252
253               dmadata = program_read_dword_32be(src);
254               if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(src, dst, dmadata, size);
255               program_write_dword_32be(dst, dmadata);
256
257               dmadata = program_read_dword_32be(src+4);
258               if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(src, dst, dmadata, size);
259               program_write_dword_32be(dst+4, dmadata);
260
261               dmadata = program_read_dword_32be(src+8);
262               if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(src, dst, dmadata, size);
263               program_write_dword_32be(dst+8, dmadata);
264
265               dmadata = program_read_dword_32be(src+12);
266               if (sh2->dma_callback_kludge) dmadata = sh2->dma_callback_kludge(src, dst, dmadata, size);
267               program_write_dword_32be(dst+12, dmadata);
268
241269               src += 16;
242270               if(incd == 1)
243271                  dst += 16;
r3485r3486
692720   sh2->m = auto_malloc(0x200);
693721
694722   if(conf)
723   {
695724      sh2->is_slave = conf->is_slave;
725      sh2->dma_callback_kludge = conf->dma_callback_kludge;
726   }
696727   else
728   {
697729      sh2->is_slave = 0;
730      sh2->dma_callback_kludge = NULL;
698731
732   }
699733   sh2->cpu_number = index;
700734   sh2->irq_callback = irqcallback;
701735
src/emu/cpu/sh2/sh2.c
r3485r3486
21562156   f = sh2->ftcsr_read_callback;
21572157   save_irqcallback = sh2->irq_callback;
21582158   save_is_slave = sh2->is_slave;
2159   dma_callback_kludge = sh2->dma_callback_kludge;
2160
21592161   memset(sh2, 0, sizeof(SH2));
2162
2163   sh2->dma_callback_kludge = dma_callback_kludge;
21602164   sh2->is_slave = save_is_slave;
21612165   sh2->ftcsr_read_callback = f;
21622166   sh2->irq_callback = save_irqcallback;
src/emu/cpu/i8051/i8051.c
r3485r3486
5353 *        July 28,2004: Fixed MOVX command and added External Ram Paging Support
5454 *        July 31,2004: Added Serial Mode 0 Support & Fixed Interrupt Flags for Serial Port
5555 *
56 *        Todo: Full Timer support (all modes)
57 *
5856 *        NOW Implemented: RAM paging using hardware configured addressing...
5957 *        (July 28,2004)   the "MOVX a,@R0/R1" and "MOVX @R0/R1,a" commands can use any of the other ports
6058 *                 to output a page offset into external ram, but it is totally based on the hardware setup.
6159 *
6260 *        Timing needs to be implemented via MAME timers perhaps?
6361 *
62 *        October, 2008, Couriersud - Major rewrite
63 *
6464 *****************************************************************************/
6565
66/* TODO: Varios
67 *  - EA pin - defined by architecture, must implement:
68 *    1 means external access, bypassing internal ROM
69 *  - T0 output clock ?
70 *
71 * - Full Timer support (all modes)
72 * - Implement cmos features
73 * - Fix serial communication - This is a big hack (but working) right now.
74 * - Implement 87C751 in sslam.c
75 * - Fix cardline.c
76 * - Fix sslam.c and cardline.c
77 *      most likely due to different behaviour of I/O pins. The boards
78 *      actually use 80CXX, i.e. CMOS versions.
79 *      "Normal" 805X will return a 0 if reading from a output port which has
80 *      a 0 written to it's latch. At least cardline expects a 1 here.
81 *
82 * Done:
83 * - Fix segas18.c (segaic16.c) memory handling.
84 * - Fix sslam.c
85 * - Fix limenko.c videopkr.c : Issue with core allocation of ram (duplicate savestate)
86 * - Handle internal ram better (debugger visible)
87 *  - Fixed port reading
88 *  - Rewrote Macros for better readibility
89 *  - Fixed and rewrote Interrupt handling
90 *  - Now returns INTERNAL_DIVIDER, adjusted cycle counts
91 *  - Remove unnecessary and duplicated code
92 * - Remove unnecessary functions
93 * - Rewrite to have sfr-registers stored in int_ram.
94 * - Debugger may now watch sfr-registers as well.
95 * - implemented interrupt callbacks (HOLD_LINE now supported)
96 * - Runtime switch for processor type - remove ifdefs
97 * - internal memory maps for internal rom versions (internal ram now displayed in debugger)
98 * - more timer cleanups from manual
99 */
100
66101#include "debugger.h"
67102#include "deprecat.h"
68103#include "i8051.h"
69104
70#define VERBOSE
105#define VERBOSE 1
71106
72107#define LOG(x)   do { if (VERBOSE) logerror x; } while (0)
73108
109/***************************************************************************
110    CONSTANTS
111***************************************************************************/
74112
75//Prototypes
76INLINE void push_pc(void);
77INLINE void pop_pc(void);
78INLINE void set_parity(void);
79INLINE void do_add_flags(UINT8 a, UINT8 data, UINT8 c);
80INLINE void do_sub_flags(UINT8 a, UINT8 data, UINT8 c);
81INLINE UINT8 check_interrupts(void);
82INLINE void update_timer(int cyc);
83INLINE void   update_serial(int cyc);
84INLINE void serial_transmit(UINT8 data);
85static READ8_HANDLER(internal_ram_read);
86static WRITE8_HANDLER(internal_ram_write);
87static READ8_HANDLER(internal_ram_iread);
88static READ32_HANDLER(external_ram_iaddr);
89static WRITE8_HANDLER(internal_ram_iwrite);
90static READ8_HANDLER(sfr_read);
91static WRITE8_HANDLER(sfr_write);
92static WRITE8_HANDLER( bit_address_w );
93static READ8_HANDLER( bit_address_r );
113enum
114{
115   FEATURE_NONE         = 0,
116   FEATURE_I8052_UART      = 1,
117   FEATURE_CMOS_IDLE      = 2,
118   FEATURE_CMOS_POWERDOWN   = 4,
119};
94120
95#if (HAS_I8052 || HAS_I8752)
96static READ8_HANDLER(i8052_internal_ram_iread);
97static WRITE8_HANDLER(i8052_internal_ram_iwrite);
98#endif
99//
121/* Internal address in SFR of registers */
122enum
123{
124   ADDR_PSW   = 0xd0,
125   ADDR_ACC   = 0xe0,
126   ADDR_B      = 0xf0,
100127
101typedef struct {
102   UINT8   timerbaud;      //Flag set if timer overflow is controlling baud
103   UINT8   sending;      //Flag set when uart is sending
128   ADDR_P0      = 0x80,
129   ADDR_SP      = 0x81,
130   ADDR_DPL   = 0x82,
131   ADDR_DPH   = 0x83,
132   ADDR_PCON   = 0x87,
133   ADDR_TCON   = 0x88,
134   ADDR_TMOD   = 0x89,
135   ADDR_TL0   = 0x8a,
136   ADDR_TL1   = 0x8b,
137   ADDR_TH0   = 0x8c,
138   ADDR_TH1   = 0x8d,
139   ADDR_P1      = 0x90,
140   ADDR_SCON   = 0x98,
141   ADDR_SBUF   = 0x99,
142   ADDR_P2      = 0xa0,
143   ADDR_IE      = 0xa8,
144   ADDR_P3      = 0xb0,
145   ADDR_IP      = 0xb8,
146
147   /* 8052 Only registers */
148    ADDR_T2CON   = 0xc8,
149    ADDR_RCAP2L   = 0xca,
150    ADDR_RCAP2H   = 0xcb,
151    ADDR_TL2   = 0xcc,
152    ADDR_TH2   = 0xcd,
153};
154
155/* PC vectors */
156
157enum
158{
159   V_RESET = 0x000,   /* power on address */
160   V_IE0   = 0x003,   /* External Interrupt 0 */
161   V_TF0   = 0x00b,   /* Timer 0 Overflow */
162   V_IE1   = 0x013,   /* External Interrupt 1 */
163   V_TF1   = 0x01b,   /* Timer 1 Overflow */
164   V_RITI   = 0x023,   /* Serial Receive/Transmit */
165
166   /* 8052 Only Vectors */
167   V_TF2   = 0x02b,   /* Timer 2 Overflow */
168};
169
170/***************************************************************************
171    TYPE DEFINITIONS
172***************************************************************************/
173
174typedef struct _mcs51_uart mcs51_uart;
175struct _mcs51_uart
176{
104177   UINT8   data_out;      //Data to send out
105178   UINT8   bits_to_send;   //How many bits left to send when transmitting out the serial port
106   UINT8   bitcycles;      //# of bitcycles passed since last bit was sent
107} I8051_UART;
108179
109typedef struct {
180   int      smod_div;      /* signal divided by 2^SMOD */
181   int      rx_clk;         /* rx clock */
182   int      tx_clk;         /* tx clock */
183   UINT8   delay_cycles;   //Gross Hack;
184};
110185
186typedef struct _mcs51_regs mcs51_regs;
187struct _mcs51_regs
188{
111189   //Internal stuff
112190   UINT16   ppc;         //previous pc
113191   UINT16   pc;            //current pc
114   UINT16   subtype;      //specific version of the cpu, ie 8031, or 8051 for example
192   UINT16   features;      //features of this cpu
115193   UINT8   cur_irq;      //Holds value of any current IRQ being serviced
116194   UINT8   irq_priority;   //Holds value of the current IRQ Priority Level
117195   UINT8   rwm;         //Signals that the current instruction is a read/write/modify instruction
118   UINT8   prev_used_cycles;   //Track previous # of used cycles
119   UINT8   last_int0;         //Store state of int0
120   UINT8   last_int1;         //Store state of int1
121   UINT8   int_vec;         //Pending Interrupt Vector
122   UINT8   priority_request;   //Priority level of incoming new irq
123   //SFR Registers         (Note: Appear in order as they do in memory)
124   UINT8   po;            //Port 0
125   UINT8   sp;            //Stack Pointer
126   UINT8   dpl;         //Data Pointer (DPTR) (Hi bit)
127   UINT8   dph;         //Data Pointer (DPTR) (Lo bit)
128   UINT8   pcon;         //Power Mode Control
129   UINT8   tcon;         //Timer/Counter Control
130   UINT8   tmod;         //Timer/Counter Mode Control
131   UINT8   tl0;         //Timer 0 Lo
132   UINT8   tl1;         //Timer 1 Lo
133   UINT8   th0;         //Timer 0 Hi
134   UINT8   th1;         //Timer 1 Hi
135   UINT8   p1;            //Port 1
136   UINT8   scon;         //Serial Control
137   UINT8   sbuf;         //Serial Data Buffer
138   UINT8   p2;            //Port 2
139   UINT8   ie;            //Interrupt Enable
140   UINT8   p3;            //Port 3
141   UINT8   ip;            //Interrupt Priority
142   //8052 Only registers
143   #if (HAS_I8052 || HAS_I8752)
144      UINT8   t2con;      //Timer/Counter 2 Control
145      UINT8   rcap2l;      //Timer/Counter 2 Capture Register Lo
146      UINT8   rcap2h;      //Timer/Counter 2 Capture Register Hi
147      UINT8   tl2;      //Timer 2 Lo
148      UINT8   th2;      //Timer 2 Hi
149   #endif
150   UINT8   psw;         //Program Status Word
151   UINT8   acc;         //Accumulator
152   UINT8   b;            //Register B
153196
154   //Internal Ram
155   UINT8   IntRam[0xff+1];   //Max 256 Bytes of Internal RAM (8031/51 have 128, 8032/52 have 256)
197   int      inst_cycles;      /* cycles for the current instruction */
198   int      ram_mask;           /* second ram bank for indirect access available ? */
199   int      num_interrupts;      /* number of interrupts supported */
200   int      recalc_parity;      /* recalculate parity before next instruction */
201   int      last_line_state;   /* last state of input lines line */
202   int      t0_cnt;            /* number of 0->1 transistions on T0 line */
203   int      t1_cnt;            /* number of 0->1 transistions on T1 line */
204   int      t2_cnt;            /* number of 0->1 transistions on T2 line */
205   int      t2ex_cnt;         /* number of 0->1 transistions on T2EX line */
156206
207   mcs51_uart uart;         /* internal uart */
208
209   /* Internal Ram */
210   UINT8   *internal_ram;      /* 128 RAM (8031/51) + 128 RAM in second bank (8032/52) */
211   UINT8   *sfr_ram;      /* 128 SFR - these are in 0x80 - 0xFF */
212
213   // SFR Callbacks
214   void    (*sfr_write)(size_t offset, UINT8 data);
215   UINT8   (*sfr_read)(size_t offset);
216
157217   //Interrupt Callback
158218   int    (*irq_callback)(int irqline);
159219
160   //Serial Port TX/RX Call backs
220   //Serial Port TX/RX Callbacks
221   // TODO: Move to special port r/w
161222   void    (*serial_tx_callback)(int data);   //Call back funciton when sending data out of serial port
162223   int      (*serial_rx_callback)(void);      //Call back function to retrieve data when receiving serial port data
163224
164   //Internal Indirect Read/Write Handlers
165   READ8_HANDLER((*iram_iread));
166   WRITE8_HANDLER((*iram_iwrite));
225};
167226
168   //External Ram Address Callback for generating the hardware specific access to external ram
169   READ32_HANDLER((*eram_iaddr_callback));
227/***************************************************************************
228    MACROS
229***************************************************************************/
170230
171}   I8051;
231#undef change_pc
232#define change_pc(x)
172233
173static int i8051_icount;
174
175static I8051 i8051;
176static I8051_UART uart;
177
178//Hold callback functions so they can be set by caller (before the cpu reset)
179static void (*hold_serial_tx_callback)(int data);
180static int (*hold_serial_rx_callback)(void);
181static READ32_HANDLER((*hold_eram_iaddr_callback));
182
183/*Short cuts*/
184
185/***************************************************************
186 * Read Opcode/Opcode Arguments from Program Code
187 ***************************************************************/
234/* Read Opcode/Opcode Arguments from Program Code */
188235#define ROP(pc)         cpu_readop(pc)
189236#define ROP_ARG(pc)      cpu_readop_arg(pc)
190/*****************************************************************************
191 * Read a byte from External Code Memory (Usually Program Rom(s) Space)
192 *****************************************************************************
193 This area is mapped from 0-FFFF internally (64K) */
237
238/* Read a byte from External Code Memory (Usually Program Rom(s) Space) */
194239#define CODEMEM_R(a)   (UINT8)program_read_byte_8le(a)
195/*****************************************************************************
196 * Read/Write a byte from/to External Data Memory (Usually RAM or other I/O)
197 *****************************************************************************
198 This area is *ALSO* mapped from 0-FFFF internally (64K)
199                        ** HOWEVER **
200 We *FORCE* the address space into the range 10000-1FFFF to allow both
201 Code Memory and Data Memory to be pyshically separate while mapped @ the same
202 addresses, w/o any contention.
203 As far as the 8051 program code which is executing knows data memory still lives
204 in the 0-FFFF range.*/
205#define DATAMEM_R(a)   (UINT8)data_read_byte_8le(a)
206#define DATAMEM_W(a,v)   data_write_byte_8le(a,v)
207240
208/***************************************************************
209 * Read/Write a byte from/to the Internal RAM
210 ***************************************************************/
211#define IRAM_R(a)      internal_ram_read(Machine,a)
212#define IRAM_W(a,v)      internal_ram_write(Machine,a,v)
213/***************************************************************
214 * Read/Write a byte from/to the Internal RAM indirectly (called from indirect addressing)
215 ***************************************************************/
216#define IRAM_IR(a)      internal_ram_iread(Machine,a)
217#define IRAM_IW(a,v)   internal_ram_iwrite(Machine,a,v)
218/***************************************************************
219 * Form an Address to Read/Write to External RAM indirectly (called from indirect addressing)
220 ***************************************************************/
221#define ERAM_ADDR(a,m)   external_ram_iaddr(Machine,a,m)
222/***************************************************************
223 * Read/Write a byte from/to the SFR Registers
224 ***************************************************************/
225#define SFR_R(a)      sfr_read(Machine,a)
226#define SFR_W(a,v)      sfr_write(Machine,a,v)
227/***************************************************************
228 * Read/Write a bit from Bit Addressable Memory
229 ***************************************************************/
230#define BIT_R(a)      bit_address_r(Machine,a)
231#define BIT_W(a,v)      bit_address_w(Machine,a,v)
232/***************************************************************
233 * Input/Output a byte from given I/O port
234 ***************************************************************/
235#define IN(port)      ((UINT8)io_read_byte(port))
236#define OUT(port,value) io_write_byte(port,value)
237/***************************************************************
238 * Access the 4 banks of R registers (R0...R7)
239 ***************************************************************/
240#define R_R(n)         i8051.IntRam[(GET_RS*8)+(n)]
241/***************************************************************
242 * Easy macro for working with 16 bit DPTR
243 ***************************************************************/
244#define R_DPTR         ((R_DPH<<8) | R_DPL)
245#define DPTR_W(n)      SFR_W(DPH, ((n)>>8)&0xff);\
246                  SFR_W(DPL, ((n)&0xff));
247/***************************************************************
248 * Easy macros for Setting Flags
249 ***************************************************************/
250/*PSW Flags*/
251#define SET_CY(n)      R_PSW = (R_PSW & 0x7f) | (n<<7);   //Carry Flag
252#define SET_AC(n)      R_PSW = (R_PSW & 0xbf) | (n<<6);   //Aux.Carry Flag
253#define SET_FO(n)      R_PSW = (R_PSW & 0xdf) | (n<<5);   //User Flag
254#define SET_RS(n)      R_PSW = (R_PSW & 0xe7) | (n<<3);   //R Bank Select
255#define SET_OV(n)      R_PSW = (R_PSW & 0xfb) | (n<<2);   //Overflow Flag
256#define SET_P(n)      R_PSW = (R_PSW & 0xfe) | (n<<0);   //Parity Flag
257/*IE Flags*/
258#define SET_EA(n)      R_IE = (R_IE & 0x7f) | (n<<7);      //Global Interrupt Enable/Disable
259#if (HAS_I8052 || HAS_I8752)
260   #define SET_ET2(n)      R_IE = (R_IE & 0xdf) | (n<<5);   //Timer 2 Interrupt Enable/Disable
261#endif
262#define SET_ES(n)      R_IE = (R_IE & 0xef) | (n<<4);      //Serial Interrupt Enable/Disable
263#define SET_ET1(n)      R_IE = (R_IE & 0xf7) | (n<<3);      //Timer 1 Interrupt Enable/Disable
264#define SET_EX1(n)      R_IE = (R_IE & 0xfb) | (n<<2);      //External Int 1 Interrupt Enable/Disable
265#define SET_ET0(n)      R_IE = (R_IE & 0xfd) | (n<<1);      //Timer 0 Interrupt Enable/Disable
266#define SET_EX0(n)      R_IE = (R_IE & 0xfe) | (n<<0);      //External Int 0 Interrupt Enable/Disable
267/*IP Flags*/
268#if (HAS_I8052 || HAS_I8752)
269   #define SET_PT2(n)      R_IP = (R_IP & 0xdf) | (n<<5);   //Set Timer 2 Priority Level
270#endif
271#define SET_PS0(n)      R_IP = (R_IP & 0xef) | (n<<4);      //Set Serial Priority Level
272#define SET_PT1(n)      R_IP = (R_IP & 0xf7) | (n<<3);      //Set Timer 1 Priority Level
273#define SET_PX1(n)      R_IP = (R_IP & 0xfb) | (n<<2);      //Set External Int 1 Priority Level
274#define SET_PT0(n)      R_IP = (R_IP & 0xfd) | (n<<1);      //Set Timer 0 Priority Level
275#define SET_PX0(n)      R_IP = (R_IP & 0xfe) | (n<<0);      //Set External Int 0 Priority Level
276/*TCON Flags*/
277#define SET_TF1(n)      R_TCON = (R_TCON & 0x7f) | (n<<7);   //Indicated Timer 1 Overflow Int Triggered
278#define SET_TR1(n)      R_TCON = (R_TCON & 0xbf) | (n<<6);  //IndicateS Timer 1 is running
279#define SET_TF0(n)      R_TCON = (R_TCON & 0xdf) | (n<<5);   //Indicated Timer 0 Overflow Int Triggered
280#define SET_TR0(n)      R_TCON = (R_TCON & 0xef) | (n<<4);  //IndicateS Timer 0 is running
281#define SET_IE1(n)      R_TCON = (R_TCON & 0xf7) | (n<<3);  //Indicated External Int 1 Triggered
282#define SET_IT1(n)      R_TCON = (R_TCON & 0xfb) | (n<<2);  //Indicates how External Int 1 is Triggered
283#define SET_IE0(n)      R_TCON = (R_TCON & 0xfd) | (n<<1);  //Indicated External Int 0 Triggered
284#define SET_IT0(n)      R_TCON = (R_TCON & 0xfe) | (n<<0);  //Indicates how External Int 0 is Triggered
285/*SCON Flags*/
286#define SET_SM0(n)      R_SCON = (R_SCON & 0x7f) | (n<<7);   //Sets Serial Port Mode
287#define SET_SM1(n)      R_SCON = (R_SCON & 0xbf) | (n<<6);  //Sets Serial Port Mode
288#define SET_SM2(n)      R_SCON = (R_SCON & 0xdf) | (n<<5);   //Sets Serial Port Mode (Multiprocesser mode)
289#define SET_REN(n)      R_SCON = (R_SCON & 0xef) | (n<<4);  //Sets Serial Port Receive Enable
290#define SET_TB8(n)      R_SCON = (R_SCON & 0xf7) | (n<<3);  //Transmit 8th Bit
291#define SET_RB8(n)      R_SCON = (R_SCON & 0xfb) | (n<<2);  //Receive 8th Bit
292#define SET_TI(n)      R_SCON = (R_SCON & 0xfd) | (n<<1);  //Indicates Transmit Interrupt Occurred
293#define SET_RI(n)      R_SCON = (R_SCON & 0xfe) | (n<<0);  //Indicates Receive Interrupt Occurred
294/*TMOD Flags*/
295#define SET_GATE1(n)   R_TMOD = (R_TMOD & 0x7f) | (n<<7);   //Timer 1 Gate Mode
296#define SET_CT1(n)      R_TMOD = (R_TMOD & 0xbf) | (n<<6);  //Timer 1 Counter Mode
297#define SET_M1_1(n)      R_TMOD = (R_TMOD & 0xdf) | (n<<5);   //Timer 1 Timer Mode Bit 1
298#define SET_M1_0(n)      R_TMOD = (R_TMOD & 0xef) | (n<<4);  //Timer 1 Timer Mode Bit 0
299#define SET_GATE0(n)   R_TMOD = (R_TMOD & 0xf7) | (n<<3);  //Timer 0 Gate Mode
300#define SET_CT0(n)      R_TMOD = (R_TMOD & 0xfb) | (n<<2);  //Timer 0 Counter Mode
301#define SET_M0_1(n)      R_TMOD = (R_TMOD & 0xfd) | (n<<1);  //Timer 0 Timer Mode Bit 1
302#define SET_M0_0(n)      R_TMOD = (R_TMOD & 0xfe) | (n<<0);  //Timer 0 Timer Mode Bit 0
241/* Read/Write a byte from/to External Data Memory (Usually RAM or other I/O) */
242#define DATAMEM_R(a)   (UINT8)io_read_byte_8le(a)
243#define DATAMEM_W(a,v)   io_write_byte_8le(a,v)
244//#define DATAMEM_R(a)  (UINT8)data_read_byte_8le(a)
245//#define DATAMEM_W(a,v)    data_write_byte_8le(a,v)
303246
304#if (HAS_I8052 || HAS_I8752)
305  /*T2CON Flags*/
306  #define SET_TF2(n)      R_T2CON = (R_T2CON & 0x7f) | (n<<7);   //Indicated Timer 2 Overflow Int Triggered
307  #define SET_EXF2(n)      R_T2CON = (R_T2CON & 0xbf) | (n<<6);   //Indicates Timer 2 External Flag
308  #define SET_RCLK(n)      R_T2CON = (R_T2CON & 0xdf) | (n<<5);   //Receive Clock
309  #define SET_TCLK(n)      R_T2CON = (R_T2CON & 0xef) | (n<<4);   //Transmit Clock
310  #define SET_EXEN2(n)      R_T2CON = (R_T2CON & 0xf7) | (n<<3);   //Timer 2 External Interrupt Enable
311  #define SET_TR2(n)      R_T2CON = (R_T2CON & 0xfb) | (n<<2);   //Indicates Timer 2 is running
312  #define SET_CT2(n)      R_T2CON = (R_T2CON & 0xfd) | (n<<1);   //Sets Timer 2 Counter/Timer Mode
313  #define SET_CP(n)         R_T2CON = (R_T2CON & 0xfe) | (n<<0);   //Sets Timer 2 Capture/Reload Mode
314#endif
247/* Read/Write a byte from/to the Internal RAM */
315248
316/***************************************************************
317 * Easy macros for Getting Flags
318 ***************************************************************/
319/*PSW Flags*/
320#define GET_CY         ((R_PSW & 0x80)>>7)
321#define GET_AC         ((R_PSW & 0x40)>>6)
322#define GET_FO         ((R_PSW & 0x20)>>5)
323#define GET_RS         ((R_PSW & 0x18)>>3)
324#define GET_OV         ((R_PSW & 0x04)>>2)
325#define GET_P         ((R_PSW & 0x01)>>0)
326/*IE Flags*/
327#define GET_EA         ((R_IE & 0x80)>>7)
328#define GET_ET2         ((R_IE & 0x20)>>5)
329#define GET_ES         ((R_IE & 0x10)>>4)
330#define GET_ET1         ((R_IE & 0x08)>>3)
331#define GET_EX1         ((R_IE & 0x04)>>2)
332#define GET_ET0         ((R_IE & 0x02)>>1)
333#define GET_EX0         ((R_IE & 0x01)>>0)
334/*IP Flags*/
335#if (HAS_I8052 || HAS_I8752)
336  #define GET_PT2         ((R_IP & 0x20)>>5)
337#endif
338#define GET_PS         ((R_IP & 0x10)>>4)
339#define GET_PT1         ((R_IP & 0x08)>>3)
340#define GET_PX1         ((R_IP & 0x04)>>2)
341#define GET_PT0         ((R_IP & 0x02)>>1)
342#define GET_PX0         ((R_IP & 0x01)>>0)
343/*TCON Flags*/
344#define GET_TF1         ((R_TCON & 0x80)>>7)
345#define GET_TR1         ((R_TCON & 0x40)>>6)
346#define GET_TF0         ((R_TCON & 0x20)>>5)
347#define GET_TR0         ((R_TCON & 0x10)>>4)
348#define GET_IE1         ((R_TCON & 0x08)>>3)
349#define GET_IT1         ((R_TCON & 0x04)>>2)
350#define GET_IE0         ((R_TCON & 0x02)>>1)
351#define GET_IT0         ((R_TCON & 0x01)>>0)
352/*SCON Flags*/
353#define GET_SM0         ((R_SCON & 0x80)>>7)
354#define GET_SM1         ((R_SCON & 0x40)>>6)
355#define GET_SM2         ((R_SCON & 0x20)>>5)
356#define GET_REN         ((R_SCON & 0x10)>>4)
357#define GET_TB8         ((R_SCON & 0x08)>>3)
358#define GET_RB8         ((R_SCON & 0x04)>>2)
359#define GET_TI         ((R_SCON & 0x02)>>1)
360#define GET_RI         ((R_SCON & 0x01)>>0)
361/*TMOD Flags*/
362#define GET_GATE1      ((R_TMOD & 0x80)>>7)
363#define GET_CT1         ((R_TMOD & 0x40)>>6)
364#define GET_M1_1      ((R_TMOD & 0x20)>>5)
365#define GET_M1_0      ((R_TMOD & 0x10)>>4)
366#define GET_GATE0      ((R_TMOD & 0x08)>>3)
367#define GET_CT0         ((R_TMOD & 0x04)>>2)
368#define GET_M0_1      ((R_TMOD & 0x02)>>1)
369#define GET_M0_0      ((R_TMOD & 0x01)>>0)
249#define IRAM_R(a)      iram_read(a)
250#define IRAM_W(a, d)   iram_write(a, d)
370251
371#if (HAS_I8052 || HAS_I8752)
372  /*T2CON Flags*/
373  #define GET_TF2         ((R_T2CON & 0x80)>>7)
374  #define GET_EXF2         ((R_T2CON & 0x40)>>6)
375  #define GET_RCLK         ((R_T2CON & 0x20)>>5)
376  #define GET_TCLK         ((R_T2CON & 0x10)>>4)
377  #define GET_EXEN2         ((R_T2CON & 0x08)>>3)
378  #define GET_TR2         ((R_T2CON & 0x04)>>2)
379  #define GET_CT2         ((R_T2CON & 0x02)>>1)
380  #define GET_CP         ((R_T2CON & 0x01)>>0)
381#endif
252/* Read/Write a byte from/to the Internal RAM indirectly */
253/* (called from indirect addressing)                     */
254#define IRAM_IR(a)       data_read_byte_8le((a) & mcs51.ram_mask)
255#define IRAM_IW(a, d)    data_write_byte_8le((a) & mcs51.ram_mask, d)
382256
383/*Add and Subtract Flag settings*/
384#define DO_ADD_FLAGS(a,d,c)   do_add_flags(a,d,c);
385#define DO_SUB_FLAGS(a,d,c)   do_sub_flags(a,d,c);
257/* Form an Address to Read/Write to External RAM indirectly */
258/* (called from indirect addressing)                        */
259#define ERAM_ADDR(a,m)   external_ram_iaddr(a,m)
386260
387#define SET_PARITY   set_parity();
388#define PUSH_PC      push_pc();
389#define POP_PC      pop_pc();
261/* Read/Write a bit from Bit Addressable Memory */
262#define BIT_R(a)      bit_address_r(a)
263#define BIT_W(a,v)      bit_address_w(a,v)
390264
391/* PC vectors */
392#define V_RESET 0x000   /* power on address */
393#define V_IE0   0x003   /* External Interrupt 0 */
394#define V_TF0   0x00b   /* Timer 0 Overflow */
395#define V_IE1   0x013   /* External Interrupt 1 */
396#define V_TF1   0x01b   /* Timer 1 Overflow */
397#define V_RITI   0x023   /* Serial Receive/Transmit */
265/* Input/Output a byte from given I/O port */
266#define IN(port)      ((UINT8)io_read_byte(port))
267#define OUT(port,value) io_write_byte(port,value)
398268
399#if (HAS_I8052 || HAS_I8752)
400#define V_TF2   0x02b   /* Timer 2 Overflow */
401#endif
402269
403/* Any pending IRQ */
404#define SERIALPORT_IRQ    ((R_SCON & 0x03) && GET_ES)
405#define TIMERS_IRQ        ((GET_TF0 && GET_ET0) || (GET_TF1 && GET_ET1))
406#define EXTERNAL_IRQ      ((GET_IE0 && GET_EX0) || (GET_IE1 && GET_EX1))
270/***************************************************************************
271    SHORTCUTS
272***************************************************************************/
407273
408#if (HAS_I8052 || HAS_I8752)
409#define NO_PENDING_IRQ  !(TIMERS_IRQ) && !(EXTERNAL_IRQ) && !(SERIALPORT_IRQ) && !(GET_ET2 && (GET_TF2 || GET_EXF2))
410#else
411#define NO_PENDING_IRQ  !(TIMERS_IRQ) && !(EXTERNAL_IRQ) && !(SERIALPORT_IRQ)
412#endif
274#define PPC    mcs51.ppc
275#define PC      mcs51.pc
276#define RWM      mcs51.rwm
413277
414/* Clear Current IRQ  */
415#define CLEAR_CURRENT_IRQ i8051.cur_irq = 0xff;\
416                    i8051.irq_priority = 0;
278/* SFR Registers - These are accessed directly for speed on read */
279/* Read accessors                                                */
417280
418/* shorter names for the I8051 structure elements */
281#define SFR_A(a)      mcs51.sfr_ram[(a)]
282#define SET_SFR_A(a,v)   do { SFR_A(a) = (v); } while (0)
419283
420//Internal stuff
421#define PPC    i8051.ppc
422#define PC      i8051.pc
423#define TYPE   i8051.subtype
424#define RWM      i8051.rwm
284#define ACC         ((const UINT8) SFR_A(ADDR_ACC))
285#define PSW         ((const UINT8) SFR_A(ADDR_PSW))
425286
426//SFR Registers
427#define R_P0   i8051.po
428#define R_SP   i8051.sp
429#define R_DPL   i8051.dpl
430#define R_DPH   i8051.dph
431#define R_PCON   i8051.pcon
432#define R_TCON   i8051.tcon
433#define R_TMOD   i8051.tmod
434#define R_TL0   i8051.tl0
435#define R_TL1   i8051.tl1
436#define R_TH0   i8051.th0
437#define R_TH1   i8051.th1
438#define R_P1   i8051.p1
439#define R_SCON   i8051.scon
440#define R_SBUF   i8051.sbuf
441#define R_P2   i8051.p2
442#define R_IE   i8051.ie
443#define R_P3   i8051.p3
444#define R_IP   i8051.ip
445//8052 Only registers
446#if (HAS_I8052 || HAS_I8752)
447  #define R_T2CON   i8051.t2con
448  #define R_RCAP2L   i8051.rcap2l
449  #define R_RCAP2H   i8051.rcap2h
450  #define R_TL2      i8051.tl2
451  #define R_TH2      i8051.th2
452#endif
453#define R_PSW   i8051.psw
454#define R_ACC   i8051.acc
455#define R_B      i8051.b
287#define P0         ((const UINT8) SFR_A(ADDR_P0))
288#define P1         ((const UINT8) SFR_A(ADDR_P1))
289#define P2         ((const UINT8) SFR_A(ADDR_P2))
290#define P3         ((const UINT8) SFR_A(ADDR_P3))
456291
457/* # of oscilations each opcode requires*/
458static const UINT8 i8051_cycles[] = {
459   12,24,24,12,12,12,12,12,12,12,12,12,12,12,12,12,
460   24,24,24,12,12,12,12,12,12,12,12,12,12,12,12,12,
461   24,24,24,12,12,12,12,12,12,12,12,12,12,12,12,12,
462   24,24,24,12,12,12,12,12,12,12,12,12,12,12,12,12,
463   24,24,12,24,12,12,12,12,12,12,12,12,12,12,12,12,
464   24,24,12,24,12,12,12,12,12,12,12,12,12,12,12,12,
465   24,24,12,24,12,12,12,12,12,12,12,12,12,12,12,12,
466   24,24,24,24,12,24,12,12,12,12,12,12,12,12,12,12,
467   24,24,24,24,48,24,24,24,24,24,24,24,24,24,24,24,
468   24,24,24,24,12,12,12,12,12,12,12,12,12,12,12,12,
469   24,24,12,24,48,12,24,24,24,24,24,24,24,24,24,24,
470   24,24,12,12,24,24,24,24,24,24,24,24,24,24,24,24,
471   24,24,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
472   24,24,12,12,12,24,12,12,24,24,24,24,24,24,24,24,
473   24,24,24,24,12,12,12,12,12,12,12,12,12,12,12,12,
474   24,24,24,24,12,12,12,12,12,12,12,12,12,12,12,12
475};
292#define SP         SFR_A(ADDR_SP)
293#define DPL         SFR_A(ADDR_DPL)
294#define DPH         SFR_A(ADDR_DPH)
295#define PCON      SFR_A(ADDR_PCON)
296#define TCON      SFR_A(ADDR_TCON)
297#define TMOD      SFR_A(ADDR_TMOD)
298#define TL0         SFR_A(ADDR_TL0)
299#define TL1         SFR_A(ADDR_TL1)
300#define TH0         SFR_A(ADDR_TH0)
301#define TH1         SFR_A(ADDR_TH1)
302#define SCON      SFR_A(ADDR_SCON)
303#define IE         SFR_A(ADDR_IE)
304#define IP         SFR_A(ADDR_IP)
305#define B         SFR_A(ADDR_B)
306#define SBUF      SFR_A(ADDR_SBUF)
476307
477/* Include Opcode functions */
478#include "i8051ops.c"
308#define R_REG(r)   mcs51.internal_ram[(r) | (PSW & 0x18)]
309#define DPTR      ((DPH<<8) | DPL)
479310
480void i8051_init(int index, int clock, const void *config, int (*irqcallback)(int))
481{
482   i8051_set_irq_callback(irqcallback);
311/* 8052 Only registers */
312#define T2CON      SFR_A(ADDR_T2CON)
313#define RCAP2L      SFR_A(ADDR_RCAP2L)
314#define RCAP2H      SFR_A(ADDR_RCAP2H)
315#define TL2         SFR_A(ADDR_TL2)
316#define TH2         SFR_A(ADDR_TH2)
483317
484   //Internal stuff
485   state_save_register_item("i8051", index, i8051.ppc);
486   state_save_register_item("i8051", index, i8051.pc);
487   state_save_register_item("i8051", index, i8051.subtype);
488   state_save_register_item("i8051", index, i8051.rwm );
489   state_save_register_item("i8051", index, i8051.cur_irq );
490   state_save_register_item("i8051", index, i8051.irq_priority );
491   state_save_register_item("i8051", index, i8051.prev_used_cycles );
492   state_save_register_item("i8051", index, i8051.last_int0 );
493   state_save_register_item("i8051", index, i8051.last_int1 );
494   state_save_register_item("i8051", index, i8051.int_vec );
495   state_save_register_item("i8051", index, i8051.priority_request );
496   //SFR Registers
497   state_save_register_item("i8051", index, i8051.po);
498   state_save_register_item("i8051", index, i8051.sp);
499   state_save_register_item("i8051", index, i8051.dpl);
500   state_save_register_item("i8051", index, i8051.dph);
501   state_save_register_item("i8051", index, i8051.pcon);
502   state_save_register_item("i8051", index, i8051.tcon);
503   state_save_register_item("i8051", index, i8051.tmod);
504   state_save_register_item("i8051", index, i8051.tl0);
505   state_save_register_item("i8051", index, i8051.tl1);
506   state_save_register_item("i8051", index, i8051.th0);
507   state_save_register_item("i8051", index, i8051.th1);
508   state_save_register_item("i8051", index, i8051.p1);
509   state_save_register_item("i8051", index, i8051.scon);
510   state_save_register_item("i8051", index, i8051.sbuf);
511   state_save_register_item("i8051", index, i8051.p2);
512   state_save_register_item("i8051", index, i8051.ie);
513   state_save_register_item("i8051", index, i8051.p3);
514   state_save_register_item("i8051", index, i8051.ip);
515   //8052 Only registers
516   #if (HAS_I8052 || HAS_I8752)
517      state_save_register_item("i8051", index, i8051.t2con);
518      state_save_register_item("i8051", index, i8051.rcap2l);
519      state_save_register_item("i8051", index, i8051.rcap2h);
520      state_save_register_item("i8051", index, i8051.tl2);
521      state_save_register_item("i8051", index, i8051.th2);
522   #endif
523   state_save_register_item("i8051", index, i8051.psw);
524   state_save_register_item("i8051", index, i8051.acc);
525   state_save_register_item("i8051", index, i8051.b);
526   state_save_register_item_array("i8051", index, i8051.IntRam);
527}
318/* WRITE accessors */
528319
529/* Reset registers to the initial values */
530void i8051_reset(void)
531{
532   int (*save_irqcallback)(int);
320/* Shortcuts */
533321
534   save_irqcallback = i8051.irq_callback;
535   memset(&i8051, 0, sizeof(I8051));
536   i8051.irq_callback = save_irqcallback;
322#define SET_PSW(v)   do { SFR_A(ADDR_PSW) = (v); SET_PARITY(); } while (0)
323#define SET_ACC(v)   do { SFR_A(ADDR_ACC) = (v); SET_PARITY(); } while (0)
537324
538   memset(&uart, 0, sizeof(I8051_UART));
539   i8051.subtype = 8051;
325/* These trigger actions on modification and have to be written through SFR_W */
326#define SET_P0(v)   IRAM_W(ADDR_P0, v)
327#define SET_P1(v)   IRAM_W(ADDR_P1, v)
328#define SET_P2(v)   IRAM_W(ADDR_P2, v)
329#define SET_P3(v)   IRAM_W(ADDR_P3, v)
540330
541   //Set up 8051 specific internal read/write (indirect) handlers..
542   i8051.iram_iread = internal_ram_read;      //Indirect ram read/write handled the same as direct for 8051!
543   i8051.iram_iwrite = internal_ram_write;      //Indirect ram read/write handled the same as direct for 8051!
331/* Within the cpu core, do not trigger a send */
332#define SET_SBUF(v)   SET_SFR_A(ADDR_SBUF, v)
544333
545   //Set up serial call back handlers
546   i8051.serial_tx_callback = hold_serial_tx_callback;
547   hold_serial_tx_callback = NULL;
548   i8051.serial_rx_callback = hold_serial_rx_callback;
549   hold_serial_rx_callback = NULL;
334/* No actions triggered on write */
335#define SET_REG(r, v)   do { mcs51.internal_ram[(r) | (PSW & 0x18)] = (v); } while (0)
550336
551   //Setup External ram callback handlers
552   i8051.eram_iaddr_callback = hold_eram_iaddr_callback;
553   hold_eram_iaddr_callback = NULL;
337#define SET_DPTR(n)      do { DPH = ((n) >> 8) & 0xff; DPL = (n) & 0xff; } while (0)
554338
555   //Clear Ram (w/0xff)
556   memset(&i8051.IntRam,0xff,sizeof(i8051.IntRam));
339/* Macros for Setting Flags */
340#define SET_X(R, v) do { R = (v);} while (0)
557341
558   /* these are all defined reset states */
559   PC = 0;
560   SFR_W(SP, 0x7);
561   SFR_W(PSW, 0);
562   SFR_W(DPH, 0);
563   SFR_W(DPL, 0);
564   SFR_W(ACC, 0);
565   SFR_W(B, 0);
566   SFR_W(IP, 0);
567   SFR_W(IE, 0);
568   SFR_W(SCON, 0);
569   SFR_W(TCON, 0);
570   SFR_W(TMOD, 0);
571   SFR_W(TH1, 0);
572   SFR_W(TH0, 0);
573   SFR_W(TL1, 0);
574   SFR_W(TL0, 0);
575   /* set the port configurations to all 1's */
576   SFR_W(P3, 0xff);
577   SFR_W(P2, 0xff);
578   SFR_W(P1, 0xff);
579   SFR_W(P0, 0xff);
342#define SET_CY(n)      SET_PSW((PSW & 0x7f) | (n<<7))   //Carry Flag
343#define SET_AC(n)      SET_PSW((PSW & 0xbf) | (n<<6))   //Aux.Carry Flag
344#define SET_FO(n)      SET_PSW((PSW & 0xdf) | (n<<5))   //User Flag
345#define SET_RS(n)      SET_PSW((PSW & 0xe7) | (n<<3))   //R Bank Select
346#define SET_OV(n)      SET_PSW((PSW & 0xfb) | (n<<2))   //Overflow Flag
347#define SET_P(n)      SET_PSW((PSW & 0xfe) | (n<<0))   //Parity Flag
580348
581   /* Flag as NO IRQ in Progress */
582   CLEAR_CURRENT_IRQ
583}
349#define SET_BIT(R, n, v) do { R = (R & ~(1<<(n))) | ((v) << (n));} while (0)
350#define GET_BIT(R, n) (((R)>>(n)) & 0x01)
584351
585/* Shut down CPU core */
586void i8051_exit(void)
587{
588   /* nothing to do */
589}
352#define SET_EA(n)      SET_BIT(IE, 7, n)      //Global Interrupt Enable/Disable
353#define SET_ES(n)      SET_BIT(IE, 4, v)      //Serial Interrupt Enable/Disable
354#define SET_ET1(n)      SET_BIT(IE, 3, n)      //Timer 1 Interrupt Enable/Disable
355#define SET_EX1(n)      SET_BIT(IE, 2, n)      //External Int 1 Interrupt Enable/Disable
356#define SET_ET0(n)      SET_BIT(IE, 1, n)      //Timer 0 Interrupt Enable/Disable
357#define SET_EX0(n)      SET_BIT(IE, 0, n)      //External Int 0 Interrupt Enable/Disable
358/* 8052 Only flags */
359#define SET_ET2(n)      SET_BIT(IE, 5, n)      //Timer 2 Interrupt Enable/Disable
590360
591/* Execute cycles - returns number of cycles actually run */
592int i8051_execute(int cycles)
593{
594   i8051_icount = cycles;
361/* 8052 Only flags */
362#define SET_PT2(n)      SET_BIT(IP, 5, n);   //Set Timer 2 Priority Level
595363
596   do
597   {
598      //Read next opcode
599      UINT8 op = cpu_readop(PC);
364#define SET_PS0(n)      SET_BIT(IP, 4, n)      //Set Serial Priority Level
365#define SET_PT1(n)      SET_BIT(IP, 3, n)      //Set Timer 1 Priority Level
366#define SET_PX1(n)      SET_BIT(IP, 2, n)      //Set External Int 1 Priority Level
367#define SET_PT0(n)      SET_BIT(IP, 1, n)      //Set Timer 0 Priority Level
368#define SET_PX0(n)      SET_BIT(IP, 0, n)      //Set External Int 0 Priority Level
600369
601      //Store previous PC
602      PPC = PC;
370#define SET_TF1(n)      SET_BIT(TCON, 7, n)   //Indicated Timer 1 Overflow Int Triggered
371#define SET_TR1(n)      SET_BIT(TCON, 6, n)  //IndicateS Timer 1 is running
372#define SET_TF0(n)      SET_BIT(TCON, 5, n)   //Indicated Timer 0 Overflow Int Triggered
373#define SET_TR0(n)      SET_BIT(TCON, 4, n)  //IndicateS Timer 0 is running
374#define SET_IE1(n)      SET_BIT(TCON, 3, n)  //Indicated External Int 1 Triggered
375#define SET_IT1(n)      SET_BIT(TCON, 2, n)  //Indicates how External Int 1 is Triggered
376#define SET_IE0(n)      SET_BIT(TCON, 1, n)  //Indicated External Int 0 Triggered
377#define SET_IT0(n)      SET_BIT(TCON, 0, n)  //Indicates how External Int 0 is Triggered
603378
604      //Call Debugger
605      debugger_instruction_hook(Machine, PC);
379#define SET_SM0(n)      SET_BIT(SCON, 7, n)   //Sets Serial Port Mode
380#define SET_SM1(n)      SET_BIT(SCON, 6, n)  //Sets Serial Port Mode
381#define SET_SM2(n)      SET_BIT(SCON, 5, n)   //Sets Serial Port Mode (Multiprocesser mode)
382#define SET_REN(n)      SET_BIT(SCON, 4, n)  //Sets Serial Port Receive Enable
383#define SET_TB8(n)      SET_BIT(SCON, 3, n)  //Transmit 8th Bit
384#define SET_RB8(n)      SET_BIT(SCON, 2, n)  //Receive 8th Bit
385#define SET_TI(n)      SET_BIT(SCON, 1, n)  //Indicates Transmit Interrupt Occurred
386#define SET_RI(n)      SET_BIT(SCON, 0, n)  //Indicates Receive Interrupt Occurred
606387
607      //remove after testing
608      if(PC != PPC)   op = cpu_readop(PC);
388#define SET_GATE1(n)   SET_BIT(TMOD, 7, n)   //Timer 1 Gate Mode
389#define SET_CT1(n)      SET_BIT(TMOD, 6, n)  //Timer 1 Counter Mode
390#define SET_M1_1(n)      SET_BIT(TMOD, 5, n)   //Timer 1 Timer Mode Bit 1
391#define SET_M1_0(n)      SET_BIT(TMOD, 4, n)  //Timer 1 Timer Mode Bit 0
392#define SET_GATE0(n)   SET_BIT(TMOD, 3, n)  //Timer 0 Gate Mode
393#define SET_CT0(n)      SET_BIT(TMOD, 2, n)  //Timer 0 Counter Mode
394#define SET_M0_1(n)      SET_BIT(TMOD, 1, n)  //Timer 0 Timer Mode Bit 1
395#define SET_M0_0(n)      SET_BIT(TMOD, 0, n)  //Timer 0 Timer Mode Bit 0
609396
610      //Update Timer (if any timers are running)
611      if(GET_TR0 || GET_TR1)
612         update_timer(i8051.prev_used_cycles);
613397
614      //Update Serial (if serial port sending data)
615      if(uart.sending)
616         update_serial(i8051.prev_used_cycles);
617398
618      //Update PC
619      PC += 1;
620      //Decrement total count by # of cycles used for this opcode
621      i8051_icount -= (i8051_cycles[op]);
399/* 8052 Only flags - T2CON Flags */
400#define SET_TF2(n)      SET_BIT(T2CON, 7, n)   //Indicated Timer 2 Overflow Int Triggered
401#define SET_EXF2(n)      SET_BIT(T2CON, 6, n)   //Indicates Timer 2 External Flag
402#define SET_RCLK(n)      SET_BIT(T2CON, 5, n)   //Receive Clock
403#define SET_TCLK(n)      SET_BIT(T2CON, 4, n)   //Transmit Clock
404#define SET_EXEN2(n)   SET_BIT(T2CON, 3, n)   //Timer 2 External Interrupt Enable
405#define SET_TR2(n)      SET_BIT(T2CON, 2, n)   //Indicates Timer 2 is running
406#define SET_CT2(n)      SET_BIT(T2CON, 1, n)   //Sets Timer 2 Counter/Timer Mode
407#define SET_CP(n)      SET_BIT(T2CON, 0, n)   //Sets Timer 2 Capture/Reload Mode
622408
623      switch( op )
624      {
625         //NOP
626         case 0x00:                  /* 1: 0000 0000 */
627            nop();
628            break;
629         //AJMP code addr                /* 1: aaa0 0001 */
630         case 0x01:
631            ajmp();
632            break;
633         //LJMP code addr
634         case 0x02:                  /* 1: 0000 0010 */
635            ljmp();
636            break;
637         //RR A
638         case 0x03:                  /* 1: 0000 0011 */
639            rr_a();
640            break;
641         //INC A
642         case 0x04:                  /* 1: 0000 0100 */
643            inc_a();
644            break;
645         //INC data addr
646         case 0x05:                  /* 1: 0000 0101 */
647            RWM=1;
648            inc_mem();
649            RWM=0;
650         break;
651         //INC @R0/@R1                   /* 1: 0000 011i */
652         case 0x06:
653         case 0x07:
654            inc_ir(op&1);
655            break;
656         //INC R0 to R7                  /* 1: 0000 1rrr */
657         case 0x08:
658         case 0x09:
659         case 0x0a:
660         case 0x0b:
661         case 0x0c:
662         case 0x0d:
663         case 0x0e:
664         case 0x0f:
665            inc_r(op&7);
666            break;
667         //JBC bit addr, code addr
668         case 0x10:                  /* 1: 0001 0000 */
669            RWM=1;
670            jbc();
671            RWM=0;
672            break;
673         //ACALL code addr               /* 1: aaa1 0001 */
674         case 0x11:
675            acall();
676            break;
677         //LCALL code addr
678         case 0x12:                  /* 1: 0001 0010 */
679            lcall();
680            break;
681         //RRC A
682         case 0x13:                  /* 1: 0001 0011 */
683            rrc_a();
684            break;
685         //DEC A
686         case 0x14:                  /* 1: 0001 0100 */
687            dec_a();
688            break;
689         //DEC data addr
690         case 0x15:                  /* 1: 0001 0101 */
691            RWM=1;
692            dec_mem();
693            RWM=0;
694            break;
695         //DEC @R0/@R1                   /* 1: 0001 011i */
696         case 0x16:
697         case 0x17:
698            dec_ir(op&1);
699            break;
700         //DEC R0 to R7                  /* 1: 0001 1rrr */
701         case 0x18:
702         case 0x19:
703         case 0x1a:
704         case 0x1b:
705         case 0x1c:
706         case 0x1d:
707         case 0x1e:
708         case 0x1f:
709            dec_r(op&7);
710            break;
711         //JB  bit addr, code addr
712         case 0x20:                  /* 1: 0010 0000 */
713            jb();
714            break;
715         //AJMP code addr                /* 1: aaa0 0001 */
716         case 0x21:
717            ajmp();
718            break;
719         //RET
720         case 0x22:                  /* 1: 0010 0010 */
721            ret();
722            break;
723         //RL A
724         case 0x23:                  /* 1: 0010 0011 */
725            rl_a();
726            break;
727         //ADD A, #data
728         case 0x24:                  /* 1: 0010 0100 */
729            add_a_byte();
730            break;
731         //ADD A, data addr
732         case 0x25:                  /* 1: 0010 0101 */
733            add_a_mem();
734            break;
735         //ADD A, @R0/@R1                /* 1: 0010 011i */
736         case 0x26:
737         case 0x27:
738            add_a_ir(op&1);
739            break;
740         //ADD A, R0 to R7               /* 1: 0010 1rrr */
741         case 0x28:
742         case 0x29:
743         case 0x2a:
744         case 0x2b:
745         case 0x2c:
746         case 0x2d:
747         case 0x2e:
748         case 0x2f:
749            add_a_r(op&7);
750            break;
751         //JNB bit addr, code addr
752         case 0x30:                  /* 1: 0011 0000 */
753            jnb();
754            break;
755         //ACALL code addr               /* 1: aaa1 0001 */
756         case 0x31:
757            acall();
758            break;
759         //RETI
760         case 0x32:                  /* 1: 0011 0010 */
761            reti();
762            break;
763         //RLC A
764         case 0x33:                  /* 1: 0011 0011 */
765            rlc_a();
766            break;
767         //ADDC A, #data
768         case 0x34:                  /* 1: 0011 0100 */
769            addc_a_byte();
770            break;
771         //ADDC A, data addr
772         case 0x35:                  /* 1: 0011 0101 */
773            addc_a_mem();
774            break;
775         //ADDC A, @R0/@R1               /* 1: 0011 011i */
776         case 0x36:
777         case 0x37:
778            addc_a_ir(op&1);
779            break;
780         //ADDC A, R0 to R7              /* 1: 0011 1rrr */
781         case 0x38:
782         case 0x39:
783         case 0x3a:
784         case 0x3b:
785         case 0x3c:
786         case 0x3d:
787         case 0x3e:
788         case 0x3f:
789            addc_a_r(op&7);
790            break;
791         //JC code addr
792         case 0x40:                  /* 1: 0100 0000 */
793            jc();
794            break;
795         //AJMP code addr                /* 1: aaa0 0001 */
796         case 0x41:
797            ajmp();
798            break;
799         //ORL data addr, A
800         case 0x42:                  /* 1: 0100 0010 */
801            RWM=1;
802            orl_mem_a();
803            RWM=0;
804            break;
805         //ORL data addr, #data
806         case 0x43:                  /* 1: 0100 0011 */
807            RWM=1;
808            orl_mem_byte();
809            RWM=0;
810            break;
811         //ORL A, #data
812         case 0x44:                  /* 1: 0100 0100 */
813            orl_a_byte();
814            break;
815         //ORL A, data addr
816         case 0x45:                  /* 1: 0100 0101 */
817            orl_a_mem();
818            break;
819         //ORL A, @RO/@R1                /* 1: 0100 011i */
820         case 0x46:
821         case 0x47:
822            orl_a_ir(op&1);
823            break;
824         //ORL A, RO to R7               /* 1: 0100 1rrr */
825         case 0x48:
826         case 0x49:
827         case 0x4a:
828         case 0x4b:
829         case 0x4c:
830         case 0x4d:
831         case 0x4e:
832         case 0x4f:
833            orl_a_r(op&7);
834            break;
835         //JNC code addr
836         case 0x50:                  /* 1: 0101 0000 */
837            jnc();
838            break;
839         //ACALL code addr               /* 1: aaa1 0001 */
840         case 0x51:
841            acall();
842            break;
843         //ANL data addr, A
844         case 0x52:                  /* 1: 0101 0010 */
845            RWM=1;
846            anl_mem_a();
847            RWM=0;
848            break;
849         //ANL data addr, #data
850         case 0x53:                  /* 1: 0101 0011 */
851            RWM=1;
852            anl_mem_byte();
853            RWM=0;
854            break;
855         //ANL A, #data
856         case 0x54:                  /* 1: 0101 0100 */
857            anl_a_byte();
858            break;
859         //ANL A, data addr
860         case 0x55:                  /* 1: 0101 0101 */
861            anl_a_mem();
862            break;
863         //ANL A, @RO/@R1                /* 1: 0101 011i */
864         case 0x56:
865         case 0x57:
866            anl_a_ir(op&1);
867            break;
868         //ANL A, RO to R7               /* 1: 0101 1rrr */
869         case 0x58:
870         case 0x59:
871         case 0x5a:
872         case 0x5b:
873         case 0x5c:
874         case 0x5d:
875         case 0x5e:
876         case 0x5f:
877            anl_a_r(op&7);
878            break;
879         //JZ code addr
880         case 0x60:                  /* 1: 0110 0000 */
881            jz();
882            break;
883         //AJMP code addr                /* 1: aaa0 0001 */
884         case 0x61:
885            ajmp();
886            break;
887         //XRL data addr, A
888         case 0x62:                  /* 1: 0110 0010 */
889            RWM=1;
890            xrl_mem_a();
891            RWM=0;
892            break;
893         //XRL data addr, #data
894         case 0x63:                  /* 1: 0110 0011 */
895            RWM=1;
896            xrl_mem_byte();
897            RWM=0;
898            break;
899         //XRL A, #data
900         case 0x64:                  /* 1: 0110 0100 */
901            xrl_a_byte();
902            break;
903         //XRL A, data addr
904         case 0x65:                  /* 1: 0110 0101 */
905            xrl_a_mem();
906            break;
907         //XRL A, @R0/@R1                /* 1: 0110 011i */
908         case 0x66:
909         case 0x67:
910            xrl_a_ir(op&1);
911            break;
912         //XRL A, R0 to R7               /* 1: 0110 1rrr */
913         case 0x68:
914         case 0x69:
915         case 0x6a:
916         case 0x6b:
917         case 0x6c:
918         case 0x6d:
919         case 0x6e:
920         case 0x6f:
921            xrl_a_r(op&7);
922            break;
923         //JNZ code addr
924         case 0x70:                  /* 1: 0111 0000 */
925            jnz();
926            break;
927         //ACALL code addr               /* 1: aaa1 0001 */
928         case 0x71:
929            acall();
930            break;
931         //ORL C, bit addr
932         case 0x72:                  /* 1: 0111 0010 */
933            orl_c_bitaddr();
934            break;
935         //JMP @A+DPTR
936         case 0x73:                  /* 1: 0111 0011 */
937            jmp_iadptr();
938            break;
939         //MOV A, #data
940         case 0x74:                  /* 1: 0111 0100 */
941            mov_a_byte();
942            break;
943         //MOV data addr, #data
944         case 0x75:                  /* 1: 0111 0101 */
945            mov_mem_byte();
946            break;
947         //MOV @R0/@R1, #data            /* 1: 0111 011i */
948         case 0x76:
949         case 0x77:
950            mov_ir_byte(op&1);
951            break;
952         //MOV R0 to R7, #data           /* 1: 0111 1rrr */
953         case 0x78:
954         case 0x79:
955         case 0x7a:
956         case 0x7b:
957         case 0x7c:
958         case 0x7d:
959         case 0x7e:
960         case 0x7f:
961            mov_r_byte(op&7);
962            break;
963         //SJMP code addr
964         case 0x80:                  /* 1: 1000 0000 */
965            sjmp();
966            break;
967         //AJMP code addr                /* 1: aaa0 0001 */
968         case 0x81:
969            ajmp();
970            break;
971         //ANL C, bit addr
972         case 0x82:                  /* 1: 1000 0010 */
973            anl_c_bitaddr();
974            break;
975         //MOVC A, @A + PC
976         case 0x83:                  /* 1: 1000 0011 */
977            movc_a_iapc();
978            break;
979         //DIV AB
980         case 0x84:                  /* 1: 1000 0100 */
981            div_ab();
982            break;
983         //MOV data addr, data addr
984         case 0x85:                  /* 1: 1000 0101 */
985            mov_mem_mem();
986            break;
987         //MOV data addr, @R0/@R1        /* 1: 1000 011i */
988         case 0x86:
989         case 0x87:
990            mov_mem_ir(op&1);
991            break;
992         //MOV data addr,R0 to R7        /* 1: 1000 1rrr */
993         case 0x88:
994         case 0x89:
995         case 0x8a:
996         case 0x8b:
997         case 0x8c:
998         case 0x8d:
999         case 0x8e:
1000         case 0x8f:
1001            mov_mem_r(op&7);
1002            break;
1003         //MOV DPTR, #data
1004         case 0x90:                  /* 1: 1001 0000 */
1005            mov_dptr_byte();
1006            break;
1007         //ACALL code addr               /* 1: aaa1 0001 */
1008         case 0x91:
1009            acall();
1010            break;
1011         //MOV bit addr, C
1012         case 0x92:                  /* 1: 1001 0010 */
1013            RWM = 1;
1014            mov_bitaddr_c();
1015            RWM = 0;
1016            break;
1017         //MOVC A, @A + DPTR
1018         case 0x93:                  /* 1: 1001 0011 */
1019            movc_a_iadptr();
1020            break;
1021         //SUBB A, #data
1022         case 0x94:                  /* 1: 1001 0100 */
1023            subb_a_byte();
1024            break;
1025         //SUBB A, data addr
1026         case 0x95:                  /* 1: 1001 0101 */
1027            subb_a_mem();
1028            break;
1029         //SUBB A, @R0/@R1               /* 1: 1001 011i */
1030         case 0x96:
1031         case 0x97:
1032            subb_a_ir(op&1);
1033            break;
1034         //SUBB A, R0 to R7              /* 1: 1001 1rrr */
1035         case 0x98:
1036         case 0x99:
1037         case 0x9a:
1038         case 0x9b:
1039         case 0x9c:
1040         case 0x9d:
1041         case 0x9e:
1042         case 0x9f:
1043            subb_a_r(op&7);
1044            break;
1045         //ORL C, /bit addr
1046         case 0xa0:                  /* 1: 1010 0000 */
1047            orl_c_nbitaddr();
1048            break;
1049         //AJMP code addr                /* 1: aaa0 0001 */
1050         case 0xa1:
1051            ajmp();
1052            break;
1053         //MOV C, bit addr
1054         case 0xa2:                  /* 1: 1010 0010 */
1055            mov_c_bitaddr();
1056            break;
1057         //INC DPTR
1058         case 0xa3:                  /* 1: 1010 0011 */
1059            inc_dptr();
1060            break;
1061         //MUL AB
1062         case 0xa4:                  /* 1: 1010 0100 */
1063            mul_ab();
1064            break;
1065         //reserved
1066         case 0xa5:                  /* 1: 1010 0101 */
1067            illegal();
1068            break;
1069         //MOV @R0/@R1, data addr        /* 1: 1010 011i */
1070         case 0xa6:
1071         case 0xa7:
1072            mov_ir_mem(op&1);
1073            break;
1074         //MOV R0 to R7, data addr       /* 1: 1010 1rrr */
1075         case 0xa8:
1076         case 0xa9:
1077         case 0xaa:
1078         case 0xab:
1079         case 0xac:
1080         case 0xad:
1081         case 0xae:
1082         case 0xaf:
1083            mov_r_mem(op&7);
1084            break;
1085         //ANL C,/bit addr
1086         case 0xb0:                  /* 1: 1011 0000 */
1087            anl_c_nbitaddr();
1088            break;
1089         //ACALL code addr               /* 1: aaa1 0001 */
1090         case 0xb1:
1091            acall();
1092            break;
1093         //CPL bit addr
1094         case 0xb2:                  /* 1: 1011 0010 */
1095            RWM=1;
1096            cpl_bitaddr();
1097            RWM=0;
1098            break;
1099         //CPL C
1100         case 0xb3:                  /* 1: 1011 0011 */
1101            cpl_c();
1102            break;
1103         //CJNE A, #data, code addr
1104         case 0xb4:                  /* 1: 1011 0100 */
1105            cjne_a_byte();
1106            break;
1107         //CJNE A, data addr, code addr
1108         case 0xb5:                  /* 1: 1011 0101 */
1109            cjne_a_mem();
1110            break;
1111         //CJNE @R0/@R1, #data, code addr /* 1: 1011 011i */
1112         case 0xb6:
1113         case 0xb7:
1114            cjne_ir_byte(op&1);
1115            break;
1116         //CJNE R0 to R7, #data, code addr/* 1: 1011 1rrr */
1117         case 0xb8:
1118         case 0xb9:
1119         case 0xba:
1120         case 0xbb:
1121         case 0xbc:
1122         case 0xbd:
1123         case 0xbe:
1124         case 0xbf:
1125            cjne_r_byte(op&7);
1126            break;
1127         //PUSH data addr
1128         case 0xc0:                  /* 1: 1100 0000 */
1129            push();
1130            break;
1131         //AJMP code addr                /* 1: aaa0 0001 */
1132         case 0xc1:
1133            ajmp();
1134            break;
1135         //CLR bit addr
1136         case 0xc2:                  /* 1: 1100 0010 */
1137            RWM=1;
1138            clr_bitaddr();
1139            RWM=0;
1140            break;
1141         //CLR C
1142         case 0xc3:                  /* 1: 1100 0011 */
1143            clr_c();
1144            break;
1145         //SWAP A
1146         case 0xc4:                  /* 1: 1100 0100 */
1147            swap_a();
1148            break;
1149         //XCH A, data addr
1150         case 0xc5:                  /* 1: 1100 0101 */
1151            xch_a_mem();
1152            break;
1153         //XCH A, @RO/@R1                /* 1: 1100 011i */
1154         case 0xc6:
1155         case 0xc7:
1156            xch_a_ir(op&1);
1157            break;
1158         //XCH A, RO to R7               /* 1: 1100 1rrr */
1159         case 0xc8:
1160         case 0xc9:
1161         case 0xca:
1162         case 0xcb:
1163         case 0xcc:
1164         case 0xcd:
1165         case 0xce:
1166         case 0xcf:
1167            xch_a_r(op&7);
1168            break;
1169         //POP data addr
1170         case 0xd0:                  /* 1: 1101 0000 */
1171            pop();
1172            break;
1173         //ACALL code addr               /* 1: aaa1 0001 */
1174         case 0xd1:
1175            acall();
1176            break;
1177         //SETB bit addr
1178         case 0xd2:                  /* 1: 1101 0010 */
1179            RWM=1;
1180            setb_bitaddr();
1181            RWM=0;
1182            break;
1183         //SETB C
1184         case 0xd3:                  /* 1: 1101 0011 */
1185            setb_c();
1186            break;
1187         //DA A
1188         case 0xd4:                  /* 1: 1101 0100 */
1189            da_a();
1190            break;
1191         //DJNZ data addr, code addr
1192         case 0xd5:                  /* 1: 1101 0101 */
1193            RWM=1;
1194            djnz_mem();
1195            RWM=0;
1196            break;
1197         //XCHD A, @R0/@R1               /* 1: 1101 011i */
1198         case 0xd6:
1199         case 0xd7:
1200            xchd_a_ir(op&1);
1201            break;
1202         //DJNZ R0 to R7,code addr       /* 1: 1101 1rrr */
1203         case 0xd8:
1204         case 0xd9:
1205         case 0xda:
1206         case 0xdb:
1207         case 0xdc:
1208         case 0xdd:
1209         case 0xde:
1210         case 0xdf:
1211            djnz_r(op&7);
1212            break;
1213         //MOVX A,@DPTR
1214         case 0xe0:                  /* 1: 1110 0000 */
1215            movx_a_idptr();
1216            break;
1217         //AJMP code addr                /* 1: aaa0 0001 */
1218         case 0xe1:
1219            ajmp();
1220            break;
1221         //MOVX A, @R0/@R1               /* 1: 1110 001i */
1222         case 0xe2:
1223         case 0xe3:
1224            movx_a_ir(op&1);
1225            break;
1226         //CLR A
1227         case 0xe4:                  /* 1: 1110 0100 */
1228            clr_a();
1229            break;
1230         //MOV A, data addr
1231         case 0xe5:                  /* 1: 1110 0101 */
1232            mov_a_mem();
1233            break;
1234         //MOV A,@RO/@R1                 /* 1: 1110 011i */
1235         case 0xe6:
1236         case 0xe7:
1237            mov_a_ir(op&1);
1238            break;
1239         //MOV A,R0 to R7                /* 1: 1110 1rrr */
1240         case 0xe8:
1241         case 0xe9:
1242         case 0xea:
1243         case 0xeb:
1244         case 0xec:
1245         case 0xed:
1246         case 0xee:
1247         case 0xef:
1248            mov_a_r(op&7);
1249            break;
1250         //MOVX @DPTR,A
1251         case 0xf0:                  /* 1: 1111 0000 */
1252            movx_idptr_a();
1253            break;
1254         //ACALL code addr               /* 1: aaa1 0001 */
1255         case 0xf1:
1256            acall();
1257            break;
1258         //MOVX @R0/@R1,A                /* 1: 1111 001i */
1259         case 0xf2:
1260         case 0xf3:
1261            movx_ir_a(op&1);
1262            break;
1263         //CPL A
1264         case 0xf4:                  /* 1: 1111 0100 */
1265            cpl_a();
1266            break;
1267         //MOV data addr, A
1268         case 0xf5:                  /* 1: 1111 0101 */
1269            mov_mem_a();
1270            break;
1271         //MOV @R0/@R1, A                /* 1: 1111 011i */
1272         case 0xf6:
1273         case 0xf7:
1274            mov_ir_a(op&1);
1275            break;
1276         //MOV R0 to R7, A               /* 1: 1111 1rrr */
1277         case 0xf8:
1278         case 0xf9:
1279         case 0xfa:
1280         case 0xfb:
1281         case 0xfc:
1282         case 0xfd:
1283         case 0xfe:
1284         case 0xff:
1285            mov_r_a(op&7);
1286            break;
1287         default:
1288            illegal();
1289      }
409/* Macros for accessing flags */
1290410
1291      //Store # of used cycles for this opcode (for timer & serial check at top of code)
1292      i8051.prev_used_cycles = i8051_cycles[op];
411#define GET_CY         GET_BIT(PSW, 7)
412#define GET_AC         GET_BIT(PSW, 6)
413#define GET_FO         GET_BIT(PSW, 5)
414#define GET_RS         GET_BIT(PSW, 3)
415#define GET_OV         GET_BIT(PSW, 2)
416#define GET_P         GET_BIT(PSW, 0)
1293417
1294      //Check for pending interrupts & handle - remove cycles used
1295      i8051_icount-=check_interrupts();
418#define GET_EA         GET_BIT(IE, 7)
419#define GET_ET2         GET_BIT(IE, 5)
420#define GET_ES         GET_BIT(IE, 4)
421#define GET_ET1         GET_BIT(IE, 3)
422#define GET_EX1         GET_BIT(IE, 2)
423#define GET_ET0         GET_BIT(IE, 1)
424#define GET_EX0         GET_BIT(IE, 0)
1296425
1297   } while( i8051_icount > 0 );
426/* 8052 Only flags */
427#define GET_PT2         GET_BIT(IP, 5)
1298428
1299   return cycles - i8051_icount;
1300}
429#define GET_PS         GET_BIT(IP, 4)
430#define GET_PT1         GET_BIT(IP, 3)
431#define GET_PX1         GET_BIT(IP, 2)
432#define GET_PT0         GET_BIT(IP, 1)
433#define GET_PX0         GET_BIT(IP, 0)
1301434
1302/* Get registers, return context size */
1303void i8051_get_context(void *dst)
1304{
1305   if( dst )
1306      memcpy(dst, &i8051, sizeof(I8051));
1307}
435#define GET_TF1         GET_BIT(TCON, 7)
436#define GET_TR1         GET_BIT(TCON, 6)
437#define GET_TF0         GET_BIT(TCON, 5)
438#define GET_TR0         GET_BIT(TCON, 4)
439#define GET_IE1         GET_BIT(TCON, 3)
440#define GET_IT1         GET_BIT(TCON, 2)
441#define GET_IE0         GET_BIT(TCON, 1)
442#define GET_IT0         GET_BIT(TCON, 0)
1308443
1309/* Set registers */
1310void i8051_set_context(void *src)
1311{
1312   if( src )
1313      memcpy(&i8051, src, sizeof(I8051));
1314}
444#define GET_SM0         GET_BIT(SCON, 7)
445#define GET_SM1         GET_BIT(SCON, 6)
446#define GET_SM2         GET_BIT(SCON, 5)
447#define GET_REN         GET_BIT(SCON, 4)
448#define GET_TB8         GET_BIT(SCON, 3)
449#define GET_RB8         GET_BIT(SCON, 2)
450#define GET_TI         GET_BIT(SCON, 1)
451#define GET_RI         GET_BIT(SCON, 0)
1315452
1316/* Get Internal RAM value */
1317unsigned i8051_get_intram(int offset)
1318{
1319    UINT8 ram_ret = 0;
1320    RWM = 1;
1321    ram_ret = IRAM_R(offset);
1322    RWM = 0;
1323    return ram_ret;
1324}
453#define GET_GATE1      GET_BIT(TMOD, 7)
454#define GET_CT1         GET_BIT(TMOD, 6)
455#define GET_M1_1      GET_BIT(TMOD, 5)
456#define GET_M1_0      GET_BIT(TMOD, 4)
457#define GET_GATE0      GET_BIT(TMOD, 3)
458#define GET_CT0         GET_BIT(TMOD, 2)
459#define GET_M0_1      GET_BIT(TMOD, 1)
460#define GET_M0_0      GET_BIT(TMOD, 0)
1325461
1326/*NOTE: These are not used by the opcode functions, they are here only for MAME requirements*/
1327unsigned i8051_get_reg(int regnum)
1328{
1329   switch( regnum )
1330   {
1331   case REG_PREVIOUSPC: return PPC;
1332   case REG_PC:
1333   case I8051_PC:   return PC;
1334   case REG_SP:
1335   case I8051_SP:   return R_SP;
1336   case I8051_ACC:   return R_ACC;
1337   case I8051_PSW: return R_PSW;
1338   case I8051_B:   return R_B;
1339   case I8051_DPH:   return R_DPH;
1340   case I8051_DPL:   return R_DPL;
1341   case I8051_IE:   return R_IE;
1342   //Not real registers
1343   case I8051_R0:   return R_R(0);
1344   case I8051_R1:   return R_R(1);
1345   case I8051_R2:   return R_R(2);
1346   case I8051_R3:   return R_R(3);
1347   case I8051_R4:   return R_R(4);
1348   case I8051_R5:   return R_R(5);
1349   case I8051_R6:   return R_R(6);
1350   case I8051_R7:   return R_R(7);
1351   case I8051_RB:   return GET_RS;
1352   default:
1353      return 0;
1354   }
1355}
462#define GET_SMOD      GET_BIT(PCON, 7)
463#define GET_GF1         GET_BIT(TMOD, 3)
464#define GET_GF0         GET_BIT(TMOD, 2)
465#define GET_PD         GET_BIT(TMOD, 1)      /* Only in 80C51BH */
466#define GET_IDL         GET_BIT(TMOD, 0)      /* Only in 80C51BH */
1356467
1357/*NOTE: These are not used by the opcode functions, they are here only for MAME requirements*/
1358void i8051_set_reg (int regnum, unsigned val)
1359{
1360   switch( regnum )
1361   {
1362   case REG_PC:
1363   case I8051_PC:   PC = val & 0xffff; break;
1364   case REG_SP:
1365   case I8051_SP:   SFR_W(SP,val);  break;      //Use SFR to handle error checking
1366   case I8051_ACC:   SFR_W(ACC,val); break;
1367   case I8051_PSW: SFR_W(PSW,val); break;
1368   case I8051_B:   SFR_W(B,val);   break;
1369   case I8051_DPH: SFR_W(DPH,val); break;
1370   case I8051_DPL: SFR_W(DPL,val); break;
1371   case I8051_IE:  SFR_W(IE,val);  break;
1372   //Not real registers
1373   case I8051_R0:   R_R(0) = val; break;
1374   case I8051_R1:   R_R(1) = val; break;
1375   case I8051_R2:   R_R(2) = val; break;
1376   case I8051_R3:   R_R(3) = val; break;
1377   case I8051_R4:   R_R(4) = val; break;
1378   case I8051_R5:   R_R(5) = val; break;
1379   case I8051_R6:   R_R(6) = val; break;
1380   case I8051_R7:   R_R(7) = val; break;
1381   case I8051_RB:  SET_RS( (val&3) ); break;
468/* 8052 Only flags */
469#define GET_TF2         GET_BIT(T2CON, 7)
470#define GET_EXF2      GET_BIT(T2CON, 6)
471#define GET_RCLK      GET_BIT(T2CON, 5)
472#define GET_TCLK      GET_BIT(T2CON, 4)
473#define GET_EXEN2      GET_BIT(T2CON, 3)
474#define GET_TR2         GET_BIT(T2CON, 2)
475#define GET_CT2         GET_BIT(T2CON, 1)
476#define GET_CP         GET_BIT(T2CON, 0)
1382477
1383   default:
1384      return;
1385   }
1386}
478/*Add and Subtract Flag settings*/
479#define DO_ADD_FLAGS(a,d,c)   do_add_flags(a,d,c)
480#define DO_SUB_FLAGS(a,d,c)   do_sub_flags(a,d,c)
1387481
1388void i8051_set_irq_line(int irqline, int state)
1389{
1390   switch( irqline )
1391   {
1392      //External Interrupt 0
1393      case I8051_INT0_LINE:
1394         //Line Asserted?
1395         if (state != CLEAR_LINE) {
1396            //Is the enable flag for this interrupt set?
1397            if(GET_EX0) {
1398               //Need cleared->active line transition? (Logical 1-0 Pulse on the line) - CLEAR->ASSERT Transition since INT0 active lo!
1399               if(GET_IT0){
1400                  if(i8051.last_int0 == CLEAR_LINE)
1401                     SET_IE0(1);
1402               }
1403               else
1404                  SET_IE0(1);      //Nope, just set it..
1405            }
1406         }
1407         else
1408            SET_IE0(0);      //Clear Int occurred flag
1409         i8051.last_int0 = state;
482#define SET_PARITY()   do {mcs51.recalc_parity |= 1;} while (0)
483#define PUSH_PC()      push_pc()
484#define POP_PC()      pop_pc()
1410485
1411         //Do the interrupt & handle - remove machine cycles used
1412         if(GET_IE0)
1413            i8051_icount-=check_interrupts();
1414         break;
486#if 0
487/* Any pending IRQ */
488#define SERIALPORT_IRQ    ((R_SCON & 0x03) && GET_ES)
489#define TIMERS_IRQ        ((GET_TF0 && GET_ET0) || (GET_TF1 && GET_ET1))
490#define EXTERNAL_IRQ      ((GET_IE0 && GET_EX0) || (GET_IE1 && GET_EX1))
1415491
1416      //External Interrupt 1
1417      case I8051_INT1_LINE:
1418
1419         //Line Asserted?
1420         if (state != CLEAR_LINE) {
1421            if(GET_EX1) {
1422               //Need cleared->active line transition? (Logical 1-0 Pulse on the line) - CLEAR->ASSERT Transition since INT1 active lo!
1423               if(GET_IT1){
1424                  if(i8051.last_int1 == CLEAR_LINE)
1425                     SET_IE1(1);
1426               }
1427            else
1428               SET_IE1(1);      //Nope, just set it..
1429            }
1430         }
1431         else
1432            SET_IE1(0);      //Clear Int occurred flag
1433         i8051.last_int1 = state;
1434
1435         //Do the interrupt & handle - remove machine cycles used
1436         if(GET_IE1)
1437            i8051_icount-=check_interrupts();
1438         break;
1439
1440      //Serial Port Receive
1441      case I8051_RX_LINE:
1442         //Is the enable flags for this interrupt set?
1443         if(GET_ES && GET_REN) {
1444            int data = 0;
1445            //Call our callball function to retrieve the data
1446            if(i8051.serial_rx_callback)
1447               data = i8051.serial_rx_callback();
1448            //Update the register directly, since SFR_W() will trigger a serial transmit instead!
1449            R_SBUF=data;
1450            //Flag the IRQ
1451            SET_RI(1);
1452         }
1453         break;
1454         //Note: we won't call check interrupts, we'll let the main loop catch it
1455   }
1456}
1457
1458/***********************************************************************************
1459 Check for pending Interrupts and process - returns # of cycles used for the int
1460
1461 Note about priority & interrupting interrupts..
1462 1) A high priority interrupt cannot be interrupted by anything!
1463 2) A low priority interrupt can ONLY be interrupted by a high priority interrupt
1464 3) If more than 1 Interrupt Flag is set (ie, 2 simultaneous requests occur),
1465    the following logic works as follows:
1466    1) If two requests come in of different priority levels, the higher one is selected..
1467    2) If the requests are of the same level, an internal order is used:
1468        a) IEO
1469        b) TFO
1470        c) IE1
1471        d) TF1
1472        e) RI+TI
1473        f) TF2+EXF2
1474 **********************************************************************************/
1475INLINE UINT8 check_interrupts(void)
1476{
1477   //If All Inerrupts Disabled or no pending abort..
1478   if(!GET_EA)   return 0;
1479
1480   //Any Interrupts Pending?
1481   if(NO_PENDING_IRQ) return 0;
1482
1483   //Skip if current irq in progress is high priority!
1484   if(i8051.irq_priority)   { /* LOG(("high priority irq in progress, skipping irq request\n")); */ return 0; }
1485
1486   //Check which interrupt(s) requests have occurred..
1487   //NOTE: The order of checking is based on the internal/default priority levels when levels are the same
1488
1489   //External Int 0
1490   if(GET_IE0) {
1491      //Set vector & priority level request
1492      i8051.int_vec = V_IE0;
1493      i8051.priority_request = GET_PX0;
1494   }
1495   //Timer 0 overflow
1496   if(!i8051.priority_request && GET_TF0 && (!i8051.int_vec || (i8051.int_vec && GET_PT0))) {
1497      //Set vector & priority level request
1498      i8051.int_vec = V_TF0;
1499      i8051.priority_request = GET_PT0;
1500   }
1501   //External Int 1
1502   if(!i8051.priority_request && GET_IE1 && (!i8051.int_vec || (i8051.int_vec && GET_PX1))) {
1503      //Set vector & priority level request
1504      i8051.int_vec = V_IE1;
1505      i8051.priority_request = GET_PX1;
1506   }
1507   //Timer 1 overflow
1508   if(!i8051.priority_request && GET_TF1 && (!i8051.int_vec || (i8051.int_vec && GET_PT1))) {
1509      //Set vector & priority level request
1510      i8051.int_vec = V_TF1;
1511      i8051.priority_request = GET_PT1;
1512   }
1513   //Serial Interrupt Transmit/Receive Interrupts (Note: ES Bit - Serial Interrupts must be enabled)
1514   if(!i8051.priority_request && GET_ES && (GET_TI || GET_RI) && (!i8051.int_vec || (i8051.int_vec && GET_PS))) {
1515      //Set vector & priority level request
1516      i8051.int_vec = V_RITI;
1517      i8051.priority_request = GET_PS;
1518   }
1519492#if (HAS_I8052 || HAS_I8752)
1520   //Timer 2 overflow (Either Timer Overflow OR External Interrupt)
1521   if(!i8051.priority_request && GET_ET2 && (GET_TF2 || GET_EXF2) && (!i8051.int_vec || (i8051.int_vec && GET_PT2))) {
1522      //Set vector & priority level request
1523      i8051.int_vec = V_TF2;
1524      i8051.priority_request = GET_PT2;
1525   }
493#define NO_PENDING_IRQ  !(TIMERS_IRQ) && !(EXTERNAL_IRQ) && !(SERIALPORT_IRQ) && !(GET_ET2 && (GET_TF2 || GET_EXF2))
494#else
495#define NO_PENDING_IRQ  !(TIMERS_IRQ) && !(EXTERNAL_IRQ) && !(SERIALPORT_IRQ)
1526496#endif
497#endif
1527498
1528   //Skip the interrupt request if currently processing is lo priority, and the new request IS NOT HI PRIORITY!
1529   if(i8051.cur_irq < 0xff && !i8051.priority_request)
1530      { LOG(("low priority irq in progress already, skipping low irq request\n")); return 0; }
499/* Clear Current IRQ  */
500#define CLEAR_CURRENT_IRQ() do { mcs51.cur_irq = 0xff; mcs51.irq_priority = 0; } while (0)
1531501
1532    /*** --- Perform the interrupt --- ***/
502/***************************************************************************
503    GLOBAL VARIABLES
504***************************************************************************/
1533505
1534   //Save current pc to stack, set pc to new interrupt vector
1535   push_pc();
1536   PC = i8051.int_vec;
506static int mcs51_icount;
1537507
1538   //Set current Irq & Priority being serviced
1539   i8051.cur_irq = i8051.int_vec;
1540   i8051.irq_priority = i8051.priority_request;
508static mcs51_regs mcs51;
1541509
1542   //Clear any interrupt flags that should be cleared since we're servicing the irq!
1543   switch(i8051.cur_irq) {
1544      case V_IE0:
1545         //External Int Flag only cleared when configured as Edge Triggered..
1546         //if(GET_IT0)   - for some reason having this, breaks alving dmd games
1547            SET_IE0(0);
1548         break;
1549      case V_TF0:
1550         //Timer 0 - Always clear Flag
1551         SET_TF0(0);
1552         break;
1553      case V_IE1:
1554         //External Int Flag only cleared when configured as Edge Triggered..
1555         //if(GET_IT1)   - for some reason having this, breaks alving dmd games
1556            SET_IE1(0);
1557         break;
1558      case V_TF1:
1559         //Timer 0 - Always clear Flag
1560         SET_TF1(0);
1561         break;
1562      case V_RITI:
1563         // no flags are cleared, TI and RI remain set until reset by software
1564         break;
1565#if (HAS_I8052 || HAS_I8752)
1566      case V_TF2:
1567         // no flags are cleared according to manual
1568         break;
1569#endif
1570   }
1571510
1572   //Clear vars.. (these are part of the 8051 structure for speed, so we don't have to dynamically allocate space each time)
1573   i8051.int_vec = 0;
1574   i8051.priority_request = 0;
511/***************************************************************************
512    FUNCTION PROTOTYPES
513***************************************************************************/
1575514
1576   //All interrupts use 2 machine cycles
1577   return 24;
1578}
515static void check_irqs(void);
516INLINE void serial_transmit(UINT8 data);
1579517
518/* Hold callback functions so they can be set by caller (before the cpu reset) */
1580519
1581void i8051_set_irq_callback(int (*callback)(int irqline))
1582{
1583   i8051.irq_callback = callback;
1584}
520static void (*hold_serial_tx_callback)(int data);
521static int (*hold_serial_rx_callback)(void);
1585522
1586void i8051_set_serial_tx_callback(void (*callback)(int data))
1587{
1588   //Hold in static variable since this function can get called before reset has run, which wipes i8051 memory clean
1589   hold_serial_tx_callback = callback;
1590}
1591void i8051_set_serial_rx_callback(int (*callback)(void))
1592{
1593   //Hold in static variable since this function can get called before reset has run, which wipes i8051 memory clean
1594   hold_serial_rx_callback = callback;
1595}
523/***************************************************************************
524    INLINE FUNCTIONS
525***************************************************************************/
1596526
1597void i8051_set_eram_iaddr_callback(READ32_HANDLER((*callback)))
1598{
1599   //Hold in static variable since this function can get called before reset has run, which wipes i8051 memory clean
1600   hold_eram_iaddr_callback = callback;
1601}
527INLINE UINT8 r_acc(void) { return SFR_A(ADDR_ACC); }
1602528
529INLINE UINT8 r_psw(void) { return SFR_A(ADDR_PSW); }
1603530
1604void i8051_state_save(void *file)
531INLINE void update_ptrs(void)
1605532{
533   mcs51.internal_ram = memory_get_write_ptr(cpu_getactivecpu(), ADDRESS_SPACE_DATA, 0x00);
534   mcs51.sfr_ram = memory_get_write_ptr(cpu_getactivecpu(), ADDRESS_SPACE_DATA, 0x100);
1606535}
1607536
1608void i8051_state_load(void *file)
1609{
1610}
1611537
1612/* HELPER FUNCTIONS */
538/* Generate an external ram address for read/writing using indirect addressing mode */
539/*The lowest 8 bits of the address are passed in (from the R0/R1 register), however
540  the hardware can be configured to set the rest of the address lines to any available output port pins, which
541  means the only way we can implement this is to allow the driver to setup a callback to generate the
542  address as defined by the specific hardware setup. We'll assume the address won't be bigger than 32 bits
1613543
1614/*All writes to SFR are handled here*/
1615static WRITE8_HANDLER(sfr_write)
1616{
1617   data &= 0xff;      //Ensure only 8 bits
1618   switch (offset)
1619   {
1620      case P0:
1621         R_P0 = data;
1622         OUT(0,data);
1623         break;
544  Couriersud, October 2008:
545  There is no way external hardware can distinguish between 8bit access and 16 bit access.
546  During 16bit access the high order byte of the address is output on port 2. We therefore
547  assume that most hardware will use port 2 for 8bit access as well.
1624548
1625      case SP:
1626         if(offset > 0xff)
1627            LOG(("i8051 #%d: attemping to write value to SP past 256 bytes at 0x%04x\n", cpu_getactivecpu(), PC));
1628         R_SP = data&0xff; //keep sp w/in 256 bytes
1629         break;
549  On configurations where 8 bit access in conjunction with other ports is used,
550  it is up to the driver to use AM_MIRROR to mask out the high level address and
551  provide it's own mapping.
552*/
1630553
1631      case DPL:      R_DPL = data; break;
1632      case DPH:      R_DPH = data; break;
1633      case PCON:      R_PCON= data; break;
1634      case TCON:      R_TCON= data; break;
1635      case TMOD:      R_TMOD= data; break;
1636      case TL0:      R_TL0 = data; break;
1637      case TL1:      R_TL1 = data; break;
1638      case TH0:      R_TH0 = data; break;
1639      case TH1:      R_TH1 = data; break;
1640
1641      case P1:
1642         R_P1 = data;
1643         OUT(1,data);
1644         break;
1645
1646      case SCON: {
1647         //Update register
1648         R_SCON = data;
1649         break;
1650      }
1651
1652      case SBUF:
1653         //R_SBUF = data;        //This register is used only for "Receiving data coming in!"
1654         serial_transmit(data);   //Set up to transmit the data
1655         break;
1656
1657      case P2:
1658         R_P2 = data;
1659         OUT(2,data);
1660         break;
1661
1662      case IE:      R_IE  = data; break;
1663
1664      case P3:
1665         R_P3 = data;
1666         OUT(3,data);
1667         break;
1668
1669      case IP:      R_IP  = data; break;
1670
1671   //8052 Only registers
1672   #if (HAS_I8052 || HAS_I8752)
1673      case T2CON:      R_T2CON = data; break;
1674      case RCAP2L:   R_RCAP2L = data; break;
1675      case RCAP2H:   R_RCAP2H = data; break;
1676      case TL2:      R_TL2 = data; break;
1677      case TH2:      R_TH2 = data; break;
1678   #endif
1679
1680      case PSW:
1681         R_PSW = data;
1682         SET_PARITY;
1683         break;
1684
1685      case ACC:
1686         R_ACC = data;
1687         SET_PARITY;
1688         break;
1689
1690      case B:         R_B   = data; break;
1691
1692      /* Illegal or non-implemented sfr */
1693      default:
1694         LOG(("i8051 #%d: attemping to write to an invalid/non-implemented SFR address: %x at 0x%04x, data=%x\n", cpu_getactivecpu(), offset,PC,data));
1695   }
1696}
1697
1698/*All reads to SFR are handled here*/
1699static READ8_HANDLER(sfr_read)
554INLINE offs_t external_ram_iaddr(offs_t offset, offs_t mem_mask)
1700555{
1701   switch (offset)
1702   {
1703      case P0:
1704         if(RWM)
1705            return R_P0;               //Read directly from port latch
1706         else
1707            return IN(0);               //Read from actual port
1708      case SP:      return R_SP;
1709      case DPL:      return R_DPL;
1710      case DPH:      return R_DPH;
1711      case PCON:      return R_PCON;
1712      case TCON:      return R_TCON;
1713      case TMOD:      return R_TMOD;
1714      case TL0:      return R_TL0;
1715      case TL1:      return R_TL1;
1716      case TH0:      return R_TH0;
1717      case TH1:      return R_TH1;
1718      case P1:
1719         if(RWM)
1720            return R_P1;               //Read directly from port latch
1721         else
1722            return IN(1);               //Read from actual port
1723      case SCON:      return R_SCON;
1724      case SBUF:      return R_SBUF;
1725      case P2:
1726         if(RWM)
1727            return R_P2;               //Read directly from port latch
1728         else
1729            return IN(2);               //Read from actual port
1730      case IE:      return R_IE;
1731      case P3:
1732         if(RWM)
1733            return R_P3;               //Read directly from port latch
1734         else
1735            return IN(3);               //Read from actual port
1736      case IP:      return R_IP;
1737   //8052 Only registers
1738   #if (HAS_I8052 || HAS_I8752)
1739      case T2CON:      return R_T2CON;
1740      case RCAP2L:   return R_RCAP2L;
1741      case RCAP2H:   return R_RCAP2H;
1742      case TL2:      return R_TL2;
1743      case TH2:      return R_TH2;
1744   #endif
1745      case PSW:      return R_PSW;
1746      case ACC:      return R_ACC;
1747      case B:         return R_B;
1748
1749      /* Illegal or non-implemented sfr */
1750      default:
1751         LOG(("i8051 #%d: attemping to read an invalid/non-implemented SFR address: %x at 0x%04x\n", cpu_getactivecpu(), offset,PC));
1752   }
1753   return 0xff;
556   if (mem_mask == 0x00ff)
557      return (offset & mem_mask) | (P2 << 8);
558#if 0
559    if(mcs51.eram_iaddr_callback)
560        return mcs51.eram_iaddr_callback(machine,offset,mem_mask);
561    else
562        if (mem_mask <= 0x100) LOG(("mcs51 #%d: external ram address requested (8 bit offset=%02x), but no callback available! at PC:%04x\n", cpu_getactivecpu(), offset, PC));
563#endif
564   return offset;
1754565}
1755566
1756/* Reads the contents of the Internal RAM memory   */
1757/* Anything above 0x7f is a sfr/register */
1758static READ8_HANDLER(internal_ram_read)
1759{
1760   if (offset < 0x80)
1761      return i8051.IntRam[offset];
1762   else {
1763      if (offset < 0x100)
1764         return SFR_R(offset);
1765      else
1766         LOG(("i8051 #%d: attemping to read from an invalid Internal Ram address: %x at 0x%04x\n", cpu_getactivecpu(), offset,PC));
1767   }
1768   return 0xff;
1769}
567/* Internal ram read/write */
1770568
1771/* Writes the contents of the Internal RAM memory   */
1772/* Anything above 0x7f is a sfr/register */
1773static WRITE8_HANDLER(internal_ram_write)
569INLINE UINT8 iram_read(size_t offset)
1774570{
1775   data &= 0xff;            //Ensure it's only 8 bits
1776   if (offset < 0x80)
1777      i8051.IntRam[offset] = data;
1778   else {
1779      if (offset < 0x100)
1780         SFR_W(offset,data);
1781      else
1782         LOG(("i8051 #%d: attemping to write to invalid Internal Ram address: %x at 0x%04x\n", cpu_getactivecpu(), offset,PC));
1783   }
571   return (((offset) < 0x80) ? data_read_byte_8le(offset) : mcs51.sfr_read(offset));
1784572}
1785573
1786/* Reads the contents of the Internal RAM memory (BUT CALLED FROM AN INDIRECT ADDRESSING MODE)   */
1787/* Different chip types handle differently, for speed, simply call the chip's handler */
1788static READ8_HANDLER(internal_ram_iread)
574INLINE void iram_write(size_t offset, UINT8 data)
1789575{
1790   return i8051.iram_iread(machine,offset);
576   if ((offset) < 0x80)
577      data_write_byte_8le(offset, data);
578   else
579      mcs51.sfr_write(offset, data);
1791580}
1792581
1793/* Writes the contents of the Internal RAM memory (BUT CALLED FROM AN INDIRECT ADDRESSING MODE)   */
1794/* Different chip types handle differently, for speed, simply call the chip's handler */
1795static WRITE8_HANDLER(internal_ram_iwrite)
1796{
1797   i8051.iram_iwrite(machine,offset,data);
1798}
1799
1800/*Generate an external ram address for read/writing using indirect addressing mode */
1801/*The lowest 8 bits of the address are passed in (from the R0/R1 register), however
1802  the hardware can be configured to set the rest of the address lines to any available output port pins, which
1803  means the only way we can implement this is to allow the driver to setup a callback to generate the
1804  address as defined by the specific hardware setup. We'll assume the address won't be bigger than 32 bits
1805*/
1806static READ32_HANDLER(external_ram_iaddr)
1807{
1808    if(i8051.eram_iaddr_callback)
1809        return i8051.eram_iaddr_callback(machine,offset,mem_mask);
1810    else
1811        LOG(("i8051 #%d: external ram address requested (8 bit offset=%02x), but no callback available! at PC:%04x\n", cpu_getactivecpu(), offset, PC));
1812
1813   return offset;
1814}
1815
1816582/*Push the current PC to the stack*/
1817INLINE void push_pc()
583INLINE void push_pc(void)
1818584{
1819   UINT8 tmpSP = R_SP;                     //Grab and Increment Stack Pointer
585   UINT8 tmpSP = SP+1;                  //Grab and Increment Stack Pointer
586   IRAM_IW(tmpSP, (PC & 0xff));            //Store low byte of PC to Internal Ram (Use IRAM_IW to store stack above 128 bytes)
1820587   tmpSP++;                           // ""
1821   SFR_W(SP,tmpSP);                     // ""
1822    if (tmpSP == R_SP)                     //Ensure it was able to write to new stack location
1823      IRAM_IW(tmpSP, (PC & 0xff));         //Store low byte of PC to Internal Ram (Use IRAM_IW to store stack above 128 bytes)
1824   tmpSP = R_SP;                        //Increment Stack Pointer
1825   tmpSP++;                           // ""
1826   SFR_W(SP,tmpSP);                     // ""
1827   if (tmpSP == R_SP)                     //Ensure it was able to write to new stack location
1828      IRAM_IW(tmpSP, ( (PC & 0xff00) >> 8));   //Store hi byte of PC to next address in Internal Ram (Use IRAM_IW to store stack above 128 bytes)
588   SP = tmpSP;                        // ""
589   IRAM_IW(tmpSP, ( (PC & 0xff00) >> 8));      //Store hi byte of PC to next address in Internal Ram (Use IRAM_IW to store stack above 128 bytes)
1829590}
1830591
1831592/*Pop the current PC off the stack and into the pc*/
1832INLINE void pop_pc()
593INLINE void pop_pc(void)
1833594{
1834   UINT8 tmpSP = R_SP;                     //Grab Stack Pointer
1835   PC = (IRAM_IR(tmpSP) & 0xff) << 8;         //Store hi byte to PC (must use IRAM_IR to access stack pointing above 128 bytes)
1836   tmpSP = R_SP-1;                        //Decrement Stack Pointer
1837   SFR_W(SP,tmpSP);                     // ""
1838   if (tmpSP == R_SP)                     //Ensure it was able to write to new stack location
1839      PC = PC | IRAM_IR(tmpSP);            //Store lo byte to PC (must use IRAM_IR to access stack pointing above 128 bytes)
1840   SFR_W(SP,tmpSP-1);                     //Decrement Stack Pointer
595   UINT8 tmpSP = SP;                     //Grab Stack Pointer
596   PC = (IRAM_IR(tmpSP--) & 0xff) << 8;      //Store hi byte to PC (must use IRAM_IR to access stack pointing above 128 bytes)
597   PC = PC | IRAM_IR(tmpSP--);               //Store lo byte to PC (must use IRAM_IR to access stack pointing above 128 bytes)
598   SP = tmpSP;                        //Decrement Stack Pointer
599   change_pc(PC);
1841600}
1842601
1843602//Set the PSW Parity Flag
1844INLINE void set_parity()
603INLINE void set_parity(void)
1845604{
1846605   //This flag will be set when the accumulator contains an odd # of bits set..
1847   int i,
1848   p = 0;
1849   for (i=1; i<=128; i=i*2) {      //Test for each of the 8 bits in the ACC!
1850      if ((R_ACC & i) != 0)
1851         p++;               //Keep track of how many bits are set
606   UINT8 p = 0;
607   int i;
608   UINT8 a = ACC;
609
610   for (i=0; i<8; i++) {      //Test for each of the 8 bits in the ACC!
611      p ^= (a & 1);
612      a = (a >> 1);
1852613   }
1853614
1854   //Update the PSW Pairty bit
1855615   SET_P(p & 1);
1856616}
1857617
1858static READ8_HANDLER(bit_address_r)
618INLINE UINT8 bit_address_r(UINT8 offset)
1859619{
1860   int   word;
1861   int   mask;
620   UINT8   word;
621   UINT8   mask;
1862622   int   bit_pos;
1863   int   base;      /* base of bit space or sfr */
1864623   int   distance;   /* distance between bit addressable words */
1865624               /* 1 for normal bits, 8 for sfr bit addresses */
1866625
1867   offset &= 0xff;
1868
1869626   //User defined bit addresses 0x20-0x2f (values are 0x0-0x7f)
1870627   if (offset < 0x80) {
1871      base = 0x20;
1872628      distance = 1;
629      word = ( (offset & 0x78) >> 3) * distance + 0x20;
630      bit_pos = offset & 0x7;
631      mask = (0x1 << bit_pos);
632      return((IRAM_R(word) & mask) >> bit_pos);
1873633   }
1874634   //SFR bit addressable registers
1875635   else {
1876      base = 0x80;
1877636      distance = 8;
637      word = ( (offset & 0x78) >> 3) * distance + 0x80;
638      bit_pos = offset & 0x7;
639      mask = (0x1 << bit_pos);
640      return ((IRAM_R(word) & mask) >> bit_pos);
1878641   }
1879   word = ( (offset & 0x78) >> 3) * distance + base;
1880   bit_pos = offset & 0x7;
1881   mask = 0x1 << bit_pos;
1882   return((IRAM_R(word) & mask) >> bit_pos);         //Do not use IRAM_IR
1883642}
1884643
1885644
1886static WRITE8_HANDLER(bit_address_w)
645INLINE void bit_address_w(UINT8 offset, UINT8 bit)
1887646{
1888647   int   word;
1889   int   mask;
648   UINT8   mask;
1890649   int   bit_pos;
1891   int   result;
1892   int   base;
650   UINT8   result;
1893651   int   distance;
1894652
1895   offset &= 0xff;
1896
1897   //User defined bit addresses 0x20-0x2f (values are 0x0-0x7f)
653   /* User defined bit addresses 0x20-0x2f (values are 0x0-0x7f) */
1898654   if (offset < 0x80) {
1899      base = 0x20;
1900655      distance = 1;
656      word = ((offset & 0x78) >> 3) * distance + 0x20;
657      bit_pos = offset & 0x7;
658      bit = (bit & 0x1) << bit_pos;
659      mask = ~(1 << bit_pos) & 0xff;
660      result = IRAM_R(word) & mask;
661      result = result | bit;
662      IRAM_W(word, result);
1901663   }
1902   //SFR bit addressable registers
664   /* SFR bit addressable registers */
1903665   else {
1904      base = 0x80;
1905666      distance = 8;
667      word = ((offset & 0x78) >> 3) * distance + 0x80;
668      bit_pos = offset & 0x7;
669      bit = (bit & 0x1) << bit_pos;
670      mask = ~(1 << bit_pos) & 0xff;
671      result = IRAM_R(word) & mask;
672      result = result | bit;
673      IRAM_W(word, result);
1906674   }
1907   word = ((offset & 0x78) >> 3) * distance + base;
1908   bit_pos = offset & 0x7;
1909   data = (data & 0x1) << bit_pos;
1910   mask = ~(1 << bit_pos) & 0xff;
1911   result = IRAM_R(word) & mask;   //Do not use IRAM_IR
1912   result = result | data;
1913   IRAM_W(word, result);         //Do not use IRAM_IW
1914675}
1915676
1916/* The following two handlers are used by the MAME Debugger Memory Window...
1917   By keeping these functions separate from the internally used IRAM_W/IRAM_R functions,
1918   we can manipulate and display internal memory in the debugger memory window in a layout
1919   that is not necessarily how the real memory is.. this will be especially useful for
1920   the 8052 chip where both the SFR and the upper 128 bytes of ram are mapped to the same
1921   address, so we can handle that here by mapping the sfr to a different address */
1922
1923READ8_HANDLER(i8051_internal_r)
1924{
1925   //Restrict internal ram to 256 Bytes max
1926   if(offset < 0x100)
1927      return IRAM_R(offset);
1928   else
1929      return 0;
1930}
1931WRITE8_HANDLER(i8051_internal_w)
1932{
1933   //Restrict internal ram to 256 Bytes max
1934   if(offset < 0x100)
1935      IRAM_W(offset,data);
1936}
1937
1938677INLINE void do_add_flags(UINT8 a, UINT8 data, UINT8 c)
1939678{
1940679   UINT16 result = a+data+c;
1941680   INT16 result1 = (INT8)a+(INT8)data+c;
1942   int cy, ac, ov;
1943681
1944   cy = (result & 0x100) >> 8;
682   SET_CY((result & 0x100) >> 8);
1945683   result = (a&0x0f)+(data&0x0f)+c;
1946   ac = (result & 0x10) >> 4;
1947   ov = (result1 < -128 || result1 > 127);
1948
1949   SET_CY(cy);
1950   SET_AC(ac);
1951   SET_OV(ov);
1952
1953//  mame_printf_debug("add: result=%x, c=%x, ac=%x, ov=%x\n",a+data+c,cy,ac,ov);
684   SET_AC((result & 0x10) >> 4);
685   SET_OV(result1 < -128 || result1 > 127);
1954686}
1955687
1956688INLINE void do_sub_flags(UINT8 a, UINT8 data, UINT8 c)
1957689{
1958690   UINT16 result = a-(data+c);
1959691   INT16 result1 = (INT8)a-(INT8)(data+c);
1960   int cy, ac, ov;
1961   cy = (result & 0x100) >> 8;
692
693   SET_CY((result & 0x100) >> 8);
1962694   result = (a&0x0f)-((data&0x0f)+c);
1963   ac = (result & 0x10) >> 4;
1964   ov = (result1 < -128 || result1 > 127);
1965   SET_CY(cy);
1966   SET_AC(ac);
1967   SET_OV(ov);
695   SET_AC((result & 0x10) >> 4);
696   SET_OV((result1 < -128 || result1 > 127));
697}
1968698
1969//  mame_printf_debug("sub: a=%x, d=%x, c=%x, result=%x, cy=%x, ac=%x, ov=%x\n",a,data,c,a-data-c,cy,ac,ov);
699INLINE void transmit_receive(int source)
700{
701   int mode = (GET_SM0<<1) | GET_SM1;
702
703   if (source == 1) /* timer1 */
704      mcs51.uart.smod_div = (mcs51.uart.smod_div + 1) & (2-GET_SMOD);
705
706   switch(mode) {
707      //8 bit shifter ( + start,stop bit ) - baud set by clock freq / 12
708      case 0:
709         mcs51.uart.rx_clk += (source == 0) ? 16 : 0; /* clock / 12 */
710         mcs51.uart.tx_clk += (source == 0) ? 16 : 0; /* clock / 12 */
711         break;
712      //8 bit uart ( + start,stop bit ) - baud set by timer1 or timer2
713      case 1:
714      case 3:
715         if (source == 1)
716         {
717            mcs51.uart.tx_clk += (GET_TCLK ? 0 : !mcs51.uart.smod_div);
718            mcs51.uart.rx_clk += (GET_RCLK ? 0 : !mcs51.uart.smod_div);
719         }
720         if (source == 2)
721         {
722            mcs51.uart.tx_clk += (GET_TCLK ? 1 : 0);
723            mcs51.uart.rx_clk += (GET_RCLK ? 1 : 0);
724         }
725         break;
726      //9 bit uart
727      case 2:
728         mcs51.uart.rx_clk += (source == 0) ? (GET_SMOD ? 6 : 3) : 0; /* clock / 12 * 3 / 8 (16) = clock / 32 (64)*/
729         mcs51.uart.tx_clk += (source == 0) ? (GET_SMOD ? 6 : 3) : 0; /* clock / 12 */
730         break;
731   }
732   /* transmit ? */
733   if (mcs51.uart.tx_clk >= 16)
734   {
735      mcs51.uart.tx_clk &= 0x0f;
736      if(mcs51.uart.bits_to_send)
737      {
738         mcs51.uart.bits_to_send--;
739         if(mcs51.uart.bits_to_send == 0) {
740            //printf("Here1 %d\n",  mcs51.uart.bits_to_send);
741            //Call the callback function
742            if(mcs51.serial_tx_callback)
743               mcs51.serial_tx_callback(mcs51.uart.data_out);
744            //Set Interrupt Flag
745            SET_TI(1);
746            //Note: we'll let the main loop catch the interrupt
747         }
748      }
749
750   }
751   /* receive */
752   if (mcs51.uart.rx_clk >= 16)
753   {
754      mcs51.uart.rx_clk &= 0x0f;
755      if (mcs51.uart.delay_cycles>0)
756      {
757         mcs51.uart.delay_cycles--;
758         if (mcs51.uart.delay_cycles == 0)
759         {
760            int data = 0;
761            //Call our callball function to retrieve the data
762            if(mcs51.serial_rx_callback)
763               data = mcs51.serial_rx_callback();
764            //printf("RX Deliver %d\n", data);
765            SET_SBUF(data);
766            //Flag the IRQ
767            SET_RI(1);
768         }
769      }
770   }
1970771}
1971772
1972INLINE void update_timer(int cyc)
773
774INLINE void update_timer_t0(int cycles)
1973775{
1974   //This code sucks, needs to be rewritten SJE
776   int mode = (GET_M0_1<<1) | GET_M0_0;
777   UINT32 count = 0;
1975778
1976   //Todo: Probably better to store the current mode of the timer on a write, so we don't waste time reading it.
779   if (GET_TR0)
780   {
781      UINT32 delta;
1977782
1978   //Note: Counting modes increment on 1 machine cycle (12 oscilator periods) - except Timer 2 in certain modes
783      /* counter / external input */
784      delta = GET_CT0 ? mcs51.t0_cnt : cycles;
785      /* taken, reset */
786      mcs51.t0_cnt = 0;
787      /* TODO: Not sure about IE0. The manual specifies INT0=high,
788         * which in turn means CLEAR_LINE.
789         * IE0 may be edge triggered depending on IT0 */
790      if (GET_GATE0 && !GET_IE0)
791         delta = 0;
1979792
1980   /* Update Timer 0 */
1981   if(GET_TR0) {
1982      //Determine Mode
1983      int mode = (GET_M0_1<<1) | GET_M0_0;
1984      UINT32 count = 0;
1985793      switch(mode) {
1986794         case 0:         /* 13 Bit Timer Mode */
1987            count = ((R_TH0<<5) | ( R_TL0 & 0x1F ) );
1988            /* Update the timer */
1989            /* Gate Bit Set? Timer only incremented if Int0 is set! */
1990            if(GET_GATE0 && GET_IE0)
1991               count += (cyc/12);
1992            /* Counter Mode? Only increment on 1-0 transition of the Port 3's T0 Line */
1993            if(GET_CT0)
1994            {
1995               /* Not supported */
1996            }
1997            /* Neither, regular timer mode */
1998            if(!GET_GATE0 && !GET_CT0)
1999               count += (cyc/12);
2000
2001            /*  Check for overflow */
2002            if ( count & 0xffffe000 )
2003            {
795            count = ((TH0<<5) | ( TL0 & 0x1f ) );
796            count += delta;
797            if ( count & 0xffffe000 ) /* Check for overflow */
2004798               SET_TF0(1);
2005            }
2006            /* Update new values of the counter */
2007            R_TH0 = (count>>5) & 0xff;
2008            R_TL0 = count & 0x1f;
799            TH0 = (count>>5) & 0xff;
800            TL0 =  count & 0x1f ;
2009801            break;
2010802         case 1:         /* 16 Bit Timer Mode */
2011            count = ((R_TH0<<8) | R_TL0);
2012            /* Update the timer */
2013            /* Gate Bit Set? Timer only incremented if Int0 is set! */
2014            if(GET_GATE0 && GET_IE0)
2015               count += (cyc/12);
2016            /* Counter Mode? Only increment on 1-0 transition of the Port 3's T0 Line */
2017            if(GET_CT0)
2018            {
2019               /* Not supported */
2020            }
2021            /* Neither, regular timer mode */
2022            if(!GET_GATE0 && !GET_CT0)
2023               count += (cyc/12);
2024
2025            /* Check for overflow */
2026            if ( count & 0xffff0000 )
2027            {
803            count = ((TH0<<8) | TL0);
804            count += delta;
805            if ( count & 0xffff0000 ) /* Check for overflow */
2028806               SET_TF0(1);
2029            }
2030            /* Update new values of the counter */
2031            R_TH0 = (count>>8) & 0xff;
2032            R_TL0 = count & 0xff;
807            TH0 = (count>>8) & 0xff;
808            TL0 = count & 0xff;
2033809            break;
2034810         case 2:         /* 8 Bit Autoreload */
2035            count = R_TL0;
2036            count += (cyc/12);
2037            /* Check for overflow */
2038            if ( count & 0xffffff00 )
811            count = (UINT32) TL0 + delta;
812            if ( count & 0xffffff00 )             /* Check for overflow */
2039813            {
2040814               SET_TF0(1);
2041               /* Reload timer */
2042               count += R_TH0;
815               count += TH0;                   /* Reload timer */
2043816            }
2044817            /* Update new values of the counter */
2045            R_TL0 = count & 0xff;
818            TL0 = count & 0xff;
2046819            break;
2047         case 3:         /* Split Timer */
820         case 3:
2048821            /* Split Timer 1 */
2049            count = R_TL0;
2050            count += (cyc/12);
2051            /* Check for overflow */
2052            if ( count & 0xffffff00 )
2053            {
822            count = (UINT16) TL0 + delta;
823            if ( count & 0xffffff00 )             /* Check for overflow */
2054824               SET_TF0(1);
2055            }
2056            /* Update new values of the counter */
2057            R_TL0 = count & 0xff;
2058
2059            /* Split Timer 2 */
2060            count = R_TH0;
2061            count += (cyc/12);
2062            /* Check for overflow */
2063            if ( count & 0xffffff00 )
2064            {
2065               SET_TF1(1);
2066            }
2067            /* Update new values of the counter */
2068            R_TH0 = count & 0xff;
825            TL0 = count & 0xff;                /* Update new values of the counter */
2069826            break;
2070827      }
2071828   }
829   if (GET_TR1)
830   {
831      switch(mode)
832      {
833      case 3:
834         /* Split Timer 2 */
835         count = (UINT16) TH0 + cycles;         /* No gate control or counting !*/
836         if ( count & 0xffffff00 )             /* Check for overflow */
837            SET_TF1(1);
838         TH0 = count & 0xff;                  /* Update new values of the counter */
839         break;
840      }
841   }
842}
2072843
2073   /* Update Timer 1 */
2074   if(GET_TR1) {
2075      /* Determine Mode */
2076      int mode = (GET_M1_1<<1) | GET_M1_0;
2077      UINT32 count = 0;
844INLINE void update_timer_t1(int cycles)
845{
846   int mode = (GET_M1_1<<1) | GET_M1_0;
847   UINT32 count = 0;
848
849   if (GET_TR1)
850   {
851      UINT32 delta;
852      int overflow = 0;
853
854      /* counter / external input */
855      delta = GET_CT1 ? mcs51.t1_cnt : cycles;
856      /* taken, reset */
857      mcs51.t1_cnt = 0;
858      /* TODO: Not sure about IE0. The manual specifies INT0=high,
859         * which in turn means CLEAR_LINE. Change to access last_state?
860         * IE0 may be edge triggered depending on IT0 */
861      if (GET_GATE1 && !GET_IE1)
862         delta = 0;
863
864      //printf("mode: %d\n", mode);
2078865      switch(mode) {
2079866         case 0:         /* 13 Bit Timer Mode */
2080            count = ((R_TH1<<5) | ( R_TL1 & 0x1F ) );
2081            /* Update the timer */
2082            /* Gate Bit Set? Timer only incremented if Int0 is set! */
2083            if(GET_GATE1 && GET_IE1)
2084               count += (cyc/12);
2085            /* Counter Mode? Only increment on 1-0 transition of the Port 3's T1 Line */
2086            if(GET_CT1)
2087            {
2088               /* Not supported */
2089            }
2090            /* Neither, regular timer mode */
2091            if(!GET_GATE1 && !GET_CT1)
2092               count += (cyc/12);
2093
2094            /*  Check for overflow */
2095            if ( count & 0xffffe000 )
2096            {
867            count = ((TH1<<5) | ( TL1 & 0x1f ) );
868            count += delta;
869            overflow = count & 0xffffe000; /* Check for overflow */
870            if ( overflow )
2097871               SET_TF1(1);
2098            }
2099            /* Update new values of the counter */
2100            R_TH1 = (count>>5) & 0xff;
2101            R_TL1 = count & 0x1f;
872            TH1 = (count>>5) & 0xff;
873            TL1 =  count & 0x1f ;
2102874            break;
2103875         case 1:         /* 16 Bit Timer Mode */
2104            count = ((R_TH1<<8) | R_TL1);
2105            /* Update the timer */
2106            /* Gate Bit Set? Timer only incremented if Int1 is set! */
2107            if(GET_GATE1 && GET_IE1)
2108               count += (cyc/12);
2109            /* Counter Mode? Only increment on 1-0 transition of the Port 3's T1 Line */
2110            if(GET_CT1)
876            count = ((TH1<<8) | TL1);
877            count += delta;
878            overflow = count & 0xffff0000; /* Check for overflow */
879            if ( overflow )
2111880            {
2112               /* Not supported */
2113            }
2114            /* Neither, regular timer mode */
2115            if(!GET_GATE1 && !GET_CT1)
2116               count += (cyc/12);
2117
2118            /* Check for overflow */
2119            if ( count & 0xffff0000 )
2120            {
2121               //TODO: Timer 1 can be set as Serial Baud Rate in the 8051 only... process bits here..
2122881               SET_TF1(1);
2123882            }
2124            /* Update new values of the counter */
2125            R_TH1 = (count>>8) & 0xff;
2126            R_TL1 = count & 0xff;
883            TH1 = (count>>8) & 0xff;
884            TL1 = count & 0xff;
2127885            break;
2128886         case 2:         /* 8 Bit Autoreload */
2129            count = R_TL1;
2130            count += (cyc/12);
2131            /* Check for overflow */
2132            if ( count & 0xffffff00 )
887            count = (UINT32) TL1 + delta;
888            overflow = count & 0xffffff00; /* Check for overflow */
889            if ( overflow )
2133890            {
2134891               SET_TF1(1);
2135               /* Reload timer */
2136               count += R_TH1;
892               count += TH1;                   /* Reload timer */
2137893            }
2138894            /* Update new values of the counter */
2139            R_TL1 = count & 0xff;
895            TL1 = count & 0xff;
2140896            break;
897         case 3:
898            /* do nothing */
899            break;
2141900      }
901      if (overflow)
902         transmit_receive(1);
2142903   }
904}
2143905
2144#if (HAS_I8052 || HAS_I8752)
906INLINE void update_timer_t2(int cycles)
907{
2145908   /* Update Timer 2 */
2146909   if(GET_TR2) {
2147      UINT32 count = ((R_TH2<<8) | R_TL2);
910      int mode = ((GET_TCLK | GET_RCLK) << 1) | GET_CP;
911      int delta = GET_CT2 ? mcs51.t2_cnt : (mode & 2) ? cycles * (12/2) : cycles;
2148912
2149      /* Are we in counter mode? */
2150      if(GET_CT2)
2151      {
2152         /* Not supported */
2153      }
2154      /* Are we in timer mode? */
2155      else
2156      {
2157         /* 16 Bit Timer Mode */
2158         /* Timer 2 Used as Baud Generator? (For now, only *same* send/receive rates supported) */
2159         if(GET_TCLK || GET_RCLK)
2160            count += cyc/2;                  /* Timer increments every cycles/2 in baud mode */
2161         else
2162         /* REGULAR TIMER - */
2163            count += cyc/12;               /* Timer increments every cycles/12 in normal mode */
913      UINT32 count = ((TH2<<8) | TL2) + delta;
914      mcs51.t2_cnt = 0;
2164915
2165         /* Check for overflow */
2166         if ( count & 0xffff0000 )
2167         {
2168            /* Set Interrupt flag *unless* used as baud generator */
2169            if(!GET_TCLK && !GET_RCLK)
916      switch (mode)
917      {
918         case 0:   /* 16 Bit Auto Reload */
919            if ( count & 0xffff0000 )
2170920            {
2171921               SET_TF2(1);
922               count += ((RCAP2H<<8) | RCAP2L);
2172923            }
2173            else
924            else if (GET_EXEN2 && mcs51.t2ex_cnt>0)
2174925            {
2175               /* Update bits sent if sending & bits left to send! */
2176               if(uart.sending && uart.bits_to_send && uart.timerbaud)
2177                  uart.bits_to_send-=1;
926               count += ((RCAP2H<<8) | RCAP2L);
927               mcs51.t2ex_cnt = 0;
2178928            }
2179            /* Auto reload? */
2180            if(!GET_CP)
2181               count += ((R_RCAP2H<<8) | R_RCAP2L);
2182         }
2183         /* Update new values of the counter */
2184         R_TH2 = (count>>8) & 0xff;
2185         R_TL2 = count & 0xff;
929            TH2 = (count>>8) & 0xff;
930            TL2 =  count & 0xff;
931            break;
932         case 1: /* 16 Bit Capture */
933            if ( count & 0xffff0000 )
934               SET_TF2(1);
935            TH2 = (count>>8) & 0xff;
936            TL2 =  count & 0xff;
937
938            if (GET_EXEN2 && mcs51.t2ex_cnt>0)
939            {
940               RCAP2H = TH2;
941               RCAP2L = TL2;
942               mcs51.t2ex_cnt = 0;
943            }
944            break;
945         case 2:
946         case 3:   /* Baud rate */
947            if ( count & 0xffff0000 )
948            {
949               count += ((RCAP2H<<8) | RCAP2L);
950               transmit_receive(2);
951            }
952            TH2 = (count>>8) & 0xff;
953            TL2 =  count & 0xff;
954            break;
2186955      }
2187956   }
2188#endif
2189957}
2190958
959INLINE void update_timers(int cycles)
960{
961   if (cycles == 0)
962      return; /* nothing to do */
963   /* Update Timer 0 */
964   update_timer_t0(cycles);
965   update_timer_t1(cycles);
966
967   if (mcs51.features & FEATURE_I8052_UART)
968   {
969      update_timer_t2(cycles);
970   }
971}
972
2191973//Set up to transmit data out of serial port
2192974//NOTE: Enable Serial Port Interrupt bit is NOT required to send/receive data!
975
2193976INLINE void serial_transmit(UINT8 data)
2194977{
2195978   int mode = (GET_SM0<<1) | GET_SM1;
2196979
2197980   //Flag that we're sending data
2198   uart.sending = 1;
2199   uart.data_out = data;
981   mcs51.uart.data_out = data;
982   //printf("serial_tansmit: %x %x\n", mode, data);
2200983   switch(mode) {
2201984      //8 bit shifter ( + start,stop bit ) - baud set by clock freq / 12
2202985      case 0:
2203         uart.timerbaud = 0;
2204         uart.bitcycles = 0;
2205         uart.bits_to_send = 8+2;
986         mcs51.uart.bits_to_send = 8+2;
2206987         break;
2207988      //8 bit uart ( + start,stop bit ) - baud set by timer1 or timer2
2208989      case 1:
2209         uart.timerbaud = 1;
2210         uart.bits_to_send = 8+2;
990         mcs51.uart.bits_to_send = 8+2;
2211991         break;
2212992      //9 bit uart
2213993      case 2:
2214994      case 3:
2215         LOG(("Serial mode 2 & 3 not supported in i8051!\n"));
995         LOG(("Serial mode %d not supported in mcs51!\n", mode));
2216996         break;
2217997   }
2218998}
2219999
1000INLINE void serial_receive(void)
1001{
1002   int mode = (GET_SM0<<1) | GET_SM1;
1003
1004   if(GET_ES && GET_REN) {
1005      switch(mode) {
1006         //8 bit shifter ( + start,stop bit ) - baud set by clock freq / 12
1007         case 0:
1008            mcs51.uart.delay_cycles = 8+2;
1009            break;
1010         //8 bit uart ( + start,stop bit ) - baud set by timer1 or timer2
1011         case 1:
1012            mcs51.uart.delay_cycles = 8+2;
1013            break;
1014         //9 bit uart
1015         case 2:
1016         case 3:
1017            LOG(("Serial mode %d not supported in mcs51!\n", mode));
1018            break;
1019      }
1020   }
1021}
1022
22201023//Check and update status of serial port
2221INLINE void   update_serial(int cyc)
1024INLINE void   update_serial(int cycles)
22221025{
2223   //Any bits left to send?
2224   if(uart.bits_to_send) {
2225      //Timer Generated baud?
2226      if(uart.timerbaud) {
2227         //Let Timer overflow handle removing bits
1026   while (--cycles>=0)
1027      transmit_receive(0);
1028}
1029
1030/***************************************************************************
1031    CALLBACKS - TODO: Remove
1032***************************************************************************/
1033
1034
1035void i8051_set_serial_tx_callback(void (*callback)(int data))
1036{
1037   //Hold in static variable since this function can get called before reset has run, which wipes i8051 memory clean
1038   hold_serial_tx_callback = callback;
1039}
1040
1041void i8051_set_serial_rx_callback(int (*callback)(void))
1042{
1043   //Hold in static variable since this function can get called before reset has run, which wipes i8051 memory clean
1044   hold_serial_rx_callback = callback;
1045}
1046
1047/***************************************************************************
1048    OPCODES
1049***************************************************************************/
1050
1051#include "i8051ops.c"
1052
1053
1054static void execute_op(UINT8 op)
1055{
1056   if (mcs51.recalc_parity)
1057   {
1058      set_parity();
1059      mcs51.recalc_parity = 0;
1060   }
1061
1062   switch( op )
1063   {
1064
1065      case 0x00:   nop();                     break;   //NOP
1066      case 0x01:   ajmp(op);                  break;   //AJMP code addr
1067      case 0x02:   ljmp();                     break;   //LJMP code addr
1068      case 0x03:   rr_a();                     break;   //RR A
1069      case 0x04:   inc_a();                  break;   //INC A
1070      case 0x05:   RWM=1; inc_mem(); RWM=0;      break;   //INC data addr
1071
1072      case 0x06:
1073      case 0x07:   inc_ir(op&1);               break;   //INC @R0/@R1
1074
1075      case 0x08:
1076      case 0x09:
1077      case 0x0a:
1078      case 0x0b:
1079      case 0x0c:
1080      case 0x0d:
1081      case 0x0e:
1082      case 0x0f:   inc_r(op&7);               break;   //INC R0 to R7
1083
1084      case 0x10:   RWM=1; jbc(); RWM=0;          break;    //JBC bit addr, code addr
1085      case 0x11:    acall(op);                  break;   //ACALL code addr
1086      case 0x12:   lcall();                   break;   //LCALL code addr
1087      case 0x13:   rrc_a();                  break;   //RRC A
1088      case 0x14:   dec_a();                  break;   //DEC A
1089      case 0x15:   RWM=1; dec_mem(); RWM=0;      break;   //DEC data addr
1090
1091      case 0x16:
1092      case 0x17:   dec_ir(op&1);                break;   //DEC @R0/@R1
1093
1094      case 0x18:
1095      case 0x19:
1096      case 0x1a:
1097      case 0x1b:
1098      case 0x1c:
1099      case 0x1d:
1100      case 0x1e:
1101      case 0x1f:   dec_r(op&7);                break;   //DEC R0 to R7
1102
1103      case 0x20:   jb();                     break;   //JB  bit addr, code addr
1104      case 0x21:   ajmp(op);                  break;   //AJMP code addr
1105      case 0x22:   ret();                     break;   //RET
1106      case 0x23:   rl_a();                     break;   //RL A
1107      case 0x24:   add_a_byte();               break;   //ADD A, #data
1108      case 0x25:   add_a_mem();               break;   //ADD A, data addr
1109
1110      case 0x26:
1111      case 0x27:   add_a_ir(op&1);               break;   //ADD A, @R0/@R1
1112
1113      case 0x28:
1114      case 0x29:
1115      case 0x2a:
1116      case 0x2b:
1117      case 0x2c:
1118      case 0x2d:
1119      case 0x2e:
1120      case 0x2f:   add_a_r(op&7);               break;   //ADD A, R0 to R7
1121
1122      case 0x30:   jnb();                     break;   //JNB bit addr, code addr
1123      case 0x31:   acall(op);                  break;   //ACALL code addr
1124      case 0x32:   reti();                     break;   //RETI
1125      case 0x33:   rlc_a();                  break;   //RLC A
1126      case 0x34:   addc_a_byte();               break;   //ADDC A, #data
1127      case 0x35:   addc_a_mem();               break;   //ADDC A, data addr
1128
1129      case 0x36:
1130      case 0x37:  addc_a_ir(op&1);            break;   //ADDC A, @R0/@R1
1131
1132      case 0x38:
1133      case 0x39:
1134      case 0x3a:
1135      case 0x3b:
1136      case 0x3c:
1137      case 0x3d:
1138      case 0x3e:
1139      case 0x3f:   addc_a_r(op&7);               break;   //ADDC A, R0 to R7
1140
1141      case 0x40:   jc();                     break;   //JC code addr
1142      case 0x41:   ajmp(op);                  break;   //AJMP code addr
1143      case 0x42:   RWM=1; orl_mem_a();   RWM=0;      break;   //ORL data addr, A
1144      case 0x43:   RWM=1; orl_mem_byte(); RWM=0;   break;   //ORL data addr, #data
1145      case 0x44:   orl_a_byte();               break;
1146      case 0x45:   orl_a_mem();               break;   //ORL A, data addr
1147
1148      case 0x46:
1149      case 0x47:   orl_a_ir(op&1);             break;   //ORL A, @RO/@R1
1150
1151      case 0x48:
1152      case 0x49:
1153      case 0x4a:
1154      case 0x4b:
1155      case 0x4c:
1156      case 0x4d:
1157      case 0x4e:
1158      case 0x4f:    orl_a_r(op&7);                break;   //ORL A, RO to R7
1159
1160      case 0x50:   jnc();                      break;   //JNC code addr
1161      case 0x51:  acall(op);                  break;   //ACALL code addr
1162      case 0x52:   RWM=1; anl_mem_a(); RWM=0;      break;   //ANL data addr, A
1163      case 0x53:   RWM=1; anl_mem_byte(); RWM=0;   break;   //ANL data addr, #data
1164      case 0x54:   anl_a_byte();               break;   //ANL A, #data
1165      case 0x55:   anl_a_mem();               break;   //ANL A, data addr
1166
1167      case 0x56:
1168      case 0x57:   anl_a_ir(op&1);               break;   //ANL A, @RO/@R1
1169
1170      case 0x58:
1171      case 0x59:
1172      case 0x5a:
1173      case 0x5b:
1174      case 0x5c:
1175      case 0x5d:
1176      case 0x5e:
1177      case 0x5f:   anl_a_r(op&7);               break;   //ANL A, RO to R7
1178
1179      case 0x60:   jz();                     break;   //JZ code addr
1180      case 0x61:   ajmp(op);                   break;   //AJMP code addr
1181      case 0x62:   RWM=1; xrl_mem_a(); RWM=0;      break;   //XRL data addr, A
1182      case 0x63:   RWM=1; xrl_mem_byte(); RWM=0;   break;   //XRL data addr, #data
1183      case 0x64:   xrl_a_byte();               break;   //XRL A, #data
1184      case 0x65:   xrl_a_mem();               break;   //XRL A, data addr
1185
1186      case 0x66:
1187      case 0x67:   xrl_a_ir(op&1);               break;   //XRL A, @R0/@R1
1188
1189      case 0x68:
1190      case 0x69:
1191      case 0x6a:
1192      case 0x6b:
1193      case 0x6c:
1194      case 0x6d:
1195      case 0x6e:
1196      case 0x6f:   xrl_a_r(op&7);               break;   //XRL A, R0 to R7
1197
1198      case 0x70:   jnz();                     break;   //JNZ code addr
1199      case 0x71:   acall(op);                  break;   //ACALL code addr
1200      case 0x72:   orl_c_bitaddr();            break;   //ORL C, bit addr
1201      case 0x73:   jmp_iadptr();               break;   //JMP @A+DPTR
1202      case 0x74:   mov_a_byte();               break;   //MOV A, #data
1203      case 0x75:   mov_mem_byte();               break;   //MOV data addr, #data
1204
1205      case 0x76:
1206      case 0x77:   mov_ir_byte(op&1);            break;   //MOV @R0/@R1, #data
1207
1208      case 0x78:
1209      case 0x79:
1210      case 0x7a:
1211      case 0x7b:
1212      case 0x7c:
1213      case 0x7d:
1214      case 0x7e:
1215      case 0x7f:   mov_r_byte(op&7);            break;   //MOV R0 to R7, #data
1216
1217      case 0x80:   sjmp();                     break;   //SJMP code addr
1218      case 0x81:   ajmp(op);                  break;   //AJMP code addr
1219      case 0x82:   anl_c_bitaddr();            break;   //ANL C, bit addr
1220      case 0x83:   movc_a_iapc();               break;   //MOVC A, @A + PC
1221      case 0x84:   div_ab();                  break;   //DIV AB
1222      case 0x85:   mov_mem_mem();               break;   //MOV data addr, data addr
1223
1224      case 0x86:
1225      case 0x87:   mov_mem_ir(op&1);            break;   //MOV data addr, @R0/@R1
1226
1227      case 0x88:
1228      case 0x89:
1229      case 0x8a:
1230      case 0x8b:
1231      case 0x8c:
1232      case 0x8d:
1233      case 0x8e:
1234      case 0x8f:   mov_mem_r(op&7);            break;   //MOV data addr,R0 to R7
1235
1236      case 0x90:   mov_dptr_byte();            break;   //MOV DPTR, #data
1237      case 0x91:   acall(op);                  break;   //ACALL code addr
1238      case 0x92:   RWM = 1; mov_bitaddr_c(); RWM = 0; break;   //MOV bit addr, C
1239      case 0x93:   movc_a_iadptr();            break;   //MOVC A, @A + DPTR
1240      case 0x94:   subb_a_byte();               break;   //SUBB A, #data
1241      case 0x95:   subb_a_mem();               break;   //SUBB A, data addr
1242
1243      case 0x96:
1244      case 0x97:   subb_a_ir(op&1);            break;   //SUBB A, @R0/@R1
1245
1246      case 0x98:
1247      case 0x99:
1248      case 0x9a:
1249      case 0x9b:
1250      case 0x9c:
1251      case 0x9d:
1252      case 0x9e:
1253      case 0x9f:   subb_a_r(op&7);               break;   //SUBB A, R0 to R7
1254
1255      case 0xa0:   orl_c_nbitaddr();            break;   //ORL C, /bit addr
1256      case 0xa1:   ajmp(op);                  break;   //AJMP code addr
1257      case 0xa2:   mov_c_bitaddr();            break;   //MOV C, bit addr
1258      case 0xa3:   inc_dptr();                  break;   //INC DPTR
1259      case 0xa4:   mul_ab();                  break;   //MUL AB
1260      case 0xa5:   illegal(op);               break;   //reserved
1261
1262      case 0xa6:
1263      case 0xa7:   mov_ir_mem(op&1);            break;   //MOV @R0/@R1, data addr
1264
1265      case 0xa8:
1266      case 0xa9:
1267      case 0xaa:
1268      case 0xab:
1269      case 0xac:
1270      case 0xad:
1271      case 0xae:
1272      case 0xaf:   mov_r_mem(op&7);            break;   //MOV R0 to R7, data addr
1273
1274      case 0xb0:   anl_c_nbitaddr();            break;   //ANL C,/bit addr
1275      case 0xb1:   acall(op);                  break;   //ACALL code addr
1276      case 0xb2:   RWM=1; cpl_bitaddr(); RWM=0;    break;   //CPL bit addr
1277      case 0xb3:   cpl_c();                  break;   //CPL C
1278      case 0xb4:   cjne_a_byte();               break;   //CJNE A, #data, code addr
1279      case 0xb5:   cjne_a_mem();               break;   //CJNE A, data addr, code addr
1280
1281      case 0xb6:
1282      case 0xb7:   cjne_ir_byte(op&1);          break;   //CJNE @R0/@R1, #data, code addr
1283
1284      case 0xb8:
1285      case 0xb9:
1286      case 0xba:
1287      case 0xbb:
1288      case 0xbc:
1289      case 0xbd:
1290      case 0xbe:
1291      case 0xbf:   cjne_r_byte(op&7);             break;   //CJNE R0 to R7, #data, code addr
1292
1293      case 0xc0:   push();                     break;   //PUSH data addr
1294      case 0xc1:   ajmp(op);                  break;   //AJMP code addr
1295      case 0xc2:   RWM=1; clr_bitaddr(); RWM=0;   break;   //CLR bit addr
1296      case 0xc3:   clr_c();                   break;   //CLR C
1297      case 0xc4:   swap_a();                  break;   //SWAP A
1298      case 0xc5:   xch_a_mem();               break;   //XCH A, data addr
1299
1300      case 0xc6:
1301      case 0xc7:  xch_a_ir(op&1);               break;   //XCH A, @RO/@R1
1302
1303      case 0xc8:
1304      case 0xc9:
1305      case 0xca:
1306      case 0xcb:
1307      case 0xcc:
1308      case 0xcd:
1309      case 0xce:
1310      case 0xcf:   xch_a_r(op&7);               break;   //XCH A, RO to R7
1311
1312      case 0xd0:   pop();                     break;   //POP data addr
1313      case 0xd1:   acall(op);                  break;   //ACALL code addr
1314      case 0xd2:   RWM=1; setb_bitaddr(); RWM=0;   break;   //SETB bit addr
1315      case 0xd3:   setb_c();                  break;   //SETB C
1316      case 0xd4:   da_a();                   break;   //DA A
1317      case 0xd5:   RWM=1; djnz_mem(); RWM=0;      break;   //DJNZ data addr, code addr
1318
1319      case 0xd6:
1320      case 0xd7:  xchd_a_ir(op&1);            break;   //XCHD A, @R0/@R1
1321
1322      case 0xd8:
1323      case 0xd9:
1324      case 0xda:
1325      case 0xdb:
1326      case 0xdc:
1327      case 0xdd:
1328      case 0xde:
1329      case 0xdf:   djnz_r(op&7);               break;   //DJNZ R0 to R7,code addr
1330
1331      case 0xe0:   movx_a_idptr();               break;   //MOVX A,@DPTR
1332      case 0xe1:   ajmp(op);                  break;   //AJMP code addr
1333
1334      case 0xe2:
1335      case 0xe3:   movx_a_ir(op&1);            break;   //MOVX A, @R0/@R1
1336
1337      case 0xe4:   clr_a();                  break;   //CLR A
1338      case 0xe5:   mov_a_mem();               break;   //MOV A, data addr
1339      case 0xe6:
1340      case 0xe7:   mov_a_ir(op&1);               break;   //MOV A,@RO/@R1
1341
1342      case 0xe8:
1343      case 0xe9:
1344      case 0xea:
1345      case 0xeb:
1346      case 0xec:
1347      case 0xed:
1348      case 0xee:
1349      case 0xef:   mov_a_r(op&7);               break;   //MOV A,R0 to R7
1350
1351      case 0xf0:   movx_idptr_a();               break;   //MOVX @DPTR,A
1352      case 0xf1:   acall(op);                  break;   //ACALL code addr
1353
1354      case 0xf2:
1355      case 0xf3:   movx_ir_a(op&1);            break;   //MOVX @R0/@R1,A
1356
1357      case 0xf4:   cpl_a();                  break;   //CPL A
1358      case 0xf5:   mov_mem_a();               break;   //MOV data addr, A
1359
1360      case 0xf6:
1361      case 0xf7:   mov_ir_a(op&1);               break;   //MOV @R0/@R1, A
1362
1363      case 0xf8:
1364      case 0xf9:
1365      case 0xfa:
1366      case 0xfb:
1367      case 0xfc:
1368      case 0xfd:
1369      case 0xfe:
1370      case 0xff:   mov_r_a(op&7);               break;   //MOV R0 to R7, A
1371      default:
1372         illegal(op);
1373   }
1374}
1375
1376/***************************************************************************
1377    OPCODE CYCLES
1378***************************************************************************/
1379
1380/* # of oscilations each opcode requires*/
1381static const UINT8 mcs51_cycles[] = {
1382   1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,
1383   2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,
1384   2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,
1385   2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,
1386   2,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,
1387   2,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,
1388   2,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,
1389   2,2,2,2,1,2,1,1,1,1,1,1,1,1,1,1,
1390   2,2,2,2,4,2,2,2,2,2,2,2,2,2,2,2,
1391   2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,
1392   2,2,1,2,4,1,2,2,2,2,2,2,2,2,2,2,
1393   2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,
1394   2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1395   2,2,1,1,1,2,1,1,2,2,2,2,2,2,2,2,
1396   2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,
1397   2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1
1398};
1399
1400/***********************************************************************************
1401 Check for pending Interrupts and process - returns # of cycles used for the int
1402
1403 Note about priority & interrupting interrupts..
1404 1) A high priority interrupt cannot be interrupted by anything!
1405 2) A low priority interrupt can ONLY be interrupted by a high priority interrupt
1406 3) If more than 1 Interrupt Flag is set (ie, 2 simultaneous requests occur),
1407    the following logic works as follows:
1408    1) If two requests come in of different priority levels, the higher one is selected..
1409    2) If the requests are of the same level, an internal order is used:
1410        a) IEO
1411        b) TFO
1412        c) IE1
1413        d) TF1
1414        e) RI+TI
1415        f) TF2+EXF2
1416 **********************************************************************************/
1417static void check_irqs(void)
1418{
1419   UINT8 ints = (GET_IE0 | (GET_TF0<<1) | (GET_IE1<<2) | (GET_TF1<<3)
1420         | ((GET_RI|GET_TI)<<4));
1421   UINT8 ip = IP;
1422   UINT8 int_vec = 0;
1423   UINT8 priority_request = 0;
1424   int i;
1425
1426   //If All Inerrupts Disabled or no pending abort..
1427   if(!GET_EA)   return;
1428
1429   if (mcs51.features & FEATURE_I8052_UART)
1430      ints |= ((GET_TF2|GET_EXF2)<<5);
1431
1432   /* mask out interrupts not enabled */
1433   ints &= IE;
1434
1435   if (!ints)   return;
1436
1437   if(mcs51.irq_priority)
1438   {
1439      LOG(("high priority irq in progress, skipping irq request\n"));
1440      return;
1441   }
1442
1443   for (i=0; i<mcs51.num_interrupts; i++)
1444   {
1445      if (ints & (1<<i))
1446      {
1447         int_vec = (i<<3) | 3;
1448         priority_request = (ip & (1<<i));
1449         if (priority_request)
1450            break;
22281451      }
2229      else {
2230         //Oscillator Based baud rate = Osc/12 baud rate, however it also means 1 bit = 12 cycles.
2231         uart.bitcycles+=cyc;
2232         if(uart.bitcycles > 11)   {
2233            int bits_sent = uart.bitcycles / 12;
2234            int diff = uart.bitcycles % 12;
2235            //don't allow more bits sent than ready to send
2236            if(bits_sent > uart.bits_to_send) {
2237               bits_sent = uart.bits_to_send;
2238               diff = 0;
1452   }
1453
1454   //Skip the interrupt request if currently processing is lo priority, and the new request IS NOT HI PRIORITY!
1455   if(mcs51.cur_irq < 0xff && !priority_request)
1456   {
1457      LOG(("low priority irq in progress already, skipping low irq request\n"));
1458      return;
1459   }
1460
1461    //Save current pc to stack, set pc to new interrupt vector
1462   push_pc();
1463   PC = int_vec;
1464   change_pc(PC);
1465
1466   /* interrupts take 24 cycles */
1467   mcs51.inst_cycles += 2;
1468
1469   //Set current Irq & Priority being serviced
1470   mcs51.cur_irq = int_vec;
1471   mcs51.irq_priority = priority_request;
1472
1473   //Clear any interrupt flags that should be cleared since we're servicing the irq!
1474   switch(mcs51.cur_irq) {
1475      case V_IE0:
1476         //External Int Flag only cleared when configured as Edge Triggered..
1477         if(GET_IT0)  /* for some reason having this, breaks alving dmd games */
1478            SET_IE0(0);
1479
1480         /* indicate we took the external IRQ */
1481         if (mcs51.irq_callback != NULL)
1482            (*mcs51.irq_callback)(0);
1483
1484         break;
1485      case V_TF0:
1486         //Timer 0 - Always clear Flag
1487         SET_TF0(0);
1488         break;
1489      case V_IE1:
1490         //External Int Flag only cleared when configured as Edge Triggered..
1491         if(GET_IT1)  /* for some reason having this, breaks alving dmd games */
1492            SET_IE1(0);
1493         /* indicate we took the external IRQ */
1494         if (mcs51.irq_callback != NULL)
1495            (*mcs51.irq_callback)(1);
1496
1497         break;
1498      case V_TF1:
1499         //Timer 1 - Always clear Flag
1500         SET_TF1(0);
1501         break;
1502      case V_RITI:
1503         // no flags are cleared, TI and RI remain set until reset by software
1504         break;
1505      /* I8052 specific */
1506      case V_TF2:
1507         // no flags are cleared according to manual
1508         break;
1509   }
1510}
1511
1512INLINE void burn_cycles(int cycles)
1513{
1514   /* Update Timer (if any timers are running) */
1515   update_timers(cycles);
1516
1517   /* Update Serial (only for mode 0) */
1518   update_serial(cycles);
1519
1520   /* check_irqs */
1521   check_irqs();
1522}
1523
1524static void mcs51_set_irq_line(int irqline, int state)
1525{
1526   /* From the manual:
1527     *
1528     * <cite>In operatiom all the interrupt tlags are latched into the
1529     * interrupt control system during State 5 of every ma-
1530     * chine cycle. The samples are polled during the follow-
1531     * ing machine cycle.</cite>
1532     *
1533     * ==> Since we do not emulate substates, this assumes that the signal is present
1534     * for at least one cycle (12 states)
1535     *
1536     */
1537   int new_state = (mcs51.last_line_state & ~(1 << irqline)) | ((state != CLEAR_LINE) << irqline);
1538   /* detect 0->1 transistions */
1539   int tr_state = (~mcs51.last_line_state) & new_state;
1540
1541   switch( irqline )
1542   {
1543      //External Interrupt 0
1544      case I8051_INT0_LINE:
1545         //Line Asserted?
1546         if (state != CLEAR_LINE) {
1547            //Is the enable flag for this interrupt set?
1548            if (GET_EX0) {
1549               //Need cleared->active line transition? (Logical 1-0 Pulse on the line) - CLEAR->ASSERT Transition since INT0 active lo!
1550               if (GET_IT0) {
1551                  if (GET_BIT(tr_state, I8051_INT0_LINE))
1552                     SET_IE0(1);
1553               }
1554               else
1555                  SET_IE0(1);      //Nope, just set it..
22391556            }
2240            uart.bits_to_send-=bits_sent;
2241            uart.bitcycles = diff;
22421557         }
2243      }
1558         else
1559         {
1560            if (!GET_IT0) /* clear if level triggered */
1561               SET_IE0(0);
1562         }
1563
1564         break;
1565
1566      //External Interrupt 1
1567      case I8051_INT1_LINE:
1568
1569         //Line Asserted?
1570         if (state != CLEAR_LINE) {
1571            if(GET_EX1) {
1572               //Need cleared->active line transition? (Logical 1-0 Pulse on the line) - CLEAR->ASSERT Transition since INT1 active lo!
1573               if(GET_IT1){
1574                  if (GET_BIT(tr_state, I8051_INT1_LINE))
1575                     SET_IE1(1);
1576               }
1577               else
1578                  SET_IE1(1);      //Nope, just set it..
1579            }
1580         }
1581         else
1582         {
1583            if (!GET_IT1) /* clear if level triggered */
1584               SET_IE1(0);
1585         }
1586         break;
1587
1588      case MCS51_T0_LINE:
1589         if (GET_BIT(tr_state, MCS51_T0_LINE))
1590            mcs51.t0_cnt++;
1591         break;
1592
1593      case MCS51_T1_LINE:
1594         if (GET_BIT(tr_state, MCS51_T1_LINE))
1595            mcs51.t1_cnt++;
1596         break;
1597
1598      case MCS51_T2_LINE:
1599         if (mcs51.features & FEATURE_I8052_UART)
1600         {
1601            if (GET_BIT(tr_state, MCS51_T2_LINE))
1602               mcs51.t2_cnt++;
1603         }
1604         else
1605            fatalerror("mcs51: Trying to set T2_LINE on a non I8052 type cpu.\n");
1606         break;
1607
1608      case MCS51_T2EX_LINE:
1609         if (mcs51.features & FEATURE_I8052_UART)
1610         {
1611            if (GET_TR2 && GET_EXEN2)
1612               if (GET_BIT(tr_state, MCS51_T2EX_LINE))
1613               {
1614                  SET_EXF2(1);
1615                  mcs51.t2ex_cnt++;
1616               }
1617         }
1618         else
1619            fatalerror("mcs51: Trying to set T2EX_LINE on a non I8052 type cpu.\n");
1620         break;
1621      //Serial Port Receive
1622      case I8051_RX_LINE:
1623         //Is the enable flags for this interrupt set?
1624         if (state != CLEAR_LINE)
1625         {
1626            serial_receive();
1627         }
1628         break;
22441629   }
2245   //If no bits left to send - flag the interrupt & call the callback
2246   if(!uart.bits_to_send) {
2247      //Clear sending flag
2248      uart.sending = 0;
2249      uart.bitcycles = 0;
2250      //Call the callback function
2251      if(i8051.serial_tx_callback)
2252         i8051.serial_tx_callback(uart.data_out);
2253      //Set Interrupt Flag
2254      SET_TI(1);
2255      //Note: we'll let the main loop catch the interrupt
2256   }
1630   mcs51.last_line_state = new_state;
22571631}
22581632
1633/* Execute cycles - returns number of cycles actually run */
1634static int mcs51_execute(int cycles)
1635{
1636   UINT8 op;
22591637
1638   mcs51_icount = cycles;
1639
1640   /* external interrupts may have been set since we last checked */
1641   mcs51.inst_cycles = 0;
1642   check_irqs();
1643   mcs51_icount -= mcs51.inst_cycles;
1644   burn_cycles(mcs51.inst_cycles);
1645
1646   do
1647   {
1648      /* Read next opcode */
1649      PPC = PC;
1650      debugger_instruction_hook(Machine, PC);
1651      op = cpu_readop(PC++);
1652
1653      /* process opcode and count cycles */
1654      mcs51.inst_cycles = mcs51_cycles[op];
1655      execute_op(op);
1656
1657      /* burn the cycles */
1658      mcs51_icount -= mcs51.inst_cycles;
1659      burn_cycles(mcs51.inst_cycles);
1660
1661   } while( mcs51_icount > 0 );
1662
1663   return cycles - mcs51_icount;
1664}
1665
1666
22601667/****************************************************************************
2261 * 8752 Section
1668 * MCS51/8051 Section
22621669 ****************************************************************************/
2263#if (HAS_I8052 || HAS_I8752)
2264void i8752_init (int index, int clock, const void *config, int (*irqcallback)(int))   { i8051_init(index, clock, config, irqcallback); }
2265void i8752_reset (void)
1670
1671static void mcs51_sfr_write(size_t offset, UINT8 data)
22661672{
2267   memset(&i8051, 0, sizeof(I8051));
2268   memset(&uart, 0, sizeof(I8051_UART));
2269   i8051.subtype = 8752;
1673   /* update register */
1674   assert(offset >= 0x80 && offset <= 0xff);
22701675
2271   //Set up 8052 specific internal read/write (indirect) handlers..
2272   i8051.iram_iread  = i8052_internal_ram_iread;
2273   i8051.iram_iwrite = i8052_internal_ram_iwrite;
1676   /* TODO: Move to memory map */
1677   switch (offset)
1678   {
1679      case ADDR_P0:   OUT(MCS51_PORT_P0,data);   break;
1680      case ADDR_P1:   OUT(MCS51_PORT_P1,data);   break;
1681      case ADDR_P2:   OUT(MCS51_PORT_P2,data);   break;
1682      case ADDR_P3:   OUT(MCS51_PORT_P3,data);   break;
1683      case ADDR_SBUF:   serial_transmit(data);      break;
1684      case ADDR_PSW:   SET_PARITY();            break;
1685      case ADDR_ACC:   SET_PARITY();            break;
1686      /* R_SBUF = data;        //This register is used only for "Receiving data coming in!" */
22741687
1688      case ADDR_B:
1689      case ADDR_IP:
1690      case ADDR_SP:
1691      case ADDR_DPL:
1692      case ADDR_DPH:
1693      case ADDR_PCON:
1694      case ADDR_TCON:
1695      case ADDR_TMOD:
1696      case ADDR_IE:
1697      case ADDR_TL0:
1698      case ADDR_TL1:
1699      case ADDR_TH0:
1700      case ADDR_TH1:
1701      case ADDR_SCON:
1702         break;
1703      default:
1704         LOG(("mcs51 #%d: attemping to write to an invalid/non-implemented SFR address: %zx at 0x%04x, data=%x\n", cpu_getactivecpu(), offset,PC,data));
1705         /* no write in this case according to manual */
1706         return;
1707   }
1708   data_write_byte_8le((size_t)offset | 0x100, data);
1709}
1710
1711static UINT8 mcs51_sfr_read(size_t offset)
1712{
1713   assert(offset >= 0x80 && offset <= 0xff);
1714
1715   switch (offset)
1716   {
1717      /* Read/Write/Modify operations read the port latch ! */
1718      /* Move to memory map */
1719      case ADDR_P0:    return RWM ? P0 : P0 & IN(MCS51_PORT_P0);
1720      case ADDR_P1:    return RWM ? P1 : P1 & IN(MCS51_PORT_P1);
1721      case ADDR_P2:    return RWM ? P2 : P2 & IN(MCS51_PORT_P2);
1722      case ADDR_P3:    return RWM ? P3 : P3 & IN(MCS51_PORT_P3);
1723
1724      case ADDR_PSW:
1725      case ADDR_ACC:
1726      case ADDR_B:
1727      case ADDR_SP:
1728      case ADDR_DPL:
1729      case ADDR_DPH:
1730      case ADDR_PCON:
1731      case ADDR_TCON:
1732      case ADDR_TMOD:
1733      case ADDR_TL0:
1734      case ADDR_TL1:
1735      case ADDR_TH0:
1736      case ADDR_TH1:
1737      case ADDR_SCON:
1738      case ADDR_SBUF:
1739      case ADDR_IE:
1740      case ADDR_IP:
1741         return data_read_byte_8le((size_t) offset | 0x100);
1742      /* Illegal or non-implemented sfr */
1743      default:
1744         LOG(("mcs51 #%d: attemping to read an invalid/non-implemented SFR address: %zx at 0x%04x\n", cpu_getactivecpu(), offset,PC));
1745         /* according to the manual, the read may return random bits */
1746         return 0xff;
1747   }
1748}
1749
1750
1751static void mcs51_init(int index, int clock, const void *config, int (*irqcallback)(int))
1752{
1753   mcs51.irq_callback = irqcallback;
1754
1755   mcs51.features = FEATURE_NONE;
1756   mcs51.ram_mask = 0x7F;           /* 128 bytes of ram */
1757   mcs51.num_interrupts = 5;         /* 5 interrupts */
1758   mcs51.sfr_read = mcs51_sfr_read;
1759   mcs51.sfr_write = mcs51_sfr_write;
1760
1761   /* Save states */
1762   state_save_register_item("mcs51", index, mcs51.ppc);
1763   state_save_register_item("mcs51", index, mcs51.pc);
1764   state_save_register_item("mcs51", index, mcs51.rwm );
1765   state_save_register_item("mcs51", index, mcs51.cur_irq );
1766   state_save_register_item("mcs51", index, mcs51.irq_priority );
1767   state_save_register_item("mcs51", index, mcs51.last_line_state );
1768   state_save_register_item("mcs51", index, mcs51.t0_cnt );
1769   state_save_register_item("mcs51", index, mcs51.t1_cnt );
1770   state_save_register_item("mcs51", index, mcs51.t2_cnt );
1771   state_save_register_item("mcs51", index, mcs51.t2ex_cnt );
1772   state_save_register_item("mcs51", index, mcs51.recalc_parity );
1773}
1774
1775static void i80c51_init(int index, int clock, const void *config, int (*irqcallback)(int))
1776{
1777   mcs51_init(index, clock, config, irqcallback);
1778
1779   mcs51.features |=    (FEATURE_CMOS_IDLE | FEATURE_CMOS_POWERDOWN);
1780}
1781
1782/* Reset registers to the initial values */
1783static void mcs51_reset(void)
1784{
1785   update_ptrs();
22751786   //Set up serial call back handlers
2276   i8051.serial_tx_callback = hold_serial_tx_callback;
1787   mcs51.serial_tx_callback = hold_serial_tx_callback;
22771788   hold_serial_tx_callback = NULL;
2278   i8051.serial_rx_callback = hold_serial_rx_callback;
1789   mcs51.serial_rx_callback = hold_serial_rx_callback;
22791790   hold_serial_rx_callback = NULL;
22801791
2281   //Setup External ram callback handlers
2282   i8051.eram_iaddr_callback = hold_eram_iaddr_callback;
2283   hold_eram_iaddr_callback = NULL;
1792   mcs51.last_line_state = 0;
1793   mcs51.t0_cnt = 0;
1794   mcs51.t1_cnt = 0;
1795   mcs51.t2_cnt = 0;
1796   mcs51.t2ex_cnt = 0;
22841797
2285   //Clear Ram (w/0xff)
2286   memset(&i8051.IntRam,0xff,sizeof(i8051.IntRam));
2287
22881798   /* these are all defined reset states */
22891799   PC = 0;
2290   SFR_W(SP, 0x7);
2291   SFR_W(PSW, 0);
2292   SFR_W(DPH, 0);
2293   SFR_W(DPL, 0);
2294   SFR_W(ACC, 0);
2295   SFR_W(B, 0);
2296   SFR_W(IP, 0);
2297   SFR_W(IE, 0);
2298   SFR_W(SCON, 0);
2299   SFR_W(TCON, 0);
2300   SFR_W(TMOD, 0);
2301   SFR_W(TH1, 0);
2302   SFR_W(TH0, 0);
2303   SFR_W(TL1, 0);
2304   SFR_W(TL0, 0);
2305   //8052 Only registers
2306   SFR_W(T2CON, 0);
2307   SFR_W(RCAP2L, 0);
2308   SFR_W(RCAP2H, 0);
2309   SFR_W(TL2, 0);
2310   SFR_W(TH2, 0);
2311
1800   SP = 0x7;
1801   SET_PSW(0);
1802   SET_ACC(0);
1803   DPH = 0;
1804   DPL = 0;
1805   B = 0;
1806   IP = 0;
1807   IE = 0;
1808   SCON = 0;
1809   TCON = 0;
1810   TMOD = 0;
1811   TH1 = 0;
1812   TH0 = 0;
1813   TL1 = 0;
1814   TL0 = 0;
23121815   /* set the port configurations to all 1's */
2313   SFR_W(P3, 0xff);
2314   SFR_W(P2, 0xff);
2315   SFR_W(P1, 0xff);
2316   SFR_W(P0, 0xff);
1816   SET_P3(0xff);
1817   SET_P2(0xff);
1818   SET_P1(0xff);
1819   SET_P0(0xff);
23171820
23181821   /* Flag as NO IRQ in Progress */
2319   CLEAR_CURRENT_IRQ
1822   CLEAR_CURRENT_IRQ();
23201823}
23211824
2322void i8752_exit   (void)                  { i8051_exit(); }
2323int   i8752_execute(int cycles)            { return i8051_execute(cycles); }
2324void i8752_get_context (void *dst)            { i8051_get_context(dst); }
2325void i8752_set_context (void *src)            { i8051_set_context(src); }
2326unsigned i8752_get_reg (int regnum)            { return i8051_get_reg(regnum); }
2327void i8752_set_reg (int regnum, unsigned val)         { i8051_set_reg(regnum,val); }
2328void i8752_set_irq_line(int irqline, int state)         { i8051_set_irq_line(irqline,state); }
2329void i8752_set_irq_callback(int (*callback)(int irqline))   { i8051_set_irq_callback(callback); }
2330void i8752_set_serial_tx_callback(void (*callback)(int data))   { i8051_set_serial_tx_callback(callback); }
2331void i8752_set_serial_rx_callback(int (*callback)(void))   { i8051_set_serial_rx_callback(callback); }
2332void i8752_state_save(void *file)            { i8051_state_save(file); }
2333void i8752_state_load(void *file)            { i8051_state_load(file); }
1825/* Shut down CPU core */
1826static void mcs51_exit(void)
1827{
1828   /* nothing to do */
1829}
23341830
2335/* The following two handlers are used by the MAME Debugger Memory Window...
2336   By keeping these functions separate from the internally used IRAM_W/IRAM_R functions,
2337   we can manipulate and display internal memory in the debugger memory window in a layout
2338   that is not necessarily how the real memory is.. this will be especially useful for
2339   the 8052 chip where both the SFR and the upper 128 bytes of ram are mapped to the same
2340   address, so we can handle that here by mapping the sfr to a different address */
1831/****************************************************************************
1832 * 8052 Section
1833 ****************************************************************************/
23411834
2342READ8_HANDLER(i8752_internal_r)
1835static void i8052_sfr_write(size_t offset, UINT8 data)
23431836{
2344   //USE INDIRECT READ TO ALLOW FULL 256 Bytes of RAM to show in the debugger
2345   if(offset < 0x100)
2346      return IRAM_IR(offset);
2347   else
2348   //MAP SFR registers starting at 256 (they are only 128 bytes in size)
2349   if(offset < 0x100+0x80)
2350      return SFR_R(offset-0x80);
2351   else
2352   //Everything else is 0 (and invalid)
2353      return 0;
1837   switch (offset)
1838   {
1839      /* 8052 family specific */
1840      case ADDR_T2CON:
1841      case ADDR_RCAP2L:
1842      case ADDR_RCAP2H:
1843      case ADDR_TL2:
1844      case ADDR_TH2:
1845         data_write_byte_8le((size_t) offset | 0x100, data);
1846         break;
1847
1848      default:
1849         mcs51_sfr_write(offset, data);
1850   }
23541851}
2355WRITE8_HANDLER(i8752_internal_w)
1852
1853static UINT8 i8052_sfr_read(size_t offset)
23561854{
2357   //USE INDIRECT WRITE TO ALLOW FULL 256 Bytes of RAM to show in the debugger
2358   if(offset < 0x100)
2359      IRAM_IW(offset,data);
2360   else
2361      if(offset < 0x100+0x80)
2362         SFR_W(offset-0x80,data);
1855   switch (offset)
1856   {
1857      /* 8052 family specific */
1858      case ADDR_T2CON:
1859      case ADDR_RCAP2L:
1860      case ADDR_RCAP2H:
1861      case ADDR_TL2:
1862      case ADDR_TH2:
1863         return data_read_byte_8le((size_t) offset | 0x100);
1864      default:
1865         return mcs51_sfr_read(offset);
1866   }
23631867}
23641868
2365/* Reads the contents of the Internal RAM memory INDIRECTLY  */
2366/* Anything above 0x7f is NOT sfr/register, but rather UPPER 128K OF INTERNAL RAM */
2367static READ8_HANDLER(i8052_internal_ram_iread)
1869static void i8052_init (int index, int clock, const void *config, int (*irqcallback)(int))
23681870{
2369   if (offset < 0x100)
2370      return i8051.IntRam[offset];
2371   else
2372      LOG(("i8051 #%d: attemping to read from an invalid Internal Ram address: %x at 0x%04x\n", cpu_getactivecpu(), offset,PC));
2373   return 0xff;
1871   mcs51_init(index, clock, config, irqcallback);
1872
1873   mcs51.ram_mask = 0xFF;           /* 256 bytes of ram */
1874   mcs51.num_interrupts = 6;         /* 6 interrupts */
1875
1876   mcs51.features |= FEATURE_I8052_UART;
1877   mcs51.sfr_read = i8052_sfr_read;
1878   mcs51.sfr_write = i8052_sfr_write;
23741879}
23751880
2376/* Writes the contents of the Internal RAM memory INDIRECTLY */
2377/* Anything above 0x7f is NOT sfr/register, but rather UPPER 128K OF INTERNAL RAM */
2378static WRITE8_HANDLER(i8052_internal_ram_iwrite)
1881static void i80c52_init(int index, int clock, const void *config, int (*irqcallback)(int))
23791882{
2380   data &= 0xff;            //Ensure it's only 8 bits
2381   if (offset < 0x100)
2382      i8051.IntRam[offset] = data;
2383   else
2384      LOG(("i8051 #%d: attemping to write to an invalid Internal Ram address: %x at 0x%04x\n", cpu_getactivecpu(), offset,PC));
1883   i8052_init(index, clock, config, irqcallback);
1884
1885   mcs51.features |= (FEATURE_CMOS_IDLE | FEATURE_CMOS_POWERDOWN);
23851886}
23861887
2387#endif   //(HAS_8752)
1888static void i8052_reset(void)
1889{
1890   mcs51_reset();
23881891
1892   //8052 Only registers
1893   T2CON = 0;
1894   RCAP2L = 0;
1895   RCAP2H = 0;
1896   TL2 = 0;
1897   TH2 = 0;
1898}
1899
1900/***************************************************************************
1901    ADDRESS MAPS
1902***************************************************************************/
1903
1904
1905/* FIXME: the memory maps should probably support rom banking for EA */
1906static ADDRESS_MAP_START(program_12bit, ADDRESS_SPACE_PROGRAM, 8)
1907   AM_RANGE(0x00, 0x0fff) AM_ROM
1908ADDRESS_MAP_END
1909
1910static ADDRESS_MAP_START(program_13bit, ADDRESS_SPACE_PROGRAM, 8)
1911   AM_RANGE(0x00, 0x1fff) AM_ROM
1912ADDRESS_MAP_END
1913
1914static ADDRESS_MAP_START(data_7bit, ADDRESS_SPACE_DATA, 8)
1915   AM_RANGE(0x0000, 0x007f) AM_RAM
1916   AM_RANGE(0x0100, 0x01ff) AM_RAM /* SFR */
1917ADDRESS_MAP_END
1918
1919static ADDRESS_MAP_START(data_8bit, ADDRESS_SPACE_DATA, 8)
1920   AM_RANGE(0x0000, 0x00ff) AM_RAM
1921   AM_RANGE(0x0100, 0x01ff) AM_RAM /* SFR */
1922ADDRESS_MAP_END
1923
1924
1925/***************************************************************************
1926    GENERAL CONTEXT ACCESS
1927***************************************************************************/
1928
1929static void mcs51_get_context(void *dst)
1930{
1931   if( dst )
1932      memcpy(dst, &mcs51, sizeof(mcs51_regs));
1933}
1934
1935static void mcs51_set_context(void *src)
1936{
1937   if( src )
1938      memcpy(&mcs51, src, sizeof(mcs51_regs));
1939      change_pc(PC);
1940      update_ptrs();
1941}
1942
23891943/**************************************************************************
23901944 * Generic set_info
23911945 **************************************************************************/
23921946
2393static void i8051_set_info(UINT32 state, cpuinfo *info)
1947static void mcs51_set_info(UINT32 state, cpuinfo *info)
23941948{
23951949   switch (state)
23961950   {
23971951      /* --- the following bits of info are set as 64-bit signed integers --- */
23981952      case CPUINFO_INT_PC:                     PC = info->i;                     break;
2399      case CPUINFO_INT_SP:                     i8051.sp = info->i;                    break;
1953      case CPUINFO_INT_SP:                     SP = info->i;                       break;
24001954
2401      case CPUINFO_INT_INPUT_STATE + I8051_INT0_LINE:   i8051_set_irq_line(I8051_INT0_LINE, info->i); break;
2402      case CPUINFO_INT_INPUT_STATE + I8051_INT1_LINE:   i8051_set_irq_line(I8051_INT1_LINE, info->i); break;
2403      case CPUINFO_INT_INPUT_STATE + I8051_T0_LINE:   i8051_set_irq_line(I8051_T0_LINE, info->i); break;
2404      case CPUINFO_INT_INPUT_STATE + I8051_T1_LINE:   i8051_set_irq_line(I8051_T1_LINE, info->i); break;
2405      case CPUINFO_INT_INPUT_STATE + I8051_RX_LINE:   i8051_set_irq_line(I8051_RX_LINE, info->i); break;
1955      case CPUINFO_INT_INPUT_STATE + I8051_INT0_LINE:   mcs51_set_irq_line(I8051_INT0_LINE, info->i); break;
1956      case CPUINFO_INT_INPUT_STATE + I8051_INT1_LINE:   mcs51_set_irq_line(I8051_INT1_LINE, info->i); break;
1957      case CPUINFO_INT_INPUT_STATE + MCS51_T0_LINE:   mcs51_set_irq_line(MCS51_T0_LINE, info->i); break;
1958      case CPUINFO_INT_INPUT_STATE + MCS51_T1_LINE:   mcs51_set_irq_line(MCS51_T1_LINE, info->i); break;
1959      case CPUINFO_INT_INPUT_STATE + I8051_RX_LINE:   mcs51_set_irq_line(I8051_RX_LINE, info->i); break;
24061960
2407      case CPUINFO_INT_REGISTER + I8051_PC:          PC = info->i;                     break;
2408      case CPUINFO_INT_REGISTER + I8051_SP:          R_SP = info->i;                     break;
2409      case CPUINFO_INT_REGISTER + I8051_PSW:         i8051.psw = info->i;               break;
2410      case CPUINFO_INT_REGISTER + I8051_ACC:         i8051.acc = info->i;               break;
2411      case CPUINFO_INT_REGISTER + I8051_B:           i8051.b = info->i;                  break;
2412      case CPUINFO_INT_REGISTER + I8051_DPH:         i8051.dph = info->i;               break;
2413      case CPUINFO_INT_REGISTER + I8051_DPL:         i8051.dpl = info->i;               break;
2414      case CPUINFO_INT_REGISTER + I8051_IE:          i8051.ie = info->i;                  break;
2415      case CPUINFO_INT_REGISTER + I8051_R0:          i8051.IntRam[0+(8*((i8051.psw & 0x18)>>3))] = info->i; break;
2416      case CPUINFO_INT_REGISTER + I8051_R1:          i8051.IntRam[1+(8*((i8051.psw & 0x18)>>3))] = info->i; break;
2417      case CPUINFO_INT_REGISTER + I8051_R2:          i8051.IntRam[2+(8*((i8051.psw & 0x18)>>3))] = info->i; break;
2418      case CPUINFO_INT_REGISTER + I8051_R3:          i8051.IntRam[3+(8*((i8051.psw & 0x18)>>3))] = info->i; break;
2419      case CPUINFO_INT_REGISTER + I8051_R4:          i8051.IntRam[4+(8*((i8051.psw & 0x18)>>3))] = info->i; break;
2420      case CPUINFO_INT_REGISTER + I8051_R5:          i8051.IntRam[5+(8*((i8051.psw & 0x18)>>3))] = info->i; break;
2421      case CPUINFO_INT_REGISTER + I8051_R6:          i8051.IntRam[6+(8*((i8051.psw & 0x18)>>3))] = info->i; break;
2422      case CPUINFO_INT_REGISTER + I8051_R7:          i8051.IntRam[7+(8*((i8051.psw & 0x18)>>3))] = info->i; break;
2423      case CPUINFO_INT_REGISTER + I8051_RB:          i8051.IntRam[8+(8*((i8051.psw & 0x18)>>3))] = info->i; break;
1961      case CPUINFO_INT_REGISTER + I8051_PC:          PC = info->i;                        break;
1962      case CPUINFO_INT_REGISTER + I8051_SP:          SP = info->i;                     break;
1963      case CPUINFO_INT_REGISTER + I8051_PSW:         SET_PSW(info->i);                     break;
1964      case CPUINFO_INT_REGISTER + I8051_ACC:         SET_ACC(info->i);                     break;
1965      case CPUINFO_INT_REGISTER + I8051_B:           B = info->i;                        break;
1966      case CPUINFO_INT_REGISTER + I8051_DPH:         DPH = info->i;                     break;
1967      case CPUINFO_INT_REGISTER + I8051_DPL:         DPL = info->i;                     break;
1968      case CPUINFO_INT_REGISTER + I8051_IE:          IE = info->i;                     break;
1969      case CPUINFO_INT_REGISTER + I8051_R0:          SET_REG(0, info->i); break;
1970      case CPUINFO_INT_REGISTER + I8051_R1:          SET_REG(1, info->i); break;
1971      case CPUINFO_INT_REGISTER + I8051_R2:          SET_REG(2, info->i); break;
1972      case CPUINFO_INT_REGISTER + I8051_R3:          SET_REG(3, info->i); break;
1973      case CPUINFO_INT_REGISTER + I8051_R4:          SET_REG(4, info->i); break;
1974      case CPUINFO_INT_REGISTER + I8051_R5:          SET_REG(5, info->i); break;
1975      case CPUINFO_INT_REGISTER + I8051_R6:          SET_REG(6, info->i); break;
1976      case CPUINFO_INT_REGISTER + I8051_R7:          SET_REG(7, info->i); break;
1977      case CPUINFO_INT_REGISTER + I8051_RB:          SET_RS(info->i); break;
24241978   }
24251979}
24261980
1981
1982
24271983/**************************************************************************
24281984 * Generic get_info
24291985 **************************************************************************/
24301986
2431void i8051_get_info(UINT32 state, cpuinfo *info)
1987static void mcs51_get_info(UINT32 state, cpuinfo *info)
24321988{
2433   I8051 *r = &i8051;
1989   mcs51_regs *r = &mcs51;
24341990
24351991   switch (state)
24361992   {
24371993      /* --- the following bits of info are returned as 64-bit signed integers --- */
2438      case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(i8051);            break;
1994      case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(mcs51);            break;
24391995      case CPUINFO_INT_DEFAULT_IRQ_VECTOR:         info->i = 0;                     break;
24401996      case CPUINFO_INT_ENDIANNESS:               info->i = CPU_IS_LE;               break;
24411997      case CPUINFO_INT_CLOCK_MULTIPLIER:            info->i = 1;                     break;
2442      case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 1;                     break;
1998      case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 12;                     break;
24431999      case CPUINFO_INT_MIN_INSTRUCTION_BYTES:         info->i = 1;                     break;
24442000      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 5;                     break;
24452001      case CPUINFO_INT_MIN_CYCLES:               info->i = 1;                     break;
r3485r3486
24502006      case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 16;               break;
24512007      case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = 0;               break;
24522008      case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_DATA:   info->i = 8;               break;
2453      case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_DATA:    info->i = 16;               break;
2009      case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_DATA:    info->i = 9; /* due to sfr mapping */               break;
24542010      case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_DATA:    info->i = 0;               break;
24552011      case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_IO:   info->i = 8;                  break;
2456      case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO:    info->i = 16;                  break;
2012      case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO:    info->i = 17;                  break;
24572013      case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO:    info->i = 0;                  break;
24582014
24592015      case CPUINFO_INT_PREVIOUSPC:               info->i = PPC;                     break;
24602016      case CPUINFO_INT_PC:                      info->i = PC;                     break;
2461      case CPUINFO_INT_SP:                     info->i = R_SP;                     break;
2017      case CPUINFO_INT_SP:                     info->i = SP;                     break;
24622018
24632019      case CPUINFO_INT_REGISTER + I8051_PC:          info->i = PC;                     break;
2464      case CPUINFO_INT_REGISTER + I8051_SP:          info->i = R_SP;                     break;
2465      case CPUINFO_INT_REGISTER + I8051_PSW:         info->i = i8051.psw;               break;
2466      case CPUINFO_INT_REGISTER + I8051_ACC:         info->i = i8051.acc;               break;
2467      case CPUINFO_INT_REGISTER + I8051_B:           info->i = i8051.b;                  break;
2468      case CPUINFO_INT_REGISTER + I8051_DPH:         info->i = i8051.dph;               break;
2469      case CPUINFO_INT_REGISTER + I8051_DPL:         info->i = i8051.dpl;               break;
2470      case CPUINFO_INT_REGISTER + I8051_IE:          info->i = i8051.ie;                  break;
2471      case CPUINFO_INT_REGISTER + I8051_R0:          info->i = i8051.IntRam[0+(8*((i8051.psw & 0x18)>>3))]; break;
2472      case CPUINFO_INT_REGISTER + I8051_R1:          info->i = i8051.IntRam[1+(8*((i8051.psw & 0x18)>>3))]; break;
2473      case CPUINFO_INT_REGISTER + I8051_R2:          info->i = i8051.IntRam[2+(8*((i8051.psw & 0x18)>>3))]; break;
2474      case CPUINFO_INT_REGISTER + I8051_R3:          info->i = i8051.IntRam[3+(8*((i8051.psw & 0x18)>>3))]; break;
2475      case CPUINFO_INT_REGISTER + I8051_R4:          info->i = i8051.IntRam[4+(8*((i8051.psw & 0x18)>>3))]; break;
2476      case CPUINFO_INT_REGISTER + I8051_R5:          info->i = i8051.IntRam[5+(8*((i8051.psw & 0x18)>>3))]; break;
2477      case CPUINFO_INT_REGISTER + I8051_R6:          info->i = i8051.IntRam[6+(8*((i8051.psw & 0x18)>>3))]; break;
2478      case CPUINFO_INT_REGISTER + I8051_R7:          info->i = i8051.IntRam[7+(8*((i8051.psw & 0x18)>>3))]; break;
2479      case CPUINFO_INT_REGISTER + I8051_RB:          info->i = i8051.IntRam[8+(8*((i8051.psw & 0x18)>>3))]; break;
2020      case CPUINFO_INT_REGISTER + I8051_SP:          info->i = SP;                     break;
2021      case CPUINFO_INT_REGISTER + I8051_PSW:         info->i = PSW;                     break;
2022      case CPUINFO_INT_REGISTER + I8051_ACC:         info->i = ACC;                     break;
2023      case CPUINFO_INT_REGISTER + I8051_B:           info->i = B;                     break;
2024      case CPUINFO_INT_REGISTER + I8051_DPH:         info->i = DPH;                     break;
2025      case CPUINFO_INT_REGISTER + I8051_DPL:         info->i = DPL;                     break;
2026      case CPUINFO_INT_REGISTER + I8051_IE:          info->i = IE;                     break;
2027      case CPUINFO_INT_REGISTER + I8051_R0:          info->i = R_REG(0);                   break;
2028      case CPUINFO_INT_REGISTER + I8051_R1:          info->i = R_REG(1);                break;
2029      case CPUINFO_INT_REGISTER + I8051_R2:          info->i = R_REG(2);                break;
2030      case CPUINFO_INT_REGISTER + I8051_R3:          info->i = R_REG(3);                break;
2031      case CPUINFO_INT_REGISTER + I8051_R4:          info->i = R_REG(4);                break;
2032      case CPUINFO_INT_REGISTER + I8051_R5:          info->i = R_REG(5);                break;
2033      case CPUINFO_INT_REGISTER + I8051_R6:          info->i = R_REG(6);                break;
2034      case CPUINFO_INT_REGISTER + I8051_R7:          info->i = R_REG(7);                break;
2035      case CPUINFO_INT_REGISTER + I8051_RB:          info->i = R_REG(8);                break;
24802036
24812037      /* --- the following bits of info are returned as pointers to data or functions --- */
2482      case CPUINFO_PTR_SET_INFO:                  info->setinfo = i8051_set_info;         break;
2483      case CPUINFO_PTR_GET_CONTEXT:               info->getcontext = i8051_get_context;   break;
2484      case CPUINFO_PTR_SET_CONTEXT:               info->setcontext = i8051_set_context;   break;
2485      case CPUINFO_PTR_INIT:                     info->init = i8051_init;            break;
2486      case CPUINFO_PTR_RESET:                     info->reset = i8051_reset;            break;
2487      case CPUINFO_PTR_EXIT:                     info->exit = i8051_exit;            break;
2488      case CPUINFO_PTR_EXECUTE:                  info->execute = i8051_execute;         break;
2038      case CPUINFO_PTR_SET_INFO:                  info->setinfo = mcs51_set_info;         break;
2039      case CPUINFO_PTR_GET_CONTEXT:               info->getcontext = mcs51_get_context;   break;
2040      case CPUINFO_PTR_SET_CONTEXT:               info->setcontext = mcs51_set_context;   break;
2041      case CPUINFO_PTR_INIT:                     info->init = mcs51_init;            break;
2042      case CPUINFO_PTR_RESET:                     info->reset = mcs51_reset;            break;
2043      case CPUINFO_PTR_EXIT:                     info->exit = mcs51_exit;            break;
2044      case CPUINFO_PTR_EXECUTE:                  info->execute = mcs51_execute;         break;
24892045      case CPUINFO_PTR_BURN:                     info->burn = NULL;                  break;
24902046      case CPUINFO_PTR_DISASSEMBLE:               info->disassemble = i8051_dasm;         break;
2491      case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &i8051_icount;         break;
2047      case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &mcs51_icount;         break;
24922048
24932049      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = NULL;   break;
24942050      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = NULL;   break;
24952051      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_IO:      info->internal_map8 = NULL;   break;
24962052
2497      /* --- the following bits of info are returned as NULL-terminated strings --- */
24982053      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8051");            break;
24992054      case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "MCS-51");            break;
25002055      case CPUINFO_STR_CORE_VERSION:               strcpy(info->s, "1.0");               break;
r3485r3486
25032058
25042059      case CPUINFO_STR_FLAGS:
25052060         sprintf(info->s, "%c%c%c%c%c%c%c%c",
2506            r->psw & 0x80 ? 'C':'.',
2507            r->psw & 0x40 ? 'A':'.',
2508            r->psw & 0x20 ? 'F':'.',
2509            r->psw & 0x10 ? '0':'.',
2510            r->psw & 0x08 ? '1':'.',
2511            r->psw & 0x04 ? 'V':'.',
2512            r->psw & 0x02 ? '?':'.',
2513            r->psw & 0x01 ? 'P':'.');
2061            PSW & 0x80 ? 'C':'.',
2062            PSW & 0x40 ? 'A':'.',
2063            PSW & 0x20 ? 'F':'.',
2064            PSW & 0x10 ? '0':'.',
2065            PSW & 0x08 ? '1':'.',
2066            PSW & 0x04 ? 'V':'.',
2067            PSW & 0x02 ? '?':'.',
2068            PSW & 0x01 ? 'P':'.');
25142069         break;
25152070
25162071      case CPUINFO_STR_REGISTER + I8051_PC:           sprintf(info->s, "PC:%04X", r->pc);      break;
2517      case CPUINFO_STR_REGISTER + I8051_SP:           sprintf(info->s, "SP:%02X", r->sp);      break;
2518      case CPUINFO_STR_REGISTER + I8051_PSW:          sprintf(info->s, "PSW:%02X", r->psw);   break;
2519      case CPUINFO_STR_REGISTER + I8051_ACC:          sprintf(info->s, "A:%02X", r->acc);      break;
2520      case CPUINFO_STR_REGISTER + I8051_B:            sprintf(info->s, "B:%02X", r->b);      break;
2521      case CPUINFO_STR_REGISTER + I8051_DPH:          sprintf(info->s, "DPH:%02X", r->dph);   break;
2522      case CPUINFO_STR_REGISTER + I8051_DPL:          sprintf(info->s, "DPL:%02X", r->dpl);   break;
2523      case CPUINFO_STR_REGISTER + I8051_IE:           sprintf(info->s, "IE:%02X", r->ie);      break;
2524      case CPUINFO_STR_REGISTER + I8051_R0:           sprintf(info->s, "R0:%02X", r->IntRam[0+(8*((r->psw & 0x18)>>3))]); break;
2525      case CPUINFO_STR_REGISTER + I8051_R1:           sprintf(info->s, "R1:%02X", r->IntRam[1+(8*((r->psw & 0x18)>>3))]); break;
2526      case CPUINFO_STR_REGISTER + I8051_R2:           sprintf(info->s, "R2:%02X", r->IntRam[2+(8*((r->psw & 0x18)>>3))]); break;
2527      case CPUINFO_STR_REGISTER + I8051_R3:         sprintf(info->s, "R3:%02X", r->IntRam[3+(8*((r->psw & 0x18)>>3))]); break;
2528      case CPUINFO_STR_REGISTER + I8051_R4:          sprintf(info->s, "R4:%02X", r->IntRam[4+(8*((r->psw & 0x18)>>3))]); break;
2529      case CPUINFO_STR_REGISTER + I8051_R5:          sprintf(info->s, "R5:%02X", r->IntRam[5+(8*((r->psw & 0x18)>>3))]); break;
2530      case CPUINFO_STR_REGISTER + I8051_R6:          sprintf(info->s, "R6:%02X", r->IntRam[6+(8*((r->psw & 0x18)>>3))]); break;
2531      case CPUINFO_STR_REGISTER + I8051_R7:          sprintf(info->s, "R7:%02X", r->IntRam[7+(8*((r->psw & 0x18)>>3))]); break;
2532      case CPUINFO_STR_REGISTER + I8051_RB:          sprintf(info->s, "RB:%02X", ((r->psw & 0x18)>>3)); break;
2072      case CPUINFO_STR_REGISTER + I8051_SP:           sprintf(info->s, "SP:%02X", SP);      break;
2073      case CPUINFO_STR_REGISTER + I8051_PSW:          sprintf(info->s, "PSW:%02X", PSW);      break;
2074      case CPUINFO_STR_REGISTER + I8051_ACC:          sprintf(info->s, "A:%02X", ACC);      break;
2075      case CPUINFO_STR_REGISTER + I8051_B:            sprintf(info->s, "B:%02X", B);         break;
2076      case CPUINFO_STR_REGISTER + I8051_DPH:          sprintf(info->s, "DPH:%02X", DPH);      break;
2077      case CPUINFO_STR_REGISTER + I8051_DPL:          sprintf(info->s, "DPL:%02X", DPL);      break;
2078      case CPUINFO_STR_REGISTER + I8051_IE:           sprintf(info->s, "IE:%02X", IE);      break;
2079      case CPUINFO_STR_REGISTER + I8051_R0:           sprintf(info->s, "R0:%02X", R_REG(0));    break;
2080      case CPUINFO_STR_REGISTER + I8051_R1:           sprintf(info->s, "R1:%02X", R_REG(1));    break;
2081      case CPUINFO_STR_REGISTER + I8051_R2:           sprintf(info->s, "R2:%02X", R_REG(2));    break;
2082      case CPUINFO_STR_REGISTER + I8051_R3:         sprintf(info->s, "R3:%02X", R_REG(3));    break;
2083      case CPUINFO_STR_REGISTER + I8051_R4:          sprintf(info->s, "R4:%02X", R_REG(4));    break;
2084      case CPUINFO_STR_REGISTER + I8051_R5:          sprintf(info->s, "R5:%02X", R_REG(5));    break;
2085      case CPUINFO_STR_REGISTER + I8051_R6:          sprintf(info->s, "R6:%02X", R_REG(6));    break;
2086      case CPUINFO_STR_REGISTER + I8051_R7:          sprintf(info->s, "R7:%02X", R_REG(7));    break;
2087      case CPUINFO_STR_REGISTER + I8051_RB:          sprintf(info->s, "RB:%02X", ((PSW & 0x18)>>3)); break;
25332088   }
25342089}
25352090
2536#if (HAS_I8052)
2091/**************************************************************************
2092 * Specific get_info
2093 **************************************************************************/
2094
2095void i8031_get_info(UINT32 state, cpuinfo *info)
2096{
2097   switch (state)
2098   {
2099      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_7bit;   break;
2100
2101      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8031");            break;
2102      default:                              mcs51_get_info(state, info);         break;
2103   }
2104   /* --- the following bits of info are returned as NULL-terminated strings --- */
2105}
2106
2107void i8051_get_info(UINT32 state, cpuinfo *info)
2108{
2109   switch (state)
2110   {
2111      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_12bit;   break;
2112      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_7bit;   break;
2113
2114      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8051");            break;
2115      default:                              mcs51_get_info(state, info);         break;
2116   }
2117   /* --- the following bits of info are returned as NULL-terminated strings --- */
2118}
2119
2120void i8032_get_info(UINT32 state, cpuinfo *info)
2121{
2122   switch (state)
2123   {
2124      case CPUINFO_PTR_INIT:                     info->init = i8052_init;            break;
2125      case CPUINFO_PTR_RESET:                     info->reset = i8052_reset;            break;
2126
2127      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_8bit;   break;
2128
2129      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8032");            break;
2130
2131      default:                              mcs51_get_info(state, info);         break;
2132   }
2133}
2134
25372135void i8052_get_info(UINT32 state, cpuinfo *info)
25382136{
25392137   switch (state)
25402138   {
2541      case CPUINFO_PTR_GET_CONTEXT:               info->getcontext = i8752_get_context;   break;
2542      case CPUINFO_PTR_SET_CONTEXT:               info->setcontext = i8752_set_context;   break;
2543      case CPUINFO_PTR_INIT:                     info->init = i8752_init;            break;
2544      case CPUINFO_PTR_RESET:                     info->reset = i8752_reset;            break;
2545      case CPUINFO_PTR_EXIT:                     info->exit = i8752_exit;            break;
2546      case CPUINFO_PTR_EXECUTE:                  info->execute = i8752_execute;         break;
2139      case CPUINFO_PTR_INIT:                     info->init = i8052_init;            break;
2140      case CPUINFO_PTR_RESET:                     info->reset = i8052_reset;            break;
25472141
2142      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_13bit;   break;
2143      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_8bit;   break;
2144
25482145      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8052");            break;
25492146
2550      default:                              i8051_get_info(state, info);         break;
2147      default:                              mcs51_get_info(state, info);         break;
25512148   }
25522149}
2553#endif
25542150
2555#if (HAS_I8751)
25562151void i8751_get_info(UINT32 state, cpuinfo *info)
25572152{
25582153   switch (state)
25592154   {
2155      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_12bit;   break;
2156      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_7bit;   break;
2157
25602158      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8751");            break;
25612159
2562      default:                              i8051_get_info(state, info);         break;
2160      default:                              mcs51_get_info(state, info);         break;
25632161   }
25642162}
2565#endif
25662163
2567#if (HAS_I8752)
25682164void i8752_get_info(UINT32 state, cpuinfo *info)
25692165{
25702166   switch (state)
25712167   {
2572      case CPUINFO_PTR_GET_CONTEXT:               info->getcontext = i8752_get_context;   break;
2573      case CPUINFO_PTR_SET_CONTEXT:               info->setcontext = i8752_set_context;   break;
2574      case CPUINFO_PTR_INIT:                     info->init = i8752_init;            break;
2575      case CPUINFO_PTR_RESET:                     info->reset = i8752_reset;            break;
2576      case CPUINFO_PTR_EXIT:                     info->exit = i8752_exit;            break;
2577      case CPUINFO_PTR_EXECUTE:                  info->execute = i8752_execute;         break;
2168      case CPUINFO_PTR_INIT:                     info->init = i8052_init;            break;
2169      case CPUINFO_PTR_RESET:                     info->reset = i8052_reset;            break;
25782170
2171      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_13bit;   break;
2172      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_8bit;   break;
2173
25792174      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8752");            break;
25802175
2176      default:                              mcs51_get_info(state, info);         break;
2177   }
2178}
2179
2180/**************************************************************************
2181 * CMOS get_info
2182 **************************************************************************/
2183
2184void i80c31_get_info(UINT32 state, cpuinfo *info)
2185{
2186   switch (state)
2187   {
2188      case CPUINFO_PTR_INIT:                     info->init = i80c51_init;            break;
2189      case CPUINFO_STR_NAME:                     strcpy(info->s, "I80C31");            break;
2190      default:                              i8031_get_info(state, info);         break;
2191   }
2192}
2193
2194void i80c51_get_info(UINT32 state, cpuinfo *info)
2195{
2196   switch (state)
2197   {
2198      case CPUINFO_PTR_INIT:                     info->init = i80c51_init;            break;
2199      case CPUINFO_STR_NAME:                     strcpy(info->s, "I80C51");            break;
25812200      default:                              i8051_get_info(state, info);         break;
25822201   }
25832202}
2584#endif
2203
2204void i80c32_get_info(UINT32 state, cpuinfo *info)
2205{
2206   switch (state)
2207   {
2208      case CPUINFO_PTR_INIT:                     info->init = i80c52_init;            break;
2209      case CPUINFO_STR_NAME:                     strcpy(info->s, "I80C32");            break;
2210      default:                              i8032_get_info(state, info);         break;
2211   }
2212}
2213
2214void i80c52_get_info(UINT32 state, cpuinfo *info)
2215{
2216   switch (state)
2217   {
2218      case CPUINFO_PTR_INIT:                     info->init = i80c52_init;            break;
2219      case CPUINFO_STR_NAME:                     strcpy(info->s, "I80C52");            break;
2220      default:                              i8052_get_info(state, info);         break;
2221   }
2222}
2223
2224void i87c51_get_info(UINT32 state, cpuinfo *info)
2225{
2226   switch (state)
2227   {
2228      case CPUINFO_PTR_INIT:                     info->init = i80c51_init;            break;
2229      case CPUINFO_STR_NAME:                     strcpy(info->s, "I87C51");            break;
2230      default:                              i8751_get_info(state, info);         break;
2231   }
2232}
2233
2234void i87c52_get_info(UINT32 state, cpuinfo *info)
2235{
2236   switch (state)
2237   {
2238      case CPUINFO_PTR_INIT:                     info->init = i80c52_init;            break;
2239      case CPUINFO_STR_NAME:                     strcpy(info->s, "I87C52");            break;
2240      default:                              i8752_get_info(state, info);         break;
2241   }
2242}
2243
2244/**************************************************************************
2245 * Other variants get_info
2246 **************************************************************************/
2247
2248void at89c4051_get_info(UINT32 state, cpuinfo *info)
2249{
2250   switch (state)
2251   {
2252      case CPUINFO_PTR_INIT:                     info->init = i80c51_init;            break;
2253      case CPUINFO_STR_NAME:                     strcpy(info->s, "AT89C4051");            break;
2254      default:                              i8051_get_info(state, info);         break;
2255   }
2256}
src/emu/cpu/i8051/i8051ops.c
r3485r3486
11/*******************************************************************************************
22 NOTE: All registers are accessed directly, instead of using the SFR_R() function for speed
3 Direct register access is availabe from the R_(register name) macros.. ex: R_ACC for the ACC
3 Direct register access is availabe from the R_(register name) macros.. ex: ACC for the ACC
44 with the exception of the PC
55********************************************************************************************/
66
77//ACALL code addr                           /* 1: aaa1 0001 */
8INLINE void acall(void)
8INLINE void acall(UINT8 op)
99{
10   UINT8 op = ROP(PC-1);               //Grab the opcode for ACALL
1110   UINT8 addr = ROP_ARG(PC++);            //Grab code address byte
12   PUSH_PC                           //Save PC to the stack
11   PUSH_PC();                        //Save PC to the stack
1312   //Thanks Gerrit for help with this! :)
1413   PC = (PC & 0xf800) | ((op & 0xe0) << 3) | addr;
14   change_pc(PC);
1515}
1616
1717//ADD A, #data                              /* 1: 0010 0100 */
1818INLINE void add_a_byte(void)
1919{
2020   UINT8 data = ROP_ARG(PC++);            //Grab data
21   UINT8 result = R_ACC + data;         //Add data to accumulator
22   DO_ADD_FLAGS(R_ACC,data,0)            //Set Flags
23   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
21   UINT8 result = ACC + data;         //Add data to accumulator
22   DO_ADD_FLAGS(ACC,data,0);            //Set Flags
23   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
2424}
2525
2626//ADD A, data addr                          /* 1: 0010 0101 */
r3485r3486
2828{
2929   UINT8 addr = ROP_ARG(PC++);            //Grab data address
3030   UINT8 data = IRAM_R(addr);            //Grab data from data address
31   UINT8 result = R_ACC + data;         //Add data to accumulator
32   DO_ADD_FLAGS(R_ACC,data,0);            //Set Flags
33   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
31   UINT8 result = ACC + data;         //Add data to accumulator
32   DO_ADD_FLAGS(ACC,data,0);            //Set Flags
33   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
3434}
3535
3636//ADD A, @R0/@R1                            /* 1: 0010 011i */
3737INLINE void add_a_ir(int r)
3838{
39   UINT8 data = IRAM_IR(R_R(r));         //Grab data from memory pointed to by R0 or R1
40   UINT8 result = R_ACC + data;         //Add data to accumulator
41   DO_ADD_FLAGS(R_ACC,data,0);            //Set Flags
42   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
39   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from memory pointed to by R0 or R1
40   UINT8 result = ACC + data;         //Add data to accumulator
41   DO_ADD_FLAGS(ACC,data,0);            //Set Flags
42   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
4343}
4444
4545//ADD A, R0 to R7                           /* 1: 0010 1rrr */
4646INLINE void add_a_r(int r)
4747{
48   UINT8 data = R_R(r);               //Grab data from R0 - R7
49   UINT8 result = R_ACC + data;         //Add data to accumulator
50   DO_ADD_FLAGS(R_ACC,data,0);            //Set Flags
51   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
48   UINT8 data = R_REG(r);               //Grab data from R0 - R7
49   UINT8 result = ACC + data;         //Add data to accumulator
50   DO_ADD_FLAGS(ACC,data,0);            //Set Flags
51   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
5252}
5353
5454//ADDC A, #data                             /* 1: 0011 0100 */
5555INLINE void addc_a_byte(void)
5656{
5757   UINT8 data = ROP_ARG(PC++);            //Grab data
58   UINT8 result = R_ACC + data + GET_CY;   //Add data + carry flag to accumulator
59   DO_ADD_FLAGS(R_ACC,data,GET_CY);      //Set Flags
60   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
58   UINT8 result = ACC + data + GET_CY;   //Add data + carry flag to accumulator
59   DO_ADD_FLAGS(ACC,data,GET_CY);      //Set Flags
60   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
6161}
6262
6363//ADDC A, data addr                         /* 1: 0011 0101 */
r3485r3486
6565{
6666   UINT8 addr = ROP_ARG(PC++);            //Grab data address
6767   UINT8 data = IRAM_R(addr);            //Grab data from data address
68   UINT8 result = R_ACC + data + GET_CY;   //Add data + carry flag to accumulator
69   DO_ADD_FLAGS(R_ACC,data,GET_CY);      //Set Flags
70   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
68   UINT8 result = ACC + data + GET_CY;   //Add data + carry flag to accumulator
69   DO_ADD_FLAGS(ACC,data,GET_CY);      //Set Flags
70   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
7171}
7272
7373//ADDC A, @R0/@R1                           /* 1: 0011 011i */
7474INLINE void addc_a_ir(int r)
7575{
76   UINT8 data = IRAM_IR(R_R(r));         //Grab data from memory pointed to by R0 or R1
77   UINT8 result = R_ACC + data + GET_CY;   //Add data + carry flag to accumulator
78   DO_ADD_FLAGS(R_ACC,data,GET_CY);      //Set Flags
79   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
76   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from memory pointed to by R0 or R1
77   UINT8 result = ACC + data + GET_CY;   //Add data + carry flag to accumulator
78   DO_ADD_FLAGS(ACC,data,GET_CY);      //Set Flags
79   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
8080}
8181
8282//ADDC A, R0 to R7                          /* 1: 0011 1rrr */
8383INLINE void addc_a_r(int r)
8484{
85   UINT8 data = R_R(r);               //Grab data from R0 - R7
86   UINT8 result = R_ACC + data + GET_CY;   //Add data + carry flag to accumulator
87   DO_ADD_FLAGS(R_ACC,data,GET_CY);      //Set Flags
88   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
85   UINT8 data = R_REG(r);               //Grab data from R0 - R7
86   UINT8 result = ACC + data + GET_CY;   //Add data + carry flag to accumulator
87   DO_ADD_FLAGS(ACC,data,GET_CY);      //Set Flags
88   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
8989}
9090
9191//AJMP code addr                            /* 1: aaa0 0001 */
92INLINE void ajmp(void)
92INLINE void ajmp(UINT8 op)
9393{
94   UINT8 op = ROP(PC-1);               //Grab the opcode for AJMP
9594   UINT8 addr = ROP_ARG(PC++);            //Grab code address byte
9695   //Thanks Gerrit for help with this! :)
9796   PC = (PC & 0xf800) | ((op & 0xe0) << 3) | addr;
97   change_pc(PC);
9898}
9999
100100//ANL data addr, A                          /* 1: 0101 0010 */
r3485r3486
102102{
103103   UINT8 addr = ROP_ARG(PC++);            //Grab data address
104104   UINT8 data = IRAM_R(addr);            //Grab data from data address
105   IRAM_W(addr,data & R_ACC);            //Set data address value to it's value Logical AND with ACC
105   IRAM_W(addr,data & ACC);            //Set data address value to it's value Logical AND with ACC
106106}
107107
108108//ANL data addr, #data                      /* 1: 0101 0011 */
r3485r3486
118118INLINE void anl_a_byte(void)
119119{
120120   UINT8 data = ROP_ARG(PC++);            //Grab data
121   SFR_W(ACC,R_ACC & data);            //Set ACC to value of ACC Logical AND with Data
121   SET_ACC(ACC & data);            //Set ACC to value of ACC Logical AND with Data
122122}
123123
124124//ANL A, data addr                          /* 1: 0101 0101 */
r3485r3486
126126{
127127   UINT8 addr = ROP_ARG(PC++);            //Grab data address
128128   UINT8 data = IRAM_R(addr);            //Grab data from data address
129   SFR_W(ACC,R_ACC & data);            //Set ACC to value of ACC Logical AND with Data
129   SET_ACC(ACC & data);            //Set ACC to value of ACC Logical AND with Data
130130}
131131
132132//ANL A, @RO/@R1                            /* 1: 0101 011i */
133133INLINE void anl_a_ir(int r)
134134{
135   UINT8 data = IRAM_IR(R_R(r));         //Grab data from address R0 or R1 points to
136   SFR_W(ACC,R_ACC & data);            //Set ACC to value of ACC Logical AND with Data
135   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from address R0 or R1 points to
136   SET_ACC(ACC & data);            //Set ACC to value of ACC Logical AND with Data
137137}
138138
139139//ANL A, RO to R7                           /* 1: 0101 1rrr */
140140INLINE void anl_a_r(int r)
141141{
142   UINT8 data = R_R(r);               //Grab data from R0 - R7
143   SFR_W(ACC,R_ACC & data);            //Set ACC to value of ACC Logical AND with Data
142   UINT8 data = R_REG(r);               //Grab data from R0 - R7
143   SET_ACC(ACC & data);            //Set ACC to value of ACC Logical AND with Data
144144}
145145
146146//ANL C, bit addr                           /* 1: 1000 0010 */
r3485r3486
168168   UINT8 data = ROP_ARG(PC++);            //Grab data
169169   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
170170
171   if(R_ACC != data)                  //Jump if values are not equal
171   if(ACC != data)                  //Jump if values are not equal
172   {
172173      PC = PC + rel_addr;
174      change_pc(PC);
175   }
173176
174177   //Set carry flag to 1 if 1st compare value is < 2nd compare value
175   SET_CY( (R_ACC < data) );
178   SET_CY( (ACC < data) );
176179}
177180
178181//CJNE A, data addr, code addr              /* 1: 1011 0101 */
r3485r3486
182185   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
183186   UINT8 data = IRAM_R(addr);            //Pull value from data address
184187
185   if(R_ACC != data)                  //Jump if values are not equal
188   if(ACC != data)                  //Jump if values are not equal
189   {
186190      PC = PC + rel_addr;
191      change_pc(PC);
192   }
187193
188194   //Set carry flag to 1 if 1st compare value is < 2nd compare value
189   SET_CY( (R_ACC < data) );
195   SET_CY( (ACC < data) );
190196}
191197
192198//CJNE @R0/@R1, #data, code addr            /* 1: 1011 011i */
r3485r3486
194200{
195201   UINT8 data = ROP_ARG(PC++);            //Grab data
196202   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
197   UINT8 srcdata = IRAM_IR(R_R(r));      //Grab value pointed to by R0 or R1
203   UINT8 srcdata = IRAM_IR(R_REG(r));      //Grab value pointed to by R0 or R1
198204
199205   if(srcdata != data)                  //Jump if values are not equal
206   {
200207      PC = PC + rel_addr;
208      change_pc(PC);
209   }
201210
202211   //Set carry flag to 1 if 1st compare value is < 2nd compare value
203212   SET_CY( (srcdata < data) );
r3485r3486
208217{
209218   UINT8 data = ROP_ARG(PC++);            //Grab data
210219   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
211   UINT8 srcdata = R_R(r);               //Grab value of R0 - R7
220   UINT8 srcdata = R_REG(r);               //Grab value of R0 - R7
212221
213222   if(srcdata != data)                  //Jump if values are not equal
223   {
214224      PC = PC + rel_addr;
225      change_pc(PC);
226   }
215227
216228   //Set carry flag to 1 if 1st compare value is < 2nd compare value
217229   SET_CY( (srcdata < data) );
r3485r3486
233245//CLR A                                     /* 1: 1110 0100 */
234246INLINE void clr_a(void)
235247{
236   SFR_W(ACC,0);                     //Clear Accumulator
248   SET_ACC(0);                     //Clear Accumulator
237249}
238250
239251//CPL bit addr                              /* 1: 1011 0010 */
r3485r3486
254266//CPL A                                     /* 1: 1111 0100 */
255267INLINE void cpl_a(void)
256268{
257   UINT8 data = ((~R_ACC)&0xff);
258   SFR_W(ACC,data);                  //Complement Accumulator
269   UINT8 data = ((~ACC)&0xff);
270   SET_ACC(data);                  //Complement Accumulator
259271}
260272
261273//DA A                                      /* 1: 1101 0100 */
r3485r3486
269281 If the carry is set, OR the four high bits 4-7 exceed nine, six is added to the value of these bits.
270282 The carry flag will be set if the result is > 0x99, but not cleared otherwise */
271283
272 UINT16 new_acc = R_ACC & 0xff;
284 UINT16 new_acc = ACC & 0xff;
273285 if(GET_AC || (new_acc & 0x0f) > 0x09)
274286    new_acc += 0x06;
275287 if(GET_CY || ((new_acc & 0xf0) > 0x90) || (new_acc & ~0xff))
276288    new_acc += 0x60;
277 SFR_W(ACC,new_acc&0xff);
289 SET_ACC(new_acc&0xff);
278290 if(new_acc & ~0xff)
279291   SET_CY(1);
280292}
r3485r3486
282294//DEC A                                     /* 1: 0001 0100 */
283295INLINE void dec_a(void)
284296{
285   SFR_W(ACC,R_ACC-1);
297   SET_ACC(ACC-1);
286298}
287299
288300//DEC data addr                             /* 1: 0001 0101 */
r3485r3486
296308//DEC @R0/@R1                               /* 1: 0001 011i */
297309INLINE void dec_ir(int r)
298310{
299   UINT8 data = IRAM_IR(R_R(r));
300   IRAM_W(R_R(r),data-1);
311   UINT8 data = IRAM_IR(R_REG(r));
312   IRAM_W(R_REG(r),data-1);
301313}
302314
303315//DEC R0 to R7                              /* 1: 0001 1rrr */
304316INLINE void dec_r(int r)
305317{
306   R_R(r) = R_R(r) - 1;
318   SET_REG(r, R_REG(r) - 1);
307319}
308320
309321//DIV AB                                    /* 1: 1000 0100 */
310322INLINE void div_ab(void)
311323{
312   if( R_B == 0 ) {
324   if( B == 0 ) {
313325      //Overflow flag is set!
314326      SET_OV(1);
315327      //Really the values are undefined according to the manual, but we'll just leave them as is..
316      //SFR_W(ACC,0xff);
328      //SET_ACC(0xff);
317329      //SFR_W(B,0xff);
318330   }
319331   else {
320      int a = (int)R_ACC/R_B;
321      int b = (int)R_ACC%R_B;
332      int a = (int)ACC / B;
333      int b = (int)ACC % B;
322334      //A gets quotient byte, B gets remainder byte
323      SFR_W(ACC,a);
324      SFR_W(B,  b);
335      SET_ACC(a);
336      B = b;
325337      //Overflow flag is cleared
326338      SET_OV(0);
327339   }
r3485r3486
336348   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
337349   IRAM_W(addr,IRAM_R(addr) - 1);         //Decrement value contained at data address
338350   if(IRAM_R(addr) != 0)               //Branch if contents of data address is not 0
351   {
339352      PC = PC + rel_addr;
353      change_pc(PC);
354   }
340355}
341356
342357//DJNZ R0 to R7,code addr                   /* 1: 1101 1rrr */
343358INLINE void djnz_r(int r)
344359{
345360   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
346   R_R(r) = R_R(r) - 1;               //Decrement value
347   if(R_R(r) != 0)                     //Branch if contents of R0 - R7 is not 0
361   SET_REG(r ,R_REG(r) - 1);               //Decrement value
362   if(R_REG(r) != 0)                     //Branch if contents of R0 - R7 is not 0
363   {
348364      PC = PC + rel_addr;
365      change_pc(PC);
366   }
349367}
350368
351369//INC A                                     /* 1: 0000 0100 */
352370INLINE void inc_a(void)
353371{
354   SFR_W(ACC,R_ACC+1);
372   SET_ACC(ACC+1);
355373}
356374
357375//INC data addr                             /* 1: 0000 0101 */
r3485r3486
365383//INC @R0/@R1                               /* 1: 0000 011i */
366384INLINE void inc_ir(int r)
367385{
368   UINT8 data = IRAM_IR(R_R(r));
369   IRAM_W(R_R(r),data+1);
386   UINT8 data = IRAM_IR(R_REG(r));
387   IRAM_W(R_REG(r),data+1);
370388}
371389
372390//INC R0 to R7                              /* 1: 0000 1rrr */
373391INLINE void inc_r(int r)
374392{
375   UINT8 data = R_R(r);
376   R_R(r) = data + 1;
393   UINT8 data = R_REG(r);
394   SET_REG(r, data + 1);
377395}
378396
379397//INC DPTR                                  /* 1: 1010 0011 */
380398INLINE void inc_dptr(void)
381399{
382   UINT16 dptr = (R_DPTR)+1;
383   DPTR_W(dptr);
400   UINT16 dptr = (DPTR)+1;
401   SET_DPTR(dptr);
384402}
385403
386404//JB  bit addr, code addr                   /* 1: 0010 0000 */
r3485r3486
389407   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
390408   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
391409   if(BIT_R(addr))                     //If bit set at specified bit address, jump
410   {
392411      PC = PC + rel_addr;
412      change_pc(PC);
413   }
393414}
394415
395416//JBC bit addr, code addr                   /* 1: 0001 0000 */
r3485r3486
400421   if(BIT_R(addr))   {                  //If bit set at specified bit address, jump
401422      PC = PC + rel_addr;
402423      BIT_W(addr,0);                  //Clear Bit also
424      change_pc(PC);
403425   }
404426}
405427
r3485r3486
408430{
409431   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
410432   if(GET_CY)                        //Jump if Carry Flag Set
433   {
411434      PC = PC + rel_addr;
435      change_pc(PC);
436   }
412437}
413438
414439//JMP @A+DPTR                               /* 1: 0111 0011 */
415440INLINE void jmp_iadptr(void)
416441{
417   PC = R_ACC+R_DPTR;
442   PC = ACC + DPTR;
443   change_pc(PC);
418444}
419445
420446//JNB bit addr, code addr                   /* 1: 0011 0000 */
r3485r3486
423449   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
424450   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
425451   if(!BIT_R(addr))                  //If bit NOT set at specified bit address, jump
452   {
426453      PC = PC + rel_addr;
454      change_pc(PC);
455   }
427456}
428457
429458//JNC code addr                             /* 1: 0101 0000 */
r3485r3486
431460{
432461   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
433462   if(!GET_CY)                        //Jump if Carry Flag not set
463   {
434464      PC = PC + rel_addr;
465      change_pc(PC);
466   }
435467}
436468
437469//JNZ code addr                             /* 1: 0111 0000 */
438470INLINE void jnz(void)
439471{
440472   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
441   if(R_ACC != 0)                     //Branch if ACC is not 0
473   if(ACC != 0)                     //Branch if ACC is not 0
474   {
442475      PC = PC+rel_addr;
476      change_pc(PC);
477   }
443478}
444479
445480//JZ code addr                              /* 1: 0110 0000 */
446481INLINE void jz(void)
447482{
448483   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
449   if(R_ACC == 0)                     //Branch if ACC is 0
484   if(ACC == 0)                     //Branch if ACC is 0
485   {
450486      PC = PC+rel_addr;
487      change_pc(PC);
488   }
451489}
452490
453491//LCALL code addr                           /* 1: 0001 0010 */
r3485r3486
456494   UINT8 addr_hi, addr_lo;
457495   addr_hi = ROP_ARG(PC++);
458496   addr_lo = ROP_ARG(PC++);
459   PUSH_PC
497   PUSH_PC();
460498   PC = (UINT16)((addr_hi<<8) | addr_lo);
499   change_pc(PC);
461500}
462501
463502//LJMP code addr                            /* 1: 0000 0010 */
r3485r3486
467506   addr_hi = ROP_ARG(PC++);
468507   addr_lo = ROP_ARG(PC++);
469508   PC = (UINT16)((addr_hi<<8) | addr_lo);
509   change_pc(PC);
470510}
471511
472512//MOV A, #data                              /* 1: 0111 0100 */
473513INLINE void mov_a_byte(void)
474514{
475515   UINT8 data = ROP_ARG(PC++);            //Grab data
476   SFR_W(ACC,data);                  //Store data to ACC
516   SET_ACC(data);                  //Store data to ACC
477517}
478518
479519//MOV A, data addr                          /* 1: 1110 0101 */
480520INLINE void mov_a_mem(void)
481521{
482522   UINT8 addr = ROP_ARG(PC++);            //Grab data address
483   SFR_W(ACC,IRAM_R(addr));            //Store contents of data address to ACC
523   SET_ACC(IRAM_R(addr));            //Store contents of data address to ACC
484524}
485525
486526//MOV A,@RO/@R1                             /* 1: 1110 011i */
487527INLINE void mov_a_ir(int r)
488528{
489   SFR_W(ACC,IRAM_IR(R_R(r)));            //Store contents of address pointed by R0 or R1 to ACC
529   SET_ACC(IRAM_IR(R_REG(r)));            //Store contents of address pointed by R0 or R1 to ACC
490530}
491531
492532//MOV A,R0 to R7                            /* 1: 1110 1rrr */
493533INLINE void mov_a_r(int r)
494534{
495   SFR_W(ACC,R_R(r));                  //Store contents of R0 - R7 to ACC
535   SET_ACC(R_REG(r));                  //Store contents of R0 - R7 to ACC
496536}
497537
498538//MOV data addr, #data                      /* 1: 0111 0101 */
r3485r3486
517557INLINE void mov_ir_byte(int r)
518558{
519559   UINT8 data = ROP_ARG(PC++);            //Grab data
520   IRAM_IW(R_R(r),data);               //Store data to address pointed by R0 or R1
560   IRAM_IW(R_REG(r),data);               //Store data to address pointed by R0 or R1
521561}
522562
523563//MOV R0 to R7, #data                       /* 1: 0111 1rrr */
524564INLINE void mov_r_byte(int r)
525565{
526566   UINT8 data = ROP_ARG(PC++);            //Grab data
527   R_R(r) = data;                     //Store to R0 - R7
567   SET_REG(r, data);                     //Store to R0 - R7
528568}
529569
530570//MOV data addr, @R0/@R1                    /* 1: 1000 011i */
531571INLINE void mov_mem_ir(int r)
532572{
533573   UINT8 addr = ROP_ARG(PC++);            //Grab data address
534   IRAM_W(addr,IRAM_IR(R_R(r)));         //Store contents pointed to by R0 or R1 to data address
574   IRAM_W(addr,IRAM_IR(R_REG(r)));         //Store contents pointed to by R0 or R1 to data address
535575}
536576
537577//MOV data addr,R0 to R7                    /* 1: 1000 1rrr */
538578INLINE void mov_mem_r(int r)
539579{
540580   UINT8 addr = ROP_ARG(PC++);            //Grab data address
541   IRAM_W(addr,R_R(r));               //Store contents of R0 - R7 to data address
581   IRAM_W(addr,R_REG(r));               //Store contents of R0 - R7 to data address
542582}
543583
544584//MOV DPTR, #data16                         /* 1: 1001 0000 */
r3485r3486
547587   UINT8 data_hi, data_lo;
548588   data_hi = ROP_ARG(PC++);            //Grab hi byte
549589   data_lo = ROP_ARG(PC++);            //Grab lo byte
550   DPTR_W((UINT16)((data_hi<<8)|data_lo));   //Store to DPTR
590   SET_DPTR((UINT16)((data_hi<<8)|data_lo));   //Store to DPTR
551591}
552592
553593//MOV bit addr, C                           /* 1: 1001 0010 */
r3485r3486
561601INLINE void mov_ir_mem(int r)
562602{
563603   UINT8 addr = ROP_ARG(PC++);            //Grab data address
564   IRAM_IW(R_R(r),IRAM_R(addr));         //Store data from data address to address pointed to by R0 or R1
604   IRAM_IW(R_REG(r),IRAM_R(addr));         //Store data from data address to address pointed to by R0 or R1
565605}
566606
567607//MOV R0 to R7, data addr                   /* 1: 1010 1rrr */
568608INLINE void mov_r_mem(int r)
569609{
570610   UINT8 addr = ROP_ARG(PC++);            //Grab data address
571   R_R(r) = IRAM_R(addr);               //Store to R0 - R7
611   SET_REG(r, IRAM_R(addr));            //Store to R0 - R7
572612}
573613
574614//MOV data addr, A                          /* 1: 1111 0101 */
575615INLINE void mov_mem_a(void)
576616{
577617   UINT8 addr = ROP_ARG(PC++);            //Grab data address
578   IRAM_W(addr,R_ACC);                  //Store A to data address
618   IRAM_W(addr,ACC);                  //Store A to data address
579619}
580620
581621//MOV @R0/@R1, A                            /* 1: 1111 011i */
582622INLINE void mov_ir_a(int r)
583623{
584   IRAM_IW(R_R(r),R_ACC);               //Store A to location pointed to by R0 or R1
624   IRAM_IW(R_REG(r),ACC);               //Store A to location pointed to by R0 or R1
585625}
586626
587627//MOV R0 to R7, A                           /* 1: 1111 1rrr */
588628INLINE void mov_r_a(int r)
589629{
590   R_R(r) = R_ACC;                     //Store A to R0-R7
630   SET_REG(r, ACC);                  //Store A to R0-R7
591631}
592632
593633//MOVC A, @A + PC                           /* 1: 1000 0011 */
594634INLINE void movc_a_iapc(void)
595635{
596636   UINT8 data;
597   data = CODEMEM_R(R_ACC+PC);            //Move a byte from CODE(Program) Memory and store to ACC
598   SFR_W(ACC,data);
637   data = CODEMEM_R(ACC+PC);            //Move a byte from CODE(Program) Memory and store to ACC
638   SET_ACC(data);
599639}
600640
601641//MOV C, bit addr                           /* 1: 1010 0010 */
r3485r3486
609649INLINE void movc_a_iadptr(void)
610650{
611651   UINT8 data;
612   data = CODEMEM_R(R_ACC+R_DPTR);         //Move a byte from CODE(Program) Memory and store to ACC
613   SFR_W(ACC,data);
652   data = CODEMEM_R(ACC + DPTR);         //Move a byte from CODE(Program) Memory and store to ACC
653   SET_ACC(data);
614654}
615655
616656//MOVX A,@DPTR                              /* 1: 1110 0000 */
r3485r3486
618658INLINE void movx_a_idptr(void)
619659{
620660//  UINT8 byte = DATAMEM_R(R_DPTR);         //Grab 1 byte from External DATA memory pointed to by dptr
621   UINT32 addr = ERAM_ADDR(R_DPTR,0xFFFF);
661   UINT32 addr = ERAM_ADDR(DPTR, 0xFFFF);
622662   UINT8 byte = DATAMEM_R(addr);         //Grab 1 byte from External DATA memory pointed to by dptr
623   SFR_W(ACC,byte);                  //Store to ACC
663   SET_ACC(byte);                  //Store to ACC
624664}
625665
626666//MOVX A, @R0/@R1                           /* 1: 1110 001i */
627667//(Move External Ram 8 bit address to A)
628668INLINE void movx_a_ir(int r)
629669{
630   UINT32 addr = ERAM_ADDR(R_R(r),0xFF);   //Grab address by reading location pointed to by R0 or R1
670   UINT32 addr = ERAM_ADDR(R_REG(r),0xFF);   //Grab address by reading location pointed to by R0 or R1
631671   UINT8 byte = DATAMEM_R(addr);         //Grab 1 byte from External DATA memory pointed to by address
632   SFR_W(ACC,byte);                  //Store to ACC
672   SET_ACC(byte);                  //Store to ACC
633673}
634674
635675//MOVX @DPTR,A                              /* 1: 1111 0000 */
636676//(Move A to External Ram 16 bit address)
637677INLINE void movx_idptr_a(void)
638678{
639//  DATAMEM_W(R_DPTR, R_ACC);               //Store ACC to External DATA memory address pointed to by DPTR
640   UINT32 addr = ERAM_ADDR(R_DPTR,0xFFFF);
641   DATAMEM_W(addr, R_ACC);            //Store ACC to External DATA memory address pointed to by DPTR
679//  DATAMEM_W(R_DPTR, ACC);               //Store ACC to External DATA memory address pointed to by DPTR
680   UINT32 addr = ERAM_ADDR(DPTR, 0xFFFF);
681   DATAMEM_W(addr, ACC);            //Store ACC to External DATA memory address pointed to by DPTR
642682}
643683
644684//MOVX @R0/@R1,A                            /* 1: 1111 001i */
645685//(Move A to External Ram 8 bit address)
646686INLINE void movx_ir_a(int r)
647687{
648   UINT32 addr = ERAM_ADDR(R_R(r),0xFF);   //Grab address by reading location pointed to by R0 or R1
649   DATAMEM_W(addr, R_ACC);               //Store ACC to External DATA memory address
688   UINT32 addr = ERAM_ADDR(R_REG(r),0xFF);   //Grab address by reading location pointed to by R0 or R1
689   DATAMEM_W(addr, ACC);               //Store ACC to External DATA memory address
650690}
651691
652692//MUL AB                                    /* 1: 1010 0100 */
653693INLINE void mul_ab(void)
654694{
655   UINT16 result = R_ACC * R_B;
695   UINT16 result = ACC * B;
656696   //A gets lo bits, B gets hi bits of result
657   SFR_W(B,(UINT8)((result & 0xFF00) >> 8));
658   SFR_W(ACC,(UINT8)(result & 0x00FF));
697   B = (UINT8) ((result & 0xFF00) >> 8);
698   SET_ACC((UINT8)(result & 0x00FF));
659699   //Set flags
660700   SET_OV( ((result & 0x100) >> 8) );      //Set/Clear Overflow Flag if result > 255
661701   SET_CY(0);                        //Carry Flag always cleared
r3485r3486
671711{
672712   UINT8 addr = ROP_ARG(PC++);            //Grab data address
673713   UINT8 data = IRAM_R(addr);            //Grab data from data address
674   IRAM_W(addr,data | R_ACC);            //Set data address value to it's value Logical OR with ACC
714   IRAM_W(addr,data | ACC);            //Set data address value to it's value Logical OR with ACC
675715}
676716
677717//ORL data addr, #data                      /* 1: 0100 0011 */
r3485r3486
687727INLINE void orl_a_byte(void)
688728{
689729   UINT8 data = ROP_ARG(PC++);            //Grab data
690   SFR_W(ACC,R_ACC | data);            //Set ACC to value of ACC Logical OR with Data
730   SET_ACC(ACC | data);            //Set ACC to value of ACC Logical OR with Data
691731}
692732
693733//ORL A, data addr                          /* 1: 0100 0101 */
r3485r3486
695735{
696736   UINT8 addr = ROP_ARG(PC++);            //Grab data address
697737   UINT8 data = IRAM_R(addr);            //Grab data from data address
698   SFR_W(ACC,R_ACC | data);            //Set ACC to value of ACC Logical OR with Data
738   SET_ACC(ACC | data);            //Set ACC to value of ACC Logical OR with Data
699739}
700740
701741//ORL A, @RO/@R1                            /* 1: 0100 011i */
702742INLINE void orl_a_ir(int r)
703743{
704   UINT8 data = IRAM_IR(R_R(r));         //Grab data from address R0 or R1 points to
705   SFR_W(ACC,R_ACC | data);            //Set ACC to value of ACC Logical OR with Data
744   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from address R0 or R1 points to
745   SET_ACC(ACC | data);            //Set ACC to value of ACC Logical OR with Data
706746}
707747
708748//ORL A, RO to R7                           /* 1: 0100 1rrr */
709749INLINE void orl_a_r(int r)
710750{
711   UINT8 data = R_R(r);               //Grab data from R0 - R7
712   SFR_W(ACC,R_ACC | data);            //Set ACC to value of ACC Logical OR with Data
751   UINT8 data = R_REG(r);               //Grab data from R0 - R7
752   SET_ACC(ACC | data);            //Set ACC to value of ACC Logical OR with Data
713753}
714754
715755//ORL C, bit addr                           /* 1: 0111 0010 */
r3485r3486
735775INLINE void pop(void)
736776{
737777   UINT8 addr = ROP_ARG(PC++);            //Grab data address
738   IRAM_W(addr, IRAM_IR(R_SP));         //Store to contents of data addr, data pointed to by Stack - IRAM_IR needed to access upper 128 bytes of stack
778   IRAM_W(addr, IRAM_IR(SP));            //Store to contents of data addr, data pointed to by Stack - IRAM_IR needed to access upper 128 bytes of stack
739779   //IRAM_IW(addr, IRAM_IR(R_SP));         //Store to contents of data addr, data pointed to by Stack - doesn't work, sfr's are not restored this way and it's not an indirect access anyway
740   SFR_W(SP,R_SP-1);                  //Decrement SP
780   SP = SP-1;                        //Decrement SP
741781}
742782
743783//PUSH data addr                            /* 1: 1100 0000 */
744784INLINE void push(void)
745785{
746786   UINT8 addr = ROP_ARG(PC++);            //Grab data address
747   UINT8 tmpSP = R_SP;                  //Grab and Increment Stack Pointer
748   tmpSP++;                        // ""
749   SFR_W(SP,tmpSP);                  // ""
750    if (tmpSP == R_SP)                  //Ensure it was able to write to new stack location
751      IRAM_IW(tmpSP, IRAM_R(addr));      //Store to stack contents of data address - IRAM_IW needed to store to upper 128 bytes of stack, however, can't use IRAM_IR because that won't store the sfrs and it's not an indirect access anyway
787   UINT8 tmpSP = SP+1;               //Grab and Increment Stack Pointer
788   SP = tmpSP;                     // ""
789   IRAM_IW(tmpSP, IRAM_R(addr));         //Store to stack contents of data address - IRAM_IW needed to store to upper 128 bytes of stack, however, can't use IRAM_IR because that won't store the sfrs and it's not an indirect access anyway
752790}
753791
754792//RET                                       /* 1: 0010 0010 */
755793INLINE void ret(void)
756794{
757   POP_PC
795   POP_PC();
758796}
759797
760798//RETI                                      /* 1: 0011 0010 */
761799INLINE void reti(void)
762800{
763   POP_PC
764   CLEAR_CURRENT_IRQ
801   POP_PC();
802   CLEAR_CURRENT_IRQ();
765803}
766804
767805//RL A                                      /* 1: 0010 0011 */
768806INLINE void rl_a(void)
769807{
770808   //Left Shift A, Bit 7 carries to Bit 0
771   int carry = ((R_ACC & 0x80) >> 7);
772   int data = (R_ACC<<1) & 0xfe;
773   SFR_W(ACC, data | carry);
809   int carry = ((ACC & 0x80) >> 7);
810   int data = (ACC<<1) & 0xfe;
811   SET_ACC( data | carry);
774812}
775813
776814//RLC A                                     /* 1: 0011 0011 */
777815INLINE void rlc_a(void)
778816{
779817   //Left Shift A, Bit 7 goes to Carry Flag, Original Carry Flag goes to Bit 0 of ACC
780   int carry = ((R_ACC & 0x80) >> 7);
781   int data = ((R_ACC<<1) & 0xfe) | GET_CY;
782   SFR_W(ACC, data);
818   int carry = ((ACC & 0x80) >> 7);
819   int data = ((ACC<<1) & 0xfe) | GET_CY;
820   SET_ACC( data);
783821   SET_CY(carry);
784822}
785823
r3485r3486
787825INLINE void rr_a(void)
788826{
789827   //Right Shift A, Bit 0 carries to Bit 7
790   int carry = ((R_ACC & 1) << 7);
791   int data = (R_ACC>>1) & 0x7f;
792   SFR_W(ACC, data | carry);
828   int carry = ((ACC & 1) << 7);
829   int data = (ACC>>1) & 0x7f;
830   SET_ACC( data | carry);
793831}
794832
795833//RRC A                                     /* 1: 0001 0011 */
796834INLINE void rrc_a(void)
797835{
798836   //Right Shift A, Bit 0 goes to Carry Flag, Bit 7 of ACC gets set to original Carry Flag
799   int carry = (R_ACC & 1);
800   int data = ((R_ACC>>1) & 0x7f) | (GET_CY<<7);
801   SFR_W(ACC, data);
837   int carry = (ACC & 1);
838   int data = ((ACC>>1) & 0x7f) | (GET_CY<<7);
839   SET_ACC( data);
802840   SET_CY(carry);
803841}
804842
r3485r3486
820858{
821859   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
822860   PC = PC + rel_addr;                  //Update PC
861   change_pc(PC);
823862}
824863
825864//SUBB A, #data                             /* 1: 1001 0100 */
826865INLINE void subb_a_byte(void)
827866{
828867   UINT8 data = ROP_ARG(PC++);            //Grab data
829   UINT8 result = R_ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
830   DO_SUB_FLAGS(R_ACC,data,GET_CY);      //Set Flags
831   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
868   UINT8 result = ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
869   DO_SUB_FLAGS(ACC,data,GET_CY);      //Set Flags
870   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
832871
833872}
834873
r3485r3486
837876{
838877   UINT8 addr = ROP_ARG(PC++);            //Grab data address
839878   UINT8 data = IRAM_R(addr);            //Grab data from data address
840   UINT8 result = R_ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
841   DO_SUB_FLAGS(R_ACC,data,GET_CY);      //Set Flags
842   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
879   UINT8 result = ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
880   DO_SUB_FLAGS(ACC,data,GET_CY);      //Set Flags
881   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
843882}
844883
845884//SUBB A, @R0/@R1                           /* 1: 1001 011i */
846885INLINE void subb_a_ir(int r)
847886{
848   UINT8 data = IRAM_IR(R_R(r));         //Grab data from memory pointed to by R0 or R1
849   UINT8 result = R_ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
850   DO_SUB_FLAGS(R_ACC,data,GET_CY);      //Set Flags
851   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
887   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from memory pointed to by R0 or R1
888   UINT8 result = ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
889   DO_SUB_FLAGS(ACC,data,GET_CY);      //Set Flags
890   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
852891}
853892
854893//SUBB A, R0 to R7                          /* 1: 1001 1rrr */
855894INLINE void subb_a_r(int r)
856895{
857   UINT8 data = R_R(r);               //Grab data from R0 - R7
858   UINT8 result = R_ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
859   DO_SUB_FLAGS(R_ACC,data,GET_CY);      //Set Flags
860   SFR_W(ACC,result);                  //Store 8 bit result of addtion in ACC
896   UINT8 data = R_REG(r);               //Grab data from R0 - R7
897   UINT8 result = ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
898   DO_SUB_FLAGS(ACC,data,GET_CY);      //Set Flags
899   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
861900}
862901
863902//SWAP A                                    /* 1: 1100 0100 */
864903INLINE void swap_a(void)
865904{
866905   UINT8 a_nib_lo, a_nib_hi;
867   a_nib_hi = (R_ACC & 0x0f) << 4;         //Grab lo byte of ACC and move to hi
868   a_nib_lo = (R_ACC & 0xf0) >> 4;         //Grab hi byte of ACC and move to lo
869   SFR_W(ACC, a_nib_hi | a_nib_lo);
906   a_nib_hi = (ACC & 0x0f) << 4;         //Grab lo byte of ACC and move to hi
907   a_nib_lo = (ACC & 0xf0) >> 4;         //Grab hi byte of ACC and move to lo
908   SET_ACC( a_nib_hi | a_nib_lo);
870909}
871910
872911//XCH A, data addr                          /* 1: 1100 0101 */
r3485r3486
874913{
875914   UINT8 addr = ROP_ARG(PC++);            //Grab data address
876915   UINT8 data = IRAM_R(addr);            //Grab data
877   UINT8 oldACC = R_ACC;               //Hold value of ACC
878   SFR_W(ACC,data);                  //Sets ACC to data
916   UINT8 oldACC = ACC;               //Hold value of ACC
917   SET_ACC(data);                  //Sets ACC to data
879918   IRAM_W(addr,oldACC);               //Sets data address to old value of ACC
880919}
881920
882921//XCH A, @RO/@R1                            /* 1: 1100 011i */
883922INLINE void xch_a_ir(int r)
884923{
885   UINT8 data = IRAM_IR(R_R(r));         //Grab data pointed to by R0 or R1
886   UINT8 oldACC = R_ACC;               //Hold value of ACC
887   SFR_W(ACC,data);                  //Sets ACC to data
888   IRAM_W(R_R(r),oldACC);               //Sets data address to old value of ACC
924   UINT8 data = IRAM_IR(R_REG(r));         //Grab data pointed to by R0 or R1
925   UINT8 oldACC = ACC;               //Hold value of ACC
926   SET_ACC(data);                  //Sets ACC to data
927   IRAM_W(R_REG(r),oldACC);               //Sets data address to old value of ACC
889928}
890929
891930//XCH A, RO to R7                           /* 1: 1100 1rrr */
892931INLINE void xch_a_r(int r)
893932{
894   UINT8 data = R_R(r);               //Grab data from R0-R7
895   UINT8 oldACC = R_ACC;               //Hold value of ACC
896   SFR_W(ACC,data);                  //Sets ACC to data
897   R_R(r) = oldACC;                  //Sets data address to old value of ACC
933   UINT8 data = R_REG(r);               //Grab data from R0-R7
934   UINT8 oldACC = ACC;               //Hold value of ACC
935   SET_ACC(data);                  //Sets ACC to data
936   SET_REG(r, oldACC);                  //Sets data address to old value of ACC
898937}
899938
900939//XCHD A, @R0/@R1                           /* 1: 1101 011i */
901940INLINE void xchd_a_ir(int r)
902941{
903942   UINT8 acc, ir_data;
904   ir_data = IRAM_IR(R_R(r));            //Grab data pointed to by R0 or R1
905   acc = R_ACC;                     //Grab ACC value
906   SFR_W(ACC, (acc & 0xf0) | (ir_data & 0x0f) );      //Set ACC to lower nibble of data pointed to by R0 or R1
907   IRAM_W(R_R(r), (ir_data & 0xf0) | (acc & 0x0f) );   //Set data pointed to by R0 or R1 to lower nibble of ACC
943   ir_data = IRAM_IR(R_REG(r));            //Grab data pointed to by R0 or R1
944   acc = ACC;                     //Grab ACC value
945   SET_ACC( (acc & 0xf0) | (ir_data & 0x0f) );      //Set ACC to lower nibble of data pointed to by R0 or R1
946   IRAM_W(R_REG(r), (ir_data & 0xf0) | (acc & 0x0f) );   //Set data pointed to by R0 or R1 to lower nibble of ACC
908947}
909948
910949//XRL data addr, A                          /* 1: 0110 0010 */
r3485r3486
912951{
913952   UINT8 addr = ROP_ARG(PC++);            //Grab data address
914953   UINT8 data = IRAM_R(addr);            //Grab data from data address
915   IRAM_W(addr,data ^ R_ACC);            //Set data address value to it's value Logical XOR with ACC
954   IRAM_W(addr,data ^ ACC);            //Set data address value to it's value Logical XOR with ACC
916955}
917956
918957//XRL data addr, #data                      /* 1: 0110 0011 */
r3485r3486
928967INLINE void xrl_a_byte(void)
929968{
930969   UINT8 data = ROP_ARG(PC++);            //Grab data
931   SFR_W(ACC,R_ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
970   SET_ACC(ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
932971}
933972
934973//XRL A, data addr                          /* 1: 0110 0101 */
r3485r3486
936975{
937976   UINT8 addr = ROP_ARG(PC++);            //Grab data address
938977   UINT8 data = IRAM_R(addr);            //Grab data from data address
939   SFR_W(ACC,R_ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
978   SET_ACC(ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
940979}
941980
942981//XRL A, @R0/@R1                            /* 1: 0110 011i */
943982INLINE void xrl_a_ir(int r)
944983{
945   UINT8 data = IRAM_IR(R_R(r));         //Grab data from address R0 or R1 points to
946   SFR_W(ACC,R_ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
984   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from address R0 or R1 points to
985   SET_ACC(ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
947986}
948987
949988//XRL A, R0 to R7                           /* 1: 0110 1rrr */
950989INLINE void xrl_a_r(int r)
951990{
952   UINT8 data = R_R(r);               //Grab data from R0 - R7
953   SFR_W(ACC,R_ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
991   UINT8 data = R_REG(r);               //Grab data from R0 - R7
992   SET_ACC(ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
954993}
955994
956995//illegal opcodes
957INLINE void illegal(void)
996INLINE void illegal(UINT8 op)
958997{
959   LOG(("i8051 #%d: illegal opcode at 0x%03x: %02x\n", cpu_getactivecpu(), PC, ROP(PC)));
998   LOG(("i8051 #%d: illegal opcode at 0x%03x: %02x\n", cpu_getactivecpu(), PC-1, op));
960999}
src/emu/cpu/i8051/i8051.h
r3485r3486
4343   I8051_R0, I8051_R1, I8051_R2, I8051_R3, I8051_R4, I8051_R5, I8051_R6, I8051_R7, I8051_RB
4444};
4545
46#define I8051_INT0_LINE      0   /* External Interrupt 0 */
47#define I8051_INT1_LINE      1   /* External Interrupt 1 */
48#define I8051_T0_LINE      2   /* Timer 0 External Input */
49#define I8051_T1_LINE      3   /* Timer 1 External Input */
50#define I8051_RX_LINE      4   /* Serial Port Receive Line */
46enum
47{
48   I8051_INT0_LINE = 0,    /* P3.2: External Interrupt 0 */
49   I8051_INT1_LINE,      /* P3.3: External Interrupt 1 */
50   I8051_RX_LINE,         /* P3.0: Serial Port Receive Line */
51   MCS51_T0_LINE,         /* P3,4: Timer 0 External Input */
52   MCS51_T1_LINE,         /* P3.5: Timer 1 External Input */
53   MCS51_T2_LINE,         /* P1.0: Timer 2 External Input */
54   MCS51_T2EX_LINE,      /* P1.1: Timer 2 Capture Reload Trigger */
55};
5156
52/* definition of the special function registers. Note that the values are */
53/* the same as the internal memory address in the 8051 */
54#define      P0      0x80
55#define      SP      0x81
56#define      DPL      0x82
57#define      DPH      0x83
58#define      PCON      0x87
59#define      TCON      0x88
60#define      TMOD      0x89
61#define      TL0      0x8a
62#define      TL1      0x8b
63#define      TH0      0x8c
64#define      TH1      0x8d
65#define      P1      0x90
66#define      SCON      0x98
67#define      SBUF      0x99
68#define      P2      0xa0
69#define      IE      0xa8
70#define      P3      0xb0
71#define      IP      0xb8
72//8052 Only registers
73#if (HAS_I8052 || HAS_I8752)
74 #define      T2CON   0xc8
75 #define      RCAP2L   0xca
76 #define      RCAP2H   0xcb
77 #define      TL2   0xcc
78 #define      TH2   0xcd
79#endif
80#define      PSW      0xd0
81#define      ACC      0xe0
82#define      B      0xf0
57/* special I/O space ports */
8358
84/* commonly used bit address for the 8051 */
85#define      C      0xd7
86#define      P      0xd0
87#define      AC      0xd6
88#define      OV      0xd2
89#define      TF0      0x8d
90#define      TF1      0x8f
91#define      IE0      0x89
92#define      IE1      0x8b
93#define      TI      0x99
94#define      RI      0x98
59enum
60{
61   MCS51_PORT_P0   = 0x10000,
62   MCS51_PORT_P1   = 0x10001,
63   MCS51_PORT_P2   = 0x10002,
64   MCS51_PORT_P3   = 0x10003,
65   MCS51_PORT_TX   = 0x10004,   /* P3.1 */
66};
9567
96#define TI_FLAG 1
97#define RI_FLAG 2
9868
99extern void i8051_init (int index, int clock, const void *config, int (*irqcallback)(int));               /* Initialize save states */
100extern void i8051_reset (void);         /* Reset registers to the initial values */
101extern void i8051_exit   (void);             /* Shut down CPU core */
102extern int  i8051_execute(int cycles);         /* Execute cycles - returns number of cycles actually run */
103extern void i8051_get_context (void *dst);   /* Get registers, return context size */
104extern void i8051_set_context (void *src);       /* Set registers */
105extern unsigned i8051_get_intram (int offset);
106extern unsigned i8051_get_reg (int regnum);
107extern void i8051_set_reg (int regnum, unsigned val);
108extern void i8051_set_irq_line(int irqline, int state);
109extern void i8051_set_irq_callback(int (*callback)(int irqline));
110extern void i8051_state_save(void *file);
111extern void i8051_state_load(void *file);
69/***************************************************************************
70    FUNCTION PROTOTYPES
71***************************************************************************/
11272
113WRITE8_HANDLER( i8051_internal_w );
114READ8_HANDLER( i8051_internal_r );
115
11673extern void i8051_set_serial_tx_callback(void (*callback)(int data));
11774extern void i8051_set_serial_rx_callback(int (*callback)(void));
118extern void i8051_set_eram_iaddr_callback(READ32_HANDLER((*callback)));
11975
120extern offs_t i8051_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
76/* variants with no internal rom and 128 byte internal memory */
77void i8031_get_info(UINT32 state, cpuinfo *info);
12178
122/****************************************************************************
123 * 8752 Section
124 ****************************************************************************/
125#if (HAS_I8752)
126extern void i8752_init (int index, int clock, const void *config, int (*irqcallback)(int));               /* Initialize save states */
127extern void i8752_reset (void);         /* Reset registers to the initial values */
128extern void i8752_exit   (void);             /* Shut down CPU core */
129extern int   i8752_execute(int cycles);         /* Execute cycles - returns number of cycles actually run */
130extern void i8752_get_context (void *dst);   /* Get registers, return context size */
131extern void i8752_set_context (void *src);      /* Set registers */
132extern unsigned i8752_get_reg (int regnum);
133extern void i8752_set_reg (int regnum, unsigned val);
134extern void i8752_set_irq_line(int irqline, int state);
135extern void i8752_set_irq_callback(int (*callback)(int irqline));
136extern void i8752_state_save(void *file);
137extern void i8752_state_load(void *file);
138extern void i8752_set_serial_tx_callback(void (*callback)(int data));
139extern void i8752_set_serial_rx_callback(int (*callback)(void));
140WRITE8_HANDLER( i8752_internal_w );
141READ8_HANDLER( i8752_internal_r );
142#endif   //(HAS_8752)
79/* variants with no internal rom and 256 byte internal memory */
80void i8032_get_info(UINT32 state, cpuinfo *info);
14381
144
82/* variants 4k internal rom and 128 byte internal memory */
14583void i8051_get_info(UINT32 state, cpuinfo *info);
146void i8052_get_info(UINT32 state, cpuinfo *info);
14784void i8751_get_info(UINT32 state, cpuinfo *info);
85
86/* variants 8k internal rom and 256 byte internal memory and more registers */
87void i8052_get_info(UINT32 state, cpuinfo *info);
14888void i8752_get_info(UINT32 state, cpuinfo *info);
14989
90/* cmos variants */
91void i80c31_get_info(UINT32 state, cpuinfo *info);
92void i80c32_get_info(UINT32 state, cpuinfo *info);
93void i80c51_get_info(UINT32 state, cpuinfo *info);
94void i80c52_get_info(UINT32 state, cpuinfo *info);
95void i87c51_get_info(UINT32 state, cpuinfo *info);
96void i87c52_get_info(UINT32 state, cpuinfo *info);
97
98/* 4k internal perom and 128 internal ram and 2 analog comparators */
99void at89c4051_get_info(UINT32 state, cpuinfo *info);
100
101/****************************************************************************
102 * Disassembler
103 ****************************************************************************/
104
105offs_t i8051_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
106
150107#endif /* __I8051_H__ */
src/emu/video/tms34061.c
r3485r3486
8686   /* allocate memory for VRAM */
8787   tms34061.vram = auto_malloc(tms34061.intf.vramsize + 256 * 2);
8888   memset(tms34061.vram, 0, tms34061.intf.vramsize + 256 * 2);
89   /* not really a save state, just there for debugging purposes */
90   state_save_register_global_pointer(tms34061.vram, tms34061.intf.vramsize);
8991
9092   /* allocate memory for latch RAM */
9193   tms34061.latchram = auto_malloc(tms34061.intf.vramsize + 256 * 2);
r3485r3486
369371
370372   /* mask to the VRAM size */
371373   pixeloffs &= tms34061.vrammask;
374   if (VERBOSE) logerror("%04X:tms34061 xy (%04x) = %02x/%02x\n", activecpu_get_pc(), pixeloffs, data, tms34061.latchdata);
372375
373376   /* set the pixel data */
374377   tms34061.vram[pixeloffs] = data;
r3485r3486
424427         offs = ((row << tms34061.intf.rowshift) | col) & tms34061.vrammask;
425428         if (tms34061.regs[TMS34061_CONTROL2] & 0x0040)
426429            offs |= (tms34061.regs[TMS34061_CONTROL2] & 3) << 16;
430         if (VERBOSE) logerror("%04X:tms34061 direct (%04x) = %02x/%02x\n", activecpu_get_pc(), offs, data, tms34061.latchdata);
427431         if (tms34061.vram[offs] != data || tms34061.latchram[offs] != tms34061.latchdata)
428432         {
429433            tms34061.vram[offs] = data;
r3485r3486
437441         if (tms34061.regs[TMS34061_CONTROL2] & 0x0040)
438442            offs |= (tms34061.regs[TMS34061_CONTROL2] & 3) << 16;
439443         offs &= tms34061.vrammask;
444         if (VERBOSE) logerror("%04X:tms34061 shiftreg write (%04x)\n", activecpu_get_pc(), offs);
440445
441446         memcpy(&tms34061.vram[offs], tms34061.shiftreg, (size_t)1 << tms34061.intf.rowshift);
442447         memset(&tms34061.latchram[offs], tms34061.latchdata, (size_t)1 << tms34061.intf.rowshift);
r3485r3486
448453         if (tms34061.regs[TMS34061_CONTROL2] & 0x0040)
449454            offs |= (tms34061.regs[TMS34061_CONTROL2] & 3) << 16;
450455         offs &= tms34061.vrammask;
456         if (VERBOSE) logerror("%04X:tms34061 shiftreg read (%04x)\n", activecpu_get_pc(), offs);
451457
452458         tms34061.shiftreg = &tms34061.vram[offs];
453459         break;
src/emu/machine/z80pio.c
r3485r3486
396396         {
397397            /* disable interrupts until mask is written */
398398            z80pio_set_irq_enable(device, channel, 0);
399     
399
400400            /* reset pending interrupt */
401401            z80pio->irq_pending[channel] = 0;
402402
src/emu/machine/ldvp931.c
r3485r3486
102102static WRITE8_HANDLER( output0_w );
103103static WRITE8_HANDLER( output1_w );
104104static WRITE8_HANDLER( lcd_w );
105static READ8_HANDLER( unknown_r );
105106static READ8_HANDLER( keypad_r );
106107static READ8_HANDLER( datic_r );
107108static READ8_HANDLER( from_controller_r );
r3485r3486
137138
138139static ADDRESS_MAP_START( vp931_portmap, ADDRESS_SPACE_IO, 8 )
139140   AM_RANGE(0x00, 0x00) AM_MIRROR(0xcf) AM_READWRITE(keypad_r, output0_w)
140   AM_RANGE(0x10, 0x10) AM_MIRROR(0xcf) AM_WRITE(output1_w)
141   AM_RANGE(0x10, 0x10) AM_MIRROR(0xcf) AM_READWRITE(unknown_r, output1_w)
141142   AM_RANGE(0x20, 0x20) AM_MIRROR(0xcf) AM_READWRITE(datic_r, lcd_w)
142143   AM_RANGE(0x30, 0x30) AM_MIRROR(0xcf) AM_READWRITE(from_controller_r, to_controller_w)
143144   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(port1_r, port1_w)
r3485r3486
553554
554555
555556/*-------------------------------------------------
557    unknown_r - unknown input port
558-------------------------------------------------*/
559
560static READ8_HANDLER( unknown_r )
561{
562   /* only bit $80 is checked and its effects are minor */
563   return 0x00;
564}
565
566
567/*-------------------------------------------------
556568    keypad_r - vestigial keypad/button controls
557569-------------------------------------------------*/
558570
src/emu/cpuintrf.c
r3485r3486
6262void n7751_get_info(UINT32 state, cpuinfo *info);
6363void m58715_get_info(UINT32 state, cpuinfo *info);
6464void i8x41_get_info(UINT32 state, cpuinfo *info);
65void i8031_get_info(UINT32 state, cpuinfo *info);
66void i8032_get_info(UINT32 state, cpuinfo *info);
6567void i8051_get_info(UINT32 state, cpuinfo *info);
6668void i8052_get_info(UINT32 state, cpuinfo *info);
6769void i8751_get_info(UINT32 state, cpuinfo *info);
6870void i8752_get_info(UINT32 state, cpuinfo *info);
71void i80c31_get_info(UINT32 state, cpuinfo *info);
72void i80c32_get_info(UINT32 state, cpuinfo *info);
73void i80c51_get_info(UINT32 state, cpuinfo *info);
74void i80c52_get_info(UINT32 state, cpuinfo *info);
75void i87c51_get_info(UINT32 state, cpuinfo *info);
76void i87c52_get_info(UINT32 state, cpuinfo *info);
77void at89c4051_get_info(UINT32 state, cpuinfo *info);
6978void ds5002fp_get_info(UINT32 state, cpuinfo *info);
7079void m6800_get_info(UINT32 state, cpuinfo *info);
7180void m6801_get_info(UINT32 state, cpuinfo *info);
r3485r3486
415424#if (HAS_I8X41)
416425   { CPU_I8X41, i8x41_get_info },
417426#endif
427#if (HAS_I8031)
428   { CPU_I8031, i8031_get_info },
429#endif
430#if (HAS_I8032)
431   { CPU_I8032, i8032_get_info },
432#endif
418433#if (HAS_I8051)
419434   { CPU_I8051, i8051_get_info },
420435#endif
r3485r3486
427442#if (HAS_I8752)
428443   { CPU_I8752, i8752_get_info },
429444#endif
445#if (HAS_I80C31)
446   { CPU_I80C31, i80c31_get_info },
447#endif
448#if (HAS_I80C32)
449   { CPU_I80C32, i80c32_get_info },
450#endif
451#if (HAS_I80C51)
452   { CPU_I80C51, i80c51_get_info },
453#endif
454#if (HAS_I80C52)
455   { CPU_I80C52, i80c52_get_info },
456#endif
457#if (HAS_I87C51)
458   { CPU_I87C51, i87c51_get_info },
459#endif
460#if (HAS_I87C52)
461   { CPU_I87C52, i87c52_get_info },
462#endif
463#if (HAS_AT89C4051)
464   { CPU_AT89C4051, at89c4051_get_info },
465#endif
430466#if (HAS_DS5002FP)
431467   { CPU_DS5002FP, ds5002fp_get_info },
432468#endif
src/emu/cpuexec.h
r3485r3486
8888   CPU_I8749,
8989   CPU_M58715,
9090   CPU_I8X41,
91   CPU_I8031,
92   CPU_I8032,
9193   CPU_I8051,
9294   CPU_I8052,
9395   CPU_I8751,
9496   CPU_I8752,
97   CPU_I80C31,
98   CPU_I80C32,
99   CPU_I80C51,
100   CPU_I80C52,
101   CPU_I87C51,
102   CPU_I87C52,
103   CPU_AT89C4051,
95104   CPU_DS5002FP,
96105   CPU_M6800,
97106   CPU_M6801,
src/emu/sound/aica.c
r3485r3486
4040#define LPCTL(slot)      ((slot->udata.data[0x0]>>0x9)&0x0001)
4141#define PCMS(slot)      ((slot->udata.data[0x0]>>0x7)&0x0003)
4242
43#define SA(slot)      (((slot->udata.data[0x0]&0x3F)<<16)|(slot->udata.data[0x4/2]))
43#define SA(slot)      (((slot->udata.data[0x0]&0x7F)<<16)|(slot->udata.data[0x4/2]))
4444
4545#define LSA(slot)      (slot->udata.data[0x8/2])
4646
src/mess/machine/kb_keytro.c
r3485r3486
302302WRITE8_HANDLER( kb_keytronic_set_data_signal )
303303{
304304   kb_keytronic.data_signal = data;
305   cpunum_set_input_line( machine, kb_keytronic.cpunum, I8051_T0_LINE, data ? HOLD_LINE : CLEAR_LINE );
305   cpunum_set_input_line( machine, kb_keytronic.cpunum, MCS51_T0_LINE, data ? HOLD_LINE : CLEAR_LINE );
306306}
307307
308308
src/mess/drivers/genesis.c
r3485r3486
395395
396396static DRIVER_INIT( gensvp )
397397{
398   DRIVER_INIT_CALL(megadsvp);
398   DRIVER_INIT_CALL(megadriv);
399399   DRIVER_INIT_CALL(mess_md_common);
400400}
401401
docs/messnew.txt
r3485r3486
3737
3838Source Changes:
3939----------------
40(none)
40- The core is based on MAME 0.128u1.  This incorporates all features of the
41  update to this core.  [MAME team]
4142
4243
4344

Previous 15994 Revisions Next


© 1998-2018 The MESS Team