Previous 199869 Revisions Next

r36399 Friday 13th March, 2015 at 03:18:34 UTC by Robbbert
(MESS) gamate : improved readability (nw)
[src/mess/audio]gamate.c
[src/mess/drivers]gamate.c
[src/mess/includes]gamate.h

trunk/src/mess/audio/gamate.c
r244910r244911
2626//-------------------------------------------------
2727
2828gamate_sound_device::gamate_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
29   : device_t(mconfig, GAMATE_SND, "Gamate Audio Custom", tag, owner, clock, "gamate_sound", __FILE__),
30      device_sound_interface(mconfig, *this),
31      m_mixer_channel(NULL)
32{
33}
29   : device_t(mconfig, GAMATE_SND, "Gamate Audio Custom", tag, owner, clock, "gamate_sound", __FILE__)
30   , device_sound_interface(mconfig, *this)
31   , m_mixer_channel(NULL)
32   {}
3433
3534//-------------------------------------------------
3635//  device_start - device-specific startup
r244910r244911
6160   for (i = 0; i < samples; i++, left++, right++)
6261   {
6362      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;
63      while (noise.pos >= 1.0)
64      {
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;
7070      }
7171
7272      envelope.pos += envelope.step;
7373      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       
74         envelope.pos -= 1;
75         envelope.index++;
76         switch (envelope.control)
77         {
78            case 0: case 1: case 2: case 3:
79            case 4: case 5: case 6: case 7:
80            case 8: case 9: case 0xb:
81            case 0xd: case 0xf:
82               if (envelope.index>=ARRAY_LENGTH(EnvelopeVolumes)/2)
83               {
84                  envelope.index=0;
85                  envelope.first=false;
86               }
87               break;
88            default:
89               if (envelope.index>=ARRAY_LENGTH(EnvelopeVolumes))
90               {
91                  envelope.index=0;
92                  envelope.first=false;
93               }
94               break;
95         }
9496      }
9597
9698      *left = 0;
r244910r244911
99101      {
100102         if (channel->size != 0)
101103         {
102           channel->level= channel->pos <= channel->size / 2;
104            channel->level= channel->pos <= channel->size / 2;
103105            bool l= channel->full_cycle? true: channel->level;
104            if (!channel->tone) l= l && noise.level;
106            if (!channel->tone)
107               l= l && noise.level;
105108            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=0xf-EnvelopeVolumes[envelope.index]; // cube up
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              }
109            if (l)
110            {
111               if (channel->envelope_on)
112               {
113                  switch (envelope.control)
114                  {
115                     case 0: case 1: case 2: case 3:
116                     case 0x9: // one time falling, low
117                        if (envelope.first && channel->level)
118                           volume=0xf-EnvelopeVolumes[envelope.index];
119                        break;
120                     case 4: case 5: case 6: case 7:
121                     case 0xf: // one time rising, low
122                        if (envelope.first && channel->level)
123                           volume=EnvelopeVolumes[envelope.index];
124                        break;
125                     case 8: // falling
126                        if (channel->level)
127                           volume=0xf-EnvelopeVolumes[envelope.index];
128                        break;
129                     case 0xa: // rising, falling
130                        if (channel->level)
131                           volume=0xf-EnvelopeVolumes[envelope.index]; // cube up
132                        break;
133                     case 0xb: // one time falling, high
134                        if (channel->level)
135                           volume=envelope.first ? 0xf-EnvelopeVolumes[envelope.index] : 0xf;
136                        break;
137                     case 0xc: // rising, low
138                        if (channel->level)
139                           volume=envelope.index<ARRAY_LENGTH(EnvelopeVolumes)/2 ? EnvelopeVolumes[envelope.index] : 0;
140                        break;
141                     case 0xd: // one time rising, high
142                        if (channel->level)
143                           volume=envelope.first ? EnvelopeVolumes[envelope.index] : 0xf;
144                        break;
145                     case 0xe: // falling, rising
146                        if (channel->level)
147                           volume=0xf-EnvelopeVolumes[envelope.index];
148                        break;
149                  }
150               }
151               else
152               {
153                  volume=channel->volume;
154               }
139155            }
140156            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);
157               *right += Value2Volume(volume);
158            else
159            if (j==Left)
160               *left += Value2Volume(volume);
161            else
162            {
163               *right += Value2Volume(volume);
164               *left += Value2Volume(volume);
147165            }
148166            channel->pos++;
149167            if (channel->pos >= channel->size)
r244910r244911
169187      case 3:
170188      case 4:
171189      case 5:
172        chan=offset/2;
190         chan=offset/2;
173191         size = reg[chan*2] | ((reg[chan*2+1] & 0xf) << 8);
174192         if (size)
175193         {
r244910r244911
182200         m_channels[chan].pos = 0;
183201         break;
184202      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;
203         size=data&0x1f;
204         if (size==0)
205            size=1;
206         noise.step= machine().device("maincpu")->unscaled_clock() / (1.0*ClockDelay*machine().sample_rate()*size);
207         break;
189208      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;
209         m_channels[Right].full_cycle=data&1;
210         m_channels[Right].tone=data&8;
211         m_channels[Left].full_cycle=data&2;
212         m_channels[Left].tone=data&0x10;
213         m_channels[Both].full_cycle=data&4;
214         m_channels[Both].tone=data&0x20;
215         noise.state=1;
216         noise.pos=0.0;
217         noise.level=false;
218         break;
200219      case 8:
201220      case 9:
202221      case 0xa:
203        chan=offset-8;
222         chan=offset-8;
204223         m_channels[chan].envelope_on = data & 0x10; // buggy aussetzer cube up
205224         m_channels[chan].volume = data & 0xf;
206225         break;
207226      case 0xb: case 0xc:
208227         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;
228         if (size==0)
229            size=1;
230         envelope.step= machine().device("maincpu")->unscaled_clock() / (1.0*ClockDelay*machine().sample_rate()*size);
231         break;
212232      case 0xd:
213        envelope.control=data&0xf;
214        envelope.pos=0;
215        envelope.index=0;
216        envelope.first=true;
217        break;
218       
233         envelope.control=data&0xf;
234         envelope.pos=0;
235         envelope.index=0;
236         envelope.first=true;
237         break;
238
219239   }
220240   envelope.pos=0; // guess
221241   envelope.index=0;
r244910r244911
224244
225245READ8_MEMBER( gamate_sound_device::device_r )
226246{
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;
247   UINT8 data=0;
248   if ((offset&0xf)<ARRAY_LENGTH(Mask))
249      data=reg[offset&0xf]&Mask[offset&0xf]; // unused bits set to last write value? in this area
250   return data;
230251}
trunk/src/mess/drivers/gamate.c
r244910r244911
1212#include "cpu/m6502/m6502.h"
1313#include "bus/generic/slot.h"
1414#include "bus/generic/carts.h"
15#include "rendlay.h"
15//#include "rendlay.h"
1616#include "includes/gamate.h"
1717#include "ui/ui.h"
1818
r244910r244911
3838   DECLARE_WRITE8_MEMBER(cart_bankswitchmulti_w);
3939   DECLARE_WRITE8_MEMBER(cart_bankswitch_w);
4040   DECLARE_READ8_MEMBER(gamate_video_r);
41   DECLARE_READ8_MEMBER(gamate_pad_r);
4241   DECLARE_READ8_MEMBER(gamate_nmi_r);
4342   DECLARE_WRITE8_MEMBER(gamate_video_w);
44   DECLARE_READ8_MEMBER(gamate_audio_r);
45   DECLARE_WRITE8_MEMBER(gamate_audio_w);
4643   DECLARE_WRITE8_MEMBER(gamate_bios_w);
4744   DECLARE_DRIVER_INIT(gamate);
4845   UINT32 screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
r244910r244911
5552
5653   struct
5754   {
58     UINT8 reg[8];
59     struct {
60       bool page2; // else page1
61   UINT8 ypos, xpos/*tennis*/;
62       UINT8 data[2][0x100][0x20];
63     } bitmap;
64     UINT8 x, y;
55      UINT8 reg[8];
56      struct
57      {
58         bool page2; // else page1
59         UINT8 ypos, xpos/*tennis*/;
60         UINT8 data[2][0x100][0x20];
61      } bitmap;
62      UINT8 x, y;
6563      bool y_increment;
6664   } video;
6765
68   struct {
69     bool set;
66   struct
67   {
68      bool set;
7069      int bit_shifter;
7170      UINT8 cartridge_byte;
7271      UINT16 address; // in reality something more like short local cartridge address offset
7372      bool unprotected;
7473      bool failed;
75     
7674   } card_protection;
7775
7876   required_device<cpu_device> m_maincpu;
r244910r244911
8381   required_shared_ptr<UINT8> m_bios;
8482   emu_timer *timer1;
8583   emu_timer *timer2;
86   UINT8 bank_multi; 
84   UINT8 bank_multi;
8785};
8886
8987WRITE8_MEMBER( gamate_state::gamate_cart_protection_w )
9088{
91        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   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);
9290 
93   switch (offset) {
91   switch (offset)
92   {
9493   case 0:
9594      card_protection.failed= card_protection.failed || ((card_protection.cartridge_byte&0x80)!=0) != ((data&4)!=0);
9695      card_protection.bit_shifter++;
97      if (card_protection.bit_shifter>=8) {
96      if (card_protection.bit_shifter>=8)
97      {
9898         card_protection.cartridge_byte=m_cart->get_rom_base()[card_protection.address++];
9999         card_protection.bit_shifter=0;
100100      }
101101      break;
102102   }
103103}
104
104105READ8_MEMBER( gamate_state::gamate_cart_protection_r )
105106{
106
107  UINT8 ret=1;
108  if (card_protection.bit_shifter==7 && card_protection.unprotected) {
109    ret=m_cart->get_rom_base()[bank_multi*0x4000];
110  } else {
111   card_protection.bit_shifter++;
112   if (card_protection.bit_shifter==8) {
113      card_protection.bit_shifter=0;
114      card_protection.cartridge_byte='G';
115      card_protection.unprotected=true;
107   UINT8 ret=1;
108   if (card_protection.bit_shifter==7 && card_protection.unprotected)
109   {
110      ret=m_cart->get_rom_base()[bank_multi*0x4000];
116111   }
117   ret=(card_protection.cartridge_byte&0x80)?2:0;
118   if (card_protection.bit_shifter==7 && !card_protection.failed) { // now protection chip on cartridge activates cartridge chip select on cpu accesses
119//        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
112   else
113   {
114      card_protection.bit_shifter++;
115      if (card_protection.bit_shifter==8)
116      {
117         card_protection.bit_shifter=0;
118         card_protection.cartridge_byte='G';
119         card_protection.unprotected=true;
120      }
121      ret=(card_protection.cartridge_byte&0x80) ? 2 : 0;
122      if (card_protection.bit_shifter==7 && !card_protection.failed)
123      { // now protection chip on cartridge activates cartridge chip select on cpu accesses
124//         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
125      }
126      card_protection.cartridge_byte<<=1;
120127   }
121   card_protection.cartridge_byte<<=1;
122  }
123  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);
124  return ret;
128   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);
129   return ret;
125130}
126131
127READ8_MEMBER( gamate_state::protection_r ) { return card_protection.set? 3: 1; } // bits 0 and 1 checked
132READ8_MEMBER( gamate_state::protection_r )
133{
134   return card_protection.set? 3: 1;
135} // bits 0 and 1 checked
128136
129137WRITE8_MEMBER( gamate_state::protection_reset )
130138{
131  // writes 0x20
132  card_protection.address=0x6005-0x6001;
133  card_protection.bit_shifter=0;
134  card_protection.cartridge_byte=m_cart->get_rom_base()[card_protection.address++];//m_cart_rom[card_protection.address++];
135  card_protection.failed=false;
136  card_protection.unprotected=false;
139// writes 0x20
140   card_protection.address=0x6005-0x6001;
141   card_protection.bit_shifter=0;
142   card_protection.cartridge_byte=m_cart->get_rom_base()[card_protection.address++];//m_cart_rom[card_protection.address++];
143   card_protection.failed=false;
144   card_protection.unprotected=false;
137145}
138146
139147READ8_MEMBER( gamate_state::newer_protection_set )
140148{
141  card_protection.set=true;
142  return 0;
149   card_protection.set=true;
150   return 0;
143151}
144152
145
146153WRITE8_MEMBER( gamate_state::gamate_video_w )
147154{
148  video.reg[offset]=data;
149  switch (offset) {
150  case 1:
151    if (data&0xf) printf("lcd mode %x\n", data);
152    video.y_increment=data&0x40;
153    break;
154  case 2: video.bitmap.xpos=data;break;
155  case 3:
156    if (data>=200) printf("lcd ypos: %x\n", data);
157    video.bitmap.ypos=data;
158    break;
159  case 4: video.bitmap.page2=data&0x80;video.x=data&0x1f;break;
160  case 5: video.y=data;break;
161  case 7:
162    video.bitmap.data[video.bitmap.page2][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data;
163    if (video.y_increment) video.y++;
164    else video.x++; // overruns
165  }
155   video.reg[offset]=data;
156   switch (offset)
157   {
158      case 1:
159         if (data&0xf)
160            printf("lcd mode %x\n", data);
161         video.y_increment=data&0x40;
162         break;
163      case 2:
164         video.bitmap.xpos=data;
165         break;
166      case 3:
167         if (data>=200)
168            printf("lcd ypos: %x\n", data);
169         video.bitmap.ypos=data;
170         break;
171      case 4:
172         video.bitmap.page2=data&0x80;
173         video.x=data&0x1f;
174         break;
175      case 5:
176         video.y=data;
177         break;
178      case 7:
179         video.bitmap.data[video.bitmap.page2][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)]=data;
180         if (video.y_increment)
181            video.y++;
182         else
183            video.x++; // overruns
184   }
166185}
167186
168187WRITE8_MEMBER( gamate_state::cart_bankswitchmulti_w )
169188{
170  bank_multi=data;
171  membank("bankmulti")->set_base(m_cart->get_rom_base()+0x4000*data+1);
189   bank_multi=data;
190   membank("bankmulti")->set_base(m_cart->get_rom_base()+0x4000*data+1);
172191}
173192
174193WRITE8_MEMBER( gamate_state::cart_bankswitch_w )
r244910r244911
178197
179198READ8_MEMBER( gamate_state::gamate_video_r )
180199{
181  if (offset!=6) return 0;
182  UINT8 data=0;
183    data=video.bitmap.data[video.bitmap.page2][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)];
200   if (offset!=6)
201      return 0;
202   UINT8 data = video.bitmap.data[video.bitmap.page2][video.y][video.x&(ARRAY_LENGTH(video.bitmap.data[0][0])-1)];
184203//  if (m_maincpu->pc()<0xf000)
185204//    machine().ui().popup_time(2, "lcd read x:%x y:%x mode:%x data:%x\n", video.x, video.y, video.reg[1], data);
186    if (video.y_increment) video.y++;
187    else video.x++; // overruns?
205   if (video.y_increment)
206      video.y++;
207   else
208      video.x++; // overruns?
188209
189    return data;
210   return data;
190211}
191212
192WRITE8_MEMBER( gamate_state::gamate_audio_w )
193{
194//  logerror("%.6f %04x audio write %04x %02x\n",machine().time().as_double(),m_maincpu->pc(),offset,data);
195  m_sound->device_w(space, offset, data);
196}
197
198READ8_MEMBER( gamate_state::gamate_audio_r )
199{
200  UINT8 data=m_sound->device_r(space, offset);
201  return data;
202}
203
204
205READ8_MEMBER( gamate_state::gamate_pad_r )
206{
207  UINT8 data=m_io_joy->read();
208  return data;
209}
210
211213READ8_MEMBER( gamate_state::gamate_nmi_r )
212214{
213  UINT8 data=0;
214  machine().ui().popup_time(2, "nmi/4800 read\n");
215  return data;
215   UINT8 data=0;
216   machine().ui().popup_time(2, "nmi/4800 read\n");
217   return data;
216218}
217219
218220static ADDRESS_MAP_START( gamate_mem, AS_PROGRAM, 8, gamate_state )
219    AM_RANGE(0x0000, 0x03ff) AM_RAM
220  AM_RANGE(0x4000, 0x400d) AM_READWRITE(gamate_audio_r, gamate_audio_w)
221  AM_RANGE(0x4400, 0x4400) AM_READ(gamate_pad_r)
222  AM_RANGE(0x4800, 0x4800) AM_READ(gamate_nmi_r)
223  AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w)
224  AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set)
225  AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset)
226  AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r)
227
228  AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti")
229  AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank")
230
221   AM_RANGE(0x0000, 0x03ff) AM_RAM
222   AM_RANGE(0x4000, 0x400d) AM_DEVREADWRITE("custom", gamate_sound_device, device_r, device_w)
223   AM_RANGE(0x4400, 0x4400) AM_READ_PORT("JOY")
224   AM_RANGE(0x4800, 0x4800) AM_READ(gamate_nmi_r)
225   AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w)
226   AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set)
227   AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset)
228   AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r)
229   AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti")
230   AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank")
231231   AM_RANGE(0x6000, 0x6000) AM_READWRITE(gamate_cart_protection_r, gamate_cart_protection_w)
232232   AM_RANGE(0x8000, 0x8000) AM_WRITE(cart_bankswitchmulti_w)
233233   AM_RANGE(0xc000, 0xc000) AM_WRITE(cart_bankswitch_w)
234
235  AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios")
234   AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios")
236235ADDRESS_MAP_END
237236
238237
r244910r244911
251250/* palette in red, green, blue tribles */
252251static const unsigned char gamate_colors[4][3] =
253252{
254  { 255,255,255 },
255  { 0xa0, 0xa0, 0xa0 },
256  { 0x60, 0x60, 0x60 },
257  { 0, 0, 0 }
253   { 255,255,255 },
254   { 0xa0, 0xa0, 0xa0 },
255   { 0x60, 0x60, 0x60 },
256   { 0, 0, 0 }
258257};
259258
260259PALETTE_INIT_MEMBER(gamate_state, gamate)
r244910r244911
277276
278277UINT32 gamate_state::screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
279278{
280  int x, y, j;
281  for (y=0;y<152;y++) {
282    for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) {     
283      UINT8 d1, d2;
284      if (video.bitmap.ypos<200) {
285   d1=video.bitmap.data[0][(y+video.bitmap.ypos)%200][(j+video.bitmap.xpos/8)&0x1f];
286   d2=video.bitmap.data[1][(y+video.bitmap.ypos)%200][(j+video.bitmap.xpos/8)&0x1f];
287      } 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
288   int yi=(y+(video.bitmap.ypos&0xf)-8);
289   if (yi<0) yi=video.bitmap.ypos+y; // in this case only 2nd plane used!?, source of first plane?
290   d1=video.bitmap.data[0][yi][(j+video.bitmap.xpos/8)&0x1f]; // value of lines bevor 0 chaos
291   d2=video.bitmap.data[1][yi][(j+video.bitmap.xpos/8)&0x1f];
292      } else {
293   d1=video.bitmap.data[0][y][(j+video.bitmap.xpos/8)&0x1f];
294   d2=video.bitmap.data[1][y][(j+video.bitmap.xpos/8)&0x1f];   
295      }
296      BlitPlane(&bitmap.pix16(y, x+4), d1, d2);
297      BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4);
298    }
299  }
300  return 0;
279   int x, y, j;
280   for (y=0;y<152;y++)
281   {
282      for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++)
283      {
284         UINT8 d1, d2;
285         if (video.bitmap.ypos<200)
286         {
287            d1=video.bitmap.data[0][(y+video.bitmap.ypos)%200][(j+video.bitmap.xpos/8)&0x1f];
288            d2=video.bitmap.data[1][(y+video.bitmap.ypos)%200][(j+video.bitmap.xpos/8)&0x1f];
289         }
290         else
291         if ((video.bitmap.ypos&0xf)<8)
292         { // 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
293            int yi=(y+(video.bitmap.ypos&0xf)-8);
294            if (yi<0)
295               yi=video.bitmap.ypos+y; // in this case only 2nd plane used!?, source of first plane?
296            d1=video.bitmap.data[0][yi][(j+video.bitmap.xpos/8)&0x1f]; // value of lines bevor 0 chaos
297            d2=video.bitmap.data[1][yi][(j+video.bitmap.xpos/8)&0x1f];
298         }
299         else
300         {
301            d1=video.bitmap.data[0][y][(j+video.bitmap.xpos/8)&0x1f];
302            d2=video.bitmap.data[1][y][(j+video.bitmap.xpos/8)&0x1f];
303         }
304         BlitPlane(&bitmap.pix16(y, x+4), d1, d2);
305         BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4);
306      }
307   }
308   return 0;
301309}
302310
303311DRIVER_INIT_MEMBER(gamate_state,gamate)
r244910r244911
310318
311319void gamate_state::machine_start()
312320{
313   if (m_cart->exists()) {
321   if (m_cart->exists())
322   {
314323//      m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r));
315324      membank("bankmulti")->set_base(m_cart->get_rom_base()+1);
316325      membank("bank")->set_base(m_cart->get_rom_base()+0x4000); // bankswitched games in reality no offset
r244910r244911
375384   MCFG_SOUND_ADD("custom", GAMATE_SND, 0)
376385   MCFG_SOUND_ROUTE(0, "lspeaker", 0.50)
377386   MCFG_SOUND_ROUTE(1, "rspeaker", 0.50)
378   
387
379388   MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_linear_slot, "gamate_cart")
380   MCFG_GENERIC_MANDATORY
381
382389   MCFG_SOFTWARE_LIST_ADD("cart_list","gamate")
383390MACHINE_CONFIG_END
384391
r244910r244911
392399ROM_END
393400
394401
395/*    YEAR  NAME      PARENT  COMPAT    MACHINE  INPUT    CLASS          INIT      COMPANY    FULLNAME */
402/*    YEAR  NAME     PARENT  COMPAT    MACHINE  INPUT   CLASS         INIT      COMPANY    FULLNAME */
396403CONS( 19??, gamate,  0,      0,        gamate,  gamate, gamate_state, gamate, "Bit Corp", "Gamate", 0)
397404
398
trunk/src/mess/includes/gamate.h
r244910r244911
1414
1515// ======================> gamate_sound_device
1616
17class gamate_sound_device : public device_t,
18                        public device_sound_interface
17class gamate_sound_device : public device_t, public device_sound_interface
1918{
2019public:
2120   gamate_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
2221   ~gamate_sound_device() { }
2322
23   DECLARE_WRITE8_MEMBER( device_w );
24   DECLARE_READ8_MEMBER( device_r );
25
2426protected:
2527   // device-level overrides
2628   virtual void device_start();
r244910r244911
2830   // sound stream update overrides
2931   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
3032
31public:
32   DECLARE_WRITE8_MEMBER( device_w );
33   DECLARE_READ8_MEMBER( device_r );
34
3533private:
3634
3735   static const int DAConverter[];
r244910r244911
4038   sound_stream *m_mixer_channel;
4139   struct Tone
4240   {
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     }
41      Tone() :
42         envelope_on(false),
43         level(false),
44         tone(false), full_cycle(false),
45         volume(0),
46         pos(0),
47         size(0)
48         {}
5249
53     bool envelope_on, level;
54     bool tone/*else noise*/, full_cycle/* else square signal/pulse */;
55     int volume;
56     int pos, size;
50      bool envelope_on, level;
51      bool tone/*else noise*/, full_cycle/* else square signal/pulse */;
52      int volume;
53      int pos, size;
5754   };
58   enum { Right, Left, Both };
55
56   enum
57   {
58      Right,
59      Left,
60      Both
61   };
62
5963   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;
64
65   struct Noise
66   {
67      Noise():
68         state(1),
69         level(false),
70         step(0.0),
71         pos(0.0)
72         {}
73
74      int state;
75      bool level;
76      double step, pos;
6577   } 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;
78
79   struct Envelope
80   {
81      Envelope():
82         control(0),
83         index(0),
84         first(false)
85         {}
86
87      int control;
88      int index;
89      bool first;
90      double step, pos;
7291   } envelope;
92
7393   UINT8 reg[14];
7494};
7595


Previous 199869 Revisions Next


© 1997-2024 The MAME Team