trunk/src/mess/audio/gamate.c
| r244670 | r244671 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | gamate sound hardware |
| 3 | 3 | |
| 4 | | PeT mess@utanet.at |
| 4 | PeT mess@utanet.at 2015 |
| 5 | 5 | ***************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | #include "emu.h" |
| 8 | 8 | #include "includes/gamate.h" |
| 9 | #include "ui/ui.h" |
| 9 | 10 | |
| 10 | 11 | |
| 12 | enum { ClockDelay=32 }; |
| 13 | |
| 11 | 14 | // device type definition |
| 12 | 15 | const device_type GAMATE_SND = &device_creator<gamate_sound_device>; |
| 13 | 16 | |
| 14 | | |
| 17 | const 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 |
| 18 | const UINT8 Mask[]={ 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0x1f, 0x3f, 0x1f, 0x1f, 0x1f, 0xff, 0xff, 0xf }; |
| 19 | const 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 }; |
| 15 | 20 | //************************************************************************** |
| 16 | 21 | // LIVE DEVICE |
| 17 | 22 | //************************************************************************** |
| r244670 | r244671 | |
| 27 | 32 | { |
| 28 | 33 | } |
| 29 | 34 | |
| 30 | | |
| 31 | 35 | //------------------------------------------------- |
| 32 | 36 | // device_start - device-specific startup |
| 33 | 37 | //------------------------------------------------- |
| r244670 | r244671 | |
| 35 | 39 | void gamate_sound_device::device_start() |
| 36 | 40 | { |
| 37 | 41 | // bind callbacks |
| 38 | | // m_irq_cb.bind_relative_to(*owner()); |
| 42 | // m_irq_cb.bind_relative_to(*owner()); |
| 39 | 43 | |
| 40 | 44 | memset(m_channels, 0, sizeof(m_channels)); |
| 41 | 45 | memset(reg, 0, sizeof(reg)); |
| r244670 | r244671 | |
| 52 | 56 | { |
| 53 | 57 | stream_sample_t *left=outputs[0], *right=outputs[1]; |
| 54 | 58 | int i, j; |
| 55 | | GAMATE_CHANNEL *channel; |
| 56 | | |
| 59 | Tone *channel; |
| 60 | |
| 57 | 61 | for (i = 0; i < samples; i++, left++, right++) |
| 58 | 62 | { |
| 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 | |
| 59 | 96 | *left = 0; |
| 60 | 97 | *right = 0; |
| 61 | 98 | for (channel=m_channels, j=0; j<ARRAY_LENGTH(m_channels); j++, channel++) |
| 62 | 99 | { |
| 63 | 100 | if (channel->size != 0) |
| 64 | 101 | { |
| 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 | } |
| 80 | 139 | } |
| 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 | } |
| 81 | 148 | channel->pos++; |
| 82 | 149 | if (channel->pos >= channel->size) |
| 83 | 150 | channel->pos = 0; |
| r244670 | r244671 | |
| 94 | 161 | reg[offset] = data; |
| 95 | 162 | int chan=-1; |
| 96 | 163 | |
| 97 | | switch (offset) |
| 164 | switch (offset&0xf) |
| 98 | 165 | { |
| 99 | 166 | case 0: |
| 100 | 167 | case 1: |
| r244670 | r244671 | |
| 102 | 169 | case 3: |
| 103 | 170 | case 4: |
| 104 | 171 | case 5: |
| 105 | | chan=offset/2; |
| 172 | chan=offset/2; |
| 106 | 173 | size = reg[chan*2] | ((reg[chan*2+1] & 0xf) << 8); |
| 107 | 174 | if (size) |
| 108 | 175 | { |
| 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()); |
| 110 | 177 | } |
| 111 | 178 | else |
| 112 | 179 | { |
| r244670 | r244671 | |
| 115 | 182 | m_channels[chan].pos = 0; |
| 116 | 183 | break; |
| 117 | 184 | 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; |
| 118 | 189 | 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; |
| 119 | 200 | 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 |
| 123 | 205 | m_channels[chan].volume = data & 0xf; |
| 124 | 206 | 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 | |
| 125 | 219 | } |
| 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; |
| 127 | 223 | } |
| 224 | |
| 225 | READ8_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
| r244670 | r244671 | |
| 3 | 3 | Peter Wilhelmsen peter.wilhelmsen@gmail.com |
| 4 | 4 | Morten Shearman Kirkegaard morten+gamate@afdelingp.dk |
| 5 | 5 | Juan F??lix Mateos vectrex@hackermesh.org |
| 6 | | ******************************************************************************/ |
| 7 | 6 | |
| 7 | nmi unknown |
| 8 | cube up audio sometimes missing |
| 9 | bomb blast top status line missing |
| 10 | ******************************************************************************/ |
| 11 | |
| 8 | 12 | #include "emu.h" |
| 9 | 13 | #include "cpu/m6502/m6502.h" |
| 10 | 14 | #include "bus/generic/slot.h" |
| r244670 | r244671 | |
| 36 | 40 | DECLARE_WRITE8_MEMBER(cart_bankswitch_w); |
| 37 | 41 | DECLARE_READ8_MEMBER(gamate_video_r); |
| 38 | 42 | DECLARE_READ8_MEMBER(gamate_pad_r); |
| 43 | DECLARE_READ8_MEMBER(gamate_nmi_r); |
| 39 | 44 | DECLARE_WRITE8_MEMBER(gamate_video_w); |
| 40 | 45 | DECLARE_READ8_MEMBER(gamate_audio_r); |
| 41 | 46 | DECLARE_WRITE8_MEMBER(gamate_audio_w); |
| r244670 | r244671 | |
| 51 | 56 | |
| 52 | 57 | struct |
| 53 | 58 | { |
| 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 |
| 58 | 62 | 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; |
| 62 | 66 | bool y_increment; |
| 63 | 67 | } video; |
| 64 | 68 | |
| 65 | 69 | struct { |
| 66 | | bool set; |
| 70 | bool set; |
| 67 | 71 | int bit_shifter; |
| 68 | 72 | UINT8 cartridge_byte; |
| 69 | 73 | UINT16 address; // in reality something more like short local cartridge address offset |
| 70 | 74 | bool unprotected; |
| 71 | 75 | bool failed; |
| 72 | | |
| 76 | |
| 73 | 77 | } card_protection; |
| 74 | 78 | |
| 75 | 79 | required_device<cpu_device> m_maincpu; |
| r244670 | r244671 | |
| 80 | 84 | required_shared_ptr<UINT8> m_bios; |
| 81 | 85 | emu_timer *timer1; |
| 82 | 86 | emu_timer *timer2; |
| 83 | | UINT8 bank_multi; |
| 87 | UINT8 bank_multi; |
| 84 | 88 | }; |
| 85 | 89 | |
| 86 | 90 | WRITE8_MEMBER( gamate_state::gamate_cart_protection_w ) |
| 87 | 91 | { |
| 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 | |
| 90 | 94 | switch (offset) { |
| 91 | 95 | case 0: |
| 92 | 96 | card_protection.failed= card_protection.failed || ((card_protection.cartridge_byte&0x80)!=0) != ((data&4)!=0); |
| r244670 | r244671 | |
| 100 | 104 | } |
| 101 | 105 | READ8_MEMBER( gamate_state::gamate_cart_protection_r ) |
| 102 | 106 | { |
| 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 { |
| 107 | 112 | card_protection.bit_shifter++; |
| 108 | 113 | if (card_protection.bit_shifter==8) { |
| 109 | 114 | card_protection.bit_shifter=0; |
| r244670 | r244671 | |
| 112 | 117 | } |
| 113 | 118 | ret=(card_protection.cartridge_byte&0x80)?2:0; |
| 114 | 119 | 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 |
| 116 | 121 | } |
| 117 | 122 | 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; |
| 121 | 126 | } |
| 122 | 127 | |
| 123 | 128 | READ8_MEMBER( gamate_state::protection_r ) { return card_protection.set? 3: 1; } // bits 0 and 1 checked |
| 124 | 129 | |
| 125 | 130 | WRITE8_MEMBER( gamate_state::protection_reset ) |
| 126 | 131 | { |
| 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; |
| 133 | 138 | } |
| 134 | 139 | |
| 135 | 140 | READ8_MEMBER( gamate_state::newer_protection_set ) |
| 136 | 141 | { |
| 137 | | card_protection.set=true; |
| 138 | | return 0; |
| 142 | card_protection.set=true; |
| 143 | return 0; |
| 139 | 144 | } |
| 140 | 145 | |
| 141 | 146 | |
| 142 | 147 | WRITE8_MEMBER( gamate_state::gamate_video_w ) |
| 143 | 148 | { |
| 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 | } |
| 169 | 167 | } |
| 170 | 168 | |
| 171 | 169 | WRITE8_MEMBER( gamate_state::cart_bankswitchmulti_w ) |
| 172 | 170 | { |
| 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); |
| 175 | 173 | } |
| 176 | 174 | |
| 177 | 175 | WRITE8_MEMBER( gamate_state::cart_bankswitch_w ) |
| r244670 | r244671 | |
| 181 | 179 | |
| 182 | 180 | READ8_MEMBER( gamate_state::gamate_video_r ) |
| 183 | 181 | { |
| 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)]; |
| 191 | 185 | // if (m_maincpu->pc()<0xf000) |
| 192 | 186 | // 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; |
| 194 | 191 | } |
| 195 | 192 | |
| 196 | 193 | WRITE8_MEMBER( gamate_state::gamate_audio_w ) |
| 197 | 194 | { |
| 198 | 195 | // 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); |
| 200 | 197 | } |
| 201 | 198 | |
| 202 | 199 | READ8_MEMBER( gamate_state::gamate_audio_r ) |
| 203 | 200 | { |
| 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; |
| 207 | 203 | } |
| 208 | 204 | |
| 209 | 205 | |
| 210 | 206 | READ8_MEMBER( gamate_state::gamate_pad_r ) |
| 211 | 207 | { |
| 212 | | UINT8 data=m_io_joy->read(); |
| 213 | | return data; |
| 208 | UINT8 data=m_io_joy->read(); |
| 209 | return data; |
| 214 | 210 | } |
| 215 | 211 | |
| 212 | READ8_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 | |
| 216 | 219 | static 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) |
| 224 | 228 | |
| 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") |
| 227 | 231 | |
| 228 | 232 | AM_RANGE(0x6000, 0x6000) AM_READWRITE(gamate_cart_protection_r, gamate_cart_protection_w) |
| 229 | 233 | AM_RANGE(0x8000, 0x8000) AM_WRITE(cart_bankswitchmulti_w) |
| 230 | 234 | AM_RANGE(0xc000, 0xc000) AM_WRITE(cart_bankswitch_w) |
| 231 | 235 | |
| 232 | | AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios") |
| 236 | AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios") |
| 233 | 237 | ADDRESS_MAP_END |
| 234 | 238 | |
| 235 | 239 | |
| r244670 | r244671 | |
| 245 | 249 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SELECT) PORT_NAME("Select") |
| 246 | 250 | INPUT_PORTS_END |
| 247 | 251 | |
| 248 | | ATTR_UNUSED static const unsigned short gamate_palette[4] = |
| 252 | static const unsigned short gamate_palette[4] = |
| 249 | 253 | { |
| 250 | 254 | 0,1,2,3 |
| 251 | 255 | }; |
| r244670 | r244671 | |
| 254 | 258 | /* palette in red, green, blue tribles */ |
| 255 | 259 | static const unsigned char gamate_colors[4][3] = |
| 256 | 260 | { |
| 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 } |
| 261 | 265 | }; |
| 262 | 266 | |
| 263 | 267 | PALETTE_INIT_MEMBER(gamate_state, gamate) |
| r244670 | r244671 | |
| 280 | 284 | |
| 281 | 285 | UINT32 gamate_state::screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 282 | 286 | { |
| 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) { |
| 288 | 292 | d1=video.bitmap.data[0][(y+video.bitmap.ypos)%200][(j+video.bitmap.xpos/8)&0x1f]; |
| 289 | 293 | 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 |
| 291 | 295 | int yi=(y+(video.bitmap.ypos&0xf)-8); |
| 292 | 296 | if (yi<0) yi=video.bitmap.ypos+y; // in this case only 2nd plane used!?, source of first plane? |
| 293 | 297 | d1=video.bitmap.data[0][yi][(j+video.bitmap.xpos/8)&0x1f]; // value of lines bevor 0 chaos |
| 294 | 298 | d2=video.bitmap.data[1][yi][(j+video.bitmap.xpos/8)&0x1f]; |
| 295 | | } else { |
| 299 | } else { |
| 296 | 300 | 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; |
| 304 | 308 | } |
| 305 | 309 | |
| 306 | 310 | DRIVER_INIT_MEMBER(gamate_state,gamate) |
| r244670 | r244671 | |
| 314 | 318 | void gamate_state::machine_start() |
| 315 | 319 | { |
| 316 | 320 | 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)); |
| 318 | 322 | membank("bankmulti")->set_base(m_cart->get_rom_base()+1); |
| 319 | 323 | membank("bank")->set_base(m_cart->get_rom_base()+0x4000); // bankswitched games in reality no offset |
| 320 | 324 | } |
| 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 |
| 322 | 326 | card_protection.set=false; |
| 323 | 327 | bank_multi=0; |
| 324 | 328 | card_protection.unprotected=false; |
| r244670 | r244671 | |
| 378 | 382 | MCFG_SOUND_ADD("custom", GAMATE_SND, 0) |
| 379 | 383 | MCFG_SOUND_ROUTE(0, "lspeaker", 0.50) |
| 380 | 384 | MCFG_SOUND_ROUTE(1, "rspeaker", 0.50) |
| 381 | | |
| 385 | |
| 382 | 386 | MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_linear_slot, "gamate_cart") |
| 383 | 387 | MCFG_GENERIC_MANDATORY |
| 384 | 388 | |
| r244670 | r244671 | |
| 396 | 400 | |
| 397 | 401 | |
| 398 | 402 | /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME */ |
| 399 | | CONS( 19??, gamate, 0, 0, gamate, gamate, gamate_state, gamate, "Bit Corp", "Gamate", GAME_IMPERFECT_SOUND) |
| 403 | CONS( 19??, gamate, 0, 0, gamate, gamate, gamate_state, gamate, "Bit Corp", "Gamate", 0) |
| 404 | |
| 405 | |