Previous 199869 Revisions Next

r36159 Sunday 1st March, 2015 at 08:34:54 UTC by Miodrag Milanović
(MESS)-gamete: added noise and envelope emulation [Peter Trauner]
[src/mess/audio]gamate.c
[src/mess/drivers]gamate.c
[src/mess/includes]gamate.h

trunk/src/mess/audio/gamate.c
r244670r244671
11/***************************************************************************
22 gamate sound hardware
33
4 PeT mess@utanet.at
4 PeT mess@utanet.at 2015
55***************************************************************************/
66
77#include "emu.h"
88#include "includes/gamate.h"
9#include "ui/ui.h"
910
1011
12enum { ClockDelay=32 };
13
1114// device type definition
1215const device_type GAMATE_SND = &device_creator<gamate_sound_device>;
1316
14
17const int gamate_sound_device::DAConverter[]={ 0, 3, 7, 13,  23, 41, 75, 137,  249, 453, 825, 1499,  2726, 4956, 9011, 16383 }; // (*.55) on the real below index 8 bareless measureable
18const UINT8 Mask[]={ 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0x1f, 0x3f,  0x1f, 0x1f, 0x1f, 0xff, 0xff, 0xf };
19const int EnvelopeVolumes[]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0  };
1520//**************************************************************************
1621//  LIVE DEVICE
1722//**************************************************************************
r244670r244671
2732{
2833}
2934
30
3135//-------------------------------------------------
3236//  device_start - device-specific startup
3337//-------------------------------------------------
r244670r244671
3539void gamate_sound_device::device_start()
3640{
3741   // bind callbacks
38//  m_irq_cb.bind_relative_to(*owner());
42//   m_irq_cb.bind_relative_to(*owner());
3943
4044   memset(m_channels, 0, sizeof(m_channels));
4145   memset(reg, 0, sizeof(reg));
r244670r244671
5256{
5357   stream_sample_t *left=outputs[0], *right=outputs[1];
5458   int i, j;
55   GAMATE_CHANNEL *channel;
56
59   Tone *channel;
60   
5761   for (i = 0; i < samples; i++, left++, right++)
5862   {
63      noise.pos += noise.step;
64      while (noise.pos >= 1.0) {
65        // guess (white noise register taken from supervision)
66        noise.level = noise.state & 0x40 ? 1 : 0;
67        bool b1 = (noise.state & 0x40) != 0, b2 = (noise.state & 0x20) != 0;
68        noise.state=(noise.state<<1)+(b1!=b2?1:0);
69        noise.pos -= 1;
70      }
71
72      envelope.pos += envelope.step;
73      while (envelope.pos >= 1.0) {
74        envelope.pos -= 1;
75        envelope.index++;
76        switch (envelope.control) {
77          case 0: case 1: case 2: case 3:
78          case 4: case 5: case 6: case 7:
79          case 8: case 9: case 0xb:
80          case 0xd: case 0xf:
81            if (envelope.index>=ARRAY_LENGTH(EnvelopeVolumes)/2) {
82         envelope.index=0;
83         envelope.first=false;
84            }
85            break;
86          default:
87            if (envelope.index>=ARRAY_LENGTH(EnvelopeVolumes)) {
88         envelope.index=0;
89         envelope.first=false;
90            }
91            break;
92        }
93       
94      }
95
5996      *left = 0;
6097      *right = 0;
6198      for (channel=m_channels, j=0; j<ARRAY_LENGTH(m_channels); j++, channel++)
6299      {
63100         if (channel->size != 0)
64101         {
65            if (channel->on)//||channel->count)
66            {
67               int on = FALSE;
68               on = channel->pos <= channel->size / 2;
69               {
70                  INT16 s = on ? channel->volume << 8 : 0;
71                  if (j == 0)
72                     *right += s;
73                  else if (j==1)
74                     *left += s;
75                  else {
76                     *right += s;
77                     *left += s;
78                  }
79               }
102           channel->level= channel->pos <= channel->size / 2;
103            bool l= channel->full_cycle? true: channel->level;
104            if (!channel->tone) l= l && noise.level;
105            int volume=0;
106            if (l) {
107              if (channel->envelope_on) {
108                switch (envelope.control) {
109                case 0: case 1: case 2: case 3:
110                case 0x9: // one time falling, low
111                  if (envelope.first && channel->level) volume=0xf-EnvelopeVolumes[envelope.index];
112                  break;
113                case 4: case 5: case 6: case 7:
114                case 0xf: // one time rising, low
115                  if (envelope.first && channel->level) volume=EnvelopeVolumes[envelope.index];
116                  break;
117                case 8: // falling
118                  if (channel->level) volume=0xf-EnvelopeVolumes[envelope.index];
119                  break;
120                case 0xa: // rising, falling
121                  if (channel->level) volume=EnvelopeVolumes[envelope.index];
122                  break;
123                case 0xb: // one time falling, high
124                  if (channel->level) volume=envelope.first? 0xf-EnvelopeVolumes[envelope.index]: 0xf;
125                  break;
126                case 0xc: // rising, low
127                  if (channel->level) volume=envelope.index<ARRAY_LENGTH(EnvelopeVolumes)/2? EnvelopeVolumes[envelope.index]: 0;
128                  break;
129                case 0xd: // one time rising, high
130                  if (channel->level) volume=envelope.first? EnvelopeVolumes[envelope.index]: 0xf;
131                  break;
132                case 0xe: // falling, rising
133                  if (channel->level) volume=0xf-EnvelopeVolumes[envelope.index];
134                  break;
135                }
136              } else {
137                volume=channel->volume;
138              }
80139            }
140            if (j == Right)
141              *right += Value2Volume(volume);
142            else if (j==Left)
143              *left += Value2Volume(volume);
144            else {
145              *right += Value2Volume(volume);
146              *left += Value2Volume(volume);
147            }
81148            channel->pos++;
82149            if (channel->pos >= channel->size)
83150               channel->pos = 0;
r244670r244671
94161   reg[offset] = data;
95162   int chan=-1;
96163
97   switch (offset)
164   switch (offset&0xf)
98165   {
99166      case 0:
100167      case 1:
r244670r244671
102169      case 3:
103170      case 4:
104171      case 5:
105         chan=offset/2;
172        chan=offset/2;
106173         size = reg[chan*2] | ((reg[chan*2+1] & 0xf) << 8);
107174         if (size)
108175         {
109            m_channels[chan].size= (int) (machine().sample_rate() * (size << 5) / machine().device("maincpu")->unscaled_clock());
176            m_channels[chan].size= (int) (machine().sample_rate() * size*ClockDelay / machine().device("maincpu")->unscaled_clock());
110177         }
111178         else
112179         {
r244670r244671
115182         m_channels[chan].pos = 0;
116183         break;
117184      case 6:
185        size=data&0x1f;
186        if (size==0) size=1;
187        noise.step= machine().device("maincpu")->unscaled_clock() / (1.0*ClockDelay*machine().sample_rate()*size);
188        break;
118189      case 7:
190        m_channels[Right].full_cycle=data&1;
191        m_channels[Right].tone=data&8;
192        m_channels[Left].full_cycle=data&2;
193        m_channels[Left].tone=data&0x10;
194        m_channels[Both].full_cycle=data&4;
195        m_channels[Both].tone=data&0x20;
196        noise.state=1;
197        noise.pos=0.0;
198        noise.level=false;
199        break;
119200      case 8:
120         chan=offset-6;
121//          m_channels[chan]->on = data & 0x40;
122//          channel->waveform = (data & 0x30) >> 4;
201      case 9:
202      case 0xa:
203        chan=offset-8;
204         m_channels[chan].envelope_on = data & 0x10; // buggy aussetzer cube up
123205         m_channels[chan].volume = data & 0xf;
124206         break;
207      case 0xb: case 0xc:
208         size = reg[0xb] | ((reg[0xc]) << 8);
209        if (size==0) size=1;
210        envelope.step= machine().device("maincpu")->unscaled_clock() / (1.0*ClockDelay*machine().sample_rate()*size);
211        break;
212      case 0xd:
213        envelope.control=data&0xf;
214        envelope.pos=0;
215        envelope.index=0;
216        envelope.first=true;
217        break;
218       
125219   }
126   if (chan!=-1) m_channels[chan].on=m_channels[chan].volume!=0 && m_channels[chan].size>3/* avoid speed loss for unhearable >=23khz*/;
220   envelope.pos=0; // guess
221   envelope.index=0;
222   envelope.first=true;
127223}
224
225READ8_MEMBER( gamate_sound_device::device_r )
226{
227  UINT8 data=0;
228  if ((offset&0xf)<ARRAY_LENGTH(Mask)) data=reg[offset&0xf]&Mask[offset&0xf]; // unused bits set to last write value? in this area
229  return data;
230}
trunk/src/mess/drivers/gamate.c
r244670r244671
33 Peter Wilhelmsen peter.wilhelmsen@gmail.com
44 Morten Shearman Kirkegaard morten+gamate@afdelingp.dk
55 Juan F??lix Mateos vectrex@hackermesh.org
6******************************************************************************/
76
7 nmi unknown
8 cube up audio sometimes missing
9 bomb blast top status line missing
10 ******************************************************************************/
11
812#include "emu.h"
913#include "cpu/m6502/m6502.h"
1014#include "bus/generic/slot.h"
r244670r244671
3640   DECLARE_WRITE8_MEMBER(cart_bankswitch_w);
3741   DECLARE_READ8_MEMBER(gamate_video_r);
3842   DECLARE_READ8_MEMBER(gamate_pad_r);
43   DECLARE_READ8_MEMBER(gamate_nmi_r);
3944   DECLARE_WRITE8_MEMBER(gamate_video_w);
4045   DECLARE_READ8_MEMBER(gamate_audio_r);
4146   DECLARE_WRITE8_MEMBER(gamate_audio_w);
r244670r244671
5156
5257   struct
5358   {
54   UINT8 reg[8];
55   struct {
56      bool write;
57      bool page2; // else page1
59     UINT8 reg[8];
60     struct {
61       bool page2; // else page1
5862   UINT8 ypos, xpos/*tennis*/;
59      UINT8 data[2][0x100][0x20];
60      } bitmap;
61   UINT8 x, y;
63       UINT8 data[2][0x100][0x20];
64     } bitmap;
65     UINT8 x, y;
6266      bool y_increment;
6367   } video;
6468
6569   struct {
66      bool set;
70     bool set;
6771      int bit_shifter;
6872      UINT8 cartridge_byte;
6973      UINT16 address; // in reality something more like short local cartridge address offset
7074      bool unprotected;
7175      bool failed;
72
76     
7377   } card_protection;
7478
7579   required_device<cpu_device> m_maincpu;
r244670r244671
8084   required_shared_ptr<UINT8> m_bios;
8185   emu_timer *timer1;
8286   emu_timer *timer2;
83   UINT8 bank_multi;
87   UINT8 bank_multi; 
8488};
8589
8690WRITE8_MEMBER( gamate_state::gamate_cart_protection_w )
8791{
88      logerror("%.6f protection write %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, data, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
89
92        logerror("%.6f protection write %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, data, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
93 
9094   switch (offset) {
9195   case 0:
9296      card_protection.failed= card_protection.failed || ((card_protection.cartridge_byte&0x80)!=0) != ((data&4)!=0);
r244670r244671
100104}
101105READ8_MEMBER( gamate_state::gamate_cart_protection_r )
102106{
103   UINT8 ret=1;
104   if (card_protection.bit_shifter==7 && card_protection.unprotected) {
105   ret=m_cart->get_rom_base()[bank_multi*0x4000];
106   } else {
107
108  UINT8 ret=1;
109  if (card_protection.bit_shifter==7 && card_protection.unprotected) {
110    ret=m_cart->get_rom_base()[bank_multi*0x4000];
111  } else {
107112   card_protection.bit_shifter++;
108113   if (card_protection.bit_shifter==8) {
109114      card_protection.bit_shifter=0;
r244670r244671
112117   }
113118   ret=(card_protection.cartridge_byte&0x80)?2:0;
114119   if (card_protection.bit_shifter==7 && !card_protection.failed) { // now protection chip on cartridge activates cartridge chip select on cpu accesses
115//        m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); // next time I will try to get this working
120//        m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); // next time I will try to get this working
116121   }
117122   card_protection.cartridge_byte<<=1;
118   }
119   logerror("%.6f protection read %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, ret, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
120   return ret;
123  }
124  logerror("%.6f protection read %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, ret, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
125  return ret;
121126}
122127
123128READ8_MEMBER( gamate_state::protection_r ) { return card_protection.set? 3: 1; } // bits 0 and 1 checked
124129
125130WRITE8_MEMBER( gamate_state::protection_reset )
126131{
127   // writes 0x20
128   card_protection.address=0x6005-0x6001;
129   card_protection.bit_shifter=0;
130   card_protection.cartridge_byte=m_cart->get_rom_base()[card_protection.address++];//m_cart_rom[card_protection.address++];
131   card_protection.failed=false;
132   card_protection.unprotected=false;
132  // writes 0x20
133  card_protection.address=0x6005-0x6001;
134  card_protection.bit_shifter=0;
135  card_protection.cartridge_byte=m_cart->get_rom_base()[card_protection.address++];//m_cart_rom[card_protection.address++];
136  card_protection.failed=false;
137  card_protection.unprotected=false;
133138}
134139
135140READ8_MEMBER( gamate_state::newer_protection_set )
136141{
137   card_protection.set=true;
138   return 0;
142  card_protection.set=true;
143  return 0;
139144}
140145
141146
142147WRITE8_MEMBER( gamate_state::gamate_video_w )
143148{
144   video.reg[offset]=data;
145   switch (offset) {
146   case 1:
147      if (data&0xf) printf("lcd mode %x\n", data);
148      video.bitmap.write=data&0xc0; // more addressing mode
149      video.y_increment=data&0x40;
150      break;
151   case 2: video.bitmap.xpos=data;break;
152   case 3:
153      if (data>=200) printf("lcd ypos: %x\n", data);
154      video.bitmap.ypos=data;
155      break;
156   case 4: video.bitmap.page2=data&0x80;video.x=data&0x7f;break;
157   case 5: video.y=data;break;
158   case 7:
159   if (video.y>=200)
160   machine().ui().popup_time(2, "bitmap write to x:%x y:%x mode:%x data:%x\n", video.x, video.y, video.reg[1], data);
161   if (video.bitmap.write) {
162      video.bitmap.data[video.bitmap.page2][video.y][video.x]=data;
163   } else {
164      video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data;
165   }
166   if (video.y_increment) video.y++;
167      else video.x++;
168   }
149  video.reg[offset]=data;
150  switch (offset) {
151  case 1:
152    if (data&0xf) printf("lcd mode %x\n", data);
153    video.y_increment=data&0x40;
154    break;
155  case 2: video.bitmap.xpos=data;break;
156  case 3:
157    if (data>=200) printf("lcd ypos: %x\n", data);
158    video.bitmap.ypos=data;
159    break;
160  case 4: video.bitmap.page2=data&0x80;video.x=data&0x1f;break;
161  case 5: video.y=data;break;
162  case 7:
163    video.bitmap.data[video.bitmap.page2][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data;
164    if (video.y_increment) video.y++;
165    else video.x++; // overruns
166  }
169167}
170168
171169WRITE8_MEMBER( gamate_state::cart_bankswitchmulti_w )
172170{
173   bank_multi=data;
174   membank("bankmulti")->set_base(m_cart->get_rom_base()+0x4000*data+1);
171  bank_multi=data;
172  membank("bankmulti")->set_base(m_cart->get_rom_base()+0x4000*data+1);
175173}
176174
177175WRITE8_MEMBER( gamate_state::cart_bankswitch_w )
r244670r244671
181179
182180READ8_MEMBER( gamate_state::gamate_video_r )
183181{
184   if (offset!=6) return 0;
185   UINT8 data=0;
186   if (video.bitmap.write) {
187   data=video.bitmap.data[video.bitmap.page2][video.y][video.x];
188   } else {
189   data=video.bitmap.data[0][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)];
190   }
182  if (offset!=6) return 0;
183  UINT8 data=0;
184    data=video.bitmap.data[video.bitmap.page2][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)];
191185//  if (m_maincpu->pc()<0xf000)
192186//    machine().ui().popup_time(2, "lcd read x:%x y:%x mode:%x data:%x\n", video.x, video.y, video.reg[1], data);
193   return data;
187    if (video.y_increment) video.y++;
188    else video.x++; // overruns?
189
190    return data;
194191}
195192
196193WRITE8_MEMBER( gamate_state::gamate_audio_w )
197194{
198195//  printf("audio write %x:%x\n", offset, data);//logerror("%.6f %04x audio write %04x %02x\n",machine().time().as_double(),m_maincpu->pc(),offset,data);
199   m_sound->device_w(space, offset, data);
196  m_sound->device_w(space, offset, data);
200197}
201198
202199READ8_MEMBER( gamate_state::gamate_audio_r )
203200{
204// legend of dragon knight
205//  machine().ui().popup_time(2, "%.6f %04x audio read %04x \n",machine().time().as_double(),m_maincpu->pc(),offset);
206   return 0;
201  UINT8 data=m_sound->device_r(space, offset);
202  return data;
207203}
208204
209205
210206READ8_MEMBER( gamate_state::gamate_pad_r )
211207{
212   UINT8 data=m_io_joy->read();
213   return data;
208  UINT8 data=m_io_joy->read();
209  return data;
214210}
215211
212READ8_MEMBER( gamate_state::gamate_nmi_r )
213{
214  UINT8 data=0;
215  machine().ui().popup_time(2, "nmi/4800 read\n");
216  return data;
217}
218
216219static ADDRESS_MAP_START( gamate_mem, AS_PROGRAM, 8, gamate_state )
217   AM_RANGE(0x0000, 0x03ff) AM_RAM
218   AM_RANGE(0x4000, 0x400d) AM_READWRITE(gamate_audio_r, gamate_audio_w)
219   AM_RANGE(0x4400, 0x4400) AM_READ(gamate_pad_r)
220   AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w)
221   AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set)
222   AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset)
223   AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r)
220    AM_RANGE(0x0000, 0x03ff) AM_RAM
221  AM_RANGE(0x4000, 0x400d) AM_READWRITE(gamate_audio_r, gamate_audio_w)
222  AM_RANGE(0x4400, 0x4400) AM_READ(gamate_pad_r)
223  AM_RANGE(0x4800, 0x4800) AM_READ(gamate_nmi_r)
224  AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w)
225  AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set)
226  AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset)
227  AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r)
224228
225   AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti")
226   AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank")
229  AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti")
230  AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank")
227231
228232   AM_RANGE(0x6000, 0x6000) AM_READWRITE(gamate_cart_protection_r, gamate_cart_protection_w)
229233   AM_RANGE(0x8000, 0x8000) AM_WRITE(cart_bankswitchmulti_w)
230234   AM_RANGE(0xc000, 0xc000) AM_WRITE(cart_bankswitch_w)
231235
232   AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios")
236  AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios")
233237ADDRESS_MAP_END
234238
235239
r244670r244671
245249   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SELECT) PORT_NAME("Select")
246250INPUT_PORTS_END
247251
248ATTR_UNUSED static const unsigned short gamate_palette[4] =
252static const unsigned short gamate_palette[4] =
249253{
250254   0,1,2,3
251255};
r244670r244671
254258/* palette in red, green, blue tribles */
255259static const unsigned char gamate_colors[4][3] =
256260{
257   { 255,255,255 },
258   { 0xa0, 0xa0, 0xa0 },
259   { 0x60, 0x60, 0x60 },
260   { 0, 0, 0 }
261  { 255,255,255 },
262  { 0xa0, 0xa0, 0xa0 },
263  { 0x60, 0x60, 0x60 },
264  { 0, 0, 0 }
261265};
262266
263267PALETTE_INIT_MEMBER(gamate_state, gamate)
r244670r244671
280284
281285UINT32 gamate_state::screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
282286{
283   int x, y, j;
284   for (y=0;y<152;y++) {
285   for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) {
286      UINT8 d1, d2;
287      if (video.bitmap.ypos<200) {
287  int x, y, j;
288  for (y=0;y<152;y++) {
289    for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) {     
290      UINT8 d1, d2;
291      if (video.bitmap.ypos<200) {
288292   d1=video.bitmap.data[0][(y+video.bitmap.ypos)%200][(j+video.bitmap.xpos/8)&0x1f];
289293   d2=video.bitmap.data[1][(y+video.bitmap.ypos)%200][(j+video.bitmap.xpos/8)&0x1f];
290      } else if ((video.bitmap.ypos&0xf)<8) { // lcdtest, of course still some registers not known, my gamate doesn't display bottom lines
294      } else if ((video.bitmap.ypos&0xf)<8) { // lcdtest, of course still some registers not known, my gamate doesn't display bottom lines; most likely problematic 200 warp around hardware! no real usage
291295   int yi=(y+(video.bitmap.ypos&0xf)-8);
292296   if (yi<0) yi=video.bitmap.ypos+y; // in this case only 2nd plane used!?, source of first plane?
293297   d1=video.bitmap.data[0][yi][(j+video.bitmap.xpos/8)&0x1f]; // value of lines bevor 0 chaos
294298   d2=video.bitmap.data[1][yi][(j+video.bitmap.xpos/8)&0x1f];
295      } else {
299      } else {
296300   d1=video.bitmap.data[0][y][(j+video.bitmap.xpos/8)&0x1f];
297   d2=video.bitmap.data[1][y][(j+video.bitmap.xpos/8)&0x1f];
298      }
299      BlitPlane(&bitmap.pix16(y, x+4), d1, d2);
300      BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4);
301   }
302   }
303   return 0;
301   d2=video.bitmap.data[1][y][(j+video.bitmap.xpos/8)&0x1f];   
302      }
303      BlitPlane(&bitmap.pix16(y, x+4), d1, d2);
304      BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4);
305    }
306  }
307  return 0;
304308}
305309
306310DRIVER_INIT_MEMBER(gamate_state,gamate)
r244670r244671
314318void gamate_state::machine_start()
315319{
316320   if (m_cart->exists()) {
317//      m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r));
321//      m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r));
318322      membank("bankmulti")->set_base(m_cart->get_rom_base()+1);
319323      membank("bank")->set_base(m_cart->get_rom_base()+0x4000); // bankswitched games in reality no offset
320324   }
321//  m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // default bios: $47 protection readback
325//   m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // default bios: $47 protection readback
322326   card_protection.set=false;
323327   bank_multi=0;
324328   card_protection.unprotected=false;
r244670r244671
378382   MCFG_SOUND_ADD("custom", GAMATE_SND, 0)
379383   MCFG_SOUND_ROUTE(0, "lspeaker", 0.50)
380384   MCFG_SOUND_ROUTE(1, "rspeaker", 0.50)
381
385   
382386   MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_linear_slot, "gamate_cart")
383387   MCFG_GENERIC_MANDATORY
384388
r244670r244671
396400
397401
398402/*    YEAR  NAME      PARENT  COMPAT    MACHINE   INPUT    CLASS          INIT      COMPANY    FULLNAME */
399CONS( 19??, gamate,  0,      0,        gamate,  gamate, gamate_state, gamate, "Bit Corp", "Gamate", GAME_IMPERFECT_SOUND)
403CONS( 19??, gamate,  0,      0,        gamate,  gamate, gamate_state, gamate, "Bit Corp", "Gamate", 0)
404
405
trunk/src/mess/includes/gamate.h
r244670r244671
1111#include "bus/generic/slot.h"
1212#include "bus/generic/carts.h"
1313
14struct GAMATE_CHANNEL
15{
16   GAMATE_CHANNEL() :
17//      on(0),
18//      waveform(0),
19      volume(0),
20      pos(0),
21      size(0)
22//      count(0)
23   {
24   }
2514
26   int on;
27   int /*waveform,*/ volume;
28   int pos;
29   int size;
30//  int count;
31};
32
33
3415// ======================> gamate_sound_device
3516
3617class gamate_sound_device : public device_t,
r244670r244671
4930
5031public:
5132   DECLARE_WRITE8_MEMBER( device_w );
33   DECLARE_READ8_MEMBER( device_r );
5234
5335private:
5436
37   static const int DAConverter[];
38   static int Value2Volume(int volume) { return DAConverter[volume]*1; }
39
5540   sound_stream *m_mixer_channel;
56   GAMATE_CHANNEL m_channels[3];
41   struct Tone
42   {
43     Tone() :
44      envelope_on(false),
45      level(false),
46      tone(false), full_cycle(false),
47      volume(0),
48      pos(0),
49      size(0)
50     {
51     }
52
53     bool envelope_on, level;
54     bool tone/*else noise*/, full_cycle/* else square signal/pulse */;
55     int volume;
56     int pos, size;
57   };
58   enum { Right, Left, Both };
59   Tone m_channels[3];
60   struct Noise {
61     Noise(): state(1), level(false), step(0.0), pos(0.0) {}
62     int state;
63     bool level;
64     double step, pos;
65   } noise;
66   struct Envelope {
67     Envelope():control(0), index(0), first(false) {}
68     int control;
69     int index;
70     bool first;
71     double step, pos;
72   } envelope;
5773   UINT8 reg[14];
5874};
5975


Previous 199869 Revisions Next


© 1997-2024 The MAME Team