trunk/src/mess/audio/gamate.c
| r244910 | r244911 | |
| 26 | 26 | //------------------------------------------------- |
| 27 | 27 | |
| 28 | 28 | gamate_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 | {} |
| 34 | 33 | |
| 35 | 34 | //------------------------------------------------- |
| 36 | 35 | // device_start - device-specific startup |
| r244910 | r244911 | |
| 61 | 60 | for (i = 0; i < samples; i++, left++, right++) |
| 62 | 61 | { |
| 63 | 62 | 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; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | envelope.pos += envelope.step; |
| 73 | 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 | | |
| 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 | } |
| 94 | 96 | } |
| 95 | 97 | |
| 96 | 98 | *left = 0; |
| r244910 | r244911 | |
| 99 | 101 | { |
| 100 | 102 | if (channel->size != 0) |
| 101 | 103 | { |
| 102 | | channel->level= channel->pos <= channel->size / 2; |
| 104 | channel->level= channel->pos <= channel->size / 2; |
| 103 | 105 | 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; |
| 105 | 108 | 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 | } |
| 139 | 155 | } |
| 140 | 156 | 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); |
| 147 | 165 | } |
| 148 | 166 | channel->pos++; |
| 149 | 167 | if (channel->pos >= channel->size) |
| r244910 | r244911 | |
| 169 | 187 | case 3: |
| 170 | 188 | case 4: |
| 171 | 189 | case 5: |
| 172 | | chan=offset/2; |
| 190 | chan=offset/2; |
| 173 | 191 | size = reg[chan*2] | ((reg[chan*2+1] & 0xf) << 8); |
| 174 | 192 | if (size) |
| 175 | 193 | { |
| r244910 | r244911 | |
| 182 | 200 | m_channels[chan].pos = 0; |
| 183 | 201 | break; |
| 184 | 202 | 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; |
| 189 | 208 | 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; |
| 200 | 219 | case 8: |
| 201 | 220 | case 9: |
| 202 | 221 | case 0xa: |
| 203 | | chan=offset-8; |
| 222 | chan=offset-8; |
| 204 | 223 | m_channels[chan].envelope_on = data & 0x10; // buggy aussetzer cube up |
| 205 | 224 | m_channels[chan].volume = data & 0xf; |
| 206 | 225 | break; |
| 207 | 226 | case 0xb: case 0xc: |
| 208 | 227 | 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; |
| 212 | 232 | 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 | |
| 219 | 239 | } |
| 220 | 240 | envelope.pos=0; // guess |
| 221 | 241 | envelope.index=0; |
| r244910 | r244911 | |
| 224 | 244 | |
| 225 | 245 | READ8_MEMBER( gamate_sound_device::device_r ) |
| 226 | 246 | { |
| 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; |
| 230 | 251 | } |
trunk/src/mess/drivers/gamate.c
| r244910 | r244911 | |
| 12 | 12 | #include "cpu/m6502/m6502.h" |
| 13 | 13 | #include "bus/generic/slot.h" |
| 14 | 14 | #include "bus/generic/carts.h" |
| 15 | | #include "rendlay.h" |
| 15 | //#include "rendlay.h" |
| 16 | 16 | #include "includes/gamate.h" |
| 17 | 17 | #include "ui/ui.h" |
| 18 | 18 | |
| r244910 | r244911 | |
| 38 | 38 | DECLARE_WRITE8_MEMBER(cart_bankswitchmulti_w); |
| 39 | 39 | DECLARE_WRITE8_MEMBER(cart_bankswitch_w); |
| 40 | 40 | DECLARE_READ8_MEMBER(gamate_video_r); |
| 41 | | DECLARE_READ8_MEMBER(gamate_pad_r); |
| 42 | 41 | DECLARE_READ8_MEMBER(gamate_nmi_r); |
| 43 | 42 | DECLARE_WRITE8_MEMBER(gamate_video_w); |
| 44 | | DECLARE_READ8_MEMBER(gamate_audio_r); |
| 45 | | DECLARE_WRITE8_MEMBER(gamate_audio_w); |
| 46 | 43 | DECLARE_WRITE8_MEMBER(gamate_bios_w); |
| 47 | 44 | DECLARE_DRIVER_INIT(gamate); |
| 48 | 45 | UINT32 screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| r244910 | r244911 | |
| 55 | 52 | |
| 56 | 53 | struct |
| 57 | 54 | { |
| 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; |
| 65 | 63 | bool y_increment; |
| 66 | 64 | } video; |
| 67 | 65 | |
| 68 | | struct { |
| 69 | | bool set; |
| 66 | struct |
| 67 | { |
| 68 | bool set; |
| 70 | 69 | int bit_shifter; |
| 71 | 70 | UINT8 cartridge_byte; |
| 72 | 71 | UINT16 address; // in reality something more like short local cartridge address offset |
| 73 | 72 | bool unprotected; |
| 74 | 73 | bool failed; |
| 75 | | |
| 76 | 74 | } card_protection; |
| 77 | 75 | |
| 78 | 76 | required_device<cpu_device> m_maincpu; |
| r244910 | r244911 | |
| 83 | 81 | required_shared_ptr<UINT8> m_bios; |
| 84 | 82 | emu_timer *timer1; |
| 85 | 83 | emu_timer *timer2; |
| 86 | | UINT8 bank_multi; |
| 84 | UINT8 bank_multi; |
| 87 | 85 | }; |
| 88 | 86 | |
| 89 | 87 | WRITE8_MEMBER( gamate_state::gamate_cart_protection_w ) |
| 90 | 88 | { |
| 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); |
| 92 | 90 | |
| 93 | | switch (offset) { |
| 91 | switch (offset) |
| 92 | { |
| 94 | 93 | case 0: |
| 95 | 94 | card_protection.failed= card_protection.failed || ((card_protection.cartridge_byte&0x80)!=0) != ((data&4)!=0); |
| 96 | 95 | card_protection.bit_shifter++; |
| 97 | | if (card_protection.bit_shifter>=8) { |
| 96 | if (card_protection.bit_shifter>=8) |
| 97 | { |
| 98 | 98 | card_protection.cartridge_byte=m_cart->get_rom_base()[card_protection.address++]; |
| 99 | 99 | card_protection.bit_shifter=0; |
| 100 | 100 | } |
| 101 | 101 | break; |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | |
| 104 | 105 | READ8_MEMBER( gamate_state::gamate_cart_protection_r ) |
| 105 | 106 | { |
| 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]; |
| 116 | 111 | } |
| 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; |
| 120 | 127 | } |
| 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; |
| 125 | 130 | } |
| 126 | 131 | |
| 127 | | READ8_MEMBER( gamate_state::protection_r ) { return card_protection.set? 3: 1; } // bits 0 and 1 checked |
| 132 | READ8_MEMBER( gamate_state::protection_r ) |
| 133 | { |
| 134 | return card_protection.set? 3: 1; |
| 135 | } // bits 0 and 1 checked |
| 128 | 136 | |
| 129 | 137 | WRITE8_MEMBER( gamate_state::protection_reset ) |
| 130 | 138 | { |
| 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; |
| 137 | 145 | } |
| 138 | 146 | |
| 139 | 147 | READ8_MEMBER( gamate_state::newer_protection_set ) |
| 140 | 148 | { |
| 141 | | card_protection.set=true; |
| 142 | | return 0; |
| 149 | card_protection.set=true; |
| 150 | return 0; |
| 143 | 151 | } |
| 144 | 152 | |
| 145 | | |
| 146 | 153 | WRITE8_MEMBER( gamate_state::gamate_video_w ) |
| 147 | 154 | { |
| 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 | } |
| 166 | 185 | } |
| 167 | 186 | |
| 168 | 187 | WRITE8_MEMBER( gamate_state::cart_bankswitchmulti_w ) |
| 169 | 188 | { |
| 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); |
| 172 | 191 | } |
| 173 | 192 | |
| 174 | 193 | WRITE8_MEMBER( gamate_state::cart_bankswitch_w ) |
| r244910 | r244911 | |
| 178 | 197 | |
| 179 | 198 | READ8_MEMBER( gamate_state::gamate_video_r ) |
| 180 | 199 | { |
| 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)]; |
| 184 | 203 | // if (m_maincpu->pc()<0xf000) |
| 185 | 204 | // 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? |
| 188 | 209 | |
| 189 | | return data; |
| 210 | return data; |
| 190 | 211 | } |
| 191 | 212 | |
| 192 | | WRITE8_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 | | |
| 198 | | READ8_MEMBER( gamate_state::gamate_audio_r ) |
| 199 | | { |
| 200 | | UINT8 data=m_sound->device_r(space, offset); |
| 201 | | return data; |
| 202 | | } |
| 203 | | |
| 204 | | |
| 205 | | READ8_MEMBER( gamate_state::gamate_pad_r ) |
| 206 | | { |
| 207 | | UINT8 data=m_io_joy->read(); |
| 208 | | return data; |
| 209 | | } |
| 210 | | |
| 211 | 213 | READ8_MEMBER( gamate_state::gamate_nmi_r ) |
| 212 | 214 | { |
| 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; |
| 216 | 218 | } |
| 217 | 219 | |
| 218 | 220 | static 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") |
| 231 | 231 | AM_RANGE(0x6000, 0x6000) AM_READWRITE(gamate_cart_protection_r, gamate_cart_protection_w) |
| 232 | 232 | AM_RANGE(0x8000, 0x8000) AM_WRITE(cart_bankswitchmulti_w) |
| 233 | 233 | 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") |
| 236 | 235 | ADDRESS_MAP_END |
| 237 | 236 | |
| 238 | 237 | |
| r244910 | r244911 | |
| 251 | 250 | /* palette in red, green, blue tribles */ |
| 252 | 251 | static const unsigned char gamate_colors[4][3] = |
| 253 | 252 | { |
| 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 } |
| 258 | 257 | }; |
| 259 | 258 | |
| 260 | 259 | PALETTE_INIT_MEMBER(gamate_state, gamate) |
| r244910 | r244911 | |
| 277 | 276 | |
| 278 | 277 | UINT32 gamate_state::screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 279 | 278 | { |
| 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; |
| 301 | 309 | } |
| 302 | 310 | |
| 303 | 311 | DRIVER_INIT_MEMBER(gamate_state,gamate) |
| r244910 | r244911 | |
| 310 | 318 | |
| 311 | 319 | void gamate_state::machine_start() |
| 312 | 320 | { |
| 313 | | if (m_cart->exists()) { |
| 321 | if (m_cart->exists()) |
| 322 | { |
| 314 | 323 | // m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); |
| 315 | 324 | membank("bankmulti")->set_base(m_cart->get_rom_base()+1); |
| 316 | 325 | membank("bank")->set_base(m_cart->get_rom_base()+0x4000); // bankswitched games in reality no offset |
| r244910 | r244911 | |
| 375 | 384 | MCFG_SOUND_ADD("custom", GAMATE_SND, 0) |
| 376 | 385 | MCFG_SOUND_ROUTE(0, "lspeaker", 0.50) |
| 377 | 386 | MCFG_SOUND_ROUTE(1, "rspeaker", 0.50) |
| 378 | | |
| 387 | |
| 379 | 388 | MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_linear_slot, "gamate_cart") |
| 380 | | MCFG_GENERIC_MANDATORY |
| 381 | | |
| 382 | 389 | MCFG_SOFTWARE_LIST_ADD("cart_list","gamate") |
| 383 | 390 | MACHINE_CONFIG_END |
| 384 | 391 | |
| r244910 | r244911 | |
| 392 | 399 | ROM_END |
| 393 | 400 | |
| 394 | 401 | |
| 395 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME */ |
| 402 | /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME */ |
| 396 | 403 | CONS( 19??, gamate, 0, 0, gamate, gamate, gamate_state, gamate, "Bit Corp", "Gamate", 0) |
| 397 | 404 | |
| 398 | | |