trunk/src/mess/audio/mos7360.c
| r17677 | r17678 | |
| 174 | 174 | const device_type MOS7360 = &device_creator<mos7360_device>; |
| 175 | 175 | |
| 176 | 176 | |
| 177 | // default address maps |
| 178 | static ADDRESS_MAP_START( mos7360_videoram_map, AS_0, 8, mos7360_device ) |
| 179 | AM_RANGE(0x0000, 0xffff) AM_RAM |
| 180 | ADDRESS_MAP_END |
| 177 | 181 | |
| 182 | |
| 183 | //------------------------------------------------- |
| 184 | // memory_space_config - return a description of |
| 185 | // any address spaces owned by this device |
| 186 | //------------------------------------------------- |
| 187 | |
| 188 | const address_space_config *mos7360_device::memory_space_config(address_spacenum spacenum) const |
| 189 | { |
| 190 | switch (spacenum) |
| 191 | { |
| 192 | case AS_0: return &m_videoram_space_config; |
| 193 | default: return NULL; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | |
| 198 | |
| 178 | 199 | //************************************************************************** |
| 179 | 200 | // INLINE HELPERS |
| 180 | 201 | //************************************************************************** |
| r17677 | r17678 | |
| 211 | 232 | return (int) ((machine().time().as_double() - m_rastertime) * TED7360_VRETRACERATE * m_lines * 57 * 8 + 0.5); |
| 212 | 233 | } |
| 213 | 234 | |
| 235 | inline UINT8 mos7360_device::read_ram(offs_t offset) |
| 236 | { |
| 237 | int rom = m_rom; |
| 238 | m_rom = 0; |
| 214 | 239 | |
| 240 | m_last_data = space(AS_0)->read_byte(offset); |
| 215 | 241 | |
| 242 | m_rom = rom; |
| 243 | |
| 244 | return m_last_data; |
| 245 | } |
| 246 | |
| 247 | inline UINT8 mos7360_device::read_rom(offs_t offset) |
| 248 | { |
| 249 | int rom = m_rom; |
| 250 | m_rom = 1; |
| 251 | |
| 252 | m_last_data = space(AS_0)->read_byte(offset); |
| 253 | |
| 254 | m_rom = rom; |
| 255 | |
| 256 | return m_last_data; |
| 257 | } |
| 258 | |
| 259 | |
| 260 | |
| 216 | 261 | //************************************************************************** |
| 217 | 262 | // LIVE DEVICE |
| 218 | 263 | //************************************************************************** |
| r17677 | r17678 | |
| 223 | 268 | |
| 224 | 269 | mos7360_device::mos7360_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 225 | 270 | : device_t(mconfig, MOS7360, "MOS7360", tag, owner, clock), |
| 271 | device_memory_interface(mconfig, *this), |
| 226 | 272 | device_sound_interface(mconfig, *this), |
| 273 | m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, NULL, *ADDRESS_MAP_NAME(mos7360_videoram_map)), |
| 227 | 274 | m_stream(NULL) |
| 228 | 275 | { |
| 229 | 276 | } |
| r17677 | r17678 | |
| 246 | 293 | else |
| 247 | 294 | { |
| 248 | 295 | memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb)); |
| 249 | | memset(&m_in_ram_cb, 0, sizeof(m_in_ram_cb)); |
| 250 | | memset(&m_in_rom_cb, 0, sizeof(m_in_rom_cb)); |
| 251 | 296 | memset(&m_in_k_cb, 0, sizeof(m_in_k_cb)); |
| 252 | 297 | } |
| 253 | 298 | } |
| r17677 | r17678 | |
| 269 | 314 | |
| 270 | 315 | // resolve callbacks |
| 271 | 316 | m_out_irq_func.resolve(m_out_irq_cb, *this); |
| 272 | | m_in_ram_func.resolve(m_in_ram_cb, *this); |
| 273 | | m_in_rom_func.resolve(m_in_rom_cb, *this); |
| 274 | 317 | m_in_k_func.resolve(m_in_k_cb, *this); |
| 275 | 318 | |
| 276 | 319 | // allocate timers |
| r17677 | r17678 | |
| 479 | 522 | for (y = ybegin; y <= yend; y++) |
| 480 | 523 | { |
| 481 | 524 | if (INROM) |
| 482 | | code = m_in_rom_func(m_chargenaddr + ch * 8 + y); |
| 525 | code = read_rom(m_chargenaddr + ch * 8 + y); |
| 483 | 526 | else |
| 484 | | code = m_in_ram_func(m_chargenaddr + ch * 8 + y); |
| 527 | code = read_ram(m_chargenaddr + ch * 8 + y); |
| 485 | 528 | |
| 486 | | m_last_data = code; |
| 487 | | |
| 488 | 529 | m_bitmap.pix16(y + yoff, 0 + xoff) = color[code >> 7]; |
| 489 | 530 | m_bitmap.pix16(y + yoff, 1 + xoff) = color[(code >> 6) & 1]; |
| 490 | 531 | m_bitmap.pix16(y + yoff, 2 + xoff) = color[(code >> 5) & 1]; |
| r17677 | r17678 | |
| 503 | 544 | for (y = ybegin; y <= yend; y++) |
| 504 | 545 | { |
| 505 | 546 | if (INROM) |
| 506 | | code = m_in_rom_func(m_chargenaddr + ch * 8 + y); |
| 547 | code = read_rom(m_chargenaddr + ch * 8 + y); |
| 507 | 548 | else |
| 508 | | code = m_in_ram_func(m_chargenaddr + ch * 8 + y); |
| 549 | code = read_ram(m_chargenaddr + ch * 8 + y); |
| 509 | 550 | |
| 510 | | m_last_data = code; |
| 511 | | |
| 512 | 551 | m_bitmap.pix16(y + yoff, 0 + xoff) = |
| 513 | 552 | m_bitmap.pix16(y + yoff, 1 + xoff) = m_multi[code >> 6]; |
| 514 | 553 | m_bitmap.pix16(y + yoff, 2 + xoff) = |
| r17677 | r17678 | |
| 526 | 565 | |
| 527 | 566 | for (y = ybegin; y <= yend; y++) |
| 528 | 567 | { |
| 529 | | code = m_in_ram_func(m_bitmapaddr + ch * 8 + y); |
| 568 | code = read_ram(m_bitmapaddr + ch * 8 + y); |
| 530 | 569 | |
| 531 | | m_last_data = code; |
| 532 | | |
| 533 | 570 | m_bitmap.pix16(y + yoff, 0 + xoff) = m_c16_bitmap[code >> 7]; |
| 534 | 571 | m_bitmap.pix16(y + yoff, 1 + xoff) = m_c16_bitmap[(code >> 6) & 1]; |
| 535 | 572 | m_bitmap.pix16(y + yoff, 2 + xoff) = m_c16_bitmap[(code >> 5) & 1]; |
| r17677 | r17678 | |
| 547 | 584 | |
| 548 | 585 | for (y = ybegin; y <= yend; y++) |
| 549 | 586 | { |
| 550 | | code = m_in_ram_func(m_bitmapaddr + ch * 8 + y); |
| 587 | code = read_ram(m_bitmapaddr + ch * 8 + y); |
| 551 | 588 | |
| 552 | | m_last_data = code; |
| 553 | | |
| 554 | 589 | m_bitmap.pix16(y + yoff, 0 + xoff) = |
| 555 | 590 | m_bitmap.pix16(y + yoff, 1 + xoff) = m_bitmapmulti[code >> 6]; |
| 556 | 591 | m_bitmap.pix16(y + yoff, 2 + xoff) = |
| r17677 | r17678 | |
| 643 | 678 | { |
| 644 | 679 | if (HIRESON) |
| 645 | 680 | { |
| 646 | | ch = m_in_ram_func((m_videoaddr | 0x400) + offs); |
| 647 | | attr = m_in_ram_func(m_videoaddr + offs); |
| 681 | ch = read_ram((m_videoaddr | 0x400) + offs); |
| 682 | attr = read_ram(m_videoaddr + offs); |
| 648 | 683 | c1 = ((ch >> 4) & 0xf) | (attr << 4); |
| 649 | 684 | c2 = (ch & 0xf) | (attr & 0x70); |
| 650 | 685 | m_bitmapmulti[1] = m_c16_bitmap[1] = c1 & 0x7f; |
| r17677 | r17678 | |
| 660 | 695 | } |
| 661 | 696 | else |
| 662 | 697 | { |
| 663 | | ch = m_in_ram_func((m_videoaddr | 0x400) + offs); |
| 664 | | attr = m_in_ram_func(m_videoaddr + offs); |
| 698 | ch = read_ram((m_videoaddr | 0x400) + offs); |
| 699 | attr = read_ram(m_videoaddr + offs); |
| 665 | 700 | // levente harsfalvi's docu says cursor off in ecm and multicolor |
| 666 | 701 | if (ECMON) |
| 667 | 702 | { |
| r17677 | r17678 | |
| 1160 | 1195 | { |
| 1161 | 1196 | return m_last_data; |
| 1162 | 1197 | } |
| 1198 | |
| 1199 | |
| 1200 | //------------------------------------------------- |
| 1201 | // cs0_r - chip select 0 read |
| 1202 | //------------------------------------------------- |
| 1203 | |
| 1204 | int mos7360_device::cs0_r(offs_t offset) |
| 1205 | { |
| 1206 | if (m_rom && offset >= 0x8000 && offset < 0xc000) |
| 1207 | { |
| 1208 | return 0; |
| 1209 | } |
| 1210 | |
| 1211 | return 1; |
| 1212 | } |
| 1213 | |
| 1214 | |
| 1215 | //------------------------------------------------- |
| 1216 | // cs0_r - chip select 1 read |
| 1217 | //------------------------------------------------- |
| 1218 | |
| 1219 | int mos7360_device::cs1_r(offs_t offset) |
| 1220 | { |
| 1221 | if (m_rom && ((offset >= 0xc000 && offset < 0xfd00) || (offset >= 0xff20))) |
| 1222 | { |
| 1223 | return 0; |
| 1224 | } |
| 1225 | |
| 1226 | return 1; |
| 1227 | } |
trunk/src/mess/audio/mos7360.h
| r17677 | r17678 | |
| 43 | 43 | DEVICE CONFIGURATION MACROS |
| 44 | 44 | ***************************************************************************/ |
| 45 | 45 | |
| 46 | | #define MCFG_MOS7360_ADD(_tag, _screen_tag, _clock, _config) \ |
| 46 | #define MCFG_MOS7360_ADD(_tag, _screen_tag, _clock, _config, _videoram_map) \ |
| 47 | 47 | MCFG_SCREEN_ADD(_screen_tag, RASTER) \ |
| 48 | 48 | MCFG_SCREEN_REFRESH_RATE(TED7360PAL_VRETRACERATE) \ |
| 49 | 49 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) \ |
| r17677 | r17678 | |
| 52 | 52 | MCFG_SCREEN_UPDATE_DEVICE(_tag, mos7360_device, screen_update) \ |
| 53 | 53 | MCFG_PALETTE_LENGTH(128) \ |
| 54 | 54 | MCFG_DEVICE_ADD(_tag, MOS7360, _clock) \ |
| 55 | | MCFG_DEVICE_CONFIG(_config) |
| 55 | MCFG_DEVICE_CONFIG(_config) \ |
| 56 | MCFG_DEVICE_ADDRESS_MAP(AS_0, _videoram_map) |
| 56 | 57 | |
| 57 | 58 | |
| 58 | 59 | #define MOS7360_INTERFACE(_name) \ |
| r17677 | r17678 | |
| 98 | 99 | |
| 99 | 100 | devcb_write_line m_out_irq_cb; |
| 100 | 101 | |
| 101 | | devcb_read8 m_in_ram_cb; |
| 102 | | devcb_read8 m_in_rom_cb; |
| 103 | 102 | devcb_read8 m_in_k_cb; |
| 104 | 103 | }; |
| 105 | 104 | |
| r17677 | r17678 | |
| 107 | 106 | // ======================> mos7360_device |
| 108 | 107 | |
| 109 | 108 | class mos7360_device : public device_t, |
| 109 | public device_memory_interface, |
| 110 | 110 | public device_sound_interface, |
| 111 | 111 | public mos7360_interface |
| 112 | 112 | { |
| r17677 | r17678 | |
| 115 | 115 | //mos7360_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); |
| 116 | 116 | mos7360_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 117 | 117 | |
| 118 | virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; |
| 119 | |
| 118 | 120 | DECLARE_READ8_MEMBER( read ); |
| 119 | 121 | DECLARE_WRITE8_MEMBER( write ); |
| 120 | 122 | |
| 123 | int cs0_r(offs_t offset); |
| 124 | int cs1_r(offs_t offset); |
| 125 | |
| 121 | 126 | UINT8 bus_r(); |
| 122 | 127 | |
| 123 | 128 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| r17677 | r17678 | |
| 153 | 158 | inline void set_interrupt(int mask); |
| 154 | 159 | inline void clear_interrupt(int mask); |
| 155 | 160 | inline int rastercolumn(); |
| 161 | inline UINT8 read_ram(offs_t offset); |
| 162 | inline UINT8 read_rom(offs_t offset); |
| 156 | 163 | |
| 157 | 164 | void initialize_palette(); |
| 158 | 165 | void draw_character(int ybegin, int yend, int ch, int yoff, int xoff, UINT16 *color); |
| r17677 | r17678 | |
| 163 | 170 | void drawlines(int first, int last); |
| 164 | 171 | void soundport_w(int offset, int data); |
| 165 | 172 | |
| 173 | const address_space_config m_videoram_space_config; |
| 174 | |
| 166 | 175 | devcb_resolved_write_line m_out_irq_func; |
| 167 | | devcb_resolved_read8 m_in_ram_func; |
| 168 | | devcb_resolved_read8 m_in_rom_func; |
| 169 | 176 | devcb_resolved_read8 m_in_k_func; |
| 170 | 177 | |
| 171 | 178 | screen_device *m_screen; // screen which sets bitmap properties |
trunk/src/mess/drivers/plus4.c
| r17677 | r17678 | |
| 139 | 139 | *keyport = F5; |
| 140 | 140 | *kernal = F6; |
| 141 | 141 | |
| 142 | | // the following logic is actually inside the TED |
| 143 | | |
| 144 | | *cs0 = 1; |
| 145 | | *cs1 = 1; |
| 146 | | |
| 147 | | if (m_rom_en) |
| 148 | | { |
| 149 | | if (offset >= 0x8000 && offset < 0xc000) |
| 150 | | { |
| 151 | | *cs0 = 0; |
| 152 | | *cs1 = 1; |
| 153 | | } |
| 154 | | else if ((offset >= 0xc000 && offset < 0xfd00) || (offset >= 0xff20)) |
| 155 | | { |
| 156 | | *cs0 = 1; |
| 157 | | *cs1 = 0; |
| 158 | | } |
| 159 | | } |
| 142 | *cs0 = m_ted->cs0_r(offset); |
| 143 | *cs1 = m_ted->cs1_r(offset); |
| 160 | 144 | } |
| 161 | 145 | |
| 162 | 146 | |
| r17677 | r17678 | |
| 169 | 153 | UINT8 data = m_ted->bus_r(); |
| 170 | 154 | int c1l = 1, c1h = 1, c2l = 1, c2h = 1; |
| 171 | 155 | |
| 172 | | //logerror("offset %04x user %u 6551 %u addr_clk %u keyport %u kernal %u cs0 %u cs1 %u m_rom_en %u\n", offset,user,_6551,addr_clk,keyport,kernal,cs0,cs1,m_rom_en); |
| 156 | //logerror("offset %04x user %u 6551 %u addr_clk %u keyport %u kernal %u cs0 %u cs1 %u\n", offset,user,_6551,addr_clk,keyport,kernal,cs0,cs1); |
| 173 | 157 | |
| 174 | 158 | if (!scs && m_t6721) |
| 175 | 159 | { |
| r17677 | r17678 | |
| 298 | 282 | |
| 299 | 283 | bankswitch(offset, phi0, mux, ras, &scs, &phi2, &user, &_6551, &addr_clk, &keyport, &kernal, &cs0, &cs1); |
| 300 | 284 | |
| 301 | | //logerror("write offset %04x data %02x user %u 6551 %u addr_clk %u keyport %u kernal %u cs0 %u cs1 %u m_rom_en %u\n", offset,data,user,_6551,addr_clk,keyport,kernal,cs0,cs1,m_rom_en); |
| 285 | //logerror("write offset %04x data %02x user %u 6551 %u addr_clk %u keyport %u kernal %u cs0 %u cs1 %u\n", offset,data,user,_6551,addr_clk,keyport,kernal,cs0,cs1); |
| 302 | 286 | |
| 303 | 287 | if (!scs && m_t6721) |
| 304 | 288 | { |
| r17677 | r17678 | |
| 326 | 310 | } |
| 327 | 311 | else if (offset == 0xff3e) |
| 328 | 312 | { |
| 329 | | m_rom_en = 1; |
| 330 | | |
| 331 | | m_ted->rom_switch_w(m_rom_en); |
| 313 | m_ted->rom_switch_w(1); |
| 332 | 314 | } |
| 333 | 315 | else if (offset == 0xff3f) |
| 334 | 316 | { |
| 335 | | m_rom_en = 0; |
| 336 | | |
| 337 | | m_ted->rom_switch_w(m_rom_en); |
| 317 | m_ted->rom_switch_w(0); |
| 338 | 318 | } |
| 339 | 319 | else if (offset < 0xfd00 || offset >= 0xff20) |
| 340 | 320 | { |
| r17677 | r17678 | |
| 345 | 325 | } |
| 346 | 326 | |
| 347 | 327 | |
| 328 | //------------------------------------------------- |
| 329 | // ted_videoram_r - |
| 330 | //------------------------------------------------- |
| 348 | 331 | |
| 332 | READ8_MEMBER( plus4_state::ted_videoram_r ) |
| 333 | { |
| 334 | int phi0 = 1, mux = 0, ras = 1, ba = 0; |
| 335 | int scs, phi2, user, _6551, addr_clk, keyport, kernal, cs0, cs1; |
| 336 | |
| 337 | bankswitch(offset, phi0, mux, ras, &scs, &phi2, &user, &_6551, &addr_clk, &keyport, &kernal, &cs0, &cs1); |
| 338 | |
| 339 | return read_memory(space, offset, ba, scs, phi2, user, _6551, addr_clk, keyport, kernal, cs0, cs1); |
| 340 | } |
| 341 | |
| 342 | |
| 343 | |
| 349 | 344 | //************************************************************************** |
| 350 | 345 | // ADDRESS MAPS |
| 351 | 346 | //************************************************************************** |
| r17677 | r17678 | |
| 359 | 354 | ADDRESS_MAP_END |
| 360 | 355 | |
| 361 | 356 | |
| 357 | //------------------------------------------------- |
| 358 | // ADDRESS_MAP( ted_videoram_map ) |
| 359 | //------------------------------------------------- |
| 362 | 360 | |
| 361 | static ADDRESS_MAP_START( ted_videoram_map, AS_0, 8, plus4_state ) |
| 362 | AM_RANGE(0x0000, 0xffff) AM_READ(ted_videoram_r) |
| 363 | ADDRESS_MAP_END |
| 364 | |
| 365 | |
| 366 | |
| 363 | 367 | //************************************************************************** |
| 364 | 368 | // INPUT PORTS |
| 365 | 369 | //************************************************************************** |
| r17677 | r17678 | |
| 637 | 641 | check_interrupts(); |
| 638 | 642 | } |
| 639 | 643 | |
| 640 | | READ8_MEMBER( plus4_state::ted_ram_r ) |
| 641 | | { |
| 642 | | int phi0 = 1, mux = 0, ras = 1, ba = 0; |
| 643 | | int scs, phi2, user, _6551, addr_clk, keyport, kernal, cs0, cs1; |
| 644 | | |
| 645 | | bankswitch(offset, phi0, mux, ras, &scs, &phi2, &user, &_6551, &addr_clk, &keyport, &kernal, &cs0, &cs1); |
| 646 | | |
| 647 | | return read_memory(space, offset, ba, scs, phi2, user, _6551, addr_clk, keyport, kernal, 1, 1); |
| 648 | | } |
| 649 | | |
| 650 | | READ8_MEMBER( plus4_state::ted_rom_r ) |
| 651 | | { |
| 652 | | int phi0 = 1, mux = 0, ras = 1, ba = 0; |
| 653 | | int scs, phi2, user, _6551, addr_clk, keyport, kernal, cs0, cs1; |
| 654 | | |
| 655 | | bankswitch(offset, phi0, mux, ras, &scs, &phi2, &user, &_6551, &addr_clk, &keyport, &kernal, &cs0, &cs1); |
| 656 | | |
| 657 | | return read_memory(space, offset, ba, scs, phi2, user, _6551, addr_clk, keyport, kernal, cs0, cs1); |
| 658 | | } |
| 659 | | |
| 660 | 644 | READ8_MEMBER( plus4_state::ted_k_r ) |
| 661 | 645 | { |
| 662 | 646 | UINT8 value = 0xff; |
| r17677 | r17678 | |
| 685 | 669 | SCREEN_TAG, |
| 686 | 670 | MOS7501_TAG, |
| 687 | 671 | DEVCB_DRIVER_LINE_MEMBER(plus4_state, ted_irq_w), |
| 688 | | DEVCB_DRIVER_MEMBER(plus4_state, ted_ram_r), |
| 689 | | DEVCB_DRIVER_MEMBER(plus4_state, ted_rom_r), |
| 690 | 672 | DEVCB_DRIVER_MEMBER(plus4_state, ted_k_r) |
| 691 | 673 | }; |
| 692 | 674 | |
| r17677 | r17678 | |
| 872 | 854 | |
| 873 | 855 | // state saving |
| 874 | 856 | save_item(NAME(m_addr)); |
| 875 | | save_item(NAME(m_rom_en)); |
| 876 | 857 | save_item(NAME(m_ted_irq)); |
| 877 | 858 | save_item(NAME(m_acia_irq)); |
| 878 | 859 | save_item(NAME(m_exp_irq)); |
| r17677 | r17678 | |
| 902 | 883 | } |
| 903 | 884 | |
| 904 | 885 | m_addr = 0; |
| 905 | | m_rom_en = 1; |
| 906 | 886 | |
| 907 | 887 | for (int i = 0; i < 10; i++) |
| 908 | 888 | { |
| r17677 | r17678 | |
| 931 | 911 | |
| 932 | 912 | // video and sound hardware |
| 933 | 913 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 934 | | MCFG_MOS7360_ADD(MOS7360_TAG, SCREEN_TAG, XTAL_14_31818MHz/4, ted_intf) |
| 914 | MCFG_MOS7360_ADD(MOS7360_TAG, SCREEN_TAG, XTAL_14_31818MHz/4, ted_intf, ted_videoram_map) |
| 935 | 915 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 936 | 916 | |
| 937 | 917 | // devices |
| r17677 | r17678 | |
| 970 | 950 | |
| 971 | 951 | // video and sound hardware |
| 972 | 952 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 973 | | MCFG_MOS7360_ADD(MOS7360_TAG, SCREEN_TAG, XTAL_17_73447MHz/5, ted_intf) |
| 953 | MCFG_MOS7360_ADD(MOS7360_TAG, SCREEN_TAG, XTAL_17_73447MHz/5, ted_intf, ted_videoram_map) |
| 974 | 954 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 975 | 955 | |
| 976 | 956 | // devices |