| Previous | 15994 Revisions | Next |
| r8715 Thursday 5th August, 2010 at 08:19:13 UTC by Miodrag Milanović |
|---|
| Sync with MAME (address map changes and driver state) and update of MESS to follow this changes. |
| [src/emu] | addrmap.c* addrmap.h* devcpu.c devcpu.h devimage.c devintrf.c devlegcy.c devlegcy.h dimemory.c dimemory.h emu.h emu.mak machine.c machine.h mconfig.h memory.c memory.h validity.c |
| [src/emu/cpu/cop400] | cop400.c |
| [src/emu/debug] | debugcmd.c |
| [src/mame/audio] | jaguar.c |
| [src/mame/drivers] | malzak.c megadriv.c |
| [src/mame/includes] | n64.h neogeo.h snes.h |
| [src/mame/machine] | amiga.c n64.c neoprot.c snes.c snes7110.c |
| [src/mame/video] | astrocde.c jaguar.c n64.c neogeo.c ppu2c0x.c rdpfetch.c rdpfrect.c rdpspn16.c rdptpipe.c rdptrect.c snes.c |
| [src/mess/audio] | mac.c |
| [src/mess/devices] | aescart.c |
| [src/mess/drivers] | 3do.c 4004clk.c abc80.c abc80x.c apexc.c apf.c apricot.c apricotf.c atarist.c atm.c atom.c bcs3.c beta.c bw12.c bw2.c c16.c c80.c camplynx.c cat.c cdi.c cfx9850.c cgc7900.c comx35.c comxpl80.c cosmicos.c craft.c crvision.c e01.c ec65.c einstein.c elf.c elwro800.c enterp.c eti660.c exp85.c fk1.c fmtowns.c gba.c huebler.c jtc.c kyocera.c lc80.c lx800.c mac.c mc10.c mc1000.c micronic.c mikromik.c mod8.c mpf1.c mtx.c mz700.c nakajies.c nes.c newbrain.c ng_aes.c ngp.c osi.c pasogo.c pc8001.c pc8401a.c pentagon.c phc25.c poly880.c prof80.c pv1000.c pv2000.c px4.c px8.c ql.c qx10.c samcoupe.c scorpion.c scv.c sg1000.c snes.c sord.c spec128.c specpls3.c spectrum.c studio2.c supracan.c tandy2k.c ti89.c tiki100.c timex.c tmc1800.c tmc2000e.c tmc600.c trs80m2.c v1050.c vboy.c vcs80.c vg5k.c vic20.c victor9k.c vidbrain.c vii.c vip.c vtech1.c x07.c xerox820.c xor100.c z9001.c |
| [src/mess/formats] | spec_snqk.c |
| [src/mess/includes] | 3do.h abc80.h abc80x.h advision.h aim65_40.h at.h atarist.h atom.h b2m.h beta.h bw12.h bw2.h c16.h c80.h cbmb.h cgc7900.h coco.h comx35.h cosmicos.h crvision.h e01.h einstein.h elf.h eti660.h exp85.h fmtowns.h gba.h huebler.h jtc.h kyocera.h lc80.h mac.h mc1000.h micronic.h mikromik.h mpf1.h mtx.h mz700.h nes.h newbrain.h osi.h pc.h pc8001.h pc8401a.h pc8801.h pecom.h pet.h phc25.h poly880.h prof80.h px8.h ql.h samcoupe.h sg1000.h spectrum.h studio2.h tandy2k.h tiki100.h tmc1800.h tmc2000e.h tmc600.h trs80m2.h v1050.h vcs80.h vic20.h victor9k.h vidbrain.h vip.h xerox820.h xor100.h |
| [src/mess/machine] | 3do.c advision.c at.c b2m.c c16.c cbmb.c coco.c comx35.c einstein.c mac.c mtx.c mz700.c nes.c nes_ines.c nes_mmc.c nes_pcb.c nes_unif.c pc.c pc8801.c pecom.c pet.c samcoupe.c snescart.c |
| [src/mess/video] | abc80.c abc800.c abc802.c abc806.c advision.c atarist.c b2m.c cgc7900.c coco.c comx35.c fmtowns.c gba.c kyocera.c mz700.c nes.c newbrain.c osi.c pc8401a.c pecom.c samcoupe.c spectrum.c timex.c tmc1800.c tmc600.c v1050.c |
| r8714 | r8715 | |
|---|---|---|
| 183 | 183 | |
| 184 | 184 | void jaguar_dsp_suspend(running_machine *machine) |
| 185 | 185 | { |
| 186 | | |
| 186 | | |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
| 190 | 190 | void jaguar_dsp_resume(running_machine *machine) |
| 191 | 191 | { |
| 192 | | |
| 192 | | |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 |
| r8714 | r8715 | |
|---|---|---|
| 875 | 875 | |
| 876 | 876 | static void spc7110_init(running_machine* machine) |
| 877 | 877 | { |
| 878 | snes_state *state = | |
| 878 | snes_state *state = | |
| 879 | 879 | |
| 880 | 880 | snes_spc7110.r4801 = 0x00; |
| 881 | 881 | snes_spc7110.r4802 = 0x00; |
| r8714 | r8715 | |
|---|---|---|
| 727 | 727 | |
| 728 | 728 | READ32_DEVICE_HANDLER( n64_dp_reg_r ) |
| 729 | 729 | { |
| 730 | _n64_state *state = | |
| 730 | _n64_state *state = | |
| 731 | 731 | |
| 732 | 732 | switch (offset) |
| 733 | 733 | { |
| r8714 | r8715 | |
| 753 | 753 | |
| 754 | 754 | WRITE32_DEVICE_HANDLER( n64_dp_reg_w ) |
| 755 | 755 | { |
| 756 | _n64_state *state = | |
| 756 | _n64_state *state = | |
| 757 | 757 | |
| 758 | 758 | switch (offset) |
| 759 | 759 | { |
| r8714 | r8715 | |
| 814 | 814 | |
| 815 | 815 | static void n64_vi_recalculate_resolution(running_machine *machine) |
| 816 | 816 | { |
| 817 | _n64_state *state = | |
| 817 | _n64_state *state = | |
| 818 | 818 | |
| 819 | 819 | int x_start = (n64_vi_hstart & 0x03ff0000) >> 16; |
| 820 | 820 | int x_end = n64_vi_hstart & 0x000003ff; |
| r8714 | r8715 | |
| 913 | 913 | |
| 914 | 914 | WRITE32_HANDLER( n64_vi_reg_w ) |
| 915 | 915 | { |
| 916 | _n64_state *state = | |
| 916 | _n64_state *state = | |
| 917 | 917 | |
| 918 | 918 | switch (offset) |
| 919 | 919 | { |
| r8714 | r8715 | |
|---|---|---|
| 56 | 56 | |
| 57 | 57 | static TIMER_CALLBACK( snes_nmi_tick ) |
| 58 | 58 | { |
| 59 | snes_state *state = | |
| 59 | snes_state *state = | |
| 60 | 60 | |
| 61 | 61 | // pull NMI |
| 62 | 62 | cpu_set_input_line(state->maincpu, G65816_LINE_NMI, ASSERT_LINE); |
| r8714 | r8715 | |
| 67 | 67 | |
| 68 | 68 | static void snes_hirq_tick( running_machine *machine ) |
| 69 | 69 | { |
| 70 | snes_state *state = | |
| 70 | snes_state *state = | |
| 71 | 71 | |
| 72 | 72 | // latch the counters and pull IRQ |
| 73 | 73 | // (don't need to switch to the 65816 context, we don't do anything dependant on it) |
| r8714 | r8715 | |
| 86 | 86 | |
| 87 | 87 | static TIMER_CALLBACK( snes_reset_oam_address ) |
| 88 | 88 | { |
| 89 | snes_state *state = | |
| 89 | snes_state *state = | |
| 90 | 90 | // make sure we're in the 65816's context since we're messing with the OAM and stuff |
| 91 | 91 | const address_space *space = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM); |
| 92 | 92 | |
| r8714 | r8715 | |
| 100 | 100 | |
| 101 | 101 | static TIMER_CALLBACK( snes_reset_hdma ) |
| 102 | 102 | { |
| 103 | snes_state *state = | |
| 103 | snes_state *state = | |
| 104 | 104 | const address_space *cpu0space = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM); |
| 105 | 105 | snes_hdma_init(cpu0space); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | static TIMER_CALLBACK( snes_update_io ) |
| 109 | 109 | { |
| 110 | snes_state *state = | |
| 110 | snes_state *state = | |
| 111 | 111 | const address_space *cpu0space = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM); |
| 112 | 112 | state->io_read(cpu0space->machine); |
| 113 | 113 | snes_ram[HVBJOY] &= 0xfe; /* Clear busy bit */ |
| r8714 | r8715 | |
| 117 | 117 | |
| 118 | 118 | static TIMER_CALLBACK( snes_scanline_tick ) |
| 119 | 119 | { |
| 120 | snes_state *state = | |
| 120 | snes_state *state = | |
| 121 | 121 | |
| 122 | 122 | /* Increase current line - we want to latch on this line during it, not after it */ |
| 123 | 123 | snes_ppu.beam.current_vert = machine->primary_screen->vpos(); |
| r8714 | r8715 | |
| 209 | 209 | /* This is called at the start of hblank *before* the scanline indicated in current_vert! */ |
| 210 | 210 | static TIMER_CALLBACK( snes_hblank_tick ) |
| 211 | 211 | { |
| 212 | snes_state *state = | |
| 212 | snes_state *state = | |
| 213 | 213 | const address_space *cpu0space = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM); |
| 214 | 214 | int nextscan; |
| 215 | 215 | |
| r8714 | r8715 | |
| 304 | 304 | /* read & write to DMA addresses are defined separately, to be called by snessdd1 handlers */ |
| 305 | 305 | static READ8_HANDLER( snes_io_dma_r ) |
| 306 | 306 | { |
| 307 | snes_state *state = | |
| 307 | snes_state *state = | |
| 308 | 308 | |
| 309 | 309 | switch (offset) |
| 310 | 310 | { |
| r8714 | r8715 | |
| 352 | 352 | |
| 353 | 353 | static WRITE8_HANDLER( snes_io_dma_w ) |
| 354 | 354 | { |
| 355 | snes_state *state = | |
| 355 | snes_state *state = | |
| 356 | 356 | |
| 357 | 357 | switch (offset) |
| 358 | 358 | { |
| r8714 | r8715 | |
| 418 | 418 | */ |
| 419 | 419 | READ8_HANDLER( snes_r_io ) |
| 420 | 420 | { |
| 421 | snes_state *state = | |
| 421 | snes_state *state = | |
| 422 | 422 | UINT8 value = 0; |
| 423 | 423 | |
| 424 | 424 | // PPU accesses are from 2100 to 213f |
| r8714 | r8715 | |
| 558 | 558 | */ |
| 559 | 559 | WRITE8_HANDLER( snes_w_io ) |
| 560 | 560 | { |
| 561 | snes_state *state = | |
| 561 | snes_state *state = | |
| 562 | 562 | |
| 563 | 563 | // PPU accesses are from 2100 to 213f |
| 564 | 564 | if (offset >= INIDISP && offset < APU00) |
| r8714 | r8715 | |
| 765 | 765 | |
| 766 | 766 | WRITE_LINE_DEVICE_HANDLER( snes_extern_irq_w ) |
| 767 | 767 | { |
| 768 | snes_state *driver_state = | |
| 768 | snes_state *driver_state = | |
| 769 | 769 | cpu_set_input_line(driver_state->maincpu, G65816_LINE_IRQ, state); |
| 770 | 770 | } |
| 771 | 771 | |
| r8714 | r8715 | |
| 909 | 909 | /* 0x000000 - 0x2fffff */ |
| 910 | 910 | READ8_HANDLER( snes_r_bank1 ) |
| 911 | 911 | { |
| 912 | snes_state *state = | |
| 912 | snes_state *state = | |
| 913 | 913 | UINT8 value = 0xff; |
| 914 | 914 | UINT16 address = offset & 0xffff; |
| 915 | 915 | |
| r8714 | r8715 | |
| 966 | 966 | /* 0x300000 - 0x3fffff */ |
| 967 | 967 | READ8_HANDLER( snes_r_bank2 ) |
| 968 | 968 | { |
| 969 | snes_state *state = | |
| 969 | snes_state *state = | |
| 970 | 970 | UINT8 value = 0xff; |
| 971 | 971 | UINT16 address = offset & 0xffff; |
| 972 | 972 | |
| r8714 | r8715 | |
| 1029 | 1029 | /* 0x400000 - 0x5fffff */ |
| 1030 | 1030 | READ8_HANDLER( snes_r_bank3 ) |
| 1031 | 1031 | { |
| 1032 | snes_state *state = | |
| 1032 | snes_state *state = | |
| 1033 | 1033 | UINT8 value = 0xff; |
| 1034 | 1034 | UINT16 address = offset & 0xffff; |
| 1035 | 1035 | |
| r8714 | r8715 | |
| 1070 | 1070 | /* 0x600000 - 0x6fffff */ |
| 1071 | 1071 | READ8_HANDLER( snes_r_bank4 ) |
| 1072 | 1072 | { |
| 1073 | snes_state *state = | |
| 1073 | snes_state *state = | |
| 1074 | 1074 | UINT8 value = 0xff; |
| 1075 | 1075 | UINT16 address = offset & 0xffff; |
| 1076 | 1076 | |
| r8714 | r8715 | |
| 1108 | 1108 | /* 0x700000 - 0x7dffff */ |
| 1109 | 1109 | READ8_HANDLER( snes_r_bank5 ) |
| 1110 | 1110 | { |
| 1111 | snes_state *state = | |
| 1111 | snes_state *state = | |
| 1112 | 1112 | UINT8 value; |
| 1113 | 1113 | UINT16 address = offset & 0xffff; |
| 1114 | 1114 | |
| r8714 | r8715 | |
| 1144 | 1144 | /* 0x800000 - 0xbfffff */ |
| 1145 | 1145 | READ8_HANDLER( snes_r_bank6 ) |
| 1146 | 1146 | { |
| 1147 | snes_state *state = | |
| 1147 | snes_state *state = | |
| 1148 | 1148 | UINT8 value = 0; |
| 1149 | 1149 | UINT16 address = offset & 0xffff; |
| 1150 | 1150 | |
| r8714 | r8715 | |
| 1192 | 1192 | /* 0xc00000 - 0xffffff */ |
| 1193 | 1193 | READ8_HANDLER( snes_r_bank7 ) |
| 1194 | 1194 | { |
| 1195 | snes_state *state = | |
| 1195 | snes_state *state = | |
| 1196 | 1196 | UINT8 value = 0; |
| 1197 | 1197 | UINT16 address = offset & 0xffff; |
| 1198 | 1198 | |
| r8714 | r8715 | |
| 1246 | 1246 | /* 0x000000 - 0x2fffff */ |
| 1247 | 1247 | WRITE8_HANDLER( snes_w_bank1 ) |
| 1248 | 1248 | { |
| 1249 | snes_state *state = | |
| 1249 | snes_state *state = | |
| 1250 | 1250 | UINT16 address = offset & 0xffff; |
| 1251 | 1251 | |
| 1252 | 1252 | if (address < 0x2000) /* Mirror of Low RAM */ |
| r8714 | r8715 | |
| 1297 | 1297 | /* 0x300000 - 0x3fffff */ |
| 1298 | 1298 | WRITE8_HANDLER( snes_w_bank2 ) |
| 1299 | 1299 | { |
| 1300 | snes_state *state = | |
| 1300 | snes_state *state = | |
| 1301 | 1301 | UINT16 address = offset & 0xffff; |
| 1302 | 1302 | |
| 1303 | 1303 | if (address < 0x2000) /* Mirror of Low RAM */ |
| r8714 | r8715 | |
| 1354 | 1354 | /* 0x600000 - 0x6fffff */ |
| 1355 | 1355 | WRITE8_HANDLER( snes_w_bank4 ) |
| 1356 | 1356 | { |
| 1357 | snes_state *state = | |
| 1357 | snes_state *state = | |
| 1358 | 1358 | UINT16 address = offset & 0xffff; |
| 1359 | 1359 | |
| 1360 | 1360 | if (state->has_addon_chip == HAS_SUPERFX) |
| r8714 | r8715 | |
| 1380 | 1380 | /* 0x700000 - 0x7dffff */ |
| 1381 | 1381 | WRITE8_HANDLER( snes_w_bank5 ) |
| 1382 | 1382 | { |
| 1383 | snes_state *state = | |
| 1383 | snes_state *state = | |
| 1384 | 1384 | UINT16 address = offset & 0xffff; |
| 1385 | 1385 | |
| 1386 | 1386 | if (state->has_addon_chip == HAS_SUPERFX) |
| r8714 | r8715 | |
| 1406 | 1406 | /* 0x800000 - 0xbfffff */ |
| 1407 | 1407 | WRITE8_HANDLER( snes_w_bank6 ) |
| 1408 | 1408 | { |
| 1409 | snes_state *state = | |
| 1409 | snes_state *state = | |
| 1410 | 1410 | UINT16 address = offset & 0xffff; |
| 1411 | 1411 | |
| 1412 | 1412 | if (state->has_addon_chip == HAS_SUPERFX) |
| r8714 | r8715 | |
| 1454 | 1454 | /* 0xc00000 - 0xffffff */ |
| 1455 | 1455 | WRITE8_HANDLER( snes_w_bank7 ) |
| 1456 | 1456 | { |
| 1457 | snes_state *state = | |
| 1457 | snes_state *state = | |
| 1458 | 1458 | UINT16 address = offset & 0xffff; |
| 1459 | 1459 | |
| 1460 | 1460 | if (state->has_addon_chip == HAS_SUPERFX) |
| r8714 | r8715 | |
| 1499 | 1499 | |
| 1500 | 1500 | static void nss_io_read( running_machine *machine ) |
| 1501 | 1501 | { |
| 1502 | snes_state *state = | |
| 1502 | snes_state *state = | |
| 1503 | 1503 | static const char *const portnames[2][4] = |
| 1504 | 1504 | { |
| 1505 | 1505 | { "SERIAL1_DATA1_L", "SERIAL1_DATA1_H", "SERIAL1_DATA2_L", "SERIAL1_DATA2_H" }, |
| r8714 | r8715 | |
| 1545 | 1545 | |
| 1546 | 1546 | static UINT8 nss_oldjoy1_read( running_machine *machine ) |
| 1547 | 1547 | { |
| 1548 | snes_state *state = | |
| 1548 | snes_state *state = | |
| 1549 | 1549 | UINT8 res; |
| 1550 | 1550 | |
| 1551 | 1551 | if (state->read_idx[0] >= 16) |
| r8714 | r8715 | |
| 1558 | 1558 | |
| 1559 | 1559 | static UINT8 nss_oldjoy2_read( running_machine *machine ) |
| 1560 | 1560 | { |
| 1561 | snes_state *state = | |
| 1561 | snes_state *state = | |
| 1562 | 1562 | UINT8 res; |
| 1563 | 1563 | |
| 1564 | 1564 | if (state->read_idx[1] >= 16) |
| r8714 | r8715 | |
| 1577 | 1577 | |
| 1578 | 1578 | static void snes_init_timers( running_machine *machine ) |
| 1579 | 1579 | { |
| 1580 | snes_state *state = | |
| 1580 | snes_state *state = | |
| 1581 | 1581 | |
| 1582 | 1582 | /* init timers and stop them */ |
| 1583 | 1583 | state->scanline_timer = timer_alloc(machine, snes_scanline_tick, NULL); |
| r8714 | r8715 | |
| 1603 | 1603 | |
| 1604 | 1604 | static void snes_init_ram( running_machine *machine ) |
| 1605 | 1605 | { |
| 1606 | snes_state *state = | |
| 1606 | snes_state *state = | |
| 1607 | 1607 | const address_space *cpu0space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1608 | 1608 | int i; |
| 1609 | 1609 | |
| r8714 | r8715 | |
| 1691 | 1691 | |
| 1692 | 1692 | MACHINE_START( snes ) |
| 1693 | 1693 | { |
| 1694 | snes_state *state = | |
| 1694 | snes_state *state = | |
| 1695 | 1695 | int i; |
| 1696 | 1696 | |
| 1697 | 1697 | memory_set_direct_update_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), snes_direct); |
| r8714 | r8715 | |
| 1796 | 1796 | |
| 1797 | 1797 | MACHINE_RESET( snes ) |
| 1798 | 1798 | { |
| 1799 | snes_state *state = | |
| 1799 | snes_state *state = | |
| 1800 | 1800 | int i; |
| 1801 | 1801 | |
| 1802 | 1802 | snes_init_ram(machine); |
| r8714 | r8715 | |
| 1835 | 1835 | /* for mame we use an init, maybe we will need more for the different games */ |
| 1836 | 1836 | DRIVER_INIT( snes ) |
| 1837 | 1837 | { |
| 1838 | snes_state *state = | |
| 1838 | snes_state *state = | |
| 1839 | 1839 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1840 | 1840 | UINT16 total_blocks, read_blocks; |
| 1841 | 1841 | UINT8 *rom; |
| r8714 | r8715 | |
| 1901 | 1901 | |
| 1902 | 1902 | DRIVER_INIT( snes_hirom ) |
| 1903 | 1903 | { |
| 1904 | snes_state *state = | |
| 1904 | snes_state *state = | |
| 1905 | 1905 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1906 | 1906 | UINT16 total_blocks, read_blocks; |
| 1907 | 1907 | UINT8 *rom; |
| r8714 | r8715 | |
| 1986 | 1986 | |
| 1987 | 1987 | INLINE void snes_dma_transfer( const address_space *space, UINT8 dma, UINT32 abus, UINT16 bbus ) |
| 1988 | 1988 | { |
| 1989 | snes_state *state = | |
| 1989 | snes_state *state = | |
| 1990 | 1990 | |
| 1991 | 1991 | /* every byte transfer takes 8 master cycles */ |
| 1992 | 1992 | cpu_adjust_icount(space->cpu,-8); |
| r8714 | r8715 | |
| 2030 | 2030 | check again if the transfer is direct/indirect at each step... is it worth? */ |
| 2031 | 2031 | INLINE UINT32 snes_get_hdma_addr( running_machine *machine, int dma ) |
| 2032 | 2032 | { |
| 2033 | snes_state *state = | |
| 2033 | snes_state *state = | |
| 2034 | 2034 | return (state->dma_channel[dma].bank << 16) | (state->dma_channel[dma].hdma_addr++); |
| 2035 | 2035 | } |
| 2036 | 2036 | |
| 2037 | 2037 | INLINE UINT32 snes_get_hdma_iaddr( running_machine *machine, int dma ) |
| 2038 | 2038 | { |
| 2039 | snes_state *state = | |
| 2039 | snes_state *state = | |
| 2040 | 2040 | return (state->dma_channel[dma].ibank << 16) | (state->dma_channel[dma].trans_size++); |
| 2041 | 2041 | } |
| 2042 | 2042 | |
| 2043 | 2043 | INLINE int is_last_active_channel( running_machine *machine, int dma ) |
| 2044 | 2044 | { |
| 2045 | snes_state *state = | |
| 2045 | snes_state *state = | |
| 2046 | 2046 | int i; |
| 2047 | 2047 | |
| 2048 | 2048 | for (i = dma + 1; i < 8; i++) |
| r8714 | r8715 | |
| 2057 | 2057 | |
| 2058 | 2058 | static void snes_hdma_update( const address_space *space, int dma ) |
| 2059 | 2059 | { |
| 2060 | snes_state *state = | |
| 2060 | snes_state *state = | |
| 2061 | 2061 | UINT32 abus = snes_get_hdma_addr(space->machine, dma); |
| 2062 | 2062 | |
| 2063 | 2063 | state->dma_channel[dma].hdma_line_counter = snes_abus_read(space, abus); |
| r8714 | r8715 | |
| 2088 | 2088 | |
| 2089 | 2089 | static void snes_hdma_init( const address_space *space ) |
| 2090 | 2090 | { |
| 2091 | snes_state *state = | |
| 2091 | snes_state *state = | |
| 2092 | 2092 | int i; |
| 2093 | 2093 | |
| 2094 | 2094 | state->hdmaen = snes_ram[HDMAEN]; |
| r8714 | r8715 | |
| 2104 | 2104 | |
| 2105 | 2105 | static void snes_hdma( const address_space *space ) |
| 2106 | 2106 | { |
| 2107 | snes_state *state = | |
| 2107 | snes_state *state = | |
| 2108 | 2108 | UINT16 bbus; |
| 2109 | 2109 | UINT32 abus; |
| 2110 | 2110 | int i; |
| r8714 | r8715 | |
| 2188 | 2188 | |
| 2189 | 2189 | static void snes_dma( const address_space *space, UINT8 channels ) |
| 2190 | 2190 | { |
| 2191 | snes_state *state = | |
| 2191 | snes_state *state = | |
| 2192 | 2192 | int i; |
| 2193 | 2193 | INT8 increment; |
| 2194 | 2194 | UINT16 bbus; |
| r8714 | r8715 | |
|---|---|---|
| 1451 | 1451 | CUSTOM_REG(offset) = data; |
| 1452 | 1452 | |
| 1453 | 1453 | if ( temp & 0x8000 ) /* if we're generating irq's, delay a bit */ |
| 1454 | timer_adjust_oneshot( amiga_irq_timer, | |
| 1454 | timer_adjust_oneshot( amiga_irq_timer, | |
| 1455 | 1455 | else /* if we're clearing irq's, process right away */ |
| 1456 | 1456 | update_irqs(space->machine); |
| 1457 | 1457 | break; |
| r8714 | r8715 | |
|---|---|---|
| 24 | 24 | |
| 25 | 25 | static READ16_HANDLER( fatfury2_protection_16_r ) |
| 26 | 26 | { |
| 27 | neogeo_state *state = | |
| 27 | neogeo_state *state = | |
| 28 | 28 | UINT16 res = state->fatfury2_prot_data >> 24; |
| 29 | 29 | |
| 30 | 30 | switch (offset) |
| r8714 | r8715 | |
| 50 | 50 | |
| 51 | 51 | static WRITE16_HANDLER( fatfury2_protection_16_w ) |
| 52 | 52 | { |
| 53 | neogeo_state *state = | |
| 53 | neogeo_state *state = | |
| 54 | 54 | |
| 55 | 55 | switch (offset) |
| 56 | 56 | { |
| r8714 | r8715 | |
| 97 | 97 | |
| 98 | 98 | void fatfury2_install_protection( running_machine *machine ) |
| 99 | 99 | { |
| 100 | neogeo_state *state = | |
| 100 | neogeo_state *state = | |
| 101 | 101 | |
| 102 | 102 | /* the protection involves reading and writing addresses in the */ |
| 103 | 103 | /* 0x2xxxxx range. There are several checks all around the code. */ |
| r8714 | r8715 | |
| 375 | 375 | |
| 376 | 376 | static READ16_HANDLER( sma_random_r ) |
| 377 | 377 | { |
| 378 | neogeo_state *state = | |
| 378 | neogeo_state *state = | |
| 379 | 379 | UINT16 old = state->neogeo_rng; |
| 380 | 380 | |
| 381 | 381 | UINT16 newbit = ((state->neogeo_rng >> 2) ^ |
| r8714 | r8715 | |
| 395 | 395 | |
| 396 | 396 | void neogeo_reset_rng( running_machine *machine ) |
| 397 | 397 | { |
| 398 | neogeo_state *state = | |
| 398 | neogeo_state *state = | |
| 399 | 399 | state->neogeo_rng = 0x2345; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | |
| 403 | 403 | static void sma_install_random_read_handler( running_machine *machine, int addr1, int addr2 ) |
| 404 | 404 | { |
| 405 | neogeo_state *state = | |
| 405 | neogeo_state *state = | |
| 406 | 406 | state_save_register_global(machine, state->neogeo_rng); |
| 407 | 407 | |
| 408 | 408 | memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), addr1, addr1 + 1, 0, 0, sma_random_r); |
| r8714 | r8715 | |
| 462 | 462 | |
| 463 | 463 | static void pvc_w8( running_machine *machine, offs_t offset, UINT8 data ) |
| 464 | 464 | { |
| 465 | neogeo_state *state = | |
| 465 | neogeo_state *state = | |
| 466 | 466 | *(((UINT8*)state->pvc_cartridge_ram) + BYTE_XOR_LE(offset)) = data; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | |
| 470 | 470 | static UINT8 pvc_r8( running_machine *machine, offs_t offset ) |
| 471 | 471 | { |
| 472 | neogeo_state *state = | |
| 472 | neogeo_state *state = | |
| 473 | 473 | return *(((UINT8*)state->pvc_cartridge_ram) + BYTE_XOR_LE(offset)); |
| 474 | 474 | } |
| 475 | 475 | |
| r8714 | r8715 | |
| 502 | 502 | |
| 503 | 503 | static void pvc_write_bankswitch( const address_space *space ) |
| 504 | 504 | { |
| 505 | neogeo_state *state = | |
| 505 | neogeo_state *state = | |
| 506 | 506 | UINT32 bankaddress; |
| 507 | 507 | |
| 508 | 508 | bankaddress = ((state->pvc_cartridge_ram[0xff8] >> 8)|(state->pvc_cartridge_ram[0xff9] << 8)); |
| r8714 | r8715 | |
| 515 | 515 | |
| 516 | 516 | static READ16_HANDLER( pvc_prot_r ) |
| 517 | 517 | { |
| 518 | neogeo_state *state = | |
| 518 | neogeo_state *state = | |
| 519 | 519 | return state->pvc_cartridge_ram[offset]; |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
| 523 | 523 | static WRITE16_HANDLER( pvc_prot_w ) |
| 524 | 524 | { |
| 525 | neogeo_state *state = | |
| 525 | neogeo_state *state = | |
| 526 | 526 | |
| 527 | 527 | COMBINE_DATA(&state->pvc_cartridge_ram[offset] ); |
| 528 | 528 | if (offset == 0xff0) |
| r8714 | r8715 | |
| 536 | 536 | |
| 537 | 537 | void install_pvc_protection( running_machine *machine ) |
| 538 | 538 | { |
| 539 | neogeo_state *state = | |
| 539 | neogeo_state *state = | |
| 540 | 540 | state->pvc_cartridge_ram = auto_alloc_array(machine, UINT16, 0x2000 / 2); |
| 541 | 541 | state_save_register_global_pointer(machine, state->pvc_cartridge_ram, 0x2000 / 2); |
| 542 | 542 |
| r8714 | r8715 | |
|---|---|---|
| 395 | 395 | typedef void (*snes_io_read)(running_machine *machine); |
| 396 | 396 | typedef UINT8 (*snes_oldjoy_read)(running_machine *machine); |
| 397 | 397 | |
| 398 | class snes_state | |
| 398 | class snes_state : public driver_data_t | |
| 399 | 399 | { |
| 400 | 400 | public: |
| 401 | static | |
| 401 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, snes_state(machine)); } | |
| 402 | 402 | |
| 403 | snes_state(running_machine &machine) { } | |
| 403 | snes_state(running_machine &machine) | |
| 404 | : driver_data_t(machine) { } | |
| 404 | 405 | |
| 405 | 406 | /* misc */ |
| 406 | 407 | UINT16 htmult; /* in 512 wide, we run HTOTAL double and halve it on latching */ |
| r8714 | r8715 | |
|---|---|---|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | |
| 31 | class neogeo_state | |
| 31 | class neogeo_state : public driver_data_t | |
| 32 | 32 | { |
| 33 | 33 | public: |
| 34 | static | |
| 34 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, neogeo_state(machine)); } | |
| 35 | 35 | |
| 36 | neogeo_state(running_machine &machine) { } | |
| 36 | neogeo_state(running_machine &machine) | |
| 37 | : driver_data_t(machine) { } | |
| 37 | 38 | |
| 38 | 39 | /* memory pointers */ |
| 39 | 40 | // UINT8 *memcard_data; // this currently uses generic handlers |
| r8714 | r8715 | |
|---|---|---|
| 6 | 6 | |
| 7 | 7 | /*----------- driver state -----------*/ |
| 8 | 8 | |
| 9 | class _n64_state | |
| 9 | class _n64_state : public driver_data_t | |
| 10 | 10 | { |
| 11 | 11 | public: |
| 12 | static | |
| 12 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, _n64_state(machine)); } | |
| 13 | 13 | |
| 14 | _n64_state(running_machine &machine) { } | |
| 14 | _n64_state(running_machine &machine) | |
| 15 | : driver_data_t(machine) { } | |
| 15 | 16 | |
| 16 | 17 | /* video-related */ |
| 17 | 18 | N64::RDP::Processor m_rdp; |
| r8714 | r8715 | |
|---|---|---|
| 12 | 12 | |
| 13 | 13 | void Rectangle::SetMachine(running_machine* machine) |
| 14 | 14 | { |
| 15 | _n64_state *state = | |
| 15 | _n64_state *state = | |
| 16 | 16 | |
| 17 | 17 | m_machine = machine; |
| 18 | 18 | m_rdp = &state->m_rdp; |
| r8714 | r8715 | |
|---|---|---|
| 10 | 10 | |
| 11 | 11 | void TexFetch::SetMachine(running_machine *machine) |
| 12 | 12 | { |
| 13 | _n64_state *state = | |
| 13 | _n64_state *state = | |
| 14 | 14 | |
| 15 | 15 | m_machine = machine; |
| 16 | 16 | m_rdp = &state->m_rdp; |
| r8714 | r8715 | |
|---|---|---|
| 12 | 12 | |
| 13 | 13 | void TexturePipe::SetMachine(running_machine *machine) |
| 14 | 14 | { |
| 15 | _n64_state *state = | |
| 15 | _n64_state *state = | |
| 16 | 16 | |
| 17 | 17 | m_machine = machine; |
| 18 | 18 | m_rdp = &state->m_rdp; |
| r8714 | r8715 | |
|---|---|---|
| 1812 | 1812 | // utility function - latches the H/V counters. Used by IRQ, writes to WRIO, etc. |
| 1813 | 1813 | void snes_latch_counters( running_machine *machine ) |
| 1814 | 1814 | { |
| 1815 | snes_state *state = | |
| 1815 | snes_state *state = | |
| 1816 | 1816 | |
| 1817 | 1817 | snes_ppu.beam.current_horz = machine->primary_screen->hpos() / state->htmult; |
| 1818 | 1818 | snes_ppu.beam.latch_vert = machine->primary_screen->vpos(); |
| r8714 | r8715 | |
| 1825 | 1825 | |
| 1826 | 1826 | static void snes_dynamic_res_change( running_machine *machine ) |
| 1827 | 1827 | { |
| 1828 | snes_state *state = | |
| 1828 | snes_state *state = | |
| 1829 | 1829 | rectangle visarea = machine->primary_screen->visible_area(); |
| 1830 | 1830 | attoseconds_t refresh; |
| 1831 | 1831 | |
| r8714 | r8715 | |
| 1869 | 1869 | |
| 1870 | 1870 | INLINE UINT32 snes_get_vram_address( running_machine *machine ) |
| 1871 | 1871 | { |
| 1872 | snes_state *state = | |
| 1872 | snes_state *state = | |
| 1873 | 1873 | UINT32 addr = state->vmadd; |
| 1874 | 1874 | |
| 1875 | 1875 | if (state->vram_fgr_count) |
| r8714 | r8715 | |
| 2091 | 2091 | |
| 2092 | 2092 | READ8_HANDLER( snes_ppu_read ) |
| 2093 | 2093 | { |
| 2094 | snes_state *state = | |
| 2094 | snes_state *state = | |
| 2095 | 2095 | UINT8 value; |
| 2096 | 2096 | |
| 2097 | 2097 | switch (offset) |
| r8714 | r8715 | |
| 2239 | 2239 | |
| 2240 | 2240 | WRITE8_HANDLER( snes_ppu_write ) |
| 2241 | 2241 | { |
| 2242 | snes_state *state = | |
| 2242 | snes_state *state = | |
| 2243 | 2243 | |
| 2244 | 2244 | switch (offset) |
| 2245 | 2245 | { |
| r8714 | r8715 | |
|---|---|---|
| 309 | 309 | |
| 310 | 310 | void jaguar_gpu_suspend(running_machine *machine) |
| 311 | 311 | { |
| 312 | | |
| 312 | | |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | |
| 316 | 316 | void jaguar_gpu_resume(running_machine *machine) |
| 317 | 317 | { |
| 318 | | |
| 318 | | |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 |
| r8714 | r8715 | |
|---|---|---|
| 448 | 448 | else |
| 449 | 449 | { |
| 450 | 450 | cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, interrupt_vector & 0xf0); |
| 451 | timer_set(machine, cpu | |
| 451 | timer_set(machine, machine->device<cpu | |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /* latch the feedback registers */ |
| r8714 | r8715 | |
| 488 | 488 | else |
| 489 | 489 | { |
| 490 | 490 | cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, interrupt_vector); |
| 491 | timer_set(machine, cpu | |
| 491 | timer_set(machine, machine->device<cpu | |
| 492 | 492 | } |
| 493 | 493 | } |
| 494 | 494 |
| r8714 | r8715 | |
|---|---|---|
| 75 | 75 | |
| 76 | 76 | void Span::SetMachine(running_machine *machine) |
| 77 | 77 | { |
| 78 | _n64_state *state = | |
| 78 | _n64_state *state = | |
| 79 | 79 | |
| 80 | 80 | m_machine = machine; |
| 81 | 81 | m_rdp = &state->m_rdp; |
| r8714 | r8715 | |
|---|---|---|
| 12 | 12 | |
| 13 | 13 | void TexRectangle::SetMachine(running_machine* machine) |
| 14 | 14 | { |
| 15 | _n64_state *state = | |
| 15 | _n64_state *state = | |
| 16 | 16 | |
| 17 | 17 | m_machine = machine; |
| 18 | 18 | m_rdp = &state->m_rdp; |
| r8714 | r8715 | |
|---|---|---|
| 20 | 20 | |
| 21 | 21 | static void set_videoram_offset( running_machine *machine, UINT16 data ) |
| 22 | 22 | { |
| 23 | neogeo_state *state = | |
| 23 | neogeo_state *state = | |
| 24 | 24 | state->videoram_offset = data; |
| 25 | 25 | |
| 26 | 26 | /* the read happens right away */ |
| r8714 | r8715 | |
| 30 | 30 | |
| 31 | 31 | static UINT16 get_videoram_data( running_machine *machine ) |
| 32 | 32 | { |
| 33 | neogeo_state *state = | |
| 33 | neogeo_state *state = | |
| 34 | 34 | return state->videoram_read_buffer; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | static void set_videoram_data( running_machine *machine, UINT16 data) |
| 39 | 39 | { |
| 40 | neogeo_state *state = | |
| 40 | neogeo_state *state = | |
| 41 | 41 | state->videoram[state->videoram_offset] = data; |
| 42 | 42 | |
| 43 | 43 | /* auto increment/decrement the current offset - A15 is NOT effected */ |
| r8714 | r8715 | |
| 50 | 50 | |
| 51 | 51 | static void set_videoram_modulo( running_machine *machine, UINT16 data) |
| 52 | 52 | { |
| 53 | neogeo_state *state = | |
| 53 | neogeo_state *state = | |
| 54 | 54 | state->videoram_modulo = data; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | static UINT16 get_videoram_modulo( running_machine *machine ) |
| 59 | 59 | { |
| 60 | neogeo_state *state = | |
| 60 | neogeo_state *state = | |
| 61 | 61 | return state->videoram_modulo; |
| 62 | 62 | } |
| 63 | 63 | |
| r8714 | r8715 | |
| 71 | 71 | |
| 72 | 72 | static void compute_rgb_weights( running_machine *machine ) |
| 73 | 73 | { |
| 74 | neogeo_state *state = | |
| 74 | neogeo_state *state = | |
| 75 | 75 | static const int resistances[] = { 220, 470, 1000, 2200, 3900 }; |
| 76 | 76 | |
| 77 | 77 | /* compute four sets of weights - with or without the pulldowns - |
| r8714 | r8715 | |
| 101 | 101 | |
| 102 | 102 | static pen_t get_pen( running_machine *machine, UINT16 data ) |
| 103 | 103 | { |
| 104 | neogeo_state *state = | |
| 104 | neogeo_state *state = | |
| 105 | 105 | double *weights; |
| 106 | 106 | UINT8 r, g, b; |
| 107 | 107 | |
| r8714 | r8715 | |
| 147 | 147 | |
| 148 | 148 | static STATE_POSTLOAD( regenerate_pens ) |
| 149 | 149 | { |
| 150 | neogeo_state *state = | |
| 150 | neogeo_state *state = | |
| 151 | 151 | int i; |
| 152 | 152 | |
| 153 | 153 | for (i = 0; i < NUM_PENS; i++) |
| r8714 | r8715 | |
| 157 | 157 | |
| 158 | 158 | void neogeo_set_palette_bank( running_machine *machine, UINT8 data ) |
| 159 | 159 | { |
| 160 | neogeo_state *state = | |
| 160 | neogeo_state *state = | |
| 161 | 161 | if (data != state->palette_bank) |
| 162 | 162 | { |
| 163 | 163 | state->palette_bank = data; |
| r8714 | r8715 | |
| 169 | 169 | |
| 170 | 170 | void neogeo_set_screen_dark( running_machine *machine, UINT8 data ) |
| 171 | 171 | { |
| 172 | neogeo_state *state = | |
| 172 | neogeo_state *state = | |
| 173 | 173 | if (data != state->screen_dark) |
| 174 | 174 | { |
| 175 | 175 | state->screen_dark = data; |
| r8714 | r8715 | |
| 181 | 181 | |
| 182 | 182 | READ16_HANDLER( neogeo_paletteram_r ) |
| 183 | 183 | { |
| 184 | neogeo_state *state = | |
| 184 | neogeo_state *state = | |
| 185 | 185 | return state->palettes[state->palette_bank][offset]; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | WRITE16_HANDLER( neogeo_paletteram_w ) |
| 190 | 190 | { |
| 191 | neogeo_state *state = | |
| 191 | neogeo_state *state = | |
| 192 | 192 | UINT16 *addr = &state->palettes[state->palette_bank][offset]; |
| 193 | 193 | |
| 194 | 194 | COMBINE_DATA(addr); |
| r8714 | r8715 | |
| 206 | 206 | |
| 207 | 207 | static void set_auto_animation_speed( running_machine *machine, UINT8 data) |
| 208 | 208 | { |
| 209 | neogeo_state *state = | |
| 209 | neogeo_state *state = | |
| 210 | 210 | state->auto_animation_speed = data; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
| 214 | 214 | static void set_auto_animation_disabled( running_machine *machine, UINT8 data) |
| 215 | 215 | { |
| 216 | neogeo_state *state = | |
| 216 | neogeo_state *state = | |
| 217 | 217 | state->auto_animation_disabled = data; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | |
| 221 | 221 | UINT8 neogeo_get_auto_animation_counter( running_machine *machine ) |
| 222 | 222 | { |
| 223 | neogeo_state *state = | |
| 223 | neogeo_state *state = | |
| 224 | 224 | return state->auto_animation_counter; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | |
| 228 | 228 | static TIMER_CALLBACK( auto_animation_timer_callback ) |
| 229 | 229 | { |
| 230 | neogeo_state *state = | |
| 230 | neogeo_state *state = | |
| 231 | 231 | if (state->auto_animation_frame_counter == 0) |
| 232 | 232 | { |
| 233 | 233 | state->auto_animation_frame_counter = state->auto_animation_speed; |
| r8714 | r8715 | |
| 242 | 242 | |
| 243 | 243 | static void create_auto_animation_timer( running_machine *machine ) |
| 244 | 244 | { |
| 245 | neogeo_state *state = | |
| 245 | neogeo_state *state = | |
| 246 | 246 | state->auto_animation_timer = timer_alloc(machine, auto_animation_timer_callback, NULL); |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
| 250 | 250 | static void start_auto_animation_timer( running_machine *machine ) |
| 251 | 251 | { |
| 252 | neogeo_state *state = | |
| 252 | neogeo_state *state = | |
| 253 | 253 | timer_adjust_oneshot(state->auto_animation_timer, machine->primary_screen->time_until_pos(NEOGEO_VSSTART), 0); |
| 254 | 254 | } |
| 255 | 255 | |
| r8714 | r8715 | |
| 263 | 263 | |
| 264 | 264 | void neogeo_set_fixed_layer_source( running_machine *machine, UINT8 data ) |
| 265 | 265 | { |
| 266 | neogeo_state *state = | |
| 266 | neogeo_state *state = | |
| 267 | 267 | state->fixed_layer_source = data; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | |
| 271 | 271 | static void draw_fixed_layer( running_machine *machine, bitmap_t *bitmap, int scanline ) |
| 272 | 272 | { |
| 273 | neogeo_state *state = | |
| 273 | neogeo_state *state = | |
| 274 | 274 | int x; |
| 275 | 275 | |
| 276 | 276 | UINT8* gfx_base = memory_region(machine, state->fixed_layer_source ? "fixed" : "fixedbios"); |
| r8714 | r8715 | |
| 403 | 403 | |
| 404 | 404 | static void draw_sprites( running_machine *machine, bitmap_t *bitmap, int scanline ) |
| 405 | 405 | { |
| 406 | neogeo_state *state = | |
| 406 | neogeo_state *state = | |
| 407 | 407 | int sprite_index; |
| 408 | 408 | int max_sprite_index; |
| 409 | 409 | |
| r8714 | r8715 | |
| 592 | 592 | |
| 593 | 593 | static void parse_sprites( running_machine *machine, int scanline ) |
| 594 | 594 | { |
| 595 | neogeo_state *state = | |
| 595 | neogeo_state *state = | |
| 596 | 596 | UINT16 sprite_number; |
| 597 | 597 | int y = 0; |
| 598 | 598 | int rows = 0; |
| r8714 | r8715 | |
| 644 | 644 | |
| 645 | 645 | static TIMER_CALLBACK( sprite_line_timer_callback ) |
| 646 | 646 | { |
| 647 | neogeo_state *state = | |
| 647 | neogeo_state *state = | |
| 648 | 648 | int scanline = param; |
| 649 | 649 | |
| 650 | 650 | /* we are at the beginning of a scanline - |
| r8714 | r8715 | |
| 663 | 663 | |
| 664 | 664 | static void create_sprite_line_timer( running_machine *machine ) |
| 665 | 665 | { |
| 666 | neogeo_state *state = | |
| 666 | neogeo_state *state = | |
| 667 | 667 | state->sprite_line_timer = timer_alloc(machine, sprite_line_timer_callback, NULL); |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | |
| 671 | 671 | static void start_sprite_line_timer( running_machine *machine ) |
| 672 | 672 | { |
| 673 | neogeo_state *state = | |
| 673 | neogeo_state *state = | |
| 674 | 674 | timer_adjust_oneshot(state->sprite_line_timer, machine->primary_screen->time_until_pos(0), 0); |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | |
| 678 | 678 | static void optimize_sprite_data( running_machine *machine ) |
| 679 | 679 | { |
| 680 | neogeo_state *state = | |
| 680 | neogeo_state *state = | |
| 681 | 681 | |
| 682 | 682 | /* convert the sprite graphics data into a format that |
| 683 | 683 | allows faster blitting */ |
| r8714 | r8715 | |
| 849 | 849 | |
| 850 | 850 | VIDEO_START( neogeo ) |
| 851 | 851 | { |
| 852 | neogeo_state *state = | |
| 852 | neogeo_state *state = | |
| 853 | 853 | |
| 854 | 854 | /* allocate memory not directly mapped */ |
| 855 | 855 | state->palettes[0] = auto_alloc_array(machine, UINT16, NUM_PENS); |
| r8714 | r8715 | |
| 921 | 921 | |
| 922 | 922 | VIDEO_UPDATE( neogeo ) |
| 923 | 923 | { |
| 924 | neogeo_state *state = | |
| 924 | neogeo_state *state = | |
| 925 | 925 | |
| 926 | 926 | /* fill with background color first */ |
| 927 | 927 | bitmap_fill(bitmap, cliprect, state->pens[0x0fff]); |
| r8714 | r8715 | |
|---|---|---|
| 867 | 867 | // a game can read the high bit of $2002 before the NMI is called (potentially resetting the bit |
| 868 | 868 | // via a read from $2002 in the NMI handler). |
| 869 | 869 | // B-Wings is an example game that needs this. |
| 870 | timer_adjust_oneshot(ppu2c0x->nmi_timer, | |
| 870 | timer_adjust_oneshot(ppu2c0x->nmi_timer, | |
| 871 | 871 | } |
| 872 | 872 | } |
| 873 | 873 | |
| r8714 | r8715 | |
| 895 | 895 | next_scanline = 0; |
| 896 | 896 | |
| 897 | 897 | // Call us back when the hblank starts for this scanline |
| 898 | timer_adjust_oneshot(ppu2c0x->hblank_timer, | |
| 898 | timer_adjust_oneshot(ppu2c0x->hblank_timer, | |
| 899 | 899 | |
| 900 | 900 | // trigger again at the start of the next scanline |
| 901 | 901 | timer_adjust_oneshot(ppu2c0x->scanline_timer, device->machine->primary_screen->time_until_pos(next_scanline * ppu2c0x->scan_scale), 0); |
| r8714 | r8715 | |
| 1305 | 1305 | timer_adjust_oneshot(ppu2c0x->scanline_timer, device->machine->primary_screen->time_until_pos(1), 0); |
| 1306 | 1306 | |
| 1307 | 1307 | ppu2c0x->hblank_timer = timer_alloc(device->machine, hblank_callback, (void *) device); |
| 1308 | timer_adjust_oneshot(ppu2c0x->hblank_timer, | |
| 1308 | timer_adjust_oneshot(ppu2c0x->hblank_timer, | |
| 1309 | 1309 | |
| 1310 | 1310 | ppu2c0x->nmi_timer = timer_alloc(device->machine, nmi_callback, (void *) device); |
| 1311 | 1311 | timer_adjust_oneshot(ppu2c0x->nmi_timer, attotime_never, 0); |
| r8714 | r8715 | |
|---|---|---|
| 1177 | 1177 | void N64::RDP::Triangle::InitFromData(running_machine *machine, bool shade, bool texture, bool zbuffer) |
| 1178 | 1178 | { |
| 1179 | 1179 | m_machine = machine; |
| 1180 | m_rdp = &( | |
| 1180 | m_rdp = &( | |
| 1181 | 1181 | m_cmd_data = m_rdp->GetCommandData(); |
| 1182 | 1182 | m_misc_state = m_rdp->GetMiscState(); |
| 1183 | 1183 | m_shade = shade; |
| r8714 | r8715 | |
| 2503 | 2503 | |
| 2504 | 2504 | VIDEO_START(n64) |
| 2505 | 2505 | { |
| 2506 | _n64_state *state = | |
| 2506 | _n64_state *state = | |
| 2507 | 2507 | |
| 2508 | 2508 | state->m_rdp.SetMachine(machine); |
| 2509 | 2509 | state->m_rdp.InitInternalState(); |
| r8714 | r8715 | |
| 2526 | 2526 | |
| 2527 | 2527 | VIDEO_UPDATE(n64) |
| 2528 | 2528 | { |
| 2529 | _n64_state *state = | |
| 2529 | _n64_state *state = | |
| 2530 | 2530 | |
| 2531 | 2531 | int height = state->m_rdp.GetMiscState()->m_fb_height; |
| 2532 | 2532 | //UINT16 *frame_buffer = (UINT16*)&rdram[(n64_vi_origin & 0xffffff) >> 2]; |
| r8714 | r8715 | |
|---|---|---|
| 409 | 409 | MDRV_SCREEN_REFRESH_RATE(50) |
| 410 | 410 | //MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(SAA5050_VBLANK)) |
| 411 | 411 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 412 | MDRV_SCREEN_SIZE(240, 256) /* vert size is a guess */ | |
| 413 | MDRV_SCREEN_VISIBLE_AREA(0, 239, 0, 239) | |
| 412 | MDRV_SCREEN_SIZE(480, 512) /* vert size is a guess */ | |
| 413 | MDRV_SCREEN_VISIBLE_AREA(0, 479, 0, 511) | |
| 414 | 414 | |
| 415 | 415 | MDRV_GFXDECODE(malzak) |
| 416 | 416 | MDRV_PALETTE_LENGTH(128) |
| r8714 | r8715 | |
|---|---|---|
| 2004 | 2004 | if (((megadrive_io_data_regs[portnum]&0x40)==0x00) && ((data&0x40) == 0x40)) |
| 2005 | 2005 | { |
| 2006 | 2006 | io_stage[portnum]++; |
| 2007 | timer_adjust_oneshot(io_timeout[portnum], cpu | |
| 2007 | timer_adjust_oneshot(io_timeout[portnum], machine->device<cpu | |
| 2008 | 2008 | } |
| 2009 | 2009 | |
| 2010 | 2010 | } |
| r8714 | r8715 | |
| 2211 | 2211 | if ( genz80.z80_is_reset ) |
| 2212 | 2212 | { |
| 2213 | 2213 | devtag_reset( machine, "genesis_snd_z80" ); |
| 2214 | | |
| 2214 | | |
| 2215 | 2215 | devtag_reset( machine, "ymsnd" ); |
| 2216 | 2216 | } |
| 2217 | 2217 | else |
| r8714 | r8715 | |
| 2219 | 2219 | /* Check if z80 has the bus */ |
| 2220 | 2220 | if ( genz80.z80_has_bus ) |
| 2221 | 2221 | { |
| 2222 | cpu | |
| 2222 | machine->device<cpu | |
| 2223 | 2223 | } |
| 2224 | 2224 | else |
| 2225 | 2225 | { |
| 2226 | | |
| 2226 | | |
| 2227 | 2227 | } |
| 2228 | 2228 | } |
| 2229 | 2229 | } |
| r8714 | r8715 | |
| 3964 | 3964 | /* reference */ |
| 3965 | 3965 | |
| 3966 | 3966 | // time_elapsed_since_crap = frame_timer->time_elapsed(); |
| 3967 | // xxx = | |
| 3967 | // xxx = | |
| 3968 | 3968 | // mame_printf_debug("update cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.attoseconds>>32),(UINT32)(time_elapsed_since_crap.attoseconds&0xffffffff)); |
| 3969 | 3969 | |
| 3970 | 3970 | return 0; |
| r8714 | r8715 | |
| 6145 | 6145 | frametime = ATTOSECONDS_PER_SECOND/megadriv_framerate; |
| 6146 | 6146 | |
| 6147 | 6147 | //time_elapsed_since_crap = frame_timer->time_elapsed(); |
| 6148 | //xxx = cpu | |
| 6148 | //xxx = machine->device<cpudevice>("maincpu")->attotime_to_cy | |
| 6149 | 6149 | //mame_printf_debug("---------- cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.attoseconds>>32),(UINT32)(time_elapsed_since_crap.attoseconds&0xffffffff)); |
| 6150 | 6150 | //mame_printf_debug("---------- framet %d, %08x %08x\n",xxx, (UINT32)(frametime>>32),(UINT32)(frametime&0xffffffff)); |
| 6151 | 6151 | frame_timer->adjust(attotime_zero); |
| r8714 | r8715 | |
|---|---|---|
| 1712 | 1712 | { |
| 1713 | 1713 | offset = 0; |
| 1714 | 1714 | length = space->bytemask + 1; |
| 1715 | for (entry = space->map->entrylist; entry != NULL; entry = entry->next) | |
| 1715 | for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next) | |
| 1716 | 1716 | { |
| 1717 | cheat_region[region_count].offset = memory_address_to_byte(space, entry->addrstart) & space->bytemask; | |
| 1718 | cheat_region[region_count].endoffset = memory_address_to_byte(space, entry->addrend) & space->bytemask; | |
| 1719 | cheat_region[region_count].share = entry->share; | |
| 1720 | cheat_region[region_count].disabled = (entry->write.type == AMH_RAM) ? FALSE : TRUE; | |
| 1717 | cheat_region[region_count].offset = memory_address_to_byte(space, entry->m_addrstart) & space->bytemask; | |
| 1718 | cheat_region[region_count].endoffset = memory_address_to_byte(space, entry->m_addrend) & space->bytemask; | |
| 1719 | cheat_region[region_count].share = entry->m_share; | |
| 1720 | cheat_region[region_count].disabled = (entry->m_write.type == AMH_RAM) ? FALSE : TRUE; | |
| 1721 | 1721 | |
| 1722 | 1722 | /* disable double share regions */ |
| 1723 | if (entry->share != NULL) | |
| 1723 | if (entry->m_share != NULL) | |
| 1724 | 1724 | for (i = 0; i < region_count; i++) |
| 1725 | 1725 | if (cheat_region[i].share != NULL) |
| 1726 | if (strcmp(cheat_region[i].share, entry->share)==0) | |
| 1726 | if (strcmp(cheat_region[i].share, entry->m_share)==0) | |
| 1727 | 1727 | cheat_region[region_count].disabled = TRUE; |
| 1728 | 1728 | |
| 1729 | 1729 | region_count++; |
| r8714 | r8715 | |
|---|---|---|
| 1258 | 1258 | AM_RANGE(0x00, 0x7f) AM_RAM |
| 1259 | 1259 | ADDRESS_MAP_END |
| 1260 | 1260 | |
| 1261 | #ifdef UNUSED_CODE | |
| 1261 | 1262 | static ADDRESS_MAP_START( data_160b, ADDRESS_SPACE_DATA, 8 ) |
| 1262 | 1263 | AM_RANGE(0x00, 0x9f) AM_RAM |
| 1263 | 1264 | ADDRESS_MAP_END |
| 1265 | #endif | |
| 1264 | 1266 | |
| 1265 | 1267 | /*************************************************************************** |
| 1266 | 1268 | VALIDITY CHECKS |
| r8714 | r8715 | |
|---|---|---|
| 711 | 711 | |
| 712 | 712 | device_t::~device_t() |
| 713 | 713 | { |
| 714 | auto_free(&m_machine, m_debug); | |
| 714 | 715 | } |
| 715 | 716 | |
| 716 | 717 |
| r8714 | r8715 | |
|---|---|---|
| 65 | 65 | |
| 66 | 66 | // memory and address spaces |
| 67 | 67 | #include "memory.h" |
| 68 | #include "addrmap.h" | |
| 68 | 69 | |
| 69 | 70 | // devices and callbacks |
| 70 | 71 | #include "devintrf.h" |
| r8714 | r8715 | |
|---|---|---|
| 174 | 174 | generic_video_data(NULL), |
| 175 | 175 | generic_audio_data(NULL), |
| 176 | 176 | m_debug_view(NULL), |
| 177 | driver_data(NULL), | |
| 178 | 177 | m_logerror_list(NULL), |
| 179 | 178 | m_scheduler(*this), |
| 180 | 179 | m_options(options), |
| r8714 | r8715 | |
| 190 | 189 | m_saveload_schedule(SLS_NONE), |
| 191 | 190 | m_saveload_schedule_time(attotime_zero), |
| 192 | 191 | m_saveload_searchpath(NULL), |
| 193 | m_rand_seed(0x9d14abd7) | |
| 192 | m_rand_seed(0x9d14abd7), | |
| 193 | m_driver_data(NULL) | |
| 194 | 194 | { |
| 195 | 195 | memset(gfx, 0, sizeof(gfx)); |
| 196 | 196 | memset(&generic, 0, sizeof(generic)); |
| r8714 | r8715 | |
| 202 | 202 | |
| 203 | 203 | // allocate the driver data (after devices) |
| 204 | 204 | if (m_config.m_driver_data_alloc != NULL) |
| 205 | driver_data = (*m_config.m_driver_data_alloc)(*this); | |
| 205 | m_driver_data = (*m_config.m_driver_data_alloc)(*this); | |
| 206 | 206 | |
| 207 | 207 | // find devices |
| 208 | 208 | primary_screen = screen_first(*this); |
| r8714 | r8715 | |
| 966 | 966 | |
| 967 | 967 | |
| 968 | 968 | //************************************************************************** |
| 969 | // DRIVER DATA | |
| 970 | //************************************************************************** | |
| 971 | ||
| 972 | //------------------------------------------------- | |
| 973 | // driver_data_t - constructor | |
| 974 | //------------------------------------------------- | |
| 975 | ||
| 976 | driver_data_t::driver_data_t(running_machine &machine) | |
| 977 | : m_machine(machine) | |
| 978 | { | |
| 979 | } | |
| 980 | ||
| 981 | ||
| 982 | //------------------------------------------------- | |
| 983 | // driver_data_t - destructor | |
| 984 | //------------------------------------------------- | |
| 985 | ||
| 986 | driver_data_t::~driver_data_t() | |
| 987 | { | |
| 988 | } | |
| 989 | ||
| 990 | ||
| 991 | ||
| 992 | //************************************************************************** | |
| 969 | 993 | // SYSTEM TIME |
| 970 | 994 | //************************************************************************** |
| 971 | 995 |
| r8714 | r8715 | |
|---|---|---|
| 157 | 157 | typedef tagged_list<region_info> region_list; |
| 158 | 158 | |
| 159 | 159 | |
| 160 | // base class for all driver data structures | |
| 161 | class driver_data_t | |
| 162 | { | |
| 163 | public: | |
| 164 | driver_data_t(running_machine &machine); | |
| 165 | virtual ~driver_data_t(); | |
| 166 | ||
| 167 | running_machine & m_machine; | |
| 168 | }; | |
| 169 | ||
| 170 | ||
| 160 | 171 | // memory region |
| 161 | 172 | class region_info |
| 162 | 173 | { |
| r8714 | r8715 | |
| 231 | 242 | }; |
| 232 | 243 | |
| 233 | 244 | |
| 245 | // system time description, both local and UTC | |
| 234 | 246 | class system_time |
| 235 | 247 | { |
| 236 | 248 | public: |
| r8714 | r8715 | |
| 385 | 397 | debug_view_manager * m_debug_view; // internal data from debugvw.c |
| 386 | 398 | |
| 387 | 399 | // driver-specific information |
| 388 | void * driver_data; // drivers can hang data off of here instead of using globals | |
| 400 | template<class T> | |
| 401 | T *driver_data() const { return downcast<T *>(m_driver_data); } | |
| 389 | 402 | |
| 390 | 403 | private: |
| 391 | 404 | void start(); |
| r8714 | r8715 | |
| 448 | 461 | |
| 449 | 462 | // base time |
| 450 | 463 | time_t m_base_time; |
| 464 | ||
| 465 | driver_data_t * m_driver_data; // drivers can hang data off of here instead of using globals | |
| 451 | 466 | }; |
| 452 | 467 | |
| 453 | 468 |
| r8714 | r8715 | |
|---|---|---|
| 263 | 263 | m_space_config.m_addrbus_shift = get_legacy_config_int(DEVINFO_INT_ADDRBUS_SHIFT); |
| 264 | 264 | m_space_config.m_logaddr_width = m_space_config.m_addrbus_width; |
| 265 | 265 | m_space_config.m_page_shift = 0; |
| 266 | m_space_config.m_internal_map = reinterpret_cast<const addrmap_token *>(get_legacy_config_ptr(DEVINFO_PTR_INTERNAL_MEMORY_MAP)); | |
| 267 | m_space_config.m_default_map = reinterpret_cast<const addrmap_token *>(get_legacy_config_ptr(DEVINFO_PTR_DEFAULT_MEMORY_MAP)); | |
| 266 | m_space_config.m_internal_map = reinterpret_cast<address_map_constructor>(get_legacy_config_fct(DEVINFO_PTR_INTERNAL_MEMORY_MAP)); | |
| 267 | m_space_config.m_default_map = reinterpret_cast<address_map_constructor>(get_legacy_config_fct(DEVINFO_PTR_DEFAULT_MEMORY_MAP)); | |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 |
| r8714 | r8715 | |
|---|---|---|
| 89 | 89 | DEVINFO_PTR_ROM_REGION = DEVINFO_PTR_FIRST, // R/O: pointer to device-specific ROM region |
| 90 | 90 | DEVINFO_PTR_MACHINE_CONFIG, // R/O: pointer to device-specific machine config |
| 91 | 91 | |
| 92 | DEVINFO_PTR_INTERNAL_MEMORY_MAP, // R/O: | |
| 92 | DEVINFO_PTR_INTERNAL_MEMORY_MAP, // R/O: | |
| 93 | 93 | DEVINFO_PTR_INTERNAL_MEMORY_MAP_0 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 0, |
| 94 | 94 | DEVINFO_PTR_INTERNAL_MEMORY_MAP_1 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 1, |
| 95 | 95 | DEVINFO_PTR_INTERNAL_MEMORY_MAP_2 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 2, |
| 96 | 96 | DEVINFO_PTR_INTERNAL_MEMORY_MAP_3 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 3, |
| 97 | 97 | DEVINFO_PTR_INTERNAL_MEMORY_MAP_LAST = DEVINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACES - 1, |
| 98 | 98 | |
| 99 | DEVINFO_PTR_DEFAULT_MEMORY_MAP, // R/O: | |
| 99 | DEVINFO_PTR_DEFAULT_MEMORY_MAP, // R/O: | |
| 100 | 100 | DEVINFO_PTR_DEFAULT_MEMORY_MAP_0 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 0, |
| 101 | 101 | DEVINFO_PTR_DEFAULT_MEMORY_MAP_1 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 1, |
| 102 | 102 | DEVINFO_PTR_DEFAULT_MEMORY_MAP_2 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 2, |
| r8714 | r8715 | |
| 403 | 403 | device_nvram_func nvram; // DEVINFO_FCT_NVRAM |
| 404 | 404 | const rom_entry * romregion; // DEVINFO_PTR_ROM_REGION |
| 405 | 405 | const machine_config_token *machine_config; // DEVINFO_PTR_MACHINE_CONFIG |
| 406 | const addrmap8_token * internal_map8; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 407 | const addrmap16_token * internal_map16; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 408 | const addrmap32_token * internal_map32; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 409 | const addrmap64_token * internal_map64; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 410 | const addrmap8_token * default_map8; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 411 | const addrmap16_token * default_map16; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 412 | const addrmap32_token * default_map32; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 413 | const addrmap64_token * default_map64; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 406 | address_map_constructor internal_map8; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 407 | address_map_constructor internal_map16; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 408 | address_map_constructor internal_map32; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 409 | address_map_constructor internal_map64; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 410 | address_map_constructor default_map8; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 411 | address_map_constructor default_map16; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 412 | address_map_constructor default_map32; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 413 | address_map_constructor default_map64; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 414 | 414 | }; |
| 415 | 415 | |
| 416 | 416 |
| r8714 | r8715 | |
|---|---|---|
| 1187 | 1187 | for (drivnum = 0; drivers[drivnum]; drivnum++) |
| 1188 | 1188 | { |
| 1189 | 1189 | const game_driver *driver = drivers[drivnum]; |
| 1190 | machine_config *config = NULL; | |
| 1190 | 1191 | ioport_list portlist; |
| 1191 | machine_config *config; | |
| 1192 | 1192 | region_array rgninfo; |
| 1193 | 1193 | |
| 1194 | 1194 | /* non-debug builds only care about games in the same driver */ |
| 1195 | 1195 | if (curdriver != NULL && strcmp(curdriver->source_file, driver->source_file) != 0) |
| 1196 | 1196 | continue; |
| 1197 | 1197 | |
| 1198 | /* expand the machine driver */ | |
| 1199 | expansion -= get_profile_ticks(); | |
| 1200 | config = global_alloc(machine_config(driver->machine_config)); | |
| 1201 | expansion += get_profile_ticks(); | |
| 1198 | try | |
| 1199 | { | |
| 1200 | /* expand the machine driver */ | |
| 1201 | expansion -= get_profile_ticks(); | |
| 1202 | config = global_alloc(machine_config(driver->machine_config)); | |
| 1203 | expansion += get_profile_ticks(); | |
| 1202 | 1204 | |
| 1203 | /* validate the driver entry */ | |
| 1204 | driver_checks -= get_profile_ticks(); | |
| 1205 | error = validate_driver(drivnum, config, names, descriptions) || error; | |
| 1206 | driver_checks += get_profile_ticks(); | |
| 1205 | /* validate the driver entry */ | |
| 1206 | driver_checks -= get_profile_ticks(); | |
| 1207 | error = validate_driver(drivnum, config, names, descriptions) || error; | |
| 1208 | driver_checks += get_profile_ticks(); | |
| 1207 | 1209 | |
| 1208 | /* validate the ROM information */ | |
| 1209 | rom_checks -= get_profile_ticks(); | |
| 1210 | error = validate_roms(drivnum, config, &rgninfo, roms) || error; | |
| 1211 | rom_checks += get_profile_ticks(); | |
| 1210 | /* validate the ROM information */ | |
| 1211 | rom_checks -= get_profile_ticks(); | |
| 1212 | error = validate_roms(drivnum, config, &rgninfo, roms) || error; | |
| 1213 | rom_checks += get_profile_ticks(); | |
| 1212 | 1214 | |
| 1213 | /* validate input ports */ | |
| 1214 | input_checks -= get_profile_ticks(); | |
| 1215 | error = validate_inputs(drivnum, config, defstr, portlist) || error; | |
| 1216 | input_checks += get_profile_ticks(); | |
| 1215 | /* validate input ports */ | |
| 1216 | input_checks -= get_profile_ticks(); | |
| 1217 | error = validate_inputs(drivnum, config, defstr, portlist) || error; | |
| 1218 | input_checks += get_profile_ticks(); | |
| 1217 | 1219 | |
| 1218 | /* validate the display */ | |
| 1219 | display_checks -= get_profile_ticks(); | |
| 1220 | error = validate_display(drivnum, config) || error; | |
| 1221 | display_checks += get_profile_ticks(); | |
| 1220 | /* validate the display */ | |
| 1221 | display_checks -= get_profile_ticks(); | |
| 1222 | error = validate_display(drivnum, config) || error; | |
| 1223 | display_checks += get_profile_ticks(); | |
| 1222 | 1224 | |
| 1223 | /* validate the graphics decoding */ | |
| 1224 | gfx_checks -= get_profile_ticks(); | |
| 1225 | error = validate_gfx(drivnum, config, &rgninfo) || error; | |
| 1226 | gfx_checks += get_profile_ticks(); | |
| 1225 | /* validate the graphics decoding */ | |
| 1226 | gfx_checks -= get_profile_ticks(); | |
| 1227 | error = validate_gfx(drivnum, config, &rgninfo) || error; | |
| 1228 | gfx_checks += get_profile_ticks(); | |
| 1227 | 1229 | |
| 1228 | /* validate devices */ | |
| 1229 | device_checks -= get_profile_ticks(); | |
| 1230 | error = validate_devices(drivnum, config, portlist, &rgninfo) || error; | |
| 1231 | device_checks += get_profile_ticks(); | |
| 1232 | ||
| 1230 | /* validate devices */ | |
| 1231 | device_checks -= get_profile_ticks(); | |
| 1232 | error = validate_devices(drivnum, config, portlist, &rgninfo) || error; | |
| 1233 | device_checks += get_profile_ticks(); | |
| 1234 | } | |
| 1235 | catch (emu_fatalerror &err) | |
| 1236 | { | |
| 1237 | global_free(config); | |
| 1238 | throw emu_fatalerror("Validating %s (%s): %s", driver->name, driver->source_file, err.string()); | |
| 1239 | } | |
| 1240 | ||
| 1233 | 1241 | global_free(config); |
| 1234 | 1242 | } |
| 1235 | 1243 |
| r8714 | r8715 | |
|---|---|---|
| 605 | 605 | void *legacy_image_device_base::get_device_specific_call() |
| 606 | 606 | { |
| 607 | 607 | return (void*) m_config.get_legacy_config_fct(DEVINFO_FCT_DEVICE_SPECIFIC); |
| 608 | } | |
| No newline at end of file | ||
| 608 | } |
| r8714 | r8715 | |
|---|---|---|
| 79 | 79 | m_space_config[spacenum].m_addrbus_shift = get_legacy_config_int(DEVINFO_INT_ADDRBUS_SHIFT + spacenum); |
| 80 | 80 | m_space_config[spacenum].m_logaddr_width = get_legacy_config_int(CPUINFO_INT_LOGADDR_WIDTH + spacenum); |
| 81 | 81 | m_space_config[spacenum].m_page_shift = get_legacy_config_int(CPUINFO_INT_PAGE_SHIFT + spacenum); |
| 82 | m_space_config[spacenum].m_internal_map = reinterpret_cast<const addrmap_token *>(get_legacy_config_ptr(DEVINFO_PTR_INTERNAL_MEMORY_MAP + spacenum)); | |
| 83 | m_space_config[spacenum].m_default_map = reinterpret_cast<const addrmap_token *>(get_legacy_config_ptr(DEVINFO_PTR_DEFAULT_MEMORY_MAP + spacenum)); | |
| 82 | m_space_config[spacenum].m_internal_map = reinterpret_cast<address_map_constructor>(get_legacy_config_fct(DEVINFO_PTR_INTERNAL_MEMORY_MAP + spacenum)); | |
| 83 | m_space_config[spacenum].m_default_map = reinterpret_cast<address_map_constructor>(get_legacy_config_fct(DEVINFO_PTR_DEFAULT_MEMORY_MAP + spacenum)); | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // set the real name |
| r8714 | r8715 | |
|---|---|---|
| 304 | 304 | #define cpu_set_input_line_vector device_set_input_line_vector |
| 305 | 305 | #define cpu_set_input_line_and_vector device_set_input_line_and_vector |
| 306 | 306 | #define cpu_set_irq_callback device_set_irq_callback |
| 307 | #define cpu_spin_until_int device_spin_until_int | |
| 308 | 307 | |
| 309 | 308 | #define cpu_get_address_space device_get_space |
| 310 | 309 | |
| r8714 | r8715 | |
| 320 | 319 | #define cputag_get_address_space(mach, tag, spc) downcast<cpu_device *>((mach)->device(tag))->space(spc) |
| 321 | 320 | #define cputag_get_clock(mach, tag) (mach)->device(tag)->unscaled_clock() |
| 322 | 321 | #define cputag_set_clock(mach, tag, clock) (mach)->device(tag)->set_unscaled_clock(clock) |
| 323 | #define cputag_clocks_to_attotime(mach, tag, clocks) (mach)->device(tag)->clocks_to_attotime(clocks) | |
| 324 | #define cputag_attotime_to_clocks(mach, tag, duration) (mach)->device(tag)->attotime_to_clocks(duration) | |
| 325 | 322 | |
| 326 | #define cputag_suspend(mach, tag, reason, eat) device_suspend((mach)->device(tag), reason, eat) | |
| 327 | #define cputag_resume(mach, tag, reason) device_resume((mach)->device(tag), reason) | |
| 328 | ||
| 329 | 323 | #define cputag_set_input_line(mach, tag, line, state) downcast<cpu_device *>((mach)->device(tag))->set_input_line(line, state) |
| 330 | 324 | #define cputag_set_input_line_and_vector(mach, tag, line, state, vec) downcast<cpu_device *>((mach)->device(tag))->set_input_line_and_vector(line, state, vec) |
| 331 | 325 | |
| r8714 | r8715 | |
| 384 | 378 | cpu_string_io_func import_string; // CPUINFO_FCT_IMPORT_STRING |
| 385 | 379 | cpu_string_io_func export_string; // CPUINFO_FCT_EXPORT_STRING |
| 386 | 380 | int * icount; // CPUINFO_PTR_INSTRUCTION_COUNTER |
| 387 | const addrmap8_token * internal_map8; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 388 | const addrmap16_token * internal_map16; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 389 | const addrmap32_token * internal_map32; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 390 | const addrmap64_token * internal_map64; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 391 | const addrmap8_token * default_map8; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 392 | const addrmap16_token * default_map16; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 393 | const addrmap32_token * default_map32; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 394 | const addrmap64_token * default_map64; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 381 | address_map_constructor internal_map8; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 382 | address_map_constructor internal_map16; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 383 | address_map_constructor internal_map32; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 384 | address_map_constructor internal_map64; // DEVINFO_PTR_INTERNAL_MEMORY_MAP | |
| 385 | address_map_constructor default_map8; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 386 | address_map_constructor default_map16; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 387 | address_map_constructor default_map32; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 388 | address_map_constructor default_map64; // DEVINFO_PTR_DEFAULT_MEMORY_MAP | |
| 395 | 389 | }; |
| 396 | 390 | |
| 397 | 391 |
| r8714 | r8715 | |
|---|---|---|
| 395 | 395 | static void memory_init_locate(running_machine *machine); |
| 396 | 396 | static void memory_exit(running_machine &machine); |
| 397 | 397 | |
| 398 | /* address map helpers */ | |
| 399 | static void map_detokenize(memory_private *memdata, address_map *map, const game_driver *driver, const device_config *devconfig, const addrmap_token *tokens); | |
| 400 | ||
| 401 | 398 | /* memory mapping helpers */ |
| 402 | 399 | static void space_map_range(address_space *space, read_or_write readorwrite, int handlerbits, int handlerunitmask, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name); |
| 403 | 400 | static void *space_find_backing_memory(const address_space *space, offs_t addrstart, offs_t addrend); |
| r8714 | r8715 | |
| 823 | 820 | |
| 824 | 821 | |
| 825 | 822 | /*************************************************************************** |
| 826 | ADDRESS MAPS | |
| 827 | ***************************************************************************/ | |
| 828 | ||
| 829 | /*------------------------------------------------- | |
| 830 | address_map_alloc - build and allocate an | |
| 831 | address map for a device's address space | |
| 832 | -------------------------------------------------*/ | |
| 833 | ||
| 834 | address_map *address_map_alloc(const device_config *devconfig, const game_driver *driver, int spacenum, void *memdata) | |
| 835 | { | |
| 836 | address_map *map = global_alloc_clear(address_map); | |
| 837 | ||
| 838 | const device_config_memory_interface *memintf; | |
| 839 | if (!devconfig->interface(memintf)) | |
| 840 | throw emu_fatalerror("No memory interface defined for device '%s'\n", devconfig->tag()); | |
| 841 | ||
| 842 | const address_space_config *spaceconfig = memintf->space_config(spacenum); | |
| 843 | ||
| 844 | /* append the internal device map (first so it takes priority) */ | |
| 845 | if (spaceconfig != NULL && spaceconfig->m_internal_map != NULL) | |
| 846 | map_detokenize((memory_private *)memdata, map, driver, devconfig, spaceconfig->m_internal_map); | |
| 847 | ||
| 848 | /* construct the standard map */ | |
| 849 | if (memintf->address_map(spacenum) != NULL) | |
| 850 | map_detokenize((memory_private *)memdata, map, driver, devconfig, memintf->address_map(spacenum)); | |
| 851 | ||
| 852 | /* append the default device map (last so it can be overridden) */ | |
| 853 | if (spaceconfig != NULL && spaceconfig->m_default_map != NULL) | |
| 854 | map_detokenize((memory_private *)memdata, map, driver, devconfig, spaceconfig->m_default_map); | |
| 855 | ||
| 856 | return map; | |
| 857 | } | |
| 858 | ||
| 859 | ||
| 860 | /*------------------------------------------------- | |
| 861 | address_map_free - release allocated memory | |
| 862 | for an address map | |
| 863 | -------------------------------------------------*/ | |
| 864 | ||
| 865 | void address_map_free(address_map *map) | |
| 866 | { | |
| 867 | /* free all entries */ | |
| 868 | while (map->entrylist != NULL) | |
| 869 | { | |
| 870 | address_map_entry *entry = map->entrylist; | |
| 871 | map->entrylist = entry->next; | |
| 872 | global_free(entry); | |
| 873 | } | |
| 874 | ||
| 875 | /* free the map */ | |
| 876 | global_free(map); | |
| 877 | } | |
| 878 | ||
| 879 | ||
| 880 | ||
| 881 | /*************************************************************************** | |
| 882 | 823 | DIRECT ACCESS CONTROL |
| 883 | 824 | ***************************************************************************/ |
| 884 | 825 | |
| r8714 | r8715 | |
| 1811 | 1752 | int entrynum; |
| 1812 | 1753 | |
| 1813 | 1754 | /* allocate the address map */ |
| 1814 | space->map = address_map | |
| 1755 | space->map = global_alloc(address_map | |
| 1815 | 1756 | |
| 1816 | 1757 | /* extract global parameters specified by the map */ |
| 1817 | space->unmap = (space->map->unmapval == 0) ? 0 : ~0; | |
| 1818 | if (space->map->globalmask != 0) | |
| 1758 | space->unmap = (space->map->m_unmapval == 0) ? 0 : ~0; | |
| 1759 | if (space->map->m_globalmask != 0) | |
| 1819 | 1760 | { |
| 1820 | space->addrmask = space->map->globalmask; | |
| 1761 | space->addrmask = space->map->m_globalmask; | |
| 1821 | 1762 | space->bytemask = memory_address_to_byte_end(space, space->addrmask); |
| 1822 | 1763 | } |
| 1823 | 1764 | |
| 1824 | 1765 | /* make a pass over the address map, adjusting for the device and getting memory pointers */ |
| 1825 | for (entry = space->map->entrylist; entry != NULL; entry = entry->next) | |
| 1766 | for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next) | |
| 1826 | 1767 | { |
| 1768 | /* if we have a share entry, add it to our map */ | |
| 1769 | if (entry->m_share != NULL) | |
| 1770 | memdata->sharemap.add(entry->m_share, UNMAPPED_SHARE_PTR, FALSE); | |
| 1771 | ||
| 1827 | 1772 | /* computed adjusted addresses first */ |
| 1828 | entry->bytestart = entry->addrstart; | |
| 1829 | entry->byteend = entry->addrend; | |
| 1830 | entry->bytemirror = entry->addrmirror; | |
| 1831 | entry->bytemask = entry->addrmask; | |
| 1832 | adjust_addresses(space, &entry->bytestart, &entry->byteend, &entry->bytemask, &entry->bytemirror); | |
| 1773 | entry->m_bytestart = entry->m_addrstart; | |
| 1774 | entry->m_byteend = entry->m_addrend; | |
| 1775 | entry->m_bytemirror = entry->m_addrmirror; | |
| 1776 | entry->m_bytemask = entry->m_addrmask; | |
| 1777 | adjust_addresses(space, &entry->m_bytestart, &entry->m_byteend, &entry->m_bytemask, &entry->m_bytemirror); | |
| 1833 | 1778 | |
| 1834 | 1779 | /* if this is a ROM handler without a specified region, attach it to the implicit region */ |
| 1835 | if (space->spacenum == ADDRESS_SPACE_0 && entry->read.type == AMH_ROM && entry->region == NULL) | |
| 1780 | if (space->spacenum == ADDRESS_SPACE_0 && entry->m_read.type == AMH_ROM && entry->m_region == NULL) | |
| 1836 | 1781 | { |
| 1837 | 1782 | /* make sure it fits within the memory region before doing so, however */ |
| 1838 | if (entry->byteend < devregionsize) | |
| 1783 | if (entry->m_byteend < devregionsize) | |
| 1839 | 1784 | { |
| 1840 | entry->region = space->cpu->tag(); | |
| 1841 | entry->rgnoffs = entry->bytestart; | |
| 1785 | entry->m_region = space->cpu->tag(); | |
| 1786 | entry->m_rgnoffs = entry->m_bytestart; | |
| 1842 | 1787 | } |
| 1843 | 1788 | } |
| 1844 | 1789 | |
| 1845 | 1790 | /* validate adjusted addresses against implicit regions */ |
| 1846 | if (entry->region != NULL && entry->share == NULL && entry->baseptr == NULL) | |
| 1791 | if (entry->m_region != NULL && entry->m_share == NULL && entry->m_baseptr == NULL) | |
| 1847 | 1792 | { |
| 1848 | const region_info *region = machine->region(entry->region); | |
| 1793 | const region_info *region = machine->region(entry->m_region); | |
| 1849 | 1794 | if (region == NULL) |
| 1850 | fatalerror("Error: device '%s' %s space memory map entry %X-%X references non-existant region \"%s\"", space->cpu->tag(), space->name, entry->addrstart, entry->addrend, entry->region); | |
| 1795 | fatalerror("Error: device '%s' %s space memory map entry %X-%X references non-existant region \"%s\"", space->cpu->tag(), space->name, entry->m_addrstart, entry->m_addrend, entry->m_region); | |
| 1851 | 1796 | |
| 1852 | 1797 | /* validate the region */ |
| 1853 | if (entry->rgnoffs + (entry->byteend - entry->bytestart + 1) > region->bytes()) | |
| 1854 | fatalerror("Error: device '%s' %s space memory map entry %X-%X extends beyond region \"%s\" size (%X)", space->cpu->tag(), space->name, entry->addrstart, entry->addrend, entry->region, region->bytes()); | |
| 1798 | if (entry->m_rgnoffs + (entry->m_byteend - entry->m_bytestart + 1) > region->bytes()) | |
| 1799 | fatalerror("Error: device '%s' %s space memory map entry %X-%X extends beyond region \"%s\" size (%X)", space->cpu->tag(), space->name, entry->m_addrstart, entry->m_addrend, entry->m_region, region->bytes()); | |
| 1855 | 1800 | } |
| 1856 | 1801 | |
| 1857 | 1802 | /* convert any region-relative entries to their memory pointers */ |
| 1858 | if (entry->region != NULL) | |
| 1859 | entry->memory = machine->region(entry->region)->base() + entry->rgnoffs; | |
| 1803 | if (entry->m_region != NULL) | |
| 1804 | entry->m_memory = machine->region(entry->m_region)->base() + entry->m_rgnoffs; | |
| 1860 | 1805 | } |
| 1861 | 1806 | |
| 1862 | 1807 | /* now loop over all the handlers and enforce the address mask */ |
| r8714 | r8715 | |
| 1887 | 1832 | const address_map_entry *last_entry = NULL; |
| 1888 | 1833 | |
| 1889 | 1834 | /* install the handlers, using the original, unadjusted memory map */ |
| 1890 | while (last_entry != space->map->entrylist) | |
| 1835 | while (last_entry != space->map->m_entrylist) | |
| 1891 | 1836 | { |
| 1892 | 1837 | const address_map_entry *entry; |
| 1893 | 1838 | |
| 1894 | 1839 | /* find the entry before the last one we processed */ |
| 1895 | for (entry = space->map->entrylist; entry->next != last_entry; entry = entry->next) ; | |
| 1840 | for (entry = space->map->m_entrylist; entry->m_next != last_entry; entry = entry->m_next) ; | |
| 1896 | 1841 | last_entry = entry; |
| 1897 | 1842 | |
| 1898 | 1843 | /* map both read and write halves */ |
| r8714 | r8715 | |
| 1911 | 1856 | |
| 1912 | 1857 | static void memory_init_map_entry(address_space *space, const address_map_entry *entry, read_or_write readorwrite) |
| 1913 | 1858 | { |
| 1914 | const map_handler_data *handler = (readorwrite == ROW_READ) ? &entry->read : &entry->write; | |
| 1859 | const map_handler_data *handler = (readorwrite == ROW_READ) ? &entry->m_read : &entry->m_write; | |
| 1915 | 1860 | device_t *device; |
| 1916 | 1861 | |
| 1917 | 1862 | /* based on the handler type, alter the bits, name, funcptr, and object */ |
| r8714 | r8715 | |
| 1926 | 1871 | /* fall through to the RAM case otherwise */ |
| 1927 | 1872 | |
| 1928 | 1873 | case AMH_RAM: |
| 1929 | _memory_install_ram(space, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1874 | _memory_install_ram(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 1930 | 1875 | readorwrite == ROW_READ, readorwrite == ROW_WRITE, NULL); |
| 1931 | 1876 | break; |
| 1932 | 1877 | |
| 1933 | 1878 | case AMH_NOP: |
| 1934 | _memory_unmap(space, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1879 | _memory_unmap(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 1935 | 1880 | readorwrite == ROW_READ, readorwrite == ROW_WRITE, TRUE); |
| 1936 | 1881 | break; |
| 1937 | 1882 | |
| 1938 | 1883 | case AMH_UNMAP: |
| 1939 | _memory_unmap(space, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1884 | _memory_unmap(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 1940 | 1885 | readorwrite == ROW_READ, readorwrite == ROW_WRITE, FALSE); |
| 1941 | 1886 | break; |
| 1942 | 1887 | |
| r8714 | r8715 | |
| 1944 | 1889 | switch ((handler->bits != 0) ? handler->bits : space->dbits) |
| 1945 | 1890 | { |
| 1946 | 1891 | case 8: |
| 1947 | _memory_install_handler8(space, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1892 | _memory_install_handler8(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 1948 | 1893 | (readorwrite == ROW_READ) ? handler->handler.read.shandler8 : NULL, handler->name, |
| 1949 | 1894 | (readorwrite == ROW_WRITE) ? handler->handler.write.shandler8 : NULL, handler->name, |
| 1950 | 1895 | handler->mask); |
| 1951 | 1896 | break; |
| 1952 | 1897 | |
| 1953 | 1898 | case 16: |
| 1954 | _memory_install_handler16(space, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1899 | _memory_install_handler16(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 1955 | 1900 | (readorwrite == ROW_READ) ? handler->handler.read.shandler16 : NULL, handler->name, |
| 1956 | 1901 | (readorwrite == ROW_WRITE) ? handler->handler.write.shandler16 : NULL, handler->name, |
| 1957 | 1902 | handler->mask); |
| 1958 | 1903 | break; |
| 1959 | 1904 | |
| 1960 | 1905 | case 32: |
| 1961 | _memory_install_handler32(space, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1906 | _memory_install_handler32(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 1962 | 1907 | (readorwrite == ROW_READ) ? handler->handler.read.shandler32 : NULL, handler->name, |
| 1963 | 1908 | (readorwrite == ROW_WRITE) ? handler->handler.write.shandler32 : NULL, handler->name, |
| 1964 | 1909 | handler->mask); |
| 1965 | 1910 | break; |
| 1966 | 1911 | |
| 1967 | 1912 | case 64: |
| 1968 | _memory_install_handler64(space, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1913 | _memory_install_handler64(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 1969 | 1914 | (readorwrite == ROW_READ) ? handler->handler.read.shandler64 : NULL, handler->name, |
| 1970 | 1915 | (readorwrite == ROW_WRITE) ? handler->handler.write.shandler64 : NULL, handler->name, |
| 1971 | 1916 | handler->mask); |
| r8714 | r8715 | |
| 1980 | 1925 | switch ((handler->bits != 0) ? handler->bits : space->dbits) |
| 1981 | 1926 | { |
| 1982 | 1927 | case 8: |
| 1983 | _memory_install_device_handler8(space, device, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1928 | _memory_install_device_handler8(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 1984 | 1929 | (readorwrite == ROW_READ) ? handler->handler.read.dhandler8 : NULL, handler->name, |
| 1985 | 1930 | (readorwrite == ROW_WRITE) ? handler->handler.write.dhandler8 : NULL, handler->name, |
| 1986 | 1931 | handler->mask); |
| 1987 | 1932 | break; |
| 1988 | 1933 | |
| 1989 | 1934 | case 16: |
| 1990 | _memory_install_device_handler16(space, device, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1935 | _memory_install_device_handler16(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 1991 | 1936 | (readorwrite == ROW_READ) ? handler->handler.read.dhandler16 : NULL, handler->name, |
| 1992 | 1937 | (readorwrite == ROW_WRITE) ? handler->handler.write.dhandler16 : NULL, handler->name, |
| 1993 | 1938 | handler->mask); |
| 1994 | 1939 | break; |
| 1995 | 1940 | |
| 1996 | 1941 | case 32: |
| 1997 | _memory_install_device_handler32(space, device, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1942 | _memory_install_device_handler32(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 1998 | 1943 | (readorwrite == ROW_READ) ? handler->handler.read.dhandler32 : NULL, handler->name, |
| 1999 | 1944 | (readorwrite == ROW_WRITE) ? handler->handler.write.dhandler32 : NULL, handler->name, |
| 2000 | 1945 | handler->mask); |
| 2001 | 1946 | break; |
| 2002 | 1947 | |
| 2003 | 1948 | case 64: |
| 2004 | _memory_install_device_handler64(space, device, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1949 | _memory_install_device_handler64(space, device, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 2005 | 1950 | (readorwrite == ROW_READ) ? handler->handler.read.dhandler64 : NULL, handler->name, |
| 2006 | 1951 | (readorwrite == ROW_WRITE) ? handler->handler.write.dhandler64 : NULL, handler->name, |
| 2007 | 1952 | handler->mask); |
| r8714 | r8715 | |
| 2010 | 1955 | break; |
| 2011 | 1956 | |
| 2012 | 1957 | case AMH_PORT: |
| 2013 | _memory_install_port(space, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1958 | _memory_install_port(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 2014 | 1959 | (readorwrite == ROW_READ) ? handler->tag : NULL, |
| 2015 | 1960 | (readorwrite == ROW_WRITE) ? handler->tag : NULL); |
| 2016 | 1961 | break; |
| 2017 | 1962 | |
| 2018 | 1963 | case AMH_BANK: |
| 2019 | _memory_install_bank(space, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1964 | _memory_install_bank(space, entry->m_addrstart, entry->m_addrend, entry->m_addrmask, entry->m_addrmirror, | |
| 2020 | 1965 | (readorwrite == ROW_READ) ? handler->tag : NULL, |
| 2021 | 1966 | (readorwrite == ROW_WRITE) ? handler->tag : NULL); |
| 2022 | 1967 | break; |
| r8714 | r8715 | |
| 2044 | 1989 | |
| 2045 | 1990 | /* make a first pass over the memory map and track blocks with hardcoded pointers */ |
| 2046 | 1991 | /* we do this to make sure they are found by space_find_backing_memory first */ |
| 2047 | for (entry = space->map->entrylist; entry != NULL; entry = entry->next) | |
| 2048 | if (entry->memory != NULL) | |
| 2049 | block_allocate(space, entry->bytestart, entry->byteend, entry->memory); | |
| 1992 | for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next) | |
| 1993 | if (entry->m_memory != NULL) | |
| 1994 | block_allocate(space, entry->m_bytestart, entry->m_byteend, entry->m_memory); | |
| 2050 | 1995 | |
| 2051 | 1996 | /* loop over all blocks just allocated and assign pointers from them */ |
| 2052 | 1997 | for (memblock = memdata->memory_block_list; memblock != prev_memblock_head; memblock = memblock->next) |
| r8714 | r8715 | |
| 2064 | 2009 | void *block; |
| 2065 | 2010 | |
| 2066 | 2011 | /* work in MEMORY_BLOCK_CHUNK-sized chunks */ |
| 2067 | offs_t curblockstart = unassigned->bytestart / MEMORY_BLOCK_CHUNK; | |
| 2068 | offs_t curblockend = unassigned->byteend / MEMORY_BLOCK_CHUNK; | |
| 2012 | offs_t curblockstart = unassigned->m_bytestart / MEMORY_BLOCK_CHUNK; | |
| 2013 | offs_t curblockend = unassigned->m_byteend / MEMORY_BLOCK_CHUNK; | |
| 2069 | 2014 | |
| 2070 | 2015 | /* loop while we keep finding unassigned blocks in neighboring MEMORY_BLOCK_CHUNK chunks */ |
| 2071 | 2016 | do |
| r8714 | r8715 | |
| 2073 | 2018 | changed = FALSE; |
| 2074 | 2019 | |
| 2075 | 2020 | /* scan for unmapped blocks in the adjusted map */ |
| 2076 | for (entry = space->map->entrylist; entry != NULL; entry = entry->next) | |
| 2077 | if (entry->memory == NULL && entry != unassigned && space_needs_backing_store(space, entry)) | |
| 2021 | for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next) | |
| 2022 | if (entry->m_memory == NULL && entry != unassigned && space_needs_backing_store(space, entry)) | |
| 2078 | 2023 | { |
| 2079 | 2024 | offs_t blockstart, blockend; |
| 2080 | 2025 | |
| 2081 | 2026 | /* get block start/end blocks for this block */ |
| 2082 | blockstart = entry->bytestart / MEMORY_BLOCK_CHUNK; | |
| 2083 | blockend = entry->byteend / MEMORY_BLOCK_CHUNK; | |
| 2027 | blockstart = entry->m_bytestart / MEMORY_BLOCK_CHUNK; | |
| 2028 | blockend = entry->m_byteend / MEMORY_BLOCK_CHUNK; | |
| 2084 | 2029 | |
| 2085 | 2030 | /* if we intersect or are adjacent, adjust the start/end */ |
| 2086 | 2031 | if (blockstart <= curblockend + 1 && blockend >= curblockstart - 1) |
| r8714 | r8715 | |
| 2122 | 2067 | const address_map_entry *entry; |
| 2123 | 2068 | |
| 2124 | 2069 | /* fill in base/size entries */ |
| 2125 | for (entry = space->map->entrylist; entry != NULL; entry = entry->next) | |
| 2070 | for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next) | |
| 2126 | 2071 | { |
| 2127 | if (entry->baseptr != NULL) | |
| 2128 | *entry->baseptr = entry->memory; | |
| 2129 | if (entry->baseptroffs_plus1 != 0) | |
| 2130 | *(void **)((UINT8 *)machine->driver_data + entry->baseptroffs_plus1 - 1) = entry->memory; | |
| 2131 | if (entry->genbaseptroffs_plus1 != 0) | |
| 2132 | *(void **)((UINT8 *)&machine->generic + entry->genbaseptroffs_plus1 - 1) = entry->memory; | |
| 2133 | if (entry->sizeptr != NULL) | |
| 2134 | *entry->sizeptr = entry->byteend - entry->bytestart + 1; | |
| 2135 | if (entry->sizeptroffs_plus1 != 0) | |
| 2136 | *(size_t *)((UINT8 *)machine->driver_data + entry->sizeptroffs_plus1 - 1) = entry->byteend - entry->bytestart + 1; | |
| 2137 | if (entry->gensizeptroffs_plus1 != 0) | |
| 2138 | *(size_t *)((UINT8 *)&machine->generic + entry->gensizeptroffs_plus1 - 1) = entry->byteend - entry->bytestart + 1; | |
| 2072 | if (entry->m_baseptr != NULL) | |
| 2073 | *entry->m_baseptr = entry->m_memory; | |
| 2074 | if (entry->m_baseptroffs_plus1 != 0) | |
| 2075 | *(void **)(reinterpret_cast<UINT8 *>(machine->driver_data<void>()) + entry->m_baseptroffs_plus1 - 1) = entry->m_memory; | |
| 2076 | if (entry->m_genbaseptroffs_plus1 != 0) | |
| 2077 | *(void **)((UINT8 *)&machine->generic + entry->m_genbaseptroffs_plus1 - 1) = entry->m_memory; | |
| 2078 | if (entry->m_sizeptr != NULL) | |
| 2079 | *entry->m_sizeptr = entry->m_byteend - entry->m_bytestart + 1; | |
| 2080 | if (entry->m_sizeptroffs_plus1 != 0) | |
| 2081 | *(size_t *)(reinterpret_cast<UINT8 *>(machine->driver_data<void>()) + entry->m_sizeptroffs_plus1 - 1) = entry->m_byteend - entry->m_bytestart + 1; | |
| 2082 | if (entry->m_gensizeptroffs_plus1 != 0) | |
| 2083 | *(size_t *)((UINT8 *)&machine->generic + entry->m_gensizeptroffs_plus1 - 1) = entry->m_byteend - entry->m_bytestart + 1; | |
| 2139 | 2084 | } |
| 2140 | 2085 | } |
| 2141 | 2086 | |
| r8714 | r8715 | |
| 2148 | 2093 | |
| 2149 | 2094 | /* set the initial bank pointer */ |
| 2150 | 2095 | for (ref = bank->reflist; !foundit && ref != NULL; ref = ref->next) |
| 2151 | for (entry = ref->space->map->entrylist; entry != NULL; entry = entry->next) | |
| 2152 | if (entry->bytestart == bank->bytestart && entry->memory != NULL) | |
| 2096 | for (entry = ref->space->map->m_entrylist; entry != NULL; entry = entry->m_next) | |
| 2097 | if (entry->m_bytestart == bank->bytestart && entry->m_memory != NULL) | |
| 2153 | 2098 | { |
| 2154 | memdata->bank_ptr[bank->index] = (UINT8 *)entry->memory; | |
| 2099 | memdata->bank_ptr[bank->index] = (UINT8 *)entry->m_memory; | |
| 2155 | 2100 | foundit = TRUE; |
| 2156 | VPRINTF(("assigned bank '%s' pointer to memory from range %08X-%08X [%p]\n", bank->tag, entry->addrstart, entry->addrend, entry->memory)); | |
| 2101 | VPRINTF(("assigned bank '%s' pointer to memory from range %08X-%08X [%p]\n", bank->tag, entry->m_addrstart, entry->m_addrend, entry->m_memory)); | |
| 2157 | 2102 | break; |
| 2158 | 2103 | } |
| 2159 | 2104 | |
| r8714 | r8715 | |
| 2180 | 2125 | for (space = (address_space *)memdata->spacelist; space != NULL; space = space->next) |
| 2181 | 2126 | { |
| 2182 | 2127 | /* free the address map and tables */ |
| 2183 | if (space->map != NULL) | |
| 2184 | address_map_free(space->map); | |
| 2128 | global_free(space->map); | |
| 2185 | 2129 | } |
| 2186 | 2130 | } |
| 2187 | 2131 | |
| 2188 | 2132 | |
| 2189 | 2133 | |
| 2190 | 2134 | /*************************************************************************** |
| 2191 | ADDRESS MAP HELPERS | |
| 2192 | ***************************************************************************/ | |
| 2193 | ||
| 2194 | /*------------------------------------------------- | |
| 2195 | map_detokenize - detokenize an array of | |
| 2196 | address map tokens | |
| 2197 | -------------------------------------------------*/ | |
| 2198 | ||
| 2199 | #define check_map(field) do { \ | |
| 2200 | if (map->field != 0 && map->field != tmap.field) \ | |
| 2201 | fatalerror("%s: %s included a mismatched address map (%s %d) for an existing map with %s %d!\n", driver->source_file, driver->name, #field, tmap.field, #field, map->field); \ | |
| 2202 | } while (0) | |
| 2203 | ||
| 2204 | #define check_entry_handler(row) do { \ | |
| 2205 | if (entry->row.type != AMH_NONE) \ | |
| 2206 | fatalerror("%s: %s AM_RANGE(0x%x, 0x%x) %s handler already set!\n", driver->source_file, driver->name, entry->addrstart, entry->addrend, #row); \ | |
| 2207 | } while (0) | |
| 2208 | ||
| 2209 | #define check_entry_field(field) do { \ | |
| 2210 | if (entry->field != 0) \ | |
| 2211 | fatalerror("%s: %s AM_RANGE(0x%x, 0x%x) setting %s already set!\n", driver->source_file, driver->name, entry->addrstart, entry->addrend, #field); \ | |
| 2212 | } while (0) | |
| 2213 | ||
| 2214 | static void map_detokenize(memory_private *memdata, address_map *map, const game_driver *driver, const device_config *devconfig, const addrmap_token *tokens) | |
| 2215 | { | |
| 2216 | address_map_entry **firstentryptr; | |
| 2217 | address_map_entry **entryptr; | |
| 2218 | address_map_entry *entry; | |
| 2219 | address_map tmap = {0}; | |
| 2220 | UINT32 entrytype; | |
| 2221 | int maptype; | |
| 2222 | ||
| 2223 | /* check the first token */ | |
| 2224 | TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, tmap.spacenum, 8, tmap.databits, 8); | |
| 2225 | if (entrytype != ADDRMAP_TOKEN_START) | |
| 2226 | fatalerror("%s: %s Address map missing ADDRMAP_TOKEN_START!\n", driver->source_file, driver->name); | |
| 2227 | if (tmap.spacenum >= ADDRESS_SPACES) | |
| 2228 | fatalerror("%s: %s Invalid address space %d for memory map!\n", driver->source_file, driver->name, tmap.spacenum); | |
| 2229 | if (tmap.databits != 8 && tmap.databits != 16 && tmap.databits != 32 && tmap.databits != 64) | |
| 2230 | fatalerror("%s: %s Invalid data bits %d for memory map!\n", driver->source_file, driver->name, tmap.databits); | |
| 2231 | check_map(spacenum); | |
| 2232 | check_map(databits); | |
| 2233 | ||
| 2234 | /* fill in the map values */ | |
| 2235 | map->spacenum = tmap.spacenum; | |
| 2236 | map->databits = tmap.databits; | |
| 2237 | ||
| 2238 | /* find the end of the list */ | |
| 2239 | for (entryptr = &map->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next) ; | |
| 2240 | firstentryptr = entryptr; | |
| 2241 | entry = NULL; | |
| 2242 | ||
| 2243 | /* loop over tokens until we hit the end */ | |
| 2244 | while (entrytype != ADDRMAP_TOKEN_END) | |
| 2245 | { | |
| 2246 | /* unpack the token from the first entry */ | |
| 2247 | TOKEN_GET_UINT32_UNPACK1(tokens, entrytype, 8); | |
| 2248 | switch (entrytype) | |
| 2249 | { | |
| 2250 | /* end */ | |
| 2251 | case ADDRMAP_TOKEN_END: | |
| 2252 | break; | |
| 2253 | ||
| 2254 | /* including */ | |
| 2255 | case ADDRMAP_TOKEN_INCLUDE: | |
| 2256 | map_detokenize(memdata, map, driver, devconfig, TOKEN_GET_PTR(tokens, tokenptr)); | |
| 2257 | for (entryptr = &map->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next) ; | |
| 2258 | entry = NULL; | |
| 2259 | break; | |
| 2260 | ||
| 2261 | /* global flags */ | |
| 2262 | case ADDRMAP_TOKEN_GLOBAL_MASK: | |
| 2263 | TOKEN_UNGET_UINT32(tokens); | |
| 2264 | TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, tmap.globalmask, 32); | |
| 2265 | check_map(globalmask); | |
| 2266 | map->globalmask = tmap.globalmask; | |
| 2267 | break; | |
| 2268 | ||
| 2269 | case ADDRMAP_TOKEN_UNMAP_VALUE: | |
| 2270 | TOKEN_UNGET_UINT32(tokens); | |
| 2271 | TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, tmap.unmapval, 1); | |
| 2272 | check_map(unmapval); | |
| 2273 | map->unmapval = tmap.unmapval; | |
| 2274 | break; | |
| 2275 | ||
| 2276 | /* start a new range */ | |
| 2277 | case ADDRMAP_TOKEN_RANGE: | |
| 2278 | entry = *entryptr = global_alloc_clear(address_map_entry); | |
| 2279 | entryptr = &entry->next; | |
| 2280 | TOKEN_GET_UINT64_UNPACK2(tokens, entry->addrstart, 32, entry->addrend, 32); | |
| 2281 | break; | |
| 2282 | ||
| 2283 | case ADDRMAP_TOKEN_MASK: | |
| 2284 | check_entry_field(addrmask); | |
| 2285 | TOKEN_UNGET_UINT32(tokens); | |
| 2286 | TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->addrmask, 32); | |
| 2287 | break; | |
| 2288 | ||
| 2289 | case ADDRMAP_TOKEN_MIRROR: | |
| 2290 | check_entry_field(addrmirror); | |
| 2291 | TOKEN_UNGET_UINT32(tokens); | |
| 2292 | TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->addrmirror, 32); | |
| 2293 | if (entry->addrmirror != 0) | |
| 2294 | { | |
| 2295 | entry->addrstart &= ~entry->addrmirror; | |
| 2296 | entry->addrend &= ~entry->addrmirror; | |
| 2297 | } | |
| 2298 | break; | |
| 2299 | ||
| 2300 | case ADDRMAP_TOKEN_READ: | |
| 2301 | check_entry_handler(read); | |
| 2302 | TOKEN_UNGET_UINT32(tokens); | |
| 2303 | TOKEN_GET_UINT32_UNPACK4(tokens, entrytype, 8, maptype, 8, entry->read.bits, 8, entry->read.mask, 8); | |
| 2304 | entry->read.type = (map_handler_type)maptype; | |
| 2305 | if (entry->read.type == AMH_HANDLER || entry->read.type == AMH_DEVICE_HANDLER) | |
| 2306 | { | |
| 2307 | entry->read.handler.read = TOKEN_GET_PTR(tokens, read); | |
| 2308 | entry->read.name = TOKEN_GET_STRING(tokens); | |
| 2309 | } | |
| 2310 | if (entry->read.type == AMH_DEVICE_HANDLER || entry->read.type == AMH_PORT || entry->read.type == AMH_BANK) | |
| 2311 | entry->read.tag = devconfig->siblingtag(entry->read.derived_tag, TOKEN_GET_STRING(tokens)); | |
| 2312 | break; | |
| 2313 | ||
| 2314 | case ADDRMAP_TOKEN_WRITE: | |
| 2315 | check_entry_handler(write); | |
| 2316 | TOKEN_UNGET_UINT32(tokens); | |
| 2317 | TOKEN_GET_UINT32_UNPACK4(tokens, entrytype, 8, maptype, 8, entry->write.bits, 8, entry->write.mask, 8); | |
| 2318 | entry->write.type = (map_handler_type)maptype; | |
| 2319 | if (entry->write.type == AMH_HANDLER || entry->write.type == AMH_DEVICE_HANDLER) | |
| 2320 | { | |
| 2321 | entry->write.handler.write = TOKEN_GET_PTR(tokens, write); | |
| 2322 | entry->write.name = TOKEN_GET_STRING(tokens); | |
| 2323 | } | |
| 2324 | if (entry->write.type == AMH_DEVICE_HANDLER || entry->write.type == AMH_PORT || entry->write.type == AMH_BANK) | |
| 2325 | entry->write.tag = devconfig->siblingtag(entry->write.derived_tag, TOKEN_GET_STRING(tokens)); | |
| 2326 | break; | |
| 2327 | ||
| 2328 | case ADDRMAP_TOKEN_READWRITE: | |
| 2329 | check_entry_handler(read); | |
| 2330 | check_entry_handler(write); | |
| 2331 | TOKEN_UNGET_UINT32(tokens); | |
| 2332 | TOKEN_GET_UINT32_UNPACK4(tokens, entrytype, 8, maptype, 8, entry->read.bits, 8, entry->read.mask, 8); | |
| 2333 | entry->write.type = entry->read.type = (map_handler_type)maptype; | |
| 2334 | entry->write.bits = entry->read.bits; | |
| 2335 | entry->write.mask = entry->read.mask; | |
| 2336 | if (entry->read.type == AMH_HANDLER || entry->read.type == AMH_DEVICE_HANDLER) | |
| 2337 | { | |
| 2338 | entry->read.handler.read = TOKEN_GET_PTR(tokens, read); | |
| 2339 | entry->read.name = TOKEN_GET_STRING(tokens); | |
| 2340 | entry->write.handler.write = TOKEN_GET_PTR(tokens, write); | |
| 2341 | entry->write.name = TOKEN_GET_STRING(tokens); | |
| 2342 | } | |
| 2343 | if (entry->read.type == AMH_DEVICE_HANDLER || entry->read.type == AMH_PORT || entry->read.type == AMH_BANK) | |
| 2344 | { | |
| 2345 | const char *basetag = TOKEN_GET_STRING(tokens); | |
| 2346 | entry->read.tag = devconfig->siblingtag(entry->read.derived_tag, basetag); | |
| 2347 | entry->write.tag = devconfig->siblingtag(entry->write.derived_tag, basetag); | |
| 2348 | } | |
| 2349 | break; | |
| 2350 | ||
| 2351 | case ADDRMAP_TOKEN_REGION: | |
| 2352 | check_entry_field(region); | |
| 2353 | TOKEN_UNGET_UINT32(tokens); | |
| 2354 | TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->rgnoffs, 32); | |
| 2355 | entry->region = devconfig->siblingtag(entry->region_string, TOKEN_GET_STRING(tokens)); | |
| 2356 | break; | |
| 2357 | ||
| 2358 | case ADDRMAP_TOKEN_SHARE: | |
| 2359 | check_entry_field(share); | |
| 2360 | entry->share = TOKEN_GET_STRING(tokens); | |
| 2361 | if (memdata != NULL) | |
| 2362 | memdata->sharemap.add(entry->share, UNMAPPED_SHARE_PTR, FALSE); | |
| 2363 | break; | |
| 2364 | ||
| 2365 | case ADDRMAP_TOKEN_BASEPTR: | |
| 2366 | check_entry_field(baseptr); | |
| 2367 | entry->baseptr = (void **)TOKEN_GET_PTR(tokens, voidptr); | |
| 2368 | break; | |
| 2369 | ||
| 2370 | case ADDRMAP_TOKEN_BASE_MEMBER: | |
| 2371 | check_entry_field(baseptroffs_plus1); | |
| 2372 | TOKEN_UNGET_UINT32(tokens); | |
| 2373 | TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->baseptroffs_plus1, 24); | |
| 2374 | entry->baseptroffs_plus1++; | |
| 2375 | break; | |
| 2376 | ||
| 2377 | case ADDRMAP_TOKEN_BASE_GENERIC: | |
| 2378 | check_entry_field(genbaseptroffs_plus1); | |
| 2379 | TOKEN_UNGET_UINT32(tokens); | |
| 2380 | TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->genbaseptroffs_plus1, 24); | |
| 2381 | entry->genbaseptroffs_plus1++; | |
| 2382 | break; | |
| 2383 | ||
| 2384 | case ADDRMAP_TOKEN_SIZEPTR: | |
| 2385 | check_entry_field(sizeptr); | |
| 2386 | entry->sizeptr = TOKEN_GET_PTR(tokens, sizeptr); | |
| 2387 | break; | |
| 2388 | ||
| 2389 | case ADDRMAP_TOKEN_SIZE_MEMBER: | |
| 2390 | check_entry_field(sizeptroffs_plus1); | |
| 2391 | TOKEN_UNGET_UINT32(tokens); | |
| 2392 | TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->sizeptroffs_plus1, 24); | |
| 2393 | entry->sizeptroffs_plus1++; | |
| 2394 | break; | |
| 2395 | ||
| 2396 | case ADDRMAP_TOKEN_SIZE_GENERIC: | |
| 2397 | check_entry_field(gensizeptroffs_plus1); | |
| 2398 | TOKEN_UNGET_UINT32(tokens); | |
| 2399 | TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->gensizeptroffs_plus1, 24); | |
| 2400 | entry->gensizeptroffs_plus1++; | |
| 2401 | break; | |
| 2402 | ||
| 2403 | default: | |
| 2404 | fatalerror("Invalid token %d in address map\n", entrytype); | |
| 2405 | break; | |
| 2406 | } | |
| 2407 | } | |
| 2408 | ||
| 2409 | /* post-process to apply the global mask */ | |
| 2410 | if (map->globalmask != 0) | |
| 2411 | for (entry = map->entrylist; entry != NULL; entry = entry->next) | |
| 2412 | { | |
| 2413 | entry->addrstart &= map->globalmask; | |
| 2414 | entry->addrend &= map->globalmask; | |
| 2415 | entry->addrmask &= map->globalmask; | |
| 2416 | } | |
| 2417 | } | |
| 2418 | ||
| 2419 | ||
| 2420 | ||
| 2421 | /*************************************************************************** | |
| 2422 | 2135 | MEMORY MAPPING HELPERS |
| 2423 | 2136 | ***************************************************************************/ |
| 2424 | 2137 | |
| r8714 | r8715 | |
| 2498 | 2211 | VPRINTF(("space_find_backing_memory('%s',%s,%08X-%08X) -> ", space->cpu->tag(), space->name, bytestart, byteend)); |
| 2499 | 2212 | |
| 2500 | 2213 | /* look in the address map first */ |
| 2501 | for (entry = space->map->entrylist; entry != NULL; entry = entry->next) | |
| 2214 | for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next) | |
| 2502 | 2215 | { |
| 2503 | offs_t maskstart = bytestart & entry->bytemask; | |
| 2504 | offs_t maskend = byteend & entry->bytemask; | |
| 2505 | if (entry->memory != NULL && maskstart >= entry->bytestart && maskend <= entry->byteend) | |
| 2216 | offs_t maskstart = bytestart & entry->m_bytemask; | |
| 2217 | offs_t maskend = byteend & entry->m_bytemask; | |
| 2218 | if (entry->m_memory != NULL && maskstart >= entry->m_bytestart && maskend <= entry->m_byteend) | |
| 2506 | 2219 | { |
| 2507 | VPRINTF(("found in entry %08X-%08X [%p]\n", entry->addrstart, entry->addrend, (UINT8 *)entry->memory + (maskstart - entry->bytestart))); | |
| 2508 | return (UINT8 *)entry->memory + (maskstart - entry->bytestart); | |
| 2220 | VPRINTF(("found in entry %08X-%08X [%p]\n", entry->m_addrstart, entry->m_addrend, (UINT8 *)entry->m_memory + (maskstart - entry->m_bytestart))); | |
| 2221 | return (UINT8 *)entry->m_memory + (maskstart - entry->m_bytestart); | |
| 2509 | 2222 | } |
| 2510 | 2223 | } |
| 2511 | 2224 | |
| r8714 | r8715 | |
| 2531 | 2244 | static int space_needs_backing_store(const address_space *space, const address_map_entry *entry) |
| 2532 | 2245 | { |
| 2533 | 2246 | /* if we are asked to provide a base pointer, then yes, we do need backing */ |
| 2534 | if (entry->baseptr != NULL || entry->baseptroffs_plus1 != 0 || entry->genbaseptroffs_plus1 != 0) | |
| 2247 | if (entry->m_baseptr != NULL || entry->m_baseptroffs_plus1 != 0 || entry->m_genbaseptroffs_plus1 != 0) | |
| 2535 | 2248 | return TRUE; |
| 2536 | 2249 | |
| 2537 | 2250 | /* if we're writing to any sort of bank or RAM, then yes, we do need backing */ |
| 2538 | if (entry->write.type == AMH_BANK || entry->write.type == AMH_RAM) | |
| 2251 | if (entry->m_write.type == AMH_BANK || entry->m_write.type == AMH_RAM) | |
| 2539 | 2252 | return TRUE; |
| 2540 | 2253 | |
| 2541 | 2254 | /* if we're reading from RAM or from ROM outside of address space 0 or its region, then yes, we do need backing */ |
| 2542 | 2255 | const region_info *region = space->machine->region(space->cpu->tag()); |
| 2543 | if (entry->read.type == AMH_RAM || | |
| 2544 | (entry->read.type == AMH_ROM && (space->spacenum != ADDRESS_SPACE_0 || region == NULL || entry->addrstart >= region->bytes()))) | |
| 2256 | if (entry->m_read.type == AMH_RAM || | |
| 2257 | (entry->m_read.type == AMH_ROM && (space->spacenum != ADDRESS_SPACE_0 || region == NULL || entry->m_addrstart >= region->bytes()))) | |
| 2545 | 2258 | return TRUE; |
| 2546 | 2259 | |
| 2547 | 2260 | /* all other cases don't need backing */ |
| r8714 | r8715 | |
| 3384 | 3097 | address_map_entry *entry, *unassigned = NULL; |
| 3385 | 3098 | |
| 3386 | 3099 | /* loop over the adjusted map and assign memory to any blocks we can */ |
| 3387 | for (entry = space->map->entrylist; entry != NULL; entry = entry->next) | |
| 3100 | for (entry = space->map->m_entrylist; entry != NULL; entry = entry->m_next) | |
| 3388 | 3101 | { |
| 3389 | 3102 | /* if we haven't assigned this block yet, see if we have a mapped shared pointer for it */ |
| 3390 | if (entry->memory == NULL && entry->share != NULL) | |
| 3103 | if (entry->m_memory == NULL && entry->m_share != NULL) | |
| 3391 | 3104 | { |
| 3392 | void *shareptr = memdata->sharemap.find(entry->share); | |
| 3105 | void *shareptr = memdata->sharemap.find(entry->m_share); | |
| 3393 | 3106 | if (shareptr != UNMAPPED_SHARE_PTR) |
| 3394 | 3107 | { |
| 3395 | entry->memory = shareptr; | |
| 3396 | VPRINTF(("memory range %08X-%08X -> shared_ptr '%s' [%p]\n", entry->addrstart, entry->addrend, entry->share, entry->memory)); | |
| 3108 | entry->m_memory = shareptr; | |
| 3109 | VPRINTF(("memory range %08X-%08X -> shared_ptr '%s' [%p]\n", entry->m_addrstart, entry->m_addrend, entry->m_share, entry->m_memory)); | |
| 3397 | 3110 | } |
| 3398 | 3111 | } |
| 3399 | 3112 | |
| 3400 | 3113 | /* otherwise, look for a match in this block */ |
| 3401 | if (entry->memory == NULL && entry->bytestart >= bytestart && entry->byteend <= byteend) | |
| 3114 | if (entry->m_memory == NULL && entry->m_bytestart >= bytestart && entry->m_byteend <= byteend) | |
| 3402 | 3115 | { |
| 3403 | entry->memory = base + (entry->bytestart - bytestart); | |
| 3404 | VPRINTF(("memory range %08X-%08X -> found in block from %08X-%08X [%p]\n", entry->addrstart, entry->addrend, bytestart, byteend, entry->memory)); | |
| 3116 | entry->m_memory = base + (entry->m_bytestart - bytestart); | |
| 3117 | VPRINTF(("memory range %08X-%08X -> found in block from %08X-%08X [%p]\n", entry->m_addrstart, entry->m_addrend, bytestart, byteend, entry->m_memory)); | |
| 3405 | 3118 | } |
| 3406 | 3119 | |
| 3407 | 3120 | /* if we're the first match on a shared pointer, assign it now */ |
| 3408 | if (entry->memory != NULL && entry->share != NULL) | |
| 3121 | if (entry->m_memory != NULL && entry->m_share != NULL) | |
| 3409 | 3122 | { |
| 3410 | void *shareptr = memdata->sharemap.find(entry->share); | |
| 3123 | void *shareptr = memdata->sharemap.find(entry->m_share); | |
| 3411 | 3124 | if (shareptr == UNMAPPED_SHARE_PTR) |
| 3412 | memdata->sharemap.add(entry->share, entry->memory, TRUE); | |
| 3125 | memdata->sharemap.add(entry->m_share, entry->m_memory, TRUE); | |
| 3413 | 3126 | } |
| 3414 | 3127 | |
| 3415 | 3128 | /* keep track of the first unassigned entry */ |
| 3416 | if (entry->memory == NULL && unassigned == NULL && space_needs_backing_store(space, entry)) | |
| 3129 | if (entry->m_memory == NULL && unassigned == NULL && space_needs_backing_store(space, entry)) | |
| 3417 | 3130 | unassigned = entry; |
| 3418 | 3131 | } |
| 3419 | 3132 |
| r8714 | r8715 | |
|---|---|---|
| 37 | 37 | #------------------------------------------------- |
| 38 | 38 | |
| 39 | 39 | EMUOBJS = \ |
| 40 | $(EMUOBJ)/addrmap.o \ | |
| 40 | 41 | $(EMUOBJ)/attotime.o \ |
| 41 | 42 | $(EMUOBJ)/audit.o \ |
| 42 | 43 | $(EMUOBJ)/cheat.o \ |
| r8714 | r8715 | |
|---|---|---|
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | |
| 38 | /* address map handler types */ | |
| 39 | enum _map_handler_type | |
| 40 | { | |
| 41 | AMH_NONE = 0, | |
| 42 | AMH_RAM, | |
| 43 | AMH_ROM, | |
| 44 | AMH_NOP, | |
| 45 | AMH_UNMAP, | |
| 46 | AMH_HANDLER, | |
| 47 | AMH_DEVICE_HANDLER, | |
| 48 | AMH_PORT, | |
| 49 | AMH_BANK | |
| 50 | }; | |
| 51 | typedef enum _map_handler_type map_handler_type; | |
| 52 | 38 | |
| 53 | ||
| 54 | /* address map tokens */ | |
| 55 | enum | |
| 56 | { | |
| 57 | ADDRMAP_TOKEN_INVALID, | |
| 58 | ||
| 59 | ADDRMAP_TOKEN_START, | |
| 60 | ADDRMAP_TOKEN_END, | |
| 61 | ADDRMAP_TOKEN_INCLUDE, | |
| 62 | ||
| 63 | ADDRMAP_TOKEN_GLOBAL_MASK, | |
| 64 | ADDRMAP_TOKEN_UNMAP_VALUE, | |
| 65 | ||
| 66 | ADDRMAP_TOKEN_RANGE, | |
| 67 | ADDRMAP_TOKEN_MASK, | |
| 68 | ADDRMAP_TOKEN_MIRROR, | |
| 69 | ADDRMAP_TOKEN_READ, | |
| 70 | ADDRMAP_TOKEN_WRITE, | |
| 71 | ADDRMAP_TOKEN_READWRITE, | |
| 72 | ADDRMAP_TOKEN_REGION, | |
| 73 | ADDRMAP_TOKEN_SHARE, | |
| 74 | ADDRMAP_TOKEN_BASEPTR, | |
| 75 | ADDRMAP_TOKEN_BASE_MEMBER, | |
| 76 | ADDRMAP_TOKEN_BASE_GENERIC, | |
| 77 | ADDRMAP_TOKEN_SIZEPTR, | |
| 78 | ADDRMAP_TOKEN_SIZE_MEMBER, | |
| 79 | ADDRMAP_TOKEN_SIZE_GENERIC | |
| 80 | }; | |
| 81 | ||
| 82 | ||
| 83 | ||
| 84 | 39 | /*************************************************************************** |
| 85 | 40 | TYPE DEFINITIONS |
| 86 | 41 | ***************************************************************************/ |
| r8714 | r8715 | |
| 88 | 43 | /* referenced types from other classes */ |
| 89 | 44 | class device_config; |
| 90 | 45 | class device_t; |
| 46 | class address_map; | |
| 91 | 47 | struct game_driver; |
| 92 | 48 | |
| 93 | 49 | |
| r8714 | r8715 | |
| 169 | 125 | }; |
| 170 | 126 | |
| 171 | 127 | |
| 172 | /* read_handler is a union of all the different read handler types */ | |
| 173 | typedef union _read_handler read_handler; | |
| 174 | union _read_handler | |
| 175 | { | |
| 176 | genf * generic; /* generic function pointer */ | |
| 177 | read8_space_func shandler8; /* 8-bit space read handler */ | |
| 178 | read16_space_func shandler16; /* 16-bit space read handler */ | |
| 179 | read32_space_func shandler32; /* 32-bit space read handler */ | |
| 180 | read64_space_func shandler64; /* 64-bit space read handler */ | |
| 181 | read8_device_func dhandler8; /* 8-bit device read handler */ | |
| 182 | read16_device_func dhandler16; /* 16-bit device read handler */ | |
| 183 | read32_device_func dhandler32; /* 32-bit device read handler */ | |
| 184 | read64_device_func dhandler64; /* 64-bit device read handler */ | |
| 185 | }; | |
| 186 | ||
| 187 | ||
| 188 | /* write_handler is a union of all the different write handler types */ | |
| 189 | typedef union _write_handler write_handler; | |
| 190 | union _write_handler | |
| 191 | { | |
| 192 | genf * generic; /* generic function pointer */ | |
| 193 | write8_space_func shandler8; /* 8-bit space write handler */ | |
| 194 | write16_space_func shandler16; /* 16-bit space write handler */ | |
| 195 | write32_space_func shandler32; /* 32-bit space write handler */ | |
| 196 | write64_space_func shandler64; /* 64-bit space write handler */ | |
| 197 | write8_device_func dhandler8; /* 8-bit device write handler */ | |
| 198 | write16_device_func dhandler16; /* 16-bit device write handler */ | |
| 199 | write32_device_func dhandler32; /* 32-bit device write handler */ | |
| 200 | write64_device_func dhandler64; /* 64-bit device write handler */ | |
| 201 | }; | |
| 202 | ||
| 203 | ||
| 204 | /* memory_handler is a union of all read and write handler types */ | |
| 205 | typedef union _memory_handler memory_handler; | |
| 206 | union _memory_handler | |
| 207 | { | |
| 208 | genf * generic; /* generic function pointer */ | |
| 209 | read_handler read; /* read handler union */ | |
| 210 | write_handler write; /* write handler union */ | |
| 211 | }; | |
| 212 | ||
| 213 | ||
| 214 | /* address map handler data */ | |
| 215 | typedef struct _map_handler_data map_handler_data; | |
| 216 | struct _map_handler_data | |
| 217 | { | |
| 218 | map_handler_type type; /* type of the handler */ | |
| 219 | UINT8 bits; /* width of the handler in bits, or 0 for default */ | |
| 220 | UINT8 mask; /* mask for which lanes apply */ | |
| 221 | memory_handler handler; /* a memory handler */ | |
| 222 | const char * name; /* name of the handler */ | |
| 223 | const char * tag; /* tag pointing to a reference */ | |
| 224 | astring derived_tag; /* string used to hold derived names */ | |
| 225 | }; | |
| 226 | ||
| 227 | ||
| 228 | /* address_map_entry is a linked list element describing one address range in a map */ | |
| 229 | typedef struct _address_map_entry address_map_entry; | |
| 230 | struct _address_map_entry | |
| 231 | { | |
| 232 | address_map_entry * next; /* pointer to the next entry */ | |
| 233 | astring region_string; /* string used to hold derived names */ | |
| 234 | ||
| 235 | offs_t addrstart; /* start address */ | |
| 236 | offs_t addrend; /* end address */ | |
| 237 | offs_t addrmirror; /* mirror bits */ | |
| 238 | offs_t addrmask; /* mask bits */ | |
| 239 | map_handler_data read; /* data for read handler */ | |
| 240 | map_handler_data write; /* data for write handler */ | |
| 241 | const char * share; /* tag of a shared memory block */ | |
| 242 | void ** baseptr; /* receives pointer to memory (optional) */ | |
| 243 | size_t * sizeptr; /* receives size of area in bytes (optional) */ | |
| 244 | UINT32 baseptroffs_plus1; /* offset of base pointer within driver_data, plus 1 */ | |
| 245 | UINT32 sizeptroffs_plus1; /* offset of size pointer within driver_data, plus 1 */ | |
| 246 | UINT32 genbaseptroffs_plus1;/* offset of base pointer within generic_pointers, plus 1 */ | |
| 247 | UINT32 gensizeptroffs_plus1;/* offset of size pointer within generic_pointers, plus 1 */ | |
| 248 | const char * region; /* tag of region containing the memory backing this entry */ | |
| 249 | offs_t rgnoffs; /* offset within the region */ | |
| 250 | ||
| 251 | void * memory; /* pointer to memory backing this entry */ | |
| 252 | offs_t bytestart; /* byte-adjusted start address */ | |
| 253 | offs_t byteend; /* byte-adjusted end address */ | |
| 254 | offs_t bytemirror; /* byte-adjusted mirror bits */ | |
| 255 | offs_t bytemask; /* byte-adjusted mask bits */ | |
| 256 | }; | |
| 257 | ||
| 258 | ||
| 259 | /* address_map holds global map parameters plus the head of the list of entries */ | |
| 260 | typedef struct _address_map address_map; | |
| 261 | struct _address_map | |
| 262 | { | |
| 263 | UINT8 spacenum; /* space number of the map */ | |
| 264 | UINT8 databits; /* data bits represented by the map */ | |
| 265 | UINT8 unmapval; /* unmapped memory value */ | |
| 266 | offs_t globalmask; /* global mask */ | |
| 267 | address_map_entry * entrylist; /* list of entries */ | |
| 268 | }; | |
| 269 | ||
| 270 | ||
| 271 | 128 | /* address_table contains information about read/write accesses within an address space */ |
| 272 | 129 | typedef struct _address_table address_table; |
| 273 | 130 | struct _address_table |
| r8714 | r8715 | |
| 314 | 171 | }; |
| 315 | 172 | |
| 316 | 173 | |
| 317 | /* addrmap_token is a union of all types for a generic address map */ | |
| 318 | typedef union _addrmap_token addrmap_token; | |
| 319 | union _addrmap_token | |
| 320 | { | |
| 321 | TOKEN_COMMON_FIELDS | |
| 322 | const addrmap_token * tokenptr; | |
| 323 | read_handler read; /* generic read handlers */ | |
| 324 | write_handler write; /* generic write handlers */ | |
| 325 | UINT8 ** memptr; /* memory pointer */ | |
| 326 | size_t * sizeptr; /* size pointer */ | |
| 327 | }; | |
| 328 | 174 | |
| 329 | ||
| 330 | /* addrmap8_token is a union of all types for an 8-bit address map */ | |
| 331 | typedef union _addrmap8_token addrmap8_token; | |
| 332 | union _addrmap8_token | |
| 333 | { | |
| 334 | TOKEN_COMMON_FIELDS | |
| 335 | const addrmap8_token * tokenptr; | |
| 336 | read8_space_func sread; /* pointer to native space read handler */ | |
| 337 | write8_space_func swrite; /* pointer to native space write handler */ | |
| 338 | read8_device_func dread; /* pointer to native device read handler */ | |
| 339 | write8_device_func dwrite; /* pointer to native device write handler */ | |
| 340 | read_handler read; /* generic read handlers */ | |
| 341 | write_handler write; /* generic write handlers */ | |
| 342 | UINT8 ** memptr; /* memory pointer */ | |
| 343 | size_t * sizeptr; /* size pointer */ | |
| 344 | ||
| 345 | operator const addrmap_token *() const { return reinterpret_cast<const addrmap_token *>(this); } | |
| 346 | }; | |
| 347 | ||
| 348 | ||
| 349 | /* addrmap16_token is a union of all types for a 16-bit address map */ | |
| 350 | typedef union _addrmap16_token addrmap16_token; | |
| 351 | union _addrmap16_token | |
| 352 | { | |
| 353 | TOKEN_COMMON_FIELDS | |
| 354 | const addrmap16_token * tokenptr; | |
| 355 | read16_space_func sread; /* pointer to native read handler */ | |
| 356 | write16_space_func swrite; /* pointer to native write handler */ | |
| 357 | read16_device_func dread; /* pointer to native device read handler */ | |
| 358 | write16_device_func dwrite; /* pointer to native device write handler */ | |
| 359 | read8_space_func sread8; /* pointer to 8-bit space read handler */ | |
| 360 | write8_space_func swrite8; /* pointer to 8-bit space write handler */ | |
| 361 | read8_device_func dread8; /* pointer to 8-bit device read handler */ | |
| 362 | write8_device_func dwrite8; /* pointer to 8-bit device write handler */ | |
| 363 | read_handler read; /* generic read handlers */ | |
| 364 | write_handler write; /* generic write handlers */ | |
| 365 | UINT16 ** memptr; /* memory pointer */ | |
| 366 | size_t * sizeptr; /* size pointer */ | |
| 367 | ||
| 368 | operator const addrmap_token *() const { return reinterpret_cast<const addrmap_token *>(this); } | |
| 369 | }; | |
| 370 | ||
| 371 | ||
| 372 | /* addrmap32_token is a union of all types for a 32-bit address map */ | |
| 373 | typedef union _addrmap32_token addrmap32_token; | |
| 374 | union _addrmap32_token | |
| 375 | { | |
| 376 | TOKEN_COMMON_FIELDS | |
| 377 | const addrmap32_token * tokenptr; | |
| 378 | read32_space_func sread; /* pointer to native read handler */ | |
| 379 | write32_space_func swrite; /* pointer to native write handler */ | |
| 380 | read32_device_func dread; /* pointer to native device read handler */ | |
| 381 | write32_device_func dwrite; /* pointer to native device write handler */ | |
| 382 | read8_space_func sread8; /* pointer to 8-bit space read handler */ | |
| 383 | write8_space_func swrite8; /* pointer to 8-bit space write handler */ | |
| 384 | read8_device_func dread8; /* pointer to 8-bit device read handler */ | |
| 385 | write8_device_func dwrite8; /* pointer to 8-bit device write handler */ | |
| 386 | read16_space_func sread16; /* pointer to 16-bit space read handler */ | |
| 387 | write16_space_func swrite16; /* pointer to 16-bit space write handler */ | |
| 388 | read16_device_func dread16; /* pointer to 16-bit device read handler */ | |
| 389 | write16_device_func dwrite16; /* pointer to 16-bit device write handler */ | |
| 390 | read_handler read; /* generic read handlers */ | |
| 391 | write_handler write; /* generic write handlers */ | |
| 392 | UINT32 ** memptr; /* memory pointer */ | |
| 393 | size_t * sizeptr; /* size pointer */ | |
| 394 | ||
| 395 | operator const addrmap_token *() const { return reinterpret_cast<const addrmap_token *>(this); } | |
| 396 | }; | |
| 397 | ||
| 398 | ||
| 399 | /* addrmap64_token is a union of all types for a 64-bit address map */ | |
| 400 | typedef union _addrmap64_token addrmap64_token; | |
| 401 | union _addrmap64_token | |
| 402 | { | |
| 403 | TOKEN_COMMON_FIELDS | |
| 404 | const addrmap64_token * tokenptr; | |
| 405 | read64_space_func sread; /* pointer to native read handler */ | |
| 406 | write64_space_func swrite; /* pointer to native write handler */ | |
| 407 | read64_device_func dread; /* pointer to native device read handler */ | |
| 408 | write64_device_func dwrite; /* pointer to native device write handler */ | |
| 409 | read8_space_func sread8; /* pointer to 8-bit space read handler */ | |
| 410 | write8_space_func swrite8; /* pointer to 8-bit space write handler */ | |
| 411 | read8_device_func dread8; /* pointer to 8-bit device read handler */ | |
| 412 | write8_device_func dwrite8; /* pointer to 8-bit device write handler */ | |
| 413 | read16_space_func sread16; /* pointer to 16-bit space read handler */ | |
| 414 | write16_space_func swrite16; /* pointer to 16-bit space write handler */ | |
| 415 | read16_device_func dread16; /* pointer to 16-bit device read handler */ | |
| 416 | write16_device_func dwrite16; /* pointer to 16-bit device write handler */ | |
| 417 | read32_space_func sread32; /* pointer to 32-bit space read handler */ | |
| 418 | write32_space_func swrite32; /* pointer to 32-bit space write handler */ | |
| 419 | read32_device_func dread32; /* pointer to 32-bit device read handler */ | |
| 420 | write32_device_func dwrite32; /* pointer to 32-bit device write handler */ | |
| 421 | read_handler read; /* generic read handlers */ | |
| 422 | write_handler write; /* generic write handlers */ | |
| 423 | UINT64 ** memptr; /* memory pointer */ | |
| 424 | size_t * sizeptr; /* size pointer */ | |
| 425 | ||
| 426 | operator const addrmap_token *() const { return reinterpret_cast<const addrmap_token *>(this); } | |
| 427 | }; | |
| 428 | ||
| 429 | ||
| 430 | ||
| 431 | 175 | /*************************************************************************** |
| 432 | 176 | MACROS |
| 433 | 177 | ***************************************************************************/ |
| r8714 | r8715 | |
| 603 | 347 | |
| 604 | 348 | |
| 605 | 349 | /*************************************************************************** |
| 606 | ADDRESS MAP MACROS | |
| 607 | ***************************************************************************/ | |
| 608 | ||
| 609 | /* so that "0" can be used for unneeded address maps */ | |
| 610 | #define address_map_0 NULL | |
| 611 | ||
| 612 | ||
| 613 | /* maps a full 64-bit mask down to an 8-bit byte mask */ | |
| 614 | #define UNITMASK8(x) \ | |
| 615 | ((((UINT64)(x) >> (63-7)) & 0x80) | \ | |
| 616 | (((UINT64)(x) >> (55-6)) & 0x40) | \ | |
| 617 | (((UINT64)(x) >> (47-5)) & 0x20) | \ | |
| 618 | (((UINT64)(x) >> (39-4)) & 0x10) | \ | |
| 619 | (((UINT64)(x) >> (31-3)) & 0x08) | \ | |
| 620 | (((UINT64)(x) >> (23-2)) & 0x04) | \ | |
| 621 | (((UINT64)(x) >> (15-1)) & 0x02) | \ | |
| 622 | (((UINT64)(x) >> ( 7-0)) & 0x01)) | |
| 623 | ||
| 624 | /* maps a full 64-bit mask down to a 4-bit word mask */ | |
| 625 | #define UNITMASK16(x) \ | |
| 626 | ((((UINT64)(x) >> (63-3)) & 0x08) | \ | |
| 627 | (((UINT64)(x) >> (47-2)) & 0x04) | \ | |
| 628 | (((UINT64)(x) >> (31-1)) & 0x02) | \ | |
| 629 | (((UINT64)(x) >> (15-0)) & 0x01)) | |
| 630 | ||
| 631 | /* maps a full 64-bit mask down to a 2-bit dword mask */ | |
| 632 | #define UNITMASK32(x) \ | |
| 633 | ((((UINT64)(x) >> (63-1)) & 0x02) | \ | |
| 634 | (((UINT64)(x) >> (31-0)) & 0x01)) | |
| 635 | ||
| 636 | ||
| 637 | ||
| 638 | /* start/end tags for the address map */ | |
| 639 | #define ADDRESS_MAP_NAME(_name) address_map_##_name | |
| 640 | #define ADDRESS_MAP_START(_name, _space, _bits) \ | |
| 641 | const addrmap##_bits##_token ADDRESS_MAP_NAME(_name)[] = { \ | |
| 642 | TOKEN_UINT32_PACK3(ADDRMAP_TOKEN_START, 8, _space, 8, _bits, 8), | |
| 643 | ||
| 644 | #define ADDRESS_MAP_END \ | |
| 645 | TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_END, 8) }; | |
| 646 | ||
| 647 | /* use this to declare external references to an address map */ | |
| 648 | #define ADDRESS_MAP_EXTERN(_name, _bits) \ | |
| 649 | extern const addrmap##_bits##_token ADDRESS_MAP_NAME(_name)[] | |
| 650 | ||
| 651 | ||
| 652 | /* global controls */ | |
| 653 | #define ADDRESS_MAP_GLOBAL_MASK(_mask) \ | |
| 654 | TOKEN_UINT64_PACK2(ADDRMAP_TOKEN_GLOBAL_MASK, 8, _mask, 32), | |
| 655 | ||
| 656 | #define ADDRESS_MAP_UNMAP_LOW \ | |
| 657 | TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_UNMAP_VALUE, 8, 0, 1), | |
| 658 | ||
| 659 | #define ADDRESS_MAP_UNMAP_HIGH \ | |
| 660 | TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_UNMAP_VALUE, 8, 1, 1), | |
| 661 | ||
| 662 | ||
| 663 | /* importing data from other address maps */ | |
| 664 | #define AM_IMPORT_FROM(_name) \ | |
| 665 | TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_INCLUDE, 8), \ | |
| 666 | TOKEN_PTR(tokenptr, ADDRESS_MAP_NAME(_name)), | |
| 667 | ||
| 668 | ||
| 669 | /* address ranges */ | |
| 670 | #define AM_RANGE(_start, _end) \ | |
| 671 | TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_RANGE, 8), \ | |
| 672 | TOKEN_UINT64_PACK2(_start, 32, _end, 32), | |
| 673 | ||
| 674 | #define AM_MASK(_mask) \ | |
| 675 | TOKEN_UINT64_PACK2(ADDRMAP_TOKEN_MASK, 8, _mask, 32), | |
| 676 | ||
| 677 | #define AM_MIRROR(_mirror) \ | |
| 678 | TOKEN_UINT64_PACK2(ADDRMAP_TOKEN_MIRROR, 8, _mirror, 32), | |
| 679 | ||
| 680 | ||
| 681 | /* space reads */ | |
| 682 | #define AM_READ(_handler) \ | |
| 683 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_HANDLER, 8, 0, 8, 0, 8), \ | |
| 684 | TOKEN_PTR(sread, _handler), \ | |
| 685 | TOKEN_STRING(#_handler), | |
| 686 | ||
| 687 | #define AM_READ8(_handler, _unitmask) \ | |
| 688 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_HANDLER, 8, 8, 8, UNITMASK8(_unitmask), 8), \ | |
| 689 | TOKEN_PTR(sread8, _handler), \ | |
| 690 | TOKEN_STRING(#_handler), | |
| 691 | ||
| 692 | #define AM_READ16(_handler, _unitmask) \ | |
| 693 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_HANDLER, 8, 16, 8, UNITMASK16(_unitmask), 8), \ | |
| 694 | TOKEN_PTR(sread16, _handler), \ | |
| 695 | TOKEN_STRING(#_handler), | |
| 696 | ||
| 697 | #define AM_READ32(_handler, _unitmask) \ | |
| 698 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_HANDLER, 8, 32, 8, UNITMASK32(_unitmask), 8), \ | |
| 699 | TOKEN_PTR(sread32, _handler), \ | |
| 700 | TOKEN_STRING(#_handler), | |
| 701 | ||
| 702 | ||
| 703 | /* space writes */ | |
| 704 | #define AM_WRITE(_handler) \ | |
| 705 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_HANDLER, 8, 0, 8, 0, 8), \ | |
| 706 | TOKEN_PTR(swrite, _handler), \ | |
| 707 | TOKEN_STRING(#_handler), | |
| 708 | ||
| 709 | #define AM_WRITE8(_handler, _unitmask) \ | |
| 710 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_HANDLER, 8, 8, 8, UNITMASK8(_unitmask), 8), \ | |
| 711 | TOKEN_PTR(swrite8, _handler), \ | |
| 712 | TOKEN_STRING(#_handler), | |
| 713 | ||
| 714 | #define AM_WRITE16(_handler, _unitmask) \ | |
| 715 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_HANDLER, 8, 16, 8, UNITMASK16(_unitmask), 8), \ | |
| 716 | TOKEN_PTR(swrite16, _handler), \ | |
| 717 | TOKEN_STRING(#_handler), | |
| 718 | ||
| 719 | #define AM_WRITE32(_handler, _unitmask) \ | |
| 720 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_HANDLER, 8, 32, 8, UNITMASK32(_unitmask), 8), \ | |
| 721 | TOKEN_PTR(swrite32, _handler), \ | |
| 722 | TOKEN_STRING(#_handler), | |
| 723 | ||
| 724 | ||
| 725 | /* space reads/writes */ | |
| 726 | #define AM_READWRITE(_rhandler, _whandler) \ | |
| 727 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_HANDLER, 8, 0, 8, 0, 8), \ | |
| 728 | TOKEN_PTR(sread, _rhandler), \ | |
| 729 | TOKEN_STRING(#_rhandler), \ | |
| 730 | TOKEN_PTR(swrite, _whandler), \ | |
| 731 | TOKEN_STRING(#_whandler), | |
| 732 | ||
| 733 | #define AM_READWRITE8(_rhandler, _whandler, _unitmask) \ | |
| 734 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_HANDLER, 8, 8, 8, UNITMASK8(_unitmask), 8), \ | |
| 735 | TOKEN_PTR(sread8, _rhandler), \ | |
| 736 | TOKEN_STRING(#_rhandler), \ | |
| 737 | TOKEN_PTR(swrite8, _whandler), \ | |
| 738 | TOKEN_STRING(#_whandler), | |
| 739 | ||
| 740 | #define AM_READWRITE16(_rhandler, _whandler, _unitmask) \ | |
| 741 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_HANDLER, 8, 16, 8, UNITMASK16(_unitmask), 8), \ | |
| 742 | TOKEN_PTR(sread16, _rhandler), \ | |
| 743 | TOKEN_STRING(#_rhandler), \ | |
| 744 | TOKEN_PTR(swrite16, _whandler), \ | |
| 745 | TOKEN_STRING(#_whandler), | |
| 746 | ||
| 747 | #define AM_READWRITE32(_rhandler, _whandler, _unitmask) \ | |
| 748 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_HANDLER, 8, 32, 8, UNITMASK32(_unitmask), 8), \ | |
| 749 | TOKEN_PTR(sread32, _rhandler), \ | |
| 750 | TOKEN_STRING(#_rhandler), \ | |
| 751 | TOKEN_PTR(swrite32, _whandler), \ | |
| 752 | TOKEN_STRING(#_whandler), | |
| 753 | ||
| 754 | ||
| 755 | /* device reads */ | |
| 756 | #define AM_DEVREAD(_tag, _handler) \ | |
| 757 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_DEVICE_HANDLER, 8, 0, 8, 0, 8), \ | |
| 758 | TOKEN_PTR(dread, _handler), \ | |
| 759 | TOKEN_STRING(#_handler), \ | |
| 760 | TOKEN_STRING(_tag), | |
| 761 | ||
| 762 | #define AM_DEVREAD8(_tag, _handler, _unitmask) \ | |
| 763 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_DEVICE_HANDLER, 8, 8, 8, UNITMASK8(_unitmask), 8), \ | |
| 764 | TOKEN_PTR(dread8, _handler), \ | |
| 765 | TOKEN_STRING(#_handler), \ | |
| 766 | TOKEN_STRING(_tag), | |
| 767 | ||
| 768 | #define AM_DEVREAD16(_tag, _handler, _unitmask) \ | |
| 769 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_DEVICE_HANDLER, 8, 16, 8, UNITMASK16(_unitmask), 8), \ | |
| 770 | TOKEN_PTR(dread16, _handler), \ | |
| 771 | TOKEN_STRING(#_handler), \ | |
| 772 | TOKEN_STRING(_tag), | |
| 773 | ||
| 774 | #define AM_DEVREAD32(_tag, _handler, _unitmask) \ | |
| 775 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_DEVICE_HANDLER, 8, 32, 8, UNITMASK32(_unitmask), 8), \ | |
| 776 | TOKEN_PTR(dread32, _handler), \ | |
| 777 | TOKEN_STRING(#_handler), \ | |
| 778 | TOKEN_STRING(_tag), | |
| 779 | ||
| 780 | ||
| 781 | /* device writes */ | |
| 782 | #define AM_DEVWRITE(_tag, _handler) \ | |
| 783 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_DEVICE_HANDLER, 8, 0, 8, 0, 8), \ | |
| 784 | TOKEN_PTR(dwrite, _handler), \ | |
| 785 | TOKEN_STRING(#_handler), \ | |
| 786 | TOKEN_STRING(_tag), | |
| 787 | ||
| 788 | #define AM_DEVWRITE8(_tag, _handler, _unitmask) \ | |
| 789 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_DEVICE_HANDLER, 8, 8, 8, UNITMASK8(_unitmask), 8), \ | |
| 790 | TOKEN_PTR(dwrite8, _handler), \ | |
| 791 | TOKEN_STRING(#_handler), \ | |
| 792 | TOKEN_STRING(_tag), | |
| 793 | ||
| 794 | #define AM_DEVWRITE16(_tag, _handler, _unitmask) \ | |
| 795 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_DEVICE_HANDLER, 8, 16, 8, UNITMASK16(_unitmask), 8), \ | |
| 796 | TOKEN_PTR(dwrite16, _handler), \ | |
| 797 | TOKEN_STRING(#_handler), \ | |
| 798 | TOKEN_STRING(_tag), | |
| 799 | ||
| 800 | #define AM_DEVWRITE32(_tag, _handler, _unitmask) \ | |
| 801 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_DEVICE_HANDLER, 8, 32, 8, UNITMASK32(_unitmask), 8), \ | |
| 802 | TOKEN_PTR(dwrite32, _handler), \ | |
| 803 | TOKEN_STRING(#_handler), \ | |
| 804 | TOKEN_STRING(_tag), | |
| 805 | ||
| 806 | ||
| 807 | /* device reads/writes */ | |
| 808 | #define AM_DEVREADWRITE(_tag, _rhandler, _whandler) \ | |
| 809 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_DEVICE_HANDLER, 8, 0, 8, 0, 8), \ | |
| 810 | TOKEN_PTR(dread, _rhandler), \ | |
| 811 | TOKEN_STRING(#_rhandler), \ | |
| 812 | TOKEN_PTR(dwrite, _whandler), \ | |
| 813 | TOKEN_STRING(#_whandler), \ | |
| 814 | TOKEN_STRING(_tag), | |
| 815 | ||
| 816 | #define AM_DEVREADWRITE8(_tag, _rhandler, _whandler, _unitmask) \ | |
| 817 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_DEVICE_HANDLER, 8, 8, 8, UNITMASK8(_unitmask), 8), \ | |
| 818 | TOKEN_PTR(dread8, _rhandler), \ | |
| 819 | TOKEN_STRING(#_rhandler), \ | |
| 820 | TOKEN_PTR(dwrite8, _whandler), \ | |
| 821 | TOKEN_STRING(#_whandler), \ | |
| 822 | TOKEN_STRING(_tag), | |
| 823 | ||
| 824 | #define AM_DEVREADWRITE16(_tag, _rhandler, _whandler, _unitmask) \ | |
| 825 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_DEVICE_HANDLER, 8, 16, 8, UNITMASK16(_unitmask), 8), \ | |
| 826 | TOKEN_PTR(dread16, _rhandler), \ | |
| 827 | TOKEN_STRING(#_rhandler), \ | |
| 828 | TOKEN_PTR(dwrite16, _whandler), \ | |
| 829 | TOKEN_STRING(#_whandler), \ | |
| 830 | TOKEN_STRING(_tag), | |
| 831 | ||
| 832 | #define AM_DEVREADWRITE32(_tag, _rhandler, _whandler, _unitmask) \ | |
| 833 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_DEVICE_HANDLER, 8, 32, 8, UNITMASK32(_unitmask), 8), \ | |
| 834 | TOKEN_PTR(dread32, _rhandler), \ | |
| 835 | TOKEN_STRING(#_rhandler), \ | |
| 836 | TOKEN_PTR(dwrite32, _whandler), \ | |
| 837 | TOKEN_STRING(#_whandler), \ | |
| 838 | TOKEN_STRING(_tag), | |
| 839 | ||
| 840 | ||
| 841 | /* special-case accesses */ | |
| 842 | #define AM_ROM \ | |
| 843 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_ROM, 8, 0, 8, 0, 8), | |
| 844 | ||
| 845 | #define AM_RAM \ | |
| 846 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_RAM, 8, 0, 8, 0, 8), | |
| 847 | ||
| 848 | #define AM_READONLY \ | |
| 849 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_RAM, 8, 0, 8, 0, 8), | |
| 850 | ||
| 851 | #define AM_WRITEONLY \ | |
| 852 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_RAM, 8, 0, 8, 0, 8), | |
| 853 | ||
| 854 | #define AM_UNMAP \ | |
| 855 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_UNMAP, 8, 0, 8, 0, 8), | |
| 856 | ||
| 857 | #define AM_NOP \ | |
| 858 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_NOP, 8, 0, 8, 0, 8), | |
| 859 | ||
| 860 | #define AM_READNOP \ | |
| 861 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_NOP, 8, 0, 8, 0, 8), | |
| 862 | ||
| 863 | #define AM_WRITENOP \ | |
| 864 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_NOP, 8, 0, 8, 0, 8), | |
| 865 | ||
| 866 | ||
| 867 | /* port accesses */ | |
| 868 | #define AM_READ_PORT(_tag) \ | |
| 869 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_PORT, 8, 0, 8, 0, 8), \ | |
| 870 | TOKEN_STRING(_tag), | |
| 871 | ||
| 872 | #define AM_WRITE_PORT(_tag) \ | |
| 873 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_PORT, 8, 0, 8, 0, 8), \ | |
| 874 | TOKEN_STRING(_tag), | |
| 875 | ||
| 876 | #define AM_READWRITE_PORT(_tag) \ | |
| 877 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_PORT, 8, 0, 8, 0, 8), \ | |
| 878 | TOKEN_STRING(_tag), | |
| 879 | ||
| 880 | ||
| 881 | /* bank accesses */ | |
| 882 | #define AM_READ_BANK(_tag) \ | |
| 883 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READ, 8, AMH_BANK, 8, 0, 8, 0, 8), \ | |
| 884 | TOKEN_STRING(_tag), | |
| 885 | ||
| 886 | #define AM_WRITE_BANK(_tag) \ | |
| 887 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_WRITE, 8, AMH_BANK, 8, 0, 8, 0, 8), \ | |
| 888 | TOKEN_STRING(_tag), | |
| 889 | ||
| 890 | #define AM_READWRITE_BANK(_tag) \ | |
| 891 | TOKEN_UINT32_PACK4(ADDRMAP_TOKEN_READWRITE, 8, AMH_BANK, 8, 0, 8, 0, 8), \ | |
| 892 | TOKEN_STRING(_tag), | |
| 893 | ||
| 894 | ||
| 895 | /* attributes for accesses */ | |
| 896 | #define AM_REGION(_tag, _offs) \ | |
| 897 | TOKEN_UINT64_PACK2(ADDRMAP_TOKEN_REGION, 8, _offs, 32), \ | |
| 898 | TOKEN_STRING(_tag), | |
| 899 | ||
| 900 | #define AM_SHARE(_tag) \ | |
| 901 | TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_SHARE, 8), \ | |
| 902 | TOKEN_STRING(_tag), | |
| 903 | ||
| 904 | #define AM_BASE(_base) \ | |
| 905 | TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_BASEPTR, 8), \ | |
| 906 | TOKEN_PTR(memptr, _base), | |
| 907 | ||
| 908 | #define myoffsetof(_struct, _member) ((FPTR)&((_struct *)0x1000)->_member - 0x1000) | |
| 909 | #define AM_BASE_MEMBER(_struct, _member) \ | |
| 910 | TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_BASE_MEMBER, 8, myoffsetof(_struct, _member), 24), | |
| 911 | ||
| 912 | #define AM_BASE_GENERIC(_member) \ | |
| 913 | TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_BASE_GENERIC, 8, offsetof(generic_pointers, _member), 24), | |
| 914 | ||
| 915 | #define AM_SIZE(_size) \ | |
| 916 | TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_SIZEPTR, 8), \ | |
| 917 | TOKEN_PTR(sizeptr, _size), | |
| 918 | ||
| 919 | #define AM_SIZE_MEMBER(_struct, _member) \ | |
| 920 | TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_SIZE_MEMBER, 8, myoffsetof(_struct, _member), 24), | |
| 921 | ||
| 922 | #define AM_SIZE_GENERIC(_member) \ | |
| 923 | TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_SIZE_GENERIC, 8, offsetof(generic_pointers, _member##_size), 24), | |
| 924 | ||
| 925 | ||
| 926 | /* common shortcuts */ | |
| 927 | #define AM_ROMBANK(_bank) AM_READ_BANK(_bank) | |
| 928 | #define AM_RAMBANK(_bank) AM_READWRITE_BANK(_bank) | |
| 929 | #define AM_RAM_READ(_read) AM_READ(_read) AM_WRITEONLY | |
| 930 | #define AM_RAM_WRITE(_write) AM_READONLY AM_WRITE(_write) | |
| 931 | #define AM_RAM_DEVREAD(_tag, _read) AM_DEVREAD(_tag, _read) AM_WRITEONLY | |
| 932 | #define AM_RAM_DEVWRITE(_tag, _write) AM_READONLY AM_DEVWRITE(_tag, _write) | |
| 933 | ||
| 934 | #define AM_BASE_SIZE_MEMBER(_struct, _base, _size) AM_BASE_MEMBER(_struct, _base) AM_SIZE_MEMBER(_struct, _size) | |
| 935 | #define AM_BASE_SIZE_GENERIC(_member) AM_BASE_GENERIC(_member) AM_SIZE_GENERIC(_member) | |
| 936 | ||
| 937 | ||
| 938 | ||
| 939 | /*************************************************************************** | |
| 940 | 350 | GLOBAL VARIABLES |
| 941 | 351 | ***************************************************************************/ |
| 942 | 352 | |
| r8714 | r8715 | |
| 956 | 366 | |
| 957 | 367 | |
| 958 | 368 | |
| 959 | /* ----- address maps ----- */ | |
| 960 | ||
| 961 | /* build and allocate an address map for a device's address space */ | |
| 962 | address_map *address_map_alloc(const device_config *devconfig, const game_driver *driver, int spacenum, void *memdata); | |
| 963 | ||
| 964 | /* release allocated memory for an address map */ | |
| 965 | void address_map_free(address_map *map); | |
| 966 | ||
| 967 | ||
| 968 | ||
| 969 | 369 | /* ----- direct access control ----- */ |
| 970 | 370 | |
| 971 | 371 | /* registers an address range as having a decrypted data pointer */ |
| r0 | r8715 | |
|---|---|---|
| 1 | /*************************************************************************** | |
| 2 | ||
| 3 | addrmap.c | |
| 4 | ||
| 5 | Macros and helper functions for handling address map definitions. | |
| 6 | ||
| 7 | **************************************************************************** | |
| 8 | ||
| 9 | Copyright Aaron Giles | |
| 10 | All rights reserved. | |
| 11 | ||
| 12 | Redistribution and use in source and binary forms, with or without | |
| 13 | modification, are permitted provided that the following conditions are | |
| 14 | met: | |
| 15 | ||
| 16 | * Redistributions of source code must retain the above copyright | |
| 17 | notice, this list of conditions and the following disclaimer. | |
| 18 | * Redistributions in binary form must reproduce the above copyright | |
| 19 | notice, this list of conditions and the following disclaimer in | |
| 20 | the documentation and/or other materials provided with the | |
| 21 | distribution. | |
| 22 | * Neither the name 'MAME' nor the names of its contributors may be | |
| 23 | used to endorse or promote products derived from this software | |
| 24 | without specific prior written permission. | |
| 25 | ||
| 26 | THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR | |
| 27 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 28 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 29 | DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, | |
| 30 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 31 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 32 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 34 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
| 35 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 36 | POSSIBILITY OF SUCH DAMAGE. | |
| 37 | ||
| 38 | ***************************************************************************/ | |
| 39 | ||
| 40 | #include "emu.h" | |
| 41 | ||
| 42 | ||
| 43 | //************************************************************************** | |
| 44 | // MACROS | |
| 45 | //************************************************************************** | |
| 46 | ||
| 47 | // maps a full 64-bit mask down to an 8-bit byte mask | |
| 48 | #define UNITMASK8(x) \ | |
| 49 | ((((UINT64)(x) >> (63-7)) & 0x80) | \ | |
| 50 | (((UINT64)(x) >> (55-6)) & 0x40) | \ | |
| 51 | (((UINT64)(x) >> (47-5)) & 0x20) | \ | |
| 52 | (((UINT64)(x) >> (39-4)) & 0x10) | \ | |
| 53 | (((UINT64)(x) >> (31-3)) & 0x08) | \ | |
| 54 | (((UINT64)(x) >> (23-2)) & 0x04) | \ | |
| 55 | (((UINT64)(x) >> (15-1)) & 0x02) | \ | |
| 56 | (((UINT64)(x) >> ( 7-0)) & 0x01)) | |
| 57 | ||
| 58 | // maps a full 64-bit mask down to a 4-bit word mask | |
| 59 | #define UNITMASK16(x) \ | |
| 60 | ((((UINT64)(x) >> (63-3)) & 0x08) | \ | |
| 61 | (((UINT64)(x) >> (47-2)) & 0x04) | \ | |
| 62 | (((UINT64)(x) >> (31-1)) & 0x02) | \ | |
| 63 | (((UINT64)(x) >> (15-0)) & 0x01)) | |
| 64 | ||
| 65 | // maps a full 64-bit mask down to a 2-bit dword mask | |
| 66 | #define UNITMASK32(x) \ | |
| 67 | ((((UINT64)(x) >> (63-1)) & 0x02) | \ | |
| 68 | (((UINT64)(x) >> (31-0)) & 0x01)) | |
| 69 | ||
| 70 | ||
| 71 | ||
| 72 | //************************************************************************** | |
| 73 | // ADDRESS MAP ENTRY | |
| 74 | //************************************************************************** | |
| 75 | ||
| 76 | //------------------------------------------------- | |
| 77 | // address_map_entry - constructor | |
| 78 | //------------------------------------------------- | |
| 79 | ||
| 80 | address_map_entry::address_map_entry(address_map &map, offs_t start, offs_t end) | |
| 81 | : m_next(NULL), | |
| 82 | m_map(map), | |
| 83 | m_addrstart((map.m_globalmask == 0) ? start : start & map.m_globalmask), | |
| 84 | m_addrend((map.m_globalmask == 0) ? end : end & map.m_globalmask), | |
| 85 | m_addrmirror(0), | |
| 86 | m_addrmask(0), | |
| 87 | m_share(NULL), | |
| 88 | m_baseptr(NULL), | |
| 89 | m_sizeptr(NULL), | |
| 90 | m_baseptroffs_plus1(0), | |
| 91 | m_sizeptroffs_plus1(0), | |
| 92 | m_genbaseptroffs_plus1(0), | |
| 93 | m_gensizeptroffs_plus1(0), | |
| 94 | m_region(NULL), | |
| 95 | m_rgnoffs(0), | |
| 96 | m_memory(NULL), | |
| 97 | m_bytestart(0), | |
| 98 | m_byteend(0), | |
| 99 | m_bytemirror(0), | |
| 100 | m_bytemask(0) | |
| 101 | { | |
| 102 | } | |
| 103 | ||
| 104 | ||
| 105 | //------------------------------------------------- | |
| 106 | // set_mask - set the mask value | |
| 107 | //------------------------------------------------- | |
| 108 | ||
| 109 | void address_map_entry::set_mask(offs_t _mask) | |
| 110 | { | |
| 111 | m_addrmask = _mask; | |
| 112 | if (m_map.m_globalmask != 0) | |
| 113 | m_addrmask &= m_map.m_globalmask; | |
| 114 | } | |
| 115 | ||
| 116 | ||
| 117 | //------------------------------------------------- | |
| 118 | // set_read_port - set up a handler for reading | |
| 119 | // an I/O port | |
| 120 | //------------------------------------------------- | |
| 121 | ||
| 122 | void address_map_entry::set_read_port(const device_config &devconfig, const char *tag) | |
| 123 | { | |
| 124 | m_read.type = AMH_PORT; | |
| 125 | m_read.tag = devconfig.siblingtag(m_read.derived_tag, tag); | |
| 126 | } | |
| 127 | ||
| 128 | ||
| 129 | //------------------------------------------------- | |
| 130 | // set_write_port - set up a handler for writing | |
| 131 | // an I/O port | |
| 132 | //------------------------------------------------- | |
| 133 | ||
| 134 | void address_map_entry::set_write_port(const device_config &devconfig, const char *tag) | |
| 135 | { | |
| 136 | m_write.type = AMH_PORT; | |
| 137 | m_write.tag = devconfig.siblingtag(m_write.derived_tag, tag); | |
| 138 | } | |
| 139 | ||
| 140 | ||
| 141 | //------------------------------------------------- | |
| 142 | // set_readwrite_port - set up a handler for | |
| 143 | // reading and writing an I/O port | |
| 144 | //------------------------------------------------- | |
| 145 | ||
| 146 | void address_map_entry::set_readwrite_port(const device_config &devconfig, const char *tag) | |
| 147 | { | |
| 148 | m_read.type = AMH_PORT; | |
| 149 | m_read.tag = devconfig.siblingtag(m_read.derived_tag, tag); | |
| 150 | m_write.type = AMH_PORT; | |
| 151 | m_write.tag = devconfig.siblingtag(m_write.derived_tag, tag); | |
| 152 | } | |
| 153 | ||
| 154 | ||
| 155 | //------------------------------------------------- | |
| 156 | // set_read_bank - set up a handler for reading | |
| 157 | // from a memory bank | |
| 158 | //------------------------------------------------- | |
| 159 | ||
| 160 | void address_map_entry::set_read_bank(const device_config &devconfig, const char *tag) | |
| 161 | { | |
| 162 | m_read.type = AMH_BANK; | |
| 163 | m_read.tag = devconfig.siblingtag(m_read.derived_tag, tag); | |
| 164 | } | |
| 165 | ||
| 166 | ||
| 167 | //------------------------------------------------- | |
| 168 | // set_write_bank - set up a handler for writing | |
| 169 | // to a memory bank | |
| 170 | //------------------------------------------------- | |
| 171 | ||
| 172 | void address_map_entry::set_write_bank(const device_config &devconfig, const char *tag) | |
| 173 | { | |
| 174 | m_write.type = AMH_BANK; | |
| 175 | m_write.tag = devconfig.siblingtag(m_write.derived_tag, tag); | |
| 176 | } | |
| 177 | ||
| 178 | ||
| 179 | //------------------------------------------------- | |
| 180 | // set_readwrite_bank - set up a handler for | |
| 181 | // writing to a memory bank | |
| 182 | //------------------------------------------------- | |
| 183 | ||
| 184 | void address_map_entry::set_readwrite_bank(const device_config &devconfig, const char *tag) | |
| 185 | { | |
| 186 | m_read.type = AMH_BANK; | |
| 187 | m_read.tag = devconfig.siblingtag(m_read.derived_tag, tag); | |
| 188 | m_write.type = AMH_BANK; | |
| 189 | m_write.tag = devconfig.siblingtag(m_write.derived_tag, tag); | |
| 190 | } | |
| 191 | ||
| 192 | ||
| 193 | //------------------------------------------------- | |
| 194 | // internal_set_handler - handler setters for | |
| 195 | // 8-bit read/write handlers | |
| 196 | //------------------------------------------------- | |
| 197 | ||
| 198 | void address_map_entry::internal_set_handler(read8_space_func func, const char *string, UINT64 unitmask) | |
| 199 | { | |
| 200 | assert(unitmask_is_appropriate(8, unitmask, string)); | |
| 201 | m_read.type = AMH_HANDLER; | |
| 202 | m_read.bits = (unitmask == 0) ? 0 : 8; | |
| 203 | m_read.mask = UNITMASK8(unitmask); | |
| 204 | m_read.handler.read.shandler8 = func; | |
| 205 | m_read.name = string; | |
| 206 | } | |
| 207 | ||
| 208 | ||
| 209 | void address_map_entry::internal_set_handler(write8_space_func func, const char *string, UINT64 unitmask) | |
| 210 | { | |
| 211 | assert(unitmask_is_appropriate(8, unitmask, string)); | |
| 212 | m_write.type = AMH_HANDLER; | |
| 213 | m_write.bits = (unitmask == 0) ? 0 : 8; | |
| 214 | m_write.mask = UNITMASK8(unitmask); | |
| 215 | m_write.handler.write.shandler8 = func; | |
| 216 | m_write.name = string; | |
| 217 | } | |
| 218 | ||
| 219 | ||
| 220 | void address_map_entry::internal_set_handler(read8_space_func rfunc, const char *rstring, write8_space_func wfunc, const char *wstring, UINT64 unitmask) | |
| 221 | { | |
| 222 | internal_set_handler(rfunc, rstring, unitmask); | |
| 223 | internal_set_handler(wfunc, wstring, unitmask); | |
| 224 | } | |
| 225 | ||
| 226 | ||
| 227 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, read8_device_func func, const char *string, UINT64 unitmask) | |
| 228 | { | |
| 229 | assert(unitmask_is_appropriate(8, unitmask, string)); | |
| 230 | m_read.type = AMH_DEVICE_HANDLER; | |
| 231 | m_read.bits = (unitmask == 0) ? 0 : 8; | |
| 232 | m_read.mask = UNITMASK8(unitmask); | |
| 233 | m_read.handler.read.dhandler8 = func; | |
| 234 | m_read.name = string; | |
| 235 | m_read.tag = devconfig.siblingtag(m_read.derived_tag, tag); | |
| 236 | } | |
| 237 | ||
| 238 | ||
| 239 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, write8_device_func func, const char *string, UINT64 unitmask) | |
| 240 | { | |
| 241 | assert(unitmask_is_appropriate(8, unitmask, string)); | |
| 242 | m_write.type = AMH_DEVICE_HANDLER; | |
| 243 | m_write.bits = (unitmask == 0) ? 0 : 8; | |
| 244 | m_write.mask = UNITMASK8(unitmask); | |
| 245 | m_write.handler.write.dhandler8 = func; | |
| 246 | m_write.name = string; | |
| 247 | m_write.tag = devconfig.siblingtag(m_write.derived_tag, tag); | |
| 248 | } | |
| 249 | ||
| 250 | ||
| 251 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, read8_device_func rfunc, const char *rstring, write8_device_func wfunc, const char *wstring, UINT64 unitmask) | |
| 252 | { | |
| 253 | internal_set_handler(devconfig, tag, rfunc, rstring, unitmask); | |
| 254 | internal_set_handler(devconfig, tag, wfunc, wstring, unitmask); | |
| 255 | } | |
| 256 | ||
| 257 | ||
| 258 | //------------------------------------------------- | |
| 259 | // internal_set_handler - handler setters for | |
| 260 | // 16-bit read/write handlers | |
| 261 | //------------------------------------------------- | |
| 262 | ||
| 263 | void address_map_entry::internal_set_handler(read16_space_func func, const char *string, UINT64 unitmask) | |
| 264 | { | |
| 265 | assert(unitmask_is_appropriate(16, unitmask, string)); | |
| 266 | m_read.type = AMH_HANDLER; | |
| 267 | m_read.bits = (unitmask == 0) ? 0 : 16; | |
| 268 | m_read.mask = UNITMASK16(unitmask); | |
| 269 | m_read.handler.read.shandler16 = func; | |
| 270 | m_read.name = string; | |
| 271 | } | |
| 272 | ||
| 273 | ||
| 274 | void address_map_entry::internal_set_handler(write16_space_func func, const char *string, UINT64 unitmask) | |
| 275 | { | |
| 276 | assert(unitmask_is_appropriate(16, unitmask, string)); | |
| 277 | m_write.type = AMH_HANDLER; | |
| 278 | m_write.bits = (unitmask == 0) ? 0 : 16; | |
| 279 | m_write.mask = UNITMASK16(unitmask); | |
| 280 | m_write.handler.write.shandler16 = func; | |
| 281 | m_write.name = string; | |
| 282 | } | |
| 283 | ||
| 284 | ||
| 285 | void address_map_entry::internal_set_handler(read16_space_func rfunc, const char *rstring, write16_space_func wfunc, const char *wstring, UINT64 unitmask) | |
| 286 | { | |
| 287 | internal_set_handler(rfunc, rstring, unitmask); | |
| 288 | internal_set_handler(wfunc, wstring, unitmask); | |
| 289 | } | |
| 290 | ||
| 291 | ||
| 292 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, read16_device_func func, const char *string, UINT64 unitmask) | |
| 293 | { | |
| 294 | assert(unitmask_is_appropriate(16, unitmask, string)); | |
| 295 | m_read.type = AMH_DEVICE_HANDLER; | |
| 296 | m_read.bits = (unitmask == 0) ? 0 : 16; | |
| 297 | m_read.mask = UNITMASK16(unitmask); | |
| 298 | m_read.handler.read.dhandler16 = func; | |
| 299 | m_read.name = string; | |
| 300 | m_read.tag = devconfig.siblingtag(m_read.derived_tag, tag); | |
| 301 | } | |
| 302 | ||
| 303 | ||
| 304 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, write16_device_func func, const char *string, UINT64 unitmask) | |
| 305 | { | |
| 306 | assert(unitmask_is_appropriate(16, unitmask, string)); | |
| 307 | m_write.type = AMH_DEVICE_HANDLER; | |
| 308 | m_write.bits = (unitmask == 0) ? 0 : 16; | |
| 309 | m_write.mask = UNITMASK16(unitmask); | |
| 310 | m_write.handler.write.dhandler16 = func; | |
| 311 | m_write.name = string; | |
| 312 | m_write.tag = devconfig.siblingtag(m_write.derived_tag, tag); | |
| 313 | } | |
| 314 | ||
| 315 | ||
| 316 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, read16_device_func rfunc, const char *rstring, write16_device_func wfunc, const char *wstring, UINT64 unitmask) | |
| 317 | { | |
| 318 | internal_set_handler(devconfig, tag, rfunc, rstring, unitmask); | |
| 319 | internal_set_handler(devconfig, tag, wfunc, wstring, unitmask); | |
| 320 | } | |
| 321 | ||
| 322 | ||
| 323 | //------------------------------------------------- | |
| 324 | // internal_set_handler - handler setters for | |
| 325 | // 32-bit read/write handlers | |
| 326 | //------------------------------------------------- | |
| 327 | ||
| 328 | void address_map_entry::internal_set_handler(read32_space_func func, const char *string, UINT64 unitmask) | |
| 329 | { | |
| 330 | assert(unitmask_is_appropriate(32, unitmask, string)); | |
| 331 | m_read.type = AMH_HANDLER; | |
| 332 | m_read.bits = (unitmask == 0) ? 0 : 32; | |
| 333 | m_read.mask = UNITMASK32(unitmask); | |
| 334 | m_read.handler.read.shandler32 = func; | |
| 335 | m_read.name = string; | |
| 336 | } | |
| 337 | ||
| 338 | ||
| 339 | void address_map_entry::internal_set_handler(write32_space_func func, const char *string, UINT64 unitmask) | |
| 340 | { | |
| 341 | assert(unitmask_is_appropriate(32, unitmask, string)); | |
| 342 | m_write.type = AMH_HANDLER; | |
| 343 | m_write.bits = (unitmask == 0) ? 0 : 32; | |
| 344 | m_write.mask = UNITMASK32(unitmask); | |
| 345 | m_write.handler.write.shandler32 = func; | |
| 346 | m_write.name = string; | |
| 347 | } | |
| 348 | ||
| 349 | ||
| 350 | void address_map_entry::internal_set_handler(read32_space_func rfunc, const char *rstring, write32_space_func wfunc, const char *wstring, UINT64 unitmask) | |
| 351 | { | |
| 352 | internal_set_handler(rfunc, rstring, unitmask); | |
| 353 | internal_set_handler(wfunc, wstring, unitmask); | |
| 354 | } | |
| 355 | ||
| 356 | ||
| 357 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, read32_device_func func, const char *string, UINT64 unitmask) | |
| 358 | { | |
| 359 | assert(unitmask_is_appropriate(32, unitmask, string)); | |
| 360 | m_read.type = AMH_DEVICE_HANDLER; | |
| 361 | m_read.bits = (unitmask == 0) ? 0 : 32; | |
| 362 | m_read.mask = UNITMASK32(unitmask); | |
| 363 | m_read.handler.read.dhandler32 = func; | |
| 364 | m_read.name = string; | |
| 365 | m_read.tag = devconfig.siblingtag(m_read.derived_tag, tag); | |
| 366 | } | |
| 367 | ||
| 368 | ||
| 369 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, write32_device_func func, const char *string, UINT64 unitmask) | |
| 370 | { | |
| 371 | assert(unitmask_is_appropriate(32, unitmask, string)); | |
| 372 | m_write.type = AMH_DEVICE_HANDLER; | |
| 373 | m_write.bits = (unitmask == 0) ? 0 : 32; | |
| 374 | m_write.mask = UNITMASK32(unitmask); | |
| 375 | m_write.handler.write.dhandler32 = func; | |
| 376 | m_write.name = string; | |
| 377 | m_write.tag = devconfig.siblingtag(m_write.derived_tag, tag); | |
| 378 | } | |
| 379 | ||
| 380 | ||
| 381 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, read32_device_func rfunc, const char *rstring, write32_device_func wfunc, const char *wstring, UINT64 unitmask) | |
| 382 | { | |
| 383 | internal_set_handler(devconfig, tag, rfunc, rstring, unitmask); | |
| 384 | internal_set_handler(devconfig, tag, wfunc, wstring, unitmask); | |
| 385 | } | |
| 386 | ||
| 387 | ||
| 388 | //------------------------------------------------- | |
| 389 | // internal_set_handler - handler setters for | |
| 390 | // 64-bit read/write handlers | |
| 391 | //------------------------------------------------- | |
| 392 | ||
| 393 | void address_map_entry::internal_set_handler(read64_space_func func, const char *string, UINT64 unitmask) | |
| 394 | { | |
| 395 | assert(unitmask_is_appropriate(64, unitmask, string)); | |
| 396 | m_read.type = AMH_HANDLER; | |
| 397 | m_read.bits = (unitmask == 0) ? 0 : 64; | |
| 398 | m_read.mask = 0; | |
| 399 | m_read.handler.read.shandler64 = func; | |
| 400 | m_read.name = string; | |
| 401 | } | |
| 402 | ||
| 403 | ||
| 404 | void address_map_entry::internal_set_handler(write64_space_func func, const char *string, UINT64 unitmask) | |
| 405 | { | |
| 406 | assert(unitmask_is_appropriate(64, unitmask, string)); | |
| 407 | m_write.type = AMH_HANDLER; | |
| 408 | m_write.bits = (unitmask == 0) ? 0 : 64; | |
| 409 | m_write.mask = 0; | |
| 410 | m_write.handler.write.shandler64 = func; | |
| 411 | m_write.name = string; | |
| 412 | } | |
| 413 | ||
| 414 | ||
| 415 | void address_map_entry::internal_set_handler(read64_space_func rfunc, const char *rstring, write64_space_func wfunc, const char *wstring, UINT64 unitmask) | |
| 416 | { | |
| 417 | internal_set_handler(rfunc, rstring, unitmask); | |
| 418 | internal_set_handler(wfunc, wstring, unitmask); | |
| 419 | } | |
| 420 | ||
| 421 | ||
| 422 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, read64_device_func func, const char *string, UINT64 unitmask) | |
| 423 | { | |
| 424 | assert(unitmask_is_appropriate(64, unitmask, string)); | |
| 425 | m_read.type = AMH_DEVICE_HANDLER; | |
| 426 | m_read.bits = (unitmask == 0) ? 0 : 64; | |
| 427 | m_read.mask = 0; | |
| 428 | m_read.handler.read.dhandler64 = func; | |
| 429 | m_read.name = string; | |
| 430 | m_read.tag = devconfig.siblingtag(m_read.derived_tag, tag); | |
| 431 | } | |
| 432 | ||
| 433 | ||
| 434 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, write64_device_func func, const char *string, UINT64 unitmask) | |
| 435 | { | |
| 436 | assert(unitmask_is_appropriate(64, unitmask, string)); | |
| 437 | m_write.type = AMH_DEVICE_HANDLER; | |
| 438 | m_write.bits = (unitmask == 0) ? 0 : 64; | |
| 439 | m_write.mask = 0; | |
| 440 | m_write.handler.write.dhandler64 = func; | |
| 441 | m_write.name = string; | |
| 442 | m_write.tag = devconfig.siblingtag(m_write.derived_tag, tag); | |
| 443 | } | |
| 444 | ||
| 445 | ||
| 446 | void address_map_entry::internal_set_handler(const device_config &devconfig, const char *tag, read64_device_func rfunc, const char *rstring, write64_device_func wfunc, const char *wstring, UINT64 unitmask) | |
| 447 | { | |
| 448 | internal_set_handler(devconfig, tag, rfunc, rstring, unitmask); | |
| 449 | internal_set_handler(devconfig, tag, wfunc, wstring, unitmask); | |
| 450 | } | |
| 451 | ||
| 452 | ||
| 453 | //------------------------------------------------- | |
| 454 | // unitmask_is_appropriate - verify that the | |
| 455 | // provided unitmask is valid and expected | |
| 456 | //------------------------------------------------- | |
| 457 | ||
| 458 | bool address_map_entry::unitmask_is_appropriate(UINT8 width, UINT64 unitmask, const char *string) | |
| 459 | { | |
| 460 | // if no mask, this must match the default width of the map | |
| 461 | if (unitmask == 0) | |
| 462 | { | |
| 463 | if (m_map.m_databits != width) | |
| 464 | throw emu_fatalerror("Handler %s is a %d-bit handler but was specified in a %d-bit address map", string, width, m_map.m_databits); | |
| 465 | return true; | |
| 466 | } | |
| 467 | ||
| 468 | // if we have a mask, we must be smaller than the default width of the map | |
| 469 | if (m_map.m_databits <= width) | |
| 470 | throw emu_fatalerror("Handler %s is a %d-bit handler and is too wide to be used in a %d-bit address map", string, width, m_map.m_databits); | |
| 471 | ||
| 472 | // the mask must represent whole units of width | |
| 473 | UINT32 basemask = (width == 8) ? 0xff : (width == 16) ? 0xffff : 0xffffffff; | |
| 474 | UINT64 singlemask = basemask; | |
| 475 | while (singlemask != 0) | |
| 476 | { | |
| 477 | if ((unitmask & singlemask) != 0 && (unitmask & singlemask) != singlemask) | |
| 478 | throw emu_fatalerror("Handler %s specified a mask of %08X%08X; needs to be in even chunks of %X", string, (UINT32)(unitmask >> 32), (UINT32)unitmask, basemask); | |
| 479 | singlemask <<= width; | |
| 480 | } | |
| 481 | return true; | |
| 482 | } | |
| 483 | ||
| 484 | ||
| 485 | ||
| 486 | //************************************************************************** | |
| 487 | // WIDTH-SPECIFIC ADDRESS MAP ENTRY CONSTRUCTORS | |
| 488 | //************************************************************************** | |
| 489 | ||
| 490 | //------------------------------------------------- | |
| 491 | // address_map_entry8 - constructor | |
| 492 | //------------------------------------------------- | |
| 493 | ||
| 494 | address_map_entry8::address_map_entry8(address_map &map, offs_t start, offs_t end) | |
| 495 | : address_map_entry(map, start, end) | |
| 496 | { | |
| 497 | } | |
| 498 | ||
| 499 | ||
| 500 | //------------------------------------------------- | |
| 501 | // address_map_entry16 - constructor | |
| 502 | //------------------------------------------------- | |
| 503 | ||
| 504 | address_map_entry16::address_map_entry16(address_map &map, offs_t start, offs_t end) | |
| 505 | : address_map_entry(map, start, end) | |
| 506 | { | |
| 507 | } | |
| 508 | ||
| 509 | ||
| 510 | //------------------------------------------------- | |
| 511 | // address_map_entry32 - constructor | |
| 512 | //------------------------------------------------- | |
| 513 | ||
| 514 | address_map_entry32::address_map_entry32(address_map &map, offs_t start, offs_t end) | |
| 515 | : address_map_entry(map, start, end) | |
| 516 | { | |
| 517 | } | |
| 518 | ||
| 519 | ||
| 520 | //------------------------------------------------- | |
| 521 | // address_map_entry64 - constructor | |
| 522 | //------------------------------------------------- | |
| 523 | ||
| 524 | address_map_entry64::address_map_entry64(address_map &map, offs_t start, offs_t end) | |
| 525 | : address_map_entry(map, start, end) | |
| 526 | { | |
| 527 | } | |
| 528 | ||
| 529 | ||
| 530 | ||
| 531 | //************************************************************************** | |
| 532 | // ADDRESS MAP | |
| 533 | //************************************************************************** | |
| 534 | ||
| 535 | //------------------------------------------------- | |
| 536 | // address_map - constructor | |
| 537 | //------------------------------------------------- | |
| 538 | ||
| 539 | address_map::address_map(const device_config &devconfig, int spacenum) | |
| 540 | : m_spacenum(spacenum), | |
| 541 | m_databits(0xff), | |
| 542 | m_unmapval(0), | |
| 543 | m_globalmask(0), | |
| 544 | m_entrylist(NULL), | |
| 545 | m_tailptr(&m_entrylist) | |
| 546 | { | |
| 547 | // get our memory interface | |
| 548 | const device_config_memory_interface *memintf; | |
| 549 | if (!devconfig.interface(memintf)) | |
| 550 | throw emu_fatalerror("No memory interface defined for device '%s'\n", devconfig.tag()); | |
| 551 | ||
| 552 | // and then the configuration for the current address space | |
| 553 | const address_space_config *spaceconfig = memintf->space_config(spacenum); | |
| 554 | if (!devconfig.interface(memintf)) | |
| 555 | throw emu_fatalerror("No memory address space configuration found for device '%s', space %d\n", devconfig.tag(), spacenum); | |
| 556 | ||
| 557 | // append the internal device map (first so it takes priority) */ | |
| 558 | if (spaceconfig->m_internal_map != NULL) | |
| 559 | (*spaceconfig->m_internal_map)(*this, devconfig); | |
| 560 | ||
| 561 | // construct the standard map */ | |
| 562 | if (memintf->address_map(spacenum) != NULL) | |
| 563 | (*memintf->address_map(spacenum))(*this, devconfig); | |
| 564 | ||
| 565 | // append the default device map (last so it can be overridden) */ | |
| 566 | if (spaceconfig->m_default_map != NULL) | |
| 567 | (*spaceconfig->m_default_map)(*this, devconfig); | |
| 568 | } | |
| 569 | ||
| 570 | ||
| 571 | //------------------------------------------------- | |
| 572 | // ~address_map - destructor | |
| 573 | //------------------------------------------------- | |
| 574 | ||
| 575 | address_map::~address_map() | |
| 576 | { | |
| 577 | // free all entries */ | |
| 578 | while (m_entrylist != NULL) | |
| 579 | { | |
| 580 | address_map_entry *entry = m_entrylist; | |
| 581 | m_entrylist = entry->m_next; | |
| 582 | global_free(entry); | |
| 583 | } | |
| 584 | } | |
| 585 | ||
| 586 | ||
| 587 | //------------------------------------------------- | |
| 588 | // configure - either configure the space and | |
| 589 | // databits, or verify they match previously-set | |
| 590 | // values | |
| 591 | //------------------------------------------------- | |
| 592 | ||
| 593 | void address_map::configure(UINT8 spacenum, UINT8 databits) | |
| 594 | { | |
| 595 | assert(m_spacenum == spacenum); | |
| 596 | if (m_databits == 0xff) | |
| 597 | m_databits = databits; | |
| 598 | else | |
| 599 | assert(m_databits == databits); | |
| 600 | } | |
| 601 | ||
| 602 | ||
| 603 | //------------------------------------------------- | |
| 604 | // append - append an entry to the end of the | |
| 605 | // list | |
| 606 | //------------------------------------------------- | |
| 607 | ||
| 608 | void address_map::set_global_mask(offs_t mask) | |
| 609 | { | |
| 610 | // if (m_entrylist != NULL) | |
| 611 | // throw emu_fatalerror("AM_GLOBALMASK must be specified before any entries"); | |
| 612 | m_globalmask = mask; | |
| 613 | } | |
| 614 | ||
| 615 | ||
| 616 | ||
| 617 | //------------------------------------------------- | |
| 618 | // add - add a new entry of the appropriate type | |
| 619 | //------------------------------------------------- | |
| 620 | ||
| 621 | address_map_entry8 *address_map::add(offs_t start, offs_t end, address_map_entry8 *ptr) | |
| 622 | { | |
| 623 | ptr = global_alloc(address_map_entry8(*this, start, end)); | |
| 624 | *m_tailptr = ptr; | |
| 625 | m_tailptr = &ptr->m_next; | |
| 626 | return ptr; | |
| 627 | } | |
| 628 | ||
| 629 | ||
| 630 | address_map_entry16 *address_map::add(offs_t start, offs_t end, address_map_entry16 *ptr) | |
| 631 | { | |
| 632 | ptr = global_alloc(address_map_entry16(*this, start, end)); | |
| 633 | *m_tailptr = ptr; | |
| 634 | m_tailptr = &ptr->m_next; | |
| 635 | return ptr; | |
| 636 | } | |
| 637 | ||
| 638 | ||
| 639 | address_map_entry32 *address_map::add(offs_t start, offs_t end, address_map_entry32 *ptr) | |
| 640 | { | |
| 641 | ptr = global_alloc(address_map_entry32(*this, start, end)); | |
| 642 | *m_tailptr = ptr; | |
| 643 | m_tailptr = &ptr->m_next; | |
| 644 | return ptr; | |
| 645 | } | |
| 646 | ||
| 647 | ||
| 648 | address_map_entry64 *address_map::add(offs_t start, offs_t end, address_map_entry64 *ptr) | |
| 649 | { | |
| 650 | ptr = global_alloc(address_map_entry64(*this, start, end)); | |
| 651 | *m_tailptr = ptr; | |
| 652 | m_tailptr = &ptr->m_next; | |
| 653 | return ptr; | |
| 654 | } | |
| 655 | ||
| 656 | ||
| 657 | ||
| 658 | #if 0 | |
| 659 | ||
| 660 | // old code for reference | |
| 661 | ||
| 662 | /*************************************************************************** | |
| 663 | ADDRESS MAP HELPERS | |
| 664 | ***************************************************************************/ | |
| 665 | ||
| 666 | /*------------------------------------------------- | |
| 667 | map_detokenize - detokenize an array of | |
| 668 | address map tokens | |
| 669 | -------------------------------------------------*/ | |
| 670 | ||
| 671 | #define check_map(field) do { \ | |
| 672 | if (map->field != 0 && map->field != tmap.field) \ | |
| 673 | fatalerror("%s: %s included a mismatched address map (%s %d) for an existing map with %s %d!\n", driver->source_file, driver->name, #field, tmap.field, #field, map->field); \ | |
| 674 | } while (0) | |
| 675 | ||
| 676 | #define check_entry_handler(row) do { \ | |
| 677 | if (entry->row.type != AMH_NONE) \ | |
| 678 | fatalerror("%s: %s AM_RANGE(0x%x, 0x%x) %s handler already set!\n", driver->source_file, driver->name, entry->addrstart, entry->addrend, #row); \ | |
| 679 | } while (0) | |
| 680 | ||
| 681 | #define check_entry_field(field) do { \ | |
| 682 | if (entry->field != 0) \ | |
| 683 | fatalerror("%s: %s AM_RANGE(0x%x, 0x%x) setting %s already set!\n", driver->source_file, driver->name, entry->addrstart, entry->addrend, #field); \ | |
| 684 | } while (0) | |
| 685 | ||
| 686 | static void map_detokenize(memory_private *memdata, address_map *map, const game_driver *driver, const device_config *devconfig, const addrmap_token *tokens) | |
| 687 | { | |
| 688 | address_map_entry **firstentryptr; | |
| 689 | address_map_entry **entryptr; | |
| 690 | address_map_entry *entry; | |
| 691 | address_map tmap = {0}; | |
| 692 | UINT32 entrytype; | |
| 693 | int maptype; | |
| 694 | ||
| 695 | /* check the first token */ | |
| 696 | TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, tmap.spacenum, 8, tmap.databits, 8); | |
| 697 | if (entrytype != ADDRMAP_TOKEN_START) | |
| 698 | fatalerror("%s: %s Address map missing ADDRMAP_TOKEN_START!\n", driver->source_file, driver->name); | |
| 699 | if (tmap.spacenum >= ADDRESS_SPACES) | |
| 700 | fatalerror("%s: %s Invalid address space %d for memory map!\n", driver->source_file, driver->name, tmap.spacenum); | |
| 701 | if (tmap.databits != 8 && tmap.databits != 16 && tmap.databits != 32 && tmap.databits != 64) | |
| 702 | fatalerror("%s: %s Invalid data bits %d for memory map!\n", driver->source_file, driver->name, tmap.databits); | |
| 703 | check_map(spacenum); | |
| 704 | check_map(databits); | |
| 705 | ||
| 706 | /* fill in the map values */ | |
| 707 | map->spacenum = tmap.spacenum; | |
| 708 | map->databits = tmap.databits; | |
| 709 | ||
| 710 | /* find the end of the list */ | |
| 711 | for (entryptr = &map->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next) ; | |
| 712 | firstentryptr = entryptr; | |
| 713 | entry = NULL; | |
| 714 | ||
| 715 | /* loop over tokens until we hit the end */ | |
| 716 | while (entrytype != ADDRMAP_TOKEN_END) | |
| 717 | { | |
| 718 | /* unpack the token from the first entry */ | |
| 719 | TOKEN_GET_UINT32_UNPACK1(tokens, entrytype, 8); | |
| 720 | switch (entrytype) | |
| 721 | { | |
| 722 | /* end */ | |
| 723 | case ADDRMAP_TOKEN_END: | |
| 724 | break; | |
| 725 | ||
| 726 | /* including */ | |
| 727 | case ADDRMAP_TOKEN_INCLUDE: | |
| 728 | map_detokenize(memdata, map, driver, devconfig, TOKEN_GET_PTR(tokens, tokenptr)); | |
| 729 | for (entryptr = &map->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next) ; | |
| 730 | entry = NULL; | |
| 731 | break; | |
| 732 | ||
| 733 | /* global flags */ | |
| 734 | case ADDRMAP_TOKEN_GLOBAL_MASK: | |
| 735 | TOKEN_UNGET_UINT32(tokens); | |
| 736 | TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, tmap.globalmask, 32); | |
| 737 | check_map(globalmask); | |
| 738 | map->globalmask = tmap.globalmask; | |
| 739 | break; | |
| 740 | ||
| 741 | case ADDRMAP_TOKEN_UNMAP_VALUE: | |
| 742 | TOKEN_UNGET_UINT32(tokens); | |
| 743 | TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, tmap.unmapval, 1); | |
| 744 | check_map(unmapval); | |
| 745 | map->unmapval = tmap.unmapval; | |
| 746 | break; | |
| 747 | ||
| 748 | /* start a new range */ | |
| 749 | case ADDRMAP_TOKEN_RANGE: | |
| 750 | entry = *entryptr = global_alloc_clear(address_map_entry); | |
| 751 | entryptr = &entry->next; | |
| 752 | TOKEN_GET_UINT64_UNPACK2(tokens, entry->addrstart, 32, entry->addrend, 32); | |
| 753 | break; | |
| 754 | ||
| 755 | case ADDRMAP_TOKEN_MASK: | |
| 756 | check_entry_field(addrmask); | |
| 757 | TOKEN_UNGET_UINT32(tokens); | |
| 758 | TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->addrmask, 32); | |
| 759 | break; | |
| 760 | ||
| 761 | case ADDRMAP_TOKEN_MIRROR: | |
| 762 | check_entry_field(addrmirror); | |
| 763 | TOKEN_UNGET_UINT32(tokens); | |
| 764 | TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->addrmirror, 32); | |
| 765 | if (entry->addrmirror != 0) | |
| 766 | { | |
| 767 | entry->addrstart &= ~entry->addrmirror; | |
| 768 | entry->addrend &= ~entry->addrmirror; | |
| 769 | } | |
| 770 | break; | |
| 771 | ||
| 772 | case ADDRMAP_TOKEN_READ: | |
| 773 | check_entry_handler(read); | |
| 774 | TOKEN_UNGET_UINT32(tokens); | |
| 775 | TOKEN_GET_UINT32_UNPACK4(tokens, entrytype, 8, maptype, 8, entry->read.bits, 8, entry->read.mask, 8); | |
| 776 | entry->read.type = (map_handler_type)maptype; | |
| 777 | if (entry->read.type == AMH_HANDLER || entry->read.type == AMH_DEVICE_HANDLER) | |
| 778 | { | |
| 779 | entry->read.handler.read = TOKEN_GET_PTR(tokens, read); | |
| 780 | entry->read.name = TOKEN_GET_STRING(tokens); | |
| 781 | } | |
| 782 | if (entry->read.type == AMH_DEVICE_HANDLER || entry->read.type == AMH_PORT || entry->read.type == AMH_BANK) | |
| 783 | entry->read.tag = devconfig->siblingtag(entry->read.derived_tag, TOKEN_GET_STRING(tokens)); | |
| 784 | break; | |
| 785 | ||
| 786 | case ADDRMAP_TOKEN_WRITE: | |
| 787 | check_entry_handler(write); | |
| 788 | TOKEN_UNGET_UINT32(tokens); | |
| 789 | TOKEN_GET_UINT32_UNPACK4(tokens, entrytype, 8, maptype, 8, entry->write.bits, 8, entry->write.mask, 8); | |
| 790 | entry->write.type = (map_handler_type)maptype; | |
| 791 | if (entry->write.type == AMH_HANDLER || entry->write.type == AMH_DEVICE_HANDLER) | |
| 792 | { | |
| 793 | entry->write.handler.write = TOKEN_GET_PTR(tokens, write); | |
| 794 | entry->write.name = TOKEN_GET_STRING(tokens); | |
| 795 | } | |
| 796 | if (entry->write.type == AMH_DEVICE_HANDLER || entry->write.type == AMH_PORT || entry->write.type == AMH_BANK) | |
| 797 | entry->write.tag = devconfig->siblingtag(entry->write.derived_tag, TOKEN_GET_STRING(tokens)); | |
| 798 | break; | |
| 799 | ||
| 800 | case ADDRMAP_TOKEN_READWRITE: | |
| 801 | check_entry_handler(read); | |
| 802 | check_entry_handler(write); | |
| 803 | TOKEN_UNGET_UINT32(tokens); | |
| 804 | TOKEN_GET_UINT32_UNPACK4(tokens, entrytype, 8, maptype, 8, entry->read.bits, 8, entry->read.mask, 8); | |
| 805 | entry->write.type = entry->read.type = (map_handler_type)maptype; | |
| 806 | entry->write.bits = entry->read.bits; | |
| 807 | entry->write.mask = entry->read.mask; | |
| 808 | if (entry->read.type == AMH_HANDLER || entry->read.type == AMH_DEVICE_HANDLER) | |
| 809 | { | |
| 810 | entry->read.handler.read = TOKEN_GET_PTR(tokens, read); | |
| 811 | entry->read.name = TOKEN_GET_STRING(tokens); | |
| 812 | entry->write.handler.write = TOKEN_GET_PTR(tokens, write); | |
| 813 | entry->write.name = TOKEN_GET_STRING(tokens); | |
| 814 | } | |
| 815 | if (entry->read.type == AMH_DEVICE_HANDLER || entry->read.type == AMH_PORT || entry->read.type == AMH_BANK) | |
| 816 | { | |
| 817 | const char *basetag = TOKEN_GET_STRING(tokens); | |
| 818 | entry->read.tag = devconfig->siblingtag(entry->read.derived_tag, basetag); | |
| 819 | entry->write.tag = devconfig->siblingtag(entry->write.derived_tag, basetag); | |
| 820 | } | |
| 821 | break; | |
| 822 | ||
| 823 | case ADDRMAP_TOKEN_REGION: | |
| 824 | check_entry_field(region); | |
| 825 | TOKEN_UNGET_UINT32(tokens); | |
| 826 | TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->rgnoffs, 32); | |
| 827 | entry->region = devconfig->siblingtag(entry->region_string, TOKEN_GET_STRING(tokens)); | |
| 828 | break; | |
| 829 | ||
| 830 | case ADDRMAP_TOKEN_SHARE: | |
| 831 | check_entry_field(share); | |
| 832 | entry->share = TOKEN_GET_STRING(tokens); | |
| 833 | if (memdata != NULL) | |
| 834 | memdata->sharemap.add(entry->share, UNMAPPED_SHARE_PTR, FALSE); | |
| 835 | break; | |
| 836 | ||
| 837 | case ADDRMAP_TOKEN_BASEPTR: | |
| 838 | check_entry_field(baseptr); | |
| 839 | entry->baseptr = (void **)TOKEN_GET_PTR(tokens, voidptr); | |
| 840 | break; | |
| 841 | ||
| 842 | case ADDRMAP_TOKEN_BASE_MEMBER: | |
| 843 | check_entry_field(baseptroffs_plus1); | |
| 844 | TOKEN_UNGET_UINT32(tokens); | |
| 845 | TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->baseptroffs_plus1, 24); | |
| 846 | entry->baseptroffs_plus1++; | |
| 847 | break; | |
| 848 | ||
| 849 | case ADDRMAP_TOKEN_BASE_GENERIC: | |
| 850 | check_entry_field(genbaseptroffs_plus1); | |
| 851 | TOKEN_UNGET_UINT32(tokens); | |
| 852 | TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->genbaseptroffs_plus1, 24); | |
| 853 | entry->genbaseptroffs_plus1++; | |
| 854 | break; | |
| 855 | ||
| 856 | case ADDRMAP_TOKEN_SIZEPTR: | |
| 857 | check_entry_field(sizeptr); | |
| 858 | entry->sizeptr = TOKEN_GET_PTR(tokens, sizeptr); | |
| 859 | break; | |
| 860 | ||
| 861 | case ADDRMAP_TOKEN_SIZE_MEMBER: | |
| 862 | check_entry_field(sizeptroffs_plus1); | |
| 863 | TOKEN_UNGET_UINT32(tokens); | |
| 864 | TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->sizeptroffs_plus1, 24); | |
| 865 | entry->sizeptroffs_plus1++; | |
| 866 | break; | |
| 867 | ||
| 868 | case ADDRMAP_TOKEN_SIZE_GENERIC: | |
| 869 | check_entry_field(gensizeptroffs_plus1); | |
| 870 | TOKEN_UNGET_UINT32(tokens); | |
| 871 | TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, entry->gensizeptroffs_plus1, 24); | |
| 872 | entry->gensizeptroffs_plus1++; | |
| 873 | break; | |
| 874 | ||
| 875 | default: | |
| 876 | fatalerror("Invalid token %d in address map\n", entrytype); | |
| 877 | break; | |
| 878 | } | |
| 879 | } | |
| 880 | ||
| 881 | /* post-process to apply the global mask */ | |
| 882 | if (map->globalmask != 0) | |
| 883 | for (entry = map->entrylist; entry != NULL; entry = entry->next) | |
| 884 | { | |
| 885 | entry->addrstart &= map->globalmask; | |
| 886 | entry->addrend &= map->globalmask; | |
| 887 | entry->addrmask &= map->globalmask; | |
| 888 | } | |
| 889 | } | |
| 890 | ||
| 891 | #endif |
| r0 | r8715 | |
|---|---|---|
| 1 | /*************************************************************************** | |
| 2 | ||
| 3 | addrmap.h | |
| 4 | ||
| 5 | Macros and helper functions for handling address map definitions. | |
| 6 | ||
| 7 | **************************************************************************** | |
| 8 | ||
| 9 | Copyright Aaron Giles | |
| 10 | All rights reserved. | |
| 11 | ||
| 12 | Redistribution and use in source and binary forms, with or without | |
| 13 | modification, are permitted provided that the following conditions are | |
| 14 | met: | |
| 15 | ||
| 16 | * Redistributions of source code must retain the above copyright | |
| 17 | notice, this list of conditions and the following disclaimer. | |
| 18 | * Redistributions in binary form must reproduce the above copyright | |
| 19 | notice, this list of conditions and the following disclaimer in | |
| 20 | the documentation and/or other materials provided with the | |
| 21 | distribution. | |
| 22 | * Neither the name 'MAME' nor the names of its contributors may be | |
| 23 | used to endorse or promote products derived from this software | |
| 24 | without specific prior written permission. | |
| 25 | ||
| 26 | THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR | |
| 27 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 28 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 29 | DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, | |
| 30 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 31 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 32 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
| 34 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
| 35 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 36 | POSSIBILITY OF SUCH DAMAGE. | |
| 37 | ||
| 38 | ***************************************************************************/ | |
| 39 | ||
| 40 | #pragma once | |
| 41 | ||
| 42 | #ifndef __EMU_H__ | |
| 43 | #error Dont include this file directly; include emu.h instead. | |
| 44 | #endif | |
| 45 | ||
| 46 | #ifndef __ADDRMAP_H__ | |
| 47 | #define __ADDRMAP_H__ | |
| 48 | ||
| 49 | ||
| 50 | ||
| 51 | //************************************************************************** | |
| 52 | // CONSTANTS | |
| 53 | //************************************************************************** | |
| 54 | ||
| 55 | // address map handler types | |
| 56 | enum map_handler_type | |
| 57 | { | |
| 58 | AMH_NONE = 0, | |
| 59 | AMH_RAM, | |
| 60 | AMH_ROM, | |
| 61 | AMH_NOP, | |
| 62 | AMH_UNMAP, | |
| 63 | AMH_HANDLER, | |
| 64 | AMH_DEVICE_HANDLER, | |
| 65 | AMH_PORT, | |
| 66 | AMH_BANK | |
| 67 | }; | |
| 68 | ||
| 69 | ||
| 70 | ||
| 71 | //************************************************************************** | |
| 72 | // TYPE DEFINITIONS | |
| 73 | //************************************************************************** | |
| 74 | ||
| 75 | // address map constructors are functions generated by tokens | |
| 76 | typedef void (*address_map_constructor)(address_map &map, const device_config &devconfig); | |
| 77 | ||
| 78 | ||
| 79 | // read_handler is a union of all the different read handler types | |
| 80 | union read_handler | |
| 81 | { | |
| 82 | genf * generic; // generic function pointer | |
| 83 | read8_space_func shandler8; // 8-bit space read handler | |
| 84 | read16_space_func shandler16; // 16-bit space read handler | |
| 85 | read32_space_func shandler32; // 32-bit space read handler | |
| 86 | read64_space_func shandler64; // 64-bit space read handler | |
| 87 | read8_device_func dhandler8; // 8-bit device read handler | |
| 88 | read16_device_func dhandler16; // 16-bit device read handler | |
| 89 | read32_device_func dhandler32; // 32-bit device read handler | |
| 90 | read64_device_func dhandler64; // 64-bit device read handler | |
| 91 | }; | |
| 92 | ||
| 93 | ||
| 94 | // write_handler is a union of all the different write handler types | |
| 95 | union write_handler | |
| 96 | { | |
| 97 | genf * generic; // generic function pointer | |
| 98 | write8_space_func shandler8; // 8-bit space write handler | |
| 99 | write16_space_func shandler16; // 16-bit space write handler | |
| 100 | write32_space_func shandler32; // 32-bit space write handler | |
| 101 | write64_space_func shandler64; // 64-bit space write handler | |
| 102 | write8_device_func dhandler8; // 8-bit device write handler | |
| 103 | write16_device_func dhandler16; // 16-bit device write handler | |
| 104 | write32_device_func dhandler32; // 32-bit device write handler | |
| 105 | write64_device_func dhandler64; // 64-bit device write handler | |
| 106 | }; | |
| 107 | ||
| 108 | ||
| 109 | // memory_handler is a union of all read and write handler types | |
| 110 | union memory_handler | |
| 111 | { | |
| 112 | genf * generic; // generic function pointer | |
| 113 | read_handler read; // read handler union | |
| 114 | write_handler write; // write handler union | |
| 115 | }; | |
| 116 | ||
| 117 | ||
| 118 | // address map handler data | |
| 119 | class map_handler_data | |
| 120 | { | |
| 121 | public: | |
| 122 | map_handler_data() | |
| 123 | : type(AMH_NONE), | |
| 124 | bits(0), | |
| 125 | mask(0), | |
| 126 | name(NULL), | |
| 127 | tag(NULL) { handler.generic = NULL; } | |
| 128 | ||
| 129 | map_handler_type type; // type of the handler | |
| 130 | UINT8 bits; // width of the handler in bits, or 0 for default | |
| 131 | UINT8 mask; // mask for which lanes apply | |
| 132 | memory_handler handler; // a memory handler | |
| 133 | const char * name; // name of the handler | |
| 134 | const char * tag; // tag pointing to a reference | |
| 135 | astring derived_tag; // string used to hold derived names | |
| 136 | }; | |
| 137 | ||
| 138 | ||
| 139 | ||
| 140 | // ======================> address_map_entry | |
| 141 | ||
| 142 | // address_map_entry is a linked list element describing one address range in a map | |
| 143 | class address_map_entry | |
| 144 | { | |
| 145 | public: | |
| 146 | // construction/destruction | |
| 147 | address_map_entry(address_map &map, offs_t start, offs_t end); | |
| 148 | ||
| 149 | // simple inline setters | |
| 150 | void set_mirror(offs_t _mirror) { m_addrmirror = _mirror; } | |
| 151 | void set_read_type(map_handler_type _type) { m_read.type = _type; } | |
| 152 | void set_write_type(map_handler_type _type) { m_write.type = _type; } | |
| 153 | void set_region(const char *tag, offs_t offset) { m_region = tag; m_rgnoffs = offset; } | |
| 154 | void set_share(const char *tag) { m_share = tag; } | |
| 155 | void set_sizeptr(size_t *_sizeptr) { m_sizeptr = _sizeptr; } | |
| 156 | void set_member_baseptr(FPTR offs) { m_baseptroffs_plus1 = offs + 1; } | |
| 157 | void set_member_sizeptr(FPTR offs) { m_sizeptroffs_plus1 = offs + 1; } | |
| 158 | void set_generic_baseptr(FPTR offs) { m_genbaseptroffs_plus1 = offs + 1; } | |
| 159 | void set_generic_sizeptr(FPTR offs) { m_gensizeptroffs_plus1 = offs + 1; } | |
| 160 | ||
| 161 | // mask setting | |
| 162 | void set_mask(offs_t _mask); | |
| 163 | ||
| 164 | // I/O port configuration | |
| 165 | void set_read_port(const device_config &devconfig, const char *tag); | |
| 166 | void set_write_port(const device_config &devconfig, const char *tag); | |
| 167 | void set_readwrite_port(const device_config &devconfig, const char *tag); | |
| 168 | ||
| 169 | // memory bank configuration | |
| 170 | void set_read_bank(const device_config &devconfig, const char *tag); | |
| 171 | void set_write_bank(const device_config &devconfig, const char *tag); | |
| 172 | void set_readwrite_bank(const device_config &devconfig, const char *tag); | |
| 173 | ||
| 174 | // public state | |
| 175 | address_map_entry * m_next; // pointer to the next entry | |
| 176 | address_map & m_map; // reference to our owning map | |
| 177 | astring m_region_string; // string used to hold derived names | |
| 178 | ||
| 179 | offs_t m_addrstart; // start address | |
| 180 | offs_t m_addrend; // end address | |
| 181 | offs_t m_addrmirror; // mirror bits | |
| 182 | offs_t m_addrmask; // mask bits | |
| 183 | map_handler_data m_read; // data for read handler | |
| 184 | map_handler_data m_write; // data for write handler | |
| 185 | const char * m_share; // tag of a shared memory block | |
| 186 | void ** m_baseptr; // receives pointer to memory (optional) | |
| 187 | size_t * m_sizeptr; // receives size of area in bytes (optional) | |
| 188 | UINT32 m_baseptroffs_plus1; // offset of base pointer within driver_data, plus 1 | |
| 189 | UINT32 m_sizeptroffs_plus1; // offset of size pointer within driver_data, plus 1 | |
| 190 | UINT32 m_genbaseptroffs_plus1; // offset of base pointer within generic_pointers, plus 1 | |
| 191 | UINT32 m_gensizeptroffs_plus1; // offset of size pointer within generic_pointers, plus 1 | |
| 192 | const char * m_region; // tag of region containing the memory backing this entry | |
| 193 | offs_t m_rgnoffs; // offset within the region | |
| 194 | ||
| 195 | void * m_memory; // pointer to memory backing this entry | |
| 196 | offs_t m_bytestart; // byte-adjusted start address | |
| 197 | offs_t m_byteend; // byte-adjusted end address | |
| 198 | offs_t m_bytemirror; // byte-adjusted mirror bits | |
| 199 | offs_t m_bytemask; // byte-adjusted mask bits | |
| 200 | ||
| 201 | protected: | |
| 202 | // internal base pointer setting (derived classes provide typed versions) | |
| 203 | void internal_set_baseptr(void **_baseptr) { m_baseptr = _baseptr; } | |
| 204 | ||
| 205 | // internal handler setters for 8-bit functions | |
| 206 | void internal_set_handler(read8_space_func func, const char *string, UINT64 mask); | |
| 207 | void internal_set_handler(write8_space_func func, const char *string, UINT64 mask); | |
| 208 | void internal_set_handler(read8_space_func rfunc, const char *rstring,write8_space_func wfunc, const char *wstring, UINT64 mask); | |
| 209 | void internal_set_handler(const device_config &devconfig, const char *tag, read8_device_func func, const char *string, UINT64 mask); | |
| 210 | void internal_set_handler(const device_config &devconfig, const char *tag, write8_device_func func, const char *string, UINT64 mask); | |
| 211 | void internal_set_handler(const device_config &devconfig, const char *tag, read8_device_func rfunc, const char *rstring, write8_device_func wfunc, const char *wstring, UINT64 mask); | |
| 212 | ||
| 213 | // internal handler setters for 16-bit functions | |
| 214 | void internal_set_handler(read16_space_func func, const char *string, UINT64 mask); | |
| 215 | void internal_set_handler(write16_space_func func, const char *string, UINT64 mask); | |
| 216 | void internal_set_handler(read16_space_func rfunc, const char *rstring, write16_space_func wfunc, const char *wstring, UINT64 mask); | |
| 217 | void internal_set_handler(const device_config &devconfig, const char *tag, read16_device_func func, const char *string, UINT64 mask); | |
| 218 | void internal_set_handler(const device_config &devconfig, const char *tag, write16_device_func func, const char *string, UINT64 mask); | |
| 219 | void internal_set_handler(const device_config &devconfig, const char *tag, read16_device_func rfunc, const char *rstring, write16_device_func wfunc, const char *wstring, UINT64 mask); | |
| 220 | ||
| 221 | // internal handler setters for 32-bit functions | |
| 222 | void internal_set_handler(read32_space_func func, const char *string, UINT64 mask); | |
| 223 | void internal_set_handler(write32_space_func func, const char *string, UINT64 mask); | |
| 224 | void internal_set_handler(read32_space_func rfunc, const char *rstring, write32_space_func wfunc, const char *wstring, UINT64 mask); | |
| 225 | void internal_set_handler(const device_config &devconfig, const char *tag, read32_device_func func, const char *string, UINT64 mask); | |
| 226 | void internal_set_handler(const device_config &devconfig, const char *tag, write32_device_func func, const char *string, UINT64 mask); | |
| 227 | void internal_set_handler(const device_config &devconfig, const char *tag, read32_device_func rfunc, const char *rstring, write32_device_func wfunc, const char *wstring, UINT64 mask); | |
| 228 | ||
| 229 | // internal handler setters for 64-bit functions | |
| 230 | void internal_set_handler(read64_space_func func, const char *string, UINT64 mask); | |
| 231 | void internal_set_handler(write64_space_func func, const char *string, UINT64 mask); | |
| 232 | void internal_set_handler(read64_space_func rfunc, const char *rstring, write64_space_func wfunc, const char *wstring, UINT64 mask); | |
| 233 | void internal_set_handler(const device_config &devconfig, const char *tag, read64_device_func func, const char *string, UINT64 mask); | |
| 234 | void internal_set_handler(const device_config &devconfig, const char *tag, write64_device_func func, const char *string, UINT64 mask); | |
| 235 | void internal_set_handler(const device_config &devconfig, const char *tag, read64_device_func rfunc, const char *rstring, write64_device_func wfunc, const char *wstring, UINT64 mask); | |
| 236 | ||
| 237 | private: | |
| 238 | // helper functions | |
| 239 | bool unitmask_is_appropriate(UINT8 width, UINT64 unitmask, const char *string); | |
| 240 | }; | |
| 241 | ||
| 242 | ||
| 243 | // ======================> address_map_entry8 | |
| 244 | ||
| 245 | // 8-bit address map version of address_map_entry which only permits valid 8-bit handlers | |
| 246 | class address_map_entry8 : public address_map_entry | |
| 247 | { | |
| 248 | public: | |
| 249 | address_map_entry8(address_map &map, offs_t start, offs_t end); | |
| 250 | ||
| 251 | void set_baseptr(UINT8 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); } | |
| 252 | ||
| 253 | // native-size handlers | |
| 254 | void set_handler(read8_space_func func, const char *string) { internal_set_handler(func, string, 0); } | |
| 255 | void set_handler(write8_space_func func, const char *string) { internal_set_handler(func, string, 0); } | |
| 256 | void set_handler(read8_space_func rfunc, const char *rstring, write8_space_func wfunc, const char *wstring) { internal_set_handler(rfunc, rstring, wfunc, wstring, 0); } | |
| 257 | void set_handler(const device_config &devconfig, const char *tag, read8_device_func func, const char *string) { internal_set_handler(devconfig, tag, func, string, 0); } | |
| 258 | void set_handler(const device_config &devconfig, const char *tag, write8_device_func func, const char *string) { internal_set_handler(devconfig, tag, func, string, 0); } | |
| 259 | void set_handler(const device_config &devconfig, const char *tag, read8_device_func rfunc, const char *rstring, write8_device_func wfunc, const char *wstring) { internal_set_handler(devconfig, tag, rfunc, rstring, wfunc, wstring, 0); } | |
| 260 | }; | |
| 261 | ||
| 262 | ||
| 263 | // ======================> address_map_entry16 | |
| 264 | ||
| 265 | // 16-bit address map version of address_map_entry which only permits valid 16-bit handlers | |
| 266 | class address_map_entry16 : public address_map_entry | |
| 267 | { | |
| 268 | public: | |
| 269 | address_map_entry16(address_map &map, offs_t start, offs_t end); | |
| 270 | ||
| 271 | void set_baseptr(UINT16 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); } | |
| 272 | ||
| 273 | // native-size handlers | |
| 274 | void set_handler(read16_space_func func, const char *string) { internal_set_handler(func, string, 0); } | |
| 275 | void set_handler(write16_space_func func, const char *string) { internal_set_handler(func, string, 0); } | |
| 276 | void set_handler(read16_space_func rfunc, const char *rstring, write16_space_func wfunc, const char *wstring) { internal_set_handler(rfunc, rstring, wfunc, wstring, 0); } | |
| 277 | void set_handler(const device_config &devconfig, const char *tag, read16_device_func func, const char *string) { internal_set_handler(devconfig, tag, func, string, 0); } | |
| 278 | void set_handler(const device_config &devconfig, const char *tag, write16_device_func func, const char *string) { internal_set_handler(devconfig, tag, func, string, 0); } | |
| 279 | void set_handler(const device_config &devconfig, const char *tag, read16_device_func rfunc, const char *rstring, write16_device_func wfunc, const char *wstring) { internal_set_handler(devconfig, tag, rfunc, rstring, wfunc, wstring, 0); } | |
| 280 | ||
| 281 | // 8-bit handlers | |
| 282 | void set_handler(read8_space_func func, const char *string, UINT16 mask) { internal_set_handler(func, string, mask); } | |
| 283 | void set_handler(write8_space_func func, const char *string, UINT16 mask) { internal_set_handler(func, string, mask); } | |
| 284 | void set_handler(read8_space_func rfunc, const char *rstring, write8_space_func wfunc, const char *wstring, UINT16 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); } | |
| 285 | void set_handler(const device_config &devconfig, const char *tag, read8_device_func func, const char *string, UINT16 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 286 | void set_handler(const device_config &devconfig, const char *tag, write8_device_func func, const char *string, UINT16 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 287 | void set_handler(const device_config &devconfig, const char *tag, read8_device_func rfunc, const char *rstring, write8_device_func wfunc, const char *wstring, UINT16 mask) { internal_set_handler(devconfig, tag, rfunc, rstring, wfunc, wstring, mask); } | |
| 288 | }; | |
| 289 | ||
| 290 | ||
| 291 | // ======================> address_map_entry32 | |
| 292 | ||
| 293 | // 32-bit address map version of address_map_entry which only permits valid 32-bit handlers | |
| 294 | class address_map_entry32 : public address_map_entry | |
| 295 | { | |
| 296 | public: | |
| 297 | address_map_entry32(address_map &map, offs_t start, offs_t end); | |
| 298 | ||
| 299 | void set_baseptr(UINT32 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); } | |
| 300 | ||
| 301 | // native-size handlers | |
| 302 | void set_handler(read32_space_func func, const char *string) { internal_set_handler(func, string, 0); } | |
| 303 | void set_handler(write32_space_func func, const char *string) { internal_set_handler(func, string, 0); } | |
| 304 | void set_handler(read32_space_func rfunc, const char *rstring, write32_space_func wfunc, const char *wstring) { internal_set_handler(rfunc, rstring, wfunc, wstring, 0); } | |
| 305 | void set_handler(const device_config &devconfig, const char *tag, read32_device_func func, const char *string) { internal_set_handler(devconfig, tag, func, string, 0); } | |
| 306 | void set_handler(const device_config &devconfig, const char *tag, write32_device_func func, const char *string) { internal_set_handler(devconfig, tag, func, string, 0); } | |
| 307 | void set_handler(const device_config &devconfig, const char *tag, read32_device_func rfunc, const char *rstring, write32_device_func wfunc, const char *wstring) { internal_set_handler(devconfig, tag, rfunc, rstring, wfunc, wstring, 0); } | |
| 308 | ||
| 309 | // 16-bit handlers | |
| 310 | void set_handler(read16_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); } | |
| 311 | void set_handler(write16_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); } | |
| 312 | void set_handler(read16_space_func rfunc, const char *rstring, write16_space_func wfunc, const char *wstring, UINT32 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); } | |
| 313 | void set_handler(const device_config &devconfig, const char *tag, read16_device_func func, const char *string, UINT32 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 314 | void set_handler(const device_config &devconfig, const char *tag, write16_device_func func, const char *string, UINT32 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 315 | void set_handler(const device_config &devconfig, const char *tag, read16_device_func rfunc, const char *rstring, write16_device_func wfunc, const char *wstring, UINT32 mask) { internal_set_handler(devconfig, tag, rfunc, rstring, wfunc, wstring, mask); } | |
| 316 | ||
| 317 | // 8-bit handlers | |
| 318 | void set_handler(read8_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); } | |
| 319 | void set_handler(write8_space_func func, const char *string, UINT32 mask) { internal_set_handler(func, string, mask); } | |
| 320 | void set_handler(read8_space_func rfunc, const char *rstring, write8_space_func wfunc, const char *wstring, UINT32 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); } | |
| 321 | void set_handler(const device_config &devconfig, const char *tag, read8_device_func func, const char *string, UINT32 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 322 | void set_handler(const device_config &devconfig, const char *tag, write8_device_func func, const char *string, UINT32 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 323 | void set_handler(const device_config &devconfig, const char *tag, read8_device_func rfunc, const char *rstring, write8_device_func wfunc, const char *wstring, UINT32 mask) { internal_set_handler(devconfig, tag, rfunc, rstring, wfunc, wstring, mask); } | |
| 324 | }; | |
| 325 | ||
| 326 | ||
| 327 | // ======================> address_map_entry64 | |
| 328 | ||
| 329 | // 64-bit address map version of address_map_entry which only permits valid 64-bit handlers | |
| 330 | class address_map_entry64 : public address_map_entry | |
| 331 | { | |
| 332 | public: | |
| 333 | address_map_entry64(address_map &map, offs_t start, offs_t end); | |
| 334 | ||
| 335 | void set_baseptr(UINT64 **baseptr) { internal_set_baseptr(reinterpret_cast<void **>(baseptr)); } | |
| 336 | ||
| 337 | // native-size handlers | |
| 338 | void set_handler(read64_space_func func, const char *string) { internal_set_handler(func, string, 0); } | |
| 339 | void set_handler(write64_space_func func, const char *string) { internal_set_handler(func, string, 0); } | |
| 340 | void set_handler(read64_space_func rfunc, const char *rstring, write64_space_func wfunc, const char *wstring) { internal_set_handler(rfunc, rstring, wfunc, wstring, 0); } | |
| 341 | void set_handler(const device_config &devconfig, const char *tag, read64_device_func func, const char *string) { internal_set_handler(devconfig, tag, func, string, 0); } | |
| 342 | void set_handler(const device_config &devconfig, const char *tag, write64_device_func func, const char *string) { internal_set_handler(devconfig, tag, func, string, 0); } | |
| 343 | void set_handler(const device_config &devconfig, const char *tag, read64_device_func rfunc, const char *rstring, write64_device_func wfunc, const char *wstring) { internal_set_handler(devconfig, tag, rfunc, rstring, wfunc, wstring, 0); } | |
| 344 | ||
| 345 | // 32-bit handlers | |
| 346 | void set_handler(read32_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); } | |
| 347 | void set_handler(write32_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); } | |
| 348 | void set_handler(read32_space_func rfunc, const char *rstring, write32_space_func wfunc, const char *wstring, UINT64 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); } | |
| 349 | void set_handler(const device_config &devconfig, const char *tag, read32_device_func func, const char *string, UINT64 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 350 | void set_handler(const device_config &devconfig, const char *tag, write32_device_func func, const char *string, UINT64 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 351 | void set_handler(const device_config &devconfig, const char *tag, read32_device_func rfunc, const char *rstring, write32_device_func wfunc, const char *wstring, UINT64 mask) { internal_set_handler(devconfig, tag, rfunc, rstring, wfunc, wstring, mask); } | |
| 352 | ||
| 353 | // 16-bit handlers | |
| 354 | void set_handler(read16_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); } | |
| 355 | void set_handler(write16_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); } | |
| 356 | void set_handler(read16_space_func rfunc, const char *rstring, write16_space_func wfunc, const char *wstring, UINT64 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); } | |
| 357 | void set_handler(const device_config &devconfig, const char *tag, read16_device_func func, const char *string, UINT64 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 358 | void set_handler(const device_config &devconfig, const char *tag, write16_device_func func, const char *string, UINT64 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 359 | void set_handler(const device_config &devconfig, const char *tag, read16_device_func rfunc, const char *rstring, write16_device_func wfunc, const char *wstring, UINT64 mask) { internal_set_handler(devconfig, tag, rfunc, rstring, wfunc, wstring, mask); } | |
| 360 | ||
| 361 | // 8-bit handlers | |
| 362 | void set_handler(read8_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); } | |
| 363 | void set_handler(write8_space_func func, const char *string, UINT64 mask) { internal_set_handler(func, string, mask); } | |
| 364 | void set_handler(read8_space_func rfunc, const char *rstring, write8_space_func wfunc, const char *wstring, UINT64 mask) { internal_set_handler(rfunc, rstring, wfunc, wstring, mask); } | |
| 365 | void set_handler(const device_config &devconfig, const char *tag, read8_device_func func, const char *string, UINT64 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 366 | void set_handler(const device_config &devconfig, const char *tag, write8_device_func func, const char *string, UINT64 mask) { internal_set_handler(devconfig, tag, func, string, mask); } | |
| 367 | void set_handler(const device_config &devconfig, const char *tag, read8_device_func rfunc, const char *rstring, write8_device_func wfunc, const char *wstring, UINT64 mask) { internal_set_handler(devconfig, tag, rfunc, rstring, wfunc, wstring, mask); } | |
| 368 | }; | |
| 369 | ||
| 370 | ||
| 371 | // ======================> address_map | |
| 372 | ||
| 373 | // address_map holds global map parameters plus the head of the list of entries | |
| 374 | class address_map | |
| 375 | { | |
| 376 | public: | |
| 377 | // construction/destruction | |
| 378 | address_map(const device_config &devconfig, int spacenum); | |
| 379 | ~address_map(); | |
| 380 | ||
| 381 | // configuration | |
| 382 | void configure(UINT8 _spacenum, UINT8 _databits); | |
| 383 | ||
| 384 | // setters | |
| 385 | void set_global_mask(offs_t mask); | |
| 386 | void set_unmap_value(UINT8 value) { m_unmapval = value; } | |
| 387 | ||
| 388 | // add a new entry of the given type | |
| 389 | address_map_entry8 *add(offs_t start, offs_t end, address_map_entry8 *ptr); | |
| 390 | address_map_entry16 *add(offs_t start, offs_t end, address_map_entry16 *ptr); | |
| 391 | address_map_entry32 *add(offs_t start, offs_t end, address_map_entry32 *ptr); | |
| 392 | address_map_entry64 *add(offs_t start, offs_t end, address_map_entry64 *ptr); | |
| 393 | ||
| 394 | // public data | |
| 395 | UINT8 m_spacenum; // space number of the map | |
| 396 | UINT8 m_databits; // data bits represented by the map | |
| 397 | UINT8 m_unmapval; // unmapped memory value | |
| 398 | offs_t m_globalmask; // global mask | |
| 399 | address_map_entry * m_entrylist; // list of entries | |
| 400 | ||
| 401 | private: | |
| 402 | // internal data | |
| 403 | address_map_entry ** m_tailptr; | |
| 404 | }; | |
| 405 | ||
| 406 | ||
| 407 | ||
| 408 | //************************************************************************** | |
| 409 | // ADDRESS MAP MACROS | |
| 410 | //************************************************************************** | |
| 411 | ||
| 412 | // so that "0" can be used for unneeded address maps | |
| 413 | #define construct_address_map_0 NULL | |
| 414 | ||
| 415 | ||
| 416 | // start/end tags for the address map | |
| 417 | #define ADDRESS_MAP_NAME(_name) construct_address_map_##_name | |
| 418 | ||
| 419 | #define ADDRESS_MAP_START(_name, _space, _bits) \ | |
| 420 | void ADDRESS_MAP_NAME(_name)(address_map &map, const device_config &devconfig) \ | |
| 421 | { \ | |
| 422 | address_map_entry##_bits *curentry = NULL; \ | |
| 423 | (void)curentry; \ | |
| 424 | map.configure(_space, _bits); \ | |
| 425 | ||
| 426 | #define ADDRESS_MAP_END \ | |
| 427 | } | |
| 428 | ||
| 429 | // use this to declare external references to an address map | |
| 430 | #define ADDRESS_MAP_EXTERN(_name, _bits) \ | |
| 431 | extern void ADDRESS_MAP_NAME(_name)(address_map &map, const device_config &devconfig) | |
| 432 | ||
| 433 | ||
| 434 | // global controls | |
| 435 | #define ADDRESS_MAP_GLOBAL_MASK(_mask) \ | |
| 436 | map.set_global_mask(_mask); \ | |
| 437 | ||
| 438 | #define ADDRESS_MAP_UNMAP_LOW \ | |
| 439 | map.set_unmap_value(0); \ | |
| 440 | ||
| 441 | #define ADDRESS_MAP_UNMAP_HIGH \ | |
| 442 | map.set_unmap_value(~0); \ | |
| 443 | ||
| 444 | ||
| 445 | // importing data from other address maps | |
| 446 | #define AM_IMPORT_FROM(_name) \ | |
| 447 | ADDRESS_MAP_NAME(_name)(map, devconfig); \ | |
| 448 | ||
| 449 | ||
| 450 | // address ranges | |
| 451 | #define AM_RANGE(_start, _end) \ | |
| 452 | curentry = map.add(_start, _end, curentry); \ | |
| 453 | ||
| 454 | #define AM_MASK(_mask) \ | |
| 455 | curentry->set_mask(_mask); \ | |
| 456 | ||
| 457 | #define AM_MIRROR(_mirror) \ | |
| 458 | curentry->set_mirror(_mirror); \ | |
| 459 | ||
| 460 | ||
| 461 | // space reads | |
| 462 | #define AM_READ(_handler) \ | |
| 463 | curentry->set_handler(_handler, #_handler); \ | |
| 464 | ||
| 465 | #define AM_READ8(_handler, _unitmask) \ | |
| 466 | curentry->set_handler(_handler, #_handler, _unitmask); \ | |
| 467 | ||
| 468 | #define AM_READ16(_handler, _unitmask) \ | |
| 469 | curentry->set_handler(_handler, #_handler, _unitmask); \ | |
| 470 | ||
| 471 | #define AM_READ32(_handler, _unitmask) \ | |
| 472 | curentry->set_handler(_handler, #_handler, _unitmask); \ | |
| 473 | ||
| 474 | ||
| 475 | // space writes | |
| 476 | #define AM_WRITE(_handler) \ | |
| 477 | curentry->set_handler(_handler, #_handler); \ | |
| 478 | ||
| 479 | #define AM_WRITE8(_handler, _unitmask) \ | |
| 480 | curentry->set_handler(_handler, #_handler, _unitmask); \ | |
| 481 | ||
| 482 | #define AM_WRITE16(_handler, _unitmask) \ | |
| 483 | curentry->set_handler(_handler, #_handler, _unitmask); \ | |
| 484 | ||
| 485 | #define AM_WRITE32(_handler, _unitmask) \ | |
| 486 | curentry->set_handler(_handler, #_handler, _unitmask); \ | |
| 487 | ||
| 488 | ||
| 489 | // space reads/writes | |
| 490 | #define AM_READWRITE(_rhandler, _whandler) \ | |
| 491 | curentry->set_handler(_rhandler, #_rhandler, _whandler, #_whandler); \ | |
| 492 | ||
| 493 | #define AM_READWRITE8(_rhandler, _whandler, _unitmask) \ | |
| 494 | curentry->set_handler(_rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \ | |
| 495 | ||
| 496 | #define AM_READWRITE16(_rhandler, _whandler, _unitmask) \ | |
| 497 | curentry->set_handler(_rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \ | |
| 498 | ||
| 499 | #define AM_READWRITE32(_rhandler, _whandler, _unitmask) \ | |
| 500 | curentry->set_handler(_rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \ | |
| 501 | ||
| 502 | ||
| 503 | // device reads | |
| 504 | #define AM_DEVREAD(_tag, _handler) \ | |
| 505 | curentry->set_handler(devconfig, _tag, _handler, #_handler); \ | |
| 506 | ||
| 507 | #define AM_DEVREAD8(_tag, _handler, _unitmask) \ | |
| 508 | curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \ | |
| 509 | ||
| 510 | #define AM_DEVREAD16(_tag, _handler, _unitmask) \ | |
| 511 | curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \ | |
| 512 | ||
| 513 | #define AM_DEVREAD32(_tag, _handler, _unitmask) \ | |
| 514 | curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \ | |
| 515 | ||
| 516 | ||
| 517 | // device writes | |
| 518 | #define AM_DEVWRITE(_tag, _handler) \ | |
| 519 | curentry->set_handler(devconfig, _tag, _handler, #_handler); \ | |
| 520 | ||
| 521 | #define AM_DEVWRITE8(_tag, _handler, _unitmask) \ | |
| 522 | curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \ | |
| 523 | ||
| 524 | #define AM_DEVWRITE16(_tag, _handler, _unitmask) \ | |
| 525 | curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \ | |
| 526 | ||
| 527 | #define AM_DEVWRITE32(_tag, _handler, _unitmask) \ | |
| 528 | curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \ | |
| 529 | ||
| 530 | ||
| 531 | // device reads/writes | |
| 532 | #define AM_DEVREADWRITE(_tag, _rhandler, _whandler) \ | |
| 533 | curentry->set_handler(devconfig, _tag, _rhandler, #_rhandler, _whandler, #_whandler); \ | |
| 534 | ||
| 535 | #define AM_DEVREADWRITE8(_tag, _rhandler, _whandler, _unitmask) \ | |
| 536 | curentry->set_handler(devconfig, _tag, _rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \ | |
| 537 | ||
| 538 | #define AM_DEVREADWRITE16(_tag, _rhandler, _whandler, _unitmask) \ | |
| 539 | curentry->set_handler(devconfig, _tag, _rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \ | |
| 540 | ||
| 541 | #define AM_DEVREADWRITE32(_tag, _rhandler, _whandler, _unitmask) \ | |
| 542 | curentry->set_handler(devconfig, _tag, _rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \ | |
| 543 | ||
| 544 | ||
| 545 | // special-case accesses | |
| 546 | #define AM_ROM \ | |
| 547 | curentry->set_read_type(AMH_ROM); \ | |
| 548 | ||
| 549 | #define AM_RAM \ | |
| 550 | curentry->set_read_type(AMH_RAM); \ | |
| 551 | curentry->set_write_type(AMH_RAM); \ | |
| 552 | ||
| 553 | #define AM_READONLY \ | |
| 554 | curentry->set_read_type(AMH_RAM); \ | |
| 555 | ||
| 556 | #define AM_WRITEONLY \ | |
| 557 | curentry->set_write_type(AMH_RAM); \ | |
| 558 | ||
| 559 | #define AM_UNMAP \ | |
| 560 | curentry->set_read_type(AMH_UNMAP); \ | |
| 561 | curentry->set_write_type(AMH_UNMAP); \ | |
| 562 | ||
| 563 | #define AM_NOP \ | |
| 564 | curentry->set_read_type(AMH_NOP); \ | |
| 565 | curentry->set_write_type(AMH_NOP); \ | |
| 566 | ||
| 567 | #define AM_READNOP \ | |
| 568 | curentry->set_read_type(AMH_NOP); \ | |
| 569 | ||
| 570 | #define AM_WRITENOP \ | |
| 571 | curentry->set_write_type(AMH_NOP); \ | |
| 572 | ||
| 573 | ||
| 574 | // port accesses | |
| 575 | #define AM_READ_PORT(_tag) \ | |
| 576 | curentry->set_read_port(devconfig, _tag); \ | |
| 577 | ||
| 578 | #define AM_WRITE_PORT(_tag) \ | |
| 579 | curentry->set_write_port(devconfig, _tag); \ | |
| 580 | ||
| 581 | #define AM_READWRITE_PORT(_tag) \ | |
| 582 | curentry->set_readwrite_port(devconfig, _tag); \ | |
| 583 | ||
| 584 | ||
| 585 | // bank accesses | |
| 586 | #define AM_READ_BANK(_tag) \ | |
| 587 | curentry->set_read_bank(devconfig, _tag); \ | |
| 588 | ||
| 589 | #define AM_WRITE_BANK(_tag) \ | |
| 590 | curentry->set_write_bank(devconfig, _tag); \ | |
| 591 | ||
| 592 | #define AM_READWRITE_BANK(_tag) \ | |
| 593 | curentry->set_readwrite_bank(devconfig, _tag); \ | |
| 594 | ||
| 595 | ||
| 596 | // attributes for accesses | |
| 597 | #define AM_REGION(_tag, _offs) \ | |
| 598 | curentry->set_region(_tag, _offs); \ | |
| 599 | ||
| 600 | #define AM_SHARE(_tag) \ | |
| 601 | curentry->set_share(_tag); \ | |
| 602 | ||
| 603 | #define AM_BASE(_base) \ | |
| 604 | curentry->set_baseptr(_base); \ | |
| 605 | ||
| 606 | #define myoffsetof(_struct, _member) ((FPTR)&((_struct *)0x1000)->_member - 0x1000) | |
| 607 | #define AM_BASE_MEMBER(_struct, _member) \ | |
| 608 | curentry->set_member_baseptr(myoffsetof(_struct, _member)); \ | |
| 609 | ||
| 610 | #define AM_BASE_GENERIC(_member) \ | |
| 611 | curentry->set_generic_baseptr(myoffsetof(generic_pointers, _member)); \ | |
| 612 | ||
| 613 | #define AM_SIZE(_size) \ | |
| 614 | curentry->set_sizeptr(_size); \ | |
| 615 | ||
| 616 | #define AM_SIZE_MEMBER(_struct, _member) \ | |
| 617 | curentry->set_member_sizeptr(myoffsetof(_struct, _member)); \ | |
| 618 | ||
| 619 | #define AM_SIZE_GENERIC(_member) \ | |
| 620 | curentry->set_generic_sizeptr(myoffsetof(generic_pointers, _member##_size)); \ | |
| 621 | ||
| 622 | ||
| 623 | // common shortcuts | |
| 624 | #define AM_ROMBANK(_bank) AM_READ_BANK(_bank) | |
| 625 | #define AM_RAMBANK(_bank) AM_READWRITE_BANK(_bank) | |
| 626 | #define AM_RAM_READ(_read) AM_READ(_read) AM_WRITEONLY | |
| 627 | #define AM_RAM_WRITE(_write) AM_READONLY AM_WRITE(_write) | |
| 628 | #define AM_RAM_DEVREAD(_tag, _read) AM_DEVREAD(_tag, _read) AM_WRITEONLY | |
| 629 | #define AM_RAM_DEVWRITE(_tag, _write) AM_READONLY AM_DEVWRITE(_tag, _write) | |
| 630 | ||
| 631 | #define AM_BASE_SIZE_MEMBER(_struct, _base, _size) AM_BASE_MEMBER(_struct, _base) AM_SIZE_MEMBER(_struct, _size) | |
| 632 | #define AM_BASE_SIZE_GENERIC(_member) AM_BASE_GENERIC(_member) AM_SIZE_GENERIC(_member) | |
| 633 | ||
| 634 | ||
| 635 | #endif /* __ADDRMAP_H__ */ |
| r8714 | r8715 | |
|---|---|---|
| 78 | 78 | { |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | address_space_config::address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, | |
| 81 | address_space_config::address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, | |
| 82 | 82 | : m_name(name), |
| 83 | 83 | m_endianness(endian), |
| 84 | 84 | m_databus_width(datawidth), |
| r8714 | r8715 | |
| 91 | 91 | { |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | address_space_config::address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, UINT8 logwidth, UINT8 pageshift, | |
| 94 | address_space_config::address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, UINT8 logwidth, UINT8 pageshift, | |
| 95 | 95 | : m_name(name), |
| 96 | 96 | m_endianness(endian), |
| 97 | 97 | m_databus_width(datawidth), |
| r8714 | r8715 | |
| 188 | 188 | int alignunit = datawidth / 8; |
| 189 | 189 | |
| 190 | 190 | // construct the maps |
| 191 | ::address_map *map = address_map | |
| 191 | ::address_map *map = global_alloc(::address_map | |
| 192 | 192 | |
| 193 | 193 | // if this is an empty map, just skip it |
| 194 | if (map->entrylist == NULL) | |
| 194 | if (map->m_entrylist == NULL) | |
| 195 | 195 | { |
| 196 | a | |
| 196 | global | |
| 197 | 197 | continue; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // validate the global map parameters |
| 201 | if (map->spacenum != spacenum) | |
| 201 | if (map->m_spacenum != spacenum) | |
| 202 | 202 | { |
| 203 | mame_printf_error("%s: %s device '%s' space %d has address space %d handlers!\n", driver.source_file, driver.name, devconfig->tag(), spacenum, map->spacenum); | |
| 203 | mame_printf_error("%s: %s device '%s' space %d has address space %d handlers!\n", driver.source_file, driver.name, devconfig->tag(), spacenum, map->m_spacenum); | |
| 204 | 204 | error = true; |
| 205 | 205 | } |
| 206 | if (map->databits != datawidth) | |
| 206 | if (map->m_databits != datawidth) | |
| 207 | 207 | { |
| 208 | mame_printf_error("%s: %s device '%s' uses wrong memory handlers for %s space! (width = %d, memory = %08x)\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, datawidth, map->databits); | |
| 208 | mame_printf_error("%s: %s device '%s' uses wrong memory handlers for %s space! (width = %d, memory = %08x)\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, datawidth, map->m_databits); | |
| 209 | 209 | error = true; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // loop over entries and look for errors |
| 213 | for (address_map_entry *entry = map->entrylist; entry != NULL; entry = entry->next) | |
| 213 | for (address_map_entry *entry = map->m_entrylist; entry != NULL; entry = entry->m_next) | |
| 214 | 214 | { |
| 215 | UINT32 bytestart = spaceconfig->addr2byte(entry->addrstart); | |
| 216 | UINT32 byteend = spaceconfig->addr2byte_end(entry->addrend); | |
| 215 | UINT32 bytestart = spaceconfig->addr2byte(entry->m_addrstart); | |
| 216 | UINT32 byteend = spaceconfig->addr2byte_end(entry->m_addrend); | |
| 217 | 217 | |
| 218 | 218 | // look for overlapping entries |
| 219 | 219 | if (!detected_overlap) |
| 220 | 220 | { |
| 221 | 221 | address_map_entry *scan; |
| 222 | for (scan = map->entrylist; scan != entry; scan = scan->next) | |
| 223 | if (entry->addrstart <= scan->addrend && entry->addrend >= scan->addrstart && | |
| 224 | ((entry->read.type != AMH_NONE && scan->read.type != AMH_NONE) || | |
| 225 | (entry->write.type != AMH_NONE && scan->write.type != AMH_NONE))) | |
| 222 | for (scan = map->m_entrylist; scan != entry; scan = scan->m_next) | |
| 223 | if (entry->m_addrstart <= scan->m_addrend && entry->m_addrend >= scan->m_addrstart && | |
| 224 | ((entry->m_read.type != AMH_NONE && scan->m_read.type != AMH_NONE) || | |
| 225 | (entry->m_write.type != AMH_NONE && scan->m_write.type != AMH_NONE))) | |
| 226 | 226 | { |
| 227 | mame_printf_warning("%s: %s '%s' %s space has overlapping memory (%X-%X,%d,%d) vs (%X-%X,%d,%d)\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->addrstart, entry->addrend, entry->read.type, entry->write.type, scan->addrstart, scan->addrend, scan->read.type, scan->write.type); | |
| 227 | mame_printf_warning("%s: %s '%s' %s space has overlapping memory (%X-%X,%d,%d) vs (%X-%X,%d,%d)\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->m_addrstart, entry->m_addrend, entry->m_read.type, entry->m_write.type, scan->m_addrstart, scan->m_addrend, scan->m_read.type, scan->m_write.type); | |
| 228 | 228 | detected_overlap = true; |
| 229 | 229 | break; |
| 230 | 230 | } |
| r8714 | r8715 | |
| 233 | 233 | // look for inverted start/end pairs |
| 234 | 234 | if (byteend < bytestart) |
| 235 | 235 | { |
| 236 | mame_printf_error("%s: %s wrong %s memory read handler start = %08x > end = %08x\n", driver.source_file, driver.name, spaceconfig->m_name, entry->addrstart, entry->addrend); | |
| 236 | mame_printf_error("%s: %s wrong %s memory read handler start = %08x > end = %08x\n", driver.source_file, driver.name, spaceconfig->m_name, entry->m_addrstart, entry->m_addrend); | |
| 237 | 237 | error = true; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // look for misaligned entries |
| 241 | 241 | if ((bytestart & (alignunit - 1)) != 0 || (byteend & (alignunit - 1)) != (alignunit - 1)) |
| 242 | 242 | { |
| 243 | mame_printf_error("%s: %s wrong %s memory read handler start = %08x, end = %08x ALIGN = %d\n", driver.source_file, driver.name, spaceconfig->m_name, entry->addrstart, entry->addrend, alignunit); | |
| 243 | mame_printf_error("%s: %s wrong %s memory read handler start = %08x, end = %08x ALIGN = %d\n", driver.source_file, driver.name, spaceconfig->m_name, entry->m_addrstart, entry->m_addrend, alignunit); | |
| 244 | 244 | error = true; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | // if this is a program space, auto-assign implicit ROM entries |
| 248 | if (entry->read.type == AMH_ROM && entry->region == NULL) | |
| 248 | if (entry->m_read.type == AMH_ROM && entry->m_region == NULL) | |
| 249 | 249 | { |
| 250 | entry->region = devconfig->tag(); | |
| 251 | entry->rgnoffs = entry->addrstart; | |
| 250 | entry->m_region = devconfig->tag(); | |
| 251 | entry->m_rgnoffs = entry->m_addrstart; | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | // if this entry references a memory region, validate it |
| 255 | if (entry->region != NULL && entry->share == 0) | |
| 255 | if (entry->m_region != NULL && entry->m_share == 0) | |
| 256 | 256 | { |
| 257 | 257 | // look for the region |
| 258 | 258 | bool found = false; |
| r8714 | r8715 | |
| 264 | 264 | { |
| 265 | 265 | astring fulltag; |
| 266 | 266 | rom_region_name(fulltag, &driver, source, romp); |
| 267 | if (fulltag.cmp(entry->region) == 0) | |
| 267 | if (fulltag.cmp(entry->m_region) == 0) | |
| 268 | 268 | { |
| 269 | 269 | // verify the address range is within the region's bounds |
| 270 | 270 | offs_t length = ROMREGION_GETLENGTH(romp); |
| 271 | if (entry->rgnoffs + (byteend - bytestart + 1) > length) | |
| 271 | if (entry->m_rgnoffs + (byteend - bytestart + 1) > length) | |
| 272 | 272 | { |
| 273 | mame_printf_error("%s: %s device '%s' %s space memory map entry %X-%X extends beyond region '%s' size (%X)\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->addrstart, entry->addrend, entry->region, length); | |
| 273 | mame_printf_error("%s: %s device '%s' %s space memory map entry %X-%X extends beyond region '%s' size (%X)\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->m_addrstart, entry->m_addrend, entry->m_region, length); | |
| 274 | 274 | error = true; |
| 275 | 275 | } |
| 276 | 276 | found = true; |
| r8714 | r8715 | |
| 281 | 281 | // error if not found |
| 282 | 282 | if (!found) |
| 283 | 283 | { |
| 284 | mame_printf_error("%s: %s device '%s' %s space memory map entry %X-%X references non-existant region '%s'\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->addrstart, entry->addrend, entry->region); | |
| 284 | mame_printf_error("%s: %s device '%s' %s space memory map entry %X-%X references non-existant region '%s'\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->m_addrstart, entry->m_addrend, entry->m_region); | |
| 285 | 285 | error = true; |
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | // make sure all devices exist |
| 290 | if ((entry->read.type == AMH_DEVICE_HANDLER && entry->read.tag != NULL && m_machine_config.m_devicelist.find(entry->read.tag) == NULL) || | |
| 291 | (entry->write.type == AMH_DEVICE_HANDLER && entry->write.tag != NULL && m_machine_config.m_devicelist.find(entry->write.tag) == NULL)) | |
| 290 | if ((entry->m_read.type == AMH_DEVICE_HANDLER && entry->m_read.tag != NULL && m_machine_config.m_devicelist.find(entry->m_read.tag) == NULL) || | |
| 291 | (entry->m_write.type == AMH_DEVICE_HANDLER && entry->m_write.tag != NULL && m_machine_config.m_devicelist.find(entry->m_write.tag) == NULL)) | |
| 292 | 292 | { |
| 293 | mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant device '%s'\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->write.tag); | |
| 293 | mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant device '%s'\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->m_write.tag); | |
| 294 | 294 | error = true; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | // make sure ports exist |
| 298 | // if ((entry->read.type == AMH_PORT && entry->read.tag != NULL && portlist.find(entry->read.tag) == NULL) || | |
| 299 | // (entry->write.type == AMH_PORT && entry->write.tag != NULL && portlist.find(entry->write.tag) == NULL)) | |
| 298 | // if ((entry->m_read.type == AMH_PORT && entry->m_read.tag != NULL && portlist.find(entry->m_read.tag) == NULL) || | |
| 299 | // (entry->m_write.type == AMH_PORT && entry->m_write.tag != NULL && portlist.find(entry->m_write.tag) == NULL)) | |
| 300 | 300 | // { |
| 301 | // mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant port tag '%s'\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->read.tag); | |
| 301 | // mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant port tag '%s'\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->m_read.tag); | |
| 302 | 302 | // error = true; |
| 303 | 303 | // } |
| 304 | 304 | |
| 305 | 305 | // validate bank and share tags |
| 306 | if (entry->read.type == AMH_BANK && !validate_tag(&driver, "bank", entry->read.tag)) | |
| 306 | if (entry->m_read.type == AMH_BANK && !validate_tag(&driver, "bank", entry->m_read.tag)) | |
| 307 | 307 | error = true ; |
| 308 | if (entry->write.type == AMH_BANK && !validate_tag(&driver, "bank", entry->write.tag)) | |
| 308 | if (entry->m_write.type == AMH_BANK && !validate_tag(&driver, "bank", entry->m_write.tag)) | |
| 309 | 309 | error = true; |
| 310 | if (entry->share != NULL && !validate_tag(&driver, "share", entry->share)) | |
| 310 | if (entry->m_share != NULL && !validate_tag(&driver, "share", entry->m_share)) | |
| 311 | 311 | error = true; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // release the address map |
| 315 | a | |
| 315 | global | |
| 316 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | return error; |
| r8714 | r8715 | |
|---|---|---|
| 106 | 106 | #define video_update_0 NULL |
| 107 | 107 | |
| 108 | 108 | |
| 109 | class driver_data_t; | |
| 110 | ||
| 109 | 111 | typedef void (*nvram_handler_func)(running_machine *machine, mame_file *file, int read_or_write); |
| 110 | 112 | typedef void (*memcard_handler_func)(running_machine *machine, mame_file *file, int action); |
| 111 | 113 | typedef void (*machine_start_func)(running_machine *machine); |
| r8714 | r8715 | |
| 117 | 119 | typedef void (*palette_init_func)(running_machine *machine, const UINT8 *color_prom); |
| 118 | 120 | typedef void (*video_eof_func)(running_machine *machine); |
| 119 | 121 | typedef UINT32 (*video_update_func)(device_t *screen, bitmap_t *bitmap, const rectangle *cliprect); |
| 120 | typedef | |
| 122 | typedef driver_data_t * | |
| 121 | 123 | |
| 122 | 124 | |
| 123 | 125 | |
| r8714 | r8715 | |
| 295 | 297 | TOKEN_COMMON_FIELDS |
| 296 | 298 | const machine_config_token *tokenptr; |
| 297 | 299 | const gfx_decode_entry *gfxdecode; |
| 298 | | |
| 300 | | |
| 299 | 301 | device_type devtype; |
| 300 | 302 | nvram_handler_func nvram_handler; |
| 301 | 303 | memcard_handler_func memcard_handler; |
| r8714 | r8715 | |
|---|---|---|
| 83 | 83 | |
| 84 | 84 | #define MDRV_DEVICE_ADDRESS_MAP(_space, _map) \ |
| 85 | 85 | TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DIMEMORY_MAP, 8, _space, 8), \ |
| 86 | TOKEN_PTR(addrmap, ( | |
| 86 | TOKEN_PTR(addrmap, ( | |
| 87 | 87 | |
| 88 | 88 | #define MDRV_DEVICE_PROGRAM_MAP(_map) \ |
| 89 | 89 | MDRV_DEVICE_ADDRESS_MAP(AS_PROGRAM, _map) |
| r8714 | r8715 | |
| 106 | 106 | { |
| 107 | 107 | public: |
| 108 | 108 | address_space_config(); |
| 109 | address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift = 0, const addrmap_token *internal = NULL, const addrmap_token *defmap = NULL); | |
| 110 | address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, UINT8 logwidth, UINT8 pageshift, const addrmap_token *internal = NULL, const addrmap_token *defmap = NULL); | |
| 109 | address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift = 0, address_map_constructor internal = NULL, address_map_constructor defmap = NULL); | |
| 110 | address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, UINT8 logwidth, UINT8 pageshift, address_map_constructor internal = NULL, address_map_constructor defmap = NULL); | |
| 111 | 111 | |
| 112 | 112 | inline offs_t addr2byte(offs_t address) const |
| 113 | 113 | { |
| r8714 | r8715 | |
| 136 | 136 | INT8 m_addrbus_shift; |
| 137 | 137 | UINT8 m_logaddr_width; |
| 138 | 138 | UINT8 m_page_shift; |
| 139 | const addrmap_token *m_internal_map; | |
| 140 | const addrmap_token *m_default_map; | |
| 139 | address_map_constructor m_internal_map; | |
| 140 | address_map_constructor m_default_map; | |
| 141 | 141 | }; |
| 142 | 142 | |
| 143 | 143 | |
| r8714 | r8715 | |
| 155 | 155 | virtual ~device_config_memory_interface(); |
| 156 | 156 | |
| 157 | 157 | // basic information getters |
| 158 | | |
| 158 | | |
| 159 | 159 | const address_space_config *space_config(int spacenum = 0) const { return memory_space_config(spacenum); } |
| 160 | 160 | |
| 161 | 161 | protected: |
| r8714 | r8715 | |
| 166 | 166 | virtual bool interface_process_token(UINT32 entrytype, const machine_config_token *&tokens); |
| 167 | 167 | virtual bool interface_validity_check(const game_driver &driver) const; |
| 168 | 168 | |
| 169 | | |
| 169 | | |
| 170 | 170 | }; |
| 171 | 171 | |
| 172 | 172 |
| r8714 | r8715 | |
|---|---|---|
| 403 | 403 | // handle protected carts |
| 404 | 404 | static void install_protection(device_image_interface& image) |
| 405 | 405 | { |
| 406 | neogeo_state *state = | |
| 406 | neogeo_state *state = | |
| 407 | 407 | const char *crypt_feature = image.get_feature( "crypt" ); |
| 408 | 408 | |
| 409 | 409 | if(crypt_feature == NULL) |
| r8714 | r8715 | |
|---|---|---|
| 68 | 68 | INT16 last_val = 0; |
| 69 | 69 | stream_sample_t *buffer = outputs[0]; |
| 70 | 70 | mac_sound *token = get_token(device); |
| 71 | mac_state *mac = | |
| 71 | mac_state *mac = | |
| 72 | 72 | |
| 73 | 73 | if ((mac->mac_model == MODEL_MAC_PORTABLE) || (mac->mac_model == MODEL_MAC_PB100)) |
| 74 | 74 | { |
| r8714 | r8715 | |
|---|---|---|
| 296 | 296 | |
| 297 | 297 | READ32_HANDLER( _3do_svf_r ) |
| 298 | 298 | { |
| 299 | _3do_state *state = | |
| 299 | _3do_state *state = | |
| 300 | 300 | UINT32 addr = ( offset & ( 0x07fc / 4 ) ) << 9; |
| 301 | 301 | UINT32 *p = state->vram + addr; |
| 302 | 302 | |
| r8714 | r8715 | |
| 322 | 322 | |
| 323 | 323 | WRITE32_HANDLER( _3do_svf_w ) |
| 324 | 324 | { |
| 325 | _3do_state *state = | |
| 325 | _3do_state *state = | |
| 326 | 326 | UINT32 addr = ( offset & ( 0x07fc / 4 ) ) << 9; |
| 327 | 327 | UINT32 *p = state->vram + addr; |
| 328 | 328 | |
| r8714 | r8715 | |
| 1132 | 1132 | /* This is incorrect! Just testing stuff */ |
| 1133 | 1133 | VIDEO_UPDATE( _3do ) |
| 1134 | 1134 | { |
| 1135 | _3do_state *state = | |
| 1135 | _3do_state *state = | |
| 1136 | 1136 | UINT32 *source_p = state->vram + 0x1c0000 / 4; |
| 1137 | 1137 | |
| 1138 | 1138 | for ( int i = 0; i < 120; i++ ) |
| r8714 | r8715 | |
|---|---|---|
| 204 | 204 | READ8_DEVICE_HANDLER( cbmb_keyboard_line_c ) |
| 205 | 205 | { |
| 206 | 206 | int data = 0; |
| 207 | cbmb_state *state = | |
| 207 | cbmb_state *state = | |
| 208 | 208 | if ((input_port_read(device->machine, "ROW0") & ~cbmb_keyline_a) || |
| 209 | 209 | (input_port_read(device->machine, "ROW1") & ~cbmb_keyline_b)) |
| 210 | 210 | data |= 0x01; |
| r8714 | r8715 | |
| 311 | 311 | |
| 312 | 312 | static void cbmb_common_driver_init( running_machine *machine ) |
| 313 | 313 | { |
| 314 | cbmb_state *state = | |
| 314 | cbmb_state *state = | |
| 315 | 315 | cbmb_chargen = memory_region(machine, "maincpu") + 0x100000; |
| 316 | 316 | /* memset(c64_memory, 0, 0xfd00); */ |
| 317 | 317 | |
| r8714 | r8715 | |
| 323 | 323 | |
| 324 | 324 | DRIVER_INIT( cbm600 ) |
| 325 | 325 | { |
| 326 | cbmb_state *state = | |
| 326 | cbmb_state *state = | |
| 327 | 327 | cbmb_common_driver_init(machine); |
| 328 | 328 | state->cbm_ntsc = 1; |
| 329 | 329 | cbm600_vh_init(machine); |
| r8714 | r8715 | |
| 331 | 331 | |
| 332 | 332 | DRIVER_INIT( cbm600pal ) |
| 333 | 333 | { |
| 334 | cbmb_state *state = | |
| 334 | cbmb_state *state = | |
| 335 | 335 | cbmb_common_driver_init(machine); |
| 336 | 336 | state->cbm_ntsc = 0; |
| 337 | 337 | cbm600_vh_init(machine); |
| r8714 | r8715 | |
| 339 | 339 | |
| 340 | 340 | DRIVER_INIT( cbm600hu ) |
| 341 | 341 | { |
| 342 | cbmb_state *state = | |
| 342 | cbmb_state *state = | |
| 343 | 343 | cbmb_common_driver_init(machine); |
| 344 | 344 | state->cbm_ntsc = 0; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | DRIVER_INIT( cbm700 ) |
| 348 | 348 | { |
| 349 | cbmb_state *state = | |
| 349 | cbmb_state *state = | |
| 350 | 350 | cbmb_common_driver_init(machine); |
| 351 | 351 | state->cbm700 = 1; |
| 352 | 352 | state->cbm_ntsc = 0; |
| r8714 | r8715 | |
| 355 | 355 | |
| 356 | 356 | DRIVER_INIT( p500 ) |
| 357 | 357 | { |
| 358 | cbmb_state *state = | |
| 358 | cbmb_state *state = | |
| 359 | 359 | cbmb_common_driver_init(machine); |
| 360 | 360 | state->p500 = 1; |
| 361 | 361 | state->cbm_ntsc = 1; |
| r8714 | r8715 | |
|---|---|---|
| 600 | 600 | |
| 601 | 601 | static void pak_load_trailer(running_machine *machine, const pak_decodedtrailer *trailer) |
| 602 | 602 | { |
| 603 | coco_state *state = | |
| 603 | coco_state *state = | |
| 604 | 604 | |
| 605 | 605 | cpu_set_reg(machine->device("maincpu"), M6809_PC, trailer->reg_pc); |
| 606 | 606 | cpu_set_reg(machine->device("maincpu"), M6809_X, trailer->reg_x); |
| r8714 | r8715 | |
| 909 | 909 | |
| 910 | 910 | static void d_recalc_irq(running_machine *machine) |
| 911 | 911 | { |
| 912 | coco_state *state = | |
| 912 | coco_state *state = | |
| 913 | 913 | UINT8 pia0_irq_a = pia6821_get_irq_a(state->pia_0); |
| 914 | 914 | UINT8 pia0_irq_b = pia6821_get_irq_b(state->pia_0); |
| 915 | 915 | |
| r8714 | r8715 | |
| 921 | 921 | |
| 922 | 922 | static void d_recalc_firq(running_machine *machine) |
| 923 | 923 | { |
| 924 | coco_state *state = | |
| 924 | coco_state *state = | |
| 925 | 925 | UINT8 pia1_firq_a = pia6821_get_irq_a(state->pia_1); |
| 926 | 926 | UINT8 pia1_firq_b = pia6821_get_irq_b(state->pia_1); |
| 927 | 927 | UINT8 pia2_firq_a = (state->pia_2 != NULL) ? pia6821_get_irq_a(state->pia_2) : 0x00; |
| r8714 | r8715 | |
| 1036 | 1036 | |
| 1037 | 1037 | void coco3_horizontal_sync_callback(running_machine *machine,int data) |
| 1038 | 1038 | { |
| 1039 | coco_state *state = | |
| 1039 | coco_state *state = | |
| 1040 | 1040 | pia6821_ca1_w(state->pia_0, data); |
| 1041 | 1041 | coco3_raise_interrupt(machine, COCO3_INT_HBORD, data); |
| 1042 | 1042 | } |
| r8714 | r8715 | |
| 1045 | 1045 | |
| 1046 | 1046 | void coco3_field_sync_callback(running_machine *machine,int data) |
| 1047 | 1047 | { |
| 1048 | coco_state *state = | |
| 1048 | coco_state *state = | |
| 1049 | 1049 | pia6821_cb1_w(state->pia_0, data); |
| 1050 | 1050 | } |
| 1051 | 1051 | |
| r8714 | r8715 | |
| 1175 | 1175 | |
| 1176 | 1176 | static running_device *cassette_device_image(running_machine *machine) |
| 1177 | 1177 | { |
| 1178 | coco_state *state = | |
| 1178 | coco_state *state = | |
| 1179 | 1179 | return state->cassette_device; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | static running_device *bitbanger_image(running_machine *machine) |
| 1183 | 1183 | { |
| 1184 | coco_state *state = | |
| 1184 | coco_state *state = | |
| 1185 | 1185 | return state->bitbanger_device; |
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | 1188 | static running_device *printer_image(running_machine *machine) |
| 1189 | 1189 | { |
| 1190 | coco_state *state = | |
| 1190 | coco_state *state = | |
| 1191 | 1191 | return state->printer_device; |
| 1192 | 1192 | } |
| 1193 | 1193 | |
| 1194 | 1194 | static running_device *cococart_device(running_machine *machine) |
| 1195 | 1195 | { |
| 1196 | coco_state *state = | |
| 1196 | coco_state *state = | |
| 1197 | 1197 | return state->cococart_device; |
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | static int get_soundmux_status(running_machine *machine) |
| 1201 | 1201 | { |
| 1202 | coco_state *state = | |
| 1202 | coco_state *state = | |
| 1203 | 1203 | |
| 1204 | 1204 | int soundmux_status = 0; |
| 1205 | 1205 | if (pia6821_get_output_cb2(state->pia_1)) |
| r8714 | r8715 | |
| 1242 | 1242 | |
| 1243 | 1243 | static void coco_sound_update(running_machine *machine) |
| 1244 | 1244 | { |
| 1245 | coco_state *state = | |
| 1245 | coco_state *state = | |
| 1246 | 1246 | |
| 1247 | 1247 | /* Call this function whenever you need to update the sound. It will |
| 1248 | 1248 | * automatically mute any devices that are switched out. |
| r8714 | r8715 | |
| 1356 | 1356 | |
| 1357 | 1357 | static UINT8 coco_update_keyboard( running_machine *machine ) |
| 1358 | 1358 | { |
| 1359 | coco_state *state = | |
| 1359 | coco_state *state = | |
| 1360 | 1360 | UINT8 porta = 0x7f, port_za = 0x7f; |
| 1361 | 1361 | int joyval; |
| 1362 | 1362 | static const int joy_rat_table[] = {15, 24, 42, 33 }; |
| r8714 | r8715 | |
| 1542 | 1542 | /* Printer output for the Dragon, output to Paralel port */ |
| 1543 | 1543 | static void printer_out_dragon(running_machine *machine, int data) |
| 1544 | 1544 | { |
| 1545 | coco_state *state = | |
| 1545 | coco_state *state = | |
| 1546 | 1546 | |
| 1547 | 1547 | /* If strobe bit is high send data from pia0 port b to dragon parallel printer */ |
| 1548 | 1548 | if (data & 0x02) |
| r8714 | r8715 | |
| 1735 | 1735 | /* The NMI line on the alphaAlpha is gated through IC16 (early PLD), and is gated by pia2 CA2 */ |
| 1736 | 1736 | static WRITE_LINE_DEVICE_HANDLER( dgnalpha_fdc_intrq_w ) |
| 1737 | 1737 | { |
| 1738 | coco_state *cstate = | |
| 1738 | coco_state *cstate = | |
| 1739 | 1739 | |
| 1740 | 1740 | if (state) |
| 1741 | 1741 | { |
| r8714 | r8715 | |
| 1757 | 1757 | /* for pia1 cb1 */ |
| 1758 | 1758 | static WRITE_LINE_DEVICE_HANDLER( dgnalpha_fdc_drq_w ) |
| 1759 | 1759 | { |
| 1760 | coco_state *cstate = | |
| 1760 | coco_state *cstate = | |
| 1761 | 1761 | pia6821_cb1_w(cstate->pia_2, state ? CARTLINE_ASSERTED : CARTLINE_CLEAR); |
| 1762 | 1762 | } |
| 1763 | 1763 | |
| r8714 | r8715 | |
| 1839 | 1839 | |
| 1840 | 1840 | static READ8_DEVICE_HANDLER ( d_pia1_pb_r_coco ) |
| 1841 | 1841 | { |
| 1842 | coco_state *state = | |
| 1842 | coco_state *state = | |
| 1843 | 1843 | |
| 1844 | 1844 | /* This handles the reading of the memory sense switch (pb2) for the CoCo 1, |
| 1845 | 1845 | * and serial-in (pb0). Serial-in not yet implemented. */ |
| r8714 | r8715 | |
| 1883 | 1883 | |
| 1884 | 1884 | static READ8_DEVICE_HANDLER ( d_pia1_pb_r_coco2 ) |
| 1885 | 1885 | { |
| 1886 | coco_state *state = | |
| 1886 | coco_state *state = | |
| 1887 | 1887 | |
| 1888 | 1888 | /* This handles the reading of the memory sense switch (pb2) for the CoCo 2 and 3, |
| 1889 | 1889 | * and serial-in (pb0). Serial-in not yet implemented. |
| r8714 | r8715 | |
| 2034 | 2034 | |
| 2035 | 2035 | /* We need to init these vars from the sam, as this may be called from outside the sam callbacks */ |
| 2036 | 2036 | const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM ); |
| 2037 | coco_state *state = | |
| 2037 | coco_state *state = | |
| 2038 | 2038 | UINT8 memsize = sam6883_memorysize(state->sam); |
| 2039 | 2039 | UINT8 maptype = sam6883_maptype(state->sam); |
| 2040 | 2040 | //UINT8 pagemode = sam6883_pagemode(machine); |
| r8714 | r8715 | |
| 2711 | 2711 | |
| 2712 | 2712 | void coco_cart_w(running_device *device, int data) |
| 2713 | 2713 | { |
| 2714 | coco_state *state = | |
| 2714 | coco_state *state = | |
| 2715 | 2715 | pia6821_cb1_w(state->pia_1, data ? ASSERT_LINE : CLEAR_LINE); |
| 2716 | 2716 | } |
| 2717 | 2717 | |
| r8714 | r8715 | |
| 2783 | 2783 | /* for everything except the coco3, so it made sense not to pass it as a parameter */ |
| 2784 | 2784 | static void generic_init_machine(running_machine *machine, const machine_init_interface *init) |
| 2785 | 2785 | { |
| 2786 | coco_state *state = (coco_state *) | |
| 2786 | coco_state *state = (coco_state *) | |
| 2787 | 2787 | |
| 2788 | 2788 | /* locate devices */ |
| 2789 | 2789 | state->cococart_device = machine->device("coco_cartslot"); |
| r8714 | r8715 | |
|---|---|---|
| 27 | 27 | |
| 28 | 28 | MACHINE_START( advision ) |
| 29 | 29 | { |
| 30 | advision_state *state = | |
| 30 | advision_state *state = | |
| 31 | 31 | /* configure EA banking */ |
| 32 | 32 | memory_configure_bank(machine, "bank1", 0, 1, memory_region(machine, "bios"), 0); |
| 33 | 33 | memory_configure_bank(machine, "bank1", 1, 1, memory_region(machine, I8048_TAG), 0); |
| r8714 | r8715 | |
| 40 | 40 | |
| 41 | 41 | MACHINE_RESET( advision ) |
| 42 | 42 | { |
| 43 | advision_state *state = | |
| 43 | advision_state *state = | |
| 44 | 44 | |
| 45 | 45 | /* enable internal ROM */ |
| 46 | 46 | cputag_set_input_line(machine, I8048_TAG, MCS48_INPUT_EA, CLEAR_LINE); |
| r8714 | r8715 | |
| 59 | 59 | |
| 60 | 60 | WRITE8_HANDLER( advision_bankswitch_w ) |
| 61 | 61 | { |
| 62 | advision_state *state = | |
| 62 | advision_state *state = | |
| 63 | 63 | |
| 64 | 64 | int ea = BIT(data, 2); |
| 65 | 65 | |
| r8714 | r8715 | |
| 74 | 74 | |
| 75 | 75 | READ8_HANDLER( advision_extram_r ) |
| 76 | 76 | { |
| 77 | advision_state *state = | |
| 77 | advision_state *state = | |
| 78 | 78 | |
| 79 | 79 | UINT8 data = state->extram[state->rambank + offset]; |
| 80 | 80 | |
| r8714 | r8715 | |
| 94 | 94 | |
| 95 | 95 | WRITE8_HANDLER( advision_extram_w ) |
| 96 | 96 | { |
| 97 | advision_state *state = | |
| 97 | advision_state *state = | |
| 98 | 98 | |
| 99 | 99 | state->extram[state->rambank + offset] = data; |
| 100 | 100 | } |
| r8714 | r8715 | |
| 103 | 103 | |
| 104 | 104 | READ8_HANDLER( advision_sound_cmd_r ) |
| 105 | 105 | { |
| 106 | advision_state *state = | |
| 106 | advision_state *state = | |
| 107 | 107 | |
| 108 | 108 | return state->sound_cmd; |
| 109 | 109 | } |
| r8714 | r8715 | |
| 111 | 111 | static void update_dac(running_machine *machine) |
| 112 | 112 | { |
| 113 | 113 | running_device *dac_device = machine->device("dac"); |
| 114 | advision_state *state = | |
| 114 | advision_state *state = | |
| 115 | 115 | |
| 116 | 116 | if (state->sound_g == 0 && state->sound_d == 0) |
| 117 | 117 | dac_data_w(dac_device, 0xff); |
| r8714 | r8715 | |
| 123 | 123 | |
| 124 | 124 | WRITE8_HANDLER( advision_sound_g_w ) |
| 125 | 125 | { |
| 126 | advision_state *state = | |
| 126 | advision_state *state = | |
| 127 | 127 | state->sound_g = data & 0x01; |
| 128 | 128 | update_dac(space->machine); |
| 129 | 129 | } |
| r8714 | r8715 | |
| 131 | 131 | |
| 132 | 132 | WRITE8_HANDLER( advision_sound_d_w ) |
| 133 | 133 | { |
| 134 | advision_state *state = | |
| 134 | advision_state *state = | |
| 135 | 135 | state->sound_d = data & 0x01; |
| 136 | 136 | update_dac(space->machine); |
| 137 | 137 | } |
| r8714 | r8715 | |
| 140 | 140 | |
| 141 | 141 | WRITE8_HANDLER( advision_av_control_w ) |
| 142 | 142 | { |
| 143 | advision_state *state = | |
| 143 | advision_state *state = | |
| 144 | 144 | |
| 145 | 145 | state->sound_cmd = data >> 4; |
| 146 | 146 | |
| r8714 | r8715 | |
| 163 | 163 | |
| 164 | 164 | READ8_HANDLER( advision_vsync_r ) |
| 165 | 165 | { |
| 166 | advision_state *state = | |
| 166 | advision_state *state = | |
| 167 | 167 | |
| 168 | 168 | if (state->frame_start) |
| 169 | 169 | { |
| r8714 | r8715 | |
|---|---|---|
| 143 | 143 | |
| 144 | 144 | static WRITE_LINE_DEVICE_HANDLER(bm2_pit_out1) |
| 145 | 145 | { |
| 146 | b2m_state *st = | |
| 146 | b2m_state *st = | |
| 147 | 147 | speaker_level_w(st->speaker, state); |
| 148 | 148 | } |
| 149 | 149 | |
| r8714 | r8715 | |
| 170 | 170 | |
| 171 | 171 | static WRITE8_DEVICE_HANDLER (b2m_8255_porta_w ) |
| 172 | 172 | { |
| 173 | b2m_state *state = | |
| 173 | b2m_state *state = | |
| 174 | 174 | state->b2m_8255_porta = data; |
| 175 | 175 | } |
| 176 | 176 | static WRITE8_DEVICE_HANDLER (b2m_8255_portb_w ) |
| 177 | 177 | { |
| 178 | b2m_state *state = | |
| 178 | b2m_state *state = | |
| 179 | 179 | state->b2m_video_scroll = data; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | static WRITE8_DEVICE_HANDLER (b2m_8255_portc_w ) |
| 183 | 183 | { |
| 184 | b2m_state *state = | |
| 184 | b2m_state *state = | |
| 185 | 185 | |
| 186 | 186 | state->b2m_8255_portc = data; |
| 187 | 187 | b2m_set_bank(device->machine, state->b2m_8255_portc & 7); |
| r8714 | r8715 | |
| 190 | 190 | |
| 191 | 191 | static READ8_DEVICE_HANDLER (b2m_8255_portb_r ) |
| 192 | 192 | { |
| 193 | b2m_state *state = | |
| 193 | b2m_state *state = | |
| 194 | 194 | return state->b2m_video_scroll; |
| 195 | 195 | } |
| 196 | 196 | |
| r8714 | r8715 | |
| 210 | 210 | { |
| 211 | 211 | UINT8 drive = ((data >> 1) & 1) ^ 1; |
| 212 | 212 | UINT8 side = (data & 1) ^ 1; |
| 213 | b2m_state *state = | |
| 213 | b2m_state *state = | |
| 214 | 214 | floppy_mon_w(floppy_get_device(device->machine, 0), 1); |
| 215 | 215 | floppy_mon_w(floppy_get_device(device->machine, 1), 1); |
| 216 | 216 | |
| r8714 | r8715 | |
| 241 | 241 | |
| 242 | 242 | static READ8_DEVICE_HANDLER (b2m_romdisk_porta_r ) |
| 243 | 243 | { |
| 244 | b2m_state *state = | |
| 244 | b2m_state *state = | |
| 245 | 245 | |
| 246 | 246 | UINT8 *romdisk = memory_region(device->machine, "maincpu") + 0x12000; |
| 247 | 247 | return romdisk[state->b2m_romdisk_msb*256+state->b2m_romdisk_lsb]; |
| r8714 | r8715 | |
| 249 | 249 | |
| 250 | 250 | static WRITE8_DEVICE_HANDLER (b2m_romdisk_portb_w ) |
| 251 | 251 | { |
| 252 | b2m_state *state = | |
| 252 | b2m_state *state = | |
| 253 | 253 | state->b2m_romdisk_lsb = data; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | static WRITE8_DEVICE_HANDLER (b2m_romdisk_portc_w ) |
| 257 | 257 | { |
| 258 | b2m_state *state = | |
| 258 | b2m_state *state = | |
| 259 | 259 | state->b2m_romdisk_msb = data & 0x7f; |
| 260 | 260 | } |
| 261 | 261 | |
| r8714 | r8715 | |
| 277 | 277 | /* Driver initialization */ |
| 278 | 278 | DRIVER_INIT( b2m ) |
| 279 | 279 | { |
| 280 | b2m_state *state = | |
| 280 | b2m_state *state = | |
| 281 | 281 | state->vblank_state = 0; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | WRITE8_HANDLER ( b2m_palette_w ) |
| 285 | 285 | { |
| 286 | b2m_state *state = | |
| 286 | b2m_state *state = | |
| 287 | 287 | |
| 288 | 288 | UINT8 b = (3 - ((data >> 6) & 3)) * 0x55; |
| 289 | 289 | UINT8 g = (3 - ((data >> 4) & 3)) * 0x55; |
| r8714 | r8715 | |
| 302 | 302 | |
| 303 | 303 | READ8_HANDLER ( b2m_palette_r ) |
| 304 | 304 | { |
| 305 | b2m_state *state = | |
| 305 | b2m_state *state = | |
| 306 | 306 | return state->b2m_color[offset]; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | WRITE8_HANDLER ( b2m_localmachine_w ) |
| 310 | 310 | { |
| 311 | b2m_state *state = | |
| 311 | b2m_state *state = | |
| 312 | 312 | state->b2m_localmachine = data; |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | READ8_HANDLER ( b2m_localmachine_r ) |
| 316 | 316 | { |
| 317 | b2m_state *state = | |
| 317 | b2m_state *state = | |
| 318 | 318 | return state->b2m_localmachine; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | static STATE_POSTLOAD( b2m_postload ) |
| 322 | 322 | { |
| 323 | b2m_state *state = | |
| 323 | b2m_state *state = | |
| 324 | 324 | b2m_set_bank(machine, state->b2m_8255_portc & 7); |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | MACHINE_START(b2m) |
| 328 | 328 | { |
| 329 | b2m_state *state = | |
| 329 | b2m_state *state = | |
| 330 | 330 | state->pic = machine->device("pic8259"); |
| 331 | 331 | state->fdc = machine->device("wd1793"); |
| 332 | 332 | state->speaker = machine->device("speaker"); |
| r8714 | r8715 | |
| 351 | 351 | |
| 352 | 352 | static IRQ_CALLBACK(b2m_irq_callback) |
| 353 | 353 | { |
| 354 | b2m_state *state = | |
| 354 | b2m_state *state = | |
| 355 | 355 | return pic8259_acknowledge(state->pic); |
| 356 | 356 | } |
| 357 | 357 | |
| r8714 | r8715 | |
| 362 | 362 | |
| 363 | 363 | INTERRUPT_GEN( b2m_vblank_interrupt ) |
| 364 | 364 | { |
| 365 | b2m_state *state = | |
| 365 | b2m_state *state = | |
| 366 | 366 | state->vblank_state++; |
| 367 | 367 | if (state->vblank_state>1) state->vblank_state=0; |
| 368 | 368 | pic8259_ir0_w(state->pic, state->vblank_state); |
| r8714 | r8715 | |
| 370 | 370 | |
| 371 | 371 | MACHINE_RESET(b2m) |
| 372 | 372 | { |
| 373 | b2m_state *state = | |
| 373 | b2m_state *state = | |
| 374 | 374 | state->b2m_side = 0; |
| 375 | 375 | state->b2m_drive = 0; |
| 376 | 376 |
| r8714 | r8715 | |
|---|---|---|
| 151 | 151 | static READ8_DEVICE_HANDLER( petb_kin_r ) |
| 152 | 152 | { |
| 153 | 153 | UINT8 data = 0xff; |
| 154 | pet_state *state = | |
| 154 | pet_state *state = | |
| 155 | 155 | static const char *const keynames[] = { |
| 156 | 156 | "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", |
| 157 | 157 | "ROW5", "ROW6", "ROW7", "ROW8", "ROW9" |
| r8714 | r8715 | |
| 206 | 206 | |
| 207 | 207 | static WRITE_LINE_DEVICE_HANDLER( pia0_irq_w ) |
| 208 | 208 | { |
| 209 | pet_state *driver_state = | |
| 209 | pet_state *driver_state = | |
| 210 | 210 | |
| 211 | 211 | driver_state->pia0_irq = state; |
| 212 | 212 | int level = (driver_state->pia0_irq | driver_state->pia1_irq | driver_state->via_irq) ? ASSERT_LINE : CLEAR_LINE; |
| r8714 | r8715 | |
| 293 | 293 | |
| 294 | 294 | static WRITE_LINE_DEVICE_HANDLER( pia1_irq_w ) |
| 295 | 295 | { |
| 296 | pet_state *driver_state = | |
| 296 | pet_state *driver_state = | |
| 297 | 297 | |
| 298 | 298 | driver_state->pia1_irq = state; |
| 299 | 299 | int level = (driver_state->pia0_irq | driver_state->pia1_irq | driver_state->via_irq) ? ASSERT_LINE : CLEAR_LINE; |
| r8714 | r8715 | |
| 425 | 425 | |
| 426 | 426 | static WRITE_LINE_DEVICE_HANDLER( via_irq_w ) |
| 427 | 427 | { |
| 428 | pet_state *driver_state = | |
| 428 | pet_state *driver_state = | |
| 429 | 429 | |
| 430 | 430 | driver_state->via_irq = state; |
| 431 | 431 | int level = (driver_state->pia0_irq | driver_state->pia1_irq | driver_state->via_irq) ? ASSERT_LINE : CLEAR_LINE; |
| r8714 | r8715 | |
| 697 | 697 | static void pet_common_driver_init( running_machine *machine ) |
| 698 | 698 | { |
| 699 | 699 | int i; |
| 700 | pet_state *state = | |
| 700 | pet_state *state = | |
| 701 | 701 | |
| 702 | 702 | pet_font = 0; |
| 703 | 703 | |
| r8714 | r8715 | |
| 730 | 730 | |
| 731 | 731 | DRIVER_INIT( pet2001 ) |
| 732 | 732 | { |
| 733 | pet_state *state = | |
| 733 | pet_state *state = | |
| 734 | 734 | pet_memory = messram_get_ptr(machine->device("messram")); |
| 735 | 735 | pet_common_driver_init(machine); |
| 736 | 736 | state->pet_basic1 = 1; |
| r8714 | r8715 | |
| 746 | 746 | |
| 747 | 747 | DRIVER_INIT( pet80 ) |
| 748 | 748 | { |
| 749 | pet_state *state = | |
| 749 | pet_state *state = | |
| 750 | 750 | pet_memory = memory_region(machine, "maincpu"); |
| 751 | 751 | |
| 752 | 752 | pet_common_driver_init(machine); |
| r8714 | r8715 | |
| 759 | 759 | |
| 760 | 760 | DRIVER_INIT( superpet ) |
| 761 | 761 | { |
| 762 | pet_state *state = | |
| 762 | pet_state *state = | |
| 763 | 763 | pet_memory = messram_get_ptr(machine->device("messram")); |
| 764 | 764 | pet_common_driver_init(machine); |
| 765 | 765 | state->superpet = 1; |
| r8714 | r8715 | |
| 774 | 774 | |
| 775 | 775 | MACHINE_RESET( pet ) |
| 776 | 776 | { |
| 777 | pet_state *state = | |
| 777 | pet_state *state = | |
| 778 | 778 | running_device *ieeebus = machine->device("ieee_bus"); |
| 779 | 779 | running_device *scapegoat = machine->device("pia_0"); |
| 780 | 780 | |
| r8714 | r8715 | |
| 820 | 820 | |
| 821 | 821 | INTERRUPT_GEN( pet_frame_interrupt ) |
| 822 | 822 | { |
| 823 | pet_state *state = | |
| 823 | pet_state *state = | |
| 824 | 824 | if (state->superpet) |
| 825 | 825 | { |
| 826 | 826 | if (input_port_read(device->machine, "CFG") & 0x04) |
| r8714 | r8715 | |
|---|---|---|
| 70 | 70 | |
| 71 | 71 | void c16_m7501_port_write( running_device *device, UINT8 direction, UINT8 data ) |
| 72 | 72 | { |
| 73 | c16_state *state = | |
| 73 | c16_state *state = | |
| 74 | 74 | |
| 75 | 75 | /* bit zero then output 0 */ |
| 76 | 76 | cbm_iec_atn_w(state->serbus, device, !BIT(data, 2)); |
| r8714 | r8715 | |
| 84 | 84 | |
| 85 | 85 | UINT8 c16_m7501_port_read( running_device *device, UINT8 direction ) |
| 86 | 86 | { |
| 87 | c16_state *state = | |
| 87 | c16_state *state = | |
| 88 | 88 | UINT8 data = 0xff; |
| 89 | 89 | UINT8 c16_port7501 = m6510_get_port(state->maincpu); |
| 90 | 90 | |
| r8714 | r8715 | |
| 106 | 106 | |
| 107 | 107 | static void c16_bankswitch( running_machine *machine ) |
| 108 | 108 | { |
| 109 | c16_state *state = | |
| 109 | c16_state *state = | |
| 110 | 110 | UINT8 *rom = memory_region(machine, "maincpu"); |
| 111 | 111 | memory_set_bankptr(machine, "bank9", messram_get_ptr(state->messram)); |
| 112 | 112 | |
| r8714 | r8715 | |
| 150 | 150 | |
| 151 | 151 | WRITE8_HANDLER( c16_switch_to_rom ) |
| 152 | 152 | { |
| 153 | c16_state *state = | |
| 153 | c16_state *state = | |
| 154 | 154 | |
| 155 | 155 | ted7360_rom_switch_w(state->ted7360, 1); |
| 156 | 156 | c16_bankswitch(space->machine); |
| r8714 | r8715 | |
| 171 | 171 | * 1 1 c2 high */ |
| 172 | 172 | WRITE8_HANDLER( c16_select_roms ) |
| 173 | 173 | { |
| 174 | c16_state *state = | |
| 174 | c16_state *state = | |
| 175 | 175 | |
| 176 | 176 | state->lowrom = offset & 0x03; |
| 177 | 177 | state->highrom = (offset & 0x0c) >> 2; |
| r8714 | r8715 | |
| 181 | 181 | |
| 182 | 182 | WRITE8_HANDLER( c16_switch_to_ram ) |
| 183 | 183 | { |
| 184 | c16_state *state = | |
| 184 | c16_state *state = | |
| 185 | 185 | |
| 186 | 186 | ted7360_rom_switch_w(state->ted7360, 0); |
| 187 | 187 | |
| r8714 | r8715 | |
| 193 | 193 | |
| 194 | 194 | UINT8 c16_read_keyboard( running_machine *machine, int databus ) |
| 195 | 195 | { |
| 196 | c16_state *state = | |
| 196 | c16_state *state = | |
| 197 | 197 | UINT8 value = 0xff; |
| 198 | 198 | int i; |
| 199 | 199 | |
| r8714 | r8715 | |
| 228 | 228 | */ |
| 229 | 229 | WRITE8_HANDLER( c16_6529_port_w ) |
| 230 | 230 | { |
| 231 | c16_state *state = | |
| 231 | c16_state *state = | |
| 232 | 232 | state->port6529 = data; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | READ8_HANDLER( c16_6529_port_r ) |
| 236 | 236 | { |
| 237 | c16_state *state = | |
| 237 | c16_state *state = | |
| 238 | 238 | return state->port6529 & (c16_read_keyboard (space->machine, 0xff /*databus */ ) | (state->port6529 ^ 0xff)); |
| 239 | 239 | } |
| 240 | 240 | |
| r8714 | r8715 | |
| 254 | 254 | |
| 255 | 255 | READ8_HANDLER( plus4_6529_port_r ) |
| 256 | 256 | { |
| 257 | c16_state *state = | |
| 257 | c16_state *state = | |
| 258 | 258 | int data = 0x00; |
| 259 | 259 | |
| 260 | 260 | if ((cassette_get_state(state->cassette) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| r8714 | r8715 | |
| 267 | 267 | |
| 268 | 268 | READ8_HANDLER( c16_fd1x_r ) |
| 269 | 269 | { |
| 270 | c16_state *state = | |
| 270 | c16_state *state = | |
| 271 | 271 | int data = 0x00; |
| 272 | 272 | |
| 273 | 273 | if ((cassette_get_state(state->cassette) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| r8714 | r8715 | |
| 317 | 317 | */ |
| 318 | 318 | WRITE8_HANDLER( c16_6551_port_w ) |
| 319 | 319 | { |
| 320 | c16_state *state = | |
| 320 | c16_state *state = | |
| 321 | 321 | |
| 322 | 322 | offset &= 0x03; |
| 323 | 323 | DBG_LOG(space->machine, 3, "6551", ("port write %.2x %.2x\n", offset, data)); |
| r8714 | r8715 | |
| 335 | 335 | |
| 336 | 336 | int c16_dma_read( running_machine *machine, int offset ) |
| 337 | 337 | { |
| 338 | c16_state *state = | |
| 338 | c16_state *state = | |
| 339 | 339 | return messram_get_ptr(state->messram)[offset % messram_get_size(state->messram)]; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | int c16_dma_read_rom( running_machine *machine, int offset ) |
| 343 | 343 | { |
| 344 | c16_state *state = | |
| 344 | c16_state *state = | |
| 345 | 345 | |
| 346 | 346 | /* should read real c16 system bus from 0xfd00 -ff1f */ |
| 347 | 347 | if (offset >= 0xc000) |
| r8714 | r8715 | |
| 382 | 382 | |
| 383 | 383 | void c16_interrupt( running_machine *machine, int level ) |
| 384 | 384 | { |
| 385 | c16_state *state = | |
| 385 | c16_state *state = | |
| 386 | 386 | |
| 387 | 387 | if (level != state->old_level) |
| 388 | 388 | { |
| r8714 | r8715 | |
| 394 | 394 | |
| 395 | 395 | static void c16_common_driver_init( running_machine *machine ) |
| 396 | 396 | { |
| 397 | c16_state *state = | |
| 397 | c16_state *state = | |
| 398 | 398 | UINT8 *rom = memory_region(machine, "maincpu"); |
| 399 | 399 | |
| 400 | 400 | /* initial bankswitch (notice that TED7360 is init to ROM) */ |
| r8714 | r8715 | |
| 415 | 415 | |
| 416 | 416 | DRIVER_INIT( c16 ) |
| 417 | 417 | { |
| 418 | c16_state *state = | |
| 418 | c16_state *state = | |
| 419 | 419 | c16_common_driver_init(machine); |
| 420 | 420 | |
| 421 | 421 | state->sidcard = 0; |
| r8714 | r8715 | |
| 424 | 424 | |
| 425 | 425 | DRIVER_INIT( plus4 ) |
| 426 | 426 | { |
| 427 | c16_state *state = | |
| 427 | c16_state *state = | |
| 428 | 428 | c16_common_driver_init(machine); |
| 429 | 429 | |
| 430 | 430 | state->sidcard = 0; |
| r8714 | r8715 | |
| 433 | 433 | |
| 434 | 434 | DRIVER_INIT( c16sid ) |
| 435 | 435 | { |
| 436 | c16_state *state = | |
| 436 | c16_state *state = | |
| 437 | 437 | c16_common_driver_init(machine); |
| 438 | 438 | |
| 439 | 439 | state->sidcard = 1; |
| r8714 | r8715 | |
| 442 | 442 | |
| 443 | 443 | DRIVER_INIT( plus4sid ) |
| 444 | 444 | { |
| 445 | c16_state *state = | |
| 445 | c16_state *state = | |
| 446 | 446 | c16_common_driver_init(machine); |
| 447 | 447 | |
| 448 | 448 | state->sidcard = 1; |
| r8714 | r8715 | |
| 452 | 452 | MACHINE_RESET( c16 ) |
| 453 | 453 | { |
| 454 | 454 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 455 | c16_state *state = | |
| 455 | c16_state *state = | |
| 456 | 456 | |
| 457 | 457 | memset(state->keyline, 0xff, ARRAY_LENGTH(state->keyline)); |
| 458 | 458 | |
| r8714 | r8715 | |
| 487 | 487 | // would a real SID Card allow for this? If not, this should be removed completely |
| 488 | 488 | static WRITE8_HANDLER( c16_sidcart_16k ) |
| 489 | 489 | { |
| 490 | c16_state *state = | |
| 490 | c16_state *state = | |
| 491 | 491 | |
| 492 | 492 | messram_get_ptr(state->messram)[0x1400 + offset] = data; |
| 493 | 493 | messram_get_ptr(state->messram)[0x5400 + offset] = data; |
| r8714 | r8715 | |
| 499 | 499 | |
| 500 | 500 | static WRITE8_HANDLER( c16_sidcart_64k ) |
| 501 | 501 | { |
| 502 | c16_state *state = | |
| 502 | c16_state *state = | |
| 503 | 503 | |
| 504 | 504 | messram_get_ptr(state->messram)[0xd400 + offset] = data; |
| 505 | 505 | |
| r8714 | r8715 | |
| 509 | 509 | static TIMER_CALLBACK( c16_sidhack_tick ) |
| 510 | 510 | { |
| 511 | 511 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 512 | c16_state *state = | |
| 512 | c16_state *state = | |
| 513 | 513 | |
| 514 | 514 | if (input_port_read_safe(machine, "SID", 0x00) & 0x02) |
| 515 | 515 | { |
| r8714 | r8715 | |
| 527 | 527 | |
| 528 | 528 | static TIMER_CALLBACK( c16_sidcard_tick ) |
| 529 | 529 | { |
| 530 | c16_state *state = | |
| 530 | c16_state *state = | |
| 531 | 531 | const address_space *space = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM); |
| 532 | 532 | |
| 533 | 533 | if (input_port_read_safe(machine, "SID", 0x00) & 0x01) |
| r8714 | r8715 | |
| 538 | 538 | |
| 539 | 539 | INTERRUPT_GEN( c16_frame_interrupt ) |
| 540 | 540 | { |
| 541 | c16_state *state = | |
| 541 | c16_state *state = | |
| 542 | 542 | int value, i; |
| 543 | 543 | static const char *const c16ports[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7" }; |
| 544 | 544 |
| r8714 | r8715 | |
|---|---|---|
| 100 | 100 | |
| 101 | 101 | static WRITE_LINE_DEVICE_HANDLER( at_pit8254_out0_changed ) |
| 102 | 102 | { |
| 103 | at_state *st = | |
| 103 | at_state *st = | |
| 104 | 104 | if (st->pic8259_master) |
| 105 | 105 | { |
| 106 | 106 | pic8259_ir0_w(st->pic8259_master, state); |
| r8714 | r8715 | |
| 143 | 143 | |
| 144 | 144 | static void at_set_irq_line(running_machine *machine,int irq, int state) |
| 145 | 145 | { |
| 146 | at_state *st = | |
| 146 | at_state *st = | |
| 147 | 147 | |
| 148 | 148 | switch (irq) |
| 149 | 149 | { |
| r8714 | r8715 | |
| 161 | 161 | |
| 162 | 162 | static void at_set_keyb_int(running_machine *machine, int state) |
| 163 | 163 | { |
| 164 | at_state *st = | |
| 164 | at_state *st = | |
| 165 | 165 | pic8259_ir1_w(st->pic8259_master, state); |
| 166 | 166 | } |
| 167 | 167 | |
| r8714 | r8715 | |
| 187 | 187 | |
| 188 | 188 | static void at_keyboard_interrupt(running_machine *machine, int state) |
| 189 | 189 | { |
| 190 | at_state *st = | |
| 190 | at_state *st = | |
| 191 | 191 | pic8259_ir1_w(st->pic8259_master, state); |
| 192 | 192 | } |
| 193 | 193 | |
| r8714 | r8715 | |
| 255 | 255 | |
| 256 | 256 | static WRITE_LINE_DEVICE_HANDLER( pc_dma_hrq_changed ) |
| 257 | 257 | { |
| 258 | at_state *st = | |
| 258 | at_state *st = | |
| 259 | 259 | cpu_set_input_line(st->maincpu, INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE); |
| 260 | 260 | |
| 261 | 261 | /* Assert HLDA */ |
| r8714 | r8715 | |
| 350 | 350 | /* called when a interrupt is set/cleared from com hardware */ |
| 351 | 351 | static INS8250_INTERRUPT( at_com_interrupt_1 ) |
| 352 | 352 | { |
| 353 | at_state *st = | |
| 353 | at_state *st = | |
| 354 | 354 | pic8259_ir4_w(st->pic8259_master, state); |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | static INS8250_INTERRUPT( at_com_interrupt_2 ) |
| 358 | 358 | { |
| 359 | at_state *st = | |
| 359 | at_state *st = | |
| 360 | 360 | pic8259_ir3_w(st->pic8259_master, state); |
| 361 | 361 | } |
| 362 | 362 | |
| r8714 | r8715 | |
| 419 | 419 | |
| 420 | 420 | static void at_fdc_interrupt(running_machine *machine, int state) |
| 421 | 421 | { |
| 422 | at_state *st = | |
| 422 | at_state *st = | |
| 423 | 423 | pic8259_ir6_w(st->pic8259_master, state); |
| 424 | 424 | //if ( messram_get_ptr(machine->device("messram"))[0x0490] == 0x74 ) |
| 425 | 425 | // messram_get_ptr(machine->device("messram"))[0x0490] = 0x54; |
| r8714 | r8715 | |
| 428 | 428 | |
| 429 | 429 | static void at_fdc_dma_drq(running_machine *machine, int state, int read_) |
| 430 | 430 | { |
| 431 | at_state *st = | |
| 431 | at_state *st = | |
| 432 | 432 | i8237_dreq2_w( st->dma8237_1, state); |
| 433 | 433 | } |
| 434 | 434 | |
| r8714 | r8715 | |
| 447 | 447 | |
| 448 | 448 | |
| 449 | 449 | static int at_get_out2(running_machine *machine) { |
| 450 | at_state *st = | |
| 450 | at_state *st = | |
| 451 | 451 | return pit8253_get_output(st->pit8254, 2 ); |
| 452 | 452 | } |
| 453 | 453 | |
| r8714 | r8715 | |
| 510 | 510 | |
| 511 | 511 | static WRITE8_HANDLER( at_kbdc8042_p2_w ) |
| 512 | 512 | { |
| 513 | at_state *st = | |
| 513 | at_state *st = | |
| 514 | 514 | running_device *keyboard = space->machine->device("keyboard"); |
| 515 | 515 | |
| 516 | 516 | //logerror("%04x: writing $%02x to P2\n", cpu_get_pc(space->machine->device("maincpu")), data ); |
| r8714 | r8715 | |
| 572 | 572 | READ8_HANDLER(at_kbdc8042_r) |
| 573 | 573 | { |
| 574 | 574 | UINT8 data = 0; |
| 575 | at_state *st = | |
| 575 | at_state *st = | |
| 576 | 576 | |
| 577 | 577 | switch ( offset ) |
| 578 | 578 | { |
| r8714 | r8715 | |
| 618 | 618 | |
| 619 | 619 | WRITE8_HANDLER(at_kbdc8042_w) |
| 620 | 620 | { |
| 621 | at_state *st = | |
| 621 | at_state *st = | |
| 622 | 622 | if (LOG_KBDC) |
| 623 | 623 | logerror("kbdc8042_8_w(): ofset=%d data=0x%02x\n", offset, data); |
| 624 | 624 | |
| r8714 | r8715 | |
| 742 | 742 | |
| 743 | 743 | static IRQ_CALLBACK(at_irq_callback) |
| 744 | 744 | { |
| 745 | at_state *st = | |
| 745 | at_state *st = | |
| 746 | 746 | return pic8259_acknowledge( st->pic8259_master); |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | static void pc_set_irq_line(running_machine *machine,int irq, int state) |
| 750 | 750 | { |
| 751 | pc_state *st = | |
| 751 | pc_state *st = | |
| 752 | 752 | |
| 753 | 753 | switch (irq) |
| 754 | 754 | { |
| r8714 | r8715 | |
| 775 | 775 | |
| 776 | 776 | MACHINE_RESET( at ) |
| 777 | 777 | { |
| 778 | at_state *st = | |
| 778 | at_state *st = | |
| 779 | 779 | st->maincpu = machine->device("maincpu"); |
| 780 | 780 | st->pic8259_master = machine->device("pic8259_master"); |
| 781 | 781 | st->pic8259_slave = machine->device("pic8259_slave"); |
| r8714 | r8715 | |
|---|---|---|
| 74 | 74 | |
| 75 | 75 | int einstein_keyboard_daisy_device::z80daisy_irq_state() |
| 76 | 76 | { |
| 77 | einstein_state *einstein = | |
| 77 | einstein_state *einstein = | |
| 78 | 78 | |
| 79 | 79 | if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_KEY_INT) |
| 80 | 80 | return Z80_DAISY_INT; |
| r8714 | r8715 | |
| 173 | 173 | |
| 174 | 174 | int einstein_adc_daisy_device::z80daisy_irq_state() |
| 175 | 175 | { |
| 176 | einstein_state *einstein = | |
| 176 | einstein_state *einstein = | |
| 177 | 177 | |
| 178 | 178 | if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_ADC_INT) |
| 179 | 179 | return Z80_DAISY_INT; |
| r8714 | r8715 | |
| 272 | 272 | |
| 273 | 273 | int einstein_fire_daisy_device::z80daisy_irq_state() |
| 274 | 274 | { |
| 275 | einstein_state *einstein = | |
| 275 | einstein_state *einstein = | |
| 276 | 276 | |
| 277 | 277 | if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_FIRE_INT) |
| 278 | 278 | return Z80_DAISY_INT; |
| r8714 | r8715 | |
|---|---|---|
| 650 | 650 | // helper function for the few mappers reading from 0x8000-0xffff for protection |
| 651 | 651 | INLINE UINT8 mmc_hi_access_rom( running_machine *machine, UINT32 offset ) |
| 652 | 652 | { |
| 653 | nes_state *state = | |
| 653 | nes_state *state = | |
| 654 | 654 | |
| 655 | 655 | // usual ROM access |
| 656 | 656 | switch (offset & 0x6000) |
| r8714 | r8715 | |
| 776 | 776 | |
| 777 | 777 | static WRITE8_HANDLER( cnrom_w ) |
| 778 | 778 | { |
| 779 | nes_state *state = | |
| 779 | nes_state *state = | |
| 780 | 780 | LOG_MMC(("cnrom_w, offset: %04x, data: %02x\n", offset, data)); |
| 781 | 781 | |
| 782 | 782 | if (state->ce_mask) |
| r8714 | r8715 | |
| 911 | 911 | |
| 912 | 912 | static TIMER_CALLBACK( mmc1_resync_callback ) |
| 913 | 913 | { |
| 914 | nes_state *state = | |
| 914 | nes_state *state = | |
| 915 | 915 | state->mmc1_reg_write_enable = 1; |
| 916 | 916 | } |
| 917 | 917 | |
| r8714 | r8715 | |
| 919 | 919 | static void mmc1_set_wram( const address_space *space, int board ) |
| 920 | 920 | { |
| 921 | 921 | running_machine *machine = space->machine; |
| 922 | nes_state *state = | |
| 922 | nes_state *state = | |
| 923 | 923 | UINT8 bank = BIT(state->mmc_reg[0], 4) ? BIT(state->mmc_reg[1], 4) : BIT(state->mmc_reg[1], 3); |
| 924 | 924 | |
| 925 | 925 | switch (board) |
| r8714 | r8715 | |
| 954 | 954 | |
| 955 | 955 | static void mmc1_set_prg( running_machine *machine ) |
| 956 | 956 | { |
| 957 | nes_state *state = | |
| 957 | nes_state *state = | |
| 958 | 958 | UINT8 prg_mode, prg_offset; |
| 959 | 959 | |
| 960 | 960 | prg_mode = state->mmc_reg[0] & 0x0c; |
| r8714 | r8715 | |
| 996 | 996 | |
| 997 | 997 | static void mmc1_set_chr( running_machine *machine ) |
| 998 | 998 | { |
| 999 | nes_state *state = | |
| 999 | nes_state *state = | |
| 1000 | 1000 | UINT8 chr_mode = BIT(state->mmc_reg[0], 4); |
| 1001 | 1001 | |
| 1002 | 1002 | if (chr_mode) |
| r8714 | r8715 | |
| 1011 | 1011 | static void common_sxrom_write_handler( const address_space *space, offs_t offset, UINT8 data, int board ) |
| 1012 | 1012 | { |
| 1013 | 1013 | running_machine *machine = space->machine; |
| 1014 | nes_state *state = | |
| 1014 | nes_state *state = | |
| 1015 | 1015 | /* Note that there is only one latch and shift counter, shared amongst the 4 regs */ |
| 1016 | 1016 | /* Space Shuttle will not work if they have independent variables. */ |
| 1017 | 1017 | |
| r8714 | r8715 | |
| 1086 | 1086 | |
| 1087 | 1087 | static WRITE8_HANDLER( sxrom_w ) |
| 1088 | 1088 | { |
| 1089 | nes_state *state = | |
| 1089 | nes_state *state = | |
| 1090 | 1090 | |
| 1091 | 1091 | LOG_MMC(("sxrom_w, offset: %04x, data: %02x\n", offset, data)); |
| 1092 | 1092 | common_sxrom_write_handler(space, offset, data, state->pcb_id); |
| r8714 | r8715 | |
| 1106 | 1106 | |
| 1107 | 1107 | static void mmc2_latch( running_device *device, offs_t offset ) |
| 1108 | 1108 | { |
| 1109 | nes_state *state = | |
| 1109 | nes_state *state = | |
| 1110 | 1110 | if ((offset & 0x3ff0) == 0x0fd0) |
| 1111 | 1111 | { |
| 1112 | 1112 | LOG_MMC(("mmc2 vrom latch switch (bank 0 low): %02x\n", state->mmc_reg[0])); |
| r8714 | r8715 | |
| 1135 | 1135 | |
| 1136 | 1136 | static WRITE8_HANDLER( pxrom_w ) |
| 1137 | 1137 | { |
| 1138 | nes_state *state = | |
| 1138 | nes_state *state = | |
| 1139 | 1139 | LOG_MMC(("pxrom_w, offset: %04x, data: %02x\n", offset, data)); |
| 1140 | 1140 | switch (offset & 0x7000) |
| 1141 | 1141 | { |
| r8714 | r8715 | |
| 1208 | 1208 | static void mmc3_set_wram( const address_space *space ) |
| 1209 | 1209 | { |
| 1210 | 1210 | running_machine *machine = space->machine; |
| 1211 | nes_state *state = | |
| 1211 | nes_state *state = | |
| 1212 | 1212 | |
| 1213 | 1213 | // skip this function if we are emulating a MMC3 clone with mid writes |
| 1214 | 1214 | if (state->mmc_write_mid != NULL) |
| r8714 | r8715 | |
| 1233 | 1233 | |
| 1234 | 1234 | static void mmc3_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 1235 | 1235 | { |
| 1236 | nes_state *state = | |
| 1236 | nes_state *state = | |
| 1237 | 1237 | UINT8 prg_flip = (state->mmc3_latch & 0x40) ? 2 : 0; |
| 1238 | 1238 | |
| 1239 | 1239 | state->mmc3_prg_cb(machine, 0, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask)); |
| r8714 | r8715 | |
| 1244 | 1244 | |
| 1245 | 1245 | static void mmc3_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask ) |
| 1246 | 1246 | { |
| 1247 | nes_state *state = | |
| 1247 | nes_state *state = | |
| 1248 | 1248 | UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5; |
| 1249 | 1249 | |
| 1250 | 1250 | state->mmc3_chr_cb(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr); |
| r8714 | r8715 | |
| 1260 | 1260 | /* Here, IRQ counter decrements every scanline. */ |
| 1261 | 1261 | static void mmc3_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 1262 | 1262 | { |
| 1263 | nes_state *state = | |
| 1263 | nes_state *state = | |
| 1264 | 1264 | |
| 1265 | 1265 | if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE) |
| 1266 | 1266 | { |
| r8714 | r8715 | |
| 1282 | 1282 | |
| 1283 | 1283 | static WRITE8_HANDLER( txrom_w ) |
| 1284 | 1284 | { |
| 1285 | nes_state *state = | |
| 1285 | nes_state *state = | |
| 1286 | 1286 | UINT8 mmc_helper, cmd; |
| 1287 | 1287 | |
| 1288 | 1288 | LOG_MMC(("txrom_w, offset: %04x, data: %02x\n", offset, data)); |
| r8714 | r8715 | |
| 1360 | 1360 | |
| 1361 | 1361 | static WRITE8_HANDLER( hkrom_m_w ) |
| 1362 | 1362 | { |
| 1363 | nes_state *state = | |
| 1363 | nes_state *state = | |
| 1364 | 1364 | UINT8 write_hi, write_lo; |
| 1365 | 1365 | LOG_MMC(("hkrom_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 1366 | 1366 | |
| r8714 | r8715 | |
| 1380 | 1380 | |
| 1381 | 1381 | static READ8_HANDLER( hkrom_m_r ) |
| 1382 | 1382 | { |
| 1383 | nes_state *state = | |
| 1383 | nes_state *state = | |
| 1384 | 1384 | LOG_MMC(("hkrom_m_r, offset: %04x\n", offset)); |
| 1385 | 1385 | |
| 1386 | 1386 | if (offset < 0x1000) |
| r8714 | r8715 | |
| 1401 | 1401 | |
| 1402 | 1402 | static WRITE8_HANDLER( hkrom_w ) |
| 1403 | 1403 | { |
| 1404 | nes_state *state = | |
| 1404 | nes_state *state = | |
| 1405 | 1405 | UINT8 mmc6_helper; |
| 1406 | 1406 | LOG_MMC(("hkrom_w, offset: %04x, data: %02x\n", offset, data)); |
| 1407 | 1407 | |
| r8714 | r8715 | |
| 1454 | 1454 | |
| 1455 | 1455 | static void txsrom_set_mirror( running_machine *machine ) |
| 1456 | 1456 | { |
| 1457 | nes_state *state = | |
| 1457 | nes_state *state = | |
| 1458 | 1458 | if (state->mmc3_latch & 0x80) |
| 1459 | 1459 | { |
| 1460 | 1460 | set_nt_page(machine, 0, CIRAM, (state->mmc_vrom_bank[2] & 0x80) >> 7, 1); |
| r8714 | r8715 | |
| 1506 | 1506 | |
| 1507 | 1507 | static void tqrom_set_chr( running_machine *machine ) |
| 1508 | 1508 | { |
| 1509 | nes_state *state = | |
| 1509 | nes_state *state = | |
| 1510 | 1510 | UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5; |
| 1511 | 1511 | UINT8 chr_src[6], chr_mask[6]; |
| 1512 | 1512 | int i; |
| r8714 | r8715 | |
| 1529 | 1529 | |
| 1530 | 1530 | static WRITE8_HANDLER( tqrom_w ) |
| 1531 | 1531 | { |
| 1532 | nes_state *state = | |
| 1532 | nes_state *state = | |
| 1533 | 1533 | UINT8 mmc_helper, cmd; |
| 1534 | 1534 | LOG_MMC(("tqrom_w, offset: %04x, data: %02x\n", offset, data)); |
| 1535 | 1535 | |
| r8714 | r8715 | |
| 1581 | 1581 | |
| 1582 | 1582 | static WRITE8_HANDLER( zz_m_w ) |
| 1583 | 1583 | { |
| 1584 | nes_state *state = | |
| 1584 | nes_state *state = | |
| 1585 | 1585 | UINT8 mmc_helper = data & 0x07; |
| 1586 | 1586 | LOG_MMC(("zz_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 1587 | 1587 | |
| r8714 | r8715 | |
| 1604 | 1604 | |
| 1605 | 1605 | static WRITE8_HANDLER( qj_m_w ) |
| 1606 | 1606 | { |
| 1607 | nes_state *state = | |
| 1607 | nes_state *state = | |
| 1608 | 1608 | LOG_MMC(("qj_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 1609 | 1609 | |
| 1610 | 1610 | state->mmc_prg_base = BIT(data, 0) << 4; |
| r8714 | r8715 | |
| 1630 | 1630 | #if 0 |
| 1631 | 1631 | static void mmc5_update_chr_a( running_machine *machine ) |
| 1632 | 1632 | { |
| 1633 | nes_state *state = | |
| 1633 | nes_state *state = | |
| 1634 | 1634 | switch (state->mmc5_chr_mode) |
| 1635 | 1635 | { |
| 1636 | 1636 | case 0: // 8k banks |
| r8714 | r8715 | |
| 1664 | 1664 | |
| 1665 | 1665 | static void mmc5_update_chr_b( running_machine *machine ) |
| 1666 | 1666 | { |
| 1667 | nes_state *state = | |
| 1667 | nes_state *state = | |
| 1668 | 1668 | switch (state->mmc5_chr_mode) |
| 1669 | 1669 | { |
| 1670 | 1670 | case 0: // 8k banks |
| r8714 | r8715 | |
| 1699 | 1699 | |
| 1700 | 1700 | static void mmc5_update_prg( running_machine *machine ) |
| 1701 | 1701 | { |
| 1702 | nes_state *state = | |
| 1702 | nes_state *state = | |
| 1703 | 1703 | int bank1, bank2, bank3; |
| 1704 | 1704 | |
| 1705 | 1705 | switch (state->mmc5_prg_mode) |
| r8714 | r8715 | |
| 1792 | 1792 | |
| 1793 | 1793 | static void mmc5_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 1794 | 1794 | { |
| 1795 | nes_state *state = | |
| 1795 | nes_state *state = | |
| 1796 | 1796 | |
| 1797 | 1797 | #if 1 |
| 1798 | 1798 | if (scanline == 0) |
| r8714 | r8715 | |
| 1841 | 1841 | |
| 1842 | 1842 | static READ8_HANDLER( exrom_l_r ) |
| 1843 | 1843 | { |
| 1844 | nes_state *state = | |
| 1844 | nes_state *state = | |
| 1845 | 1845 | int retVal; |
| 1846 | 1846 | |
| 1847 | 1847 | /* $5c00 - $5fff: extended videoram attributes */ |
| r8714 | r8715 | |
| 1878 | 1878 | |
| 1879 | 1879 | static WRITE8_HANDLER( exrom_l_w ) |
| 1880 | 1880 | { |
| 1881 | nes_state *state = | |
| 1881 | nes_state *state = | |
| 1882 | 1882 | |
| 1883 | 1883 | // LOG_MMC(("Mapper 5 write, offset: %04x, data: %02x\n", offset + 0x4100, data)); |
| 1884 | 1884 | /* Send $5000-$5015 to the sound chip */ |
| r8714 | r8715 | |
| 2380 | 2380 | |
| 2381 | 2381 | static WRITE8_HANDLER( ntbrom_w ) |
| 2382 | 2382 | { |
| 2383 | nes_state *state = | |
| 2383 | nes_state *state = | |
| 2384 | 2384 | |
| 2385 | 2385 | LOG_MMC(("ntbrom_w, offset %04x, data: %02x\n", offset, data)); |
| 2386 | 2386 | |
| r8714 | r8715 | |
| 2435 | 2435 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 2436 | 2436 | static void jxrom_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 2437 | 2437 | { |
| 2438 | nes_state *state = | |
| 2438 | nes_state *state = | |
| 2439 | 2439 | |
| 2440 | 2440 | /* TODO: change to reflect the actual number of cycles spent */ |
| 2441 | 2441 | if ((state->IRQ_enable & 0x80) && (state->IRQ_enable & 0x01)) |
| r8714 | r8715 | |
| 2459 | 2459 | |
| 2460 | 2460 | static WRITE8_HANDLER( jxrom_w ) |
| 2461 | 2461 | { |
| 2462 | nes_state *state = | |
| 2462 | nes_state *state = | |
| 2463 | 2463 | LOG_MMC(("jxrom_w, offset %04x, data: %02x\n", offset, data)); |
| 2464 | 2464 | |
| 2465 | 2465 | switch (offset & 0x6000) |
| r8714 | r8715 | |
| 2552 | 2552 | |
| 2553 | 2553 | static WRITE8_HANDLER( dxrom_w ) |
| 2554 | 2554 | { |
| 2555 | nes_state *state = | |
| 2555 | nes_state *state = | |
| 2556 | 2556 | LOG_MMC(("dxrom_w, offset: %04x, data: %02x\n", offset, data)); |
| 2557 | 2557 | |
| 2558 | 2558 | if (offset >= 0x2000) |
| r8714 | r8715 | |
| 2618 | 2618 | |
| 2619 | 2619 | static WRITE8_HANDLER( namcot3446_w ) |
| 2620 | 2620 | { |
| 2621 | nes_state *state = | |
| 2621 | nes_state *state = | |
| 2622 | 2622 | LOG_MMC(("namcot3446_w, offset: %04x, data: %02x\n", offset, data)); |
| 2623 | 2623 | |
| 2624 | 2624 | // NEStopia does not have this! |
| r8714 | r8715 | |
| 2663 | 2663 | |
| 2664 | 2664 | static WRITE8_HANDLER( namcot3425_w ) |
| 2665 | 2665 | { |
| 2666 | nes_state *state = | |
| 2666 | nes_state *state = | |
| 2667 | 2667 | UINT8 mode; |
| 2668 | 2668 | LOG_MMC(("namcot3425_w, offset: %04x, data: %02x\n", offset, data)); |
| 2669 | 2669 | if (offset >= 0x2000) |
| r8714 | r8715 | |
| 2717 | 2717 | |
| 2718 | 2718 | static WRITE8_HANDLER( dis_74x377_w ) |
| 2719 | 2719 | { |
| 2720 | nes_state *state = | |
| 2720 | nes_state *state = | |
| 2721 | 2721 | LOG_MMC(("dis_74x377_w, offset: %04x, data: %02x\n", offset, data)); |
| 2722 | 2722 | |
| 2723 | 2723 | chr8(space->machine, data >> 4, state->mmc_chr_source); |
| r8714 | r8715 | |
| 2771 | 2771 | |
| 2772 | 2772 | static WRITE8_HANDLER( dis_74x161x161x32_w ) |
| 2773 | 2773 | { |
| 2774 | nes_state *state = | |
| 2774 | nes_state *state = | |
| 2775 | 2775 | LOG_MMC(("dis_74x161x161x32_w, offset: %04x, data: %02x\n", offset, data)); |
| 2776 | 2776 | |
| 2777 | 2777 | if (!state->hard_mirroring) // there are two 'variants' depending on hardwired or mapper ctrl mirroring |
| r8714 | r8715 | |
| 2808 | 2808 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 2809 | 2809 | static void bandai_lz_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 2810 | 2810 | { |
| 2811 | nes_state *state = | |
| 2811 | nes_state *state = | |
| 2812 | 2812 | |
| 2813 | 2813 | /* 114 is the number of cycles per scanline */ |
| 2814 | 2814 | /* TODO: change to reflect the actual number of cycles spent */ |
| r8714 | r8715 | |
| 2825 | 2825 | |
| 2826 | 2826 | static WRITE8_HANDLER( lz93d50_w ) |
| 2827 | 2827 | { |
| 2828 | nes_state *state = | |
| 2828 | nes_state *state = | |
| 2829 | 2829 | LOG_MMC(("lz93d50_w, offset: %04x, data: %02x\n", offset, data)); |
| 2830 | 2830 | |
| 2831 | 2831 | switch (offset & 0x000f) |
| r8714 | r8715 | |
| 2863 | 2863 | |
| 2864 | 2864 | static WRITE8_HANDLER( lz93d50_m_w ) |
| 2865 | 2865 | { |
| 2866 | nes_state *state = | |
| 2866 | nes_state *state = | |
| 2867 | 2867 | LOG_MMC(("lz93d50_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 2868 | 2868 | |
| 2869 | 2869 | if (!state->battery && !state->wram) |
| r8714 | r8715 | |
| 2876 | 2876 | |
| 2877 | 2877 | static void fjump2_set_prg( running_machine *machine ) |
| 2878 | 2878 | { |
| 2879 | nes_state *state = | |
| 2879 | nes_state *state = | |
| 2880 | 2880 | UINT8 mmc_helper = 0; |
| 2881 | 2881 | int i; |
| 2882 | 2882 | |
| r8714 | r8715 | |
| 2889 | 2889 | |
| 2890 | 2890 | static WRITE8_HANDLER( fjump2_w ) |
| 2891 | 2891 | { |
| 2892 | nes_state *state = | |
| 2892 | nes_state *state = | |
| 2893 | 2893 | LOG_MMC(("fjump2_w, offset: %04x, data: %02x\n", offset, data)); |
| 2894 | 2894 | |
| 2895 | 2895 | switch (offset & 0x000f) |
| r8714 | r8715 | |
| 2943 | 2943 | |
| 2944 | 2944 | static WRITE8_HANDLER( bandai_ok_w ) |
| 2945 | 2945 | { |
| 2946 | nes_state *state = | |
| 2946 | nes_state *state = | |
| 2947 | 2947 | UINT8 mmc_helper; |
| 2948 | 2948 | LOG_MMC(("mapper96_w, offset: %04x, data: %02x\n", offset, data)); |
| 2949 | 2949 | |
| r8714 | r8715 | |
| 3025 | 3025 | |
| 3026 | 3026 | static WRITE8_HANDLER( g101_w ) |
| 3027 | 3027 | { |
| 3028 | nes_state *state = | |
| 3028 | nes_state *state = | |
| 3029 | 3029 | LOG_MMC(("g101_w, offset: %04x, data: %02x\n", offset, data)); |
| 3030 | 3030 | |
| 3031 | 3031 | switch (offset & 0x7000) |
| r8714 | r8715 | |
| 3066 | 3066 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 3067 | 3067 | static void h3001_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 3068 | 3068 | { |
| 3069 | nes_state *state = | |
| 3069 | nes_state *state = | |
| 3070 | 3070 | if (state->IRQ_enable) |
| 3071 | 3071 | { |
| 3072 | 3072 | state->IRQ_count -= 114; |
| r8714 | r8715 | |
| 3081 | 3081 | |
| 3082 | 3082 | static WRITE8_HANDLER( h3001_w ) |
| 3083 | 3083 | { |
| 3084 | nes_state *state = | |
| 3084 | nes_state *state = | |
| 3085 | 3085 | LOG_MMC(("h3001_w, offset %04x, data: %02x\n", offset, data)); |
| 3086 | 3086 | |
| 3087 | 3087 | switch (offset & 0x7fff) |
| r8714 | r8715 | |
| 3147 | 3147 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 3148 | 3148 | static void ss88006_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 3149 | 3149 | { |
| 3150 | nes_state *state = | |
| 3150 | nes_state *state = | |
| 3151 | 3151 | |
| 3152 | 3152 | /* Increment & check the IRQ scanline counter */ |
| 3153 | 3153 | if (state->IRQ_enable) |
| r8714 | r8715 | |
| 3194 | 3194 | |
| 3195 | 3195 | static WRITE8_HANDLER( ss88006_w ) |
| 3196 | 3196 | { |
| 3197 | nes_state *state = | |
| 3197 | nes_state *state = | |
| 3198 | 3198 | UINT8 bank; |
| 3199 | 3199 | LOG_MMC(("mapper18_w, offset: %04x, data: %02x\n", offset, data)); |
| 3200 | 3200 | |
| r8714 | r8715 | |
| 3416 | 3416 | |
| 3417 | 3417 | static WRITE8_HANDLER( konami_vrc1_w ) |
| 3418 | 3418 | { |
| 3419 | nes_state *state = | |
| 3419 | nes_state *state = | |
| 3420 | 3420 | LOG_MMC(("konami_vrc1_w, offset: %04x, data: %02x\n", offset, data)); |
| 3421 | 3421 | |
| 3422 | 3422 | switch (offset & 0x7000) |
| r8714 | r8715 | |
| 3458 | 3458 | |
| 3459 | 3459 | static WRITE8_HANDLER( konami_vrc2_w ) |
| 3460 | 3460 | { |
| 3461 | nes_state *state = | |
| 3461 | nes_state *state = | |
| 3462 | 3462 | UINT8 bank, shift, mask; |
| 3463 | 3463 | UINT32 shifted_offs = (offset & 0x7000) |
| 3464 | 3464 | | ((offset << (9 - state->vrc_ls_prg_a)) & 0x200) |
| r8714 | r8715 | |
| 3507 | 3507 | static WRITE8_HANDLER( konami_vrc3_w ) |
| 3508 | 3508 | { |
| 3509 | 3509 | LOG_MMC(("konami_vrc3_w, offset: %04x, data: %02x\n", offset, data)); |
| 3510 | nes_state *state = | |
| 3510 | nes_state *state = | |
| 3511 | 3511 | |
| 3512 | 3512 | switch (offset & 0x7000) |
| 3513 | 3513 | { |
| r8714 | r8715 | |
| 3547 | 3547 | |
| 3548 | 3548 | static void vrc4_set_prg( running_machine *machine ) |
| 3549 | 3549 | { |
| 3550 | nes_state *state = | |
| 3550 | nes_state *state = | |
| 3551 | 3551 | if (state->mmc_latch1 & 0x02) |
| 3552 | 3552 | { |
| 3553 | 3553 | prg8_89(machine, 0xfe); |
| r8714 | r8715 | |
| 3562 | 3562 | |
| 3563 | 3563 | static void konami_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 3564 | 3564 | { |
| 3565 | nes_state *state = | |
| 3565 | nes_state *state = | |
| 3566 | 3566 | /* Increment & check the IRQ scanline counter */ |
| 3567 | 3567 | if (state->IRQ_enable && (++state->IRQ_count == 0x100)) |
| 3568 | 3568 | { |
| r8714 | r8715 | |
| 3574 | 3574 | |
| 3575 | 3575 | static WRITE8_HANDLER( konami_vrc4_w ) |
| 3576 | 3576 | { |
| 3577 | nes_state *state = | |
| 3577 | nes_state *state = | |
| 3578 | 3578 | UINT8 bank, shift, mask; |
| 3579 | 3579 | UINT32 shifted_offs = (offset & 0x7000) |
| 3580 | 3580 | | ((offset << (9 - state->vrc_ls_prg_a)) & 0x200) |
| r8714 | r8715 | |
| 3663 | 3663 | |
| 3664 | 3664 | static WRITE8_HANDLER( konami_vrc6_w ) |
| 3665 | 3665 | { |
| 3666 | nes_state *state = | |
| 3666 | nes_state *state = | |
| 3667 | 3667 | UINT8 bank; |
| 3668 | 3668 | UINT32 shifted_offs = (offset & 0x7000) |
| 3669 | 3669 | | ((offset << (9 - state->vrc_ls_prg_a)) & 0x200) |
| r8714 | r8715 | |
| 3743 | 3743 | |
| 3744 | 3744 | static WRITE8_HANDLER( konami_vrc7_w ) |
| 3745 | 3745 | { |
| 3746 | nes_state *state = | |
| 3746 | nes_state *state = | |
| 3747 | 3747 | UINT8 bank; |
| 3748 | 3748 | LOG_MMC(("konami_vrc7_w, offset: %04x, data: %02x\n", offset, data)); |
| 3749 | 3749 | |
| r8714 | r8715 | |
| 3831 | 3831 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 3832 | 3832 | static void namcot_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 3833 | 3833 | { |
| 3834 | nes_state *state = | |
| 3834 | nes_state *state = | |
| 3835 | 3835 | |
| 3836 | 3836 | if (state->IRQ_enable) |
| 3837 | 3837 | { |
| r8714 | r8715 | |
| 3847 | 3847 | |
| 3848 | 3848 | static WRITE8_HANDLER( namcot163_l_w ) |
| 3849 | 3849 | { |
| 3850 | nes_state *state = | |
| 3850 | nes_state *state = | |
| 3851 | 3851 | LOG_MMC(("namcot163_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 3852 | 3852 | offset += 0x100; |
| 3853 | 3853 | |
| r8714 | r8715 | |
| 3868 | 3868 | |
| 3869 | 3869 | static READ8_HANDLER( namcot163_l_r ) |
| 3870 | 3870 | { |
| 3871 | nes_state *state = | |
| 3871 | nes_state *state = | |
| 3872 | 3872 | LOG_MMC(("namcot163_l_r, offset: %04x\n", offset)); |
| 3873 | 3873 | offset += 0x100; |
| 3874 | 3874 | |
| r8714 | r8715 | |
| 3895 | 3895 | |
| 3896 | 3896 | static WRITE8_HANDLER( namcot163_w ) |
| 3897 | 3897 | { |
| 3898 | nes_state *state = | |
| 3898 | nes_state *state = | |
| 3899 | 3899 | LOG_MMC(("namcot163_w, offset: %04x, data: %02x\n", offset, data)); |
| 3900 | 3900 | switch (offset & 0x7800) |
| 3901 | 3901 | { |
| r8714 | r8715 | |
| 3947 | 3947 | |
| 3948 | 3948 | static WRITE8_HANDLER( sunsoft1_m_w ) |
| 3949 | 3949 | { |
| 3950 | nes_state *state = | |
| 3950 | nes_state *state = | |
| 3951 | 3951 | LOG_MMC(("sunsoft1_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 3952 | 3952 | |
| 3953 | 3953 | if (state->chr_chunks) |
| r8714 | r8715 | |
| 3972 | 3972 | |
| 3973 | 3973 | static WRITE8_HANDLER( sunsoft2_w ) |
| 3974 | 3974 | { |
| 3975 | nes_state *state = | |
| 3975 | nes_state *state = | |
| 3976 | 3976 | UINT8 sunsoft_helper = (data & 0x07) | ((data & 0x80) ? 0x08 : 0x00); |
| 3977 | 3977 | LOG_MMC(("sunsoft2_w, offset: %04x, data: %02x\n", offset, data)); |
| 3978 | 3978 | |
| r8714 | r8715 | |
| 4000 | 4000 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 4001 | 4001 | static void sunsoft3_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 4002 | 4002 | { |
| 4003 | nes_state *state = | |
| 4003 | nes_state *state = | |
| 4004 | 4004 | |
| 4005 | 4005 | /* TODO: change to reflect the actual number of cycles spent: both using 114 or cycling 114,114,113 |
| 4006 | 4006 | produces a 1-line glitch in Fantasy Zone 2: it really requires the counter to be updated each CPU cycle! */ |
| r8714 | r8715 | |
| 4019 | 4019 | |
| 4020 | 4020 | static WRITE8_HANDLER( sunsoft3_w ) |
| 4021 | 4021 | { |
| 4022 | nes_state *state = | |
| 4022 | nes_state *state = | |
| 4023 | 4023 | LOG_MMC(("sunsoft3_w, offset %04x, data: %02x\n", offset, data)); |
| 4024 | 4024 | |
| 4025 | 4025 | switch (offset & 0x7800) |
| r8714 | r8715 | |
| 4135 | 4135 | |
| 4136 | 4136 | static WRITE8_HANDLER( tc0190fmc_p16_w ) |
| 4137 | 4137 | { |
| 4138 | nes_state *state = | |
| 4138 | nes_state *state = | |
| 4139 | 4139 | LOG_MMC(("tc0190fmc_p16_w, offset: %04x, data: %02x\n", offset, data)); |
| 4140 | 4140 | |
| 4141 | 4141 | switch (offset & 0x7003) |
| r8714 | r8715 | |
| 4186 | 4186 | |
| 4187 | 4187 | static WRITE8_HANDLER( x1005_m_w ) |
| 4188 | 4188 | { |
| 4189 | nes_state *state = | |
| 4189 | nes_state *state = | |
| 4190 | 4190 | LOG_MMC(("x1005_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 4191 | 4191 | |
| 4192 | 4192 | switch (offset) |
| r8714 | r8715 | |
| 4242 | 4242 | |
| 4243 | 4243 | static READ8_HANDLER( x1005_m_r ) |
| 4244 | 4244 | { |
| 4245 | nes_state *state = | |
| 4245 | nes_state *state = | |
| 4246 | 4246 | LOG_MMC(("x1005a_m_r, offset: %04x\n", offset)); |
| 4247 | 4247 | |
| 4248 | 4248 | if (offset >= 0x1f00 && state->mapper_ram != NULL && state->mmc_latch1 == 0xa3) |
| r8714 | r8715 | |
| 4294 | 4294 | |
| 4295 | 4295 | static void x1017_set_chr( running_machine *machine ) |
| 4296 | 4296 | { |
| 4297 | nes_state *state = | |
| 4297 | nes_state *state = | |
| 4298 | 4298 | if (state->mmc_latch1) |
| 4299 | 4299 | { |
| 4300 | 4300 | chr2_4(machine, state->mmc_vrom_bank[0] >> 1, CHRROM); |
| r8714 | r8715 | |
| 4313 | 4313 | |
| 4314 | 4314 | static WRITE8_HANDLER( x1017_m_w ) |
| 4315 | 4315 | { |
| 4316 | nes_state *state = | |
| 4316 | nes_state *state = | |
| 4317 | 4317 | UINT8 reg = offset & 0x07; |
| 4318 | 4318 | LOG_MMC(("x1017_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 4319 | 4319 | |
| r8714 | r8715 | |
| 4364 | 4364 | |
| 4365 | 4365 | static READ8_HANDLER( x1017_m_r ) |
| 4366 | 4366 | { |
| 4367 | nes_state *state = | |
| 4367 | nes_state *state = | |
| 4368 | 4368 | LOG_MMC(("x1017_m_r, offset: %04x\n", offset)); |
| 4369 | 4369 | |
| 4370 | 4370 | // 2+2+1 KB of Internal RAM can be independently enabled/disabled! |
| r8714 | r8715 | |
| 4539 | 4539 | |
| 4540 | 4540 | static WRITE8_HANDLER( cne_fsb_m_w ) |
| 4541 | 4541 | { |
| 4542 | nes_state *state = | |
| 4542 | nes_state *state = | |
| 4543 | 4543 | LOG_MMC(("cne_fsb_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 4544 | 4544 | |
| 4545 | 4545 | if (offset < 0x0800) |
| r8714 | r8715 | |
| 4615 | 4615 | |
| 4616 | 4616 | static WRITE8_HANDLER( caltron6in1_m_w ) |
| 4617 | 4617 | { |
| 4618 | nes_state *state = | |
| 4618 | nes_state *state = | |
| 4619 | 4619 | LOG_MMC(("caltron6in1_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 4620 | 4620 | |
| 4621 | 4621 | state->mmc_latch1 = offset & 0xff; |
| r8714 | r8715 | |
| 4625 | 4625 | |
| 4626 | 4626 | static WRITE8_HANDLER( caltron6in1_w ) |
| 4627 | 4627 | { |
| 4628 | nes_state *state = | |
| 4628 | nes_state *state = | |
| 4629 | 4629 | LOG_MMC(("caltron6in1_w, offset: %04x, data: %02x\n", offset, data)); |
| 4630 | 4630 | |
| 4631 | 4631 | if (state->mmc_latch1 & 0x04) |
| r8714 | r8715 | |
| 4651 | 4651 | |
| 4652 | 4652 | static WRITE8_HANDLER( bf9093_w ) |
| 4653 | 4653 | { |
| 4654 | nes_state *state = | |
| 4654 | nes_state *state = | |
| 4655 | 4655 | LOG_MMC(("bf9093_w, offset: %04x, data: %02x\n", offset, data)); |
| 4656 | 4656 | |
| 4657 | 4657 | switch (offset & 0x7000) |
| r8714 | r8715 | |
| 4690 | 4690 | |
| 4691 | 4691 | static void bf9096_set_prg( running_machine *machine ) |
| 4692 | 4692 | { |
| 4693 | nes_state *state = | |
| 4693 | nes_state *state = | |
| 4694 | 4694 | prg16_89ab(machine, (state->mmc_latch2 & 0x03) | ((state->mmc_latch1 & 0x18) >> 1)); |
| 4695 | 4695 | prg16_cdef(machine, 0x03 | ((state->mmc_latch1 & 0x18) >> 1)); |
| 4696 | 4696 | } |
| 4697 | 4697 | |
| 4698 | 4698 | static WRITE8_HANDLER( bf9096_w ) |
| 4699 | 4699 | { |
| 4700 | nes_state *state = | |
| 4700 | nes_state *state = | |
| 4701 | 4701 | LOG_MMC(("bf9096_w, offset: %04x, data: %02x\n", offset, data)); |
| 4702 | 4702 | |
| 4703 | 4703 | if (offset < 0x2000) |
| r8714 | r8715 | |
| 4722 | 4722 | |
| 4723 | 4723 | static WRITE8_HANDLER( golden5_w ) |
| 4724 | 4724 | { |
| 4725 | nes_state *state = | |
| 4725 | nes_state *state = | |
| 4726 | 4726 | LOG_MMC(("golden5_w, offset: %04x, data: %02x\n", offset, data)); |
| 4727 | 4727 | |
| 4728 | 4728 | if (offset < 0x4000) |
| r8714 | r8715 | |
| 4757 | 4757 | |
| 4758 | 4758 | static WRITE8_HANDLER( cony_l_w ) |
| 4759 | 4759 | { |
| 4760 | nes_state *state = | |
| 4760 | nes_state *state = | |
| 4761 | 4761 | LOG_MMC(("cony_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 4762 | 4762 | |
| 4763 | 4763 | if (offset >= 0x1000 && offset < 0x1103) // from 0x5100-0x51ff |
| r8714 | r8715 | |
| 4766 | 4766 | |
| 4767 | 4767 | static READ8_HANDLER( cony_l_r ) |
| 4768 | 4768 | { |
| 4769 | nes_state *state = | |
| 4769 | nes_state *state = | |
| 4770 | 4770 | LOG_MMC(("cony_l_r, offset: %04x\n", offset)); |
| 4771 | 4771 | |
| 4772 | 4772 | if (offset == 0x0f00) // 0x5000 |
| r8714 | r8715 | |
| 4781 | 4781 | |
| 4782 | 4782 | static void cony_set_prg( running_machine *machine ) |
| 4783 | 4783 | { |
| 4784 | nes_state *state = | |
| 4784 | nes_state *state = | |
| 4785 | 4785 | prg16_89ab(machine, state->mapper83_reg[8] & 0x3f); |
| 4786 | 4786 | prg16_cdef(machine, (state->mapper83_reg[8] & 0x30) | 0x0f); |
| 4787 | 4787 | } |
| 4788 | 4788 | |
| 4789 | 4789 | static void cony_set_chr( running_machine *machine ) |
| 4790 | 4790 | { |
| 4791 | nes_state *state = | |
| 4791 | nes_state *state = | |
| 4792 | 4792 | // FIXME: here we emulate at least 3 different boards!!! |
| 4793 | 4793 | // one board switches 1k VROM banks only |
| 4794 | 4794 | // one writes to 0x8000 and then switches 2k VROM banks only |
| r8714 | r8715 | |
| 4816 | 4816 | |
| 4817 | 4817 | static WRITE8_HANDLER( cony_w ) |
| 4818 | 4818 | { |
| 4819 | nes_state *state = | |
| 4819 | nes_state *state = | |
| 4820 | 4820 | LOG_MMC(("cony_w, offset: %04x, data: %02x\n", offset, data)); |
| 4821 | 4821 | |
| 4822 | 4822 | switch (offset) |
| r8714 | r8715 | |
| 4917 | 4917 | |
| 4918 | 4918 | static WRITE8_HANDLER( fukutake_l_w ) |
| 4919 | 4919 | { |
| 4920 | nes_state *state = | |
| 4920 | nes_state *state = | |
| 4921 | 4921 | LOG_MMC(("fukutake_l_w offset: %04x, data: %02x\n", offset, data)); |
| 4922 | 4922 | offset += 0x100; |
| 4923 | 4923 | |
| r8714 | r8715 | |
| 4934 | 4934 | |
| 4935 | 4935 | static READ8_HANDLER( fukutake_l_r ) |
| 4936 | 4936 | { |
| 4937 | nes_state *state = | |
| 4937 | nes_state *state = | |
| 4938 | 4938 | LOG_MMC(("fukutake_l_r offset: %04x\n", offset)); |
| 4939 | 4939 | offset += 0x100; |
| 4940 | 4940 | |
| r8714 | r8715 | |
| 4967 | 4967 | |
| 4968 | 4968 | static void futuremedia_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 4969 | 4969 | { |
| 4970 | nes_state *state = | |
| 4970 | nes_state *state = | |
| 4971 | 4971 | // if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE) |
| 4972 | 4972 | { |
| 4973 | 4973 | if (state->IRQ_enable && state->IRQ_count) |
| r8714 | r8715 | |
| 4981 | 4981 | |
| 4982 | 4982 | static WRITE8_HANDLER( futuremedia_w ) |
| 4983 | 4983 | { |
| 4984 | nes_state *state = | |
| 4984 | nes_state *state = | |
| 4985 | 4985 | LOG_MMC(("futuremedia_w, offset: %04x, data: %02x\n", offset, data)); |
| 4986 | 4986 | |
| 4987 | 4987 | switch (offset) |
| r8714 | r8715 | |
| 5044 | 5044 | |
| 5045 | 5045 | static WRITE8_HANDLER( gouder_sf4_l_w ) |
| 5046 | 5046 | { |
| 5047 | nes_state *state = | |
| 5047 | nes_state *state = | |
| 5048 | 5048 | static const UINT8 conv_table[256] = |
| 5049 | 5049 | { |
| 5050 | 5050 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x49,0x19,0x09,0x59,0x49,0x19,0x09, |
| r8714 | r8715 | |
| 5077 | 5077 | |
| 5078 | 5078 | static READ8_HANDLER( gouder_sf4_l_r ) |
| 5079 | 5079 | { |
| 5080 | nes_state *state = | |
| 5080 | nes_state *state = | |
| 5081 | 5081 | LOG_MMC(("gouder_sf4_l_r, offset: %04x\n", offset)); |
| 5082 | 5082 | |
| 5083 | 5083 | if (!(offset < 0x1700)) |
| r8714 | r8715 | |
| 5201 | 5201 | |
| 5202 | 5202 | static WRITE8_HANDLER( hosenkan_w ) |
| 5203 | 5203 | { |
| 5204 | nes_state *state = | |
| 5204 | nes_state *state = | |
| 5205 | 5205 | LOG_MMC(("hosenkan_w, offset: %04x, data: %02x\n", offset, data)); |
| 5206 | 5206 | |
| 5207 | 5207 | switch (offset & 0x7003) |
| r8714 | r8715 | |
| 5298 | 5298 | |
| 5299 | 5299 | static WRITE8_HANDLER( ks7022_w ) |
| 5300 | 5300 | { |
| 5301 | nes_state *state = | |
| 5301 | nes_state *state = | |
| 5302 | 5302 | LOG_MMC(("ks7022_w, offset: %04x, data: %02x\n", offset, data)); |
| 5303 | 5303 | |
| 5304 | 5304 | if (offset == 0) |
| r8714 | r8715 | |
| 5310 | 5310 | |
| 5311 | 5311 | static READ8_HANDLER( ks7022_r ) |
| 5312 | 5312 | { |
| 5313 | nes_state *state = | |
| 5313 | nes_state *state = | |
| 5314 | 5314 | LOG_MMC(("ks7022_r, offset: %04x\n", offset)); |
| 5315 | 5315 | |
| 5316 | 5316 | if (offset == 0x7ffc) |
| r8714 | r8715 | |
| 5337 | 5337 | |
| 5338 | 5338 | static void ks7032_prg_update( running_machine *machine ) |
| 5339 | 5339 | { |
| 5340 | nes_state *state = | |
| 5340 | nes_state *state = | |
| 5341 | 5341 | |
| 5342 | 5342 | prg8_67(machine, state->mmc_reg[4]); |
| 5343 | 5343 | prg8_89(machine, state->mmc_reg[1]); |
| r8714 | r8715 | |
| 5347 | 5347 | |
| 5348 | 5348 | static void ks7032_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 5349 | 5349 | { |
| 5350 | nes_state *state = | |
| 5350 | nes_state *state = | |
| 5351 | 5351 | |
| 5352 | 5352 | if (state->IRQ_enable) |
| 5353 | 5353 | { |
| r8714 | r8715 | |
| 5364 | 5364 | |
| 5365 | 5365 | static WRITE8_HANDLER( ks7032_w ) |
| 5366 | 5366 | { |
| 5367 | nes_state *state = | |
| 5367 | nes_state *state = | |
| 5368 | 5368 | LOG_MMC(("ks7032_w, offset: %04x, data: %02x\n", offset, data)); |
| 5369 | 5369 | |
| 5370 | 5370 | switch (offset & 0x7000) |
| r8714 | r8715 | |
| 5409 | 5409 | |
| 5410 | 5410 | static WRITE8_HANDLER( ks202_w ) |
| 5411 | 5411 | { |
| 5412 | nes_state *state = | |
| 5412 | nes_state *state = | |
| 5413 | 5413 | LOG_MMC(("ks202_w, offset: %04x, data: %02x\n", offset, data)); |
| 5414 | 5414 | |
| 5415 | 5415 | switch (offset & 0x7000) |
| r8714 | r8715 | |
| 5462 | 5462 | |
| 5463 | 5463 | static void mmc_fds_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 5464 | 5464 | { |
| 5465 | nes_state *state = | |
| 5465 | nes_state *state = | |
| 5466 | 5466 | |
| 5467 | 5467 | if (state->IRQ_enable) |
| 5468 | 5468 | { |
| r8714 | r8715 | |
| 5479 | 5479 | |
| 5480 | 5480 | static WRITE8_HANDLER( ks7017_l_w ) |
| 5481 | 5481 | { |
| 5482 | nes_state *state = | |
| 5482 | nes_state *state = | |
| 5483 | 5483 | LOG_MMC(("ks7022_w, offset: %04x, data: %02x\n", offset, data)); |
| 5484 | 5484 | |
| 5485 | 5485 | offset += 0x100; |
| r8714 | r8715 | |
| 5493 | 5493 | |
| 5494 | 5494 | WRITE8_HANDLER( ks7017_extra_w ) |
| 5495 | 5495 | { |
| 5496 | nes_state *state = | |
| 5496 | nes_state *state = | |
| 5497 | 5497 | LOG_MMC(("ks7017_extra_w, offset: %04x, data: %02x\n", offset, data)); |
| 5498 | 5498 | |
| 5499 | 5499 | offset += 0x20; |
| r8714 | r8715 | |
| 5510 | 5510 | |
| 5511 | 5511 | READ8_HANDLER( ks7017_extra_r ) |
| 5512 | 5512 | { |
| 5513 | nes_state *state = | |
| 5513 | nes_state *state = | |
| 5514 | 5514 | LOG_MMC(("ks7017_extra_r, offset: %04x\n", offset)); |
| 5515 | 5515 | |
| 5516 | 5516 | state->IRQ_status &= ~0x01; |
| r8714 | r8715 | |
| 5534 | 5534 | |
| 5535 | 5535 | static WRITE8_HANDLER( kay_pp_l_w ) |
| 5536 | 5536 | { |
| 5537 | nes_state *state = | |
| 5537 | nes_state *state = | |
| 5538 | 5538 | LOG_MMC(("kay_pp_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 5539 | 5539 | offset += 0x100; |
| 5540 | 5540 | |
| r8714 | r8715 | |
| 5558 | 5558 | |
| 5559 | 5559 | static READ8_HANDLER( kay_pp_l_r ) |
| 5560 | 5560 | { |
| 5561 | nes_state *state = | |
| 5561 | nes_state *state = | |
| 5562 | 5562 | LOG_MMC(("kay_pp_l_r, offset: %04x\n", offset)); |
| 5563 | 5563 | offset += 0x100; |
| 5564 | 5564 | |
| r8714 | r8715 | |
| 5570 | 5570 | |
| 5571 | 5571 | static void kay_pp_update_regs( running_machine *machine ) |
| 5572 | 5572 | { |
| 5573 | nes_state *state = | |
| 5573 | nes_state *state = | |
| 5574 | 5574 | |
| 5575 | 5575 | switch (state->mmc_reg[5] & 0x3f) |
| 5576 | 5576 | { |
| r8714 | r8715 | |
| 5612 | 5612 | |
| 5613 | 5613 | static void kay_pp_prg_cb( running_machine *machine, int start, int bank ) |
| 5614 | 5614 | { |
| 5615 | nes_state *state = | |
| 5615 | nes_state *state = | |
| 5616 | 5616 | |
| 5617 | 5617 | if (state->mmc_reg[5] & 0x3f) |
| 5618 | 5618 | { |
| r8714 | r8715 | |
| 5627 | 5627 | |
| 5628 | 5628 | static void kay_pp_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 5629 | 5629 | { |
| 5630 | nes_state *state = | |
| 5630 | nes_state *state = | |
| 5631 | 5631 | UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5; |
| 5632 | 5632 | |
| 5633 | 5633 | if ((start & 0x04) == chr_page) |
| r8714 | r8715 | |
| 5638 | 5638 | |
| 5639 | 5639 | static WRITE8_HANDLER( kay_pp_w ) |
| 5640 | 5640 | { |
| 5641 | nes_state *state = | |
| 5641 | nes_state *state = | |
| 5642 | 5642 | LOG_MMC(("kay_pp_w, offset: %04x, data: %02x\n", offset, data)); |
| 5643 | 5643 | |
| 5644 | 5644 | switch (offset & 0x6003) |
| r8714 | r8715 | |
| 5687 | 5687 | |
| 5688 | 5688 | static void kasing_prg_cb( running_machine *machine, int start, int bank ) |
| 5689 | 5689 | { |
| 5690 | nes_state *state = | |
| 5690 | nes_state *state = | |
| 5691 | 5691 | if (BIT(state->mmc_reg[0], 7)) |
| 5692 | 5692 | prg32(machine, state->mmc_reg[0] >> 1); |
| 5693 | 5693 | else |
| r8714 | r8715 | |
| 5696 | 5696 | |
| 5697 | 5697 | static WRITE8_HANDLER( kasing_m_w ) |
| 5698 | 5698 | { |
| 5699 | nes_state *state = | |
| 5699 | nes_state *state = | |
| 5700 | 5700 | LOG_MMC(("kasing_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 5701 | 5701 | |
| 5702 | 5702 | switch (offset & 0x01) |
| r8714 | r8715 | |
| 5749 | 5749 | |
| 5750 | 5750 | static void nanjing_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 5751 | 5751 | { |
| 5752 | nes_state *state = | |
| 5752 | nes_state *state = | |
| 5753 | 5753 | |
| 5754 | 5754 | if (BIT(state->mmc_reg[0], 7)) |
| 5755 | 5755 | { |
| r8714 | r8715 | |
| 5770 | 5770 | |
| 5771 | 5771 | static WRITE8_HANDLER( nanjing_l_w ) |
| 5772 | 5772 | { |
| 5773 | nes_state *state = | |
| 5773 | nes_state *state = | |
| 5774 | 5774 | LOG_MMC(("nanjing_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 5775 | 5775 | |
| 5776 | 5776 | offset += 0x100; |
| r8714 | r8715 | |
| 5812 | 5812 | |
| 5813 | 5813 | static READ8_HANDLER( nanjing_l_r ) |
| 5814 | 5814 | { |
| 5815 | nes_state *state = | |
| 5815 | nes_state *state = | |
| 5816 | 5816 | UINT8 value = 0; |
| 5817 | 5817 | LOG_MMC(("nanjing_l_r, offset: %04x\n", offset)); |
| 5818 | 5818 | |
| r8714 | r8715 | |
| 5878 | 5878 | |
| 5879 | 5879 | static WRITE8_HANDLER( ntdec_asder_w ) |
| 5880 | 5880 | { |
| 5881 | nes_state *state = | |
| 5881 | nes_state *state = | |
| 5882 | 5882 | LOG_MMC(("ntdec_asder_w, offset: %04x, data: %02x\n", offset, data)); |
| 5883 | 5883 | |
| 5884 | 5884 | switch (offset) |
| r8714 | r8715 | |
| 6026 | 6026 | |
| 6027 | 6027 | static WRITE8_HANDLER( gs2015_w ) |
| 6028 | 6028 | { |
| 6029 | nes_state *state = | |
| 6029 | nes_state *state = | |
| 6030 | 6030 | LOG_MMC(("gs2015_w, offset: %04x, data: %02x\n", offset, data)); |
| 6031 | 6031 | |
| 6032 | 6032 | prg32(space->machine, offset); |
| r8714 | r8715 | |
| 6086 | 6086 | |
| 6087 | 6087 | static WRITE8_HANDLER( rex_dbz_l_w ) |
| 6088 | 6088 | { |
| 6089 | nes_state *state = | |
| 6089 | nes_state *state = | |
| 6090 | 6090 | LOG_MMC(("rex_dbz_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6091 | 6091 | |
| 6092 | 6092 | state->mmc_reg[0] = data; |
| r8714 | r8715 | |
| 6102 | 6102 | |
| 6103 | 6103 | static void rex_dbz_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 6104 | 6104 | { |
| 6105 | nes_state *state = | |
| 6105 | nes_state *state = | |
| 6106 | 6106 | int shift = (start < 4) ? 8 : 4; |
| 6107 | 6107 | |
| 6108 | 6108 | bank |= ((state->mmc_reg[0] << shift) & 0x100); |
| r8714 | r8715 | |
| 6125 | 6125 | |
| 6126 | 6126 | static void rex_sl1632_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 6127 | 6127 | { |
| 6128 | nes_state *state = | |
| 6128 | nes_state *state = | |
| 6129 | 6129 | |
| 6130 | 6130 | if (state->mmc_reg[0] & 0x02) |
| 6131 | 6131 | { |
| r8714 | r8715 | |
| 6142 | 6142 | |
| 6143 | 6143 | static void rex_sl1632_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask ) |
| 6144 | 6144 | { |
| 6145 | nes_state *state = | |
| 6145 | nes_state *state = | |
| 6146 | 6146 | static const UINT8 conv_table[8] = {5, 5, 5, 5, 3, 3, 1, 1}; |
| 6147 | 6147 | UINT8 chr_page = (state->mmc3_latch & 0x80) >> 5; |
| 6148 | 6148 | UINT8 bank[8]; |
| r8714 | r8715 | |
| 6178 | 6178 | |
| 6179 | 6179 | static WRITE8_HANDLER( rex_sl1632_w ) |
| 6180 | 6180 | { |
| 6181 | nes_state *state = | |
| 6181 | nes_state *state = | |
| 6182 | 6182 | UINT8 map14_helper1, map14_helper2, mmc_helper, cmd; |
| 6183 | 6183 | LOG_MMC(("rex_sl1632_w, offset: %04x, data: %02x\n", offset, data)); |
| 6184 | 6184 | |
| r8714 | r8715 | |
| 6279 | 6279 | |
| 6280 | 6280 | static WRITE8_HANDLER( rumblestation_m_w ) |
| 6281 | 6281 | { |
| 6282 | nes_state *state = | |
| 6282 | nes_state *state = | |
| 6283 | 6283 | LOG_MMC(("rumblestation_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6284 | 6284 | |
| 6285 | 6285 | state->mmc_prg_bank[0] = (state->mmc_prg_bank[0] & 0x01) | ((data & 0x0f) << 1); |
| r8714 | r8715 | |
| 6290 | 6290 | |
| 6291 | 6291 | static WRITE8_HANDLER( rumblestation_w ) |
| 6292 | 6292 | { |
| 6293 | nes_state *state = | |
| 6293 | nes_state *state = | |
| 6294 | 6294 | LOG_MMC(("rumblestation_w, offset: %04x, data: %02x\n", offset, data)); |
| 6295 | 6295 | |
| 6296 | 6296 | state->mmc_prg_bank[0] = (state->mmc_prg_bank[0] & ~0x01) | (data & 0x01); |
| r8714 | r8715 | |
| 6335 | 6335 | |
| 6336 | 6336 | static WRITE8_HANDLER( sachen_74x374_l_w ) |
| 6337 | 6337 | { |
| 6338 | nes_state *state = | |
| 6338 | nes_state *state = | |
| 6339 | 6339 | LOG_MMC(("sachen_74x374_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6340 | 6340 | |
| 6341 | 6341 | /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| r8714 | r8715 | |
| 6375 | 6375 | |
| 6376 | 6376 | static READ8_HANDLER( sachen_74x374_l_r ) |
| 6377 | 6377 | { |
| 6378 | nes_state *state = | |
| 6378 | nes_state *state = | |
| 6379 | 6379 | LOG_MMC(("sachen_74x374_l_r, offset: %04x", offset)); |
| 6380 | 6380 | |
| 6381 | 6381 | /* read happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| r8714 | r8715 | |
| 6387 | 6387 | |
| 6388 | 6388 | static WRITE8_HANDLER( sachen_74x374a_l_w ) |
| 6389 | 6389 | { |
| 6390 | nes_state *state = | |
| 6390 | nes_state *state = | |
| 6391 | 6391 | LOG_MMC(("sachen_74x374a_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6392 | 6392 | |
| 6393 | 6393 | /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| r8714 | r8715 | |
| 6438 | 6438 | |
| 6439 | 6439 | static void common_s8259_write_handler( const address_space *space, offs_t offset, UINT8 data, int board ) |
| 6440 | 6440 | { |
| 6441 | nes_state *state = | |
| 6441 | nes_state *state = | |
| 6442 | 6442 | UINT8 bank_helper1, bank_helper2, shift, add1, add2, add3; |
| 6443 | 6443 | |
| 6444 | 6444 | /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| r8714 | r8715 | |
| 6494 | 6494 | |
| 6495 | 6495 | static WRITE8_HANDLER( s8259_l_w ) |
| 6496 | 6496 | { |
| 6497 | nes_state *state = | |
| 6497 | nes_state *state = | |
| 6498 | 6498 | LOG_MMC(("s8259_w, type: %d, offset: %04x, data: %02x\n", state->pcb_id, offset, data)); |
| 6499 | 6499 | |
| 6500 | 6500 | common_s8259_write_handler(space, offset, data, state->pcb_id); |
| r8714 | r8715 | |
| 6502 | 6502 | |
| 6503 | 6503 | static WRITE8_HANDLER( s8259_m_w ) |
| 6504 | 6504 | { |
| 6505 | nes_state *state = | |
| 6505 | nes_state *state = | |
| 6506 | 6506 | LOG_MMC(("s8259_w, type: %d, offset: %04x, data: %02x\n", state->pcb_id, offset, data)); |
| 6507 | 6507 | |
| 6508 | 6508 | common_s8259_write_handler(space, (offset + 0x100) & 0xfff, data, state->pcb_id); |
| r8714 | r8715 | |
| 6523 | 6523 | |
| 6524 | 6524 | static WRITE8_HANDLER( sa009_l_w ) |
| 6525 | 6525 | { |
| 6526 | nes_state *state = | |
| 6526 | nes_state *state = | |
| 6527 | 6527 | LOG_MMC(("sa009_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6528 | 6528 | |
| 6529 | 6529 | chr8(space->machine, data, state->mmc_chr_source); |
| r8714 | r8715 | |
| 6683 | 6683 | |
| 6684 | 6684 | static WRITE8_HANDLER( tcu02_l_w ) |
| 6685 | 6685 | { |
| 6686 | nes_state *state = | |
| 6686 | nes_state *state = | |
| 6687 | 6687 | LOG_MMC(("tcu02_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6688 | 6688 | |
| 6689 | 6689 | if ((offset & 0x103) == 0x002) |
| r8714 | r8715 | |
| 6695 | 6695 | |
| 6696 | 6696 | static READ8_HANDLER( tcu02_l_r ) |
| 6697 | 6697 | { |
| 6698 | nes_state *state = | |
| 6698 | nes_state *state = | |
| 6699 | 6699 | LOG_MMC(("tcu02_l_r, offset: %04x\n", offset)); |
| 6700 | 6700 | |
| 6701 | 6701 | if ((offset & 0x103) == 0x000) |
| r8714 | r8715 | |
| 6715 | 6715 | |
| 6716 | 6716 | static WRITE8_HANDLER( subor0_w ) |
| 6717 | 6717 | { |
| 6718 | nes_state *state = | |
| 6718 | nes_state *state = | |
| 6719 | 6719 | UINT8 subor_helper1, subor_helper2; |
| 6720 | 6720 | LOG_MMC(("subor0_w, offset: %04x, data: %02x\n", offset, data)); |
| 6721 | 6721 | |
| r8714 | r8715 | |
| 6754 | 6754 | |
| 6755 | 6755 | static WRITE8_HANDLER( subor1_w ) |
| 6756 | 6756 | { |
| 6757 | nes_state *state = | |
| 6757 | nes_state *state = | |
| 6758 | 6758 | UINT8 subor_helper1, subor_helper2; |
| 6759 | 6759 | LOG_MMC(("subor1_w, offset: %04x, data: %02x\n", offset, data)); |
| 6760 | 6760 | |
| r8714 | r8715 | |
| 6800 | 6800 | |
| 6801 | 6801 | static void sgame_boog_prg_cb( running_machine *machine, int start, int bank ) |
| 6802 | 6802 | { |
| 6803 | nes_state *state = | |
| 6803 | nes_state *state = | |
| 6804 | 6804 | if (!(state->mmc_reg[0] & 0x80)) // if this is != 0 we should never even arrive here |
| 6805 | 6805 | { |
| 6806 | 6806 | if (state->mmc_reg[1] & 0x08) |
| r8714 | r8715 | |
| 6814 | 6814 | |
| 6815 | 6815 | static void sgame_boog_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 6816 | 6816 | { |
| 6817 | nes_state *state = | |
| 6817 | nes_state *state = | |
| 6818 | 6818 | |
| 6819 | 6819 | if ((state->mmc_reg[1] & 0x04)) |
| 6820 | 6820 | bank |= 0x100; |
| r8714 | r8715 | |
| 6826 | 6826 | |
| 6827 | 6827 | static void sgame_boog_set_prg( running_machine *machine ) |
| 6828 | 6828 | { |
| 6829 | nes_state *state = | |
| 6829 | nes_state *state = | |
| 6830 | 6830 | if (state->mmc_reg[0] & 0x80) |
| 6831 | 6831 | { |
| 6832 | 6832 | prg16_89ab(machine, (state->mmc_reg[0] & 0xf0) | (state->mmc_reg[1] & 0x10)); |
| r8714 | r8715 | |
| 6838 | 6838 | |
| 6839 | 6839 | static WRITE8_HANDLER( sgame_boog_l_w ) |
| 6840 | 6840 | { |
| 6841 | nes_state *state = | |
| 6841 | nes_state *state = | |
| 6842 | 6842 | LOG_MMC(("sgame_boog_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6843 | 6843 | offset += 0x100; |
| 6844 | 6844 | |
| r8714 | r8715 | |
| 6863 | 6863 | |
| 6864 | 6864 | static WRITE8_HANDLER( sgame_boog_m_w ) |
| 6865 | 6865 | { |
| 6866 | nes_state *state = | |
| 6866 | nes_state *state = | |
| 6867 | 6867 | LOG_MMC(("sgame_boog_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6868 | 6868 | |
| 6869 | 6869 | if (offset == 0x0000) |
| r8714 | r8715 | |
| 6887 | 6887 | |
| 6888 | 6888 | static WRITE8_HANDLER( sgame_boog_w ) |
| 6889 | 6889 | { |
| 6890 | nes_state *state = | |
| 6890 | nes_state *state = | |
| 6891 | 6891 | static const UINT8 conv_table[8] = {0,2,5,3,6,1,7,4}; |
| 6892 | 6892 | LOG_MMC(("sgame_boog_w, offset: %04x, data: %02x\n", offset, data)); |
| 6893 | 6893 | |
| r8714 | r8715 | |
| 6966 | 6966 | |
| 6967 | 6967 | static WRITE8_HANDLER( sgame_lion_m_w ) |
| 6968 | 6968 | { |
| 6969 | nes_state *state = | |
| 6969 | nes_state *state = | |
| 6970 | 6970 | LOG_MMC(("sgame_lion_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6971 | 6971 | |
| 6972 | 6972 | state->map114_reg = data; |
| r8714 | r8715 | |
| 6983 | 6983 | |
| 6984 | 6984 | static WRITE8_HANDLER( sgame_lion_w ) |
| 6985 | 6985 | { |
| 6986 | nes_state *state = | |
| 6986 | nes_state *state = | |
| 6987 | 6987 | static const UINT8 conv_table[8] = {0, 3, 1, 5, 6, 7, 2, 4}; |
| 6988 | 6988 | LOG_MMC(("sgame_lion_w, offset: %04x, data: %02x\n", offset, data)); |
| 6989 | 6989 | |
| r8714 | r8715 | |
| 7057 | 7057 | |
| 7058 | 7058 | static void tengen_800032_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 7059 | 7059 | { |
| 7060 | nes_state *state = | |
| 7060 | nes_state *state = | |
| 7061 | 7061 | if (!state->IRQ_mode) // we are in scanline mode! |
| 7062 | 7062 | { |
| 7063 | 7063 | if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE) |
| r8714 | r8715 | |
| 7114 | 7114 | |
| 7115 | 7115 | static void tengen_800032_set_prg( running_machine *machine ) |
| 7116 | 7116 | { |
| 7117 | nes_state *state = | |
| 7117 | nes_state *state = | |
| 7118 | 7118 | UINT8 prg_mode = state->mmc_latch1 & 0x40; |
| 7119 | 7119 | |
| 7120 | 7120 | prg8_89(machine, state->mmc_prg_bank[prg_mode ? 2: 0]); |
| r8714 | r8715 | |
| 7124 | 7124 | |
| 7125 | 7125 | static void tengen_800032_set_chr( running_machine *machine ) |
| 7126 | 7126 | { |
| 7127 | nes_state *state = | |
| 7127 | nes_state *state = | |
| 7128 | 7128 | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 7129 | 7129 | |
| 7130 | 7130 | if (state->mmc_latch1 & 0x20) |
| r8714 | r8715 | |
| 7150 | 7150 | |
| 7151 | 7151 | static WRITE8_HANDLER( tengen_800032_w ) |
| 7152 | 7152 | { |
| 7153 | nes_state *state = | |
| 7153 | nes_state *state = | |
| 7154 | 7154 | UINT8 map64_helper, cmd; |
| 7155 | 7155 | LOG_MMC(("tengen_800032_w, offset: %04x, data: %02x\n", offset, data)); |
| 7156 | 7156 | |
| r8714 | r8715 | |
| 7236 | 7236 | // probably wrong... |
| 7237 | 7237 | static void tengen_800037_set_mirror( running_machine *machine ) |
| 7238 | 7238 | { |
| 7239 | nes_state *state = | |
| 7239 | nes_state *state = | |
| 7240 | 7240 | UINT8 nt_mode = state->mmc_latch1 & 0x80; |
| 7241 | 7241 | |
| 7242 | 7242 | set_nt_page(machine, 0, ROM, state->mmc_vrom_bank[nt_mode ? 2 : 0], 0); |
| r8714 | r8715 | |
| 7247 | 7247 | |
| 7248 | 7248 | static WRITE8_HANDLER( tengen_800037_w ) |
| 7249 | 7249 | { |
| 7250 | nes_state *state = | |
| 7250 | nes_state *state = | |
| 7251 | 7251 | UINT8 map158_helper, cmd; |
| 7252 | 7252 | LOG_MMC(("tengen_800037_w, offset: %04x, data: %02x\n", offset, data)); |
| 7253 | 7253 | |
| r8714 | r8715 | |
| 7323 | 7323 | |
| 7324 | 7324 | static WRITE8_HANDLER( txc_22211_l_w ) |
| 7325 | 7325 | { |
| 7326 | nes_state *state = | |
| 7326 | nes_state *state = | |
| 7327 | 7327 | LOG_MMC(("txc_22211_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 7328 | 7328 | |
| 7329 | 7329 | if (offset < 4) |
| r8714 | r8715 | |
| 7332 | 7332 | |
| 7333 | 7333 | static READ8_HANDLER( txc_22211_l_r ) |
| 7334 | 7334 | { |
| 7335 | nes_state *state = | |
| 7335 | nes_state *state = | |
| 7336 | 7336 | LOG_MMC(("txc_22211_l_r, offset: %04x\n", offset)); |
| 7337 | 7337 | |
| 7338 | 7338 | if (offset == 0x0000) |
| r8714 | r8715 | |
| 7343 | 7343 | |
| 7344 | 7344 | static WRITE8_HANDLER( txc_22211_w ) |
| 7345 | 7345 | { |
| 7346 | nes_state *state = | |
| 7346 | nes_state *state = | |
| 7347 | 7347 | LOG_MMC(("txc_22211_w, offset: %04x, data: %02x\n", offset, data)); |
| 7348 | 7348 | |
| 7349 | 7349 | prg32(space->machine, state->txc_reg[2] >> 2); |
| r8714 | r8715 | |
| 7367 | 7367 | |
| 7368 | 7368 | static WRITE8_HANDLER( txc_22211b_w ) |
| 7369 | 7369 | { |
| 7370 | nes_state *state = | |
| 7370 | nes_state *state = | |
| 7371 | 7371 | LOG_MMC(("txc_22211b_w, offset: %04x, data: %02x\n", offset, data)); |
| 7372 | 7372 | |
| 7373 | 7373 | prg32(space->machine, state->txc_reg[2] >> 2); |
| r8714 | r8715 | |
| 7391 | 7391 | |
| 7392 | 7392 | static READ8_HANDLER( txc_22211c_l_r ) |
| 7393 | 7393 | { |
| 7394 | nes_state *state = | |
| 7394 | nes_state *state = | |
| 7395 | 7395 | LOG_MMC(("txc_22211c_l_r, offset: %04x\n", offset)); |
| 7396 | 7396 | |
| 7397 | 7397 | if (offset == 0x0000) |
| r8714 | r8715 | |
| 7663 | 7663 | |
| 7664 | 7664 | static WRITE8_HANDLER( waixing_f_w ) |
| 7665 | 7665 | { |
| 7666 | nes_state *state = | |
| 7666 | nes_state *state = | |
| 7667 | 7667 | UINT8 cmd; |
| 7668 | 7668 | LOG_MMC(("waixing_f_w, offset: %04x, data: %02x\n", offset, data)); |
| 7669 | 7669 | |
| r8714 | r8715 | |
| 7709 | 7709 | |
| 7710 | 7710 | static void waixing_g_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 7711 | 7711 | { |
| 7712 | nes_state *state = | |
| 7712 | nes_state *state = | |
| 7713 | 7713 | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 7714 | 7714 | |
| 7715 | 7715 | state->mmc3_chr_cb(machine, chr_page ^ 0, chr_base | (state->mmc_vrom_bank[0] & chr_mask), state->mmc_chr_source); |
| r8714 | r8715 | |
| 7724 | 7724 | |
| 7725 | 7725 | static WRITE8_HANDLER( waixing_g_w ) |
| 7726 | 7726 | { |
| 7727 | nes_state *state = | |
| 7727 | nes_state *state = | |
| 7728 | 7728 | UINT8 MMC3_helper, cmd; |
| 7729 | 7729 | LOG_MMC(("waixing_g_w, offset: %04x, data: %02x\n", offset, data)); |
| 7730 | 7730 | |
| r8714 | r8715 | |
| 7795 | 7795 | |
| 7796 | 7796 | static WRITE8_HANDLER( waixing_h_w ) |
| 7797 | 7797 | { |
| 7798 | nes_state *state = | |
| 7798 | nes_state *state = | |
| 7799 | 7799 | UINT8 cmd; |
| 7800 | 7800 | LOG_MMC(("waixing_h_w, offset: %04x, data: %02x\n", offset, data)); |
| 7801 | 7801 | |
| r8714 | r8715 | |
| 7841 | 7841 | |
| 7842 | 7842 | static WRITE8_HANDLER( waixing_sgz_w ) |
| 7843 | 7843 | { |
| 7844 | nes_state *state = | |
| 7844 | nes_state *state = | |
| 7845 | 7845 | UINT8 mmc_helper, bank; |
| 7846 | 7846 | LOG_MMC(("waixing_sgz_w, offset: %04x, data: %02x\n", offset, data)); |
| 7847 | 7847 | |
| r8714 | r8715 | |
| 7904 | 7904 | |
| 7905 | 7905 | static WRITE8_HANDLER( waixing_sgzlz_l_w ) |
| 7906 | 7906 | { |
| 7907 | nes_state *state = | |
| 7907 | nes_state *state = | |
| 7908 | 7908 | LOG_MMC(("waixing_sgzlz_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 7909 | 7909 | |
| 7910 | 7910 | switch (offset) |
| r8714 | r8715 | |
| 7937 | 7937 | |
| 7938 | 7938 | static WRITE8_HANDLER( waixing_ffv_l_w ) |
| 7939 | 7939 | { |
| 7940 | nes_state *state = | |
| 7940 | nes_state *state = | |
| 7941 | 7941 | UINT8 mmc_helper; |
| 7942 | 7942 | LOG_MMC(("waixing_ffv_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 7943 | 7943 | offset += 0x100; /* the checks work better on addresses */ |
| r8714 | r8715 | |
| 8093 | 8093 | |
| 8094 | 8094 | static void waixing_sec_prg_cb( running_machine *machine, int start, int bank ) |
| 8095 | 8095 | { |
| 8096 | nes_state *state = | |
| 8096 | nes_state *state = | |
| 8097 | 8097 | |
| 8098 | 8098 | if (state->mmc_reg[0]) |
| 8099 | 8099 | bank = ((bank & 0x01)) | ((bank >> 3) & 0x02) | ((bank >> 1) & 0x04) | ((bank << 2) & 0x18); |
| r8714 | r8715 | |
| 8103 | 8103 | |
| 8104 | 8104 | static void waixing_sec_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 8105 | 8105 | { |
| 8106 | nes_state *state = | |
| 8106 | nes_state *state = | |
| 8107 | 8107 | |
| 8108 | 8108 | if (state->mmc_reg[0]) |
| 8109 | 8109 | bank = ((bank & 0x03)) | ((bank >> 1) & 0x04) | ((bank >> 4) & 0x08) | |
| r8714 | r8715 | |
| 8114 | 8114 | |
| 8115 | 8115 | static WRITE8_HANDLER( waixing_sec_l_w ) |
| 8116 | 8116 | { |
| 8117 | nes_state *state = | |
| 8117 | nes_state *state = | |
| 8118 | 8118 | LOG_MMC(("waixing_sec_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 8119 | 8119 | |
| 8120 | 8120 | offset += 0x100; |
| r8714 | r8715 | |
| 8143 | 8143 | |
| 8144 | 8144 | static void waixing_sh2_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 8145 | 8145 | { |
| 8146 | nes_state *state = | |
| 8146 | nes_state *state = | |
| 8147 | 8147 | |
| 8148 | 8148 | chr4_0(machine, state->mmc_reg[0], state->mmc_reg[0] ? CHRRAM : CHRROM); |
| 8149 | 8149 | chr4_4(machine, state->mmc_reg[1], state->mmc_reg[1] ? CHRRAM : CHRROM); |
| r8714 | r8715 | |
| 8151 | 8151 | |
| 8152 | 8152 | READ8_HANDLER( waixing_sh2_chr_r ) |
| 8153 | 8153 | { |
| 8154 | nes_state *state = | |
| 8154 | nes_state *state = | |
| 8155 | 8155 | int bank = offset >> 10; |
| 8156 | 8156 | UINT8 val = state->chr_map[bank].access[offset & 0x3ff]; // this would be usual return value |
| 8157 | 8157 | int chr_helper; |
| r8714 | r8715 | |
| 8186 | 8186 | |
| 8187 | 8187 | static void unl_8237_prg_cb( running_machine *machine, int start, int bank ) |
| 8188 | 8188 | { |
| 8189 | nes_state *state = | |
| 8189 | nes_state *state = | |
| 8190 | 8190 | |
| 8191 | 8191 | if (!(state->mmc_reg[0] & 0x80)) |
| 8192 | 8192 | prg8_x(machine, start, bank); |
| r8714 | r8715 | |
| 8194 | 8194 | |
| 8195 | 8195 | static void unl_8237_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 8196 | 8196 | { |
| 8197 | nes_state *state = | |
| 8197 | nes_state *state = | |
| 8198 | 8198 | bank |= ((state->mmc_reg[1] << 6) & 0x100); |
| 8199 | 8199 | |
| 8200 | 8200 | chr1_x(machine, start, bank, source); |
| r8714 | r8715 | |
| 8202 | 8202 | |
| 8203 | 8203 | static WRITE8_HANDLER( unl_8237_l_w ) |
| 8204 | 8204 | { |
| 8205 | nes_state *state = | |
| 8205 | nes_state *state = | |
| 8206 | 8206 | LOG_MMC(("unl_8237_l_w offset: %04x, data: %02x\n", offset, data)); |
| 8207 | 8207 | offset += 0x100; |
| 8208 | 8208 | |
| r8714 | r8715 | |
| 8232 | 8232 | |
| 8233 | 8233 | static WRITE8_HANDLER( unl_8237_w ) |
| 8234 | 8234 | { |
| 8235 | nes_state *state = | |
| 8235 | nes_state *state = | |
| 8236 | 8236 | static const UINT8 conv_table[8] = {0, 2, 6, 1, 7, 3, 4, 5}; |
| 8237 | 8237 | LOG_MMC(("unl_8237_w offset: %04x, data: %02x\n", offset, data)); |
| 8238 | 8238 | |
| r8714 | r8715 | |
| 8282 | 8282 | |
| 8283 | 8283 | static void unl_ax5705_set_prg( running_machine *machine ) |
| 8284 | 8284 | { |
| 8285 | nes_state *state = | |
| 8285 | nes_state *state = | |
| 8286 | 8286 | prg8_89(machine, state->mmc_prg_bank[0]); |
| 8287 | 8287 | prg8_ab(machine, state->mmc_prg_bank[1]); |
| 8288 | 8288 | } |
| 8289 | 8289 | |
| 8290 | 8290 | static WRITE8_HANDLER( unl_ax5705_w ) |
| 8291 | 8291 | { |
| 8292 | nes_state *state = | |
| 8292 | nes_state *state = | |
| 8293 | 8293 | UINT8 bank; |
| 8294 | 8294 | LOG_MMC(("unl_ax5705_w offset: %04x, data: %02x\n", offset, data)); |
| 8295 | 8295 | |
| r8714 | r8715 | |
| 8434 | 8434 | |
| 8435 | 8435 | static WRITE8_HANDLER( unl_t230_w ) |
| 8436 | 8436 | { |
| 8437 | nes_state *state = | |
| 8437 | nes_state *state = | |
| 8438 | 8438 | UINT8 bank; |
| 8439 | 8439 | LOG_MMC(("unl_t230_w offset: %04x, data: %02x\n", offset, data)); |
| 8440 | 8440 | |
| r8714 | r8715 | |
| 8524 | 8524 | |
| 8525 | 8525 | static void kof96_prg_cb( running_machine *machine, int start, int bank ) |
| 8526 | 8526 | { |
| 8527 | nes_state *state = | |
| 8527 | nes_state *state = | |
| 8528 | 8528 | |
| 8529 | 8529 | if (!(state->mmc_reg[0] & 0x80)) |
| 8530 | 8530 | prg8_x(machine, start, bank); |
| r8714 | r8715 | |
| 8532 | 8532 | |
| 8533 | 8533 | static void kof96_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 8534 | 8534 | { |
| 8535 | nes_state *state = | |
| 8535 | nes_state *state = | |
| 8536 | 8536 | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 8537 | 8537 | |
| 8538 | 8538 | if ((start & 0x04) == chr_page) |
| r8714 | r8715 | |
| 8543 | 8543 | |
| 8544 | 8544 | static WRITE8_HANDLER( kof96_l_w ) |
| 8545 | 8545 | { |
| 8546 | nes_state *state = | |
| 8546 | nes_state *state = | |
| 8547 | 8547 | UINT8 new_bank; |
| 8548 | 8548 | LOG_MMC(("kof96_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 8549 | 8549 | offset += 0x100; |
| r8714 | r8715 | |
| 8595 | 8595 | |
| 8596 | 8596 | static READ8_HANDLER( kof96_l_r ) |
| 8597 | 8597 | { |
| 8598 | nes_state *state = | |
| 8598 | nes_state *state = | |
| 8599 | 8599 | LOG_MMC(("kof96_l_r, offset: %04x\n", offset)); |
| 8600 | 8600 | offset += 0x100; |
| 8601 | 8601 | |
| r8714 | r8715 | |
| 8607 | 8607 | |
| 8608 | 8608 | static WRITE8_HANDLER( kof96_w ) |
| 8609 | 8609 | { |
| 8610 | nes_state *state = | |
| 8610 | nes_state *state = | |
| 8611 | 8611 | LOG_MMC(("kof96_w, offset: %04x, data: %02x\n", offset, data)); |
| 8612 | 8612 | |
| 8613 | 8613 | switch (offset & 0x6003) |
| r8714 | r8715 | |
| 8658 | 8658 | |
| 8659 | 8659 | static WRITE8_HANDLER( mk2_m_w ) |
| 8660 | 8660 | { |
| 8661 | nes_state *state = | |
| 8661 | nes_state *state = | |
| 8662 | 8662 | LOG_MMC(("mk2_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 8663 | 8663 | |
| 8664 | 8664 | switch (offset & 0x1000) |
| r8714 | r8715 | |
| 8714 | 8714 | |
| 8715 | 8715 | static WRITE8_HANDLER( n625092_w ) |
| 8716 | 8716 | { |
| 8717 | nes_state *state = | |
| 8717 | nes_state *state = | |
| 8718 | 8718 | LOG_MMC(("n625092_w, offset: %04x, data: %02x\n", offset, data)); |
| 8719 | 8719 | |
| 8720 | 8720 | if (offset < 0x4000) |
| r8714 | r8715 | |
| 8754 | 8754 | |
| 8755 | 8755 | static void sc127_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 8756 | 8756 | { |
| 8757 | nes_state *state = | |
| 8757 | nes_state *state = | |
| 8758 | 8758 | |
| 8759 | 8759 | if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE && state->IRQ_enable) |
| 8760 | 8760 | { |
| r8714 | r8715 | |
| 8772 | 8772 | |
| 8773 | 8773 | static WRITE8_HANDLER( sc127_w ) |
| 8774 | 8774 | { |
| 8775 | nes_state *state = | |
| 8775 | nes_state *state = | |
| 8776 | 8776 | LOG_MMC(("sc127_w, offset: %04x, data: %02x\n", offset, data)); |
| 8777 | 8777 | |
| 8778 | 8778 | switch (offset) |
| r8714 | r8715 | |
| 8828 | 8828 | |
| 8829 | 8829 | static WRITE8_HANDLER( smb2j_w ) |
| 8830 | 8830 | { |
| 8831 | nes_state *state = | |
| 8831 | nes_state *state = | |
| 8832 | 8832 | int bank = (((offset >> 8) & 0x03) * 0x20) + (offset & 0x1f); |
| 8833 | 8833 | |
| 8834 | 8834 | LOG_MMC(("smb2j_w, offset: %04x, data: %02x\n", offset, data)); |
| r8714 | r8715 | |
| 8897 | 8897 | |
| 8898 | 8898 | static void smb2jb_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 8899 | 8899 | { |
| 8900 | nes_state *state = | |
| 8900 | nes_state *state = | |
| 8901 | 8901 | if (state->IRQ_enable) |
| 8902 | 8902 | { |
| 8903 | 8903 | if (state->IRQ_count < 0x1000) |
| r8714 | r8715 | |
| 8916 | 8916 | |
| 8917 | 8917 | static WRITE8_HANDLER( smb2jb_l_w ) |
| 8918 | 8918 | { |
| 8919 | nes_state *state = | |
| 8919 | nes_state *state = | |
| 8920 | 8920 | UINT8 prg; |
| 8921 | 8921 | LOG_MMC(("smb2jb_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 8922 | 8922 | offset += 0x100; |
| r8714 | r8715 | |
| 8957 | 8957 | |
| 8958 | 8958 | static void unl_sf3_set_chr( running_machine *machine, UINT8 chr_source, int chr_base, int chr_mask ) |
| 8959 | 8959 | { |
| 8960 | nes_state *state = | |
| 8960 | nes_state *state = | |
| 8961 | 8961 | chr4_0(machine, chr_base | ((state->mmc_vrom_bank[0] >> 1) & chr_mask), chr_source); |
| 8962 | 8962 | chr2_4(machine, chr_base | (state->mmc_vrom_bank[1] & chr_mask), chr_source); |
| 8963 | 8963 | chr2_6(machine, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr_source); |
| r8714 | r8715 | |
| 8965 | 8965 | |
| 8966 | 8966 | static WRITE8_HANDLER( unl_sf3_w ) |
| 8967 | 8967 | { |
| 8968 | nes_state *state = | |
| 8968 | nes_state *state = | |
| 8969 | 8969 | UINT8 mmc_helper, cmd; |
| 8970 | 8970 | LOG_MMC(("unl_sf3_w, offset: %04x, data: %02x\n", offset, data)); |
| 8971 | 8971 | |
| r8714 | r8715 | |
| 9047 | 9047 | |
| 9048 | 9048 | static void racmate_update_banks( running_machine *machine ) |
| 9049 | 9049 | { |
| 9050 | nes_state *state = | |
| 9050 | nes_state *state = | |
| 9051 | 9051 | chr4_4(machine, state->mmc_latch1 & 0x0f, state->mmc_chr_source); |
| 9052 | 9052 | prg16_89ab(machine, state->mmc_latch1 >> 1); |
| 9053 | 9053 | } |
| 9054 | 9054 | |
| 9055 | 9055 | static WRITE8_HANDLER( unl_racmate_w ) |
| 9056 | 9056 | { |
| 9057 | nes_state *state = | |
| 9057 | nes_state *state = | |
| 9058 | 9058 | LOG_MMC(("unl_racmate_w offset: %04x, data: %02x\n", offset, data)); |
| 9059 | 9059 | |
| 9060 | 9060 | if (offset == 0x3000) |
| r8714 | r8715 | |
| 9107 | 9107 | // is the code fine for ai senshi nicol?!? |
| 9108 | 9108 | static WRITE8_HANDLER( btl_mariobaby_w ) |
| 9109 | 9109 | { |
| 9110 | nes_state *state = | |
| 9110 | nes_state *state = | |
| 9111 | 9111 | LOG_MMC(("btl_mariobaby_w, offset: %04x, data: %02x\n", offset, data)); |
| 9112 | 9112 | |
| 9113 | 9113 | if (offset >= 0x7000) |
| r8714 | r8715 | |
| 9151 | 9151 | |
| 9152 | 9152 | static void btl_smb2a_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 9153 | 9153 | { |
| 9154 | nes_state *state = | |
| 9154 | nes_state *state = | |
| 9155 | 9155 | |
| 9156 | 9156 | if (state->IRQ_enable) |
| 9157 | 9157 | { |
| r8714 | r8715 | |
| 9168 | 9168 | |
| 9169 | 9169 | static WRITE8_HANDLER( btl_smb2a_w ) |
| 9170 | 9170 | { |
| 9171 | nes_state *state = | |
| 9171 | nes_state *state = | |
| 9172 | 9172 | LOG_MMC(("btl_smb2a_w, offset: %04x, data: %02x\n", offset, data)); |
| 9173 | 9173 | |
| 9174 | 9174 | switch (offset & 0x6000) |
| r8714 | r8715 | |
| 9239 | 9239 | |
| 9240 | 9240 | static void btl_smb3_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 9241 | 9241 | { |
| 9242 | nes_state *state = | |
| 9242 | nes_state *state = | |
| 9243 | 9243 | |
| 9244 | 9244 | if (state->IRQ_enable) |
| 9245 | 9245 | { |
| r8714 | r8715 | |
| 9255 | 9255 | |
| 9256 | 9256 | static WRITE8_HANDLER( btl_smb3_w ) |
| 9257 | 9257 | { |
| 9258 | nes_state *state = | |
| 9258 | nes_state *state = | |
| 9259 | 9259 | LOG_MMC(("btl_smb3_w, offset: %04x, data: %02x\n", offset, data)); |
| 9260 | 9260 | switch (offset & 0x0f) |
| 9261 | 9261 | { |
| r8714 | r8715 | |
| 9315 | 9315 | /* Scanline based IRQ ? */ |
| 9316 | 9316 | static void btl_dn_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 9317 | 9317 | { |
| 9318 | nes_state *state = | |
| 9318 | nes_state *state = | |
| 9319 | 9319 | if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE) |
| 9320 | 9320 | { |
| 9321 | 9321 | if (!state->IRQ_count || ++state->IRQ_count < 240) |
| r8714 | r8715 | |
| 9330 | 9330 | |
| 9331 | 9331 | static WRITE8_HANDLER( btl_dn_w ) |
| 9332 | 9332 | { |
| 9333 | nes_state *state = | |
| 9333 | nes_state *state = | |
| 9334 | 9334 | UINT8 bank; |
| 9335 | 9335 | LOG_MMC(("btl_dn_w, offset: %04x, data: %02x\n", offset, data)); |
| 9336 | 9336 | |
| r8714 | r8715 | |
| 9376 | 9376 | |
| 9377 | 9377 | static WRITE8_HANDLER( btl_pika_y2k_w ) |
| 9378 | 9378 | { |
| 9379 | nes_state *state = | |
| 9379 | nes_state *state = | |
| 9380 | 9380 | LOG_MMC(("btl_pika_y2k_w, offset: %04x, data: %02x\n", offset, data)); |
| 9381 | 9381 | |
| 9382 | 9382 | switch (offset & 0x6001) |
| r8714 | r8715 | |
| 9396 | 9396 | // strange WRAM usage: it is protected at start, and gets unprotected after the first write to 0xa000 |
| 9397 | 9397 | static WRITE8_HANDLER( btl_pika_y2k_m_w ) |
| 9398 | 9398 | { |
| 9399 | nes_state *state = | |
| 9399 | nes_state *state = | |
| 9400 | 9400 | LOG_MMC(("btl_pika_y2k_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 9401 | 9401 | |
| 9402 | 9402 | state->wram[offset] = data; |
| r8714 | r8715 | |
| 9404 | 9404 | |
| 9405 | 9405 | static READ8_HANDLER( btl_pika_y2k_m_r ) |
| 9406 | 9406 | { |
| 9407 | nes_state *state = | |
| 9407 | nes_state *state = | |
| 9408 | 9408 | LOG_MMC(("btl_pika_y2k_m_r, offset: %04x\n", offset)); |
| 9409 | 9409 | |
| 9410 | 9410 | return state->wram[offset] ^ (state->mmc_latch2 & state->mmc_reg[0]); |
| r8714 | r8715 | |
| 9428 | 9428 | #if 0 |
| 9429 | 9429 | static void fk23c_prg_cb( running_machine *machine, int start, int bank ) |
| 9430 | 9430 | { |
| 9431 | nes_state *state = | |
| 9431 | nes_state *state = | |
| 9432 | 9432 | |
| 9433 | 9433 | if (((state->mmc_reg[0] & 0x07) - 3) > 1 && (!(state->mmc_reg[3] & 0x02) || start < 2)) |
| 9434 | 9434 | { |
| r8714 | r8715 | |
| 9441 | 9441 | |
| 9442 | 9442 | static void fk23c_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 9443 | 9443 | { |
| 9444 | nes_state *state = | |
| 9444 | nes_state *state = | |
| 9445 | 9445 | |
| 9446 | 9446 | if (!(state->mmc_reg[0] & 0x40) && (!(state->mmc_reg[3] & 0x02) || (start != 1 && start != 3))) |
| 9447 | 9447 | chr1_x(machine, start, ((state->mmc_reg[2] & 0x7f) << 3) | bank, source); |
| r8714 | r8715 | |
| 9451 | 9451 | |
| 9452 | 9452 | static void fk23c_prg_cb( running_machine *machine, int start, int bank ) |
| 9453 | 9453 | { |
| 9454 | nes_state *state = | |
| 9454 | nes_state *state = | |
| 9455 | 9455 | UINT8 mask = (0x3f >> (state->mmc_reg[0] & 0x03)); |
| 9456 | 9456 | |
| 9457 | 9457 | if ((state->mmc_reg[0] & 0x07) < 3) |
| r8714 | r8715 | |
| 9465 | 9465 | |
| 9466 | 9466 | static void fk23c_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 9467 | 9467 | { |
| 9468 | nes_state *state = | |
| 9468 | nes_state *state = | |
| 9469 | 9469 | |
| 9470 | 9470 | if (!(state->mmc_reg[0] & 0x40) && (!(state->mmc_reg[3] & 0x02) || (start != 1 && start != 3))) |
| 9471 | 9471 | chr1_x(machine, start, ((state->mmc_reg[2] & 0x7f) << 3) | bank, source); |
| r8714 | r8715 | |
| 9473 | 9473 | |
| 9474 | 9474 | static void fk23c_set_prg( running_machine *machine ) |
| 9475 | 9475 | { |
| 9476 | nes_state *state = | |
| 9476 | nes_state *state = | |
| 9477 | 9477 | |
| 9478 | 9478 | if ((state->mmc_reg[0] & 0x07) == 4) |
| 9479 | 9479 | prg32(machine, (state->mmc_reg[1] & 0x7f) >> 1); |
| r8714 | r8715 | |
| 9496 | 9496 | |
| 9497 | 9497 | static void fk23c_set_chr( running_machine *machine ) |
| 9498 | 9498 | { |
| 9499 | nes_state *state = | |
| 9499 | nes_state *state = | |
| 9500 | 9500 | |
| 9501 | 9501 | if (state->mmc_reg[0] & 0x40) |
| 9502 | 9502 | chr8(machine, state->mmc_reg[2] | state->mmc_cmd1, state->mmc_chr_source); |
| r8714 | r8715 | |
| 9515 | 9515 | |
| 9516 | 9516 | static WRITE8_HANDLER( fk23c_l_w ) |
| 9517 | 9517 | { |
| 9518 | nes_state *state = | |
| 9518 | nes_state *state = | |
| 9519 | 9519 | LOG_MMC(("fk23c_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 9520 | 9520 | offset += 0x100; |
| 9521 | 9521 | |
| r8714 | r8715 | |
| 9533 | 9533 | |
| 9534 | 9534 | static WRITE8_HANDLER( fk23c_w ) |
| 9535 | 9535 | { |
| 9536 | nes_state *state = | |
| 9536 | nes_state *state = | |
| 9537 | 9537 | LOG_MMC(("fk23c_w, offset: %04x, data: %02x\n", offset, data)); |
| 9538 | 9538 | |
| 9539 | 9539 | if (state->mmc_reg[0] & 0x40) |
| r8714 | r8715 | |
| 9585 | 9585 | |
| 9586 | 9586 | static void bmc_64in1nr_set_prg( running_machine *machine ) |
| 9587 | 9587 | { |
| 9588 | nes_state *state = | |
| 9588 | nes_state *state = | |
| 9589 | 9589 | UINT8 helper1 = (state->mmc_reg[1] & 0x1f); |
| 9590 | 9590 | UINT8 helper2 = (helper1 << 1) | ((state->mmc_reg[1] & 0x40) >> 6); |
| 9591 | 9591 | |
| r8714 | r8715 | |
| 9605 | 9605 | |
| 9606 | 9606 | static WRITE8_HANDLER( bmc_64in1nr_l_w ) |
| 9607 | 9607 | { |
| 9608 | nes_state *state = | |
| 9608 | nes_state *state = | |
| 9609 | 9609 | LOG_MMC(("bmc_64in1nr_l_w offset: %04x, data: %02x\n", offset, data)); |
| 9610 | 9610 | offset += 0x100; |
| 9611 | 9611 | |
| r8714 | r8715 | |
| 9626 | 9626 | |
| 9627 | 9627 | static WRITE8_HANDLER( bmc_64in1nr_w ) |
| 9628 | 9628 | { |
| 9629 | nes_state *state = | |
| 9629 | nes_state *state = | |
| 9630 | 9630 | LOG_MMC(("bmc_64in1nr_w offset: %04x, data: %02x\n", offset, data)); |
| 9631 | 9631 | |
| 9632 | 9632 | state->mmc_reg[3] = data; // reg[3] is currently unused?!? |
| r8714 | r8715 | |
| 9733 | 9733 | |
| 9734 | 9734 | static void bmc_s24in1sc03_prg_cb( running_machine *machine, int start, int bank ) |
| 9735 | 9735 | { |
| 9736 | nes_state *state = | |
| 9736 | nes_state *state = | |
| 9737 | 9737 | static const UINT8 masks[8] = {0x3f, 0x1f, 0x0f, 0x01, 0x03, 0x00, 0x00, 0x00}; |
| 9738 | 9738 | int prg_base = state->mmc_reg[1] << 1; |
| 9739 | 9739 | int prg_mask = masks[state->mmc_reg[0] & 0x07]; |
| r8714 | r8715 | |
| 9744 | 9744 | |
| 9745 | 9745 | static void bmc_s24in1sc03_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 9746 | 9746 | { |
| 9747 | nes_state *state = | |
| 9747 | nes_state *state = | |
| 9748 | 9748 | UINT8 chr = BIT(state->mmc_reg[0], 5) ? CHRRAM : CHRROM; |
| 9749 | 9749 | int chr_base = (state->mmc_reg[2] << 3) & 0xf00; |
| 9750 | 9750 | |
| r8714 | r8715 | |
| 9753 | 9753 | |
| 9754 | 9754 | static WRITE8_HANDLER( bmc_s24in1sc03_l_w ) |
| 9755 | 9755 | { |
| 9756 | nes_state *state = | |
| 9756 | nes_state *state = | |
| 9757 | 9757 | LOG_MMC(("bmc_s24in1sc03_l_w offset: %04x, data: %02x\n", offset, data)); |
| 9758 | 9758 | offset += 0x100; |
| 9759 | 9759 | |
| r8714 | r8715 | |
| 9789 | 9789 | |
| 9790 | 9790 | static WRITE8_HANDLER( bmc_t262_w ) |
| 9791 | 9791 | { |
| 9792 | nes_state *state = | |
| 9792 | nes_state *state = | |
| 9793 | 9793 | UINT8 mmc_helper; |
| 9794 | 9794 | LOG_MMC(("bmc_t262_w offset: %04x, data: %02x\n", offset, data)); |
| 9795 | 9795 | |
| r8714 | r8715 | |
| 9822 | 9822 | |
| 9823 | 9823 | static WRITE8_HANDLER( bmc_ws_m_w ) |
| 9824 | 9824 | { |
| 9825 | nes_state *state = | |
| 9825 | nes_state *state = | |
| 9826 | 9826 | UINT8 mmc_helper; |
| 9827 | 9827 | LOG_MMC(("bmc_ws_m_w offset: %04x, data: %02x\n", offset, data)); |
| 9828 | 9828 | |
| r8714 | r8715 | |
| 9898 | 9898 | |
| 9899 | 9899 | static WRITE8_HANDLER( bmc_gka_w ) |
| 9900 | 9900 | { |
| 9901 | nes_state *state = | |
| 9901 | nes_state *state = | |
| 9902 | 9902 | LOG_MMC(("bmc_gka_w, offset: %04x, data: %02x\n", offset, data)); |
| 9903 | 9903 | |
| 9904 | 9904 | if (offset & 0x0800) |
| r8714 | r8715 | |
| 9954 | 9954 | |
| 9955 | 9955 | static WRITE8_HANDLER( bmc_gkb_w ) |
| 9956 | 9956 | { |
| 9957 | nes_state *state = | |
| 9957 | nes_state *state = | |
| 9958 | 9958 | UINT8 bank = (offset & 0x40) ? 0 : 1; |
| 9959 | 9959 | LOG_MMC(("bmc_gkb_w, offset: %04x, data: %02x\n", offset, data)); |
| 9960 | 9960 | |
| r8714 | r8715 | |
| 10130 | 10130 | |
| 10131 | 10131 | static WRITE8_HANDLER( bmc_15in1_m_w ) |
| 10132 | 10132 | { |
| 10133 | nes_state *state = | |
| 10133 | nes_state *state = | |
| 10134 | 10134 | LOG_MMC(("bmc_15in1_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 10135 | 10135 | |
| 10136 | 10136 | if (offset & 0x0800) |
| r8714 | r8715 | |
| 10251 | 10251 | // does this work for super42in1 as well?!? |
| 10252 | 10252 | static WRITE8_HANDLER( bmc_76in1_w ) |
| 10253 | 10253 | { |
| 10254 | nes_state *state = | |
| 10254 | nes_state *state = | |
| 10255 | 10255 | int hi_bank; |
| 10256 | 10256 | int size_16; |
| 10257 | 10257 | int bank; |
| r8714 | r8715 | |
| 10463 | 10463 | |
| 10464 | 10464 | static WRITE8_HANDLER( bmc_sbig7_w ) |
| 10465 | 10465 | { |
| 10466 | nes_state *state = | |
| 10466 | nes_state *state = | |
| 10467 | 10467 | UINT8 page; |
| 10468 | 10468 | LOG_MMC(("bmc_sbig7_w, offset: %04x, data: %02x\n", offset, data)); |
| 10469 | 10469 | |
| r8714 | r8715 | |
| 10503 | 10503 | |
| 10504 | 10504 | static WRITE8_HANDLER( bmc_hik8_m_w ) |
| 10505 | 10505 | { |
| 10506 | nes_state *state = | |
| 10506 | nes_state *state = | |
| 10507 | 10507 | LOG_MMC(("bmc_hik8_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 10508 | 10508 | |
| 10509 | 10509 | /* This bit is the "register lock". Once register are locked, writes go to WRAM |
| r8714 | r8715 | |
| 10551 | 10551 | |
| 10552 | 10552 | static WRITE8_HANDLER( bmc_hik4in1_m_w ) |
| 10553 | 10553 | { |
| 10554 | nes_state *state = | |
| 10554 | nes_state *state = | |
| 10555 | 10555 | LOG_MMC(("bmc_hik4in1_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 10556 | 10556 | |
| 10557 | 10557 | /* mid writes only work when WRAM is enabled. not sure if I should |
| r8714 | r8715 | |
| 10589 | 10589 | |
| 10590 | 10590 | static void bmc_ball11_set_banks( running_machine *machine ) |
| 10591 | 10591 | { |
| 10592 | nes_state *state = | |
| 10592 | nes_state *state = | |
| 10593 | 10593 | set_nt_mirroring(machine, (state->mmc_reg[0] == 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 10594 | 10594 | |
| 10595 | 10595 | if (state->mmc_reg[0] & 0x01) |
| r8714 | r8715 | |
| 10605 | 10605 | |
| 10606 | 10606 | static WRITE8_HANDLER( bmc_ball11_m_w ) |
| 10607 | 10607 | { |
| 10608 | nes_state *state = | |
| 10608 | nes_state *state = | |
| 10609 | 10609 | |
| 10610 | 10610 | LOG_MMC(("bmc_ball11_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 10611 | 10611 | |
| r8714 | r8715 | |
| 10615 | 10615 | |
| 10616 | 10616 | static WRITE8_HANDLER( bmc_ball11_w ) |
| 10617 | 10617 | { |
| 10618 | nes_state *state = | |
| 10618 | nes_state *state = | |
| 10619 | 10619 | |
| 10620 | 10620 | LOG_MMC(("bmc_ball11_w, offset: %04x, data: %02x\n", offset, data)); |
| 10621 | 10621 | |
| r8714 | r8715 | |
| 10649 | 10649 | |
| 10650 | 10650 | static WRITE8_HANDLER( bmc_mario7in1_m_w ) |
| 10651 | 10651 | { |
| 10652 | nes_state *state = | |
| 10652 | nes_state *state = | |
| 10653 | 10653 | UINT8 map52_helper1, map52_helper2; |
| 10654 | 10654 | LOG_MMC(("bmc_mario7in1_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 10655 | 10655 | |
| r8714 | r8715 | |
| 10692 | 10692 | // remove mask & base parameters! |
| 10693 | 10693 | static void bmc_gc6in1_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 10694 | 10694 | { |
| 10695 | nes_state *state = | |
| 10695 | nes_state *state = | |
| 10696 | 10696 | state->mmc_prg_base = (state->mmc_reg[1] & 0x08) ? 0 : (state->mmc_reg[1] & 0x10); |
| 10697 | 10697 | state->mmc_prg_mask = (state->mmc_reg[1] & 0x08) ? 0x1f : 0x0f; |
| 10698 | 10698 | |
| r8714 | r8715 | |
| 10703 | 10703 | |
| 10704 | 10704 | static void bmc_gc6in1_set_chr( running_machine *machine, UINT8 chr ) |
| 10705 | 10705 | { |
| 10706 | nes_state *state = | |
| 10706 | nes_state *state = | |
| 10707 | 10707 | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 10708 | 10708 | int chr_base = (state->mmc_reg[1] & 0x08) ? 0x00 : ((state->mmc_reg[1] & 0x10) << 3); |
| 10709 | 10709 | int chr_mask = (state->mmc_reg[1] & 0x08) ? 0xff : 0x7f; |
| r8714 | r8715 | |
| 10722 | 10722 | |
| 10723 | 10723 | static WRITE8_HANDLER( bmc_gc6in1_l_w ) |
| 10724 | 10724 | { |
| 10725 | nes_state *state = | |
| 10725 | nes_state *state = | |
| 10726 | 10726 | UINT8 bank; |
| 10727 | 10727 | LOG_MMC(("bmc_gc6in1_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 10728 | 10728 | offset += 0x100; |
| r8714 | r8715 | |
| 10752 | 10752 | |
| 10753 | 10753 | static WRITE8_HANDLER( bmc_gc6in1_w ) |
| 10754 | 10754 | { |
| 10755 | nes_state *state = | |
| 10755 | nes_state *state = | |
| 10756 | 10756 | UINT8 mmc_helper, cmd; |
| 10757 | 10757 | static const UINT8 conv_table[8] = {0, 6, 3, 7, 5, 2, 4, 1}; |
| 10758 | 10758 | LOG_MMC(("bmc_gc6in1_w, offset: %04x, data: %02x\n", offset, data)); |
| r8714 | r8715 | |
| 10870 | 10870 | |
| 10871 | 10871 | static WRITE8_HANDLER( bmc_family4646_m_w ) |
| 10872 | 10872 | { |
| 10873 | nes_state *state = | |
| 10873 | nes_state *state = | |
| 10874 | 10874 | LOG_MMC(("bmc_family4646_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 10875 | 10875 | |
| 10876 | 10876 | if (offset == 0x01) |
| r8714 | r8715 | |
| 10892 | 10892 | |
| 10893 | 10893 | static WRITE8_HANDLER( bmc_vt5201_w ) |
| 10894 | 10894 | { |
| 10895 | nes_state *state = | |
| 10895 | nes_state *state = | |
| 10896 | 10896 | LOG_MMC(("bmc_vt5201_w, offset: %04x, data: %02x\n", offset, data)); |
| 10897 | 10897 | |
| 10898 | 10898 | state->mmc_latch1 = BIT(offset, 8); |
| r8714 | r8715 | |
| 10912 | 10912 | |
| 10913 | 10913 | static READ8_HANDLER( bmc_vt5201_r ) |
| 10914 | 10914 | { |
| 10915 | nes_state *state = | |
| 10915 | nes_state *state = | |
| 10916 | 10916 | LOG_MMC(("bmc_vt5201_r, offset: %04x\n", offset)); |
| 10917 | 10917 | // state->mmc_dipsetting = input_port_read(space->machine, "CARTDIPS"); |
| 10918 | 10918 | |
| r8714 | r8715 | |
| 10932 | 10932 | |
| 10933 | 10933 | static void bmc_bs5_update_banks( running_machine *machine ) |
| 10934 | 10934 | { |
| 10935 | nes_state *state = | |
| 10935 | nes_state *state = | |
| 10936 | 10936 | |
| 10937 | 10937 | prg8_89(machine, state->mmc_prg_bank[0]); |
| 10938 | 10938 | prg8_ab(machine, state->mmc_prg_bank[1]); |
| r8714 | r8715 | |
| 10946 | 10946 | |
| 10947 | 10947 | static WRITE8_HANDLER( bmc_bs5_w ) |
| 10948 | 10948 | { |
| 10949 | nes_state *state = | |
| 10949 | nes_state *state = | |
| 10950 | 10950 | UINT8 bs5_helper = (offset & 0xc00) >> 10; |
| 10951 | 10951 | LOG_MMC(("bmc_bs5_w, offset: %04x, data: %02x\n", offset, data)); |
| 10952 | 10952 | // state->mmc_dipsetting = input_port_read(space->machine, "CARTDIPS"); |
| r8714 | r8715 | |
| 11027 | 11027 | |
| 11028 | 11028 | static void bmc_gb63_update( running_machine *machine ) |
| 11029 | 11029 | { |
| 11030 | nes_state *state = | |
| 11030 | nes_state *state = | |
| 11031 | 11031 | |
| 11032 | 11032 | set_nt_mirroring(machine, BIT(state->mmc_reg[0], 6) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); |
| 11033 | 11033 | |
| r8714 | r8715 | |
| 11047 | 11047 | |
| 11048 | 11048 | static WRITE8_HANDLER( bmc_gb63_w ) |
| 11049 | 11049 | { |
| 11050 | nes_state *state = | |
| 11050 | nes_state *state = | |
| 11051 | 11051 | LOG_MMC(("bmc_gb63_w, offset: %04x, data: %02x\n", offset, data)); |
| 11052 | 11052 | |
| 11053 | 11053 | state->mmc_reg[offset & 1] = data; |
| r8714 | r8715 | |
| 11057 | 11057 | |
| 11058 | 11058 | static READ8_HANDLER( bmc_gb63_r ) |
| 11059 | 11059 | { |
| 11060 | nes_state *state = | |
| 11060 | nes_state *state = | |
| 11061 | 11061 | LOG_MMC(("bmc_gb63_r, offset: %04x\n", offset)); |
| 11062 | 11062 | // state->mmc_dipsetting = input_port_read(space->machine, "CARTDIPS"); |
| 11063 | 11063 | |
| r8714 | r8715 | |
| 11089 | 11089 | |
| 11090 | 11090 | static void h2288_prg_cb( running_machine *machine, int start, int bank ) |
| 11091 | 11091 | { |
| 11092 | nes_state *state = | |
| 11092 | nes_state *state = | |
| 11093 | 11093 | |
| 11094 | 11094 | if (!(state->mmc_reg[0] & 0x40)) |
| 11095 | 11095 | prg8_x(machine, start, bank); |
| r8714 | r8715 | |
| 11097 | 11097 | |
| 11098 | 11098 | static WRITE8_HANDLER( h2288_l_w ) |
| 11099 | 11099 | { |
| 11100 | nes_state *state = | |
| 11100 | nes_state *state = | |
| 11101 | 11101 | LOG_MMC(("h2288_l_w offset: %04x, data: %02x\n", offset, data)); |
| 11102 | 11102 | offset += 0x100; |
| 11103 | 11103 | |
| r8714 | r8715 | |
| 11159 | 11159 | /* I think the IRQ should only get fired if enough CPU cycles have passed, but we don't implement (yet) this part */ |
| 11160 | 11160 | static void shjy3_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 11161 | 11161 | { |
| 11162 | nes_state *state = | |
| 11162 | nes_state *state = | |
| 11163 | 11163 | if (state->IRQ_enable & 0x02) |
| 11164 | 11164 | { |
| 11165 | 11165 | if (state->IRQ_count == 0xff) |
| r8714 | r8715 | |
| 11175 | 11175 | |
| 11176 | 11176 | static void shjy3_update( running_machine *machine ) |
| 11177 | 11177 | { |
| 11178 | nes_state *state = | |
| 11178 | nes_state *state = | |
| 11179 | 11179 | int i; |
| 11180 | 11180 | |
| 11181 | 11181 | prg8_89(machine, state->mmc_prg_bank[0]); |
| r8714 | r8715 | |
| 11203 | 11203 | |
| 11204 | 11204 | static WRITE8_HANDLER( shjy3_w ) |
| 11205 | 11205 | { |
| 11206 | nes_state *state = | |
| 11206 | nes_state *state = | |
| 11207 | 11207 | UINT8 mmc_helper, shift; |
| 11208 | 11208 | LOG_MMC(("shjy3_w, offset: %04x, data: %02x\n", offset, data)); |
| 11209 | 11209 | |
| r8714 | r8715 | |
| 11265 | 11265 | |
| 11266 | 11266 | WRITE8_HANDLER( unl_6035052_extra_w ) |
| 11267 | 11267 | { |
| 11268 | nes_state *state = | |
| 11268 | nes_state *state = | |
| 11269 | 11269 | LOG_MMC(("unl_6035052_extra_w, offset: %04x, data: %02x\n", offset, data)); |
| 11270 | 11270 | state->mmc_latch1 = data & 0x03; |
| 11271 | 11271 | if (state->mmc_latch1 == 1) |
| r8714 | r8715 | |
| 11274 | 11274 | |
| 11275 | 11275 | READ8_HANDLER( unl_6035052_extra_r ) |
| 11276 | 11276 | { |
| 11277 | nes_state *state = | |
| 11277 | nes_state *state = | |
| 11278 | 11278 | LOG_MMC(("unl_6035052_extra_r, offset: %04x\n", offset)); |
| 11279 | 11279 | return state->mmc_latch1; |
| 11280 | 11280 | } |
| r8714 | r8715 | |
| 11288 | 11288 | |
| 11289 | 11289 | static void pjoy84_prg_cb( running_machine *machine, int start, int bank ) |
| 11290 | 11290 | { |
| 11291 | nes_state *state = | |
| 11291 | nes_state *state = | |
| 11292 | 11292 | UINT8 flip = (state->mmc3_latch & 0x40) ? 2 : 0; |
| 11293 | 11293 | |
| 11294 | 11294 | if (!(state->mmc_reg[3] & 0x03)) |
| r8714 | r8715 | |
| 11307 | 11307 | |
| 11308 | 11308 | static void pjoy84_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 11309 | 11309 | { |
| 11310 | nes_state *state = | |
| 11310 | nes_state *state = | |
| 11311 | 11311 | |
| 11312 | 11312 | if (!(state->mmc_reg[3] & 0x10)) |
| 11313 | 11313 | chr1_x(machine, start, bank, source); |
| r8714 | r8715 | |
| 11315 | 11315 | |
| 11316 | 11316 | INLINE void pjoy84_set_base_mask( running_machine *machine ) |
| 11317 | 11317 | { |
| 11318 | nes_state *state = | |
| 11318 | nes_state *state = | |
| 11319 | 11319 | |
| 11320 | 11320 | state->mmc_prg_base = ((state->mmc_reg[0] & (0x06 | BIT(state->mmc_reg[0], 6))) << 4) | |
| 11321 | 11321 | (BIT(state->mmc_reg[0], 4) << 7); |
| r8714 | r8715 | |
| 11331 | 11331 | |
| 11332 | 11332 | static WRITE8_HANDLER( pjoy84_m_w ) |
| 11333 | 11333 | { |
| 11334 | nes_state *state = | |
| 11334 | nes_state *state = | |
| 11335 | 11335 | LOG_MMC(("pjoy84_m_w offset: %04x, data: %02x\n", offset, data)); |
| 11336 | 11336 | |
| 11337 | 11337 | switch (offset & 0x03) |
| r8714 | r8715 | |
| 11374 | 11374 | // MMC1 Mode emulation |
| 11375 | 11375 | static void someri_mmc1_set_prg( running_machine *machine ) |
| 11376 | 11376 | { |
| 11377 | nes_state *state = | |
| 11377 | nes_state *state = | |
| 11378 | 11378 | UINT8 prg_mode = state->mmc_reg[0] & 0x0c; |
| 11379 | 11379 | UINT8 prg_offset = state->mmc_reg[1] & 0x10; |
| 11380 | 11380 | |
| r8714 | r8715 | |
| 11397 | 11397 | |
| 11398 | 11398 | static void someri_mmc1_set_chr( running_machine *machine ) |
| 11399 | 11399 | { |
| 11400 | nes_state *state = | |
| 11400 | nes_state *state = | |
| 11401 | 11401 | UINT8 chr_mode = BIT(state->mmc_reg[0], 4); |
| 11402 | 11402 | |
| 11403 | 11403 | if (chr_mode) |
| r8714 | r8715 | |
| 11411 | 11411 | |
| 11412 | 11412 | static WRITE8_HANDLER( someri_mmc1_w ) |
| 11413 | 11413 | { |
| 11414 | nes_state *state = | |
| 11414 | nes_state *state = | |
| 11415 | 11415 | |
| 11416 | 11416 | assert(state->mmc_cmd1 == 2); |
| 11417 | 11417 | |
| r8714 | r8715 | |
| 11471 | 11471 | // MMC3 Mode emulation |
| 11472 | 11472 | static WRITE8_HANDLER( someri_mmc3_w ) |
| 11473 | 11473 | { |
| 11474 | nes_state *state = | |
| 11474 | nes_state *state = | |
| 11475 | 11475 | UINT8 mmc_helper, cmd; |
| 11476 | 11476 | |
| 11477 | 11477 | assert(state->mmc_cmd1 == 1); |
| r8714 | r8715 | |
| 11519 | 11519 | // VRC2 Mode emulation |
| 11520 | 11520 | static WRITE8_HANDLER( someri_vrc2_w ) |
| 11521 | 11521 | { |
| 11522 | nes_state *state = | |
| 11522 | nes_state *state = | |
| 11523 | 11523 | UINT8 bank, shift; |
| 11524 | 11524 | |
| 11525 | 11525 | assert(state->mmc_cmd1 == 0); |
| r8714 | r8715 | |
| 11556 | 11556 | |
| 11557 | 11557 | static WRITE8_HANDLER( someri_w ) |
| 11558 | 11558 | { |
| 11559 | nes_state *state = | |
| 11559 | nes_state *state = | |
| 11560 | 11560 | LOG_MMC(("someri_w mode %d, offset: %04x, data: %02x\n", state->mmc_cmd1, offset, data)); |
| 11561 | 11561 | |
| 11562 | 11562 | switch (state->mmc_cmd1) |
| r8714 | r8715 | |
| 11569 | 11569 | |
| 11570 | 11570 | static void someri_mode_update( running_machine *machine ) |
| 11571 | 11571 | { |
| 11572 | nes_state *state = | |
| 11572 | nes_state *state = | |
| 11573 | 11573 | int i; |
| 11574 | 11574 | |
| 11575 | 11575 | switch (state->mmc_cmd1) |
| r8714 | r8715 | |
| 11593 | 11593 | |
| 11594 | 11594 | static WRITE8_HANDLER( someri_l_w ) |
| 11595 | 11595 | { |
| 11596 | nes_state *state = | |
| 11596 | nes_state *state = | |
| 11597 | 11597 | LOG_MMC(("someri_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 11598 | 11598 | offset += 0x100; |
| 11599 | 11599 | |
| r8714 | r8715 | |
| 11618 | 11618 | |
| 11619 | 11619 | static WRITE8_HANDLER( fujiya_m_w ) |
| 11620 | 11620 | { |
| 11621 | nes_state *state = | |
| 11621 | nes_state *state = | |
| 11622 | 11622 | LOG_MMC(("fujiya_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 11623 | 11623 | offset += 0x6000; |
| 11624 | 11624 | |
| r8714 | r8715 | |
| 11628 | 11628 | |
| 11629 | 11629 | static READ8_HANDLER( fujiya_m_r ) |
| 11630 | 11630 | { |
| 11631 | nes_state *state = | |
| 11631 | nes_state *state = | |
| 11632 | 11632 | LOG_MMC(("fujiya_m_r, offset: %04x\n", offset)); |
| 11633 | 11633 | offset += 0x6000; |
| 11634 | 11634 | |
| r8714 | r8715 | |
| 11967 | 11967 | |
| 11968 | 11968 | void pcb_handlers_setup( running_machine *machine ) |
| 11969 | 11969 | { |
| 11970 | nes_state *state = | |
| 11970 | nes_state *state = | |
| 11971 | 11971 | const nes_pcb_intf *intf = nes_pcb_intf_lookup(state->pcb_id); |
| 11972 | 11972 | |
| 11973 | 11973 | if (intf == NULL) |
| r8714 | r8715 | |
| 12092 | 12092 | /* this is used by many boards (MMC3, MMC6 + most MMC3 pirate clone boards) */ |
| 12093 | 12093 | static void mmc3_common_initialize( running_machine *machine, int prg_mask, int chr_mask, int IRQ_type ) |
| 12094 | 12094 | { |
| 12095 | nes_state *state = | |
| 12095 | nes_state *state = | |
| 12096 | 12096 | |
| 12097 | 12097 | state->mmc3_alt_irq = IRQ_type; // later MMC3 boards seem to use MMC6-type IRQ... more investigations are in progress at NESDev... |
| 12098 | 12098 | state->mmc_prg_bank[0] = state->mmc_prg_bank[2] = 0xfe; // prg_bank[2] & prg_bank[3] remain always the same in most MMC3 variants |
| r8714 | r8715 | |
| 12109 | 12109 | // WIP code |
| 12110 | 12110 | static int pcb_initialize( running_machine *machine, int idx ) |
| 12111 | 12111 | { |
| 12112 | nes_state *state = | |
| 12112 | nes_state *state = | |
| 12113 | 12113 | int err = 0, i; |
| 12114 | 12114 | |
| 12115 | 12115 | /* basic PRG config */ |
| r8714 | r8715 | |
| 12995 | 12995 | |
| 12996 | 12996 | int nes_pcb_reset( running_machine *machine ) |
| 12997 | 12997 | { |
| 12998 | nes_state *state = | |
| 12998 | nes_state *state = | |
| 12999 | 12999 | int err = 0; |
| 13000 | 13000 | const nes_pcb_intf *intf = nes_pcb_intf_lookup(state->pcb_id); |
| 13001 | 13001 |
| r8714 | r8715 | |
|---|---|---|
| 44 | 44 | |
| 45 | 45 | static void samcoupe_install_ext_mem(const address_space *space) |
| 46 | 46 | { |
| 47 | coupe_asic *asic = | |
| 47 | coupe_asic *asic = | |
| 48 | 48 | UINT8 *mem; |
| 49 | 49 | |
| 50 | 50 | /* bank 3 */ |
| r8714 | r8715 | |
| 67 | 67 | |
| 68 | 68 | void samcoupe_update_memory(const address_space *space) |
| 69 | 69 | { |
| 70 | coupe_asic *asic = | |
| 70 | coupe_asic *asic = | |
| 71 | 71 | const int PAGE_MASK = ((messram_get_size(space->machine->device("messram")) & 0xfffff) / 0x4000) - 1; |
| 72 | 72 | UINT8 *rom = memory_region(space->machine, "maincpu"); |
| 73 | 73 | UINT8 *memory; |
| r8714 | r8715 | |
| 140 | 140 | WRITE8_HANDLER( samcoupe_ext_mem_w ) |
| 141 | 141 | { |
| 142 | 142 | const address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 143 | coupe_asic *asic = | |
| 143 | coupe_asic *asic = | |
| 144 | 144 | |
| 145 | 145 | if (offset & 1) |
| 146 | 146 | asic->hext = data; |
| r8714 | r8715 | |
| 177 | 177 | |
| 178 | 178 | static TIMER_CALLBACK( samcoupe_mouse_reset ) |
| 179 | 179 | { |
| 180 | coupe_asic *asic = | |
| 180 | coupe_asic *asic = | |
| 181 | 181 | asic->mouse_index = 0; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | UINT8 samcoupe_mouse_r(running_machine *machine) |
| 185 | 185 | { |
| 186 | coupe_asic *asic = | |
| 186 | coupe_asic *asic = | |
| 187 | 187 | UINT8 result; |
| 188 | 188 | |
| 189 | 189 | /* on a read, reset the timer */ |
| r8714 | r8715 | |
| 228 | 228 | |
| 229 | 229 | MACHINE_START( samcoupe ) |
| 230 | 230 | { |
| 231 | coupe_asic *asic = | |
| 231 | coupe_asic *asic = | |
| 232 | 232 | asic->mouse_reset = timer_alloc(machine, samcoupe_mouse_reset, 0); |
| 233 | 233 | |
| 234 | 234 | /* schedule our video updates */ |
| r8714 | r8715 | |
| 244 | 244 | { |
| 245 | 245 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 246 | 246 | const address_space *spaceio = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO); |
| 247 | coupe_asic *asic = | |
| 247 | coupe_asic *asic = | |
| 248 | 248 | |
| 249 | 249 | /* initialize asic */ |
| 250 | 250 | asic->lmpr = 0x0f; /* ROM0 paged in, ROM1 paged out RAM Banks */ |
| r8714 | r8715 | |
|---|---|---|
| 163 | 163 | |
| 164 | 164 | static int dos_card_active(running_machine *machine) |
| 165 | 165 | { |
| 166 | comx35_state *state = | |
| 166 | comx35_state *state = | |
| 167 | 167 | |
| 168 | 168 | if (expansion_box_installed(machine)) |
| 169 | 169 | { |
| r8714 | r8715 | |
| 178 | 178 | /* Floppy Disc Controller */ |
| 179 | 179 | static WRITE_LINE_DEVICE_HANDLER( comx35_fdc_intrq_w ) |
| 180 | 180 | { |
| 181 | comx35_state *driver_state = | |
| 181 | comx35_state *driver_state = | |
| 182 | 182 | driver_state->fdc_irq = state; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | static WRITE_LINE_DEVICE_HANDLER( comx35_fdc_drq_w ) |
| 186 | 186 | { |
| 187 | comx35_state *driver_state = | |
| 187 | comx35_state *driver_state = | |
| 188 | 188 | |
| 189 | 189 | if (driver_state->fdc_drq_enable) |
| 190 | 190 | driver_state->cdp1802_ef4 = state; |
| r8714 | r8715 | |
| 200 | 200 | |
| 201 | 201 | static UINT8 fdc_r(const address_space *space) |
| 202 | 202 | { |
| 203 | comx35_state *state = | |
| 203 | comx35_state *state = | |
| 204 | 204 | running_device *fdc = space->machine->device(WD1770_TAG); |
| 205 | 205 | |
| 206 | 206 | UINT8 data; |
| r8714 | r8715 | |
| 233 | 233 | |
| 234 | 234 | */ |
| 235 | 235 | |
| 236 | comx35_state *state = | |
| 236 | comx35_state *state = | |
| 237 | 237 | |
| 238 | 238 | if (state->cdp1802_q) |
| 239 | 239 | { |
| r8714 | r8715 | |
| 271 | 271 | |
| 272 | 272 | static UINT8 printer_r(running_machine *machine) |
| 273 | 273 | { |
| 274 | // comx35_state *state = | |
| 274 | // comx35_state *state = | |
| 275 | 275 | |
| 276 | 276 | int printer = input_port_read(machine, "PRINTER") & 0x07; |
| 277 | 277 | UINT8 data = 0; |
| r8714 | r8715 | |
| 312 | 312 | |
| 313 | 313 | static void printer_w(running_machine *machine, UINT8 data) |
| 314 | 314 | { |
| 315 | // comx35_state *state = | |
| 315 | // comx35_state *state = | |
| 316 | 316 | int printer = input_port_read(machine, "PRINTER") & 0x07; |
| 317 | 317 | |
| 318 | 318 | switch (printer) |
| r8714 | r8715 | |
| 348 | 348 | |
| 349 | 349 | static void get_active_bank(running_machine *machine, UINT8 data) |
| 350 | 350 | { |
| 351 | comx35_state *state = | |
| 351 | comx35_state *state = | |
| 352 | 352 | static const char *const slotnames[] = { "", "SLOT1", "SLOT2", "SLOT3", "SLOT4" }; |
| 353 | 353 | |
| 354 | 354 | if (expansion_box_installed(machine)) |
| r8714 | r8715 | |
| 382 | 382 | |
| 383 | 383 | static void set_active_bank(running_machine *machine) |
| 384 | 384 | { |
| 385 | comx35_state *state = | |
| 385 | comx35_state *state = | |
| 386 | 386 | const address_space *program = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM); |
| 387 | 387 | int bank = state->bank; |
| 388 | 388 | |
| r8714 | r8715 | |
| 460 | 460 | |
| 461 | 461 | READ8_HANDLER( comx35_io_r ) |
| 462 | 462 | { |
| 463 | comx35_state *state = | |
| 463 | comx35_state *state = | |
| 464 | 464 | |
| 465 | 465 | UINT8 data = 0xff; |
| 466 | 466 | |
| r8714 | r8715 | |
| 496 | 496 | |
| 497 | 497 | READ8_HANDLER( comx35_io2_r ) |
| 498 | 498 | { |
| 499 | comx35_state *state = | |
| 499 | comx35_state *state = | |
| 500 | 500 | |
| 501 | 501 | UINT8 data = 0xff; |
| 502 | 502 | |
| r8714 | r8715 | |
| 530 | 530 | |
| 531 | 531 | WRITE8_HANDLER( comx35_io_w ) |
| 532 | 532 | { |
| 533 | comx35_state *state = | |
| 533 | comx35_state *state = | |
| 534 | 534 | |
| 535 | 535 | switch (state->bank) |
| 536 | 536 | { |
| r8714 | r8715 | |
| 563 | 563 | |
| 564 | 564 | static TIMER_CALLBACK( reset_tick ) |
| 565 | 565 | { |
| 566 | comx35_state *state = | |
| 566 | comx35_state *state = | |
| 567 | 567 | |
| 568 | 568 | state->cdp1802_mode = CDP1802_MODE_RUN; |
| 569 | 569 | } |
| r8714 | r8715 | |
| 590 | 590 | |
| 591 | 591 | MACHINE_START( comx35p ) |
| 592 | 592 | { |
| 593 | comx35_state *state = | |
| 593 | comx35_state *state = | |
| 594 | 594 | const address_space *program = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM); |
| 595 | 595 | |
| 596 | 596 | /* opbase handling for DOS Card */ |
| r8714 | r8715 | |
| 669 | 669 | |
| 670 | 670 | MACHINE_START( comx35n ) |
| 671 | 671 | { |
| 672 | comx35_state *state = | |
| 672 | comx35_state *state = | |
| 673 | 673 | |
| 674 | 674 | MACHINE_START_CALL(comx35p); |
| 675 | 675 | |
| r8714 | r8715 | |
| 680 | 680 | |
| 681 | 681 | MACHINE_RESET( comx35 ) |
| 682 | 682 | { |
| 683 | comx35_state *state = | |
| 683 | comx35_state *state = | |
| 684 | 684 | int t = RES_K(27) * CAP_U(1) * 1000; // t = R1 * C1 |
| 685 | 685 | |
| 686 | 686 | state->cdp1802_mode = CDP1802_MODE_RESET; |
| r8714 | r8715 | |
|---|---|---|
| 173 | 173 | // handle disk enable lines |
| 174 | 174 | void mac_fdc_set_enable_lines(running_device *device,int enable_mask) |
| 175 | 175 | { |
| 176 | mac_state *mac = | |
| 176 | mac_state *mac = | |
| 177 | 177 | |
| 178 | 178 | if (mac->mac_model != MODEL_MAC_SE) |
| 179 | 179 | { |
| r8714 | r8715 | |
| 230 | 230 | |
| 231 | 231 | static void mac_field_interrupts(running_machine *machine) |
| 232 | 232 | { |
| 233 | mac_state *mac = | |
| 233 | mac_state *mac = | |
| 234 | 234 | |
| 235 | 235 | int take_interrupt = -1; |
| 236 | 236 | |
| r8714 | r8715 | |
| 331 | 331 | offs_t memory_size; |
| 332 | 332 | UINT8 *memory_data; |
| 333 | 333 | int is_rom; |
| 334 | mac_state *mac = | |
| 334 | mac_state *mac = | |
| 335 | 335 | |
| 336 | 336 | /* normalize overlay */ |
| 337 | 337 | overlay = overlay ? TRUE : FALSE; |
| r8714 | r8715 | |
| 435 | 435 | int keybuf; |
| 436 | 436 | int keycode; |
| 437 | 437 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6" }; |
| 438 | mac_state *mac = | |
| 438 | mac_state *mac = | |
| 439 | 439 | |
| 440 | 440 | if (mac->keycode_buf_index) |
| 441 | 441 | { |
| r8714 | r8715 | |
| 562 | 562 | { |
| 563 | 563 | int i; |
| 564 | 564 | running_device *via_0 = machine->device("via6522_0"); |
| 565 | mac_state *mac = | |
| 565 | mac_state *mac = | |
| 566 | 566 | |
| 567 | 567 | if (mac->kbd_comm == TRUE) |
| 568 | 568 | { |
| r8714 | r8715 | |
| 591 | 591 | |
| 592 | 592 | static void kbd_shift_out(running_machine *machine, int data) |
| 593 | 593 | { |
| 594 | mac_state *mac = | |
| 594 | mac_state *mac = | |
| 595 | 595 | |
| 596 | 596 | if (mac->kbd_comm == TRUE) |
| 597 | 597 | { |
| r8714 | r8715 | |
| 602 | 602 | |
| 603 | 603 | static WRITE8_DEVICE_HANDLER(mac_via_out_cb2) |
| 604 | 604 | { |
| 605 | mac_state *mac = | |
| 605 | mac_state *mac = | |
| 606 | 606 | |
| 607 | 607 | if (mac->kbd_comm == FALSE && data == 0) |
| 608 | 608 | { |
| r8714 | r8715 | |
| 633 | 633 | */ |
| 634 | 634 | static void keyboard_receive(running_machine *machine, int val) |
| 635 | 635 | { |
| 636 | mac_state *mac = | |
| 636 | mac_state *mac = | |
| 637 | 637 | |
| 638 | 638 | switch (val) |
| 639 | 639 | { |
| r8714 | r8715 | |
| 716 | 716 | static int count_x = 0, count_y = 0; |
| 717 | 717 | int new_mx, new_my; |
| 718 | 718 | int x_needs_update = 0, y_needs_update = 0; |
| 719 | mac_state *mac = | |
| 719 | mac_state *mac = | |
| 720 | 720 | |
| 721 | 721 | new_mx = input_port_read(machine, "MOUSE1"); |
| 722 | 722 | new_my = input_port_read(machine, "MOUSE2"); |
| r8714 | r8715 | |
| 927 | 927 | |
| 928 | 928 | static void mac_scsi_irq(running_machine *machine, int state) |
| 929 | 929 | { |
| 930 | mac_state *mac = | |
| 930 | mac_state *mac = | |
| 931 | 931 | |
| 932 | 932 | if ((mac->mac_scsiirq_enable) && ((mac->mac_model == MODEL_MAC_SE) || (mac->mac_model == MODEL_MAC_CLASSIC))) |
| 933 | 933 | { |
| r8714 | r8715 | |
| 1253 | 1253 | /* TODO : save write_protect flag, save time difference with host clock */ |
| 1254 | 1254 | NVRAM_HANDLER( mac ) |
| 1255 | 1255 | { |
| 1256 | mac_state *mac = | |
| 1256 | mac_state *mac = | |
| 1257 | 1257 | |
| 1258 | 1258 | if (read_or_write) |
| 1259 | 1259 | { |
| r8714 | r8715 | |
| 1394 | 1394 | { |
| 1395 | 1395 | int i, j, keybuf, report, codes[2], result; |
| 1396 | 1396 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5" }; |
| 1397 | mac_state *mac = | |
| 1397 | mac_state *mac = | |
| 1398 | 1398 | |
| 1399 | 1399 | codes[0] = codes[1] = 0x80; // key up |
| 1400 | 1400 | report = result = 0; |
| r8714 | r8715 | |
| 1588 | 1588 | static void mac_adb_talk(running_machine *machine) |
| 1589 | 1589 | { |
| 1590 | 1590 | int addr, reg; |
| 1591 | mac_state *mac = | |
| 1591 | mac_state *mac = | |
| 1592 | 1592 | |
| 1593 | 1593 | addr = (mac->adb_command>>4); |
| 1594 | 1594 | reg = (mac->adb_command & 3); |
| r8714 | r8715 | |
| 1775 | 1775 | static TIMER_CALLBACK(mac_adb_tick) |
| 1776 | 1776 | { |
| 1777 | 1777 | running_device *via_0 = machine->device("via6522_0"); |
| 1778 | mac_state *mac = | |
| 1778 | mac_state *mac = | |
| 1779 | 1779 | |
| 1780 | 1780 | // do one clock transition on CB1 to advance the VIA shifter |
| 1781 | 1781 | mac->adb_extclock ^= 1; |
| r8714 | r8715 | |
| 1867 | 1867 | static READ8_DEVICE_HANDLER(mac_adb_via_in_cb2) |
| 1868 | 1868 | { |
| 1869 | 1869 | UINT8 ret; |
| 1870 | mac_state *mac = | |
| 1870 | mac_state *mac = | |
| 1871 | 1871 | |
| 1872 | 1872 | ret = (mac->adb_send & 0x80)>>7; |
| 1873 | 1873 | mac->adb_send <<= 1; |
| r8714 | r8715 | |
| 1879 | 1879 | |
| 1880 | 1880 | static WRITE8_DEVICE_HANDLER(mac_adb_via_out_cb2) |
| 1881 | 1881 | { |
| 1882 | mac_state *mac = | |
| 1882 | mac_state *mac = | |
| 1883 | 1883 | |
| 1884 | 1884 | // printf("VIA OUT CB2 = %x\n", data); |
| 1885 | 1885 | mac->adb_command <<= 1; |
| r8714 | r8715 | |
| 2227 | 2227 | |
| 2228 | 2228 | static void adb_vblank(running_machine *machine) |
| 2229 | 2229 | { |
| 2230 | mac_state *mac = | |
| 2230 | mac_state *mac = | |
| 2231 | 2231 | |
| 2232 | 2232 | if (mac->adb_state == ADB_STATE_IDLE) |
| 2233 | 2233 | { |
| r8714 | r8715 | |
| 2354 | 2354 | |
| 2355 | 2355 | static READ8_DEVICE_HANDLER(mac_via_in_a) |
| 2356 | 2356 | { |
| 2357 | mac_state *mac = | |
| 2357 | mac_state *mac = | |
| 2358 | 2358 | |
| 2359 | 2359 | // printf("VIA1 IN_A (PC %x)\n", cpu_get_pc(device->machine->device("maincpu"))); |
| 2360 | 2360 | |
| r8714 | r8715 | |
| 2402 | 2402 | static READ8_DEVICE_HANDLER(mac_via_in_b) |
| 2403 | 2403 | { |
| 2404 | 2404 | int val = 0; |
| 2405 | mac_state *mac = | |
| 2405 | mac_state *mac = | |
| 2406 | 2406 | |
| 2407 | 2407 | // portable/PB100 is pretty different |
| 2408 | 2408 | if (mac->mac_model >= MODEL_MAC_PORTABLE && mac->mac_model <= MODEL_MAC_PB100) |
| r8714 | r8715 | |
| 2452 | 2452 | { |
| 2453 | 2453 | running_device *sound = device->machine->device("custom"); |
| 2454 | 2454 | running_device *fdc = device->machine->device("fdc"); |
| 2455 | mac_state *mac = | |
| 2455 | mac_state *mac = | |
| 2456 | 2456 | |
| 2457 | 2457 | // printf("VIA1 OUT A: %02x (PC %x)\n", data, cpu_get_pc(device->machine->device("maincpu"))); |
| 2458 | 2458 | |
| r8714 | r8715 | |
| 2492 | 2492 | { |
| 2493 | 2493 | running_device *sound = device->machine->device("custom"); |
| 2494 | 2494 | int new_rtc_rTCClk; |
| 2495 | mac_state *mac = | |
| 2495 | mac_state *mac = | |
| 2496 | 2496 | |
| 2497 | 2497 | // printf("VIA1 OUT B: %02x (PC %x)\n", data, cpu_get_pc(device->machine->device("maincpu"))); |
| 2498 | 2498 | |
| r8714 | r8715 | |
| 2625 | 2625 | static READ8_DEVICE_HANDLER(mac_via2_in_a) |
| 2626 | 2626 | { |
| 2627 | 2627 | UINT8 result = 0xc0; |
| 2628 | mac_state *mac = | |
| 2628 | mac_state *mac = | |
| 2629 | 2629 | |
| 2630 | 2630 | result |= mac->mac_nubus_irq_state; |
| 2631 | 2631 | |
| r8714 | r8715 | |
| 2639 | 2639 | |
| 2640 | 2640 | static READ8_DEVICE_HANDLER(mac_via2_in_b) |
| 2641 | 2641 | { |
| 2642 | mac_state *mac = | |
| 2642 | mac_state *mac = | |
| 2643 | 2643 | |
| 2644 | 2644 | // logerror("VIA2 IN B (PC %x)\n", cpu_get_pc(device->machine->device("maincpu"))); |
| 2645 | 2645 | |
| r8714 | r8715 | |
| 2679 | 2679 | |
| 2680 | 2680 | MACHINE_START( mac ) |
| 2681 | 2681 | { |
| 2682 | mac_state *mac = | |
| 2682 | mac_state *mac = | |
| 2683 | 2683 | if (has_adb(mac)) |
| 2684 | 2684 | { |
| 2685 | 2685 | mac_adb_timer = timer_alloc(machine, mac_adb_tick, NULL); |
| r8714 | r8715 | |
| 2690 | 2690 | } |
| 2691 | 2691 | MACHINE_RESET(mac) |
| 2692 | 2692 | { |
| 2693 | mac_state *mac = | |
| 2693 | mac_state *mac = | |
| 2694 | 2694 | mac_model_t model_save; |
| 2695 | 2695 | emu_timer *timer_save; |
| 2696 | 2696 | |
| r8714 | r8715 | |
| 2745 | 2745 | static STATE_POSTLOAD( mac_state_load ) |
| 2746 | 2746 | { |
| 2747 | 2747 | int overlay; |
| 2748 | mac_state *mac = | |
| 2748 | mac_state *mac = | |
| 2749 | 2749 | |
| 2750 | 2750 | overlay = mac->mac_overlay; |
| 2751 | 2751 | mac->mac_overlay = -1; |
| r8714 | r8715 | |
| 2755 | 2755 | |
| 2756 | 2756 | static DIRECT_UPDATE_HANDLER (overlay_opbaseoverride) |
| 2757 | 2757 | { |
| 2758 | mac_state *mac = | |
| 2758 | mac_state *mac = | |
| 2759 | 2759 | |
| 2760 | 2760 | if (mac->mac_overlay != -1) |
| 2761 | 2761 | { |
| r8714 | r8715 | |
| 2798 | 2798 | |
| 2799 | 2799 | static void mac_driver_init(running_machine *machine, mac_model_t model) |
| 2800 | 2800 | { |
| 2801 | mac_state *mac = | |
| 2801 | mac_state *mac = | |
| 2802 | 2802 | |
| 2803 | 2803 | mac->mac_overlay = -1; |
| 2804 | 2804 | scsi_interrupt = 0; |
| r8714 | r8715 | |
| 2998 | 2998 | void mac_nubus_slot_interrupt(running_machine *machine, UINT8 slot, UINT32 state) |
| 2999 | 2999 | { |
| 3000 | 3000 | UINT8 masks[6] = { 0x1, 0x2, 0x4, 0x8, 0x10, 0x20 }; |
| 3001 | mac_state *mac = | |
| 3001 | mac_state *mac = | |
| 3002 | 3002 | |
| 3003 | 3003 | slot -= 9; |
| 3004 | 3004 | |
| r8714 | r8715 | |
| 3024 | 3024 | { |
| 3025 | 3025 | static int irq_count = 0, ca1_data = 0, ca2_data = 0; |
| 3026 | 3026 | running_device *via_0 = machine->device("via6522_0"); |
| 3027 | mac_state *mac = | |
| 3027 | mac_state *mac = | |
| 3028 | 3028 | |
| 3029 | 3029 | /* handle ADB keyboard/mouse */ |
| 3030 | 3030 | if (has_adb(mac)) |
| r8714 | r8715 | |
| 3083 | 3083 | static TIMER_CALLBACK(mac_scanline_tick) |
| 3084 | 3084 | { |
| 3085 | 3085 | int scanline; |
| 3086 | mac_state *mac = | |
| 3086 | mac_state *mac = | |
| 3087 | 3087 | |
| 3088 | 3088 | if (mac->mac_model < MODEL_MAC_II) |
| 3089 | 3089 | { |
| r8714 | r8715 | |
|---|---|---|
| 35 | 35 | |
| 36 | 36 | static void init_nes_core( running_machine *machine ) |
| 37 | 37 | { |
| 38 | nes_state *state = | |
| 38 | nes_state *state = | |
| 39 | 39 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 40 | 40 | static const char *const bank_names[] = { "bank1", "bank2", "bank3", "bank4" }; |
| 41 | 41 | int prg_banks = (state->prg_chunks == 1) ? (2 * 2) : (state->prg_chunks * 2); |
| r8714 | r8715 | |
| 188 | 188 | |
| 189 | 189 | MACHINE_RESET( nes ) |
| 190 | 190 | { |
| 191 | nes_state *state = | |
| 191 | nes_state *state = | |
| 192 | 192 | |
| 193 | 193 | /* Reset the mapper variables. Will also mark the char-gen ram as dirty */ |
| 194 | 194 | if (state->disk_expansion && state->pcb_id == NO_BOARD) |
| r8714 | r8715 | |
| 205 | 205 | |
| 206 | 206 | static TIMER_CALLBACK( nes_irq_callback ) |
| 207 | 207 | { |
| 208 | nes_state *state = | |
| 208 | nes_state *state = | |
| 209 | 209 | cpu_set_input_line(state->maincpu, M6502_IRQ_LINE, HOLD_LINE); |
| 210 | 210 | timer_adjust_oneshot(state->irq_timer, attotime_never, 0); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | static STATE_POSTLOAD( nes_banks_restore ) |
| 214 | 214 | { |
| 215 | nes_state *state = | |
| 215 | nes_state *state = | |
| 216 | 216 | |
| 217 | 217 | memory_set_bank(machine, "bank1", state->prg_bank[0]); |
| 218 | 218 | memory_set_bank(machine, "bank2", state->prg_bank[1]); |
| r8714 | r8715 | |
| 223 | 223 | |
| 224 | 224 | static void nes_state_register( running_machine *machine ) |
| 225 | 225 | { |
| 226 | nes_state *state = | |
| 226 | nes_state *state = | |
| 227 | 227 | |
| 228 | 228 | state_save_register_global_array(machine, state->prg_bank); |
| 229 | 229 | |
| r8714 | r8715 | |
| 276 | 276 | |
| 277 | 277 | MACHINE_START( nes ) |
| 278 | 278 | { |
| 279 | nes_state *state = | |
| 279 | nes_state *state = | |
| 280 | 280 | |
| 281 | 281 | init_nes_core(machine); |
| 282 | 282 | machine->add_notifier(MACHINE_NOTIFY_EXIT, nes_machine_stop); |
| r8714 | r8715 | |
| 292 | 292 | |
| 293 | 293 | static void nes_machine_stop( running_machine &machine ) |
| 294 | 294 | { |
| 295 | nes_state *state = | |
| 295 | nes_state *state = | |
| 296 | 296 | device_image_interface *image = dynamic_cast<device_image_interface *>(state->cart); |
| 297 | 297 | /* Write out the battery file if necessary */ |
| 298 | 298 | if (state->battery) |
| r8714 | r8715 | |
| 306 | 306 | |
| 307 | 307 | READ8_HANDLER( nes_IN0_r ) |
| 308 | 308 | { |
| 309 | nes_state *state = | |
| 309 | nes_state *state = | |
| 310 | 310 | int cfg = input_port_read(space->machine, "CTRLSEL"); |
| 311 | 311 | int ret; |
| 312 | 312 | |
| r8714 | r8715 | |
| 374 | 374 | |
| 375 | 375 | READ8_HANDLER( nes_IN1_r ) |
| 376 | 376 | { |
| 377 | nes_state *state = | |
| 377 | nes_state *state = | |
| 378 | 378 | int cfg = input_port_read(space->machine, "CTRLSEL"); |
| 379 | 379 | int ret; |
| 380 | 380 | |
| r8714 | r8715 | |
| 453 | 453 | // to also emulate the fact that nothing should be in Port 2 if there is a Crazy Climber pad, etc. |
| 454 | 454 | static void nes_read_input_device( running_machine *machine, int cfg, nes_input *vals, int pad_port, int supports_zapper ) |
| 455 | 455 | { |
| 456 | nes_state *state = | |
| 456 | nes_state *state = | |
| 457 | 457 | static const char *const padnames[] = { "PAD1", "PAD2", "PAD3", "PAD4", "CC_LEFT", "CC_RIGHT" }; |
| 458 | 458 | |
| 459 | 459 | vals->i0 = 0; |
| r8714 | r8715 | |
| 528 | 528 | |
| 529 | 529 | WRITE8_HANDLER( nes_IN0_w ) |
| 530 | 530 | { |
| 531 | nes_state *state = | |
| 531 | nes_state *state = | |
| 532 | 532 | int cfg = input_port_read(space->machine, "CTRLSEL"); |
| 533 | 533 | |
| 534 | 534 | /* Check if lightgun has been chosen as input: if so, enable crosshair */ |
| r8714 | r8715 | |
| 641 | 641 | |
| 642 | 642 | DEVICE_IMAGE_LOAD( nes_cart ) |
| 643 | 643 | { |
| 644 | nes_state *state = | |
| 644 | nes_state *state = | |
| 645 | 645 | state->pcb_id = NO_BOARD; // initialization |
| 646 | 646 | |
| 647 | 647 | if (image.software_entry() == NULL) |
| r8714 | r8715 | |
| 1511 | 1511 | |
| 1512 | 1512 | static void fds_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 1513 | 1513 | { |
| 1514 | nes_state *state = | |
| 1514 | nes_state *state = | |
| 1515 | 1515 | |
| 1516 | 1516 | if (state->IRQ_enable_latch) |
| 1517 | 1517 | cpu_set_input_line(state->maincpu, M6502_IRQ_LINE, HOLD_LINE); |
| r8714 | r8715 | |
| 1531 | 1531 | |
| 1532 | 1532 | static READ8_HANDLER( nes_fds_r ) |
| 1533 | 1533 | { |
| 1534 | nes_state *state = | |
| 1534 | nes_state *state = | |
| 1535 | 1535 | UINT8 ret = 0x00; |
| 1536 | 1536 | |
| 1537 | 1537 | switch (offset) |
| r8714 | r8715 | |
| 1581 | 1581 | |
| 1582 | 1582 | static WRITE8_HANDLER( nes_fds_w ) |
| 1583 | 1583 | { |
| 1584 | nes_state *state = | |
| 1584 | nes_state *state = | |
| 1585 | 1585 | |
| 1586 | 1586 | switch (offset) |
| 1587 | 1587 | { |
| r8714 | r8715 | |
| 1622 | 1622 | |
| 1623 | 1623 | static void nes_load_proc( device_image_interface &image ) |
| 1624 | 1624 | { |
| 1625 | nes_state *state = | |
| 1625 | nes_state *state = | |
| 1626 | 1626 | int header = 0; |
| 1627 | 1627 | state->fds_sides = 0; |
| 1628 | 1628 | |
| r8714 | r8715 | |
| 1643 | 1643 | |
| 1644 | 1644 | static void nes_unload_proc( device_image_interface &image ) |
| 1645 | 1645 | { |
| 1646 | nes_state *state = | |
| 1646 | nes_state *state = | |
| 1647 | 1647 | |
| 1648 | 1648 | /* TODO: should write out changes here as well */ |
| 1649 | 1649 | state->fds_sides = 0; |
| r8714 | r8715 | |
| 1651 | 1651 | |
| 1652 | 1652 | DRIVER_INIT( famicom ) |
| 1653 | 1653 | { |
| 1654 | nes_state *state = | |
| 1654 | nes_state *state = | |
| 1655 | 1655 | int i; |
| 1656 | 1656 | |
| 1657 | 1657 | /* clear some of the variables we don't use */ |
| r8714 | r8715 | |
|---|---|---|
| 149 | 149 | |
| 150 | 150 | void unif_mapr_setup( running_machine *machine, const char *board ) |
| 151 | 151 | { |
| 152 | nes_state *state = | |
| 152 | nes_state *state = | |
| 153 | 153 | const unif *unif_board = nes_unif_lookup(board); |
| 154 | 154 | |
| 155 | 155 | logerror("%s\n", board); |
| r8714 | r8715 | |
|---|---|---|
| 82 | 82 | |
| 83 | 83 | DRIVER_INIT( mz700 ) |
| 84 | 84 | { |
| 85 | mz_state *mz = | |
| 85 | mz_state *mz = | |
| 86 | 86 | mz->mz700 = TRUE; |
| 87 | 87 | mz->mz700_mode = TRUE; |
| 88 | 88 | |
| r8714 | r8715 | |
| 93 | 93 | |
| 94 | 94 | DRIVER_INIT( mz800 ) |
| 95 | 95 | { |
| 96 | mz_state *mz = | |
| 96 | mz_state *mz = | |
| 97 | 97 | mz->mz700 = FALSE; |
| 98 | 98 | mz->mz700_mode = FALSE; |
| 99 | 99 | |
| r8714 | r8715 | |
| 108 | 108 | |
| 109 | 109 | MACHINE_START( mz700 ) |
| 110 | 110 | { |
| 111 | mz_state *mz = | |
| 111 | mz_state *mz = | |
| 112 | 112 | |
| 113 | 113 | mz->pit = machine->device("pit8253"); |
| 114 | 114 | mz->ppi = machine->device("ppi8255"); |
| r8714 | r8715 | |
| 124 | 124 | |
| 125 | 125 | static READ8_HANDLER( mz700_e008_r ) |
| 126 | 126 | { |
| 127 | mz_state *mz = | |
| 127 | mz_state *mz = | |
| 128 | 128 | UINT8 data = 0; |
| 129 | 129 | |
| 130 | 130 | data |= mz->other_timer; |
| r8714 | r8715 | |
| 138 | 138 | |
| 139 | 139 | static WRITE8_HANDLER( mz700_e008_w ) |
| 140 | 140 | { |
| 141 | mz_state *mz = | |
| 141 | mz_state *mz = | |
| 142 | 142 | pit8253_gate0_w(mz->pit, BIT(data, 0)); |
| 143 | 143 | } |
| 144 | 144 | |
| r8714 | r8715 | |
| 150 | 150 | READ8_HANDLER( mz800_bank_0_r ) |
| 151 | 151 | { |
| 152 | 152 | const address_space *spc = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 153 | mz_state *mz = | |
| 153 | mz_state *mz = | |
| 154 | 154 | |
| 155 | 155 | /* switch in cgrom */ |
| 156 | 156 | memory_install_read_bank(spc, 0x1000, 0x1fff, 0, 0, "bank2"); |
| r8714 | r8715 | |
| 206 | 206 | READ8_HANDLER( mz800_bank_1_r ) |
| 207 | 207 | { |
| 208 | 208 | const address_space *spc = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 209 | mz_state *mz = | |
| 209 | mz_state *mz = | |
| 210 | 210 | |
| 211 | 211 | /* switch in ram from 0x1000 to 0x1fff */ |
| 212 | 212 | memory_install_readwrite_bank(spc, 0x1000, 0x1fff, 0x1000, 0, "bank2"); |
| r8714 | r8715 | |
| 231 | 231 | WRITE8_HANDLER( mz700_bank_1_w ) |
| 232 | 232 | { |
| 233 | 233 | const address_space *spc = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 234 | mz_state *mz = | |
| 234 | mz_state *mz = | |
| 235 | 235 | |
| 236 | 236 | if (mz->mz700_mode) |
| 237 | 237 | { |
| r8714 | r8715 | |
| 267 | 267 | WRITE8_HANDLER( mz700_bank_3_w ) |
| 268 | 268 | { |
| 269 | 269 | const address_space *spc = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 270 | mz_state *mz = | |
| 270 | mz_state *mz = | |
| 271 | 271 | |
| 272 | 272 | if (mz->mz700_mode) |
| 273 | 273 | { |
| r8714 | r8715 | |
| 314 | 314 | WRITE8_HANDLER( mz700_bank_4_w ) |
| 315 | 315 | { |
| 316 | 316 | const address_space *spc = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 317 | mz_state *mz = | |
| 317 | mz_state *mz = | |
| 318 | 318 | |
| 319 | 319 | if (mz->mz700_mode) |
| 320 | 320 | { |
| r8714 | r8715 | |
| 371 | 371 | WRITE8_HANDLER( mz700_bank_5_w ) |
| 372 | 372 | { |
| 373 | 373 | const address_space *spc = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 374 | mz_state *mz = | |
| 374 | mz_state *mz = | |
| 375 | 375 | |
| 376 | 376 | if (mz->mz700_mode) |
| 377 | 377 | { |
| r8714 | r8715 | |
| 389 | 389 | |
| 390 | 390 | WRITE8_HANDLER( mz700_bank_6_w ) |
| 391 | 391 | { |
| 392 | mz_state *mz = | |
| 392 | mz_state *mz = | |
| 393 | 393 | |
| 394 | 394 | if (mz->mz700_mode) |
| 395 | 395 | { |
| r8714 | r8715 | |
| 433 | 433 | /* timer 2 is the AM/PM (12 hour) interrupt */ |
| 434 | 434 | static WRITE_LINE_DEVICE_HANDLER( pit_irq_2 ) |
| 435 | 435 | { |
| 436 | mz_state *mz = | |
| 436 | mz_state *mz = | |
| 437 | 437 | |
| 438 | 438 | if (mz->intmsk) |
| 439 | 439 | cputag_set_input_line(device->machine, "maincpu", 0, ASSERT_LINE); |
| r8714 | r8715 | |
| 475 | 475 | static READ8_DEVICE_HANDLER( pio_port_c_r ) |
| 476 | 476 | { |
| 477 | 477 | running_device *cas = device->machine->device("cassette"); |
| 478 | mz_state *mz = | |
| 478 | mz_state *mz = | |
| 479 | 479 | UINT8 data = 0; |
| 480 | 480 | |
| 481 | 481 | /* note: this is actually connected to Q output of the motor-control flip-flop (see below) */ |
| r8714 | r8715 | |
| 644 | 644 | */ |
| 645 | 645 | WRITE8_HANDLER( mz800_display_mode_w ) |
| 646 | 646 | { |
| 647 | mz_state *mz = | |
| 647 | mz_state *mz = | |
| 648 | 648 | |
| 649 | 649 | mz->mz700_mode = BIT(data, 3); |
| 650 | 650 | mz->hires_mode = BIT(data, 2); |
| r8714 | r8715 | |
|---|---|---|
| 167 | 167 | |
| 168 | 168 | WRITE8_HANDLER( nes_chr_w ) |
| 169 | 169 | { |
| 170 | nes_state *state = | |
| 170 | nes_state *state = | |
| 171 | 171 | int bank = offset >> 10; |
| 172 | 172 | |
| 173 | 173 | if (state->chr_map[bank].source == CHRRAM) |
| r8714 | r8715 | |
| 178 | 178 | |
| 179 | 179 | READ8_HANDLER( nes_chr_r ) |
| 180 | 180 | { |
| 181 | nes_state *state = | |
| 181 | nes_state *state = | |
| 182 | 182 | int bank = offset >> 10; |
| 183 | 183 | |
| 184 | 184 | // a few CNROM boards contained copy protection schemes through |
| r8714 | r8715 | |
| 193 | 193 | |
| 194 | 194 | WRITE8_HANDLER( nes_nt_w ) |
| 195 | 195 | { |
| 196 | nes_state *state = | |
| 196 | nes_state *state = | |
| 197 | 197 | int page = ((offset & 0xc00) >> 10); |
| 198 | 198 | |
| 199 | 199 | if (state->nt_page[page].writable == 0) |
| r8714 | r8715 | |
| 204 | 204 | |
| 205 | 205 | READ8_HANDLER( nes_nt_r ) |
| 206 | 206 | { |
| 207 | nes_state *state = | |
| 207 | nes_state *state = | |
| 208 | 208 | int page = ((offset & 0xc00) >> 10); |
| 209 | 209 | |
| 210 | 210 | if (state->nt_page[page].source == MMC5FILL) |
| r8714 | r8715 | |
| 219 | 219 | |
| 220 | 220 | WRITE8_HANDLER( nes_low_mapper_w ) |
| 221 | 221 | { |
| 222 | nes_state *state = | |
| 222 | nes_state *state = | |
| 223 | 223 | |
| 224 | 224 | if (state->mmc_write_low) |
| 225 | 225 | (*state->mmc_write_low)(space, offset, data); |
| r8714 | r8715 | |
| 229 | 229 | |
| 230 | 230 | READ8_HANDLER( nes_low_mapper_r ) |
| 231 | 231 | { |
| 232 | nes_state *state = | |
| 232 | nes_state *state = | |
| 233 | 233 | |
| 234 | 234 | if (state->mmc_read_low) |
| 235 | 235 | return (*state->mmc_read_low)(space, offset); |
| r8714 | r8715 | |
| 247 | 247 | |
| 248 | 248 | static void wram_bank( running_machine *machine, int bank, int source ) |
| 249 | 249 | { |
| 250 | nes_state *state = | |
| 250 | nes_state *state = | |
| 251 | 251 | |
| 252 | 252 | assert(state->battery || state->prg_ram); |
| 253 | 253 | if (source == NES_BATTERY) |
| r8714 | r8715 | |
| 265 | 265 | |
| 266 | 266 | INLINE void prg_bank_refresh( running_machine *machine ) |
| 267 | 267 | { |
| 268 | nes_state *state = | |
| 268 | nes_state *state = | |
| 269 | 269 | memory_set_bank(machine, "bank1", state->prg_bank[0]); |
| 270 | 270 | memory_set_bank(machine, "bank2", state->prg_bank[1]); |
| 271 | 271 | memory_set_bank(machine, "bank3", state->prg_bank[2]); |
| r8714 | r8715 | |
| 276 | 276 | |
| 277 | 277 | static void prg32( running_machine *machine, int bank ) |
| 278 | 278 | { |
| 279 | nes_state *state = | |
| 279 | nes_state *state = | |
| 280 | 280 | |
| 281 | 281 | /* assumes that bank references a 32k chunk */ |
| 282 | 282 | bank &= ((state->prg_chunks >> 1) - 1); |
| r8714 | r8715 | |
| 290 | 290 | |
| 291 | 291 | static void prg16_89ab( running_machine *machine, int bank ) |
| 292 | 292 | { |
| 293 | nes_state *state = | |
| 293 | nes_state *state = | |
| 294 | 294 | |
| 295 | 295 | /* assumes that bank references a 16k chunk */ |
| 296 | 296 | bank &= (state->prg_chunks - 1); |
| r8714 | r8715 | |
| 302 | 302 | |
| 303 | 303 | static void prg16_cdef( running_machine *machine, int bank ) |
| 304 | 304 | { |
| 305 | nes_state *state = | |
| 305 | nes_state *state = | |
| 306 | 306 | |
| 307 | 307 | /* assumes that bank references a 16k chunk */ |
| 308 | 308 | bank &= (state->prg_chunks - 1); |
| r8714 | r8715 | |
| 314 | 314 | |
| 315 | 315 | static void prg8_89( running_machine *machine, int bank ) |
| 316 | 316 | { |
| 317 | nes_state *state = | |
| 317 | nes_state *state = | |
| 318 | 318 | |
| 319 | 319 | /* assumes that bank references an 8k chunk */ |
| 320 | 320 | bank &= ((state->prg_chunks << 1) - 1); |
| r8714 | r8715 | |
| 325 | 325 | |
| 326 | 326 | static void prg8_ab( running_machine *machine, int bank ) |
| 327 | 327 | { |
| 328 | nes_state *state = | |
| 328 | nes_state *state = | |
| 329 | 329 | |
| 330 | 330 | /* assumes that bank references an 8k chunk */ |
| 331 | 331 | bank &= ((state->prg_chunks << 1) - 1); |
| r8714 | r8715 | |
| 336 | 336 | |
| 337 | 337 | static void prg8_cd( running_machine *machine, int bank ) |
| 338 | 338 | { |
| 339 | nes_state *state = | |
| 339 | nes_state *state = | |
| 340 | 340 | |
| 341 | 341 | /* assumes that bank references an 8k chunk */ |
| 342 | 342 | bank &= ((state->prg_chunks << 1) - 1); |
| r8714 | r8715 | |
| 347 | 347 | |
| 348 | 348 | static void prg8_ef( running_machine *machine, int bank ) |
| 349 | 349 | { |
| 350 | nes_state *state = | |
| 350 | nes_state *state = | |
| 351 | 351 | |
| 352 | 352 | /* assumes that bank references an 8k chunk */ |
| 353 | 353 | bank &= ((state->prg_chunks << 1) - 1); |
| r8714 | r8715 | |
| 361 | 361 | |
| 362 | 362 | static void prg8_67( running_machine *machine, int bank ) |
| 363 | 363 | { |
| 364 | nes_state *state = | |
| 364 | nes_state *state = | |
| 365 | 365 | |
| 366 | 366 | /* assumes that bank references an 8k chunk */ |
| 367 | 367 | bank &= ((state->prg_chunks << 1) - 1); |
| r8714 | r8715 | |
| 373 | 373 | /* We also define an additional helper to map 8k PRG-ROM to one of the banks (passed as parameter) */ |
| 374 | 374 | static void prg8_x( running_machine *machine, int start, int bank ) |
| 375 | 375 | { |
| 376 | nes_state *state = | |
| 376 | nes_state *state = | |
| 377 | 377 | |
| 378 | 378 | assert(start < 4); |
| 379 | 379 | |
| r8714 | r8715 | |
| 389 | 389 | // this can be probably removed later, but it is useful while testing xml and unf handling with VRAM & VROM |
| 390 | 390 | INLINE void chr_sanity_check( running_machine *machine, int source ) |
| 391 | 391 | { |
| 392 | nes_state *state = | |
| 392 | nes_state *state = | |
| 393 | 393 | |
| 394 | 394 | if (source == CHRRAM && state->vram == NULL) |
| 395 | 395 | fatalerror("CHRRAM bankswitch with no VRAM"); |
| r8714 | r8715 | |
| 400 | 400 | |
| 401 | 401 | static void chr8( running_machine *machine, int bank, int source ) |
| 402 | 402 | { |
| 403 | nes_state *state = | |
| 403 | nes_state *state = | |
| 404 | 404 | int i; |
| 405 | 405 | |
| 406 | 406 | chr_sanity_check(machine, source); |
| r8714 | r8715 | |
| 429 | 429 | |
| 430 | 430 | static void chr4_x( running_machine *machine, int start, int bank, int source ) |
| 431 | 431 | { |
| 432 | nes_state *state = | |
| 432 | nes_state *state = | |
| 433 | 433 | int i; |
| 434 | 434 | |
| 435 | 435 | chr_sanity_check(machine, source); |
| r8714 | r8715 | |
| 468 | 468 | |
| 469 | 469 | static void chr2_x( running_machine *machine, int start, int bank, int source ) |
| 470 | 470 | { |
| 471 | nes_state *state = | |
| 471 | nes_state *state = | |
| 472 | 472 | int i; |
| 473 | 473 | |
| 474 | 474 | chr_sanity_check(machine, source); |
| r8714 | r8715 | |
| 517 | 517 | |
| 518 | 518 | static void chr1_x( running_machine *machine, int start, int bank, int source ) |
| 519 | 519 | { |
| 520 | nes_state *state = | |
| 520 | nes_state *state = | |
| 521 | 521 | |
| 522 | 522 | chr_sanity_check(machine, source); |
| 523 | 523 | |
| r8714 | r8715 | |
| 582 | 582 | |
| 583 | 583 | static void set_nt_page( running_machine *machine, int page, int source, int bank, int writable ) |
| 584 | 584 | { |
| 585 | nes_state *state = | |
| 585 | nes_state *state = | |
| 586 | 586 | UINT8* base_ptr; |
| 587 | 587 | |
| 588 | 588 | switch (source) |
| r8714 | r8715 | |
|---|---|---|
| 47 | 47 | |
| 48 | 48 | WRITE8_HANDLER( pc88_rtc_w ) |
| 49 | 49 | { |
| 50 | pc88_state *state = | |
| 50 | pc88_state *state = | |
| 51 | 51 | |
| 52 | 52 | /* real time clock */ |
| 53 | 53 | upd1990a_c0_w(state->upd1990a, BIT(data, 0)); |
| r8714 | r8715 | |
| 143 | 143 | { |
| 144 | 144 | /* bit 3,4,6 not implemented */ |
| 145 | 145 | /* bit 7 incorrect behavior */ |
| 146 | pc88_state *state = | |
| 146 | pc88_state *state = | |
| 147 | 147 | running_device *speaker = space->machine->device("beep"); |
| 148 | 148 | |
| 149 | 149 | /* printer */ |
| r8714 | r8715 | |
| 175 | 175 | READ8_HANDLER( pc88sr_inport_40 ) |
| 176 | 176 | { |
| 177 | 177 | /* bit 2 not implemented */ |
| 178 | pc88_state *state = | |
| 178 | pc88_state *state = | |
| 179 | 179 | UINT8 r; |
| 180 | 180 | |
| 181 | 181 | r = centronics_busy_r(state->centronics); |
| r8714 | r8715 | |
| 679 | 679 | |
| 680 | 680 | static READ8_DEVICE_HANDLER( cpu_8255_c_r ) |
| 681 | 681 | { |
| 682 | pc88_state *state = | |
| 682 | pc88_state *state = | |
| 683 | 683 | |
| 684 | 684 | return state->i8255_1_pc >> 4; |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | static WRITE8_DEVICE_HANDLER( cpu_8255_c_w ) |
| 688 | 688 | { |
| 689 | pc88_state *state = | |
| 689 | pc88_state *state = | |
| 690 | 690 | |
| 691 | 691 | state->i8255_0_pc = data; |
| 692 | 692 | } |
| r8714 | r8715 | |
| 703 | 703 | |
| 704 | 704 | static READ8_DEVICE_HANDLER( fdc_8255_c_r ) |
| 705 | 705 | { |
| 706 | pc88_state *state = | |
| 706 | pc88_state *state = | |
| 707 | 707 | |
| 708 | 708 | return state->i8255_0_pc >> 4; |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | static WRITE8_DEVICE_HANDLER( fdc_8255_c_w ) |
| 712 | 712 | { |
| 713 | pc88_state *state = | |
| 713 | pc88_state *state = | |
| 714 | 714 | |
| 715 | 715 | state->i8255_1_pc = data; |
| 716 | 716 | } |
| r8714 | r8715 | |
| 727 | 727 | |
| 728 | 728 | static TIMER_CALLBACK( pc8801fd_upd765_tc_to_zero ) |
| 729 | 729 | { |
| 730 | pc88_state *state = | |
| 730 | pc88_state *state = | |
| 731 | 731 | |
| 732 | 732 | upd765_tc_w(state->upd765, 0); |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | READ8_HANDLER( pc8801fd_upd765_tc ) |
| 736 | 736 | { |
| 737 | pc88_state *state = | |
| 737 | pc88_state *state = | |
| 738 | 738 | |
| 739 | 739 | upd765_tc_w(state->upd765, 1); |
| 740 | 740 | timer_set(space->machine, attotime_zero, NULL, 0, pc8801fd_upd765_tc_to_zero ); |
| r8714 | r8715 | |
| 790 | 790 | |
| 791 | 791 | READ8_HANDLER( pc88_kanji_r ) |
| 792 | 792 | { |
| 793 | pc88_state *state = | |
| 793 | pc88_state *state = | |
| 794 | 794 | |
| 795 | 795 | UINT8 *kanji = memory_region(space->machine, "gfx1"); |
| 796 | 796 | UINT32 addr = (state->kanji << 1) | !offset; |
| r8714 | r8715 | |
| 800 | 800 | |
| 801 | 801 | WRITE8_HANDLER( pc88_kanji_w ) |
| 802 | 802 | { |
| 803 | pc88_state *state = | |
| 803 | pc88_state *state = | |
| 804 | 804 | |
| 805 | 805 | switch (offset) |
| 806 | 806 | { |
| r8714 | r8715 | |
| 816 | 816 | |
| 817 | 817 | READ8_HANDLER( pc88_kanji2_r ) |
| 818 | 818 | { |
| 819 | pc88_state *state = | |
| 819 | pc88_state *state = | |
| 820 | 820 | |
| 821 | 821 | UINT8 *kanji2 = memory_region(space->machine, "kanji2"); |
| 822 | 822 | UINT32 addr = (state->kanji2 << 1) | !offset; |
| r8714 | r8715 | |
| 826 | 826 | |
| 827 | 827 | WRITE8_HANDLER( pc88_kanji2_w ) |
| 828 | 828 | { |
| 829 | pc88_state *state = | |
| 829 | pc88_state *state = | |
| 830 | 830 | |
| 831 | 831 | switch (offset) |
| 832 | 832 | { |
| r8714 | r8715 | |
| 844 | 844 | |
| 845 | 845 | MACHINE_START( pc88srl ) |
| 846 | 846 | { |
| 847 | pc88_state *state = | |
| 847 | pc88_state *state = | |
| 848 | 848 | |
| 849 | 849 | /* find devices */ |
| 850 | 850 | state->upd765 = machine->device(UPD765_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 30 | 30 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 31 | 31 | static void ffe_irq( running_device *device, int scanline, int vblank, int blanked ) |
| 32 | 32 | { |
| 33 | nes_state *state = | |
| 33 | nes_state *state = | |
| 34 | 34 | |
| 35 | 35 | /* 114 is the number of cycles per scanline */ |
| 36 | 36 | /* TODO: change to reflect the actual number of cycles spent */ |
| r8714 | r8715 | |
| 48 | 48 | |
| 49 | 49 | static WRITE8_HANDLER( mapper6_l_w ) |
| 50 | 50 | { |
| 51 | nes_state *state = | |
| 51 | nes_state *state = | |
| 52 | 52 | LOG_MMC(("mapper6_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 53 | 53 | |
| 54 | 54 | switch (offset) |
| r8714 | r8715 | |
| 76 | 76 | |
| 77 | 77 | static WRITE8_HANDLER( mapper6_w ) |
| 78 | 78 | { |
| 79 | nes_state *state = | |
| 79 | nes_state *state = | |
| 80 | 80 | LOG_MMC(("mapper6_w, offset: %04x, data: %02x\n", offset, data)); |
| 81 | 81 | |
| 82 | 82 | if (!state->mmc_latch1) // when in "FFE mode" we are forced to use CHRRAM/EXRAM bank? |
| r8714 | r8715 | |
| 124 | 124 | |
| 125 | 125 | static WRITE8_HANDLER( mapper17_l_w ) |
| 126 | 126 | { |
| 127 | nes_state *state = | |
| 127 | nes_state *state = | |
| 128 | 128 | LOG_MMC(("mapper17_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 129 | 129 | |
| 130 | 130 | switch (offset) |
| r8714 | r8715 | |
|---|---|---|
| 115 | 115 | |
| 116 | 116 | READ8_DEVICE_HANDLER( mtx_sound_strobe_r ) |
| 117 | 117 | { |
| 118 | mtx_state *state = | |
| 118 | mtx_state *state = | |
| 119 | 119 | |
| 120 | 120 | sn76496_w(device, 0, state->sound_latch); |
| 121 | 121 | |
| r8714 | r8715 | |
| 128 | 128 | |
| 129 | 129 | WRITE8_HANDLER( mtx_sound_latch_w ) |
| 130 | 130 | { |
| 131 | mtx_state *state = | |
| 131 | mtx_state *state = | |
| 132 | 132 | |
| 133 | 133 | state->sound_latch = data; |
| 134 | 134 | } |
| r8714 | r8715 | |
| 189 | 189 | |
| 190 | 190 | WRITE8_HANDLER( mtx_sense_w ) |
| 191 | 191 | { |
| 192 | mtx_state *state = | |
| 192 | mtx_state *state = | |
| 193 | 193 | |
| 194 | 194 | state->key_sense = data; |
| 195 | 195 | } |
| r8714 | r8715 | |
| 200 | 200 | |
| 201 | 201 | READ8_HANDLER( mtx_key_lo_r ) |
| 202 | 202 | { |
| 203 | mtx_state *state = | |
| 203 | mtx_state *state = | |
| 204 | 204 | |
| 205 | 205 | UINT8 data = 0xff; |
| 206 | 206 | |
| r8714 | r8715 | |
| 222 | 222 | |
| 223 | 223 | READ8_HANDLER( mtx_key_hi_r ) |
| 224 | 224 | { |
| 225 | mtx_state *state = | |
| 225 | mtx_state *state = | |
| 226 | 226 | |
| 227 | 227 | UINT8 data = input_port_read(space->machine, "country_code"); |
| 228 | 228 | |
| r8714 | r8715 | |
| 338 | 338 | |
| 339 | 339 | static void mtx_tms9929a_interrupt(running_machine *machine, int data) |
| 340 | 340 | { |
| 341 | mtx_state *state = | |
| 341 | mtx_state *state = | |
| 342 | 342 | |
| 343 | 343 | z80ctc_trg0_w(state->z80ctc, data ? 0 : 1); |
| 344 | 344 | } |
| r8714 | r8715 | |
| 403 | 403 | |
| 404 | 404 | MACHINE_START( mtx512 ) |
| 405 | 405 | { |
| 406 | mtx_state *state = | |
| 406 | mtx_state *state = | |
| 407 | 407 | running_device *messram = machine->device("messram"); |
| 408 | 408 | |
| 409 | 409 | /* find devices */ |
| r8714 | r8715 | |
|---|---|---|
| 122 | 122 | /* Loads the battery backed RAM into the appropriate memory area */ |
| 123 | 123 | static void snes_load_sram(running_machine *machine) |
| 124 | 124 | { |
| 125 | snes_state *state = | |
| 125 | snes_state *state = | |
| 126 | 126 | UINT8 ii; |
| 127 | 127 | UINT8 *battery_ram, *ptr; |
| 128 | 128 | |
| r8714 | r8715 | |
| 172 | 172 | /* Saves the battery backed RAM from the appropriate memory area */ |
| 173 | 173 | static void snes_save_sram(running_machine *machine) |
| 174 | 174 | { |
| 175 | snes_state *state = | |
| 175 | snes_state *state = | |
| 176 | 176 | UINT8 ii; |
| 177 | 177 | UINT8 *battery_ram, *ptr; |
| 178 | 178 | |
| r8714 | r8715 | |
| 213 | 213 | |
| 214 | 214 | static void snes_machine_stop(running_machine &machine) |
| 215 | 215 | { |
| 216 | snes_state *state = | |
| 216 | snes_state *state = | |
| 217 | 217 | |
| 218 | 218 | /* Save SRAM */ |
| 219 | 219 | if (state->cart[0].sram > 0) |
| r8714 | r8715 | |
| 258 | 258 | |
| 259 | 259 | static void sufami_machine_stop(running_machine &machine) |
| 260 | 260 | { |
| 261 | snes_state *state = | |
| 261 | snes_state *state = | |
| 262 | 262 | UINT8 ii; |
| 263 | 263 | UINT8 *battery_ram, *ptr; |
| 264 | 264 | |
| r8714 | r8715 | |
| 453 | 453 | detect BSX and ST carts) */ |
| 454 | 454 | static UINT32 snes_find_hilo_mode( device_image_interface &image, UINT8 *buffer, UINT32 offset, int cartid ) |
| 455 | 455 | { |
| 456 | snes_state *state = | |
| 456 | snes_state *state = | |
| 457 | 457 | UINT8 valid_mode20, valid_mode21, valid_mode25; |
| 458 | 458 | UINT32 retvalue; |
| 459 | 459 | |
| r8714 | r8715 | |
| 503 | 503 | |
| 504 | 504 | static int snes_find_addon_chip( running_machine *machine ) |
| 505 | 505 | { |
| 506 | snes_state *state = | |
| 506 | snes_state *state = | |
| 507 | 507 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 508 | 508 | int supported_type = 1; |
| 509 | 509 | |
| r8714 | r8715 | |
| 629 | 629 | |
| 630 | 630 | static void snes_cart_log_info( running_machine *machine, int total_blocks, int supported ) |
| 631 | 631 | { |
| 632 | snes_state *state = | |
| 632 | snes_state *state = | |
| 633 | 633 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 634 | 634 | char title[21], rom_id[4], company_id[2]; |
| 635 | 635 | int i, company, has_ram = 0, has_sram = 0; |
| r8714 | r8715 | |
| 706 | 706 | { |
| 707 | 707 | int supported_type = 1, i, j; |
| 708 | 708 | running_machine *machine = image.device().machine; |
| 709 | snes_state *state = | |
| 709 | snes_state *state = | |
| 710 | 710 | const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM ); |
| 711 | 711 | int total_blocks, read_blocks, has_bsx_slot = 0, st_bios = 0; |
| 712 | 712 | UINT32 offset, int_header_offs; |
| r8714 | r8715 | |
| 1071 | 1071 | static DEVICE_IMAGE_LOAD( sufami_cart ) |
| 1072 | 1072 | { |
| 1073 | 1073 | running_machine *machine = image.device().machine; |
| 1074 | snes_state *state = | |
| 1074 | snes_state *state = | |
| 1075 | 1075 | int total_blocks, read_blocks; |
| 1076 | 1076 | int st_bios = 0, slot_id = 0; |
| 1077 | 1077 | UINT32 offset, st_data_offset = 0; |
| r8714 | r8715 | |
| 1176 | 1176 | static DEVICE_IMAGE_LOAD( bsx_cart ) |
| 1177 | 1177 | { |
| 1178 | 1178 | running_machine *machine = image.device().machine; |
| 1179 | snes_state *state = | |
| 1179 | snes_state *state = | |
| 1180 | 1180 | int total_blocks, read_blocks; |
| 1181 | 1181 | int has_bsx_slot = 0; |
| 1182 | 1182 | UINT32 offset, int_header_offs; |
| r8714 | r8715 | |
| 1278 | 1278 | static DEVICE_IMAGE_LOAD( bsx2slot_cart ) |
| 1279 | 1279 | { |
| 1280 | 1280 | running_machine *machine = image.device().machine; |
| 1281 | snes_state *state = | |
| 1281 | snes_state *state = | |
| 1282 | 1282 | UINT32 offset, int_header_offs; |
| 1283 | 1283 | UINT8 *ROM = memory_region(image.device().machine, "flash"); |
| 1284 | 1284 | |
| r8714 | r8715 | |
| 1384 | 1384 | |
| 1385 | 1385 | DRIVER_INIT( snesst ) |
| 1386 | 1386 | { |
| 1387 | snes_state *state = | |
| 1387 | snes_state *state = | |
| 1388 | 1388 | UINT8 *STBIOS = memory_region(machine, "sufami"); |
| 1389 | 1389 | int i, j; |
| 1390 | 1390 |
| r8714 | r8715 | |
|---|---|---|
| 72 | 72 | |
| 73 | 73 | WRITE8_HANDLER(pc_page_w) |
| 74 | 74 | { |
| 75 | pc_state *st = | |
| 75 | pc_state *st = | |
| 76 | 76 | switch(offset % 4) |
| 77 | 77 | { |
| 78 | 78 | case 1: |
| r8714 | r8715 | |
| 90 | 90 | |
| 91 | 91 | static WRITE_LINE_DEVICE_HANDLER( pc_dma_hrq_changed ) |
| 92 | 92 | { |
| 93 | pc_state *st = | |
| 93 | pc_state *st = | |
| 94 | 94 | cpu_set_input_line(st->maincpu, INPUT_LINE_HALT, state ? ASSERT_LINE : CLEAR_LINE); |
| 95 | 95 | |
| 96 | 96 | /* Assert HLDA */ |
| r8714 | r8715 | |
| 101 | 101 | static READ8_HANDLER( pc_dma_read_byte ) |
| 102 | 102 | { |
| 103 | 103 | UINT8 result; |
| 104 | pc_state *st = | |
| 104 | pc_state *st = | |
| 105 | 105 | offs_t page_offset = (((offs_t) st->dma_offset[0][st->dma_channel]) << 16) |
| 106 | 106 | & 0x0F0000; |
| 107 | 107 | |
| r8714 | r8715 | |
| 112 | 112 | |
| 113 | 113 | static WRITE8_HANDLER( pc_dma_write_byte ) |
| 114 | 114 | { |
| 115 | pc_state *st = | |
| 115 | pc_state *st = | |
| 116 | 116 | offs_t page_offset = (((offs_t) st->dma_offset[0][st->dma_channel]) << 16) |
| 117 | 117 | & 0x0F0000; |
| 118 | 118 | |
| r8714 | r8715 | |
| 146 | 146 | |
| 147 | 147 | static WRITE8_DEVICE_HANDLER( pc_dma8237_0_dack_w ) |
| 148 | 148 | { |
| 149 | pc_state *st = | |
| 149 | pc_state *st = | |
| 150 | 150 | st->u73_q2 = 0; |
| 151 | 151 | i8237_dreq0_w( st->dma8237, st->u73_q2 ); |
| 152 | 152 | } |
| r8714 | r8715 | |
| 159 | 159 | |
| 160 | 160 | static void set_dma_channel(running_device *device, int channel, int state) |
| 161 | 161 | { |
| 162 | pc_state *st = | |
| 162 | pc_state *st = | |
| 163 | 163 | |
| 164 | 164 | if (!state) st->dma_channel = channel; |
| 165 | 165 | } |
| r8714 | r8715 | |
| 240 | 240 | *************************************************************************/ |
| 241 | 241 | UINT8 pc_speaker_get_spk(running_machine *machine) |
| 242 | 242 | { |
| 243 | pc_state *st = | |
| 243 | pc_state *st = | |
| 244 | 244 | return st->pc_spkrdata & st->pc_input; |
| 245 | 245 | } |
| 246 | 246 | |
| r8714 | r8715 | |
| 248 | 248 | void pc_speaker_set_spkrdata(running_machine *machine, UINT8 data) |
| 249 | 249 | { |
| 250 | 250 | running_device *speaker = machine->device("speaker"); |
| 251 | pc_state *st = | |
| 251 | pc_state *st = | |
| 252 | 252 | st->pc_spkrdata = data ? 1 : 0; |
| 253 | 253 | speaker_level_w( speaker, pc_speaker_get_spk(machine) ); |
| 254 | 254 | } |
| r8714 | r8715 | |
| 257 | 257 | void pc_speaker_set_input(running_machine *machine, UINT8 data) |
| 258 | 258 | { |
| 259 | 259 | running_device *speaker = machine->device("speaker"); |
| 260 | pc_state *st = | |
| 260 | pc_state *st = | |
| 261 | 261 | st->pc_input = data ? 1 : 0; |
| 262 | 262 | speaker_level_w( speaker, pc_speaker_get_spk(machine) ); |
| 263 | 263 | } |
| r8714 | r8715 | |
| 271 | 271 | |
| 272 | 272 | static WRITE_LINE_DEVICE_HANDLER( ibm5150_pit8253_out1_changed ) |
| 273 | 273 | { |
| 274 | pc_state *st = | |
| 274 | pc_state *st = | |
| 275 | 275 | /* Trigger DMA channel #0 */ |
| 276 | 276 | if ( st->out1 == 0 && state == 1 && st->u73_q2 == 0 ) |
| 277 | 277 | { |
| r8714 | r8715 | |
| 342 | 342 | /* called when a interrupt is set/cleared from com hardware */ |
| 343 | 343 | static INS8250_INTERRUPT( pc_com_interrupt_1 ) |
| 344 | 344 | { |
| 345 | pc_state *st = | |
| 345 | pc_state *st = | |
| 346 | 346 | pic8259_ir4_w(st->pic8259, state); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | static INS8250_INTERRUPT( pc_com_interrupt_2 ) |
| 350 | 350 | { |
| 351 | pc_state *st = | |
| 351 | pc_state *st = | |
| 352 | 352 | pic8259_ir3_w(st->pic8259, state); |
| 353 | 353 | } |
| 354 | 354 | |
| r8714 | r8715 | |
| 486 | 486 | |
| 487 | 487 | static void pcjr_set_keyb_int(running_machine *machine, int state) |
| 488 | 488 | { |
| 489 | pc_state *st = | |
| 489 | pc_state *st = | |
| 490 | 490 | if ( state ) |
| 491 | 491 | { |
| 492 | 492 | UINT8 data = pc_keyb_read(); |
| r8714 | r8715 | |
| 602 | 602 | { |
| 603 | 603 | int data = 0xFF; |
| 604 | 604 | running_machine *machine = device->machine; |
| 605 | pc_state *st = | |
| 605 | pc_state *st = | |
| 606 | 606 | |
| 607 | 607 | /* KB port A */ |
| 608 | 608 | if (st->ppi_keyboard_clear) |
| r8714 | r8715 | |
| 655 | 655 | |
| 656 | 656 | static READ8_DEVICE_HANDLER ( ibm5150_ppi_portc_r ) |
| 657 | 657 | { |
| 658 | pc_state *st = | |
| 658 | pc_state *st = | |
| 659 | 659 | int timer2_output = pit8253_get_output( st->pit8253, 2 ); |
| 660 | 660 | int data=0xff; |
| 661 | 661 | running_machine *machine = device->machine; |
| r8714 | r8715 | |
| 735 | 735 | |
| 736 | 736 | static WRITE8_DEVICE_HANDLER ( ibm5150_ppi_portb_w ) |
| 737 | 737 | { |
| 738 | pc_state *st = | |
| 738 | pc_state *st = | |
| 739 | 739 | running_device *keyboard = device->machine->device("keyboard"); |
| 740 | 740 | |
| 741 | 741 | /* KB controller port B */ |
| r8714 | r8715 | |
| 772 | 772 | |
| 773 | 773 | WRITE8_HANDLER( ibm5150_kb_set_clock_signal ) |
| 774 | 774 | { |
| 775 | pc_state *st = | |
| 775 | pc_state *st = | |
| 776 | 776 | running_device *keyboard = space->machine->device("keyboard"); |
| 777 | 777 | |
| 778 | 778 | if ( st->ppi_clock_signal != data ) |
| r8714 | r8715 | |
| 806 | 806 | |
| 807 | 807 | WRITE8_HANDLER( ibm5150_kb_set_data_signal ) |
| 808 | 808 | { |
| 809 | pc_state *st = | |
| 809 | pc_state *st = | |
| 810 | 810 | running_device *keyboard = space->machine->device("keyboard"); |
| 811 | 811 | |
| 812 | 812 | st->ppi_data_signal = data; |
| r8714 | r8715 | |
| 832 | 832 | { |
| 833 | 833 | int data = 0xFF; |
| 834 | 834 | running_machine *machine = device->machine; |
| 835 | pc_state *st = | |
| 835 | pc_state *st = | |
| 836 | 836 | |
| 837 | 837 | /* KB port A */ |
| 838 | 838 | if (st->ppi_keyboard_clear) |
| r8714 | r8715 | |
| 859 | 859 | |
| 860 | 860 | static READ8_DEVICE_HANDLER ( ibm5160_ppi_portc_r ) |
| 861 | 861 | { |
| 862 | pc_state *st = | |
| 862 | pc_state *st = | |
| 863 | 863 | int timer2_output = pit8253_get_output( st->pit8253, 2 ); |
| 864 | 864 | int data=0xff; |
| 865 | 865 | running_machine *machine = device->machine; |
| r8714 | r8715 | |
| 893 | 893 | |
| 894 | 894 | static WRITE8_DEVICE_HANDLER( ibm5160_ppi_portb_w ) |
| 895 | 895 | { |
| 896 | pc_state *st = | |
| 896 | pc_state *st = | |
| 897 | 897 | running_device *keyboard = device->machine->device("keyboard"); |
| 898 | 898 | |
| 899 | 899 | /* PPI controller port B*/ |
| r8714 | r8715 | |
| 932 | 932 | { |
| 933 | 933 | int data = 0xFF; |
| 934 | 934 | running_machine *machine = device->machine; |
| 935 | pc_state *st = | |
| 935 | pc_state *st = | |
| 936 | 936 | |
| 937 | 937 | /* KB port A */ |
| 938 | 938 | if (st->ppi_keyboard_clear) |
| r8714 | r8715 | |
| 959 | 959 | |
| 960 | 960 | static WRITE8_DEVICE_HANDLER( pc_ppi_portb_w ) |
| 961 | 961 | { |
| 962 | pc_state *st = | |
| 962 | pc_state *st = | |
| 963 | 963 | /* PPI controller port B*/ |
| 964 | 964 | st->ppi_portb = data; |
| 965 | 965 | st->ppi_portc_switch_high = data & 0x08; |
| r8714 | r8715 | |
| 987 | 987 | |
| 988 | 988 | static WRITE8_DEVICE_HANDLER ( pcjr_ppi_portb_w ) |
| 989 | 989 | { |
| 990 | pc_state *st = | |
| 990 | pc_state *st = | |
| 991 | 991 | /* KB controller port B */ |
| 992 | 992 | st->ppi_portb = data; |
| 993 | 993 | st->ppi_portc_switch_high = data & 0x08; |
| r8714 | r8715 | |
| 1025 | 1025 | */ |
| 1026 | 1026 | static READ8_DEVICE_HANDLER ( pcjr_ppi_portc_r ) |
| 1027 | 1027 | { |
| 1028 | pc_state *st = | |
| 1028 | pc_state *st = | |
| 1029 | 1029 | int timer2_output = pit8253_get_output( device->machine->device("pit8253"), 2 ); |
| 1030 | 1030 | int data=0xff; |
| 1031 | 1031 | |
| r8714 | r8715 | |
| 1080 | 1080 | |
| 1081 | 1081 | static void pc_fdc_interrupt(running_machine *machine, int state) |
| 1082 | 1082 | { |
| 1083 | pc_state *st = | |
| 1083 | pc_state *st = | |
| 1084 | 1084 | if (st->pic8259) |
| 1085 | 1085 | { |
| 1086 | 1086 | pic8259_ir6_w(st->pic8259, state); |
| r8714 | r8715 | |
| 1089 | 1089 | |
| 1090 | 1090 | static void pc_fdc_dma_drq(running_machine *machine, int state, int read_) |
| 1091 | 1091 | { |
| 1092 | pc_state *st = | |
| 1092 | pc_state *st = | |
| 1093 | 1093 | i8237_dreq2_w( st->dma8237, state); |
| 1094 | 1094 | } |
| 1095 | 1095 | |
| r8714 | r8715 | |
| 1118 | 1118 | |
| 1119 | 1119 | static void pc_set_irq_line(running_machine *machine,int irq, int state) |
| 1120 | 1120 | { |
| 1121 | pc_state *st = | |
| 1121 | pc_state *st = | |
| 1122 | 1122 | |
| 1123 | 1123 | switch (irq) |
| 1124 | 1124 | { |
| r8714 | r8715 | |
| 1317 | 1317 | |
| 1318 | 1318 | static IRQ_CALLBACK(pc_irq_callback) |
| 1319 | 1319 | { |
| 1320 | pc_state *st = | |
| 1320 | pc_state *st = | |
| 1321 | 1321 | return pic8259_acknowledge( st->pic8259 ); |
| 1322 | 1322 | } |
| 1323 | 1323 | |
| 1324 | 1324 | |
| 1325 | 1325 | MACHINE_START( pc ) |
| 1326 | 1326 | { |
| 1327 | pc_state *st = | |
| 1327 | pc_state *st = | |
| 1328 | 1328 | |
| 1329 | 1329 | st->pic8259 = machine->device("pic8259"); |
| 1330 | 1330 | st->dma8237 = machine->device("dma8237"); |
| r8714 | r8715 | |
| 1336 | 1336 | MACHINE_RESET( pc ) |
| 1337 | 1337 | { |
| 1338 | 1338 | running_device *speaker = machine->device("speaker"); |
| 1339 | pc_state *st = | |
| 1339 | pc_state *st = | |
| 1340 | 1340 | memset(st,0,sizeof(st)); |
| 1341 | 1341 | st->maincpu = machine->device("maincpu" ); |
| 1342 | 1342 | cpu_set_irq_callback(st->maincpu, pc_irq_callback); |
| r8714 | r8715 | |
| 1353 | 1353 | |
| 1354 | 1354 | MACHINE_START( pcjr ) |
| 1355 | 1355 | { |
| 1356 | pc_state *st = | |
| 1356 | pc_state *st = | |
| 1357 | 1357 | pc_fdc_init( machine, &pcjr_fdc_interface_nc ); |
| 1358 | 1358 | pcjr_keyb.keyb_signal_timer = timer_alloc(machine, pcjr_keyb_signal_callback, NULL ); |
| 1359 | 1359 | pc_int_delay_timer = timer_alloc(machine, pcjr_delayed_pic8259_irq, NULL ); |
| r8714 | r8715 | |
| 1369 | 1369 | MACHINE_RESET( pcjr ) |
| 1370 | 1370 | { |
| 1371 | 1371 | running_device *speaker = machine->device("speaker"); |
| 1372 | pc_state *st = | |
| 1372 | pc_state *st = | |
| 1373 | 1373 | memset(st,0,sizeof(st)); |
| 1374 | 1374 | st->u73_q2 = 0; |
| 1375 | 1375 | st->out1 = 0; |
| r8714 | r8715 | |
|---|---|---|
| 19 | 19 | |
| 20 | 20 | static TIMER_CALLBACK( reset_tick ) |
| 21 | 21 | { |
| 22 | pecom_state *state = | |
| 22 | pecom_state *state = | |
| 23 | 23 | |
| 24 | 24 | state->cdp1802_mode = CDP1802_MODE_RUN; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | MACHINE_START( pecom ) |
| 28 | 28 | { |
| 29 | pecom_state *state = | |
| 29 | pecom_state *state = | |
| 30 | 30 | state->reset_timer = timer_alloc(machine, reset_tick, NULL); |
| 31 | 31 | } |
| 32 | 32 | |
| r8714 | r8715 | |
| 35 | 35 | UINT8 *rom = memory_region(machine, "maincpu"); |
| 36 | 36 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 37 | 37 | |
| 38 | pecom_state *state = | |
| 38 | pecom_state *state = | |
| 39 | 39 | |
| 40 | 40 | memory_unmap_write(space, 0x0000, 0x3fff, 0, 0); |
| 41 | 41 | memory_install_write_bank(space, 0x4000, 0x7fff, 0, 0, "bank2"); |
| r8714 | r8715 | |
| 104 | 104 | /* CDP1802 Interface */ |
| 105 | 105 | static CDP1802_MODE_READ( pecom64_mode_r ) |
| 106 | 106 | { |
| 107 | pecom_state *state = | |
| 107 | pecom_state *state = | |
| 108 | 108 | |
| 109 | 109 | return (cdp1802_control_mode)state->cdp1802_mode; |
| 110 | 110 | } |
| r8714 | r8715 | |
|---|---|---|
| 14 | 14 | |
| 15 | 15 | static VIDEO_START( pc8401a ) |
| 16 | 16 | { |
| 17 | pc8401a_state *state = | |
| 17 | pc8401a_state *state = | |
| 18 | 18 | |
| 19 | 19 | /* allocate video memory */ |
| 20 | 20 | state->video_ram = auto_alloc_array(machine, UINT8, PC8401A_LCD_VIDEORAM_SIZE); |
| r8714 | r8715 | |
| 32 | 32 | |
| 33 | 33 | static VIDEO_START( pc8500 ) |
| 34 | 34 | { |
| 35 | pc8401a_state *state = | |
| 35 | pc8401a_state *state = | |
| 36 | 36 | |
| 37 | 37 | /* find devices */ |
| 38 | 38 | state->sed1330 = machine->device(SED1330_TAG); |
| r8714 | r8715 | |
| 48 | 48 | |
| 49 | 49 | static VIDEO_UPDATE( pc8500 ) |
| 50 | 50 | { |
| 51 | pc8401a_state *state = | |
| 51 | pc8401a_state *state = | |
| 52 | 52 | |
| 53 | 53 | if (screen == state->lcd) |
| 54 | 54 | { |
| r8714 | r8715 | |
| 66 | 66 | |
| 67 | 67 | static READ8_HANDLER( pc8500_sed1330_vd_r ) |
| 68 | 68 | { |
| 69 | pc8401a_state *state = | |
| 69 | pc8401a_state *state = | |
| 70 | 70 | |
| 71 | 71 | return state->video_ram[offset & PC8500_LCD_VIDEORAM_MASK]; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | static WRITE8_HANDLER( pc8500_sed1330_vd_w ) |
| 75 | 75 | { |
| 76 | pc8401a_state *state = | |
| 76 | pc8401a_state *state = | |
| 77 | 77 | |
| 78 | 78 | state->video_ram[offset & PC8500_LCD_VIDEORAM_MASK] = data; |
| 79 | 79 | } |
| r8714 | r8715 | |
|---|---|---|
| 31 | 31 | |
| 32 | 32 | static ATTR_CONST UINT8 coco_get_attributes_2(running_machine *machine, UINT8 c, int scanline, int pos) |
| 33 | 33 | { |
| 34 | coco_state *state = | |
| 34 | coco_state *state = | |
| 35 | 35 | UINT8 result = 0x00; |
| 36 | 36 | UINT8 pia1_pb = pia6821_get_output_b(state->pia_1); |
| 37 | 37 | |
| r8714 | r8715 | |
| 47 | 47 | |
| 48 | 48 | ATTR_CONST UINT8 coco_get_attributes(running_machine *machine, UINT8 c, int scanline, int pos) |
| 49 | 49 | { |
| 50 | coco_state *state = | |
| 50 | coco_state *state = | |
| 51 | 51 | UINT8 result = 0x00; |
| 52 | 52 | UINT8 pia1_pb = pia6821_get_output_b(state->pia_1); |
| 53 | 53 | |
| r8714 | r8715 | |
| 64 | 64 | |
| 65 | 65 | static void coco_horizontal_sync_callback(running_machine *machine, int data) |
| 66 | 66 | { |
| 67 | coco_state *state = | |
| 67 | coco_state *state = | |
| 68 | 68 | pia6821_ca1_w(state->pia_0, data); |
| 69 | 69 | } |
| 70 | 70 | |
| r8714 | r8715 | |
| 72 | 72 | |
| 73 | 73 | static void coco_field_sync_callback(running_machine *machine, int data) |
| 74 | 74 | { |
| 75 | coco_state *state = | |
| 75 | coco_state *state = | |
| 76 | 76 | pia6821_cb1_w(state->pia_0, data); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | static const UINT8 *get_video_ram_coco(running_machine *machine,int scanline) |
| 80 | 80 | { |
| 81 | coco_state *state = | |
| 81 | coco_state *state = | |
| 82 | 82 | return sam6883_videoram(state->sam, scanline); |
| 83 | 83 | } |
| 84 | 84 |
| r8714 | r8715 | |
|---|---|---|
| 13 | 13 | |
| 14 | 14 | static void nes_vh_reset( running_machine &machine ) |
| 15 | 15 | { |
| 16 | nes_state *state = | |
| 16 | nes_state *state = | |
| 17 | 17 | ppu2c0x_set_vidaccess_callback(machine.device("ppu"), nes_ppu_vidaccess); |
| 18 | 18 | |
| 19 | 19 | if (state->four_screen_vram) |
| r8714 | r8715 | |
| 37 | 37 | |
| 38 | 38 | VIDEO_START( nes ) |
| 39 | 39 | { |
| 40 | nes_state *state = | |
| 40 | nes_state *state = | |
| 41 | 41 | |
| 42 | 42 | state->last_frame_flip = 0; |
| 43 | 43 | |
| r8714 | r8715 | |
| 58 | 58 | |
| 59 | 59 | VIDEO_UPDATE( nes ) |
| 60 | 60 | { |
| 61 | nes_state *state = | |
| 61 | nes_state *state = | |
| 62 | 62 | |
| 63 | 63 | /* render the ppu */ |
| 64 | 64 | ppu2c0x_render(state->ppu, bitmap, 0, 0, 0, 0); |
| r8714 | r8715 | |
|---|---|---|
| 4 | 4 | |
| 5 | 5 | WRITE8_HANDLER( tmc600_vismac_register_w ) |
| 6 | 6 | { |
| 7 | tmc600_state *state = | |
| 7 | tmc600_state *state = | |
| 8 | 8 | |
| 9 | 9 | state->vismac_reg_latch = data; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | WRITE8_DEVICE_HANDLER( tmc600_vismac_data_w ) |
| 13 | 13 | { |
| 14 | tmc600_state *state = | |
| 14 | tmc600_state *state = | |
| 15 | 15 | |
| 16 | 16 | switch (state->vismac_reg_latch) |
| 17 | 17 | { |
| r8714 | r8715 | |
| 46 | 46 | |
| 47 | 47 | static TIMER_DEVICE_CALLBACK( blink_tick ) |
| 48 | 48 | { |
| 49 | tmc600_state *state = | |
| 49 | tmc600_state *state = | |
| 50 | 50 | |
| 51 | 51 | state->blink = !state->blink; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | static UINT8 tmc600_get_color(running_machine *machine, UINT16 pma) |
| 55 | 55 | { |
| 56 | tmc600_state *state = | |
| 56 | tmc600_state *state = | |
| 57 | 57 | |
| 58 | 58 | UINT16 pageaddr = pma & TMC600_PAGE_RAM_MASK; |
| 59 | 59 | UINT8 color = state->color_ram[pageaddr]; |
| r8714 | r8715 | |
| 68 | 68 | |
| 69 | 69 | static READ8_DEVICE_HANDLER( tmc600_page_ram_r ) |
| 70 | 70 | { |
| 71 | tmc600_state *state = | |
| 71 | tmc600_state *state = | |
| 72 | 72 | |
| 73 | 73 | UINT16 addr = offset & TMC600_PAGE_RAM_MASK; |
| 74 | 74 | |
| r8714 | r8715 | |
| 77 | 77 | |
| 78 | 78 | static WRITE8_DEVICE_HANDLER( tmc600_page_ram_w ) |
| 79 | 79 | { |
| 80 | tmc600_state *state = | |
| 80 | tmc600_state *state = | |
| 81 | 81 | |
| 82 | 82 | UINT16 addr = offset & TMC600_PAGE_RAM_MASK; |
| 83 | 83 | |
| r8714 | r8715 | |
| 87 | 87 | |
| 88 | 88 | static CDP1869_CHAR_RAM_READ( tmc600_char_ram_r ) |
| 89 | 89 | { |
| 90 | tmc600_state *state = | |
| 90 | tmc600_state *state = | |
| 91 | 91 | |
| 92 | 92 | UINT16 pageaddr = pma & TMC600_PAGE_RAM_MASK; |
| 93 | 93 | UINT8 column = state->page_ram[pageaddr]; |
| r8714 | r8715 | |
| 125 | 125 | |
| 126 | 126 | static VIDEO_START( tmc600 ) |
| 127 | 127 | { |
| 128 | tmc600_state *state = | |
| 128 | tmc600_state *state = | |
| 129 | 129 | |
| 130 | 130 | /* allocate memory */ |
| 131 | 131 | |
| r8714 | r8715 | |
| 153 | 153 | |
| 154 | 154 | static VIDEO_UPDATE( tmc600 ) |
| 155 | 155 | { |
| 156 | tmc600_state *state = | |
| 156 | tmc600_state *state = | |
| 157 | 157 | |
| 158 | 158 | cdp1869_update(state->cdp1869, bitmap, cliprect); |
| 159 | 159 |
| r8714 | r8715 | |
|---|---|---|
| 19 | 19 | ***************************************************************************/ |
| 20 | 20 | VIDEO_START( advision ) |
| 21 | 21 | { |
| 22 | advision_state *state = | |
| 22 | advision_state *state = | |
| 23 | 23 | |
| 24 | 24 | state->video_hpos = 0; |
| 25 | 25 | state->display = auto_alloc_array(machine, UINT8, 8 * 8 * 256); |
| r8714 | r8715 | |
| 51 | 51 | |
| 52 | 52 | void advision_vh_write(running_machine *machine, int data) |
| 53 | 53 | { |
| 54 | advision_state *state = | |
| 54 | advision_state *state = | |
| 55 | 55 | |
| 56 | 56 | if (state->video_bank >= 1 && state->video_bank <=5) |
| 57 | 57 | { |
| r8714 | r8715 | |
| 61 | 61 | |
| 62 | 62 | void advision_vh_update(running_machine *machine, int x) |
| 63 | 63 | { |
| 64 | advision_state *state = | |
| 64 | advision_state *state = | |
| 65 | 65 | |
| 66 | 66 | UINT8 *dst = &state->display[x]; |
| 67 | 67 | int y; |
| r8714 | r8715 | |
| 94 | 94 | |
| 95 | 95 | VIDEO_UPDATE( advision ) |
| 96 | 96 | { |
| 97 | advision_state *state = | |
| 97 | advision_state *state = | |
| 98 | 98 | |
| 99 | 99 | int x, y; |
| 100 | 100 |
| r8714 | r8715 | |
|---|---|---|
| 49 | 49 | VIDEO_UPDATE( mz700 ) |
| 50 | 50 | { |
| 51 | 51 | int offs; |
| 52 | mz_state *mz = | |
| 52 | mz_state *mz = | |
| 53 | 53 | |
| 54 | 54 | bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); |
| 55 | 55 | |
| r8714 | r8715 | |
| 76 | 76 | |
| 77 | 77 | VIDEO_START( mz800 ) |
| 78 | 78 | { |
| 79 | mz_state *mz = | |
| 79 | mz_state *mz = | |
| 80 | 80 | gfx_element_set_source(machine->gfx[0], mz->cgram); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | VIDEO_UPDATE( mz800 ) |
| 84 | 84 | { |
| 85 | mz_state *mz = | |
| 85 | mz_state *mz = | |
| 86 | 86 | |
| 87 | 87 | bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); |
| 88 | 88 | |
| r8714 | r8715 | |
| 125 | 125 | |
| 126 | 126 | WRITE8_HANDLER( mz800_cgram_w ) |
| 127 | 127 | { |
| 128 | mz_state *mz = | |
| 128 | mz_state *mz = | |
| 129 | 129 | mz->cgram[offset] = data; |
| 130 | 130 | |
| 131 | 131 | gfx_element_mark_dirty(space->machine->gfx[0], offset/8); |
| r8714 | r8715 | |
|---|---|---|
| 41 | 41 | |
| 42 | 42 | WRITE8_HANDLER( abc800_hrs_w ) |
| 43 | 43 | { |
| 44 | abc800_state *state = | |
| 44 | abc800_state *state = | |
| 45 | 45 | |
| 46 | 46 | state->hrs = data; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | WRITE8_HANDLER( abc800_hrc_w ) |
| 50 | 50 | { |
| 51 | abc800_state *state = | |
| 51 | abc800_state *state = | |
| 52 | 52 | |
| 53 | 53 | state->fgctl = data; |
| 54 | 54 | } |
| r8714 | r8715 | |
| 57 | 57 | |
| 58 | 58 | static MC6845_UPDATE_ROW( abc800m_update_row ) |
| 59 | 59 | { |
| 60 | abc800_state *state = | |
| 60 | abc800_state *state = | |
| 61 | 61 | |
| 62 | 62 | int column; |
| 63 | 63 | |
| r8714 | r8715 | |
| 96 | 96 | |
| 97 | 97 | static WRITE_LINE_DEVICE_HANDLER( abc800_vsync_changed ) |
| 98 | 98 | { |
| 99 | abc800_state *driver_state = | |
| 99 | abc800_state *driver_state = | |
| 100 | 100 | |
| 101 | 101 | z80dart_rib_w(driver_state->z80dart, state); |
| 102 | 102 | } |
| r8714 | r8715 | |
| 126 | 126 | |
| 127 | 127 | static void abc800m_hr_update(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 128 | 128 | { |
| 129 | abc800_state *state = | |
| 129 | abc800_state *state = | |
| 130 | 130 | |
| 131 | 131 | UINT16 addr = 0; |
| 132 | 132 | int sx, y, dot; |
| r8714 | r8715 | |
| 155 | 155 | |
| 156 | 156 | static void abc800c_hr_update(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 157 | 157 | { |
| 158 | abc800_state *state = | |
| 158 | abc800_state *state = | |
| 159 | 159 | |
| 160 | 160 | UINT16 addr = 0; |
| 161 | 161 | int sx, y, dot; |
| r8714 | r8715 | |
| 185 | 185 | |
| 186 | 186 | static VIDEO_START( abc800m ) |
| 187 | 187 | { |
| 188 | abc800_state *state = | |
| 188 | abc800_state *state = | |
| 189 | 189 | |
| 190 | 190 | /* find devices */ |
| 191 | 191 | state->mc6845 = machine->device(MC6845_TAG); |
| r8714 | r8715 | |
| 201 | 201 | |
| 202 | 202 | static VIDEO_START( abc800c ) |
| 203 | 203 | { |
| 204 | abc800_state *state = | |
| 204 | abc800_state *state = | |
| 205 | 205 | |
| 206 | 206 | /* find memory regions */ |
| 207 | 207 | state->char_rom = memory_region(machine, "chargen"); |
| r8714 | r8715 | |
| 216 | 216 | |
| 217 | 217 | static VIDEO_UPDATE( abc800m ) |
| 218 | 218 | { |
| 219 | abc800_state *state = | |
| 219 | abc800_state *state = | |
| 220 | 220 | |
| 221 | 221 | /* expand visible area to workaround MC6845 */ |
| 222 | 222 | screen->set_visible_area(0, 767, 0, 311); |
| r8714 | r8715 | |
| 238 | 238 | |
| 239 | 239 | static VIDEO_UPDATE( abc800c ) |
| 240 | 240 | { |
| 241 | abc800_state *state = | |
| 241 | abc800_state *state = | |
| 242 | 242 | |
| 243 | 243 | /* clear screen */ |
| 244 | 244 | bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); |
| r8714 | r8715 | |
|---|---|---|
| 21 | 21 | UINT8 code2; |
| 22 | 22 | UINT8 col; |
| 23 | 23 | int y, x, b; |
| 24 | b2m_state *state = | |
| 24 | b2m_state *state = | |
| 25 | 25 | |
| 26 | 26 | for (x = 0; x < 48; x++) |
| 27 | 27 | { |
| r8714 | r8715 | |
|---|---|---|
| 37 | 37 | |
| 38 | 38 | static TILE_GET_INFO( abc80_get_tile_info ) |
| 39 | 39 | { |
| 40 | abc80_state *state = | |
| 40 | abc80_state *state = | |
| 41 | 41 | |
| 42 | 42 | int attr = state->video_ram[tile_index]; |
| 43 | 43 | int code = attr & 0x7f; |
| r8714 | r8715 | |
| 73 | 73 | |
| 74 | 74 | static TIMER_DEVICE_CALLBACK(abc80_blink_tick) |
| 75 | 75 | { |
| 76 | abc80_state *state = | |
| 76 | abc80_state *state = | |
| 77 | 77 | |
| 78 | 78 | state->blink = !state->blink; |
| 79 | 79 | } |
| r8714 | r8715 | |
| 81 | 81 | #ifdef UNUSED_FUNCTION |
| 82 | 82 | static void abc80_update(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 83 | 83 | { |
| 84 | abc80_state *state = | |
| 84 | abc80_state *state = | |
| 85 | 85 | UINT16 videoram_addr; |
| 86 | 86 | int y, sx, c = 0, r = 0; |
| 87 | 87 | |
| r8714 | r8715 | |
| 200 | 200 | |
| 201 | 201 | static VIDEO_START( abc80 ) |
| 202 | 202 | { |
| 203 | abc80_state *state = | |
| 203 | abc80_state *state = | |
| 204 | 204 | |
| 205 | 205 | /* create tx_tilemap */ |
| 206 | 206 | |
| r8714 | r8715 | |
| 226 | 226 | |
| 227 | 227 | static VIDEO_UPDATE( abc80 ) |
| 228 | 228 | { |
| 229 | abc80_state *state = | |
| 229 | abc80_state *state = | |
| 230 | 230 | rectangle rect; |
| 231 | 231 | |
| 232 | 232 | rect.min_x = ABC80_HDSTART; |
| r8714 | r8715 | |
|---|---|---|
| 21 | 21 | ***************************************************************************/ |
| 22 | 22 | VIDEO_START( spectrum ) |
| 23 | 23 | { |
| 24 | spectrum_state *state = | |
| 24 | spectrum_state *state = | |
| 25 | 25 | state->frame_number = 0; |
| 26 | 26 | state->flash_invert = 0; |
| 27 | 27 | |
| r8714 | r8715 | |
| 34 | 34 | |
| 35 | 35 | VIDEO_START( spectrum_128 ) |
| 36 | 36 | { |
| 37 | spectrum_state *state = | |
| 37 | spectrum_state *state = | |
| 38 | 38 | state->frame_number = 0; |
| 39 | 39 | state->flash_invert = 0; |
| 40 | 40 | |
| r8714 | r8715 | |
| 57 | 57 | independent of frame skip etc. */ |
| 58 | 58 | VIDEO_EOF( spectrum ) |
| 59 | 59 | { |
| 60 | spectrum_state *state = | |
| 60 | spectrum_state *state = | |
| 61 | 61 | EVENT_LIST_ITEM *pItem; |
| 62 | 62 | int NumItems; |
| 63 | 63 | |
| r8714 | r8715 | |
| 114 | 114 | VIDEO_UPDATE( spectrum ) |
| 115 | 115 | { |
| 116 | 116 | /* for now do a full-refresh */ |
| 117 | spectrum_state *state = | |
| 117 | spectrum_state *state = | |
| 118 | 118 | int x, y, b, scrx, scry; |
| 119 | 119 | unsigned short ink, pap; |
| 120 | 120 | unsigned char *attr, *scr; |
| r8714 | r8715 | |
|---|---|---|
| 17 | 17 | |
| 18 | 18 | INLINE pen_t atarist_shift_mode_0(running_machine *machine) |
| 19 | 19 | { |
| 20 | atarist_state *state = | |
| 20 | atarist_state *state = | |
| 21 | 21 | |
| 22 | 22 | int color = (BIT(state->shifter_rr[3], 15) << 3) | (BIT(state->shifter_rr[2], 15) << 2) | (BIT(state->shifter_rr[1], 15) << 1) | BIT(state->shifter_rr[0], 15); |
| 23 | 23 | |
| r8714 | r8715 | |
| 31 | 31 | |
| 32 | 32 | INLINE pen_t atarist_shift_mode_1(running_machine *machine) |
| 33 | 33 | { |
| 34 | atarist_state *state = | |
| 34 | atarist_state *state = | |
| 35 | 35 | |
| 36 | 36 | int color = (BIT(state->shifter_rr[1], 15) << 1) | BIT(state->shifter_rr[0], 15); |
| 37 | 37 | |
| r8714 | r8715 | |
| 52 | 52 | |
| 53 | 53 | INLINE pen_t atarist_shift_mode_2(running_machine *machine) |
| 54 | 54 | { |
| 55 | atarist_state *state = | |
| 55 | atarist_state *state = | |
| 56 | 56 | |
| 57 | 57 | int color = BIT(state->shifter_rr[0], 15); |
| 58 | 58 | |
| r8714 | r8715 | |
| 86 | 86 | |
| 87 | 87 | static TIMER_CALLBACK( atarist_shifter_tick ) |
| 88 | 88 | { |
| 89 | atarist_state *state = | |
| 89 | atarist_state *state = | |
| 90 | 90 | |
| 91 | 91 | int y = machine->primary_screen->vpos(); |
| 92 | 92 | int x = machine->primary_screen->hpos(); |
| r8714 | r8715 | |
| 117 | 117 | |
| 118 | 118 | INLINE void atarist_shifter_load(running_machine *machine) |
| 119 | 119 | { |
| 120 | atarist_state *state = | |
| 120 | atarist_state *state = | |
| 121 | 121 | |
| 122 | 122 | const address_space *program = cputag_get_address_space(machine, M68000_TAG, ADDRESS_SPACE_PROGRAM); |
| 123 | 123 | UINT16 data = memory_read_word_16be(program, state->shifter_ofs); |
| r8714 | r8715 | |
| 139 | 139 | |
| 140 | 140 | static TIMER_CALLBACK( atarist_glue_tick ) |
| 141 | 141 | { |
| 142 | atarist_state *state = | |
| 142 | atarist_state *state = | |
| 143 | 143 | |
| 144 | 144 | int y = machine->primary_screen->vpos(); |
| 145 | 145 | int x = machine->primary_screen->hpos(); |
| r8714 | r8715 | |
| 175 | 175 | |
| 176 | 176 | static void atarist_set_screen_parameters(running_machine *machine) |
| 177 | 177 | { |
| 178 | atarist_state *state = | |
| 178 | atarist_state *state = | |
| 179 | 179 | |
| 180 | 180 | if (state->shifter_sync & 0x02) |
| 181 | 181 | { |
| r8714 | r8715 | |
| 201 | 201 | |
| 202 | 202 | READ16_HANDLER( atarist_shifter_base_r ) |
| 203 | 203 | { |
| 204 | atarist_state *state = | |
| 204 | atarist_state *state = | |
| 205 | 205 | |
| 206 | 206 | switch (offset) |
| 207 | 207 | { |
| r8714 | r8715 | |
| 216 | 216 | |
| 217 | 217 | WRITE16_HANDLER( atarist_shifter_base_w ) |
| 218 | 218 | { |
| 219 | atarist_state *state = | |
| 219 | atarist_state *state = | |
| 220 | 220 | |
| 221 | 221 | switch (offset) |
| 222 | 222 | { |
| r8714 | r8715 | |
| 233 | 233 | |
| 234 | 234 | READ16_HANDLER( atarist_shifter_counter_r ) |
| 235 | 235 | { |
| 236 | atarist_state *state = | |
| 236 | atarist_state *state = | |
| 237 | 237 | |
| 238 | 238 | switch (offset) |
| 239 | 239 | { |
| r8714 | r8715 | |
| 250 | 250 | |
| 251 | 251 | READ8_HANDLER( atarist_shifter_sync_r ) |
| 252 | 252 | { |
| 253 | atarist_state *state = | |
| 253 | atarist_state *state = | |
| 254 | 254 | |
| 255 | 255 | return state->shifter_sync; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | WRITE8_HANDLER( atarist_shifter_sync_w ) |
| 259 | 259 | { |
| 260 | atarist_state *state = | |
| 260 | atarist_state *state = | |
| 261 | 261 | |
| 262 | 262 | state->shifter_sync = data; |
| 263 | 263 | logerror("SHIFTER Sync %x\n", state->shifter_sync); |
| r8714 | r8715 | |
| 266 | 266 | |
| 267 | 267 | READ8_HANDLER( atarist_shifter_mode_r ) |
| 268 | 268 | { |
| 269 | atarist_state *state = | |
| 269 | atarist_state *state = | |
| 270 | 270 | |
| 271 | 271 | return state->shifter_mode; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | WRITE8_HANDLER( atarist_shifter_mode_w ) |
| 275 | 275 | { |
| 276 | atarist_state *state = | |
| 276 | atarist_state *state = | |
| 277 | 277 | |
| 278 | 278 | state->shifter_mode = data; |
| 279 | 279 | logerror("SHIFTER Mode %x\n", state->shifter_mode); |
| r8714 | r8715 | |
| 281 | 281 | |
| 282 | 282 | READ16_HANDLER( atarist_shifter_palette_r ) |
| 283 | 283 | { |
| 284 | atarist_state *state = | |
| 284 | atarist_state *state = | |
| 285 | 285 | |
| 286 | 286 | return state->shifter_palette[offset]; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | WRITE16_HANDLER( atarist_shifter_palette_w ) |
| 290 | 290 | { |
| 291 | atarist_state *state = | |
| 291 | atarist_state *state = | |
| 292 | 292 | |
| 293 | 293 | state->shifter_palette[offset] = data; |
| 294 | 294 | logerror("SHIFTER Palette[%x] = %x\n", offset, data); |
| r8714 | r8715 | |
| 300 | 300 | |
| 301 | 301 | READ16_HANDLER( atariste_shifter_base_low_r ) |
| 302 | 302 | { |
| 303 | atarist_state *state = | |
| 303 | atarist_state *state = | |
| 304 | 304 | |
| 305 | 305 | return state->shifter_base & 0xfe; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | WRITE16_HANDLER( atariste_shifter_base_low_w ) |
| 309 | 309 | { |
| 310 | atarist_state *state = | |
| 310 | atarist_state *state = | |
| 311 | 311 | |
| 312 | 312 | state->shifter_base = (state->shifter_base & 0x3fff00) | (data & 0xfe); |
| 313 | 313 | logerror("SHIFTER Video Base Address %06x\n", state->shifter_base); |
| r8714 | r8715 | |
| 315 | 315 | |
| 316 | 316 | READ16_HANDLER( atariste_shifter_counter_r ) |
| 317 | 317 | { |
| 318 | atarist_state *state = | |
| 318 | atarist_state *state = | |
| 319 | 319 | |
| 320 | 320 | switch (offset) |
| 321 | 321 | { |
| r8714 | r8715 | |
| 332 | 332 | |
| 333 | 333 | WRITE16_HANDLER( atariste_shifter_counter_w ) |
| 334 | 334 | { |
| 335 | atarist_state *state = | |
| 335 | atarist_state *state = | |
| 336 | 336 | |
| 337 | 337 | switch (offset) |
| 338 | 338 | { |
| r8714 | r8715 | |
| 353 | 353 | |
| 354 | 354 | WRITE16_HANDLER( atariste_shifter_palette_w ) |
| 355 | 355 | { |
| 356 | atarist_state *state = | |
| 356 | atarist_state *state = | |
| 357 | 357 | |
| 358 | 358 | int r = ((data >> 7) & 0x0e) | BIT(data, 11); |
| 359 | 359 | int g = ((data >> 3) & 0x0e) | BIT(data, 7); |
| r8714 | r8715 | |
| 367 | 367 | |
| 368 | 368 | READ16_HANDLER( atariste_shifter_lineofs_r ) |
| 369 | 369 | { |
| 370 | atarist_state *state = | |
| 370 | atarist_state *state = | |
| 371 | 371 | |
| 372 | 372 | return state->shifter_lineofs; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | WRITE16_HANDLER( atariste_shifter_lineofs_w ) |
| 376 | 376 | { |
| 377 | atarist_state *state = | |
| 377 | atarist_state *state = | |
| 378 | 378 | |
| 379 | 379 | state->shifter_lineofs = data & 0xff; |
| 380 | 380 | logerror("SHIFTER Line Offset %x\n", state->shifter_lineofs); |
| r8714 | r8715 | |
| 382 | 382 | |
| 383 | 383 | READ16_HANDLER( atariste_shifter_pixelofs_r ) |
| 384 | 384 | { |
| 385 | atarist_state *state = | |
| 385 | atarist_state *state = | |
| 386 | 386 | |
| 387 | 387 | return state->shifter_pixelofs; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | WRITE16_HANDLER( atariste_shifter_pixelofs_w ) |
| 391 | 391 | { |
| 392 | atarist_state *state = | |
| 392 | atarist_state *state = | |
| 393 | 393 | |
| 394 | 394 | state->shifter_pixelofs = data & 0x0f; |
| 395 | 395 | logerror("SHIFTER Pixel Offset %x\n", state->shifter_pixelofs); |
| r8714 | r8715 | |
| 419 | 419 | |
| 420 | 420 | static void atarist_blitter_source(running_machine *machine) |
| 421 | 421 | { |
| 422 | atarist_state *state = | |
| 422 | atarist_state *state = | |
| 423 | 423 | |
| 424 | 424 | const address_space *program = cputag_get_address_space(machine, M68000_TAG, ADDRESS_SPACE_PROGRAM); |
| 425 | 425 | UINT16 data = memory_read_word_16be(program, state->blitter_src); |
| r8714 | r8715 | |
| 436 | 436 | |
| 437 | 437 | static UINT16 atarist_blitter_hop(running_machine *machine) |
| 438 | 438 | { |
| 439 | atarist_state *state = | |
| 439 | atarist_state *state = | |
| 440 | 440 | |
| 441 | 441 | UINT16 source = state->blitter_srcbuf >> (state->blitter_skew & 0x0f); |
| 442 | 442 | UINT16 halftone = state->blitter_halftone[state->blitter_ctrl & 0x0f]; |
| r8714 | r8715 | |
| 463 | 463 | |
| 464 | 464 | static void atarist_blitter_op(running_machine *machine, UINT16 s, UINT32 dstaddr, UINT16 mask) |
| 465 | 465 | { |
| 466 | atarist_state *state = | |
| 466 | atarist_state *state = | |
| 467 | 467 | const address_space *program = cputag_get_address_space(machine, M68000_TAG, ADDRESS_SPACE_PROGRAM); |
| 468 | 468 | |
| 469 | 469 | UINT16 d = memory_read_word_16be(program, dstaddr); |
| r8714 | r8715 | |
| 479 | 479 | |
| 480 | 480 | static TIMER_CALLBACK( atarist_blitter_tick ) |
| 481 | 481 | { |
| 482 | atarist_state *state = | |
| 482 | atarist_state *state = | |
| 483 | 483 | |
| 484 | 484 | do |
| 485 | 485 | { |
| r8714 | r8715 | |
| 538 | 538 | |
| 539 | 539 | READ16_HANDLER( atarist_blitter_halftone_r ) |
| 540 | 540 | { |
| 541 | atarist_state *state = | |
| 541 | atarist_state *state = | |
| 542 | 542 | |
| 543 | 543 | return state->blitter_halftone[offset]; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | READ16_HANDLER( atarist_blitter_src_inc_x_r ) |
| 547 | 547 | { |
| 548 | atarist_state *state = | |
| 548 | atarist_state *state = | |
| 549 | 549 | |
| 550 | 550 | return state->blitter_src_inc_x; |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | READ16_HANDLER( atarist_blitter_src_inc_y_r ) |
| 554 | 554 | { |
| 555 | atarist_state *state = | |
| 555 | atarist_state *state = | |
| 556 | 556 | |
| 557 | 557 | return state->blitter_src_inc_y; |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | READ16_HANDLER( atarist_blitter_src_r ) |
| 561 | 561 | { |
| 562 | atarist_state *state = | |
| 562 | atarist_state *state = | |
| 563 | 563 | |
| 564 | 564 | switch (offset) |
| 565 | 565 | { |
| r8714 | r8715 | |
| 574 | 574 | |
| 575 | 575 | READ16_HANDLER( atarist_blitter_end_mask_r ) |
| 576 | 576 | { |
| 577 | atarist_state *state = | |
| 577 | atarist_state *state = | |
| 578 | 578 | |
| 579 | 579 | switch (offset) |
| 580 | 580 | { |
| r8714 | r8715 | |
| 591 | 591 | |
| 592 | 592 | READ16_HANDLER( atarist_blitter_dst_inc_x_r ) |
| 593 | 593 | { |
| 594 | atarist_state *state = | |
| 594 | atarist_state *state = | |
| 595 | 595 | |
| 596 | 596 | return state->blitter_dst_inc_x; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | READ16_HANDLER( atarist_blitter_dst_inc_y_r ) |
| 600 | 600 | { |
| 601 | atarist_state *state = | |
| 601 | atarist_state *state = | |
| 602 | 602 | |
| 603 | 603 | return state->blitter_dst_inc_y; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | READ16_HANDLER( atarist_blitter_dst_r ) |
| 607 | 607 | { |
| 608 | atarist_state *state = | |
| 608 | atarist_state *state = | |
| 609 | 609 | |
| 610 | 610 | switch (offset) |
| 611 | 611 | { |
| r8714 | r8715 | |
| 620 | 620 | |
| 621 | 621 | READ16_HANDLER( atarist_blitter_count_x_r ) |
| 622 | 622 | { |
| 623 | atarist_state *state = | |
| 623 | atarist_state *state = | |
| 624 | 624 | |
| 625 | 625 | return state->blitter_xcount; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | READ16_HANDLER( atarist_blitter_count_y_r ) |
| 629 | 629 | { |
| 630 | atarist_state *state = | |
| 630 | atarist_state *state = | |
| 631 | 631 | |
| 632 | 632 | return state->blitter_ycount; |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | READ16_HANDLER( atarist_blitter_op_r ) |
| 636 | 636 | { |
| 637 | atarist_state *state = | |
| 637 | atarist_state *state = | |
| 638 | 638 | |
| 639 | 639 | if (ACCESSING_BITS_0_7) |
| 640 | 640 | { |
| r8714 | r8715 | |
| 648 | 648 | |
| 649 | 649 | READ16_HANDLER( atarist_blitter_ctrl_r ) |
| 650 | 650 | { |
| 651 | atarist_state *state = | |
| 651 | atarist_state *state = | |
| 652 | 652 | |
| 653 | 653 | if (ACCESSING_BITS_0_7) |
| 654 | 654 | { |
| r8714 | r8715 | |
| 662 | 662 | |
| 663 | 663 | WRITE16_HANDLER( atarist_blitter_halftone_w ) |
| 664 | 664 | { |
| 665 | atarist_state *state = | |
| 665 | atarist_state *state = | |
| 666 | 666 | |
| 667 | 667 | state->blitter_halftone[offset] = data; |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | WRITE16_HANDLER( atarist_blitter_src_inc_x_w ) |
| 671 | 671 | { |
| 672 | atarist_state *state = | |
| 672 | atarist_state *state = | |
| 673 | 673 | |
| 674 | 674 | state->blitter_src_inc_x = data & 0xfffe; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | WRITE16_HANDLER( atarist_blitter_src_inc_y_w ) |
| 678 | 678 | { |
| 679 | atarist_state *state = | |
| 679 | atarist_state *state = | |
| 680 | 680 | |
| 681 | 681 | state->blitter_src_inc_y = data & 0xfffe; |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | WRITE16_HANDLER( atarist_blitter_src_w ) |
| 685 | 685 | { |
| 686 | atarist_state *state = | |
| 686 | atarist_state *state = | |
| 687 | 687 | |
| 688 | 688 | switch (offset) |
| 689 | 689 | { |
| r8714 | r8715 | |
| 696 | 696 | |
| 697 | 697 | WRITE16_HANDLER( atarist_blitter_end_mask_w ) |
| 698 | 698 | { |
| 699 | atarist_state *state = | |
| 699 | atarist_state *state = | |
| 700 | 700 | |
| 701 | 701 | switch (offset) |
| 702 | 702 | { |
| r8714 | r8715 | |
| 711 | 711 | |
| 712 | 712 | WRITE16_HANDLER( atarist_blitter_dst_inc_x_w ) |
| 713 | 713 | { |
| 714 | atarist_state *state = | |
| 714 | atarist_state *state = | |
| 715 | 715 | |
| 716 | 716 | state->blitter_dst_inc_x = data & 0xfffe; |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | WRITE16_HANDLER( atarist_blitter_dst_inc_y_w ) |
| 720 | 720 | { |
| 721 | atarist_state *state = | |
| 721 | atarist_state *state = | |
| 722 | 722 | |
| 723 | 723 | state->blitter_dst_inc_y = data & 0xfffe; |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | WRITE16_HANDLER( atarist_blitter_dst_w ) |
| 727 | 727 | { |
| 728 | atarist_state *state = | |
| 728 | atarist_state *state = | |
| 729 | 729 | |
| 730 | 730 | switch (offset) |
| 731 | 731 | { |
| r8714 | r8715 | |
| 738 | 738 | |
| 739 | 739 | WRITE16_HANDLER( atarist_blitter_count_x_w ) |
| 740 | 740 | { |
| 741 | atarist_state *state = | |
| 741 | atarist_state *state = | |
| 742 | 742 | |
| 743 | 743 | state->blitter_xcount = data; |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | WRITE16_HANDLER( atarist_blitter_count_y_w ) |
| 747 | 747 | { |
| 748 | atarist_state *state = | |
| 748 | atarist_state *state = | |
| 749 | 749 | |
| 750 | 750 | state->blitter_ycount = data; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | WRITE16_HANDLER( atarist_blitter_op_w ) |
| 754 | 754 | { |
| 755 | atarist_state *state = | |
| 755 | atarist_state *state = | |
| 756 | 756 | |
| 757 | 757 | if (ACCESSING_BITS_0_7) |
| 758 | 758 | { |
| r8714 | r8715 | |
| 766 | 766 | |
| 767 | 767 | WRITE16_HANDLER( atarist_blitter_ctrl_w ) |
| 768 | 768 | { |
| 769 | atarist_state *state = | |
| 769 | atarist_state *state = | |
| 770 | 770 | |
| 771 | 771 | if (ACCESSING_BITS_0_7) |
| 772 | 772 | { |
| r8714 | r8715 | |
| 791 | 791 | |
| 792 | 792 | VIDEO_START( atarist ) |
| 793 | 793 | { |
| 794 | atarist_state *state = | |
| 794 | atarist_state *state = | |
| 795 | 795 | |
| 796 | 796 | state->shifter_timer = timer_alloc(machine, atarist_shifter_tick, NULL); |
| 797 | 797 | state->glue_timer = timer_alloc(machine, atarist_glue_tick, NULL); |
| r8714 | r8715 | |
|---|---|---|
| 25 | 25 | /* Update FLASH status for ts2068. Assumes flash update every 1/2s. */ |
| 26 | 26 | VIDEO_EOF( ts2068 ) |
| 27 | 27 | { |
| 28 | spectrum_state *state = | |
| 28 | spectrum_state *state = | |
| 29 | 29 | EVENT_LIST_ITEM *pItem; |
| 30 | 30 | int NumItems; |
| 31 | 31 | |
| r8714 | r8715 | |
| 75 | 75 | /* Draw a scanline in TS2068/TC2048 hires mode (code modified from COUPE.C) */ |
| 76 | 76 | static void ts2068_hires_scanline(running_machine *machine,bitmap_t *bitmap, int y, int borderlines) |
| 77 | 77 | { |
| 78 | spectrum_state *state = | |
| 78 | spectrum_state *state = | |
| 79 | 79 | int x,b,scrx,scry; |
| 80 | 80 | unsigned short ink,pap; |
| 81 | 81 | unsigned char *attr, *scr; |
| r8714 | r8715 | |
| 155 | 155 | /* Draw a scanline in TS2068/TC2048 lores (normal Spectrum) mode */ |
| 156 | 156 | static void ts2068_lores_scanline(running_machine *machine,bitmap_t *bitmap, int y, int borderlines, int screen) |
| 157 | 157 | { |
| 158 | spectrum_state *state = | |
| 158 | spectrum_state *state = | |
| 159 | 159 | int x,b,scrx,scry; |
| 160 | 160 | unsigned short ink,pap; |
| 161 | 161 | unsigned char *attr, *scr; |
| r8714 | r8715 | |
| 201 | 201 | VIDEO_UPDATE( ts2068 ) |
| 202 | 202 | { |
| 203 | 203 | /* for now TS2068 will do a full-refresh */ |
| 204 | spectrum_state *state = | |
| 204 | spectrum_state *state = | |
| 205 | 205 | int count; |
| 206 | 206 | int full_refresh = 1; |
| 207 | 207 | |
| r8714 | r8715 | |
| 242 | 242 | VIDEO_UPDATE( tc2048 ) |
| 243 | 243 | { |
| 244 | 244 | /* for now TS2068 will do a full-refresh */ |
| 245 | spectrum_state *state = | |
| 245 | spectrum_state *state = | |
| 246 | 246 | int count; |
| 247 | 247 | int full_refresh = 1; |
| 248 | 248 |
| r8714 | r8715 | |
|---|---|---|
| 24 | 24 | |
| 25 | 25 | static VIDEO_START( osi600 ) |
| 26 | 26 | { |
| 27 | osi_state *state = | |
| 27 | osi_state *state = | |
| 28 | 28 | UINT16 addr; |
| 29 | 29 | |
| 30 | 30 | /* randomize video memory contents */ |
| r8714 | r8715 | |
| 47 | 47 | |
| 48 | 48 | static VIDEO_UPDATE( osi600 ) |
| 49 | 49 | { |
| 50 | osi_state *state = | |
| 50 | osi_state *state = | |
| 51 | 51 | |
| 52 | 52 | int y, bit, sx; |
| 53 | 53 | |
| r8714 | r8715 | |
| 124 | 124 | |
| 125 | 125 | static VIDEO_UPDATE( uk101 ) |
| 126 | 126 | { |
| 127 | osi_state *state = | |
| 127 | osi_state *state = | |
| 128 | 128 | |
| 129 | 129 | int y, bit, sx; |
| 130 | 130 |
| r8714 | r8715 | |
|---|---|---|
| 22 | 22 | |
| 23 | 23 | READ8_HANDLER( v1050_attr_r ) |
| 24 | 24 | { |
| 25 | v1050_state *state = | |
| 25 | v1050_state *state = | |
| 26 | 26 | |
| 27 | 27 | return state->attr; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | WRITE8_HANDLER( v1050_attr_w ) |
| 31 | 31 | { |
| 32 | v1050_state *state = | |
| 32 | v1050_state *state = | |
| 33 | 33 | |
| 34 | 34 | state->attr = data; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | READ8_HANDLER( v1050_videoram_r ) |
| 38 | 38 | { |
| 39 | v1050_state *state = | |
| 39 | v1050_state *state = | |
| 40 | 40 | |
| 41 | 41 | if (offset >= 0x2000) |
| 42 | 42 | { |
| r8714 | r8715 | |
| 48 | 48 | |
| 49 | 49 | WRITE8_HANDLER( v1050_videoram_w ) |
| 50 | 50 | { |
| 51 | v1050_state *state = | |
| 51 | v1050_state *state = | |
| 52 | 52 | |
| 53 | 53 | state->video_ram[offset] = data; |
| 54 | 54 | |
| r8714 | r8715 | |
| 62 | 62 | |
| 63 | 63 | static MC6845_UPDATE_ROW( v1050_update_row ) |
| 64 | 64 | { |
| 65 | v1050_state *state = | |
| 65 | v1050_state *state = | |
| 66 | 66 | |
| 67 | 67 | int column, bit; |
| 68 | 68 | |
| r8714 | r8715 | |
| 129 | 129 | |
| 130 | 130 | static VIDEO_START( v1050 ) |
| 131 | 131 | { |
| 132 | v1050_state *state = | |
| 132 | v1050_state *state = | |
| 133 | 133 | |
| 134 | 134 | /* find devices */ |
| 135 | 135 | state->mc6845 = machine->device(H46505_TAG); |
| r8714 | r8715 | |
| 146 | 146 | |
| 147 | 147 | static VIDEO_UPDATE( v1050 ) |
| 148 | 148 | { |
| 149 | v1050_state *state = | |
| 149 | v1050_state *state = | |
| 150 | 150 | |
| 151 | 151 | mc6845_update(state->mc6845, bitmap, cliprect); |
| 152 | 152 |
| r8714 | r8715 | |
|---|---|---|
| 93 | 93 | |
| 94 | 94 | static void update_clut(running_machine *machine) |
| 95 | 95 | { |
| 96 | cgc7900_state *state = | |
| 96 | cgc7900_state *state = | |
| 97 | 97 | |
| 98 | 98 | for (int i = 0; i < 256; i++) |
| 99 | 99 | { |
| r8714 | r8715 | |
| 121 | 121 | |
| 122 | 122 | static void draw_overlay(screen_device *screen, bitmap_t *bitmap) |
| 123 | 123 | { |
| 124 | cgc7900_state *state = | |
| 124 | cgc7900_state *state = | |
| 125 | 125 | |
| 126 | 126 | for (int y = 0; y < 768; y++) |
| 127 | 127 | { |
| r8714 | r8715 | |
| 167 | 167 | |
| 168 | 168 | static TIMER_DEVICE_CALLBACK( blink_tick ) |
| 169 | 169 | { |
| 170 | cgc7900_state *state = | |
| 170 | cgc7900_state *state = | |
| 171 | 171 | |
| 172 | 172 | state->blink = !state->blink; |
| 173 | 173 | } |
| r8714 | r8715 | |
| 194 | 194 | |
| 195 | 195 | static VIDEO_START( cgc7900 ) |
| 196 | 196 | { |
| 197 | cgc7900_state *state = | |
| 197 | cgc7900_state *state = | |
| 198 | 198 | |
| 199 | 199 | /* find memory regions */ |
| 200 | 200 | state->char_rom = memory_region(machine, "gfx1"); |
| r8714 | r8715 | |
|---|---|---|
| 9 | 9 | |
| 10 | 10 | static WRITE_LINE_DEVICE_HANDLER( tmc1800_efx_w ) |
| 11 | 11 | { |
| 12 | tmc1800_state *driver_state = | |
| 12 | tmc1800_state *driver_state = | |
| 13 | 13 | |
| 14 | 14 | driver_state->cdp1861_efx = state; |
| 15 | 15 | } |
| r8714 | r8715 | |
| 25 | 25 | |
| 26 | 26 | static VIDEO_UPDATE( tmc1800 ) |
| 27 | 27 | { |
| 28 | tmc1800_state *state = | |
| 28 | tmc1800_state *state = | |
| 29 | 29 | |
| 30 | 30 | cdp1861_update(state->cdp1861, bitmap, cliprect); |
| 31 | 31 | |
| r8714 | r8715 | |
| 36 | 36 | |
| 37 | 37 | static READ_LINE_DEVICE_HANDLER( rdata_r ) |
| 38 | 38 | { |
| 39 | tmc2000_state *state = | |
| 39 | tmc2000_state *state = | |
| 40 | 40 | |
| 41 | 41 | return BIT(state->color, 2); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | static READ_LINE_DEVICE_HANDLER( bdata_r ) |
| 45 | 45 | { |
| 46 | tmc2000_state *state = | |
| 46 | tmc2000_state *state = | |
| 47 | 47 | |
| 48 | 48 | return BIT(state->color, 1); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | static READ_LINE_DEVICE_HANDLER( gdata_r ) |
| 52 | 52 | { |
| 53 | tmc2000_state *state = | |
| 53 | tmc2000_state *state = | |
| 54 | 54 | |
| 55 | 55 | return BIT(state->color, 0); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | static WRITE_LINE_DEVICE_HANDLER( tmc2000_efx_w ) |
| 59 | 59 | { |
| 60 | tmc2000_state *driver_state = | |
| 60 | tmc2000_state *driver_state = | |
| 61 | 61 | |
| 62 | 62 | driver_state->cdp1864_efx = state; |
| 63 | 63 | } |
| r8714 | r8715 | |
| 81 | 81 | |
| 82 | 82 | static VIDEO_UPDATE( tmc2000 ) |
| 83 | 83 | { |
| 84 | tmc2000_state *state = | |
| 84 | tmc2000_state *state = | |
| 85 | 85 | |
| 86 | 86 | cdp1864_update(state->cdp1864, bitmap, cliprect); |
| 87 | 87 | |
| r8714 | r8715 | |
| 92 | 92 | |
| 93 | 93 | static WRITE_LINE_DEVICE_HANDLER( oscnano_efx_w ) |
| 94 | 94 | { |
| 95 | oscnano_state *driver_state = | |
| 95 | oscnano_state *driver_state = | |
| 96 | 96 | |
| 97 | 97 | driver_state->cdp1864_efx = state; |
| 98 | 98 | } |
| r8714 | r8715 | |
| 116 | 116 | |
| 117 | 117 | static VIDEO_UPDATE( oscnano ) |
| 118 | 118 | { |
| 119 | oscnano_state *state = | |
| 119 | oscnano_state *state = | |
| 120 | 120 | |
| 121 | 121 | cdp1864_update(state->cdp1864, bitmap, cliprect); |
| 122 | 122 |
| r8714 | r8715 | |
|---|---|---|
| 104 | 104 | |
| 105 | 105 | void towns_crtc_refresh_mode(running_machine* machine) |
| 106 | 106 | { |
| 107 | towns_state* state = | |
| 107 | towns_state* state = | |
| 108 | 108 | rectangle scr; |
| 109 | 109 | unsigned int width,height; |
| 110 | 110 | |
| r8714 | r8715 | |
| 139 | 139 | |
| 140 | 140 | READ8_HANDLER( towns_gfx_high_r ) |
| 141 | 141 | { |
| 142 | towns_state* state = | |
| 142 | towns_state* state = | |
| 143 | 143 | return state->towns_gfxvram[offset]; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | WRITE8_HANDLER( towns_gfx_high_w ) |
| 147 | 147 | { |
| 148 | towns_state* state = | |
| 148 | towns_state* state = | |
| 149 | 149 | state->towns_gfxvram[offset] = data; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | READ8_HANDLER( towns_gfx_r ) |
| 153 | 153 | { |
| 154 | towns_state* state = | |
| 154 | towns_state* state = | |
| 155 | 155 | UINT8 ret = 0; |
| 156 | 156 | |
| 157 | 157 | if(state->towns_mainmem_enable != 0) |
| r8714 | r8715 | |
| 176 | 176 | |
| 177 | 177 | WRITE8_HANDLER( towns_gfx_w ) |
| 178 | 178 | { |
| 179 | towns_state* state = | |
| 179 | towns_state* state = | |
| 180 | 180 | |
| 181 | 181 | if(state->towns_mainmem_enable != 0) |
| 182 | 182 | { |
| r8714 | r8715 | |
| 234 | 234 | |
| 235 | 235 | static void towns_update_kanji_offset(running_machine* machine) |
| 236 | 236 | { |
| 237 | towns_state* state = | |
| 237 | towns_state* state = | |
| 238 | 238 | // this is a little over the top... |
| 239 | 239 | if(state->video.towns_kanji_code_h < 0x30) |
| 240 | 240 | { |
| r8714 | r8715 | |
| 263 | 263 | |
| 264 | 264 | READ8_HANDLER( towns_video_cff80_r ) |
| 265 | 265 | { |
| 266 | towns_state* state = | |
| 266 | towns_state* state = | |
| 267 | 267 | UINT8* ROM = memory_region(space->machine,"user"); |
| 268 | 268 | |
| 269 | 269 | switch(offset) |
| r8714 | r8715 | |
| 297 | 297 | |
| 298 | 298 | WRITE8_HANDLER( towns_video_cff80_w ) |
| 299 | 299 | { |
| 300 | towns_state* state = | |
| 300 | towns_state* state = | |
| 301 | 301 | |
| 302 | 302 | switch(offset) |
| 303 | 303 | { |
| r8714 | r8715 | |
| 338 | 338 | |
| 339 | 339 | READ8_HANDLER( towns_video_cff80_mem_r ) |
| 340 | 340 | { |
| 341 | towns_state* state = | |
| 341 | towns_state* state = | |
| 342 | 342 | |
| 343 | 343 | if(state->towns_mainmem_enable != 0) |
| 344 | 344 | return messram_get_ptr(state->messram)[offset+0xcff80]; |
| r8714 | r8715 | |
| 348 | 348 | |
| 349 | 349 | WRITE8_HANDLER( towns_video_cff80_mem_w ) |
| 350 | 350 | { |
| 351 | towns_state* state = | |
| 351 | towns_state* state = | |
| 352 | 352 | |
| 353 | 353 | if(state->towns_mainmem_enable != 0) |
| 354 | 354 | { |
| r8714 | r8715 | |
| 367 | 367 | */ |
| 368 | 368 | READ8_HANDLER(towns_video_440_r) |
| 369 | 369 | { |
| 370 | towns_state* state = | |
| 370 | towns_state* state = | |
| 371 | 371 | UINT8 ret = 0; |
| 372 | 372 | UINT16 xpos,ypos; |
| 373 | 373 | |
| r8714 | r8715 | |
| 430 | 430 | |
| 431 | 431 | WRITE8_HANDLER(towns_video_440_w) |
| 432 | 432 | { |
| 433 | towns_state* state = | |
| 433 | towns_state* state = | |
| 434 | 434 | |
| 435 | 435 | switch(offset) |
| 436 | 436 | { |
| r8714 | r8715 | |
| 470 | 470 | |
| 471 | 471 | READ8_HANDLER(towns_video_5c8_r) |
| 472 | 472 | { |
| 473 | towns_state* state = | |
| 473 | towns_state* state = | |
| 474 | 474 | |
| 475 | 475 | logerror("VID: read port %04x\n",offset+0x5c8); |
| 476 | 476 | switch(offset) |
| r8714 | r8715 | |
| 489 | 489 | |
| 490 | 490 | WRITE8_HANDLER(towns_video_5c8_w) |
| 491 | 491 | { |
| 492 | towns_state* state = | |
| 492 | towns_state* state = | |
| 493 | 493 | running_device* dev = state->pic_slave; |
| 494 | 494 | |
| 495 | 495 | switch(offset) |
| r8714 | r8715 | |
| 511 | 511 | */ |
| 512 | 512 | READ8_HANDLER(towns_video_fd90_r) |
| 513 | 513 | { |
| 514 | towns_state* state = | |
| 514 | towns_state* state = | |
| 515 | 515 | UINT8 ret = 0; |
| 516 | 516 | UINT16 xpos; |
| 517 | 517 | switch(offset) |
| r8714 | r8715 | |
| 549 | 549 | |
| 550 | 550 | WRITE8_HANDLER(towns_video_fd90_w) |
| 551 | 551 | { |
| 552 | towns_state* state = | |
| 552 | towns_state* state = | |
| 553 | 553 | |
| 554 | 554 | switch(offset) |
| 555 | 555 | { |
| r8714 | r8715 | |
| 585 | 585 | |
| 586 | 586 | READ8_HANDLER(towns_video_ff81_r) |
| 587 | 587 | { |
| 588 | towns_state* state = | |
| 588 | towns_state* state = | |
| 589 | 589 | |
| 590 | 590 | return ((state->video.towns_vram_rplane << 6) & 0xc0) | state->video.towns_vram_wplane; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | WRITE8_HANDLER(towns_video_ff81_w) |
| 594 | 594 | { |
| 595 | towns_state* state = | |
| 595 | towns_state* state = | |
| 596 | 596 | |
| 597 | 597 | state->video.towns_vram_wplane = data & 0x0f; |
| 598 | 598 | state->video.towns_vram_rplane = (data & 0xc0) >> 6; |
| r8714 | r8715 | |
| 612 | 612 | */ |
| 613 | 613 | READ8_HANDLER(towns_spriteram_low_r) |
| 614 | 614 | { |
| 615 | towns_state* state = | |
| 615 | towns_state* state = | |
| 616 | 616 | UINT8* RAM = messram_get_ptr(state->messram); |
| 617 | 617 | UINT8* ROM = memory_region(space->machine,"user"); |
| 618 | 618 | |
| r8714 | r8715 | |
| 651 | 651 | |
| 652 | 652 | WRITE8_HANDLER(towns_spriteram_low_w) |
| 653 | 653 | { |
| 654 | towns_state* state = | |
| 654 | towns_state* state = | |
| 655 | 655 | UINT8* RAM = messram_get_ptr(state->messram); |
| 656 | 656 | |
| 657 | 657 | if(offset < 0x1000) |
| r8714 | r8715 | |
| 678 | 678 | |
| 679 | 679 | READ8_HANDLER( towns_spriteram_r) |
| 680 | 680 | { |
| 681 | towns_state* state = | |
| 681 | towns_state* state = | |
| 682 | 682 | |
| 683 | 683 | return state->towns_txtvram[offset]; |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | WRITE8_HANDLER( towns_spriteram_w) |
| 687 | 687 | { |
| 688 | towns_state* state = | |
| 688 | towns_state* state = | |
| 689 | 689 | |
| 690 | 690 | state->towns_txtvram[offset] = data; |
| 691 | 691 | } |
| r8714 | r8715 | |
| 711 | 711 | */ |
| 712 | 712 | void render_sprite_4(running_machine* machine, UINT32 poffset, UINT32 coffset, UINT16 x, UINT16 y, UINT16 xflip, UINT16 yflip, const rectangle* rect) |
| 713 | 713 | { |
| 714 | towns_state* state = | |
| 714 | towns_state* state = | |
| 715 | 715 | UINT16 xpos,ypos; |
| 716 | 716 | UINT16 col,pixel; |
| 717 | 717 | UINT32 voffset; |
| r8714 | r8715 | |
| 787 | 787 | |
| 788 | 788 | void render_sprite_16(running_machine* machine, UINT32 poffset, UINT16 x, UINT16 y, UINT16 xflip, UINT16 yflip, const rectangle* rect) |
| 789 | 789 | { |
| 790 | towns_state* state = | |
| 790 | towns_state* state = | |
| 791 | 791 | UINT16 xpos,ypos; |
| 792 | 792 | UINT16 col; |
| 793 | 793 | UINT32 voffset; |
| r8714 | r8715 | |
| 848 | 848 | |
| 849 | 849 | void draw_sprites(running_machine* machine, const rectangle* rect) |
| 850 | 850 | { |
| 851 | towns_state* state = | |
| 851 | towns_state* state = | |
| 852 | 852 | UINT16 sprite_limit = (state->video.towns_sprite_reg[0] | (state->video.towns_sprite_reg[1] << 8)) & 0x3ff; |
| 853 | 853 | int n; |
| 854 | 854 | UINT16 x,y,attr,colour; |
| r8714 | r8715 | |
| 906 | 906 | |
| 907 | 907 | void towns_crtc_draw_scan_layer_hicolour(running_machine* machine, bitmap_t* bitmap,const rectangle* rect,int layer,int line,int scanline) |
| 908 | 908 | { |
| 909 | towns_state* state = | |
| 909 | towns_state* state = | |
| 910 | 910 | UINT32 off = 0; |
| 911 | 911 | int x; |
| 912 | 912 | UINT16 colour; |
| r8714 | r8715 | |
| 999 | 999 | |
| 1000 | 1000 | void towns_crtc_draw_scan_layer_256(running_machine* machine, bitmap_t* bitmap,const rectangle* rect,int layer,int line,int scanline) |
| 1001 | 1001 | { |
| 1002 | towns_state* state = | |
| 1002 | towns_state* state = | |
| 1003 | 1003 | int off = 0; |
| 1004 | 1004 | int x; |
| 1005 | 1005 | UINT8 colour; |
| r8714 | r8715 | |
| 1083 | 1083 | |
| 1084 | 1084 | void towns_crtc_draw_scan_layer_16(running_machine* machine, bitmap_t* bitmap,const rectangle* rect,int layer,int line,int scanline) |
| 1085 | 1085 | { |
| 1086 | towns_state* state = | |
| 1086 | towns_state* state = | |
| 1087 | 1087 | int off = 0; |
| 1088 | 1088 | int x; |
| 1089 | 1089 | UINT8 colour; |
| r8714 | r8715 | |
| 1191 | 1191 | |
| 1192 | 1192 | void towns_crtc_draw_layer(running_machine* machine,bitmap_t* bitmap,const rectangle* rect,int layer) |
| 1193 | 1193 | { |
| 1194 | towns_state* state = | |
| 1194 | towns_state* state = | |
| 1195 | 1195 | int line; |
| 1196 | 1196 | int scanline; |
| 1197 | 1197 | int height; |
| r8714 | r8715 | |
| 1292 | 1292 | |
| 1293 | 1293 | void render_text_char(running_machine* machine, UINT8 x, UINT8 y, UINT8 ascii, UINT16 jis, UINT8 attr) |
| 1294 | 1294 | { |
| 1295 | towns_state* state = | |
| 1295 | towns_state* state = | |
| 1296 | 1296 | UINT32 rom_addr; |
| 1297 | 1297 | UINT32 vram_addr; |
| 1298 | 1298 | UINT16 linesize = state->video.towns_crtc_reg[24] * 4; |
| r8714 | r8715 | |
| 1388 | 1388 | * |
| 1389 | 1389 | * The video hardware renders text to VRAM layer 1, there is no separate text layer |
| 1390 | 1390 | */ |
| 1391 | towns_state* state = | |
| 1391 | towns_state* state = | |
| 1392 | 1392 | int x,y,c = 0; |
| 1393 | 1393 | |
| 1394 | 1394 | for(y=0;y<40;y++) |
| r8714 | r8715 | |
| 1404 | 1404 | static TIMER_CALLBACK( towns_vblank_end ) |
| 1405 | 1405 | { |
| 1406 | 1406 | // here we'll clear the vsync signal, I presume it goes low on it's own eventually |
| 1407 | towns_state* state = | |
| 1407 | towns_state* state = | |
| 1408 | 1408 | running_device* dev = (running_device*)ptr; |
| 1409 | 1409 | pic8259_ir3_w(dev, 0); // IRQ11 = VSync |
| 1410 | 1410 | logerror("PIC: IRQ11 (VSync) set low\n"); |
| r8714 | r8715 | |
| 1413 | 1413 | |
| 1414 | 1414 | INTERRUPT_GEN( towns_vsync_irq ) |
| 1415 | 1415 | { |
| 1416 | towns_state* state = | |
| 1416 | towns_state* state = | |
| 1417 | 1417 | running_device* dev = state->pic_slave; |
| 1418 | 1418 | pic8259_ir3_w(dev, 1); // IRQ11 = VSync |
| 1419 | 1419 | logerror("PIC: IRQ11 (VSync) set high\n"); |
| r8714 | r8715 | |
| 1427 | 1427 | |
| 1428 | 1428 | VIDEO_START( towns ) |
| 1429 | 1429 | { |
| 1430 | towns_state* state = | |
| 1430 | towns_state* state = | |
| 1431 | 1431 | |
| 1432 | 1432 | state->video.towns_vram_wplane = 0x00; |
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | 1435 | VIDEO_UPDATE( towns ) |
| 1436 | 1436 | { |
| 1437 | towns_state* state = | |
| 1437 | towns_state* state = | |
| 1438 | 1438 | |
| 1439 | 1439 | bitmap_fill(bitmap,cliprect,0x00000000); |
| 1440 | 1440 |
| r8714 | r8715 | |
|---|---|---|
| 3 | 3 | |
| 4 | 4 | static VIDEO_START( newbrain ) |
| 5 | 5 | { |
| 6 | newbrain_state *state = | |
| 6 | newbrain_state *state = | |
| 7 | 7 | |
| 8 | 8 | /* find memory regions */ |
| 9 | 9 | |
| r8714 | r8715 | |
| 19 | 19 | |
| 20 | 20 | static void newbrain_update(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 21 | 21 | { |
| 22 | newbrain_state *state = | |
| 22 | newbrain_state *state = | |
| 23 | 23 | |
| 24 | 24 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 25 | 25 | |
| r8714 | r8715 | |
| 109 | 109 | |
| 110 | 110 | static VIDEO_UPDATE( newbrain ) |
| 111 | 111 | { |
| 112 | newbrain_state *state = | |
| 112 | newbrain_state *state = | |
| 113 | 113 | |
| 114 | 114 | if (state->enrg1 & NEWBRAIN_ENRG1_TVP) |
| 115 | 115 | { |
| r8714 | r8715 | |
|---|---|---|
| 11 | 11 | |
| 12 | 12 | static VIDEO_START( kc85 ) |
| 13 | 13 | { |
| 14 | kc85_state *state = | |
| 14 | kc85_state *state = | |
| 15 | 15 | |
| 16 | 16 | /* find devices */ |
| 17 | 17 | state->hd44102[0] = machine->device("m1"); |
| r8714 | r8715 | |
| 28 | 28 | |
| 29 | 29 | static VIDEO_UPDATE( kc85 ) |
| 30 | 30 | { |
| 31 | kc85_state *state = | |
| 31 | kc85_state *state = | |
| 32 | 32 | int i; |
| 33 | 33 | |
| 34 | 34 | for (i = 0; i < 10; i++) |
| r8714 | r8715 | |
| 41 | 41 | |
| 42 | 42 | static VIDEO_START( tandy200 ) |
| 43 | 43 | { |
| 44 | tandy200_state *state = | |
| 44 | tandy200_state *state = | |
| 45 | 45 | |
| 46 | 46 | /* find devices */ |
| 47 | 47 | state->hd61830 = machine->device(HD61830_TAG); |
| r8714 | r8715 | |
| 49 | 49 | |
| 50 | 50 | static VIDEO_UPDATE( tandy200 ) |
| 51 | 51 | { |
| 52 | tandy200_state *state = | |
| 52 | tandy200_state *state = | |
| 53 | 53 | |
| 54 | 54 | hd61830_update(state->hd61830, bitmap, cliprect); |
| 55 | 55 |
| r8714 | r8715 | |
|---|---|---|
| 28 | 28 | |
| 29 | 29 | static void draw_mode4_line(running_machine *machine, int y, int hpos) |
| 30 | 30 | { |
| 31 | coupe_asic *asic = | |
| 31 | coupe_asic *asic = | |
| 32 | 32 | |
| 33 | 33 | /* get start address */ |
| 34 | 34 | UINT8 *vram = machine->generic.videoram.u8 + ((y - SAM_BORDER_TOP) * 128) + ((hpos - SAM_BORDER_LEFT) / 4); |
| r8714 | r8715 | |
| 52 | 52 | |
| 53 | 53 | static void draw_mode3_line(running_machine *machine, int y, int hpos) |
| 54 | 54 | { |
| 55 | coupe_asic *asic = | |
| 55 | coupe_asic *asic = | |
| 56 | 56 | |
| 57 | 57 | /* get start address */ |
| 58 | 58 | UINT8 *vram = machine->generic.videoram.u8 + ((y - SAM_BORDER_TOP) * 128) + ((hpos - SAM_BORDER_LEFT) / 4); |
| r8714 | r8715 | |
| 90 | 90 | |
| 91 | 91 | static void draw_mode2_line(running_machine *machine, int y, int hpos) |
| 92 | 92 | { |
| 93 | coupe_asic *asic = | |
| 93 | coupe_asic *asic = | |
| 94 | 94 | |
| 95 | 95 | int cell = (y - SAM_BORDER_TOP) * 32 + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2; |
| 96 | 96 | |
| r8714 | r8715 | |
| 102 | 102 | |
| 103 | 103 | static void draw_mode1_line(running_machine *machine, int y, int hpos) |
| 104 | 104 | { |
| 105 | coupe_asic *asic = | |
| 105 | coupe_asic *asic = | |
| 106 | 106 | |
| 107 | 107 | UINT8 mask = machine->generic.videoram.u8[((((y - SAM_BORDER_TOP) & 0xc0) << 5) | (((y - SAM_BORDER_TOP) & 0x07) << 8) | (((y - SAM_BORDER_TOP) & 0x38) << 2)) + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2]; |
| 108 | 108 | asic->attribute = machine->generic.videoram.u8[32*192 + (((y - SAM_BORDER_TOP) & 0xf8) << 2) + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2]; |
| r8714 | r8715 | |
| 112 | 112 | |
| 113 | 113 | TIMER_CALLBACK( sam_video_update_callback ) |
| 114 | 114 | { |
| 115 | coupe_asic *asic = | |
| 115 | coupe_asic *asic = | |
| 116 | 116 | |
| 117 | 117 | int vpos = machine->primary_screen->vpos(); |
| 118 | 118 | int hpos = machine->primary_screen->hpos(); |
| r8714 | r8715 | |
|---|---|---|
| 10 | 10 | |
| 11 | 11 | static READ8_DEVICE_HANDLER( comx35_pageram_r ) |
| 12 | 12 | { |
| 13 | comx35_state *state = | |
| 13 | comx35_state *state = | |
| 14 | 14 | |
| 15 | 15 | UINT16 addr = offset & COMX35_PAGERAM_MASK; |
| 16 | 16 | |
| r8714 | r8715 | |
| 19 | 19 | |
| 20 | 20 | static WRITE8_DEVICE_HANDLER( comx35_pageram_w ) |
| 21 | 21 | { |
| 22 | comx35_state *state = | |
| 22 | comx35_state *state = | |
| 23 | 23 | |
| 24 | 24 | UINT16 addr = offset & COMX35_PAGERAM_MASK; |
| 25 | 25 | |
| r8714 | r8715 | |
| 28 | 28 | |
| 29 | 29 | static CDP1869_CHAR_RAM_READ( comx35_charram_r ) |
| 30 | 30 | { |
| 31 | comx35_state *state = | |
| 31 | comx35_state *state = | |
| 32 | 32 | |
| 33 | 33 | UINT16 pageaddr = pma & COMX35_PAGERAM_MASK; |
| 34 | 34 | UINT8 column = state->pageram[pageaddr] & 0x7f; |
| r8714 | r8715 | |
| 39 | 39 | |
| 40 | 40 | static CDP1869_CHAR_RAM_WRITE( comx35_charram_w ) |
| 41 | 41 | { |
| 42 | comx35_state *state = | |
| 42 | comx35_state *state = | |
| 43 | 43 | |
| 44 | 44 | UINT16 pageaddr = pma & COMX35_PAGERAM_MASK; |
| 45 | 45 | UINT8 column = state->pageram[pageaddr] & 0x7f; |
| r8714 | r8715 | |
| 50 | 50 | |
| 51 | 51 | static CDP1869_PCB_READ( comx35_pcb_r ) |
| 52 | 52 | { |
| 53 | comx35_state *state = | |
| 53 | comx35_state *state = | |
| 54 | 54 | |
| 55 | 55 | UINT16 pageaddr = pma & COMX35_PAGERAM_MASK; |
| 56 | 56 | |
| r8714 | r8715 | |
| 59 | 59 | |
| 60 | 60 | static WRITE_LINE_DEVICE_HANDLER( comx35_prd_w ) |
| 61 | 61 | { |
| 62 | comx35_state *driver_state = | |
| 62 | comx35_state *driver_state = | |
| 63 | 63 | |
| 64 | 64 | if (!driver_state->iden && !state) |
| 65 | 65 | { |
| r8714 | r8715 | |
| 99 | 99 | |
| 100 | 100 | static VIDEO_START( comx35 ) |
| 101 | 101 | { |
| 102 | comx35_state *state = | |
| 102 | comx35_state *state = | |
| 103 | 103 | |
| 104 | 104 | // allocate memory |
| 105 | 105 | |
| r8714 | r8715 | |
| 141 | 141 | |
| 142 | 142 | READ8_HANDLER( comx35_videoram_r ) |
| 143 | 143 | { |
| 144 | comx35_state *state = | |
| 144 | comx35_state *state = | |
| 145 | 145 | |
| 146 | 146 | return state->videoram[offset]; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | WRITE8_HANDLER( comx35_videoram_w ) |
| 150 | 150 | { |
| 151 | comx35_state *state = | |
| 151 | comx35_state *state = | |
| 152 | 152 | |
| 153 | 153 | state->videoram[offset] = data; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | static MC6845_UPDATE_ROW( comx35_update_row ) |
| 157 | 157 | { |
| 158 | comx35_state *state = | |
| 158 | comx35_state *state = | |
| 159 | 159 | |
| 160 | 160 | UINT8 *charrom = memory_region(device->machine, "chargen"); |
| 161 | 161 | |
| r8714 | r8715 | |
| 186 | 186 | |
| 187 | 187 | static WRITE_LINE_DEVICE_HANDLER( comx35_hsync_changed ) |
| 188 | 188 | { |
| 189 | comx35_state *driver_state = | |
| 189 | comx35_state *driver_state = | |
| 190 | 190 | |
| 191 | 191 | driver_state->cdp1802_ef4 = state; |
| 192 | 192 | } |
| r8714 | r8715 | |
|---|---|---|
| 13 | 13 | |
| 14 | 14 | READ8_HANDLER( abc802_charram_r ) |
| 15 | 15 | { |
| 16 | abc802_state *state = | |
| 16 | abc802_state *state = | |
| 17 | 17 | |
| 18 | 18 | return state->charram[offset]; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | WRITE8_HANDLER( abc802_charram_w ) |
| 22 | 22 | { |
| 23 | abc802_state *state = | |
| 23 | abc802_state *state = | |
| 24 | 24 | |
| 25 | 25 | state->charram[offset] = data; |
| 26 | 26 | } |
| r8714 | r8715 | |
| 68 | 68 | |
| 69 | 69 | */ |
| 70 | 70 | |
| 71 | abc802_state *state = | |
| 71 | abc802_state *state = | |
| 72 | 72 | |
| 73 | 73 | int column; |
| 74 | 74 | int rf = 0, rc = 0, rg = 0; |
| r8714 | r8715 | |
| 170 | 170 | |
| 171 | 171 | static WRITE_LINE_DEVICE_HANDLER( abc802_vsync_changed ) |
| 172 | 172 | { |
| 173 | abc802_state *driver_state = | |
| 173 | abc802_state *driver_state = | |
| 174 | 174 | |
| 175 | 175 | if (!state) |
| 176 | 176 | { |
| r8714 | r8715 | |
| 209 | 209 | |
| 210 | 210 | static VIDEO_START( abc802 ) |
| 211 | 211 | { |
| 212 | abc802_state *state = | |
| 212 | abc802_state *state = | |
| 213 | 213 | |
| 214 | 214 | /* allocate memory */ |
| 215 | 215 | |
| r8714 | r8715 | |
| 236 | 236 | |
| 237 | 237 | static VIDEO_UPDATE( abc802 ) |
| 238 | 238 | { |
| 239 | abc802_state *state = | |
| 239 | abc802_state *state = | |
| 240 | 240 | |
| 241 | 241 | /* expand visible area to workaround MC6845 */ |
| 242 | 242 | screen->set_visible_area(0, 767, 0, 311); |
| r8714 | r8715 | |
|---|---|---|
| 51 | 51 | |
| 52 | 52 | */ |
| 53 | 53 | |
| 54 | abc806_state *state = | |
| 54 | abc806_state *state = | |
| 55 | 55 | |
| 56 | 56 | state->hrs = data; |
| 57 | 57 | } |
| r8714 | r8715 | |
| 60 | 60 | |
| 61 | 61 | WRITE8_HANDLER( abc806_hrc_w ) |
| 62 | 62 | { |
| 63 | abc806_state *state = | |
| 63 | abc806_state *state = | |
| 64 | 64 | |
| 65 | 65 | int reg = (offset >> 8) & 0x0f; |
| 66 | 66 | |
| r8714 | r8715 | |
| 71 | 71 | |
| 72 | 72 | READ8_HANDLER( abc806_charram_r ) |
| 73 | 73 | { |
| 74 | abc806_state *state = | |
| 74 | abc806_state *state = | |
| 75 | 75 | |
| 76 | 76 | state->attr_data = state->colorram[offset]; |
| 77 | 77 | |
| r8714 | r8715 | |
| 80 | 80 | |
| 81 | 81 | WRITE8_HANDLER( abc806_charram_w ) |
| 82 | 82 | { |
| 83 | abc806_state *state = | |
| 83 | abc806_state *state = | |
| 84 | 84 | |
| 85 | 85 | state->colorram[offset] = state->attr_data; |
| 86 | 86 | state->charram[offset] = data; |
| r8714 | r8715 | |
| 90 | 90 | |
| 91 | 91 | READ8_HANDLER( abc806_ami_r ) |
| 92 | 92 | { |
| 93 | abc806_state *state = | |
| 93 | abc806_state *state = | |
| 94 | 94 | |
| 95 | 95 | return state->attr_data; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | WRITE8_HANDLER( abc806_amo_w ) |
| 99 | 99 | { |
| 100 | abc806_state *state = | |
| 100 | abc806_state *state = | |
| 101 | 101 | |
| 102 | 102 | state->attr_data = data; |
| 103 | 103 | } |
| r8714 | r8715 | |
| 106 | 106 | |
| 107 | 107 | READ8_HANDLER( abc806_cli_r ) |
| 108 | 108 | { |
| 109 | abc806_state *state = | |
| 109 | abc806_state *state = | |
| 110 | 110 | |
| 111 | 111 | /* |
| 112 | 112 | |
| r8714 | r8715 | |
| 155 | 155 | |
| 156 | 156 | WRITE8_HANDLER( abc806_sto_w ) |
| 157 | 157 | { |
| 158 | abc806_state *state = | |
| 158 | abc806_state *state = | |
| 159 | 159 | |
| 160 | 160 | int level = BIT(data, 7); |
| 161 | 161 | |
| r8714 | r8715 | |
| 199 | 199 | |
| 200 | 200 | WRITE8_HANDLER( abc806_sso_w ) |
| 201 | 201 | { |
| 202 | abc806_state *state = | |
| 202 | abc806_state *state = | |
| 203 | 203 | |
| 204 | 204 | state->sync = data & 0x3f; |
| 205 | 205 | } |
| r8714 | r8715 | |
| 208 | 208 | |
| 209 | 209 | static MC6845_UPDATE_ROW( abc806_update_row ) |
| 210 | 210 | { |
| 211 | abc806_state *state = | |
| 211 | abc806_state *state = | |
| 212 | 212 | |
| 213 | 213 | int column; |
| 214 | 214 | |
| r8714 | r8715 | |
| 324 | 324 | |
| 325 | 325 | static WRITE_LINE_DEVICE_HANDLER( abc806_hsync_changed ) |
| 326 | 326 | { |
| 327 | abc806_state *driver_state = | |
| 327 | abc806_state *driver_state = | |
| 328 | 328 | |
| 329 | 329 | int vsync; |
| 330 | 330 | |
| r8714 | r8715 | |
| 369 | 369 | |
| 370 | 370 | static WRITE_LINE_DEVICE_HANDLER( abc806_vsync_changed ) |
| 371 | 371 | { |
| 372 | abc806_state *driver_state = | |
| 372 | abc806_state *driver_state = | |
| 373 | 373 | |
| 374 | 374 | driver_state->vsync = state; |
| 375 | 375 | } |
| r8714 | r8715 | |
| 393 | 393 | |
| 394 | 394 | static void abc806_hr_update(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 395 | 395 | { |
| 396 | abc806_state *state = | |
| 396 | abc806_state *state = | |
| 397 | 397 | |
| 398 | 398 | UINT32 addr = (state->hrs & 0x0f) << 15; |
| 399 | 399 | int sx, y, pixel; |
| r8714 | r8715 | |
| 424 | 424 | |
| 425 | 425 | static VIDEO_START(abc806) |
| 426 | 426 | { |
| 427 | abc806_state *state = | |
| 427 | abc806_state *state = | |
| 428 | 428 | |
| 429 | 429 | int i; |
| 430 | 430 | |
| r8714 | r8715 | |
| 480 | 480 | |
| 481 | 481 | static VIDEO_UPDATE( abc806 ) |
| 482 | 482 | { |
| 483 | abc806_state *state = | |
| 483 | abc806_state *state = | |
| 484 | 484 | |
| 485 | 485 | /* expand visible area to workaround MC6845 */ |
| 486 | 486 | screen->set_visible_area(0, 767, 0, 311); |
| r8714 | r8715 | |
|---|---|---|
| 14 | 14 | |
| 15 | 15 | static READ8_DEVICE_HANDLER( pecom_page_ram_r ) |
| 16 | 16 | { |
| 17 | pecom_state *state = | |
| 17 | pecom_state *state = | |
| 18 | 18 | |
| 19 | 19 | UINT16 addr = offset & PECOM_PAGE_RAM_MASK; |
| 20 | 20 | |
| r8714 | r8715 | |
| 23 | 23 | |
| 24 | 24 | static WRITE8_DEVICE_HANDLER( pecom_page_ram_w ) |
| 25 | 25 | { |
| 26 | pecom_state *state = | |
| 26 | pecom_state *state = | |
| 27 | 27 | |
| 28 | 28 | UINT16 addr = offset & PECOM_PAGE_RAM_MASK; |
| 29 | 29 | |
| r8714 | r8715 | |
| 33 | 33 | |
| 34 | 34 | static CDP1869_CHAR_RAM_READ( pecom_char_ram_r ) |
| 35 | 35 | { |
| 36 | pecom_state *state = | |
| 36 | pecom_state *state = | |
| 37 | 37 | |
| 38 | 38 | UINT16 pageaddr = pma & PECOM_PAGE_RAM_MASK; |
| 39 | 39 | UINT8 column = state->page_ram[pageaddr] & 0x7f; |
| r8714 | r8715 | |
| 44 | 44 | |
| 45 | 45 | static CDP1869_CHAR_RAM_WRITE( pecom_char_ram_w ) |
| 46 | 46 | { |
| 47 | pecom_state *state = | |
| 47 | pecom_state *state = | |
| 48 | 48 | |
| 49 | 49 | UINT16 pageaddr = pma & PECOM_PAGE_RAM_MASK; |
| 50 | 50 | UINT8 column = state->page_ram[pageaddr] & 0x7f; |
| r8714 | r8715 | |
| 55 | 55 | |
| 56 | 56 | static CDP1869_PCB_READ( pecom_pcb_r ) |
| 57 | 57 | { |
| 58 | pecom_state *state = | |
| 58 | pecom_state *state = | |
| 59 | 59 | |
| 60 | 60 | UINT16 pageaddr = pma & PECOM_PAGE_RAM_MASK; |
| 61 | 61 | |
| r8714 | r8715 | |
| 65 | 65 | |
| 66 | 66 | static WRITE_LINE_DEVICE_HANDLER( pecom_prd_w ) |
| 67 | 67 | { |
| 68 | pecom_state *driver_state = | |
| 68 | pecom_state *driver_state = | |
| 69 | 69 | // every other PRD triggers a DMAOUT request |
| 70 | 70 | if (driver_state->dma) |
| 71 | 71 | { |
| r8714 | r8715 | |
| 97 | 97 | |
| 98 | 98 | static VIDEO_START( pecom ) |
| 99 | 99 | { |
| 100 | pecom_state *state = | |
| 100 | pecom_state *state = | |
| 101 | 101 | |
| 102 | 102 | /* allocate memory */ |
| 103 | 103 | |
| r8714 | r8715 | |
| 116 | 116 | |
| 117 | 117 | static VIDEO_UPDATE( pecom ) |
| 118 | 118 | { |
| 119 | pecom_state *state = | |
| 119 | pecom_state *state = | |
| 120 | 120 | |
| 121 | 121 | cdp1869_update(state->cdp1869, bitmap, cliprect); |
| 122 | 122 |
| r8714 | r8715 | |
|---|---|---|
| 1767 | 1767 | UINT16 *scanline = BITMAP_ADDR16(bitmap, y, 0); |
| 1768 | 1768 | int i, x; |
| 1769 | 1769 | static UINT32 xferscan[7][240+2048]; // up to 1024 pixels of slop on either side to allow easier clip handling |
| 1770 | gba_state *state = | |
| 1770 | gba_state *state = | |
| 1771 | 1771 | UINT8 submode = 0; |
| 1772 | 1772 | int bpp = 0; |
| 1773 | 1773 |
| r8714 | r8715 | |
|---|---|---|
| 131 | 131 | }; |
| 132 | 132 | |
| 133 | 133 | /* driver state */ |
| 134 | class gba_state | |
| 134 | class gba_state : public driver_data_t | |
| 135 | 135 | { |
| 136 | 136 | public: |
| 137 | static | |
| 137 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gba_state(machine)); } | |
| 138 | 138 | |
| 139 | gba_state(running_machine &machine) { } | |
| 139 | gba_state(running_machine &machine) | |
| 140 | : driver_data_t(machine) { } | |
| 140 | 141 | |
| 141 | 142 | UINT32 DISPSTAT; |
| 142 | 143 | UINT32 BG2X, BG2Y, BG3X, BG3Y; |
| r8714 | r8715 | |
|---|---|---|
| 9 | 9 | #define DISCRETE_TAG "discrete" |
| 10 | 10 | #define CASSETTE_TAG "cassette" |
| 11 | 11 | |
| 12 | class vidbrain_state | |
| 12 | class vidbrain_state : public driver_data_t | |
| 13 | 13 | { |
| 14 | 14 | public: |
| 15 | static | |
| 15 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vidbrain_state(machine)); } | |
| 16 | 16 | |
| 17 | vidbrain_state(running_machine &machine) { } | |
| 17 | vidbrain_state(running_machine &machine) | |
| 18 | : driver_data_t(machine) { } | |
| 18 | 19 | |
| 19 | 20 | /* keyboard state */ |
| 20 | 21 | UINT8 keylatch; |
| r8714 | r8715 | |
|---|---|---|
| 31 | 31 | #define VIP_LED_Q 1 |
| 32 | 32 | #define VIP_LED_TAPE 2 |
| 33 | 33 | |
| 34 | class vip_state | |
| 34 | class vip_state : public driver_data_t | |
| 35 | 35 | { |
| 36 | 36 | public: |
| 37 | static | |
| 37 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vip_state(machine)); } | |
| 38 | 38 | |
| 39 | vip_state(running_machine &machine) { } | |
| 39 | vip_state(running_machine &machine) | |
| 40 | : driver_data_t(machine) { } | |
| 40 | 41 | |
| 41 | 42 | /* cpu state */ |
| 42 | 43 | int reset; /* reset activated */ |
| r8714 | r8715 | |
|---|---|---|
| 9 | 9 | #define DM9368_H_TAG "a8" |
| 10 | 10 | #define CASSETTE_TAG "cassette" |
| 11 | 11 | |
| 12 | class elf2_state | |
| 12 | class elf2_state : public driver_data_t | |
| 13 | 13 | { |
| 14 | 14 | public: |
| 15 | static | |
| 15 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, elf2_state(machine)); } | |
| 16 | 16 | |
| 17 | elf2_state(running_machine &machine) { } | |
| 17 | elf2_state(running_machine &machine) | |
| 18 | : driver_data_t(machine) { } | |
| 18 | 19 | |
| 19 | 20 | /* display state */ |
| 20 | 21 | int cdp1861_efx; /* EFx */ |
| r8714 | r8715 | |
|---|---|---|
| 8 | 8 | #define CASSETTE_TAG "cassette" |
| 9 | 9 | #define SPEAKER_TAG "speaker" |
| 10 | 10 | |
| 11 | class exp85_state | |
| 11 | class exp85_state : public driver_data_t | |
| 12 | 12 | { |
| 13 | 13 | public: |
| 14 | static | |
| 14 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, exp85_state(machine)); } | |
| 15 | 15 | |
| 16 | exp85_state(running_machine &machine) { } | |
| 16 | exp85_state(running_machine &machine) | |
| 17 | : driver_data_t(machine) { } | |
| 17 | 18 | |
| 18 | 19 | /* cassette state */ |
| 19 | 20 | int tape_control; |
| r8714 | r8715 | |
|---|---|---|
| 13 | 13 | #define MC6845_TAG "u11" |
| 14 | 14 | #define CENTRONICS_TAG "j2" |
| 15 | 15 | |
| 16 | class trs80m2_state | |
| 16 | class trs80m2_state : public driver_data_t | |
| 17 | 17 | { |
| 18 | 18 | public: |
| 19 | static | |
| 19 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, trs80m2_state(machine)); } | |
| 20 | 20 | |
| 21 | trs80m2_state(running_machine &machine) { } | |
| 21 | trs80m2_state(running_machine &machine) | |
| 22 | : driver_data_t(machine) { } | |
| 22 | 23 | |
| 23 | 24 | /* memory state */ |
| 24 | 25 | int boot_rom; |
| r8714 | r8715 | |
|---|---|---|
| 18 | 18 | #define PC8500_LCD_VIDEORAM_SIZE 0x4000 |
| 19 | 19 | #define PC8500_LCD_VIDEORAM_MASK 0x3fff |
| 20 | 20 | |
| 21 | class pc8401a_state | |
| 21 | class pc8401a_state : public driver_data_t | |
| 22 | 22 | { |
| 23 | 23 | public: |
| 24 | static | |
| 24 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pc8401a_state(machine)); } | |
| 25 | 25 | |
| 26 | pc8401a_state(running_machine &machine) { } | |
| 26 | pc8401a_state(running_machine &machine) | |
| 27 | : driver_data_t(machine) { } | |
| 27 | 28 | |
| 28 | 29 | /* keyboard state */ |
| 29 | 30 | int key_strobe; /* key pressed */ |
| r8714 | r8715 | |
|---|---|---|
| 7 | 7 | #ifndef _3DO_H_ |
| 8 | 8 | #define _3DO_H_ |
| 9 | 9 | |
| 10 | class _3do_state | |
| 10 | class _3do_state : public driver_data_t | |
| 11 | 11 | { |
| 12 | 12 | public: |
| 13 | static | |
| 13 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, _3do_state(machine)); } | |
| 14 | 14 | |
| 15 | _3do_state(running_machine &machine) { } | |
| 15 | _3do_state(running_machine &machine) | |
| 16 | : driver_data_t(machine) { } | |
| 16 | 17 | |
| 17 | 18 | legacy_cpu_device* maincpu; |
| 18 | 19 | UINT32 *dram; |
| r8714 | r8715 | |
|---|---|---|
| 12 | 12 | #define MC1000_MC6845_VIDEORAM_SIZE 0x800 |
| 13 | 13 | #define MC1000_MC6847_VIDEORAM_SIZE 0x1800 |
| 14 | 14 | |
| 15 | class mc1000_state | |
| 15 | class mc1000_state : public driver_data_t | |
| 16 | 16 | { |
| 17 | 17 | public: |
| 18 | static | |
| 18 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mc1000_state(machine)); } | |
| 19 | 19 | |
| 20 | mc1000_state(running_machine &machine) { } | |
| 20 | mc1000_state(running_machine &machine) | |
| 21 | : driver_data_t(machine) { } | |
| 21 | 22 | |
| 22 | 23 | /* cpu state */ |
| 23 | 24 | int ne555_int; |
| r8714 | r8715 | |
|---|---|---|
| 177 | 177 | |
| 178 | 178 | /* Mac driver data */ |
| 179 | 179 | |
| 180 | class mac_state | |
| 180 | class mac_state : public driver_data_t | |
| 181 | 181 | { |
| 182 | 182 | public: |
| 183 | static | |
| 183 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mac_state(machine)); } | |
| 184 | 184 | |
| 185 | mac_state(running_machine &machine) { } | |
| 185 | mac_state(running_machine &machine) | |
| 186 | : driver_data_t(machine) { } | |
| 186 | 187 | |
| 187 | 188 | mac_model_t mac_model; |
| 188 | 189 |
| r8714 | r8715 | |
|---|---|---|
| 15 | 15 | #include "machine/6526cia.h" |
| 16 | 16 | #include "devices/cartslot.h" |
| 17 | 17 | |
| 18 | class cbmb_state | |
| 18 | class cbmb_state : public driver_data_t | |
| 19 | 19 | { |
| 20 | 20 | public: |
| 21 | static | |
| 21 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cbmb_state(machine)); } | |
| 22 | 22 | |
| 23 | cbmb_state(running_machine &machine) { } | |
| 23 | cbmb_state(running_machine &machine) | |
| 24 | : driver_data_t(machine) { } | |
| 24 | 25 | |
| 25 | 26 | /* keyboard lines */ |
| 26 | 27 | int cbmb_keyline_a; |
| r8714 | r8715 | |
|---|---|---|
| 15 | 15 | #define BW12_VIDEORAM_MASK 0x7ff |
| 16 | 16 | #define BW12_CHARROM_MASK 0xfff |
| 17 | 17 | |
| 18 | class bw12_state | |
| 18 | class bw12_state : public driver_data_t | |
| 19 | 19 | { |
| 20 | 20 | public: |
| 21 | static | |
| 21 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bw12_state(machine)); } | |
| 22 | 22 | |
| 23 | bw12_state(running_machine &machine) { } | |
| 23 | bw12_state(running_machine &machine) | |
| 24 | : driver_data_t(machine) { } | |
| 24 | 25 | |
| 25 | 26 | /* memory state */ |
| 26 | 27 | int bank; |
| r8714 | r8715 | |
|---|---|---|
| 29 | 29 | TYPE DEFINITIONS |
| 30 | 30 | ***************************************************************************/ |
| 31 | 31 | |
| 32 | class coco_state | |
| 32 | class coco_state : public driver_data_t | |
| 33 | 33 | { |
| 34 | 34 | public: |
| 35 | static | |
| 35 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, coco_state(machine)); } | |
| 36 | 36 | |
| 37 | coco_state(running_machine &machine) { } | |
| 37 | coco_state(running_machine &machine) | |
| 38 | : driver_data_t(machine) { } | |
| 38 | 39 | |
| 39 | 40 | running_device *cococart_device; |
| 40 | 41 | running_device *cassette_device; |
| r8714 | r8715 | |
|---|---|---|
| 64 | 64 | typedef void (*nes_prg_callback)(running_machine *machine, int start, int bank); |
| 65 | 65 | typedef void (*nes_chr_callback)(running_machine *machine, int start, int bank, int source); |
| 66 | 66 | |
| 67 | class nes_state | |
| 67 | class nes_state : public driver_data_t | |
| 68 | 68 | { |
| 69 | 69 | public: |
| 70 | static | |
| 70 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nes_state(machine)); } | |
| 71 | 71 | |
| 72 | nes_state(running_machine &machine) { } | |
| 72 | nes_state(running_machine &machine) | |
| 73 | : driver_data_t(machine) { } | |
| 73 | 74 | |
| 74 | 75 | /* input_related - this part has to be cleaned up (e.g. in_2 and in_3 are not really necessary here...) */ |
| 75 | 76 | nes_input in_0, in_1, in_2, in_3; |
| r8714 | r8715 | |
|---|---|---|
| 13 | 13 | #define CENTRONICS_TAG "centronics" |
| 14 | 14 | #define TERMINAL_TAG "terminal" |
| 15 | 15 | |
| 16 | class xor100_state | |
| 16 | class xor100_state : public driver_data_t | |
| 17 | 17 | { |
| 18 | 18 | public: |
| 19 | static | |
| 19 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, xor100_state(machine)); } | |
| 20 | 20 | |
| 21 | xor100_state(running_machine &machine) { } | |
| 21 | xor100_state(running_machine &machine) | |
| 22 | : driver_data_t(machine) { } | |
| 22 | 23 | |
| 23 | 24 | /* memory state */ |
| 24 | 25 | int mode; |
| r8714 | r8715 | |
|---|---|---|
| 10 | 10 | #define TMC600_PAGE_RAM_SIZE 0x400 |
| 11 | 11 | #define TMC600_PAGE_RAM_MASK 0x3ff |
| 12 | 12 | |
| 13 | class tmc600_state | |
| 13 | class tmc600_state : public driver_data_t | |
| 14 | 14 | { |
| 15 | 15 | public: |
| 16 | static | |
| 16 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tmc600_state(machine)); } | |
| 17 | 17 | |
| 18 | tmc600_state(running_machine &machine) { } | |
| 18 | tmc600_state(running_machine &machine) | |
| 19 | : driver_data_t(machine) { } | |
| 19 | 20 | |
| 20 | 21 | /* video state */ |
| 21 | 22 | int vismac_reg_latch; /* video register latch */ |
| r8714 | r8715 | |
|---|---|---|
| 11 | 11 | #define I8048_TAG "i8048" |
| 12 | 12 | #define COP411_TAG "cop411" |
| 13 | 13 | |
| 14 | class advision_state | |
| 14 | class advision_state : public driver_data_t | |
| 15 | 15 | { |
| 16 | 16 | public: |
| 17 | static | |
| 17 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, advision_state(machine)); } | |
| 18 | 18 | |
| 19 | advision_state(running_machine &machine) { } | |
| 19 | advision_state(running_machine &machine) | |
| 20 | : driver_data_t(machine) { } | |
| 20 | 21 | |
| 21 | 22 | /* external RAM state */ |
| 22 | 23 | UINT8 *extram; |
| r8714 | r8715 | |
|---|---|---|
| 17 | 17 | #include "machine/z80pio.h" |
| 18 | 18 | |
| 19 | 19 | |
| 20 | class mz_state | |
| 20 | class mz_state : public driver_data_t | |
| 21 | 21 | { |
| 22 | 22 | public: |
| 23 | static | |
| 23 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mz_state(machine)); } | |
| 24 | 24 | |
| 25 | mz_state(running_machine &machine) { } | |
| 25 | mz_state(running_machine &machine) | |
| 26 | : driver_data_t(machine) { } | |
| 26 | 27 | |
| 27 | 28 | int mz700; /* 1 if running on an mz700 */ |
| 28 | 29 |
| r8714 | r8715 | |
|---|---|---|
| 26 | 26 | #define UNIO_CENTRONICS1_TAG "n3" |
| 27 | 27 | #define UNIO_CENTRONICS2_TAG "n4" |
| 28 | 28 | |
| 29 | class prof80_state | |
| 29 | class prof80_state : public driver_data_t | |
| 30 | 30 | { |
| 31 | 31 | public: |
| 32 | static | |
| 32 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, prof80_state(machine)); } | |
| 33 | 33 | |
| 34 | prof80_state(running_machine &machine) { } | |
| 34 | prof80_state(running_machine &machine) | |
| 35 | : driver_data_t(machine) { } | |
| 35 | 36 | |
| 36 | 37 | /* memory state */ |
| 37 | 38 | UINT8 mmu[16]; /* MMU block register */ |
| r8714 | r8715 | |
|---|---|---|
| 13 | 13 | #include "sound/speaker.h" |
| 14 | 14 | #include "sound/wave.h" |
| 15 | 15 | |
| 16 | class b2m_state | |
| 16 | class b2m_state : public driver_data_t | |
| 17 | 17 | { |
| 18 | 18 | public: |
| 19 | static | |
| 19 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, b2m_state(machine)); } | |
| 20 | 20 | |
| 21 | b2m_state(running_machine &machine) { } | |
| 21 | b2m_state(running_machine &machine) | |
| 22 | : driver_data_t(machine) { } | |
| 22 | 23 | |
| 23 | 24 | UINT8 b2m_8255_porta; |
| 24 | 25 | UINT8 b2m_video_scroll; |
| r8714 | r8715 | |
|---|---|---|
| 14 | 14 | #define CASSETTE_TAG "cassette" |
| 15 | 15 | #define TIMER_C1530_TAG "c1530" |
| 16 | 16 | |
| 17 | class vic20_state | |
| 17 | class vic20_state : public driver_data_t | |
| 18 | 18 | { |
| 19 | 19 | public: |
| 20 | static | |
| 20 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vic20_state(machine)); } | |
| 21 | 21 | |
| 22 | vic20_state(running_machine &machine) { } | |
| 22 | vic20_state(running_machine &machine) | |
| 23 | : driver_data_t(machine) { } | |
| 23 | 24 | |
| 24 | 25 | /* keyboard state */ |
| 25 | 26 | int key_col; |
| r8714 | r8715 | |
|---|---|---|
| 51 | 51 | #define ABCBUS_TAG "abcbus" |
| 52 | 52 | #define CASSETTE_TAG "cassette" |
| 53 | 53 | |
| 54 | class abc80_state | |
| 54 | class abc80_state : public driver_data_t | |
| 55 | 55 | { |
| 56 | 56 | public: |
| 57 | static | |
| 57 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, abc80_state(machine)); } | |
| 58 | 58 | |
| 59 | abc80_state(running_machine &machine) { } | |
| 59 | abc80_state(running_machine &machine) | |
| 60 | : driver_data_t(machine) { } | |
| 60 | 61 | |
| 61 | 62 | /* keyboard state */ |
| 62 | 63 | int key_data; |
| r8714 | r8715 | |
|---|---|---|
| 51 | 51 | #define TS2068_RIGHT_BORDER 96 /* Number of right hand border pixels */ |
| 52 | 52 | #define TS2068_SCREEN_WIDTH (TS2068_LEFT_BORDER + TS2068_DISPLAY_XSIZE + TS2068_RIGHT_BORDER) |
| 53 | 53 | |
| 54 | class spectrum_state | |
| 54 | class spectrum_state : public driver_data_t | |
| 55 | 55 | { |
| 56 | 56 | public: |
| 57 | static | |
| 57 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, spectrum_state(machine)); } | |
| 58 | 58 | |
| 59 | spectrum_state(running_machine &machine) { } | |
| 59 | spectrum_state(running_machine &machine) | |
| 60 | : driver_data_t(machine) { } | |
| 60 | 61 | |
| 61 | 62 | int port_fe_data; |
| 62 | 63 | int port_7ffd_data; |
| r8714 | r8715 | |
|---|---|---|
| 9 | 9 | #define CASSETTE_TAG "cassette" |
| 10 | 10 | #define SPEAKER_TAG "speaker" |
| 11 | 11 | |
| 12 | class mpf1_state | |
| 12 | class mpf1_state : public driver_data_t | |
| 13 | 13 | { |
| 14 | 14 | public: |
| 15 | static | |
| 15 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mpf1_state(machine)); } | |
| 16 | 16 | |
| 17 | mpf1_state(running_machine &machine) { } | |
| 17 | mpf1_state(running_machine &machine) | |
| 18 | : driver_data_t(machine) { } | |
| 18 | 19 | |
| 19 | 20 | int _break; |
| 20 | 21 | int m1; |
| r8714 | r8715 | |
|---|---|---|
| 48 | 48 | IKBD_MOUSE_PHASE_NEGATIVE |
| 49 | 49 | }; |
| 50 | 50 | |
| 51 | class atarist_state | |
| 51 | class atarist_state : public driver_data_t | |
| 52 | 52 | { |
| 53 | 53 | public: |
| 54 | static | |
| 54 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, atarist_state(machine)); } | |
| 55 | 55 | |
| 56 | atarist_state(running_machine &machine) { } | |
| 56 | atarist_state(running_machine &machine) | |
| 57 | : driver_data_t(machine) { } | |
| 57 | 58 | |
| 58 | 59 | /* memory state */ |
| 59 | 60 | UINT8 mmu; |
| r8714 | r8715 | |
|---|---|---|
| 33 | 33 | running_device *image; |
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | class victor9k_state | |
| 36 | class victor9k_state : public driver_data_t | |
| 37 | 37 | { |
| 38 | 38 | public: |
| 39 | static | |
| 39 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, victor9k_state(machine)); } | |
| 40 | 40 | |
| 41 | victor9k_state(running_machine &machine) { } | |
| 41 | victor9k_state(running_machine &machine) | |
| 42 | : driver_data_t(machine) { } | |
| 42 | 43 | |
| 43 | 44 | /* video state */ |
| 44 | 45 | UINT8 *video_ram; |
| r8714 | r8715 | |
|---|---|---|
| 24 | 24 | #define IS_CARTRIDGE_MUSIC_EDITOR(ptr) \ |
| 25 | 25 | (!strncmp("PIANO", (const char *)&ptr[0x0841], 5)) |
| 26 | 26 | |
| 27 | class sg1000_state | |
| 27 | class sg1000_state : public driver_data_t | |
| 28 | 28 | { |
| 29 | 29 | public: |
| 30 | static | |
| 30 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sg1000_state(machine)); } | |
| 31 | 31 | |
| 32 | sg1000_state(running_machine &machine) { } | |
| 32 | sg1000_state(running_machine &machine) | |
| 33 | : driver_data_t(machine) { } | |
| 33 | 34 | |
| 34 | 35 | /* keyboard state */ |
| 35 | 36 | UINT8 keylatch; |
| r8714 | r8715 | |
|---|---|---|
| 7 | 7 | #define EPROM_TAG "eprom" |
| 8 | 8 | #define SPEAKER_TAG "b237" |
| 9 | 9 | |
| 10 | class beta_state | |
| 10 | class beta_state : public driver_data_t | |
| 11 | 11 | { |
| 12 | 12 | public: |
| 13 | static | |
| 13 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, beta_state(machine)); } | |
| 14 | 14 | |
| 15 | beta_state(running_machine &machine) { } | |
| 15 | beta_state(running_machine &machine) | |
| 16 | : driver_data_t(machine) { } | |
| 16 | 17 | |
| 17 | 18 | /* EPROM state */ |
| 18 | 19 | int eprom_oe; |
| r8714 | r8715 | |
|---|---|---|
| 12 | 12 | #define SCREEN_TAG "screen" |
| 13 | 13 | #define SPEAKER_TAG "speaker" |
| 14 | 14 | |
| 15 | class pc8001_state | |
| 15 | class pc8001_state : public driver_data_t | |
| 16 | 16 | { |
| 17 | 17 | public: |
| 18 | static | |
| 18 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pc8001_state(machine)); } | |
| 19 | 19 | |
| 20 | pc8001_state(running_machine &machine) { } | |
| 20 | pc8001_state(running_machine &machine) | |
| 21 | : driver_data_t(machine) { } | |
| 21 | 22 | |
| 22 | 23 | /* video state */ |
| 23 | 24 | UINT8 *char_rom; |
| r8714 | r8715 | |
|---|---|---|
| 15 | 15 | LED_PULSE |
| 16 | 16 | }; |
| 17 | 17 | |
| 18 | class eti660_state | |
| 18 | class eti660_state : public driver_data_t | |
| 19 | 19 | { |
| 20 | 20 | public: |
| 21 | static | |
| 21 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, eti660_state(machine)); } | |
| 22 | 22 | |
| 23 | eti660_state(running_machine &machine) { } | |
| 23 | eti660_state(running_machine &machine) | |
| 24 | : driver_data_t(machine) { } | |
| 24 | 25 | |
| 25 | 26 | /* cpu state */ |
| 26 | 27 | cdp1802_control_mode cdp1802_mode; |
| r8714 | r8715 | |
|---|---|---|
| 12 | 12 | |
| 13 | 13 | #define PX8_VIDEORAM_MASK 0x17ff |
| 14 | 14 | |
| 15 | class px8_state | |
| 15 | class px8_state : public driver_data_t | |
| 16 | 16 | { |
| 17 | 17 | public: |
| 18 | static | |
| 18 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, px8_state(machine)); } | |
| 19 | 19 | |
| 20 | px8_state(running_machine &machine) { } | |
| 20 | px8_state(running_machine &machine) | |
| 21 | : driver_data_t(machine) { } | |
| 21 | 22 | |
| 22 | 23 | /* GAH40M state */ |
| 23 | 24 | UINT16 icr; /* input capture register */ |
| r8714 | r8715 | |
|---|---|---|
| 10 | 10 | |
| 11 | 11 | #define PHC25_VIDEORAM_SIZE 0x1800 |
| 12 | 12 | |
| 13 | class phc25_state | |
| 13 | class phc25_state : public driver_data_t | |
| 14 | 14 | { |
| 15 | 15 | public: |
| 16 | static | |
| 16 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, phc25_state(machine)); } | |
| 17 | 17 | |
| 18 | phc25_state(running_machine &machine) { } | |
| 18 | phc25_state(running_machine &machine) | |
| 19 | : driver_data_t(machine) { } | |
| 19 | 20 | |
| 20 | 21 | /* video state */ |
| 21 | 22 | UINT8 *video_ram; |
| r8714 | r8715 | |
|---|---|---|
| 12 | 12 | #define UPD7220_TAG "ic101" |
| 13 | 13 | #define SPEAKER_TAG "speaker" |
| 14 | 14 | |
| 15 | class mm1_state | |
| 15 | class mm1_state : public driver_data_t | |
| 16 | 16 | { |
| 17 | 17 | public: |
| 18 | static | |
| 18 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mm1_state(machine)); } | |
| 19 | 19 | |
| 20 | mm1_state(running_machine &machine) { } | |
| 20 | mm1_state(running_machine &machine) | |
| 21 | : driver_data_t(machine) { } | |
| 21 | 22 | |
| 22 | 23 | /* keyboard state */ |
| 23 | 24 | int sense; |
| r8714 | r8715 | |
|---|---|---|
| 8 | 8 | #define Z80PIO2_TAG "i3" |
| 9 | 9 | #define CASSETTE_TAG "cassette" |
| 10 | 10 | |
| 11 | class poly880_state | |
| 11 | class poly880_state : public driver_data_t | |
| 12 | 12 | { |
| 13 | 13 | public: |
| 14 | static | |
| 14 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, poly880_state(machine)); } | |
| 15 | 15 | |
| 16 | poly880_state(running_machine &machine) { } | |
| 16 | poly880_state(running_machine &machine) | |
| 17 | : driver_data_t(machine) { } | |
| 17 | 18 | |
| 18 | 19 | /* display state */ |
| 19 | 20 | UINT8 digit; |
| r8714 | r8715 | |
|---|---|---|
| 19 | 19 | #include "machine/upd765.h" |
| 20 | 20 | #include "machine/i8255a.h" |
| 21 | 21 | |
| 22 | class pc88_state | |
| 22 | class pc88_state : public driver_data_t | |
| 23 | 23 | { |
| 24 | 24 | public: |
| 25 | static | |
| 25 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pc88_state(machine)); } | |
| 26 | 26 | |
| 27 | pc88_state(running_machine &machine) { } | |
| 27 | pc88_state(running_machine &machine) | |
| 28 | : driver_data_t(machine) { } | |
| 28 | 29 | |
| 29 | 30 | /* floppy state */ |
| 30 | 31 | UINT8 i8255_0_pc; |
| r8714 | r8715 | |
|---|---|---|
| 12 | 12 | #include "machine/6522via.h" |
| 13 | 13 | #include "devices/cartslot.h" |
| 14 | 14 | |
| 15 | class pet_state | |
| 15 | class pet_state : public driver_data_t | |
| 16 | 16 | { |
| 17 | 17 | public: |
| 18 | static | |
| 18 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pet_state(machine)); } | |
| 19 | 19 | |
| 20 | pet_state(running_machine &machine) { } | |
| 20 | pet_state(running_machine &machine) | |
| 21 | : driver_data_t(machine) { } | |
| 21 | 22 | |
| 22 | 23 | int pet_basic1; /* basic version 1 for quickloader */ |
| 23 | 24 | int superpet; |
| r8714 | r8715 | |
|---|---|---|
| 8 | 8 | #define CDP1864_TAG "cdp1864" |
| 9 | 9 | #define SCREEN_TAG "screen" |
| 10 | 10 | |
| 11 | class studio2_state | |
| 11 | class studio2_state : public driver_data_t | |
| 12 | 12 | { |
| 13 | 13 | public: |
| 14 | static | |
| 14 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, studio2_state(machine)); } | |
| 15 | 15 | |
| 16 | studio2_state(running_machine &machine) { } | |
| 16 | studio2_state(running_machine &machine) | |
| 17 | : driver_data_t(machine) { } | |
| 17 | 18 | |
| 18 | 19 | /* cpu state */ |
| 19 | 20 | cdp1802_control_mode cdp1802_mode; |
| r8714 | r8715 | |
|---|---|---|
| 7 | 7 | #ifndef __C16_H__ |
| 8 | 8 | #define __C16_H__ |
| 9 | 9 | |
| 10 | class c16_state | |
| 10 | class c16_state : public driver_data_t | |
| 11 | 11 | { |
| 12 | 12 | public: |
| 13 | static | |
| 13 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, c16_state(machine)); } | |
| 14 | 14 | |
| 15 | c16_state(running_machine &machine) { } | |
| 15 | c16_state(running_machine &machine) | |
| 16 | : driver_data_t(machine) { } | |
| 16 | 17 | |
| 17 | 18 | /* memory pointers */ |
| 18 | 19 | UINT8 * mem10000; |
| r8714 | r8715 | |
|---|---|---|
| 24 | 24 | BANK_ROM |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | class bw2_state | |
| 27 | class bw2_state : public driver_data_t | |
| 28 | 28 | { |
| 29 | 29 | public: |
| 30 | static | |
| 30 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bw2_state(machine)); } | |
| 31 | 31 | |
| 32 | bw2_state(running_machine &machine) { } | |
| 32 | bw2_state(running_machine &machine) | |
| 33 | : driver_data_t(machine) { } | |
| 33 | 34 | |
| 34 | 35 | |
| 35 | 36 | /* keyboard state */ |
| r8714 | r8715 | |
|---|---|---|
| 11 | 11 | #define OSI600_VIDEORAM_SIZE 0x400 |
| 12 | 12 | #define OSI630_COLORRAM_SIZE 0x400 |
| 13 | 13 | |
| 14 | class osi_state | |
| 14 | class osi_state : public driver_data_t | |
| 15 | 15 | { |
| 16 | 16 | public: |
| 17 | static | |
| 17 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, osi_state(machine)); } | |
| 18 | 18 | |
| 19 | osi_state(running_machine &machine) { } | |
| 19 | osi_state(running_machine &machine) | |
| 20 | : driver_data_t(machine) { } | |
| 20 | 21 | |
| 21 | 22 | /* keyboard state */ |
| 22 | 23 | UINT8 keylatch; |
| r8714 | r8715 | |
|---|---|---|
| 19 | 19 | #define X1 XTAL_3_579545MHz // MC6847 Clock |
| 20 | 20 | #define X2 XTAL_4MHz // CPU Clock - a divider reduces it to 1MHz |
| 21 | 21 | |
| 22 | class atom_state | |
| 22 | class atom_state : public driver_data_t | |
| 23 | 23 | { |
| 24 | 24 | public: |
| 25 | static | |
| 25 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, atom_state(machine)); } | |
| 26 | 26 | |
| 27 | atom_state(running_machine &machine) { } | |
| 27 | atom_state(running_machine &machine) | |
| 28 | : driver_data_t(machine) { } | |
| 28 | 29 | |
| 29 | 30 | /* eprom state */ |
| 30 | 31 | int eprom; |
| r8714 | r8715 | |
|---|---|---|
| 11 | 11 | |
| 12 | 12 | #include "machine/8237dma.h" |
| 13 | 13 | |
| 14 | class at_state | |
| 14 | class at_state : public driver_data_t | |
| 15 | 15 | { |
| 16 | 16 | public: |
| 17 | static | |
| 17 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, at_state(machine)); } | |
| 18 | 18 | |
| 19 | at_state(running_machine &machine) { } | |
| 19 | at_state(running_machine &machine) | |
| 20 | : driver_data_t(machine) { } | |
| 20 | 21 | |
| 21 | 22 | running_device *maincpu; |
| 22 | 23 | running_device *pic8259_master; |
| r8714 | r8715 | |
|---|---|---|
| 9 | 9 | #define CASSETTE_TAG "cassette" |
| 10 | 10 | #define SPEAKER_TAG "b237" |
| 11 | 11 | |
| 12 | class lc80_state | |
| 12 | class lc80_state : public driver_data_t | |
| 13 | 13 | { |
| 14 | 14 | public: |
| 15 | static | |
| 15 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lc80_state(machine)); } | |
| 16 | 16 | |
| 17 | lc80_state(running_machine &machine) { } | |
| 17 | lc80_state(running_machine &machine) | |
| 18 | : driver_data_t(machine) { } | |
| 18 | 19 | |
| 19 | 20 | /* display state */ |
| 20 | 21 | UINT8 digit; |
| r8714 | r8715 | |
|---|---|---|
| 34 | 34 | #define INT_EXPANSION_B 0x40 |
| 35 | 35 | #define INT_EXPANSION_A 0x80 |
| 36 | 36 | |
| 37 | class v1050_state | |
| 37 | class v1050_state : public driver_data_t | |
| 38 | 38 | { |
| 39 | 39 | public: |
| 40 | static | |
| 40 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, v1050_state(machine)); } | |
| 41 | 41 | |
| 42 | v1050_state(running_machine &machine) { } | |
| 42 | v1050_state(running_machine &machine) | |
| 43 | : driver_data_t(machine) { } | |
| 43 | 44 | |
| 44 | 45 | /* interrupt state */ |
| 45 | 46 | UINT8 int_mask; /* interrupt mask */ |
| r8714 | r8715 | |
|---|---|---|
| 18 | 18 | #define X4 XTAL_11MHz |
| 19 | 19 | |
| 20 | 20 | |
| 21 | class ql_state | |
| 21 | class ql_state : public driver_data_t | |
| 22 | 22 | { |
| 23 | 23 | public: |
| 24 | static | |
| 24 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ql_state(machine)); } | |
| 25 | 25 | |
| 26 | ql_state(running_machine &machine) { } | |
| 26 | ql_state(running_machine &machine) | |
| 27 | : driver_data_t(machine) { } | |
| 27 | 28 | |
| 28 | 29 | /* IPC state */ |
| 29 | 30 | UINT8 keylatch; |
| r8714 | r8715 | |
|---|---|---|
| 13 | 13 | #define AM2910_TAG "11d" |
| 14 | 14 | #define SCREEN_TAG "screen" |
| 15 | 15 | |
| 16 | class cgc7900_state | |
| 16 | class cgc7900_state : public driver_data_t | |
| 17 | 17 | { |
| 18 | 18 | public: |
| 19 | static | |
| 19 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cgc7900_state(machine)); } | |
| 20 | 20 | |
| 21 | cgc7900_state(running_machine &machine) { } | |
| 21 | cgc7900_state(running_machine &machine) | |
| 22 | : driver_data_t(machine) { } | |
| 22 | 23 | |
| 23 | 24 | /* interrupt state */ |
| 24 | 25 | UINT16 int_mask; |
| r8714 | r8715 | |
|---|---|---|
| 37 | 37 | #define ABC800_CHAR_WIDTH 6 |
| 38 | 38 | #define ABC800_CCLK ABC800_X01/ABC800_CHAR_WIDTH |
| 39 | 39 | |
| 40 | class abc800_state | |
| 40 | class abc800_state : public driver_data_t | |
| 41 | 41 | { |
| 42 | 42 | public: |
| 43 | static | |
| 43 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, abc800_state(machine)); } | |
| 44 | 44 | |
| 45 | abc800_state(running_machine &machine) { } | |
| 45 | abc800_state(running_machine &machine) | |
| 46 | : driver_data_t(machine) { } | |
| 46 | 47 | |
| 47 | 48 | /* cpu state */ |
| 48 | 49 | int fetch_charram; /* opcode fetched from character RAM region (0x7800-0x7fff) */ |
| r8714 | r8715 | |
| 67 | 68 | running_device *cassette; |
| 68 | 69 | }; |
| 69 | 70 | |
| 70 | class abc802_state | |
| 71 | class abc802_state : public driver_data_t | |
| 71 | 72 | { |
| 72 | 73 | public: |
| 73 | static | |
| 74 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, abc802_state(machine)); } | |
| 74 | 75 | |
| 75 | abc802_state(running_machine &machine) { } | |
| 76 | abc802_state(running_machine &machine) | |
| 77 | : driver_data_t(machine) { } | |
| 76 | 78 | |
| 77 | 79 | /* cpu state */ |
| 78 | 80 | int lrs; /* low RAM select */ |
| r8714 | r8715 | |
| 97 | 99 | running_device *cassette; |
| 98 | 100 | }; |
| 99 | 101 | |
| 100 | class abc806_state | |
| 102 | class abc806_state : public driver_data_t | |
| 101 | 103 | { |
| 102 | 104 | public: |
| 103 | static | |
| 105 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, abc806_state(machine)); } | |
| 104 | 106 | |
| 105 | abc806_state(running_machine &machine) { } | |
| 107 | abc806_state(running_machine &machine) | |
| 108 | : driver_data_t(machine) { } | |
| 106 | 109 | |
| 107 | 110 | /* memory state */ |
| 108 | 111 | int keydtr; /* keyboard DTR */ |
| r8714 | r8715 | |
|---|---|---|
| 7 | 7 | #define Z80PIO2_TAG "d12" |
| 8 | 8 | #define CASSETTE_TAG "cassette" |
| 9 | 9 | |
| 10 | class c80_state | |
| 10 | class c80_state : public driver_data_t | |
| 11 | 11 | { |
| 12 | 12 | public: |
| 13 | static | |
| 13 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, c80_state(machine)); } | |
| 14 | 14 | |
| 15 | c80_state(running_machine &machine) { } | |
| 15 | c80_state(running_machine &machine) | |
| 16 | : driver_data_t(machine) { } | |
| 16 | 17 | |
| 17 | 18 | /* keyboard state */ |
| 18 | 19 | int keylatch; |
| r8714 | r8715 | |
|---|---|---|
| 8 | 8 | |
| 9 | 9 | #define TMC2000E_COLORRAM_SIZE 0x100 // ??? |
| 10 | 10 | |
| 11 | class tmc2000e_state | |
| 11 | class tmc2000e_state : public driver_data_t | |
| 12 | 12 | { |
| 13 | 13 | public: |
| 14 | static | |
| 14 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tmc2000e_state(machine)); } | |
| 15 | 15 | |
| 16 | tmc2000e_state(running_machine &machine) { } | |
| 16 | tmc2000e_state(running_machine &machine) | |
| 17 | : driver_data_t(machine) { } | |
| 17 | 18 | |
| 18 | 19 | /* video state */ |
| 19 | 20 | int cdp1864_efx; /* EFx */ |
| r8714 | r8715 | |
|---|---|---|
| 12 | 12 | #define BANK_ROM1 "bank1" |
| 13 | 13 | #define BANK_ROM2 "bank2" |
| 14 | 14 | |
| 15 | class crvision_state | |
| 15 | class crvision_state : public driver_data_t | |
| 16 | 16 | { |
| 17 | 17 | public: |
| 18 | static | |
| 18 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, crvision_state(machine)); } | |
| 19 | 19 | |
| 20 | crvision_state(running_machine &machine) { } | |
| 20 | crvision_state(running_machine &machine) | |
| 21 | : driver_data_t(machine) { } | |
| 21 | 22 | |
| 22 | 23 | /* keyboard state */ |
| 23 | 24 | UINT8 keylatch; |
| r8714 | r8715 | |
|---|---|---|
| 7 | 7 | #define CDP1864_TAG "m3" |
| 8 | 8 | #define CASSETTE_TAG "cassette" |
| 9 | 9 | |
| 10 | class tmc1800_state | |
| 10 | class tmc1800_state : public driver_data_t | |
| 11 | 11 | { |
| 12 | 12 | public: |
| 13 | static | |
| 13 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tmc1800_state(machine)); } | |
| 14 | 14 | |
| 15 | tmc1800_state(running_machine &machine) { } | |
| 15 | tmc1800_state(running_machine &machine) | |
| 16 | : driver_data_t(machine) { } | |
| 16 | 17 | |
| 17 | 18 | /* cpu state */ |
| 18 | 19 | int reset; /* reset activated */ |
| r8714 | r8715 | |
| 28 | 29 | running_device *cassette; |
| 29 | 30 | }; |
| 30 | 31 | |
| 31 | class osc1000b_state | |
| 32 | class osc1000b_state : public driver_data_t | |
| 32 | 33 | { |
| 33 | 34 | public: |
| 34 | static | |
| 35 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, osc1000b_state(machine)); } | |
| 35 | 36 | |
| 36 | osc1000b_state(running_machine &machine) { } | |
| 37 | osc1000b_state(running_machine &machine) | |
| 38 | : driver_data_t(machine) { } | |
| 37 | 39 | |
| 38 | 40 | /* cpu state */ |
| 39 | 41 | int reset; /* reset activated */ |
| r8714 | r8715 | |
| 45 | 47 | running_device *cassette; |
| 46 | 48 | }; |
| 47 | 49 | |
| 48 | class tmc2000_state | |
| 50 | class tmc2000_state : public driver_data_t | |
| 49 | 51 | { |
| 50 | 52 | public: |
| 51 | static | |
| 53 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tmc2000_state(machine)); } | |
| 52 | 54 | |
| 53 | tmc2000_state(running_machine &machine) { } | |
| 55 | tmc2000_state(running_machine &machine) | |
| 56 | : driver_data_t(machine) { } | |
| 54 | 57 | |
| 55 | 58 | /* video state */ |
| 56 | 59 | int cdp1864_efx; /* EFx */ |
| r8714 | r8715 | |
| 67 | 70 | running_device *cassette; |
| 68 | 71 | }; |
| 69 | 72 | |
| 70 | class oscnano_state | |
| 73 | class oscnano_state : public driver_data_t | |
| 71 | 74 | { |
| 72 | 75 | public: |
| 73 | static | |
| 76 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, oscnano_state(machine)); } | |
| 74 | 77 | |
| 75 | oscnano_state(running_machine &machine) { } | |
| 78 | oscnano_state(running_machine &machine) | |
| 79 | : driver_data_t(machine) { } | |
| 76 | 80 | |
| 77 | 81 | /* cpu state */ |
| 78 | 82 | int monitor_ef4; /* EF4 line */ |
| r8714 | r8715 | |
|---|---|---|
| 72 | 72 | UINT8 towns_layer_ctrl; |
| 73 | 73 | }; |
| 74 | 74 | |
| 75 | class towns_state | |
| 75 | class towns_state : public driver_data_t | |
| 76 | 76 | { |
| 77 | 77 | public: |
| 78 | static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, towns_state(machine)); } | |
| 79 | towns_state(running_machine &machine) {} | |
| 80 | ||
| 78 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, towns_state(machine)); } | |
| 79 | towns_state(running_machine &machine) | |
| 80 | : driver_data_t(machine) { } | |
| 81 | ||
| 81 | 82 | UINT8 ftimer; |
| 82 | 83 | UINT8 nmi_mask; |
| 83 | 84 | UINT8 compat_mode; |
| r8714 | r8715 | |
|---|---|---|
| 38 | 38 | #define NEWBRAIN_VIDEO_UCR 0x08 |
| 39 | 39 | #define NEWBRAIN_VIDEO_80L 0x40 |
| 40 | 40 | |
| 41 | class newbrain_state | |
| 41 | class newbrain_state : public driver_data_t | |
| 42 | 42 | { |
| 43 | 43 | public: |
| 44 | static | |
| 44 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, newbrain_state(machine)); } | |
| 45 | 45 | |
| 46 | newbrain_state(running_machine &machine) { } | |
| 46 | newbrain_state(running_machine &machine) | |
| 47 | : driver_data_t(machine) { } | |
| 47 | 48 | |
| 48 | 49 | /* processor state */ |
| 49 | 50 | int pwrup; /* power up */ |
| r8714 | r8715 | |
|---|---|---|
| 20 | 20 | #define CASSETTE_TAG "cassette" |
| 21 | 21 | #define CENTRONICS_TAG "centronics" |
| 22 | 22 | |
| 23 | class mtx_state | |
| 23 | class mtx_state : public driver_data_t | |
| 24 | 24 | { |
| 25 | 25 | public: |
| 26 | static | |
| 26 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mtx_state(machine)); } | |
| 27 | 27 | |
| 28 | mtx_state(running_machine &machine) { } | |
| 28 | mtx_state(running_machine &machine) | |
| 29 | : driver_data_t(machine) { } | |
| 29 | 30 | |
| 30 | 31 | /* keyboard state */ |
| 31 | 32 | UINT8 key_sense; |
| r8714 | r8715 | |
|---|---|---|
| 13 | 13 | TYPE DEFINITIONS |
| 14 | 14 | ***************************************************************************/ |
| 15 | 15 | |
| 16 | class einstein_state | |
| 16 | class einstein_state : public driver_data_t | |
| 17 | 17 | { |
| 18 | 18 | public: |
| 19 | static | |
| 19 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, einstein_state(machine)); } | |
| 20 | 20 | |
| 21 | einstein_state(running_machine &machine) { } | |
| 21 | einstein_state(running_machine &machine) | |
| 22 | : driver_data_t(machine) { } | |
| 22 | 23 | |
| 23 | 24 | running_device *color_screen; |
| 24 | 25 | running_device *ctc; |
| r8714 | r8715 | |
|---|---|---|
| 18 | 18 | #define TCM5089_TAG "m11" |
| 19 | 19 | #define MSM8251_TAG "m20" |
| 20 | 20 | |
| 21 | class kc85_state | |
| 21 | class kc85_state : public driver_data_t | |
| 22 | 22 | { |
| 23 | 23 | public: |
| 24 | static | |
| 24 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, kc85_state(machine)); } | |
| 25 | 25 | |
| 26 | kc85_state(running_machine &machine) { } | |
| 26 | kc85_state(running_machine &machine) | |
| 27 | : driver_data_t(machine) { } | |
| 27 | 28 | |
| 28 | 29 | /* memory state */ |
| 29 | 30 | UINT8 bank; /* memory bank selection */ |
| r8714 | r8715 | |
| 47 | 48 | running_device *cassette; |
| 48 | 49 | }; |
| 49 | 50 | |
| 50 | class tandy200_state | |
| 51 | class tandy200_state : public driver_data_t | |
| 51 | 52 | { |
| 52 | 53 | public: |
| 53 | static | |
| 54 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tandy200_state(machine)); } | |
| 54 | 55 | |
| 55 | tandy200_state(running_machine &machine) { } | |
| 56 | tandy200_state(running_machine &machine) | |
| 57 | : driver_data_t(machine) { } | |
| 56 | 58 | |
| 57 | 59 | /* memory state */ |
| 58 | 60 | UINT8 bank; /* memory bank selection */ |
| r8714 | r8715 | |
|---|---|---|
| 31 | 31 | #define SAM_MIDIOUT_INT 0x10 |
| 32 | 32 | |
| 33 | 33 | |
| 34 | class coupe_asic | |
| 34 | class coupe_asic : public driver_data_t | |
| 35 | 35 | { |
| 36 | 36 | public: |
| 37 | static | |
| 37 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, coupe_asic(machine)); } | |
| 38 | 38 | |
| 39 | coupe_asic(running_machine &machine) { } | |
| 39 | coupe_asic(running_machine &machine) | |
| 40 | : driver_data_t(machine) { } | |
| 40 | 41 | |
| 41 | 42 | emu_timer *video_update_timer; |
| 42 | 43 |
| r8714 | r8715 | |
|---|---|---|
| 37 | 37 | BANK_RAMCARD |
| 38 | 38 | }; |
| 39 | 39 | |
| 40 | class comx35_state | |
| 40 | class comx35_state : public driver_data_t | |
| 41 | 41 | { |
| 42 | 42 | public: |
| 43 | static | |
| 43 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, comx35_state(machine)); } | |
| 44 | 44 | |
| 45 | comx35_state(running_machine &machine) { } | |
| 45 | comx35_state(running_machine &machine) | |
| 46 | : driver_data_t(machine) { } | |
| 46 | 47 | |
| 47 | 48 | /* processor state */ |
| 48 | 49 | int cdp1802_mode; /* CPU mode */ |
| r8714 | r8715 | |
|---|---|---|
| 9 | 9 | |
| 10 | 10 | #define JTC_ES40_VIDEORAM_SIZE 0x2000 |
| 11 | 11 | |
| 12 | class jtc_state | |
| 12 | class jtc_state : public driver_data_t | |
| 13 | 13 | { |
| 14 | 14 | public: |
| 15 | static | |
| 15 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, jtc_state(machine)); } | |
| 16 | 16 | |
| 17 | jtc_state(running_machine &machine) { } | |
| 17 | jtc_state(running_machine &machine) | |
| 18 | : driver_data_t(machine) { } | |
| 18 | 19 | |
| 19 | 20 | /* video state */ |
| 20 | 21 | UINT8 video_bank; |
| r8714 | r8715 | |
|---|---|---|
| 16 | 16 | #define BANK_RAM 1 |
| 17 | 17 | #define BANK_VIDEO_RAM 2 |
| 18 | 18 | |
| 19 | class tiki100_state | |
| 19 | class tiki100_state : public driver_data_t | |
| 20 | 20 | { |
| 21 | 21 | public: |
| 22 | static | |
| 22 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tiki100_state(machine)); } | |
| 23 | 23 | |
| 24 | tiki100_state(running_machine &machine) { } | |
| 24 | tiki100_state(running_machine &machine) | |
| 25 | : driver_data_t(machine) { } | |
| 25 | 26 | |
| 26 | 27 | /* memory state */ |
| 27 | 28 | int rome; |
| r8714 | r8715 | |
|---|---|---|
| 10 | 10 | #define M6551_TAG "m6551" |
| 11 | 11 | #define SPEAKER_TAG "speaker" |
| 12 | 12 | |
| 13 | class aim65_40_state | |
| 13 | class aim65_40_state : public driver_data_t | |
| 14 | 14 | { |
| 15 | 15 | public: |
| 16 | static | |
| 16 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, aim65_40_state(machine)); } | |
| 17 | 17 | |
| 18 | aim65_40_state(running_machine &machine) { } | |
| 18 | aim65_40_state(running_machine &machine) | |
| 19 | : driver_data_t(machine) { } | |
| 19 | 20 | |
| 20 | 21 | /* devices */ |
| 21 | 22 | running_device *via0; |
| r8714 | r8715 | |
|---|---|---|
| 11 | 11 | #define MC6854_TAG "mc6854" |
| 12 | 12 | #define CENTRONICS_TAG "centronics" |
| 13 | 13 | |
| 14 | class e01_state | |
| 14 | class e01_state : public driver_data_t | |
| 15 | 15 | { |
| 16 | 16 | public: |
| 17 | static | |
| 17 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, e01_state(machine)); } | |
| 18 | 18 | |
| 19 | e01_state(running_machine &machine) { } | |
| 19 | e01_state(running_machine &machine) | |
| 20 | : driver_data_t(machine) { } | |
| 20 | 21 | |
| 21 | 22 | /* interrupt state */ |
| 22 | 23 | int adlc_ie; |
| r8714 | r8715 | |
|---|---|---|
| 15 | 15 | #define XEROX820_VIDEORAM_SIZE 0x1000 |
| 16 | 16 | #define XEROX820_VIDEORAM_MASK 0x0fff |
| 17 | 17 | |
| 18 | class xerox820_state | |
| 18 | class xerox820_state : public driver_data_t | |
| 19 | 19 | { |
| 20 | 20 | public: |
| 21 | static | |
| 21 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, xerox820_state(machine)); } | |
| 22 | 22 | |
| 23 | xerox820_state(running_machine &machine) { } | |
| 23 | xerox820_state(running_machine &machine) | |
| 24 | : driver_data_t(machine) { } | |
| 24 | 25 | |
| 25 | 26 | /* keyboard state */ |
| 26 | 27 | int keydata; /* keyboard data */ |
| r8714 | r8715 | |
|---|---|---|
| 11 | 11 | #include "machine/i8255a.h" |
| 12 | 12 | #include "machine/8237dma.h" |
| 13 | 13 | |
| 14 | class pc_state | |
| 14 | class pc_state : public driver_data_t | |
| 15 | 15 | { |
| 16 | 16 | public: |
| 17 | static | |
| 17 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pc_state(machine)); } | |
| 18 | 18 | |
| 19 | pc_state(running_machine &machine) { } | |
| 19 | pc_state(running_machine &machine) | |
| 20 | : driver_data_t(machine) { } | |
| 20 | 21 | |
| 21 | 22 | running_device *maincpu; |
| 22 | 23 | running_device *pic8259; |
| r8714 | r8715 | |
|---|---|---|
| 5 | 5 | #define Z80_TAG "z80" |
| 6 | 6 | #define MC146818_TAG "mc146818" |
| 7 | 7 | |
| 8 | class micronic_state | |
| 8 | class micronic_state : public driver_data_t | |
| 9 | 9 | { |
| 10 | 10 | public: |
| 11 | static | |
| 11 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, micronic_state(machine)); } | |
| 12 | 12 | |
| 13 | micronic_state(running_machine &machine) { } | |
| 13 | micronic_state(running_machine &machine) | |
| 14 | : driver_data_t(machine) { } | |
| 14 | 15 | |
| 15 | 16 | UINT8 *ram; |
| 16 | 17 | UINT8 kp_matrix; |
| r8714 | r8715 | |
|---|---|---|
| 7 | 7 | #define PECOM_PAGE_RAM_SIZE 0x400 |
| 8 | 8 | #define PECOM_PAGE_RAM_MASK 0x3ff |
| 9 | 9 | |
| 10 | class pecom_state | |
| 10 | class pecom_state : public driver_data_t | |
| 11 | 11 | { |
| 12 | 12 | public: |
| 13 | static | |
| 13 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pecom_state(machine)); } | |
| 14 | 14 | |
| 15 | pecom_state(running_machine &machine) { } | |
| 15 | pecom_state(running_machine &machine) | |
| 16 | : driver_data_t(machine) { } | |
| 16 | 17 | |
| 17 | 18 | UINT8 *page_ram; /* page memory */ |
| 18 | 19 | UINT8 *charram; /* character generator ROM */ |
| r8714 | r8715 | |
|---|---|---|
| 5 | 5 | #define Z80_TAG "z80" |
| 6 | 6 | #define Z80PIO_TAG "z80pio" |
| 7 | 7 | |
| 8 | class vcs80_state | |
| 8 | class vcs80_state : public driver_data_t | |
| 9 | 9 | { |
| 10 | 10 | public: |
| 11 | static | |
| 11 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vcs80_state(machine)); } | |
| 12 | 12 | |
| 13 | vcs80_state(running_machine &machine) { } | |
| 13 | vcs80_state(running_machine &machine) | |
| 14 | : driver_data_t(machine) { } | |
| 14 | 15 | |
| 15 | 16 | /* keyboard state */ |
| 16 | 17 | int keylatch; |
| r8714 | r8715 | |
|---|---|---|
| 16 | 16 | #define SPEAKER_TAG "speaker" |
| 17 | 17 | #define CENTRONICS_TAG "centronics" |
| 18 | 18 | |
| 19 | class tandy2k_state | |
| 19 | class tandy2k_state : public driver_data_t | |
| 20 | 20 | { |
| 21 | 21 | public: |
| 22 | static | |
| 22 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tandy2k_state(machine)); } | |
| 23 | 23 | |
| 24 | tandy2k_state(running_machine &machine) { } | |
| 24 | tandy2k_state(running_machine &machine) | |
| 25 | : driver_data_t(machine) { } | |
| 25 | 26 | |
| 26 | 27 | /* DMA state */ |
| 27 | 28 | UINT8 dma_mux; |
| r8714 | r8715 | |
|---|---|---|
| 28 | 28 | LED_CASSETTE |
| 29 | 29 | }; |
| 30 | 30 | |
| 31 | class cosmicos_state | |
| 31 | class cosmicos_state : public driver_data_t | |
| 32 | 32 | { |
| 33 | 33 | public: |
| 34 | static | |
| 34 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cosmicos_state(machine)); } | |
| 35 | 35 | |
| 36 | cosmicos_state(running_machine &machine) { } | |
| 36 | cosmicos_state(running_machine &machine) | |
| 37 | : driver_data_t(machine) { } | |
| 37 | 38 | |
| 38 | 39 | /* CPU state */ |
| 39 | 40 | cdp1802_control_mode cdp1802_mode; |
| r8714 | r8715 | |
|---|---|---|
| 9 | 9 | #define Z80PIO2_TAG "z80pio2" |
| 10 | 10 | #define CASSETTE_TAG "cassette" |
| 11 | 11 | |
| 12 | class amu880_state | |
| 12 | class amu880_state : public driver_data_t | |
| 13 | 13 | { |
| 14 | 14 | public: |
| 15 | static | |
| 15 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, amu880_state(machine)); } | |
| 16 | 16 | |
| 17 | amu880_state(running_machine &machine) { } | |
| 17 | amu880_state(running_machine &machine) | |
| 18 | : driver_data_t(machine) { } | |
| 18 | 19 | |
| 19 | 20 | /* keyboard state */ |
| 20 | 21 | int key_y; |
| r8714 | r8715 | |
|---|---|---|
| 47 | 47 | *******************************************************************/ |
| 48 | 48 | static void spectrum_update_paging(running_machine *machine) |
| 49 | 49 | { |
| 50 | spectrum_state *state = | |
| 50 | spectrum_state *state = | |
| 51 | 51 | if (state->port_7ffd_data == -1) |
| 52 | 52 | return; |
| 53 | 53 | if (state->port_1ffd_data == -1) |
| r8714 | r8715 | |
| 67 | 67 | /* Page in the 48K Basic ROM. Used when running 48K snapshots on a 128K machine. */ |
| 68 | 68 | static void spectrum_page_basicrom(running_machine *machine) |
| 69 | 69 | { |
| 70 | spectrum_state *state = | |
| 70 | spectrum_state *state = | |
| 71 | 71 | if (state->port_7ffd_data == -1) |
| 72 | 72 | return; |
| 73 | 73 | state->port_7ffd_data |= 0x10; |
| r8714 | r8715 | |
| 276 | 276 | int i, SP_OFFSET; |
| 277 | 277 | UINT8 intr; |
| 278 | 278 | UINT16 start, size, data, status; |
| 279 | spectrum_state *state = | |
| 279 | spectrum_state *state = | |
| 280 | 280 | running_device *cpu = machine->device("maincpu"); |
| 281 | 281 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 282 | 282 | |
| r8714 | r8715 | |
| 478 | 478 | long bank_offset; |
| 479 | 479 | UINT8 intr; |
| 480 | 480 | UINT16 data, addr; |
| 481 | spectrum_state *state = | |
| 481 | spectrum_state *state = | |
| 482 | 482 | running_device *cpu = machine->device("maincpu"); |
| 483 | 483 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 484 | 484 | |
| r8714 | r8715 | |
| 701 | 701 | int i; |
| 702 | 702 | UINT8 intr; |
| 703 | 703 | UINT16 data; |
| 704 | spectrum_state *state = | |
| 704 | spectrum_state *state = | |
| 705 | 705 | running_device *cpu = machine->device("maincpu"); |
| 706 | 706 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 707 | 707 | |
| r8714 | r8715 | |
| 836 | 836 | int i; |
| 837 | 837 | UINT8 intr; |
| 838 | 838 | UINT16 addr, data; |
| 839 | spectrum_state *state = | |
| 839 | spectrum_state *state = | |
| 840 | 840 | running_device *cpu = machine->device("maincpu"); |
| 841 | 841 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 842 | 842 | |
| r8714 | r8715 | |
| 1008 | 1008 | int i, j; |
| 1009 | 1009 | UINT8 intr; |
| 1010 | 1010 | UINT16 addr = 0, data; |
| 1011 | spectrum_state *state = | |
| 1011 | spectrum_state *state = | |
| 1012 | 1012 | running_device *cpu = machine->device("maincpu"); |
| 1013 | 1013 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1014 | 1014 | |
| r8714 | r8715 | |
| 1178 | 1178 | int i; |
| 1179 | 1179 | UINT8 intr; |
| 1180 | 1180 | UINT16 data; |
| 1181 | spectrum_state *state = | |
| 1181 | spectrum_state *state = | |
| 1182 | 1182 | running_device *cpu = machine->device("maincpu"); |
| 1183 | 1183 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1184 | 1184 | |
| r8714 | r8715 | |
| 1299 | 1299 | int i; |
| 1300 | 1300 | UINT8 intr; |
| 1301 | 1301 | UINT16 data; |
| 1302 | spectrum_state *state = | |
| 1302 | spectrum_state *state = | |
| 1303 | 1303 | running_device *cpu = machine->device("maincpu"); |
| 1304 | 1304 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1305 | 1305 | |
| r8714 | r8715 | |
| 1431 | 1431 | int i; |
| 1432 | 1432 | UINT8 intr; |
| 1433 | 1433 | UINT16 data, mode; |
| 1434 | spectrum_state *state = | |
| 1434 | spectrum_state *state = | |
| 1435 | 1435 | running_device *cpu = machine->device("maincpu"); |
| 1436 | 1436 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1437 | 1437 | |
| r8714 | r8715 | |
| 1565 | 1565 | int i; |
| 1566 | 1566 | UINT8 intr; |
| 1567 | 1567 | UINT16 data; |
| 1568 | spectrum_state *state = | |
| 1568 | spectrum_state *state = | |
| 1569 | 1569 | running_device *cpu = machine->device("maincpu"); |
| 1570 | 1570 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1571 | 1571 | |
| r8714 | r8715 | |
| 1794 | 1794 | { |
| 1795 | 1795 | UINT8 intr; |
| 1796 | 1796 | UINT16 data, addr; |
| 1797 | spectrum_state *state = | |
| 1797 | spectrum_state *state = | |
| 1798 | 1798 | running_device *cpu = machine->device("maincpu"); |
| 1799 | 1799 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1800 | 1800 | |
| r8714 | r8715 | |
| 1950 | 1950 | int i, j; |
| 1951 | 1951 | UINT8 intr; |
| 1952 | 1952 | UINT16 addr, data; |
| 1953 | spectrum_state *state = | |
| 1953 | spectrum_state *state = | |
| 1954 | 1954 | running_device *cpu = machine->device("maincpu"); |
| 1955 | 1955 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1956 | 1956 | |
| r8714 | r8715 | |
| 2172 | 2172 | /* now supports 48k & 128k .Z80 files */ |
| 2173 | 2173 | void spectrum_setup_z80(running_machine *machine, UINT8 *snapdata, UINT32 snapsize) |
| 2174 | 2174 | { |
| 2175 | spectrum_state *state = | |
| 2175 | spectrum_state *state = | |
| 2176 | 2176 | int i; |
| 2177 | 2177 | UINT8 lo, hi, data; |
| 2178 | 2178 | SPECTRUM_Z80_SNAPSHOT_TYPE z80_type; |
| r8714 | r8715 | |
| 2543 | 2543 | int i; |
| 2544 | 2544 | UINT8 data; |
| 2545 | 2545 | UINT16 start, len; |
| 2546 | spectrum_state *state = | |
| 2546 | spectrum_state *state = | |
| 2547 | 2547 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 2548 | 2548 | |
| 2549 | 2549 | start = (quickdata[RAW_OFFSET + 4] << 8) | quickdata[RAW_OFFSET + 3]; |
| r8714 | r8715 | |
|---|---|---|
| 253 | 253 | |
| 254 | 254 | static WRITE8_HANDLER( keylatch_w ) |
| 255 | 255 | { |
| 256 | vip_state *state = | |
| 256 | vip_state *state = | |
| 257 | 257 | |
| 258 | 258 | state->keylatch = data & 0x0f; |
| 259 | 259 | } |
| r8714 | r8715 | |
| 383 | 383 | |
| 384 | 384 | static WRITE_LINE_DEVICE_HANDLER( vip_efx_w ) |
| 385 | 385 | { |
| 386 | vip_state *driver_state = | |
| 386 | vip_state *driver_state = | |
| 387 | 387 | |
| 388 | 388 | driver_state->cdp1861_efx = state; |
| 389 | 389 | } |
| r8714 | r8715 | |
| 399 | 399 | |
| 400 | 400 | static READ_LINE_DEVICE_HANDLER( rd_r ) |
| 401 | 401 | { |
| 402 | vip_state *state = | |
| 402 | vip_state *state = | |
| 403 | 403 | |
| 404 | 404 | return BIT(state->color, 1); |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | static READ_LINE_DEVICE_HANDLER( bd_r ) |
| 408 | 408 | { |
| 409 | vip_state *state = | |
| 409 | vip_state *state = | |
| 410 | 410 | |
| 411 | 411 | return BIT(state->color, 2); |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | static READ_LINE_DEVICE_HANDLER( gd_r ) |
| 415 | 415 | { |
| 416 | vip_state *state = | |
| 416 | vip_state *state = | |
| 417 | 417 | |
| 418 | 418 | return BIT(state->color, 3); |
| 419 | 419 | } |
| r8714 | r8715 | |
| 436 | 436 | |
| 437 | 437 | static WRITE8_HANDLER( vip_colorram_w ) |
| 438 | 438 | { |
| 439 | vip_state *state = | |
| 439 | vip_state *state = | |
| 440 | 440 | UINT8 mask = 0xff; |
| 441 | 441 | |
| 442 | 442 | state->a12 = (offset & 0x1000) ? 1 : 0; |
| r8714 | r8715 | |
| 455 | 455 | |
| 456 | 456 | static VIDEO_UPDATE( vip ) |
| 457 | 457 | { |
| 458 | vip_state *state = | |
| 458 | vip_state *state = | |
| 459 | 459 | |
| 460 | 460 | switch (input_port_read(screen->machine, "VIDEO")) |
| 461 | 461 | { |
| r8714 | r8715 | |
| 475 | 475 | |
| 476 | 476 | static CDP1802_MODE_READ( vip_mode_r ) |
| 477 | 477 | { |
| 478 | vip_state *state = | |
| 478 | vip_state *state = | |
| 479 | 479 | |
| 480 | 480 | if (input_port_read(device->machine, "RUN") & 0x01) |
| 481 | 481 | { |
| r8714 | r8715 | |
| 502 | 502 | |
| 503 | 503 | static CDP1802_EF_READ( vip_ef_r ) |
| 504 | 504 | { |
| 505 | vip_state *state = | |
| 505 | vip_state *state = | |
| 506 | 506 | |
| 507 | 507 | UINT8 flags = 0x0f; |
| 508 | 508 | |
| r8714 | r8715 | |
| 549 | 549 | |
| 550 | 550 | static WRITE_LINE_DEVICE_HANDLER( vip_q_w ) |
| 551 | 551 | { |
| 552 | vip_state *driver_state = | |
| 552 | vip_state *driver_state = | |
| 553 | 553 | |
| 554 | 554 | /* sound output */ |
| 555 | 555 | |
| r8714 | r8715 | |
| 584 | 584 | |
| 585 | 585 | static WRITE8_DEVICE_HANDLER( vip_dma_w ) |
| 586 | 586 | { |
| 587 | vip_state *state = | |
| 587 | vip_state *state = | |
| 588 | 588 | |
| 589 | 589 | switch (input_port_read(device->machine, "VIDEO")) |
| 590 | 590 | { |
| r8714 | r8715 | |
| 624 | 624 | |
| 625 | 625 | static MACHINE_START( vip ) |
| 626 | 626 | { |
| 627 | vip_state *state = | |
| 627 | vip_state *state = | |
| 628 | 628 | |
| 629 | 629 | UINT8 *ram = memory_region(machine, CDP1802_TAG); |
| 630 | 630 | UINT16 addr; |
| r8714 | r8715 | |
| 675 | 675 | |
| 676 | 676 | static MACHINE_RESET( vip ) |
| 677 | 677 | { |
| 678 | vip_state *state = | |
| 678 | vip_state *state = | |
| 679 | 679 | |
| 680 | 680 | const address_space *program = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM); |
| 681 | 681 | const address_space *io = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_IO); |
| r8714 | r8715 | |
|---|---|---|
| 43 | 43 | |
| 44 | 44 | static READ8_HANDLER( data_r ) |
| 45 | 45 | { |
| 46 | elf2_state *state = | |
| 46 | elf2_state *state = | |
| 47 | 47 | |
| 48 | 48 | return state->data; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | static WRITE8_HANDLER( data_w ) |
| 52 | 52 | { |
| 53 | elf2_state *state = | |
| 53 | elf2_state *state = | |
| 54 | 54 | |
| 55 | 55 | dm9368_w(state->dm9368_l, 0, data & 0x0f); |
| 56 | 56 | dm9368_w(state->dm9368_h, 0, data >> 4); |
| r8714 | r8715 | |
| 58 | 58 | |
| 59 | 59 | static WRITE8_HANDLER( memory_w ) |
| 60 | 60 | { |
| 61 | elf2_state *state = | |
| 61 | elf2_state *state = | |
| 62 | 62 | |
| 63 | 63 | if (LOAD(space->machine)) |
| 64 | 64 | { |
| r8714 | r8715 | |
| 166 | 166 | EF4 input switch |
| 167 | 167 | */ |
| 168 | 168 | |
| 169 | elf2_state *state = | |
| 169 | elf2_state *state = | |
| 170 | 170 | |
| 171 | 171 | UINT8 flags = 0x0f; |
| 172 | 172 | |
| r8714 | r8715 | |
| 195 | 195 | |
| 196 | 196 | static READ8_DEVICE_HANDLER( elf2_dma_r ) |
| 197 | 197 | { |
| 198 | elf2_state *state = | |
| 198 | elf2_state *state = | |
| 199 | 199 | |
| 200 | 200 | return state->data; |
| 201 | 201 | } |
| r8714 | r8715 | |
| 214 | 214 | |
| 215 | 215 | static WRITE_LINE_DEVICE_HANDLER( mm74c923_da_w ) |
| 216 | 216 | { |
| 217 | elf2_state *driver_state = | |
| 217 | elf2_state *driver_state = | |
| 218 | 218 | |
| 219 | 219 | if (state) |
| 220 | 220 | { |
| r8714 | r8715 | |
| 247 | 247 | |
| 248 | 248 | static VIDEO_UPDATE( elf2 ) |
| 249 | 249 | { |
| 250 | elf2_state *state = | |
| 250 | elf2_state *state = | |
| 251 | 251 | |
| 252 | 252 | cdp1861_update(state->cdp1861, bitmap, cliprect); |
| 253 | 253 | |
| r8714 | r8715 | |
| 256 | 256 | |
| 257 | 257 | static WRITE_LINE_DEVICE_HANDLER( elf2_efx_w ) |
| 258 | 258 | { |
| 259 | elf2_state *driver_state = | |
| 259 | elf2_state *driver_state = | |
| 260 | 260 | |
| 261 | 261 | driver_state->cdp1861_efx = state; |
| 262 | 262 | } |
| r8714 | r8715 | |
| 274 | 274 | |
| 275 | 275 | static MACHINE_START( elf2 ) |
| 276 | 276 | { |
| 277 | elf2_state *state = | |
| 277 | elf2_state *state = | |
| 278 | 278 | const address_space *program = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM); |
| 279 | 279 | |
| 280 | 280 | /* find devices */ |
| r8714 | r8715 | |
|---|---|---|
| 1 | 1 | #include "emu.h" |
| 2 | 2 | #include "cpu/m6805/m6805.h" |
| 3 | 3 | |
| 4 | class comxpl80_state | |
| 4 | class comxpl80_state : public driver_data_t | |
| 5 | 5 | { |
| 6 | 6 | public: |
| 7 | static | |
| 7 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, comxpl80_state(machine)); } | |
| 8 | 8 | |
| 9 | comxpl80_state(running_machine &machine) { } | |
| 9 | comxpl80_state(running_machine &machine) | |
| 10 | : driver_data_t(machine) { } | |
| 10 | 11 | |
| 11 | 12 | /* printer state */ |
| 12 | 13 | UINT8 centronics_data; /* centronics data */ |
| r8714 | r8715 | |
| 40 | 41 | |
| 41 | 42 | */ |
| 42 | 43 | |
| 43 | comxpl80_state *state = | |
| 44 | comxpl80_state *state = | |
| 44 | 45 | |
| 45 | 46 | state->y_motor_phase = data & 0x0f; |
| 46 | 47 | state->font_addr = (BIT(data, 4) << 12) | (state->font_addr & 0xfff); |
| r8714 | r8715 | |
| 89 | 90 | |
| 90 | 91 | */ |
| 91 | 92 | |
| 92 | comxpl80_state *state = | |
| 93 | comxpl80_state *state = | |
| 93 | 94 | |
| 94 | 95 | state->z_motor_phase = data & 0x0f; |
| 95 | 96 | |
| r8714 | r8715 | |
| 113 | 114 | |
| 114 | 115 | */ |
| 115 | 116 | |
| 116 | comxpl80_state *state = | |
| 117 | comxpl80_state *state = | |
| 117 | 118 | |
| 118 | 119 | state->font_addr = (state->font_addr & 0x1f00) | data; |
| 119 | 120 | |
| r8714 | r8715 | |
| 140 | 141 | |
| 141 | 142 | */ |
| 142 | 143 | |
| 143 | comxpl80_state *state = | |
| 144 | comxpl80_state *state = | |
| 144 | 145 | |
| 145 | 146 | return state->plotter_data; |
| 146 | 147 | } |
| r8714 | r8715 | |
|---|---|---|
| 45 | 45 | |
| 46 | 46 | static void pc8401a_keyboard_scan(running_machine *machine) |
| 47 | 47 | { |
| 48 | pc8401a_state *state = | |
| 48 | pc8401a_state *state = | |
| 49 | 49 | int row, strobe = 0; |
| 50 | 50 | |
| 51 | 51 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7", "KEY8", "KEY9" }; |
| r8714 | r8715 | |
| 190 | 190 | |
| 191 | 191 | */ |
| 192 | 192 | |
| 193 | pc8401a_state *state = | |
| 193 | pc8401a_state *state = | |
| 194 | 194 | |
| 195 | 195 | if (data != state->mmr) |
| 196 | 196 | { |
| r8714 | r8715 | |
| 202 | 202 | |
| 203 | 203 | static READ8_HANDLER( mmr_r ) |
| 204 | 204 | { |
| 205 | pc8401a_state *state = | |
| 205 | pc8401a_state *state = | |
| 206 | 206 | |
| 207 | 207 | return state->mmr; |
| 208 | 208 | } |
| r8714 | r8715 | |
| 224 | 224 | |
| 225 | 225 | */ |
| 226 | 226 | |
| 227 | pc8401a_state *state = | |
| 227 | pc8401a_state *state = | |
| 228 | 228 | |
| 229 | 229 | return (state->rtc_data << 1) | (state->rtc_tp << 2); |
| 230 | 230 | } |
| r8714 | r8715 | |
| 246 | 246 | |
| 247 | 247 | */ |
| 248 | 248 | |
| 249 | pc8401a_state *state = | |
| 249 | pc8401a_state *state = | |
| 250 | 250 | |
| 251 | 251 | upd1990a_c0_w(state->upd1990a, BIT(data, 0)); |
| 252 | 252 | upd1990a_c1_w(state->upd1990a, BIT(data, 1)); |
| r8714 | r8715 | |
| 271 | 271 | |
| 272 | 272 | */ |
| 273 | 273 | |
| 274 | pc8401a_state *state = | |
| 274 | pc8401a_state *state = | |
| 275 | 275 | |
| 276 | 276 | upd1990a_oe_w(state->upd1990a, BIT(data, 0)); |
| 277 | 277 | upd1990a_stb_w(state->upd1990a, BIT(data, 1)); |
| r8714 | r8715 | |
| 280 | 280 | |
| 281 | 281 | static READ8_HANDLER( io_rom_data_r ) |
| 282 | 282 | { |
| 283 | pc8401a_state *state = | |
| 283 | pc8401a_state *state = | |
| 284 | 284 | |
| 285 | 285 | UINT8 *iorom = memory_region(space->machine, "iorom"); |
| 286 | 286 | |
| r8714 | r8715 | |
| 291 | 291 | |
| 292 | 292 | static WRITE8_HANDLER( io_rom_addr_w ) |
| 293 | 293 | { |
| 294 | pc8401a_state *state = | |
| 294 | pc8401a_state *state = | |
| 295 | 295 | |
| 296 | 296 | switch (offset) |
| 297 | 297 | { |
| r8714 | r8715 | |
| 330 | 330 | |
| 331 | 331 | */ |
| 332 | 332 | |
| 333 | pc8401a_state *state = | |
| 333 | pc8401a_state *state = | |
| 334 | 334 | |
| 335 | 335 | return 0x10 | state->key_strobe; |
| 336 | 336 | } |
| r8714 | r8715 | |
| 342 | 342 | |
| 343 | 343 | static WRITE8_HANDLER( port70_w ) |
| 344 | 344 | { |
| 345 | pc8401a_state *state = | |
| 345 | pc8401a_state *state = | |
| 346 | 346 | |
| 347 | 347 | state->key_strobe = 0; |
| 348 | 348 | } |
| r8714 | r8715 | |
| 513 | 513 | |
| 514 | 514 | static MACHINE_START( pc8401a ) |
| 515 | 515 | { |
| 516 | pc8401a_state *state = | |
| 516 | pc8401a_state *state = | |
| 517 | 517 | |
| 518 | 518 | /* find devices */ |
| 519 | 519 | state->upd1990a = machine->device(UPD1990A_TAG); |
| r8714 | r8715 | |
| 605 | 605 | |
| 606 | 606 | static WRITE_LINE_DEVICE_HANDLER( pc8401a_upd1990a_data_w ) |
| 607 | 607 | { |
| 608 | pc8401a_state *driver_state = | |
| 608 | pc8401a_state *driver_state = | |
| 609 | 609 | |
| 610 | 610 | driver_state->rtc_data = state; |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | static WRITE_LINE_DEVICE_HANDLER( pc8401a_upd1990a_tp_w ) |
| 614 | 614 | { |
| 615 | pc8401a_state *driver_state = | |
| 615 | pc8401a_state *driver_state = | |
| 616 | 616 | |
| 617 | 617 | driver_state->rtc_tp = state; |
| 618 | 618 | } |
| r8714 | r8715 | |
|---|---|---|
| 197 | 197 | #include "sound/speaker.h" |
| 198 | 198 | |
| 199 | 199 | |
| 200 | class nakajies_state | |
| 200 | class nakajies_state : public driver_data_t | |
| 201 | 201 | { |
| 202 | 202 | public: |
| 203 | static | |
| 203 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nakajies_state(machine)); } | |
| 204 | 204 | |
| 205 | nakajies_state(running_machine &machine) { } | |
| 205 | nakajies_state(running_machine &machine) | |
| 206 | : driver_data_t(machine) { } | |
| 206 | 207 | |
| 207 | 208 | /* Device lookups */ |
| 208 | 209 | running_device *cpu; |
| r8714 | r8715 | |
| 240 | 241 | |
| 241 | 242 | static void nakajies_update_irqs( running_machine *machine ) |
| 242 | 243 | { |
| 243 | nakajies_state *state = | |
| 244 | nakajies_state *state = | |
| 244 | 245 | UINT8 irq = state->irq_enabled & state->irq_active; |
| 245 | 246 | UINT8 vector = 0xff; |
| 246 | 247 | |
| r8714 | r8715 | |
| 272 | 273 | |
| 273 | 274 | static WRITE8_HANDLER( irq_clear_w ) |
| 274 | 275 | { |
| 275 | nakajies_state *state = | |
| 276 | nakajies_state *state = | |
| 276 | 277 | |
| 277 | 278 | state->irq_active &= ~data; |
| 278 | 279 | nakajies_update_irqs( space->machine ); |
| r8714 | r8715 | |
| 281 | 282 | |
| 282 | 283 | static READ8_HANDLER( irq_enable_r ) |
| 283 | 284 | { |
| 284 | nakajies_state *state = | |
| 285 | nakajies_state *state = | |
| 285 | 286 | |
| 286 | 287 | return state->irq_enabled; |
| 287 | 288 | } |
| r8714 | r8715 | |
| 289 | 290 | |
| 290 | 291 | static WRITE8_HANDLER( irq_enable_w ) |
| 291 | 292 | { |
| 292 | nakajies_state *state = | |
| 293 | nakajies_state *state = | |
| 293 | 294 | |
| 294 | 295 | state->irq_enabled = data; |
| 295 | 296 | nakajies_update_irqs( space->machine ); |
| r8714 | r8715 | |
| 311 | 312 | |
| 312 | 313 | static INPUT_CHANGED( trigger_irq ) |
| 313 | 314 | { |
| 314 | nakajies_state *state = | |
| 315 | nakajies_state *state = | |
| 315 | 316 | UINT8 irqs = input_port_read( field->port->machine, "debug" ); |
| 316 | 317 | |
| 317 | 318 | state->irq_active |= irqs; |
| r8714 | r8715 | |
| 334 | 335 | |
| 335 | 336 | static MACHINE_RESET( nakajies ) |
| 336 | 337 | { |
| 337 | nakajies_state *state = | |
| 338 | nakajies_state *state = | |
| 338 | 339 | |
| 339 | 340 | state->cpu = machine->device( "v20hl" ); |
| 340 | 341 | state->irq_enabled = 0; |
| r8714 | r8715 | |
|---|---|---|
| 131 | 131 | |
| 132 | 132 | static MACHINE_RESET( 3do ) |
| 133 | 133 | { |
| 134 | _3do_state *state = | |
| 134 | _3do_state *state = | |
| 135 | 135 | |
| 136 | 136 | state->maincpu = downcast<legacy_cpu_device*>( machine->device("maincpu") ); |
| 137 | 137 |
| r8714 | r8715 | |
|---|---|---|
| 34 | 34 | |
| 35 | 35 | static void mc1000_bankswitch(running_machine *machine) |
| 36 | 36 | { |
| 37 | mc1000_state *state = | |
| 37 | mc1000_state *state = | |
| 38 | 38 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 39 | 39 | |
| 40 | 40 | /* MC6845 video RAM */ |
| r8714 | r8715 | |
| 84 | 84 | |
| 85 | 85 | static READ8_HANDLER( printer_r ) |
| 86 | 86 | { |
| 87 | mc1000_state *state = | |
| 87 | mc1000_state *state = | |
| 88 | 88 | |
| 89 | 89 | return centronics_busy_r(state->centronics); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | static WRITE8_HANDLER( printer_w ) |
| 93 | 93 | { |
| 94 | mc1000_state *state = | |
| 94 | mc1000_state *state = | |
| 95 | 95 | |
| 96 | 96 | centronics_strobe_w(state->centronics, BIT(data, 0)); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | static WRITE8_HANDLER( mc6845_ctrl_w ) |
| 100 | 100 | { |
| 101 | mc1000_state *state = | |
| 101 | mc1000_state *state = | |
| 102 | 102 | |
| 103 | 103 | state->mc6845_bank = BIT(data, 0); |
| 104 | 104 | |
| r8714 | r8715 | |
| 122 | 122 | |
| 123 | 123 | */ |
| 124 | 124 | |
| 125 | mc1000_state *state = | |
| 125 | mc1000_state *state = | |
| 126 | 126 | |
| 127 | 127 | state->mc6847_bank = BIT(data, 0); |
| 128 | 128 | mc6847_css_w(state->mc6847, BIT(data, 1)); |
| r8714 | r8715 | |
| 247 | 247 | |
| 248 | 248 | static WRITE_LINE_DEVICE_HANDLER( mc1000_mc6847_fs_w ) |
| 249 | 249 | { |
| 250 | mc1000_state *mc1000 = | |
| 250 | mc1000_state *mc1000 = | |
| 251 | 251 | mc1000->vsync = state; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | static WRITE_LINE_DEVICE_HANDLER( mc1000_mc6847_hs_w ) |
| 255 | 255 | { |
| 256 | mc1000_state *mc1000 = | |
| 256 | mc1000_state *mc1000 = | |
| 257 | 257 | mc1000->hsync = state; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | static READ8_DEVICE_HANDLER( mc1000_mc6847_videoram_r ) |
| 261 | 261 | { |
| 262 | mc1000_state *state = | |
| 262 | mc1000_state *state = | |
| 263 | 263 | |
| 264 | 264 | mc6847_inv_w(device, BIT(state->mc6847_video_ram[offset], 7)); |
| 265 | 265 | |
| r8714 | r8715 | |
| 268 | 268 | |
| 269 | 269 | static VIDEO_UPDATE( mc1000 ) |
| 270 | 270 | { |
| 271 | mc1000_state *state = | |
| 271 | mc1000_state *state = | |
| 272 | 272 | return mc6847_update(state->mc6847, bitmap, cliprect); |
| 273 | 273 | } |
| 274 | 274 | |
| r8714 | r8715 | |
| 276 | 276 | |
| 277 | 277 | static WRITE8_DEVICE_HANDLER( keylatch_w ) |
| 278 | 278 | { |
| 279 | mc1000_state *state = | |
| 279 | mc1000_state *state = | |
| 280 | 280 | |
| 281 | 281 | state->keylatch = data; |
| 282 | 282 | |
| r8714 | r8715 | |
| 285 | 285 | |
| 286 | 286 | static READ8_DEVICE_HANDLER( keydata_r ) |
| 287 | 287 | { |
| 288 | mc1000_state *state = | |
| 288 | mc1000_state *state = | |
| 289 | 289 | |
| 290 | 290 | UINT8 data = 0xff; |
| 291 | 291 | |
| r8714 | r8715 | |
| 319 | 319 | |
| 320 | 320 | static MACHINE_START( mc1000 ) |
| 321 | 321 | { |
| 322 | mc1000_state *state = | |
| 322 | mc1000_state *state = | |
| 323 | 323 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 324 | 324 | |
| 325 | 325 | /* find devices */ |
| r8714 | r8715 | |
| 364 | 364 | |
| 365 | 365 | static MACHINE_RESET( mc1000 ) |
| 366 | 366 | { |
| 367 | mc1000_state *state = | |
| 367 | mc1000_state *state = | |
| 368 | 368 | |
| 369 | 369 | memory_set_bank(machine, "bank1", 1); |
| 370 | 370 | |
| r8714 | r8715 | |
| 375 | 375 | |
| 376 | 376 | static TIMER_DEVICE_CALLBACK( ne555_tick ) |
| 377 | 377 | { |
| 378 | mc1000_state *state = | |
| 378 | mc1000_state *state = | |
| 379 | 379 | |
| 380 | 380 | if (state->ne555_int == ASSERT_LINE) |
| 381 | 381 | { |
| r8714 | r8715 | |
| 469 | 469 | |
| 470 | 470 | static DIRECT_UPDATE_HANDLER( mc1000_direct_update_handler ) |
| 471 | 471 | { |
| 472 | mc1000_state *state = | |
| 472 | mc1000_state *state = | |
| 473 | 473 | |
| 474 | 474 | if (state->rom0000) |
| 475 | 475 | { |
| r8714 | r8715 | |
|---|---|---|
| 8 | 8 | #include "cpu/hcd62121/hcd62121.h" |
| 9 | 9 | |
| 10 | 10 | |
| 11 | class cfx9850_state | |
| 11 | class cfx9850_state : public driver_data_t | |
| 12 | 12 | { |
| 13 | 13 | public: |
| 14 | static | |
| 14 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cfx9850_state(machine)); } | |
| 15 | 15 | |
| 16 | cfx9850_state(running_machine &machine) { } | |
| 16 | cfx9850_state(running_machine &machine) | |
| 17 | : driver_data_t(machine) { } | |
| 17 | 18 | |
| 18 | 19 | UINT8 *video_ram; |
| 19 | 20 | UINT8 *display_ram; |
| r8714 | r8715 | |
| 36 | 37 | |
| 37 | 38 | static WRITE8_HANDLER( cfx9850_kol_w ) |
| 38 | 39 | { |
| 39 | cfx9850_state *state = | |
| 40 | cfx9850_state *state = | |
| 40 | 41 | |
| 41 | 42 | state->ko = ( state->ko & 0xff00 ) | data; |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | static WRITE8_HANDLER( cfx9850_koh_w ) |
| 45 | 46 | { |
| 46 | cfx9850_state *state = | |
| 47 | cfx9850_state *state = | |
| 47 | 48 | |
| 48 | 49 | state->ko = ( state->ko & 0x00ff ) | ( data << 8 ); |
| 49 | 50 | } |
| r8714 | r8715 | |
| 51 | 52 | |
| 52 | 53 | static READ8_HANDLER( cfx9850_ki_r ) |
| 53 | 54 | { |
| 54 | cfx9850_state *state = | |
| 55 | cfx9850_state *state = | |
| 55 | 56 | UINT8 data = 0; |
| 56 | 57 | |
| 57 | 58 | if ( state->ko & 0x0001 ) |
| r8714 | r8715 | |
|---|---|---|
| 54 | 54 | #define TILE_X_FLIP 0x0004 |
| 55 | 55 | #define TILE_Y_FLIP 0x0008 |
| 56 | 56 | |
| 57 | class vii_state | |
| 57 | class vii_state : public driver_data_t | |
| 58 | 58 | { |
| 59 | 59 | public: |
| 60 | static | |
| 60 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vii_state(machine)); } | |
| 61 | 61 | |
| 62 | vii_state(running_machine &machine) { } | |
| 62 | vii_state(running_machine &machine) | |
| 63 | : driver_data_t(machine) { } | |
| 63 | 64 | |
| 64 | 65 | UINT16 *ram; |
| 65 | 66 | UINT16 *cart; |
| r8714 | r8715 | |
| 157 | 158 | |
| 158 | 159 | static void vii_blit(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 xoff, UINT32 yoff, UINT32 attr, UINT32 ctrl, UINT32 bitmap_addr, UINT16 tile) |
| 159 | 160 | { |
| 160 | vii_state *state = | |
| 161 | vii_state *state = | |
| 161 | 162 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 162 | 163 | |
| 163 | 164 | UINT32 h = 8 << ((attr & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT); |
| r8714 | r8715 | |
| 295 | 296 | |
| 296 | 297 | static void vii_blit_sprite(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int depth, UINT32 base_addr) |
| 297 | 298 | { |
| 298 | vii_state *state = | |
| 299 | vii_state *state = | |
| 299 | 300 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 300 | 301 | UINT16 tile, attr; |
| 301 | 302 | INT16 x, y; |
| r8714 | r8715 | |
| 337 | 338 | |
| 338 | 339 | static void vii_blit_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int depth) |
| 339 | 340 | { |
| 340 | vii_state *state = | |
| 341 | vii_state *state = | |
| 341 | 342 | UINT32 n; |
| 342 | 343 | |
| 343 | 344 | if (!(state->video_regs[0x42] & 1)) |
| r8714 | r8715 | |
| 356 | 357 | |
| 357 | 358 | static VIDEO_UPDATE( vii ) |
| 358 | 359 | { |
| 359 | vii_state *state = | |
| 360 | vii_state *state = | |
| 360 | 361 | int i, x, y; |
| 361 | 362 | |
| 362 | 363 | bitmap_fill(bitmap, cliprect, 0); |
| r8714 | r8715 | |
| 387 | 388 | |
| 388 | 389 | static void vii_do_dma(running_machine *machine, UINT32 len) |
| 389 | 390 | { |
| 390 | vii_state *state = | |
| 391 | vii_state *state = | |
| 391 | 392 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 392 | 393 | UINT32 src = state->video_regs[0x70]; |
| 393 | 394 | UINT32 dst = state->video_regs[0x71] + 0x2c00; |
| r8714 | r8715 | |
| 403 | 404 | |
| 404 | 405 | static READ16_HANDLER( vii_video_r ) |
| 405 | 406 | { |
| 406 | vii_state *state = | |
| 407 | vii_state *state = | |
| 407 | 408 | |
| 408 | 409 | switch(offset) |
| 409 | 410 | { |
| r8714 | r8715 | |
| 424 | 425 | |
| 425 | 426 | static WRITE16_HANDLER( vii_video_w ) |
| 426 | 427 | { |
| 427 | vii_state *state = | |
| 428 | vii_state *state = | |
| 428 | 429 | |
| 429 | 430 | switch(offset) |
| 430 | 431 | { |
| r8714 | r8715 | |
| 487 | 488 | |
| 488 | 489 | static void vii_switch_bank(running_machine *machine, UINT32 bank) |
| 489 | 490 | { |
| 490 | vii_state *state = | |
| 491 | vii_state *state = | |
| 491 | 492 | UINT8 *cart = memory_region(machine, "cart"); |
| 492 | 493 | |
| 493 | 494 | if(bank == state->current_bank) |
| r8714 | r8715 | |
| 502 | 503 | |
| 503 | 504 | static void vii_do_gpio(running_machine *machine, UINT32 offset) |
| 504 | 505 | { |
| 505 | vii_state *state = | |
| 506 | vii_state *state = | |
| 506 | 507 | UINT32 index = (offset - 1) / 5; |
| 507 | 508 | UINT16 buffer = state->io_regs[5*index + 2]; |
| 508 | 509 | UINT16 dir = state->io_regs[5*index + 3]; |
| r8714 | r8715 | |
| 552 | 553 | |
| 553 | 554 | static void spg_do_dma(running_machine *machine, UINT32 len) |
| 554 | 555 | { |
| 555 | vii_state *state = | |
| 556 | vii_state *state = | |
| 556 | 557 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 557 | 558 | |
| 558 | 559 | UINT32 src = ((state->io_regs[0x101] & 0x3f) << 16) | state->io_regs[0x100]; |
| r8714 | r8715 | |
| 572 | 573 | static const char *gpioregs[] = { "GPIO Data Port", "GPIO Buffer Port", "GPIO Direction Port", "GPIO Attribute Port", "GPIO IRQ/Latch Port" }; |
| 573 | 574 | static const char gpioports[] = { 'A', 'B', 'C' }; |
| 574 | 575 | |
| 575 | vii_state *state = | |
| 576 | vii_state *state = | |
| 576 | 577 | UINT16 val = state->io_regs[offset]; |
| 577 | 578 | |
| 578 | 579 | offset -= 0x500; |
| r8714 | r8715 | |
| 643 | 644 | static const char *gpioregs[] = { "GPIO Data Port", "GPIO Buffer Port", "GPIO Direction Port", "GPIO Attribute Port", "GPIO IRQ/Latch Port" }; |
| 644 | 645 | static const char gpioports[3] = { 'A', 'B', 'C' }; |
| 645 | 646 | |
| 646 | vii_state *state = | |
| 647 | vii_state *state = | |
| 647 | 648 | UINT16 temp = 0; |
| 648 | 649 | |
| 649 | 650 | offset -= 0x500; |
| r8714 | r8715 | |
| 839 | 840 | |
| 840 | 841 | static DEVICE_IMAGE_LOAD( vii_cart ) |
| 841 | 842 | { |
| 842 | vii_state *state = | |
| 843 | vii_state *state = | |
| 843 | 844 | UINT8 *cart = memory_region( image.device().machine, "cart" ); |
| 844 | 845 | if (image.software_entry() == NULL) |
| 845 | 846 | { |
| r8714 | r8715 | |
| 873 | 874 | |
| 874 | 875 | static DEVICE_IMAGE_LOAD( vsmile_cart ) |
| 875 | 876 | { |
| 876 | vii_state *state = | |
| 877 | vii_state *state = | |
| 877 | 878 | UINT8 *cart = memory_region( image.device().machine, "cart" ); |
| 878 | 879 | if (image.software_entry() == NULL) |
| 879 | 880 | { |
| r8714 | r8715 | |
| 896 | 897 | |
| 897 | 898 | static MACHINE_START( vii ) |
| 898 | 899 | { |
| 899 | vii_state *state = | |
| 900 | vii_state *state = | |
| 900 | 901 | |
| 901 | 902 | memset(state->video_regs, 0, 0x100 * sizeof(UINT16)); |
| 902 | 903 | memset(state->io_regs, 0, 0x100 * sizeof(UINT16)); |
| r8714 | r8715 | |
| 919 | 920 | |
| 920 | 921 | static INTERRUPT_GEN( vii_vblank ) |
| 921 | 922 | { |
| 922 | vii_state *state = | |
| 923 | vii_state *state = | |
| 923 | 924 | UINT32 x = mame_rand(device->machine) & 0x3ff; |
| 924 | 925 | UINT32 y = mame_rand(device->machine) & 0x3ff; |
| 925 | 926 | UINT32 z = mame_rand(device->machine) & 0x3ff; |
| r8714 | r8715 | |
| 1042 | 1043 | |
| 1043 | 1044 | static DRIVER_INIT( vii ) |
| 1044 | 1045 | { |
| 1045 | vii_state *state = | |
| 1046 | vii_state *state = | |
| 1046 | 1047 | |
| 1047 | 1048 | state->spg243_mode = SPG243_VII; |
| 1048 | 1049 | state->centered_coordinates = 1; |
| r8714 | r8715 | |
| 1050 | 1051 | |
| 1051 | 1052 | static DRIVER_INIT( batman ) |
| 1052 | 1053 | { |
| 1053 | vii_state *state = | |
| 1054 | vii_state *state = | |
| 1054 | 1055 | |
| 1055 | 1056 | state->spg243_mode = SPG243_BATMAN; |
| 1056 | 1057 | state->centered_coordinates = 1; |
| r8714 | r8715 | |
| 1058 | 1059 | |
| 1059 | 1060 | static DRIVER_INIT( vsmile ) |
| 1060 | 1061 | { |
| 1061 | vii_state *state = | |
| 1062 | vii_state *state = | |
| 1062 | 1063 | |
| 1063 | 1064 | state->spg243_mode = SPG243_VSMILE; |
| 1064 | 1065 | state->centered_coordinates = 1; |
| r8714 | r8715 | |
|---|---|---|
| 41 | 41 | |
| 42 | 42 | static void xor100_bankswitch(running_machine *machine) |
| 43 | 43 | { |
| 44 | xor100_state *state = | |
| 44 | xor100_state *state = | |
| 45 | 45 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 46 | 46 | running_device *messram = machine->device("messram"); |
| 47 | 47 | int banks = messram_get_size(messram) / 0x10000; |
| r8714 | r8715 | |
| 120 | 120 | |
| 121 | 121 | */ |
| 122 | 122 | |
| 123 | xor100_state *state = | |
| 123 | xor100_state *state = | |
| 124 | 124 | |
| 125 | 125 | state->bank = data & 0x07; |
| 126 | 126 | |
| r8714 | r8715 | |
| 129 | 129 | |
| 130 | 130 | static WRITE8_HANDLER( prom_toggle_w ) |
| 131 | 131 | { |
| 132 | xor100_state *state = | |
| 132 | xor100_state *state = | |
| 133 | 133 | |
| 134 | 134 | switch (state->mode) |
| 135 | 135 | { |
| r8714 | r8715 | |
| 142 | 142 | |
| 143 | 143 | static READ8_HANDLER( prom_disable_r ) |
| 144 | 144 | { |
| 145 | xor100_state *state = | |
| 145 | xor100_state *state = | |
| 146 | 146 | |
| 147 | 147 | state->mode = EPROM_F800; |
| 148 | 148 | |
| r8714 | r8715 | |
| 182 | 182 | |
| 183 | 183 | */ |
| 184 | 184 | |
| 185 | xor100_state *state = | |
| 185 | xor100_state *state = | |
| 186 | 186 | |
| 187 | 187 | if (!state->fdc_irq && !state->fdc_drq) |
| 188 | 188 | { |
| r8714 | r8715 | |
| 210 | 210 | |
| 211 | 211 | */ |
| 212 | 212 | |
| 213 | xor100_state *state = | |
| 213 | xor100_state *state = | |
| 214 | 214 | |
| 215 | 215 | /* drive select */ |
| 216 | 216 | if (BIT(data, 0)) wd17xx_set_drive(state->wd1795, 0); |
| r8714 | r8715 | |
| 239 | 239 | |
| 240 | 240 | */ |
| 241 | 241 | |
| 242 | xor100_state *state = | |
| 242 | xor100_state *state = | |
| 243 | 243 | |
| 244 | 244 | switch (data & 0x03) |
| 245 | 245 | { |
| r8714 | r8715 | |
| 363 | 363 | |
| 364 | 364 | static WRITE_LINE_DEVICE_HANDLER( com5016_fr_w ) |
| 365 | 365 | { |
| 366 | xor100_state *driver_state = | |
| 366 | xor100_state *driver_state = | |
| 367 | 367 | |
| 368 | 368 | msm8251_transmit_clock(driver_state->i8251_a); |
| 369 | 369 | msm8251_receive_clock(driver_state->i8251_a); |
| r8714 | r8715 | |
| 371 | 371 | |
| 372 | 372 | static WRITE_LINE_DEVICE_HANDLER( com5016_ft_w ) |
| 373 | 373 | { |
| 374 | xor100_state *driver_state = | |
| 374 | xor100_state *driver_state = | |
| 375 | 375 | |
| 376 | 376 | msm8251_transmit_clock(driver_state->i8251_b); |
| 377 | 377 | msm8251_receive_clock(driver_state->i8251_b); |
| r8714 | r8715 | |
| 423 | 423 | |
| 424 | 424 | */ |
| 425 | 425 | |
| 426 | xor100_state *driver_state = | |
| 426 | xor100_state *driver_state = | |
| 427 | 427 | UINT8 data = 0; |
| 428 | 428 | |
| 429 | 429 | /* on line */ |
| r8714 | r8715 | |
| 480 | 480 | |
| 481 | 481 | static WRITE_LINE_DEVICE_HANDLER( fdc_irq_w ) |
| 482 | 482 | { |
| 483 | xor100_state *driver_state = | |
| 483 | xor100_state *driver_state = | |
| 484 | 484 | |
| 485 | 485 | driver_state->fdc_irq = state; |
| 486 | 486 | z80ctc_trg0_w(driver_state->z80ctc, state); |
| r8714 | r8715 | |
| 494 | 494 | |
| 495 | 495 | static WRITE_LINE_DEVICE_HANDLER( fdc_drq_w ) |
| 496 | 496 | { |
| 497 | xor100_state *driver_state = | |
| 497 | xor100_state *driver_state = | |
| 498 | 498 | |
| 499 | 499 | driver_state->fdc_drq = state; |
| 500 | 500 | |
| r8714 | r8715 | |
| 517 | 517 | |
| 518 | 518 | static WRITE8_DEVICE_HANDLER( xor100_kbd_put ) |
| 519 | 519 | { |
| 520 | xor100_state *state = | |
| 520 | xor100_state *state = | |
| 521 | 521 | |
| 522 | 522 | msm8251_receive_character(state->i8251_b, data); |
| 523 | 523 | } |
| r8714 | r8715 | |
| 531 | 531 | |
| 532 | 532 | static MACHINE_START( xor100 ) |
| 533 | 533 | { |
| 534 | xor100_state *state = | |
| 534 | xor100_state *state = | |
| 535 | 535 | running_device *messram = machine->device("messram"); |
| 536 | 536 | int banks = messram_get_size(messram) / 0x10000; |
| 537 | 537 | |
| r8714 | r8715 | |
| 559 | 559 | |
| 560 | 560 | static MACHINE_RESET( xor100 ) |
| 561 | 561 | { |
| 562 | xor100_state *state = | |
| 562 | xor100_state *state = | |
| 563 | 563 | |
| 564 | 564 | state->mode = EPROM_0000; |
| 565 | 565 |
| r8714 | r8715 | |
|---|---|---|
| 94 | 94 | |
| 95 | 95 | static WRITE8_HANDLER( keyboard_latch_w ) |
| 96 | 96 | { |
| 97 | tmc600_state *state = | |
| 97 | tmc600_state *state = | |
| 98 | 98 | |
| 99 | 99 | state->keylatch = data; |
| 100 | 100 | } |
| r8714 | r8715 | |
| 225 | 225 | |
| 226 | 226 | static CDP1802_EF_READ( tmc600_ef_r ) |
| 227 | 227 | { |
| 228 | tmc600_state *state = | |
| 228 | tmc600_state *state = | |
| 229 | 229 | |
| 230 | 230 | int flags = 0x0f; |
| 231 | 231 | static const char *const keynames[] = { "IN0", "IN1", "IN2", "IN3", "IN4", "IN5", "IN6", "IN7" }; |
| r8714 | r8715 | |
| 250 | 250 | |
| 251 | 251 | static WRITE_LINE_DEVICE_HANDLER( tmc600_q_w ) |
| 252 | 252 | { |
| 253 | tmc600_state *driver_state = | |
| 253 | tmc600_state *driver_state = | |
| 254 | 254 | |
| 255 | 255 | cassette_output(driver_state->cassette, state ? +1.0 : -1.0); |
| 256 | 256 | } |
| r8714 | r8715 | |
| 269 | 269 | |
| 270 | 270 | static MACHINE_START( tmc600 ) |
| 271 | 271 | { |
| 272 | tmc600_state *state = | |
| 272 | tmc600_state *state = | |
| 273 | 273 | const address_space *program = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM); |
| 274 | 274 | |
| 275 | 275 | /* find devices */ |
| r8714 | r8715 | |
|---|---|---|
| 185 | 185 | |
| 186 | 186 | */ |
| 187 | 187 | |
| 188 | vic20_state *state = | |
| 188 | vic20_state *state = | |
| 189 | 189 | UINT8 data = 0xfc; |
| 190 | 190 | |
| 191 | 191 | /* serial clock in */ |
| r8714 | r8715 | |
| 223 | 223 | |
| 224 | 224 | */ |
| 225 | 225 | |
| 226 | vic20_state *state = | |
| 226 | vic20_state *state = | |
| 227 | 227 | |
| 228 | 228 | /* serial attention out */ |
| 229 | 229 | cbm_iec_atn_w(state->iec, device, !BIT(data, 7)); |
| r8714 | r8715 | |
| 269 | 269 | |
| 270 | 270 | static WRITE8_DEVICE_HANDLER( via0_ca2_w ) |
| 271 | 271 | { |
| 272 | vic20_state *state = | |
| 272 | vic20_state *state = | |
| 273 | 273 | |
| 274 | 274 | if (!BIT(data, 0)) |
| 275 | 275 | { |
| r8714 | r8715 | |
| 319 | 319 | |
| 320 | 320 | */ |
| 321 | 321 | |
| 322 | vic20_state *state = | |
| 322 | vic20_state *state = | |
| 323 | 323 | UINT8 data = 0xff; |
| 324 | 324 | |
| 325 | 325 | if (!BIT(state->key_col, 0)) data &= input_port_read(device->machine, "ROW0"); |
| r8714 | r8715 | |
| 376 | 376 | |
| 377 | 377 | */ |
| 378 | 378 | |
| 379 | vic20_state *state = | |
| 379 | vic20_state *state = | |
| 380 | 380 | |
| 381 | 381 | /* cassette write */ |
| 382 | 382 | cassette_output(device->machine->device("cassette"), BIT(data, 3) ? -(0x5a9e >> 1) : +(0x5a9e >> 1)); |
| r8714 | r8715 | |
| 387 | 387 | |
| 388 | 388 | static WRITE_LINE_DEVICE_HANDLER( via1_ca2_w ) |
| 389 | 389 | { |
| 390 | vic20_state *driver_state = | |
| 390 | vic20_state *driver_state = | |
| 391 | 391 | |
| 392 | 392 | /* serial clock out */ |
| 393 | 393 | cbm_iec_clk_w(driver_state->iec, device, !state); |
| r8714 | r8715 | |
| 395 | 395 | |
| 396 | 396 | static WRITE_LINE_DEVICE_HANDLER( via1_cb2_w ) |
| 397 | 397 | { |
| 398 | vic20_state *driver_state = | |
| 398 | vic20_state *driver_state = | |
| 399 | 399 | |
| 400 | 400 | /* serial data out */ |
| 401 | 401 | cbm_iec_data_w(driver_state->iec, device, !state); |
| r8714 | r8715 | |
| 424 | 424 | |
| 425 | 425 | static TIMER_DEVICE_CALLBACK( cassette_tick ) |
| 426 | 426 | { |
| 427 | vic20_state *state = | |
| 427 | vic20_state *state = | |
| 428 | 428 | int data = (cassette_input(state->cassette) > +0.0) ? 1 : 0; |
| 429 | 429 | |
| 430 | 430 | via_ca1_w(state->via1, data); |
| r8714 | r8715 | |
| 516 | 516 | |
| 517 | 517 | static MACHINE_START( vic20 ) |
| 518 | 518 | { |
| 519 | vic20_state *state = | |
| 519 | vic20_state *state = | |
| 520 | 520 | const address_space *program = cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM); |
| 521 | 521 | |
| 522 | 522 | /* find devices */ |
| r8714 | r8715 | |
| 622 | 622 | |
| 623 | 623 | static VIDEO_UPDATE( vic20 ) |
| 624 | 624 | { |
| 625 | vic20_state *state = | |
| 625 | vic20_state *state = | |
| 626 | 626 | mos6560_video_update(state->mos6560, bitmap, cliprect); |
| 627 | 627 | return 0; |
| 628 | 628 | } |
| r8714 | r8715 | |
| 631 | 631 | |
| 632 | 632 | static INTERRUPT_GEN( vic20_raster_interrupt ) |
| 633 | 633 | { |
| 634 | vic20_state *state = | |
| 634 | vic20_state *state = | |
| 635 | 635 | mos6560_raster_interrupt_gen(state->mos6560); |
| 636 | 636 | } |
| 637 | 637 |
| r8714 | r8715 | |
|---|---|---|
| 16 | 16 | #include "emu.h" |
| 17 | 17 | #include "cpu/z80/z80.h" |
| 18 | 18 | |
| 19 | class bcs3_state | |
| 19 | class bcs3_state : public driver_data_t | |
| 20 | 20 | { |
| 21 | 21 | public: |
| 22 | static | |
| 22 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bcs3_state(machine)); } | |
| 23 | 23 | |
| 24 | bcs3_state(running_machine &machine) { } | |
| 24 | bcs3_state(running_machine &machine) | |
| 25 | : driver_data_t(machine) { } | |
| 25 | 26 | |
| 26 | 27 | const UINT8 *fnt; |
| 27 | 28 | UINT8 *videoram; |
| r8714 | r8715 | |
| 29 | 30 | |
| 30 | 31 | static READ8_HANDLER( bcs3_videoram_r ) |
| 31 | 32 | { |
| 32 | bcs3_state *state = | |
| 33 | bcs3_state *state = | |
| 33 | 34 | |
| 34 | 35 | return state->videoram[offset]; |
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | static WRITE8_HANDLER( bcs3_videoram_w ) |
| 38 | 39 | { |
| 39 | bcs3_state *state = | |
| 40 | bcs3_state *state = | |
| 40 | 41 | |
| 41 | 42 | state->videoram[offset] = data; |
| 42 | 43 | } |
| r8714 | r8715 | |
| 221 | 222 | |
| 222 | 223 | static VIDEO_START( bcs3 ) |
| 223 | 224 | { |
| 224 | bcs3_state *state = | |
| 225 | bcs3_state *state = | |
| 225 | 226 | |
| 226 | 227 | state->fnt = memory_region(machine, "gfx1"); |
| 227 | 228 | } |
| 228 | 229 | |
| 229 | 230 | static VIDEO_UPDATE( bcs3 ) |
| 230 | 231 | { |
| 231 | bcs3_state *state = | |
| 232 | bcs3_state *state = | |
| 232 | 233 | UINT8 y,ra,chr,gfx,rat; |
| 233 | 234 | UINT16 sy=0,ma=0,x; |
| 234 | 235 | |
| r8714 | r8715 | |
| 271 | 272 | with the cursor always in sight. */ |
| 272 | 273 | static VIDEO_UPDATE( bcs3a ) |
| 273 | 274 | { |
| 274 | bcs3_state *state = | |
| 275 | bcs3_state *state = | |
| 275 | 276 | UINT8 y,ra,chr,gfx,rat; |
| 276 | 277 | UINT16 sy=0,ma=128,x; |
| 277 | 278 | UINT16 cursor = (state->videoram[0x7a] | (state->videoram[0x7b] << 8)) - 0x3c80; // get cursor relative position |
| r8714 | r8715 | |
| 315 | 316 | |
| 316 | 317 | static VIDEO_UPDATE( bcs3b ) |
| 317 | 318 | { |
| 318 | bcs3_state *state = | |
| 319 | bcs3_state *state = | |
| 319 | 320 | UINT8 y,ra,chr,gfx,rat; |
| 320 | 321 | UINT16 sy=0,ma=128,x; |
| 321 | 322 | UINT16 cursor = (state->videoram[0x7a] | (state->videoram[0x7b] << 8)) - 0x3c80; // get cursor relative position |
| r8714 | r8715 | |
| 359 | 360 | |
| 360 | 361 | static VIDEO_UPDATE( bcs3c ) |
| 361 | 362 | { |
| 362 | bcs3_state *state = | |
| 363 | bcs3_state *state = | |
| 363 | 364 | UINT8 y,ra,chr,gfx,rat; |
| 364 | 365 | UINT16 sy=0,ma=0xb4,x; |
| 365 | 366 | UINT16 cursor = (state->videoram[0x08] | (state->videoram[0x09] << 8)) - 0x3c80; // get cursor relative position |
| r8714 | r8715 | |
|---|---|---|
| 185 | 185 | |
| 186 | 186 | static void scorpion_update_memory(running_machine *machine) |
| 187 | 187 | { |
| 188 | spectrum_state *state = | |
| 188 | spectrum_state *state = | |
| 189 | 189 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 190 | 190 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 191 | 191 | |
| r8714 | r8715 | |
| 218 | 218 | |
| 219 | 219 | static DIRECT_UPDATE_HANDLER( scorpion_direct ) |
| 220 | 220 | { |
| 221 | spectrum_state *state = | |
| 221 | spectrum_state *state = | |
| 222 | 222 | running_device *beta = space->machine->device(BETA_DISK_TAG); |
| 223 | 223 | UINT16 pc = cpu_get_reg(space->machine->device("maincpu"), STATE_GENPCBASE); |
| 224 | 224 | |
| r8714 | r8715 | |
| 249 | 249 | |
| 250 | 250 | static TIMER_CALLBACK(nmi_check_callback) |
| 251 | 251 | { |
| 252 | spectrum_state *state = | |
| 252 | spectrum_state *state = | |
| 253 | 253 | |
| 254 | 254 | if ((input_port_read(machine, "NMI") & 1)==1) |
| 255 | 255 | { |
| r8714 | r8715 | |
| 261 | 261 | |
| 262 | 262 | static WRITE8_HANDLER(scorpion_port_7ffd_w) |
| 263 | 263 | { |
| 264 | spectrum_state *state = | |
| 264 | spectrum_state *state = | |
| 265 | 265 | |
| 266 | 266 | /* disable paging */ |
| 267 | 267 | if (state->port_7ffd_data & 0x20) |
| r8714 | r8715 | |
| 276 | 276 | |
| 277 | 277 | static WRITE8_HANDLER(scorpion_port_1ffd_w) |
| 278 | 278 | { |
| 279 | spectrum_state *state = | |
| 279 | spectrum_state *state = | |
| 280 | 280 | |
| 281 | 281 | /* if paging not disabled */ |
| 282 | 282 | if ((state->port_7ffd_data & 0x20)==0) |
| r8714 | r8715 | |
| 303 | 303 | |
| 304 | 304 | static MACHINE_RESET( scorpion ) |
| 305 | 305 | { |
| 306 | spectrum_state *state = | |
| 306 | spectrum_state *state = | |
| 307 | 307 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 308 | 308 | running_device *beta = machine->device(BETA_DISK_TAG); |
| 309 | 309 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| r8714 | r8715 | |
|---|---|---|
| 167 | 167 | |
| 168 | 168 | static TIMER_CALLBACK( keyboard_data_clear ) |
| 169 | 169 | { |
| 170 | abc80_state *state = | |
| 170 | abc80_state *state = | |
| 171 | 171 | |
| 172 | 172 | state->key_data = 0; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | static void abc80_keyboard_scan(running_machine *machine) |
| 176 | 176 | { |
| 177 | abc80_state *state = | |
| 177 | abc80_state *state = | |
| 178 | 178 | |
| 179 | 179 | static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6" }; |
| 180 | 180 | int table = 0, row, col; |
| r8714 | r8715 | |
| 379 | 379 | |
| 380 | 380 | static TIMER_DEVICE_CALLBACK( z80pio_astb_tick ) |
| 381 | 381 | { |
| 382 | abc80_state *state = | |
| 382 | abc80_state *state = | |
| 383 | 383 | |
| 384 | 384 | /* toggle ASTB every other video line */ |
| 385 | 385 | state->z80pio_astb = !state->z80pio_astb; |
| r8714 | r8715 | |
| 406 | 406 | |
| 407 | 407 | */ |
| 408 | 408 | |
| 409 | abc80_state *state = | |
| 409 | abc80_state *state = | |
| 410 | 410 | |
| 411 | 411 | return (state->key_strobe << 7) | state->key_data; |
| 412 | 412 | }; |
| r8714 | r8715 | |
| 428 | 428 | |
| 429 | 429 | */ |
| 430 | 430 | |
| 431 | abc80_state *state = | |
| 431 | abc80_state *state = | |
| 432 | 432 | |
| 433 | 433 | /* cassette data */ |
| 434 | 434 | UINT8 data = (cassette_input(state->cassette) > +1.0) ? 0x80 : 0; |
| r8714 | r8715 | |
| 453 | 453 | |
| 454 | 454 | */ |
| 455 | 455 | |
| 456 | abc80_state *state = | |
| 456 | abc80_state *state = | |
| 457 | 457 | |
| 458 | 458 | /* cassette motor */ |
| 459 | 459 | cassette_change_state(state->cassette, BIT(data, 5) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| r8714 | r8715 | |
| 491 | 491 | |
| 492 | 492 | static MACHINE_START( abc80 ) |
| 493 | 493 | { |
| 494 | abc80_state *state = | |
| 494 | abc80_state *state = | |
| 495 | 495 | |
| 496 | 496 | /* configure RAM expansion */ |
| 497 | 497 | memory_configure_bank(machine, "bank1", 0, 1, messram_get_ptr(machine->device("messram")), 0); |
| r8714 | r8715 | |
|---|---|---|
| 294 | 294 | |
| 295 | 295 | WRITE8_HANDLER(spectrum_port_fe_w) |
| 296 | 296 | { |
| 297 | spectrum_state *state = | |
| 297 | spectrum_state *state = | |
| 298 | 298 | running_device *speaker = space->machine->device("speaker"); |
| 299 | 299 | unsigned char Changed; |
| 300 | 300 | |
| r8714 | r8715 | |
| 425 | 425 | |
| 426 | 426 | static READ8_HANDLER ( spectrum_port_ula_r ) |
| 427 | 427 | { |
| 428 | spectrum_state *state = | |
| 428 | spectrum_state *state = | |
| 429 | 429 | int vpos = space->machine->primary_screen->vpos(); |
| 430 | 430 | |
| 431 | 431 | return vpos<193 ? state->video_ram[(vpos&0xf8)<<2]:0xff; |
| r8714 | r8715 | |
| 635 | 635 | |
| 636 | 636 | MACHINE_RESET( spectrum ) |
| 637 | 637 | { |
| 638 | spectrum_state *state = | |
| 638 | spectrum_state *state = | |
| 639 | 639 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 640 | 640 | |
| 641 | 641 | memory_set_direct_update_handler(space, spectrum_direct); |
| r8714 | r8715 | |
|---|---|---|
| 216 | 216 | |
| 217 | 217 | static TIMER_CALLBACK( led_refresh ) |
| 218 | 218 | { |
| 219 | mpf1_state *state = | |
| 219 | mpf1_state *state = | |
| 220 | 220 | |
| 221 | 221 | if (BIT(state->lednum, 5)) output_set_digit_value(0, param); |
| 222 | 222 | if (BIT(state->lednum, 4)) output_set_digit_value(1, param); |
| r8714 | r8715 | |
| 228 | 228 | |
| 229 | 229 | static READ8_DEVICE_HANDLER( mpf1_porta_r ) |
| 230 | 230 | { |
| 231 | mpf1_state *state = | |
| 231 | mpf1_state *state = | |
| 232 | 232 | UINT8 data = 0x7f; |
| 233 | 233 | |
| 234 | 234 | /* bit 0 to 5, keyboard rows 0 to 5 */ |
| r8714 | r8715 | |
| 250 | 250 | |
| 251 | 251 | static WRITE8_DEVICE_HANDLER( mpf1_portb_w ) |
| 252 | 252 | { |
| 253 | mpf1_state *state = | |
| 253 | mpf1_state *state = | |
| 254 | 254 | |
| 255 | 255 | /* swap bits around for the mame 7-segment emulation */ |
| 256 | 256 | UINT8 led_data = BITSWAP8(data, 6, 1, 2, 0, 7, 5, 4, 3); |
| r8714 | r8715 | |
| 261 | 261 | |
| 262 | 262 | static WRITE8_DEVICE_HANDLER( mpf1_portc_w ) |
| 263 | 263 | { |
| 264 | mpf1_state *state = | |
| 264 | mpf1_state *state = | |
| 265 | 265 | |
| 266 | 266 | /* bits 0-5, led select and keyboard latch */ |
| 267 | 267 | state->lednum = data & 0x3f; |
| r8714 | r8715 | |
| 360 | 360 | |
| 361 | 361 | static MACHINE_START( mpf1 ) |
| 362 | 362 | { |
| 363 | mpf1_state *state = | |
| 363 | mpf1_state *state = | |
| 364 | 364 | |
| 365 | 365 | /* find devices */ |
| 366 | 366 | state->speaker = machine->device(SPEAKER_TAG); |
| r8714 | r8715 | |
| 378 | 378 | |
| 379 | 379 | static MACHINE_RESET( mpf1 ) |
| 380 | 380 | { |
| 381 | mpf1_state *state = | |
| 381 | mpf1_state *state = | |
| 382 | 382 | |
| 383 | 383 | state->lednum = 0; |
| 384 | 384 | } |
| r8714 | r8715 | |
| 495 | 495 | |
| 496 | 496 | static DIRECT_UPDATE_HANDLER( mpf1_direct_update_handler ) |
| 497 | 497 | { |
| 498 | mpf1_state *state = | |
| 498 | mpf1_state *state = | |
| 499 | 499 | |
| 500 | 500 | if (!state->_break) |
| 501 | 501 | { |
| r8714 | r8715 | |
|---|---|---|
| 42 | 42 | static void atarist_fdc_dma_transfer(running_machine *machine) |
| 43 | 43 | { |
| 44 | 44 | const address_space *program = cputag_get_address_space(machine, M68000_TAG, ADDRESS_SPACE_PROGRAM); |
| 45 | atarist_state *state = | |
| 45 | atarist_state *state = | |
| 46 | 46 | |
| 47 | 47 | if ((state->fdc_mode & ATARIST_FLOPPY_MODE_DMA_DISABLE) == 0) |
| 48 | 48 | { |
| r8714 | r8715 | |
| 83 | 83 | |
| 84 | 84 | static WRITE_LINE_DEVICE_HANDLER( atarist_fdc_intrq_w ) |
| 85 | 85 | { |
| 86 | atarist_state *driver_state = | |
| 86 | atarist_state *driver_state = | |
| 87 | 87 | |
| 88 | 88 | driver_state->fdc_irq = state; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | static WRITE_LINE_DEVICE_HANDLER( atarist_fdc_drq_w ) |
| 92 | 92 | { |
| 93 | atarist_state *driver_state = | |
| 93 | atarist_state *driver_state = | |
| 94 | 94 | |
| 95 | 95 | if (state) |
| 96 | 96 | { |
| r8714 | r8715 | |
| 121 | 121 | |
| 122 | 122 | static READ16_HANDLER( atarist_fdc_data_r ) |
| 123 | 123 | { |
| 124 | atarist_state *state = | |
| 124 | atarist_state *state = | |
| 125 | 125 | |
| 126 | 126 | if (state->fdc_mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT) |
| 127 | 127 | { |
| r8714 | r8715 | |
| 145 | 145 | |
| 146 | 146 | static WRITE16_HANDLER( atarist_fdc_data_w ) |
| 147 | 147 | { |
| 148 | atarist_state *state = | |
| 148 | atarist_state *state = | |
| 149 | 149 | |
| 150 | 150 | if (state->fdc_mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT) |
| 151 | 151 | { |
| r8714 | r8715 | |
| 176 | 176 | |
| 177 | 177 | static READ16_HANDLER( atarist_fdc_dma_status_r ) |
| 178 | 178 | { |
| 179 | atarist_state *state = | |
| 179 | atarist_state *state = | |
| 180 | 180 | |
| 181 | 181 | return state->fdc_status; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | static WRITE16_HANDLER( atarist_fdc_dma_mode_w ) |
| 185 | 185 | { |
| 186 | atarist_state *state = | |
| 186 | atarist_state *state = | |
| 187 | 187 | |
| 188 | 188 | if ((data & ATARIST_FLOPPY_MODE_WRITE) != (state->fdc_mode & ATARIST_FLOPPY_MODE_WRITE)) |
| 189 | 189 | { |
| r8714 | r8715 | |
| 196 | 196 | |
| 197 | 197 | static READ16_HANDLER( atarist_fdc_dma_base_r ) |
| 198 | 198 | { |
| 199 | atarist_state *state = | |
| 199 | atarist_state *state = | |
| 200 | 200 | |
| 201 | 201 | switch (offset) |
| 202 | 202 | { |
| r8714 | r8715 | |
| 213 | 213 | |
| 214 | 214 | static WRITE16_HANDLER( atarist_fdc_dma_base_w ) |
| 215 | 215 | { |
| 216 | atarist_state *state = | |
| 216 | atarist_state *state = | |
| 217 | 217 | |
| 218 | 218 | switch (offset) |
| 219 | 219 | { |
| r8714 | r8715 | |
| 235 | 235 | |
| 236 | 236 | static READ16_HANDLER( atarist_mmu_r ) |
| 237 | 237 | { |
| 238 | atarist_state *state = | |
| 238 | atarist_state *state = | |
| 239 | 239 | |
| 240 | 240 | return state->mmu; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | static WRITE16_HANDLER( atarist_mmu_w ) |
| 244 | 244 | { |
| 245 | atarist_state *state = | |
| 245 | atarist_state *state = | |
| 246 | 246 | |
| 247 | 247 | state->mmu = data & 0xff; |
| 248 | 248 | } |
| r8714 | r8715 | |
| 269 | 269 | |
| 270 | 270 | */ |
| 271 | 271 | |
| 272 | atarist_state *state = | |
| 272 | atarist_state *state = | |
| 273 | 273 | |
| 274 | 274 | return state->ikbd_keylatch; |
| 275 | 275 | } |
| r8714 | r8715 | |
| 288 | 288 | |
| 289 | 289 | */ |
| 290 | 290 | |
| 291 | atarist_state *state = | |
| 291 | atarist_state *state = | |
| 292 | 292 | |
| 293 | 293 | return (state->ikbd_tx << 3) | (input_port_read_safe(space->machine, "IKBD_JOY1", 0xff) & 0x06); |
| 294 | 294 | } |
| r8714 | r8715 | |
| 307 | 307 | |
| 308 | 308 | */ |
| 309 | 309 | |
| 310 | atarist_state *state = | |
| 310 | atarist_state *state = | |
| 311 | 311 | |
| 312 | 312 | state->ikbd_rx = (data & 0x10) >> 4; |
| 313 | 313 | } |
| r8714 | r8715 | |
| 329 | 329 | |
| 330 | 330 | */ |
| 331 | 331 | |
| 332 | atarist_state *state = | |
| 332 | atarist_state *state = | |
| 333 | 333 | |
| 334 | 334 | set_led_status(space->machine, 1, data & 0x01); |
| 335 | 335 | |
| r8714 | r8715 | |
| 359 | 359 | |
| 360 | 360 | */ |
| 361 | 361 | |
| 362 | atarist_state *state = | |
| 362 | atarist_state *state = | |
| 363 | 363 | |
| 364 | 364 | if (input_port_read(space->machine, "config") & 0x01) |
| 365 | 365 | { |
| r8714 | r8715 | |
| 442 | 442 | |
| 443 | 443 | */ |
| 444 | 444 | |
| 445 | atarist_state *state = | |
| 445 | atarist_state *state = | |
| 446 | 446 | |
| 447 | 447 | if (~data & 0x01) state->ikbd_keylatch = input_port_read(space->machine, "P40"); |
| 448 | 448 | if (~data & 0x02) state->ikbd_keylatch = input_port_read(space->machine, "P41"); |
| r8714 | r8715 | |
| 460 | 460 | |
| 461 | 461 | static void atariste_dmasound_set_state(running_machine *machine, int level) |
| 462 | 462 | { |
| 463 | atarist_state *state = | |
| 463 | atarist_state *state = | |
| 464 | 464 | |
| 465 | 465 | state->dmasnd_active = level; |
| 466 | 466 | mc68901_tai_w(state->mc68901, level); |
| r8714 | r8715 | |
| 478 | 478 | |
| 479 | 479 | static TIMER_CALLBACK( atariste_dmasound_tick ) |
| 480 | 480 | { |
| 481 | atarist_state *state = | |
| 481 | atarist_state *state = | |
| 482 | 482 | |
| 483 | 483 | if (state->dmasnd_samples == 0) |
| 484 | 484 | { |
| r8714 | r8715 | |
| 528 | 528 | |
| 529 | 529 | static READ16_HANDLER( atariste_sound_dma_control_r ) |
| 530 | 530 | { |
| 531 | atarist_state *state = | |
| 531 | atarist_state *state = | |
| 532 | 532 | |
| 533 | 533 | return state->dmasnd_ctrl; |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | static READ16_HANDLER( atariste_sound_dma_base_r ) |
| 537 | 537 | { |
| 538 | atarist_state *state = | |
| 538 | atarist_state *state = | |
| 539 | 539 | |
| 540 | 540 | switch (offset) |
| 541 | 541 | { |
| r8714 | r8715 | |
| 552 | 552 | |
| 553 | 553 | static READ16_HANDLER( atariste_sound_dma_counter_r ) |
| 554 | 554 | { |
| 555 | atarist_state *state = | |
| 555 | atarist_state *state = | |
| 556 | 556 | |
| 557 | 557 | switch (offset) |
| 558 | 558 | { |
| r8714 | r8715 | |
| 569 | 569 | |
| 570 | 570 | static READ16_HANDLER( atariste_sound_dma_end_r ) |
| 571 | 571 | { |
| 572 | atarist_state *state = | |
| 572 | atarist_state *state = | |
| 573 | 573 | |
| 574 | 574 | switch (offset) |
| 575 | 575 | { |
| r8714 | r8715 | |
| 586 | 586 | |
| 587 | 587 | static READ16_HANDLER( atariste_sound_mode_r ) |
| 588 | 588 | { |
| 589 | atarist_state *state = | |
| 589 | atarist_state *state = | |
| 590 | 590 | |
| 591 | 591 | return state->dmasnd_mode; |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | static WRITE16_HANDLER( atariste_sound_dma_control_w ) |
| 595 | 595 | { |
| 596 | atarist_state *state = | |
| 596 | atarist_state *state = | |
| 597 | 597 | |
| 598 | 598 | state->dmasnd_ctrl = data & 0x03; |
| 599 | 599 | |
| r8714 | r8715 | |
| 614 | 614 | |
| 615 | 615 | static WRITE16_HANDLER( atariste_sound_dma_base_w ) |
| 616 | 616 | { |
| 617 | atarist_state *state = | |
| 617 | atarist_state *state = | |
| 618 | 618 | |
| 619 | 619 | switch (offset) |
| 620 | 620 | { |
| r8714 | r8715 | |
| 637 | 637 | |
| 638 | 638 | static WRITE16_HANDLER( atariste_sound_dma_end_w ) |
| 639 | 639 | { |
| 640 | atarist_state *state = | |
| 640 | atarist_state *state = | |
| 641 | 641 | |
| 642 | 642 | switch (offset) |
| 643 | 643 | { |
| r8714 | r8715 | |
| 660 | 660 | |
| 661 | 661 | static WRITE16_HANDLER( atariste_sound_mode_w ) |
| 662 | 662 | { |
| 663 | atarist_state *state = | |
| 663 | atarist_state *state = | |
| 664 | 664 | |
| 665 | 665 | state->dmasnd_mode = data & 0x8f; |
| 666 | 666 | } |
| r8714 | r8715 | |
| 669 | 669 | |
| 670 | 670 | static void atariste_microwire_shift(running_machine *machine) |
| 671 | 671 | { |
| 672 | atarist_state *state = | |
| 672 | atarist_state *state = | |
| 673 | 673 | |
| 674 | 674 | if (BIT(state->mw_mask, 15)) |
| 675 | 675 | { |
| r8714 | r8715 | |
| 687 | 687 | |
| 688 | 688 | static TIMER_CALLBACK( atariste_microwire_tick ) |
| 689 | 689 | { |
| 690 | atarist_state *state = | |
| 690 | atarist_state *state = | |
| 691 | 691 | |
| 692 | 692 | switch (state->mw_shift) |
| 693 | 693 | { |
| r8714 | r8715 | |
| 711 | 711 | |
| 712 | 712 | static READ16_HANDLER( atariste_microwire_data_r ) |
| 713 | 713 | { |
| 714 | atarist_state *state = | |
| 714 | atarist_state *state = | |
| 715 | 715 | |
| 716 | 716 | return state->mw_data; |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | static WRITE16_HANDLER( atariste_microwire_data_w ) |
| 720 | 720 | { |
| 721 | atarist_state *state = | |
| 721 | atarist_state *state = | |
| 722 | 722 | |
| 723 | 723 | if (!timer_enabled(state->microwire_timer)) |
| 724 | 724 | { |
| r8714 | r8715 | |
| 729 | 729 | |
| 730 | 730 | static READ16_HANDLER( atariste_microwire_mask_r ) |
| 731 | 731 | { |
| 732 | atarist_state *state = | |
| 732 | atarist_state *state = | |
| 733 | 733 | |
| 734 | 734 | return state->mw_mask; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | static WRITE16_HANDLER( atariste_microwire_mask_w ) |
| 738 | 738 | { |
| 739 | atarist_state *state = | |
| 739 | atarist_state *state = | |
| 740 | 740 | |
| 741 | 741 | if (!timer_enabled(state->microwire_timer)) |
| 742 | 742 | { |
| r8714 | r8715 | |
| 748 | 748 | |
| 749 | 749 | static READ16_HANDLER( megaste_cache_r ) |
| 750 | 750 | { |
| 751 | atarist_state *state = | |
| 751 | atarist_state *state = | |
| 752 | 752 | |
| 753 | 753 | return state->megaste_cache; |
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | static WRITE16_HANDLER( megaste_cache_w ) |
| 757 | 757 | { |
| 758 | atarist_state *state = | |
| 758 | atarist_state *state = | |
| 759 | 759 | |
| 760 | 760 | state->megaste_cache = data; |
| 761 | 761 | |
| r8714 | r8715 | |
| 1288 | 1288 | |
| 1289 | 1289 | static WRITE8_DEVICE_HANDLER( ym2149_port_a_w ) |
| 1290 | 1290 | { |
| 1291 | atarist_state *state = | |
| 1291 | atarist_state *state = | |
| 1292 | 1292 | |
| 1293 | 1293 | wd17xx_set_side(state->wd1772, BIT(data, 0) ? 0 : 1); |
| 1294 | 1294 | |
| r8714 | r8715 | |
| 1325 | 1325 | |
| 1326 | 1326 | static READ_LINE_DEVICE_HANDLER( ikbd_rx ) |
| 1327 | 1327 | { |
| 1328 | atarist_state *driver_state = | |
| 1328 | atarist_state *driver_state = | |
| 1329 | 1329 | |
| 1330 | 1330 | return driver_state->ikbd_rx; |
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | 1333 | static WRITE_LINE_DEVICE_HANDLER( ikbd_tx ) |
| 1334 | 1334 | { |
| 1335 | atarist_state *driver_state = | |
| 1335 | atarist_state *driver_state = | |
| 1336 | 1336 | |
| 1337 | 1337 | driver_state->ikbd_tx = state; |
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | static READ_LINE_DEVICE_HANDLER( midi_rx ) |
| 1341 | 1341 | { |
| 1342 | atarist_state *driver_state = | |
| 1342 | atarist_state *driver_state = | |
| 1343 | 1343 | |
| 1344 | 1344 | return driver_state->midi_rx; |
| 1345 | 1345 | } |
| 1346 | 1346 | |
| 1347 | 1347 | static WRITE_LINE_DEVICE_HANDLER( midi_tx ) |
| 1348 | 1348 | { |
| 1349 | atarist_state *driver_state = | |
| 1349 | atarist_state *driver_state = | |
| 1350 | 1350 | |
| 1351 | 1351 | driver_state->midi_tx = state; |
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | 1354 | static WRITE_LINE_DEVICE_HANDLER( acia_interrupt ) |
| 1355 | 1355 | { |
| 1356 | atarist_state *driver_state = | |
| 1356 | atarist_state *driver_state = | |
| 1357 | 1357 | |
| 1358 | 1358 | driver_state->acia_irq = state; |
| 1359 | 1359 | } |
| r8714 | r8715 | |
| 1384 | 1384 | |
| 1385 | 1385 | static IRQ_CALLBACK( atarist_int_ack ) |
| 1386 | 1386 | { |
| 1387 | atarist_state *state = | |
| 1387 | atarist_state *state = | |
| 1388 | 1388 | |
| 1389 | 1389 | if (irqline == M68K_IRQ_6) |
| 1390 | 1390 | { |
| r8714 | r8715 | |
| 1411 | 1411 | |
| 1412 | 1412 | */ |
| 1413 | 1413 | |
| 1414 | atarist_state *state = | |
| 1414 | atarist_state *state = | |
| 1415 | 1415 | |
| 1416 | 1416 | UINT8 data = centronics_busy_r(state->centronics); |
| 1417 | 1417 | |
| r8714 | r8715 | |
| 1435 | 1435 | |
| 1436 | 1436 | static WRITE_LINE_DEVICE_HANDLER( mfp_so_w ) |
| 1437 | 1437 | { |
| 1438 | atarist_state *driver_state = | |
| 1438 | atarist_state *driver_state = | |
| 1439 | 1439 | |
| 1440 | 1440 | rs232_td_w(driver_state->rs232, device, state); |
| 1441 | 1441 | } |
| r8714 | r8715 | |
| 1500 | 1500 | |
| 1501 | 1501 | static void atarist_state_save(running_machine *machine) |
| 1502 | 1502 | { |
| 1503 | atarist_state *state = | |
| 1503 | atarist_state *state = | |
| 1504 | 1504 | |
| 1505 | 1505 | state->fdc_status |= ATARIST_FLOPPY_STATUS_DMA_ERROR; |
| 1506 | 1506 | |
| r8714 | r8715 | |
| 1526 | 1526 | |
| 1527 | 1527 | static MACHINE_START( atarist ) |
| 1528 | 1528 | { |
| 1529 | atarist_state *state = | |
| 1529 | atarist_state *state = | |
| 1530 | 1530 | |
| 1531 | 1531 | /* configure RAM banking */ |
| 1532 | 1532 | atarist_configure_memory(machine); |
| r8714 | r8715 | |
| 1571 | 1571 | |
| 1572 | 1572 | */ |
| 1573 | 1573 | |
| 1574 | atarist_state *state = | |
| 1574 | atarist_state *state = | |
| 1575 | 1575 | |
| 1576 | 1576 | UINT8 data = centronics_busy_r(state->centronics); |
| 1577 | 1577 | |
| r8714 | r8715 | |
| 1603 | 1603 | |
| 1604 | 1604 | static void atariste_state_save(running_machine *machine) |
| 1605 | 1605 | { |
| 1606 | atarist_state *state = | |
| 1606 | atarist_state *state = | |
| 1607 | 1607 | |
| 1608 | 1608 | atarist_state_save(machine); |
| 1609 | 1609 | |
| r8714 | r8715 | |
| 1624 | 1624 | |
| 1625 | 1625 | static MACHINE_START( atariste ) |
| 1626 | 1626 | { |
| 1627 | atarist_state *state = | |
| 1627 | atarist_state *state = | |
| 1628 | 1628 | |
| 1629 | 1629 | /* configure RAM banking */ |
| 1630 | 1630 | atarist_configure_memory(machine); |
| r8714 | r8715 | |
| 1649 | 1649 | |
| 1650 | 1650 | static MACHINE_START( megaste ) |
| 1651 | 1651 | { |
| 1652 | atarist_state *state = | |
| 1652 | atarist_state *state = | |
| 1653 | 1653 | |
| 1654 | 1654 | MACHINE_START_CALL(atariste); |
| 1655 | 1655 | |
| r8714 | r8715 | |
| 1687 | 1687 | |
| 1688 | 1688 | static WRITE8_DEVICE_HANDLER( stbook_ym2149_port_a_w ) |
| 1689 | 1689 | { |
| 1690 | atarist_state *state = | |
| 1690 | atarist_state *state = | |
| 1691 | 1691 | |
| 1692 | 1692 | wd17xx_set_side(state->wd1772, (data & 0x01) ? 0 : 1); |
| 1693 | 1693 | |
| r8714 | r8715 | |
| 1750 | 1750 | |
| 1751 | 1751 | */ |
| 1752 | 1752 | |
| 1753 | atarist_state *state = | |
| 1753 | atarist_state *state = | |
| 1754 | 1754 | |
| 1755 | 1755 | UINT8 data = centronics_busy_r(state->centronics); |
| 1756 | 1756 | |
| r8714 | r8715 | |
| 1781 | 1781 | |
| 1782 | 1782 | static MACHINE_START( stbook ) |
| 1783 | 1783 | { |
| 1784 | atarist_state *state = | |
| 1784 | atarist_state *state = | |
| 1785 | 1785 | |
| 1786 | 1786 | /* configure RAM banking */ |
| 1787 | 1787 | stbook_configure_memory(machine); |
| r8714 | r8715 | |
|---|---|---|
| 11 | 11 | #include "cpu/m68000/m68000.h" |
| 12 | 12 | #include "machine/68681.h" |
| 13 | 13 | |
| 14 | class cat_state | |
| 14 | class cat_state : public driver_data_t | |
| 15 | 15 | { |
| 16 | 16 | public: |
| 17 | static | |
| 17 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cat_state(machine)); } | |
| 18 | 18 | |
| 19 | cat_state(running_machine &machine) { } | |
| 19 | cat_state(running_machine &machine) | |
| 20 | : driver_data_t(machine) { } | |
| 20 | 21 | |
| 21 | 22 | UINT16 *video_ram; |
| 22 | 23 | |
| r8714 | r8715 | |
| 31 | 32 | |
| 32 | 33 | static WRITE16_HANDLER( cat_video_status_w ) |
| 33 | 34 | { |
| 34 | cat_state *state = | |
| 35 | cat_state *state = | |
| 35 | 36 | |
| 36 | 37 | state->video_enable = BIT( data, 3 ); |
| 37 | 38 | } |
| r8714 | r8715 | |
| 56 | 57 | } |
| 57 | 58 | static WRITE16_HANDLER( cat_printer_w ) |
| 58 | 59 | { |
| 59 | cat_state *state = | |
| 60 | cat_state *state = | |
| 60 | 61 | |
| 61 | 62 | state->pr_cont = data; |
| 62 | 63 | } |
| r8714 | r8715 | |
| 70 | 71 | |
| 71 | 72 | static READ16_HANDLER( cat_keyboard_r ) |
| 72 | 73 | { |
| 73 | cat_state *state = | |
| 74 | cat_state *state = | |
| 74 | 75 | UINT16 retVal = 0; |
| 75 | 76 | // Read country code |
| 76 | 77 | if (state->pr_cont == 0x0900) |
| r8714 | r8715 | |
| 97 | 98 | } |
| 98 | 99 | static WRITE16_HANDLER( cat_keyboard_w ) |
| 99 | 100 | { |
| 100 | cat_state *state = | |
| 101 | cat_state *state = | |
| 101 | 102 | |
| 102 | 103 | state->keyboard_line = data >> 8; |
| 103 | 104 | } |
| r8714 | r8715 | |
| 269 | 270 | |
| 270 | 271 | static MACHINE_START(cat) |
| 271 | 272 | { |
| 272 | cat_state *state = | |
| 273 | cat_state *state = | |
| 273 | 274 | |
| 274 | 275 | state->duart_inp = 0x0e; |
| 275 | 276 | state->keyboard_timer = timer_alloc(machine, keyboard_callback, NULL); |
| r8714 | r8715 | |
| 277 | 278 | |
| 278 | 279 | static MACHINE_RESET(cat) |
| 279 | 280 | { |
| 280 | cat_state *state = | |
| 281 | cat_state *state = | |
| 281 | 282 | cpu_set_irq_callback(machine->device("maincpu"), cat_int_ack); |
| 282 | 283 | timer_adjust_periodic(state->keyboard_timer, attotime_zero, 0, ATTOTIME_IN_HZ(120)); |
| 283 | 284 | } |
| r8714 | r8715 | |
| 288 | 289 | |
| 289 | 290 | static VIDEO_UPDATE( cat ) |
| 290 | 291 | { |
| 291 | cat_state *state = | |
| 292 | cat_state *state = | |
| 292 | 293 | UINT16 code; |
| 293 | 294 | int y, x, b; |
| 294 | 295 | |
| r8714 | r8715 | |
| 334 | 335 | |
| 335 | 336 | static VIDEO_UPDATE( swyft ) |
| 336 | 337 | { |
| 337 | cat_state *state = | |
| 338 | cat_state *state = | |
| 338 | 339 | UINT16 code; |
| 339 | 340 | int y, x, b; |
| 340 | 341 | |
| r8714 | r8715 | |
| 365 | 366 | |
| 366 | 367 | static UINT8 duart_input(running_device *device) |
| 367 | 368 | { |
| 368 | cat_state *state = | |
| 369 | cat_state *state = | |
| 369 | 370 | |
| 370 | 371 | if (state->duart_inp != 0) |
| 371 | 372 | { |
| r8714 | r8715 | |
| 389 | 390 | |
| 390 | 391 | static NVRAM_HANDLER( cat ) |
| 391 | 392 | { |
| 392 | cat_state *state = | |
| 393 | cat_state *state = | |
| 393 | 394 | |
| 394 | 395 | if (read_or_write) |
| 395 | 396 | { |
| r8714 | r8715 | |
|---|---|---|
| 107 | 107 | |
| 108 | 108 | static WRITE8_HANDLER( tvdraw_axis_w ) |
| 109 | 109 | { |
| 110 | sg1000_state *state = | |
| 110 | sg1000_state *state = | |
| 111 | 111 | |
| 112 | 112 | if (data & 0x01) |
| 113 | 113 | { |
| r8714 | r8715 | |
| 137 | 137 | |
| 138 | 138 | static READ8_HANDLER( tvdraw_data_r ) |
| 139 | 139 | { |
| 140 | sg1000_state *state = | |
| 140 | sg1000_state *state = | |
| 141 | 141 | |
| 142 | 142 | return state->tvdraw_data; |
| 143 | 143 | } |
| r8714 | r8715 | |
| 574 | 574 | PA7 Keyboard input |
| 575 | 575 | */ |
| 576 | 576 | |
| 577 | sg1000_state *state = | |
| 577 | sg1000_state *state = | |
| 578 | 578 | |
| 579 | 579 | static const char *const keynames[] = { "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7" }; |
| 580 | 580 | |
| r8714 | r8715 | |
| 596 | 596 | PB7 Cassette tape input |
| 597 | 597 | */ |
| 598 | 598 | |
| 599 | sg1000_state *state = | |
| 599 | sg1000_state *state = | |
| 600 | 600 | |
| 601 | 601 | static const char *const keynames[] = { "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7" }; |
| 602 | 602 | |
| r8714 | r8715 | |
| 630 | 630 | PC7 /FEED to printer |
| 631 | 631 | */ |
| 632 | 632 | |
| 633 | sg1000_state *state = | |
| 633 | sg1000_state *state = | |
| 634 | 634 | |
| 635 | 635 | /* keyboard */ |
| 636 | 636 | state->keylatch = data & 0x07; |
| r8714 | r8715 | |
| 682 | 682 | PA7 |
| 683 | 683 | */ |
| 684 | 684 | |
| 685 | sg1000_state *state = | |
| 685 | sg1000_state *state = | |
| 686 | 686 | UINT8 result = 0; |
| 687 | 687 | |
| 688 | 688 | result |= state->fdc_irq; |
| r8714 | r8715 | |
| 707 | 707 | PC7 /STROBE to Centronics printer |
| 708 | 708 | */ |
| 709 | 709 | |
| 710 | sg1000_state *state = | |
| 710 | sg1000_state *state = | |
| 711 | 711 | |
| 712 | 712 | /* floppy motor */ |
| 713 | 713 | floppy_mon_w(floppy_get_device(device->machine, 0), BIT(data, 1)); |
| r8714 | r8715 | |
| 745 | 745 | |
| 746 | 746 | static WRITE_LINE_DEVICE_HANDLER( sf7000_fdc_interrupt ) |
| 747 | 747 | { |
| 748 | sg1000_state *driver_state = | |
| 748 | sg1000_state *driver_state = | |
| 749 | 749 | |
| 750 | 750 | driver_state->fdc_irq = state; |
| 751 | 751 | } |
| r8714 | r8715 | |
| 975 | 975 | |
| 976 | 976 | static MACHINE_START( sg1000 ) |
| 977 | 977 | { |
| 978 | sg1000_state *state = | |
| 978 | sg1000_state *state = | |
| 979 | 979 | |
| 980 | 980 | /* configure VDP */ |
| 981 | 981 | TMS9928A_configure(&tms9928a_interface); |
| r8714 | r8715 | |
| 993 | 993 | |
| 994 | 994 | static MACHINE_START( sc3000 ) |
| 995 | 995 | { |
| 996 | sg1000_state *state = | |
| 996 | sg1000_state *state = | |
| 997 | 997 | |
| 998 | 998 | /* find devices */ |
| 999 | 999 | state->cassette = machine->device(CASSETTE_TAG); |
| r8714 | r8715 | |
| 1015 | 1015 | |
| 1016 | 1016 | static void sf7000_fdc_index_callback(running_device *controller, running_device *img, int state) |
| 1017 | 1017 | { |
| 1018 | sg1000_state *driver_state = | |
| 1018 | sg1000_state *driver_state = | |
| 1019 | 1019 | |
| 1020 | 1020 | driver_state->fdc_index = state; |
| 1021 | 1021 | } |
| r8714 | r8715 | |
| 1026 | 1026 | |
| 1027 | 1027 | static MACHINE_START( sf7000 ) |
| 1028 | 1028 | { |
| 1029 | sg1000_state *state = | |
| 1029 | sg1000_state *state = | |
| 1030 | 1030 | |
| 1031 | 1031 | /* find devices */ |
| 1032 | 1032 | state->upd765 = machine->device(UPD765_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 39 | 39 | |
| 40 | 40 | static WRITE8_HANDLER( eti660_colorram_w ) |
| 41 | 41 | { |
| 42 | eti660_state *state = | |
| 42 | eti660_state *state = | |
| 43 | 43 | int colorram_offset = RX(space->machine) & 0xff; |
| 44 | 44 | |
| 45 | 45 | colorram_offset = ((colorram_offset & 0xf8) >> 1) || (colorram_offset & 0x03); |
| r8714 | r8715 | |
| 65 | 65 | |
| 66 | 66 | static INPUT_CHANGED( trigger_reset ) |
| 67 | 67 | { |
| 68 | eti660_state *state = | |
| 68 | eti660_state *state = | |
| 69 | 69 | |
| 70 | 70 | state->cdp1802_mode = newval ? CDP1802_MODE_RUN : CDP1802_MODE_RESET; |
| 71 | 71 | } |
| r8714 | r8715 | |
| 104 | 104 | |
| 105 | 105 | static WRITE_LINE_DEVICE_HANDLER( eti660_efx_w ) |
| 106 | 106 | { |
| 107 | eti660_state *driver_state = | |
| 107 | eti660_state *driver_state = | |
| 108 | 108 | |
| 109 | 109 | driver_state->cdp1864_efx = state; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | static READ_LINE_DEVICE_HANDLER( rdata_r ) |
| 113 | 113 | { |
| 114 | eti660_state *state = | |
| 114 | eti660_state *state = | |
| 115 | 115 | |
| 116 | 116 | return BIT(state->color, 0); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | static READ_LINE_DEVICE_HANDLER( bdata_r ) |
| 120 | 120 | { |
| 121 | eti660_state *state = | |
| 121 | eti660_state *state = | |
| 122 | 122 | |
| 123 | 123 | return BIT(state->color, 1); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | static READ_LINE_DEVICE_HANDLER( gdata_r ) |
| 127 | 127 | { |
| 128 | eti660_state *state = | |
| 128 | eti660_state *state = | |
| 129 | 129 | |
| 130 | 130 | return BIT(state->color, 2); |
| 131 | 131 | } |
| r8714 | r8715 | |
| 149 | 149 | |
| 150 | 150 | static VIDEO_UPDATE( eti660 ) |
| 151 | 151 | { |
| 152 | eti660_state *state = | |
| 152 | eti660_state *state = | |
| 153 | 153 | |
| 154 | 154 | cdp1864_update(state->cdp1864, bitmap, cliprect); |
| 155 | 155 | |
| r8714 | r8715 | |
| 160 | 160 | |
| 161 | 161 | static CDP1802_MODE_READ( eti660_mode_r ) |
| 162 | 162 | { |
| 163 | eti660_state *state = | |
| 163 | eti660_state *state = | |
| 164 | 164 | |
| 165 | 165 | return state->cdp1802_mode; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | static CDP1802_EF_READ( eti660_ef_r ) |
| 169 | 169 | { |
| 170 | eti660_state *state = | |
| 170 | eti660_state *state = | |
| 171 | 171 | |
| 172 | 172 | int ef = 0x0f; |
| 173 | 173 | |
| r8714 | r8715 | |
| 185 | 185 | |
| 186 | 186 | static WRITE_LINE_DEVICE_HANDLER( eti660_q_w ) |
| 187 | 187 | { |
| 188 | eti660_state *driver_state = | |
| 188 | eti660_state *driver_state = | |
| 189 | 189 | |
| 190 | 190 | /* CDP1864 audio output enable */ |
| 191 | 191 | cdp1864_aoe_w(driver_state->cdp1864, state); |
| r8714 | r8715 | |
| 199 | 199 | |
| 200 | 200 | static WRITE8_DEVICE_HANDLER( eti660_dma_w ) |
| 201 | 201 | { |
| 202 | eti660_state *state = | |
| 202 | eti660_state *state = | |
| 203 | 203 | UINT8 colorram_offset = ((offset & 0xf8) >> 1) || (offset & 0x03); |
| 204 | 204 | |
| 205 | 205 | state->color = state->color_ram[colorram_offset]; |
| r8714 | r8715 | |
| 237 | 237 | |
| 238 | 238 | */ |
| 239 | 239 | |
| 240 | eti660_state *state = | |
| 240 | eti660_state *state = | |
| 241 | 241 | UINT8 data = 0xf0; |
| 242 | 242 | |
| 243 | 243 | if (!BIT(state->keylatch, 0)) data &= input_port_read(device->machine, "PA0"); |
| r8714 | r8715 | |
| 265 | 265 | |
| 266 | 266 | */ |
| 267 | 267 | |
| 268 | eti660_state *state = | |
| 268 | eti660_state *state = | |
| 269 | 269 | |
| 270 | 270 | state->keylatch = data & 0x0f; |
| 271 | 271 | } |
| r8714 | r8715 | |
| 290 | 290 | |
| 291 | 291 | static TIMER_CALLBACK( set_cpu_mode ) |
| 292 | 292 | { |
| 293 | eti660_state *state = | |
| 293 | eti660_state *state = | |
| 294 | 294 | |
| 295 | 295 | state->cdp1802_mode = CDP1802_MODE_RUN; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | static MACHINE_START( eti660 ) |
| 299 | 299 | { |
| 300 | eti660_state *state = | |
| 300 | eti660_state *state = | |
| 301 | 301 | |
| 302 | 302 | /* find devices */ |
| 303 | 303 | state->cdp1864 = machine->device(CDP1864_TAG); |
| r8714 | r8715 | |
| 310 | 310 | |
| 311 | 311 | static MACHINE_RESET( eti660 ) |
| 312 | 312 | { |
| 313 | eti660_state *state = | |
| 313 | eti660_state *state = | |
| 314 | 314 | |
| 315 | 315 | /* reset CPU */ |
| 316 | 316 | state->cdp1802_mode = CDP1802_MODE_RESET; |
| r8714 | r8715 | |
|---|---|---|
| 85 | 85 | |
| 86 | 86 | static void bankswitch(running_machine *machine) |
| 87 | 87 | { |
| 88 | px8_state *state = | |
| 88 | px8_state *state = | |
| 89 | 89 | const address_space *program = cputag_get_address_space(machine, UPD70008_TAG, ADDRESS_SPACE_PROGRAM); |
| 90 | 90 | UINT8 *ram = messram_get_ptr(machine->device("messram")); |
| 91 | 91 | UINT8 *ipl_rom = memory_region(machine, UPD70008_TAG); |
| r8714 | r8715 | |
| 275 | 275 | |
| 276 | 276 | static WRITE8_HANDLER( gah40m_w ) |
| 277 | 277 | { |
| 278 | px8_state *state = | |
| 278 | px8_state *state = | |
| 279 | 279 | |
| 280 | 280 | switch (offset) |
| 281 | 281 | { |
| r8714 | r8715 | |
| 383 | 383 | |
| 384 | 384 | static READ8_HANDLER( gah40s_r ) |
| 385 | 385 | { |
| 386 | px8_state *state = | |
| 386 | px8_state *state = | |
| 387 | 387 | UINT8 data = 0xff; |
| 388 | 388 | |
| 389 | 389 | switch (offset) |
| r8714 | r8715 | |
| 410 | 410 | |
| 411 | 411 | static WRITE8_HANDLER( gah40s_w ) |
| 412 | 412 | { |
| 413 | px8_state *state = | |
| 413 | px8_state *state = | |
| 414 | 414 | |
| 415 | 415 | switch (offset) |
| 416 | 416 | { |
| r8714 | r8715 | |
| 455 | 455 | |
| 456 | 456 | static WRITE8_HANDLER( gah40s_ier_w ) |
| 457 | 457 | { |
| 458 | px8_state *state = | |
| 458 | px8_state *state = | |
| 459 | 459 | |
| 460 | 460 | state->ier = data; |
| 461 | 461 | } |
| r8714 | r8715 | |
| 466 | 466 | // |
| 467 | 467 | //static UINT8 krtn_read(running_machine *machine) |
| 468 | 468 | //{ |
| 469 | // px8_state *state = | |
| 469 | // px8_state *state = | |
| 470 | 470 | // UINT8 data = 0xff; |
| 471 | 471 | // |
| 472 | 472 | // switch (state->ksc) |
| r8714 | r8715 | |
| 510 | 510 | // |
| 511 | 511 | //static WRITE8_HANDLER( ksc_w ) |
| 512 | 512 | //{ |
| 513 | // px8_state *state = | |
| 513 | // px8_state *state = | |
| 514 | 514 | // |
| 515 | 515 | // state->ksc = data; |
| 516 | 516 | //} |
| r8714 | r8715 | |
| 709 | 709 | |
| 710 | 710 | static READ8_DEVICE_HANDLER( vd_r ) |
| 711 | 711 | { |
| 712 | px8_state *state = | |
| 712 | px8_state *state = | |
| 713 | 713 | |
| 714 | 714 | return state->video_ram[offset & PX8_VIDEORAM_MASK]; |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | static WRITE8_DEVICE_HANDLER( vd_w ) |
| 718 | 718 | { |
| 719 | px8_state *state = | |
| 719 | px8_state *state = | |
| 720 | 720 | |
| 721 | 721 | state->video_ram[offset & PX8_VIDEORAM_MASK] = data; |
| 722 | 722 | } |
| r8714 | r8715 | |
| 752 | 752 | |
| 753 | 753 | static VIDEO_UPDATE( px8 ) |
| 754 | 754 | { |
| 755 | px8_state *state = | |
| 755 | px8_state *state = | |
| 756 | 756 | |
| 757 | 757 | sed1330_update(state->sed1320, bitmap, cliprect); |
| 758 | 758 | |
| r8714 | r8715 | |
| 821 | 821 | |
| 822 | 822 | static MACHINE_START( px8 ) |
| 823 | 823 | { |
| 824 | px8_state *state = | |
| 824 | px8_state *state = | |
| 825 | 825 | |
| 826 | 826 | /* find devices */ |
| 827 | 827 | state->sed1320 = machine->device(SED1320_TAG); |
| r8714 | r8715 | |
| 838 | 838 | |
| 839 | 839 | static MACHINE_RESET( px8 ) |
| 840 | 840 | { |
| 841 | px8_state *state = | |
| 841 | px8_state *state = | |
| 842 | 842 | |
| 843 | 843 | state->bank0 = 0; |
| 844 | 844 | state->bk2 = 1; |
| r8714 | r8715 | |
|---|---|---|
| 57 | 57 | |
| 58 | 58 | */ |
| 59 | 59 | |
| 60 | phc25_state *state = | |
| 60 | phc25_state *state = | |
| 61 | 61 | |
| 62 | 62 | UINT8 data = 0; |
| 63 | 63 | |
| r8714 | r8715 | |
| 93 | 93 | |
| 94 | 94 | */ |
| 95 | 95 | |
| 96 | phc25_state *state = | |
| 96 | phc25_state *state = | |
| 97 | 97 | |
| 98 | 98 | /* cassette output */ |
| 99 | 99 | cassette_output(state->cassette, BIT(data, 0) ? -1.0 : +1.0); |
| r8714 | r8715 | |
| 260 | 260 | |
| 261 | 261 | static READ8_DEVICE_HANDLER( phc25_video_ram_r ) |
| 262 | 262 | { |
| 263 | phc25_state *state = | |
| 263 | phc25_state *state = | |
| 264 | 264 | |
| 265 | 265 | return state->video_ram[offset & 0x17ff]; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | static UINT8 phc25_char_rom_r(running_machine *machine, UINT8 ch, int line) |
| 269 | 269 | { |
| 270 | phc25_state *state = | |
| 270 | phc25_state *state = | |
| 271 | 271 | |
| 272 | 272 | return state->char_rom[((ch - state->char_substact) * state->char_size) + line + state->char_correct]; |
| 273 | 273 | } |
| r8714 | r8715 | |
| 290 | 290 | |
| 291 | 291 | static VIDEO_START( pal ) |
| 292 | 292 | { |
| 293 | phc25_state *state = | |
| 293 | phc25_state *state = | |
| 294 | 294 | |
| 295 | 295 | /* find memory regions */ |
| 296 | 296 | state->char_rom = memory_region(machine, Z80_TAG) + 0x5000; |
| r8714 | r8715 | |
| 301 | 301 | |
| 302 | 302 | static VIDEO_START( ntsc ) |
| 303 | 303 | { |
| 304 | phc25_state *state = | |
| 304 | phc25_state *state = | |
| 305 | 305 | |
| 306 | 306 | /* find memory regions */ |
| 307 | 307 | state->char_rom = memory_region(machine, Z80_TAG) + 0x5000; |
| r8714 | r8715 | |
| 312 | 312 | |
| 313 | 313 | static VIDEO_UPDATE( phc25 ) |
| 314 | 314 | { |
| 315 | phc25_state *state = | |
| 315 | phc25_state *state = | |
| 316 | 316 | |
| 317 | 317 | return mc6847_update(state->mc6847, bitmap, cliprect); |
| 318 | 318 | } |
| r8714 | r8715 | |
| 343 | 343 | |
| 344 | 344 | static MACHINE_START( phc25 ) |
| 345 | 345 | { |
| 346 | phc25_state *state = | |
| 346 | phc25_state *state = | |
| 347 | 347 | |
| 348 | 348 | /* find devices */ |
| 349 | 349 | state->mc6847 = machine->device(MC6847_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 69 | 69 | |
| 70 | 70 | static WRITE8_HANDLER( ls259_w ) |
| 71 | 71 | { |
| 72 | mm1_state *state = | |
| 72 | mm1_state *state = | |
| 73 | 73 | const address_space *program = cputag_get_address_space(space->machine, I8085A_TAG, ADDRESS_SPACE_PROGRAM); |
| 74 | 74 | int d = BIT(data, 0); |
| 75 | 75 | |
| r8714 | r8715 | |
| 279 | 279 | |
| 280 | 280 | static I8275_DISPLAY_PIXELS( crtc_display_pixels ) |
| 281 | 281 | { |
| 282 | mm1_state *state = | |
| 282 | mm1_state *state = | |
| 283 | 283 | |
| 284 | 284 | UINT8 romdata = state->char_rom[(charcode << 4) | linecount]; |
| 285 | 285 | |
| r8714 | r8715 | |
| 336 | 336 | |
| 337 | 337 | static VIDEO_START( mm1 ) |
| 338 | 338 | { |
| 339 | mm1_state *state = | |
| 339 | mm1_state *state = | |
| 340 | 340 | |
| 341 | 341 | /* find memory regions */ |
| 342 | 342 | state->char_rom = memory_region(machine, "chargen"); |
| r8714 | r8715 | |
| 346 | 346 | |
| 347 | 347 | static VIDEO_UPDATE( mm1 ) |
| 348 | 348 | { |
| 349 | mm1_state *state = | |
| 349 | mm1_state *state = | |
| 350 | 350 | |
| 351 | 351 | /* text */ |
| 352 | 352 | i8275_update(state->i8275, bitmap, cliprect); |
| r8714 | r8715 | |
| 378 | 378 | |
| 379 | 379 | static READ8_DEVICE_HANDLER( kb_r ) |
| 380 | 380 | { |
| 381 | mm1_state *state = | |
| 381 | mm1_state *state = | |
| 382 | 382 | |
| 383 | 383 | return state->keydata; |
| 384 | 384 | } |
| r8714 | r8715 | |
| 402 | 402 | |
| 403 | 403 | static READ8_DEVICE_HANDLER( mpsc_dack_r ) |
| 404 | 404 | { |
| 405 | mm1_state *state = | |
| 405 | mm1_state *state = | |
| 406 | 406 | |
| 407 | 407 | /* clear data request */ |
| 408 | 408 | i8237_dreq2_w(state->i8237, CLEAR_LINE); |
| r8714 | r8715 | |
| 412 | 412 | |
| 413 | 413 | static WRITE8_DEVICE_HANDLER( mpsc_dack_w ) |
| 414 | 414 | { |
| 415 | mm1_state *state = | |
| 415 | mm1_state *state = | |
| 416 | 416 | |
| 417 | 417 | upd7201_hai_w(device, data); |
| 418 | 418 | |
| r8714 | r8715 | |
| 422 | 422 | |
| 423 | 423 | static WRITE_LINE_DEVICE_HANDLER( tc_w ) |
| 424 | 424 | { |
| 425 | mm1_state *driver_state = | |
| 425 | mm1_state *driver_state = | |
| 426 | 426 | |
| 427 | 427 | if (!driver_state->dack3) |
| 428 | 428 | { |
| r8714 | r8715 | |
| 437 | 437 | |
| 438 | 438 | static WRITE_LINE_DEVICE_HANDLER( dack3_w ) |
| 439 | 439 | { |
| 440 | mm1_state *driver_state = | |
| 440 | mm1_state *driver_state = | |
| 441 | 441 | |
| 442 | 442 | driver_state->dack3 = state; |
| 443 | 443 | |
| r8714 | r8715 | |
| 463 | 463 | |
| 464 | 464 | static UPD765_DMA_REQUEST( drq_w ) |
| 465 | 465 | { |
| 466 | mm1_state *driver_state = | |
| 466 | mm1_state *driver_state = | |
| 467 | 467 | |
| 468 | 468 | i8237_dreq3_w(driver_state->i8237, state); |
| 469 | 469 | } |
| r8714 | r8715 | |
| 481 | 481 | |
| 482 | 482 | static WRITE_LINE_DEVICE_HANDLER( itxc_w ) |
| 483 | 483 | { |
| 484 | mm1_state *driver_state = | |
| 484 | mm1_state *driver_state = | |
| 485 | 485 | |
| 486 | 486 | if (!driver_state->intc) |
| 487 | 487 | { |
| r8714 | r8715 | |
| 491 | 491 | |
| 492 | 492 | static WRITE_LINE_DEVICE_HANDLER( irxc_w ) |
| 493 | 493 | { |
| 494 | mm1_state *driver_state = | |
| 494 | mm1_state *driver_state = | |
| 495 | 495 | |
| 496 | 496 | if (!driver_state->intc) |
| 497 | 497 | { |
| r8714 | r8715 | |
| 501 | 501 | |
| 502 | 502 | static WRITE_LINE_DEVICE_HANDLER( auxc_w ) |
| 503 | 503 | { |
| 504 | mm1_state *driver_state = | |
| 504 | mm1_state *driver_state = | |
| 505 | 505 | |
| 506 | 506 | upd7201_txcb_w(driver_state->upd7201, state); |
| 507 | 507 | upd7201_rxcb_w(driver_state->upd7201, state); |
| r8714 | r8715 | |
| 530 | 530 | |
| 531 | 531 | static WRITE_LINE_DEVICE_HANDLER( drq2_w ) |
| 532 | 532 | { |
| 533 | mm1_state *driver_state = | |
| 533 | mm1_state *driver_state = | |
| 534 | 534 | |
| 535 | 535 | if (state) i8237_dreq2_w(driver_state->i8237, ASSERT_LINE); |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | static WRITE_LINE_DEVICE_HANDLER( drq1_w ) |
| 539 | 539 | { |
| 540 | mm1_state *driver_state = | |
| 540 | mm1_state *driver_state = | |
| 541 | 541 | |
| 542 | 542 | if (state) i8237_dreq1_w(driver_state->i8237, ASSERT_LINE); |
| 543 | 543 | } |
| r8714 | r8715 | |
| 595 | 595 | |
| 596 | 596 | static TIMER_DEVICE_CALLBACK( kbclk_tick ) |
| 597 | 597 | { |
| 598 | mm1_state *state = | |
| 598 | mm1_state *state = | |
| 599 | 599 | static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8", "ROW9" }; |
| 600 | 600 | |
| 601 | 601 | UINT8 data = input_port_read(timer.machine, keynames[state->drive]); |
| r8714 | r8715 | |
| 684 | 684 | |
| 685 | 685 | static MACHINE_START( mm1 ) |
| 686 | 686 | { |
| 687 | mm1_state *state = | |
| 687 | mm1_state *state = | |
| 688 | 688 | const address_space *program = cputag_get_address_space(machine, I8085A_TAG, ADDRESS_SPACE_PROGRAM); |
| 689 | 689 | |
| 690 | 690 | /* look up devices */ |
| r8714 | r8715 | |
| 720 | 720 | |
| 721 | 721 | static MACHINE_RESET( mm1 ) |
| 722 | 722 | { |
| 723 | mm1_state *state = | |
| 723 | mm1_state *state = | |
| 724 | 724 | const address_space *program = cputag_get_address_space(machine, I8085A_TAG, ADDRESS_SPACE_PROGRAM); |
| 725 | 725 | int i; |
| 726 | 726 |
| r8714 | r8715 | |
|---|---|---|
| 171 | 171 | |
| 172 | 172 | static WRITE8_HANDLER(spectrum_128_port_7ffd_w) |
| 173 | 173 | { |
| 174 | spectrum_state *state = | |
| 174 | spectrum_state *state = | |
| 175 | 175 | |
| 176 | 176 | /* D0-D2: RAM page located at 0x0c000-0x0ffff */ |
| 177 | 177 | /* D3 - Screen select (screen 0 in ram page 5, screen 1 in ram page 7 */ |
| r8714 | r8715 | |
| 191 | 191 | |
| 192 | 192 | void spectrum_128_update_memory(running_machine *machine) |
| 193 | 193 | { |
| 194 | spectrum_state *state = | |
| 194 | spectrum_state *state = | |
| 195 | 195 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 196 | 196 | unsigned char *ChosenROM; |
| 197 | 197 | int ROMSelection; |
| r8714 | r8715 | |
| 228 | 228 | |
| 229 | 229 | static READ8_HANDLER ( spectrum_128_ula_r ) |
| 230 | 230 | { |
| 231 | spectrum_state *state = | |
| 231 | spectrum_state *state = | |
| 232 | 232 | int vpos = space->machine->primary_screen->vpos(); |
| 233 | 233 | |
| 234 | 234 | return vpos<193 ? state->screen_location[0x1800|(vpos&0xf8)<<2]:0xff; |
| r8714 | r8715 | |
| 254 | 254 | |
| 255 | 255 | static MACHINE_RESET( spectrum_128 ) |
| 256 | 256 | { |
| 257 | spectrum_state *state = | |
| 257 | spectrum_state *state = | |
| 258 | 258 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 259 | 259 | |
| 260 | 260 | memset(messram,0,128*1024); |
| r8714 | r8715 | |
|---|---|---|
| 432 | 432 | |
| 433 | 433 | static VIDEO_UPDATE( c16 ) |
| 434 | 434 | { |
| 435 | c16_state *state = | |
| 435 | c16_state *state = | |
| 436 | 436 | ted7360_video_update(state->ted7360, bitmap, cliprect); |
| 437 | 437 | return 0; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | static INTERRUPT_GEN( c16_raster_interrupt ) |
| 441 | 441 | { |
| 442 | c16_state *state = | |
| 442 | c16_state *state = | |
| 443 | 443 | ted7360_raster_interrupt_gen(state->ted7360); |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | |
| 447 | 447 | static MACHINE_START( c16 ) |
| 448 | 448 | { |
| 449 | c16_state *state = | |
| 449 | c16_state *state = | |
| 450 | 450 | |
| 451 | 451 | state->maincpu = machine->device<legacy_cpu_device>("maincpu"); |
| 452 | 452 | state->ted7360 = machine->device("ted7360"); |
| r8714 | r8715 | |
|---|---|---|
| 207 | 207 | |
| 208 | 208 | static WRITE8_HANDLER( keylatch_w ) |
| 209 | 209 | { |
| 210 | studio2_state *state = | |
| 210 | studio2_state *state = | |
| 211 | 211 | |
| 212 | 212 | state->keylatch = data & 0x0f; |
| 213 | 213 | } |
| r8714 | r8715 | |
| 297 | 297 | |
| 298 | 298 | static WRITE_LINE_DEVICE_HANDLER( studio2_efx_w ) |
| 299 | 299 | { |
| 300 | studio2_state *driver_state = | |
| 300 | studio2_state *driver_state = | |
| 301 | 301 | |
| 302 | 302 | driver_state->cdp1861_efx = state; |
| 303 | 303 | } |
| r8714 | r8715 | |
| 313 | 313 | |
| 314 | 314 | static VIDEO_UPDATE( studio2 ) |
| 315 | 315 | { |
| 316 | studio2_state *state = | |
| 316 | studio2_state *state = | |
| 317 | 317 | |
| 318 | 318 | cdp1861_update(state->cdp1861, bitmap, cliprect); |
| 319 | 319 | |
| r8714 | r8715 | |
| 330 | 330 | |
| 331 | 331 | static WRITE_LINE_DEVICE_HANDLER( mpt02_efx_w ) |
| 332 | 332 | { |
| 333 | studio2_state *driver_state = | |
| 333 | studio2_state *driver_state = | |
| 334 | 334 | |
| 335 | 335 | driver_state->cdp1864_efx = state; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | static READ_LINE_DEVICE_HANDLER( rdata_r ) |
| 339 | 339 | { |
| 340 | studio2_state *state = | |
| 340 | studio2_state *state = | |
| 341 | 341 | |
| 342 | 342 | return BIT(state->color, 0); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | static READ_LINE_DEVICE_HANDLER( bdata_r ) |
| 346 | 346 | { |
| 347 | studio2_state *state = | |
| 347 | studio2_state *state = | |
| 348 | 348 | |
| 349 | 349 | return BIT(state->color, 1); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | static READ_LINE_DEVICE_HANDLER( gdata_r ) |
| 353 | 353 | { |
| 354 | studio2_state *state = | |
| 354 | studio2_state *state = | |
| 355 | 355 | |
| 356 | 356 | return BIT(state->color, 2); |
| 357 | 357 | } |
| r8714 | r8715 | |
| 375 | 375 | |
| 376 | 376 | static VIDEO_UPDATE( mpt02 ) |
| 377 | 377 | { |
| 378 | studio2_state *state = | |
| 378 | studio2_state *state = | |
| 379 | 379 | |
| 380 | 380 | cdp1864_update(state->cdp1864, bitmap, cliprect); |
| 381 | 381 | |
| r8714 | r8715 | |
| 386 | 386 | |
| 387 | 387 | static CDP1802_MODE_READ( studio2_mode_r ) |
| 388 | 388 | { |
| 389 | studio2_state *state = | |
| 389 | studio2_state *state = | |
| 390 | 390 | |
| 391 | 391 | return state->cdp1802_mode; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | static CDP1802_EF_READ( studio2_ef_r ) |
| 395 | 395 | { |
| 396 | studio2_state *state = | |
| 396 | studio2_state *state = | |
| 397 | 397 | |
| 398 | 398 | int ef = 0x0f; |
| 399 | 399 | |
| r8714 | r8715 | |
| 423 | 423 | |
| 424 | 424 | static CDP1802_EF_READ( mpt02_ef_r ) |
| 425 | 425 | { |
| 426 | studio2_state *state = | |
| 426 | studio2_state *state = | |
| 427 | 427 | |
| 428 | 428 | int ef = 0x0f; |
| 429 | 429 | |
| r8714 | r8715 | |
| 437 | 437 | |
| 438 | 438 | static WRITE8_DEVICE_HANDLER( mpt02_dma_w ) |
| 439 | 439 | { |
| 440 | studio2_state *state = | |
| 440 | studio2_state *state = | |
| 441 | 441 | UINT8 addr = ((offset & 0xe0) >> 2) | (offset & 0x07); |
| 442 | 442 | |
| 443 | 443 | state->color = state->color_ram[addr]; |
| r8714 | r8715 | |
| 460 | 460 | |
| 461 | 461 | static TIMER_CALLBACK( set_cpu_mode ) |
| 462 | 462 | { |
| 463 | studio2_state *state = | |
| 463 | studio2_state *state = | |
| 464 | 464 | |
| 465 | 465 | state->cdp1802_mode = CDP1802_MODE_RUN; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | static MACHINE_START( studio2 ) |
| 469 | 469 | { |
| 470 | studio2_state *state = | |
| 470 | studio2_state *state = | |
| 471 | 471 | |
| 472 | 472 | /* find devices */ |
| 473 | 473 | state->cdp1861 = machine->device(CDP1861_TAG); |
| r8714 | r8715 | |
| 480 | 480 | |
| 481 | 481 | static MACHINE_RESET( studio2 ) |
| 482 | 482 | { |
| 483 | studio2_state *state = | |
| 483 | studio2_state *state = | |
| 484 | 484 | |
| 485 | 485 | /* reset CPU */ |
| 486 | 486 | state->cdp1802_mode = CDP1802_MODE_RESET; |
| r8714 | r8715 | |
| 492 | 492 | |
| 493 | 493 | static MACHINE_START( mpt02 ) |
| 494 | 494 | { |
| 495 | studio2_state *state = | |
| 495 | studio2_state *state = | |
| 496 | 496 | |
| 497 | 497 | /* find devices */ |
| 498 | 498 | state->cdp1864 = machine->device(CDP1864_TAG); |
| r8714 | r8715 | |
| 505 | 505 | |
| 506 | 506 | static MACHINE_RESET( mpt02 ) |
| 507 | 507 | { |
| 508 | studio2_state *state = | |
| 508 | studio2_state *state = | |
| 509 | 509 | |
| 510 | 510 | /* reset CPU */ |
| 511 | 511 | state->cdp1802_mode = CDP1802_MODE_RESET; |
| r8714 | r8715 | |
|---|---|---|
| 233 | 233 | |
| 234 | 234 | static READ8_HANDLER( osi600_keyboard_r ) |
| 235 | 235 | { |
| 236 | osi_state *state = | |
| 236 | osi_state *state = | |
| 237 | 237 | |
| 238 | 238 | static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7" }; |
| 239 | 239 | |
| r8714 | r8715 | |
| 251 | 251 | static WRITE8_HANDLER( osi600_keyboard_w ) |
| 252 | 252 | { |
| 253 | 253 | running_device *discrete = space->machine->device("discrete"); |
| 254 | osi_state *state = | |
| 254 | osi_state *state = | |
| 255 | 255 | |
| 256 | 256 | state->keylatch = data; |
| 257 | 257 | |
| r8714 | r8715 | |
| 260 | 260 | |
| 261 | 261 | static WRITE8_HANDLER( uk101_keyboard_w ) |
| 262 | 262 | { |
| 263 | osi_state *state = | |
| 263 | osi_state *state = | |
| 264 | 264 | |
| 265 | 265 | state->keylatch = data; |
| 266 | 266 | } |
| r8714 | r8715 | |
| 283 | 283 | */ |
| 284 | 284 | |
| 285 | 285 | running_device *discrete = space->machine->device("discrete"); |
| 286 | osi_state *state = | |
| 286 | osi_state *state = | |
| 287 | 287 | |
| 288 | 288 | state->_32 = BIT(data, 0); |
| 289 | 289 | state->coloren = BIT(data, 1); |
| r8714 | r8715 | |
| 356 | 356 | |
| 357 | 357 | static void osi470_index_callback(running_device *controller, running_device *img, int state) |
| 358 | 358 | { |
| 359 | osi_state *driver_state = | |
| 359 | osi_state *driver_state = | |
| 360 | 360 | |
| 361 | 361 | driver_state->fdc_index = state; |
| 362 | 362 | } |
| r8714 | r8715 | |
| 379 | 379 | |
| 380 | 380 | */ |
| 381 | 381 | |
| 382 | osi_state *state = | |
| 382 | osi_state *state = | |
| 383 | 383 | |
| 384 | 384 | return (state->fdc_index << 7); |
| 385 | 385 | } |
| r8714 | r8715 | |
| 615 | 615 | |
| 616 | 616 | static READ_LINE_DEVICE_HANDLER( cassette_rx ) |
| 617 | 617 | { |
| 618 | osi_state *driver_state = | |
| 618 | osi_state *driver_state = | |
| 619 | 619 | |
| 620 | 620 | return (cassette_input(driver_state->cassette) > 0.0) ? 1 : 0; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | static WRITE_LINE_DEVICE_HANDLER( cassette_tx ) |
| 624 | 624 | { |
| 625 | osi_state *driver_state = | |
| 625 | osi_state *driver_state = | |
| 626 | 626 | |
| 627 | 627 | cassette_output(driver_state->cassette, state ? +1.0 : -1.0); |
| 628 | 628 | } |
| r8714 | r8715 | |
| 665 | 665 | |
| 666 | 666 | static MACHINE_START( osi600 ) |
| 667 | 667 | { |
| 668 | osi_state *state = | |
| 668 | osi_state *state = | |
| 669 | 669 | |
| 670 | 670 | const address_space *program = cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM); |
| 671 | 671 | |
| r8714 | r8715 | |
| 695 | 695 | |
| 696 | 696 | static MACHINE_START( c1p ) |
| 697 | 697 | { |
| 698 | osi_state *state = | |
| 698 | osi_state *state = | |
| 699 | 699 | |
| 700 | 700 | const address_space *program = cputag_get_address_space(machine, M6502_TAG, ADDRESS_SPACE_PROGRAM); |
| 701 | 701 |
| r8714 | r8715 | |
|---|---|---|
| 131 | 131 | |
| 132 | 132 | void v1050_set_int(running_machine *machine, UINT8 mask, int state) |
| 133 | 133 | { |
| 134 | v1050_state *driver_state = | |
| 134 | v1050_state *driver_state = | |
| 135 | 135 | |
| 136 | 136 | if (state) |
| 137 | 137 | { |
| r8714 | r8715 | |
| 147 | 147 | |
| 148 | 148 | static void v1050_bankswitch(running_machine *machine) |
| 149 | 149 | { |
| 150 | v1050_state *state = | |
| 150 | v1050_state *state = | |
| 151 | 151 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 152 | 152 | |
| 153 | 153 | int bank = (state->bank >> 1) & 0x03; |
| r8714 | r8715 | |
| 248 | 248 | |
| 249 | 249 | static void v1050_keyboard_scan(running_machine *machine) |
| 250 | 250 | { |
| 251 | v1050_state *state = | |
| 251 | v1050_state *state = | |
| 252 | 252 | |
| 253 | 253 | static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8", "ROW9", "ROW10", "ROW11" }; |
| 254 | 254 | int table = 0, row, col; |
| r8714 | r8715 | |
| 303 | 303 | |
| 304 | 304 | static READ8_HANDLER( v1050_get_key ) |
| 305 | 305 | { |
| 306 | v1050_state *state = | |
| 306 | v1050_state *state = | |
| 307 | 307 | |
| 308 | 308 | state->keyavail = 0; |
| 309 | 309 | |
| r8714 | r8715 | |
| 314 | 314 | |
| 315 | 315 | static READ8_HANDLER( v1050_get_key_status ) |
| 316 | 316 | { |
| 317 | v1050_state *state = | |
| 317 | v1050_state *state = | |
| 318 | 318 | |
| 319 | 319 | UINT8 val = msm8251_status_r(state->i8251_kb, 0); |
| 320 | 320 | |
| r8714 | r8715 | |
| 325 | 325 | |
| 326 | 326 | static WRITE8_HANDLER( v1050_i8214_w ) |
| 327 | 327 | { |
| 328 | v1050_state *state = | |
| 328 | v1050_state *state = | |
| 329 | 329 | |
| 330 | 330 | i8214_b_w(state->i8214, 0, (data >> 1) & 0x0f); |
| 331 | 331 | } |
| r8714 | r8715 | |
| 356 | 356 | |
| 357 | 357 | static WRITE8_HANDLER( bank_w ) |
| 358 | 358 | { |
| 359 | v1050_state *state = | |
| 359 | v1050_state *state = | |
| 360 | 360 | |
| 361 | 361 | state->bank = data; |
| 362 | 362 | |
| r8714 | r8715 | |
| 379 | 379 | |
| 380 | 380 | /*static READ8_HANDLER( keyboard_r ) |
| 381 | 381 | { |
| 382 | v1050_state *state = | |
| 382 | v1050_state *state = | |
| 383 | 383 | |
| 384 | 384 | static const char *const KEY_ROW[] = { "X0", "X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8", "X9", "XA", "XB" }; |
| 385 | 385 | |
| r8714 | r8715 | |
| 388 | 388 | |
| 389 | 389 | static WRITE8_HANDLER( keyboard_w ) |
| 390 | 390 | { |
| 391 | v1050_state *state = | |
| 391 | v1050_state *state = | |
| 392 | 392 | |
| 393 | 393 | state->keylatch = data & 0x0f; |
| 394 | 394 | } |
| r8714 | r8715 | |
| 410 | 410 | // |
| 411 | 411 | // */ |
| 412 | 412 | // |
| 413 | // v1050_state *state = | |
| 413 | // v1050_state *state = | |
| 414 | 414 | // |
| 415 | 415 | // output_set_led_value(0, BIT(data, 5)); |
| 416 | 416 | //// discrete_sound_w(discrete, NODE_01, BIT(data, 6)); |
| r8714 | r8715 | |
| 744 | 744 | |
| 745 | 745 | static WRITE8_DEVICE_HANDLER( crt_z80_8255_c_w ) |
| 746 | 746 | { |
| 747 | v1050_state *state = | |
| 747 | v1050_state *state = | |
| 748 | 748 | |
| 749 | 749 | i8255a_pc2_w(state->i8255a_crt_m6502, BIT(data, 6)); |
| 750 | 750 | i8255a_pc4_w(state->i8255a_crt_m6502, BIT(data, 7)); |
| r8714 | r8715 | |
| 762 | 762 | |
| 763 | 763 | static WRITE8_DEVICE_HANDLER( crt_m6502_8255_c_w ) |
| 764 | 764 | { |
| 765 | v1050_state *state = | |
| 765 | v1050_state *state = | |
| 766 | 766 | |
| 767 | 767 | i8255a_pc2_w(state->i8255a_crt_z80, BIT(data, 7)); |
| 768 | 768 | i8255a_pc4_w(state->i8255a_crt_z80, BIT(data, 6)); |
| r8714 | r8715 | |
| 797 | 797 | |
| 798 | 798 | */ |
| 799 | 799 | |
| 800 | v1050_state *state = | |
| 800 | v1050_state *state = | |
| 801 | 801 | |
| 802 | 802 | int f_motor_on = !BIT(data, 6); |
| 803 | 803 | |
| r8714 | r8715 | |
| 822 | 822 | |
| 823 | 823 | static WRITE8_DEVICE_HANDLER( misc_8255_b_w ) |
| 824 | 824 | { |
| 825 | v1050_state *state = | |
| 825 | v1050_state *state = | |
| 826 | 826 | |
| 827 | 827 | centronics_data_w(state->centronics, 0, ~data & 0xff); |
| 828 | 828 | } |
| r8714 | r8715 | |
| 844 | 844 | |
| 845 | 845 | */ |
| 846 | 846 | |
| 847 | v1050_state *state = | |
| 847 | v1050_state *state = | |
| 848 | 848 | |
| 849 | 849 | UINT8 data = 0; |
| 850 | 850 | |
| r8714 | r8715 | |
| 871 | 871 | |
| 872 | 872 | */ |
| 873 | 873 | |
| 874 | v1050_state *state = | |
| 874 | v1050_state *state = | |
| 875 | 875 | |
| 876 | 876 | int baud_sel = (data >> 2) & 0x03; |
| 877 | 877 | |
| r8714 | r8715 | |
| 929 | 929 | |
| 930 | 930 | */ |
| 931 | 931 | |
| 932 | v1050_state *state = | |
| 932 | v1050_state *state = | |
| 933 | 933 | |
| 934 | 934 | state->int_mask = data; |
| 935 | 935 | } |
| r8714 | r8715 | |
| 951 | 951 | |
| 952 | 952 | */ |
| 953 | 953 | |
| 954 | v1050_state *state = | |
| 954 | v1050_state *state = | |
| 955 | 955 | |
| 956 | 956 | return msm58321_busy_r(state->msm58321) << 3; |
| 957 | 957 | } |
| r8714 | r8715 | |
| 973 | 973 | |
| 974 | 974 | */ |
| 975 | 975 | |
| 976 | v1050_state *state = | |
| 976 | v1050_state *state = | |
| 977 | 977 | |
| 978 | 978 | msm58321_address_write_w(state->msm58321, BIT(data, 4)); |
| 979 | 979 | msm58321_write_w(state->msm58321, BIT(data, 5)); |
| r8714 | r8715 | |
| 995 | 995 | |
| 996 | 996 | static TIMER_DEVICE_CALLBACK( kb_8251_tick ) |
| 997 | 997 | { |
| 998 | v1050_state *state = | |
| 998 | v1050_state *state = | |
| 999 | 999 | |
| 1000 | 1000 | msm8251_transmit_clock(state->i8251_kb); |
| 1001 | 1001 | msm8251_receive_clock(state->i8251_kb); |
| r8714 | r8715 | |
| 1017 | 1017 | |
| 1018 | 1018 | static TIMER_DEVICE_CALLBACK( sio_8251_tick ) |
| 1019 | 1019 | { |
| 1020 | v1050_state *state = | |
| 1020 | v1050_state *state = | |
| 1021 | 1021 | |
| 1022 | 1022 | msm8251_transmit_clock(state->i8251_sio); |
| 1023 | 1023 | msm8251_receive_clock(state->i8251_sio); |
| r8714 | r8715 | |
| 1025 | 1025 | |
| 1026 | 1026 | static WRITE_LINE_DEVICE_HANDLER( sio_8251_rxrdy_w ) |
| 1027 | 1027 | { |
| 1028 | v1050_state *driver_state = | |
| 1028 | v1050_state *driver_state = | |
| 1029 | 1029 | |
| 1030 | 1030 | driver_state->rxrdy = state; |
| 1031 | 1031 | |
| r8714 | r8715 | |
| 1034 | 1034 | |
| 1035 | 1035 | static WRITE_LINE_DEVICE_HANDLER( sio_8251_txrdy_w ) |
| 1036 | 1036 | { |
| 1037 | v1050_state *driver_state = | |
| 1037 | v1050_state *driver_state = | |
| 1038 | 1038 | |
| 1039 | 1039 | driver_state->txrdy = state; |
| 1040 | 1040 | |
| r8714 | r8715 | |
| 1052 | 1052 | |
| 1053 | 1053 | static WRITE_LINE_DEVICE_HANDLER( v1050_mb8877_intrq_w ) |
| 1054 | 1054 | { |
| 1055 | v1050_state *driver_state = | |
| 1055 | v1050_state *driver_state = | |
| 1056 | 1056 | |
| 1057 | 1057 | if (driver_state->f_int_enb) |
| 1058 | 1058 | v1050_set_int(device->machine, INT_FLOPPY, state); |
| r8714 | r8715 | |
| 1064 | 1064 | |
| 1065 | 1065 | static WRITE_LINE_DEVICE_HANDLER( v1050_mb8877_drq_w ) |
| 1066 | 1066 | { |
| 1067 | v1050_state *driver_state = | |
| 1067 | v1050_state *driver_state = | |
| 1068 | 1068 | |
| 1069 | 1069 | if (driver_state->f_int_enb) |
| 1070 | 1070 | cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, state); |
| r8714 | r8715 | |
| 1087 | 1087 | |
| 1088 | 1088 | static IRQ_CALLBACK( v1050_int_ack ) |
| 1089 | 1089 | { |
| 1090 | v1050_state *state = | |
| 1090 | v1050_state *state = | |
| 1091 | 1091 | |
| 1092 | 1092 | UINT8 vector = 0xf0 | (i8214_a_r(state->i8214, 0) << 1); |
| 1093 | 1093 | |
| r8714 | r8715 | |
| 1100 | 1100 | |
| 1101 | 1101 | static MACHINE_START( v1050 ) |
| 1102 | 1102 | { |
| 1103 | v1050_state *state = | |
| 1103 | v1050_state *state = | |
| 1104 | 1104 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 1105 | 1105 | |
| 1106 | 1106 | /* find devices */ |
| r8714 | r8715 | |
| 1160 | 1160 | |
| 1161 | 1161 | static MACHINE_RESET( v1050 ) |
| 1162 | 1162 | { |
| 1163 | v1050_state *state = | |
| 1163 | v1050_state *state = | |
| 1164 | 1164 | |
| 1165 | 1165 | state->bank = 0; |
| 1166 | 1166 |
| r8714 | r8715 | |
|---|---|---|
| 164 | 164 | |
| 165 | 165 | */ |
| 166 | 166 | |
| 167 | cgc7900_state *state = | |
| 167 | cgc7900_state *state = | |
| 168 | 168 | |
| 169 | 169 | state->int_mask = data; |
| 170 | 170 | } |
| r8714 | r8715 | |
| 394 | 394 | |
| 395 | 395 | static MACHINE_START( cgc7900 ) |
| 396 | 396 | { |
| 397 | cgc7900_state *state = | |
| 397 | cgc7900_state *state = | |
| 398 | 398 | |
| 399 | 399 | /* register for state saving */ |
| 400 | 400 | state_save_register_global_pointer(machine, state->overlay_ram, 0x4000); |
| r8714 | r8715 | |
|---|---|---|
| 58 | 58 | |
| 59 | 59 | static WRITE8_HANDLER( ipc_w ) |
| 60 | 60 | { |
| 61 | ql_state *state = | |
| 61 | ql_state *state = | |
| 62 | 62 | |
| 63 | 63 | // pulse COMCTL line |
| 64 | 64 | |
| r8714 | r8715 | |
| 83 | 83 | |
| 84 | 84 | */ |
| 85 | 85 | |
| 86 | ql_state *state = | |
| 86 | ql_state *state = | |
| 87 | 87 | |
| 88 | 88 | state->keylatch = data; |
| 89 | 89 | } |
| r8714 | r8715 | |
| 106 | 106 | */ |
| 107 | 107 | |
| 108 | 108 | running_device *speaker = space->machine->device("speaker"); |
| 109 | ql_state *state = | |
| 109 | ql_state *state = | |
| 110 | 110 | |
| 111 | 111 | int ipl = (BIT(data, 2) << 1) | BIT(data, 3); |
| 112 | 112 | |
| r8714 | r8715 | |
| 162 | 162 | |
| 163 | 163 | */ |
| 164 | 164 | |
| 165 | ql_state *state = | |
| 165 | ql_state *state = | |
| 166 | 166 | |
| 167 | 167 | int irq = (state->ser2_rxd | state->ser1_txd); |
| 168 | 168 | |
| r8714 | r8715 | |
| 173 | 173 | |
| 174 | 174 | static READ8_HANDLER( ipc_t1_r ) |
| 175 | 175 | { |
| 176 | ql_state *state = | |
| 176 | ql_state *state = | |
| 177 | 177 | |
| 178 | 178 | return state->baudx4; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | static READ8_HANDLER( ipc_bus_r ) |
| 182 | 182 | { |
| 183 | ql_state *state = | |
| 183 | ql_state *state = | |
| 184 | 184 | |
| 185 | 185 | /* |
| 186 | 186 | |
| r8714 | r8715 | |
| 493 | 493 | |
| 494 | 494 | static WRITE_LINE_DEVICE_HANDLER( ql_baudx4_w ) |
| 495 | 495 | { |
| 496 | ql_state *driver_state = | |
| 496 | ql_state *driver_state = | |
| 497 | 497 | |
| 498 | 498 | driver_state->baudx4 = state; |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | static WRITE_LINE_DEVICE_HANDLER( ql_comdata_w ) |
| 502 | 502 | { |
| 503 | ql_state *driver_state = | |
| 503 | ql_state *driver_state = | |
| 504 | 504 | |
| 505 | 505 | driver_state->comdata = state; |
| 506 | 506 | } |
| r8714 | r8715 | |
| 517 | 517 | |
| 518 | 518 | static VIDEO_UPDATE( ql ) |
| 519 | 519 | { |
| 520 | ql_state *state = | |
| 520 | ql_state *state = | |
| 521 | 521 | |
| 522 | 522 | zx8301_update(state->zx8301, bitmap, cliprect); |
| 523 | 523 | |
| r8714 | r8715 | |
| 528 | 528 | |
| 529 | 529 | static MACHINE_START( ql ) |
| 530 | 530 | { |
| 531 | ql_state *state = | |
| 531 | ql_state *state = | |
| 532 | 532 | |
| 533 | 533 | const address_space *program = cputag_get_address_space(machine, M68008_TAG, ADDRESS_SPACE_PROGRAM); |
| 534 | 534 |
| r8714 | r8715 | |
|---|---|---|
| 209 | 209 | |
| 210 | 210 | static void abc800_bankswitch(running_machine *machine) |
| 211 | 211 | { |
| 212 | abc800_state *state = | |
| 212 | abc800_state *state = | |
| 213 | 213 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 214 | 214 | |
| 215 | 215 | if (state->fetch_charram) |
| r8714 | r8715 | |
| 226 | 226 | |
| 227 | 227 | static void abc802_bankswitch(running_machine *machine) |
| 228 | 228 | { |
| 229 | abc802_state *state = | |
| 229 | abc802_state *state = | |
| 230 | 230 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 231 | 231 | |
| 232 | 232 | if (state->lrs) |
| r8714 | r8715 | |
| 246 | 246 | |
| 247 | 247 | static void abc806_bankswitch(running_machine *machine) |
| 248 | 248 | { |
| 249 | abc806_state *state = | |
| 249 | abc806_state *state = | |
| 250 | 250 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 251 | 251 | UINT32 videoram_mask = messram_get_size(machine->device("messram")) - (32 * 1024) - 1; |
| 252 | 252 | int bank; |
| r8714 | r8715 | |
| 377 | 377 | |
| 378 | 378 | static READ8_HANDLER( abc806_mai_r ) |
| 379 | 379 | { |
| 380 | abc806_state *state = | |
| 380 | abc806_state *state = | |
| 381 | 381 | |
| 382 | 382 | int bank = offset >> 12; |
| 383 | 383 | |
| r8714 | r8715 | |
| 401 | 401 | |
| 402 | 402 | */ |
| 403 | 403 | |
| 404 | abc806_state *state = | |
| 404 | abc806_state *state = | |
| 405 | 405 | |
| 406 | 406 | int bank = offset >> 12; |
| 407 | 407 | |
| r8714 | r8715 | |
| 415 | 415 | static READ8_HANDLER( abc800_pling_r ) |
| 416 | 416 | { |
| 417 | 417 | running_device *discrete = space->machine->device("discrete"); |
| 418 | abc800_state *state = | |
| 418 | abc800_state *state = | |
| 419 | 419 | |
| 420 | 420 | state->pling = !state->pling; |
| 421 | 421 | |
| r8714 | r8715 | |
| 427 | 427 | static READ8_HANDLER( abc802_pling_r ) |
| 428 | 428 | { |
| 429 | 429 | running_device *discrete = space->machine->device("discrete"); |
| 430 | abc802_state *state = | |
| 430 | abc802_state *state = | |
| 431 | 431 | |
| 432 | 432 | state->pling = !state->pling; |
| 433 | 433 | |
| r8714 | r8715 | |
| 849 | 849 | |
| 850 | 850 | static WRITE_LINE_DEVICE_HANDLER( abc802_dart_dtrb_r ) |
| 851 | 851 | { |
| 852 | abc802_state *driver_state = | |
| 852 | abc802_state *driver_state = | |
| 853 | 853 | |
| 854 | 854 | /* low RAM select */ |
| 855 | 855 | driver_state->lrs = state; |
| r8714 | r8715 | |
| 859 | 859 | |
| 860 | 860 | static WRITE_LINE_DEVICE_HANDLER( abc802_dart_rtsb_r ) |
| 861 | 861 | { |
| 862 | abc802_state *driver_state = | |
| 862 | abc802_state *driver_state = | |
| 863 | 863 | |
| 864 | 864 | /* _MUX 80/40 */ |
| 865 | 865 | driver_state->mux80_40 = state; |
| r8714 | r8715 | |
| 888 | 888 | |
| 889 | 889 | static WRITE_LINE_DEVICE_HANDLER( abc806_dart_dtrb_w ) |
| 890 | 890 | { |
| 891 | abc806_state *driver_state = | |
| 891 | abc806_state *driver_state = | |
| 892 | 892 | |
| 893 | 893 | driver_state->keydtr = state; |
| 894 | 894 | |
| r8714 | r8715 | |
| 944 | 944 | |
| 945 | 945 | static MACHINE_START( abc800 ) |
| 946 | 946 | { |
| 947 | abc800_state *state = | |
| 947 | abc800_state *state = | |
| 948 | 948 | |
| 949 | 949 | /* find devices */ |
| 950 | 950 | state->z80ctc = machine->device(Z80CTC_TAG); |
| r8714 | r8715 | |
| 960 | 960 | |
| 961 | 961 | static MACHINE_RESET( abc800 ) |
| 962 | 962 | { |
| 963 | abc800_state *state = | |
| 963 | abc800_state *state = | |
| 964 | 964 | |
| 965 | 965 | state->fetch_charram = 0; |
| 966 | 966 | abc800_bankswitch(machine); |
| r8714 | r8715 | |
| 968 | 968 | |
| 969 | 969 | static MACHINE_START( abc802 ) |
| 970 | 970 | { |
| 971 | abc802_state *state = | |
| 971 | abc802_state *state = | |
| 972 | 972 | |
| 973 | 973 | /* find devices */ |
| 974 | 974 | state->z80ctc = machine->device(Z80CTC_TAG); |
| r8714 | r8715 | |
| 988 | 988 | |
| 989 | 989 | static MACHINE_RESET( abc802 ) |
| 990 | 990 | { |
| 991 | abc802_state *state = | |
| 991 | abc802_state *state = | |
| 992 | 992 | |
| 993 | 993 | UINT8 config = input_port_read(machine, "CONFIG"); |
| 994 | 994 | |
| r8714 | r8715 | |
| 1010 | 1010 | |
| 1011 | 1011 | static MACHINE_START( abc806 ) |
| 1012 | 1012 | { |
| 1013 | abc806_state *state = | |
| 1013 | abc806_state *state = | |
| 1014 | 1014 | |
| 1015 | 1015 | UINT8 *mem = memory_region(machine, Z80_TAG); |
| 1016 | 1016 | UINT32 videoram_size = messram_get_size(machine->device("messram")) - (32 * 1024); |
| r8714 | r8715 | |
| 1045 | 1045 | |
| 1046 | 1046 | static MACHINE_RESET( abc806 ) |
| 1047 | 1047 | { |
| 1048 | abc806_state *state = | |
| 1048 | abc806_state *state = | |
| 1049 | 1049 | |
| 1050 | 1050 | /* setup memory banking */ |
| 1051 | 1051 | int bank; |
| r8714 | r8715 | |
| 1359 | 1359 | |
| 1360 | 1360 | static DIRECT_UPDATE_HANDLER( abc800_direct_update_handler ) |
| 1361 | 1361 | { |
| 1362 | abc800_state *state = | |
| 1362 | abc800_state *state = | |
| 1363 | 1363 | |
| 1364 | 1364 | if (address >= 0x7800 && address < 0x8000) |
| 1365 | 1365 | { |
| r8714 | r8715 | |
| 1385 | 1385 | |
| 1386 | 1386 | static DIRECT_UPDATE_HANDLER( abc802_direct_update_handler ) |
| 1387 | 1387 | { |
| 1388 | abc802_state *state = | |
| 1388 | abc802_state *state = | |
| 1389 | 1389 | |
| 1390 | 1390 | if (state->lrs) |
| 1391 | 1391 | { |
| r8714 | r8715 | |
| 1406 | 1406 | |
| 1407 | 1407 | static DIRECT_UPDATE_HANDLER( abc806_direct_update_handler ) |
| 1408 | 1408 | { |
| 1409 | abc806_state *state = | |
| 1409 | abc806_state *state = | |
| 1410 | 1410 | |
| 1411 | 1411 | if (address >= 0x7800 && address < 0x8000) |
| 1412 | 1412 | { |
| r8714 | r8715 | |
|---|---|---|
| 33 | 33 | Driver data |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | class qx10_state | |
| 36 | class qx10_state : public driver_data_t | |
| 37 | 37 | { |
| 38 | 38 | public: |
| 39 | static | |
| 39 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, qx10_state(machine)); } | |
| 40 | 40 | |
| 41 | qx10_state(running_machine &machine) { } | |
| 41 | qx10_state(running_machine &machine) | |
| 42 | : driver_data_t(machine) { } | |
| 42 | 43 | |
| 43 | 44 | int mc146818_offset; |
| 44 | 45 | |
| r8714 | r8715 | |
| 66 | 67 | static void update_memory_mapping(running_machine *machine) |
| 67 | 68 | { |
| 68 | 69 | int drambank = 0; |
| 69 | qx10_state *state = | |
| 70 | qx10_state *state = | |
| 70 | 71 | |
| 71 | 72 | if (state->membank & 1) |
| 72 | 73 | { |
| r8714 | r8715 | |
| 105 | 106 | |
| 106 | 107 | static WRITE8_HANDLER(qx10_18_w) |
| 107 | 108 | { |
| 108 | qx10_state *state = | |
| 109 | qx10_state *state = | |
| 109 | 110 | state->membank = (data >> 4) & 0x0f; |
| 110 | 111 | update_memory_mapping(space->machine); |
| 111 | 112 | } |
| 112 | 113 | |
| 113 | 114 | static WRITE8_HANDLER(prom_sel_w) |
| 114 | 115 | { |
| 115 | qx10_state *state = | |
| 116 | qx10_state *state = | |
| 116 | 117 | state->memprom = data & 1; |
| 117 | 118 | update_memory_mapping(space->machine); |
| 118 | 119 | } |
| 119 | 120 | |
| 120 | 121 | static WRITE8_HANDLER(cmos_sel_w) |
| 121 | 122 | { |
| 122 | qx10_state *state = | |
| 123 | qx10_state *state = | |
| 123 | 124 | state->memcmos = data & 1; |
| 124 | 125 | update_memory_mapping(space->machine); |
| 125 | 126 | } |
| r8714 | r8715 | |
| 142 | 143 | |
| 143 | 144 | static WRITE_LINE_DEVICE_HANDLER(qx10_upd765_interrupt) |
| 144 | 145 | { |
| 145 | qx10_state *driver_state = | |
| 146 | qx10_state *driver_state = | |
| 146 | 147 | driver_state->fdcint = state; |
| 147 | 148 | |
| 148 | 149 | //logerror("Interrupt from upd765: %d\n", state); |
| r8714 | r8715 | |
| 152 | 153 | |
| 153 | 154 | static UPD765_DMA_REQUEST( drq_w ) |
| 154 | 155 | { |
| 155 | qx10_state *driver_state = | |
| 156 | qx10_state *driver_state = | |
| 156 | 157 | //logerror("DMA Request from upd765: %d\n", state); |
| 157 | 158 | i8237_dreq0_w(driver_state->dma8237_1, !state); |
| 158 | 159 | } |
| r8714 | r8715 | |
| 168 | 169 | |
| 169 | 170 | static WRITE8_HANDLER(fdd_motor_w) |
| 170 | 171 | { |
| 171 | qx10_state *driver_state = | |
| 172 | qx10_state *driver_state = | |
| 172 | 173 | driver_state->fdcmotor = 1; |
| 173 | 174 | |
| 174 | 175 | floppy_mon_w(floppy_get_device(space->machine, 0), CLEAR_LINE); |
| r8714 | r8715 | |
| 178 | 179 | |
| 179 | 180 | static READ8_HANDLER(qx10_30_r) |
| 180 | 181 | { |
| 181 | qx10_state *driver_state = | |
| 182 | qx10_state *driver_state = | |
| 182 | 183 | return driver_state->fdcint | |
| 183 | 184 | /*driver_state->fdcmotor*/ 0 << 1 | |
| 184 | 185 | driver_state->membank << 4; |
| r8714 | r8715 | |
| 206 | 207 | |
| 207 | 208 | static WRITE_LINE_DEVICE_HANDLER( tc_w ) |
| 208 | 209 | { |
| 209 | qx10_state *driver_state = | |
| 210 | qx10_state *driver_state = | |
| 210 | 211 | |
| 211 | 212 | /* floppy terminal count */ |
| 212 | 213 | upd765_tc_w(driver_state->upd765, !state); |
| r8714 | r8715 | |
| 265 | 266 | */ |
| 266 | 267 | static READ8_HANDLER(mc146818_data_r) |
| 267 | 268 | { |
| 268 | qx10_state *state = | |
| 269 | qx10_state *state = | |
| 269 | 270 | return mc146818_port_r(space, state->mc146818_offset); |
| 270 | 271 | }; |
| 271 | 272 | |
| 272 | 273 | static WRITE8_HANDLER(mc146818_data_w) |
| 273 | 274 | { |
| 274 | qx10_state *state = | |
| 275 | qx10_state *state = | |
| 275 | 276 | mc146818_port_w(space, state->mc146818_offset, data); |
| 276 | 277 | }; |
| 277 | 278 | |
| 278 | 279 | static WRITE8_HANDLER(mc146818_offset_w) |
| 279 | 280 | { |
| 280 | qx10_state *state = | |
| 281 | qx10_state *state = | |
| 281 | 282 | state->mc146818_offset = data; |
| 282 | 283 | }; |
| 283 | 284 | |
| r8714 | r8715 | |
| 396 | 397 | static IRQ_CALLBACK( irq_callback ) |
| 397 | 398 | { |
| 398 | 399 | int r = 0; |
| 399 | r = pic8259_acknowledge( | |
| 400 | r = pic8259_acknowledge( | |
| 400 | 401 | if (r==0) |
| 401 | 402 | { |
| 402 | r = pic8259_acknowledge( | |
| 403 | r = pic8259_acknowledge( | |
| 403 | 404 | } |
| 404 | 405 | return r; |
| 405 | 406 | } |
| r8714 | r8715 | |
| 453 | 454 | |
| 454 | 455 | static MACHINE_START(qx10) |
| 455 | 456 | { |
| 456 | qx10_state *state = | |
| 457 | qx10_state *state = | |
| 457 | 458 | |
| 458 | 459 | cpu_set_irq_callback(machine->device("maincpu"), irq_callback); |
| 459 | 460 | |
| r8714 | r8715 | |
| 470 | 471 | |
| 471 | 472 | static MACHINE_RESET(qx10) |
| 472 | 473 | { |
| 473 | qx10_state *state = | |
| 474 | qx10_state *state = | |
| 474 | 475 | |
| 475 | 476 | i8237_dreq0_w(state->dma8237_1, 1); |
| 476 | 477 |
| r8714 | r8715 | |
|---|---|---|
| 141 | 141 | |
| 142 | 142 | static WRITE8_HANDLER( tmc1800_keylatch_w ) |
| 143 | 143 | { |
| 144 | tmc1800_state *state = | |
| 144 | tmc1800_state *state = | |
| 145 | 145 | |
| 146 | 146 | state->keylatch = data; |
| 147 | 147 | } |
| r8714 | r8715 | |
| 163 | 163 | |
| 164 | 164 | */ |
| 165 | 165 | |
| 166 | tmc2000_state *state = | |
| 166 | tmc2000_state *state = | |
| 167 | 167 | |
| 168 | 168 | state->keylatch = data & 0x3f; |
| 169 | 169 | } |
| r8714 | r8715 | |
| 185 | 185 | |
| 186 | 186 | */ |
| 187 | 187 | |
| 188 | oscnano_state *state = | |
| 188 | oscnano_state *state = | |
| 189 | 189 | |
| 190 | 190 | state->keylatch = data & 0x0f; |
| 191 | 191 | } |
| r8714 | r8715 | |
| 440 | 440 | |
| 441 | 441 | static CDP1802_MODE_READ( tmc1800_mode_r ) |
| 442 | 442 | { |
| 443 | tmc1800_state *state = | |
| 443 | tmc1800_state *state = | |
| 444 | 444 | |
| 445 | 445 | if (input_port_read(device->machine, "RUN") & 0x01) |
| 446 | 446 | { |
| r8714 | r8715 | |
| 464 | 464 | |
| 465 | 465 | static CDP1802_EF_READ( tmc1800_ef_r ) |
| 466 | 466 | { |
| 467 | tmc1800_state *state = | |
| 467 | tmc1800_state *state = | |
| 468 | 468 | |
| 469 | 469 | UINT8 flags = 0x0f; |
| 470 | 470 | static const char *const keynames[] = { "IN0", "IN1", "IN2", "IN3", "IN4", "IN5", "IN6", "IN7" }; |
| r8714 | r8715 | |
| 490 | 490 | |
| 491 | 491 | static WRITE_LINE_DEVICE_HANDLER( tmc1800_q_w ) |
| 492 | 492 | { |
| 493 | tmc1800_state *driver_state = | |
| 493 | tmc1800_state *driver_state = | |
| 494 | 494 | |
| 495 | 495 | /* tape output */ |
| 496 | 496 | cassette_output(driver_state->cassette, state ? 1.0 : -1.0); |
| r8714 | r8715 | |
| 520 | 520 | |
| 521 | 521 | static CDP1802_MODE_READ( tmc2000_mode_r ) |
| 522 | 522 | { |
| 523 | tmc2000_state *state = | |
| 523 | tmc2000_state *state = | |
| 524 | 524 | |
| 525 | 525 | if (input_port_read(device->machine, "RUN") & 0x01) |
| 526 | 526 | { |
| r8714 | r8715 | |
| 544 | 544 | |
| 545 | 545 | static CDP1802_EF_READ( tmc2000_ef_r ) |
| 546 | 546 | { |
| 547 | tmc2000_state *state = | |
| 547 | tmc2000_state *state = | |
| 548 | 548 | |
| 549 | 549 | int flags = 0x0f; |
| 550 | 550 | static const char *const keynames[] = { "IN0", "IN1", "IN2", "IN3", "IN4", "IN5", "IN6", "IN7" }; |
| r8714 | r8715 | |
| 570 | 570 | |
| 571 | 571 | static WRITE_LINE_DEVICE_HANDLER( tmc2000_q_w ) |
| 572 | 572 | { |
| 573 | tmc2000_state *driver_state = | |
| 573 | tmc2000_state *driver_state = | |
| 574 | 574 | |
| 575 | 575 | /* CDP1864 audio output enable */ |
| 576 | 576 | cdp1864_aoe_w(driver_state->cdp1864, state); |
| r8714 | r8715 | |
| 584 | 584 | |
| 585 | 585 | static WRITE8_DEVICE_HANDLER( tmc2000_dma_w ) |
| 586 | 586 | { |
| 587 | tmc2000_state *state = | |
| 587 | tmc2000_state *state = | |
| 588 | 588 | |
| 589 | 589 | state->color = ~(state->colorram[offset & 0x1ff]) & 0x07; |
| 590 | 590 | |
| r8714 | r8715 | |
| 606 | 606 | |
| 607 | 607 | static TIMER_CALLBACK( oscnano_ef4_tick ) |
| 608 | 608 | { |
| 609 | oscnano_state *state = | |
| 609 | oscnano_state *state = | |
| 610 | 610 | |
| 611 | 611 | /* assert EF4 */ |
| 612 | 612 | state->monitor_ef4 = 1; |
| r8714 | r8715 | |
| 614 | 614 | |
| 615 | 615 | static CDP1802_MODE_READ( oscnano_mode_r ) |
| 616 | 616 | { |
| 617 | oscnano_state *state = | |
| 617 | oscnano_state *state = | |
| 618 | 618 | |
| 619 | 619 | int run = input_port_read(device->machine, "RUN") & 0x01; |
| 620 | 620 | int monitor = input_port_read(device->machine, "MONITOR") & 0x01; |
| r8714 | r8715 | |
| 653 | 653 | |
| 654 | 654 | static CDP1802_EF_READ( oscnano_ef_r ) |
| 655 | 655 | { |
| 656 | oscnano_state *state = | |
| 656 | oscnano_state *state = | |
| 657 | 657 | |
| 658 | 658 | static const char *const keynames[] = { "IN0", "IN1", "IN2", "IN3", "IN4", "IN5", "IN6", "IN7" }; |
| 659 | 659 | |
| r8714 | r8715 | |
| 683 | 683 | |
| 684 | 684 | static WRITE_LINE_DEVICE_HANDLER( oscnano_q_w ) |
| 685 | 685 | { |
| 686 | oscnano_state *driver_state = | |
| 686 | oscnano_state *driver_state = | |
| 687 | 687 | |
| 688 | 688 | /* CDP1864 audio output enable */ |
| 689 | 689 | cdp1864_aoe_w(driver_state->cdp1864, state); |
| r8714 | r8715 | |
| 711 | 711 | |
| 712 | 712 | static MACHINE_START( tmc1800 ) |
| 713 | 713 | { |
| 714 | tmc1800_state *state = | |
| 714 | tmc1800_state *state = | |
| 715 | 715 | |
| 716 | 716 | /* find devices */ |
| 717 | 717 | state->cdp1861 = machine->device(CDP1861_TAG); |
| r8714 | r8715 | |
| 725 | 725 | |
| 726 | 726 | static MACHINE_RESET( tmc1800 ) |
| 727 | 727 | { |
| 728 | tmc1800_state *state = | |
| 728 | tmc1800_state *state = | |
| 729 | 729 | |
| 730 | 730 | /* reset CDP1861 */ |
| 731 | 731 | state->cdp1861->reset(); |
| r8714 | r8715 | |
| 735 | 735 | |
| 736 | 736 | static MACHINE_START( osc1000b ) |
| 737 | 737 | { |
| 738 | osc1000b_state *state = | |
| 738 | osc1000b_state *state = | |
| 739 | 739 | |
| 740 | 740 | /* find devices */ |
| 741 | 741 | state->cassette = machine->device(CASSETTE_TAG); |
| r8714 | r8715 | |
| 753 | 753 | |
| 754 | 754 | static MACHINE_START( tmc2000 ) |
| 755 | 755 | { |
| 756 | tmc2000_state *state = | |
| 756 | tmc2000_state *state = | |
| 757 | 757 | |
| 758 | 758 | UINT16 addr; |
| 759 | 759 | |
| r8714 | r8715 | |
| 785 | 785 | |
| 786 | 786 | static MACHINE_RESET( tmc2000 ) |
| 787 | 787 | { |
| 788 | tmc2000_state *state = | |
| 788 | tmc2000_state *state = | |
| 789 | 789 | |
| 790 | 790 | /* reset CDP1864 */ |
| 791 | 791 | state->cdp1864->reset(); |
| r8714 | r8715 | |
| 805 | 805 | |
| 806 | 806 | static MACHINE_START( oscnano ) |
| 807 | 807 | { |
| 808 | oscnano_state *state = | |
| 808 | oscnano_state *state = | |
| 809 | 809 | |
| 810 | 810 | /* RAM/ROM banking */ |
| 811 | 811 | memory_configure_bank(machine, "bank1", 0, 2, memory_region(machine, CDP1802_TAG), 0x8000); |
| r8714 | r8715 | |
| 829 | 829 | |
| 830 | 830 | static MACHINE_RESET( oscnano ) |
| 831 | 831 | { |
| 832 | oscnano_state *state = | |
| 832 | oscnano_state *state = | |
| 833 | 833 | |
| 834 | 834 | /* reset CDP1864 */ |
| 835 | 835 | state->cdp1864->reset(); |
| r8714 | r8715 | |
|---|---|---|
| 570 | 570 | PA7 Cassette data in/out |
| 571 | 571 | */ |
| 572 | 572 | |
| 573 | crvision_state *state = | |
| 573 | crvision_state *state = | |
| 574 | 574 | |
| 575 | 575 | /* keyboard raster */ |
| 576 | 576 | state->keylatch = ~data & 0x0f; |
| r8714 | r8715 | |
| 623 | 623 | PA7 Cassette data in/out |
| 624 | 624 | */ |
| 625 | 625 | |
| 626 | crvision_state *state = | |
| 626 | crvision_state *state = | |
| 627 | 627 | |
| 628 | 628 | UINT8 data = 0x7f; |
| 629 | 629 | |
| r8714 | r8715 | |
| 647 | 647 | PB7 Keyboard input |
| 648 | 648 | */ |
| 649 | 649 | |
| 650 | crvision_state *state = | |
| 650 | crvision_state *state = | |
| 651 | 651 | |
| 652 | 652 | UINT8 data = 0xff; |
| 653 | 653 | |
| r8714 | r8715 | |
| 694 | 694 | PA7 Keyboard column 7 |
| 695 | 695 | */ |
| 696 | 696 | |
| 697 | crvision_state *state = | |
| 697 | crvision_state *state = | |
| 698 | 698 | |
| 699 | 699 | UINT8 data = 0xff; |
| 700 | 700 | |
| r8714 | r8715 | |
| 723 | 723 | PA7 ? |
| 724 | 724 | */ |
| 725 | 725 | |
| 726 | crvision_state *state = | |
| 726 | crvision_state *state = | |
| 727 | 727 | |
| 728 | 728 | state->joylatch = data; |
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | static READ8_DEVICE_HANDLER( lasr2001_pia_pb_r ) |
| 732 | 732 | { |
| 733 | crvision_state *state = | |
| 733 | crvision_state *state = | |
| 734 | 734 | |
| 735 | 735 | UINT8 data = 0xff; |
| 736 | 736 | |
| r8714 | r8715 | |
| 757 | 757 | PB7 Keyboard row 7, PSG data 0, centronics data 7 |
| 758 | 758 | */ |
| 759 | 759 | |
| 760 | crvision_state *state = | |
| 760 | crvision_state *state = | |
| 761 | 761 | |
| 762 | 762 | /* keyboard latch */ |
| 763 | 763 | state->keylatch = data; |
| r8714 | r8715 | |
| 778 | 778 | |
| 779 | 779 | static READ_LINE_DEVICE_HANDLER( lasr2001_pia_cb1_r ) |
| 780 | 780 | { |
| 781 | crvision_state *state = | |
| 781 | crvision_state *state = | |
| 782 | 782 | |
| 783 | 783 | /* actually this is a diode-AND (READY & _BUSY), but ctronics.c returns busy status if printer image is not mounted -> Manager won't boot */ |
| 784 | 784 | return sn76496_ready_r(state->psg) & (centronics_not_busy_r(state->centronics) | pia6821_get_output_ca2_z(device)); |
| r8714 | r8715 | |
| 786 | 786 | |
| 787 | 787 | static WRITE_LINE_DEVICE_HANDLER( lasr2001_pia_cb2_w ) |
| 788 | 788 | { |
| 789 | crvision_state *driver_state = | |
| 789 | crvision_state *driver_state = | |
| 790 | 790 | |
| 791 | 791 | if (pia6821_get_output_ca2_z(device)) |
| 792 | 792 | { |
| r8714 | r8715 | |
| 876 | 876 | |
| 877 | 877 | static MACHINE_START( creativision ) |
| 878 | 878 | { |
| 879 | crvision_state *state = | |
| 879 | crvision_state *state = | |
| 880 | 880 | |
| 881 | 881 | /* find devices */ |
| 882 | 882 | state->psg = machine->device(SN76489_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 164 | 164 | static void towns_init_serial_rom(running_machine* machine) |
| 165 | 165 | { |
| 166 | 166 | // TODO: init serial ROM contents |
| 167 | towns_state* state = | |
| 167 | towns_state* state = | |
| 168 | 168 | int x; |
| 169 | 169 | UINT8 code[8] = { 0x04,0x65,0x54,0xA4,0x95,0x45,0x35,0x5F }; |
| 170 | 170 | UINT8* srom = memory_region(machine,"serial"); |
| r8714 | r8715 | |
| 202 | 202 | |
| 203 | 203 | static void towns_init_rtc(running_machine* machine) |
| 204 | 204 | { |
| 205 | towns_state* state = | |
| 205 | towns_state* state = | |
| 206 | 206 | // for now, we'll just keep a static time stored here |
| 207 | 207 | // seconds |
| 208 | 208 | state->towns_rtc_reg[0] = 0; |
| r8714 | r8715 | |
| 228 | 228 | |
| 229 | 229 | static READ8_HANDLER(towns_system_r) |
| 230 | 230 | { |
| 231 | towns_state* state = | |
| 231 | towns_state* state = | |
| 232 | 232 | UINT8 ret = 0; |
| 233 | 233 | |
| 234 | 234 | switch(offset) |
| r8714 | r8715 | |
| 267 | 267 | |
| 268 | 268 | static WRITE8_HANDLER(towns_system_w) |
| 269 | 269 | { |
| 270 | towns_state* state = | |
| 270 | towns_state* state = | |
| 271 | 271 | |
| 272 | 272 | switch(offset) |
| 273 | 273 | { |
| r8714 | r8715 | |
| 309 | 309 | |
| 310 | 310 | static WRITE8_HANDLER(towns_sys6c_w) |
| 311 | 311 | { |
| 312 | towns_state* state = | |
| 312 | towns_state* state = | |
| 313 | 313 | // logerror("SYS: (0x6c) write to timer (0x%02x)\n",data); |
| 314 | 314 | state->ftimer -= 0x54; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | static READ8_HANDLER(towns_dma1_r) |
| 318 | 318 | { |
| 319 | towns_state* state = | |
| 319 | towns_state* state = | |
| 320 | 320 | running_device* dev = state->dma_1; |
| 321 | 321 | |
| 322 | 322 | logerror("DMA#1: read register %i\n",offset); |
| r8714 | r8715 | |
| 325 | 325 | |
| 326 | 326 | static WRITE8_HANDLER(towns_dma1_w) |
| 327 | 327 | { |
| 328 | towns_state* state = | |
| 328 | towns_state* state = | |
| 329 | 329 | running_device* dev = state->dma_1; |
| 330 | 330 | |
| 331 | 331 | logerror("DMA#1: wrote 0x%02x to register %i\n",data,offset); |
| r8714 | r8715 | |
| 334 | 334 | |
| 335 | 335 | static READ8_HANDLER(towns_dma2_r) |
| 336 | 336 | { |
| 337 | towns_state* state = | |
| 337 | towns_state* state = | |
| 338 | 338 | running_device* dev = state->dma_2; |
| 339 | 339 | |
| 340 | 340 | logerror("DMA#2: read register %i\n",offset); |
| r8714 | r8715 | |
| 343 | 343 | |
| 344 | 344 | static WRITE8_HANDLER(towns_dma2_w) |
| 345 | 345 | { |
| 346 | towns_state* state = | |
| 346 | towns_state* state = | |
| 347 | 347 | running_device* dev = state->dma_2; |
| 348 | 348 | |
| 349 | 349 | logerror("DMA#2: wrote 0x%02x to register %i\n",data,offset); |
| r8714 | r8715 | |
| 356 | 356 | |
| 357 | 357 | static WRITE_LINE_DEVICE_HANDLER( towns_mb8877a_irq_w ) |
| 358 | 358 | { |
| 359 | towns_state* tstate = | |
| 359 | towns_state* tstate = | |
| 360 | 360 | |
| 361 | 361 | if(tstate->towns_fdc_irq6mask == 0) |
| 362 | 362 | state = 0; |
| r8714 | r8715 | |
| 371 | 371 | |
| 372 | 372 | static READ8_HANDLER(towns_floppy_r) |
| 373 | 373 | { |
| 374 | towns_state* state = | |
| 374 | towns_state* state = | |
| 375 | 375 | running_device* fdc = state->fdc; |
| 376 | 376 | |
| 377 | 377 | switch(offset) |
| r8714 | r8715 | |
| 401 | 401 | |
| 402 | 402 | static WRITE8_HANDLER(towns_floppy_w) |
| 403 | 403 | { |
| 404 | towns_state* state = | |
| 404 | towns_state* state = | |
| 405 | 405 | running_device* fdc = state->fdc; |
| 406 | 406 | |
| 407 | 407 | switch(offset) |
| r8714 | r8715 | |
| 468 | 468 | |
| 469 | 469 | static UINT16 towns_fdc_dma_r(running_machine* machine) |
| 470 | 470 | { |
| 471 | towns_state* state = | |
| 471 | towns_state* state = | |
| 472 | 472 | running_device* fdc = state->fdc; |
| 473 | 473 | return wd17xx_data_r(fdc,0); |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | static void towns_fdc_dma_w(running_machine* machine, UINT16 data) |
| 477 | 477 | { |
| 478 | towns_state* state = | |
| 478 | towns_state* state = | |
| 479 | 479 | running_device* fdc = state->fdc; |
| 480 | 480 | wd17xx_data_w(fdc,0,data); |
| 481 | 481 | } |
| r8714 | r8715 | |
| 498 | 498 | */ |
| 499 | 499 | static void towns_kb_sendcode(running_machine* machine, UINT8 scancode, int release) |
| 500 | 500 | { |
| 501 | towns_state* state = | |
| 501 | towns_state* state = | |
| 502 | 502 | running_device* dev = state->pic_master; |
| 503 | 503 | |
| 504 | 504 | switch(release) |
| r8714 | r8715 | |
| 566 | 566 | |
| 567 | 567 | static READ8_HANDLER(towns_keyboard_r) |
| 568 | 568 | { |
| 569 | towns_state* state = | |
| 569 | towns_state* state = | |
| 570 | 570 | UINT8 ret = 0x00; |
| 571 | 571 | |
| 572 | 572 | switch(offset) |
| r8714 | r8715 | |
| 594 | 594 | |
| 595 | 595 | static WRITE8_HANDLER(towns_keyboard_w) |
| 596 | 596 | { |
| 597 | towns_state* state = | |
| 597 | towns_state* state = | |
| 598 | 598 | |
| 599 | 599 | switch(offset) |
| 600 | 600 | { |
| r8714 | r8715 | |
| 623 | 623 | */ |
| 624 | 624 | static READ8_HANDLER(towns_port60_r) |
| 625 | 625 | { |
| 626 | towns_state* state = | |
| 626 | towns_state* state = | |
| 627 | 627 | UINT8 val = 0x00; |
| 628 | 628 | |
| 629 | 629 | if ( pit8253_get_output(state->pit, 0 ) ) |
| r8714 | r8715 | |
| 639 | 639 | |
| 640 | 640 | static WRITE8_HANDLER(towns_port60_w) |
| 641 | 641 | { |
| 642 | towns_state* state = | |
| 642 | towns_state* state = | |
| 643 | 643 | running_device* dev = state->pic_master; |
| 644 | 644 | |
| 645 | 645 | if(data & 0x80) |
| r8714 | r8715 | |
| 653 | 653 | |
| 654 | 654 | static READ32_HANDLER(towns_sys5e8_r) |
| 655 | 655 | { |
| 656 | towns_state* state = | |
| 656 | towns_state* state = | |
| 657 | 657 | |
| 658 | 658 | switch(offset) |
| 659 | 659 | { |
| r8714 | r8715 | |
| 677 | 677 | |
| 678 | 678 | static WRITE32_HANDLER(towns_sys5e8_w) |
| 679 | 679 | { |
| 680 | towns_state* state = | |
| 680 | towns_state* state = | |
| 681 | 681 | |
| 682 | 682 | switch(offset) |
| 683 | 683 | { |
| r8714 | r8715 | |
| 704 | 704 | // W/O -- (0x4ec) LED control |
| 705 | 705 | static READ8_HANDLER(towns_sound_ctrl_r) |
| 706 | 706 | { |
| 707 | towns_state* state = | |
| 707 | towns_state* state = | |
| 708 | 708 | UINT8 ret = 0; |
| 709 | 709 | |
| 710 | 710 | switch(offset) |
| r8714 | r8715 | |
| 730 | 730 | |
| 731 | 731 | static WRITE8_HANDLER(towns_sound_ctrl_w) |
| 732 | 732 | { |
| 733 | towns_state* state = | |
| 733 | towns_state* state = | |
| 734 | 734 | switch(offset) |
| 735 | 735 | { |
| 736 | 736 | case 0x02: // PCM channel interrupt mask |
| r8714 | r8715 | |
| 745 | 745 | // Joysticks are multiplexed, with fire buttons available when bits 0 and 1 of port 0x4d6 are high. (bits 2 and 3 for second port?) |
| 746 | 746 | static TIMER_CALLBACK(towns_mouse_timeout) |
| 747 | 747 | { |
| 748 | towns_state* state = | |
| 748 | towns_state* state = | |
| 749 | 749 | state->towns_mouse_output = MOUSE_START; // reset mouse data |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | static READ32_HANDLER(towns_padport_r) |
| 753 | 753 | { |
| 754 | towns_state* tstate = | |
| 754 | towns_state* tstate = | |
| 755 | 755 | UINT32 ret = 0; |
| 756 | 756 | UINT32 porttype = input_port_read(space->machine,"ctrltype"); |
| 757 | 757 | UINT8 extra1; |
| r8714 | r8715 | |
| 870 | 870 | |
| 871 | 871 | static WRITE32_HANDLER(towns_pad_mask_w) |
| 872 | 872 | { |
| 873 | towns_state* state = | |
| 873 | towns_state* state = | |
| 874 | 874 | static UINT8 prev; |
| 875 | 875 | static UINT8 prev_x,prev_y; |
| 876 | 876 | UINT8 current_x,current_y; |
| r8714 | r8715 | |
| 956 | 956 | |
| 957 | 957 | static READ8_HANDLER( towns_cmos8_r ) |
| 958 | 958 | { |
| 959 | towns_state* state = | |
| 959 | towns_state* state = | |
| 960 | 960 | return state->towns_cmos[offset]; |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | static WRITE8_HANDLER( towns_cmos8_w ) |
| 964 | 964 | { |
| 965 | towns_state* state = | |
| 965 | towns_state* state = | |
| 966 | 966 | state->towns_cmos[offset] = data; |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | static READ8_HANDLER( towns_cmos_low_r ) |
| 970 | 970 | { |
| 971 | towns_state* state = | |
| 971 | towns_state* state = | |
| 972 | 972 | if(state->towns_mainmem_enable != 0) |
| 973 | 973 | return messram_get_ptr(state->messram)[offset + 0xd8000]; |
| 974 | 974 | |
| r8714 | r8715 | |
| 977 | 977 | |
| 978 | 978 | static WRITE8_HANDLER( towns_cmos_low_w ) |
| 979 | 979 | { |
| 980 | towns_state* state = | |
| 980 | towns_state* state = | |
| 981 | 981 | if(state->towns_mainmem_enable != 0) |
| 982 | 982 | messram_get_ptr(state->messram)[offset+0xd8000] = data; |
| 983 | 983 | else |
| r8714 | r8715 | |
| 986 | 986 | |
| 987 | 987 | static READ8_HANDLER( towns_cmos_r ) |
| 988 | 988 | { |
| 989 | towns_state* state = | |
| 989 | towns_state* state = | |
| 990 | 990 | return state->towns_cmos[offset]; |
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | static WRITE8_HANDLER( towns_cmos_w ) |
| 994 | 994 | { |
| 995 | towns_state* state = | |
| 995 | towns_state* state = | |
| 996 | 996 | state->towns_cmos[offset] = data; |
| 997 | 997 | } |
| 998 | 998 | |
| 999 | 999 | void towns_update_video_banks(const address_space* space) |
| 1000 | 1000 | { |
| 1001 | towns_state* state = | |
| 1001 | towns_state* state = | |
| 1002 | 1002 | UINT8* ROM; |
| 1003 | 1003 | |
| 1004 | 1004 | if(state->towns_mainmem_enable != 0) // first MB is RAM |
| r8714 | r8715 | |
| 1049 | 1049 | |
| 1050 | 1050 | static READ8_HANDLER( towns_sys480_r ) |
| 1051 | 1051 | { |
| 1052 | towns_state* state = | |
| 1052 | towns_state* state = | |
| 1053 | 1053 | if(state->towns_system_port & 0x02) |
| 1054 | 1054 | return 0x02; |
| 1055 | 1055 | else |
| r8714 | r8715 | |
| 1058 | 1058 | |
| 1059 | 1059 | static WRITE8_HANDLER( towns_sys480_w ) |
| 1060 | 1060 | { |
| 1061 | towns_state* state = | |
| 1061 | towns_state* state = | |
| 1062 | 1062 | |
| 1063 | 1063 | state->towns_system_port = data; |
| 1064 | 1064 | state->towns_ram_enable = data & 0x02; |
| r8714 | r8715 | |
| 1067 | 1067 | |
| 1068 | 1068 | static WRITE32_HANDLER( towns_video_404_w ) |
| 1069 | 1069 | { |
| 1070 | towns_state* state = | |
| 1070 | towns_state* state = | |
| 1071 | 1071 | if(ACCESSING_BITS_0_7) |
| 1072 | 1072 | { |
| 1073 | 1073 | state->towns_mainmem_enable = data & 0x80; |
| r8714 | r8715 | |
| 1078 | 1078 | |
| 1079 | 1079 | static READ32_HANDLER( towns_video_404_r ) |
| 1080 | 1080 | { |
| 1081 | towns_state* state = | |
| 1081 | towns_state* state = | |
| 1082 | 1082 | if(ACCESSING_BITS_0_7) |
| 1083 | 1083 | { |
| 1084 | 1084 | logerror("mainmem_enable - reading 0x%02x\n",state->towns_mainmem_enable); |
| r8714 | r8715 | |
| 1127 | 1127 | */ |
| 1128 | 1128 | static void towns_cdrom_set_irq(running_machine* machine,int line,int state) |
| 1129 | 1129 | { |
| 1130 | towns_state* tstate = | |
| 1130 | towns_state* tstate = | |
| 1131 | 1131 | switch(line) |
| 1132 | 1132 | { |
| 1133 | 1133 | case TOWNS_CD_IRQ_MPU: |
| r8714 | r8715 | |
| 1175 | 1175 | |
| 1176 | 1176 | static TIMER_CALLBACK( towns_cd_status_ready ) |
| 1177 | 1177 | { |
| 1178 | towns_state* state = | |
| 1178 | towns_state* state = | |
| 1179 | 1179 | state->towns_cd.status |= 0x02; // status read request |
| 1180 | 1180 | state->towns_cd.status |= 0x01; // ready |
| 1181 | 1181 | state->towns_cd.cmd_status_ptr = 0; |
| r8714 | r8715 | |
| 1184 | 1184 | |
| 1185 | 1185 | static void towns_cd_set_status(running_machine* machine, UINT8 st0, UINT8 st1, UINT8 st2, UINT8 st3) |
| 1186 | 1186 | { |
| 1187 | towns_state* state = | |
| 1187 | towns_state* state = | |
| 1188 | 1188 | state->towns_cd.cmd_status[0] = st0; |
| 1189 | 1189 | state->towns_cd.cmd_status[1] = st1; |
| 1190 | 1190 | state->towns_cd.cmd_status[2] = st2; |
| r8714 | r8715 | |
| 1195 | 1195 | |
| 1196 | 1196 | static UINT8 towns_cd_get_track(running_machine* machine) |
| 1197 | 1197 | { |
| 1198 | towns_state* state = | |
| 1198 | towns_state* state = | |
| 1199 | 1199 | running_device* cdrom = state->cdrom; |
| 1200 | 1200 | running_device* cdda = state->cdda; |
| 1201 | 1201 | UINT32 lba = cdda_get_audio_lba(cdda); |
| r8714 | r8715 | |
| 1212 | 1212 | static TIMER_CALLBACK( towns_cdrom_read_byte ) |
| 1213 | 1213 | { |
| 1214 | 1214 | running_device* device = (running_device* )ptr; |
| 1215 | towns_state* state = | |
| 1215 | towns_state* state = | |
| 1216 | 1216 | int masked; |
| 1217 | 1217 | // TODO: support software transfers, for now DMA is assumed. |
| 1218 | 1218 | |
| r8714 | r8715 | |
| 1269 | 1269 | // parameters: |
| 1270 | 1270 | // 3 bytes: MSF of first sector to read |
| 1271 | 1271 | // 3 bytes: MSF of last sector to read |
| 1272 | towns_state* state = | |
| 1272 | towns_state* state = | |
| 1273 | 1273 | UINT32 lba1,lba2,track; |
| 1274 | 1274 | |
| 1275 | 1275 | lba1 = state->towns_cd.parameter[7] << 16; |
| r8714 | r8715 | |
| 1315 | 1315 | // Parameters: |
| 1316 | 1316 | // 3 bytes: starting MSF of audio to play |
| 1317 | 1317 | // 3 bytes: ending MSF of audio to play (can span multiple tracks) |
| 1318 | towns_state* state = | |
| 1318 | towns_state* state = | |
| 1319 | 1319 | UINT32 lba1,lba2; |
| 1320 | 1320 | running_device* cdda = state->cdda; |
| 1321 | 1321 | |
| r8714 | r8715 | |
| 1338 | 1338 | |
| 1339 | 1339 | static void towns_cdrom_execute_command(running_device* device) |
| 1340 | 1340 | { |
| 1341 | towns_state* state = | |
| 1341 | towns_state* state = | |
| 1342 | 1342 | |
| 1343 | 1343 | if(mess_cd_get_cdrom_file(device) == NULL) |
| 1344 | 1344 | { // No CD in drive |
| r8714 | r8715 | |
| 1440 | 1440 | |
| 1441 | 1441 | static UINT16 towns_cdrom_dma_r(running_machine* machine) |
| 1442 | 1442 | { |
| 1443 | towns_state* state = | |
| 1443 | towns_state* state = | |
| 1444 | 1444 | if(state->towns_cd.buffer_ptr >= 2048) |
| 1445 | 1445 | return 0x00; |
| 1446 | 1446 | return state->towns_cd.buffer[state->towns_cd.buffer_ptr++]; |
| r8714 | r8715 | |
| 1448 | 1448 | |
| 1449 | 1449 | static READ8_HANDLER(towns_cdrom_r) |
| 1450 | 1450 | { |
| 1451 | towns_state* state = | |
| 1451 | towns_state* state = | |
| 1452 | 1452 | UINT32 addr = 0; |
| 1453 | 1453 | UINT8 ret = 0; |
| 1454 | 1454 | |
| r8714 | r8715 | |
| 1598 | 1598 | |
| 1599 | 1599 | static WRITE8_HANDLER(towns_cdrom_w) |
| 1600 | 1600 | { |
| 1601 | towns_state* state = | |
| 1601 | towns_state* state = | |
| 1602 | 1602 | int x; |
| 1603 | 1603 | switch(offset) |
| 1604 | 1604 | { |
| r8714 | r8715 | |
| 1654 | 1654 | */ |
| 1655 | 1655 | static READ32_HANDLER(towns_rtc_r) |
| 1656 | 1656 | { |
| 1657 | towns_state* state = | |
| 1657 | towns_state* state = | |
| 1658 | 1658 | if(ACCESSING_BITS_0_7) |
| 1659 | 1659 | return 0x80 | state->towns_rtc_reg[state->towns_rtc_select]; |
| 1660 | 1660 | |
| r8714 | r8715 | |
| 1663 | 1663 | |
| 1664 | 1664 | static WRITE32_HANDLER(towns_rtc_w) |
| 1665 | 1665 | { |
| 1666 | towns_state* state = | |
| 1666 | towns_state* state = | |
| 1667 | 1667 | if(ACCESSING_BITS_0_7) |
| 1668 | 1668 | state->towns_rtc_data = data; |
| 1669 | 1669 | } |
| 1670 | 1670 | |
| 1671 | 1671 | static WRITE32_HANDLER(towns_rtc_select_w) |
| 1672 | 1672 | { |
| 1673 | towns_state* state = | |
| 1673 | towns_state* state = | |
| 1674 | 1674 | if(ACCESSING_BITS_0_7) |
| 1675 | 1675 | { |
| 1676 | 1676 | if(data & 0x80) |
| r8714 | r8715 | |
| 1683 | 1683 | |
| 1684 | 1684 | static void rtc_hour(running_machine* machine) |
| 1685 | 1685 | { |
| 1686 | towns_state* state = | |
| 1686 | towns_state* state = | |
| 1687 | 1687 | |
| 1688 | 1688 | state->towns_rtc_reg[4]++; |
| 1689 | 1689 | if(state->towns_rtc_reg[4] > 4 && state->towns_rtc_reg[5] == 2) |
| r8714 | r8715 | |
| 1700 | 1700 | |
| 1701 | 1701 | static void rtc_minute(running_machine* machine) |
| 1702 | 1702 | { |
| 1703 | towns_state* state = | |
| 1703 | towns_state* state = | |
| 1704 | 1704 | |
| 1705 | 1705 | state->towns_rtc_reg[2]++; |
| 1706 | 1706 | if(state->towns_rtc_reg[2] > 9) |
| r8714 | r8715 | |
| 1717 | 1717 | |
| 1718 | 1718 | static TIMER_CALLBACK(rtc_second) |
| 1719 | 1719 | { |
| 1720 | towns_state* state = | |
| 1720 | towns_state* state = | |
| 1721 | 1721 | // increase RTC time by one second |
| 1722 | 1722 | state->towns_rtc_reg[0]++; |
| 1723 | 1723 | if(state->towns_rtc_reg[0] > 9) |
| r8714 | r8715 | |
| 1750 | 1750 | |
| 1751 | 1751 | static IRQ_CALLBACK( towns_irq_callback ) |
| 1752 | 1752 | { |
| 1753 | towns_state* state = | |
| 1753 | towns_state* state = | |
| 1754 | 1754 | running_device* pic1 = state->pic_master; |
| 1755 | 1755 | running_device* pic2 = state->pic_slave; |
| 1756 | 1756 | int r; |
| r8714 | r8715 | |
| 1767 | 1767 | // YM3438 interrupt (IRQ 13) |
| 1768 | 1768 | void towns_fm_irq(running_device* device, int irq) |
| 1769 | 1769 | { |
| 1770 | towns_state* state = | |
| 1770 | towns_state* state = | |
| 1771 | 1771 | running_device* pic = state->pic_slave; |
| 1772 | 1772 | if(irq) |
| 1773 | 1773 | { |
| r8714 | r8715 | |
| 1786 | 1786 | // PCM interrupt (IRQ 13) |
| 1787 | 1787 | void towns_pcm_irq(running_device* device, int channel) |
| 1788 | 1788 | { |
| 1789 | towns_state* state = | |
| 1789 | towns_state* state = | |
| 1790 | 1790 | running_device* pic = state->pic_slave; |
| 1791 | 1791 | |
| 1792 | 1792 | state->towns_pcm_irq_flag = 1; |
| r8714 | r8715 | |
| 1806 | 1806 | |
| 1807 | 1807 | static WRITE_LINE_DEVICE_HANDLER( towns_pit_out0_changed ) |
| 1808 | 1808 | { |
| 1809 | towns_state* tstate = | |
| 1809 | towns_state* tstate = | |
| 1810 | 1810 | running_device* dev = tstate->pic_master; |
| 1811 | 1811 | |
| 1812 | 1812 | if(tstate->towns_timer_mask & 0x01) |
| r8714 | r8715 | |
| 1818 | 1818 | |
| 1819 | 1819 | static WRITE_LINE_DEVICE_HANDLER( towns_pit_out1_changed ) |
| 1820 | 1820 | { |
| 1821 | towns_state* tstate = | |
| 1821 | towns_state* tstate = | |
| 1822 | 1822 | // running_device* dev = tstate->pic_master; |
| 1823 | 1823 | |
| 1824 | 1824 | if(tstate->towns_timer_mask & 0x02) |
| r8714 | r8715 | |
| 2144 | 2144 | |
| 2145 | 2145 | static DRIVER_INIT( towns ) |
| 2146 | 2146 | { |
| 2147 | towns_state* state = | |
| 2147 | towns_state* state = | |
| 2148 | 2148 | state->pic_master = machine->device("pic8259_master"); |
| 2149 | 2149 | state->pic_slave = machine->device("pic8259_slave"); |
| 2150 | 2150 | state->towns_vram = auto_alloc_array(machine,UINT32,0x20000); |
| r8714 | r8715 | |
| 2167 | 2167 | |
| 2168 | 2168 | static DRIVER_INIT( marty ) |
| 2169 | 2169 | { |
| 2170 | towns_state* state = | |
| 2170 | towns_state* state = | |
| 2171 | 2171 | DRIVER_INIT_CALL(towns); |
| 2172 | 2172 | state->towns_machine_id = 0x034a; |
| 2173 | 2173 | } |
| 2174 | 2174 | |
| 2175 | 2175 | static MACHINE_RESET( towns ) |
| 2176 | 2176 | { |
| 2177 | towns_state* state = | |
| 2177 | towns_state* state = | |
| 2178 | 2178 | state->maincpu = machine->device("maincpu"); |
| 2179 | 2179 | state->dma_1 = machine->device("dma_1"); |
| 2180 | 2180 | state->dma_2 = machine->device("dma_2"); |
| r8714 | r8715 | |
|---|---|---|
| 63 | 63 | |
| 64 | 64 | static void check_interrupt(running_machine *machine) |
| 65 | 65 | { |
| 66 | newbrain_state *state = | |
| 66 | newbrain_state *state = | |
| 67 | 67 | |
| 68 | 68 | int level = (!state->clkint || !state->copint) ? ASSERT_LINE : CLEAR_LINE; |
| 69 | 69 | |
| r8714 | r8715 | |
| 84 | 84 | |
| 85 | 85 | static void newbrain_eim_bankswitch(running_machine *machine) |
| 86 | 86 | { |
| 87 | newbrain_state *state = | |
| 87 | newbrain_state *state = | |
| 88 | 88 | |
| 89 | 89 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 90 | 90 | int bank; |
| r8714 | r8715 | |
| 124 | 124 | |
| 125 | 125 | static void newbrain_a_bankswitch(running_machine *machine) |
| 126 | 126 | { |
| 127 | newbrain_state *state = | |
| 127 | newbrain_state *state = | |
| 128 | 128 | |
| 129 | 129 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 130 | 130 | int bank; |
| r8714 | r8715 | |
| 228 | 228 | |
| 229 | 229 | */ |
| 230 | 230 | |
| 231 | newbrain_state *state = | |
| 231 | newbrain_state *state = | |
| 232 | 232 | |
| 233 | 233 | state->enrg1 = data; |
| 234 | 234 | } |
| r8714 | r8715 | |
| 250 | 250 | |
| 251 | 251 | */ |
| 252 | 252 | |
| 253 | newbrain_state *state = | |
| 253 | newbrain_state *state = | |
| 254 | 254 | |
| 255 | 255 | state->enrg1 = data; |
| 256 | 256 | } |
| r8714 | r8715 | |
| 273 | 273 | |
| 274 | 274 | */ |
| 275 | 275 | |
| 276 | newbrain_state *state = | |
| 276 | newbrain_state *state = | |
| 277 | 277 | |
| 278 | 278 | UINT8 data = (state->copint << 7) | (state->aciaint << 6) | (state->clkint << 5) | (state->userint << 4) | 0x04; |
| 279 | 279 | |
| r8714 | r8715 | |
| 357 | 357 | |
| 358 | 358 | */ |
| 359 | 359 | |
| 360 | newbrain_state *state = | |
| 360 | newbrain_state *state = | |
| 361 | 361 | |
| 362 | 362 | return (state->copint << 7) | (state->clkint << 5) | (state->pwrup << 1) | 0x01; |
| 363 | 363 | } |
| r8714 | r8715 | |
| 379 | 379 | |
| 380 | 380 | */ |
| 381 | 381 | |
| 382 | newbrain_state *state = | |
| 382 | newbrain_state *state = | |
| 383 | 383 | |
| 384 | 384 | state->user = 0; |
| 385 | 385 | |
| r8714 | r8715 | |
| 388 | 388 | |
| 389 | 389 | static WRITE8_HANDLER( user_w ) |
| 390 | 390 | { |
| 391 | newbrain_state *state = | |
| 391 | newbrain_state *state = | |
| 392 | 392 | |
| 393 | 393 | state->user = data; |
| 394 | 394 | } |
| r8714 | r8715 | |
| 397 | 397 | |
| 398 | 398 | static READ8_HANDLER( clclk_r ) |
| 399 | 399 | { |
| 400 | newbrain_state *state = | |
| 400 | newbrain_state *state = | |
| 401 | 401 | |
| 402 | 402 | state->clkint = 1; |
| 403 | 403 | check_interrupt(space->machine); |
| r8714 | r8715 | |
| 407 | 407 | |
| 408 | 408 | static WRITE8_HANDLER( clclk_w ) |
| 409 | 409 | { |
| 410 | newbrain_state *state = | |
| 410 | newbrain_state *state = | |
| 411 | 411 | |
| 412 | 412 | state->clkint = 1; |
| 413 | 413 | check_interrupt(space->machine); |
| r8714 | r8715 | |
| 415 | 415 | |
| 416 | 416 | static READ8_HANDLER( clusr_r ) |
| 417 | 417 | { |
| 418 | newbrain_state *state = | |
| 418 | newbrain_state *state = | |
| 419 | 419 | |
| 420 | 420 | state->userint = 1; |
| 421 | 421 | |
| r8714 | r8715 | |
| 424 | 424 | |
| 425 | 425 | static WRITE8_HANDLER( clusr_w ) |
| 426 | 426 | { |
| 427 | newbrain_state *state = | |
| 427 | newbrain_state *state = | |
| 428 | 428 | |
| 429 | 429 | state->userint = 1; |
| 430 | 430 | } |
| r8714 | r8715 | |
| 435 | 435 | { |
| 436 | 436 | // connected to the Z80 data bus |
| 437 | 437 | |
| 438 | newbrain_state *state = | |
| 438 | newbrain_state *state = | |
| 439 | 439 | |
| 440 | 440 | return state->cop_bus; |
| 441 | 441 | } |
| r8714 | r8715 | |
| 444 | 444 | { |
| 445 | 445 | // connected to the Z80 data bus |
| 446 | 446 | |
| 447 | newbrain_state *state = | |
| 447 | newbrain_state *state = | |
| 448 | 448 | |
| 449 | 449 | state->cop_bus = data; |
| 450 | 450 | } |
| r8714 | r8715 | |
| 462 | 462 | |
| 463 | 463 | */ |
| 464 | 464 | |
| 465 | newbrain_state *state = | |
| 465 | newbrain_state *state = | |
| 466 | 466 | |
| 467 | 467 | state->copint = BIT(data, 0); |
| 468 | 468 | check_interrupt(space->machine); |
| r8714 | r8715 | |
| 486 | 486 | |
| 487 | 487 | */ |
| 488 | 488 | |
| 489 | newbrain_state *state = | |
| 489 | newbrain_state *state = | |
| 490 | 490 | |
| 491 | 491 | return (BIT(state->keydata, 3) << 3) | (BIT(state->keydata, 0) << 2) | (BIT(state->keydata, 1) << 1); |
| 492 | 492 | } |
| r8714 | r8715 | |
| 504 | 504 | |
| 505 | 505 | */ |
| 506 | 506 | |
| 507 | newbrain_state *state = | |
| 507 | newbrain_state *state = | |
| 508 | 508 | |
| 509 | 509 | static const char *const keynames[] = { |
| 510 | 510 | "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", |
| r8714 | r8715 | |
| 555 | 555 | |
| 556 | 556 | */ |
| 557 | 557 | |
| 558 | newbrain_state *state = | |
| 558 | newbrain_state *state = | |
| 559 | 559 | |
| 560 | 560 | return (state->cop_wr << 3) | (state->cop_access << 2) | (state->cop_rd << 1) | BIT(state->keydata, 2); |
| 561 | 561 | } |
| r8714 | r8715 | |
| 564 | 564 | { |
| 565 | 565 | // connected to K1 |
| 566 | 566 | |
| 567 | newbrain_state *state = | |
| 567 | newbrain_state *state = | |
| 568 | 568 | |
| 569 | 569 | state->cop_so = data; |
| 570 | 570 | } |
| r8714 | r8715 | |
| 573 | 573 | { |
| 574 | 574 | // connected to K2 |
| 575 | 575 | |
| 576 | newbrain_state *state = | |
| 576 | newbrain_state *state = | |
| 577 | 577 | |
| 578 | 578 | state->segment_data[state->keylatch] >>= 1; |
| 579 | 579 | state->segment_data[state->keylatch] = (state->cop_so << 15) | (state->segment_data[state->keylatch] & 0x7fff); |
| r8714 | r8715 | |
| 583 | 583 | { |
| 584 | 584 | // connected to TDI |
| 585 | 585 | |
| 586 | newbrain_state *state = | |
| 586 | newbrain_state *state = | |
| 587 | 587 | |
| 588 | 588 | state->cop_tdi = ((cassette_input(state->cassette1) > +1.0) || (cassette_input(state->cassette2) > +1.0)) ^ state->cop_tdo; |
| 589 | 589 | |
| r8714 | r8715 | |
| 594 | 594 | |
| 595 | 595 | static void newbrain_tvram_w(running_machine *machine, UINT8 data, int a6) |
| 596 | 596 | { |
| 597 | newbrain_state *state = | |
| 597 | newbrain_state *state = | |
| 598 | 598 | |
| 599 | 599 | /* latch video address counter bits A5-A0 */ |
| 600 | 600 | state->tvram = (state->tvctl & NEWBRAIN_VIDEO_80L) ? 0x04 : 0x02; |
| r8714 | r8715 | |
| 637 | 637 | |
| 638 | 638 | */ |
| 639 | 639 | |
| 640 | newbrain_state *state = | |
| 640 | newbrain_state *state = | |
| 641 | 641 | |
| 642 | 642 | state->tvctl = data; |
| 643 | 643 | } |
| r8714 | r8715 | |
| 661 | 661 | |
| 662 | 662 | */ |
| 663 | 663 | |
| 664 | newbrain_state *state = | |
| 664 | newbrain_state *state = | |
| 665 | 665 | |
| 666 | 666 | floppy_mon_w(floppy_get_device(space->machine, 0), !BIT(data, 0)); |
| 667 | 667 | floppy_drive_set_ready_state(floppy_get_device(space->machine, 0), 1, 0); |
| r8714 | r8715 | |
| 688 | 688 | |
| 689 | 689 | */ |
| 690 | 690 | |
| 691 | newbrain_state *state = | |
| 691 | newbrain_state *state = | |
| 692 | 692 | |
| 693 | 693 | return (state->fdc_att << 7) | (state->paging << 6) | (state->fdc_int << 5); |
| 694 | 694 | } |
| r8714 | r8715 | |
| 748 | 748 | |
| 749 | 749 | static READ8_HANDLER( cop_r ) |
| 750 | 750 | { |
| 751 | newbrain_state *state = | |
| 751 | newbrain_state *state = | |
| 752 | 752 | |
| 753 | 753 | state->copint = 1; |
| 754 | 754 | check_interrupt(space->machine); |
| r8714 | r8715 | |
| 758 | 758 | |
| 759 | 759 | static WRITE8_HANDLER( cop_w ) |
| 760 | 760 | { |
| 761 | newbrain_state *state = | |
| 761 | newbrain_state *state = | |
| 762 | 762 | |
| 763 | 763 | copdata = data; |
| 764 | 764 | |
| r8714 | r8715 | |
| 823 | 823 | |
| 824 | 824 | static TIMER_DEVICE_CALLBACK( cop_regint_tick ) |
| 825 | 825 | { |
| 826 | newbrain_state *state = | |
| 826 | newbrain_state *state = | |
| 827 | 827 | |
| 828 | 828 | if (copregint) |
| 829 | 829 | { |
| r8714 | r8715 | |
| 852 | 852 | |
| 853 | 853 | */ |
| 854 | 854 | |
| 855 | newbrain_state *state = | |
| 855 | newbrain_state *state = | |
| 856 | 856 | |
| 857 | 857 | state->enrg2 = data; |
| 858 | 858 | } |
| r8714 | r8715 | |
| 877 | 877 | |
| 878 | 878 | */ |
| 879 | 879 | |
| 880 | newbrain_state *state = | |
| 880 | newbrain_state *state = | |
| 881 | 881 | |
| 882 | 882 | int page = (BIT(offset, 12) >> 9) | (BIT(offset, 15) >> 13) | (BIT(offset, 14) >> 13) | (BIT(offset, 13) >> 13); |
| 883 | 883 | int bank = (BIT(offset, 11) >> 3) | (data & 0x7f); |
| r8714 | r8715 | |
| 889 | 889 | |
| 890 | 890 | static READ8_HANDLER( ei_user_r ) |
| 891 | 891 | { |
| 892 | newbrain_state *state = | |
| 892 | newbrain_state *state = | |
| 893 | 893 | |
| 894 | 894 | state->user = 0xff; |
| 895 | 895 | |
| r8714 | r8715 | |
| 898 | 898 | |
| 899 | 899 | static WRITE8_HANDLER( ei_user_w ) |
| 900 | 900 | { |
| 901 | newbrain_state *state = | |
| 901 | newbrain_state *state = | |
| 902 | 902 | |
| 903 | 903 | state->user = data; |
| 904 | 904 | } |
| r8714 | r8715 | |
| 941 | 941 | |
| 942 | 942 | */ |
| 943 | 943 | |
| 944 | newbrain_state *state = | |
| 944 | newbrain_state *state = | |
| 945 | 945 | |
| 946 | 946 | return (state->copint << 7) | (state->aciaint << 6) | (state->clkint << 5) | (state->userint << 4) | (state->userint0 << 3) | (state->pwrup) << 1 | 0x01; |
| 947 | 947 | } |
| r8714 | r8715 | |
| 963 | 963 | |
| 964 | 964 | */ |
| 965 | 965 | |
| 966 | newbrain_state *state = | |
| 966 | newbrain_state *state = | |
| 967 | 967 | |
| 968 | 968 | return (state->tvcnsl << 6) | 0x10 | 0x08 | 0x04; |
| 969 | 969 | } |
| r8714 | r8715 | |
| 999 | 999 | |
| 1000 | 1000 | static WRITE8_HANDLER( ei_paging_w ) |
| 1001 | 1001 | { |
| 1002 | newbrain_state *state = | |
| 1002 | newbrain_state *state = | |
| 1003 | 1003 | |
| 1004 | 1004 | if (BIT(offset, 8)) |
| 1005 | 1005 | { |
| r8714 | r8715 | |
| 1060 | 1060 | |
| 1061 | 1061 | static ADC080X_ON_EOC_CHANGED( newbrain_adc_on_eoc_changed ) |
| 1062 | 1062 | { |
| 1063 | newbrain_state *state = | |
| 1063 | newbrain_state *state = | |
| 1064 | 1064 | |
| 1065 | 1065 | state->anint = level; |
| 1066 | 1066 | } |
| r8714 | r8715 | |
| 1266 | 1266 | |
| 1267 | 1267 | static READ_LINE_DEVICE_HANDLER( acia_rx ) |
| 1268 | 1268 | { |
| 1269 | newbrain_state *driver_state = | |
| 1269 | newbrain_state *driver_state = | |
| 1270 | 1270 | |
| 1271 | 1271 | return driver_state->acia_rxd; |
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | static WRITE_LINE_DEVICE_HANDLER( acia_tx ) |
| 1275 | 1275 | { |
| 1276 | newbrain_state *driver_state = | |
| 1276 | newbrain_state *driver_state = | |
| 1277 | 1277 | |
| 1278 | 1278 | driver_state->acia_txd = state; |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | static WRITE_LINE_DEVICE_HANDLER( acia_interrupt ) |
| 1282 | 1282 | { |
| 1283 | newbrain_state *driver_state = | |
| 1283 | newbrain_state *driver_state = | |
| 1284 | 1284 | |
| 1285 | 1285 | driver_state->aciaint = state; |
| 1286 | 1286 | } |
| r8714 | r8715 | |
| 1299 | 1299 | |
| 1300 | 1300 | static WRITE_LINE_DEVICE_HANDLER( newbrain_fdc_interrupt ) |
| 1301 | 1301 | { |
| 1302 | newbrain_state *driver_state = | |
| 1302 | newbrain_state *driver_state = | |
| 1303 | 1303 | |
| 1304 | 1304 | driver_state->fdc_int = state; |
| 1305 | 1305 | } |
| r8714 | r8715 | |
| 1315 | 1315 | |
| 1316 | 1316 | static WRITE_LINE_DEVICE_HANDLER( ctc_z0_w ) |
| 1317 | 1317 | { |
| 1318 | newbrain_state *driver_state = | |
| 1318 | newbrain_state *driver_state = | |
| 1319 | 1319 | |
| 1320 | 1320 | /* connected to the ACIA receive clock */ |
| 1321 | 1321 | if (state) acia6850_rx_clock_in(driver_state->mc6850); |
| r8714 | r8715 | |
| 1323 | 1323 | |
| 1324 | 1324 | static WRITE_LINE_DEVICE_HANDLER( ctc_z1_w ) |
| 1325 | 1325 | { |
| 1326 | newbrain_state *driver_state = | |
| 1326 | newbrain_state *driver_state = | |
| 1327 | 1327 | |
| 1328 | 1328 | /* connected to the ACIA transmit clock */ |
| 1329 | 1329 | if (state) acia6850_tx_clock_in(driver_state->mc6850); |
| r8714 | r8715 | |
| 1331 | 1331 | |
| 1332 | 1332 | static WRITE_LINE_DEVICE_HANDLER( ctc_z2_w ) |
| 1333 | 1333 | { |
| 1334 | newbrain_state *driver_state = | |
| 1334 | newbrain_state *driver_state = | |
| 1335 | 1335 | |
| 1336 | 1336 | /* connected to CTC channel 0/1 clock inputs */ |
| 1337 | 1337 | z80ctc_trg0_w(driver_state->z80ctc, state); |
| r8714 | r8715 | |
| 1349 | 1349 | |
| 1350 | 1350 | static TIMER_DEVICE_CALLBACK( ctc_c2_tick ) |
| 1351 | 1351 | { |
| 1352 | newbrain_state *state = | |
| 1352 | newbrain_state *state = | |
| 1353 | 1353 | |
| 1354 | 1354 | z80ctc_trg2_w(state->z80ctc, 1); |
| 1355 | 1355 | z80ctc_trg2_w(state->z80ctc, 0); |
| r8714 | r8715 | |
| 1373 | 1373 | |
| 1374 | 1374 | static TIMER_CALLBACK( pwrup_tick ) |
| 1375 | 1375 | { |
| 1376 | newbrain_state *state = | |
| 1376 | newbrain_state *state = | |
| 1377 | 1377 | |
| 1378 | 1378 | state->pwrup = 0; |
| 1379 | 1379 | newbrain_a_bankswitch(machine); |
| r8714 | r8715 | |
| 1381 | 1381 | |
| 1382 | 1382 | static MACHINE_START( newbrain ) |
| 1383 | 1383 | { |
| 1384 | newbrain_state *state = | |
| 1384 | newbrain_state *state = | |
| 1385 | 1385 | |
| 1386 | 1386 | /* find devices */ |
| 1387 | 1387 | state->cassette1 = machine->device(CASSETTE1_TAG); |
| r8714 | r8715 | |
| 1439 | 1439 | |
| 1440 | 1440 | static MACHINE_START( newbrain_eim ) |
| 1441 | 1441 | { |
| 1442 | newbrain_state *state = | |
| 1442 | newbrain_state *state = | |
| 1443 | 1443 | |
| 1444 | 1444 | MACHINE_START_CALL(newbrain); |
| 1445 | 1445 | |
| r8714 | r8715 | |
| 1457 | 1457 | |
| 1458 | 1458 | static MACHINE_RESET( newbrain ) |
| 1459 | 1459 | { |
| 1460 | newbrain_state *state = | |
| 1460 | newbrain_state *state = | |
| 1461 | 1461 | |
| 1462 | 1462 | cputag_set_input_line(machine, Z80_TAG, INPUT_LINE_RESET, HOLD_LINE); |
| 1463 | 1463 | cputag_set_input_line(machine, COP420_TAG, INPUT_LINE_RESET, HOLD_LINE); |
| r8714 | r8715 | |
| 1467 | 1467 | |
| 1468 | 1468 | static INTERRUPT_GEN( newbrain_interrupt ) |
| 1469 | 1469 | { |
| 1470 | newbrain_state *state = | |
| 1470 | newbrain_state *state = | |
| 1471 | 1471 | |
| 1472 | 1472 | if (!(state->enrg1 & NEWBRAIN_ENRG1_CLK)) |
| 1473 | 1473 | { |
| r8714 | r8715 | |
|---|---|---|
| 74 | 74 | */ |
| 75 | 75 | static WRITE8_HANDLER( einstein_80col_ram_w ) |
| 76 | 76 | { |
| 77 | einstein_state *einstein = | |
| 77 | einstein_state *einstein = | |
| 78 | 78 | einstein->crtc_ram[((offset & 0x07) << 8) | ((offset >> 8) & 0xff)] = data; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | static READ8_HANDLER( einstein_80col_ram_r ) |
| 82 | 82 | { |
| 83 | einstein_state *einstein = | |
| 83 | einstein_state *einstein = | |
| 84 | 84 | return einstein->crtc_ram[((offset & 0x07) << 8) | ((offset >> 8) & 0xff)]; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /* TODO: Verify implementation */ |
| 88 | 88 | static MC6845_UPDATE_ROW( einstein_6845_update_row ) |
| 89 | 89 | { |
| 90 | einstein_state *einstein = | |
| 90 | einstein_state *einstein = | |
| 91 | 91 | UINT8 *data = memory_region(device->machine, "gfx1"); |
| 92 | 92 | UINT8 char_code, data_byte; |
| 93 | 93 | int i, x; |
| r8714 | r8715 | |
| 114 | 114 | */ |
| 115 | 115 | static READ8_HANDLER( einstein_80col_state_r ) |
| 116 | 116 | { |
| 117 | einstein_state *einstein = | |
| 117 | einstein_state *einstein = | |
| 118 | 118 | UINT8 result = 0; |
| 119 | 119 | |
| 120 | 120 | result |= einstein->crtc_screen->vblank(); |
| r8714 | r8715 | |
| 145 | 145 | /* refresh keyboard data. It is refreshed when the keyboard line is written */ |
| 146 | 146 | static void einstein_scan_keyboard(running_machine *machine) |
| 147 | 147 | { |
| 148 | einstein_state *einstein = | |
| 148 | einstein_state *einstein = | |
| 149 | 149 | UINT8 data = 0xff; |
| 150 | 150 | |
| 151 | 151 | if (!BIT(einstein->keyboard_line, 0)) data &= input_port_read(machine, "LINE0"); |
| r8714 | r8715 | |
| 162 | 162 | |
| 163 | 163 | static TIMER_DEVICE_CALLBACK( einstein_keyboard_timer_callback ) |
| 164 | 164 | { |
| 165 | einstein_state *einstein = | |
| 165 | einstein_state *einstein = | |
| 166 | 166 | |
| 167 | 167 | /* re-scan keyboard */ |
| 168 | 168 | einstein_scan_keyboard(timer.machine); |
| r8714 | r8715 | |
| 183 | 183 | |
| 184 | 184 | static WRITE8_HANDLER( einstein_keyboard_line_write ) |
| 185 | 185 | { |
| 186 | einstein_state *einstein = | |
| 186 | einstein_state *einstein = | |
| 187 | 187 | |
| 188 | 188 | logerror("einstein_keyboard_line_write: %02x\n", data); |
| 189 | 189 | |
| r8714 | r8715 | |
| 195 | 195 | |
| 196 | 196 | static READ8_HANDLER( einstein_keyboard_data_read ) |
| 197 | 197 | { |
| 198 | einstein_state *einstein = | |
| 198 | einstein_state *einstein = | |
| 199 | 199 | |
| 200 | 200 | /* re-scan the keyboard */ |
| 201 | 201 | einstein_scan_keyboard(space->machine); |
| r8714 | r8715 | |
| 236 | 236 | /* channel 0 and 1 have a 2 MHz input clock for triggering */ |
| 237 | 237 | static TIMER_DEVICE_CALLBACK( einstein_ctc_trigger_callback ) |
| 238 | 238 | { |
| 239 | einstein_state *einstein = | |
| 239 | einstein_state *einstein = | |
| 240 | 240 | |
| 241 | 241 | /* toggle line status */ |
| 242 | 242 | einstein->ctc_trigger ^= 1; |
| r8714 | r8715 | |
| 269 | 269 | |
| 270 | 270 | static void einstein_page_rom(running_machine *machine) |
| 271 | 271 | { |
| 272 | einstein_state *einstein = | |
| 272 | einstein_state *einstein = | |
| 273 | 273 | memory_set_bankptr(machine, "bank1", einstein->rom_enabled ? memory_region(machine, "bios") : messram_get_ptr(machine->device("messram"))); |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /* writing to this port is a simple trigger, and switches between RAM and ROM */ |
| 277 | 277 | static WRITE8_HANDLER( einstein_rom_w ) |
| 278 | 278 | { |
| 279 | einstein_state *einstein = | |
| 279 | einstein_state *einstein = | |
| 280 | 280 | einstein->rom_enabled ^= 1; |
| 281 | 281 | einstein_page_rom(space->machine); |
| 282 | 282 | } |
| r8714 | r8715 | |
| 289 | 289 | static READ8_HANDLER( einstein_kybintmsk_r ) |
| 290 | 290 | { |
| 291 | 291 | running_device *printer = space->machine->device("centronics"); |
| 292 | einstein_state *einstein = | |
| 292 | einstein_state *einstein = | |
| 293 | 293 | UINT8 data = 0; |
| 294 | 294 | |
| 295 | 295 | /* clear key int. a read of this I/O port will do this or a reset */ |
| r8714 | r8715 | |
| 313 | 313 | |
| 314 | 314 | static WRITE8_HANDLER( einstein_kybintmsk_w ) |
| 315 | 315 | { |
| 316 | einstein_state *einstein = | |
| 316 | einstein_state *einstein = | |
| 317 | 317 | |
| 318 | 318 | logerror("%s: einstein_kybintmsk_w %02x\n", cpuexec_describe_context(space->machine), data); |
| 319 | 319 | |
| r8714 | r8715 | |
| 334 | 334 | /* writing 0 enables the /ADC interrupt */ |
| 335 | 335 | static WRITE8_HANDLER( einstein_adcintmsk_w ) |
| 336 | 336 | { |
| 337 | einstein_state *einstein = | |
| 337 | einstein_state *einstein = | |
| 338 | 338 | |
| 339 | 339 | logerror("%s: einstein_adcintmsk_w %02x\n", cpuexec_describe_context(space->machine), data); |
| 340 | 340 | |
| r8714 | r8715 | |
| 354 | 354 | /* writing 0 enables the /FIRE interrupt */ |
| 355 | 355 | static WRITE8_HANDLER( einstein_fire_int_w ) |
| 356 | 356 | { |
| 357 | einstein_state *einstein = | |
| 357 | einstein_state *einstein = | |
| 358 | 358 | |
| 359 | 359 | logerror("%s: einstein_fire_int_w %02x\n", cpuexec_describe_context(space->machine), data); |
| 360 | 360 | |
| r8714 | r8715 | |
| 390 | 390 | |
| 391 | 391 | static MACHINE_RESET( einstein ) |
| 392 | 392 | { |
| 393 | einstein_state *einstein = | |
| 393 | einstein_state *einstein = | |
| 394 | 394 | running_device *floppy; |
| 395 | 395 | UINT8 config = input_port_read(machine, "config"); |
| 396 | 396 | |
| r8714 | r8715 | |
| 428 | 428 | |
| 429 | 429 | static MACHINE_RESET( einstein2 ) |
| 430 | 430 | { |
| 431 | einstein_state *einstein = | |
| 431 | einstein_state *einstein = | |
| 432 | 432 | |
| 433 | 433 | /* call standard initialization first */ |
| 434 | 434 | MACHINE_RESET_CALL(einstein); |
| r8714 | r8715 | |
| 443 | 443 | } |
| 444 | 444 | static MACHINE_START( einstein2 ) |
| 445 | 445 | { |
| 446 | einstein_state *einstein = | |
| 446 | einstein_state *einstein = | |
| 447 | 447 | einstein->crtc_ram = auto_alloc_array(machine, UINT8, 2048); |
| 448 | 448 | MACHINE_START_CALL(einstein); |
| 449 | 449 | } |
| r8714 | r8715 | |
| 455 | 455 | |
| 456 | 456 | static VIDEO_UPDATE( einstein2 ) |
| 457 | 457 | { |
| 458 | einstein_state *einstein = | |
| 458 | einstein_state *einstein = | |
| 459 | 459 | |
| 460 | 460 | if (screen == einstein->color_screen) |
| 461 | 461 | VIDEO_UPDATE_CALL(tms9928a); |
| r8714 | r8715 | |
|---|---|---|
| 46 | 46 | UINT16 BKCOL; |
| 47 | 47 | }; |
| 48 | 48 | |
| 49 | class vboy_state | |
| 49 | class vboy_state : public driver_data_t | |
| 50 | 50 | { |
| 51 | 51 | public: |
| 52 | static | |
| 52 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vboy_state(machine)); } | |
| 53 | 53 | |
| 54 | vboy_state(running_machine &machine) { } | |
| 54 | vboy_state(running_machine &machine) | |
| 55 | : driver_data_t(machine) { } | |
| 55 | 56 | |
| 56 | 57 | UINT16 *font; |
| 57 | 58 | UINT16 *bgmap; |
| r8714 | r8715 | |
| 71 | 72 | |
| 72 | 73 | static READ32_HANDLER( port_02_read ) |
| 73 | 74 | { |
| 74 | vboy_state *state = | |
| 75 | vboy_state *state = | |
| 75 | 76 | UINT32 value = 0x00; |
| 76 | 77 | |
| 77 | 78 | switch ((offset << 2)) |
| r8714 | r8715 | |
| 106 | 107 | |
| 107 | 108 | static WRITE32_HANDLER( port_02_write ) |
| 108 | 109 | { |
| 109 | vboy_state *state = | |
| 110 | vboy_state *state = | |
| 110 | 111 | |
| 111 | 112 | switch (offset<<2) |
| 112 | 113 | { |
| r8714 | r8715 | |
| 147 | 148 | |
| 148 | 149 | static READ16_HANDLER( vip_r ) |
| 149 | 150 | { |
| 150 | vboy_state *state = | |
| 151 | vboy_state *state = | |
| 151 | 152 | |
| 152 | 153 | switch(offset << 1) { |
| 153 | 154 | case 0x00: //INTPND |
| r8714 | r8715 | |
| 214 | 215 | |
| 215 | 216 | static WRITE16_HANDLER( vip_w ) |
| 216 | 217 | { |
| 217 | vboy_state *state = | |
| 218 | vboy_state *state = | |
| 218 | 219 | |
| 219 | 220 | switch(offset << 1) { |
| 220 | 221 | case 0x00: //INTPND |
| r8714 | r8715 | |
| 309 | 310 | |
| 310 | 311 | static WRITE16_HANDLER( vboy_font0_w ) |
| 311 | 312 | { |
| 312 | vboy_state *state = | |
| 313 | vboy_state *state = | |
| 313 | 314 | |
| 314 | 315 | state->font[offset] = data | (state->font[offset] & (mem_mask ^ 0xffff)); |
| 315 | 316 | } |
| 316 | 317 | |
| 317 | 318 | static WRITE16_HANDLER( vboy_font1_w ) |
| 318 | 319 | { |
| 319 | vboy_state *state = | |
| 320 | vboy_state *state = | |
| 320 | 321 | |
| 321 | 322 | state->font[offset + 0x1000] = data | (state->font[offset + 0x1000] & (mem_mask ^ 0xffff)); |
| 322 | 323 | } |
| 323 | 324 | |
| 324 | 325 | static WRITE16_HANDLER( vboy_font2_w ) |
| 325 | 326 | { |
| 326 | vboy_state *state = | |
| 327 | vboy_state *state = | |
| 327 | 328 | |
| 328 | 329 | state->font[offset + 0x2000] = data | (state->font[offset + 0x2000] & (mem_mask ^ 0xffff)); |
| 329 | 330 | } |
| 330 | 331 | |
| 331 | 332 | static WRITE16_HANDLER( vboy_font3_w ) |
| 332 | 333 | { |
| 333 | vboy_state *state = | |
| 334 | vboy_state *state = | |
| 334 | 335 | |
| 335 | 336 | state->font[offset + 0x3000] = data | (state->font[offset + 0x3000] & (mem_mask ^ 0xffff)); |
| 336 | 337 | } |
| 337 | 338 | |
| 338 | 339 | static READ16_HANDLER( vboy_font0_r ) |
| 339 | 340 | { |
| 340 | vboy_state *state = | |
| 341 | vboy_state *state = | |
| 341 | 342 | |
| 342 | 343 | return state->font[offset]; |
| 343 | 344 | } |
| 344 | 345 | |
| 345 | 346 | static READ16_HANDLER( vboy_font1_r ) |
| 346 | 347 | { |
| 347 | vboy_state *state = | |
| 348 | vboy_state *state = | |
| 348 | 349 | |
| 349 | 350 | return state->font[offset + 0x1000]; |
| 350 | 351 | } |
| 351 | 352 | |
| 352 | 353 | static READ16_HANDLER( vboy_font2_r ) |
| 353 | 354 | { |
| 354 | vboy_state *state = | |
| 355 | vboy_state *state = | |
| 355 | 356 | |
| 356 | 357 | return state->font[offset + 0x2000]; |
| 357 | 358 | } |
| 358 | 359 | |
| 359 | 360 | static READ16_HANDLER( vboy_font3_r ) |
| 360 | 361 | { |
| 361 | vboy_state *state = | |
| 362 | vboy_state *state = | |
| 362 | 363 | |
| 363 | 364 | return state->font[offset + 0x3000]; |
| 364 | 365 | } |
| r8714 | r8715 | |
| 397 | 398 | |
| 398 | 399 | static WRITE16_HANDLER( vboy_bgmap_w ) |
| 399 | 400 | { |
| 400 | vboy_state *state = | |
| 401 | vboy_state *state = | |
| 401 | 402 | |
| 402 | 403 | state->bgmap[offset] = data | (state->bgmap[offset] & (mem_mask ^ 0xffff)); |
| 403 | 404 | } |
| 404 | 405 | |
| 405 | 406 | static READ16_HANDLER( vboy_bgmap_r ) |
| 406 | 407 | { |
| 407 | vboy_state *state = | |
| 408 | vboy_state *state = | |
| 408 | 409 | |
| 409 | 410 | return state->bgmap[offset]; |
| 410 | 411 | } |
| r8714 | r8715 | |
| 491 | 492 | |
| 492 | 493 | static MACHINE_RESET(vboy) |
| 493 | 494 | { |
| 494 | vboy_state *state = | |
| 495 | vboy_state *state = | |
| 495 | 496 | |
| 496 | 497 | /* Initial values taken from Reality Boy, to be verified when emulation improves */ |
| 497 | 498 | state->vboy_regs.lpc = 0x6d; |
| r8714 | r8715 | |
| 510 | 511 | |
| 511 | 512 | static VIDEO_START( vboy ) |
| 512 | 513 | { |
| 513 | vboy_state *state = | |
| 514 | vboy_state *state = | |
| 514 | 515 | int i; |
| 515 | 516 | |
| 516 | 517 | // Allocate memory for temporary screens |
| r8714 | r8715 | |
| 632 | 633 | |
| 633 | 634 | static VIDEO_UPDATE( vboy ) |
| 634 | 635 | { |
| 635 | vboy_state *state = | |
| 636 | vboy_state *state = | |
| 636 | 637 | int i; |
| 637 | 638 | UINT8 right = 0; |
| 638 | 639 | running_device *_3d_right_screen = screen->machine->device("3dright"); |
| r8714 | r8715 | |
| 652 | 653 | |
| 653 | 654 | static TIMER_DEVICE_CALLBACK( video_tick ) |
| 654 | 655 | { |
| 655 | vboy_state *state = | |
| 656 | vboy_state *state = | |
| 656 | 657 | |
| 657 | 658 | state->vip_regs.XPSTTS = (state->vip_regs.XPSTTS==0) ? 0x0c : 0x00; |
| 658 | 659 | } |
| r8714 | r8715 | |
|---|---|---|
| 13 | 13 | #include "machine/msm8251.h" |
| 14 | 14 | #include "devices/messram.h" |
| 15 | 15 | |
| 16 | class fk1_state | |
| 16 | class fk1_state : public driver_data_t | |
| 17 | 17 | { |
| 18 | 18 | public: |
| 19 | static | |
| 19 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, fk1_state(machine)); } | |
| 20 | 20 | |
| 21 | fk1_state(running_machine &machine) { } | |
| 21 | fk1_state(running_machine &machine) | |
| 22 | : driver_data_t(machine) { } | |
| 22 | 23 | |
| 23 | 24 | UINT8 video_rol; |
| 24 | 25 | UINT8 int_vector; |
| r8714 | r8715 | |
| 165 | 166 | } |
| 166 | 167 | static WRITE8_DEVICE_HANDLER (fk1_ppi_3_b_w ) |
| 167 | 168 | { |
| 168 | fk1_state *state = | |
| 169 | fk1_state *state = | |
| 169 | 170 | |
| 170 | 171 | state->video_rol = data; |
| 171 | 172 | } |
| r8714 | r8715 | |
| 181 | 182 | } |
| 182 | 183 | static READ8_DEVICE_HANDLER (fk1_ppi_3_b_r ) |
| 183 | 184 | { |
| 184 | fk1_state *state = | |
| 185 | fk1_state *state = | |
| 185 | 186 | |
| 186 | 187 | return state->video_rol; |
| 187 | 188 | } |
| r8714 | r8715 | |
| 341 | 342 | |
| 342 | 343 | static TIMER_CALLBACK(keyboard_callback) |
| 343 | 344 | { |
| 344 | fk1_state *state = | |
| 345 | fk1_state *state = | |
| 345 | 346 | |
| 346 | 347 | if (input_port_read(machine, "LINE0")) { |
| 347 | 348 | state->int_vector = 6; |
| r8714 | r8715 | |
| 362 | 363 | |
| 363 | 364 | static IRQ_CALLBACK (fk1_irq_callback) |
| 364 | 365 | { |
| 365 | fk1_state *state = | |
| 366 | fk1_state *state = | |
| 366 | 367 | |
| 367 | 368 | logerror("IRQ %02x\n", state->int_vector*2); |
| 368 | 369 | return state->int_vector * 2; |
| r8714 | r8715 | |
| 370 | 371 | |
| 371 | 372 | static TIMER_CALLBACK( vsync_callback ) |
| 372 | 373 | { |
| 373 | fk1_state *state = | |
| 374 | fk1_state *state = | |
| 374 | 375 | |
| 375 | 376 | state->int_vector = 3; |
| 376 | 377 | cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); |
| r8714 | r8715 | |
| 397 | 398 | |
| 398 | 399 | static VIDEO_UPDATE( fk1 ) |
| 399 | 400 | { |
| 400 | fk1_state *state = | |
| 401 | fk1_state *state = | |
| 401 | 402 | UINT8 code; |
| 402 | 403 | int y, x, b; |
| 403 | 404 | UINT8 *ram = messram_get_ptr(screen->machine->device("messram")); |
| r8714 | r8715 | |
|---|---|---|
| 153 | 153 | TYPE DEFINITIONS |
| 154 | 154 | ***************************************************************************/ |
| 155 | 155 | |
| 156 | class vtech1_state | |
| 156 | class vtech1_state : public driver_data_t | |
| 157 | 157 | { |
| 158 | 158 | public: |
| 159 | static | |
| 159 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vtech1_state(machine)); } | |
| 160 | 160 | |
| 161 | vtech1_state(running_machine &machine) { } | |
| 161 | vtech1_state(running_machine &machine) | |
| 162 | : driver_data_t(machine) { } | |
| 162 | 163 | |
| 163 | 164 | /* devices */ |
| 164 | 165 | running_device *mc6847; |
| r8714 | r8715 | |
| 191 | 192 | |
| 192 | 193 | static SNAPSHOT_LOAD( vtech1 ) |
| 193 | 194 | { |
| 194 | vtech1_state *vtech1 = | |
| 195 | vtech1_state *vtech1 = | |
| 195 | 196 | const address_space *space = cputag_get_address_space(image.device().machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 196 | 197 | UINT8 i, header[24]; |
| 197 | 198 | UINT16 start, end, size; |
| r8714 | r8715 | |
| 300 | 301 | ***************************************************************************/ |
| 301 | 302 | static void vtech1_load_proc(device_image_interface &image) |
| 302 | 303 | { |
| 303 | vtech1_state *vtech1 = | |
| 304 | vtech1_state *vtech1 = | |
| 304 | 305 | int id = floppy_get_drive(&image.device()); |
| 305 | 306 | |
| 306 | 307 | if (image.is_writable()) |
| r8714 | r8715 | |
| 311 | 312 | |
| 312 | 313 | static void vtech1_get_track(running_machine *machine) |
| 313 | 314 | { |
| 314 | vtech1_state *vtech1 = | |
| 315 | vtech1_state *vtech1 = | |
| 315 | 316 | device_image_interface *image = dynamic_cast<device_image_interface *>(floppy_get_device(machine,vtech1->drive)); |
| 316 | 317 | |
| 317 | 318 | /* drive selected or and image file ok? */ |
| r8714 | r8715 | |
| 331 | 332 | |
| 332 | 333 | static void vtech1_put_track(running_machine *machine) |
| 333 | 334 | { |
| 334 | vtech1_state *vtech1 = | |
| 335 | vtech1_state *vtech1 = | |
| 335 | 336 | |
| 336 | 337 | |
| 337 | 338 | /* drive selected and image file ok? */ |
| r8714 | r8715 | |
| 349 | 350 | |
| 350 | 351 | static READ8_HANDLER( vtech1_fdc_r ) |
| 351 | 352 | { |
| 352 | vtech1_state *vtech1 = | |
| 353 | vtech1_state *vtech1 = | |
| 353 | 354 | int data = 0xff; |
| 354 | 355 | |
| 355 | 356 | switch (offset) |
| r8714 | r8715 | |
| 397 | 398 | |
| 398 | 399 | static WRITE8_HANDLER( vtech1_fdc_w ) |
| 399 | 400 | { |
| 400 | vtech1_state *vtech1 = | |
| 401 | vtech1_state *vtech1 = | |
| 401 | 402 | int drive; |
| 402 | 403 | |
| 403 | 404 | switch (offset) |
| r8714 | r8715 | |
| 583 | 584 | |
| 584 | 585 | static READ8_HANDLER( vtech1_keyboard_r ) |
| 585 | 586 | { |
| 586 | vtech1_state *vtech1 = | |
| 587 | vtech1_state *vtech1 = | |
| 587 | 588 | UINT8 result = 0x3f; |
| 588 | 589 | |
| 589 | 590 | /* bit 0 to 5, keyboard input */ |
| r8714 | r8715 | |
| 612 | 613 | |
| 613 | 614 | static WRITE8_HANDLER( vtech1_latch_w ) |
| 614 | 615 | { |
| 615 | vtech1_state *vtech1 = | |
| 616 | vtech1_state *vtech1 = | |
| 616 | 617 | |
| 617 | 618 | if (LOG_VTECH1_LATCH) |
| 618 | 619 | logerror("vtech1_latch_w $%02X\n", data); |
| r8714 | r8715 | |
| 642 | 643 | |
| 643 | 644 | static WRITE8_HANDLER( vtech1_memory_bank_w ) |
| 644 | 645 | { |
| 645 | vtech1_state *vtech1 = | |
| 646 | vtech1_state *vtech1 = | |
| 646 | 647 | |
| 647 | 648 | logerror("vtech1_memory_bank_w $%02X\n", data); |
| 648 | 649 | |
| r8714 | r8715 | |
| 672 | 673 | |
| 673 | 674 | static VIDEO_UPDATE( vtech1 ) |
| 674 | 675 | { |
| 675 | vtech1_state *vtech1 = | |
| 676 | vtech1_state *vtech1 = | |
| 676 | 677 | return mc6847_update(vtech1->mc6847, bitmap, cliprect); |
| 677 | 678 | } |
| 678 | 679 | |
| r8714 | r8715 | |
| 683 | 684 | |
| 684 | 685 | static DRIVER_INIT( vtech1 ) |
| 685 | 686 | { |
| 686 | vtech1_state *vtech1 = | |
| 687 | vtech1_state *vtech1 = | |
| 687 | 688 | const address_space *prg = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 688 | 689 | int id; |
| 689 | 690 |
| r8714 | r8715 | |
|---|---|---|
| 81 | 81 | #include "video/mc6845.h" |
| 82 | 82 | #include "sound/dac.h" |
| 83 | 83 | |
| 84 | class camplynx_state | |
| 84 | class camplynx_state : public driver_data_t | |
| 85 | 85 | { |
| 86 | 86 | public: |
| 87 | static | |
| 87 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, camplynx_state(machine)); } | |
| 88 | 88 | |
| 89 | camplynx_state(running_machine &machine) { } | |
| 89 | camplynx_state(running_machine &machine) | |
| 90 | : driver_data_t(machine) { } | |
| 90 | 91 | |
| 91 | 92 | running_device *mc6845; |
| 92 | 93 | }; |
| r8714 | r8715 | |
| 409 | 410 | |
| 410 | 411 | static VIDEO_START( lynx48k ) |
| 411 | 412 | { |
| 412 | camplynx_state *state = | |
| 413 | camplynx_state *state = | |
| 413 | 414 | |
| 414 | 415 | state->mc6845 = machine->device("crtc"); |
| 415 | 416 | } |
| 416 | 417 | |
| 417 | 418 | static VIDEO_UPDATE( lynx48k ) |
| 418 | 419 | { |
| 419 | camplynx_state *state = | |
| 420 | camplynx_state *state = | |
| 420 | 421 | |
| 421 | 422 | mc6845_update(state->mc6845, bitmap, cliprect); |
| 422 | 423 | return 0; |
| r8714 | r8715 | |
|---|---|---|
| 81 | 81 | |
| 82 | 82 | static void adjust_display_position_interrupt_timer( running_machine *machine ) |
| 83 | 83 | { |
| 84 | neogeo_state *state = | |
| 84 | neogeo_state *state = | |
| 85 | 85 | |
| 86 | 86 | if ((state->display_counter + 1) != 0) |
| 87 | 87 | { |
| r8714 | r8715 | |
| 95 | 95 | |
| 96 | 96 | void neogeo_set_display_position_interrupt_control( running_machine *machine, UINT16 data ) |
| 97 | 97 | { |
| 98 | neogeo_state *state = | |
| 98 | neogeo_state *state = | |
| 99 | 99 | state->display_position_interrupt_control = data; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | void neogeo_set_display_counter_msb( const address_space *space, UINT16 data ) |
| 104 | 104 | { |
| 105 | neogeo_state *state = | |
| 105 | neogeo_state *state = | |
| 106 | 106 | |
| 107 | 107 | state->display_counter = (state->display_counter & 0x0000ffff) | ((UINT32)data << 16); |
| 108 | 108 | |
| r8714 | r8715 | |
| 112 | 112 | |
| 113 | 113 | void neogeo_set_display_counter_lsb( const address_space *space, UINT16 data ) |
| 114 | 114 | { |
| 115 | neogeo_state *state = | |
| 115 | neogeo_state *state = | |
| 116 | 116 | |
| 117 | 117 | state->display_counter = (state->display_counter & 0xffff0000) | data; |
| 118 | 118 | |
| r8714 | r8715 | |
| 128 | 128 | |
| 129 | 129 | static void update_interrupts( running_machine *machine ) |
| 130 | 130 | { |
| 131 | neogeo_state *state = | |
| 131 | neogeo_state *state = | |
| 132 | 132 | |
| 133 | 133 | cputag_set_input_line(machine, "maincpu", 1, state->vblank_interrupt_pending ? ASSERT_LINE : CLEAR_LINE); |
| 134 | 134 | cputag_set_input_line(machine, "maincpu", 2, state->display_position_interrupt_pending ? ASSERT_LINE : CLEAR_LINE); |
| r8714 | r8715 | |
| 138 | 138 | |
| 139 | 139 | void neogeo_acknowledge_interrupt( running_machine *machine, UINT16 data ) |
| 140 | 140 | { |
| 141 | neogeo_state *state = | |
| 141 | neogeo_state *state = | |
| 142 | 142 | |
| 143 | 143 | if (data & 0x01) |
| 144 | 144 | state->irq3_pending = 0; |
| r8714 | r8715 | |
| 153 | 153 | |
| 154 | 154 | static TIMER_CALLBACK( display_position_interrupt_callback ) |
| 155 | 155 | { |
| 156 | neogeo_state *state = | |
| 156 | neogeo_state *state = | |
| 157 | 157 | |
| 158 | 158 | if (LOG_VIDEO_SYSTEM) logerror("--- Scanline @ %d,%d\n", machine->primary_screen->vpos(), machine->primary_screen->hpos()); |
| 159 | 159 | |
| r8714 | r8715 | |
| 175 | 175 | |
| 176 | 176 | static TIMER_CALLBACK( display_position_vblank_callback ) |
| 177 | 177 | { |
| 178 | neogeo_state *state = | |
| 178 | neogeo_state *state = | |
| 179 | 179 | |
| 180 | 180 | if (state->display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_VBLANK) |
| 181 | 181 | { |
| r8714 | r8715 | |
| 190 | 190 | |
| 191 | 191 | static TIMER_CALLBACK( vblank_interrupt_callback ) |
| 192 | 192 | { |
| 193 | neogeo_state *state = | |
| 193 | neogeo_state *state = | |
| 194 | 194 | |
| 195 | 195 | if (LOG_VIDEO_SYSTEM) logerror("+++ VBLANK @ %d,%d\n", machine->primary_screen->vpos(), machine->primary_screen->hpos()); |
| 196 | 196 | |
| r8714 | r8715 | |
| 208 | 208 | |
| 209 | 209 | static void create_interrupt_timers( running_machine *machine ) |
| 210 | 210 | { |
| 211 | neogeo_state *state = | |
| 211 | neogeo_state *state = | |
| 212 | 212 | state->display_position_interrupt_timer = timer_alloc(machine, display_position_interrupt_callback, NULL); |
| 213 | 213 | state->display_position_vblank_timer = timer_alloc(machine, display_position_vblank_callback, NULL); |
| 214 | 214 | state->vblank_interrupt_timer = timer_alloc(machine, vblank_interrupt_callback, NULL); |
| r8714 | r8715 | |
| 217 | 217 | |
| 218 | 218 | static void start_interrupt_timers( running_machine *machine ) |
| 219 | 219 | { |
| 220 | neogeo_state *state = | |
| 220 | neogeo_state *state = | |
| 221 | 221 | timer_adjust_oneshot(state->vblank_interrupt_timer, machine->primary_screen->time_until_pos(NEOGEO_VBSTART, 0), 0); |
| 222 | 222 | timer_adjust_oneshot(state->display_position_vblank_timer, machine->primary_screen->time_until_pos(NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0); |
| 223 | 223 | } |
| r8714 | r8715 | |
| 232 | 232 | |
| 233 | 233 | static void audio_cpu_irq(running_device *device, int assert) |
| 234 | 234 | { |
| 235 | neogeo_state *state = | |
| 235 | neogeo_state *state = | |
| 236 | 236 | cpu_set_input_line(state->audiocpu, 0, assert ? ASSERT_LINE : CLEAR_LINE); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | |
| 240 | 240 | static void audio_cpu_assert_nmi(running_machine *machine) |
| 241 | 241 | { |
| 242 | neogeo_state *state = | |
| 242 | neogeo_state *state = | |
| 243 | 243 | cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, ASSERT_LINE); |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | |
| 247 | 247 | static WRITE8_HANDLER( audio_cpu_clear_nmi_w ) |
| 248 | 248 | { |
| 249 | neogeo_state *state = | |
| 249 | neogeo_state *state = | |
| 250 | 250 | cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE); |
| 251 | 251 | } |
| 252 | 252 | |
| r8714 | r8715 | |
| 260 | 260 | |
| 261 | 261 | static void select_controller( running_machine *machine, UINT8 data ) |
| 262 | 262 | { |
| 263 | neogeo_state *state = | |
| 263 | neogeo_state *state = | |
| 264 | 264 | state->controller_select = data; |
| 265 | 265 | } |
| 266 | 266 | |
| r8714 | r8715 | |
| 307 | 307 | |
| 308 | 308 | static WRITE16_HANDLER( io_control_w ) |
| 309 | 309 | { |
| 310 | neogeo_state *state = | |
| 310 | neogeo_state *state = | |
| 311 | 311 | switch (offset) |
| 312 | 312 | { |
| 313 | 313 | case 0x00: select_controller(space->machine, data & 0x00ff); break; |
| r8714 | r8715 | |
| 335 | 335 | |
| 336 | 336 | READ16_HANDLER( neogeo_unmapped_r ) |
| 337 | 337 | { |
| 338 | neogeo_state *state = | |
| 338 | neogeo_state *state = | |
| 339 | 339 | UINT16 ret; |
| 340 | 340 | |
| 341 | 341 | /* unmapped memory returns the last word on the data bus, which is almost always the opcode |
| r8714 | r8715 | |
| 390 | 390 | |
| 391 | 391 | static CUSTOM_INPUT( get_calendar_status ) |
| 392 | 392 | { |
| 393 | neogeo_state *state = | |
| 393 | neogeo_state *state = | |
| 394 | 394 | return (upd4990a_databit_r(state->upd4990a, 0) << 1) | upd4990a_testbit_r(state->upd4990a, 0); |
| 395 | 395 | } |
| 396 | 396 | |
| r8714 | r8715 | |
| 420 | 420 | |
| 421 | 421 | static void set_save_ram_unlock( running_machine *machine, UINT8 data ) |
| 422 | 422 | { |
| 423 | neogeo_state *state = | |
| 423 | neogeo_state *state = | |
| 424 | 424 | state->save_ram_unlocked = data; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | |
| 428 | 428 | static WRITE16_HANDLER( save_ram_w ) |
| 429 | 429 | { |
| 430 | neogeo_state *state = | |
| 430 | neogeo_state *state = | |
| 431 | 431 | |
| 432 | 432 | if (state->save_ram_unlocked) |
| 433 | 433 | COMBINE_DATA(&save_ram[offset]); |
| r8714 | r8715 | |
| 534 | 534 | |
| 535 | 535 | static WRITE8_HANDLER( audio_result_w ) |
| 536 | 536 | { |
| 537 | neogeo_state *state = | |
| 537 | neogeo_state *state = | |
| 538 | 538 | |
| 539 | 539 | if (LOG_CPU_COMM && (state->audio_result != data)) logerror(" AUD CPU PC %04x: audio_result_w %02x\n", cpu_get_pc(space->cpu), data); |
| 540 | 540 | |
| r8714 | r8715 | |
| 544 | 544 | |
| 545 | 545 | static CUSTOM_INPUT( get_audio_result ) |
| 546 | 546 | { |
| 547 | neogeo_state *state = | |
| 547 | neogeo_state *state = | |
| 548 | 548 | UINT32 ret = state->audio_result; |
| 549 | 549 | |
| 550 | 550 | // if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_result_r %02x\n", cpu_get_pc(field->port->machine->device("maincpu")), ret); |
| r8714 | r8715 | |
| 562 | 562 | |
| 563 | 563 | static void _set_main_cpu_vector_table_source( running_machine *machine ) |
| 564 | 564 | { |
| 565 | neogeo_state *state = | |
| 565 | neogeo_state *state = | |
| 566 | 566 | memory_set_bank(machine, NEOGEO_BANK_VECTORS, state->main_cpu_vector_table_source); |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | |
| 570 | 570 | static void set_main_cpu_vector_table_source( running_machine *machine, UINT8 data ) |
| 571 | 571 | { |
| 572 | neogeo_state *state = | |
| 572 | neogeo_state *state = | |
| 573 | 573 | state->main_cpu_vector_table_source = data; |
| 574 | 574 | |
| 575 | 575 | _set_main_cpu_vector_table_source(machine); |
| r8714 | r8715 | |
| 578 | 578 | |
| 579 | 579 | static void _set_main_cpu_bank_address( running_machine *machine ) |
| 580 | 580 | { |
| 581 | neogeo_state *state = | |
| 581 | neogeo_state *state = | |
| 582 | 582 | memory_set_bankptr(machine, NEOGEO_BANK_CARTRIDGE, &memory_region(machine, "maincpu")[state->main_cpu_bank_address]); |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | |
| 586 | 586 | void neogeo_set_main_cpu_bank_address( const address_space *space, UINT32 bank_address ) |
| 587 | 587 | { |
| 588 | neogeo_state *state = | |
| 588 | neogeo_state *state = | |
| 589 | 589 | |
| 590 | 590 | if (LOG_MAIN_CPU_BANKING) logerror("MAIN CPU PC %06x: neogeo_set_main_cpu_bank_address %06x\n", cpu_get_pc(space->cpu), bank_address); |
| 591 | 591 | |
| r8714 | r8715 | |
| 642 | 642 | |
| 643 | 643 | static void set_audio_cpu_banking( running_machine *machine ) |
| 644 | 644 | { |
| 645 | neogeo_state *state = | |
| 645 | neogeo_state *state = | |
| 646 | 646 | int region; |
| 647 | 647 | |
| 648 | 648 | for (region = 0; region < 4; region++) |
| r8714 | r8715 | |
| 652 | 652 | |
| 653 | 653 | static void audio_cpu_bank_select( const address_space *space, int region, UINT8 bank ) |
| 654 | 654 | { |
| 655 | neogeo_state *state = | |
| 655 | neogeo_state *state = | |
| 656 | 656 | |
| 657 | 657 | if (LOG_AUDIO_CPU_BANKING) logerror("Audio CPU PC %03x: audio_cpu_bank_select: Region: %d Bank: %02x\n", cpu_get_pc(space->cpu), region, bank); |
| 658 | 658 | |
| r8714 | r8715 | |
| 696 | 696 | |
| 697 | 697 | static void _set_audio_cpu_rom_source( const address_space *space ) |
| 698 | 698 | { |
| 699 | neogeo_state *state = | |
| 699 | neogeo_state *state = | |
| 700 | 700 | |
| 701 | 701 | /* if (!memory_region(machine, "audiobios")) */ |
| 702 | 702 | state->audio_cpu_rom_source = 1; |
| r8714 | r8715 | |
| 717 | 717 | |
| 718 | 718 | static void set_audio_cpu_rom_source( const address_space *space, UINT8 data ) |
| 719 | 719 | { |
| 720 | neogeo_state *state = | |
| 720 | neogeo_state *state = | |
| 721 | 721 | state->audio_cpu_rom_source = data; |
| 722 | 722 | |
| 723 | 723 | _set_audio_cpu_rom_source(space); |
| r8714 | r8715 | |
| 726 | 726 | |
| 727 | 727 | static void audio_cpu_banking_init( running_machine *machine ) |
| 728 | 728 | { |
| 729 | neogeo_state *state = | |
| 729 | neogeo_state *state = | |
| 730 | 730 | int region; |
| 731 | 731 | int bank; |
| 732 | 732 | UINT8 *rgn; |
| r8714 | r8715 | |
| 815 | 815 | |
| 816 | 816 | static MACHINE_START( neogeo ) |
| 817 | 817 | { |
| 818 | neogeo_state *state = | |
| 818 | neogeo_state *state = | |
| 819 | 819 | |
| 820 | 820 | /* set the BIOS bank */ |
| 821 | 821 | memory_set_bankptr(machine, NEOGEO_BANK_BIOS, memory_region(machine, "mainbios")); |
| r8714 | r8715 | |
| 880 | 880 | |
| 881 | 881 | static MACHINE_RESET( neogeo ) |
| 882 | 882 | { |
| 883 | neogeo_state *state = | |
| 883 | neogeo_state *state = | |
| 884 | 884 | offs_t offs; |
| 885 | 885 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 886 | 886 |
| r8714 | r8715 | |
|---|---|---|
| 104 | 104 | |
| 105 | 105 | */ |
| 106 | 106 | |
| 107 | kc85_state *state = | |
| 107 | kc85_state *state = | |
| 108 | 108 | |
| 109 | 109 | return (state->iosel << 5) | state->bank; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | static void pc8201_bankswitch(running_machine *machine, UINT8 data) |
| 113 | 113 | { |
| 114 | kc85_state *state = | |
| 114 | kc85_state *state = | |
| 115 | 115 | |
| 116 | 116 | const address_space *program = cputag_get_address_space(machine, I8085_TAG, ADDRESS_SPACE_PROGRAM); |
| 117 | 117 | |
| r8714 | r8715 | |
| 207 | 207 | |
| 208 | 208 | */ |
| 209 | 209 | |
| 210 | kc85_state *state = | |
| 210 | kc85_state *state = | |
| 211 | 211 | |
| 212 | 212 | /* cassette motor */ |
| 213 | 213 | cassette_change_state(state->cassette, BIT(data, 3) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| r8714 | r8715 | |
| 239 | 239 | |
| 240 | 240 | */ |
| 241 | 241 | #if 0 |
| 242 | kc85_state *state = | |
| 242 | kc85_state *state = | |
| 243 | 243 | |
| 244 | 244 | im6402_sbs_w(state->im6402, BIT(data, 0)); |
| 245 | 245 | im6402_epe_w(state->im6402, BIT(data, 1)); |
| r8714 | r8715 | |
| 266 | 266 | |
| 267 | 267 | */ |
| 268 | 268 | #if 0 |
| 269 | kc85_state *state = | |
| 269 | kc85_state *state = | |
| 270 | 270 | |
| 271 | 271 | UINT8 data = 0; |
| 272 | 272 | |
| r8714 | r8715 | |
| 301 | 301 | |
| 302 | 302 | */ |
| 303 | 303 | #if 0 |
| 304 | kc85_state *state = | |
| 304 | kc85_state *state = | |
| 305 | 305 | |
| 306 | 306 | UINT8 data = 0; |
| 307 | 307 | |
| r8714 | r8715 | |
| 336 | 336 | |
| 337 | 337 | */ |
| 338 | 338 | #if 0 |
| 339 | kc85_state *state = | |
| 339 | kc85_state *state = | |
| 340 | 340 | |
| 341 | 341 | mc14412_en_w(state->mc14412, BIT(data, 1)); |
| 342 | 342 | #endif |
| r8714 | r8715 | |
| 359 | 359 | |
| 360 | 360 | */ |
| 361 | 361 | |
| 362 | kc85_state *state = | |
| 362 | kc85_state *state = | |
| 363 | 363 | |
| 364 | 364 | /* ROM bank selection */ |
| 365 | 365 | memory_set_bank(space->machine, "bank1", BIT(data, 0)); |
| r8714 | r8715 | |
| 393 | 393 | |
| 394 | 394 | static READ8_HANDLER( keyboard_r ) |
| 395 | 395 | { |
| 396 | kc85_state *state = | |
| 396 | kc85_state *state = | |
| 397 | 397 | |
| 398 | 398 | return read_keyboard(space->machine, state->keylatch); |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | static READ8_HANDLER( tandy200_bank_r ) |
| 402 | 402 | { |
| 403 | tandy200_state *state = | |
| 403 | tandy200_state *state = | |
| 404 | 404 | |
| 405 | 405 | return state->bank; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | static WRITE8_HANDLER( tandy200_bank_w ) |
| 409 | 409 | { |
| 410 | tandy200_state *state = | |
| 410 | tandy200_state *state = | |
| 411 | 411 | |
| 412 | 412 | const address_space *program = cputag_get_address_space(space->machine, I8085_TAG, ADDRESS_SPACE_PROGRAM); |
| 413 | 413 | |
| r8714 | r8715 | |
| 442 | 442 | |
| 443 | 443 | static READ8_HANDLER( tandy200_stbk_r ) |
| 444 | 444 | { |
| 445 | tandy200_state *state = | |
| 445 | tandy200_state *state = | |
| 446 | 446 | |
| 447 | 447 | return read_keyboard(space->machine, state->keylatch); |
| 448 | 448 | } |
| r8714 | r8715 | |
| 464 | 464 | |
| 465 | 465 | */ |
| 466 | 466 | |
| 467 | tandy200_state *state = | |
| 467 | tandy200_state *state = | |
| 468 | 468 | |
| 469 | 469 | /* printer strobe */ |
| 470 | 470 | centronics_strobe_w(state->centronics, BIT(data, 0)); |
| r8714 | r8715 | |
| 475 | 475 | |
| 476 | 476 | static READ8_HANDLER( lcd_r ) |
| 477 | 477 | { |
| 478 | kc85_state *state = | |
| 478 | kc85_state *state = | |
| 479 | 479 | |
| 480 | 480 | UINT8 data = 0; |
| 481 | 481 | int i; |
| r8714 | r8715 | |
| 490 | 490 | |
| 491 | 491 | static WRITE8_HANDLER( lcd_w ) |
| 492 | 492 | { |
| 493 | kc85_state *state = | |
| 493 | kc85_state *state = | |
| 494 | 494 | int i; |
| 495 | 495 | |
| 496 | 496 | for (i = 0; i < 10; i++) |
| r8714 | r8715 | |
| 843 | 843 | |
| 844 | 844 | */ |
| 845 | 845 | |
| 846 | kc85_state *state = | |
| 846 | kc85_state *state = | |
| 847 | 847 | |
| 848 | 848 | UINT8 data = 0; |
| 849 | 849 | |
| r8714 | r8715 | |
| 871 | 871 | |
| 872 | 872 | */ |
| 873 | 873 | |
| 874 | kc85_state *state = | |
| 874 | kc85_state *state = | |
| 875 | 875 | |
| 876 | 876 | /* keyboard */ |
| 877 | 877 | state->keylatch = (state->keylatch & 0x100) | data; |
| r8714 | r8715 | |
| 911 | 911 | |
| 912 | 912 | */ |
| 913 | 913 | |
| 914 | kc85_state *state = | |
| 914 | kc85_state *state = | |
| 915 | 915 | |
| 916 | 916 | /* keyboard */ |
| 917 | 917 | state->keylatch = (BIT(data, 0) << 8) | (state->keylatch & 0xff); |
| r8714 | r8715 | |
| 929 | 929 | |
| 930 | 930 | static WRITE_LINE_DEVICE_HANDLER( kc85_8155_to_w ) |
| 931 | 931 | { |
| 932 | kc85_state *driver_state = | |
| 932 | kc85_state *driver_state = | |
| 933 | 933 | |
| 934 | 934 | if (!driver_state->buzzer && driver_state->bell) |
| 935 | 935 | { |
| r8714 | r8715 | |
| 963 | 963 | |
| 964 | 964 | */ |
| 965 | 965 | |
| 966 | kc85_state *state = | |
| 966 | kc85_state *state = | |
| 967 | 967 | |
| 968 | 968 | UINT8 data = 0; |
| 969 | 969 | |
| r8714 | r8715 | |
| 991 | 991 | |
| 992 | 992 | */ |
| 993 | 993 | |
| 994 | kc85_state *state = | |
| 994 | kc85_state *state = | |
| 995 | 995 | |
| 996 | 996 | /* keyboard */ |
| 997 | 997 | state->keylatch = (BIT(data, 0) << 8) | (state->keylatch & 0xff); |
| r8714 | r8715 | |
| 1033 | 1033 | |
| 1034 | 1034 | */ |
| 1035 | 1035 | |
| 1036 | tandy200_state *state = | |
| 1036 | tandy200_state *state = | |
| 1037 | 1037 | |
| 1038 | 1038 | UINT8 data = 0x01; |
| 1039 | 1039 | |
| r8714 | r8715 | |
| 1060 | 1060 | |
| 1061 | 1061 | */ |
| 1062 | 1062 | |
| 1063 | tandy200_state *state = | |
| 1063 | tandy200_state *state = | |
| 1064 | 1064 | |
| 1065 | 1065 | centronics_data_w(state->centronics, 0, data); |
| 1066 | 1066 | |
| r8714 | r8715 | |
| 1084 | 1084 | |
| 1085 | 1085 | */ |
| 1086 | 1086 | |
| 1087 | tandy200_state *state = | |
| 1087 | tandy200_state *state = | |
| 1088 | 1088 | |
| 1089 | 1089 | /* keyboard */ |
| 1090 | 1090 | state->keylatch = (BIT(data, 0) << 8) | (state->keylatch & 0xff); |
| r8714 | r8715 | |
| 1098 | 1098 | |
| 1099 | 1099 | static WRITE_LINE_DEVICE_HANDLER( tandy200_8155_to_w ) |
| 1100 | 1100 | { |
| 1101 | tandy200_state *driver_state = | |
| 1101 | tandy200_state *driver_state = | |
| 1102 | 1102 | |
| 1103 | 1103 | if (!driver_state->buzzer && driver_state->bell) |
| 1104 | 1104 | { |
| r8714 | r8715 | |
| 1129 | 1129 | |
| 1130 | 1130 | static MACHINE_START( kc85 ) |
| 1131 | 1131 | { |
| 1132 | kc85_state *state = | |
| 1132 | kc85_state *state = | |
| 1133 | 1133 | |
| 1134 | 1134 | const address_space *program = cputag_get_address_space(machine, I8085_TAG, ADDRESS_SPACE_PROGRAM); |
| 1135 | 1135 | |
| r8714 | r8715 | |
| 1175 | 1175 | |
| 1176 | 1176 | static MACHINE_START( pc8201 ) |
| 1177 | 1177 | { |
| 1178 | kc85_state *state = | |
| 1178 | kc85_state *state = | |
| 1179 | 1179 | |
| 1180 | 1180 | /* find devices */ |
| 1181 | 1181 | state->upd1990a = machine->device(UPD1990A_TAG); |
| r8714 | r8715 | |
| 1210 | 1210 | |
| 1211 | 1211 | static MACHINE_START( trsm100 ) |
| 1212 | 1212 | { |
| 1213 | kc85_state *state = | |
| 1213 | kc85_state *state = | |
| 1214 | 1214 | |
| 1215 | 1215 | const address_space *program = cputag_get_address_space(machine, I8085_TAG, ADDRESS_SPACE_PROGRAM); |
| 1216 | 1216 | |
| r8714 | r8715 | |
| 1266 | 1266 | |
| 1267 | 1267 | static MACHINE_START( tandy200 ) |
| 1268 | 1268 | { |
| 1269 | tandy200_state *state = | |
| 1269 | tandy200_state *state = | |
| 1270 | 1270 | |
| 1271 | 1271 | /* find devices */ |
| 1272 | 1272 | state->centronics = machine->device(CENTRONICS_TAG); |
| r8714 | r8715 | |
| 1319 | 1319 | |
| 1320 | 1320 | static TIMER_DEVICE_CALLBACK( tandy200_tp_tick ) |
| 1321 | 1321 | { |
| 1322 | tandy200_state *state = | |
| 1322 | tandy200_state *state = | |
| 1323 | 1323 | |
| 1324 | 1324 | cputag_set_input_line(timer.machine, I8085_TAG, I8085_RST75_LINE, state->tp); |
| 1325 | 1325 |
| r8714 | r8715 | |
|---|---|---|
| 559 | 559 | BYTE68K deltaUV[BYTE68K_MAX + 1]; |
| 560 | 560 | }; |
| 561 | 561 | |
| 562 | class cdi_state | |
| 562 | class cdi_state : public driver_data_t | |
| 563 | 563 | { |
| 564 | 564 | public: |
| 565 | static | |
| 565 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cdi_state(machine)); } | |
| 566 | 566 | |
| 567 | cdi_state(running_machine &machine) { } | |
| 567 | cdi_state(running_machine &machine) | |
| 568 | : driver_data_t(machine) { } | |
| 568 | 569 | |
| 569 | 570 | UINT16 *planea; |
| 570 | 571 | UINT16 *planeb; |
| r8714 | r8715 | |
| 599 | 600 | |
| 600 | 601 | static TIMER_CALLBACK( scc68070_timer0_callback ) |
| 601 | 602 | { |
| 602 | cdi_state *state = | |
| 603 | cdi_state *state = | |
| 603 | 604 | scc68070_regs_t *scc68070 = &state->scc68070_regs; |
| 604 | 605 | |
| 605 | 606 | scc68070->timers.timer0 = scc68070->timers.reload_register; |
| r8714 | r8715 | |
| 616 | 617 | |
| 617 | 618 | static READ16_HANDLER( scc68070_periphs_r ) |
| 618 | 619 | { |
| 619 | cdi_state *state = | |
| 620 | cdi_state *state = | |
| 620 | 621 | scc68070_regs_t *scc68070 = &state->scc68070_regs; |
| 621 | 622 | |
| 622 | 623 | switch(offset) |
| r8714 | r8715 | |
| 859 | 860 | |
| 860 | 861 | static WRITE16_HANDLER( scc68070_periphs_w ) |
| 861 | 862 | { |
| 862 | cdi_state *state = | |
| 863 | cdi_state *state = | |
| 863 | 864 | scc68070_regs_t *scc68070 = &state->scc68070_regs; |
| 864 | 865 | |
| 865 | 866 | switch(offset) |
| r8714 | r8715 | |
| 1560 | 1561 | { |
| 1561 | 1562 | // Get XA format from sector header |
| 1562 | 1563 | |
| 1563 | cdi_state *state = | |
| 1564 | cdi_state *state = | |
| 1564 | 1565 | cdic_regs_t *cdic = &state->cdic_regs; |
| 1565 | 1566 | const unsigned char *hdr = xa + 4; |
| 1566 | 1567 | int channels; |
| r8714 | r8715 | |
| 1687 | 1688 | // After an appropriate delay for decoding to take place... |
| 1688 | 1689 | static TIMER_CALLBACK( audio_sample_trigger ) |
| 1689 | 1690 | { |
| 1690 | cdi_state *state = | |
| 1691 | cdi_state *state = | |
| 1691 | 1692 | cdic_regs_t *cdic = &state->cdic_regs; |
| 1692 | 1693 | |
| 1693 | 1694 | if(cdic->decode_addr == 0xffff) |
| r8714 | r8715 | |
| 1814 | 1815 | |
| 1815 | 1816 | static TIMER_CALLBACK( cdic_trigger_readback_int ) |
| 1816 | 1817 | { |
| 1817 | cdi_state *state = | |
| 1818 | cdi_state *state = | |
| 1818 | 1819 | cdic_regs_t *cdic = &state->cdic_regs; |
| 1819 | 1820 | |
| 1820 | 1821 | switch(cdic->command) |
| r8714 | r8715 | |
| 2124 | 2125 | |
| 2125 | 2126 | static READ16_HANDLER( cdic_r ) |
| 2126 | 2127 | { |
| 2127 | cdi_state *state = | |
| 2128 | cdi_state *state = | |
| 2128 | 2129 | cdic_regs_t *cdic = &state->cdic_regs; |
| 2129 | 2130 | |
| 2130 | 2131 | offset += 0x3c00/2; |
| r8714 | r8715 | |
| 2209 | 2210 | |
| 2210 | 2211 | static WRITE16_HANDLER( cdic_w ) |
| 2211 | 2212 | { |
| 2212 | cdi_state *state = | |
| 2213 | cdi_state *state = | |
| 2213 | 2214 | cdic_regs_t *cdic = &state->cdic_regs; |
| 2214 | 2215 | |
| 2215 | 2216 | offset += 0x3c00/2; |
| r8714 | r8715 | |
| 2417 | 2418 | |
| 2418 | 2419 | static TIMER_CALLBACK( slave_trigger_readback_int ) |
| 2419 | 2420 | { |
| 2420 | cdi_state *state = | |
| 2421 | cdi_state *state = | |
| 2421 | 2422 | slave_regs_t *slave = &state->slave_regs; |
| 2422 | 2423 | |
| 2423 | 2424 | verboselog(machine, 0, "Asserting IRQ2\n" ); |
| r8714 | r8715 | |
| 2428 | 2429 | |
| 2429 | 2430 | static void slave_prepare_readback(running_machine *machine, attotime delay, UINT8 channel, UINT8 count, UINT8 data0, UINT8 data1, UINT8 data2, UINT8 data3, UINT8 cmd) |
| 2430 | 2431 | { |
| 2431 | cdi_state *state = | |
| 2432 | cdi_state *state = | |
| 2432 | 2433 | slave_regs_t *slave = &state->slave_regs; |
| 2433 | 2434 | |
| 2434 | 2435 | slave->channel[channel].out_index = 0; |
| r8714 | r8715 | |
| 2444 | 2445 | |
| 2445 | 2446 | static void perform_mouse_update(running_machine *machine) |
| 2446 | 2447 | { |
| 2447 | cdi_state *state = | |
| 2448 | cdi_state *state = | |
| 2448 | 2449 | slave_regs_t *slave = &state->slave_regs; |
| 2449 | 2450 | UINT16 x = input_port_read(machine, "MOUSEX"); |
| 2450 | 2451 | UINT16 y = input_port_read(machine, "MOUSEY"); |
| r8714 | r8715 | |
| 2491 | 2492 | |
| 2492 | 2493 | static READ16_HANDLER( slave_r ) |
| 2493 | 2494 | { |
| 2494 | cdi_state *state = | |
| 2495 | cdi_state *state = | |
| 2495 | 2496 | slave_regs_t *slave = &state->slave_regs; |
| 2496 | 2497 | |
| 2497 | 2498 | if(slave->channel[offset].out_count) |
| r8714 | r8715 | |
| 2528 | 2529 | |
| 2529 | 2530 | static void set_mouse_position(running_machine* machine) |
| 2530 | 2531 | { |
| 2531 | cdi_state *state = | |
| 2532 | cdi_state *state = | |
| 2532 | 2533 | slave_regs_t *slave = &state->slave_regs; |
| 2533 | 2534 | UINT16 x, y; |
| 2534 | 2535 | |
| r8714 | r8715 | |
| 2548 | 2549 | |
| 2549 | 2550 | static WRITE16_HANDLER( slave_w ) |
| 2550 | 2551 | { |
| 2551 | cdi_state *state = | |
| 2552 | cdi_state *state = | |
| 2552 | 2553 | slave_regs_t *slave = &state->slave_regs; |
| 2553 | 2554 | |
| 2554 | 2555 | switch(offset) |
| r8714 | r8715 | |
| 2886 | 2887 | |
| 2887 | 2888 | static void cdi220_draw_lcd(running_machine *machine, int y) |
| 2888 | 2889 | { |
| 2889 | cdi_state *state = | |
| 2890 | cdi_state *state = | |
| 2890 | 2891 | bitmap_t *bitmap = state->lcdbitmap; |
| 2891 | 2892 | UINT32 *scanline = BITMAP_ADDR32(bitmap, y, 0); |
| 2892 | 2893 | int x = 0; |
| r8714 | r8715 | |
| 2911 | 2912 | |
| 2912 | 2913 | static READ16_HANDLER(mcd212_r) |
| 2913 | 2914 | { |
| 2914 | cdi_state *state = | |
| 2915 | cdi_state *state = | |
| 2915 | 2916 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 2916 | 2917 | UINT8 channel = 1 - (offset / 8); |
| 2917 | 2918 | |
| r8714 | r8715 | |
| 2974 | 2975 | |
| 2975 | 2976 | static void mcd212_update_visible_area(running_machine *machine) |
| 2976 | 2977 | { |
| 2977 | cdi_state *state = | |
| 2978 | cdi_state *state = | |
| 2978 | 2979 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 2979 | 2980 | const rectangle &visarea = machine->primary_screen->visible_area(); |
| 2980 | 2981 | rectangle visarea1; |
| r8714 | r8715 | |
| 3000 | 3001 | |
| 3001 | 3002 | static WRITE16_HANDLER(mcd212_w) |
| 3002 | 3003 | { |
| 3003 | cdi_state *state = | |
| 3004 | cdi_state *state = | |
| 3004 | 3005 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 3005 | 3006 | |
| 3006 | 3007 | switch(offset) |
| r8714 | r8715 | |
| 3040 | 3041 | |
| 3041 | 3042 | static void mcd212_set_register(running_machine *machine, int channel, UINT8 reg, UINT32 value) |
| 3042 | 3043 | { |
| 3043 | cdi_state *state = | |
| 3044 | cdi_state *state = | |
| 3044 | 3045 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 3045 | 3046 | |
| 3046 | 3047 | switch(reg) |
| r8714 | r8715 | |
| 3232 | 3233 | |
| 3233 | 3234 | static void mcd212_process_ica(running_machine *machine, int channel) |
| 3234 | 3235 | { |
| 3235 | cdi_state *state = | |
| 3236 | cdi_state *state = | |
| 3236 | 3237 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 3237 | 3238 | UINT16 *ica = channel ? state->planeb : state->planea; |
| 3238 | 3239 | UINT32 addr = 0x000400/2; |
| r8714 | r8715 | |
| 3317 | 3318 | |
| 3318 | 3319 | static void mcd212_process_dca(running_machine *machine, int channel) |
| 3319 | 3320 | { |
| 3320 | cdi_state *state = | |
| 3321 | cdi_state *state = | |
| 3321 | 3322 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 3322 | 3323 | UINT16 *dca = channel ? state->planeb : state->planea; |
| 3323 | 3324 | UINT32 addr = (mcd212->channel[channel].dca & 0x0007ffff) / 2; //(mcd212_get_dcp(mcd212, channel) & 0x0007ffff) / 2; // mcd212->channel[channel].dca / 2; |
| r8714 | r8715 | |
| 3465 | 3466 | |
| 3466 | 3467 | static void mcd212_update_region_arrays(running_machine *machine) |
| 3467 | 3468 | { |
| 3468 | cdi_state *state = | |
| 3469 | cdi_state *state = | |
| 3469 | 3470 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 3470 | 3471 | int x = 0; |
| 3471 | 3472 | int latched_rf0 = 0; |
| r8714 | r8715 | |
| 3698 | 3699 | |
| 3699 | 3700 | static int mcd212_get_screen_width(running_machine *machine) |
| 3700 | 3701 | { |
| 3701 | cdi_state *state = | |
| 3702 | cdi_state *state = | |
| 3702 | 3703 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 3703 | 3704 | |
| 3704 | 3705 | if((mcd212->channel[0].dcr & (MCD212_DCR_CF | MCD212_DCR_FD)) && (mcd212->channel[0].csrw & MCD212_CSR1W_ST)) |
| r8714 | r8715 | |
| 3710 | 3711 | |
| 3711 | 3712 | static void mcd212_process_vsr(running_machine *machine, int channel, UINT8 *pixels_r, UINT8 *pixels_g, UINT8 *pixels_b) |
| 3712 | 3713 | { |
| 3713 | cdi_state *state = | |
| 3714 | cdi_state *state = | |
| 3714 | 3715 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 3715 | 3716 | UINT8 *data = channel ? (UINT8*)state->planeb : (UINT8*)state->planea; |
| 3716 | 3717 | UINT32 vsr = mcd212_get_vsr(mcd212, channel) & 0x0007ffff; |
| r8714 | r8715 | |
| 4019 | 4020 | |
| 4020 | 4021 | static void mcd212_draw_cursor(running_machine *machine, UINT32 *scanline, int y) |
| 4021 | 4022 | { |
| 4022 | cdi_state *state = | |
| 4023 | cdi_state *state = | |
| 4023 | 4024 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 4024 | 4025 | |
| 4025 | 4026 | if(mcd212->channel[0].cursor_control & MCD212_CURCNT_EN) |
| r8714 | r8715 | |
| 4067 | 4068 | |
| 4068 | 4069 | static void mcd212_mix_lines(running_machine *machine, UINT8 *plane_a_r, UINT8 *plane_a_g, UINT8 *plane_a_b, UINT8 *plane_b_r, UINT8 *plane_b_g, UINT8 *plane_b_b, UINT32 *out) |
| 4069 | 4070 | { |
| 4070 | cdi_state *state = | |
| 4071 | cdi_state *state = | |
| 4071 | 4072 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 4072 | 4073 | int x = 0; |
| 4073 | 4074 | UINT8 debug_mode = input_port_read(machine, "DEBUG"); |
| r8714 | r8715 | |
| 4263 | 4264 | |
| 4264 | 4265 | static TIMER_CALLBACK( mcd212_perform_scan ) |
| 4265 | 4266 | { |
| 4266 | cdi_state *state = | |
| 4267 | cdi_state *state = | |
| 4267 | 4268 | mcd212_regs_t *mcd212 = &state->mcd212_regs; |
| 4268 | 4269 | int scanline = machine->primary_screen->vpos(); |
| 4269 | 4270 | |
| r8714 | r8715 | |
| 4456 | 4457 | |
| 4457 | 4458 | static VIDEO_START(cdi) |
| 4458 | 4459 | { |
| 4459 | cdi_state *state = | |
| 4460 | cdi_state *state = | |
| 4460 | 4461 | |
| 4461 | 4462 | VIDEO_START_CALL(generic_bitmapped); |
| 4462 | 4463 | mcd212_ab_init(&state->mcd212_ab); |
| r8714 | r8715 | |
| 4469 | 4470 | |
| 4470 | 4471 | static VIDEO_UPDATE(cdi) |
| 4471 | 4472 | { |
| 4472 | cdi_state *state = | |
| 4473 | cdi_state *state = | |
| 4473 | 4474 | running_device *main_screen = screen->machine->device("screen"); |
| 4474 | 4475 | running_device *lcd_screen = screen->machine->device("lcd"); |
| 4475 | 4476 | |
| r8714 | r8715 | |
| 4487 | 4488 | |
| 4488 | 4489 | static TIMER_CALLBACK( test_timer_callback ) |
| 4489 | 4490 | { |
| 4490 | cdi_state *state = | |
| 4491 | cdi_state *state = | |
| 4491 | 4492 | |
| 4492 | 4493 | // This function manually triggers interrupt requests as a test. |
| 4493 | 4494 | if(state->timer_set == 0) |
| r8714 | r8715 | |
| 4511 | 4512 | |
| 4512 | 4513 | static WRITE16_HANDLER(cdic_ram_w) |
| 4513 | 4514 | { |
| 4514 | cdi_state *state = | |
| 4515 | cdi_state *state = | |
| 4515 | 4516 | cdic_regs_t *cdic = &state->cdic_regs; |
| 4516 | 4517 | |
| 4517 | 4518 | verboselog(space->machine, 0, "cdic_ram_w: %08x = %04x & %04x\n", 0x00300000 + offset*2, data, mem_mask); |
| r8714 | r8715 | |
| 4520 | 4521 | |
| 4521 | 4522 | static READ16_HANDLER(cdic_ram_r) |
| 4522 | 4523 | { |
| 4523 | cdi_state *state = | |
| 4524 | cdi_state *state = | |
| 4524 | 4525 | cdic_regs_t *cdic = &state->cdic_regs; |
| 4525 | 4526 | |
| 4526 | 4527 | verboselog(space->machine, 0, "cdic_ram_r: %08x = %04x & %04x\n", 0x00300000 + offset*2, cdic->ram[offset], mem_mask); |
| r8714 | r8715 | |
| 4594 | 4595 | |
| 4595 | 4596 | static MACHINE_START( cdi ) |
| 4596 | 4597 | { |
| 4597 | cdi_state *state = | |
| 4598 | cdi_state *state = | |
| 4598 | 4599 | |
| 4599 | 4600 | scc68070_register_globals(machine, &state->scc68070_regs); |
| 4600 | 4601 | cdic_register_globals(machine, &state->cdic_regs); |
| r8714 | r8715 | |
| 4618 | 4619 | |
| 4619 | 4620 | static MACHINE_RESET( cdi ) |
| 4620 | 4621 | { |
| 4621 | cdi_state *state = | |
| 4622 | cdi_state *state = | |
| 4622 | 4623 | UINT16 *src = (UINT16*)memory_region(machine, "maincpu"); |
| 4623 | 4624 | UINT16 *dst = state->planea; |
| 4624 | 4625 | running_device *cdrom_dev = machine->device("cdrom"); |
| r8714 | r8715 | |
|---|---|---|
| 123 | 123 | |
| 124 | 124 | static WRITE8_HANDLER( samcoupe_clut_w ) |
| 125 | 125 | { |
| 126 | coupe_asic *asic = | |
| 126 | coupe_asic *asic = | |
| 127 | 127 | asic->clut[(offset >> 8) & 0x0f] = data & 0x7f; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | static READ8_HANDLER( samcoupe_status_r ) |
| 131 | 131 | { |
| 132 | coupe_asic *asic = | |
| 132 | coupe_asic *asic = | |
| 133 | 133 | UINT8 data = 0xe0; |
| 134 | 134 | |
| 135 | 135 | /* bit 5-7, keyboard input */ |
| r8714 | r8715 | |
| 150 | 150 | |
| 151 | 151 | static WRITE8_HANDLER( samcoupe_line_int_w ) |
| 152 | 152 | { |
| 153 | coupe_asic *asic = | |
| 153 | coupe_asic *asic = | |
| 154 | 154 | asic->line_int = data; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | static READ8_HANDLER( samcoupe_lmpr_r ) |
| 158 | 158 | { |
| 159 | coupe_asic *asic = | |
| 159 | coupe_asic *asic = | |
| 160 | 160 | return asic->lmpr; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | static WRITE8_HANDLER( samcoupe_lmpr_w ) |
| 164 | 164 | { |
| 165 | 165 | const address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 166 | coupe_asic *asic = | |
| 166 | coupe_asic *asic = | |
| 167 | 167 | |
| 168 | 168 | asic->lmpr = data; |
| 169 | 169 | samcoupe_update_memory(space_program); |
| r8714 | r8715 | |
| 171 | 171 | |
| 172 | 172 | static READ8_HANDLER( samcoupe_hmpr_r ) |
| 173 | 173 | { |
| 174 | coupe_asic *asic = | |
| 174 | coupe_asic *asic = | |
| 175 | 175 | return asic->hmpr; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | static WRITE8_HANDLER( samcoupe_hmpr_w ) |
| 179 | 179 | { |
| 180 | 180 | const address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 181 | coupe_asic *asic = | |
| 181 | coupe_asic *asic = | |
| 182 | 182 | |
| 183 | 183 | asic->hmpr = data; |
| 184 | 184 | samcoupe_update_memory(space_program); |
| r8714 | r8715 | |
| 186 | 186 | |
| 187 | 187 | static READ8_HANDLER( samcoupe_vmpr_r ) |
| 188 | 188 | { |
| 189 | coupe_asic *asic = | |
| 189 | coupe_asic *asic = | |
| 190 | 190 | return asic->vmpr; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | static WRITE8_HANDLER( samcoupe_vmpr_w ) |
| 194 | 194 | { |
| 195 | 195 | const address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 196 | coupe_asic *asic = | |
| 196 | coupe_asic *asic = | |
| 197 | 197 | |
| 198 | 198 | asic->vmpr = data; |
| 199 | 199 | samcoupe_update_memory(space_program); |
| r8714 | r8715 | |
| 250 | 250 | { |
| 251 | 251 | running_device *cassette = space->machine->device("cassette"); |
| 252 | 252 | running_device *speaker = space->machine->device("speaker"); |
| 253 | coupe_asic *asic = | |
| 253 | coupe_asic *asic = | |
| 254 | 254 | |
| 255 | 255 | asic->border = data; |
| 256 | 256 | |
| r8714 | r8715 | |
| 263 | 263 | |
| 264 | 264 | static READ8_HANDLER( samcoupe_attributes_r ) |
| 265 | 265 | { |
| 266 | coupe_asic *asic = | |
| 266 | coupe_asic *asic = | |
| 267 | 267 | return asic->attribute; |
| 268 | 268 | } |
| 269 | 269 | |
| r8714 | r8715 | |
| 325 | 325 | |
| 326 | 326 | static TIMER_CALLBACK( irq_off ) |
| 327 | 327 | { |
| 328 | coupe_asic *asic = | |
| 328 | coupe_asic *asic = | |
| 329 | 329 | |
| 330 | 330 | /* adjust STATUS register */ |
| 331 | 331 | asic->status |= param; |
| r8714 | r8715 | |
| 338 | 338 | |
| 339 | 339 | void samcoupe_irq(running_device *device, UINT8 src) |
| 340 | 340 | { |
| 341 | coupe_asic *asic = | |
| 341 | coupe_asic *asic = | |
| 342 | 342 | |
| 343 | 343 | /* assert irq and a timer to set it off again */ |
| 344 | 344 | cpu_set_input_line(device, 0, ASSERT_LINE); |
| r8714 | r8715 | |
|---|---|---|
| 203 | 203 | |
| 204 | 204 | static CDP1802_MODE_READ( comx35_mode_r ) |
| 205 | 205 | { |
| 206 | comx35_state *state = | |
| 206 | comx35_state *state = | |
| 207 | 207 | |
| 208 | 208 | return (cdp1802_control_mode)state->cdp1802_mode; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | static CDP1802_EF_READ( comx35_ef_r ) |
| 212 | 212 | { |
| 213 | comx35_state *state = | |
| 213 | comx35_state *state = | |
| 214 | 214 | |
| 215 | 215 | int flags = 0x0f; |
| 216 | 216 | |
| r8714 | r8715 | |
| 246 | 246 | |
| 247 | 247 | static CDP1802_SC_WRITE( comx35_sc_w ) |
| 248 | 248 | { |
| 249 | comx35_state *driver_state = | |
| 249 | comx35_state *driver_state = | |
| 250 | 250 | |
| 251 | 251 | switch (state) |
| 252 | 252 | { |
| r8714 | r8715 | |
| 285 | 285 | |
| 286 | 286 | static WRITE_LINE_DEVICE_HANDLER( comx35_q_w ) |
| 287 | 287 | { |
| 288 | comx35_state *driver_state = | |
| 288 | comx35_state *driver_state = | |
| 289 | 289 | |
| 290 | 290 | driver_state->cdp1802_q = state; |
| 291 | 291 | |
| r8714 | r8715 | |
| 313 | 313 | |
| 314 | 314 | static WRITE_LINE_DEVICE_HANDLER( comx35_da_w ) |
| 315 | 315 | { |
| 316 | comx35_state *driver_state = | |
| 316 | comx35_state *driver_state = | |
| 317 | 317 | |
| 318 | 318 | driver_state->cdp1871_efxa = state; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | static WRITE_LINE_DEVICE_HANDLER( comx35_rpt_w ) |
| 322 | 322 | { |
| 323 | comx35_state *driver_state = | |
| 323 | comx35_state *driver_state = | |
| 324 | 324 | |
| 325 | 325 | driver_state->cdp1871_efxb = state; |
| 326 | 326 | } |
| r8714 | r8715 | |
|---|---|---|
| 34 | 34 | |
| 35 | 35 | */ |
| 36 | 36 | |
| 37 | jtc_state *state = | |
| 37 | jtc_state *state = | |
| 38 | 38 | |
| 39 | 39 | centronics_strobe_w(state->centronics, BIT(data, 5)); |
| 40 | 40 | } |
| r8714 | r8715 | |
| 56 | 56 | |
| 57 | 57 | */ |
| 58 | 58 | |
| 59 | jtc_state *state = | |
| 59 | jtc_state *state = | |
| 60 | 60 | |
| 61 | 61 | UINT8 data = 0; |
| 62 | 62 | |
| r8714 | r8715 | |
| 83 | 83 | |
| 84 | 84 | */ |
| 85 | 85 | |
| 86 | jtc_state *state = | |
| 86 | jtc_state *state = | |
| 87 | 87 | |
| 88 | 88 | /* tape */ |
| 89 | 89 | cassette_output(state->cassette, BIT(data, 6) ? +1.0 : -1.0); |
| r8714 | r8715 | |
| 94 | 94 | |
| 95 | 95 | static READ8_HANDLER( es40_videoram_r ) |
| 96 | 96 | { |
| 97 | jtc_state *state = | |
| 97 | jtc_state *state = | |
| 98 | 98 | |
| 99 | 99 | UINT8 data = 0; |
| 100 | 100 | |
| r8714 | r8715 | |
| 108 | 108 | |
| 109 | 109 | static WRITE8_HANDLER( es40_videoram_w ) |
| 110 | 110 | { |
| 111 | jtc_state *state = | |
| 111 | jtc_state *state = | |
| 112 | 112 | |
| 113 | 113 | if (state->video_bank & 0x80) state->color_ram_r[offset] = data; |
| 114 | 114 | if (state->video_bank & 0x40) state->color_ram_g[offset] = data; |
| r8714 | r8715 | |
| 118 | 118 | |
| 119 | 119 | static WRITE8_HANDLER( es40_banksel_w ) |
| 120 | 120 | { |
| 121 | jtc_state *state = | |
| 121 | jtc_state *state = | |
| 122 | 122 | |
| 123 | 123 | state->video_bank = offset & 0xf0; |
| 124 | 124 | } |
| r8714 | r8715 | |
| 510 | 510 | |
| 511 | 511 | static VIDEO_UPDATE( jtc ) |
| 512 | 512 | { |
| 513 | jtc_state *state = | |
| 513 | jtc_state *state = | |
| 514 | 514 | |
| 515 | 515 | int x, y, sx; |
| 516 | 516 | |
| r8714 | r8715 | |
| 537 | 537 | |
| 538 | 538 | static VIDEO_UPDATE( jtc_es23 ) |
| 539 | 539 | { |
| 540 | jtc_state *state = | |
| 540 | jtc_state *state = | |
| 541 | 541 | |
| 542 | 542 | int x, y, sx; |
| 543 | 543 | |
| r8714 | r8715 | |
| 564 | 564 | |
| 565 | 565 | static VIDEO_START( jtc_es40 ) |
| 566 | 566 | { |
| 567 | jtc_state *state = | |
| 567 | jtc_state *state = | |
| 568 | 568 | |
| 569 | 569 | /* allocate memory */ |
| 570 | 570 | state->video_ram = auto_alloc_array(machine, UINT8, JTC_ES40_VIDEORAM_SIZE); |
| r8714 | r8715 | |
| 582 | 582 | |
| 583 | 583 | static VIDEO_UPDATE( jtc_es40 ) |
| 584 | 584 | { |
| 585 | jtc_state *state = | |
| 585 | jtc_state *state = | |
| 586 | 586 | |
| 587 | 587 | int x, y, sx; |
| 588 | 588 | |
| r8714 | r8715 | |
| 611 | 611 | |
| 612 | 612 | static MACHINE_START( jtc ) |
| 613 | 613 | { |
| 614 | jtc_state *state = | |
| 614 | jtc_state *state = | |
| 615 | 615 | |
| 616 | 616 | /* find devices */ |
| 617 | 617 | state->cassette = machine->device(CASSETTE_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 45 | 45 | |
| 46 | 46 | static READ8_HANDLER( gfxram_r ) |
| 47 | 47 | { |
| 48 | tiki100_state *state = | |
| 48 | tiki100_state *state = | |
| 49 | 49 | |
| 50 | 50 | UINT16 addr = (offset + (state->scroll << 7)) & TIKI100_VIDEORAM_MASK; |
| 51 | 51 | |
| r8714 | r8715 | |
| 54 | 54 | |
| 55 | 55 | static WRITE8_HANDLER( gfxram_w ) |
| 56 | 56 | { |
| 57 | tiki100_state *state = | |
| 57 | tiki100_state *state = | |
| 58 | 58 | |
| 59 | 59 | UINT16 addr = (offset + (state->scroll << 7)) & TIKI100_VIDEORAM_MASK; |
| 60 | 60 | |
| r8714 | r8715 | |
| 63 | 63 | |
| 64 | 64 | static void tiki100_bankswitch(running_machine *machine) |
| 65 | 65 | { |
| 66 | tiki100_state *state = | |
| 66 | tiki100_state *state = | |
| 67 | 67 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 68 | 68 | |
| 69 | 69 | if (state->vire) |
| r8714 | r8715 | |
| 116 | 116 | |
| 117 | 117 | static READ8_HANDLER( keyboard_r ) |
| 118 | 118 | { |
| 119 | tiki100_state *state = | |
| 119 | tiki100_state *state = | |
| 120 | 120 | |
| 121 | 121 | static const char *const keynames[] = { "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8", "ROW9", "ROW10", "ROW11", "ROW12" }; |
| 122 | 122 | UINT8 data = input_port_read(space->machine, keynames[state->keylatch]); |
| r8714 | r8715 | |
| 130 | 130 | |
| 131 | 131 | static WRITE8_HANDLER( keyboard_w ) |
| 132 | 132 | { |
| 133 | tiki100_state *state = | |
| 133 | tiki100_state *state = | |
| 134 | 134 | |
| 135 | 135 | state->keylatch = 0; |
| 136 | 136 | } |
| r8714 | r8715 | |
| 152 | 152 | |
| 153 | 153 | */ |
| 154 | 154 | |
| 155 | tiki100_state *state = | |
| 155 | tiki100_state *state = | |
| 156 | 156 | |
| 157 | 157 | state->mode = data; |
| 158 | 158 | |
| r8714 | r8715 | |
| 182 | 182 | |
| 183 | 183 | */ |
| 184 | 184 | |
| 185 | tiki100_state *state = | |
| 185 | tiki100_state *state = | |
| 186 | 186 | |
| 187 | 187 | state->palette = data; |
| 188 | 188 | } |
| r8714 | r8715 | |
| 204 | 204 | |
| 205 | 205 | */ |
| 206 | 206 | |
| 207 | tiki100_state *state = | |
| 207 | tiki100_state *state = | |
| 208 | 208 | |
| 209 | 209 | /* drive select */ |
| 210 | 210 | if (BIT(data, 0)) wd17xx_set_drive(state->fd1797, 0); |
| r8714 | r8715 | |
| 407 | 407 | |
| 408 | 408 | static VIDEO_UPDATE( tiki100 ) |
| 409 | 409 | { |
| 410 | tiki100_state *state = | |
| 410 | tiki100_state *state = | |
| 411 | 411 | |
| 412 | 412 | UINT16 addr = (state->scroll << 7); |
| 413 | 413 | int sx, y, pixel, mode = (state->mode >> 4) & 0x03; |
| r8714 | r8715 | |
| 514 | 514 | |
| 515 | 515 | static TIMER_DEVICE_CALLBACK( ctc_tick ) |
| 516 | 516 | { |
| 517 | tiki100_state *state = | |
| 517 | tiki100_state *state = | |
| 518 | 518 | |
| 519 | 519 | z80ctc_trg0_w(state->z80ctc, 1); |
| 520 | 520 | z80ctc_trg0_w(state->z80ctc, 0); |
| r8714 | r8715 | |
| 550 | 550 | |
| 551 | 551 | static WRITE8_DEVICE_HANDLER( video_scroll_w ) |
| 552 | 552 | { |
| 553 | tiki100_state *state = | |
| 553 | tiki100_state *state = | |
| 554 | 554 | |
| 555 | 555 | state->scroll = data; |
| 556 | 556 | } |
| r8714 | r8715 | |
| 579 | 579 | |
| 580 | 580 | static MACHINE_START( tiki100 ) |
| 581 | 581 | { |
| 582 | tiki100_state *state = | |
| 582 | tiki100_state *state = | |
| 583 | 583 | |
| 584 | 584 | /* find devices */ |
| 585 | 585 | state->fd1797 = machine->device(FD1797_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 11 | 11 | |
| 12 | 12 | static DIRECT_UPDATE_HANDLER( atm_direct ) |
| 13 | 13 | { |
| 14 | spectrum_state *state = | |
| 14 | spectrum_state *state = | |
| 15 | 15 | running_device *beta = space->machine->device(BETA_DISK_TAG); |
| 16 | 16 | UINT16 pc = cpu_get_reg(space->machine->device("maincpu"), STATE_GENPCBASE); |
| 17 | 17 | |
| r8714 | r8715 | |
| 48 | 48 | |
| 49 | 49 | static void atm_update_memory(running_machine *machine) |
| 50 | 50 | { |
| 51 | spectrum_state *state = | |
| 51 | spectrum_state *state = | |
| 52 | 52 | running_device *beta = machine->device(BETA_DISK_TAG); |
| 53 | 53 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 54 | 54 | |
| r8714 | r8715 | |
| 70 | 70 | |
| 71 | 71 | static WRITE8_HANDLER(atm_port_7ffd_w) |
| 72 | 72 | { |
| 73 | spectrum_state *state = | |
| 73 | spectrum_state *state = | |
| 74 | 74 | |
| 75 | 75 | /* disable paging */ |
| 76 | 76 | if (state->port_7ffd_data & 0x20) |
| r8714 | r8715 | |
| 98 | 98 | |
| 99 | 99 | static MACHINE_RESET( atm ) |
| 100 | 100 | { |
| 101 | spectrum_state *state = | |
| 101 | spectrum_state *state = | |
| 102 | 102 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 103 | 103 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 104 | 104 | running_device *beta = machine->device(BETA_DISK_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 92 | 92 | |
| 93 | 93 | static TIMER_DEVICE_CALLBACK( vcs80_keyboard_tick ) |
| 94 | 94 | { |
| 95 | vcs80_state *state = | |
| 95 | vcs80_state *state = | |
| 96 | 96 | |
| 97 | 97 | if (state->keyclk) |
| 98 | 98 | { |
| r8714 | r8715 | |
| 122 | 122 | |
| 123 | 123 | */ |
| 124 | 124 | |
| 125 | vcs80_state *state = | |
| 125 | vcs80_state *state = | |
| 126 | 126 | |
| 127 | 127 | UINT8 data = 0; |
| 128 | 128 | |
| r8714 | r8715 | |
| 157 | 157 | |
| 158 | 158 | */ |
| 159 | 159 | |
| 160 | vcs80_state *state = | |
| 160 | vcs80_state *state = | |
| 161 | 161 | |
| 162 | 162 | UINT8 led_data = BITSWAP8(data & 0x7f, 7, 5, 6, 4, 3, 2, 1, 0); |
| 163 | 163 | int digit = state->keylatch; |
| r8714 | r8715 | |
| 191 | 191 | |
| 192 | 192 | static MACHINE_START(vcs80) |
| 193 | 193 | { |
| 194 | vcs80_state *state = | |
| 194 | vcs80_state *state = | |
| 195 | 195 | |
| 196 | 196 | /* find devices */ |
| 197 | 197 | state->z80pio = machine->device(Z80PIO_TAG); |
| r8714 | r8715 | |
| 242 | 242 | |
| 243 | 243 | static DIRECT_UPDATE_HANDLER( vcs80_direct_update_handler ) |
| 244 | 244 | { |
| 245 | vcs80_state *state = | |
| 245 | vcs80_state *state = | |
| 246 | 246 | |
| 247 | 247 | /* _A0 is connected to PIO PB7 */ |
| 248 | 248 | z80pio_pb_w(state->z80pio, 0, (!BIT(address, 0)) << 7); |
| r8714 | r8715 | |
|---|---|---|
| 11 | 11 | #include "cpu/i8008/i8008.h" |
| 12 | 12 | #include "machine/teleprinter.h" |
| 13 | 13 | |
| 14 | class mod8_state | |
| 14 | class mod8_state : public driver_data_t | |
| 15 | 15 | { |
| 16 | 16 | public: |
| 17 | static | |
| 17 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mod8_state(machine)); } | |
| 18 | 18 | |
| 19 | mod8_state(running_machine &machine) { } | |
| 19 | mod8_state(running_machine &machine) | |
| 20 | : driver_data_t(machine) { } | |
| 20 | 21 | |
| 21 | 22 | UINT16 tty_data; |
| 22 | 23 | UINT8 tty_key_data; |
| r8714 | r8715 | |
| 25 | 26 | |
| 26 | 27 | static WRITE8_HANDLER(out_w) |
| 27 | 28 | { |
| 28 | mod8_state *state = | |
| 29 | mod8_state *state = | |
| 29 | 30 | running_device *devconf = space->machine->device(TELEPRINTER_TAG); |
| 30 | 31 | |
| 31 | 32 | state->tty_data >>= 1; |
| r8714 | r8715 | |
| 39 | 40 | |
| 40 | 41 | static WRITE8_HANDLER(tty_w) |
| 41 | 42 | { |
| 42 | mod8_state *state = | |
| 43 | mod8_state *state = | |
| 43 | 44 | |
| 44 | 45 | state->tty_data = 0; |
| 45 | 46 | state->tty_cnt = 0; |
| r8714 | r8715 | |
| 47 | 48 | |
| 48 | 49 | static READ8_HANDLER(tty_r) |
| 49 | 50 | { |
| 50 | mod8_state *state = | |
| 51 | mod8_state *state = | |
| 51 | 52 | UINT8 d = state->tty_key_data & 0x01; |
| 52 | 53 | |
| 53 | 54 | state->tty_key_data >>= 1; |
| r8714 | r8715 | |
| 84 | 85 | |
| 85 | 86 | static WRITE8_DEVICE_HANDLER( mod8_kbd_put ) |
| 86 | 87 | { |
| 87 | mod8_state *state = | |
| 88 | mod8_state *state = | |
| 88 | 89 | |
| 89 | 90 | state->tty_key_data = data ^ 0xff; |
| 90 | 91 | cputag_set_input_line(device->machine, "maincpu", 0, HOLD_LINE); |
| r8714 | r8715 | |
|---|---|---|
| 84 | 84 | |
| 85 | 85 | */ |
| 86 | 86 | |
| 87 | tandy2k_state *state = | |
| 87 | tandy2k_state *state = | |
| 88 | 88 | |
| 89 | 89 | /* keyboard enable */ |
| 90 | 90 | state->kben = BIT(data, 0); |
| r8714 | r8715 | |
| 128 | 128 | |
| 129 | 129 | */ |
| 130 | 130 | |
| 131 | tandy2k_state *state = | |
| 131 | tandy2k_state *state = | |
| 132 | 132 | |
| 133 | 133 | state->dma_mux = data; |
| 134 | 134 | |
| r8714 | r8715 | |
| 181 | 181 | |
| 182 | 182 | */ |
| 183 | 183 | |
| 184 | tandy2k_state *state = | |
| 184 | tandy2k_state *state = | |
| 185 | 185 | |
| 186 | 186 | /* video access */ |
| 187 | 187 | state->vram_base = data << 15; |
| r8714 | r8715 | |
| 215 | 215 | // |
| 216 | 216 | // */ |
| 217 | 217 | // |
| 218 | // tandy2k_state *state = | |
| 218 | // tandy2k_state *state = | |
| 219 | 219 | // |
| 220 | 220 | // UINT8 data = 0xff; |
| 221 | 221 | // |
| r8714 | r8715 | |
| 252 | 252 | // |
| 253 | 253 | // */ |
| 254 | 254 | // |
| 255 | // tandy2k_state *state = | |
| 255 | // tandy2k_state *state = | |
| 256 | 256 | // |
| 257 | 257 | // /* keyboard row select */ |
| 258 | 258 | // state->keylatch = (state->keylatch & 0xff00) | data; |
| r8714 | r8715 | |
| 275 | 275 | // |
| 276 | 276 | // */ |
| 277 | 277 | // |
| 278 | // tandy2k_state *state = | |
| 278 | // tandy2k_state *state = | |
| 279 | 279 | // |
| 280 | 280 | // /* keyboard row select */ |
| 281 | 281 | // state->keylatch = ((data & 0x0f) << 8) | (state->keylatch & 0xff); |
| r8714 | r8715 | |
| 453 | 453 | |
| 454 | 454 | static VIDEO_START( tandy2k ) |
| 455 | 455 | { |
| 456 | tandy2k_state *state = | |
| 456 | tandy2k_state *state = | |
| 457 | 457 | |
| 458 | 458 | /* find devices */ |
| 459 | 459 | state->vpac = machine->device(CRT9007_TAG); |
| r8714 | r8715 | |
| 461 | 461 | |
| 462 | 462 | static VIDEO_UPDATE( tandy2k ) |
| 463 | 463 | { |
| 464 | tandy2k_state *state = | |
| 464 | tandy2k_state *state = | |
| 465 | 465 | |
| 466 | 466 | //if (state->vidouts) |
| 467 | 467 | { |
| r8714 | r8715 | |
| 473 | 473 | |
| 474 | 474 | static CRT9007_DRAW_SCANLINE( tandy2k_crt9007_display_pixels ) |
| 475 | 475 | { |
| 476 | tandy2k_state *state = | |
| 476 | tandy2k_state *state = | |
| 477 | 477 | const address_space *program = cputag_get_address_space(device->machine, I80186_TAG, ADDRESS_SPACE_PROGRAM); |
| 478 | 478 | |
| 479 | 479 | for (int sx = 0; sx < x_count; sx++) |
| r8714 | r8715 | |
| 512 | 512 | |
| 513 | 513 | static WRITE_LINE_DEVICE_HANDLER( rxrdy_w ) |
| 514 | 514 | { |
| 515 | tandy2k_state *driver_state = | |
| 515 | tandy2k_state *driver_state = | |
| 516 | 516 | |
| 517 | 517 | driver_state->rxrdy = state; |
| 518 | 518 | pic8259_ir2_w(driver_state->pic0, driver_state->rxrdy | driver_state->txrdy); |
| r8714 | r8715 | |
| 520 | 520 | |
| 521 | 521 | static WRITE_LINE_DEVICE_HANDLER( txrdy_w ) |
| 522 | 522 | { |
| 523 | tandy2k_state *driver_state = | |
| 523 | tandy2k_state *driver_state = | |
| 524 | 524 | |
| 525 | 525 | driver_state->txrdy = state; |
| 526 | 526 | pic8259_ir2_w(driver_state->pic0, driver_state->rxrdy | driver_state->txrdy); |
| r8714 | r8715 | |
| 537 | 537 | |
| 538 | 538 | static WRITE_LINE_DEVICE_HANDLER( outspkr_w ) |
| 539 | 539 | { |
| 540 | tandy2k_state *driver_state = | |
| 540 | tandy2k_state *driver_state = | |
| 541 | 541 | |
| 542 | 542 | driver_state->outspkr = state; |
| 543 | 543 | speaker_update(driver_state); |
| r8714 | r8715 | |
| 545 | 545 | |
| 546 | 546 | static WRITE_LINE_DEVICE_HANDLER( intbrclk_w ) |
| 547 | 547 | { |
| 548 | tandy2k_state *driver_state = | |
| 548 | tandy2k_state *driver_state = | |
| 549 | 549 | |
| 550 | 550 | if (!driver_state->extclk && state) |
| 551 | 551 | { |
| r8714 | r8715 | |
| 603 | 603 | |
| 604 | 604 | */ |
| 605 | 605 | |
| 606 | tandy2k_state *state = | |
| 606 | tandy2k_state *state = | |
| 607 | 607 | |
| 608 | 608 | UINT8 data = 0; |
| 609 | 609 | |
| r8714 | r8715 | |
| 656 | 656 | |
| 657 | 657 | */ |
| 658 | 658 | |
| 659 | tandy2k_state *state = | |
| 659 | tandy2k_state *state = | |
| 660 | 660 | |
| 661 | 661 | /* input select */ |
| 662 | 662 | state->pb_sel = (data >> 1) & 0x03; |
| r8714 | r8715 | |
| 761 | 761 | |
| 762 | 762 | static MACHINE_START( tandy2k ) |
| 763 | 763 | { |
| 764 | tandy2k_state *state = | |
| 764 | tandy2k_state *state = | |
| 765 | 765 | |
| 766 | 766 | /* find devices */ |
| 767 | 767 | state->uart = machine->device(I8251A_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 41 | 41 | static void draw_point(running_machine *machine, UINT8 x, UINT8 y, UINT8 color); |
| 42 | 42 | static void draw_udk(running_machine *machine); |
| 43 | 43 | |
| 44 | class t6834_state | |
| 44 | class t6834_state : public driver_data_t | |
| 45 | 45 | { |
| 46 | 46 | public: |
| 47 | static | |
| 47 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, t6834_state(machine)); } | |
| 48 | 48 | |
| 49 | t6834_state(running_machine &machine) { } | |
| 49 | t6834_state(running_machine &machine) | |
| 50 | : driver_data_t(machine) { } | |
| 50 | 51 | |
| 51 | 52 | /* General */ |
| 52 | 53 | UINT8 *ram; |
| r8714 | r8715 | |
| 113 | 114 | { |
| 114 | 115 | UINT16 address; |
| 115 | 116 | UINT8 p1, p2, p3, p4, i; |
| 116 | t6834_state *state = | |
| 117 | t6834_state *state = | |
| 117 | 118 | |
| 118 | 119 | switch (cmd) |
| 119 | 120 | { |
| r8714 | r8715 | |
| 500 | 501 | |
| 501 | 502 | static void receive_from_t6834 (running_machine *machine) |
| 502 | 503 | { |
| 503 | t6834_state *state = | |
| 504 | t6834_state *state = | |
| 504 | 505 | |
| 505 | 506 | state->regs_r[0] = 0x40; |
| 506 | 507 | state->regs_r[1] = state->out_data[state->out_pos]; |
| r8714 | r8715 | |
| 510 | 511 | |
| 511 | 512 | static void ack_from_t6834 (running_machine *machine) |
| 512 | 513 | { |
| 513 | t6834_state *state = | |
| 514 | t6834_state *state = | |
| 514 | 515 | |
| 515 | 516 | state->out_pos++; |
| 516 | 517 | state->regs_r[2] &= 0xfe; |
| r8714 | r8715 | |
| 524 | 525 | |
| 525 | 526 | static void send_to_t6834 (running_machine *machine) |
| 526 | 527 | { |
| 527 | t6834_state *state = | |
| 528 | t6834_state *state = | |
| 528 | 529 | |
| 529 | 530 | if (!state->in_size) |
| 530 | 531 | { |
| r8714 | r8715 | |
| 597 | 598 | ****************************************************/ |
| 598 | 599 | static void send_to_printer(running_machine *machine) |
| 599 | 600 | { |
| 600 | t6834_state *state = | |
| 601 | t6834_state *state = | |
| 601 | 602 | UINT16 char_pos = 0; |
| 602 | 603 | UINT16 text_color = 0; |
| 603 | 604 | UINT16 text_size = 1; |
| r8714 | r8715 | |
| 660 | 661 | |
| 661 | 662 | static void keyboard_scan(running_machine *machine) |
| 662 | 663 | { |
| 663 | t6834_state *state = | |
| 664 | t6834_state *state = | |
| 664 | 665 | static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8"}; |
| 665 | 666 | UINT8 row, col, val, kb_table = 0; |
| 666 | 667 | UINT16 f_ptr = 0; |
| r8714 | r8715 | |
| 767 | 768 | |
| 768 | 769 | static void irq_exec(running_machine *machine) |
| 769 | 770 | { |
| 770 | t6834_state *state = | |
| 771 | t6834_state *state = | |
| 771 | 772 | |
| 772 | 773 | if (state->kb_size) |
| 773 | 774 | { |
| r8714 | r8715 | |
| 807 | 808 | |
| 808 | 809 | static void draw_char(running_machine *machine, UINT8 x, UINT8 y, UINT8 char_pos) |
| 809 | 810 | { |
| 810 | t6834_state *state = | |
| 811 | t6834_state *state = | |
| 811 | 812 | UINT8 cl; |
| 812 | 813 | |
| 813 | 814 | if(x < 20 && y < 4) |
| r8714 | r8715 | |
| 825 | 826 | |
| 826 | 827 | static void draw_point(running_machine *machine, UINT8 x, UINT8 y, UINT8 color) |
| 827 | 828 | { |
| 828 | t6834_state *state = | |
| 829 | t6834_state *state = | |
| 829 | 830 | if((x) < 120 && (y) < 32) |
| 830 | 831 | state->lcd_map[y][x] = color; |
| 831 | 832 | } |
| r8714 | r8715 | |
| 833 | 834 | |
| 834 | 835 | static void draw_udk(running_machine *machine) |
| 835 | 836 | { |
| 836 | t6834_state *state = | |
| 837 | t6834_state *state = | |
| 837 | 838 | UINT8 i, x, j; |
| 838 | 839 | |
| 839 | 840 | for(i = 0, x = 0; i < 5; i++) |
| r8714 | r8715 | |
| 856 | 857 | |
| 857 | 858 | static VIDEO_UPDATE( x07 ) |
| 858 | 859 | { |
| 859 | t6834_state *state = | |
| 860 | t6834_state *state = | |
| 860 | 861 | static UINT8 cursor_blink = 0; |
| 861 | 862 | |
| 862 | 863 | cursor_blink++; |
| r8714 | r8715 | |
| 906 | 907 | |
| 907 | 908 | static READ8_HANDLER( x07_IO_r ) |
| 908 | 909 | { |
| 909 | t6834_state *state = | |
| 910 | t6834_state *state = | |
| 910 | 911 | UINT32 val = 0xff; |
| 911 | 912 | |
| 912 | 913 | switch(offset) |
| r8714 | r8715 | |
| 956 | 957 | |
| 957 | 958 | static WRITE8_HANDLER( x07_IO_w ) |
| 958 | 959 | { |
| 959 | t6834_state *state = | |
| 960 | t6834_state *state = | |
| 960 | 961 | |
| 961 | 962 | switch(offset) |
| 962 | 963 | { |
| r8714 | r8715 | |
| 1113 | 1114 | |
| 1114 | 1115 | static NVRAM_HANDLER( x07 ) |
| 1115 | 1116 | { |
| 1116 | t6834_state *state = | |
| 1117 | t6834_state *state = | |
| 1117 | 1118 | |
| 1118 | 1119 | if (read_or_write) |
| 1119 | 1120 | { |
| r8714 | r8715 | |
| 1154 | 1155 | |
| 1155 | 1156 | static TIMER_CALLBACK( keyboard_clear ) |
| 1156 | 1157 | { |
| 1157 | t6834_state *state = | |
| 1158 | t6834_state *state = | |
| 1158 | 1159 | |
| 1159 | 1160 | state->kb_wait = 0; |
| 1160 | 1161 | } |
| r8714 | r8715 | |
| 1182 | 1183 | |
| 1183 | 1184 | static MACHINE_START( x07 ) |
| 1184 | 1185 | { |
| 1185 | t6834_state *state = | |
| 1186 | t6834_state *state = | |
| 1186 | 1187 | |
| 1187 | 1188 | state->irq_clear = timer_alloc(machine, irq_clear, 0); |
| 1188 | 1189 | state->beep_clear = timer_alloc(machine, beep_stop, 0); |
| r8714 | r8715 | |
| 1236 | 1237 | |
| 1237 | 1238 | static MACHINE_RESET( x07 ) |
| 1238 | 1239 | { |
| 1239 | t6834_state *state = | |
| 1240 | t6834_state *state = | |
| 1240 | 1241 | |
| 1241 | 1242 | cpu_set_reg(machine->device("maincpu"), Z80_PC, 0xc3c3); |
| 1242 | 1243 |
| r8714 | r8715 | |
|---|---|---|
| 9 | 9 | #include "emu.h" |
| 10 | 10 | #include "cpu/z80/z80.h" |
| 11 | 11 | |
| 12 | class z9001_state | |
| 12 | class z9001_state : public driver_data_t | |
| 13 | 13 | { |
| 14 | 14 | public: |
| 15 | static | |
| 15 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, z9001_state(machine)); } | |
| 16 | 16 | |
| 17 | z9001_state(running_machine &machine) { } | |
| 17 | z9001_state(running_machine &machine) | |
| 18 | : driver_data_t(machine) { } | |
| 18 | 19 | |
| 19 | 20 | UINT8 *videoram; |
| 20 | 21 | }; |
| r8714 | r8715 | |
| 47 | 48 | |
| 48 | 49 | static VIDEO_UPDATE( z9001 ) |
| 49 | 50 | { |
| 50 | z9001_state *state = | |
| 51 | z9001_state *state = | |
| 51 | 52 | UINT8 code; |
| 52 | 53 | UINT8 line; |
| 53 | 54 | int y, x, j, b; |
| r8714 | r8715 | |
|---|---|---|
| 31 | 31 | |
| 32 | 32 | static TIMER_DEVICE_CALLBACK( keyboard_tick ) |
| 33 | 33 | { |
| 34 | amu880_state *state = | |
| 34 | amu880_state *state = | |
| 35 | 35 | |
| 36 | 36 | state->key_y++; |
| 37 | 37 | |
| r8714 | r8715 | |
| 57 | 57 | |
| 58 | 58 | */ |
| 59 | 59 | |
| 60 | amu880_state *state = | |
| 60 | amu880_state *state = | |
| 61 | 61 | |
| 62 | 62 | static const char *const keynames[] = { "Y0", "Y1", "Y2", "Y3", "Y4", "Y5", "Y6", "Y7", "Y8", "Y9", "Y10", "Y11", "Y12", "Y13", "Y14", "Y15" }; |
| 63 | 63 | |
| r8714 | r8715 | |
| 215 | 215 | |
| 216 | 216 | static VIDEO_START( amu880 ) |
| 217 | 217 | { |
| 218 | amu880_state *state = | |
| 218 | amu880_state *state = | |
| 219 | 219 | |
| 220 | 220 | /* find memory regions */ |
| 221 | 221 | state->char_rom = memory_region(machine, "chargen"); |
| r8714 | r8715 | |
| 223 | 223 | |
| 224 | 224 | static VIDEO_UPDATE( amu880 ) |
| 225 | 225 | { |
| 226 | amu880_state *state = | |
| 226 | amu880_state *state = | |
| 227 | 227 | |
| 228 | 228 | int y, sx, x, line; |
| 229 | 229 | |
| r8714 | r8715 | |
| 333 | 333 | |
| 334 | 334 | static MACHINE_START( amu880 ) |
| 335 | 335 | { |
| 336 | amu880_state *state = | |
| 336 | amu880_state *state = | |
| 337 | 337 | |
| 338 | 338 | /* find devices */ |
| 339 | 339 | state->cassette = machine->device(CASSETTE_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 62 | 62 | |
| 63 | 63 | static WRITE8_HANDLER( vlsi_w ) |
| 64 | 64 | { |
| 65 | vidbrain_state *state = | |
| 65 | vidbrain_state *state = | |
| 66 | 66 | |
| 67 | 67 | switch (offset) |
| 68 | 68 | { |
| r8714 | r8715 | |
| 116 | 116 | |
| 117 | 117 | */ |
| 118 | 118 | |
| 119 | vidbrain_state *state = | |
| 119 | vidbrain_state *state = | |
| 120 | 120 | |
| 121 | 121 | state->keylatch = data; |
| 122 | 122 | } |
| r8714 | r8715 | |
| 142 | 142 | |
| 143 | 143 | */ |
| 144 | 144 | |
| 145 | vidbrain_state *state = | |
| 145 | vidbrain_state *state = | |
| 146 | 146 | |
| 147 | 147 | UINT8 data = 0;//input_port_read(space->machine, "JOY-R"); |
| 148 | 148 | |
| r8714 | r8715 | |
| 180 | 180 | |
| 181 | 181 | */ |
| 182 | 182 | |
| 183 | vidbrain_state *state = | |
| 183 | vidbrain_state *state = | |
| 184 | 184 | |
| 185 | 185 | /* sound clock */ |
| 186 | 186 | int sound_clk = BIT(data, 7); |
| r8714 | r8715 | |
| 370 | 370 | |
| 371 | 371 | static VIDEO_UPDATE( vidbrain ) |
| 372 | 372 | { |
| 373 | vidbrain_state *state = | |
| 373 | vidbrain_state *state = | |
| 374 | 374 | |
| 375 | 375 | UINT16 addr = 0x2f; |
| 376 | 376 | |
| r8714 | r8715 | |
| 482 | 482 | |
| 483 | 483 | static MACHINE_START( vidbrain ) |
| 484 | 484 | { |
| 485 | vidbrain_state *state = | |
| 485 | vidbrain_state *state = | |
| 486 | 486 | |
| 487 | 487 | /* find devices */ |
| 488 | 488 | state->discrete = machine->device(DISCRETE_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 124 | 124 | |
| 125 | 125 | */ |
| 126 | 126 | |
| 127 | exp85_state *state = | |
| 127 | exp85_state *state = | |
| 128 | 128 | |
| 129 | 129 | /* tape control */ |
| 130 | 130 | state->tape_control = BIT(data, 0); |
| r8714 | r8715 | |
| 145 | 145 | |
| 146 | 146 | static WRITE_LINE_DEVICE_HANDLER( exp85_sod_w ) |
| 147 | 147 | { |
| 148 | exp85_state *driver_state = | |
| 148 | exp85_state *driver_state = | |
| 149 | 149 | |
| 150 | 150 | cassette_output(driver_state->cassette, state ? -1.0 : +1.0); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | static READ_LINE_DEVICE_HANDLER( exp85_sid_r ) |
| 154 | 154 | { |
| 155 | exp85_state *driver_state = | |
| 155 | exp85_state *driver_state = | |
| 156 | 156 | |
| 157 | 157 | int data = 1; |
| 158 | 158 | |
| r8714 | r8715 | |
| 176 | 176 | |
| 177 | 177 | static MACHINE_START( exp85 ) |
| 178 | 178 | { |
| 179 | exp85_state *state = | |
| 179 | exp85_state *state = | |
| 180 | 180 | const address_space *program = cputag_get_address_space(machine, I8085A_TAG, ADDRESS_SPACE_PROGRAM); |
| 181 | 181 | |
| 182 | 182 | /* setup memory banking */ |
| r8714 | r8715 | |
|---|---|---|
| 80 | 80 | |
| 81 | 81 | static void trs80m2_keyboard_scan(running_machine *machine) |
| 82 | 82 | { |
| 83 | trs80m2_state *state = | |
| 83 | trs80m2_state *state = | |
| 84 | 84 | |
| 85 | 85 | if (!state->kbirq) return; |
| 86 | 86 | |
| r8714 | r8715 | |
| 160 | 160 | |
| 161 | 161 | static void bankswitch(running_machine *machine) |
| 162 | 162 | { |
| 163 | trs80m2_state *state = | |
| 163 | trs80m2_state *state = | |
| 164 | 164 | |
| 165 | 165 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 166 | 166 | running_device *messram = machine->device("messram"); |
| r8714 | r8715 | |
| 214 | 214 | |
| 215 | 215 | */ |
| 216 | 216 | |
| 217 | trs80m2_state *state = | |
| 217 | trs80m2_state *state = | |
| 218 | 218 | |
| 219 | 219 | state->boot_rom = BIT(data, 0); |
| 220 | 220 | bankswitch(space->machine); |
| r8714 | r8715 | |
| 222 | 222 | |
| 223 | 223 | static READ8_HANDLER( keyboard_r ) |
| 224 | 224 | { |
| 225 | trs80m2_state *state = | |
| 225 | trs80m2_state *state = | |
| 226 | 226 | |
| 227 | 227 | /* clear keyboard interrupt */ |
| 228 | 228 | if (!state->kbirq) |
| r8714 | r8715 | |
| 261 | 261 | |
| 262 | 262 | */ |
| 263 | 263 | |
| 264 | trs80m2_state *state = | |
| 264 | trs80m2_state *state = | |
| 265 | 265 | |
| 266 | 266 | UINT8 data = 0; |
| 267 | 267 | |
| r8714 | r8715 | |
| 297 | 297 | |
| 298 | 298 | */ |
| 299 | 299 | |
| 300 | trs80m2_state *state = | |
| 300 | trs80m2_state *state = | |
| 301 | 301 | |
| 302 | 302 | /* memory bank select */ |
| 303 | 303 | state->bank = data & 0x0f; |
| r8714 | r8715 | |
| 325 | 325 | |
| 326 | 326 | //static READ8_HANDLER( keyboard_busy_r ) |
| 327 | 327 | //{ |
| 328 | // trs80m2_state *state = | |
| 328 | // trs80m2_state *state = | |
| 329 | 329 | // |
| 330 | 330 | // return state->kbirq; |
| 331 | 331 | //} |
| 332 | 332 | // |
| 333 | 333 | //static READ8_HANDLER( keyboard_data_r ) |
| 334 | 334 | //{ |
| 335 | // trs80m2_state *state = | |
| 335 | // trs80m2_state *state = | |
| 336 | 336 | // |
| 337 | 337 | // static const char *const KEY_ROW[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8", "ROW9", "ROW10", "ROW11" }; |
| 338 | 338 | // |
| r8714 | r8715 | |
| 356 | 356 | // |
| 357 | 357 | // */ |
| 358 | 358 | // |
| 359 | // trs80m2_state *state = | |
| 359 | // trs80m2_state *state = | |
| 360 | 360 | // |
| 361 | 361 | // int kbdata = BIT(data, 0); |
| 362 | 362 | // int kbclk = BIT(data, 1); |
| r8714 | r8715 | |
| 402 | 402 | // |
| 403 | 403 | // */ |
| 404 | 404 | // |
| 405 | // trs80m2_state *state = | |
| 405 | // trs80m2_state *state = | |
| 406 | 406 | // |
| 407 | 407 | // state->key_latch = BITSWAP8(data, 7, 6, 5, 4, 0, 1, 2, 3) & 0x0f; |
| 408 | 408 | //} |
| r8714 | r8715 | |
| 666 | 666 | |
| 667 | 667 | static MC6845_UPDATE_ROW( trs80m2_update_row ) |
| 668 | 668 | { |
| 669 | trs80m2_state *state = | |
| 669 | trs80m2_state *state = | |
| 670 | 670 | |
| 671 | 671 | for (int column = 0; column < x_count; column++) |
| 672 | 672 | { |
| r8714 | r8715 | |
| 693 | 693 | |
| 694 | 694 | static WRITE_LINE_DEVICE_HANDLER( de_w ) |
| 695 | 695 | { |
| 696 | trs80m2_state *driver_state = | |
| 696 | trs80m2_state *driver_state = | |
| 697 | 697 | |
| 698 | 698 | driver_state->de = state; |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | static WRITE_LINE_DEVICE_HANDLER( vsync_w ) |
| 702 | 702 | { |
| 703 | trs80m2_state *driver_state = | |
| 703 | trs80m2_state *driver_state = | |
| 704 | 704 | |
| 705 | 705 | if (state) |
| 706 | 706 | { |
| r8714 | r8715 | |
| 730 | 730 | |
| 731 | 731 | static VIDEO_START( trs80m2 ) |
| 732 | 732 | { |
| 733 | trs80m2_state *state = | |
| 733 | trs80m2_state *state = | |
| 734 | 734 | |
| 735 | 735 | /* find devices */ |
| 736 | 736 | state->mc6845 = machine->device(MC6845_TAG); |
| r8714 | r8715 | |
| 741 | 741 | |
| 742 | 742 | static VIDEO_UPDATE( trs80m2 ) |
| 743 | 743 | { |
| 744 | trs80m2_state *state = | |
| 744 | trs80m2_state *state = | |
| 745 | 745 | |
| 746 | 746 | if (state->blnkvid) |
| 747 | 747 | { |
| r8714 | r8715 | |
| 787 | 787 | |
| 788 | 788 | */ |
| 789 | 789 | |
| 790 | trs80m2_state *state = | |
| 790 | trs80m2_state *state = | |
| 791 | 791 | |
| 792 | 792 | UINT8 data = 0; |
| 793 | 793 | |
| r8714 | r8715 | |
| 829 | 829 | |
| 830 | 830 | */ |
| 831 | 831 | |
| 832 | trs80m2_state *state = | |
| 832 | trs80m2_state *state = | |
| 833 | 833 | |
| 834 | 834 | /* prime */ |
| 835 | 835 | centronics_prime_w(state->centronics, BIT(data, 3)); |
| r8714 | r8715 | |
| 882 | 882 | |
| 883 | 883 | static TIMER_DEVICE_CALLBACK( ctc_tick ) |
| 884 | 884 | { |
| 885 | trs80m2_state *state = | |
| 885 | trs80m2_state *state = | |
| 886 | 886 | |
| 887 | 887 | z80ctc_trg0_w(state->z80ctc, 1); |
| 888 | 888 | z80ctc_trg0_w(state->z80ctc, 0); |
| r8714 | r8715 | |
| 919 | 919 | |
| 920 | 920 | static WRITE_LINE_DEVICE_HANDLER( fdc_intrq_w ) |
| 921 | 921 | { |
| 922 | trs80m2_state *driver_state = | |
| 922 | trs80m2_state *driver_state = | |
| 923 | 923 | |
| 924 | 924 | driver_state->fdc_intrq = state; |
| 925 | 925 | |
| r8714 | r8715 | |
| 949 | 949 | |
| 950 | 950 | static MACHINE_START( trs80m2 ) |
| 951 | 951 | { |
| 952 | trs80m2_state *state = | |
| 952 | trs80m2_state *state = | |
| 953 | 953 | |
| 954 | 954 | /* find devices */ |
| 955 | 955 | state->z80ctc = machine->device(Z80CTC_TAG); |
| r8714 | r8715 | |
| 981 | 981 | |
| 982 | 982 | static MACHINE_RESET( trs80m2 ) |
| 983 | 983 | { |
| 984 | trs80m2_state *state = | |
| 984 | trs80m2_state *state = | |
| 985 | 985 | |
| 986 | 986 | /* clear keyboard interrupt */ |
| 987 | 987 | state->kbirq = 1; |
| r8714 | r8715 | |
|---|---|---|
| 14 | 14 | DEFINE_LEGACY_SOUND_DEVICE(PV1000,pv1000_sound); |
| 15 | 15 | |
| 16 | 16 | |
| 17 | class d65010_state { | |
| 17 | class d65010_state : public driver_data_t { | |
| 18 | 18 | public: |
| 19 | static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, d65010_state(machine)); } | |
| 20 | d65010_state(running_machine &machine) { } | |
| 19 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, d65010_state(machine)); } | |
| 20 | d65010_state(running_machine &machine) | |
| 21 | : driver_data_t(machine) { } | |
| 21 | 22 | |
| 22 | 23 | UINT8 io_regs[8]; |
| 23 | 24 | UINT8 fd_data; |
| r8714 | r8715 | |
| 69 | 70 | |
| 70 | 71 | static WRITE8_HANDLER( pv1000_io_w ) |
| 71 | 72 | { |
| 72 | d65010_state *state = | |
| 73 | d65010_state *state = | |
| 73 | 74 | |
| 74 | 75 | switch ( offset ) |
| 75 | 76 | { |
| r8714 | r8715 | |
| 95 | 96 | |
| 96 | 97 | static READ8_HANDLER( pv1000_io_r ) |
| 97 | 98 | { |
| 98 | d65010_state *state = | |
| 99 | d65010_state *state = | |
| 99 | 100 | UINT8 data = state->io_regs[offset]; |
| 100 | 101 | |
| 101 | 102 | // logerror("pv1000_io_r offset=%02x\n", offset ); |
| r8714 | r8715 | |
| 213 | 214 | |
| 214 | 215 | static VIDEO_UPDATE( pv1000 ) |
| 215 | 216 | { |
| 216 | d65010_state *state = | |
| 217 | d65010_state *state = | |
| 217 | 218 | int x, y; |
| 218 | 219 | |
| 219 | 220 | for ( y = 0; y < 24; y++ ) |
| r8714 | r8715 | |
| 251 | 252 | |
| 252 | 253 | static STREAM_UPDATE( pv1000_sound_update ) |
| 253 | 254 | { |
| 254 | d65010_state *state = | |
| 255 | d65010_state *state = | |
| 255 | 256 | stream_sample_t *buffer = outputs[0]; |
| 256 | 257 | |
| 257 | 258 | while ( samples > 0 ) |
| r8714 | r8715 | |
| 284 | 285 | |
| 285 | 286 | static DEVICE_START( pv1000_sound ) |
| 286 | 287 | { |
| 287 | d65010_state *state = | |
| 288 | d65010_state *state = | |
| 288 | 289 | state->sh_channel = stream_create( device, 0, 1, device->clock()/1024, 0, pv1000_sound_update ); |
| 289 | 290 | } |
| 290 | 291 | |
| r8714 | r8715 | |
| 307 | 308 | /* we have chosen to trigger on scanlines 195, 199, 203, 207, 211, 215, 219, 223, 227, 231, 235, 239, 243, 247, 251, 255 */ |
| 308 | 309 | static TIMER_CALLBACK( d65010_irq_on_cb ) |
| 309 | 310 | { |
| 310 | d65010_state *state = | |
| 311 | d65010_state *state = | |
| 311 | 312 | int vpos = state->screen->vpos(); |
| 312 | 313 | int next_vpos = vpos + 12; |
| 313 | 314 | |
| r8714 | r8715 | |
| 326 | 327 | |
| 327 | 328 | static TIMER_CALLBACK( d65010_irq_off_cb ) |
| 328 | 329 | { |
| 329 | d65010_state *state = | |
| 330 | d65010_state *state = | |
| 330 | 331 | |
| 331 | 332 | cpu_set_input_line( state->maincpu, 0, CLEAR_LINE ); |
| 332 | 333 | } |
| r8714 | r8715 | |
| 334 | 335 | |
| 335 | 336 | static MACHINE_START( pv1000 ) |
| 336 | 337 | { |
| 337 | d65010_state *state = | |
| 338 | d65010_state *state = | |
| 338 | 339 | |
| 339 | 340 | state->irq_on_timer = timer_alloc( machine, d65010_irq_on_cb, NULL ); |
| 340 | 341 | state->irq_off_timer = timer_alloc( machine, d65010_irq_off_cb, NULL ); |
| r8714 | r8715 | |
| 345 | 346 | |
| 346 | 347 | static MACHINE_RESET( pv1000 ) |
| 347 | 348 | { |
| 348 | d65010_state *state = | |
| 349 | d65010_state *state = | |
| 349 | 350 | |
| 350 | 351 | state->io_regs[5] = 0; |
| 351 | 352 | state->fd_data = 0; |
| r8714 | r8715 | |
|---|---|---|
| 82 | 82 | |
| 83 | 83 | static READ8_HANDLER(mac_asc_r) |
| 84 | 84 | { |
| 85 | mac_state *mac = | |
| 85 | mac_state *mac = | |
| 86 | 86 | |
| 87 | 87 | logerror("ASC: Read @ %x (PC %x)\n", offset, cpu_get_pc(space->machine->device("maincpu"))); |
| 88 | 88 | |
| r8714 | r8715 | |
| 121 | 121 | { |
| 122 | 122 | static dmadac_sound_device *dacs[2]; |
| 123 | 123 | INT32 i; |
| 124 | mac_state *mac = | |
| 124 | mac_state *mac = | |
| 125 | 125 | |
| 126 | 126 | logerror("ASC: %02x to %x (PC %x)\n", data, offset, cpu_get_pc(space->machine->device("maincpu"))); |
| 127 | 127 |
| r8714 | r8715 | |
|---|---|---|
| 58 | 58 | /* PI-5 interface is required. mode 2 of the 8255 is used to communicate with the FD-5 */ |
| 59 | 59 | |
| 60 | 60 | |
| 61 | class sord_state | |
| 61 | class sord_state : public driver_data_t | |
| 62 | 62 | { |
| 63 | 63 | public: |
| 64 | static | |
| 64 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sord_state(machine)); } | |
| 65 | 65 | |
| 66 | sord_state(running_machine &machine) { } | |
| 66 | sord_state(running_machine &machine) | |
| 67 | : driver_data_t(machine) { } | |
| 67 | 68 | |
| 68 | 69 | UINT8 fd5_databus; |
| 69 | 70 | int fd5_port_0x020_data; |
| r8714 | r8715 | |
| 83 | 84 | /* stb and ack automatically set on read/write? */ |
| 84 | 85 | static WRITE8_HANDLER(fd5_communication_w) |
| 85 | 86 | { |
| 86 | sord_state *state = | |
| 87 | sord_state *state = | |
| 87 | 88 | |
| 88 | 89 | cpu_yield(space->cpu); |
| 89 | 90 | |
| r8714 | r8715 | |
| 93 | 94 | |
| 94 | 95 | static READ8_HANDLER(fd5_communication_r) |
| 95 | 96 | { |
| 96 | sord_state *state = | |
| 97 | sord_state *state = | |
| 97 | 98 | int data; |
| 98 | 99 | |
| 99 | 100 | cpu_yield(space->cpu); |
| r8714 | r8715 | |
| 106 | 107 | |
| 107 | 108 | static READ8_HANDLER(fd5_data_r) |
| 108 | 109 | { |
| 109 | sord_state *state = | |
| 110 | sord_state *state = | |
| 110 | 111 | |
| 111 | 112 | cpu_yield(space->cpu); |
| 112 | 113 | |
| r8714 | r8715 | |
| 121 | 122 | |
| 122 | 123 | static WRITE8_HANDLER(fd5_data_w) |
| 123 | 124 | { |
| 124 | sord_state *state = | |
| 125 | sord_state *state = | |
| 125 | 126 | |
| 126 | 127 | LOG(("fd5 0x010 w: %02x %04x\n",data,cpu_get_pc(space->cpu))); |
| 127 | 128 | |
| r8714 | r8715 | |
| 201 | 202 | |
| 202 | 203 | static READ8_DEVICE_HANDLER(sord_ppi_porta_r) |
| 203 | 204 | { |
| 204 | sord_state *state = | |
| 205 | sord_state *state = | |
| 205 | 206 | |
| 206 | 207 | cpu_yield(device->machine->device("maincpu")); |
| 207 | 208 | |
| r8714 | r8715 | |
| 219 | 220 | |
| 220 | 221 | static READ8_DEVICE_HANDLER(sord_ppi_portc_r) |
| 221 | 222 | { |
| 222 | sord_state *state = | |
| 223 | sord_state *state = | |
| 223 | 224 | |
| 224 | 225 | cpu_yield(device->machine->device("maincpu")); |
| 225 | 226 | |
| r8714 | r8715 | |
| 252 | 253 | |
| 253 | 254 | static WRITE8_DEVICE_HANDLER(sord_ppi_porta_w) |
| 254 | 255 | { |
| 255 | sord_state *state = | |
| 256 | sord_state *state = | |
| 256 | 257 | |
| 257 | 258 | cpu_yield(device->machine->device("maincpu")); |
| 258 | 259 | |
| r8714 | r8715 | |
| 283 | 284 | |
| 284 | 285 | static WRITE8_DEVICE_HANDLER(sord_ppi_portc_w) |
| 285 | 286 | { |
| 286 | sord_state *state = | |
| 287 | sord_state *state = | |
| 287 | 288 | |
| 288 | 289 | state->obfa = (data & 0x80) ? 1 : 0; |
| 289 | 290 | state->intra = (data & 0x08) ? 1 : 0; |
| r8714 | r8715 | |
|---|---|---|
| 54 | 54 | |
| 55 | 55 | static void bw12_bankswitch(running_machine *machine) |
| 56 | 56 | { |
| 57 | bw12_state *state = | |
| 57 | bw12_state *state = | |
| 58 | 58 | |
| 59 | 59 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 60 | 60 | |
| r8714 | r8715 | |
| 87 | 87 | |
| 88 | 88 | static TIMER_CALLBACK( floppy_motor_off_tick ) |
| 89 | 89 | { |
| 90 | bw12_state *state = | |
| 90 | bw12_state *state = | |
| 91 | 91 | |
| 92 | 92 | floppy_mon_w(get_floppy_image(machine, 0), ASSERT_LINE); |
| 93 | 93 | floppy_mon_w(get_floppy_image(machine, 1), ASSERT_LINE); |
| r8714 | r8715 | |
| 100 | 100 | |
| 101 | 101 | static void bw12_set_floppy_motor_off_timer(running_machine *machine) |
| 102 | 102 | { |
| 103 | bw12_state *state = | |
| 103 | bw12_state *state = | |
| 104 | 104 | |
| 105 | 105 | if (state->motor0 || state->motor1) |
| 106 | 106 | { |
| r8714 | r8715 | |
| 122 | 122 | |
| 123 | 123 | static void ls259_w(running_machine *machine, int address, int data) |
| 124 | 124 | { |
| 125 | bw12_state *state = | |
| 125 | bw12_state *state = | |
| 126 | 126 | |
| 127 | 127 | switch (address) |
| 128 | 128 | { |
| r8714 | r8715 | |
| 363 | 363 | |
| 364 | 364 | static MC6845_UPDATE_ROW( bw12_update_row ) |
| 365 | 365 | { |
| 366 | bw12_state *state = | |
| 366 | bw12_state *state = | |
| 367 | 367 | |
| 368 | 368 | int column, bit; |
| 369 | 369 | |
| r8714 | r8715 | |
| 406 | 406 | |
| 407 | 407 | static VIDEO_START( bw12 ) |
| 408 | 408 | { |
| 409 | bw12_state *state = | |
| 409 | bw12_state *state = | |
| 410 | 410 | |
| 411 | 411 | /* find devices */ |
| 412 | 412 | state->mc6845 = machine->device(MC6845_TAG); |
| r8714 | r8715 | |
| 417 | 417 | |
| 418 | 418 | static VIDEO_UPDATE( bw12 ) |
| 419 | 419 | { |
| 420 | bw12_state *state = | |
| 420 | bw12_state *state = | |
| 421 | 421 | |
| 422 | 422 | mc6845_update(state->mc6845, bitmap, cliprect); |
| 423 | 423 | |
| r8714 | r8715 | |
| 428 | 428 | |
| 429 | 429 | static WRITE_LINE_DEVICE_HANDLER( bw12_upd765_interrupt ) |
| 430 | 430 | { |
| 431 | bw12_state *driver_state = | |
| 431 | bw12_state *driver_state = | |
| 432 | 432 | |
| 433 | 433 | driver_state->fdcint = state; |
| 434 | 434 | } |
| r8714 | r8715 | |
| 476 | 476 | |
| 477 | 477 | */ |
| 478 | 478 | |
| 479 | bw12_state *state = | |
| 479 | bw12_state *state = | |
| 480 | 480 | |
| 481 | 481 | UINT8 data = 0; |
| 482 | 482 | |
| r8714 | r8715 | |
| 494 | 494 | |
| 495 | 495 | static READ_LINE_DEVICE_HANDLER( bw12_pia6821_cb1_r ) |
| 496 | 496 | { |
| 497 | bw12_state *state = | |
| 497 | bw12_state *state = | |
| 498 | 498 | |
| 499 | 499 | return state->key_stb; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | static WRITE_LINE_DEVICE_HANDLER( bw12_pia6821_cb2_w ) |
| 503 | 503 | { |
| 504 | bw12_state *driver_state = | |
| 504 | bw12_state *driver_state = | |
| 505 | 505 | |
| 506 | 506 | if (state) |
| 507 | 507 | { |
| r8714 | r8715 | |
| 572 | 572 | |
| 573 | 573 | static WRITE_LINE_DEVICE_HANDLER( bw12_pit8253_out2_w ) |
| 574 | 574 | { |
| 575 | bw12_state *driver_state = | |
| 575 | bw12_state *driver_state = | |
| 576 | 576 | |
| 577 | 577 | /* PIA6821 PA4 */ |
| 578 | 578 | driver_state->pit_out2 = state; |
| r8714 | r8715 | |
| 633 | 633 | |
| 634 | 634 | static WRITE_LINE_DEVICE_HANDLER( bw2_ay3600_data_ready_w ) |
| 635 | 635 | { |
| 636 | bw12_state *driver_state = | |
| 636 | bw12_state *driver_state = | |
| 637 | 637 | |
| 638 | 638 | driver_state->key_stb = state; |
| 639 | 639 | |
| r8714 | r8715 | |
| 671 | 671 | |
| 672 | 672 | static MACHINE_START( bw12 ) |
| 673 | 673 | { |
| 674 | bw12_state *state = | |
| 674 | bw12_state *state = | |
| 675 | 675 | |
| 676 | 676 | /* find devices */ |
| 677 | 677 | state->pia6821 = machine->device(PIA6821_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 11 | 11 | |
| 12 | 12 | static DIRECT_UPDATE_HANDLER( pentagon_direct ) |
| 13 | 13 | { |
| 14 | spectrum_state *state = | |
| 14 | spectrum_state *state = | |
| 15 | 15 | running_device *beta = space->machine->device(BETA_DISK_TAG); |
| 16 | 16 | UINT16 pc = cpu_get_reg(space->machine->device("maincpu"), STATE_GENPCBASE); |
| 17 | 17 | |
| r8714 | r8715 | |
| 48 | 48 | |
| 49 | 49 | static void pentagon_update_memory(running_machine *machine) |
| 50 | 50 | { |
| 51 | spectrum_state *state = | |
| 51 | spectrum_state *state = | |
| 52 | 52 | running_device *beta = machine->device(BETA_DISK_TAG); |
| 53 | 53 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 54 | 54 | state->screen_location = messram + ((state->port_7ffd_data & 8) ? (7<<14) : (5<<14)); |
| r8714 | r8715 | |
| 74 | 74 | |
| 75 | 75 | static WRITE8_HANDLER(pentagon_port_7ffd_w) |
| 76 | 76 | { |
| 77 | spectrum_state *state = | |
| 77 | spectrum_state *state = | |
| 78 | 78 | |
| 79 | 79 | /* disable paging */ |
| 80 | 80 | if (state->port_7ffd_data & 0x20) |
| r8714 | r8715 | |
| 102 | 102 | |
| 103 | 103 | static MACHINE_RESET( pentagon ) |
| 104 | 104 | { |
| 105 | spectrum_state *state = | |
| 105 | spectrum_state *state = | |
| 106 | 106 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 107 | 107 | running_device *beta = machine->device(BETA_DISK_TAG); |
| 108 | 108 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| r8714 | r8715 | |
|---|---|---|
| 117 | 117 | }; |
| 118 | 118 | |
| 119 | 119 | |
| 120 | class ngp_state | |
| 120 | class ngp_state : public driver_data_t | |
| 121 | 121 | { |
| 122 | 122 | public: |
| 123 | static | |
| 123 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ngp_state(machine)); } | |
| 124 | 124 | |
| 125 | ngp_state(running_machine &machine) { } | |
| 125 | ngp_state(running_machine &machine) | |
| 126 | : driver_data_t(machine) { } | |
| 126 | 127 | |
| 127 | 128 | UINT8 io_reg[0x40]; |
| 128 | 129 | UINT8 old_to3; |
| r8714 | r8715 | |
| 149 | 150 | |
| 150 | 151 | static TIMER_CALLBACK( ngp_seconds_callback ) |
| 151 | 152 | { |
| 152 | ngp_state *state = | |
| 153 | ngp_state *state = | |
| 153 | 154 | |
| 154 | 155 | state->io_reg[0x16] += 1; |
| 155 | 156 | if ( ( state->io_reg[0x16] & 0x0f ) == 0x0a ) |
| r8714 | r8715 | |
| 184 | 185 | |
| 185 | 186 | static READ8_HANDLER( ngp_io_r ) |
| 186 | 187 | { |
| 187 | ngp_state *state = | |
| 188 | ngp_state *state = | |
| 188 | 189 | UINT8 data = state->io_reg[offset]; |
| 189 | 190 | |
| 190 | 191 | switch( offset ) |
| r8714 | r8715 | |
| 204 | 205 | |
| 205 | 206 | static WRITE8_HANDLER( ngp_io_w ) |
| 206 | 207 | { |
| 207 | ngp_state *state = | |
| 208 | ngp_state *state = | |
| 208 | 209 | |
| 209 | 210 | switch( offset ) |
| 210 | 211 | { |
| r8714 | r8715 | |
| 472 | 473 | |
| 473 | 474 | static WRITE8_HANDLER( flash0_w ) |
| 474 | 475 | { |
| 475 | ngp_state *state = | |
| 476 | ngp_state *state = | |
| 476 | 477 | |
| 477 | 478 | flash_w( state, 0, offset, data ); |
| 478 | 479 | } |
| r8714 | r8715 | |
| 480 | 481 | |
| 481 | 482 | static WRITE8_HANDLER( flash1_w ) |
| 482 | 483 | { |
| 483 | ngp_state *state = | |
| 484 | ngp_state *state = | |
| 484 | 485 | |
| 485 | 486 | flash_w( state, 1, offset, data ); |
| 486 | 487 | } |
| r8714 | r8715 | |
| 500 | 501 | |
| 501 | 502 | static READ8_HANDLER( ngp_z80_comm_r ) |
| 502 | 503 | { |
| 503 | ngp_state *state = | |
| 504 | ngp_state *state = | |
| 504 | 505 | |
| 505 | 506 | return state->io_reg[0x3c]; |
| 506 | 507 | } |
| r8714 | r8715 | |
| 508 | 509 | |
| 509 | 510 | static WRITE8_HANDLER( ngp_z80_comm_w ) |
| 510 | 511 | { |
| 511 | ngp_state *state = | |
| 512 | ngp_state *state = | |
| 512 | 513 | |
| 513 | 514 | state->io_reg[0x3c] = data; |
| 514 | 515 | } |
| r8714 | r8715 | |
| 516 | 517 | |
| 517 | 518 | static WRITE8_HANDLER( ngp_z80_signal_main_w ) |
| 518 | 519 | { |
| 519 | ngp_state *state = | |
| 520 | ngp_state *state = | |
| 520 | 521 | |
| 521 | 522 | cpu_set_input_line( state->tlcs900, TLCS900_INT5, ASSERT_LINE ); |
| 522 | 523 | } |
| r8714 | r8715 | |
| 532 | 533 | |
| 533 | 534 | static WRITE8_HANDLER( ngp_z80_clear_irq ) |
| 534 | 535 | { |
| 535 | ngp_state *state = | |
| 536 | ngp_state *state = | |
| 536 | 537 | |
| 537 | 538 | cpu_set_input_line( state->z80, 0, CLEAR_LINE ); |
| 538 | 539 | |
| r8714 | r8715 | |
| 548 | 549 | |
| 549 | 550 | static INPUT_CHANGED( power_callback ) |
| 550 | 551 | { |
| 551 | ngp_state *state = | |
| 552 | ngp_state *state = | |
| 552 | 553 | |
| 553 | 554 | if ( state->io_reg[0x33] & 0x04 ) |
| 554 | 555 | { |
| r8714 | r8715 | |
| 576 | 577 | |
| 577 | 578 | static WRITE8_DEVICE_HANDLER( ngp_vblank_pin_w ) |
| 578 | 579 | { |
| 579 | ngp_state *state = | |
| 580 | ngp_state *state = | |
| 580 | 581 | |
| 581 | 582 | cpu_set_input_line( state->tlcs900, TLCS900_INT4, data ? ASSERT_LINE : CLEAR_LINE ); |
| 582 | 583 | } |
| r8714 | r8715 | |
| 584 | 585 | |
| 585 | 586 | static WRITE8_DEVICE_HANDLER( ngp_hblank_pin_w ) |
| 586 | 587 | { |
| 587 | ngp_state *state = | |
| 588 | ngp_state *state = | |
| 588 | 589 | |
| 589 | 590 | cpu_set_input_line( state->tlcs900, TLCS900_TIO, data ? ASSERT_LINE : CLEAR_LINE ); |
| 590 | 591 | } |
| r8714 | r8715 | |
| 592 | 593 | |
| 593 | 594 | static WRITE8_DEVICE_HANDLER( ngp_tlcs900_to3 ) |
| 594 | 595 | { |
| 595 | ngp_state *state = | |
| 596 | ngp_state *state = | |
| 596 | 597 | |
| 597 | 598 | if ( data && ! state->old_to3 ) |
| 598 | 599 | cpu_set_input_line( state->z80, 0, ASSERT_LINE ); |
| r8714 | r8715 | |
| 603 | 604 | |
| 604 | 605 | static MACHINE_START( ngp ) |
| 605 | 606 | { |
| 606 | ngp_state *state = | |
| 607 | ngp_state *state = | |
| 607 | 608 | |
| 608 | 609 | state->seconds_timer = timer_alloc( machine, ngp_seconds_callback, NULL ); |
| 609 | 610 | timer_adjust_periodic( state->seconds_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(1) ); |
| r8714 | r8715 | |
| 612 | 613 | |
| 613 | 614 | static MACHINE_RESET( ngp ) |
| 614 | 615 | { |
| 615 | ngp_state *state = | |
| 616 | ngp_state *state = | |
| 616 | 617 | |
| 617 | 618 | state->old_to3 = 0; |
| 618 | 619 | state->tlcs900 = machine->device( "maincpu" ); |
| r8714 | r8715 | |
| 629 | 630 | |
| 630 | 631 | static VIDEO_UPDATE( ngp ) |
| 631 | 632 | { |
| 632 | ngp_state *state = | |
| 633 | ngp_state *state = | |
| 633 | 634 | |
| 634 | 635 | k1ge_update( state->k1ge, bitmap, cliprect ); |
| 635 | 636 | return 0; |
| r8714 | r8715 | |
| 638 | 639 | |
| 639 | 640 | static DEVICE_START( ngp_cart ) |
| 640 | 641 | { |
| 641 | ngp_state *state = | |
| 642 | ngp_state *state = | |
| 642 | 643 | UINT8 *cart = memory_region(device->machine, "cart"); |
| 643 | 644 | |
| 644 | 645 | state->flash_chip[0].present = 0; |
| r8714 | r8715 | |
| 653 | 654 | |
| 654 | 655 | static DEVICE_IMAGE_LOAD( ngp_cart ) |
| 655 | 656 | { |
| 656 | ngp_state *state = | |
| 657 | ngp_state *state = | |
| 657 | 658 | UINT32 filesize; |
| 658 | 659 | |
| 659 | 660 | if (image.software_entry() == NULL) |
| r8714 | r8715 | |
| 742 | 743 | |
| 743 | 744 | static DEVICE_IMAGE_UNLOAD( ngp_cart ) |
| 744 | 745 | { |
| 745 | ngp_state *state = | |
| 746 | ngp_state *state = | |
| 746 | 747 | |
| 747 | 748 | state->flash_chip[0].present = 0; |
| 748 | 749 | state->flash_chip[0].state = F_READ; |
| r8714 | r8715 | |
|---|---|---|
| 38 | 38 | |
| 39 | 39 | static WRITE8_HANDLER(nes_vh_sprite_dma_w) |
| 40 | 40 | { |
| 41 | nes_state *state = | |
| 41 | nes_state *state = | |
| 42 | 42 | ppu2c0x_spriteram_dma(space, state->ppu, data); |
| 43 | 43 | } |
| 44 | 44 |
| r8714 | r8715 | |
|---|---|---|
| 85 | 85 | |
| 86 | 86 | static TIMER_DEVICE_CALLBACK( ne556_cursor_callback ) |
| 87 | 87 | { |
| 88 | mz_state *mz = | |
| 88 | mz_state *mz = | |
| 89 | 89 | mz->cursor_timer ^= 1; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | static TIMER_DEVICE_CALLBACK( ne556_other_callback ) |
| 93 | 93 | { |
| 94 | mz_state *mz = | |
| 94 | mz_state *mz = | |
| 95 | 95 | mz->other_timer ^= 1; |
| 96 | 96 | } |
| 97 | 97 |
| r8714 | r8715 | |
|---|---|---|
| 88 | 88 | |
| 89 | 89 | static void prof80_keyboard_scan(running_machine *machine) |
| 90 | 90 | { |
| 91 | prof80_state *state = | |
| 91 | prof80_state *state = | |
| 92 | 92 | |
| 93 | 93 | static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8" }; |
| 94 | 94 | int table = 0, row, col; |
| r8714 | r8715 | |
| 136 | 136 | |
| 137 | 137 | static TIMER_DEVICE_CALLBACK( keyboard_tick ) |
| 138 | 138 | { |
| 139 | prof80_state *state = | |
| 139 | prof80_state *state = | |
| 140 | 140 | |
| 141 | 141 | if (!state->kbf) prof80_keyboard_scan(timer.machine); |
| 142 | 142 | } |
| r8714 | r8715 | |
| 151 | 151 | |
| 152 | 152 | static void prof80_bankswitch(running_machine *machine) |
| 153 | 153 | { |
| 154 | prof80_state *state = | |
| 154 | prof80_state *state = | |
| 155 | 155 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 156 | 156 | UINT8 *ram = messram_get_ptr(machine->device("messram")); |
| 157 | 157 | UINT8 *rom = memory_region(machine, Z80_TAG); |
| r8714 | r8715 | |
| 195 | 195 | |
| 196 | 196 | static TIMER_CALLBACK( floppy_motor_off_tick ) |
| 197 | 197 | { |
| 198 | prof80_state *state = | |
| 198 | prof80_state *state = | |
| 199 | 199 | |
| 200 | 200 | floppy_mon_w(floppy_get_device(machine, 0), ASSERT_LINE); |
| 201 | 201 | floppy_mon_w(floppy_get_device(machine, 1), ASSERT_LINE); |
| r8714 | r8715 | |
| 207 | 207 | |
| 208 | 208 | static void ls259_w(running_machine *machine, int fa, int sa, int fb, int sb) |
| 209 | 209 | { |
| 210 | prof80_state *state = | |
| 210 | prof80_state *state = | |
| 211 | 211 | |
| 212 | 212 | switch (sa) |
| 213 | 213 | { |
| r8714 | r8715 | |
| 346 | 346 | |
| 347 | 347 | */ |
| 348 | 348 | |
| 349 | prof80_state *state = | |
| 349 | prof80_state *state = | |
| 350 | 350 | |
| 351 | 351 | return (state->fdc_index << 5) | 0x01; |
| 352 | 352 | } |
| r8714 | r8715 | |
| 368 | 368 | |
| 369 | 369 | */ |
| 370 | 370 | |
| 371 | prof80_state *state = | |
| 371 | prof80_state *state = | |
| 372 | 372 | UINT8 data = 0; |
| 373 | 373 | int js4 = 0, js5 = 0; |
| 374 | 374 | |
| r8714 | r8715 | |
| 407 | 407 | |
| 408 | 408 | static WRITE8_HANDLER( par_w ) |
| 409 | 409 | { |
| 410 | prof80_state *state = | |
| 410 | prof80_state *state = | |
| 411 | 411 | |
| 412 | 412 | int bank = offset >> 12; |
| 413 | 413 | |
| r8714 | r8715 | |
| 420 | 420 | |
| 421 | 421 | static READ8_HANDLER( gripc_r ) |
| 422 | 422 | { |
| 423 | prof80_state *state = | |
| 423 | prof80_state *state = | |
| 424 | 424 | |
| 425 | 425 | //logerror("GRIP status read %02x\n", state->gripc); |
| 426 | 426 | |
| r8714 | r8715 | |
| 429 | 429 | |
| 430 | 430 | static READ8_HANDLER( gripd_r ) |
| 431 | 431 | { |
| 432 | prof80_state *state = | |
| 432 | prof80_state *state = | |
| 433 | 433 | |
| 434 | 434 | //logerror("GRIP data read %02x\n", state->gripd); |
| 435 | 435 | |
| r8714 | r8715 | |
| 442 | 442 | |
| 443 | 443 | static WRITE8_HANDLER( gripd_w ) |
| 444 | 444 | { |
| 445 | prof80_state *state = | |
| 445 | prof80_state *state = | |
| 446 | 446 | |
| 447 | 447 | state->gripd = data; |
| 448 | 448 | //logerror("GRIP data write %02x\n", data); |
| r8714 | r8715 | |
| 456 | 456 | |
| 457 | 457 | static WRITE8_HANDLER( vol0_w ) |
| 458 | 458 | { |
| 459 | prof80_state *state = | |
| 459 | prof80_state *state = | |
| 460 | 460 | |
| 461 | 461 | state->vol0 = BIT(data, 7); |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | static WRITE8_HANDLER( vol1_w ) |
| 465 | 465 | { |
| 466 | prof80_state *state = | |
| 466 | prof80_state *state = | |
| 467 | 467 | |
| 468 | 468 | state->vol1 = BIT(data, 7); |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | static WRITE8_HANDLER( flash_w ) |
| 472 | 472 | { |
| 473 | prof80_state *state = | |
| 473 | prof80_state *state = | |
| 474 | 474 | |
| 475 | 475 | state->flash = BIT(data, 7); |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | static WRITE8_HANDLER( page_w ) |
| 479 | 479 | { |
| 480 | prof80_state *state = | |
| 480 | prof80_state *state = | |
| 481 | 481 | |
| 482 | 482 | state->page = BIT(data, 7); |
| 483 | 483 | |
| r8714 | r8715 | |
| 501 | 501 | |
| 502 | 502 | */ |
| 503 | 503 | |
| 504 | prof80_state *state = | |
| 504 | prof80_state *state = | |
| 505 | 505 | UINT8 data = 0; |
| 506 | 506 | int js0 = 0, js1 = 0; |
| 507 | 507 | |
| r8714 | r8715 | |
| 540 | 540 | |
| 541 | 541 | static READ8_HANDLER( lrs_r ) |
| 542 | 542 | { |
| 543 | prof80_state *state = | |
| 543 | prof80_state *state = | |
| 544 | 544 | |
| 545 | 545 | state->lps = 0; |
| 546 | 546 | |
| r8714 | r8715 | |
| 549 | 549 | |
| 550 | 550 | static WRITE8_HANDLER( lrs_w ) |
| 551 | 551 | { |
| 552 | prof80_state *state = | |
| 552 | prof80_state *state = | |
| 553 | 553 | |
| 554 | 554 | state->lps = 0; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | static READ8_HANDLER( cxstb_r ) |
| 558 | 558 | { |
| 559 | prof80_state *state = | |
| 559 | prof80_state *state = | |
| 560 | 560 | |
| 561 | 561 | centronics_strobe_w(state->centronics, 0); |
| 562 | 562 | centronics_strobe_w(state->centronics, 1); |
| r8714 | r8715 | |
| 566 | 566 | |
| 567 | 567 | static WRITE8_HANDLER( cxstb_w ) |
| 568 | 568 | { |
| 569 | prof80_state *state = | |
| 569 | prof80_state *state = | |
| 570 | 570 | |
| 571 | 571 | centronics_strobe_w(state->centronics, 0); |
| 572 | 572 | centronics_strobe_w(state->centronics, 1); |
| r8714 | r8715 | |
| 576 | 576 | |
| 577 | 577 | static WRITE8_HANDLER( unio_ctrl_w ) |
| 578 | 578 | { |
| 579 | // prof80_state *state = | |
| 579 | // prof80_state *state = | |
| 580 | 580 | |
| 581 | 581 | // int flag = BIT(data, 0); |
| 582 | 582 | int flad = (data >> 1) & 0x07; |
| r8714 | r8715 | |
| 944 | 944 | |
| 945 | 945 | static MC6845_UPDATE_ROW( grip_update_row ) |
| 946 | 946 | { |
| 947 | prof80_state *state = | |
| 947 | prof80_state *state = | |
| 948 | 948 | int column, bit; |
| 949 | 949 | |
| 950 | 950 | for (column = 0; column < x_count; column++) |
| r8714 | r8715 | |
| 982 | 982 | |
| 983 | 983 | static VIDEO_UPDATE( grip ) |
| 984 | 984 | { |
| 985 | prof80_state *state = | |
| 985 | prof80_state *state = | |
| 986 | 986 | |
| 987 | 987 | mc6845_update(state->mc6845, bitmap, cliprect); |
| 988 | 988 | |
| r8714 | r8715 | |
| 1001 | 1001 | |
| 1002 | 1002 | static void prof80_fdc_index_callback(running_device *controller, running_device *img, int state) |
| 1003 | 1003 | { |
| 1004 | prof80_state *driver_state = | |
| 1004 | prof80_state *driver_state = | |
| 1005 | 1005 | |
| 1006 | 1006 | driver_state->fdc_index = state; |
| 1007 | 1007 | } |
| r8714 | r8715 | |
| 1034 | 1034 | |
| 1035 | 1035 | */ |
| 1036 | 1036 | |
| 1037 | prof80_state *state = | |
| 1037 | prof80_state *state = | |
| 1038 | 1038 | |
| 1039 | 1039 | return state->gripd; |
| 1040 | 1040 | } |
| r8714 | r8715 | |
| 1056 | 1056 | |
| 1057 | 1057 | */ |
| 1058 | 1058 | |
| 1059 | prof80_state *state = | |
| 1059 | prof80_state *state = | |
| 1060 | 1060 | |
| 1061 | 1061 | state->gripd = data; |
| 1062 | 1062 | } |
| r8714 | r8715 | |
| 1078 | 1078 | |
| 1079 | 1079 | */ |
| 1080 | 1080 | |
| 1081 | prof80_state *state = | |
| 1081 | prof80_state *state = | |
| 1082 | 1082 | |
| 1083 | 1083 | return state->keydata; |
| 1084 | 1084 | } |
| r8714 | r8715 | |
| 1100 | 1100 | |
| 1101 | 1101 | */ |
| 1102 | 1102 | |
| 1103 | prof80_state *state = | |
| 1103 | prof80_state *state = | |
| 1104 | 1104 | |
| 1105 | 1105 | /* keyboard interrupt */ |
| 1106 | 1106 | z80sti_i4_w(state->z80sti, BIT(data, 0)); |
| r8714 | r8715 | |
| 1144 | 1144 | |
| 1145 | 1145 | */ |
| 1146 | 1146 | |
| 1147 | prof80_state *state = | |
| 1147 | prof80_state *state = | |
| 1148 | 1148 | |
| 1149 | 1149 | return centronics_busy_r(state->centronics) << 3; |
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | static WRITE_LINE_DEVICE_HANDLER( grip_speaker_w ) |
| 1153 | 1153 | { |
| 1154 | prof80_state *driver_state = | |
| 1154 | prof80_state *driver_state = | |
| 1155 | 1155 | int level = state && ((driver_state->vol1 << 1) | driver_state->vol0); |
| 1156 | 1156 | |
| 1157 | 1157 | speaker_level_w(device, level); |
| r8714 | r8715 | |
| 1184 | 1184 | |
| 1185 | 1185 | static MACHINE_START( prof80 ) |
| 1186 | 1186 | { |
| 1187 | prof80_state *state = | |
| 1187 | prof80_state *state = | |
| 1188 | 1188 | |
| 1189 | 1189 | /* find devices */ |
| 1190 | 1190 | state->upd765 = machine->device(UPD765_TAG); |
| r8714 | r8715 | |
| 1216 | 1216 | |
| 1217 | 1217 | static MACHINE_RESET( prof80 ) |
| 1218 | 1218 | { |
| 1219 | prof80_state *state = | |
| 1219 | prof80_state *state = | |
| 1220 | 1220 | |
| 1221 | 1221 | int i; |
| 1222 | 1222 | |
| r8714 | r8715 | |
| 1230 | 1230 | |
| 1231 | 1231 | static MACHINE_START( grip ) |
| 1232 | 1232 | { |
| 1233 | prof80_state *state = | |
| 1233 | prof80_state *state = | |
| 1234 | 1234 | |
| 1235 | 1235 | MACHINE_START_CALL(prof80); |
| 1236 | 1236 |
| r8714 | r8715 | |
|---|---|---|
| 53 | 53 | } mapper[26]; |
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | class pasogo_state | |
| 56 | class pasogo_state : public driver_data_t | |
| 57 | 57 | { |
| 58 | 58 | public: |
| 59 | static | |
| 59 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pasogo_state(machine)); } | |
| 60 | 60 | |
| 61 | pasogo_state(running_machine &machine) { } | |
| 61 | pasogo_state(running_machine &machine) | |
| 62 | : driver_data_t(machine) { } | |
| 62 | 63 | |
| 63 | 64 | |
| 64 | 65 | struct _vg230_t vg230; |
| r8714 | r8715 | |
| 68 | 69 | |
| 69 | 70 | static TIMER_CALLBACK( vg230_timer ) |
| 70 | 71 | { |
| 71 | pasogo_state *state = | |
| 72 | pasogo_state *state = | |
| 72 | 73 | vg230_t *vg230 = &state->vg230; |
| 73 | 74 | |
| 74 | 75 | vg230->rtc.seconds+=1; |
| r8714 | r8715 | |
| 99 | 100 | |
| 100 | 101 | static void vg230_reset(running_machine *machine) |
| 101 | 102 | { |
| 102 | pasogo_state *state = | |
| 103 | pasogo_state *state = | |
| 103 | 104 | vg230_t *vg230 = &state->vg230; |
| 104 | 105 | system_time systime; |
| 105 | 106 | |
| r8714 | r8715 | |
| 126 | 127 | |
| 127 | 128 | static READ8_HANDLER( vg230_io_r ) |
| 128 | 129 | { |
| 129 | pasogo_state *state = | |
| 130 | pasogo_state *state = | |
| 130 | 131 | vg230_t *vg230 = &state->vg230; |
| 131 | 132 | int log=TRUE; |
| 132 | 133 | UINT8 data=0; |
| r8714 | r8715 | |
| 191 | 192 | |
| 192 | 193 | static WRITE8_HANDLER( vg230_io_w ) |
| 193 | 194 | { |
| 194 | pasogo_state *state = | |
| 195 | pasogo_state *state = | |
| 195 | 196 | vg230_t *vg230 = &state->vg230; |
| 196 | 197 | int log=TRUE; |
| 197 | 198 | |
| r8714 | r8715 | |
| 236 | 237 | |
| 237 | 238 | static READ8_HANDLER( ems_r ) |
| 238 | 239 | { |
| 239 | pasogo_state *state = | |
| 240 | pasogo_state *state = | |
| 240 | 241 | ems_t *ems = &state->ems; |
| 241 | 242 | UINT8 data=0; |
| 242 | 243 | |
| r8714 | r8715 | |
| 250 | 251 | |
| 251 | 252 | static WRITE8_HANDLER( ems_w ) |
| 252 | 253 | { |
| 253 | pasogo_state *state = | |
| 254 | pasogo_state *state = | |
| 254 | 255 | ems_t *ems = &state->ems; |
| 255 | 256 | char bank[10]; |
| 256 | 257 | |
| r8714 | r8715 | |
| 574 | 575 | |
| 575 | 576 | static DRIVER_INIT( pasogo ) |
| 576 | 577 | { |
| 577 | pasogo_state *state = | |
| 578 | pasogo_state *state = | |
| 578 | 579 | vg230_init(machine); |
| 579 | 580 | memset(&state->ems, 0, sizeof(state->ems)); |
| 580 | 581 | memory_set_bankptr( machine, "bank27", memory_region(machine, "user1") + 0x00000 ); |
| r8714 | r8715 | |
|---|---|---|
| 183 | 183 | |
| 184 | 184 | static WRITE8_HANDLER(spectrum_plus3_port_3ffd_w) |
| 185 | 185 | { |
| 186 | spectrum_state *state = | |
| 186 | spectrum_state *state = | |
| 187 | 187 | if (state->floppy==1) |
| 188 | 188 | upd765_data_w(space->machine->device("upd765"), 0,data); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | static READ8_HANDLER(spectrum_plus3_port_3ffd_r) |
| 192 | 192 | { |
| 193 | spectrum_state *state = | |
| 193 | spectrum_state *state = | |
| 194 | 194 | if (state->floppy==0) |
| 195 | 195 | return 0xff; |
| 196 | 196 | else |
| r8714 | r8715 | |
| 200 | 200 | |
| 201 | 201 | static READ8_HANDLER(spectrum_plus3_port_2ffd_r) |
| 202 | 202 | { |
| 203 | spectrum_state *state = | |
| 203 | spectrum_state *state = | |
| 204 | 204 | if (state->floppy==0) |
| 205 | 205 | return 0xff; |
| 206 | 206 | else |
| r8714 | r8715 | |
| 210 | 210 | |
| 211 | 211 | void spectrum_plus3_update_memory(running_machine *machine) |
| 212 | 212 | { |
| 213 | spectrum_state *state = | |
| 213 | spectrum_state *state = | |
| 214 | 214 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 215 | 215 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 216 | 216 | |
| r8714 | r8715 | |
| 301 | 301 | /* D4 - ROM select - which rom paged into 0x0000-0x03fff */ |
| 302 | 302 | /* D5 - Disable paging */ |
| 303 | 303 | |
| 304 | spectrum_state *state = | |
| 304 | spectrum_state *state = | |
| 305 | 305 | |
| 306 | 306 | /* disable paging? */ |
| 307 | 307 | if (state->port_7ffd_data & 0x20) |
| r8714 | r8715 | |
| 321 | 321 | /* D3 - Disk motor on/off */ |
| 322 | 322 | /* D4 - parallel port strobe */ |
| 323 | 323 | |
| 324 | spectrum_state *state = | |
| 324 | spectrum_state *state = | |
| 325 | 325 | |
| 326 | 326 | floppy_mon_w(floppy_get_device(space->machine, 0), !BIT(data, 3)); |
| 327 | 327 | floppy_mon_w(floppy_get_device(space->machine, 1), !BIT(data, 3)); |
| r8714 | r8715 | |
| 354 | 354 | |
| 355 | 355 | static MACHINE_RESET( spectrum_plus3 ) |
| 356 | 356 | { |
| 357 | spectrum_state *state = | |
| 357 | spectrum_state *state = | |
| 358 | 358 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 359 | 359 | memset(messram,0,128*1024); |
| 360 | 360 | |
| r8714 | r8715 | |
| 368 | 368 | |
| 369 | 369 | static DRIVER_INIT( plus3 ) |
| 370 | 370 | { |
| 371 | spectrum_state *state = | |
| 371 | spectrum_state *state = | |
| 372 | 372 | state->floppy = 1; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | static DRIVER_INIT( plus2 ) |
| 376 | 376 | { |
| 377 | spectrum_state *state = | |
| 377 | spectrum_state *state = | |
| 378 | 378 | state->floppy = 0; |
| 379 | 379 | } |
| 380 | 380 |
| r8714 | r8715 | |
|---|---|---|
| 10 | 10 | #include "cpu/apexc/apexc.h" |
| 11 | 11 | |
| 12 | 12 | |
| 13 | class apexc_state | |
| 13 | class apexc_state : public driver_data_t | |
| 14 | 14 | { |
| 15 | 15 | public: |
| 16 | static | |
| 16 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, apexc_state(machine)); } | |
| 17 | 17 | |
| 18 | apexc_state(running_machine &machine) { } | |
| 18 | apexc_state(running_machine &machine) | |
| 19 | : driver_data_t(machine) { } | |
| 19 | 20 | |
| 20 | 21 | UINT32 panel_data_reg; /* value of a data register on the control panel which can |
| 21 | 22 | be edited - the existence of this register is a personnal |
| r8714 | r8715 | |
| 392 | 393 | */ |
| 393 | 394 | static INTERRUPT_GEN( apexc_interrupt ) |
| 394 | 395 | { |
| 395 | apexc_state *state = | |
| 396 | apexc_state *state = | |
| 396 | 397 | const address_space* space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 397 | 398 | UINT32 edit_keys; |
| 398 | 399 | int control_keys; |
| r8714 | r8715 | |
| 552 | 553 | |
| 553 | 554 | static VIDEO_START( apexc ) |
| 554 | 555 | { |
| 555 | apexc_state *state = | |
| 556 | apexc_state *state = | |
| 556 | 557 | screen_device *screen = screen_first(*machine); |
| 557 | 558 | int width = screen->width(); |
| 558 | 559 | int height = screen->height(); |
| r8714 | r8715 | |
| 593 | 594 | |
| 594 | 595 | static VIDEO_UPDATE( apexc ) |
| 595 | 596 | { |
| 596 | apexc_state *state = | |
| 597 | apexc_state *state = | |
| 597 | 598 | int i; |
| 598 | 599 | char the_char; |
| 599 | 600 | |
| r8714 | r8715 | |
| 625 | 626 | |
| 626 | 627 | static void apexc_teletyper_init(running_machine *machine) |
| 627 | 628 | { |
| 628 | apexc_state *state = | |
| 629 | apexc_state *state = | |
| 629 | 630 | |
| 630 | 631 | state->letters = FALSE; |
| 631 | 632 | state->pos = 0; |
| r8714 | r8715 | |
| 633 | 634 | |
| 634 | 635 | static void apexc_teletyper_linefeed(running_machine *machine) |
| 635 | 636 | { |
| 636 | apexc_state *state = | |
| 637 | apexc_state *state = | |
| 637 | 638 | UINT8 buf[teletyper_window_width]; |
| 638 | 639 | int y; |
| 639 | 640 | |
| r8714 | r8715 | |
| 672 | 673 | } |
| 673 | 674 | }; |
| 674 | 675 | |
| 675 | apexc_state *state = | |
| 676 | apexc_state *state = | |
| 676 | 677 | char buffer[2] = "x"; |
| 677 | 678 | |
| 678 | 679 | character &= 0x1f; |
| r8714 | r8715 | |
|---|---|---|
| 88 | 88 | |
| 89 | 89 | static MC6845_UPDATE_ROW( victor9k_update_row ) |
| 90 | 90 | { |
| 91 | victor9k_state *state = | |
| 91 | victor9k_state *state = | |
| 92 | 92 | const address_space *program = cputag_get_address_space(device->machine, I8088_TAG, ADDRESS_SPACE_PROGRAM); |
| 93 | 93 | |
| 94 | 94 | if (BIT(ma, 13)) |
| r8714 | r8715 | |
| 122 | 122 | |
| 123 | 123 | static WRITE_LINE_DEVICE_HANDLER( vsync_w ) |
| 124 | 124 | { |
| 125 | victor9k_state *driver_state = | |
| 125 | victor9k_state *driver_state = | |
| 126 | 126 | |
| 127 | 127 | pic8259_ir7_w(driver_state->pic, state); |
| 128 | 128 | driver_state->vert = state; |
| r8714 | r8715 | |
| 144 | 144 | |
| 145 | 145 | static VIDEO_START( victor9k ) |
| 146 | 146 | { |
| 147 | victor9k_state *state = | |
| 147 | victor9k_state *state = | |
| 148 | 148 | |
| 149 | 149 | /* find devices */ |
| 150 | 150 | state->crt = machine->device(HD46505S_TAG); |
| r8714 | r8715 | |
| 152 | 152 | |
| 153 | 153 | static VIDEO_UPDATE( victor9k ) |
| 154 | 154 | { |
| 155 | victor9k_state *state = | |
| 155 | victor9k_state *state = | |
| 156 | 156 | |
| 157 | 157 | mc6845_update(state->crt, bitmap, cliprect); |
| 158 | 158 | |
| r8714 | r8715 | |
| 250 | 250 | |
| 251 | 251 | static WRITE_LINE_DEVICE_HANDLER( ssda_irq_w ) |
| 252 | 252 | { |
| 253 | victor9k_state *driver_state = | |
| 253 | victor9k_state *driver_state = | |
| 254 | 254 | |
| 255 | 255 | driver_state->via6_irq = state; |
| 256 | 256 | |
| r8714 | r8715 | |
| 289 | 289 | |
| 290 | 290 | */ |
| 291 | 291 | |
| 292 | victor9k_state *state = | |
| 292 | victor9k_state *state = | |
| 293 | 293 | |
| 294 | 294 | return ieee488_dio_r(state->ieee488, 0); |
| 295 | 295 | } |
| r8714 | r8715 | |
| 311 | 311 | |
| 312 | 312 | */ |
| 313 | 313 | |
| 314 | victor9k_state *state = | |
| 314 | victor9k_state *state = | |
| 315 | 315 | |
| 316 | 316 | ieee488_dio_w(state->ieee488, device, data); |
| 317 | 317 | } |
| r8714 | r8715 | |
| 333 | 333 | |
| 334 | 334 | */ |
| 335 | 335 | |
| 336 | victor9k_state *state = | |
| 336 | victor9k_state *state = | |
| 337 | 337 | |
| 338 | 338 | UINT8 data = 0; |
| 339 | 339 | |
| r8714 | r8715 | |
| 381 | 381 | |
| 382 | 382 | */ |
| 383 | 383 | |
| 384 | victor9k_state *state = | |
| 384 | victor9k_state *state = | |
| 385 | 385 | |
| 386 | 386 | /* data valid */ |
| 387 | 387 | ieee488_dav_w(state->ieee488, device, BIT(data, 0)); |
| r8714 | r8715 | |
| 414 | 414 | |
| 415 | 415 | static WRITE_LINE_DEVICE_HANDLER( via1_irq_w ) |
| 416 | 416 | { |
| 417 | victor9k_state *driver_state = | |
| 417 | victor9k_state *driver_state = | |
| 418 | 418 | |
| 419 | 419 | driver_state->via1_irq = state; |
| 420 | 420 | |
| r8714 | r8715 | |
| 457 | 457 | |
| 458 | 458 | */ |
| 459 | 459 | |
| 460 | victor9k_state *state = | |
| 460 | victor9k_state *state = | |
| 461 | 461 | |
| 462 | 462 | UINT8 data = 0; |
| 463 | 463 | |
| r8714 | r8715 | |
| 502 | 502 | |
| 503 | 503 | */ |
| 504 | 504 | |
| 505 | victor9k_state *state = | |
| 505 | victor9k_state *state = | |
| 506 | 506 | |
| 507 | 507 | /* brightness */ |
| 508 | 508 | state->brt = (data >> 2) & 0x07; |
| r8714 | r8715 | |
| 513 | 513 | |
| 514 | 514 | static WRITE_LINE_DEVICE_HANDLER( via2_irq_w ) |
| 515 | 515 | { |
| 516 | victor9k_state *driver_state = | |
| 516 | victor9k_state *driver_state = | |
| 517 | 517 | |
| 518 | 518 | driver_state->via2_irq = state; |
| 519 | 519 | |
| r8714 | r8715 | |
| 614 | 614 | |
| 615 | 615 | */ |
| 616 | 616 | |
| 617 | victor9k_state *state = | |
| 617 | victor9k_state *state = | |
| 618 | 618 | |
| 619 | 619 | /* codec clock output */ |
| 620 | 620 | mc6852_rx_clk_w(state->ssda, BIT(data, 7)); |
| r8714 | r8715 | |
| 623 | 623 | |
| 624 | 624 | static WRITE_LINE_DEVICE_HANDLER( via3_irq_w ) |
| 625 | 625 | { |
| 626 | victor9k_state *driver_state = | |
| 626 | victor9k_state *driver_state = | |
| 627 | 627 | |
| 628 | 628 | driver_state->via3_irq = state; |
| 629 | 629 | |
| r8714 | r8715 | |
| 691 | 691 | |
| 692 | 692 | static WRITE_LINE_DEVICE_HANDLER( via4_irq_w ) |
| 693 | 693 | { |
| 694 | victor9k_state *driver_state = | |
| 694 | victor9k_state *driver_state = | |
| 695 | 695 | |
| 696 | 696 | driver_state->via4_irq = state; |
| 697 | 697 | |
| r8714 | r8715 | |
| 757 | 757 | |
| 758 | 758 | static WRITE_LINE_DEVICE_HANDLER( via5_irq_w ) |
| 759 | 759 | { |
| 760 | victor9k_state *driver_state = | |
| 760 | victor9k_state *driver_state = | |
| 761 | 761 | |
| 762 | 762 | driver_state->via5_irq = state; |
| 763 | 763 | |
| r8714 | r8715 | |
| 800 | 800 | |
| 801 | 801 | */ |
| 802 | 802 | |
| 803 | victor9k_state *state = | |
| 803 | victor9k_state *state = | |
| 804 | 804 | |
| 805 | 805 | UINT8 data = 0; |
| 806 | 806 | |
| r8714 | r8715 | |
| 833 | 833 | |
| 834 | 834 | */ |
| 835 | 835 | |
| 836 | victor9k_state *state = | |
| 836 | victor9k_state *state = | |
| 837 | 837 | |
| 838 | 838 | /* side select */ |
| 839 | 839 | state->side = BIT(data, 4); |
| r8714 | r8715 | |
| 859 | 859 | |
| 860 | 860 | */ |
| 861 | 861 | |
| 862 | victor9k_state *state = | |
| 862 | victor9k_state *state = | |
| 863 | 863 | |
| 864 | 864 | UINT8 data = 0; |
| 865 | 865 | |
| r8714 | r8715 | |
| 892 | 892 | |
| 893 | 893 | */ |
| 894 | 894 | |
| 895 | victor9k_state *state = | |
| 895 | victor9k_state *state = | |
| 896 | 896 | |
| 897 | 897 | /* motor speed controller reset */ |
| 898 | 898 | cputag_set_input_line(device->machine, I8048_TAG, INPUT_LINE_RESET, BIT(data, 2)); |
| r8714 | r8715 | |
| 914 | 914 | |
| 915 | 915 | static WRITE_LINE_DEVICE_HANDLER( via6_irq_w ) |
| 916 | 916 | { |
| 917 | victor9k_state *driver_state = | |
| 917 | victor9k_state *driver_state = | |
| 918 | 918 | |
| 919 | 919 | driver_state->via6_irq = state; |
| 920 | 920 | |
| r8714 | r8715 | |
| 966 | 966 | |
| 967 | 967 | static IRQ_CALLBACK( victor9k_irq_callback ) |
| 968 | 968 | { |
| 969 | victor9k_state *state = | |
| 969 | victor9k_state *state = | |
| 970 | 970 | |
| 971 | 971 | return pic8259_acknowledge(state->pic); |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | 974 | static MACHINE_START( victor9k ) |
| 975 | 975 | { |
| 976 | victor9k_state *state = | |
| 976 | victor9k_state *state = | |
| 977 | 977 | |
| 978 | 978 | /* set interrupt callback */ |
| 979 | 979 | cpu_set_irq_callback(machine->firstcpu, victor9k_irq_callback); |
| r8714 | r8715 | |
|---|---|---|
| 55 | 55 | |
| 56 | 56 | */ |
| 57 | 57 | |
| 58 | pc8001_state *state = | |
| 58 | pc8001_state *state = | |
| 59 | 59 | |
| 60 | 60 | /* characters per line */ |
| 61 | 61 | state->width80 = BIT(data, 0); |
| r8714 | r8715 | |
| 309 | 309 | |
| 310 | 310 | static VIDEO_START( pc8001 ) |
| 311 | 311 | { |
| 312 | pc8001_state *state = | |
| 312 | pc8001_state *state = | |
| 313 | 313 | |
| 314 | 314 | /* find memory regions */ |
| 315 | 315 | state->char_rom = memory_region(machine, "chargen"); |
| r8714 | r8715 | |
| 317 | 317 | |
| 318 | 318 | static VIDEO_UPDATE( pc8001 ) |
| 319 | 319 | { |
| 320 | pc8001_state *state = | |
| 320 | pc8001_state *state = | |
| 321 | 321 | |
| 322 | 322 | upd3301_update(state->upd3301, bitmap, cliprect); |
| 323 | 323 | |
| r8714 | r8715 | |
| 328 | 328 | |
| 329 | 329 | static UPD3301_DISPLAY_PIXELS( pc8001_display_pixels ) |
| 330 | 330 | { |
| 331 | pc8001_state *state = | |
| 331 | pc8001_state *state = | |
| 332 | 332 | |
| 333 | 333 | UINT8 data = state->char_rom[(cc << 3) | lc]; |
| 334 | 334 | int i; |
| r8714 | r8715 | |
| 430 | 430 | |
| 431 | 431 | static MACHINE_START( pc8001 ) |
| 432 | 432 | { |
| 433 | pc8001_state *state = | |
| 433 | pc8001_state *state = | |
| 434 | 434 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 435 | 435 | running_device *messram = machine->device("messram"); |
| 436 | 436 |
| r8714 | r8715 | |
|---|---|---|
| 79 | 79 | |
| 80 | 80 | static TIMER_CALLBACK( led_refresh ) |
| 81 | 81 | { |
| 82 | beta_state *state = | |
| 82 | beta_state *state = | |
| 83 | 83 | |
| 84 | 84 | if (state->ls145_p < 6) |
| 85 | 85 | { |
| r8714 | r8715 | |
| 105 | 105 | |
| 106 | 106 | */ |
| 107 | 107 | |
| 108 | beta_state *state = | |
| 108 | beta_state *state = | |
| 109 | 109 | |
| 110 | 110 | UINT8 data = 0xff; |
| 111 | 111 | |
| r8714 | r8715 | |
| 143 | 143 | |
| 144 | 144 | */ |
| 145 | 145 | |
| 146 | beta_state *state = | |
| 146 | beta_state *state = | |
| 147 | 147 | |
| 148 | 148 | // logerror("PA %02x\n", data); |
| 149 | 149 | |
| r8714 | r8715 | |
| 177 | 177 | |
| 178 | 178 | */ |
| 179 | 179 | |
| 180 | beta_state *state = | |
| 180 | beta_state *state = | |
| 181 | 181 | |
| 182 | 182 | //logerror("PB %02x %02x\n", data, olddata); |
| 183 | 183 | |
| r8714 | r8715 | |
| 237 | 237 | |
| 238 | 238 | static MACHINE_START( beta ) |
| 239 | 239 | { |
| 240 | beta_state *state = | |
| 240 | beta_state *state = | |
| 241 | 241 | |
| 242 | 242 | /* find devices */ |
| 243 | 243 | state->speaker = machine->device(SPEAKER_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 68 | 68 | TYPE DEFINITIONS |
| 69 | 69 | ***************************************************************************/ |
| 70 | 70 | |
| 71 | class px4_state | |
| 71 | class px4_state : public driver_data_t | |
| 72 | 72 | { |
| 73 | 73 | public: |
| 74 | static | |
| 74 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, px4_state(machine)); } | |
| 75 | 75 | |
| 76 | px4_state(running_machine &machine) { } | |
| 76 | px4_state(running_machine &machine) | |
| 77 | : driver_data_t(machine) { } | |
| 77 | 78 | |
| 78 | 79 | /* internal ram */ |
| 79 | 80 | running_device *ram; |
| r8714 | r8715 | |
| 243 | 244 | /* process interrupts */ |
| 244 | 245 | static void gapnit_interrupt(running_machine *machine) |
| 245 | 246 | { |
| 246 | px4_state *px4 = | |
| 247 | px4_state *px4 = | |
| 247 | 248 | |
| 248 | 249 | /* any interrupts enabled and pending? */ |
| 249 | 250 | if (px4->ier & px4->isr & INT0_7508) |
| r8714 | r8715 | |
| 266 | 267 | /* external cassette or barcode reader input */ |
| 267 | 268 | static TIMER_CALLBACK( ext_cassette_read ) |
| 268 | 269 | { |
| 269 | px4_state *px4 = | |
| 270 | px4_state *px4 = | |
| 270 | 271 | UINT8 result; |
| 271 | 272 | int trigger = 0; |
| 272 | 273 | |
| r8714 | r8715 | |
| 305 | 306 | /* free running counter */ |
| 306 | 307 | static TIMER_DEVICE_CALLBACK( frc_tick ) |
| 307 | 308 | { |
| 308 | px4_state *px4 = | |
| 309 | px4_state *px4 = | |
| 309 | 310 | |
| 310 | 311 | px4->frc_value++; |
| 311 | 312 | |
| r8714 | r8715 | |
| 319 | 320 | /* input capture register low command trigger */ |
| 320 | 321 | static READ8_HANDLER( px4_icrlc_r ) |
| 321 | 322 | { |
| 322 | px4_state *px4 = | |
| 323 | px4_state *px4 = | |
| 323 | 324 | |
| 324 | 325 | if (VERBOSE) |
| 325 | 326 | logerror("%s: px4_icrlc_r\n", cpuexec_describe_context(space->machine)); |
| r8714 | r8715 | |
| 333 | 334 | /* control register 1 */ |
| 334 | 335 | static WRITE8_HANDLER( px4_ctrl1_w ) |
| 335 | 336 | { |
| 336 | px4_state *px4 = | |
| 337 | px4_state *px4 = | |
| 337 | 338 | int baud; |
| 338 | 339 | |
| 339 | 340 | if (VERBOSE) |
| r8714 | r8715 | |
| 354 | 355 | /* input capture register high command trigger */ |
| 355 | 356 | static READ8_HANDLER( px4_icrhc_r ) |
| 356 | 357 | { |
| 357 | px4_state *px4 = | |
| 358 | px4_state *px4 = | |
| 358 | 359 | |
| 359 | 360 | if (VERBOSE) |
| 360 | 361 | logerror("%s: px4_icrhc_r\n", cpuexec_describe_context(space->machine)); |
| r8714 | r8715 | |
| 365 | 366 | /* command register */ |
| 366 | 367 | static WRITE8_HANDLER( px4_cmdr_w ) |
| 367 | 368 | { |
| 368 | px4_state *px4 = | |
| 369 | px4_state *px4 = | |
| 369 | 370 | |
| 370 | 371 | if (VERBOSE) |
| 371 | 372 | logerror("%s: px4_cmdr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| r8714 | r8715 | |
| 381 | 382 | /* input capture register low barcode trigger */ |
| 382 | 383 | static READ8_HANDLER( px4_icrlb_r ) |
| 383 | 384 | { |
| 384 | px4_state *px4 = | |
| 385 | px4_state *px4 = | |
| 385 | 386 | |
| 386 | 387 | if (VERBOSE) |
| 387 | 388 | logerror("%s: px4_icrlb_r\n", cpuexec_describe_context(space->machine)); |
| r8714 | r8715 | |
| 392 | 393 | /* control register 2 */ |
| 393 | 394 | static WRITE8_HANDLER( px4_ctrl2_w ) |
| 394 | 395 | { |
| 395 | px4_state *px4 = | |
| 396 | px4_state *px4 = | |
| 396 | 397 | |
| 397 | 398 | if (VERBOSE) |
| 398 | 399 | logerror("%s: px4_ctrl2_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| r8714 | r8715 | |
| 416 | 417 | /* input capture register high barcode trigger */ |
| 417 | 418 | static READ8_HANDLER( px4_icrhb_r ) |
| 418 | 419 | { |
| 419 | px4_state *px4 = | |
| 420 | px4_state *px4 = | |
| 420 | 421 | |
| 421 | 422 | if (VERBOSE) |
| 422 | 423 | logerror("%s: px4_icrhb_r\n", cpuexec_describe_context(space->machine)); |
| r8714 | r8715 | |
| 431 | 432 | /* interrupt status register */ |
| 432 | 433 | static READ8_HANDLER( px4_isr_r ) |
| 433 | 434 | { |
| 434 | px4_state *px4 = | |
| 435 | px4_state *px4 = | |
| 435 | 436 | |
| 436 | 437 | if (VERBOSE) |
| 437 | 438 | logerror("%s: px4_isr_r\n", cpuexec_describe_context(space->machine)); |
| r8714 | r8715 | |
| 442 | 443 | /* interrupt enable register */ |
| 443 | 444 | static WRITE8_HANDLER( px4_ier_w ) |
| 444 | 445 | { |
| 445 | px4_state *px4 = | |
| 446 | px4_state *px4 = | |
| 446 | 447 | |
| 447 | 448 | if (VERBOSE) |
| 448 | 449 | logerror("%s: px4_ier_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| r8714 | r8715 | |
| 454 | 455 | /* status register */ |
| 455 | 456 | static READ8_HANDLER( px4_str_r ) |
| 456 | 457 | { |
| 457 | px4_state *px4 = | |
| 458 | px4_state *px4 = | |
| 458 | 459 | UINT8 result = 0; |
| 459 | 460 | |
| 460 | 461 | if (VERBOSE) |
| r8714 | r8715 | |
| 472 | 473 | /* helper function to map rom capsules */ |
| 473 | 474 | static void install_rom_capsule(const address_space *space, int size, const char *region) |
| 474 | 475 | { |
| 475 | px4_state *px4 = | |
| 476 | px4_state *px4 = | |
| 476 | 477 | |
| 477 | 478 | /* ram, part 1 */ |
| 478 | 479 | memory_install_readwrite_bank(space, 0x0000, 0xdfff - size, 0, 0, "bank1"); |
| r8714 | r8715 | |
| 499 | 500 | /* bank register */ |
| 500 | 501 | static WRITE8_HANDLER( px4_bankr_w ) |
| 501 | 502 | { |
| 502 | px4_state *px4 = | |
| 503 | px4_state *px4 = | |
| 503 | 504 | const address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 504 | 505 | |
| 505 | 506 | if (VERBOSE) |
| r8714 | r8715 | |
| 542 | 543 | /* serial io register */ |
| 543 | 544 | static READ8_HANDLER( px4_sior_r ) |
| 544 | 545 | { |
| 545 | px4_state *px4 = | |
| 546 | px4_state *px4 = | |
| 546 | 547 | |
| 547 | 548 | if (VERBOSE) |
| 548 | 549 | logerror("%s: px4_sior_r 0x%02x\n", cpuexec_describe_context(space->machine), px4->sior); |
| r8714 | r8715 | |
| 553 | 554 | /* serial io register */ |
| 554 | 555 | static WRITE8_HANDLER( px4_sior_w ) |
| 555 | 556 | { |
| 556 | px4_state *px4 = | |
| 557 | px4_state *px4 = | |
| 557 | 558 | |
| 558 | 559 | if (VERBOSE) |
| 559 | 560 | logerror("%s: px4_sior_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| r8714 | r8715 | |
| 685 | 686 | /* vram start address register */ |
| 686 | 687 | static WRITE8_HANDLER( px4_vadr_w ) |
| 687 | 688 | { |
| 688 | px4_state *px4 = | |
| 689 | px4_state *px4 = | |
| 689 | 690 | |
| 690 | 691 | if (VERBOSE) |
| 691 | 692 | logerror("%s: px4_vadr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| r8714 | r8715 | |
| 696 | 697 | /* y offset register */ |
| 697 | 698 | static WRITE8_HANDLER( px4_yoff_w ) |
| 698 | 699 | { |
| 699 | px4_state *px4 = | |
| 700 | px4_state *px4 = | |
| 700 | 701 | |
| 701 | 702 | if (VERBOSE) |
| 702 | 703 | logerror("%s: px4_yoff_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| r8714 | r8715 | |
| 725 | 726 | |
| 726 | 727 | static TIMER_CALLBACK( transmit_data ) |
| 727 | 728 | { |
| 728 | px4_state *px4 = | |
| 729 | px4_state *px4 = | |
| 729 | 730 | |
| 730 | 731 | if (ART_TX_ENABLED) |
| 731 | 732 | { |
| r8714 | r8715 | |
| 735 | 736 | |
| 736 | 737 | static TIMER_CALLBACK( receive_data ) |
| 737 | 738 | { |
| 738 | px4_state *px4 = | |
| 739 | px4_state *px4 = | |
| 739 | 740 | |
| 740 | 741 | if (ART_RX_ENABLED) |
| 741 | 742 | { |
| r8714 | r8715 | |
| 762 | 763 | /* art data input register */ |
| 763 | 764 | static READ8_HANDLER( px4_artdir_r ) |
| 764 | 765 | { |
| 765 | px4_state *px4 = | |
| 766 | px4_state *px4 = | |
| 766 | 767 | |
| 767 | 768 | if (VERBOSE) |
| 768 | 769 | logerror("%s: px4_artdir_r\n", cpuexec_describe_context(space->machine)); |
| r8714 | r8715 | |
| 773 | 774 | /* art data output register */ |
| 774 | 775 | static WRITE8_HANDLER( px4_artdor_w ) |
| 775 | 776 | { |
| 776 | px4_state *px4 = | |
| 777 | px4_state *px4 = | |
| 777 | 778 | |
| 778 | 779 | if (VERBOSE) |
| 779 | 780 | logerror("%s: px4_artdor_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| r8714 | r8715 | |
| 787 | 788 | /* art status register */ |
| 788 | 789 | static READ8_HANDLER( px4_artsr_r ) |
| 789 | 790 | { |
| 790 | px4_state *px4 = | |
| 791 | px4_state *px4 = | |
| 791 | 792 | UINT8 result = 0; |
| 792 | 793 | |
| 793 | 794 | if (VERBOSE) |
| r8714 | r8715 | |
| 801 | 802 | /* art mode register */ |
| 802 | 803 | static WRITE8_HANDLER( px4_artmr_w ) |
| 803 | 804 | { |
| 804 | px4_state *px4 = | |
| 805 | px4_state *px4 = | |
| 805 | 806 | |
| 806 | 807 | if (VERBOSE) |
| 807 | 808 | logerror("%s: px4_artmr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| r8714 | r8715 | |
| 812 | 813 | /* io status register */ |
| 813 | 814 | static READ8_HANDLER( px4_iostr_r ) |
| 814 | 815 | { |
| 815 | px4_state *px4 = | |
| 816 | px4_state *px4 = | |
| 816 | 817 | UINT8 result = 0; |
| 817 | 818 | |
| 818 | 819 | if (VERBOSE) |
| r8714 | r8715 | |
| 833 | 834 | /* art command register */ |
| 834 | 835 | static WRITE8_HANDLER( px4_artcr_w ) |
| 835 | 836 | { |
| 836 | px4_state *px4 = | |
| 837 | px4_state *px4 = | |
| 837 | 838 | |
| 838 | 839 | if (VERBOSE) |
| 839 | 840 | logerror("%s: px4_artcr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| r8714 | r8715 | |
| 867 | 868 | /* switch register */ |
| 868 | 869 | static WRITE8_HANDLER( px4_swr_w ) |
| 869 | 870 | { |
| 870 | px4_state *px4 = | |
| 871 | px4_state *px4 = | |
| 871 | 872 | |
| 872 | 873 | if (VERBOSE) |
| 873 | 874 | logerror("%s: px4_swr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| r8714 | r8715 | |
| 878 | 879 | /* io control register */ |
| 879 | 880 | static WRITE8_HANDLER( px4_ioctlr_w ) |
| 880 | 881 | { |
| 881 | px4_state *px4 = | |
| 882 | px4_state *px4 = | |
| 882 | 883 | |
| 883 | 884 | if (VERBOSE) |
| 884 | 885 | logerror("%s: px4_ioctlr_w (0x%02x)\n", cpuexec_describe_context(space->machine), data); |
| r8714 | r8715 | |
| 904 | 905 | |
| 905 | 906 | static TIMER_DEVICE_CALLBACK( upd7508_1sec_callback ) |
| 906 | 907 | { |
| 907 | px4_state *px4 = | |
| 908 | px4_state *px4 = | |
| 908 | 909 | |
| 909 | 910 | /* adjust interrupt status */ |
| 910 | 911 | px4->interrupt_status |= UPD7508_INT_ONE_SECOND; |
| r8714 | r8715 | |
| 919 | 920 | |
| 920 | 921 | static INPUT_CHANGED( key_callback ) |
| 921 | 922 | { |
| 922 | px4_state *px4 = | |
| 923 | px4_state *px4 = | |
| 923 | 924 | UINT32 oldvalue = oldval * field->mask, newvalue = newval * field->mask; |
| 924 | 925 | UINT32 delta = oldvalue ^ newvalue; |
| 925 | 926 | int i, scancode = 0xff, down = 0; |
| r8714 | r8715 | |
| 964 | 965 | |
| 965 | 966 | static WRITE8_HANDLER( px4_ramdisk_address_w ) |
| 966 | 967 | { |
| 967 | px4_state *px4 = | |
| 968 | px4_state *px4 = | |
| 968 | 969 | |
| 969 | 970 | switch (offset) |
| 970 | 971 | { |
| r8714 | r8715 | |
| 976 | 977 | |
| 977 | 978 | static READ8_HANDLER( px4_ramdisk_data_r ) |
| 978 | 979 | { |
| 979 | px4_state *px4 = | |
| 980 | px4_state *px4 = | |
| 980 | 981 | UINT8 ret = 0xff; |
| 981 | 982 | |
| 982 | 983 | if (px4->ramdisk_address < 0x20000) |
| r8714 | r8715 | |
| 997 | 998 | |
| 998 | 999 | static WRITE8_HANDLER( px4_ramdisk_data_w ) |
| 999 | 1000 | { |
| 1000 | px4_state *px4 = | |
| 1001 | px4_state *px4 = | |
| 1001 | 1002 | |
| 1002 | 1003 | if (px4->ramdisk_address < 0x20000) |
| 1003 | 1004 | px4->ramdisk[px4->ramdisk_address] = data; |
| r8714 | r8715 | |
| 1013 | 1014 | |
| 1014 | 1015 | static NVRAM_HANDLER( px4_ramdisk ) |
| 1015 | 1016 | { |
| 1016 | px4_state *px4 = | |
| 1017 | px4_state *px4 = | |
| 1017 | 1018 | |
| 1018 | 1019 | if (read_or_write) |
| 1019 | 1020 | mame_fwrite(file, px4->ramdisk, 0x20000); |
| r8714 | r8715 | |
| 1029 | 1030 | |
| 1030 | 1031 | static VIDEO_UPDATE( px4 ) |
| 1031 | 1032 | { |
| 1032 | px4_state *px4 = | |
| 1033 | px4_state *px4 = | |
| 1033 | 1034 | |
| 1034 | 1035 | /* display enabled? */ |
| 1035 | 1036 | if (BIT(px4->yoff, 7)) |
| r8714 | r8715 | |
| 1078 | 1079 | |
| 1079 | 1080 | static DRIVER_INIT( px4 ) |
| 1080 | 1081 | { |
| 1081 | px4_state *px4 = | |
| 1082 | px4_state *px4 = | |
| 1082 | 1083 | |
| 1083 | 1084 | /* find devices */ |
| 1084 | 1085 | px4->ram = machine->device("messram"); |
| r8714 | r8715 | |
| 1111 | 1112 | |
| 1112 | 1113 | static DRIVER_INIT( px4p ) |
| 1113 | 1114 | { |
| 1114 | px4_state *px4 = | |
| 1115 | px4_state *px4 = | |
| 1115 | 1116 | |
| 1116 | 1117 | DRIVER_INIT_CALL(px4); |
| 1117 | 1118 | |
| r8714 | r8715 | |
| 1121 | 1122 | |
| 1122 | 1123 | static MACHINE_RESET( px4 ) |
| 1123 | 1124 | { |
| 1124 | px4_state *px4 = | |
| 1125 | px4_state *px4 = | |
| 1125 | 1126 | |
| 1126 | 1127 | px4->artsr = ART_TXRDY | ART_TXEMPTY; |
| 1127 | 1128 | } |
| r8714 | r8715 | |
|---|---|---|
| 44 | 44 | |
| 45 | 45 | static WRITE8_HANDLER( cldig_w ) |
| 46 | 46 | { |
| 47 | poly880_state *state = | |
| 47 | poly880_state *state = | |
| 48 | 48 | |
| 49 | 49 | state->digit = data; |
| 50 | 50 | |
| r8714 | r8715 | |
| 164 | 164 | |
| 165 | 165 | */ |
| 166 | 166 | |
| 167 | poly880_state *state = | |
| 167 | poly880_state *state = | |
| 168 | 168 | |
| 169 | 169 | state->segment = BITSWAP8(data, 3, 4, 6, 0, 1, 2, 7, 5); |
| 170 | 170 | |
| r8714 | r8715 | |
| 188 | 188 | |
| 189 | 189 | */ |
| 190 | 190 | |
| 191 | poly880_state *state = | |
| 191 | poly880_state *state = | |
| 192 | 192 | |
| 193 | 193 | UINT8 data = 0xf0 | ((cassette_input(state->cassette) < +0.0) << 1); |
| 194 | 194 | int i; |
| r8714 | r8715 | |
| 223 | 223 | |
| 224 | 224 | */ |
| 225 | 225 | |
| 226 | poly880_state *state = | |
| 226 | poly880_state *state = | |
| 227 | 227 | |
| 228 | 228 | /* tape output */ |
| 229 | 229 | cassette_output(state->cassette, BIT(data, 2) ? +1.0 : -1.0); |
| r8714 | r8715 | |
| 265 | 265 | |
| 266 | 266 | static MACHINE_START( poly880 ) |
| 267 | 267 | { |
| 268 | poly880_state *state = | |
| 268 | poly880_state *state = | |
| 269 | 269 | |
| 270 | 270 | /* find devices */ |
| 271 | 271 | state->cassette = machine->device(CASSETTE_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 171 | 171 | |
| 172 | 172 | static READ8_HANDLER(ts2068_port_f4_r) |
| 173 | 173 | { |
| 174 | spectrum_state *state = | |
| 174 | spectrum_state *state = | |
| 175 | 175 | |
| 176 | 176 | return state->port_f4_data; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | static WRITE8_HANDLER(ts2068_port_f4_w) |
| 180 | 180 | { |
| 181 | spectrum_state *state = | |
| 181 | spectrum_state *state = | |
| 182 | 182 | |
| 183 | 183 | state->port_f4_data = data; |
| 184 | 184 | ts2068_update_memory(space->machine); |
| r8714 | r8715 | |
| 186 | 186 | |
| 187 | 187 | static READ8_HANDLER(ts2068_port_ff_r) |
| 188 | 188 | { |
| 189 | spectrum_state *state = | |
| 189 | spectrum_state *state = | |
| 190 | 190 | |
| 191 | 191 | return state->port_ff_data; |
| 192 | 192 | } |
| r8714 | r8715 | |
| 199 | 199 | Bit 6 17ms Interrupt Inhibit |
| 200 | 200 | Bit 7 Cartridge (0) / EXROM (1) select |
| 201 | 201 | */ |
| 202 | spectrum_state *state = | |
| 202 | spectrum_state *state = | |
| 203 | 203 | |
| 204 | 204 | state->port_ff_data = data; |
| 205 | 205 | ts2068_update_memory(space->machine); |
| r8714 | r8715 | |
| 226 | 226 | *******************************************************************/ |
| 227 | 227 | void ts2068_update_memory(running_machine *machine) |
| 228 | 228 | { |
| 229 | spectrum_state *state = | |
| 229 | spectrum_state *state = | |
| 230 | 230 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 231 | 231 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 232 | 232 | unsigned char *ChosenROM, *ExROM, *DOCK; |
| r8714 | r8715 | |
| 561 | 561 | |
| 562 | 562 | static MACHINE_RESET( ts2068 ) |
| 563 | 563 | { |
| 564 | spectrum_state *state = | |
| 564 | spectrum_state *state = | |
| 565 | 565 | |
| 566 | 566 | state->port_ff_data = 0; |
| 567 | 567 | state->port_f4_data = 0; |
| r8714 | r8715 | |
| 577 | 577 | |
| 578 | 578 | static WRITE8_HANDLER( tc2048_port_ff_w ) |
| 579 | 579 | { |
| 580 | spectrum_state *state = | |
| 580 | spectrum_state *state = | |
| 581 | 581 | |
| 582 | 582 | state->port_ff_data = data; |
| 583 | 583 | logerror("Port %04x write %02x\n", offset, data); |
| r8714 | r8715 | |
| 598 | 598 | |
| 599 | 599 | static MACHINE_RESET( tc2048 ) |
| 600 | 600 | { |
| 601 | spectrum_state *state = | |
| 601 | spectrum_state *state = | |
| 602 | 602 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 603 | 603 | |
| 604 | 604 | memory_set_bankptr(machine, "bank1", messram); |
| r8714 | r8715 | |
|---|---|---|
| 68 | 68 | |
| 69 | 69 | */ |
| 70 | 70 | |
| 71 | bw2_state *state = | |
| 71 | bw2_state *state = | |
| 72 | 72 | |
| 73 | 73 | int max_ram_bank = 0; |
| 74 | 74 | |
| r8714 | r8715 | |
| 150 | 150 | |
| 151 | 151 | */ |
| 152 | 152 | |
| 153 | bw2_state *state = | |
| 153 | bw2_state *state = | |
| 154 | 154 | |
| 155 | 155 | int max_ram_bank = BANK_RAM1; |
| 156 | 156 | |
| r8714 | r8715 | |
| 217 | 217 | |
| 218 | 218 | static WRITE8_HANDLER( ramcard_bank_w ) |
| 219 | 219 | { |
| 220 | bw2_state *state = | |
| 220 | bw2_state *state = | |
| 221 | 221 | |
| 222 | 222 | UINT8 ramcard_bank = data & 0x0f; |
| 223 | 223 | UINT32 bank_offset = ramcard_bank * 0x8000; |
| r8714 | r8715 | |
| 327 | 327 | |
| 328 | 328 | */ |
| 329 | 329 | |
| 330 | bw2_state *state = | |
| 330 | bw2_state *state = | |
| 331 | 331 | |
| 332 | 332 | state->keyboard_row = data & 0x0f; |
| 333 | 333 | |
| r8714 | r8715 | |
| 361 | 361 | |
| 362 | 362 | */ |
| 363 | 363 | |
| 364 | bw2_state *state = | |
| 364 | bw2_state *state = | |
| 365 | 365 | |
| 366 | 366 | UINT8 row; |
| 367 | 367 | static const char *const rownames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8", "ROW9" }; |
| r8714 | r8715 | |
| 406 | 406 | |
| 407 | 407 | */ |
| 408 | 408 | |
| 409 | bw2_state *state = | |
| 409 | bw2_state *state = | |
| 410 | 410 | |
| 411 | 411 | UINT8 data = 0; |
| 412 | 412 | |
| r8714 | r8715 | |
| 432 | 432 | |
| 433 | 433 | static WRITE_LINE_DEVICE_HANDLER( bw2_timer0_w ) |
| 434 | 434 | { |
| 435 | bw2_state *driver_state = | |
| 435 | bw2_state *driver_state = | |
| 436 | 436 | |
| 437 | 437 | msm8251_transmit_clock(driver_state->msm8251); |
| 438 | 438 | msm8251_receive_clock(driver_state->msm8251); |
| r8714 | r8715 | |
| 440 | 440 | |
| 441 | 441 | static WRITE_LINE_DEVICE_HANDLER( bw2_timer2_w ) |
| 442 | 442 | { |
| 443 | bw2_state *driver_state = | |
| 443 | bw2_state *driver_state = | |
| 444 | 444 | |
| 445 | 445 | driver_state->mtron = state; |
| 446 | 446 | driver_state->mfdbk = !state; |
| r8714 | r8715 | |
| 488 | 488 | |
| 489 | 489 | static VIDEO_UPDATE( bw2 ) |
| 490 | 490 | { |
| 491 | bw2_state *state = | |
| 491 | bw2_state *state = | |
| 492 | 492 | |
| 493 | 493 | msm6255_update(state->msm6255, bitmap, cliprect); |
| 494 | 494 | |
| r8714 | r8715 | |
| 499 | 499 | |
| 500 | 500 | static DRIVER_INIT( bw2 ) |
| 501 | 501 | { |
| 502 | bw2_state *state = | |
| 502 | bw2_state *state = | |
| 503 | 503 | |
| 504 | 504 | /* allocate work memory */ |
| 505 | 505 | state->work_ram = auto_alloc_array(machine, UINT8, messram_get_size(machine->device("messram"))); |
| r8714 | r8715 | |
| 513 | 513 | |
| 514 | 514 | static MACHINE_START( bw2 ) |
| 515 | 515 | { |
| 516 | bw2_state *state = | |
| 516 | bw2_state *state = | |
| 517 | 517 | |
| 518 | 518 | /* find devices */ |
| 519 | 519 | state->msm8251 = machine->device(MSM8251_TAG); |
| r8714 | r8715 | |
| 538 | 538 | |
| 539 | 539 | static MACHINE_RESET( bw2 ) |
| 540 | 540 | { |
| 541 | bw2_state *state = | |
| 541 | bw2_state *state = | |
| 542 | 542 | |
| 543 | 543 | if (get_ramdisk_size(machine) > 0) |
| 544 | 544 | { |
| r8714 | r8715 | |
| 728 | 728 | |
| 729 | 729 | static MSM6255_CHAR_RAM_READ( bw2_charram_r ) |
| 730 | 730 | { |
| 731 | bw2_state *state = | |
| 731 | bw2_state *state = | |
| 732 | 732 | |
| 733 | 733 | return state->video_ram[ma & 0x3fff]; |
| 734 | 734 | } |
| r8714 | r8715 | |
| 779 | 779 | |
| 780 | 780 | static DEVICE_IMAGE_LOAD( bw2_serial ) |
| 781 | 781 | { |
| 782 | bw2_state *state = | |
| 782 | bw2_state *state = | |
| 783 | 783 | |
| 784 | 784 | if (device_load_serial(image) == IMAGE_INIT_PASS) |
| 785 | 785 | { |
| r8714 | r8715 | |
|---|---|---|
| 27 | 27 | #define ENTERPRISE_XTAL_X1 XTAL_8MHz |
| 28 | 28 | |
| 29 | 29 | |
| 30 | class ep_state | |
| 30 | class ep_state : public driver_data_t | |
| 31 | 31 | { |
| 32 | 32 | public: |
| 33 | static | |
| 33 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ep_state(machine)); } | |
| 34 | 34 | |
| 35 | ep_state(running_machine &machine) { } | |
| 35 | ep_state(running_machine &machine) | |
| 36 | : driver_data_t(machine) { } | |
| 36 | 37 | |
| 37 | 38 | UINT8 exdos_card_value; /* state of the wd1770 irq/drq lines */ |
| 38 | 39 | UINT8 keyboard_line; /* index of keyboard line to read */ |
| r8714 | r8715 | |
| 111 | 112 | /* EP specific handling of dave register write */ |
| 112 | 113 | static WRITE8_DEVICE_HANDLER( enterprise_dave_reg_write ) |
| 113 | 114 | { |
| 114 | ep_state *ep = | |
| 115 | ep_state *ep = | |
| 115 | 116 | |
| 116 | 117 | switch (offset) |
| 117 | 118 | { |
| r8714 | r8715 | |
| 137 | 138 | "LINE5", "LINE6", "LINE7", "LINE8", "LINE9" |
| 138 | 139 | }; |
| 139 | 140 | |
| 140 | ep_state *ep = | |
| 141 | ep_state *ep = | |
| 141 | 142 | |
| 142 | 143 | switch (offset) |
| 143 | 144 | { |
| r8714 | r8715 | |
| 193 | 194 | |
| 194 | 195 | static WRITE_LINE_DEVICE_HANDLER( enterp_wd1770_intrq_w ) |
| 195 | 196 | { |
| 196 | ep_state *ep = | |
| 197 | ep_state *ep = | |
| 197 | 198 | |
| 198 | 199 | if (state) |
| 199 | 200 | ep->exdos_card_value |= 0x02; |
| r8714 | r8715 | |
| 203 | 204 | |
| 204 | 205 | static WRITE_LINE_DEVICE_HANDLER( enterp_wd1770_drq_w ) |
| 205 | 206 | { |
| 206 | ep_state *ep = | |
| 207 | ep_state *ep = | |
| 207 | 208 | |
| 208 | 209 | if (state) |
| 209 | 210 | ep->exdos_card_value |= 0x80; |
| r8714 | r8715 | |
| 223 | 224 | */ |
| 224 | 225 | static READ8_HANDLER( exdos_card_r ) |
| 225 | 226 | { |
| 226 | ep_state *ep = | |
| 227 | ep_state *ep = | |
| 227 | 228 | return ep->exdos_card_value; |
| 228 | 229 | } |
| 229 | 230 |
| r8714 | r8715 | |
|---|---|---|
| 21 | 21 | TYPE DEFINITIONS |
| 22 | 22 | ***************************************************************************/ |
| 23 | 23 | |
| 24 | class mc10_state | |
| 24 | class mc10_state : public driver_data_t | |
| 25 | 25 | { |
| 26 | 26 | public: |
| 27 | static | |
| 27 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mc10_state(machine)); } | |
| 28 | 28 | |
| 29 | mc10_state(running_machine &machine) { } | |
| 29 | mc10_state(running_machine &machine) | |
| 30 | : driver_data_t(machine) { } | |
| 30 | 31 | |
| 31 | 32 | running_device *mc6847; |
| 32 | 33 | running_device *dac; |
| r8714 | r8715 | |
| 45 | 46 | |
| 46 | 47 | static READ8_HANDLER( mc10_bfff_r ) |
| 47 | 48 | { |
| 48 | mc10_state *mc10 = | |
| 49 | mc10_state *mc10 = | |
| 49 | 50 | UINT8 result = 0xff; |
| 50 | 51 | |
| 51 | 52 | if (!BIT(mc10->keyboard_strobe, 0)) result &= input_port_read(space->machine, "pb0"); |
| r8714 | r8715 | |
| 62 | 63 | |
| 63 | 64 | static WRITE8_HANDLER( mc10_bfff_w ) |
| 64 | 65 | { |
| 65 | mc10_state *mc10 = | |
| 66 | mc10_state *mc10 = | |
| 66 | 67 | |
| 67 | 68 | /* bit 2 to 6, mc6847 mode lines */ |
| 68 | 69 | mc6847_gm2_w(mc10->mc6847, BIT(data, 2)); |
| r8714 | r8715 | |
| 84 | 85 | /* keyboard strobe */ |
| 85 | 86 | static READ8_HANDLER( mc10_port1_r ) |
| 86 | 87 | { |
| 87 | mc10_state *mc10 = | |
| 88 | mc10_state *mc10 = | |
| 88 | 89 | return mc10->keyboard_strobe; |
| 89 | 90 | } |
| 90 | 91 | |
| 91 | 92 | /* keyboard strobe */ |
| 92 | 93 | static WRITE8_HANDLER( mc10_port1_w ) |
| 93 | 94 | { |
| 94 | mc10_state *mc10 = | |
| 95 | mc10_state *mc10 = | |
| 95 | 96 | mc10->keyboard_strobe = data; |
| 96 | 97 | } |
| 97 | 98 | |
| 98 | 99 | static READ8_HANDLER( mc10_port2_r ) |
| 99 | 100 | { |
| 100 | mc10_state *mc10 = | |
| 101 | mc10_state *mc10 = | |
| 101 | 102 | UINT8 result = 0xef; |
| 102 | 103 | |
| 103 | 104 | /* bit 1, keyboard line pa6 */ |
| r8714 | r8715 | |
| 117 | 118 | |
| 118 | 119 | static WRITE8_HANDLER( mc10_port2_w ) |
| 119 | 120 | { |
| 120 | mc10_state *mc10 = | |
| 121 | mc10_state *mc10 = | |
| 121 | 122 | |
| 122 | 123 | /* bit 0, cassette & printer output */ |
| 123 | 124 | cassette_output(mc10->cassette, BIT(data, 0) ? +1.0 : -1.0); |
| r8714 | r8715 | |
| 130 | 131 | |
| 131 | 132 | static READ8_DEVICE_HANDLER( mc10_mc6847_videoram_r ) |
| 132 | 133 | { |
| 133 | mc10_state *mc10 = | |
| 134 | mc10_state *mc10 = | |
| 134 | 135 | |
| 135 | 136 | mc6847_inv_w(device, BIT(mc10->ram[offset], 6)); |
| 136 | 137 | mc6847_as_w(device, BIT(mc10->ram[offset], 7)); |
| r8714 | r8715 | |
| 140 | 141 | |
| 141 | 142 | static VIDEO_UPDATE( mc10 ) |
| 142 | 143 | { |
| 143 | mc10_state *mc10 = | |
| 144 | mc10_state *mc10 = | |
| 144 | 145 | return mc6847_update(mc10->mc6847, bitmap, cliprect); |
| 145 | 146 | } |
| 146 | 147 | |
| r8714 | r8715 | |
| 151 | 152 | |
| 152 | 153 | static DRIVER_INIT( mc10 ) |
| 153 | 154 | { |
| 154 | mc10_state *mc10 = | |
| 155 | mc10_state *mc10 = | |
| 155 | 156 | const address_space *prg = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 156 | 157 | |
| 157 | 158 | /* initialize keyboard strobe */ |
| r8714 | r8715 | |
|---|---|---|
| 136 | 136 | |
| 137 | 137 | static void bankswitch(running_machine *machine) |
| 138 | 138 | { |
| 139 | atom_state *state = | |
| 139 | atom_state *state = | |
| 140 | 140 | const address_space *program = cputag_get_address_space(machine, SY6502_TAG, ADDRESS_SPACE_PROGRAM); |
| 141 | 141 | |
| 142 | 142 | UINT8 *eprom = memory_region(machine, "a000") + (state->eprom << 12); |
| r8714 | r8715 | |
| 150 | 150 | |
| 151 | 151 | static READ8_HANDLER( eprom_r ) |
| 152 | 152 | { |
| 153 | atom_state *state = | |
| 153 | atom_state *state = | |
| 154 | 154 | |
| 155 | 155 | return state->eprom; |
| 156 | 156 | } |
| r8714 | r8715 | |
| 176 | 176 | |
| 177 | 177 | */ |
| 178 | 178 | |
| 179 | atom_state *state = | |
| 179 | atom_state *state = | |
| 180 | 180 | |
| 181 | 181 | /* block A */ |
| 182 | 182 | state->eprom = data & 0x0f; |
| r8714 | r8715 | |
| 366 | 366 | |
| 367 | 367 | static VIDEO_UPDATE( atom ) |
| 368 | 368 | { |
| 369 | atom_state *state = | |
| 369 | atom_state *state = | |
| 370 | 370 | |
| 371 | 371 | return mc6847_update(state->mc6847, bitmap, cliprect); |
| 372 | 372 | } |
| r8714 | r8715 | |
| 396 | 396 | |
| 397 | 397 | */ |
| 398 | 398 | |
| 399 | atom_state *state = | |
| 399 | atom_state *state = | |
| 400 | 400 | |
| 401 | 401 | /* keyboard column */ |
| 402 | 402 | state->keylatch = data & 0x0f; |
| r8714 | r8715 | |
| 425 | 425 | |
| 426 | 426 | */ |
| 427 | 427 | |
| 428 | atom_state *state = | |
| 428 | atom_state *state = | |
| 429 | 429 | UINT8 data = 0xff; |
| 430 | 430 | |
| 431 | 431 | switch (state->keylatch) |
| r8714 | r8715 | |
| 464 | 464 | |
| 465 | 465 | */ |
| 466 | 466 | |
| 467 | atom_state *state = | |
| 467 | atom_state *state = | |
| 468 | 468 | |
| 469 | 469 | UINT8 data = 0; |
| 470 | 470 | |
| r8714 | r8715 | |
| 500 | 500 | |
| 501 | 501 | */ |
| 502 | 502 | |
| 503 | atom_state *state = | |
| 503 | atom_state *state = | |
| 504 | 504 | |
| 505 | 505 | /* cassette output */ |
| 506 | 506 | state->pc0 = BIT(data, 0); |
| r8714 | r8715 | |
| 635 | 635 | |
| 636 | 636 | static TIMER_DEVICE_CALLBACK( cassette_output_tick ) |
| 637 | 637 | { |
| 638 | atom_state *state = | |
| 638 | atom_state *state = | |
| 639 | 639 | |
| 640 | 640 | int level = !(!(!state->hz2400 & state->pc1) & state->pc0); |
| 641 | 641 | |
| r8714 | r8715 | |
| 663 | 663 | |
| 664 | 664 | static READ8_DEVICE_HANDLER( atom_mc6847_videoram_r ) |
| 665 | 665 | { |
| 666 | atom_state *state = | |
| 666 | atom_state *state = | |
| 667 | 667 | |
| 668 | 668 | mc6847_as_w(device, BIT(state->video_ram[offset], 6)); |
| 669 | 669 | mc6847_intext_w(device, BIT(state->video_ram[offset], 6)); |
| r8714 | r8715 | |
| 698 | 698 | |
| 699 | 699 | static MACHINE_START( atom ) |
| 700 | 700 | { |
| 701 | atom_state *state = | |
| 701 | atom_state *state = | |
| 702 | 702 | |
| 703 | 703 | /* this is temporary */ |
| 704 | 704 | /* Kees van Oss mentions that address 8-b are used for the random number |
| r8714 | r8715 | |
|---|---|---|
| 25 | 25 | TYPE DEFINITIONS |
| 26 | 26 | ***************************************************************************/ |
| 27 | 27 | |
| 28 | class apricot_state | |
| 28 | class apricot_state : public driver_data_t | |
| 29 | 29 | { |
| 30 | 30 | public: |
| 31 | static | |
| 31 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, apricot_state(machine)); } | |
| 32 | 32 | |
| 33 | apricot_state(running_machine &machine) { } | |
| 33 | apricot_state(running_machine &machine) | |
| 34 | : driver_data_t(machine) { } | |
| 34 | 35 | |
| 35 | 36 | running_device *pic8259; |
| 36 | 37 | running_device *wd2793; |
| r8714 | r8715 | |
| 49 | 50 | |
| 50 | 51 | static READ8_DEVICE_HANDLER( apricot_sysctrl_r ) |
| 51 | 52 | { |
| 52 | apricot_state *apricot = | |
| 53 | apricot_state *apricot = | |
| 53 | 54 | UINT8 data = 0; |
| 54 | 55 | |
| 55 | 56 | data |= apricot->display_enabled << 3; |
| r8714 | r8715 | |
| 59 | 60 | |
| 60 | 61 | static WRITE8_DEVICE_HANDLER( apricot_sysctrl_w ) |
| 61 | 62 | { |
| 62 | apricot_state *apricot = | |
| 63 | apricot_state *apricot = | |
| 63 | 64 | |
| 64 | 65 | apricot->display_on = BIT(data, 3); |
| 65 | 66 | apricot->video_mode = BIT(data, 4); |
| r8714 | r8715 | |
| 101 | 102 | |
| 102 | 103 | static void apricot_sio_irq_w(running_device *device, int state) |
| 103 | 104 | { |
| 104 | apricot_state *apricot = | |
| 105 | apricot_state *apricot = | |
| 105 | 106 | pic8259_ir5_w(apricot->pic8259, state); |
| 106 | 107 | } |
| 107 | 108 | |
| r8714 | r8715 | |
| 122 | 123 | |
| 123 | 124 | static IRQ_CALLBACK( apricot_irq_ack ) |
| 124 | 125 | { |
| 125 | apricot_state *apricot = | |
| 126 | apricot_state *apricot = | |
| 126 | 127 | return pic8259_acknowledge(apricot->pic8259); |
| 127 | 128 | } |
| 128 | 129 | |
| r8714 | r8715 | |
| 138 | 139 | |
| 139 | 140 | static WRITE_LINE_DEVICE_HANDLER( apricot_wd2793_intrq_w ) |
| 140 | 141 | { |
| 141 | apricot_state *apricot = | |
| 142 | apricot_state *apricot = | |
| 142 | 143 | |
| 143 | 144 | pic8259_ir4_w(apricot->pic8259, state); |
| 144 | 145 | // i8089 external terminate channel 1 |
| r8714 | r8715 | |
| 164 | 165 | |
| 165 | 166 | static VIDEO_UPDATE( apricot ) |
| 166 | 167 | { |
| 167 | apricot_state *apricot = | |
| 168 | apricot_state *apricot = | |
| 168 | 169 | |
| 169 | 170 | if (!apricot->display_on) |
| 170 | 171 | mc6845_update(apricot->mc6845, bitmap, cliprect); |
| r8714 | r8715 | |
| 176 | 177 | |
| 177 | 178 | static MC6845_UPDATE_ROW( apricot_update_row ) |
| 178 | 179 | { |
| 179 | apricot_state *apricot = | |
| 180 | apricot_state *apricot = | |
| 180 | 181 | UINT8 *ram = messram_get_ptr(device->machine->device("messram")); |
| 181 | 182 | int i, x; |
| 182 | 183 | |
| r8714 | r8715 | |
| 211 | 212 | |
| 212 | 213 | static WRITE_LINE_DEVICE_HANDLER( apricot_mc6845_de ) |
| 213 | 214 | { |
| 214 | apricot_state *apricot = | |
| 215 | apricot_state *apricot = | |
| 215 | 216 | apricot->display_enabled = state; |
| 216 | 217 | } |
| 217 | 218 | |
| r8714 | r8715 | |
| 236 | 237 | |
| 237 | 238 | static DRIVER_INIT( apricot ) |
| 238 | 239 | { |
| 239 | apricot_state *apricot = | |
| 240 | apricot_state *apricot = | |
| 240 | 241 | running_device *maincpu = machine->device("maincpu"); |
| 241 | 242 | const address_space *prg = cpu_get_address_space(maincpu, ADDRESS_SPACE_PROGRAM); |
| 242 | 243 |
| r8714 | r8715 | |
|---|---|---|
| 154 | 154 | |
| 155 | 155 | */ |
| 156 | 156 | |
| 157 | lc80_state *state = | |
| 157 | lc80_state *state = | |
| 158 | 158 | |
| 159 | 159 | state->segment = BITSWAP8(~data, 4, 3, 1, 6, 7, 5, 0, 2); |
| 160 | 160 | |
| r8714 | r8715 | |
| 178 | 178 | |
| 179 | 179 | */ |
| 180 | 180 | |
| 181 | lc80_state *state = | |
| 181 | lc80_state *state = | |
| 182 | 182 | |
| 183 | 183 | return (cassette_input(state->cassette) < +0.0); |
| 184 | 184 | } |
| r8714 | r8715 | |
| 200 | 200 | |
| 201 | 201 | */ |
| 202 | 202 | |
| 203 | lc80_state *state = | |
| 203 | lc80_state *state = | |
| 204 | 204 | |
| 205 | 205 | /* tape output */ |
| 206 | 206 | cassette_output(state->cassette, BIT(data, 1) ? +1.0 : -1.0); |
| r8714 | r8715 | |
| 246 | 246 | |
| 247 | 247 | */ |
| 248 | 248 | |
| 249 | lc80_state *state = | |
| 249 | lc80_state *state = | |
| 250 | 250 | UINT8 data = 0xf0; |
| 251 | 251 | int i; |
| 252 | 252 | |
| r8714 | r8715 | |
| 289 | 289 | |
| 290 | 290 | static MACHINE_START( lc80 ) |
| 291 | 291 | { |
| 292 | lc80_state *state = | |
| 292 | lc80_state *state = | |
| 293 | 293 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 294 | 294 | |
| 295 | 295 | /* find devices */ |
| r8714 | r8715 | |
|---|---|---|
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | 48 | /* 6600, 6500-6503 wd179x disc controller? 6400, 6401 */ |
| 49 | class apf_state | |
| 49 | class apf_state : public driver_data_t | |
| 50 | 50 | { |
| 51 | 51 | public: |
| 52 | static | |
| 52 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, apf_state(machine)); } | |
| 53 | 53 | |
| 54 | apf_state(running_machine &machine) { } | |
| 54 | apf_state(running_machine &machine) | |
| 55 | : driver_data_t(machine) { } | |
| 55 | 56 | |
| 56 | 57 | unsigned char keyboard_data; |
| 57 | 58 | unsigned char pad_data; |
| r8714 | r8715 | |
| 67 | 68 | |
| 68 | 69 | static READ8_DEVICE_HANDLER( apf_mc6847_videoram_r ) |
| 69 | 70 | { |
| 70 | apf_state *state = | |
| 71 | apf_state *state = | |
| 71 | 72 | mc6847_css_w(device, state->mc6847_css && BIT(state->videoram[offset + 0x200], 6)); |
| 72 | 73 | mc6847_inv_w(device, BIT(state->videoram[offset + 0x200], 6)); |
| 73 | 74 | mc6847_as_w(device, BIT(state->videoram[offset + 0x200], 7)); |
| r8714 | r8715 | |
| 77 | 78 | |
| 78 | 79 | static WRITE_LINE_DEVICE_HANDLER( apf_mc6847_fs_w ) |
| 79 | 80 | { |
| 80 | apf_state *state_ = | |
| 81 | apf_state *state_ = | |
| 81 | 82 | |
| 82 | 83 | if (state) |
| 83 | 84 | state_->apf_ints |= 0x10; |
| r8714 | r8715 | |
| 95 | 96 | |
| 96 | 97 | static READ8_DEVICE_HANDLER(apf_m1000_pia_in_a_func) |
| 97 | 98 | { |
| 98 | apf_state *state = | |
| 99 | apf_state *state = | |
| 99 | 100 | UINT8 data=~0; |
| 100 | 101 | |
| 101 | 102 | if (!(state->pad_data & 0x08)) |
| r8714 | r8715 | |
| 144 | 145 | |
| 145 | 146 | static WRITE8_DEVICE_HANDLER( apf_m1000_pia_out_b_func ) |
| 146 | 147 | { |
| 147 | apf_state *state = | |
| 148 | apf_state *state = | |
| 148 | 149 | running_device *mc6847 = device->machine->device("mc6847"); |
| 149 | 150 | |
| 150 | 151 | /* bit 7..4 video control -- TODO: bit 5 and 4? */ |
| r8714 | r8715 | |
| 157 | 158 | |
| 158 | 159 | static WRITE_LINE_DEVICE_HANDLER(apf_m1000_pia_out_ca2_func) |
| 159 | 160 | { |
| 160 | apf_state *state_ = | |
| 161 | apf_state *state_ = | |
| 161 | 162 | |
| 162 | 163 | state_->mc6847_css = state; |
| 163 | 164 | } |
| r8714 | r8715 | |
| 176 | 177 | |
| 177 | 178 | static void apf_update_ints(running_machine *machine) |
| 178 | 179 | { |
| 179 | apf_state *state = | |
| 180 | apf_state *state = | |
| 180 | 181 | |
| 181 | 182 | cputag_set_input_line(machine, "maincpu", 0, state->apf_ints ? HOLD_LINE : CLEAR_LINE); |
| 182 | 183 | } |
| 183 | 184 | |
| 184 | 185 | static WRITE_LINE_DEVICE_HANDLER( apf_m1000_irq_a_func ) |
| 185 | 186 | { |
| 186 | apf_state *state_ = | |
| 187 | apf_state *state_ = | |
| 187 | 188 | |
| 188 | 189 | if (state) |
| 189 | 190 | { |
| r8714 | r8715 | |
| 200 | 201 | |
| 201 | 202 | static WRITE_LINE_DEVICE_HANDLER( apf_m1000_irq_b_func ) |
| 202 | 203 | { |
| 203 | apf_state *state_ = | |
| 204 | apf_state *state_ = | |
| 204 | 205 | |
| 205 | 206 | //logerror("pia 0 irq b %d\n",state); |
| 206 | 207 | |
| r8714 | r8715 | |
| 236 | 237 | |
| 237 | 238 | static READ8_DEVICE_HANDLER(apf_imagination_pia_in_a_func) |
| 238 | 239 | { |
| 239 | apf_state *state = | |
| 240 | apf_state *state = | |
| 240 | 241 | |
| 241 | 242 | return state->keyboard_data; |
| 242 | 243 | } |
| r8714 | r8715 | |
| 280 | 281 | |
| 281 | 282 | static WRITE8_DEVICE_HANDLER(apf_imagination_pia_out_b_func) |
| 282 | 283 | { |
| 283 | apf_state *state = | |
| 284 | apf_state *state = | |
| 284 | 285 | |
| 285 | 286 | /* bits 2..0 = keyboard line */ |
| 286 | 287 | /* bit 3 = ??? */ |
| r8714 | r8715 | |
| 315 | 316 | |
| 316 | 317 | static WRITE_LINE_DEVICE_HANDLER( apf_imagination_irq_a_func ) |
| 317 | 318 | { |
| 318 | apf_state *state_ = | |
| 319 | apf_state *state_ = | |
| 319 | 320 | |
| 320 | 321 | if (state) |
| 321 | 322 | { |
| r8714 | r8715 | |
| 331 | 332 | |
| 332 | 333 | static WRITE_LINE_DEVICE_HANDLER( apf_imagination_irq_b_func ) |
| 333 | 334 | { |
| 334 | apf_state *state_ = | |
| 335 | apf_state *state_ = | |
| 335 | 336 | |
| 336 | 337 | if (state) |
| 337 | 338 | { |
| r8714 | r8715 | |
| 365 | 366 | |
| 366 | 367 | static MACHINE_START( apf_imagination ) |
| 367 | 368 | { |
| 368 | apf_state *state = | |
| 369 | apf_state *state = | |
| 369 | 370 | |
| 370 | 371 | state->apf_ints = 0; |
| 371 | 372 | } |
| r8714 | r8715 | |
|---|---|---|
| 97 | 97 | |
| 98 | 98 | static CUSTOM_INPUT( snes_mouse_speed_input ) |
| 99 | 99 | { |
| 100 | snes_state *state = | |
| 100 | snes_state *state = | |
| 101 | 101 | int port = (FPTR)param; |
| 102 | 102 | |
| 103 | 103 | if (snes_ram[OLDJOY1] & 0x1) |
| r8714 | r8715 | |
| 112 | 112 | |
| 113 | 113 | static CUSTOM_INPUT( snes_superscope_offscreen_input ) |
| 114 | 114 | { |
| 115 | snes_state *state = | |
| 115 | snes_state *state = | |
| 116 | 116 | int port = (FPTR)param; |
| 117 | 117 | static const char *const portnames[2][3] = |
| 118 | 118 | { |
| r8714 | r8715 | |
| 378 | 378 | |
| 379 | 379 | static void snes_input_read_joy( running_machine *machine, int port ) |
| 380 | 380 | { |
| 381 | snes_state *state = | |
| 381 | snes_state *state = | |
| 382 | 382 | static const char *const portnames[2][4] = |
| 383 | 383 | { |
| 384 | 384 | { "SERIAL1_DATA1_L", "SERIAL1_DATA1_H", "SERIAL1_DATA2_L", "SERIAL1_DATA2_H" }, |
| r8714 | r8715 | |
| 401 | 401 | |
| 402 | 402 | static void snes_input_read_mouse( running_machine *machine, int port ) |
| 403 | 403 | { |
| 404 | snes_state *state = | |
| 404 | snes_state *state = | |
| 405 | 405 | INT16 var; |
| 406 | 406 | static const char *const portnames[2][3] = |
| 407 | 407 | { |
| r8714 | r8715 | |
| 464 | 464 | |
| 465 | 465 | static void snes_input_read_superscope( running_machine *machine, int port ) |
| 466 | 466 | { |
| 467 | snes_state *state = | |
| 467 | snes_state *state = | |
| 468 | 468 | static const char *const portnames[2][3] = |
| 469 | 469 | { |
| 470 | 470 | { "SUPERSCOPE1", "SUPERSCOPE1_X", "SUPERSCOPE1_Y" }, |
| r8714 | r8715 | |
| 526 | 526 | |
| 527 | 527 | static void snes_input_read( running_machine *machine ) |
| 528 | 528 | { |
| 529 | snes_state *state = | |
| 529 | snes_state *state = | |
| 530 | 530 | UINT8 ctrl1 = input_port_read(machine, "CTRLSEL") & 0x0f; |
| 531 | 531 | UINT8 ctrl2 = (input_port_read(machine, "CTRLSEL") & 0xf0) >> 4; |
| 532 | 532 | |
| r8714 | r8715 | |
| 591 | 591 | |
| 592 | 592 | static UINT8 snes_oldjoy1_read( running_machine *machine ) |
| 593 | 593 | { |
| 594 | snes_state *state = | |
| 594 | snes_state *state = | |
| 595 | 595 | UINT8 ctrl1 = input_port_read(machine, "CTRLSEL") & 0x0f; |
| 596 | 596 | UINT8 res = 0; |
| 597 | 597 | |
| r8714 | r8715 | |
| 631 | 631 | |
| 632 | 632 | static UINT8 snes_oldjoy2_read( running_machine *machine ) |
| 633 | 633 | { |
| 634 | snes_state *state = | |
| 634 | snes_state *state = | |
| 635 | 635 | UINT8 ctrl2 = (input_port_read(machine, "CTRLSEL") & 0xf0) >> 4; |
| 636 | 636 | UINT8 res = 0; |
| 637 | 637 | |
| r8714 | r8715 | |
| 677 | 677 | |
| 678 | 678 | static MACHINE_RESET( snes_mess ) |
| 679 | 679 | { |
| 680 | snes_state *state = | |
| 680 | snes_state *state = | |
| 681 | 681 | |
| 682 | 682 | MACHINE_RESET_CALL(snes); |
| 683 | 683 |
| r8714 | r8715 | |
|---|---|---|
| 87 | 87 | UINT16 control; |
| 88 | 88 | }; |
| 89 | 89 | |
| 90 | class supracan_state | |
| 90 | class supracan_state : public driver_data_t | |
| 91 | 91 | { |
| 92 | 92 | public: |
| 93 | static | |
| 93 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, supracan_state(machine)); } | |
| 94 | 94 | |
| 95 | supracan_state(running_machine &machine) { } | |
| 95 | supracan_state(running_machine &machine) | |
| 96 | : driver_data_t(machine) { } | |
| 96 | 97 | |
| 97 | 98 | acan_dma_regs_t acan_dma_regs; |
| 98 | 99 | acan_sprdma_regs_t acan_sprdma_regs; |
| r8714 | r8715 | |
| 163 | 164 | |
| 164 | 165 | static VIDEO_START( supracan ) |
| 165 | 166 | { |
| 166 | supracan_state *state = | |
| 167 | supracan_state *state = | |
| 167 | 168 | state->roz_bitmap = auto_bitmap_alloc(machine, 1024, 512, BITMAP_FORMAT_INDEXED16); |
| 168 | 169 | state->roz_final_bitmap = auto_bitmap_alloc(machine, 1024, 512, BITMAP_FORMAT_INDEXED16); |
| 169 | 170 | } |
| 170 | 171 | |
| 171 | 172 | static void draw_tilemap(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,int layer) |
| 172 | 173 | { |
| 173 | supracan_state *state = | |
| 174 | supracan_state *state = | |
| 174 | 175 | UINT16 *supracan_vram = state->vram; |
| 175 | 176 | UINT32 count; |
| 176 | 177 | int x,y; |
| r8714 | r8715 | |
| 240 | 241 | /* */ |
| 241 | 242 | static void draw_roz_bitmap_scanline(running_machine *machine, bitmap_t *roz_bitmap, UINT16 *scanline, int ypos, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed) |
| 242 | 243 | { |
| 243 | supracan_state *state = | |
| 244 | supracan_state *state = | |
| 244 | 245 | |
| 245 | 246 | INT32 sx = 0; |
| 246 | 247 | INT32 sy = 0; |
| r8714 | r8715 | |
| 328 | 329 | |
| 329 | 330 | static void draw_roz(running_machine *machine, const rectangle *cliprect) |
| 330 | 331 | { |
| 331 | supracan_state *state = | |
| 332 | supracan_state *state = | |
| 332 | 333 | UINT16 *supracan_vram = state->vram; |
| 333 | 334 | UINT32 roz_base_addr = state->roz_base_addr; |
| 334 | 335 | int region = 0; |
| r8714 | r8715 | |
| 375 | 376 | |
| 376 | 377 | static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 377 | 378 | { |
| 378 | supracan_state *state = | |
| 379 | supracan_state *state = | |
| 379 | 380 | UINT16 *supracan_vram = state->vram; |
| 380 | 381 | int x, y; |
| 381 | 382 | int xtile, ytile; |
| r8714 | r8715 | |
| 493 | 494 | #if DRAW_DEBUG_ROZ |
| 494 | 495 | static void draw_debug_roz(running_machine *machine, bitmap_t *bitmap) |
| 495 | 496 | { |
| 496 | supracan_state *state = | |
| 497 | supracan_state *state = | |
| 497 | 498 | UINT16 *supracan_vram = state->vram; |
| 498 | 499 | |
| 499 | 500 | for(int y = 0; y < 240; y++) |
| r8714 | r8715 | |
| 522 | 523 | |
| 523 | 524 | static VIDEO_UPDATE( supracan ) |
| 524 | 525 | { |
| 525 | supracan_state *state = | |
| 526 | supracan_state *state = | |
| 526 | 527 | |
| 527 | 528 | bitmap_fill(bitmap, cliprect, 0); |
| 528 | 529 | |
| r8714 | r8715 | |
| 623 | 624 | |
| 624 | 625 | static WRITE16_HANDLER( supracan_dma_w ) |
| 625 | 626 | { |
| 626 | supracan_state *state = | |
| 627 | supracan_state *state = | |
| 627 | 628 | acan_dma_regs_t *acan_dma_regs = &state->acan_dma_regs; |
| 628 | 629 | int i; |
| 629 | 630 | int ch; |
| r8714 | r8715 | |
| 729 | 730 | |
| 730 | 731 | static WRITE16_HANDLER( supracan_char_w ) |
| 731 | 732 | { |
| 732 | supracan_state *state = | |
| 733 | supracan_state *state = | |
| 733 | 734 | UINT16 *supracan_vram = state->vram; |
| 734 | 735 | |
| 735 | 736 | COMBINE_DATA(&supracan_vram[offset]); |
| r8714 | r8715 | |
| 880 | 881 | |
| 881 | 882 | static WRITE16_HANDLER( supracan_soundram_w ) |
| 882 | 883 | { |
| 883 | supracan_state *state = | |
| 884 | supracan_state *state = | |
| 884 | 885 | |
| 885 | 886 | state->soundram_16[offset] = data; |
| 886 | 887 | |
| r8714 | r8715 | |
| 898 | 899 | |
| 899 | 900 | static WRITE16_HANDLER( supracan_sound_w ) |
| 900 | 901 | { |
| 901 | supracan_state *state = | |
| 902 | supracan_state *state = | |
| 902 | 903 | |
| 903 | 904 | switch ( offset ) |
| 904 | 905 | { |
| r8714 | r8715 | |
| 932 | 933 | |
| 933 | 934 | static READ16_HANDLER( supracan_video_r ) |
| 934 | 935 | { |
| 935 | supracan_state *state = | |
| 936 | supracan_state *state = | |
| 936 | 937 | UINT16 data = state->video_regs[offset]; |
| 937 | 938 | |
| 938 | 939 | switch(offset) |
| r8714 | r8715 | |
| 950 | 951 | |
| 951 | 952 | static TIMER_CALLBACK( supracan_video_callback ) |
| 952 | 953 | { |
| 953 | supracan_state *state = | |
| 954 | supracan_state *state = | |
| 954 | 955 | int vpos = machine->primary_screen->vpos(); |
| 955 | 956 | |
| 956 | 957 | switch( vpos ) |
| r8714 | r8715 | |
| 993 | 994 | */ |
| 994 | 995 | static WRITE16_HANDLER( supracan_video_w ) |
| 995 | 996 | { |
| 996 | supracan_state *state = | |
| 997 | supracan_state *state = | |
| 997 | 998 | acan_sprdma_regs_t *acan_sprdma_regs = &state->acan_sprdma_regs; |
| 998 | 999 | int i; |
| 999 | 1000 | |
| r8714 | r8715 | |
| 1148 | 1149 | |
| 1149 | 1150 | static MACHINE_START( supracan ) |
| 1150 | 1151 | { |
| 1151 | supracan_state *state = | |
| 1152 | supracan_state *state = | |
| 1152 | 1153 | |
| 1153 | 1154 | state->video_timer = timer_alloc( machine, supracan_video_callback, NULL ); |
| 1154 | 1155 | } |
| r8714 | r8715 | |
| 1156 | 1157 | |
| 1157 | 1158 | static MACHINE_RESET( supracan ) |
| 1158 | 1159 | { |
| 1159 | supracan_state *state = | |
| 1160 | supracan_state *state = | |
| 1160 | 1161 | |
| 1161 | 1162 | cputag_set_input_line(machine, "soundcpu", INPUT_LINE_HALT, ASSERT_LINE); |
| 1162 | 1163 | timer_adjust_oneshot( state->video_timer, machine->primary_screen->time_until_pos(0, 0 ), 0 ); |
| r8714 | r8715 | |
| 1204 | 1205 | |
| 1205 | 1206 | static INTERRUPT_GEN( supracan_irq ) |
| 1206 | 1207 | { |
| 1207 | supracan_state *state = | |
| 1208 | supracan_state *state = | |
| 1208 | 1209 | |
| 1209 | 1210 | if(state->irq_mask) |
| 1210 | 1211 | cpu_set_input_line(device, 7, HOLD_LINE); |
| r8714 | r8715 | |
|---|---|---|
| 11 | 11 | #include "sound/dac.h" |
| 12 | 12 | #include "4004clk.lh" |
| 13 | 13 | |
| 14 | class _4004clk_state | |
| 14 | class _4004clk_state : public driver_data_t | |
| 15 | 15 | { |
| 16 | 16 | public: |
| 17 | static | |
| 17 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, _4004clk_state(machine)); } | |
| 18 | 18 | |
| 19 | _4004clk_state(running_machine &machine) { } | |
| 19 | _4004clk_state(running_machine &machine) | |
| 20 | : driver_data_t(machine) { } | |
| 20 | 21 | |
| 21 | 22 | UINT16 nixie[16]; |
| 22 | 23 | UINT8 timer; |
| r8714 | r8715 | |
| 55 | 56 | |
| 56 | 57 | static void update_nixie(running_machine *machine) |
| 57 | 58 | { |
| 58 | _4004clk_state *state = | |
| 59 | _4004clk_state *state = | |
| 59 | 60 | |
| 60 | 61 | output_set_nixie_value(5,nixie_to_num(((state->nixie[2] & 3)<<8) | (state->nixie[1] << 4) | state->nixie[0])); |
| 61 | 62 | output_set_nixie_value(4,nixie_to_num((state->nixie[4] << 6) | (state->nixie[3] << 2) | (state->nixie[2] >>2))); |
| r8714 | r8715 | |
| 67 | 68 | |
| 68 | 69 | static WRITE8_HANDLER(nixie_w) |
| 69 | 70 | { |
| 70 | _4004clk_state *state = | |
| 71 | _4004clk_state *state = | |
| 71 | 72 | state->nixie[offset] = data; |
| 72 | 73 | update_nixie(space->machine); |
| 73 | 74 | } |
| r8714 | r8715 | |
| 82 | 83 | |
| 83 | 84 | static WRITE8_HANDLER(relays_w) |
| 84 | 85 | { |
| 85 | _4004clk_state *state = | |
| 86 | _4004clk_state *state = | |
| 86 | 87 | dac_data_w(state->dac, (data & 1) ? 0x80 : 0x40); //tick - tock |
| 87 | 88 | } |
| 88 | 89 | |
| r8714 | r8715 | |
| 127 | 128 | |
| 128 | 129 | static TIMER_CALLBACK(timer_callback) |
| 129 | 130 | { |
| 130 | _4004clk_state *state = | |
| 131 | _4004clk_state *state = | |
| 131 | 132 | i4004_set_test(machine->device("maincpu"),state->timer); |
| 132 | 133 | state->timer^=1; |
| 133 | 134 | } |
| 134 | 135 | |
| 135 | 136 | static MACHINE_START(4004clk) |
| 136 | 137 | { |
| 137 | _4004clk_state *state = | |
| 138 | _4004clk_state *state = | |
| 138 | 139 | state->timer = 0; |
| 139 | 140 | state->dac = machine->device("dac"); |
| 140 | 141 |
| r8714 | r8715 | |
|---|---|---|
| 96 | 96 | |
| 97 | 97 | */ |
| 98 | 98 | |
| 99 | c80_state *state = | |
| 99 | c80_state *state = | |
| 100 | 100 | |
| 101 | 101 | UINT8 data = !state->pio1_brdy << 4 | 0x07; |
| 102 | 102 | |
| r8714 | r8715 | |
| 134 | 134 | |
| 135 | 135 | */ |
| 136 | 136 | |
| 137 | c80_state *state = | |
| 137 | c80_state *state = | |
| 138 | 138 | |
| 139 | 139 | state->pio1_a5 = BIT(data, 5); |
| 140 | 140 | |
| r8714 | r8715 | |
| 163 | 163 | |
| 164 | 164 | */ |
| 165 | 165 | |
| 166 | c80_state *state = | |
| 166 | c80_state *state = | |
| 167 | 167 | |
| 168 | 168 | if (!state->pio1_a5) |
| 169 | 169 | { |
| r8714 | r8715 | |
| 175 | 175 | |
| 176 | 176 | static WRITE_LINE_DEVICE_HANDLER( pio1_brdy_w ) |
| 177 | 177 | { |
| 178 | c80_state *driver_state = | |
| 178 | c80_state *driver_state = | |
| 179 | 179 | |
| 180 | 180 | driver_state->pio1_brdy = state; |
| 181 | 181 | |
| r8714 | r8715 | |
| 226 | 226 | |
| 227 | 227 | static MACHINE_START( c80 ) |
| 228 | 228 | { |
| 229 | c80_state *state = | |
| 229 | c80_state *state = | |
| 230 | 230 | |
| 231 | 231 | /* find devices */ |
| 232 | 232 | state->cassette = machine->device(CASSETTE_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 80 | 80 | |
| 81 | 81 | static WRITE8_HANDLER( keyboard_latch_w ) |
| 82 | 82 | { |
| 83 | tmc2000e_state *state = | |
| 83 | tmc2000e_state *state = | |
| 84 | 84 | |
| 85 | 85 | state->keylatch = data; |
| 86 | 86 | } |
| r8714 | r8715 | |
| 128 | 128 | |
| 129 | 129 | static READ_LINE_DEVICE_HANDLER( rdata_r ) |
| 130 | 130 | { |
| 131 | tmc2000e_state *state = | |
| 131 | tmc2000e_state *state = | |
| 132 | 132 | |
| 133 | 133 | return BIT(state->color, 2); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | static READ_LINE_DEVICE_HANDLER( bdata_r ) |
| 137 | 137 | { |
| 138 | tmc2000e_state *state = | |
| 138 | tmc2000e_state *state = | |
| 139 | 139 | |
| 140 | 140 | return BIT(state->color, 1); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | static READ_LINE_DEVICE_HANDLER( gdata_r ) |
| 144 | 144 | { |
| 145 | tmc2000e_state *state = | |
| 145 | tmc2000e_state *state = | |
| 146 | 146 | |
| 147 | 147 | return BIT(state->color, 0); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | static WRITE_LINE_DEVICE_HANDLER( tmc2000e_efx_w ) |
| 151 | 151 | { |
| 152 | tmc2000e_state *driver_state = | |
| 152 | tmc2000e_state *driver_state = | |
| 153 | 153 | |
| 154 | 154 | driver_state->cdp1864_efx = state; |
| 155 | 155 | } |
| r8714 | r8715 | |
| 173 | 173 | |
| 174 | 174 | static VIDEO_UPDATE( tmc2000e ) |
| 175 | 175 | { |
| 176 | tmc2000e_state *state = | |
| 176 | tmc2000e_state *state = | |
| 177 | 177 | |
| 178 | 178 | cdp1864_update(state->cdp1864, bitmap, cliprect); |
| 179 | 179 | |
| r8714 | r8715 | |
| 196 | 196 | |
| 197 | 197 | static CDP1802_EF_READ( tmc2000e_ef_r ) |
| 198 | 198 | { |
| 199 | tmc2000e_state *state = | |
| 199 | tmc2000e_state *state = | |
| 200 | 200 | |
| 201 | 201 | UINT8 flags = 0x0f; |
| 202 | 202 | static const char *const keynames[] = { "IN0", "IN1", "IN2", "IN3", "IN4", "IN5", "IN6", "IN7" }; |
| r8714 | r8715 | |
| 225 | 225 | |
| 226 | 226 | static WRITE_LINE_DEVICE_HANDLER( tmc2000e_q_w ) |
| 227 | 227 | { |
| 228 | tmc2000e_state *driver_state = | |
| 228 | tmc2000e_state *driver_state = | |
| 229 | 229 | |
| 230 | 230 | // turn CDP1864 sound generator on/off |
| 231 | 231 | |
| r8714 | r8715 | |
| 244 | 244 | |
| 245 | 245 | static WRITE8_DEVICE_HANDLER( tmc2000e_dma_w ) |
| 246 | 246 | { |
| 247 | tmc2000e_state *state = | |
| 247 | tmc2000e_state *state = | |
| 248 | 248 | |
| 249 | 249 | state->color = (state->colorram[offset & 0x3ff]) & 0x07; // 0x04 = R, 0x02 = B, 0x01 = G |
| 250 | 250 | |
| r8714 | r8715 | |
| 266 | 266 | |
| 267 | 267 | static MACHINE_START( tmc2000e ) |
| 268 | 268 | { |
| 269 | tmc2000e_state *state = | |
| 269 | tmc2000e_state *state = | |
| 270 | 270 | |
| 271 | 271 | /* allocate color RAM */ |
| 272 | 272 | state->colorram = auto_alloc_array(machine, UINT8, TMC2000E_COLORRAM_SIZE); |
| r8714 | r8715 | |
| 283 | 283 | |
| 284 | 284 | static MACHINE_RESET( tmc2000e ) |
| 285 | 285 | { |
| 286 | tmc2000e_state *state = | |
| 286 | tmc2000e_state *state = | |
| 287 | 287 | |
| 288 | 288 | state->cdp1864->reset(); |
| 289 | 289 |
| r8714 | r8715 | |
|---|---|---|
| 37 | 37 | * I/O devices * |
| 38 | 38 | \****************************************************/ |
| 39 | 39 | |
| 40 | class craft_state | |
| 40 | class craft_state : public driver_data_t | |
| 41 | 41 | { |
| 42 | 42 | public: |
| 43 | static | |
| 43 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, craft_state(machine)); } | |
| 44 | 44 | |
| 45 | craft_state(running_machine &machine) { } | |
| 45 | craft_state(running_machine &machine) | |
| 46 | : driver_data_t(machine) { } | |
| 46 | 47 | |
| 47 | 48 | UINT8 regs[0x100]; |
| 48 | 49 | INT32 tcnt1_direction; |
| r8714 | r8715 | |
| 189 | 190 | |
| 190 | 191 | static TIMER_CALLBACK( ocr1a_timer_compare ) |
| 191 | 192 | { |
| 192 | //craft_state *state = | |
| 193 | //craft_state *state = | |
| 193 | 194 | //avr8_regs *regs = &state->regs; |
| 194 | 195 | |
| 195 | 196 | // TODO |
| r8714 | r8715 | |
| 200 | 201 | |
| 201 | 202 | static TIMER_CALLBACK( ocr1b_timer_compare ) |
| 202 | 203 | { |
| 203 | //craft_state *state = | |
| 204 | //craft_state *state = | |
| 204 | 205 | //avr8_regs *regs = &state->regs; |
| 205 | 206 | |
| 206 | 207 | // TODO |
| r8714 | r8715 | |
| 211 | 212 | |
| 212 | 213 | static READ8_HANDLER( avr8_read ) |
| 213 | 214 | { |
| 214 | craft_state *state = | |
| 215 | craft_state *state = | |
| 215 | 216 | |
| 216 | 217 | if(offset <= Avr8::REGIDX_R31) |
| 217 | 218 | { |
| r8714 | r8715 | |
| 234 | 235 | |
| 235 | 236 | static UINT8 avr8_get_ddr(running_machine *machine, int reg) |
| 236 | 237 | { |
| 237 | craft_state *state = | |
| 238 | craft_state *state = | |
| 238 | 239 | |
| 239 | 240 | switch(reg) |
| 240 | 241 | { |
| r8714 | r8715 | |
| 257 | 258 | |
| 258 | 259 | static void avr8_change_ddr(running_machine *machine, int reg, UINT8 data) |
| 259 | 260 | { |
| 260 | //craft_state *state = | |
| 261 | //craft_state *state = | |
| 261 | 262 | |
| 262 | 263 | UINT8 oldddr = avr8_get_ddr(machine, reg); |
| 263 | 264 | UINT8 newddr = data; |
| r8714 | r8715 | |
| 272 | 273 | |
| 273 | 274 | static void avr8_change_port(running_machine *machine, int reg, UINT8 data) |
| 274 | 275 | { |
| 275 | //craft_state *state = | |
| 276 | //craft_state *state = | |
| 276 | 277 | |
| 277 | 278 | UINT8 oldport = avr8_get_ddr(machine, reg); |
| 278 | 279 | UINT8 newport = data; |
| r8714 | r8715 | |
| 345 | 346 | static void avr8_spi_update_masterslave_select(running_machine *machine) |
| 346 | 347 | { |
| 347 | 348 | // TODO |
| 348 | craft_state *state = | |
| 349 | craft_state *state = | |
| 349 | 350 | verboselog(machine, 0, "avr8_spi_update_masterslave_select: TODO; AVR is %s\n", AVR8_SPCR_MSTR ? "Master" : "Slave"); |
| 350 | 351 | } |
| 351 | 352 | |
| 352 | 353 | static void avr8_spi_update_clock_polarity(running_machine *machine) |
| 353 | 354 | { |
| 354 | 355 | // TODO |
| 355 | craft_state *state = | |
| 356 | craft_state *state = | |
| 356 | 357 | verboselog(machine, 0, "avr8_spi_update_clock_polarity: TODO; SCK is Active-%s\n", AVR8_SPCR_CPOL ? "Low" : "High"); |
| 357 | 358 | } |
| 358 | 359 | |
| 359 | 360 | static void avr8_spi_update_clock_phase(running_machine *machine) |
| 360 | 361 | { |
| 361 | 362 | // TODO |
| 362 | craft_state *state = | |
| 363 | craft_state *state = | |
| 363 | 364 | verboselog(machine, 0, "avr8_spi_update_clock_phase: TODO; Sampling edge is %s\n", AVR8_SPCR_CPHA ? "Trailing" : "Leading"); |
| 364 | 365 | } |
| 365 | 366 | |
| r8714 | r8715 | |
| 368 | 369 | static void avr8_spi_update_clock_rate(running_machine *machine) |
| 369 | 370 | { |
| 370 | 371 | // TODO |
| 371 | craft_state *state = | |
| 372 | craft_state *state = | |
| 372 | 373 | verboselog(machine, 0, "avr8_spi_update_clock_rate: TODO; New clock rate should be f/%d\n", avr8_spi_clock_divisor[AVR8_SPCR_SPR] / (AVR8_SPSR_SPR2X ? 2 : 1)); |
| 373 | 374 | } |
| 374 | 375 | |
| 375 | 376 | static void avr8_change_spcr(running_machine *machine, UINT8 data) |
| 376 | 377 | { |
| 377 | craft_state *state = | |
| 378 | craft_state *state = | |
| 378 | 379 | |
| 379 | 380 | UINT8 oldspcr = AVR8_SPCR; |
| 380 | 381 | UINT8 newspcr = data; |
| r8714 | r8715 | |
| 422 | 423 | |
| 423 | 424 | static void avr8_change_spsr(running_machine *machine, UINT8 data) |
| 424 | 425 | { |
| 425 | craft_state *state = | |
| 426 | craft_state *state = | |
| 426 | 427 | |
| 427 | 428 | UINT8 oldspsr = AVR8_SPSR; |
| 428 | 429 | UINT8 newspsr = data; |
| r8714 | r8715 | |
| 445 | 446 | |
| 446 | 447 | static void avr8_change_timsk1(running_machine *machine, UINT8 data) |
| 447 | 448 | { |
| 448 | craft_state *state = | |
| 449 | craft_state *state = | |
| 449 | 450 | |
| 450 | 451 | UINT8 oldtimsk = AVR8_TIMSK1; |
| 451 | 452 | UINT8 newtimsk = data; |
| r8714 | r8715 | |
| 479 | 480 | static void avr8_update_timer1_compare_mode(running_machine *machine, int reg) |
| 480 | 481 | { |
| 481 | 482 | // TODO |
| 482 | craft_state *state = | |
| 483 | craft_state *state = | |
| 483 | 484 | UINT8 mode = (reg == AVR8_REG_A) ? AVR8_TCCR1A_COM1A : AVR8_TCCR1A_COM1B; |
| 484 | 485 | switch(mode) |
| 485 | 486 | { |
| r8714 | r8715 | |
| 577 | 578 | { |
| 578 | 579 | // TODO |
| 579 | 580 | UINT16 top = 0; |
| 580 | craft_state *state = | |
| 581 | craft_state *state = | |
| 581 | 582 | verboselog(machine, 0, "avr8_update_timer1_waveform_gen_mode: TODO; WGM1 is %d\n", AVR8_WGM1 ); |
| 582 | 583 | switch(AVR8_WGM1) |
| 583 | 584 | { |
| r8714 | r8715 | |
| 622 | 623 | |
| 623 | 624 | static void avr8_changed_tccr1a(running_machine *machine, UINT8 data) |
| 624 | 625 | { |
| 625 | craft_state *state = | |
| 626 | craft_state *state = | |
| 626 | 627 | |
| 627 | 628 | UINT8 oldtccr = AVR8_TCCR1A; |
| 628 | 629 | UINT8 newtccr = data; |
| r8714 | r8715 | |
| 654 | 655 | static void avr8_update_timer1_input_edge_select(running_machine *machine) |
| 655 | 656 | { |
| 656 | 657 | // TODO |
| 657 | //craft_state *state = | |
| 658 | //craft_state *state = | |
| 658 | 659 | verboselog(machine, 0, "avr8_update_timer1_input_edge_select: TODO; Clocking edge is %s\n", "test"); |
| 659 | 660 | } |
| 660 | 661 | |
| r8714 | r8715 | |
| 664 | 665 | |
| 665 | 666 | static void avr8_changed_tccr1b(running_machine *machine, UINT8 data) |
| 666 | 667 | { |
| 667 | craft_state *state = | |
| 668 | craft_state *state = | |
| 668 | 669 | |
| 669 | 670 | UINT8 oldtccr = AVR8_TCCR1B; |
| 670 | 671 | UINT8 newtccr = data; |
| r8714 | r8715 | |
| 697 | 698 | |
| 698 | 699 | static void avr8_update_ocr1(running_machine *machine, UINT16 newval, UINT8 reg) |
| 699 | 700 | { |
| 700 | craft_state *state = | |
| 701 | craft_state *state = | |
| 701 | 702 | UINT8 *p_reg_h = (reg == AVR8_REG_A) ? &AVR8_OCR1AH : &AVR8_OCR1BH; |
| 702 | 703 | UINT8 *p_reg_l = (reg == AVR8_REG_A) ? &AVR8_OCR1AL : &AVR8_OCR1BL; |
| 703 | 704 | *p_reg_h = (UINT8)(newval >> 8); |
| r8714 | r8715 | |
| 708 | 709 | |
| 709 | 710 | static WRITE8_HANDLER( avr8_write ) |
| 710 | 711 | { |
| 711 | craft_state *state = | |
| 712 | craft_state *state = | |
| 712 | 713 | |
| 713 | 714 | if(offset <= Avr8::REGIDX_R31) |
| 714 | 715 | { |
| r8714 | r8715 | |
| 818 | 819 | |
| 819 | 820 | static DRIVER_INIT( craft ) |
| 820 | 821 | { |
| 821 | craft_state *state = | |
| 822 | craft_state *state = | |
| 822 | 823 | |
| 823 | 824 | state->ocr1a_timer = timer_alloc(machine, ocr1a_timer_compare, 0); |
| 824 | 825 | state->ocr1b_timer = timer_alloc(machine, ocr1b_timer_compare, 0); |
| r8714 | r8715 | |
| 826 | 827 | |
| 827 | 828 | static MACHINE_RESET( craft ) |
| 828 | 829 | { |
| 829 | craft_state *state = | |
| 830 | craft_state *state = | |
| 830 | 831 | |
| 831 | 832 | AVR8_TIMSK1 = 0; |
| 832 | 833 | AVR8_OCR1AH = 0; |
| r8714 | r8715 | |
|---|---|---|
| 22 | 22 | #define VIA6522_1_TAG "via6522_1" |
| 23 | 23 | #define MC6845_TAG "mc6845" |
| 24 | 24 | |
| 25 | class ec65_state | |
| 25 | class ec65_state : public driver_data_t | |
| 26 | 26 | { |
| 27 | 27 | public: |
| 28 | static | |
| 28 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ec65_state(machine)); } | |
| 29 | 29 | |
| 30 | ec65_state(running_machine &machine) { } | |
| 30 | ec65_state(running_machine &machine) | |
| 31 | : driver_data_t(machine) { } | |
| 31 | 32 | |
| 32 | 33 | UINT8 *video_ram; |
| 33 | 34 | }; |
| r8714 | r8715 | |
| 158 | 159 | |
| 159 | 160 | static MC6845_UPDATE_ROW( ec65_update_row ) |
| 160 | 161 | { |
| 161 | ec65_state *state = | |
| 162 | ec65_state *state = | |
| 162 | 163 | UINT8 *charrom = memory_region(device->machine, "chargen"); |
| 163 | 164 | int column, bit; |
| 164 | 165 |
| r8714 | r8715 | |
|---|---|---|
| 15 | 15 | #include "devices/flopdrv.h" |
| 16 | 16 | #include "formats/basicdsk.h" |
| 17 | 17 | |
| 18 | class act_state | |
| 18 | class act_state : public driver_data_t | |
| 19 | 19 | { |
| 20 | 20 | public: |
| 21 | static | |
| 21 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, act_state(machine)); } | |
| 22 | 22 | |
| 23 | act_state(running_machine &machine) { } | |
| 23 | act_state(running_machine &machine) | |
| 24 | : driver_data_t(machine) { } | |
| 24 | 25 | |
| 25 | 26 | UINT16 *paletteram; |
| 26 | 27 | UINT16 *vram; |
| r8714 | r8715 | |
| 35 | 36 | |
| 36 | 37 | static VIDEO_UPDATE( act_f1 ) |
| 37 | 38 | { |
| 38 | act_state *state = | |
| 39 | act_state *state = | |
| 39 | 40 | int x,y,i; |
| 40 | 41 | int x_count; |
| 41 | 42 | |
| r8714 | r8715 | |
| 74 | 75 | |
| 75 | 76 | static READ8_HANDLER( act_fdc_r ) |
| 76 | 77 | { |
| 77 | act_state *state = | |
| 78 | act_state *state = | |
| 78 | 79 | running_device* dev = space->machine->device("fdc"); |
| 79 | 80 | |
| 80 | 81 | // printf("%02x\n",offset); |
| r8714 | r8715 | |
| 102 | 103 | |
| 103 | 104 | static WRITE8_HANDLER( act_fdc_w ) |
| 104 | 105 | { |
| 105 | act_state *state = | |
| 106 | act_state *state = | |
| 106 | 107 | running_device* dev = space->machine->device("fdc"); |
| 107 | 108 | |
| 108 | 109 | // printf("%02x %02x\n",offset,data); |
| r8714 | r8715 | |
| 132 | 133 | |
| 133 | 134 | static READ16_HANDLER( act_pal_r ) |
| 134 | 135 | { |
| 135 | act_state *state = | |
| 136 | act_state *state = | |
| 136 | 137 | |
| 137 | 138 | return state->paletteram[offset]; |
| 138 | 139 | } |
| 139 | 140 | |
| 140 | 141 | static WRITE16_HANDLER( act_pal_w ) |
| 141 | 142 | { |
| 142 | act_state *state = | |
| 143 | act_state *state = | |
| 143 | 144 | UINT8 i,r,g,b; |
| 144 | 145 | COMBINE_DATA(&state->paletteram[offset]); |
| 145 | 146 |
| r8714 | r8715 | |
|---|---|---|
| 211 | 211 | |
| 212 | 212 | static TIMER_DEVICE_CALLBACK( ctc_tick ) |
| 213 | 213 | { |
| 214 | mtx_state *state = | |
| 214 | mtx_state *state = | |
| 215 | 215 | |
| 216 | 216 | z80ctc_trg1_w(state->z80ctc, 1); |
| 217 | 217 | z80ctc_trg1_w(state->z80ctc, 0 ); |
| r8714 | r8715 | |
| 221 | 221 | |
| 222 | 222 | static WRITE_LINE_DEVICE_HANDLER( ctc_trg1_w ) |
| 223 | 223 | { |
| 224 | mtx_state *driver_state = | |
| 224 | mtx_state *driver_state = | |
| 225 | 225 | |
| 226 | 226 | if (driver_state->z80dart != NULL) |
| 227 | 227 | { |
| r8714 | r8715 | |
| 232 | 232 | |
| 233 | 233 | static WRITE_LINE_DEVICE_HANDLER( ctc_trg2_w ) |
| 234 | 234 | { |
| 235 | mtx_state *driver_state = | |
| 235 | mtx_state *driver_state = | |
| 236 | 236 | |
| 237 | 237 | if (driver_state->z80dart != NULL) |
| 238 | 238 | { |
| r8714 | r8715 | |
| 301 | 301 | |
| 302 | 302 | static TIMER_DEVICE_CALLBACK( cassette_tick ) |
| 303 | 303 | { |
| 304 | mtx_state *state = | |
| 304 | mtx_state *state = | |
| 305 | 305 | int data = (cassette_input(state->cassette) > +0.0) ? 0 : 1; |
| 306 | 306 | |
| 307 | 307 | z80ctc_trg3_w(state->z80ctc, data); |
| r8714 | r8715 | |
|---|---|---|
| 50 | 50 | #include "formats/vg5k_cas.h" |
| 51 | 51 | |
| 52 | 52 | |
| 53 | class vg5k_state | |
| 53 | class vg5k_state : public driver_data_t | |
| 54 | 54 | { |
| 55 | 55 | public: |
| 56 | static | |
| 56 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vg5k_state(machine)); } | |
| 57 | 57 | |
| 58 | vg5k_state(running_machine &machine) { } | |
| 58 | vg5k_state(running_machine &machine) | |
| 59 | : driver_data_t(machine) { } | |
| 59 | 60 | |
| 60 | 61 | running_device *ef9345; |
| 61 | 62 | running_device *dac; |
| r8714 | r8715 | |
| 68 | 69 | |
| 69 | 70 | READ8_HANDLER( printer_r ) |
| 70 | 71 | { |
| 71 | vg5k_state *vg5k = | |
| 72 | vg5k_state *vg5k = | |
| 72 | 73 | |
| 73 | 74 | return (printer_is_ready(vg5k->printer) ? 0x00 : 0xff); |
| 74 | 75 | } |
| r8714 | r8715 | |
| 76 | 77 | |
| 77 | 78 | WRITE8_HANDLER( printer_w ) |
| 78 | 79 | { |
| 79 | vg5k_state *vg5k = | |
| 80 | vg5k_state *vg5k = | |
| 80 | 81 | |
| 81 | 82 | printer_output(vg5k->printer, data); |
| 82 | 83 | } |
| r8714 | r8715 | |
| 84 | 85 | |
| 85 | 86 | WRITE8_HANDLER ( ef9345_offset_w ) |
| 86 | 87 | { |
| 87 | vg5k_state *vg5k = | |
| 88 | vg5k_state *vg5k = | |
| 88 | 89 | |
| 89 | 90 | vg5k->ef9345_offset = data; |
| 90 | 91 | } |
| r8714 | r8715 | |
| 92 | 93 | |
| 93 | 94 | READ8_HANDLER ( ef9345_io_r ) |
| 94 | 95 | { |
| 95 | vg5k_state *vg5k = | |
| 96 | vg5k_state *vg5k = | |
| 96 | 97 | |
| 97 | 98 | return ef9345_r(vg5k->ef9345, vg5k->ef9345_offset); |
| 98 | 99 | } |
| r8714 | r8715 | |
| 100 | 101 | |
| 101 | 102 | WRITE8_HANDLER ( ef9345_io_w ) |
| 102 | 103 | { |
| 103 | vg5k_state *vg5k = | |
| 104 | vg5k_state *vg5k = | |
| 104 | 105 | |
| 105 | 106 | ef9345_w(vg5k->ef9345, vg5k->ef9345_offset, data); |
| 106 | 107 | } |
| r8714 | r8715 | |
| 108 | 109 | |
| 109 | 110 | READ8_HANDLER ( cassette_r ) |
| 110 | 111 | { |
| 111 | vg5k_state *vg5k = | |
| 112 | vg5k_state *vg5k = | |
| 112 | 113 | double level; |
| 113 | 114 | |
| 114 | 115 | level = cassette_input(vg5k->cassette); |
| r8714 | r8715 | |
| 119 | 120 | |
| 120 | 121 | WRITE8_HANDLER ( cassette_w ) |
| 121 | 122 | { |
| 122 | vg5k_state *vg5k = | |
| 123 | vg5k_state *vg5k = | |
| 123 | 124 | |
| 124 | 125 | dac_data_w(vg5k->dac, data <<2); |
| 125 | 126 | |
| r8714 | r8715 | |
| 290 | 291 | |
| 291 | 292 | static TIMER_DEVICE_CALLBACK( vg5k_scanline ) |
| 292 | 293 | { |
| 293 | vg5k_state *vg5k = | |
| 294 | vg5k_state *vg5k = | |
| 294 | 295 | |
| 295 | 296 | ef9345_scanline(vg5k->ef9345, (UINT16)param); |
| 296 | 297 | } |
| r8714 | r8715 | |
| 298 | 299 | |
| 299 | 300 | static MACHINE_START( vg5k ) |
| 300 | 301 | { |
| 301 | vg5k_state *vg5k = | |
| 302 | vg5k_state *vg5k = | |
| 302 | 303 | |
| 303 | 304 | vg5k->ef9345 = machine->device("ef9345"); |
| 304 | 305 | vg5k->dac = machine->device("dac"); |
| r8714 | r8715 | |
| 312 | 313 | |
| 313 | 314 | static MACHINE_RESET( vg5k ) |
| 314 | 315 | { |
| 315 | vg5k_state *vg5k = | |
| 316 | vg5k_state *vg5k = | |
| 316 | 317 | |
| 317 | 318 | vg5k->ef9345_offset = 0; |
| 318 | 319 | } |
| r8714 | r8715 | |
| 323 | 324 | |
| 324 | 325 | static VIDEO_UPDATE( vg5k ) |
| 325 | 326 | { |
| 326 | vg5k_state *vg5k = | |
| 327 | vg5k_state *vg5k = | |
| 327 | 328 | |
| 328 | 329 | video_update_ef9345(vg5k->ef9345, bitmap, cliprect); |
| 329 | 330 |
| r8714 | r8715 | |
|---|---|---|
| 39 | 39 | *************************************/ |
| 40 | 40 | static DIRECT_UPDATE_HANDLER(elwro800_direct_handler) |
| 41 | 41 | { |
| 42 | spectrum_state *state = | |
| 42 | spectrum_state *state = | |
| 43 | 43 | if (state->ram_at_0000 && address == 0x66) |
| 44 | 44 | { |
| 45 | 45 | direct->raw = direct->decrypted = &state->df_on_databus; |
| r8714 | r8715 | |
| 90 | 90 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 91 | 91 | UINT8 cs; |
| 92 | 92 | UINT8 ls175; |
| 93 | spectrum_state *state = | |
| 93 | spectrum_state *state = | |
| 94 | 94 | |
| 95 | 95 | ls175 = BITSWAP8(data, 7, 6, 5, 4, 4, 5, 7, 6) & 0x0f; |
| 96 | 96 | |
| r8714 | r8715 | |
| 208 | 208 | { |
| 209 | 209 | UINT8 *prom = memory_region(space->machine, "proms"); |
| 210 | 210 | UINT8 cs = prom[offset & 0x1ff]; |
| 211 | spectrum_state *state = | |
| 211 | spectrum_state *state = | |
| 212 | 212 | |
| 213 | 213 | if (!BIT(cs,0)) |
| 214 | 214 | { |
| r8714 | r8715 | |
| 491 | 491 | |
| 492 | 492 | static MACHINE_RESET(elwro800) |
| 493 | 493 | { |
| 494 | spectrum_state *state = | |
| 494 | spectrum_state *state = | |
| 495 | 495 | UINT8 *messram = messram_get_ptr(machine->device("messram")); |
| 496 | 496 | |
| 497 | 497 | state->df_on_databus = 0xdf; |
| r8714 | r8715 | |
|---|---|---|
| 35 | 35 | #include "devices/cassette.h" |
| 36 | 36 | |
| 37 | 37 | |
| 38 | class pv2000_state | |
| 38 | class pv2000_state : public driver_data_t | |
| 39 | 39 | { |
| 40 | 40 | public: |
| 41 | static | |
| 41 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pv2000_state(machine)); } | |
| 42 | 42 | |
| 43 | pv2000_state(running_machine &machine) { last_state = 0; } | |
| 43 | pv2000_state(running_machine &machine) | |
| 44 | : driver_data_t(machine) { last_state = 0; } | |
| 44 | 45 | |
| 45 | 46 | int last_state; |
| 46 | 47 | UINT8 keyb_column; |
| r8714 | r8715 | |
| 51 | 52 | |
| 52 | 53 | static WRITE8_HANDLER( pv2000_cass_conf_w ) |
| 53 | 54 | { |
| 54 | pv2000_state *state = | |
| 55 | pv2000_state *state = | |
| 55 | 56 | |
| 56 | 57 | logerror( "%s: pv2000_cass_conf_w %02x\n", cpuexec_describe_context(space->machine), data ); |
| 57 | 58 | |
| r8714 | r8715 | |
| 66 | 67 | |
| 67 | 68 | static WRITE8_HANDLER( pv2000_keys_w ) |
| 68 | 69 | { |
| 69 | pv2000_state *state = | |
| 70 | pv2000_state *state = | |
| 70 | 71 | |
| 71 | 72 | logerror( "%s: pv2000_keys_w %02x\n", cpuexec_describe_context(space->machine), data ); |
| 72 | 73 | |
| r8714 | r8715 | |
| 78 | 79 | |
| 79 | 80 | static READ8_HANDLER( pv2000_keys_hi_r ) |
| 80 | 81 | { |
| 81 | pv2000_state *state = | |
| 82 | pv2000_state *state = | |
| 82 | 83 | UINT8 data = 0; |
| 83 | 84 | |
| 84 | 85 | switch ( state->keyb_column ) |
| r8714 | r8715 | |
| 118 | 119 | |
| 119 | 120 | static READ8_HANDLER( pv2000_keys_lo_r ) |
| 120 | 121 | { |
| 121 | pv2000_state *state = | |
| 122 | pv2000_state *state = | |
| 122 | 123 | UINT8 data = 0; |
| 123 | 124 | |
| 124 | 125 | logerror("%s: pv2000_keys_r\n", cpuexec_describe_context(space->machine) ); |
| r8714 | r8715 | |
| 312 | 313 | |
| 313 | 314 | static void pv2000_vdp_interrupt(running_machine *machine, int new_state) |
| 314 | 315 | { |
| 315 | pv2000_state *state = | |
| 316 | pv2000_state *state = | |
| 316 | 317 | |
| 317 | 318 | // only if it goes up |
| 318 | 319 | if (new_state && !state->last_state) |
| r8714 | r8715 | |
| 362 | 363 | |
| 363 | 364 | static MACHINE_RESET( pv2000 ) |
| 364 | 365 | { |
| 365 | pv2000_state *state = | |
| 366 | pv2000_state *state = | |
| 366 | 367 | |
| 367 | 368 | state->last_state = 0; |
| 368 | 369 | state->key_pressed = 0; |
| r8714 | r8715 | |
|---|---|---|
| 20 | 20 | static WRITE8_HANDLER( scv_cart_ram2_w ); |
| 21 | 21 | |
| 22 | 22 | |
| 23 | class scv_state | |
| 23 | class scv_state : public driver_data_t | |
| 24 | 24 | { |
| 25 | 25 | public: |
| 26 | static | |
| 26 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, scv_state(machine)); } | |
| 27 | 27 | |
| 28 | scv_state(running_machine &machine) { } | |
| 28 | scv_state(running_machine &machine) | |
| 29 | : driver_data_t(machine) { } | |
| 29 | 30 | |
| 30 | 31 | UINT8 *vram; |
| 31 | 32 | UINT8 porta; |
| r8714 | r8715 | |
| 153 | 154 | |
| 154 | 155 | static WRITE8_HANDLER( scv_cart_ram_w ) |
| 155 | 156 | { |
| 156 | scv_state *state = | |
| 157 | scv_state *state = | |
| 157 | 158 | |
| 158 | 159 | /* Check if cartridge ram is enabled */ |
| 159 | 160 | if ( state->cart_ram_enabled ) |
| r8714 | r8715 | |
| 165 | 166 | |
| 166 | 167 | static WRITE8_HANDLER( scv_cart_ram2_w ) |
| 167 | 168 | { |
| 168 | scv_state *state = | |
| 169 | scv_state *state = | |
| 169 | 170 | |
| 170 | 171 | /* Check if cartridge ram is enabled */ |
| 171 | 172 | if ( state->cart_ram_enabled ) |
| r8714 | r8715 | |
| 180 | 181 | |
| 181 | 182 | static WRITE8_HANDLER( scv_porta_w ) |
| 182 | 183 | { |
| 183 | scv_state *state = | |
| 184 | scv_state *state = | |
| 184 | 185 | |
| 185 | 186 | state->porta = data; |
| 186 | 187 | } |
| r8714 | r8715 | |
| 188 | 189 | |
| 189 | 190 | static READ8_HANDLER( scv_portb_r ) |
| 190 | 191 | { |
| 191 | scv_state *state = | |
| 192 | scv_state *state = | |
| 192 | 193 | UINT8 data = 0xff; |
| 193 | 194 | |
| 194 | 195 | if ( ! ( state->porta & 0x01 ) ) |
| r8714 | r8715 | |
| 221 | 222 | |
| 222 | 223 | static READ8_HANDLER( scv_portc_r ) |
| 223 | 224 | { |
| 224 | scv_state *state = | |
| 225 | scv_state *state = | |
| 225 | 226 | UINT8 data = state->portc; |
| 226 | 227 | |
| 227 | 228 | data = ( data & 0xfe ) | ( input_port_read( space->machine, "PC0" ) & 0x01 ); |
| r8714 | r8715 | |
| 232 | 233 | |
| 233 | 234 | static void scv_set_banks( running_machine *machine ) |
| 234 | 235 | { |
| 235 | scv_state *state = | |
| 236 | scv_state *state = | |
| 236 | 237 | |
| 237 | 238 | state->cart_ram_enabled = false; |
| 238 | 239 | |
| r8714 | r8715 | |
| 303 | 304 | |
| 304 | 305 | static WRITE8_HANDLER( scv_portc_w ) |
| 305 | 306 | { |
| 306 | scv_state *state = | |
| 307 | scv_state *state = | |
| 307 | 308 | |
| 308 | 309 | //logerror("%04x: scv_portc_w: data = 0x%02x\n", cpu_get_pc(space->machine->device("maincpu")), data ); |
| 309 | 310 | state->portc = data; |
| r8714 | r8715 | |
| 315 | 316 | |
| 316 | 317 | static DEVICE_START( scv_cart ) |
| 317 | 318 | { |
| 318 | scv_state *state = | |
| 319 | scv_state *state = | |
| 319 | 320 | |
| 320 | 321 | state->cart_rom = memory_region( device->machine, "cart" ); |
| 321 | 322 | state->cart_rom_size = 0; |
| r8714 | r8715 | |
| 328 | 329 | |
| 329 | 330 | static DEVICE_IMAGE_LOAD( scv_cart ) |
| 330 | 331 | { |
| 331 | scv_state *state = | |
| 332 | scv_state *state = | |
| 332 | 333 | |
| 333 | 334 | if ( image.software_entry() == NULL ) |
| 334 | 335 | { |
| r8714 | r8715 | |
| 420 | 421 | |
| 421 | 422 | static TIMER_CALLBACK( scv_vb_callback ) |
| 422 | 423 | { |
| 423 | scv_state *state = | |
| 424 | scv_state *state = | |
| 424 | 425 | int vpos = machine->primary_screen->vpos(); |
| 425 | 426 | |
| 426 | 427 | switch( vpos ) |
| r8714 | r8715 | |
| 727 | 728 | |
| 728 | 729 | static MACHINE_START( scv ) |
| 729 | 730 | { |
| 730 | scv_state *state = | |
| 731 | scv_state *state = | |
| 731 | 732 | |
| 732 | 733 | state->vb_timer = timer_alloc( machine, scv_vb_callback, NULL ); |
| 733 | 734 | } |
| r8714 | r8715 | |
| 735 | 736 | |
| 736 | 737 | static MACHINE_RESET( scv ) |
| 737 | 738 | { |
| 738 | scv_state *state = | |
| 739 | scv_state *state = | |
| 739 | 740 | |
| 740 | 741 | timer_adjust_oneshot( state->vb_timer, machine->primary_screen->time_until_pos(0, 0 ), 0 ); |
| 741 | 742 | } |
| r8714 | r8715 | |
|---|---|---|
| 17 | 17 | TYPE DEFINITIONS |
| 18 | 18 | ***************************************************************************/ |
| 19 | 19 | |
| 20 | class lx800_state | |
| 20 | class lx800_state : public driver_data_t | |
| 21 | 21 | { |
| 22 | 22 | public: |
| 23 | static | |
| 23 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lx800_state(machine)); } | |
| 24 | 24 | |
| 25 | lx800_state(running_machine &machine) { } | |
| 25 | lx800_state(running_machine &machine) | |
| 26 | : driver_data_t(machine) { } | |
| 26 | 27 | |
| 27 | 28 | running_device *speaker; |
| 28 | 29 | }; |
| r8714 | r8715 | |
| 84 | 85 | |
| 85 | 86 | static WRITE8_HANDLER( lx800_portc_w ) |
| 86 | 87 | { |
| 87 | lx800_state *lx800 = | |
| 88 | lx800_state *lx800 = | |
| 88 | 89 | |
| 89 | 90 | logerror("%s: lx800_portc_w(%02x): %02x\n", cpuexec_describe_context(space->machine), offset, data); |
| 90 | 91 | logerror("--> err: %d, ack: %d, fire: %d, buzzer: %d\n", BIT(data, 4), BIT(data, 5), BIT(data, 6), BIT(data, 7)); |
| r8714 | r8715 | |
| 126 | 127 | |
| 127 | 128 | static MACHINE_START( lx800 ) |
| 128 | 129 | { |
| 129 | lx800_state *lx800 = | |
| 130 | lx800_state *lx800 = | |
| 130 | 131 | |
| 131 | 132 | lx800->speaker = machine->device("beep"); |
| 132 | 133 |
| r8714 | r8715 | |
|---|---|---|
| 68 | 68 | |
| 69 | 69 | static void update_interrupts(running_machine *machine) |
| 70 | 70 | { |
| 71 | e01_state *state = | |
| 71 | e01_state *state = | |
| 72 | 72 | |
| 73 | 73 | cputag_set_input_line(machine, R65C102_TAG, INPUT_LINE_IRQ0, (state->via_irq || (state->hdc_ie & state->hdc_irq) || state->rtc_irq) ? ASSERT_LINE : CLEAR_LINE); |
| 74 | 74 | cputag_set_input_line(machine, R65C102_TAG, INPUT_LINE_NMI, (state->fdc_drq || (state->adlc_ie & state->adlc_irq)) ? ASSERT_LINE : CLEAR_LINE); |
| r8714 | r8715 | |
| 80 | 80 | |
| 81 | 81 | static void network_irq_enable(running_machine *machine, int enabled) |
| 82 | 82 | { |
| 83 | e01_state *state = | |
| 83 | e01_state *state = | |
| 84 | 84 | |
| 85 | 85 | state->adlc_ie = enabled; |
| 86 | 86 | |
| r8714 | r8715 | |
| 93 | 93 | |
| 94 | 94 | static void hdc_irq_enable(running_machine *machine, int enabled) |
| 95 | 95 | { |
| 96 | e01_state *state = | |
| 96 | e01_state *state = | |
| 97 | 97 | |
| 98 | 98 | state->hdc_ie = enabled; |
| 99 | 99 | |
| r8714 | r8715 | |
| 272 | 272 | /* |
| 273 | 273 | static WRITE_LINE_DEVICE_HANDLER( rtc_irq_w ) |
| 274 | 274 | { |
| 275 | e01_state *driver_state = | |
| 275 | e01_state *driver_state = | |
| 276 | 276 | |
| 277 | 277 | driver_state->rtc_irq = state; |
| 278 | 278 | |
| r8714 | r8715 | |
| 281 | 281 | */ |
| 282 | 282 | static TIMER_DEVICE_CALLBACK( rtc_irq_hack ) |
| 283 | 283 | { |
| 284 | e01_state *state = | |
| 284 | e01_state *state = | |
| 285 | 285 | |
| 286 | 286 | state->rtc_irq = !state->rtc_irq; |
| 287 | 287 | |
| r8714 | r8715 | |
| 294 | 294 | /* |
| 295 | 295 | static WRITE_LINE_DEVICE_HANDLER( adlc_irq_w ) |
| 296 | 296 | { |
| 297 | e01_state *driver_state = | |
| 297 | e01_state *driver_state = | |
| 298 | 298 | |
| 299 | 299 | driver_state->adlc_irq = state; |
| 300 | 300 | |
| r8714 | r8715 | |
| 315 | 315 | |
| 316 | 316 | static WRITE_LINE_DEVICE_HANDLER( via_irq_w ) |
| 317 | 317 | { |
| 318 | e01_state *driver_state = | |
| 318 | e01_state *driver_state = | |
| 319 | 319 | |
| 320 | 320 | driver_state->via_irq = state; |
| 321 | 321 | |
| r8714 | r8715 | |
| 361 | 361 | |
| 362 | 362 | static WRITE_LINE_DEVICE_HANDLER( fdc_drq_w ) |
| 363 | 363 | { |
| 364 | e01_state *driver_state = | |
| 364 | e01_state *driver_state = | |
| 365 | 365 | |
| 366 | 366 | driver_state->fdc_drq = state; |
| 367 | 367 | |
| r8714 | r8715 | |
| 386 | 386 | |
| 387 | 387 | static MACHINE_START( e01 ) |
| 388 | 388 | { |
| 389 | e01_state *state = | |
| 389 | e01_state *state = | |
| 390 | 390 | |
| 391 | 391 | UINT8 *ram = messram_get_ptr(machine->device("messram")); |
| 392 | 392 | UINT8 *rom = memory_region(machine, R65C102_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 17 | 17 | |
| 18 | 18 | static UINT8 ti_68k_keypad_r (running_machine *machine); |
| 19 | 19 | |
| 20 | class t68k_state | |
| 20 | class t68k_state : public driver_data_t | |
| 21 | 21 | { |
| 22 | 22 | public: |
| 23 | static | |
| 23 | static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, t68k_state(machine)); } | |
| 24 | 24 | |
| 25 | t68k_state(running_machine &machine) { } | |
| 25 | t68k_state(running_machine &machine) | |
| 26 | : driver_data_t(machine) { } | |
| 26 | 27 | |
| 27 | 28 | /* HW specifications */ |
| 28 | 29 | UINT8 hw_version; |
| r8714 | r8715 | |
| 61 | 62 | |
| 62 | 63 | static UINT8 ti_68k_keypad_r (running_machine *machine) |
| 63 | 64 | { |
| 64 | t68k_state *state = | |
| 65 | t68k_state *state = | |
| 65 | 66 | UINT8 port, bit, data = 0xff; |
| 66 | 67 | static const char *const bitnames[] = {"BIT0", "BIT1", "BIT2", "BIT3", "BIT4", "BIT5", "BIT6", "BIT7"}; |
| 67 | 68 | |
| r8714 | r8715 | |
| 75 | 76 | |
| 76 | 77 | WRITE16_HANDLER ( ti68k_io_w ) |
| 77 | 78 | { |
| 78 | t68k_state *state = | |
| 79 | t68k_state *state = | |
| 79 | 80 | |
| 80 | 81 | switch(offset & 0x0f) |
| 81 | 82 | { |
| r8714 | r8715 | |
| 120 | 121 | |
| 121 | 122 | READ16_HANDLER ( ti68k_io_r ) |
| 122 | 123 | { |
| 123 | t68k_state *state = | |
| 124 | t68k_state *state = | |
| 124 | 125 | UINT16 data; |
| 125 | 126 | |
| 126 | 127 | switch (offset & 0x0f) |
| r8714 | r8715 | |
| 143 | 144 | |
| 144 | 145 | WRITE16_HANDLER ( ti68k_io2_w ) |
| 145 | 146 | { |
| 146 | t68k_state *state = | |
| 147 | t68k_state *state = | |
| 147 | 148 | switch(offset & 0x7f) |
| 148 | 149 | { |
| 149 | 150 | case 0x0b: |
| r8714 | r8715 | |
| 160 | 161 | |
| 161 | 162 | READ16_HANDLER ( ti68k_io2_r ) |
| 162 | 163 | { |
| 163 | t68k_state *state = | |
| 164 | t68k_state *state = | |
| 164 | 165 | UINT16 data; |
| 165 | 166 | |
| 166 | 167 | switch (offset & 0x7f) |
| r8714 | r8715 | |
| 174 | 175 | |
| 175 | 176 | WRITE16_HANDLER ( flash_w ) |
| 176 | 177 | { |
| 177 | t68k_state *state = | |
| 178 | t68k_state *state = | |
| 178 | 179 | UINT16 *flash_base = (UINT16 *)memory_region(space->machine, "maincpu"); |
| 179 | 180 | |
| 180 | 181 | /* verification if it is flash memory */ |
| r8714 | r8715 | |
| 214 | 215 | |
| 215 | 216 | READ16_HANDLER ( rom_r ) |
| 216 | 217 | { |
| 217 | t68k_state *state = | |
| 218 | t68k_state *state = | |
| 218 | 219 | UINT16 *rom_base = (UINT16 *)memory_region(space->machine, "maincpu"); |
| 219 | 220 | |
| 220 | 221 | if (state->mem_type == FLASH) |
| r8714 | r8715 | |
| 241 | 242 | |
| 242 | 243 | static TIMER_CALLBACK( ti68k_timer_callback ) |
| 243 | 244 | { |
| 244 | t68k_state *state = | |
| 245 | t68k_state *state = | |
| 245 | 246 | static UINT64 timer; |
| 246 | 247 | |
| 247 | 248 | timer++; |
| r8714 | r8715 | |
| 323 | 324 | |
| 324 | 325 | static INPUT_CHANGED( ti68k_on_key ) |
| 325 | 326 | { |
| 326 | t68k_state *state = | |
| 327 | t68k_state *state = | |
| 327 | 328 | |
| 328 | 329 | state->on_key = newval; |
| 329 | 330 | |
| r8714 | r8715 | |
| 494 | 495 | |
| 495 | 496 | NVRAM_HANDLER( ti68k ) |
| 496 | 497 | { |
| 497 | t68k_state *state = | |
| 498 | t68k_state *state = | |
| 498 | 499 | UINT16 *rom = (UINT16 *)memory_region(machine, "maincpu"); |
| 499 | 500 | |
| 500 | 501 | if (read_or_write) |
| r8714 | r8715 | |
| 521 | 522 | |
| 522 | 523 | static MACHINE_RESET(ti68k) |
| 523 | 524 | { |
| 524 | t68k_state *state = | |
| 525 | t68k_state *state = | |
| 525 | 526 | cpu_set_reg(machine->device("maincpu"), M68K_PC, state->initial_pc); |
| 526 | 527 | |
| 527 | 528 | state->kb_mask = 0xff; |
| r8714 | r8715 | |
| 552 | 553 | static VIDEO_UPDATE( ti68k ) |
| 553 | 554 | { |
| 554 | 555 | /* preliminary implementation, doesn't use the contrast value */ |
| 555 | t68k_state *state = | |
| 556 | t68k_state *state = | |
| 556 | 557 | const address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 557 | 558 | UINT8 width = screen->width(); |
| 558 | 559 | UINT8 height = screen->height(); |
| r8714 | r8715 | |
| 575 | 576 | |
| 576 | 577 | MACHINE_START( ti68k ) |
| 577 | 578 | { |
| 578 | t68k_state *state = | |
| 579 | t68k_state *state = | |
| 579 | 580 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 580 | 581 | UINT16 *rom = (UINT16 *)memory_region(space->machine, "maincpu"); |
| 581 | 582 | int i; |
| r8714 | r8715 | |
|---|---|---|
| 84 | 84 | |
| 85 | 85 | static void xerox820_keyboard_scan(running_machine *machine) |
| 86 | 86 | { |
| 87 | xerox820_state *state = | |
| 87 | xerox820_state *state = | |
| 88 | 88 | |
| 89 | 89 | static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8" }; |
| 90 | 90 | int table = 0, row, col; |
| r8714 | r8715 | |
| 138 | 138 | |
| 139 | 139 | static void xerox820_bankswitch(running_machine *machine, int bank) |
| 140 | 140 | { |
| 141 | xerox820_state *state = | |
| 141 | xerox820_state *state = | |
| 142 | 142 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 143 | 143 | UINT8 *ram = messram_get_ptr(machine->device("messram")); |
| 144 | 144 | |
| r8714 | r8715 | |
| 159 | 159 | |
| 160 | 160 | static void xerox820ii_bankswitch(running_machine *machine, int bank) |
| 161 | 161 | { |
| 162 | xerox820_state *state = | |
| 162 | xerox820_state *state = | |
| 163 | 163 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 164 | 164 | UINT8 *ram = messram_get_ptr(machine->device("messram")); |
| 165 | 165 | |
| r8714 | r8715 | |
| 180 | 180 | |
| 181 | 181 | static WRITE8_HANDLER( scroll_w ) |
| 182 | 182 | { |
| 183 | xerox820_state *state = | |
| 183 | xerox820_state *state = | |
| 184 | 184 | |
| 185 | 185 | state->scroll = (offset >> 8) & 0x1f; |
| 186 | 186 | } |
| r8714 | r8715 | |
| 207 | 207 | |
| 208 | 208 | static WRITE8_HANDLER( bell_w ) |
| 209 | 209 | { |
| 210 | // xerox820_state *state = | |
| 210 | // xerox820_state *state = | |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | static WRITE8_HANDLER( slden_w ) |
| 214 | 214 | { |
| 215 | xerox820_state *state = | |
| 215 | xerox820_state *state = | |
| 216 | 216 | |
| 217 | 217 | wd17xx_dden_w(state->wd1771, offset ? CLEAR_LINE : ASSERT_LINE); |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | static WRITE8_HANDLER( chrom_w ) |
| 221 | 221 | { |
| 222 | xerox820_state *state = | |
| 222 | xerox820_state *state = | |
| 223 | 223 | |
| 224 | 224 | state->chrom = offset; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | static WRITE8_HANDLER( lowlite_w ) |
| 228 | 228 | { |
| 229 | xerox820_state *state = | |
| 229 | xerox820_state *state = | |
| 230 | 230 | |
| 231 | 231 | state->lowlite = data; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | static WRITE8_HANDLER( sync_w ) |
| 235 | 235 | { |
| 236 | // xerox820_state *state = | |
| 236 | // xerox820_state *state = | |
| 237 | 237 | |
| 238 | 238 | if (offset) |
| 239 | 239 | { |
| r8714 | r8715 | |
| 405 | 405 | |
| 406 | 406 | */ |
| 407 | 407 | |
| 408 | xerox820_state *state = | |
| 408 | xerox820_state *state = | |
| 409 | 409 | |
| 410 | 410 | return (state->dsdd << 5) | (state->_8n5 << 4) | (z80pio_brdy_r(state->kbpio) << 3); |
| 411 | 411 | }; |
| r8714 | r8715 | |
| 427 | 427 | |
| 428 | 428 | */ |
| 429 | 429 | |
| 430 | xerox820_state *state = | |
| 430 | xerox820_state *state = | |
| 431 | 431 | |
| 432 | 432 | /* drive select */ |
| 433 | 433 | int dvsel1 = BIT(data, 0); |
| r8714 | r8715 | |
| 482 | 482 | |
| 483 | 483 | */ |
| 484 | 484 | |
| 485 | xerox820_state *state = | |
| 485 | xerox820_state *state = | |
| 486 | 486 | |
| 487 | 487 | return state->keydata; |
| 488 | 488 | }; |
| r8714 | r8715 | |
| 541 | 541 | |
| 542 | 542 | static TIMER_DEVICE_CALLBACK( ctc_tick ) |
| 543 | 543 | { |
| 544 | xerox820_state *state = | |
| 544 | xerox820_state *state = | |
| 545 | 545 | |
| 546 | 546 | z80ctc_trg0_w(state->z80ctc, 1); |
| 547 | 547 | z80ctc_trg0_w(state->z80ctc, 0); |
| r8714 | r8715 | |
| 581 | 581 | |
| 582 | 582 | static WRITE_LINE_DEVICE_HANDLER( xerox820_wd1771_intrq_w ) |
| 583 | 583 | { |
| 584 | xerox820_state *driver_state = | |
| 584 | xerox820_state *driver_state = | |
| 585 | 585 | int halt = cpu_get_reg(device->machine->device(Z80_TAG), Z80_HALT); |
| 586 | 586 | |
| 587 | 587 | driver_state->fdc_irq = state; |
| r8714 | r8715 | |
| 594 | 594 | |
| 595 | 595 | static WRITE_LINE_DEVICE_HANDLER( xerox820_wd1771_drq_w ) |
| 596 | 596 | { |
| 597 | xerox820_state *driver_state = | |
| 597 | xerox820_state *driver_state = | |
| 598 | 598 | int halt = cpu_get_reg(device->machine->device(Z80_TAG), Z80_HALT); |
| 599 | 599 | |
| 600 | 600 | driver_state->fdc_drq = state; |
| r8714 | r8715 | |
| 628 | 628 | |
| 629 | 629 | static VIDEO_START( xerox820 ) |
| 630 | 630 | { |
| 631 | xerox820_state *state = | |
| 631 | xerox820_state *state = | |
| 632 | 632 | |
| 633 | 633 | /* find memory regions */ |
| 634 | 634 | state->char_rom = memory_region(machine, "chargen"); |
| r8714 | r8715 | |
| 636 | 636 | |
| 637 | 637 | static VIDEO_UPDATE( xerox820 ) |
| 638 | 638 | { |
| 639 | xerox820_state *state = | |
| 639 | xerox820_state *state = | |
| 640 | 640 | UINT8 y,ra,chr,gfx; |
| 641 | 641 | UINT16 sy=0,ma=(state->scroll + 1) * 0x80,x; |
| 642 | 642 | |
| r8714 | r8715 | |
| 683 | 683 | |
| 684 | 684 | static void xerox820_load_proc(device_image_interface &image) |
| 685 | 685 | { |
| 686 | xerox820_state *state = | |
| 686 | xerox820_state *state = | |
| 687 | 687 | |
| 688 | 688 | switch (image.length()) |
| 689 | 689 | { |
| r8714 | r8715 | |
| 715 | 715 | static MACHINE_START( xerox820 ) |
| 716 | 716 | { |
| 717 | 717 | int drive; |
| 718 | xerox820_state *state = | |
| 718 | xerox820_state *state = | |
| 719 | 719 | |
| 720 | 720 | /* find devices */ |
| 721 | 721 | state->kbpio = machine->device(Z80KBPIO_TAG); |
| r8714 | r8715 | |
| 741 | 741 | |
| 742 | 742 | static MACHINE_START( xerox820ii ) |
| 743 | 743 | { |
| 744 | // xerox820_state *state = | |
| 744 | // xerox820_state *state = | |
| 745 | 745 | |
| 746 | 746 | MACHINE_START_CALL(xerox820); |
| 747 | 747 |
| r8714 | r8715 | |
|---|---|---|
| 124 | 124 | |
| 125 | 125 | static UINT8 keypad_r (running_machine *machine) |
| 126 | 126 | { |
| 127 | micronic_state *state = | |
| 127 | micronic_state *state = | |
| 128 | 128 | static const char *const bitnames[] = {"BIT0", "BIT1", "BIT2", "BIT3", "BIT4", "BIT5"}; |
| 129 | 129 | UINT8 port, bit, data = 0; |
| 130 | 130 | |
| r8714 | r8715 | |
| 142 | 142 | |
| 143 | 143 | READ8_HANDLER( status_flag_r ) |
| 144 | 144 | { |
| 145 | micronic_state *state = | |
| 145 | micronic_state *state = | |
| 146 | 146 | return state->status_flag; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | WRITE8_HANDLER( status_flag_w ) |
| 150 | 150 | { |
| 151 | micronic_state *state = | |
| 151 | micronic_state *state = | |
| 152 | 152 | state->status_flag = data; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | WRITE8_HANDLER( kp_matrix_w ) |
| 156 | 156 | { |
| 157 | micronic_state *state = | |
| 157 | micronic_state *state = | |
| 158 | 158 | state->kp_matrix = data; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | WRITE8_HANDLER( beep_w ) |
| 162 | 162 | { |
| 163 | micronic_state *state = | |
| 163 | micronic_state *state = | |
| 164 | 164 | UINT16 frequency = 0; |
| 165 | 165 | |
| 166 | 166 | beep_set_state(state->speaker, (data) ? 1 : 0); |
| r8714 | r8715 | |
| 209 | 209 | |
| 210 | 210 | WRITE8_HANDLER( lcd_contrast_w ) |
| 211 | 211 | { |
| 212 | micronic_state *state = | |
| 212 | micronic_state *state = | |
| 213 | 213 | |
| 214 | 214 | state->lcd_contrast = data; |
| 215 | 215 | } |
| r8714 | r8715 | |
| 221 | 221 | |
| 222 | 222 | void set_146818_periodic_irq(running_machine *machine, UINT8 data) |
| 223 | 223 | { |
| 224 | micronic_state *state = | |
| 224 | micronic_state *state = | |
| 225 | 225 | |
| 226 | 226 | attotime timer_per = ATTOTIME_IN_SEC(0); |
| 227 | 227 | |
| r8714 | r8715 | |
| 250 | 250 | |
| 251 | 251 | WRITE8_HANDLER( rtc_address_w ) |
| 252 | 252 | { |
| 253 | micronic_state *state = | |
| 253 | micronic_state *state = | |
| 254 | 254 | state->rtc_address = data; |
| 255 | 255 | |
| 256 | 256 | mc146818_port_w(space, 0, data); |
| r8714 | r8715 | |
| 258 | 258 | |
| 259 | 259 | READ8_HANDLER( rtc_data_r ) |
| 260 | 260 | { |
| 261 | micronic_state *state = | |
| 261 | micronic_state *state = | |
| 262 | 262 | UINT8 data = 0; |
| 263 | 263 | |
| 264 | 264 | switch(state->rtc_address & 0x3f) |
| r8714 | r8715 | |
| 276 | 276 | |
| 277 | 277 | WRITE8_HANDLER( rtc_data_w ) |
| 278 | 278 | { |
| 279 | micronic_state *state = | |
| 279 | micronic_state *state = | |
| 280 | 280 | |
| 281 | 281 | mc146818_port_w(space, 1, data); |
| 282 | 282 | |
| r8714 | r8715 | |
| 293 | 293 | |
| 294 | 294 | static TIMER_CALLBACK( rtc_periodic_irq ) |
| 295 | 295 | { |
| 296 | micronic_state *state = | |
| 296 | micronic_state *state = | |
| 297 | 297 | |
| 298 | 298 | if (state->periodic_irq) |
| 299 | 299 | cputag_set_input_line(machine, Z80_TAG, 0, HOLD_LINE); |
| r8714 | r8715 | |
| 397 | 397 | |
| 398 | 398 | static NVRAM_HANDLER( micronic ) |
| 399 | 399 | { |
| 400 | micronic_state *state = | |
| 400 | micronic_state *state = | |
| 401 | 401 | UINT8 reg_a = 0, reg_b = 0; |
| 402 | 402 | |
| 403 | 403 | if (read_or_write) |
| r8714 | r8715 | |
| 440 | 440 | |
| 441 | 441 | static VIDEO_UPDATE( micronic ) |
| 442 | 442 | { |
| 443 | micronic_state *state = | |
| 443 | micronic_state *state = | |
| 444 | 444 | |
| 445 | 445 | hd61830_update(state->hd61830, bitmap, cliprect); |
| 446 | 446 | |
| r8714 | r8715 | |
| 449 | 449 | |
| 450 | 450 | static MACHINE_START( micronic ) |
| 451 | 451 | { |
| 452 | micronic_state *state = | |
| 452 | micronic_state *state = | |
| 453 | 453 | |
| 454 | 454 | /* find devices */ |
| 455 | 455 | state->hd61830 = machine->device(HD61830_TAG); |
| r8714 | r8715 | |
|---|---|---|
| 47 | 47 | |
| 48 | 48 | static READ8_DEVICE_HANDLER( video_off_r ) |
| 49 | 49 | { |
| 50 | cosmicos_state *state = | |
| 50 | cosmicos_state *state = | |
| 51 | 51 | UINT8 data = 0; |
| 52 | 52 | |
| 53 | 53 | if (!state->q) |
| r8714 | r8715 | |
| 60 | 60 | |
| 61 | 61 | static READ8_DEVICE_HANDLER( video_on_r ) |
| 62 | 62 | { |
| 63 | cosmicos_state *state = | |
| 63 | cosmicos_state *state = | |
| 64 | 64 | UINT8 data = 0; |
| 65 | 65 | |
| 66 | 66 | if (!state->q) |
| r8714 | r8715 | |
| 73 | 73 | |
| 74 | 74 | static WRITE8_DEVICE_HANDLER( audio_latch_w ) |
| 75 | 75 | { |
| 76 | cosmicos_state *state = | |
| 76 | cosmicos_state *state = | |
| 77 | 77 | |
| 78 | 78 | if (state->q) |
| 79 | 79 | { |
| r8714 | r8715 | |
| 83 | 83 | |
| 84 | 84 | static READ8_HANDLER( hex_keyboard_r ) |
| 85 | 85 | { |
| 86 | cosmicos_state *state = | |
| 86 | cosmicos_state *state = | |
| 87 | 87 | static const char *const keynames[] = { "ROW1", "ROW2", "ROW3", "ROW4" }; |
| 88 | 88 | UINT8 data = 0; |
| 89 | 89 | int i; |
| r8714 | r8715 | |
| 106 | 106 | |
| 107 | 107 | static WRITE8_HANDLER( hex_keylatch_w ) |
| 108 | 108 | { |
| 109 | cosmicos_state *state = | |
| 109 | cosmicos_state *state = | |
| 110 | 110 | |
| 111 | 111 | state->keylatch = data & 0x0f; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | static READ8_HANDLER( reset_counter_r ) |
| 115 | 115 | { |
| 116 | cosmicos_state *state = | |
| 116 | cosmicos_state *state = | |
| 117 | 117 | |
| 118 | 118 | state->counter = 0; |
| 119 | 119 | |
| r8714 | r8715 | |
| 122 | 122 | |
| 123 | 123 | static WRITE8_HANDLER( segment_w ) |
| 124 | 124 | { |
| 125 | cosmicos_state *state = | |
| 125 | cosmicos_state *state = | |
| 126 | 126 | |
| 127 | 127 | state->counter++; |
| 128 | 128 | |
| r8714 | r8715 | |
| 139 | 139 | |
| 140 | 140 | static READ8_HANDLER( data_r ) |
| 141 | 141 | { |
| 142 | cosmicos_state *state = | |
| 142 | cosmicos_state *state = | |
| 143 | 143 | |
| 144 | 144 | return state->data; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | static WRITE8_HANDLER( display_w ) |
| 148 | 148 | { |
| 149 | cosmicos_state *state = | |
| 149 | cosmicos_state *state = | |
| 150 | 150 | |
| 151 | 151 | state->segment = data; |
| 152 | 152 | } |
| r8714 | r8715 | |
| 174 | 174 | |
| 175 | 175 | static INPUT_CHANGED( data ) |
| 176 | 176 | { |
| 177 | cosmicos_state *state = | |
| 177 | cosmicos_state *state = | |
| 178 | 178 | UINT8 data = input_port_read(field->port->machine, "DATA"); |
| 179 | 179 | int i; |
| 180 | 180 | |
| r8714 | r8715 | |
| 190 | 190 | |
| 191 | 191 | static INPUT_CHANGED( enter ) |
| 192 | 192 | { |
| 193 | cosmicos_state *state = | |
| 193 | cosmicos_state *state = | |
| 194 | 194 | |
| 195 | 195 | if (!newval && (state->cdp1802_mode == CDP1802_MODE_LOAD)) |
| 196 | 196 | { |
| r8714 | r8715 | |
| 205 | 205 | |
| 206 | 206 | static void set_cdp1802_mode(running_machine *machine, cdp1802_control_mode mode) |
| 207 | 207 | { |
| 208 | cosmicos_state *state = | |
| 208 | cosmicos_state *state = | |
| 209 | 209 | |
| 210 | 210 | state->cdp1802_mode = mode; |
| 211 | 211 | |
| r8714 | r8715 | |
| 246 | 246 | |
| 247 | 247 | static void clear_input_data(running_machine *machine) |
| 248 | 248 | { |
| 249 | cosmicos_state *state = | |
| 249 | cosmicos_state *state = | |
| 250 | 250 | int i; |
| 251 | 251 | |
| 252 | 252 | state->data = 0; |
| r8714 | r8715 | |
| 264 | 264 | |
| 265 | 265 | static void set_ram_mode(running_machine *machine) |
| 266 | 266 | { |
| 267 | cosmicos_state *state = | |
| 267 | cosmicos_state *state = | |
| 268 | 268 | const address_space *program = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM); |
| 269 | 269 | |
| 270 | 270 | if (state->ram_disable) |
| r8714 | r8715 | |
| 289 | 289 | |
| 290 | 290 | static INPUT_CHANGED( memory_protect ) |
| 291 | 291 | { |
| 292 | cosmicos_state *state = | |
| 292 | cosmicos_state *state = | |
| 293 | 293 | |
| 294 | 294 | state->ram_protect = newval; |
| 295 | 295 | |
| r8714 | r8715 | |
| 298 | 298 | |
| 299 | 299 | static INPUT_CHANGED( memory_disable ) |
| 300 | 300 | { |
| 301 | cosmicos_state *state = | |
| 301 | cosmicos_state *state = | |
| 302 | 302 | |
| 303 | 303 | state->ram_disable = newval; |
| 304 | 304 | |
| r8714 | r8715 | |
| 362 | 362 | |
| 363 | 363 | static TIMER_DEVICE_CALLBACK( digit_tick ) |
| 364 | 364 | { |
| 365 | cosmicos_state *state = | |
| 365 | cosmicos_state *state = | |
| 366 | 366 | |
| 367 | 367 | state->digit = !state->digit; |
| 368 | 368 | |
| r8714 | r8715 | |
| 376 | 376 | |
| 377 | 377 | static WRITE_LINE_DEVICE_HANDLER( cosmicos_dmaout_w ) |
| 378 | 378 | { |
| 379 | cosmicos_state *driver_state = | |
| 379 | cosmicos_state *driver_state = | |
| 380 | 380 | |
| 381 | 381 | driver_state->dmaout = state; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | static WRITE_LINE_DEVICE_HANDLER( cosmicos_efx_w ) |
| 385 | 385 | { |
| 386 | cosmicos_state *driver_state = | |
| 386 | cosmicos_state *driver_state = | |
| 387 | 387 | |
| 388 | 388 | driver_state->efx = state; |
| 389 | 389 | } |
| r8714 | r8715 | |
| 407 | 407 | |
| 408 | 408 | static VIDEO_UPDATE( cosmicos ) |
| 409 | 409 | { |
| 410 | cosmicos_state *state = | |
| 410 | cosmicos_state *state = | |
| 411 | 411 | |
| 412 | 412 | cdp1864_update(state->cdp1864, bitmap, cliprect); |
| 413 | 413 | |
| r8714 | r8715 | |
| 418 | 418 | |
| 419 | 419 | static CDP1802_MODE_READ( cosmicos_mode_r ) |
| 420 | 420 | { |
| 421 | cosmicos_state *state = | |
| 421 | cosmicos_state *state = | |
| 422 | 422 | |
| 423 | 423 | return state->cdp1802_mode; |
| 424 | 424 | } |
| r8714 | r8715 | |
| 432 | 432 | EF4 ENTER |
| 433 | 433 | */ |
| 434 | 434 | |
| 435 | cosmicos_state *state = | |
| 435 | cosmicos_state *state = | |
| 436 | 436 | UINT8 special = input_port_read(device->machine, "SPECIAL"); |
| 437 | 437 | UINT8 flags = 0x0f; |
| 438 | 438 | |
| r8714 | r8715 | |
| 461 | 461 | |
| 462 | 462 | static CDP1802_SC_WRITE( cosmicos_sc_w ) |
| 463 | 463 | { |
| 464 | cosmicos_state *driver_state = | |
| 464 | cosmicos_state *driver_state = | |
| 465 | 465 | |
| 466 | 466 | if (driver_state->sc1 && !sc1) |
| 467 | 467 | { |
| r8714 | r8715 | |
| 479 | 479 | |
| 480 | 480 | static WRITE_LINE_DEVICE_HANDLER( cosmicos_q_w ) |
| 481 | 481 | { |
| 482 | cosmicos_state *driver_state = | |
| 482 | cosmicos_state *driver_state = | |
| 483 | 483 | |
| 484 | 484 | /* cassette */ |
| 485 | 485 | cassette_output(driver_state->cassette, state ? +1.0 : -1.0); |
| r8714 | r8715 | |
| 495 | 495 | |
| 496 | 496 | static READ8_DEVICE_HANDLER( cosmicos_dma_r ) |
| 497 | 497 | { |
| 498 | cosmicos_state *state = | |
| 498 | cosmicos_state *state = | |
| 499 | 499 | |
| 500 | 500 | return state->data; |
| 501 | 501 | } |
| r8714 | r8715 | |
| 514 | 514 | |
| 515 | 515 | static MACHINE_START( cosmicos ) |
| 516 | 516 | { |
| 517 | cosmicos_state *state = | |
| 517 | cosmicos_state *state = | |
| 518 | 518 | const address_space *program = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM); |
| 519 | 519 | |
| 520 | 520 | /* find devices */ |
| r8714 | r8715 | |
| 654 | 654 | |
| 655 | 655 | static DIRECT_UPDATE_HANDLER( cosmicos_direct_update_handler ) |
| 656 | 656 | { |
| 657 | cosmicos_state *state = | |
| 657 | cosmicos_state *state = | |
| 658 | 658 | |
| 659 | 659 | if (state->boot) |
| 660 | 660 | { |
| r8714 | r8715 | |
|---|---|---|
| 44 | 44 | |
| 45 | 45 | static void gba_machine_stop(running_machine &machine) |
| 46 | 46 | { |
| 47 | gba_state *state = | |
| 47 | gba_state *state = | |
| 48 | 48 | |
| 49 | 49 | // only do this if the cart loader detected some form of backup |
| 50 | 50 | if (state->nvsize > 0) |
| r8714 | r8715 | |
| 73 | 73 | |
| 74 | 74 | static void gba_request_irq(running_machine *machine, UINT32 int_type) |
| 75 | 75 | { |
| 76 | gba_state *state = | |
| 76 | gba_state *state = | |
| 77 | 77 | |
| 78 | 78 | // set flag for later recovery |
| 79 | 79 | state->IF |= int_type; |
| r8714 | r8715 | |
| 96 | 96 | int ctrl; |
| 97 | 97 | FPTR ch; |
| 98 | 98 | static UINT32 ch_int[4] = { INT_DMA0, INT_DMA1, INT_DMA2, INT_DMA3 }; |
| 99 | gba_state *state = | |
| 99 | gba_state *state = | |
| 100 | 100 | |
| 101 | 101 | ch = param; |
| 102 | 102 | |
| r8714 | r8715 | |
| 142 | 142 | int srcadd, dstadd; |
| 143 | 143 | UINT32 src, dst; |
| 144 | 144 | const address_space *space = cpu_get_address_space(machine->device("maincpu"), ADDRESS_SPACE_PROGRAM); |
| 145 | gba_state *state = | |
| 145 | gba_state *state = | |
| 146 | 146 | |
| 147 | 147 | src = state->dma_src[ch]; |
| 148 | 148 | dst = state->dma_dst[ch]; |
| r8714 | r8715 | |
| 273 | 273 | |
| 274 | 274 | static void audio_tick(running_machine *machine, int ref) |
| 275 | 275 | { |
| 276 | gba_state *state = | |
| 276 | gba_state *state = | |
| 277 | 277 | |
| 278 | 278 | if (!(state->SOUNDCNT_X & 0x80)) |
| 279 | 279 | { |
| r8714 | r8715 | |
| 365 | 365 | { |
| 366 | 366 | static UINT32 tmr_ints[4] = { INT_TM0_OVERFLOW, INT_TM1_OVERFLOW, INT_TM2_OVERFLOW, INT_TM3_OVERFLOW }; |
| 367 | 367 | FPTR tmr = (FPTR) param; |
| 368 | gba_state *state = | |
| 368 | gba_state *state = | |
| 369 | 369 | |
| 370 | 370 | // printf("Timer %d expired, SOUNDCNT_H %04x\n", tmr, state->SOUNDCNT_H); |
| 371 | 371 | |
| r8714 | r8715 | |
| 488 | 488 | |
| 489 | 489 | static TIMER_CALLBACK(handle_irq) |
| 490 | 490 | { |
| 491 | gba_state *state = | |
| 491 | gba_state *state = | |
| 492 | 492 | |
| 493 | 493 | gba_request_irq(machine, state->IF); |
| 494 | 494 | |
| r8714 | r8715 | |
| 500 | 500 | UINT32 retval = 0; |
| 501 | 501 | running_machine *machine = space->machine; |
| 502 | 502 | running_device *gb_device = space->machine->device("custom"); |
| 503 | gba_state *state = | |
| 503 | gba_state *state = | |
| 504 | 504 | |
| 505 | 505 | switch( offset ) |
| 506 | 506 | { |
| r8714 | r8715 | |
| 1018 | 1018 | { |
| 1019 | 1019 | running_machine *machine = space->machine; |
| 1020 | 1020 | running_device *gb_device = space->machine->device("custom"); |
| 1021 | gba_state *state = | |
| 1021 | gba_state *state = | |
| 1022 | 1022 | |
| 1023 | 1023 | switch( offset ) |
| 1024 | 1024 | { |
| r8714 | r8715 | |
| 1866 | 1866 | static WRITE32_HANDLER(gba_pram_w) |
| 1867 | 1867 | { |
| 1868 | 1868 | running_machine *machine = space->machine; |
| 1869 | gba_state *state = | |
| 1869 | gba_state *state = | |
| 1870 | 1870 | |
| 1871 | 1871 | state->gba_pram[offset] = COMBINE_DATA32_16(state->gba_pram[offset], data, mem_mask); |
| 1872 | 1872 | } |
| r8714 | r8715 | |
| 1874 | 1874 | static WRITE32_HANDLER(gba_vram_w) |
| 1875 | 1875 | { |
| 1876 | 1876 | running_machine *machine = space->machine; |
| 1877 | gba_state *state = | |
| 1877 | gba_state *state = | |
| 1878 | 1878 | |
| 1879 | 1879 | state->gba_vram[offset] = COMBINE_DATA32_16(state->gba_vram[offset], data, mem_mask); |
| 1880 | 1880 | } |
| r8714 | r8715 | |
| 1882 | 1882 | static WRITE32_HANDLER(gba_oam_w) |
| 1883 | 1883 | { |
| 1884 | 1884 | running_machine *machine = space->machine; |
| 1885 | gba_state *state = | |
| 1885 | gba_state *state = | |
| 1886 | 1886 | |
| 1887 | 1887 | state->gba_oam[offset] = COMBINE_DATA32_16(state->gba_oam[offset], data, mem_mask); |
| 1888 | 1888 | } |
| r8714 | r8715 | |
| 1918 | 1918 | static TIMER_CALLBACK( perform_hbl ) |
| 1919 | 1919 | { |
| 1920 | 1920 | int ch, ctrl; |
| 1921 | gba_state *state = | |
| 1921 | gba_state *state = | |
| 1922 | 1922 | int scanline = machine->primary_screen->vpos(); |
| 1923 | 1923 | |
| 1924 | 1924 | // draw only visible scanlines |
| r8714 | r8715 | |
| 1949 | 1949 | static TIMER_CALLBACK( perform_scan ) |
| 1950 | 1950 | { |
| 1951 | 1951 | int scanline; |
| 1952 | gba_state *state = | |
| 1952 | gba_state *state = | |
| 1953 | 1953 | |
| 1954 | 1954 | // clear hblank and raster IRQ flags |
| 1955 | 1955 | state->DISPSTAT &= ~(DISPSTAT_HBL|DISPSTAT_VCNT); |
| r8714 | r8715 | |
| 2008 | 2008 | running_device *gb_a_r = machine->device("direct_a_right"); |
| 2009 | 2009 | running_device *gb_b_l = machine->device("direct_b_left"); |
| 2010 | 2010 | running_device *gb_b_r = machine->device("direct_b_right"); |
| 2011 | gba_state *state = | |
| 2011 | gba_state *state = | |
| 2012 | 2012 | |
| 2013 | 2013 | memset(state, 0, sizeof(state)); |
| 2014 | 2014 | state->SOUNDBIAS = 0x0200; |
| r8714 | r8715 | |
| 2049 | 2049 | |
| 2050 | 2050 | static MACHINE_START( gba ) |
| 2051 | 2051 | { |
| 2052 | gba_state *state = | |
| 2052 | gba_state *state = | |
| 2053 | 2053 | |
| 2054 | 2054 | /* add a hook for battery save */ |
| 2055 | 2055 | machine->add_notifier(MACHINE_NOTIFY_EXIT, gba_machine_stop); |
| r8714 | r8715 | |
| 2096 | 2096 | |
| 2097 | 2097 | static READ32_HANDLER( sram_r ) |
| 2098 | 2098 | { |
| 2099 | gba_state *state = | |
| 2099 | gba_state *state = | |
| 2100 | 2100 | |
| 2101 | 2101 | return state->gba_sram[offset]; |
| 2102 | 2102 | } |
| 2103 | 2103 | |
| 2104 | 2104 | static WRITE32_HANDLER( sram_w ) |
| 2105 | 2105 | { |
| 2106 | gba_state *state = | |
| 2106 | gba_state *state = | |
| 2107 | 2107 | |
| 2108 | 2108 | COMBINE_DATA(&state->gba_sram[offset]); |
| 2109 | 2109 | } |
| 2110 | 2110 | |
| 2111 | 2111 | static READ32_HANDLER( flash_r ) |
| 2112 | 2112 | { |
| 2113 | gba_state *state = | |
| 2113 | gba_state *state = | |
| 2114 | 2114 | UINT32 rv; |
| 2115 | 2115 | |
| 2116 | 2116 | rv = 0; |
| r8714 | r8715 | |
| 2125 | 2125 | |
| 2126 | 2126 | static WRITE32_HANDLER( flash_w ) |
| 2127 | 2127 | { |
| 2128 | gba_state *state = | |
| 2128 | gba_state *state = | |
| 2129 | 2129 | |
| 2130 | 2130 | offset &= state->flash_mask; |
| 2131 | 2131 | switch (mem_mask) |
| r8714 | r8715 | |
| 2151 | 2151 | static READ32_HANDLER( eeprom_r ) |
| 2152 | 2152 | { |
| 2153 | 2153 | UINT32 out; |
| 2154 | gba_state *state = | |
| 2154 | gba_state *state = | |
| 2155 | 2155 | |
| 2156 | 2156 | switch (state->eeprom_state) |
| 2157 | 2157 | { |
| r8714 | r8715 | |
| 2201 | 2201 | |
| 2202 | 2202 | static WRITE32_HANDLER( eeprom_w ) |
| 2203 | 2203 | { |
| 2204 | gba_state *state = | |
| 2204 | gba_state *state = | |
| 2205 | 2205 | |
| 2206 | 2206 | if (~mem_mask == 0x0000ffff) |
| 2207 | 2207 | { |
| r8714 | r8715 | |
| 2297 | 2297 | UINT8 *ROM = memory_region(image.device().machine, "cartridge"); |
| 2298 | 2298 | int i; |
| 2299 | 2299 | UINT32 cart_size; |
| 2300 | gba_state *state = | |
| 2300 | gba_state *state = | |
| 2301 | 2301 | |
| 2302 | 2302 | state->nvsize = 0; |
| 2303 | 2303 | state->flash_size = 0; |
| Previous | 15994 Revisions | Next |