trunk/src/mess/drivers/jr100.c
| r20500 | r20501 | |
| 25 | 25 | { |
| 26 | 26 | public: |
| 27 | 27 | jr100_state(const machine_config &mconfig, device_type type, const char *tag) |
| 28 | | : driver_device(mconfig, type, tag) , |
| 29 | | m_ram(*this, "ram"), |
| 30 | | m_pcg(*this, "pcg"), |
| 31 | | m_vram(*this, "vram"){ } |
| 28 | : driver_device(mconfig, type, tag) |
| 29 | , m_ram(*this, "ram") |
| 30 | , m_pcg(*this, "pcg") |
| 31 | , m_vram(*this, "vram") |
| 32 | , m_via(*this, "via") |
| 33 | , m_cassette(*this, CASSETTE_TAG) |
| 34 | , m_beeper(*this, BEEPER_TAG) |
| 35 | , m_speaker(*this, SPEAKER_TAG) |
| 36 | , m_region_maincpu(*this, "maincpu") |
| 37 | , m_line0(*this, "LINE0") |
| 38 | , m_line1(*this, "LINE1") |
| 39 | , m_line2(*this, "LINE2") |
| 40 | , m_line3(*this, "LINE3") |
| 41 | , m_line4(*this, "LINE4") |
| 42 | , m_line5(*this, "LINE5") |
| 43 | , m_line6(*this, "LINE6") |
| 44 | , m_line7(*this, "LINE7") |
| 45 | , m_line8(*this, "LINE8") |
| 46 | { } |
| 32 | 47 | |
| 33 | 48 | required_shared_ptr<UINT8> m_ram; |
| 34 | 49 | required_shared_ptr<UINT8> m_pcg; |
| 35 | 50 | required_shared_ptr<UINT8> m_vram; |
| 36 | 51 | UINT8 m_keyboard_line; |
| 37 | 52 | bool m_use_pcg; |
| 38 | | UINT8 m_speaker; |
| 53 | UINT8 m_speaker_data; |
| 39 | 54 | UINT16 m_t1latch; |
| 40 | 55 | UINT8 m_beep_en; |
| 41 | 56 | DECLARE_WRITE8_MEMBER(jr100_via_w); |
| r20500 | r20501 | |
| 48 | 63 | DECLARE_WRITE8_MEMBER(jr100_via_write_a); |
| 49 | 64 | DECLARE_WRITE8_MEMBER(jr100_via_write_b); |
| 50 | 65 | DECLARE_WRITE_LINE_MEMBER(jr100_via_write_cb2); |
| 66 | |
| 67 | protected: |
| 68 | required_device<via6522_device> m_via; |
| 69 | required_device<cassette_image_device> m_cassette; |
| 70 | required_device<device_t> m_beeper; |
| 71 | required_device<device_t> m_speaker; |
| 72 | required_memory_region m_region_maincpu; |
| 73 | required_ioport m_line0; |
| 74 | required_ioport m_line1; |
| 75 | required_ioport m_line2; |
| 76 | required_ioport m_line3; |
| 77 | required_ioport m_line4; |
| 78 | required_ioport m_line5; |
| 79 | required_ioport m_line6; |
| 80 | required_ioport m_line7; |
| 81 | required_ioport m_line8; |
| 51 | 82 | }; |
| 52 | 83 | |
| 53 | 84 | |
| r20500 | r20501 | |
| 62 | 93 | m_beep_en = ((data & 0xe0) == 0xe0); |
| 63 | 94 | |
| 64 | 95 | if(!m_beep_en) |
| 65 | | beep_set_state(machine().device(BEEPER_TAG),0); |
| 96 | beep_set_state(m_beeper,0); |
| 66 | 97 | } |
| 67 | 98 | |
| 68 | 99 | /* T1L-L */ |
| r20500 | r20501 | |
| 81 | 112 | /* writing here actually enables the beeper, if above masking condition is satisfied */ |
| 82 | 113 | if(m_beep_en) |
| 83 | 114 | { |
| 84 | | beep_set_state(machine().device(BEEPER_TAG),1); |
| 85 | | beep_set_frequency(machine().device(BEEPER_TAG),894886.25 / (double)(m_t1latch) / 2.0); |
| 115 | beep_set_state(m_beeper,1); |
| 116 | beep_set_frequency(m_beeper,894886.25 / (double)(m_t1latch) / 2.0); |
| 86 | 117 | } |
| 87 | 118 | } |
| 88 | | via6522_device *via = machine().device<via6522_device>("via"); |
| 89 | | via->write(space,offset,data); |
| 119 | m_via->write(space,offset,data); |
| 90 | 120 | } |
| 91 | 121 | |
| 92 | 122 | static ADDRESS_MAP_START(jr100_mem, AS_PROGRAM, 8, jr100_state ) |
| r20500 | r20501 | |
| 167 | 197 | |
| 168 | 198 | void jr100_state::machine_start() |
| 169 | 199 | { |
| 170 | | beep_set_frequency(machine().device(BEEPER_TAG),0); |
| 171 | | beep_set_state(machine().device(BEEPER_TAG),0); |
| 200 | beep_set_frequency(m_beeper,0); |
| 201 | beep_set_state(m_beeper,0); |
| 172 | 202 | } |
| 173 | 203 | |
| 174 | 204 | void jr100_state::machine_reset() |
| r20500 | r20501 | |
| 183 | 213 | { |
| 184 | 214 | int x,y,xi,yi; |
| 185 | 215 | |
| 186 | | UINT8 *rom_pcg = memregion("maincpu")->base() + 0xe000; |
| 216 | UINT8 *rom_pcg = m_region_maincpu->base() + 0xe000; |
| 187 | 217 | for (y = 0; y < 24; y++) |
| 188 | 218 | { |
| 189 | 219 | for (x = 0; x < 32; x++) |
| r20500 | r20501 | |
| 226 | 256 | GFXDECODE_ENTRY( "maincpu", 0xe000, tiles8x8_layout, 0, 1 ) |
| 227 | 257 | GFXDECODE_END |
| 228 | 258 | |
| 229 | | static const char *const keynames[] = { |
| 230 | | "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7", |
| 231 | | "LINE8", NULL, NULL, NULL, NULL, NULL, NULL, NULL |
| 232 | | }; |
| 233 | | |
| 234 | | |
| 235 | 259 | READ8_MEMBER(jr100_state::jr100_via_read_b) |
| 236 | 260 | { |
| 237 | 261 | UINT8 val = 0x1f; |
| 238 | | if (keynames[m_keyboard_line]) { |
| 239 | | val = ioport(keynames[m_keyboard_line])->read(); |
| 262 | switch ( m_keyboard_line ) |
| 263 | { |
| 264 | case 0: val = m_line0->read(); break; |
| 265 | case 1: val = m_line1->read(); break; |
| 266 | case 2: val = m_line2->read(); break; |
| 267 | case 3: val = m_line3->read(); break; |
| 268 | case 4: val = m_line4->read(); break; |
| 269 | case 5: val = m_line5->read(); break; |
| 270 | case 6: val = m_line6->read(); break; |
| 271 | case 7: val = m_line7->read(); break; |
| 272 | case 8: val = m_line8->read(); break; |
| 240 | 273 | } |
| 241 | 274 | return val; |
| 242 | 275 | } |
| r20500 | r20501 | |
| 249 | 282 | WRITE8_MEMBER(jr100_state::jr100_via_write_b) |
| 250 | 283 | { |
| 251 | 284 | m_use_pcg = (data & 0x20) ? TRUE : FALSE; |
| 252 | | m_speaker = data>>7; |
| 285 | m_speaker_data = data>>7; |
| 253 | 286 | } |
| 254 | 287 | |
| 255 | 288 | WRITE_LINE_MEMBER(jr100_state::jr100_via_write_cb2) |
| 256 | 289 | { |
| 257 | | machine().device<cassette_image_device>(CASSETTE_TAG)->output(state ? -1.0 : +1.0); |
| 290 | m_cassette->output(state ? -1.0 : +1.0); |
| 258 | 291 | } |
| 259 | 292 | static const via6522_interface jr100_via_intf = |
| 260 | 293 | { |
| r20500 | r20501 | |
| 283 | 316 | |
| 284 | 317 | TIMER_DEVICE_CALLBACK_MEMBER(jr100_state::sound_tick) |
| 285 | 318 | { |
| 286 | | device_t *speaker = machine().device(SPEAKER_TAG); |
| 287 | | speaker_level_w(speaker,m_speaker); |
| 288 | | m_speaker = 0; |
| 319 | speaker_level_w(m_speaker,m_speaker_data); |
| 320 | m_speaker_data = 0; |
| 289 | 321 | |
| 290 | | via6522_device *via = machine().device<via6522_device>("via"); |
| 291 | | double level = (machine().device<cassette_image_device>(CASSETTE_TAG)->input()); |
| 322 | double level = (m_cassette->input()); |
| 292 | 323 | if (level > 0.0) { |
| 293 | | via->write_ca1(0); |
| 294 | | via->write_cb1(0); |
| 324 | m_via->write_ca1(0); |
| 325 | m_via->write_cb1(0); |
| 295 | 326 | } else { |
| 296 | | via->write_ca1(1); |
| 297 | | via->write_cb1(1); |
| 327 | m_via->write_ca1(1); |
| 328 | m_via->write_cb1(1); |
| 298 | 329 | } |
| 299 | | |
| 300 | | |
| 301 | 330 | } |
| 302 | 331 | |
| 303 | 332 | static UINT32 readByLittleEndian(UINT8 *buf,int pos) |