Previous 15994 Revisions Next

r5569 Thursday 3rd September, 2009 at 23:15:25 UTC by MooglyGuy
- Added more opcodes to the AVR8 core
- Fixed numerous bugs in the SuperFX core
- Hooked up SuperFX chip
[src/emu/cpu/avr8]avr8.c avr8.h avr8dasm.c
[src/emu/cpu/mips]mips3com.c mips3dsm.c
[src/emu/cpu/superfx]sfx_dasm.c superfx.c superfx.h
[src/mame]mame.mak
[src/mame/includes]snes.h
[src/mame/machine]snes.c
[src/mess]messdriv.c
[src/mess/drivers]craft.c snes.c
[src/mess/machine]snescart.c

src/mame/machine/snes.c
r5568r5569
88  Anthony Kruize
99  Based on the original code by Lee Hammerton (aka Savoury Snax)
1010  Thanks to Anomie for invaluable technical information.
11  Thanks to byuu for invaluable technical information.
1112
1213***************************************************************************/
1314#define __MACHINE_SNES_C
1415
1516#include "driver.h"
1617#include "includes/snes.h"
18#include "cpu/superfx/superfx.h"
1719#include "cpu/g65816/g65816.h"
1820
19// add-on chip emulators
20#include "machine/snesdsp1.c"
21#include "machine/snesdsp2.c"
22#include "machine/snesobc1.c"
23
2421/* -- Globals -- */
2522UINT8  *snes_ram = NULL;      /* 65816 ram */
2623UINT8  *spc_ram = NULL;         /* spc700 ram */
r5568r5569
5855   UINT8 oldrol;
5956} joypad[4];
6057
58// add-on chip emulators
59#include "machine/snesdsp1.c"
60#include "machine/snesdsp2.c"
61#include "machine/snesobc1.c"
62#include "machine/snesrtc.c"
63#include "machine/snessdd1.c"
6164
6265/*************************************
6366
r5568r5569
348351      return spc_port_out[offset & 0x3];
349352   }
350353
354   if(snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
355   {
356      if(offset >= 0x3000 && offset < 0x3300)
357      {
358         return superfx_mmio_read(cputag_get_cpu(space->machine, "superfx"), offset);
359      }
360   }
361   else if(snes_has_addon_chip == HAS_RTC)
362   {
363      if(offset == 0x2800 || offset == 0x2801)
364      {
365         return srtc_mmio_read(space->machine, offset);
366      }
367   }
368   else if(snes_has_addon_chip == HAS_SDD1)
369   {
370      if(offset >= 0x4800 && offset < 0x4808)
371      {
372         return sdd1_mmio_read(space->machine, offset);
373      }
374   }
375
351376   /* offset is from 0x000000 */
352377   switch( offset )
353378   {
r5568r5569
665690
666691   }
667692
693   //printf("unsupported read: offset == %08x\n", offset);
694
668695   /* Unsupported reads returns open bus */
669696//  printf("%02x %02x\n",offset,snes_open_bus_r(space,0));
670697   return snes_open_bus_r(space,0);
r5568r5569
687714      return;
688715   }
689716
717   if(snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
718   {
719      if(offset >= 0x3000 && offset < 0x3300)
720      {
721         superfx_mmio_write(cputag_get_cpu(space->machine, "superfx"), offset, data);
722         return;
723      }
724   }
725   else if(snes_has_addon_chip == HAS_RTC)
726   {
727      if(offset == 0x2800 || offset == 0x2801)
728      {
729         srtc_mmio_write(space->machine, offset, data);
730         return;
731      }
732   }
733   else if(snes_has_addon_chip == HAS_SDD1)
734   {
735      if((offset >= 0x4300 && offset < 0x4380) ||
736         (offset >= 0x4800 && offset < 0x4808))
737      {
738         sdd1_mmio_write(space->machine, offset, data);
739         return;
740      }
741   }
742
690743   /* offset is from 0x000000 */
691744   switch( offset )
692745   {
r5568r5569
729782               break;
730783            default:
731784               /* Unknown size so default to 8 & 16 */
732               printf( "Object size unsupported: %d\n", (data & 0xe0) >> 5 );
785               logerror( "Object size unsupported: %d\n", (data & 0xe0) >> 5 );
733786
734787               snes_ppu.oam.size[0] = 1;
735788               snes_ppu.oam.size[1] = 2;
r5568r5569
13011354         break;
13021355   }
13031356
1357   logerror("Unsupported MMIO write: offset %08x = %02x\n", offset, data);
1358
13041359   snes_ram[offset] = data;
13051360}
13061361
1362WRITE_LINE_DEVICE_HANDLER( snes_extern_irq_w )
1363{
1364   cputag_set_input_line(device->machine, "maincpu", G65816_LINE_IRQ, state);
1365}
1366
13071367/*************************************
13081368
13091369    Memory Handlers
r5568r5569
13911451      value = snes_r_io(space, address);
13921452   else if (address < 0x8000)
13931453   {
1394      if (snes_has_addon_chip == HAS_OBC1)
1454      if (snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
1455         value = snes_ram[0x700000 + (address & 0x1fff)];
1456      else if (snes_has_addon_chip == HAS_OBC1)
13951457         value = obc1_read(space, offset);
13961458      else if ((snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
13971459         value = (address < 0x7000) ? DSP2_read() : 0x00;
13981460      else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000))
13991461         value = (address < 0x7000) ? DSP1_getDr() : DSP1_getSr();
14001462      else
1463      {
1464         logerror( "snes_r_bank1: Unmapped external chip read: %04x\n", address );
14011465         value = 0xff;                                 /* Reserved */
1466      }
14021467   }
14031468   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
14041469      value = (address < 0xc000) ? DSP1_getDr() : DSP1_getSr();
r5568r5569
14331498         value = snes_ram[0x306000 + (offset & mask)];
14341499      }
14351500      else
1501      {
1502         logerror( "snes_r_bank2: Unmapped external chip read: %04x\n", address );
14361503         value = 0xff;
1504      }
14371505   }
14381506   /* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */
14391507   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1))
r5568r5569
14711539   UINT8 value = 0xff;
14721540   UINT16 address = offset & 0xffff;
14731541
1474   if (snes_cart.mode & 5)                     /* Mode 20 & 22 */
1542   if (snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
14751543   {
1544      value = snes_ram[0x600000 + offset];
1545   }
1546   else if (snes_cart.mode & 5)                     /* Mode 20 & 22 */
1547   {
14761548      if (address >= 0x8000)
14771549         value = snes_ram[0x600000 + offset];
14781550      /* some other dsp1 games use these banks 0x60 to 0x6f at address 0x0000 */
14791551      else if (snes_has_addon_chip == HAS_DSP1)
14801552         value = (address >= 0x4000) ? DSP1_getSr() : DSP1_getDr();
14811553      else
1554      {
1555         logerror( "snes_r_bank4: Unmapped external chip read: %04x\n", address );
14821556         value = 0xff;                     /* Reserved */
1557      }
14831558   }
14841559   else if (snes_cart.mode & 0x0a)               /* Mode 21 & 25 */
14851560      value = snes_ram[0x600000 + offset];
r5568r5569
14931568   UINT8 value;
14941569   UINT16 address = offset & 0xffff;
14951570
1496   if ((snes_cart.mode & 5) &&(address < 0x8000))      /* Mode 20 & 22 */
1571   if (snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
14971572   {
1573      value = snes_ram[0x700000 + offset];
1574   }
1575   else if ((snes_cart.mode & 5) &&(address < 0x8000))      /* Mode 20 & 22 */
1576   {
14981577      if (snes_cart.sram > 0)
14991578      {
15001579         int mask = ((snes_cart.sram * 1024) - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
15011580         value = snes_ram[0x700000 + (offset & mask)];
15021581      }
15031582      else
1583      {
1584         logerror( "snes_r_bank5: Unmapped external chip read: %04x\n", address );
15041585         value = 0xff;                        /* Reserved */
1586      }
15051587   }
15061588   else
1589   {
15071590      value = snes_ram[0x700000 + offset];
1591   }
15081592
15091593   return value;
15101594}
r5568r5569
15171601
15181602   if (address < 0x8000)
15191603   {
1520      if (snes_cart.mode != SNES_MODE_25)
1604      if(address >= 0x6000 && snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
1605         logerror( "snes_r_bank6 hit in Super FX mode, please fix me\n" );
1606      else if (snes_cart.mode != SNES_MODE_25)
15211607         value = memory_read_byte(space, offset);
15221608      else                     /* Mode 25 has SRAM not mirrored from lower banks */
15231609      {
r5568r5569
15301616            value = snes_ram[0x806000 + (offset & mask)];   /* SRAM */
15311617         }
15321618         else                  /* Area 0x6000-0x8000 with offset < 0x300000 is reserved */
1619         {
1620            logerror( "snes_r_bank6: Unmapped external chip read: %04x\n", address );
15331621            value = 0xff;
1622         }
15341623      }
15351624   }
15361625   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
r5568r5569
15491638   UINT8 value;
15501639   UINT16 address = offset & 0xffff;
15511640
1641   if(snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
1642   {
1643      logerror( "snes_r_bank7 hit in Super FX mode, please fix me\n" );
1644   }
15521645   if (snes_cart.mode & 5)            /* Mode 20 & 22 */
15531646   {
15541647      if (address < 0x8000)
r5568r5569
15831676      else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000))
15841677         DSP1_setDr(data);
15851678      else
1586         logerror( "Attempt to write to reserved address: %X\n", offset );
1679         logerror( "snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", offset, data );
15871680   }
15881681   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
15891682      DSP1_setDr(data);
r5568r5569
16111704      else if ((snes_cart.mode == SNES_MODE_21) && (snes_cart.sram > 0))
16121705      {
16131706         int mask = ((snes_cart.sram * 1024) - 1);         /* Limit SRAM size to what's actually present */
1707         logerror( "snes_w_bank2 hit in Super FX mode, please fix me if necessary\n" );
16141708         offset -= 0x6000;
16151709         snes_ram[0x306000 + (offset & mask)] = data;
16161710      }
16171711      else
1618         logerror("Attempt to write to reserved address: %X\n", offset + 0x300000);
1712         logerror("snes_w_bank2: Attempt to write to reserved address: %X = %02x\n", offset + 0x300000, data);
16191713   }
16201714   /* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */
16211715   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1))
r5568r5569
16311725{
16321726   UINT16 address = offset & 0xffff;
16331727
1634   if (snes_cart.mode & 5)               /* Mode 20 & 22 */
1728   if (snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
16351729   {
1730      snes_ram[0x600000 + offset] = data;
1731   }
1732   else if (snes_cart.mode & 5)               /* Mode 20 & 22 */
1733   {
16361734      if (address >= 0x8000)
1735      {
16371736         logerror("Attempt to write to ROM address: %X\n", offset + 0x600000);
1737      }
16381738      else if (snes_has_addon_chip == HAS_DSP1)
1739      {
16391740         DSP1_setDr(data);
1741      }
16401742      else
1641         logerror("Attempt to write to reserved address: %X\n", offset + 0x600000);
1743      {
1744         logerror("snes_w_bank4: Attempt to write to reserved address: %X = %02x\n", offset + 0x600000, data);
1745      }
16421746   }
16431747   else if (snes_cart.mode & 0x0a)
1748   {
16441749      logerror("Attempt to write to ROM address: %X\n", offset + 0x600000);
1750   }
16451751}
16461752
16471753/* 0x700000 - 0x7dffff */
r5568r5569
16491755{
16501756   UINT16 address = offset & 0xffff;
16511757
1652   if ((snes_cart.mode & 5) && (address < 0x8000))         /* Mode 20 & 22 */
1758   if (snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
16531759   {
1760      snes_ram[0x700000 + offset] = data;
1761   }
1762   else if ((snes_cart.mode & 5) && (address < 0x8000))         /* Mode 20 & 22 */
1763   {
16541764      if (snes_cart.sram > 0)
16551765      {
16561766         int mask = ((snes_cart.sram * 1024) - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
16571767         snes_ram[0x700000 + (offset & mask)] = data;
16581768      }
16591769      else
1660         logerror("Attempt to write to reserved address: %X\n", offset + 0x600000);
1770      {
1771         logerror("snes_w_bank5: Attempt to write to reserved address: %X = %02x\n", offset + 0x700000, data);
1772      }
16611773   }
16621774   else if (snes_cart.mode & 0x0a)
1775   {
16631776      logerror("Attempt to write to ROM address: %X\n", offset + 0x700000);
1777   }
16641778}
16651779
16661780
r5568r5569
16711785
16721786   if (address < 0x8000)
16731787   {
1788      if (address >= 0x6000 && snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
1789      {
1790         logerror( "snes_w_bank6 hit (RAM) in Super FX mode, please fix me\n" );
1791      }
16741792      if (snes_cart.mode != SNES_MODE_25)
16751793      {
16761794         if (offset < 0x300000)
r5568r5569
16941812            snes_ram[0xb06000 + (offset & mask)] = data;
16951813         }
16961814         else   /* Area in 0x6000-0x8000 && offset < 0x300000 is Reserved! */
1697            logerror("Attempt to write to reserved address: %X\n", offset + 0x800000);
1815            logerror("snes_w_bank6: Attempt to write to reserved address: %X = %02x\n", offset + 0x800000, data);
16981816      }
16991817   }
17001818   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
17011819      DSP1_setDr(data);
17021820   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000) && (address < 0xc000))
17031821      DSP2_write(data);
1822   else if (snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
1823      logerror( "snes_w_bank6 hit (ROM) in Super FX mode, please fix me\n" );
17041824   else
17051825      logerror("Attempt to write to ROM address: %X\n", offset + 0x800000);
17061826}
r5568r5569
17111831{
17121832   UINT16 address = offset & 0xffff;
17131833
1714   if (snes_cart.mode & 5)            /* Mode 20 & 22 */
1834   if (snes_has_addon_chip == HAS_SUPERFX && cputag_get_cpu(space->machine, "superfx") != NULL)
17151835   {
1836      if (offset >= 0x200000)
1837      {
1838         logerror( "snes_w_bank7 hit (ROM) in Super FX mode, please fix me\n" );
1839      }
1840      else
1841      {
1842         logerror( "snes_w_bank7 hit (RAM) in Super FX mode, please fix me\n" );
1843      }
1844   }
1845   else if (snes_cart.mode & 5)            /* Mode 20 & 22 */
1846   {
17161847      if (address < 0x8000)
17171848      {
17181849         if (offset >= 0x3e0000)
r5568r5569
17231854            snes_w_bank4(space, offset - 0x200000, data);
17241855      }
17251856      else
1726         logerror("Attempt to write to ROM address: %X\n", offset + 0xc00000);
1857         logerror("snes_w_bank7: Attempt to write to ROM address: %X = %02x\n", offset + 0xc00000, data);
17271858   }
17281859   else if (snes_cart.mode & 0x0a)
17291860      logerror("Attempt to write to ROM address: %X\n", offset + 0xc00000);
r5568r5569
18722003   snes_ram[WRMPYA] = 0xff;
18732004   snes_ram[WRDIVL] = 0xff;
18742005   snes_ram[WRDIVH] = 0xff;
2006
2007   sdd1_init(machine);
18752008}
18762009
18772010MACHINE_RESET( snes )
r5568r5569
18942027   snes_htmult = 1;
18952028   snes_ppu.interlace = 1;
18962029   snes_ppu.obj_interlace = 1;
2030
2031   srtc_reset(machine);
2032   sdd1_reset(machine);
18972033}
18982034
18992035
r5568r5569
23142450      mask <<= 1;
23152451   }
23162452}
2453
2454READ8_HANDLER( superfx_r_bank1 )
2455{
2456   return snes_ram[offset | 0x8000];
2457}
2458
2459READ8_HANDLER( superfx_r_bank2 )
2460{
2461   return snes_ram[0x400000 + offset];
2462}
2463
2464READ8_HANDLER( superfx_r_bank3 )
2465{
2466   return snes_ram[0x600000 + offset];
2467}
2468
2469WRITE8_HANDLER( superfx_w_bank1 )
2470{
2471   // Do nothing; can't write to cart ROM.
2472}
2473
2474WRITE8_HANDLER( superfx_w_bank2 )
2475{
2476   // Do nothing; can't write to cart ROM.
2477}
2478
2479WRITE8_HANDLER( superfx_w_bank3 )
2480{
2481   snes_ram[0x600000 + offset] = data;
2482}
src/mame/includes/snes.h
r5568r5569
11#ifndef _SNES_H_
22#define _SNES_H_
33
4#include "devcb.h"
45#include "streams.h"
56
67/*
r5568r5569
365366HAS_OBC1,
366367HAS_RTC,
367368HAS_Z80GB,
368HAS_C4,
369HAS_CX4,
369370HAS_ST010,
370371HAS_ST011,
371372HAS_ST018,
372373HAS_SPC7110,
373374HAS_SPC7110_RTC,
374HAS_CX4,
375375HAS_UNK
376376};
377377
r5568r5569
400400extern WRITE8_HANDLER( snes_w_bank6 );
401401extern WRITE8_HANDLER( snes_w_bank7 );
402402
403extern READ8_HANDLER( superfx_r_bank1 );
404extern READ8_HANDLER( superfx_r_bank2 );
405extern READ8_HANDLER( superfx_r_bank3 );
406extern READ8_HANDLER( superfx_r_bank4 );
407extern WRITE8_HANDLER( superfx_w_bank1 );
408extern WRITE8_HANDLER( superfx_w_bank2 );
409extern WRITE8_HANDLER( superfx_w_bank3 );
410extern WRITE8_HANDLER( superfx_w_bank4 );
411
412WRITE_LINE_DEVICE_HANDLER( snes_extern_irq_w );
413
403414extern UINT8 snes_has_addon_chip;
404415
405416extern void snes_gdma( const address_space *space, UINT8 channels );
src/mame/mame.mak
r5568r5569
18461846$(DRIVERS)/mpu4.o:      $(MAMESRC)/drivers/mpu4drvr.c
18471847$(DRIVERS)/neogeo.o:   $(MAMESRC)/drivers/neodrvr.c
18481848$(MACHINE)/snes.o:       $(MAMESRC)/machine/snesdsp1.c \
1849                  $(MAMESRC)/machine/snesdsp2.c \
1850                  $(MAMESRC)/machine/snesobc1.c
1849            $(MAMESRC)/machine/snesdsp2.c \
1850            $(MAMESRC)/machine/snesobc1.c \
1851            $(MAMESRC)/machine/snesrtc.c \
1852            $(MAMESRC)/machine/snessdd1.c
src/emu/cpu/superfx/superfx.h
r5568r5569
11#ifndef __SUPERFX_H__
22#define __SUPERFX_H__
33
4#include "devcb.h"
5
46enum
57{
68   SUPERFX_PC = 1,
r5568r5569
8284#define SUPERFX_CFGR_IRQ   0x80   // IRQ
8385#define SUPERFX_CFGR_MS0   0x20   // MS0
8486
87typedef struct _superfx_config superfx_config;
88struct _superfx_config
89{
90   devcb_write_line   out_irq_func;         /* IRQ changed callback */
91};
92#define SUPERFX_CONFIG(name) const superfx_config (name) =
93
8594CPU_GET_INFO( superfx );
8695#define CPU_SUPERFX CPU_GET_INFO_NAME( superfx )
8796
src/emu/cpu/superfx/sfx_dasm.c
r5568r5569
302302         {
303303            case SUPERFX_SFR_ALT0:
304304            case SUPERFX_SFR_ALT2:
305               print("FMULT   R%d", op & 0xf);
305               print("FMULT");
306306               break;
307307            case SUPERFX_SFR_ALT1:
308308            case SUPERFX_SFR_ALT3:
309               print("LMULT   R%d", op & 0xf);
309               print("LMULT");
310310               break;
311311         }
312312         break;
src/emu/cpu/superfx/superfx.c
r5568r5569
1818typedef struct _superfx_state superfx_state;
1919struct _superfx_state
2020{
21   superfx_config config;
22
23   devcb_resolved_write_line   out_irq_func;
24
2125   UINT8  pipeline;
26   UINT16 ramaddr;   // RAM Address
2227
2328   UINT16 r[16];   // GPRs
2429   UINT16 sfr;      // Status Flag Register
r5568r5569
4146   UINT32 ramcl;   // Clock ticks until RAMDR is valid;
4247   UINT16 ramar;   // RAM Buffer Address Register
4348   UINT8  ramdr;   // RAM Buffer Data Register
44   UINT16 ramaddr;   // RAM Address
4549
4650   UINT16 *sreg;   // Source Register (From)
4751   UINT8  sreg_idx;// Source Register (To), index
r5568r5569
7377
7478/*****************************************************************************/
7579
76static void superfx_regs_reset(superfx_state *cpustate);
80INLINE void superfx_regs_reset(superfx_state *cpustate);
7781static void superfx_update_speed(superfx_state *cpustate);
7882static void superfx_cache_flush(superfx_state *cpustate);
79static UINT8 superfx_cache_mmio_read(superfx_state *cpustate, UINT16 addr);
83static UINT8 superfx_cache_mmio_read(superfx_state *cpustate, UINT32 addr);
8084static void superfx_cache_mmio_write(superfx_state *cpustate, UINT32 addr, UINT8 data);
8185static void superfx_memory_reset(superfx_state *cpustate);
82static UINT8 superfx_bus_read(superfx_state *cpustate, UINT32 addr);
83static void superfx_bus_write(superfx_state *cpustate, UINT32 addr, UINT8 data);
84static void superfx_pixelcache_flush(superfx_state *cpustate, INT32 line);
85static void superfx_plot(superfx_state *cpustate, UINT8 x, UINT8 y);
86static UINT8 superfx_rpix(superfx_state *cpustate, UINT16 r1, UINT16 r2);
87static UINT8 superfx_color(superfx_state *cpustate, UINT8 source);
88static UINT8 superfx_rambuffer_sync(superfx_state *cpustate);
89static UINT8 superfx_rambuffer_read(superfx_state *cpustate, UINT16 addr);
90static void superfx_rambuffer_write(superfx_state *cpustate, UINT16 addr, UINT8 val);
91static void superfx_rombuffer_sync(superfx_state *cpustate);
92static void superfx_rombuffer_update(superfx_state *cpustate);
93static UINT8 superfx_rombuffer_read(superfx_state *cpustate);
94static void superfx_gpr_write(superfx_state *cpustate, UINT8 r, UINT16 data);
86INLINE UINT8 superfx_bus_read(superfx_state *cpustate, UINT32 addr);
87INLINE void superfx_bus_write(superfx_state *cpustate, UINT32 addr, UINT8 data);
88INLINE void superfx_pixelcache_flush(superfx_state *cpustate, INT32 line);
89INLINE void superfx_plot(superfx_state *cpustate, UINT8 x, UINT8 y);
90static UINT8 superfx_rpix(superfx_state *cpustate, UINT8 r1, UINT8 r2);
91INLINE UINT8 superfx_color(superfx_state *cpustate, UINT8 source);
92
93INLINE void superfx_rambuffer_sync(superfx_state *cpustate);
94INLINE UINT8 superfx_rambuffer_read(superfx_state *cpustate, UINT16 addr);
95INLINE void superfx_rambuffer_write(superfx_state *cpustate, UINT16 addr, UINT8 val);
96
97INLINE void superfx_rombuffer_sync(superfx_state *cpustate);
98INLINE void superfx_rombuffer_update(superfx_state *cpustate);
99INLINE UINT8 superfx_rombuffer_read(superfx_state *cpustate);
100
101INLINE void superfx_gpr_write(superfx_state *cpustate, UINT8 r, UINT16 data);
95102INLINE UINT8 superfx_op_read(superfx_state *cpustate, UINT16 addr);
96103INLINE UINT8 superfx_peekpipe(superfx_state *cpustate);
97104INLINE UINT8 superfx_pipe(superfx_state *cpustate);
98static void superfx_add_clocks_internal(superfx_state *cpustate, INT32 clocks);
105INLINE void superfx_add_clocks_internal(superfx_state *cpustate, UINT32 clocks);
99106static void superfx_timing_reset(superfx_state *cpustate);
100107
101108/*****************************************************************************/
r5568r5569
109116#define SUPERFX_SFR_Z_SET      ((cpustate->sfr & SUPERFX_SFR_Z) ? 1 : 0)
110117#define SUPERFX_SFR_Z_CLEAR      ((cpustate->sfr & SUPERFX_SFR_Z) ? 0 : 1)
111118
112static void superfx_regs_reset(superfx_state *cpustate)
119INLINE void superfx_regs_reset(superfx_state *cpustate)
113120{
114121   cpustate->sfr &= ~(SUPERFX_SFR_B | SUPERFX_SFR_ALT3);
115122
r5568r5569
138145   }
139146}
140147
141static UINT8 superfx_cache_mmio_read(superfx_state *cpustate, UINT16 addr)
148static UINT8 superfx_cache_mmio_read(superfx_state *cpustate, UINT32 addr)
142149{
143150   addr = (addr + cpustate->cbr) & 0x1ff;
144151   return cpustate->cache.buffer[addr];
r5568r5569
172179   }
173180}
174181
175static UINT8 superfx_bus_read(superfx_state *cpustate, UINT32 addr)
182INLINE UINT8 superfx_bus_read(superfx_state *cpustate, UINT32 addr)
176183{
177   //printf( "superfx_bus_read: %08x\n", addr );
178184   return memory_read_byte(cpustate->program, addr);
179185}
180186
181static void superfx_bus_write(superfx_state *cpustate, UINT32 addr, UINT8 data)
187INLINE void superfx_bus_write(superfx_state *cpustate, UINT32 addr, UINT8 data)
182188{
183189   memory_write_byte(cpustate->program, addr, data);
184   //printf( "superfx_bus_write: %08x = %02x\n", addr, data );
185   // TODO: Hook up to the same memory map as the main 65C816 CPU.  See src/chip/superfx/bus/bus.cpp in the bsnes source code.
186190}
187191
188static void superfx_pixelcache_flush(superfx_state *cpustate, INT32 line)
192INLINE void superfx_pixelcache_flush(superfx_state *cpustate, INT32 line)
189193{
190194   UINT8 x = cpustate->pixelcache[line].offset << 3;
191195   UINT8 y = cpustate->pixelcache[line].offset >> 5;
r5568r5569
199203      return;
200204   }
201205
202   switch((cpustate->por & SUPERFX_POR_OBJ) ? SUPERFX_SCMR_HT3 : (cpustate->scmr & SUPERFX_SCMR_HT_MASK))
206   switch(((cpustate->por & SUPERFX_POR_OBJ) ? SUPERFX_SCMR_HT3 : (cpustate->scmr & SUPERFX_SCMR_HT_MASK)))
203207   {
204208      case SUPERFX_SCMR_HT0:
205209         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 3);
206210         break;
207211      case SUPERFX_SCMR_HT1:
208         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 1) + ((y & 0xf8) >> 3);
212         cn = ((x & 0xf8) << 1) + ((x & 0xf8) >> 1) + ((y & 0xf8) >> 3);
209213         break;
210214      case SUPERFX_SCMR_HT2:
211         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 0) + ((y & 0xf8) >> 3);
215         cn = ((x & 0xf8) << 1) + ((x & 0xf8) << 0) + ((y & 0xf8) >> 3);
212216         break;
213217      case SUPERFX_SCMR_HT3:
214         cn = ((y & 0x80) << 2) + ((x & 0x80) << 1) + ((y & 0x78) << 1) + ((x & 0x78) >> 2);
218         cn = ((y & 0x80) << 2) + ((x & 0x80) << 1) + ((y & 0x78) << 1) + ((x & 0x78) >> 3);
215219         break;
216220   }
217221
r5568r5569
219223
220224   for(n = 0; n < bpp; n++)
221225   {
222      UINT8 byte = ((n >> 1) << 4) + (n & 1);  // = [n]{ 0, 1, 16, 17, 32, 33, 48, 49 };
226      UINT32 byte = ((n >> 1) << 4) + (n & 1);  // = [n]{ 0, 1, 16, 17, 32, 33, 48, 49 };
223227      UINT8 data = 0x00;
224228      UINT32 x = 0;
225229      for(x = 0; x < 8; x++)
r5568r5569
230234      {
231235         superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
232236         data &= cpustate->pixelcache[line].bitpend;
233         //printf( "superfx_pixelcache_flush: calling superfx_bus_read\n" );
234237         data |= superfx_bus_read(cpustate, addr + byte) & ~cpustate->pixelcache[line].bitpend;
235238      }
236239      superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
r5568r5569
240243   cpustate->pixelcache[line].bitpend = 0x00;
241244}
242245
243static void superfx_plot(superfx_state *cpustate, UINT8 x, UINT8 y)
246INLINE void superfx_plot(superfx_state *cpustate, UINT8 x, UINT8 y)
244247{
245248   UINT8 color = cpustate->colr;
246249   UINT16 offset = (y << 5) + (x >> 3);
247250
248   printf( "plot: %02x at %d, %d\n", color, x, y );
249
250   if((cpustate->por & SUPERFX_POR_DITHER) && ((cpustate->scmr & SUPERFX_SCMR_MD) != 3))
251   if((cpustate->por & SUPERFX_POR_DITHER) != 0 && (cpustate->scmr & SUPERFX_SCMR_MD) != 3)
251252   {
252253      if((x ^ y) & 1)
253254      {
r5568r5569
256257      color &= 0x0f;
257258   }
258259
259   if(!(cpustate->por & SUPERFX_POR_TRANSPARENT))
260   if((cpustate->por & SUPERFX_POR_TRANSPARENT) == 0)
260261   {
261262      if((cpustate->scmr & SUPERFX_SCMR_MD) == 3)
262263      {
r5568r5569
303304   }
304305}
305306
306static UINT8 superfx_rpix(superfx_state *cpustate, UINT16 x, UINT16 y)
307static UINT8 superfx_rpix(superfx_state *cpustate, UINT8 x, UINT8 y)
307308{
308309   UINT32 cn = 0;
309   UINT32 bpp = 2 << ((cpustate->scmr & SUPERFX_SCMR_MD) - ((cpustate->scmr & SUPERFX_SCMR_MD) >> 1)); // = [regs.scmr.md]{ 2, 4, 4, 8 };
310   UINT32 bpp = 0;
310311   UINT32 addr = 0;
311312   UINT8 data = 0x00;
312313   UINT32 n = 0;
r5568r5569
314315   superfx_pixelcache_flush(cpustate, 1);
315316   superfx_pixelcache_flush(cpustate, 0);
316317
318   bpp = 2 << ((cpustate->scmr & SUPERFX_SCMR_MD) - ((cpustate->scmr & SUPERFX_SCMR_MD) >> 1)); // = [regs.scmr.md]{ 2, 4, 4, 8 };
319
317320   switch((cpustate->por & SUPERFX_POR_OBJ) ? SUPERFX_SCMR_HT3 : (cpustate->scmr & SUPERFX_SCMR_HT_MASK))
318321   {
319322      case SUPERFX_SCMR_HT0:
320323         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 3);
321324         break;
322325      case SUPERFX_SCMR_HT1:
323         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 1) + ((y & 0xf8) >> 3);
326         cn = ((x & 0xf8) << 1) + ((x & 0xf8) >> 1) + ((y & 0xf8) >> 3);
324327         break;
325328      case SUPERFX_SCMR_HT2:
326         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 0) + ((y & 0xf8) >> 3);
327         break;
329         cn = ((x & 0xf8) << 1) + ((x & 0xf8) << 0) + ((y & 0xf8) >> 3);
330          break;
328331      case SUPERFX_SCMR_HT3:
329         cn = ((y & 0x80) << 2) + ((x & 0x80) << 1) + ((y & 0x78) << 1) + ((x & 0x78) >> 2);
332         cn = ((y & 0x80) << 2) + ((x & 0x80) << 1) + ((y & 0x78) << 1) + ((x & 0x78) >> 3);
330333         break;
331334   }
332335
r5568r5569
335338
336339   for(n = 0; n < bpp; n++)
337340   {
338      UINT8 byte = ((n >> 1) << 4) + (n & 1);  // = [n]{ 0, 1, 16, 17, 32, 33, 48, 49 };
341      UINT32 byte = ((n >> 1) << 4) + (n & 1);  // = [n]{ 0, 1, 16, 17, 32, 33, 48, 49 };
339342      superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
340      //printf( "superfx_rpix: calling superfx_bus_read\n" );
341343      data |= ((superfx_bus_read(cpustate, addr + byte) >> x) & 1) << n;
342344   }
343345
344346   return data;
345347}
346348
347static UINT8 superfx_color(superfx_state *cpustate, UINT8 source)
349INLINE UINT8 superfx_color(superfx_state *cpustate, UINT8 source)
348350{
349351   if(cpustate->por & SUPERFX_POR_HIGHNIBBLE)
350352   {
r5568r5569
357359   return source;
358360}
359361
360static UINT8 superfx_rambuffer_sync(superfx_state *cpustate)
362INLINE void superfx_rambuffer_sync(superfx_state *cpustate)
361363{
362364   if(cpustate->ramcl)
363365   {
364366      superfx_add_clocks_internal(cpustate, cpustate->ramcl);
365367   }
366   return 0;
367368}
368369
369static UINT8 superfx_rambuffer_read(superfx_state *cpustate, UINT16 addr)
370INLINE UINT8 superfx_rambuffer_read(superfx_state *cpustate, UINT16 addr)
370371{
371   //superfx_rambuffer_sync(cpustate);
372   //printf( "superfx_rambuffer_read: calling superfx_bus_read\n" );
372   superfx_rambuffer_sync(cpustate);
373373   return superfx_bus_read(cpustate, 0x700000 + (cpustate->rambr << 16) + addr);
374374}
375375
376static void superfx_rambuffer_write(superfx_state *cpustate, UINT16 addr, UINT8 data)
376INLINE void superfx_rambuffer_write(superfx_state *cpustate, UINT16 addr, UINT8 data)
377377{
378   superfx_bus_write(cpustate, 0x700000 + (cpustate->rambr << 16) + cpustate->ramar, cpustate->ramdr);
379   //superfx_rambuffer_sync(cpustate);
380   //cpustate->ramcl = cpustate->memory_access_speed;
381   //cpustate->ramar = addr;
382   //cpustate->ramdr = data;
378   superfx_rambuffer_sync(cpustate);
379   cpustate->ramcl = cpustate->memory_access_speed;
380   cpustate->ramar = addr;
381   cpustate->ramdr = data;
383382}
384383
385384static void superfx_rombuffer_sync(superfx_state *cpustate)
386385{
387   //printf( "superfx_rombuffer_sync\n" );
388386   if(cpustate->romcl)
389387   {
390      printf( "calling add_clocks_internal\n" );
391388      superfx_add_clocks_internal(cpustate, cpustate->romcl);
392389   }
393390}
r5568r5569
395392static void superfx_rombuffer_update(superfx_state *cpustate)
396393{
397394   cpustate->sfr |= SUPERFX_SFR_R;
398   //printf( "superfx_rombuffer_update: setting romcl\n" );
399395   cpustate->romcl = cpustate->memory_access_speed;
400396}
401397
402398static UINT8 superfx_rombuffer_read(superfx_state *cpustate)
403399{
404400   superfx_rombuffer_sync(cpustate);
405   printf( "superfx_rombuffer_read: %02x\n", cpustate->romdr);
406401   return cpustate->romdr;
407402}
408403
409static void superfx_gpr_write(superfx_state *cpustate, UINT8 r, UINT16 data)
404INLINE void superfx_gpr_write(superfx_state *cpustate, UINT8 r, UINT16 data)
410405{
411406   cpustate->r[r] = data;
412407   if(r == 14)
r5568r5569
432427         for(n = 0; n < 16; n++)
433428         {
434429            superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
435            //printf( "superfx_op_read: caching superfx_bus_read value\n" );
436430            cpustate->cache.buffer[dp++] = superfx_bus_read(cpustate, sp++);
437431         }
438432         cpustate->cache.valid[offset >> 4] = 1;
r5568r5569
449443      //$[00-5f]:[0000-ffff] ROM
450444      superfx_rombuffer_sync(cpustate);
451445      superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
452      //printf( "superfx_op_read: reading from rom, calling superfx_bus_read\n" );
453446      return superfx_bus_read(cpustate, (cpustate->pbr << 16) + addr);
454447   }
455448   else
r5568r5569
457450      //$[60-7f]:[0000-ffff] RAM
458451      superfx_rambuffer_sync(cpustate);
459452      superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
460      //printf( "superfx_op_read: reading from ram, calling superfx_bus_read\n" );
461453      return superfx_bus_read(cpustate, (cpustate->pbr << 16) + addr);
462454   }
463455}
r5568r5569
486478
487479   addr &= 0xffff;
488480
489   if(addr != 0x3030)
490   {
491      //printf( "superfx_mmio_read: %08x\n", addr );
492   }
493
494481   if(addr >= 0x3100 && addr <= 0x32ff)
495482   {
496483      return superfx_cache_mmio_read(cpustate, addr - 0x3100);
r5568r5569
511498         UINT8 r = cpustate->sfr >> 8;
512499         cpustate->sfr &= ~SUPERFX_SFR_IRQ;
513500         cpustate->irq = 0;
501         devcb_call_write_line(&cpustate->out_irq_func, cpustate->irq);
514502         return r;
515503      }
516504
r5568r5569
540528{
541529   superfx_state *cpustate = get_safe_token(cpu);
542530
543   //printf( "superfx_mmio_write: %08x = %02x\n", addr, data );
544
545531   addr &= 0xffff;
546532
547533   if(addr >= 0x3100 && addr <= 0x32ff)
r5568r5569
615601   }
616602}
617603
618static void superfx_add_clocks_internal(superfx_state *cpustate, INT32 clocks)
604INLINE void superfx_add_clocks_internal(superfx_state *cpustate, UINT32 clocks)
619605{
620   //printf( "superfx_add_clocks: %d\n", clocks);
621   /*
622    if(cpustate->romcl)
623    {
624        printf( "ROM is accessing\n" );
625        printf( "romcl = %d, -= MIN(%d, %d) (= %d)\n", cpustate->romcl, clocks, cpustate->romcl, MIN(clocks, cpustate->romcl));
626        cpustate->romcl -= MIN(clocks, cpustate->romcl);
627        if(cpustate->romcl == 0)
628        {
629            cpustate->sfr &= ~SUPERFX_SFR_R;
630            printf( "superfx_op_read: reading from rom, calling superfx_bus_read: %08x\n", (cpustate->rombr << 16) + cpustate->r[14] );
631            cpustate->romdr = superfx_bus_read(cpustate, (cpustate->rombr << 16) + cpustate->r[14]);
632        }
633    }
634    */
606   if(cpustate->romcl)
607   {
608      cpustate->romcl -= MIN(clocks, cpustate->romcl);
609      if(cpustate->romcl == 0)
610      {
611         cpustate->sfr &= ~SUPERFX_SFR_R;
612         cpustate->romdr = superfx_bus_read(cpustate, (cpustate->rombr << 16) + cpustate->r[14]);
613      }
614   }
635615
636616   if(cpustate->ramcl)
637617   {
638618      cpustate->ramcl -= MIN(clocks, cpustate->ramcl);
639619      if(cpustate->ramcl == 0)
640620      {
641         printf( "Writing %02x to %08x\n", cpustate->ramdr, 0x700000 + (cpustate->rambr << 16) + cpustate->ramar );
642621         superfx_bus_write(cpustate, 0x700000 + (cpustate->rambr << 16) + cpustate->ramar, cpustate->ramdr);
643622      }
644623   }
r5568r5569
699678
700679    cpustate->device = device;
701680    cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
681
682   if (device->static_config != NULL)
683   {
684      cpustate->config = *(superfx_config *)device->static_config;
685   }
686
687   devcb_resolve_write_line(&cpustate->out_irq_func, &cpustate->config.out_irq_func, device);
702688}
703689
704690static CPU_EXIT( superfx )
r5568r5569
769755
770756        op = superfx_peekpipe(cpustate);
771757
772      printf( "Executing op at %06x: %02x\n", (cpustate->pbr << 16) | cpustate->r[15], op );
773758      switch(op)
774759      {
775760         case 0x00: // STOP
776            if(!(cpustate->cfgr & SUPERFX_CFGR_IRQ))
761            if((cpustate->cfgr & SUPERFX_CFGR_IRQ) == 0)
777762            {
778763               cpustate->sfr |= SUPERFX_SFR_IRQ;
779764               cpustate->irq = 1;
765               devcb_call_write_line(&cpustate->out_irq_func, cpustate->irq ? ASSERT_LINE : CLEAR_LINE );
780766            }
781767            cpustate->sfr &= ~SUPERFX_SFR_G;
782768            cpustate->pipeline = 0x01;
r5568r5569
909895
910896         case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
911897         case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:   // TO
912            if(!(cpustate->sfr & SUPERFX_SFR_B))
898            if((cpustate->sfr & SUPERFX_SFR_B) == 0)
913899            {
914900               cpustate->dreg = &cpustate->r[op & 0xf];
915901               cpustate->dreg_idx = op & 0xf;
r5568r5569
978964            { // LDW_IR
979965               UINT16 data = 0;
980966               cpustate->ramaddr = cpustate->r[op & 0xf];
981               data  = superfx_rambuffer_read(cpustate, (cpustate->ramaddr ^ 0) << 0);
982               data |= superfx_rambuffer_read(cpustate, (cpustate->ramaddr ^ 1) << 8);
967               data  = superfx_rambuffer_read(cpustate, cpustate->ramaddr ^ 0) << 0;
968               data |= superfx_rambuffer_read(cpustate, cpustate->ramaddr ^ 1) << 8;
983969               superfx_gpr_write(cpustate, cpustate->dreg_idx, data);
984970               superfx_regs_reset(cpustate);
985971            }
r5568r5569
10661052         case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66: case 0x67:
10671053         case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f: // SUB / SBC / SUBI / CMP
10681054         {
1069            INT32 r = *(cpustate->sreg);
1055            INT32 r = 0;
10701056            cpustate->sfr &= ~(SUPERFX_SFR_OV | SUPERFX_SFR_S | SUPERFX_SFR_CY | SUPERFX_SFR_Z);
10711057            switch(cpustate->sfr & SUPERFX_SFR_ALT)
10721058            {
10731059               case SUPERFX_SFR_ALT0: // SUB
1074                  r -= cpustate->r[op & 0xf];
1060                  r = *(cpustate->sreg) - cpustate->r[op & 0xf];
10751061                  cpustate->sfr |= ((*(cpustate->sreg) ^ cpustate->r[op & 0xf]) & (*(cpustate->sreg) ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
10761062                  superfx_gpr_write(cpustate, cpustate->dreg_idx, r);
10771063                  break;
10781064               case SUPERFX_SFR_ALT1: // SBC
1079                  r -= cpustate->r[op & 0xf] - ((cpustate->sfr & SUPERFX_SFR_CY) ? 0 : 1);
1065                  r = *(cpustate->sreg) - cpustate->r[op & 0xf] - ((cpustate->sfr & SUPERFX_SFR_CY) ? 0 : 1);
10801066                  cpustate->sfr |= ((*(cpustate->sreg) ^ cpustate->r[op & 0xf]) & (*(cpustate->sreg) ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
10811067                  superfx_gpr_write(cpustate, cpustate->dreg_idx, r);
10821068                  break;
10831069               case SUPERFX_SFR_ALT2: // SUBI
1084                  r -= op & 0xf;
1070                  r = *(cpustate->sreg) - (op & 0xf);
10851071                  cpustate->sfr |= ((*(cpustate->sreg) ^ (op & 0xf)) & (*(cpustate->sreg) ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
10861072                  superfx_gpr_write(cpustate, cpustate->dreg_idx, r);
10871073                  break;
10881074               case SUPERFX_SFR_ALT3: // CMP
1089                  r -= cpustate->r[op & 0xf];
1075                  r = *(cpustate->sreg) - cpustate->r[op & 0xf];
10901076                  cpustate->sfr |= ((*(cpustate->sreg) ^ cpustate->r[op & 0xf]) & (*(cpustate->sreg) ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
10911077                  break;
10921078            }
10931079            cpustate->sfr |= (r & 0x8000) ? SUPERFX_SFR_S : 0;
1094            cpustate->sfr |= (r >= 0x10000) ? SUPERFX_SFR_CY : 0;
1080            cpustate->sfr |= (r >= 0x0) ? SUPERFX_SFR_CY : 0;
10951081            cpustate->sfr |= ((UINT16)r == 0) ? SUPERFX_SFR_Z : 0;
10961082            superfx_regs_reset(cpustate);
10971083            break;
r5568r5569
11751161            { // ASR
11761162               cpustate->sfr &= ~SUPERFX_SFR_CY;
11771163               cpustate->sfr |= (*(cpustate->sreg) & 1) ? SUPERFX_SFR_CY : 0;
1178               superfx_gpr_write(cpustate, cpustate->dreg_idx, (INT16)(*(cpustate->sreg) >> 1));
1164               superfx_gpr_write(cpustate, cpustate->dreg_idx, (INT16)(*(cpustate->sreg)) >> 1);
11791165               superfx_dreg_sfr_sz_update(cpustate);
11801166               superfx_regs_reset(cpustate);
11811167            }
r5568r5569
11831169            { // DIV2
11841170               cpustate->sfr &= ~SUPERFX_SFR_CY;
11851171               cpustate->sfr |= (*(cpustate->sreg) & 1) ? SUPERFX_SFR_CY : 0;
1186               superfx_gpr_write(cpustate, cpustate->dreg_idx, ((INT16)(*(cpustate->sreg) >> 1)) + ((*(cpustate->sreg) + 1) >> 16));
1172               superfx_gpr_write(cpustate, cpustate->dreg_idx, ((INT16)(*(cpustate->sreg)) >> 1) + ((*(cpustate->sreg) + 1) >> 16));
11871173               superfx_dreg_sfr_sz_update(cpustate);
11881174               superfx_regs_reset(cpustate);
11891175            }
r5568r5569
11921178         case 0x97: // ROR
11931179         {
11941180            UINT16 carry = *(cpustate->sreg) & 1;
1195            superfx_gpr_write(cpustate, cpustate->dreg_idx, (((cpustate->sfr & SUPERFX_SFR_CY) ? 1 : 0) << 15) | (*(cpustate->sreg) >> 1));
1181            superfx_gpr_write(cpustate, cpustate->dreg_idx, (SUPERFX_SFR_CY_SET << 15) | ((UINT16)(*(cpustate->sreg)) >> 1));
11961182            cpustate->sfr &= ~SUPERFX_SFR_CY;
11971183            cpustate->sfr |= carry ? SUPERFX_SFR_CY : 0;
11981184            superfx_dreg_sfr_sz_update(cpustate);
r5568r5569
12171203            break;
12181204
12191205         case 0x9e: // LOB
1220            superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) & 0xff);
1206            superfx_gpr_write(cpustate, cpustate->dreg_idx, (UINT16)(*(cpustate->sreg)) & 0x00ff);
12211207            cpustate->sfr &= ~(SUPERFX_SFR_S | SUPERFX_SFR_Z);
12221208            cpustate->sfr |= (*(cpustate->dreg) & 0x80) ? SUPERFX_SFR_S : 0;
12231209            cpustate->sfr |= (*(cpustate->dreg) == 0) ? SUPERFX_SFR_Z : 0;
r5568r5569
12261212
12271213         case 0x9f: // FMULT / LMULT
12281214         {
1229            UINT32 result = (INT16)(*(cpustate->sreg)) * (INT16)cpustate->r[6];
1215            UINT32 result = (INT16)(*(cpustate->sreg)) * (INT16)(cpustate->r[6]);
12301216            if(cpustate->sfr & SUPERFX_SFR_ALT1)
12311217            { // LMULT
12321218               superfx_gpr_write(cpustate, 4, result);
r5568r5569
12701256
12711257         case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7:
12721258         case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf: // FROM
1273            if(!(cpustate->sfr & SUPERFX_SFR_B))
1259            if((cpustate->sfr & SUPERFX_SFR_B) == 0)
12741260            {
12751261               cpustate->sreg = &(cpustate->r[op & 0xf]);
12761262               cpustate->sreg_idx = op & 0xf;
r5568r5569
12861272            break;
12871273
12881274         case 0xc0: // HIB
1289            superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) >> 8);
1290            superfx_dreg_sfr_sz_update(cpustate);
1275            superfx_gpr_write(cpustate, cpustate->dreg_idx, (*(cpustate->sreg)) >> 8);
1276            cpustate->sfr &= ~(SUPERFX_SFR_S | SUPERFX_SFR_Z);
1277            cpustate->sfr |= (*(cpustate->dreg) & 0x80) ? SUPERFX_SFR_S : 0;
1278            cpustate->sfr |= (*(cpustate->dreg) == 0) ? SUPERFX_SFR_Z : 0;
12911279            superfx_regs_reset(cpustate);
12921280            break;
12931281
r5568r5569
13531341
13541342         case 0xef: // GETB / GETBH / GETBL / GETBS
13551343         {
1356            UINT8 byte = superfx_bus_read(cpustate, (cpustate->rombr << 16) + cpustate->r[14]);
1344            UINT8 byte = superfx_rombuffer_read(cpustate);
13571345            switch(cpustate->sfr & SUPERFX_SFR_ALT)
13581346            {
13591347               case SUPERFX_SFR_ALT0: // GETB
r5568r5569
13661354                  superfx_gpr_write(cpustate, cpustate->dreg_idx, (*(cpustate->sreg) & 0xff00) | (byte << 0));
13671355                  break;
13681356               case SUPERFX_SFR_ALT3: // GETBS
1369                  superfx_gpr_write(cpustate, cpustate->dreg_idx, (INT16)((INT8)byte));
1357                  superfx_gpr_write(cpustate, cpustate->dreg_idx, (INT8)byte);
13701358                  break;
13711359            }
13721360            superfx_regs_reset(cpustate);
src/emu/cpu/avr8/avr8.c
r5568r5569
128128    UINT16 sp = SPREG;
129129    WRITE_IO_8(cpustate, sp, val);
130130    sp--;
131    //printf( "PUSH %02x, new SP = %04x\n", val, sp );
131132    WRITE_IO_8(cpustate, AVR8_IO_SPH, (sp >> 8) & 0x00ff);
132133    WRITE_IO_8(cpustate, AVR8_IO_SPL, sp & 0x00ff);
133134}
r5568r5569
138139    sp++;
139140    WRITE_IO_8(cpustate, AVR8_IO_SPH, (sp >> 8) & 0x00ff);
140141    WRITE_IO_8(cpustate, AVR8_IO_SPL, sp & 0x00ff);
142    //printf( "POP %02x, new SP = %04x\n", READ_IO_8(cpustate, sp), sp );
141143    return READ_IO_8(cpustate, sp);
142144}
143145
146static void avr8_set_irq_line(avr8_state *cpustate, UINT16 vector, int state)
147{
148    //printf( "OMFG SETTING IRQ LINE\n" );
149    // Horrible hack, not accurate
150    if(state)
151    {
152        SREG_W(AVR8_SREG_I, 0);
153        PUSH(cpustate, (cpustate->pc >> 8) & 0x00ff);
154        PUSH(cpustate, cpustate->pc & 0x00ff);
155        cpustate->pc = vector;
156    }
157}
158
144159/*****************************************************************************/
145160
146161static CPU_INIT( avr8 )
r5568r5569
176191    UINT8 rr = 0;
177192    UINT8 res = 0;
178193    UINT16 pd = 0;
194    INT16 sd = 0;
195    INT32 opcycles = 1;
179196    //UINT16 pr = 0;
180197    avr8_state *cpustate = get_safe_token(device);
181198
r5568r5569
195212                switch(op & 0x0f00)
196213                {
197214                    case 0x0000:    // NOP
198                        //output += sprintf( output, "NOP" );
199                        unimplemented_opcode(cpustate, op);
200215                        break;
201216                    case 0x0100:    // MOVW Rd+1:Rd,Rr+1:Rd
202                        //output += sprintf( output, "MOVW    R%d:R%d, R%d:R%d", RD4(op)+1, RD4(op), RR4(op)+1, RR4(op) );
203                        unimplemented_opcode(cpustate, op);
217                        WRITE_IO_8(cpustate, (RD4(op) << 1)+1, READ_IO_8(cpustate, (RR4(op) << 1)+1));
218                        WRITE_IO_8(cpustate, RD4(op) << 1, READ_IO_8(cpustate, RR4(op) << 1));
204219                        break;
205220                    case 0x0200:    // MULS Rd,Rr
206221                        //output += sprintf( output, "MULS    R%d, R%d", 16+RD4(op), 16+RR4(op) );
207222                        unimplemented_opcode(cpustate, op);
208223                        break;
209224                    case 0x0300:    // MULSU Rd,Rr
210                        //output += sprintf( output, "MULSU   R%d, R%d", 16+RD4(op), 16+RR4(op) );
211                        unimplemented_opcode(cpustate, op);
225                        sd = (INT8)READ_IO_8(cpustate, 16+RD4(op)) * (UINT8)READ_IO_8(cpustate, 16+RR4(op));
226                        WRITE_IO_8(cpustate, 1, (sd >> 8) & 0x00ff);
227                        WRITE_IO_8(cpustate, 0, sd & 0x00ff);
228                        SREG_W(AVR8_SREG_C, (sd & 0x8000) ? 1 : 0);
229                        SREG_W(AVR8_SREG_Z, (sd == 0) ? 1 : 0);
230                        opcycles = 2;
212231                        break;
213232                    case 0x0400:
214233                    case 0x0500:
r5568r5569
228247                    case 0x0900:
229248                    case 0x0a00:
230249                    case 0x0b00:    // SBC Rd,Rr
231                        //output += sprintf( output, "SBC     R%d, R%d", RD5(op), RR5(op) );
232                        unimplemented_opcode(cpustate, op);
250                        rd = READ_IO_8(cpustate, RD5(op));
251                        rr = READ_IO_8(cpustate, RR5(op));
252                        res = rd - (rr + SREG_R(AVR8_SREG_C));
253                        WRITE_IO_8(cpustate, RD5(op), res);
254                        SREG_W(AVR8_SREG_H, (NOT(BIT(rd,3)) & BIT(rr,3)) | (BIT(rr,3) & BIT(res,3)) | (BIT(res,3) & NOT(BIT(rd,3))));
255                        SREG_W(AVR8_SREG_V, (BIT(rd,7) & NOT(BIT(rr,7)) & NOT(BIT(res,7))) | (NOT(BIT(rd,7)) & BIT(rr,7) & BIT(res,7)));
256                        SREG_W(AVR8_SREG_N, BIT(res,7));
257                        SREG_W(AVR8_SREG_S, SREG_R(AVR8_SREG_N) ^ SREG_R(AVR8_SREG_V));
258                        SREG_W(AVR8_SREG_Z, (res == 0) ? 1 : 0);
259                        SREG_W(AVR8_SREG_C, (NOT(BIT(rd,7)) & BIT(rr,7)) | (BIT(rr,7) & BIT(res,7)) | (BIT(res,7) & NOT(BIT(rd,7))));
233260                        break;
234261                    case 0x0c00:
235262                    case 0x0d00:
r5568r5569
267294                        SREG_W(AVR8_SREG_C, (NOT(BIT(rd,7)) & BIT(rr,7)) | (BIT(rr,7) & BIT(res,7)) | (BIT(res,7) & NOT(BIT(rd,7))));
268295                        break;
269296                    case 0x0800:    // SUB Rd,Rr
270                        //output += sprintf( output, "SUB     R%d, R%d", RD5(op), RR5(op) );
271                        unimplemented_opcode(cpustate, op);
297                        rd = READ_IO_8(cpustate, RD5(op));
298                        rr = READ_IO_8(cpustate, RR5(op));
299                        res = rd - rr;
300                        WRITE_IO_8(cpustate, RD5(op), res);
301                        SREG_W(AVR8_SREG_H, (NOT(BIT(rd,3)) & BIT(rr,3)) | (BIT(rr,3) & BIT(res,3)) | (BIT(res,3) & NOT(BIT(rd,3))));
302                        SREG_W(AVR8_SREG_V, (BIT(rd,7) & NOT(BIT(rr,7)) & NOT(BIT(res,7))) | (NOT(BIT(rd,7)) & BIT(rr,7) & BIT(res,7)));
303                        SREG_W(AVR8_SREG_N, BIT(res,7));
304                        SREG_W(AVR8_SREG_S, SREG_R(AVR8_SREG_N) ^ SREG_R(AVR8_SREG_V));
305                        SREG_W(AVR8_SREG_Z, (res == 0) ? 1 : 0);
306                        SREG_W(AVR8_SREG_C, (NOT(BIT(rd,7)) & BIT(rr,7)) | (BIT(rr,7) & BIT(res,7)) | (BIT(res,7) & NOT(BIT(rd,7))));
272307                        break;
273308                    case 0x0c00:    // ADC Rd,Rr
274309                        rd = READ_IO_8(cpustate, RD5(op));
r5568r5569
361396                        unimplemented_opcode(cpustate, op);
362397                        break;
363398                    case 0x0008:    // LDD Rd,Y+q
364                        //output += sprintf( output, "LD(D)   R%d, Y+%02x", RD5(op), QCONST6(op) );
365                        unimplemented_opcode(cpustate, op);
399                        WRITE_IO_8(cpustate, RD5(op), YREG + QCONST6(op));
400                        opcycles = 2;
366401                        break;
367402                    case 0x0200:    // STD Z+q,Rr
368403                        //output += sprintf( output, "ST(D)   Z+%02x, R%d", QCONST6(op), RD5(op) );
369404                        unimplemented_opcode(cpustate, op);
370405                        break;
371                    case 0x0208:    // STD Z+q,Rr
372                        //output += sprintf( output, "ST(D)   Y+%02x, R%d", QCONST6(op), RD5(op) );
373                        unimplemented_opcode(cpustate, op);
406                    case 0x0208:    // STD Y+q,Rr
407                        WRITE_IO_8(cpustate, YREG + QCONST6(op), READ_IO_8(cpustate, RD5(op)));
408                        opcycles = 2;
374409                        break;
375410                }
376411                break;
r5568r5569
386421                                cpustate->pc++;
387422                                op |= READ_PRG_16(cpustate, cpustate->pc);
388423                                WRITE_IO_8(cpustate, RD5(op >> 16), READ_IO_8(cpustate, op & 0x0000ffff));
424                                opcycles = 2;
389425                                break;
390426                            case 0x0001:    // LD Rd,Z+
391427                                unimplemented_opcode(cpustate, op);
r5568r5569
396432                                break;
397433                            case 0x0004:    // LPM Rd,Z
398434                                WRITE_IO_8(cpustate, RD5(op), READ_PRG_8(cpustate, ZREG));
435                                opcycles = 3;
399436                                break;
400437                            case 0x0005:    // LPM Rd,Z+
401438                                pd = ZREG;
r5568r5569
403440                                pd++;
404441                                WRITE_IO_8(cpustate, 31, (pd >> 8) & 0x00ff);
405442                                WRITE_IO_8(cpustate, 30, pd & 0x00ff);
443                                opcycles = 3;
406444                                break;
407445                            case 0x0006:    // ELPM Rd,Z
408446                                //output += sprintf( output, "ELPM    R%d, Z", RD5(op) );
r5568r5569
425463                                unimplemented_opcode(cpustate, op);
426464                                break;
427465                            case 0x000d:    // LD Rd,X+
428                                //output += sprintf( output, "LD      R%d, X+", RD5(op) );
429                                unimplemented_opcode(cpustate, op);
466                                pd = XREG;
467                                WRITE_IO_8(cpustate, RD5(op), READ_IO_8(cpustate, pd));
468                                pd++;
469                                WRITE_IO_8(cpustate, 27, (pd >> 8) & 0x00ff);
470                                WRITE_IO_8(cpustate, 26, pd & 0x00ff);
471                                opcycles = 2;
430472                                break;
431473                            case 0x000e:    // LD Rd,-X
432474                                //output += sprintf( output, "LD      R%d,-X", RD5(op) );
433475                                unimplemented_opcode(cpustate, op);
434476                                break;
435477                            case 0x000f:    // POP Rd
436                                //output += sprintf( output, "POP     R%d", RD5(op) );
437                                unimplemented_opcode(cpustate, op);
478                                WRITE_IO_8(cpustate, RD5(op), POP(cpustate));
479                                opcycles = 2;
438480                                break;
439481                            default:
440482                                unimplemented_opcode(cpustate, op);
r5568r5569
451493                                cpustate->pc++;
452494                                op |= READ_PRG_16(cpustate, cpustate->pc);
453495                                WRITE_IO_8(cpustate, op & 0x0000ffff, READ_IO_8(cpustate, RD5(op >> 16)));
496                                opcycles = 2;
454497                                break;
455498                            case 0x0001:    // ST Z+,Rd
456499                                //output += sprintf( output, "ST       Z+, R%d", RD5(op) );
r5568r5569
471514                            case 0x000c:    // ST X,Rd
472515                                rd = READ_IO_8(cpustate, RD5(op));
473516                                WRITE_IO_8(cpustate, XREG, rd);
517                                opcycles = 2;
474518                                break;
475519                            case 0x000d:    // ST X+,Rd
476520                                pd = XREG;
r5568r5569
478522                                pd++;
479523                                WRITE_IO_8(cpustate, 27, (pd >> 8) & 0x00ff);
480524                                WRITE_IO_8(cpustate, 26, pd & 0x00ff);
525                                opcycles = 2;
481526                                break;
482527                            case 0x000e:    // ST -X,Rd
483528                                //output += sprintf( output, "ST      -X , R%d", RD5(op) );
484529                                unimplemented_opcode(cpustate, op);
485530                                break;
486531                            case 0x000f:    // PUSH Rd
487                                //output += sprintf( output, "PUSH    R%d", RD5(op) );
488                                unimplemented_opcode(cpustate, op);
532                                PUSH(cpustate, READ_IO_8(cpustate, RD5(op)));
533                                opcycles = 2;
489534                                break;
490535                            default:
491536                                unimplemented_opcode(cpustate, op);
r5568r5569
497542                        switch(op & 0x000f)
498543                        {
499544                            case 0x0000:    // COM Rd
500                                //output += sprintf( output, "COM     R%d", RD5(op) );
501                                unimplemented_opcode(cpustate, op);
545                                rd = READ_IO_8(cpustate, RD5(op));
546                                rd = ~rd;
547                                SREG_W(AVR8_SREG_C, 1);
548                                SREG_W(AVR8_SREG_Z, (res == 0) ? 1 : 0);
549                                SREG_W(AVR8_SREG_N, BIT(res,7));
550                                SREG_W(AVR8_SREG_V, 0);
551                                SREG_W(AVR8_SREG_S, SREG_R(AVR8_SREG_N) | SREG_R(AVR8_SREG_V));
502552                                break;
503553                            case 0x0001:    // NEG Rd
504                                //output += sprintf( output, "NEG     R%d", RD5(op) );
505                                unimplemented_opcode(cpustate, op);
554                                rd = READ_IO_8(cpustate, RD5(op));
555                                res = 0 - rd;
556                                SREG_W(AVR8_SREG_C, (res == 0) ? 0 : 1);
557                                SREG_W(AVR8_SREG_Z, (res == 0) ? 1 : 0);
558                                SREG_W(AVR8_SREG_N, BIT(res,7));
559                                SREG_W(AVR8_SREG_V, (res == 0x80) ? 1 : 0);
560                                SREG_W(AVR8_SREG_S, SREG_R(AVR8_SREG_N) | SREG_R(AVR8_SREG_V));
561                                SREG_W(AVR8_SREG_H, BIT(res,3) | BIT(rd,3));
506562                                break;
507563                            case 0x0002:    // SWAP Rd
508564                                //output += sprintf( output, "SWAP    R%d", RD5(op) );
r5568r5569
522578                                unimplemented_opcode(cpustate, op);
523579                                break;
524580                            case 0x0006:    // LSR Rd
525                                //output += sprintf( output, "LSR     R%d", RD5(op) );
526                                unimplemented_opcode(cpustate, op);
581                                rd = READ_IO_8(cpustate, RD5(op));
582                                res = rd >> 1;
583                                SREG_W(AVR8_SREG_C, rd & 0x01);
584                                SREG_W(AVR8_SREG_Z, (res == 0) ? 1 :0);
585                                SREG_W(AVR8_SREG_N, 0);
586                                SREG_W(AVR8_SREG_V, SREG_R(AVR8_SREG_N) ^ SREG_R(AVR8_SREG_C));
587                                SREG_W(AVR8_SREG_S, SREG_R(AVR8_SREG_N) ^ SREG_R(AVR8_SREG_V));
527588                                break;
528589                            case 0x0007:    // ROR Rd
529590                                //output += sprintf( output, "ROR     R%d", RD5(op) );
r5568r5569
559620                                {
560621                                    case 0x0000:    // IJMP
561622                                        cpustate->pc = ZREG - 1;
623                                        opcycles = 2;
562624                                        break;
563625                                    case 0x0010:    // EIJMP
564626                                        //output += sprintf( output, "EIJMP" );
565627                                        unimplemented_opcode(cpustate, op);
566628                                        break;
567629                                    default:
568                                        unimplemented_opcode(cpustate, op);
569630                                        //output += sprintf( output, "Undefined (%04x)", op );
570631                                        unimplemented_opcode(cpustate, op);
571632                                        break;
572633                                }
573634                                break;
574635                            case 0x000a:    // DEC Rd
575                                //output += sprintf( output, "DEC     R%d", RD5(op) );
576                                unimplemented_opcode(cpustate, op);
636                                rd = READ_IO_8(cpustate, RD5(op));
637                                res = rd - 1;
638                                SREG_W(AVR8_SREG_V, (rd == 0x7f) ? 1 : 0);
639                                SREG_W(AVR8_SREG_N, BIT(res,7));
640                                SREG_W(AVR8_SREG_S, SREG_R(AVR8_SREG_N) ^ SREG_R(AVR8_SREG_V));
641                                SREG_W(AVR8_SREG_Z, (res == 0) ? 1 : 0);
642                                WRITE_IO_8(cpustate, RD5(op), res);
577643                                break;
578644                            case 0x000c:
579645                            case 0x000d:    // JMP k
r5568r5569
603669                        switch(op & 0x000f)
604670                        {
605671                            case 0x0000:    // COM Rd
606                                //output += sprintf( output, "COM     R%d", RD5(op) );
607                                unimplemented_opcode(cpustate, op);
672                                rd = READ_IO_8(cpustate, RD5(op));
673                                rd = ~rd;
674                                SREG_W(AVR8_SREG_C, 1);
675                                SREG_W(AVR8_SREG_Z, (res == 0) ? 1 : 0);
676                                SREG_W(AVR8_SREG_N, BIT(res,7));
677                                SREG_W(AVR8_SREG_V, 0);
678                                SREG_W(AVR8_SREG_S, SREG_R(AVR8_SREG_N) | SREG_R(AVR8_SREG_V));
608679                                break;
609680                            case 0x0001:    // NEG Rd
610                                //output += sprintf( output, "NEG     R%d", RD5(op) );
611                                unimplemented_opcode(cpustate, op);
681                                rd = READ_IO_8(cpustate, RD5(op));
682                                res = 0 - rd;
683                                WRITE_IO_8(cpustate, RD5(op), res);
684                                SREG_W(AVR8_SREG_C, (res == 0) ? 0 : 1);
685                                SREG_W(AVR8_SREG_Z, (res == 0) ? 1 : 0);
686                                SREG_W(AVR8_SREG_N, BIT(res,7));
687                                SREG_W(AVR8_SREG_V, (res == 0x80) ? 1 : 0);
688                                SREG_W(AVR8_SREG_S, SREG_R(AVR8_SREG_N) | SREG_R(AVR8_SREG_V));
689                                SREG_W(AVR8_SREG_H, BIT(res,3) | BIT(rd,3));
612690                                break;
613691                            case 0x0002:    // SWAP Rd
614692                                //output += sprintf( output, "SWAP    R%d", RD5(op) );
r5568r5569
628706                                unimplemented_opcode(cpustate, op);
629707                                break;
630708                            case 0x0006:    // LSR Rd
631                                //output += sprintf( output, "LSR     R%d", RD5(op) );
632                                unimplemented_opcode(cpustate, op);
709                                rd = READ_IO_8(cpustate, RD5(op));
710                                res = rd >> 1;
711                                SREG_W(AVR8_SREG_C, rd & 0x01);
712                                SREG_W(AVR8_SREG_Z, (res == 0) ? 1 :0);
713                                SREG_W(AVR8_SREG_N, 0);
714                                SREG_W(AVR8_SREG_V, SREG_R(AVR8_SREG_N) ^ SREG_R(AVR8_SREG_C));
715                                SREG_W(AVR8_SREG_S, SREG_R(AVR8_SREG_N) ^ SREG_R(AVR8_SREG_V));
633716                                break;
634717                            case 0x0007:    // ROR Rd
635718                                //output += sprintf( output, "ROR     R%d", RD5(op) );
r5568r5569
642725                                        cpustate->pc = POP(cpustate);
643726                                        cpustate->pc |= POP(cpustate) << 8;
644727                                        cpustate->pc--;
728                                        opcycles = 4;
645729                                        break;
646730                                    case 0x0010:    // RETI
647                                        //output += sprintf( output, "RETI" );
648                                        unimplemented_opcode(cpustate, op);
731                                        cpustate->pc = POP(cpustate);
732                                        cpustate->pc |= POP(cpustate) << 8;
733                                        cpustate->pc--;
734                                        SREG_W(AVR8_SREG_I, 1);
735                                        opcycles = 4;
649736                                        break;
650737                                    case 0x0080:    // SLEEP
651738                                        //output += sprintf( output, "SLEEP" );
r5568r5569
661748                                        break;
662749                                    case 0x00c0:    // LPM
663750                                        WRITE_IO_8(cpustate, 0, READ_PRG_8(cpustate, ZREG));
751                                        opcycles = 3;
664752                                        break;
665753                                    case 0x00d0:    // ELPM
666754                                        //output += sprintf( output, "ELPM" );
r5568r5569
698786                                }
699787                                break;
700788                            case 0x000a:    // DEC Rd
701                                //output += sprintf( output, "DEC     R%d", RD5(op) );
702                                unimplemented_opcode(cpustate, op);
789                                rd = READ_IO_8(cpustate, RD5(op));
790                                res = rd - 1;
791                                SREG_W(AVR8_SREG_V, (rd == 0x7f) ? 1 : 0);
792                                SREG_W(AVR8_SREG_N, BIT(res,7));
793                                SREG_W(AVR8_SREG_S, SREG_R(AVR8_SREG_N) ^ SREG_R(AVR8_SREG_V));
794                                SREG_W(AVR8_SREG_Z, (res == 0) ? 1 : 0);
795                                WRITE_IO_8(cpustate, RD5(op), res);
703796                                break;
704797                            case 0x000c:
705798                            case 0x000d:    // JMP k
r5568r5569
727820                        break;
728821                    case 0x0700:    // SBIW Rd+1:Rd,K
729822                        //output += sprintf( output, "SBIW    R%d:R%d, 0x%02x", 24+(RD2(op) << 1)+1, 24+(RD2(op) << 1), KCONST6(op) );
823                        unimplemented_opcode(cpustate, op);
730824                        break;
731825                    case 0x0800:    // CBI A,b
732826                        //output += sprintf( output, "CBI     0x%02x, %d", ACONST5(op), RR3(op) );
827                        WRITE_IO_8(cpustate, ACONST5(op), READ_IO_8(cpustate, ACONST5(op)) &~ (1 << RR3(op)));
828                        opcycles = 2;
733829                        break;
734830                    case 0x0900:    // SBIC A,b
735831                        //output += sprintf( output, "SBIC    0x%02x, %d", ACONST5(op), RR3(op) );
832                        unimplemented_opcode(cpustate, op);
736833                        break;
737834                    case 0x0a00:    // SBI A,b
738835                        //output += sprintf( output, "SBI     0x%02x, %d", ACONST5(op), RR3(op) );
836                        WRITE_IO_8(cpustate, ACONST5(op), READ_IO_8(cpustate, ACONST5(op)) | (1 << RR3(op)));
837                        opcycles = 2;
739838                        break;
740839                    case 0x0b00:    // SBIS A,b
741840                        //output += sprintf( output, "SBIS    0x%02x, %d", ACONST5(op), RR3(op) );
841                        unimplemented_opcode(cpustate, op);
742842                        break;
743843                    case 0x0c00:
744844                    case 0x0d00:
745845                    case 0x0e00:
746846                    case 0x0f00:    // MUL Rd,Rr
747847                        //output += sprintf( output, "MUL     R%d, R%d", RD5(op), RR5(op) );
848                        unimplemented_opcode(cpustate, op);
748849                        break;
749850                }
750851                break;
751852            case 0xb000:
752                unimplemented_opcode(cpustate, op);
753853                if(op & 0x0800) // OUT A,Rr
754854                {
755                    //output += sprintf( output, "OUT     0x%02x, R%d", ACONST6(op), RD5(op) );
855                    WRITE_IO_8(cpustate, 0x20 + ACONST6(op), READ_IO_8(cpustate, RD5(op)));
756856                }
757857                else            // IN Rd,A
758858                {
759                    //output += sprintf( output, "IN      R%d, 0x%02x", RD5(op), ACONST6(op) );
859                    WRITE_IO_8(cpustate, RD5(op), READ_IO_8(cpustate, 0x20 + ACONST6(op)));
760860                }
761861                break;
762862            case 0xc000:    // RJMP k
763863                offs = (INT32)((op & 0x0800) ? ((op & 0x0fff) | 0xfffff000) : (op & 0x0fff));
764864                cpustate->pc += offs;
865                opcycles = 2;
765866                break;
766867            case 0xd000:    // RCALL k
767868                offs = (INT32)((op & 0x0800) ? ((op & 0x0fff) | 0xfffff000) : (op & 0x0fff));
768869                PUSH(cpustate, ((cpustate->pc + 1) >> 8) & 0x00ff);
769870                PUSH(cpustate, (cpustate->pc + 1) & 0x00ff);
770871                cpustate->pc += offs;
872                opcycles = 3;
771873                break;
772874            case 0xe000:    // LDI Rd,K
773875                rd = KCONST8(op);
r5568r5569
785887                                offs |= 0xffffff80;
786888                            }
787889                            cpustate->pc += offs;
890                            opcycles = 2;
788891                        }
789892                        break;
790893                    case 0x0400: // BRSH through BRID
r5568r5569
796899                                offs |= 0xffffff80;
797900                            }
798901                            cpustate->pc += offs;
902                            opcycles = 2;
799903                        }
800904                        break;
801905                    case 0x0800:
802                        unimplemented_opcode(cpustate, op);
803906                        if(op & 0x0200) // BST Rd, b
804907                        {
805                            //output += sprintf( output, "BST     R%d, %d", RD5(op), RR3(op) );
908                            SREG_W(AVR8_SREG_T, (BIT(READ_IO_8(cpustate, RD5(op)),RR3(op))) ? 1 : 0);
806909                        }
807910                        else            // BLD Rd, b
808911                        {
809                            //output += sprintf( output, "BLD     R%d, %d", RD5(op), RR3(op) );
912                            if(SREG_R(AVR8_SREG_T))
913                            {
914                                WRITE_IO_8(cpustate, RD5(op), READ_IO_8(cpustate, RD5(op)) | (1 << RR3(op)));
915                            }
916                            else
917                            {
918                                WRITE_IO_8(cpustate, RD5(op), READ_IO_8(cpustate, RD5(op)) &~ (1 << RR3(op)));
919                            }
810920                        }
811921                        break;
812922                    case 0x0c00:
813                        unimplemented_opcode(cpustate, op);
814923                        if(op & 0x0200) // SBRS Rd, b
815924                        {
816                            //output += sprintf( output, "SBRS    R%d, %d", RD5(op), RR3(op) );
925                            if(BIT(READ_IO_8(cpustate, RD5(op)),RR3(op)))
926                            {
927                                op = (UINT32)READ_PRG_16(cpustate, cpustate->pc++);
928                                opcycles = 2;
929                                if((op & 0xfe0c) == 0x940c ||
930                                   (op & 0xfe0f) == 0xfe0f)
931                                {
932                                    cpustate->pc++;
933                                    opcycles = 3;
934                                }
935                            }
817936                        }
818937                        else            // SBRC Rd, b
819938                        {
820                            //output += sprintf( output, "SBRC    R%d, %d", RD5(op), RR3(op) );
939                            if(!BIT(READ_IO_8(cpustate, RD5(op)),RR3(op)))
940                            {
941                                op = (UINT32)READ_PRG_16(cpustate, cpustate->pc++);
942                                opcycles = 2;
943                                if((op & 0xfe0c) == 0x940c ||
944                                   (op & 0xfc0f) == 0x9000)
945                                {
946                                    cpustate->pc++;
947                                    opcycles = 3;
948                                }
949                            }
821950                        }
822951                        break;
823952                }
r5568r5569
826955
827956        cpustate->pc++;
828957
829        --cpustate->icount;
958        cpustate->icount -= opcycles;
830959    }
831960
832961    return cycles - cpustate->icount;
r5568r5569
840969
841970    switch (state)
842971    {
972
973        /* interrupt lines/exceptions */
974        case CPUINFO_INT_INPUT_STATE + AVR8_INT_RESET:          avr8_set_irq_line(cpustate, AVR8_INT_RESET, info->i);       break;
975        case CPUINFO_INT_INPUT_STATE + AVR8_INT_INT0:           avr8_set_irq_line(cpustate, AVR8_INT_INT0, info->i);        break;
976        case CPUINFO_INT_INPUT_STATE + AVR8_INT_INT1:           avr8_set_irq_line(cpustate, AVR8_INT_INT1, info->i);        break;
977        case CPUINFO_INT_INPUT_STATE + AVR8_INT_PCINT0:         avr8_set_irq_line(cpustate, AVR8_INT_PCINT0, info->i);      break;
978        case CPUINFO_INT_INPUT_STATE + AVR8_INT_PCINT1:         avr8_set_irq_line(cpustate, AVR8_INT_PCINT1, info->i);      break;
979        case CPUINFO_INT_INPUT_STATE + AVR8_INT_PCINT2:         avr8_set_irq_line(cpustate, AVR8_INT_PCINT2, info->i);      break;
980        case CPUINFO_INT_INPUT_STATE + AVR8_INT_WDT:            avr8_set_irq_line(cpustate, AVR8_INT_WDT, info->i);         break;
981        case CPUINFO_INT_INPUT_STATE + AVR8_INT_T2COMPA:        avr8_set_irq_line(cpustate, AVR8_INT_T2COMPA, info->i);     break;
982        case CPUINFO_INT_INPUT_STATE + AVR8_INT_T2COMPB:        avr8_set_irq_line(cpustate, AVR8_INT_T2COMPB, info->i);     break;
983        case CPUINFO_INT_INPUT_STATE + AVR8_INT_T2OVF:          avr8_set_irq_line(cpustate, AVR8_INT_T2OVF, info->i);       break;
984        case CPUINFO_INT_INPUT_STATE + AVR8_INT_T1CAPT:         avr8_set_irq_line(cpustate, AVR8_INT_T1CAPT, info->i);      break;
985        case CPUINFO_INT_INPUT_STATE + AVR8_INT_T1COMPA:        avr8_set_irq_line(cpustate, AVR8_INT_T1COMPA, info->i);     break;
986        case CPUINFO_INT_INPUT_STATE + AVR8_INT_T1COMPB:        avr8_set_irq_line(cpustate, AVR8_INT_T1COMPB, info->i);     break;
987        case CPUINFO_INT_INPUT_STATE + AVR8_INT_T1OVF:          avr8_set_irq_line(cpustate, AVR8_INT_T1OVF, info->i);       break;
988        case CPUINFO_INT_INPUT_STATE + AVR8_INT_T0COMPA:        avr8_set_irq_line(cpustate, AVR8_INT_T0COMPA, info->i);     break;
989        case CPUINFO_INT_INPUT_STATE + AVR8_INT_T0COMPB:        avr8_set_irq_line(cpustate, AVR8_INT_T0COMPB, info->i);     break;
990        case CPUINFO_INT_INPUT_STATE + AVR8_INT_T0OVF:          avr8_set_irq_line(cpustate, AVR8_INT_T0OVF, info->i);       break;
991        case CPUINFO_INT_INPUT_STATE + AVR8_INT_SPI_STC:        avr8_set_irq_line(cpustate, AVR8_INT_SPI_STC, info->i);     break;
992        case CPUINFO_INT_INPUT_STATE + AVR8_INT_USART_RX:       avr8_set_irq_line(cpustate, AVR8_INT_USART_RX, info->i);    break;
993        case CPUINFO_INT_INPUT_STATE + AVR8_INT_USART_UDRE:     avr8_set_irq_line(cpustate, AVR8_INT_USART_UDRE, info->i);  break;
994        case CPUINFO_INT_INPUT_STATE + AVR8_INT_USART_TX:       avr8_set_irq_line(cpustate, AVR8_INT_USART_TX, info->i);    break;
995        case CPUINFO_INT_INPUT_STATE + AVR8_INT_ADC:            avr8_set_irq_line(cpustate, AVR8_INT_ADC, info->i);         break;
996        case CPUINFO_INT_INPUT_STATE + AVR8_INT_EE_RDY:         avr8_set_irq_line(cpustate, AVR8_INT_EE_RDY, info->i);      break;
997        case CPUINFO_INT_INPUT_STATE + AVR8_INT_ANALOG_COMP:    avr8_set_irq_line(cpustate, AVR8_INT_ANALOG_COMP, info->i); break;
998        case CPUINFO_INT_INPUT_STATE + AVR8_INT_TWI:            avr8_set_irq_line(cpustate, AVR8_INT_TWI, info->i);         break;
999        case CPUINFO_INT_INPUT_STATE + AVR8_INT_SPM_RDY:        avr8_set_irq_line(cpustate, AVR8_INT_SPM_RDY, info->i);     break;
1000
8431001        /* --- the following bits of info are set as 64-bit signed integers --- */
8441002        case CPUINFO_INT_PC:    /* intentional fallthrough */
8451003        case CPUINFO_INT_REGISTER + AVR8_PC:            cpustate->pc = info->i;                         break;
r5568r5569
9661124        case CPUINFO_STR_REGISTER + AVR8_X:             sprintf(info->s, "X: %04x", XREG ); break;
9671125        case CPUINFO_STR_REGISTER + AVR8_Y:             sprintf(info->s, "Y: %04x", YREG ); break;
9681126        case CPUINFO_STR_REGISTER + AVR8_Z:             sprintf(info->s, "Z: %04x", ZREG ); break;
1127        case CPUINFO_STR_REGISTER + AVR8_SP:            sprintf(info->s, "SP: %04x", SPREG ); break;
9691128    }
9701129}
src/emu/cpu/avr8/avr8.h
r5568r5569
5050    AVR8_X,
5151    AVR8_Y,
5252    AVR8_Z,
53    AVR8_SP,
5354};
5455
56enum
57{
58    AVR8_INT_RESET = 0,
59    AVR8_INT_INT0,
60    AVR8_INT_INT1,
61    AVR8_INT_PCINT0,
62    AVR8_INT_PCINT1,
63    AVR8_INT_PCINT2,
64    AVR8_INT_WDT,
65    AVR8_INT_T2COMPA,
66    AVR8_INT_T2COMPB,
67    AVR8_INT_T2OVF,
68    AVR8_INT_T1CAPT,
69    AVR8_INT_T1COMPA,
70    AVR8_INT_T1COMPB,
71    AVR8_INT_T1OVF,
72    AVR8_INT_T0COMPA,
73    AVR8_INT_T0COMPB,
74    AVR8_INT_T0OVF,
75    AVR8_INT_SPI_STC,
76    AVR8_INT_USART_RX,
77    AVR8_INT_USART_UDRE,
78    AVR8_INT_USART_TX,
79    AVR8_INT_ADC,
80    AVR8_INT_EE_RDY,
81    AVR8_INT_ANALOG_COMP,
82    AVR8_INT_TWI,
83    AVR8_INT_SPM_RDY,
84};
85
5586CPU_GET_INFO( avr8 );
5687#define CPU_AVR8 CPU_GET_INFO_NAME( avr8 )
5788
src/emu/cpu/avr8/avr8dasm.c
r5568r5569
3838                    output += sprintf( output, "NOP" );
3939                    break;
4040                case 0x0100:
41                    output += sprintf( output, "MOVW    R%d:R%d, R%d:R%d", RD4(op)+1, RD4(op), RR4(op)+1, RR4(op) );
41                    output += sprintf( output, "MOVW    R%d:R%d, R%d:R%d", (RD4(op) << 1)+1, RD4(op) << 1, (RR4(op) << 1)+1, RR4(op) << 1 );
4242                    break;
4343                case 0x0200:
4444                    output += sprintf( output, "MULS    R%d, R%d", 16+RD4(op), 16+RR4(op) );
src/emu/cpu/mips/mips3dsm.c
r5568r5569
1111
1212static const char *const reg[32] =
1313{
14   "0",   "r1",   "r2",   "r3",   "r4",   "r5",   "r6",   "r7",
15   "r8",   "r9",   "r10",   "r11",   "r12",   "r13",   "r14",   "r15",
16   "r16",   "r17",   "r18",   "r19",   "r20",   "r21",   "r22",   "r23",
17   "r24",   "r25",   "r26",   "r27",   "r28",   "r29",   "r30",   "r31"
14   "$0",   "$at",   "$v0",   "$v1",   "$a0",   "$a1",   "$a2",   "$a3",
15   "$t0",   "$t1",   "$t2",   "$t3",   "$t4",   "$t5",   "$t6",   "$t7",
16   "$s0",   "$s1",   "$s2",   "$s3",   "$s4",   "$s5",   "$s6",   "$s7",
17   "$t8",   "$t9",   "$k0",   "$k1",  "$gp",   "$sp",   "$fp",   "$ra"
1818};
1919
2020
src/emu/cpu/mips/mips3com.c
r5568r5569
558558      case CPUINFO_STR_REGISTER + MIPS3_WIRED:      sprintf(info->s, "Wired:%08X", (UINT32)mips->cpr[0][COP0_Wired]); break;
559559      case CPUINFO_STR_REGISTER + MIPS3_BADVADDR:      sprintf(info->s, "BadVAddr:%08X", (UINT32)mips->cpr[0][COP0_BadVAddr]); break;
560560
561      case CPUINFO_STR_REGISTER + MIPS3_R0:         sprintf(info->s, "R0: %08X%08X", (UINT32)(mips->r[0] >> 32), (UINT32)mips->r[0]); break;
562      case CPUINFO_STR_REGISTER + MIPS3_R1:         sprintf(info->s, "R1: %08X%08X", (UINT32)(mips->r[1] >> 32), (UINT32)mips->r[1]); break;
563      case CPUINFO_STR_REGISTER + MIPS3_R2:         sprintf(info->s, "R2: %08X%08X", (UINT32)(mips->r[2] >> 32), (UINT32)mips->r[2]); break;
564      case CPUINFO_STR_REGISTER + MIPS3_R3:         sprintf(info->s, "R3: %08X%08X", (UINT32)(mips->r[3] >> 32), (UINT32)mips->r[3]); break;
565      case CPUINFO_STR_REGISTER + MIPS3_R4:         sprintf(info->s, "R4: %08X%08X", (UINT32)(mips->r[4] >> 32), (UINT32)mips->r[4]); break;
566      case CPUINFO_STR_REGISTER + MIPS3_R5:         sprintf(info->s, "R5: %08X%08X", (UINT32)(mips->r[5] >> 32), (UINT32)mips->r[5]); break;
567      case CPUINFO_STR_REGISTER + MIPS3_R6:         sprintf(info->s, "R6: %08X%08X", (UINT32)(mips->r[6] >> 32), (UINT32)mips->r[6]); break;
568      case CPUINFO_STR_REGISTER + MIPS3_R7:         sprintf(info->s, "R7: %08X%08X", (UINT32)(mips->r[7] >> 32), (UINT32)mips->r[7]); break;
569      case CPUINFO_STR_REGISTER + MIPS3_R8:         sprintf(info->s, "R8: %08X%08X", (UINT32)(mips->r[8] >> 32), (UINT32)mips->r[8]); break;
570      case CPUINFO_STR_REGISTER + MIPS3_R9:         sprintf(info->s, "R9: %08X%08X", (UINT32)(mips->r[9] >> 32), (UINT32)mips->r[9]); break;
571      case CPUINFO_STR_REGISTER + MIPS3_R10:         sprintf(info->s, "R10:%08X%08X", (UINT32)(mips->r[10] >> 32), (UINT32)mips->r[10]); break;
572      case CPUINFO_STR_REGISTER + MIPS3_R11:         sprintf(info->s, "R11:%08X%08X", (UINT32)(mips->r[11] >> 32), (UINT32)mips->r[11]); break;
573      case CPUINFO_STR_REGISTER + MIPS3_R12:         sprintf(info->s, "R12:%08X%08X", (UINT32)(mips->r[12] >> 32), (UINT32)mips->r[12]); break;
574      case CPUINFO_STR_REGISTER + MIPS3_R13:         sprintf(info->s, "R13:%08X%08X", (UINT32)(mips->r[13] >> 32), (UINT32)mips->r[13]); break;
575      case CPUINFO_STR_REGISTER + MIPS3_R14:         sprintf(info->s, "R14:%08X%08X", (UINT32)(mips->r[14] >> 32), (UINT32)mips->r[14]); break;
576      case CPUINFO_STR_REGISTER + MIPS3_R15:         sprintf(info->s, "R15:%08X%08X", (UINT32)(mips->r[15] >> 32), (UINT32)mips->r[15]); break;
577      case CPUINFO_STR_REGISTER + MIPS3_R16:         sprintf(info->s, "R16:%08X%08X", (UINT32)(mips->r[16] >> 32), (UINT32)mips->r[16]); break;
578      case CPUINFO_STR_REGISTER + MIPS3_R17:         sprintf(info->s, "R17:%08X%08X", (UINT32)(mips->r[17] >> 32), (UINT32)mips->r[17]); break;
579      case CPUINFO_STR_REGISTER + MIPS3_R18:         sprintf(info->s, "R18:%08X%08X", (UINT32)(mips->r[18] >> 32), (UINT32)mips->r[18]); break;
580      case CPUINFO_STR_REGISTER + MIPS3_R19:         sprintf(info->s, "R19:%08X%08X", (UINT32)(mips->r[19] >> 32), (UINT32)mips->r[19]); break;
581      case CPUINFO_STR_REGISTER + MIPS3_R20:         sprintf(info->s, "R20:%08X%08X", (UINT32)(mips->r[20] >> 32), (UINT32)mips->r[20]); break;
582      case CPUINFO_STR_REGISTER + MIPS3_R21:         sprintf(info->s, "R21:%08X%08X", (UINT32)(mips->r[21] >> 32), (UINT32)mips->r[21]); break;
583      case CPUINFO_STR_REGISTER + MIPS3_R22:         sprintf(info->s, "R22:%08X%08X", (UINT32)(mips->r[22] >> 32), (UINT32)mips->r[22]); break;
584      case CPUINFO_STR_REGISTER + MIPS3_R23:         sprintf(info->s, "R23:%08X%08X", (UINT32)(mips->r[23] >> 32), (UINT32)mips->r[23]); break;
585      case CPUINFO_STR_REGISTER + MIPS3_R24:         sprintf(info->s, "R24:%08X%08X", (UINT32)(mips->r[24] >> 32), (UINT32)mips->r[24]); break;
586      case CPUINFO_STR_REGISTER + MIPS3_R25:         sprintf(info->s, "R25:%08X%08X", (UINT32)(mips->r[25] >> 32), (UINT32)mips->r[25]); break;
587      case CPUINFO_STR_REGISTER + MIPS3_R26:         sprintf(info->s, "R26:%08X%08X", (UINT32)(mips->r[26] >> 32), (UINT32)mips->r[26]); break;
588      case CPUINFO_STR_REGISTER + MIPS3_R27:         sprintf(info->s, "R27:%08X%08X", (UINT32)(mips->r[27] >> 32), (UINT32)mips->r[27]); break;
589      case CPUINFO_STR_REGISTER + MIPS3_R28:         sprintf(info->s, "R28:%08X%08X", (UINT32)(mips->r[28] >> 32), (UINT32)mips->r[28]); break;
590      case CPUINFO_STR_REGISTER + MIPS3_R29:         sprintf(info->s, "R29:%08X%08X", (UINT32)(mips->r[29] >> 32), (UINT32)mips->r[29]); break;
591      case CPUINFO_STR_REGISTER + MIPS3_R30:         sprintf(info->s, "R30:%08X%08X", (UINT32)(mips->r[30] >> 32), (UINT32)mips->r[30]); break;
592      case CPUINFO_STR_REGISTER + MIPS3_R31:         sprintf(info->s, "R31:%08X%08X", (UINT32)(mips->r[31] >> 32), (UINT32)mips->r[31]); break;
561      case CPUINFO_STR_REGISTER + MIPS3_R0:         sprintf(info->s, "$zero: %08X%08X", (UINT32)(mips->r[0] >> 32), (UINT32)mips->r[0]); break;
562      case CPUINFO_STR_REGISTER + MIPS3_R1:         sprintf(info->s, "  $at: %08X%08X", (UINT32)(mips->r[1] >> 32), (UINT32)mips->r[1]); break;
563      case CPUINFO_STR_REGISTER + MIPS3_R2:         sprintf(info->s, "  $v0: %08X%08X", (UINT32)(mips->r[2] >> 32), (UINT32)mips->r[2]); break;
564      case CPUINFO_STR_REGISTER + MIPS3_R3:         sprintf(info->s, "  $v1: %08X%08X", (UINT32)(mips->r[3] >> 32), (UINT32)mips->r[3]); break;
565      case CPUINFO_STR_REGISTER + MIPS3_R4:         sprintf(info->s, "  $a0: %08X%08X", (UINT32)(mips->r[4] >> 32), (UINT32)mips->r[4]); break;
566      case CPUINFO_STR_REGISTER + MIPS3_R5:         sprintf(info->s, "  $a1: %08X%08X", (UINT32)(mips->r[5] >> 32), (UINT32)mips->r[5]); break;
567      case CPUINFO_STR_REGISTER + MIPS3_R6:         sprintf(info->s, "  $a2: %08X%08X", (UINT32)(mips->r[6] >> 32), (UINT32)mips->r[6]); break;
568      case CPUINFO_STR_REGISTER + MIPS3_R7:         sprintf(info->s, "  $a3: %08X%08X", (UINT32)(mips->r[7] >> 32), (UINT32)mips->r[7]); break;
569      case CPUINFO_STR_REGISTER + MIPS3_R8:         sprintf(info->s, "  $t0: %08X%08X", (UINT32)(mips->r[8] >> 32), (UINT32)mips->r[8]); break;
570      case CPUINFO_STR_REGISTER + MIPS3_R9:         sprintf(info->s, "  $t1: %08X%08X", (UINT32)(mips->r[9] >> 32), (UINT32)mips->r[9]); break;
571      case CPUINFO_STR_REGISTER + MIPS3_R10:         sprintf(info->s, "  $t2:%08X%08X", (UINT32)(mips->r[10] >> 32), (UINT32)mips->r[10]); break;
572      case CPUINFO_STR_REGISTER + MIPS3_R11:         sprintf(info->s, "  $t3:%08X%08X", (UINT32)(mips->r[11] >> 32), (UINT32)mips->r[11]); break;
573      case CPUINFO_STR_REGISTER + MIPS3_R12:         sprintf(info->s, "  $t4:%08X%08X", (UINT32)(mips->r[12] >> 32), (UINT32)mips->r[12]); break;
574      case CPUINFO_STR_REGISTER + MIPS3_R13:         sprintf(info->s, "  $t5:%08X%08X", (UINT32)(mips->r[13] >> 32), (UINT32)mips->r[13]); break;
575      case CPUINFO_STR_REGISTER + MIPS3_R14:         sprintf(info->s, "  $t6:%08X%08X", (UINT32)(mips->r[14] >> 32), (UINT32)mips->r[14]); break;
576      case CPUINFO_STR_REGISTER + MIPS3_R15:         sprintf(info->s, "  $t7:%08X%08X", (UINT32)(mips->r[15] >> 32), (UINT32)mips->r[15]); break;
577      case CPUINFO_STR_REGISTER + MIPS3_R16:         sprintf(info->s, "  $s0:%08X%08X", (UINT32)(mips->r[16] >> 32), (UINT32)mips->r[16]); break;
578      case CPUINFO_STR_REGISTER + MIPS3_R17:         sprintf(info->s, "  $s1:%08X%08X", (UINT32)(mips->r[17] >> 32), (UINT32)mips->r[17]); break;
579      case CPUINFO_STR_REGISTER + MIPS3_R18:         sprintf(info->s, "  $s2:%08X%08X", (UINT32)(mips->r[18] >> 32), (UINT32)mips->r[18]); break;
580      case CPUINFO_STR_REGISTER + MIPS3_R19:         sprintf(info->s, "  $s3:%08X%08X", (UINT32)(mips->r[19] >> 32), (UINT32)mips->r[19]); break;
581      case CPUINFO_STR_REGISTER + MIPS3_R20:         sprintf(info->s, "  $s4:%08X%08X", (UINT32)(mips->r[20] >> 32), (UINT32)mips->r[20]); break;
582      case CPUINFO_STR_REGISTER + MIPS3_R21:         sprintf(info->s, "  $s5:%08X%08X", (UINT32)(mips->r[21] >> 32), (UINT32)mips->r[21]); break;
583      case CPUINFO_STR_REGISTER + MIPS3_R22:         sprintf(info->s, "  $s6:%08X%08X", (UINT32)(mips->r[22] >> 32), (UINT32)mips->r[22]); break;
584      case CPUINFO_STR_REGISTER + MIPS3_R23:         sprintf(info->s, "  $s7:%08X%08X", (UINT32)(mips->r[23] >> 32), (UINT32)mips->r[23]); break;
585      case CPUINFO_STR_REGISTER + MIPS3_R24:         sprintf(info->s, "  $t8:%08X%08X", (UINT32)(mips->r[24] >> 32), (UINT32)mips->r[24]); break;
586      case CPUINFO_STR_REGISTER + MIPS3_R25:         sprintf(info->s, "  $t9:%08X%08X", (UINT32)(mips->r[25] >> 32), (UINT32)mips->r[25]); break;
587      case CPUINFO_STR_REGISTER + MIPS3_R26:         sprintf(info->s, "  $k0:%08X%08X", (UINT32)(mips->r[26] >> 32), (UINT32)mips->r[26]); break;
588      case CPUINFO_STR_REGISTER + MIPS3_R27:         sprintf(info->s, "  $k1:%08X%08X", (UINT32)(mips->r[27] >> 32), (UINT32)mips->r[27]); break;
589      case CPUINFO_STR_REGISTER + MIPS3_R28:         sprintf(info->s, "  $gp:%08X%08X", (UINT32)(mips->r[28] >> 32), (UINT32)mips->r[28]); break;
590      case CPUINFO_STR_REGISTER + MIPS3_R29:         sprintf(info->s, "  $sp:%08X%08X", (UINT32)(mips->r[29] >> 32), (UINT32)mips->r[29]); break;
591      case CPUINFO_STR_REGISTER + MIPS3_R30:         sprintf(info->s, "  $fp:%08X%08X", (UINT32)(mips->r[30] >> 32), (UINT32)mips->r[30]); break;
592      case CPUINFO_STR_REGISTER + MIPS3_R31:         sprintf(info->s, "  $ra:%08X%08X", (UINT32)(mips->r[31] >> 32), (UINT32)mips->r[31]); break;
593593      case CPUINFO_STR_REGISTER + MIPS3_HI:         sprintf(info->s, "HI: %08X%08X", (UINT32)(mips->r[REG_HI] >> 32), (UINT32)mips->r[REG_HI]); break;
594594      case CPUINFO_STR_REGISTER + MIPS3_LO:         sprintf(info->s, "LO: %08X%08X", (UINT32)(mips->r[REG_LO] >> 32), (UINT32)mips->r[REG_LO]); break;
595595
src/mess/messdriv.c
r5568r5569
6565    DRIVER( gblight )   /* Nintendo Game Boy Light Handheld             */
6666    DRIVER( gbcolor )   /* Nintendo Game Boy Color Handheld                 */
6767    DRIVER( snes )      /* Nintendo Super Nintendo NTSC                     */
68    DRIVER( snessfx )   /* Nintendo Super Nintendo NTSC, SuperFX         */
6869    DRIVER( snespal )   /* Nintendo Super Nintendo PAL                      */
6970    DRIVER( sfcbox )    /* Nintendo Super Famicom Box                       */
7071    DRIVER( n64 )       /* Nintendo N64                                     */
r5568r5569
12271228    DRIVER( hc91 )    /* 1991 HC-91                                       */
12281229    DRIVER( hc128 )   /* 1991 HC-128                                      */
12291230    DRIVER( hc2000 )  /* 1992 HC-2000                                     */
1230   
1231
12311232    DRIVER( cobra )
12321233    DRIVER( cobra80 )
12331234
r5568r5569
14691470    DRIVER( sol20 )
14701471    DRIVER( 4004clk )
14711472    DRIVER( busicom )
1472   
1473
14731474#endif /* DRIVER_RECURSIVE */
src/mess/machine/snescart.c
r5568r5569
4242/* Some known countries */
4343static const char *const countries[] =
4444{
45/* 0*/   "Japan (NTSC)", "USA & Canada (NTSC)", "Europe, Oceania & Asia (PAL)", "Sweden (PAL)",
46/* 4*/   "Finland (PAL)", "Denmark (PAL)", "France (PAL)", "Holland (PAL)",
45/* 0*/   "Japan (NTSC)", "USA & Canada (NTSC)", "Europe, Oceania & Asia (PAL)", "Sweden (PAL)",
46/* 4*/   "Finland (PAL)", "Denmark (PAL)", "France (PAL)", "Holland (PAL)",
4747/* 8*/   "Spain (PAL)", "Germany, Austria & Switzerland (PAL)", "Italy (PAL)", "Hong Kong & China (PAL)",
4848/* c*/   "Indonesia (PAL)", "South Korea (NTSC)", UNK, UNK,
4949};
r5568r5569
5151/* Some known companies (integrations to the list from Snes9x) */
5252static const char *const companies[] =
5353{
54/* 0*/   "Invalid", "Nintendo", "Ajinomoto", "Imagineer-Zoom", "Chris Gray Enterprises Inc.", "Zamuse", "Falcom", UNK,
55/* 8*/   "Capcom", "HOT-B", "Jaleco", "Coconuts", "Rage Software", "Micronet", "Technos", "Mebio Software",
56/*10*/   "SHOUEi System", "Starfish", "Gremlin Graphics", "Electronic Arts", "NCS / Masaya", "COBRA Team", "Human/Field", "KOEI",
57/*18*/   "Hudson Soft", "Game Village", "Yanoman", UNK, "Tecmo", UNK, "Open System", "Virgin Games",
54/* 0*/   "Invalid", "Nintendo", "Ajinomoto", "Imagineer-Zoom", "Chris Gray Enterprises Inc.", "Zamuse", "Falcom", UNK,
55/* 8*/   "Capcom", "HOT-B", "Jaleco", "Coconuts", "Rage Software", "Micronet", "Technos", "Mebio Software",
56/*10*/   "SHOUEi System", "Starfish", "Gremlin Graphics", "Electronic Arts", "NCS / Masaya", "COBRA Team", "Human/Field", "KOEI",
57/*18*/   "Hudson Soft", "Game Village", "Yanoman", UNK, "Tecmo", UNK, "Open System", "Virgin Games",
5858/*20*/   "KSS", "Sunsoft", "POW", "Micro World", UNK, UNK, "Enix", "Loriciel/Electro Brain",
5959/*28*/   "Kemco", "Seta Co.,Ltd.", "Culture Brain", "Irem Japan", "Pal Soft", "Visit Co.,Ltd.", "INTEC Inc.", "System Sacom Corp.",
60/*30*/   "Viacom New Media", "Carrozzeria", "Dynamic", "Nintendo", "Magifact", "Hect", UNK, UNK,
61/*38*/   "Capcom Europe", "Accolade Europe", UNK, "Arcade Zone", "Empire Software", "Loriciel", "Gremlin Graphics", UNK,
62/*40*/   "Seika Corp.", "UBI Soft", UNK, UNK, "LifeFitness Exertainment", UNK, "System 3", "Spectrum Holobyte",
63/*48*/   UNK, "Irem", UNK, "Raya Systems/Sculptured Software", "Renovation Products", "Malibu Games/Black Pearl", UNK, "U.S. Gold",
64/*50*/   "Absolute Entertainment", "Acclaim", "Activision", "American Sammy", "GameTek", "Hi Tech Expressions", "LJN Toys", UNK,
65/*58*/   UNK, UNK, "Mindscape", "Romstar, Inc.", UNK, "Tradewest", UNK, "American Softworks Corp.",
66/*60*/   "Titus", "Virgin Interactive Entertainment", "Maxis", "Origin/FCI/Pony Canyon", UNK, UNK, UNK, "Ocean",
67/*68*/   UNK, "Electronic Arts", UNK, "Laser Beam", UNK, UNK, "Elite", "Electro Brain",
68/*70*/   "Infogrames", "Interplay", "LucasArts", "Parker Brothers", "Konami", "STORM", UNK, UNK,
69/*78*/   "THQ Software", "Accolade Inc.", "Triffix Entertainment", UNK, "Microprose", UNK, UNK, "Kemco",
60/*30*/   "Viacom New Media", "Carrozzeria", "Dynamic", "Nintendo", "Magifact", "Hect", UNK, UNK,
61/*38*/   "Capcom Europe", "Accolade Europe", UNK, "Arcade Zone", "Empire Software", "Loriciel", "Gremlin Graphics", UNK,
62/*40*/   "Seika Corp.", "UBI Soft", UNK, UNK, "LifeFitness Exertainment", UNK, "System 3", "Spectrum Holobyte",
63/*48*/   UNK, "Irem", UNK, "Raya Systems/Sculptured Software", "Renovation Products", "Malibu Games/Black Pearl", UNK, "U.S. Gold",
64/*50*/   "Absolute Entertainment", "Acclaim", "Activision", "American Sammy", "GameTek", "Hi Tech Expressions", "LJN Toys", UNK,
65/*58*/   UNK, UNK, "Mindscape", "Romstar, Inc.", UNK, "Tradewest", UNK, "American Softworks Corp.",
66/*60*/   "Titus", "Virgin Interactive Entertainment", "Maxis", "Origin/FCI/Pony Canyon", UNK, UNK, UNK, "Ocean",
67/*68*/   UNK, "Electronic Arts", UNK, "Laser Beam", UNK, UNK, "Elite", "Electro Brain",
68/*70*/   "Infogrames", "Interplay", "LucasArts", "Parker Brothers", "Konami", "STORM", UNK, UNK,
69/*78*/   "THQ Software", "Accolade Inc.", "Triffix Entertainment", UNK, "Microprose", UNK, UNK, "Kemco",
7070/*80*/   "Misawa", "Teichio", "Namco Ltd.", "Lozc", "Koei", UNK, "Tokuma Shoten Intermedia", "Tsukuda Original",
71/*88*/   "DATAM-Polystar", UNK, UNK, "Bullet-Proof Software", "Vic Tokai", UNK, "Character Soft", "I\'\'Max",
72/*90*/   "Takara", "CHUN Soft", "Video System Co., Ltd.", "BEC", UNK, "Varie", "Yonezawa / S'Pal Corp.", "Kaneco",
73/*98*/   UNK, "Pack in Video", "Nichibutsu", "TECMO", "Imagineer Co.", UNK, UNK, UNK,
74/*a0*/   "Telenet", "Hori", UNK, UNK, "Konami", "K.Amusement Leasing Co.", UNK, "Takara",
75/*a8*/   UNK, "Technos Jap.", "JVC", UNK, "Toei Animation", "Toho", UNK, "Namco Ltd.",
76/*b0*/   "Media Rings Corp.", "ASCII Co. Activison", "Bandai", UNK, "Enix America", UNK, "Halken", UNK,
77/*b8*/   UNK, UNK, "Culture Brain", "Sunsoft", "Toshiba EMI", "Sony Imagesoft", UNK, "Sammy",
78/*c0*/   "Taito", UNK, "Kemco", "Square", "Tokuma Soft", "Data East", "Tonkin House", UNK,
79/*c8*/   "KOEI", UNK, "Konami USA", "NTVIC", UNK, "Meldac", "Pony Canyon", "Sotsu Agency/Sunrise",
80/*d0*/   "Disco/Taito", "Sofel", "Quest Corp.", "Sigma", "Ask Kodansha Co., Ltd.", UNK, "Naxat", UNK,
81/*d8*/   "Capcom Co., Ltd.", "Banpresto", "Tomy", "Acclaim", UNK, "NCS", "Human Entertainment", "Altron",
82/*e0*/   "Jaleco", UNK, "Yutaka", UNK, "T&ESoft", "EPOCH Co.,Ltd.", UNK, "Athena",
83/*e8*/   "Asmik", "Natsume", "King Records", "Atlus", "Sony Music Entertainment", UNK, "IGS", UNK,
84/*f0*/   UNK, "Motown Software", "Left Field Entertainment", "Beam Software", "Tec Magik", UNK, UNK, UNK,
71/*88*/   "DATAM-Polystar", UNK, UNK, "Bullet-Proof Software", "Vic Tokai", UNK, "Character Soft", "I\'\'Max",
72/*90*/   "Takara", "CHUN Soft", "Video System Co., Ltd.", "BEC", UNK, "Varie", "Yonezawa / S'Pal Corp.", "Kaneco",
73/*98*/   UNK, "Pack in Video", "Nichibutsu", "TECMO", "Imagineer Co.", UNK, UNK, UNK,
74/*a0*/   "Telenet", "Hori", UNK, UNK, "Konami", "K.Amusement Leasing Co.", UNK, "Takara",
75/*a8*/   UNK, "Technos Jap.", "JVC", UNK, "Toei Animation", "Toho", UNK, "Namco Ltd.",
76/*b0*/   "Media Rings Corp.", "ASCII Co. Activison", "Bandai", UNK, "Enix America", UNK, "Halken", UNK,
77/*b8*/   UNK, UNK, "Culture Brain", "Sunsoft", "Toshiba EMI", "Sony Imagesoft", UNK, "Sammy",
78/*c0*/   "Taito", UNK, "Kemco", "Square", "Tokuma Soft", "Data East", "Tonkin House", UNK,
79/*c8*/   "KOEI", UNK, "Konami USA", "NTVIC", UNK, "Meldac", "Pony Canyon", "Sotsu Agency/Sunrise",
80/*d0*/   "Disco/Taito", "Sofel", "Quest Corp.", "Sigma", "Ask Kodansha Co., Ltd.", UNK, "Naxat", UNK,
81/*d8*/   "Capcom Co., Ltd.", "Banpresto", "Tomy", "Acclaim", UNK, "NCS", "Human Entertainment", "Altron",
82/*e0*/   "Jaleco", UNK, "Yutaka", UNK, "T&ESoft", "EPOCH Co.,Ltd.", UNK, "Athena",
83/*e8*/   "Asmik", "Natsume", "King Records", "Atlus", "Sony Music Entertainment", UNK, "IGS", UNK,
84/*f0*/   UNK, "Motown Software", "Left Field Entertainment", "Beam Software", "Tec Magik", UNK, UNK, UNK,
8585/*f8*/   UNK, "Cybersoft", UNK, "Psygnosis", UNK, UNK, "Davidson", UNK,
8686};
8787
r5568r5569
107107   else if (id == 'E') value = 0x0e;
108108   else if (id == 'F') value = 0x0f;
109109   else value = 0x00;
110   
110
111111   return value;
112112}
113113
r5568r5569
130130
131131   if (snes_cart.mode == SNES_MODE_20)
132132   {
133      /* There could be some larger image needing banks 0x70 to 0x7f at address 0x8000 for ROM
133      /* There could be some larger image needing banks 0x70 to 0x7f at address 0x8000 for ROM
134134       * mirroring. These should be treated separately or data would be overwritten by SRAM */
135135      for (ii = 0; ii < 16; ii++)
136136      {
r5568r5569
237237
238238   /* $00:[000-7fff] contains uninitialized RAM and MMIO.
239239   reset vector must point to ROM at $00:[8000-ffff] to be considered valid. */
240   if (reset_vector < 0x8000)
240   if (reset_vector < 0x8000)
241241      return 0;
242242
243243   /* some images duplicate the header in multiple locations, and others have completely
244   invalid header information that cannot be relied upon. The code below will analyze
245   the first opcode executed at the specified reset vector to determine the probability
244   invalid header information that cannot be relied upon. The code below will analyze
245   the first opcode executed at the specified reset vector to determine the probability
246246   that this is the correct header. Score is assigned accordingly. */
247247
248248   /* most likely opcodes */
r5568r5569
252252      || reset_opcode == 0x9c      //stz $nnnn (stz $4200)
253253      || reset_opcode == 0x4c      //jmp $nnnn
254254      || reset_opcode == 0x5c      //jml $nnnnnn
255   )
255   )
256256      score += 8;
257257
258258   /* plausible opcodes */
r5568r5569
267267      || reset_opcode == 0xa0      //ldy #$nn
268268      || reset_opcode == 0x20      //jsr $nnnn
269269      || reset_opcode == 0x22      //jsl $nnnnnn
270   )
270   )
271271      score += 4;
272272
273273   /* implausible opcodes */
r5568r5569
277277      || reset_opcode == 0xcd      //cmp $nnnn
278278      || reset_opcode == 0xec      //cpx $nnnn
279279      || reset_opcode == 0xcc      //cpy $nnnn
280   )   
280   )
281281      score -= 4;
282282
283283   /* least likely opcodes */
r5568r5569
286286      || reset_opcode == 0xdb      //stp
287287      || reset_opcode == 0x42      //wdm
288288      || reset_opcode == 0xff      //sbc $nnnnnn,x
289   )
289   )
290290      score -= 8;
291291
292292   /* Sometimes, both the header and reset vector's first opcode will match ...
293293   fallback and rely on info validity in these cases to determine more likely header. */
294294
295295   /* a valid checksum is the biggest indicator of a valid header. */
296   if ((checksum + ichecksum) == 0xffff && (checksum != 0) && (ichecksum != 0))
296   if ((checksum + ichecksum) == 0xffff && (checksum != 0) && (ichecksum != 0))
297297      score += 4;
298298
299299   /* then there are the expected mapper values */
r5568r5569
307307      score += 2;
308308
309309   if (offset == 0x40ffc0 && mapper == 0x25)   // 0x25 is usually ExHiROM
310      score += 2;
310      score += 2;
311311
312312   /* finally, there are valid values in the Company, Region etc. fields */
313313   if (infoblock[offset + 0x1a] == 0x33)         // Company field: 0x33 indicates extended header
314      score += 2;
314      score += 2;
315315
316316   if (infoblock[offset + 0x16] < 0x08)         // ROM Type field
317317      score++;
318318
319   if (infoblock[offset + 0x17] < 0x10)         // ROM Size field
319   if (infoblock[offset + 0x17] < 0x10)         // ROM Size field
320320      score++;
321321
322   if (infoblock[offset + 0x18] < 0x08)         // SRAM Size field
322   if (infoblock[offset + 0x18] < 0x08)         // SRAM Size field
323323      score++;
324324
325   if (infoblock[offset + 0x19] < 14)            // Region field
325   if (infoblock[offset + 0x19] < 14)            // Region field
326326      score++;
327327
328328   /* do we still have a positive score? */
329   if (score < 0)
329   if (score < 0)
330330      score = 0;
331331
332332   return score;
r5568r5569
377377      image_fseek(image, offset, SEEK_SET);
378378   }
379379
380   /* We need to take a sample to test what mode we need to be in (the
380   /* We need to take a sample to test what mode we need to be in (the
381381   sample has to be quite large to cope with large carts in ExHiRom) */
382382   image_fread(image, temp_buffer, 0x40ffff);
383383   image_fseek(image, offset, SEEK_SET);   /* Rewind */
r5568r5569
406406      snes_cart.mode = SNES_MODE_21;   // HiRom
407407      snes_cart.sram_max = 0x20000;
408408   }
409   else
409   else
410410   {
411411      snes_cart.mode = SNES_MODE_25;   // ExHiRom
412412      snes_cart.sram_max = 0x20000;
r5568r5569
418418   total_blocks = ((image_length(image) - offset) / (snes_cart.mode & 0x05 ? 0x8000 : 0x10000));
419419   read_blocks = 0;
420420
421   /* Loading all the data blocks from cart, we only partially cover banks 0x00 to 0x7f. Therefore, we
422    * have to mirror the blocks until we reach the end. E.g. for a 11Mbits image (44 blocks), we proceed
423    * as follows:
421   /* Loading all the data blocks from cart, we only partially cover banks 0x00 to 0x7f. Therefore, we
422    * have to mirror the blocks until we reach the end. E.g. for a 11Mbits image (44 blocks), we proceed
423    * as follows:
424424    * 11 Mbits = 8 Mbits (blocks 1->32) + 2 Mbits (blocks 33->40) + 1 Mbit (blocks 41->44).
425425    * Hence, we fill memory up to 16 Mbits (banks 0x00 to 0x3f) mirroring as follows
426426    * 8 Mbits (blocks 1->32) + 2 Mbits (blocks 33->40) + 1 Mbit (blocks 41->44) + 1 Mbit (blocks 41->44)
427427    *   + 2 Mbits (blocks 33->40) + 1 Mbit (blocks 41->44) + 1 Mbit (blocks 41->44)
428428    * and we repeat the same blocks in the second half of the banks (banks 0x40 to 0x7f).
429    * This is likely what happens in the real SNES as well, because the unit cannot be aware of the exact
429    * This is likely what happens in the real SNES as well, because the unit cannot be aware of the exact
430430    * size of data in the cart (procedure confirmed by byuu)
431431    */
432432   switch (snes_cart.mode)
433433   {
434434      case SNES_MODE_21:
435      /* HiROM carts load data in banks 0xc0 to 0xff. Each bank is fully mirrored in banks 0x40 to 0x7f
436       * (actually up to 0x7d, because 0x7e and 0x7f are overwritten by WRAM). The top half (address
437       * range 0x8000 - 0xffff) of each bank is also mirrored in banks 0x00 to 0x3f and 0x80 to 0xbf.
435      /* HiROM carts load data in banks 0xc0 to 0xff. Each bank is fully mirrored in banks 0x40 to 0x7f
436       * (actually up to 0x7d, because 0x7e and 0x7f are overwritten by WRAM). The top half (address
437       * range 0x8000 - 0xffff) of each bank is also mirrored in banks 0x00 to 0x3f and 0x80 to 0xbf.
438438       */
439439         while (read_blocks < 64 && read_blocks < total_blocks)
440440         {
r5568r5569
463463         break;
464464
465465      case SNES_MODE_25:
466      /* Extendend HiROM carts start to load data in banks 0xc0 to 0xff. However, they exceed the
467       * available space in these banks, and continue loading at banks 0x40 to 0x7f. The top half
466      /* Extendend HiROM carts start to load data in banks 0xc0 to 0xff. However, they exceed the
467       * available space in these banks, and continue loading at banks 0x40 to 0x7f. The top half
468468       * (address range 0x8000 - 0xffff) of each bank is also mirrored either to banks 0x00 to 0x3f
469469       * (for data in banks 0x40 to 0x7f) or to banks 0x80 to 0xbf (for data in banks 0xc0 to 0xff).
470       * Notice that banks 0x7e and 0x7f are overwritten by WRAM, but they could contain data at
471       * address > 0x8000 because the mirrors at 0x3e and 0x3f are not overwritten.
470       * Notice that banks 0x7e and 0x7f are overwritten by WRAM, but they could contain data at
471       * address > 0x8000 because the mirrors at 0x3e and 0x3f are not overwritten.
472472       */
473473         /* Reading the first 64 blocks */
474474         while (read_blocks < 64 && read_blocks < total_blocks)
r5568r5569
512512         break;
513513
514514      case SNES_MODE_22:
515      /* "Extendend LoROM" carts have their data loaded in banks 0x00 to 0x3f at address 0x8000.
515      /* "Extendend LoROM" carts have their data loaded in banks 0x00 to 0x3f at address 0x8000.
516516       * These are then mirrored in banks 0x40 to 0x7f, both at address 0x0000 and at address
517       * 0x8000, in banks 0x80 to 0xbf at address 0x8000 and in banks 0xc0 to 0xff, both at address
517       * 0x8000, in banks 0x80 to 0xbf at address 0x8000 and in banks 0xc0 to 0xff, both at address
518518       * 0x0000 and at address 0x8000. Notice that SDD-1 games (Star Ocean and Street Fighter Zero 2)
519       * also use SNES_MODE_22, but we still don't support their bankswitch mechanism: the content
520       * of banks at 0xc0 to 0xff changes according to MMC registers $4804-$4807
519       * also use SNES_MODE_22, but we still don't support their bankswitch mechanism: the content
520       * of banks at 0xc0 to 0xff changes according to MMC registers $4804-$4807
521521       */
522522         while (read_blocks < 64 && read_blocks < total_blocks)
523523         {
r5568r5569
549549
550550      default:
551551      case SNES_MODE_20:
552      /* LoROM carts load data in banks 0x00 to 0x7f at address 0x8000 (actually up to 0x7d, because 0x7e and
553       * 0x7f are overwritten by WRAM). Each block is also mirrored in banks 0x80 to 0xff (up to 0xff for real)
552      /* LoROM carts load data in banks 0x00 to 0x7f at address 0x8000 (actually up to 0x7d, because 0x7e and
553       * 0x7f are overwritten by WRAM). Each block is also mirrored in banks 0x80 to 0xff (up to 0xff for real)
554554       */
555555         while (read_blocks < 128 && read_blocks < total_blocks)
556556         {
r5568r5569
632632         case 0x1a:   // GSU-1 (21 MHz at start)
633633            if (snes_r_bank1(space, 0x00ffd5) == 0x20)
634634               snes_has_addon_chip = HAS_SUPERFX;
635               supported_type = 1;
635636            break;
636637
637638         case 0x25:
r5568r5569
662663            break;
663664
664665         case 0xf3:
665            snes_has_addon_chip = HAS_C4;
666            snes_has_addon_chip = HAS_CX4;
666667            break;
667         
668
668669         case 0xf5:
669670            if (snes_r_bank1(space, 0x00ffd5) == 0x30)
670671               snes_has_addon_chip = HAS_ST018;
r5568r5569
673674            break;
674675
675676         case 0xf6:
676            /* These Seta ST-01X chips have both 0x30 at 0x00ffd5,
677            /* These Seta ST-01X chips have both 0x30 at 0x00ffd5,
677678            they only differ for the 'size' at 0x00ffd7 */
678679            if (snes_r_bank1(space, 0x00ffd7) < 0x0a)
679680               snes_has_addon_chip = HAS_ST011;
r5568r5569
685686            if (snes_r_bank1(space, 0x00ffd5) == 0x3a)
686687               snes_has_addon_chip = HAS_SPC7110_RTC;
687688            break;
688         
689
689690         default:
690691            snes_has_addon_chip = HAS_UNK;
691692            break;
r5568r5569
700701      for( i = 0; i < 2; i++ )
701702         company_id[i] = snes_r_bank1(space, 0x00ffb0 + i);
702703      company = (char_to_int_conv(company_id[0]) << 4) + char_to_int_conv(company_id[1]);
703      if (company == 0)
704      if (company == 0)
704705         company = snes_r_bank1(space, 0x00ffda);
705706
706707      /* ROM ID */
r5568r5569
727728      logerror( "ROM DETAILS\n" );
728729      logerror( "===========\n\n" );
729730      logerror( "\tTotal blocks:  %d (%dmb)\n", total_blocks, total_blocks / (snes_cart.mode & 5 ? 32 : 16) );
730      logerror( "\tROM bank size: %s (LoROM: %d , HiROM: %d, ExHiROM: %d)\n",
731                        (snes_cart.mode == SNES_MODE_20) ? "LoROM" : ((snes_cart.mode == SNES_MODE_21) ? "HiROM" : "ExHiROM"),
731      logerror( "\tROM bank size: %s (LoROM: %d , HiROM: %d, ExHiROM: %d)\n",
732                        (snes_cart.mode == SNES_MODE_20) ? "LoROM" : ((snes_cart.mode == SNES_MODE_21) ? "HiROM" : "ExHiROM"),
732733                              valid_mode20, valid_mode21, valid_mode25);
733734      logerror( "\tCompany:       %s [%.2s]\n", companies[company], company_id );
734735      logerror( "\tROM ID:        %.4s\n\n", rom_id );
src/mess/drivers/snes.c
r5568r5569
2727***************************************************************************/
2828
2929#include "driver.h"
30#include "video/generic.h"
3031#include "cpu/spc700/spc700.h"
32#include "cpu/superfx/superfx.h"
3133#include "cpu/g65816/g65816.h"
3234#include "includes/snes.h"
3335#include "machine/snescart.h"
r5568r5569
5052   AM_RANGE(0xc00000, 0xffffff) AM_READWRITE(snes_r_bank7, snes_w_bank7)   /* Mirror and ROM */
5153ADDRESS_MAP_END
5254
55static ADDRESS_MAP_START( superfx_map, ADDRESS_SPACE_PROGRAM, 8)
56   AM_RANGE(0x000000, 0x3fffff) AM_READWRITE(superfx_r_bank1, superfx_w_bank1)
57   AM_RANGE(0x400000, 0x5fffff) AM_READWRITE(superfx_r_bank2, superfx_w_bank2)
58   AM_RANGE(0x600000, 0x7fffff) AM_READWRITE(superfx_r_bank3, superfx_w_bank3)
59ADDRESS_MAP_END
60
5361static READ8_HANDLER( spc_ram_100_r )
5462{
5563   return spc_ram_r(space, offset + 0x100);
r5568r5569
193201
194202***************************************************************************/
195203
204
196205static MACHINE_DRIVER_START( snes )
197206   /* basic machine hardware */
198207   MDRV_CPU_ADD("maincpu", G65816, MCLK_NTSC/6)   /* 2.68 MHz, also 3.58 MHz */
r5568r5569
201210   MDRV_CPU_ADD("soundcpu", SPC700, 1024000)   /* 1.024 MHz */
202211   MDRV_CPU_PROGRAM_MAP(spc_map)
203212
204//   MDRV_QUANTUM_TIME(HZ(48000))
213   //MDRV_QUANTUM_TIME(HZ(48000))
205214   MDRV_QUANTUM_PERFECT_CPU("maincpu")
206215
207216   MDRV_MACHINE_START( snes_mess )
r5568r5569
225234   MDRV_IMPORT_FROM(snes_cartslot)
226235MACHINE_DRIVER_END
227236
237static SUPERFX_CONFIG( snes_superfx_config )
238{
239   DEVCB_LINE(snes_extern_irq_w)   /* IRQ line from cart */
240};
241
242static MACHINE_DRIVER_START( snessfx )
243   MDRV_IMPORT_FROM(snes)
244
245   MDRV_CPU_ADD("superfx", SUPERFX, 21480000)   /* 21.48MHz */
246   MDRV_CPU_PROGRAM_MAP(superfx_map)
247   MDRV_CPU_CONFIG(snes_superfx_config)
248MACHINE_DRIVER_END
249
228250static MACHINE_DRIVER_START( snespal )
229251   MDRV_IMPORT_FROM(snes)
230252   MDRV_CPU_REPLACE("maincpu", G65816, MCLK_PAL/6)
r5568r5569
247269   ROM_LOAD( "dsp1data.bin", 0x000000, 0x000800, CRC(4b02d66d) SHA1(1534f4403d2a0f68ba6e35186fe7595d33de34b1) )
248270ROM_END
249271
272ROM_START(snessfx)
273   ROM_REGION( 0x100, "user5", 0 )      /* IPL ROM */
274   ROM_LOAD( "spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )   /* boot rom */
275   ROM_REGION( 0x800, "user6", 0 )      /* add-on chip ROMs (DSP, SFX, etc) */
276   ROM_LOAD( "dsp1data.bin", 0x000000, 0x000800, CRC(4b02d66d) SHA1(1534f4403d2a0f68ba6e35186fe7595d33de34b1) )
277ROM_END
278
250279ROM_START(snespal)
251280   ROM_REGION( 0x100, "user5", 0 )      /* IPL ROM */
252281   ROM_LOAD( "spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )   /* boot rom */
r5568r5569
277306
278307/*    YEAR  NAME     PARENT  COMPAT  MACHINE  INPUT  INIT  CONFIG  COMPANY     FULLNAME                                      FLAGS */
279308CONS( 1989, snes,    0,      0,      snes,    snes,  0,    0,   "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
309CONS( 1989, snessfx, snes,   0,      snessfx, snes,  0,    0,   "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC), SuperFX", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
280310CONS( 1991, snespal, snes,   0,      snespal, snes,  0,    0,   "Nintendo", "Super Nintendo Entertainment System (PAL)",  GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
281311CONS( 199?, sfcbox,  snes,   0,      snes,    snes,  0,    0,   "Nintendo", "Super Famicom Box (NTSC)", GAME_NOT_WORKING )
src/mess/drivers/craft.c
r5568r5569
66
77#include "driver.h"
88#include "cpu/avr8/avr8.h"
9#include "sound/dac.h"
910
11#define MASTER_CLOCK 20000000
12
1013/****************************************************\
1114* I/O devices                                        *
1215\****************************************************/
r5568r5569
7477
7578    UINT8 res7[5];
7679
77    UINT8 spl;
78    UINT8 sph;
80    UINT16 sp;
7981    UINT8 sreg;
8082
8183    UINT8 wdtcsr;
r5568r5569
121123
122124    UINT8 res14;
123125
124    UINT8 tcnt1l;
125    UINT8 tcnt1h;
126    UINT8 icr1l;
127    UINT8 icr1h;
128    UINT8 ocr1al;
129    UINT8 ocr1ah;
130    UINT8 ocr1bl;
131    UINT8 ocr1bh;
126    UINT16 tcnt1;
127    UINT16 icr1;
128    UINT16 ocr1a;
129    UINT16 ocr1b;
132130
133131    UINT8 res15[36];
134132
r5568r5569
164162    UINT8 udr0;
165163
166164    UINT8 res20[57];
165
166    UINT8 hidden_high;
167
168    INT64 last_tcnt1_cycle;
169
170    emu_timer *ocr1a_timer;
171    emu_timer *ocr1b_timer;
167172} avr8_regs;
168173
169174static avr8_regs regs;
170175
176#define AVR8_TIMSK1_OCIE1A  0x02
177#define AVR8_TIMSK1_OCIE1B  0x04
178
179static UINT64 avr8_get_timer_1_frequency(avr8_regs *device)
180{
181    UINT64 frequency = 0;
182    switch(device->tccr1b & 0x07)
183    {
184        case 0: // No clock source (Timer/Counter stopped).
185        case 6: // External clock source on T1 pin.  Clock on falling edge.
186        case 7: // External clock source on T1 pin.  Clock on rising edge.
187            frequency = 0;
188            break;
189
190        case 1: // clk / 1 (No prescaling)
191            frequency = MASTER_CLOCK;
192            break;
193
194        case 2: // clk / 8 (From prescaler)
195            frequency = MASTER_CLOCK / 8;
196            break;
197
198        case 3: // clk / 64 (From prescaler)
199            frequency = MASTER_CLOCK / 64;
200            break;
201
202        case 4: // clk / 256 (From prescaler)
203            frequency = MASTER_CLOCK / 256;
204            break;
205
206        case 5: // clk / 1024 (From prescaler)
207            frequency = MASTER_CLOCK / 1024;
208            break;
209
210        default:
211            frequency = 0;
212            printf( "device->tccr1b & 0x07 returned a value not in the range of 0 to 7.  This is\n" );
213            printf( "impossible.  Please ensure that your walls are not bleeding and your bathroom\n" );
214            printf( "has not turned into a psychokinetic vortex.\n" );
215            break;
216    }
217
218    return frequency;
219}
220
221static void avr8_maybe_start_timer_1(avr8_regs *device)
222{
223    UINT64 frequency = avr8_get_timer_1_frequency(device);
224    if(frequency == 0)
225    {
226        timer_adjust_oneshot(device->ocr1a_timer, attotime_never, 0);
227        timer_adjust_oneshot(device->ocr1b_timer, attotime_never, 0);
228    }
229    else
230    {
231        UINT16 wrap_count_a = (UINT16)(((UINT32)device->ocr1a - (UINT32)device->tcnt1) & 0x0000ffff);
232        UINT16 wrap_count_b = (UINT16)(((UINT32)device->ocr1b - (UINT32)device->tcnt1) & 0x0000ffff);
233        attotime period_a = attotime_mul(ATTOTIME_IN_HZ(frequency), wrap_count_a);
234        attotime period_b = attotime_mul(ATTOTIME_IN_HZ(frequency), wrap_count_b);
235        if(device->timsk1 & AVR8_TIMSK1_OCIE1A)
236        {
237            timer_adjust_oneshot(device->ocr1a_timer, period_a, 0);
238        }
239        if(device->timsk1 & AVR8_TIMSK1_OCIE1B)
240        {
241            timer_adjust_oneshot(device->ocr1b_timer, period_b, 0);
242        }
243    }
244}
245
246static TIMER_CALLBACK( ocr1a_timer_compare )
247{
248    static int blah = 0;
249    printf( "ocr1a_timer_compare %d\n", blah++ );
250    avr8_maybe_start_timer_1(&regs);
251
252    // Inaccurate
253    cpu_set_input_line(cputag_get_cpu(machine, "maincpu"), AVR8_INT_T1COMPA, ASSERT_LINE);
254}
255
256static TIMER_CALLBACK( ocr1b_timer_compare )
257{
258    printf( "ocr1b_timer_compare\n" );
259    avr8_maybe_start_timer_1(&regs);
260
261    // Inaccurate
262    cpu_set_input_line(cputag_get_cpu(machine, "maincpu"), AVR8_INT_T1COMPB, ASSERT_LINE);
263}
264
171265static READ8_HANDLER( avr8_read )
172266{
173267    switch( offset )
r5568r5569
197291            return regs.spsr;
198292        case 0x5d:
199293            //printf( "AVR8: R: regs.spl (%02x)\n", regs.spl );
200            return regs.spl;
294            return regs.sp & 0x00ff;
201295        case 0x5e:
202296            //printf( "AVR8: R: regs.sph (%02x)\n", regs.sph );
203            return regs.sph;
297            return (regs.sp >> 8) & 0x00ff;
204298        case 0x5f:
205299            return regs.sreg;
206300        case 0x6f:
r5568r5569
212306        case 0x81:
213307            printf( "AVR8: R: regs.tccr1b (%02x)\n", regs.tccr1b );
214308            return regs.tccr1b;
309        case 0x84:
310        {
311            //INT64 divisor = 1;
312            /*INT64 update = (INT64)(cpu_get_total_cycles(space->cpu)) - last_tcnt1_cycle;
313            switch(device->tccr1b & 0x07)
314            {
315                case 0: // No clock source (Timer/Counter stopped).
316                case 1: // clk / 1 (No prescaling)
317                case 6: // External clock source on T1 pin.  Clock on falling edge.
318                case 7: // External clock source on T1 pin.  Clock on rising edge.
319                    divisor = 1;
320                    break;
321
322                case 2: // clk / 8 (From prescaler)
323                    divisor = 8;
324                    break;
325
326                case 3: // clk / 64 (From prescaler)
327                    divisor = 64;
328                    break;
329
330                case 4: // clk / 256 (From prescaler)
331                    divisor = 256;
332                    break;
333
334                case 5: // clk / 1024 (From prescaler)
335                    divisor = 1024;
336                    break;
337
338                default:
339                    divisor = 1;
340                    printf( "device->tccr1b & 0x07 returned a value not in the range of 0 to 7.  This is\n" );
341                    printf( "impossible.  Please ensure that your walls are not bleeding and your bathroom\n" );
342                    printf( "has not turned into a psychokinetic vortex.\n" );
343                    break;
344            }
345            diff /= divisor;
346            diff %= regs.ocr1a;
347            printf( "AVR8: R: regs.tcnt1l read: %04x\n",  );
348            */break;
349        }
350
351        case 0x85:
352            printf( "AVR8: R: regs.tcnt1h\n" );
353            break;
215354        case 0x88:
216            printf( "AVR8: R: regs.ocr1al (%02x)\n", regs.ocr1al );
217            return regs.ocr1al;
355            printf( "AVR8: R: regs.ocr1al (%02x)\n", regs.ocr1a & 0x00ff );
356            return regs.ocr1a & 0x00ff;
218357        case 0x89:
219            printf( "AVR8: R: regs.ocr1ah (%02x)\n", regs.ocr1ah );
220            return regs.ocr1ah;
358            printf( "AVR8: R: regs.ocr1ah (%02x)\n", (regs.ocr1a >> 8) & 0x00ff );
359            return (regs.ocr1a >> 8) & 0x00ff;
221360        case 0x8a:
222            printf( "AVR8: R: regs.ocr1bl (%02x)\n", regs.ocr1bl );
223            return regs.ocr1bl;
361            printf( "AVR8: R: regs.ocr1bl (%02x)\n", regs.ocr1b & 0x00ff );
362            return regs.ocr1b & 0x00ff;
224363        case 0x8b:
225            printf( "AVR8: R: regs.ocr1bh (%02x)\n", regs.ocr1bh );
226            return regs.ocr1bh;
364            printf( "AVR8: R: regs.ocr1bh (%02x)\n", (regs.ocr1b >> 8) & 0x00ff );
365            return (regs.ocr1b >> 8) & 0x00ff;
227366        case 0xb0:
228367            printf( "AVR8: R: regs.tccr2a (%02x)\n", regs.tccr2a );
229368            return regs.tccr2a;
r5568r5569
262401            printf( "AVR8: W: regs.ddrd = %02x\n", data );
263402            regs.ddrd = data;
264403            break;
404        case 0x2b:
405            dac_data_w(devtag_get_device(space->machine, "dac"), data);
406            break;
265407        case 0x4c:
266408            printf( "AVR8: W: regs.spcr = %02x\n", data );
267409            regs.spcr = data;
r5568r5569
271413            regs.spsr = data;
272414            break;
273415        case 0x5d:
274            //printf( "AVR8: W: regs.spl = %02x\n", data );
275            regs.spl = data;
416            //printf( "AVR8: W: regs.sp(L) = %02x\n", data );
417            regs.sp = (regs.hidden_high << 8) | data;
276418            break;
277419        case 0x5e:
278            //printf( "AVR8: W: regs.sph = %02x\n", data );
279            regs.sph = data & 0x07;
420            //printf( "AVR8: W: regs.sp(H) = %02x\n", data );
421            regs.hidden_high = data & 0x07;
280422            break;
281423        case 0x5f:
282424            regs.sreg = data;
r5568r5569
284426        case 0x6f:
285427            printf( "AVR8: W: regs.timsk1 = %02x\n", data );
286428            regs.timsk1 = data;
429            avr8_maybe_start_timer_1(&regs);
287430            break;
288431        case 0x80:
289432            printf( "AVR8: W: regs.tccr1a = %02x\n", data );
r5568r5569
294437            regs.tccr1b = data;
295438            break;
296439        case 0x88:
297            printf( "AVR8: W: regs.ocr1al = %02x\n", data );
298            regs.ocr1al = data;
440            printf( "AVR8: W: regs.ocr1a(L) = %02x\n", data );
441            regs.ocr1a = (regs.hidden_high << 8) | data;
442            avr8_maybe_start_timer_1(&regs);
299443            break;
300444        case 0x89:
301            printf( "AVR8: W: regs.ocr1ah = %02x\n", data );
302            regs.ocr1ah = data;
445            printf( "AVR8: W: regs.ocr1a(H) = %02x\n", data );
446            regs.hidden_high = data;
303447            break;
304448        case 0x8a:
305            printf( "AVR8: W: regs.ocr1bl = %02x\n", data );
306            regs.ocr1bl = data;
449            printf( "AVR8: W: regs.ocr1b(L) = %02x\n", data );
450            regs.ocr1b = (regs.hidden_high << 8) | data;
451            avr8_maybe_start_timer_1(&regs);
307452            break;
308453        case 0x8b:
309            printf( "AVR8: W: regs.ocr1bh = %02x\n", data );
310            regs.ocr1bh = data;
454            printf( "AVR8: W: regs.ocr1b(H) = %02x\n", data );
455            regs.hidden_high = data;
311456            break;
312457        case 0xb0:
313458            printf( "AVR8: W: regs.tccr2a = %02x\n", data );
r5568r5569
357502* Machine definition                                 *
358503\****************************************************/
359504
505static DRIVER_INIT( craft )
506{
507    regs.ocr1a_timer = timer_alloc(machine, ocr1a_timer_compare, 0);
508    regs.ocr1b_timer = timer_alloc(machine, ocr1b_timer_compare, 0);
509}
510
360511static MACHINE_RESET( craft )
361512{
513    regs.timsk1 = 0;
514    regs.tcnt1 = 0;
515    regs.ocr1a = 0;
516    regs.ocr1b = 0;
517    regs.icr1 = 0;
518    regs.last_tcnt1_cycle = 0;
519
520    dac_data_w(devtag_get_device(machine, "dac"), 0x00);
362521}
363522
364523static MACHINE_DRIVER_START( craft )
365524    /* basic machine hardware */
366    MDRV_CPU_ADD("maincpu", AVR8, 20000000)
525    MDRV_CPU_ADD("maincpu", AVR8, MASTER_CLOCK)
367526    MDRV_CPU_PROGRAM_MAP(craft_prg_map)
368527    MDRV_CPU_IO_MAP(craft_io_map)
369528
r5568r5569
371530
372531    /* video hardware */
373532    MDRV_SCREEN_ADD("screen", RASTER)
374    MDRV_SCREEN_REFRESH_RATE(60)
375    MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
533    //MDRV_SCREEN_RAW_PARAMS( MASTER_CLOCK, 634, 0, 633, 525, 0, 481 )
534    MDRV_SCREEN_REFRESH_RATE(60.08)
535    MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1395)) /* accurate */
376536    MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
377    MDRV_SCREEN_SIZE(640, 480)
378    MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 479)
537    MDRV_SCREEN_SIZE(634, 480)
538    MDRV_SCREEN_VISIBLE_AREA(0, 633, 0, 479)
379539    MDRV_PALETTE_LENGTH(0x1000)
380540
381541    MDRV_VIDEO_START(generic_bitmapped)
382542    MDRV_VIDEO_UPDATE(craft)
543
544    /* sound hardware */
545    MDRV_SPEAKER_STANDARD_MONO("avr8")
546    MDRV_SOUND_ADD("dac", DAC, 0)
547    MDRV_SOUND_ROUTE(0, "avr8", 1.00)
383548MACHINE_DRIVER_END
384549
385550ROM_START( craft )
r5568r5569
390555ROM_END
391556
392557/*   YEAR  NAME      PARENT    COMPAT    MACHINE   INPUT     INIT      CONFIG    COMPANY          FULLNAME */
393CONS(2008, craft,    0,        0,        craft,    craft,    0,        0,        "Linus Akesson", "Craft", GAME_NO_SOUND | GAME_NOT_WORKING)
558CONS(2008, craft,    0,        0,        craft,    craft,    craft,    0,        "Linus Akesson", "Craft", GAME_NO_SOUND | GAME_NOT_WORKING)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team